Home | History | Annotate | Download | only in s390x
      1 /* test data class tests for float, double, long double:  TCEB, TCDB, TCXB */
      2 #include <math.h>
      3 #include <stdio.h>
      4 
      5 static int tcxb(long double f, long long num)
      6 {
      7 	int match;
      8 
      9 	asm volatile("	tcxb %1,0(%2)\n"
     10 			"ipm %0\n"
     11 			"srl %0,28\n"
     12 			: "=d" (match)
     13 			: "f" (f), "a" (num)
     14 			: "cc");
     15 	return match;
     16 }
     17 
     18 static int tcdb(double f, long long num)
     19 {
     20 	int match;
     21 
     22 	asm volatile("	tcdb %1,0(%2)\n"
     23 			"ipm %0\n"
     24 			"srl %0,28\n"
     25 			: "=d" (match)
     26 			: "f" (f), "a" (num)
     27 			: "cc");
     28 	return match;
     29 }
     30 
     31 static int tceb(float f, long long num)
     32 {
     33 	int match;
     34 
     35 	asm volatile("	tceb %1,0(%2)\n"
     36 			"ipm %0\n"
     37 			"srl %0,28\n"
     38 			: "=d" (match)
     39 			: "f" (f), "a" (num)
     40 			: "cc");
     41 	return match;
     42 }
     43 
     44 int main()
     45 {
     46 	int i;
     47 
     48 	for (i = 0; i < 64; i++) {
     49 		if (sizeof (long double) == 16) {
     50 			/* long double 128 bit */
     51 			printf("%d", tcxb(+0.0l,	1UL<<i));
     52 			printf("%d", tcxb(-0.0l,	1UL<<i));
     53 			printf("%d", tcxb(+2.2l,	1UL<<i));
     54 			printf("%d", tcxb(-2.2l,	1UL<<i));
     55 			printf("%d", tcxb(+INFINITY,	1UL<<i));
     56 			printf("%d", tcxb(-INFINITY,	1UL<<i));
     57 			printf("%d", tcxb(+NAN,		1UL<<i));
     58 			printf("%d", tcxb(-NAN,		1UL<<i));
     59 		} else {
     60 			/* long double 64 bit */
     61 			printf("%d", tcdb(+0.0l,	1UL<<i));
     62 			printf("%d", tcdb(-0.0l,	1UL<<i));
     63 			printf("%d", tcdb(+2.2l,	1UL<<i));
     64 			printf("%d", tcdb(-2.2l,	1UL<<i));
     65 			printf("%d", tcdb(+INFINITY,	1UL<<i));
     66 			printf("%d", tcdb(-INFINITY,	1UL<<i));
     67 			printf("%d", tcdb(+NAN,		1UL<<i));
     68 			printf("%d", tcdb(-NAN,		1UL<<i));
     69 		}
     70 		/* double 64 bit */
     71 		printf("%d", tcdb(+0.0,		1UL<<i));
     72 		printf("%d", tcdb(-0.0,		1UL<<i));
     73 		printf("%d", tcdb(+2.2,		1UL<<i));
     74 		printf("%d", tcdb(-2.2,		1UL<<i));
     75 		printf("%d", tcdb(+INFINITY,	1UL<<i));
     76 		printf("%d", tcdb(-INFINITY,	1UL<<i));
     77 		printf("%d", tcdb(+NAN,		1UL<<i));
     78 		printf("%d", tcdb(-NAN,		1UL<<i));
     79 
     80 
     81 		/* float 32 bit */
     82 		printf("%d", tceb(+0.0f,	1UL<<i));
     83 		printf("%d", tceb(-0.0f,	1UL<<i));
     84 		printf("%d", tceb(+2.2f,	1UL<<i));
     85 		printf("%d", tceb(-2.2f,	1UL<<i));
     86 		printf("%d", tceb(+INFINITY,	1UL<<i));
     87 		printf("%d", tceb(-INFINITY,	1UL<<i));
     88 		printf("%d", tceb(+NAN,		1UL<<i));
     89 		printf("%d", tceb(-NAN,		1UL<<i));
     90 
     91 		printf("\n");
     92 
     93 	}
     94 	return 0;
     95 }
     96