2003-11-27 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / mini / iltests.il
1 .assembly iltests {}\r
2 .assembly extern TestDriver {}\r
3 .assembly extern mscorlib {}\r
4 \r
5 .class public auto ansi sealed beforefieldinit Tests {\r
6 \r
7         .method static public int32 Main() il managed {\r
8                 .entrypoint\r
9                 \r
10                 ldtoken Tests\r
11                 call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)\r
12                 call       int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type)\r
13                 ret\r
14         }\r
15 \r
16         // make sure the register allocator works when the return value of\r
17         // 'div' is discarded\r
18         .method static public int32 test_0_div_regalloc () il managed {\r
19                 .locals init (\r
20                         int32 i\r
21                 )\r
22 \r
23                 ldloc 0\r
24                 ldc.i4.s 0xa\r
25                 div\r
26                 pop\r
27                 ldc.i4.0\r
28                 ret\r
29         }\r
30 \r
31         .method static public int32 test_3_copy_used_bug () il managed {\r
32 \r
33                 .locals init (\r
34                         int32 size,\r
35                         int32 res\r
36                 )\r
37 \r
38                 ldc.i4 0\r
39                 stloc res\r
40 \r
41                 ldc.i4 1\r
42                 stloc size\r
43 \r
44                 ldloc size\r
45                 ldloc size\r
46                 ldloc size\r
47                 add\r
48                 stloc size\r
49                 ldloc size\r
50                 add\r
51                 stloc res\r
52 \r
53                 ldloc res\r
54                 ret\r
55         }\r
56 \r
57         // demonstrate that the copy_used_var is not a fix for the above bug\r
58         .method static public int32 test_3_copy_used_indir_bug () il managed {\r
59 \r
60                 .locals init (\r
61                         int32 size,\r
62                         int32 res\r
63                 )\r
64 \r
65                 ldc.i4 0\r
66                 stloc res\r
67 \r
68                 ldc.i4 1\r
69                 stloc size\r
70 \r
71                 ldloc size\r
72                 ldloca size\r
73                 ldloc size\r
74                 ldloc size\r
75                 add\r
76                 stind.i4\r
77                 ldloc size\r
78                 add\r
79                 stloc res\r
80 \r
81                 ldloc res\r
82                 ret\r
83         }\r
84 \r
85         .method static public void do_nothing (int32 a) il managed {\r
86                 ret\r
87         }\r
88         \r
89         // demonstrate the block_split failure: needs -O=inline\r
90         // mini -O=inline --compile Tests:test_0_split_block_bug iltests.exe\r
91         .method static public int32 test_0_split_block_bug () il managed {\r
92 \r
93                 .locals init (\r
94                         int32 i1\r
95                 )\r
96 \r
97                 ldc.i4 1\r
98                 stloc i1\r
99  test_label:\r
100                 ldloc i1\r
101                 call void class Tests::do_nothing (int32)\r
102                 ldc.i4 0\r
103                 brtrue test_label\r
104                 \r
105                 ldc.i4 0\r
106                 ret\r
107         }\r
108 \r
109         .method public void inline_do_nothing () il managed {\r
110                 ret\r
111         }\r
112         .method static public int32 test_1_checkthis_inlining () il managed {\r
113                 ldnull\r
114                 call instance void class Tests::inline_do_nothing ()\r
115                 ldc.i4 1\r
116                 ret\r
117         }\r
118 \r
119         .class nested private auto ansi sealed beforefieldinit TailCallStruct \r
120                 extends [mscorlib]System.ValueType {\r
121                 .field public int32 a\r
122                 .field public int32 b\r
123         }\r
124 \r
125         .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {\r
126                 ldarga 0\r
127                 ldarga 0\r
128                 ldfld int32 Tests/TailCallStruct::a\r
129                 ldc.i4.1\r
130                 add\r
131                 stfld int32 Tests/TailCallStruct::a\r
132                 ldarga 0\r
133                 ldarga 0\r
134                 ldfld int32 Tests/TailCallStruct::a\r
135                 ldc.i4.2\r
136                 add\r
137                 stfld int32 Tests/TailCallStruct::a\r
138                 ldarg.0\r
139                 ret\r
140         }\r
141 \r
142         .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {\r
143                 ldarg.0\r
144                 tail.\r
145                 call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)\r
146                 ret\r
147         }\r
148 \r
149         .method static public int32 test_0_tail_calls () il managed {\r
150                 .maxstack 16\r
151                 .locals init (\r
152                         valuetype Tests/TailCallStruct arg\r
153                 )\r
154                 ldloca 0\r
155                 ldc.i4.2\r
156                 stfld int32 Tests/TailCallStruct::a\r
157                 ldloca 0\r
158                 ldc.i4.4\r
159                 stfld int32 Tests/TailCallStruct::b\r
160                 ldloc.0\r
161                 call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)\r
162                 stloc.0\r
163                 ldloca 0\r
164                 ldfld int32 Tests/TailCallStruct::a\r
165                 ldloca 0\r
166                 ldfld int32 Tests/TailCallStruct::b\r
167                 add\r
168                 ldc.i4 9\r
169                 sub\r
170                 ret\r
171         }\r
172 }\r