none/tests/fdleak_cmsg_supp.supp: Add suppressions for older glibc
[valgrind.git] / none / tests / mips64 / fpu_arithmetic.c
blob1faa9249373b556bec58ba3173f9d48053ca0725
1 #include <stdio.h>
2 #include <math.h>
3 #include "rounding_mode.h"
4 #include "macro_fpu.h"
6 #if defined(__mips_hard_float)
7 int arithmeticOperations(flt_art_op_t op)
9 double fd_d = 0;
10 float fd_f = 0;
11 int i = 0;
12 int fcsr = 0;
13 round_mode_t rm;
14 for (rm = TO_NEAREST; rm <= TO_MINUS_INFINITY; rm ++) {
15 set_rounding_mode(rm);
16 printf("roundig mode: %s\n", round_mode_name[rm]);
17 for (i = 0; i < MAX_ARR; i++) {
18 switch(op) {
19 case ABSS:
20 UNOPff("abs.s");
21 printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]);
22 break;
23 case ABSD:
24 UNOPdd("abs.d");
25 printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]);
26 break;
27 case ADDS:
28 BINOPf("add.s");
29 printf("%s %f %f %f\n",
30 flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]);
31 break;
32 case ADDD:
33 BINOPd("add.d");
34 printf("%s %lf %lf %lf\n",
35 flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]);
36 break;
37 case DIVS:
38 BINOPf("div.s");
39 printf("%s %f %f %f\n",
40 flt_art_op_names[op], roundf(fd_f), fs_f[i], ft_f[i]);
41 break;
42 case DIVD:
43 BINOPd("div.d");
44 printf("%s %lf %lf %lf\n",
45 flt_art_op_names[op], round(fd_d), fs_d[i], ft_d[i]);
46 break;
47 case MULS:
48 BINOPf("mul.s");
49 printf("%s %f %f %f\n",
50 flt_art_op_names[op], roundf(fd_f), fs_f[i], ft_f[i]);
51 break;
52 case MULD:
53 BINOPd("mul.d");
54 printf("%s %lf %lf %lf\n",
55 flt_art_op_names[op], round(fd_d), fs_d[i], ft_d[i]);
56 break;
57 case NEGS:
58 UNOPff("neg.s");
59 printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]);
60 break;
61 case NEGD:
62 UNOPdd("neg.d");
63 printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]);
64 break;
65 case SQRTS:
66 UNOPff("sqrt.s");
67 printf("%s %f %f\n",
68 flt_art_op_names[op], roundf(fd_f), fs_f[i]);
69 break;
70 case SQRTD:
71 UNOPdd("sqrt.d");
72 printf("%s %lf %lf\n",
73 flt_art_op_names[op], round(fd_d), fs_d[i]);
74 break;
75 case SUBS:
76 BINOPf("sub.s");
77 printf("%s %f %f %f\n",
78 flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]);
79 break;
80 case SUBD:
81 BINOPd("sub.d");
82 printf("%s %lf %lf %lf\n",
83 flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]);
84 break;
85 case RECIPS:
86 UNOPff("recip.s");
87 printf("%s %f %f\n",
88 flt_art_op_names[op], roundf(fd_f), fs_f[i]);
89 break;
90 case RECIPD:
91 UNOPdd("recip.d");
92 printf("%s %lf %lf\n",
93 flt_art_op_names[op], round(fd_d), fs_d[i]);
94 break;
95 case RSQRTS:
96 if (fs_f[i] >= 0) {
97 UNOPff("rsqrt.s");
98 printf("%s %f %f\n",
99 flt_art_op_names[op], roundf(fd_f), fs_f[i]);
101 break;
102 case RSQRTD:
103 if (fs_d[i] >= 0) {
104 UNOPdd("rsqrt.d");
105 printf("%s %lf %lf\n",
106 flt_art_op_names[op], round(fd_d), fs_d[i]);
108 break;
109 #if (__mips_isa_rev < 6)
110 case MSUBS:
111 TRIOPf("msub.s");
112 printf("%s %f %f %f %f\n",flt_art_op_names[op], roundf(fd_f),
113 fr_f[i], fs_f[i], ft_f[i]);
114 break;
115 case MSUBD:
116 TRIOPd("msub.d");
117 printf("%s %lf %lf %lf %lf\n", flt_art_op_names[op], round(fd_d),
118 fr_d[i], fs_d[i], ft_d[i]);
119 break;
120 case MADDS:
121 TRIOPf("madd.s");
122 printf("%s %f %f %f %f\n", flt_art_op_names[op], roundf(fd_f),
123 fr_f[i], fs_f[i], ft_f[i]);
124 break;
125 case MADDD:
126 TRIOPd("madd.d");
127 printf("%s %lf %lf %lf %lf\n", flt_art_op_names[op], round(fd_d),
128 fr_d[i], fs_d[i], ft_d[i]);
129 break;
130 case NMADDS:
131 TRIOPf("nmadd.s");
132 printf("%s %f %f %f %f\n", flt_art_op_names[op], roundf(fd_f),
133 fr_f[i], fs_f[i], ft_f[i]);
134 break;
135 case NMADDD:
136 TRIOPd("nmadd.d");
137 printf("%s %lf %lf %lf %lf\n", flt_art_op_names[op], round(fd_d),
138 fr_d[i], fs_d[i], ft_d[i]);
139 break;
140 case NMSUBS:
141 TRIOPf("nmsub.s");
142 printf("%s %f %f %f %f\n", flt_art_op_names[op], roundf(fd_f),
143 fr_f[i], fs_f[i], ft_f[i]);
144 break;
145 case NMSUBD:
146 TRIOPd("nmsub.d");
147 printf("%s 0x%lf %lf %lf %lf\n", flt_art_op_names[op],
148 round(fd_d), fr_d[i], fs_d[i],
149 ft_d[i]);
150 break;
151 #endif
152 default:
153 printf("error\n");
154 break;
158 return 0;
160 #endif
162 int main()
164 #if defined(__mips_hard_float)
165 flt_art_op_t op;
166 #if (__mips_isa_rev < 6)
167 int end = NMSUBD;
168 #else
169 int end = RSQRTD;
170 #endif
171 printf("-------------------------- %s --------------------------\n",
172 "test FPU Arithmetic Operations");
173 for (op = ABSS; op <= end; op++) {
174 arithmeticOperations(op);
176 #endif
177 return 0;