grammar updates
[mono.git] / mono / mini / inssel-ppc.brg
1 %%
2
3 #
4 # inssel-x86.brg: burg file for special x86 instructions
5 #
6 # Author:
7 #   Dietmar Maurer (dietmar@ximian.com)
8 #   Paolo Molaro (lupus@ximian.com)
9 #
10 # (C) 2002 Ximian, Inc.
11 #
12
13 stmt: CEE_STIND_I8 (OP_REGVAR, lreg) {
14         /* this should only happen for methods returning a long */
15         MONO_EMIT_NEW_UNALU (s, OP_MOVE, ppc_r3, state->right->reg1);
16         MONO_EMIT_NEW_UNALU (s, OP_MOVE, ppc_r4, state->right->reg2);
17 }
18
19 lreg: OP_LNEG (lreg) "2" {
20         MONO_EMIT_NEW_BIALU_IMM (s, OP_PPC_SUBFIC, state->reg1, state->left->reg1, 0);
21         MONO_EMIT_UNALU (s, tree, OP_PPC_SUBFZE, state->reg2, state->left->reg2);
22 }
23
24 freg: OP_LCONV_TO_R8 (lreg) {
25         mono_bblock_add_inst (s->cbb, tree);
26 }
27
28 freg: OP_LCONV_TO_R4 (lreg) {
29         mono_bblock_add_inst (s->cbb, tree);
30 }
31
32 freg: CEE_CONV_R_UN (reg) {
33         mono_bblock_add_inst (s->cbb, tree);
34 }
35
36 reg: OP_LOCALLOC (OP_ICONST) {
37         /* microcoded in mini-ppc.c */
38         tree->sreg1 = mono_regstate_next_int (s->rs);
39         MONO_EMIT_NEW_ICONST (s, tree->sreg1, state->left->tree->inst_c0);
40         mono_bblock_add_inst (s->cbb, tree);
41 }
42
43 reg: OP_LOCALLOC (reg) {
44         mono_bblock_add_inst (s->cbb, tree);
45 }
46
47 stmt: OP_SETRET (reg) {
48         tree->opcode = OP_MOVE;
49         tree->sreg1 = state->left->reg1;
50         tree->dreg = ppc_r3;
51         mono_bblock_add_inst (s->cbb, tree);
52 }
53
54 stmt: OP_SETRET (lreg) {
55         MONO_EMIT_NEW_UNALU (s, OP_MOVE, ppc_r3, state->left->reg2);
56         tree->opcode = OP_MOVE;
57         tree->sreg1 = state->left->reg1;
58         tree->dreg = ppc_r4;
59         mono_bblock_add_inst (s->cbb, tree);
60 }
61
62 stmt: OP_SETRET (freg) {
63         /* FIXME */
64 }
65
66 stmt: OP_SETRET (OP_ICONST) {
67         tree->opcode = OP_ICONST;
68         tree->inst_c0 = state->left->tree->inst_c0;
69         tree->dreg = ppc_r3;
70         mono_bblock_add_inst (s->cbb, tree);
71 }
72
73 stmt: OP_OUTARG (reg) {
74         tree->opcode = OP_SETREG;
75         tree->dreg = tree->unused;
76         tree->sreg1 = state->left->reg1;
77         mono_bblock_add_inst (s->cbb, tree);
78 }
79
80 stmt: OP_OUTARG (OP_REGVAR) {
81         tree->opcode = OP_SETREG;
82         tree->dreg = tree->unused;
83         tree->sreg1 = state->left->tree->dreg;
84         mono_bblock_add_inst (s->cbb, tree);
85 }
86
87 stmt: OP_OUTARG (lreg) {
88         MONO_EMIT_NEW_UNALU (s, OP_SETREG, tree->unused, state->left->reg2);
89         tree->opcode = OP_SETREG;
90         tree->dreg = tree->unused + 1;
91         mono_bblock_add_inst (s->cbb, tree);
92 }
93
94 stmt: OP_OUTARG (OP_ICONST) {
95         tree->opcode = OP_SETREGIMM;
96         tree->dreg = tree->unused;
97         tree->inst_c0 = state->left->tree->inst_c0;
98         mono_bblock_add_inst (s->cbb, tree);
99 }
100
101 #stmt: OP_OUTARG (CEE_LDIND_I4 (base)) {
102 #       tree->opcode = OP_X86_PUSH_MEMBASE;
103 #       tree->inst_basereg = state->left->left->tree->inst_basereg;
104 #       tree->inst_offset = state->left->left->tree->inst_offset;
105 #       mono_bblock_add_inst (s->cbb, tree);
106 #}
107
108 #stmt: OP_OUTARG (CEE_LDIND_U4 (base)) {
109 #       tree->opcode = OP_X86_PUSH_MEMBASE;
110 #       tree->inst_basereg = state->left->left->tree->inst_basereg;
111 #       tree->inst_offset = state->left->left->tree->inst_offset;
112 #       mono_bblock_add_inst (s->cbb, tree);
113 #}
114
115 #stmt: OP_OUTARG (CEE_LDIND_I (base)) {
116 #       tree->opcode = OP_X86_PUSH_MEMBASE;
117 #       tree->inst_basereg = state->left->left->tree->inst_basereg;
118 #       tree->inst_offset = state->left->left->tree->inst_offset;
119 #       mono_bblock_add_inst (s->cbb, tree);
120 #}
121
122 #stmt: OP_OUTARG (CEE_LDIND_REF (base)) {
123 #       tree->opcode = OP_X86_PUSH_MEMBASE;
124 #       tree->inst_basereg = state->left->left->tree->inst_basereg;
125 #       tree->inst_offset = state->left->left->tree->inst_offset;
126 #       mono_bblock_add_inst (s->cbb, tree);
127 #}
128
129 stmt: OP_OUTARG (CEE_LDIND_REF (OP_REGVAR)) {
130         tree->opcode = OP_SETREG;
131         tree->sreg1 = state->left->left->tree->dreg;
132         tree->dreg = tree->unused;
133         mono_bblock_add_inst (s->cbb, tree);
134 }
135
136 #stmt: OP_OUTARG (CEE_LDOBJ (reg)) {
137 #       tree->opcode = OP_X86_PUSH;
138 #       tree->sreg1 = state->left->reg1;
139 #       mono_bblock_add_inst (s->cbb, tree);
140 #}
141
142 stmt: OP_OUTARG (freg) {
143         MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, X86_ESP, X86_ESP, 8);
144         tree->opcode = OP_STORER8_MEMBASE_REG;
145         tree->sreg1 = state->left->reg1;
146         tree->inst_destbasereg = X86_ESP;
147         tree->inst_offset = 0;
148         mono_bblock_add_inst (s->cbb, tree);
149 }
150
151 stmt: OP_OUTARG_R4 (freg) {
152         MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, X86_ESP, X86_ESP, 4);
153         tree->opcode = OP_STORER4_MEMBASE_REG;
154         tree->sreg1 = state->left->reg1;
155         tree->inst_destbasereg = X86_ESP;
156         tree->inst_offset = 0;
157         mono_bblock_add_inst (s->cbb, tree);
158 }
159
160 stmt: OP_OUTARG_R8 (freg) {
161         MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, X86_ESP, X86_ESP, 8);
162         tree->opcode = OP_STORER8_MEMBASE_REG;
163         tree->sreg1 = state->left->reg1;
164         tree->inst_destbasereg = X86_ESP;
165         tree->inst_offset = 0;
166         mono_bblock_add_inst (s->cbb, tree);
167 }
168
169 stmt: OP_OUTARG_VT (CEE_LDOBJ (base)) {
170         MonoInst *vt = state->left->left->tree;
171         //g_print ("vt size: %d at R%d + %d\n", tree->inst_imm, vt->inst_basereg, vt->inst_offset);
172         if (tree->inst_imm <= 4) {
173                 tree->opcode = OP_X86_PUSH_MEMBASE;
174                 tree->inst_basereg = vt->inst_basereg;
175                 tree->inst_offset = vt->inst_offset;
176                 mono_bblock_add_inst (s->cbb, tree);
177         } else {
178                 tree->opcode = OP_X86_PUSH_OBJ;
179                 tree->inst_basereg = vt->inst_basereg;
180                 tree->inst_offset = vt->inst_offset;
181                 mono_bblock_add_inst (s->cbb, tree);
182         }
183 }
184
185 stmt: OP_OUTARG_VT (OP_ICONST) {
186         tree->opcode = OP_SETREGIMM;
187         tree->dreg = tree->unused;
188         tree->inst_imm = state->left->tree->inst_c0;
189         mono_bblock_add_inst (s->cbb, tree);
190 }
191
192 stmt: CEE_STIND_R8 (OP_REGVAR, freg) {
193         /* nothing to do: the value is already on the FP stack */
194 }
195
196 stmt: CEE_BNE_UN (fpcflags) {
197         tree->opcode = OP_FBNE_UN;
198         mono_bblock_add_inst (s->cbb, tree);
199 }
200
201 stmt: CEE_BEQ (fpcflags) {
202         tree->opcode = OP_FBEQ;
203         mono_bblock_add_inst (s->cbb, tree);
204 }
205
206 stmt: CEE_BLT (fpcflags) {
207         tree->opcode = OP_FBLT;
208         mono_bblock_add_inst (s->cbb, tree);
209 }
210
211 stmt: CEE_BLT_UN (fpcflags) {
212         tree->opcode = OP_FBLT_UN;
213         mono_bblock_add_inst (s->cbb, tree);
214 }
215
216 stmt: CEE_BGT (fpcflags) {
217         tree->opcode = OP_FBGT;
218         mono_bblock_add_inst (s->cbb, tree);
219 }
220
221 stmt: CEE_BGT_UN (fpcflags) {
222         tree->opcode = OP_FBGT_UN;
223         mono_bblock_add_inst (s->cbb, tree);
224 }
225
226 stmt: CEE_BGE  (fpcflags) {
227         tree->opcode = OP_FBGE;
228         mono_bblock_add_inst (s->cbb, tree);
229 }
230
231 stmt: CEE_BGE_UN (fpcflags) {
232         tree->opcode = OP_FBGE_UN;
233         mono_bblock_add_inst (s->cbb, tree);
234 }
235
236 stmt: CEE_BLE  (fpcflags) {
237         tree->opcode = OP_FBLE;
238         mono_bblock_add_inst (s->cbb, tree);
239 }
240
241 stmt: CEE_BLE_UN (fpcflags) {
242         tree->opcode = OP_FBLE_UN;
243         mono_bblock_add_inst (s->cbb, tree);
244 }
245
246 stmt: CEE_POP (freg) "0" {
247         /* nothing to do */
248 }     
249
250 %%