make code a bit more readble
[libfirm] / ir / be / test / optest.c
1 #include <stdio.h>
2
3 typedef int myint;
4
5 #define TESTANZ         16
6 #define IMM             23
7 #define test16_1        42
8 #define test16_2        11
9 #define test32_1        0x001200AB
10 #define test32_2        0x00341500
11 #define test32_s    7
12
13
14
15 myint test_add(myint a, myint b) {
16         return a+b;
17 }
18
19 myint test_addi(myint a) {
20         return a+IMM;
21 }
22
23 myint test_sub(myint a, myint b) {
24         return a-b;
25 }
26
27 myint test_subi(myint a) {
28         return a-IMM;
29 }
30
31 myint test_subfi(myint a) {
32         return IMM-a;
33 }
34
35 myint test_mul(myint a, myint b) {
36         return a*b;
37 }
38
39 myint test_muli(myint a) {
40         return a*IMM;
41 }
42
43 myint test_div(myint a, myint b) {
44         return a/b;
45 }
46
47 myint test_divi(myint a) {
48         return a/IMM;
49 }
50
51 myint test_shl(myint a, myint b) {
52         return a<<b;
53 }
54
55 myint test_shli(myint a) {
56         return a<<IMM;
57 }
58
59 myint test_shr(myint a, myint b) {
60         return a>>b;
61 }
62
63 myint test_shri(myint a) {
64         return a>>IMM;
65 }
66
67 myint test_cmp(myint a, myint b) {
68         return (a>b) ? 1 : 0;
69 }
70
71 myint test_cmpi(myint a) {
72         return (a>IMM) ? 1 : 0;
73 }
74
75 int main(int argc, char *argv[]) {
76   myint res16[TESTANZ];
77   myint res32[TESTANZ];
78   int i;
79
80   res16[ 0] = test_add  (test16_1, test16_2);
81   res16[ 1] = test_sub  (test16_1, test16_2);
82   res16[ 2] = test_mul  (test16_1, test16_2);
83   res16[ 3] = test_div  (test16_1, test16_2);
84   res16[ 4] = test_shl  (test16_1, test16_2);
85   res16[ 5] = test_shr  (test16_1, test16_2);
86   res16[ 6] = test_div  (test16_1, test16_2);
87   res16[ 7] = test_cmp  (test16_1, test16_2);
88   res16[ 8] = test_addi (test16_1);
89   res16[ 9] = test_subi (test16_1);
90   res16[10] = test_subfi(test16_1);
91   res16[11] = test_muli (test16_1);
92   res16[12] = test_divi (test16_1);
93   res16[13] = test_shli (test16_1);
94   res16[14] = test_shri (test16_1);
95   res16[15] = test_cmpi (test16_1);
96
97   res32[ 0] = test_add  (test32_1, test32_2);
98   res32[ 1] = test_sub  (test32_1, test32_2);
99   res32[ 2] = test_mul  (test32_1, test32_2);
100   res32[ 3] = test_div  (test32_1, test32_2);
101   res32[ 4] = test_shl  (test32_1, test32_s);
102   res32[ 5] = test_shr  (test32_1, test32_s);
103   res32[ 6] = test_div  (test32_1, test32_2);
104   res32[ 7] = test_cmp  (test32_1, test32_2);
105   res32[ 8] = test_addi (test32_1);
106   res32[ 9] = test_subi (test32_1);
107   res32[10] = test_subfi(test32_1);
108   res32[11] = test_muli (test32_1);
109   res32[12] = test_divi (test32_1);
110   res32[13] = test_shli (test32_1);
111   res32[14] = test_shri (test32_1);
112   res32[15] = test_cmpi (test32_1);
113
114   for (i=0; i<TESTANZ; i++) {
115     printf("res16[%d] = %d\n", i, res16[i]);
116     printf("res32[%d] = %d\n", i, res32[i]);
117   }
118   return 0;
119 }