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