2 #include "i64operations.h"
4 int64_t tval_a
= 1234567890003LL;
5 int64_t tval_b
= 2345678901235LL;
6 int64_t tval_c
= 1234567890001LL;
7 int64_t tval_d
= 10001LL;
8 int64_t tval_e
= 10000LL;
9 uint64_t tval_f
= 0xffffff0750135eb9;
12 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
15 i64_eq(int64_t a
, int64_t b
)
21 i64_neq(int64_t a
, int64_t b
)
27 i64_gt(int64_t a
, int64_t b
)
33 i64_le(int64_t a
, int64_t b
)
39 i64_ge(int64_t a
, int64_t b
) {
44 i64_lt(int64_t a
, int64_t b
) {
49 i64_uge(uint64_t a
, uint64_t b
)
55 i64_ult(uint64_t a
, uint64_t b
)
61 i64_ugt(uint64_t a
, uint64_t b
)
67 i64_ule(uint64_t a
, uint64_t b
)
73 i64_eq_select(int64_t a
, int64_t b
, int64_t c
, int64_t d
)
75 return ((a
== b
) ? c
: d
);
79 i64_neq_select(int64_t a
, int64_t b
, int64_t c
, int64_t d
)
81 return ((a
!= b
) ? c
: d
);
85 i64_gt_select(int64_t a
, int64_t b
, int64_t c
, int64_t d
) {
86 return ((a
> b
) ? c
: d
);
90 i64_le_select(int64_t a
, int64_t b
, int64_t c
, int64_t d
) {
91 return ((a
<= b
) ? c
: d
);
95 i64_ge_select(int64_t a
, int64_t b
, int64_t c
, int64_t d
) {
96 return ((a
>= b
) ? c
: d
);
100 i64_lt_select(int64_t a
, int64_t b
, int64_t c
, int64_t d
) {
101 return ((a
< b
) ? c
: d
);
105 i64_ugt_select(uint64_t a
, uint64_t b
, uint64_t c
, uint64_t d
)
107 return ((a
> b
) ? c
: d
);
111 i64_ule_select(uint64_t a
, uint64_t b
, uint64_t c
, uint64_t d
)
113 return ((a
<= b
) ? c
: d
);
117 i64_uge_select(uint64_t a
, uint64_t b
, uint64_t c
, uint64_t d
) {
118 return ((a
>= b
) ? c
: d
);
122 i64_ult_select(uint64_t a
, uint64_t b
, uint64_t c
, uint64_t d
) {
123 return ((a
< b
) ? c
: d
);
126 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
128 struct harness_int64_pred int64_tests_eq
[] = {
129 {"a %s a", &tval_a
, &tval_a
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
130 {"a %s b", &tval_a
, &tval_b
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
131 {"a %s c", &tval_a
, &tval_c
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
132 {"d %s e", &tval_d
, &tval_e
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
133 {"e %s e", &tval_e
, &tval_e
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
}
136 struct harness_int64_pred int64_tests_neq
[] = {
137 {"a %s a", &tval_a
, &tval_a
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
138 {"a %s b", &tval_a
, &tval_b
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
139 {"a %s c", &tval_a
, &tval_c
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
140 {"d %s e", &tval_d
, &tval_e
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
141 {"e %s e", &tval_e
, &tval_e
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
}
144 struct harness_int64_pred int64_tests_sgt
[] = {
145 {"a %s a", &tval_a
, &tval_a
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
146 {"a %s b", &tval_a
, &tval_b
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
147 {"a %s c", &tval_a
, &tval_c
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
148 {"d %s e", &tval_d
, &tval_e
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
149 {"e %s e", &tval_e
, &tval_e
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
}
152 struct harness_int64_pred int64_tests_sle
[] = {
153 {"a %s a", &tval_a
, &tval_a
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
154 {"a %s b", &tval_a
, &tval_b
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
155 {"a %s c", &tval_a
, &tval_c
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
156 {"d %s e", &tval_d
, &tval_e
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
157 {"e %s e", &tval_e
, &tval_e
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
}
160 struct harness_int64_pred int64_tests_sge
[] = {
161 {"a %s a", &tval_a
, &tval_a
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
162 {"a %s b", &tval_a
, &tval_b
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
163 {"a %s c", &tval_a
, &tval_c
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
164 {"d %s e", &tval_d
, &tval_e
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
165 {"e %s e", &tval_e
, &tval_e
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
}
168 struct harness_int64_pred int64_tests_slt
[] = {
169 {"a %s a", &tval_a
, &tval_a
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
170 {"a %s b", &tval_a
, &tval_b
, &tval_c
, &tval_d
, TRUE_VAL
, &tval_c
},
171 {"a %s c", &tval_a
, &tval_c
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
172 {"d %s e", &tval_d
, &tval_e
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
},
173 {"e %s e", &tval_e
, &tval_e
, &tval_c
, &tval_d
, FALSE_VAL
, &tval_d
}
176 struct int64_pred_s int64_preds
[] = {
177 {"eq", i64_eq
, i64_eq_select
,
178 int64_tests_eq
, ARR_SIZE(int64_tests_eq
)},
179 {"neq", i64_neq
, i64_neq_select
,
180 int64_tests_neq
, ARR_SIZE(int64_tests_neq
)},
181 {"gt", i64_gt
, i64_gt_select
,
182 int64_tests_sgt
, ARR_SIZE(int64_tests_sgt
)},
183 {"le", i64_le
, i64_le_select
,
184 int64_tests_sle
, ARR_SIZE(int64_tests_sle
)},
185 {"ge", i64_ge
, i64_ge_select
,
186 int64_tests_sge
, ARR_SIZE(int64_tests_sge
)},
187 {"lt", i64_lt
, i64_lt_select
,
188 int64_tests_slt
, ARR_SIZE(int64_tests_slt
)}
191 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
193 struct harness_uint64_pred uint64_tests_ugt
[] = {
194 {"a %s a", (uint64_t *) &tval_a
, (uint64_t *) &tval_a
, (uint64_t *) &tval_c
,
195 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
196 {"a %s b", (uint64_t *) &tval_a
, (uint64_t *) &tval_b
, (uint64_t *) &tval_c
,
197 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
198 {"a %s c", (uint64_t *) &tval_a
, (uint64_t *) &tval_c
, (uint64_t *) &tval_c
,
199 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
200 {"d %s e", (uint64_t *) &tval_d
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
201 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
202 {"e %s e", (uint64_t *) &tval_e
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
203 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
}
206 struct harness_uint64_pred uint64_tests_ule
[] = {
207 {"a %s a", (uint64_t *) &tval_a
, (uint64_t *) &tval_a
, (uint64_t *) &tval_c
,
208 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
209 {"a %s b", (uint64_t *) &tval_a
, (uint64_t *) &tval_b
, (uint64_t *) &tval_c
,
210 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
211 {"a %s c", (uint64_t *) &tval_a
, (uint64_t *) &tval_c
, (uint64_t *) &tval_c
,
212 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
213 {"d %s e", (uint64_t *) &tval_d
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
214 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
215 {"e %s e", (uint64_t *) &tval_e
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
216 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
}
219 struct harness_uint64_pred uint64_tests_uge
[] = {
220 {"a %s a", (uint64_t *) &tval_a
, (uint64_t *) &tval_a
, (uint64_t *) &tval_c
,
221 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
222 {"a %s b", (uint64_t *) &tval_a
, (uint64_t *) &tval_b
, (uint64_t *) &tval_c
,
223 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
224 {"a %s c", (uint64_t *) &tval_a
, (uint64_t *) &tval_c
, (uint64_t *) &tval_c
,
225 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
226 {"d %s e", (uint64_t *) &tval_d
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
227 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
228 {"e %s e", (uint64_t *) &tval_e
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
229 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
}
232 struct harness_uint64_pred uint64_tests_ult
[] = {
233 {"a %s a", (uint64_t *) &tval_a
, (uint64_t *) &tval_a
, (uint64_t *) &tval_c
,
234 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
235 {"a %s b", (uint64_t *) &tval_a
, (uint64_t *) &tval_b
, (uint64_t *) &tval_c
,
236 (uint64_t *) &tval_d
, TRUE_VAL
, (uint64_t *) &tval_c
},
237 {"a %s c", (uint64_t *) &tval_a
, (uint64_t *) &tval_c
, (uint64_t *) &tval_c
,
238 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
239 {"d %s e", (uint64_t *) &tval_d
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
240 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
},
241 {"e %s e", (uint64_t *) &tval_e
, (uint64_t *) &tval_e
, (uint64_t *) &tval_c
,
242 (uint64_t *) &tval_d
, FALSE_VAL
, (uint64_t *) &tval_d
}
245 struct uint64_pred_s uint64_preds
[] = {
246 {"ugt", i64_ugt
, i64_ugt_select
,
247 uint64_tests_ugt
, ARR_SIZE(uint64_tests_ugt
)},
248 {"ule", i64_ule
, i64_ule_select
,
249 uint64_tests_ule
, ARR_SIZE(uint64_tests_ule
)},
250 {"uge", i64_uge
, i64_uge_select
,
251 uint64_tests_uge
, ARR_SIZE(uint64_tests_uge
)},
252 {"ult", i64_ult
, i64_ult_select
,
253 uint64_tests_ult
, ARR_SIZE(uint64_tests_ult
)}
257 compare_expect_int64(const struct int64_pred_s
* pred
)
261 for (j
= 0; j
< pred
->n_tests
; ++j
) {
264 pred_result
= (*pred
->predfunc
) (*pred
->tests
[j
].lhs
, *pred
->tests
[j
].rhs
);
266 if (pred_result
!= pred
->tests
[j
].expected
) {
269 sprintf(str
, pred
->tests
[j
].fmt_string
, pred
->name
);
270 printf("%s: returned value is %d, expecting %d\n", str
,
271 pred_result
, pred
->tests
[j
].expected
);
272 printf(" lhs = %19lld (0x%016llx)\n", *pred
->tests
[j
].lhs
,
273 *pred
->tests
[j
].lhs
);
274 printf(" rhs = %19lld (0x%016llx)\n", *pred
->tests
[j
].rhs
,
275 *pred
->tests
[j
].rhs
);
280 selresult
= (pred
->selfunc
) (*pred
->tests
[j
].lhs
, *pred
->tests
[j
].rhs
,
281 *pred
->tests
[j
].select_a
,
282 *pred
->tests
[j
].select_b
);
284 if (selresult
!= *pred
->tests
[j
].select_expected
) {
287 sprintf(str
, pred
->tests
[j
].fmt_string
, pred
->name
);
288 printf("%s select: returned value is %d, expecting %d\n", str
,
289 pred_result
, pred
->tests
[j
].expected
);
290 printf(" lhs = %19lld (0x%016llx)\n", *pred
->tests
[j
].lhs
,
291 *pred
->tests
[j
].lhs
);
292 printf(" rhs = %19lld (0x%016llx)\n", *pred
->tests
[j
].rhs
,
293 *pred
->tests
[j
].rhs
);
294 printf(" true = %19lld (0x%016llx)\n", *pred
->tests
[j
].select_a
,
295 *pred
->tests
[j
].select_a
);
296 printf(" false = %19lld (0x%016llx)\n", *pred
->tests
[j
].select_b
,
297 *pred
->tests
[j
].select_b
);
303 printf(" %d tests performed, should be %d.\n", j
, pred
->n_tests
);
309 compare_expect_uint64(const struct uint64_pred_s
* pred
)
313 for (j
= 0; j
< pred
->n_tests
; ++j
) {
316 pred_result
= (*pred
->predfunc
) (*pred
->tests
[j
].lhs
, *pred
->tests
[j
].rhs
);
317 if (pred_result
!= pred
->tests
[j
].expected
) {
320 sprintf(str
, pred
->tests
[j
].fmt_string
, pred
->name
);
321 printf("%s: returned value is %d, expecting %d\n", str
,
322 pred_result
, pred
->tests
[j
].expected
);
323 printf(" lhs = %19llu (0x%016llx)\n", *pred
->tests
[j
].lhs
,
324 *pred
->tests
[j
].lhs
);
325 printf(" rhs = %19llu (0x%016llx)\n", *pred
->tests
[j
].rhs
,
326 *pred
->tests
[j
].rhs
);
331 selresult
= (pred
->selfunc
) (*pred
->tests
[j
].lhs
, *pred
->tests
[j
].rhs
,
332 *pred
->tests
[j
].select_a
,
333 *pred
->tests
[j
].select_b
);
334 if (selresult
!= *pred
->tests
[j
].select_expected
) {
337 sprintf(str
, pred
->tests
[j
].fmt_string
, pred
->name
);
338 printf("%s select: returned value is %d, expecting %d\n", str
,
339 pred_result
, pred
->tests
[j
].expected
);
340 printf(" lhs = %19llu (0x%016llx)\n", *pred
->tests
[j
].lhs
,
341 *pred
->tests
[j
].lhs
);
342 printf(" rhs = %19llu (0x%016llx)\n", *pred
->tests
[j
].rhs
,
343 *pred
->tests
[j
].rhs
);
344 printf(" true = %19llu (0x%016llx)\n", *pred
->tests
[j
].select_a
,
345 *pred
->tests
[j
].select_a
);
346 printf(" false = %19llu (0x%016llx)\n", *pred
->tests
[j
].select_b
,
347 *pred
->tests
[j
].select_b
);
353 printf(" %d tests performed, should be %d.\n", j
, pred
->n_tests
);
358 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
361 test_i64_sext_i32(int in
, int64_t expected
) {
362 int64_t result
= (int64_t) in
;
364 if (result
!= expected
) {
366 sprintf(str
, "i64_sext_i32(%d) returns %lld\n", in
, result
);
374 test_i64_sext_i16(short in
, int64_t expected
) {
375 int64_t result
= (int64_t) in
;
377 if (result
!= expected
) {
379 sprintf(str
, "i64_sext_i16(%hd) returns %lld\n", in
, result
);
387 test_i64_sext_i8(signed char in
, int64_t expected
) {
388 int64_t result
= (int64_t) in
;
390 if (result
!= expected
) {
392 sprintf(str
, "i64_sext_i8(%d) returns %lld\n", in
, result
);
400 test_i64_zext_i32(unsigned int in
, uint64_t expected
) {
401 uint64_t result
= (uint64_t) in
;
403 if (result
!= expected
) {
405 sprintf(str
, "i64_zext_i32(%u) returns %llu\n", in
, result
);
413 test_i64_zext_i16(unsigned short in
, uint64_t expected
) {
414 uint64_t result
= (uint64_t) in
;
416 if (result
!= expected
) {
418 sprintf(str
, "i64_zext_i16(%hu) returns %llu\n", in
, result
);
426 test_i64_zext_i8(unsigned char in
, uint64_t expected
) {
427 uint64_t result
= (uint64_t) in
;
429 if (result
!= expected
) {
431 sprintf(str
, "i64_zext_i8(%u) returns %llu\n", in
, result
);
438 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
441 i64_shl_const(int64_t a
) {
446 i64_shl(int64_t a
, int amt
) {
451 u64_shl_const(uint64_t a
) {
456 u64_shl(uint64_t a
, int amt
) {
461 i64_srl_const(int64_t a
) {
466 i64_srl(int64_t a
, int amt
) {
471 u64_srl_const(uint64_t a
) {
476 u64_srl(uint64_t a
, int amt
) {
481 i64_sra_const(int64_t a
) {
486 i64_sra(int64_t a
, int amt
) {
491 u64_sra_const(uint64_t a
) {
496 u64_sra(uint64_t a
, int amt
) {
501 test_u64_constant_shift(const char *func_name
, uint64_t (*func
)(uint64_t), uint64_t a
, uint64_t expected
) {
502 uint64_t result
= (*func
)(a
);
504 if (result
!= expected
) {
505 printf("%s(0x%016llx) returns 0x%016llx, expected 0x%016llx\n", func_name
, a
, result
, expected
);
513 test_i64_constant_shift(const char *func_name
, int64_t (*func
)(int64_t), int64_t a
, int64_t expected
) {
514 int64_t result
= (*func
)(a
);
516 if (result
!= expected
) {
517 printf("%s(0x%016llx) returns 0x%016llx, expected 0x%016llx\n", func_name
, a
, result
, expected
);
525 test_u64_variable_shift(const char *func_name
, uint64_t (*func
)(uint64_t, int), uint64_t a
, unsigned int b
, uint64_t expected
) {
526 uint64_t result
= (*func
)(a
, b
);
528 if (result
!= expected
) {
529 printf("%s(0x%016llx, %d) returns 0x%016llx, expected 0x%016llx\n", func_name
, a
, b
, result
, expected
);
537 test_i64_variable_shift(const char *func_name
, int64_t (*func
)(int64_t, int), int64_t a
, unsigned int b
, int64_t expected
) {
538 int64_t result
= (*func
)(a
, b
);
540 if (result
!= expected
) {
541 printf("%s(0x%016llx, %d) returns 0x%016llx, expected 0x%016llx\n", func_name
, a
, b
, result
, expected
);
548 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
550 int64_t i64_mul(int64_t a
, int64_t b
) {
554 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
559 int i
, j
, failed
= 0;
560 const char *something_failed
= " %d tests failed.\n";
561 const char *all_tests_passed
= " All tests passed.\n";
563 printf("tval_a = %20lld (0x%016llx)\n", tval_a
, tval_a
);
564 printf("tval_b = %20lld (0x%016llx)\n", tval_b
, tval_b
);
565 printf("tval_c = %20lld (0x%016llx)\n", tval_c
, tval_c
);
566 printf("tval_d = %20lld (0x%016llx)\n", tval_d
, tval_d
);
567 printf("tval_e = %20lld (0x%016llx)\n", tval_e
, tval_e
);
568 printf("tval_f = %20llu (0x%016llx)\n", tval_f
, tval_f
);
569 printf("tval_g = %20llu (0x%016llx)\n", tval_g
, tval_g
);
570 printf("----------------------------------------\n");
572 for (i
= 0; i
< ARR_SIZE(int64_preds
); ++i
) {
573 printf("%s series:\n", int64_preds
[i
].name
);
574 if ((failed
= compare_expect_int64(int64_preds
+ i
)) > 0) {
575 printf(something_failed
, failed
);
577 printf(all_tests_passed
);
580 printf("----------------------------------------\n");
583 for (i
= 0; i
< ARR_SIZE(uint64_preds
); ++i
) {
584 printf("%s series:\n", uint64_preds
[i
].name
);
585 if ((failed
= compare_expect_uint64(uint64_preds
+ i
)) > 0) {
586 printf(something_failed
, failed
);
588 printf(all_tests_passed
);
591 printf("----------------------------------------\n");
594 /*----------------------------------------------------------------------*/
596 puts("signed/zero-extend tests:");
599 failed
+= test_i64_sext_i32(-1, -1LL);
600 failed
+= test_i64_sext_i32(10, 10LL);
601 failed
+= test_i64_sext_i32(0x7fffffff, 0x7fffffffLL
);
602 failed
+= test_i64_sext_i16(-1, -1LL);
603 failed
+= test_i64_sext_i16(10, 10LL);
604 failed
+= test_i64_sext_i16(0x7fff, 0x7fffLL
);
605 failed
+= test_i64_sext_i8(-1, -1LL);
606 failed
+= test_i64_sext_i8(10, 10LL);
607 failed
+= test_i64_sext_i8(0x7f, 0x7fLL
);
609 failed
+= test_i64_zext_i32(0xffffffff, 0x00000000ffffffffLLU
);
610 failed
+= test_i64_zext_i32(0x01234567, 0x0000000001234567LLU
);
611 failed
+= test_i64_zext_i16(0xffff, 0x000000000000ffffLLU
);
612 failed
+= test_i64_zext_i16(0x569a, 0x000000000000569aLLU
);
613 failed
+= test_i64_zext_i8(0xff, 0x00000000000000ffLLU
);
614 failed
+= test_i64_zext_i8(0xa0, 0x00000000000000a0LLU
);
617 printf(" %d tests failed.\n", failed
);
619 printf(" All tests passed.\n");
622 printf("----------------------------------------\n");
625 puts("signed left/right shift tests:");
626 failed
+= test_i64_constant_shift("i64_shl_const", i64_shl_const
, tval_a
, 0x00047dc7ec114c00LL
);
627 failed
+= test_i64_variable_shift("i64_shl", i64_shl
, tval_a
, 10, 0x00047dc7ec114c00LL
);
628 failed
+= test_i64_constant_shift("i64_srl_const", i64_srl_const
, tval_a
, 0x0000000047dc7ec1LL
);
629 failed
+= test_i64_variable_shift("i64_srl", i64_srl
, tval_a
, 10, 0x0000000047dc7ec1LL
);
630 failed
+= test_i64_constant_shift("i64_sra_const", i64_sra_const
, tval_a
, 0x0000000047dc7ec1LL
);
631 failed
+= test_i64_variable_shift("i64_sra", i64_sra
, tval_a
, 10, 0x0000000047dc7ec1LL
);
634 printf(" %d tests ailed.\n", failed
);
636 printf(" All tests passed.\n");
639 printf("----------------------------------------\n");
642 puts("unsigned left/right shift tests:");
643 failed
+= test_u64_constant_shift("u64_shl_const", u64_shl_const
, tval_f
, 0xfffc1d404d7ae400LL
);
644 failed
+= test_u64_variable_shift("u64_shl", u64_shl
, tval_f
, 10, 0xfffc1d404d7ae400LL
);
645 failed
+= test_u64_constant_shift("u64_srl_const", u64_srl_const
, tval_f
, 0x003fffffc1d404d7LL
);
646 failed
+= test_u64_variable_shift("u64_srl", u64_srl
, tval_f
, 10, 0x003fffffc1d404d7LL
);
647 failed
+= test_i64_constant_shift("i64_sra_const", i64_sra_const
, tval_f
, 0xffffffffc1d404d7LL
);
648 failed
+= test_i64_variable_shift("i64_sra", i64_sra
, tval_f
, 10, 0xffffffffc1d404d7LL
);
649 failed
+= test_u64_constant_shift("u64_sra_const", u64_sra_const
, tval_f
, 0x003fffffc1d404d7LL
);
650 failed
+= test_u64_variable_shift("u64_sra", u64_sra
, tval_f
, 10, 0x003fffffc1d404d7LL
);
653 printf(" %d tests ailed.\n", failed
);
655 printf(" All tests passed.\n");
658 printf("----------------------------------------\n");
662 result
= i64_mul(tval_g
, tval_g
);
663 printf("%20lld * %20lld = %20lld (0x%016llx)\n", tval_g
, tval_g
, result
, result
);
664 result
= i64_mul(tval_d
, tval_e
);
665 printf("%20lld * %20lld = %20lld (0x%016llx)\n", tval_d
, tval_e
, result
, result
);
666 /* 0xba7a664f13077c9 */
667 result
= i64_mul(tval_a
, tval_b
);
668 printf("%20lld * %20lld = %20lld (0x%016llx)\n", tval_a
, tval_b
, result
, result
);
670 printf("----------------------------------------\n");