Remove VISIBILITY_HIDDEN from this file.
[llvm/avr.git] / test / CodeGen / CellSPU / useful-harnesses / i32operations.c
blob12fc30bf65d7bf44b5a25404fbce6221a4358680
1 #include <stdio.h>
3 typedef unsigned int uint32_t;
4 typedef int int32_t;
6 const char *boolstring(int val) {
7 return val ? "true" : "false";
10 int i32_eq(int32_t a, int32_t b) {
11 return (a == b);
14 int i32_neq(int32_t a, int32_t b) {
15 return (a != b);
18 int32_t i32_eq_select(int32_t a, int32_t b, int32_t c, int32_t d) {
19 return ((a == b) ? c : d);
22 int32_t i32_neq_select(int32_t a, int32_t b, int32_t c, int32_t d) {
23 return ((a != b) ? c : d);
26 struct pred_s {
27 const char *name;
28 int (*predfunc)(int32_t, int32_t);
29 int (*selfunc)(int32_t, int32_t, int32_t, int32_t);
32 struct pred_s preds[] = {
33 { "eq", i32_eq, i32_eq_select },
34 { "neq", i32_neq, i32_neq_select }
37 int main(void) {
38 int i;
39 int32_t a = 1234567890;
40 int32_t b = 345678901;
41 int32_t c = 1234500000;
42 int32_t d = 10001;
43 int32_t e = 10000;
45 printf("a = %12d (0x%08x)\n", a, a);
46 printf("b = %12d (0x%08x)\n", b, b);
47 printf("c = %12d (0x%08x)\n", c, c);
48 printf("d = %12d (0x%08x)\n", d, d);
49 printf("e = %12d (0x%08x)\n", e, e);
50 printf("----------------------------------------\n");
52 for (i = 0; i < sizeof(preds)/sizeof(preds[0]); ++i) {
53 printf("a %s a = %s\n", preds[i].name, boolstring((*preds[i].predfunc)(a, a)));
54 printf("a %s a = %s\n", preds[i].name, boolstring((*preds[i].predfunc)(a, a)));
55 printf("a %s b = %s\n", preds[i].name, boolstring((*preds[i].predfunc)(a, b)));
56 printf("a %s c = %s\n", preds[i].name, boolstring((*preds[i].predfunc)(a, c)));
57 printf("d %s e = %s\n", preds[i].name, boolstring((*preds[i].predfunc)(d, e)));
58 printf("e %s e = %s\n", preds[i].name, boolstring((*preds[i].predfunc)(e, e)));
60 printf("a %s a ? c : d = %d\n", preds[i].name, (*preds[i].selfunc)(a, a, c, d));
61 printf("a %s a ? c : d == c (%s)\n", preds[i].name, boolstring((*preds[i].selfunc)(a, a, c, d) == c));
62 printf("a %s b ? c : d = %d\n", preds[i].name, (*preds[i].selfunc)(a, b, c, d));
63 printf("a %s b ? c : d == d (%s)\n", preds[i].name, boolstring((*preds[i].selfunc)(a, b, c, d) == d));
65 printf("----------------------------------------\n");
68 return 0;