cf6b20901d35ec11f9674c28332fa5f32c8f903e
[cacao.git] / src / vm / jit / alpha / codegen.h
1 /* vm/jit/alpha/codegen.h - code generation macros and definitions for Alpha
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: codegen.h 7691 2007-04-12 12:45:10Z twisti $
26
27 */
28
29
30 #ifndef _CODEGEN_H
31 #define _CODEGEN_H
32
33 #include "config.h"
34 #include "vm/types.h"
35
36 #include "vm/jit/jit.h"
37
38
39 /* additional functions and macros to generate code ***************************/
40
41 #define gen_bound_check \
42     if (checkbounds) { \
43         M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
44         M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
45         M_BEQZ(REG_ITMP3, 0);\
46         codegen_add_arrayindexoutofboundsexception_ref(cd, s2); \
47     }
48
49
50 /* MCODECHECK(icnt) */
51
52 #define MCODECHECK(icnt) \
53     do { \
54         if ((cd->mcodeptr + (icnt) * 4) > cd->mcodeend) \
55             codegen_increase(cd); \
56     } while (0)
57
58
59 #define ALIGNCODENOP \
60     if ((s4) ((ptrint) cd->mcodeptr & 7)) { \
61         M_NOP; \
62     }
63
64
65 /* M_INTMOVE:
66      generates an integer-move from register a to b.
67      if a and b are the same int-register, no code will be generated.
68 */ 
69
70 #define M_INTMOVE(a,b) \
71     do { \
72         if ((a) != (b)) \
73             M_MOV(a, b); \
74     } while (0)
75
76
77 /* M_FLTMOVE:
78     generates a floating-point-move from register a to b.
79     if a and b are the same float-register, no code will be generated
80 */ 
81
82 #define M_FLTMOVE(a,b) \
83     do { \
84         if ((a) != (b)) \
85             M_FMOV(a, b); \
86     } while (0)
87
88
89 #define ICONST(d,c)        emit_iconst(cd, (d), (c))
90 #define LCONST(d,c)        emit_lconst(cd, (d), (c))
91
92
93 /* branch defines *************************************************************/
94
95 #define BRANCH_NOPS \
96     do { \
97         M_NOP; \
98     } while (0)
99
100
101 /* patcher defines ************************************************************/
102
103 #define PATCHER_CALL_SIZE    1 * 4     /* an instruction is 4-bytes long      */
104
105 #define PATCHER_NOPS \
106     do { \
107         M_NOP; \
108     } while (0)
109
110
111 /* stub defines ***************************************************************/
112
113 #define COMPILERSTUB_CODESIZE    3 * 4
114
115
116 /* macros to create code ******************************************************/
117
118 #define REG   0
119 #define CONST 1
120
121 /* 3-address-operations: M_OP3
122       op ..... opcode
123       fu ..... function-number
124       a  ..... register number source 1
125       b  ..... register number or constant integer source 2
126       c  ..... register number destination
127       const .. switch to use b as constant integer 
128                  (REG means: use b as register number)
129                  (CONST means: use b as constant 8-bit-integer)
130 */      
131
132 #define M_OP3(op,fu,a,b,c,const) \
133     do { \
134         *((u4 *) cd->mcodeptr) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << (16 - 3 * (const))) | ((const) << 12) | ((fu) << 5) | ((c))); \
135         cd->mcodeptr += 4; \
136     } while (0)
137
138
139 /* 3-address-floating-point-operation: M_FOP3 
140      op .... opcode
141      fu .... function-number
142      a,b ... source floating-point registers
143      c ..... destination register
144 */ 
145
146 #define M_FOP3(op,fu,a,b,c) \
147     do { \
148         *((u4 *) cd->mcodeptr) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << 16) | ((fu) << 5) | (c)); \
149         cd->mcodeptr += 4; \
150     } while (0)
151
152
153 /* branch instructions: M_BRA 
154       op ..... opcode
155       a ...... register to be tested
156       disp ... relative address to be jumped to (divided by 4)
157 */
158
159 #define M_BRA(op,a,disp) \
160     do { \
161         *((u4 *) cd->mcodeptr) = ((((s4) (op)) << 26) | ((a) << 21) | ((disp) & 0x1fffff)); \
162         cd->mcodeptr += 4; \
163     } while (0)
164
165
166 /* memory operations: M_MEM
167       op ..... opcode
168       a ...... source/target register for memory access
169       b ...... base register
170       disp ... displacement (16 bit signed) to be added to b
171 */ 
172
173 #define M_MEM(op,a,b,disp) \
174     do { \
175         *((u4 *) cd->mcodeptr) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << 16) | ((disp) & 0xffff)); \
176         cd->mcodeptr += 4; \
177     } while (0)
178
179 #define M_MEM_GET_A(x)                  (((x) >> 21) & 0x1f  )
180 #define M_MEM_GET_B(x)                  (((x) >> 16) & 0x1f  )
181 #define M_MEM_GET_DISP(x)               ( (x)        & 0xffff)
182
183
184 /* macros for all used commands (see an Alpha-manual for description) *********/
185
186 #define M_LDA_INTERN(a,b,disp)  M_MEM(0x08,a,b,disp)            /* low const  */
187
188 #define M_LDA(a,b,disp) \
189     do { \
190         s4 lo = (short) (disp); \
191         s4 hi = (short) (((disp) - lo) >> 16); \
192         if (hi == 0) { \
193             M_LDA_INTERN(a,b,lo); \
194         } else { \
195             M_LDAH(a,b,hi); \
196             M_LDA_INTERN(a,a,lo); \
197         } \
198     } while (0)
199
200 #define M_LDAH(a,b,disp)        M_MEM (0x09,a,b,disp)           /* high const */
201
202 #define M_BLDU(a,b,disp)        M_MEM (0x0a,a,b,disp)           /*  8 load    */
203 #define M_SLDU(a,b,disp)        M_MEM (0x0c,a,b,disp)           /* 16 load    */
204
205 #define M_ILD_INTERN(a,b,disp)  M_MEM(0x28,a,b,disp)            /* 32 load    */
206 #define M_LLD_INTERN(a,b,disp)  M_MEM(0x29,a,b,disp)            /* 64 load    */
207
208 #define M_ILD(a,b,disp) \
209     do { \
210         s4 lo = (short) (disp); \
211         s4 hi = (short) (((disp) - lo) >> 16); \
212         if (hi == 0) { \
213             M_ILD_INTERN(a,b,lo); \
214         } else { \
215             M_LDAH(a,b,hi); \
216             M_ILD_INTERN(a,a,lo); \
217         } \
218     } while (0)
219
220 #define M_LLD(a,b,disp) \
221     do { \
222         s4 lo = (short) (disp); \
223         s4 hi = (short) (((disp) - lo) >> 16); \
224         if (hi == 0) { \
225             M_LLD_INTERN(a,b,lo); \
226         } else { \
227             M_LDAH(a,b,hi); \
228             M_LLD_INTERN(a,a,lo); \
229         } \
230     } while (0)
231
232 #define M_ALD_INTERN(a,b,disp)  M_LLD_INTERN(a,b,disp)
233 #define M_ALD(a,b,disp)         M_LLD(a,b,disp)                 /* addr load  */
234
235 #define M_BST(a,b,disp)         M_MEM(0x0e,a,b,disp)            /*  8 store   */
236 #define M_SST(a,b,disp)         M_MEM(0x0d,a,b,disp)            /* 16 store   */
237
238 #define M_IST_INTERN(a,b,disp)  M_MEM(0x2c,a,b,disp)            /* 32 store   */
239 #define M_LST_INTERN(a,b,disp)  M_MEM(0x2d,a,b,disp)            /* 64 store   */
240
241 /* Stores with displacement overflow should only happen with PUTFIELD or on   */
242 /* the stack. The PUTFIELD instruction does not use REG_ITMP3 and a           */
243 /* reg_of_var call should not use REG_ITMP3!!!                                */
244
245 #define M_IST(a,b,disp) \
246     do { \
247         s4 lo = (short) (disp); \
248         s4 hi = (short) (((disp) - lo) >> 16); \
249         if (hi == 0) { \
250             M_IST_INTERN(a,b,lo); \
251         } else { \
252             M_LDAH(REG_ITMP3,b,hi); \
253             M_IST_INTERN(a,REG_ITMP3,lo); \
254         } \
255     } while (0)
256
257 #define M_LST(a,b,disp) \
258     do { \
259         s4 lo = (short) (disp); \
260         s4 hi = (short) (((disp) - lo) >> 16); \
261         if (hi == 0) { \
262             M_LST_INTERN(a,b,lo); \
263         } else { \
264             M_LDAH(REG_ITMP3,b,hi); \
265             M_LST_INTERN(a,REG_ITMP3,lo); \
266         } \
267     } while (0)
268
269 #define M_AST(a,b,disp)         M_LST(a,b,disp)                 /* addr store */
270
271 #define M_BSEXT(b,c)            M_OP3 (0x1c,0x0,REG_ZERO,b,c,0) /*  8 signext */
272 #define M_SSEXT(b,c)            M_OP3 (0x1c,0x1,REG_ZERO,b,c,0) /* 16 signext */
273
274 #define M_BR(disp)              M_BRA (0x30,REG_ZERO,disp)      /* branch     */
275 #define M_BSR(ra,disp)          M_BRA (0x34,ra,disp)            /* branch sbr */
276 #define M_BEQZ(a,disp)          M_BRA (0x39,a,disp)             /* br a == 0  */
277 #define M_BLTZ(a,disp)          M_BRA (0x3a,a,disp)             /* br a <  0  */
278 #define M_BLEZ(a,disp)          M_BRA (0x3b,a,disp)             /* br a <= 0  */
279 #define M_BNEZ(a,disp)          M_BRA (0x3d,a,disp)             /* br a != 0  */
280 #define M_BGEZ(a,disp)          M_BRA (0x3e,a,disp)             /* br a >= 0  */
281 #define M_BGTZ(a,disp)          M_BRA (0x3f,a,disp)             /* br a >  0  */
282
283 #define M_JMP(a,b)              M_MEM (0x1a,a,b,0x0000)         /* jump       */
284 #define M_JSR(a,b)              M_MEM (0x1a,a,b,0x4000)         /* call sbr   */
285 #define M_RET(a,b)              M_MEM (0x1a,a,b,0x8000)         /* return     */
286
287 #define M_IADD(a,b,c)           M_OP3 (0x10,0x0,  a,b,c,0)      /* 32 add     */
288 #define M_LADD(a,b,c)           M_OP3 (0x10,0x20, a,b,c,0)      /* 64 add     */
289 #define M_ISUB(a,b,c)           M_OP3 (0x10,0x09, a,b,c,0)      /* 32 sub     */
290 #define M_LSUB(a,b,c)           M_OP3 (0x10,0x29, a,b,c,0)      /* 64 sub     */
291 #define M_IMUL(a,b,c)           M_OP3 (0x13,0x00, a,b,c,0)      /* 32 mul     */
292 #define M_LMUL(a,b,c)           M_OP3 (0x13,0x20, a,b,c,0)      /* 64 mul     */
293
294 #define M_IADD_IMM(a,b,c)       M_OP3 (0x10,0x0,  a,b,c,1)      /* 32 add     */
295 #define M_LADD_IMM(a,b,c)       M_OP3 (0x10,0x20, a,b,c,1)      /* 64 add     */
296 #define M_ISUB_IMM(a,b,c)       M_OP3 (0x10,0x09, a,b,c,1)      /* 32 sub     */
297 #define M_LSUB_IMM(a,b,c)       M_OP3 (0x10,0x29, a,b,c,1)      /* 64 sub     */
298 #define M_IMUL_IMM(a,b,c)       M_OP3 (0x13,0x00, a,b,c,1)      /* 32 mul     */
299 #define M_LMUL_IMM(a,b,c)       M_OP3 (0x13,0x20, a,b,c,1)      /* 64 mul     */
300
301 #define M_AADD_IMM(a,b,c)       M_LADD_IMM(a,b,c)
302 #define M_ASUB_IMM(a,b,c)       M_LSUB_IMM(a,b,c)
303
304 #define M_CMPEQ(a,b,c)          M_OP3 (0x10,0x2d, a,b,c,0)      /* c = a == b */
305 #define M_CMPLT(a,b,c)          M_OP3 (0x10,0x4d, a,b,c,0)      /* c = a <  b */
306 #define M_CMPLE(a,b,c)          M_OP3 (0x10,0x6d, a,b,c,0)      /* c = a <= b */
307
308 #define M_CMPULE(a,b,c)         M_OP3 (0x10,0x3d, a,b,c,0)      /* c = a <= b */
309 #define M_CMPULT(a,b,c)         M_OP3 (0x10,0x1d, a,b,c,0)      /* c = a <= b */
310
311 #define M_CMPEQ_IMM(a,b,c)      M_OP3 (0x10,0x2d, a,b,c,1)      /* c = a == b */
312 #define M_CMPLT_IMM(a,b,c)      M_OP3 (0x10,0x4d, a,b,c,1)      /* c = a <  b */
313 #define M_CMPLE_IMM(a,b,c)      M_OP3 (0x10,0x6d, a,b,c,1)      /* c = a <= b */
314
315 #define M_CMPULE_IMM(a,b,c)     M_OP3 (0x10,0x3d, a,b,c,1)      /* c = a <= b */
316 #define M_CMPULT_IMM(a,b,c)     M_OP3 (0x10,0x1d, a,b,c,1)      /* c = a <= b */
317
318 #define M_AND(a,b,c)            M_OP3 (0x11,0x00, a,b,c,0)      /* c = a &  b */
319 #define M_OR( a,b,c)            M_OP3 (0x11,0x20, a,b,c,0)      /* c = a |  b */
320 #define M_XOR(a,b,c)            M_OP3 (0x11,0x40, a,b,c,0)      /* c = a ^  b */
321
322 #define M_AND_IMM(a,b,c)        M_OP3 (0x11,0x00, a,b,c,1)      /* c = a &  b */
323 #define M_OR_IMM( a,b,c)        M_OP3 (0x11,0x20, a,b,c,1)      /* c = a |  b */
324 #define M_XOR_IMM(a,b,c)        M_OP3 (0x11,0x40, a,b,c,1)      /* c = a ^  b */
325
326 #define M_MOV(a,c)              M_OR (a,a,c)                    /* c = a      */
327 #define M_CLR(c)                M_OR (31,31,c)                  /* c = 0      */
328 #define M_NOP                   M_OR (31,31,31)                 /* ;          */
329
330 #define M_SLL(a,b,c)            M_OP3 (0x12,0x39, a,b,c,0)      /* c = a << b */
331 #define M_SRA(a,b,c)            M_OP3 (0x12,0x3c, a,b,c,0)      /* c = a >> b */
332 #define M_SRL(a,b,c)            M_OP3 (0x12,0x34, a,b,c,0)      /* c = a >>>b */
333
334 #define M_SLL_IMM(a,b,c)        M_OP3 (0x12,0x39, a,b,c,1)      /* c = a << b */
335 #define M_SRA_IMM(a,b,c)        M_OP3 (0x12,0x3c, a,b,c,1)      /* c = a >> b */
336 #define M_SRL_IMM(a,b,c)        M_OP3 (0x12,0x34, a,b,c,1)      /* c = a >>>b */
337
338 #define M_FLD_INTERN(a,b,disp)  M_MEM(0x22,a,b,disp)            /* load flt   */
339 #define M_DLD_INTERN(a,b,disp)  M_MEM(0x23,a,b,disp)            /* load dbl   */
340
341 #define M_FLD(a,b,disp) \
342     do { \
343         s4 lo = (short) (disp); \
344         s4 hi = (short) (((disp) - lo) >> 16); \
345         if (hi == 0) { \
346             M_FLD_INTERN(a,b,lo); \
347         } else { \
348             M_LDAH(REG_ITMP3,b,hi); \
349             M_FLD_INTERN(a,REG_ITMP3,lo); \
350         } \
351     } while (0)
352
353 #define M_DLD(a,b,disp) \
354     do { \
355         s4 lo = (short) (disp); \
356         s4 hi = (short) (((disp) - lo) >> 16); \
357         if (hi == 0) { \
358             M_DLD_INTERN(a,b,lo); \
359         } else { \
360             M_LDAH(REG_ITMP3,b,hi); \
361             M_DLD_INTERN(a,REG_ITMP3,lo); \
362         } \
363     } while (0)
364
365 #define M_FST_INTERN(a,b,disp)  M_MEM(0x26,a,b,disp)            /* store flt  */
366 #define M_DST_INTERN(a,b,disp)  M_MEM(0x27,a,b,disp)            /* store dbl  */
367
368 /* Stores with displacement overflow should only happen with PUTFIELD or on   */
369 /* the stack. The PUTFIELD instruction does not use REG_ITMP3 and a           */
370 /* reg_of_var call should not use REG_ITMP3!!!                                */
371
372 #define M_FST(a,b,disp) \
373     do { \
374         s4 lo = (short) (disp); \
375         s4 hi = (short) (((disp) - lo) >> 16); \
376         if (hi == 0) { \
377             M_FST_INTERN(a,b,lo); \
378         } else { \
379             M_LDAH(REG_ITMP3,b,hi); \
380             M_FST_INTERN(a,REG_ITMP3,lo); \
381         } \
382     } while (0)
383
384 #define M_DST(a,b,disp) \
385     do { \
386         s4 lo = (short) (disp); \
387         s4 hi = (short) (((disp) - lo) >> 16); \
388         if (hi == 0) { \
389             M_DST_INTERN(a,b,lo); \
390         } else { \
391             M_LDAH(REG_ITMP3,b,hi); \
392             M_DST_INTERN(a,REG_ITMP3,lo); \
393         } \
394     } while (0)
395
396
397 #define M_FADD(a,b,c)           M_FOP3 (0x16, 0x080, a,b,c)     /* flt add    */
398 #define M_DADD(a,b,c)           M_FOP3 (0x16, 0x0a0, a,b,c)     /* dbl add    */
399 #define M_FSUB(a,b,c)           M_FOP3 (0x16, 0x081, a,b,c)     /* flt sub    */
400 #define M_DSUB(a,b,c)           M_FOP3 (0x16, 0x0a1, a,b,c)     /* dbl sub    */
401 #define M_FMUL(a,b,c)           M_FOP3 (0x16, 0x082, a,b,c)     /* flt mul    */
402 #define M_DMUL(a,b,c)           M_FOP3 (0x16, 0x0a2, a,b,c)     /* dbl mul    */
403 #define M_FDIV(a,b,c)           M_FOP3 (0x16, 0x083, a,b,c)     /* flt div    */
404 #define M_DDIV(a,b,c)           M_FOP3 (0x16, 0x0a3, a,b,c)     /* dbl div    */
405
406 #define M_FADDS(a,b,c)          M_FOP3 (0x16, 0x580, a,b,c)     /* flt add    */
407 #define M_DADDS(a,b,c)          M_FOP3 (0x16, 0x5a0, a,b,c)     /* dbl add    */
408 #define M_FSUBS(a,b,c)          M_FOP3 (0x16, 0x581, a,b,c)     /* flt sub    */
409 #define M_DSUBS(a,b,c)          M_FOP3 (0x16, 0x5a1, a,b,c)     /* dbl sub    */
410 #define M_FMULS(a,b,c)          M_FOP3 (0x16, 0x582, a,b,c)     /* flt mul    */
411 #define M_DMULS(a,b,c)          M_FOP3 (0x16, 0x5a2, a,b,c)     /* dbl mul    */
412 #define M_FDIVS(a,b,c)          M_FOP3 (0x16, 0x583, a,b,c)     /* flt div    */
413 #define M_DDIVS(a,b,c)          M_FOP3 (0x16, 0x5a3, a,b,c)     /* dbl div    */
414
415 #define M_CVTDF(b,c)            M_FOP3 (0x16, 0x0ac, 31,b,c)    /* dbl2flt    */
416 #define M_CVTLF(b,c)            M_FOP3 (0x16, 0x0bc, 31,b,c)    /* long2flt   */
417 #define M_CVTLD(b,c)            M_FOP3 (0x16, 0x0be, 31,b,c)    /* long2dbl   */
418 #define M_CVTDL(b,c)            M_FOP3 (0x16, 0x1af, 31,b,c)    /* dbl2long   */
419 #define M_CVTDL_C(b,c)          M_FOP3 (0x16, 0x12f, 31,b,c)    /* dbl2long   */
420 #define M_CVTLI(b,c)            M_FOP3 (0x17, 0x130, 31,b,c)    /* long2int   */
421
422 #define M_CVTDFS(b,c)           M_FOP3 (0x16, 0x5ac, 31,b,c)    /* dbl2flt    */
423 #define M_CVTFDS(b,c)           M_FOP3 (0x16, 0x6ac, 31,b,c)    /* flt2dbl    */
424 #define M_CVTDLS(b,c)           M_FOP3 (0x16, 0x5af, 31,b,c)    /* dbl2long   */
425 #define M_CVTDL_CS(b,c)         M_FOP3 (0x16, 0x52f, 31,b,c)    /* dbl2long   */
426 #define M_CVTLIS(b,c)           M_FOP3 (0x17, 0x530, 31,b,c)    /* long2int   */
427
428 #define M_FCMPEQ(a,b,c)         M_FOP3 (0x16, 0x0a5, a,b,c)     /* c = a==b   */
429 #define M_FCMPLT(a,b,c)         M_FOP3 (0x16, 0x0a6, a,b,c)     /* c = a<b    */
430
431 #define M_FCMPEQS(a,b,c)        M_FOP3 (0x16, 0x5a5, a,b,c)     /* c = a==b   */
432 #define M_FCMPLTS(a,b,c)        M_FOP3 (0x16, 0x5a6, a,b,c)     /* c = a<b    */
433
434 #define M_FMOV(fa,fb)           M_FOP3 (0x17, 0x020, fa,fa,fb)  /* b = a      */
435 #define M_FMOVN(fa,fb)          M_FOP3 (0x17, 0x021, fa,fa,fb)  /* b = -a     */
436
437 #define M_FNOP                  M_FMOV (31,31)
438
439 #define M_FBEQZ(fa,disp)        M_BRA (0x31,fa,disp)            /* br a == 0.0*/
440
441 /* macros for special commands (see an Alpha-manual for description) **********/ 
442
443 #define M_TRAPB                 M_MEM (0x18,0,0,0x0000)        /* trap barrier*/
444
445 #define M_S4ADDL(a,b,c)         M_OP3 (0x10,0x02, a,b,c,0)     /* c = a*4 + b */
446 #define M_S4ADDQ(a,b,c)         M_OP3 (0x10,0x22, a,b,c,0)     /* c = a*4 + b */
447 #define M_S4SUBL(a,b,c)         M_OP3 (0x10,0x0b, a,b,c,0)     /* c = a*4 - b */
448 #define M_S4SUBQ(a,b,c)         M_OP3 (0x10,0x2b, a,b,c,0)     /* c = a*4 - b */
449 #define M_S8ADDL(a,b,c)         M_OP3 (0x10,0x12, a,b,c,0)     /* c = a*8 + b */
450 #define M_S8ADDQ(a,b,c)         M_OP3 (0x10,0x32, a,b,c,0)     /* c = a*8 + b */
451 #define M_S8SUBL(a,b,c)         M_OP3 (0x10,0x1b, a,b,c,0)     /* c = a*8 - b */
452 #define M_S8SUBQ(a,b,c)         M_OP3 (0x10,0x3b, a,b,c,0)     /* c = a*8 - b */
453 #define M_SAADDQ(a,b,c)         M_S8ADDQ(a,b,c)                /* c = a*8 + b */
454
455 #define M_S4ADDL_IMM(a,b,c)     M_OP3 (0x10,0x02, a,b,c,1)     /* c = a*4 + b */
456 #define M_S4ADDQ_IMM(a,b,c)     M_OP3 (0x10,0x22, a,b,c,1)     /* c = a*4 + b */
457 #define M_S4SUBL_IMM(a,b,c)     M_OP3 (0x10,0x0b, a,b,c,1)     /* c = a*4 - b */
458 #define M_S4SUBQ_IMM(a,b,c)     M_OP3 (0x10,0x2b, a,b,c,1)     /* c = a*4 - b */
459 #define M_S8ADDL_IMM(a,b,c)     M_OP3 (0x10,0x12, a,b,c,1)     /* c = a*8 + b */
460 #define M_S8ADDQ_IMM(a,b,c)     M_OP3 (0x10,0x32, a,b,c,1)     /* c = a*8 + b */
461 #define M_S8SUBL_IMM(a,b,c)     M_OP3 (0x10,0x1b, a,b,c,1)     /* c = a*8 - b */
462 #define M_S8SUBQ_IMM(a,b,c)     M_OP3 (0x10,0x3b, a,b,c,1)     /* c = a*8 - b */
463
464 #define M_LLD_U(a,b,disp)       M_MEM (0x0b,a,b,disp)          /* unalign ld  */
465 #define M_LST_U(a,b,disp)       M_MEM (0x0f,a,b,disp)          /* unalign st  */
466
467 #define M_ZAP(a,b,c)            M_OP3 (0x12,0x30, a,b,c,0)
468 #define M_ZAPNOT(a,b,c)         M_OP3 (0x12,0x31, a,b,c,0)
469
470 #define M_ZAP_IMM(a,b,c)        M_OP3 (0x12,0x30, a,b,c,1)
471 #define M_ZAPNOT_IMM(a,b,c)     M_OP3 (0x12,0x31, a,b,c,1)
472
473 #define M_BZEXT(a,b)            M_ZAPNOT_IMM(a, 0x01, b)       /*  8 zeroext  */
474 #define M_CZEXT(a,b)            M_ZAPNOT_IMM(a, 0x03, b)       /* 16 zeroext  */
475 #define M_IZEXT(a,b)            M_ZAPNOT_IMM(a, 0x0f, b)       /* 32 zeroext  */
476
477 #define M_EXTBL(a,b,c)          M_OP3 (0x12,0x06, a,b,c,0)
478 #define M_EXTWL(a,b,c)          M_OP3 (0x12,0x16, a,b,c,0)
479 #define M_EXTLL(a,b,c)          M_OP3 (0x12,0x26, a,b,c,0)
480 #define M_EXTQL(a,b,c)          M_OP3 (0x12,0x36, a,b,c,0)
481 #define M_EXTWH(a,b,c)          M_OP3 (0x12,0x5a, a,b,c,0)
482 #define M_EXTLH(a,b,c)          M_OP3 (0x12,0x6a, a,b,c,0)
483 #define M_EXTQH(a,b,c)          M_OP3 (0x12,0x7a, a,b,c,0)
484 #define M_INSBL(a,b,c)          M_OP3 (0x12,0x0b, a,b,c,0)
485 #define M_INSWL(a,b,c)          M_OP3 (0x12,0x1b, a,b,c,0)
486 #define M_INSLL(a,b,c)          M_OP3 (0x12,0x2b, a,b,c,0)
487 #define M_INSQL(a,b,c)          M_OP3 (0x12,0x3b, a,b,c,0)
488 #define M_INSWH(a,b,c)          M_OP3 (0x12,0x57, a,b,c,0)
489 #define M_INSLH(a,b,c)          M_OP3 (0x12,0x67, a,b,c,0)
490 #define M_INSQH(a,b,c)          M_OP3 (0x12,0x77, a,b,c,0)
491 #define M_MSKBL(a,b,c)          M_OP3 (0x12,0x02, a,b,c,0)
492 #define M_MSKWL(a,b,c)          M_OP3 (0x12,0x12, a,b,c,0)
493 #define M_MSKLL(a,b,c)          M_OP3 (0x12,0x22, a,b,c,0)
494 #define M_MSKQL(a,b,c)          M_OP3 (0x12,0x32, a,b,c,0)
495 #define M_MSKWH(a,b,c)          M_OP3 (0x12,0x52, a,b,c,0)
496 #define M_MSKLH(a,b,c)          M_OP3 (0x12,0x62, a,b,c,0)
497 #define M_MSKQH(a,b,c)          M_OP3 (0x12,0x72, a,b,c,0)
498
499 #define M_EXTBL_IMM(a,b,c)      M_OP3 (0x12,0x06, a,b,c,1)
500 #define M_EXTWL_IMM(a,b,c)      M_OP3 (0x12,0x16, a,b,c,1)
501 #define M_EXTLL_IMM(a,b,c)      M_OP3 (0x12,0x26, a,b,c,1)
502 #define M_EXTQL_IMM(a,b,c)      M_OP3 (0x12,0x36, a,b,c,1)
503 #define M_EXTWH_IMM(a,b,c)      M_OP3 (0x12,0x5a, a,b,c,1)
504 #define M_EXTLH_IMM(a,b,c)      M_OP3 (0x12,0x6a, a,b,c,1)
505 #define M_EXTQH_IMM(a,b,c)      M_OP3 (0x12,0x7a, a,b,c,1)
506 #define M_INSBL_IMM(a,b,c)      M_OP3 (0x12,0x0b, a,b,c,1)
507 #define M_INSWL_IMM(a,b,c)      M_OP3 (0x12,0x1b, a,b,c,1)
508 #define M_INSLL_IMM(a,b,c)      M_OP3 (0x12,0x2b, a,b,c,1)
509 #define M_INSQL_IMM(a,b,c)      M_OP3 (0x12,0x3b, a,b,c,1)
510 #define M_INSWH_IMM(a,b,c)      M_OP3 (0x12,0x57, a,b,c,1)
511 #define M_INSLH_IMM(a,b,c)      M_OP3 (0x12,0x67, a,b,c,1)
512 #define M_INSQH_IMM(a,b,c)      M_OP3 (0x12,0x77, a,b,c,1)
513 #define M_MSKBL_IMM(a,b,c)      M_OP3 (0x12,0x02, a,b,c,1)
514 #define M_MSKWL_IMM(a,b,c)      M_OP3 (0x12,0x12, a,b,c,1)
515 #define M_MSKLL_IMM(a,b,c)      M_OP3 (0x12,0x22, a,b,c,1)
516 #define M_MSKQL_IMM(a,b,c)      M_OP3 (0x12,0x32, a,b,c,1)
517 #define M_MSKWH_IMM(a,b,c)      M_OP3 (0x12,0x52, a,b,c,1)
518 #define M_MSKLH_IMM(a,b,c)      M_OP3 (0x12,0x62, a,b,c,1)
519 #define M_MSKQH_IMM(a,b,c)      M_OP3 (0x12,0x72, a,b,c,1)
520
521 #define M_UMULH(a,b,c)          M_OP3 (0x13,0x30, a,b,c,0)     /* 64 umulh    */
522
523 #define M_UMULH_IMM(a,b,c)      M_OP3 (0x13,0x30, a,b,c,1)     /* 64 umulh    */
524
525 #define M_CMOVEQ(a,b,c)         M_OP3 (0x11,0x24, a,b,c,0)     /* a==0 ? c=b  */
526 #define M_CMOVNE(a,b,c)         M_OP3 (0x11,0x26, a,b,c,0)     /* a!=0 ? c=b  */
527 #define M_CMOVLT(a,b,c)         M_OP3 (0x11,0x44, a,b,c,0)     /* a< 0 ? c=b  */
528 #define M_CMOVGE(a,b,c)         M_OP3 (0x11,0x46, a,b,c,0)     /* a>=0 ? c=b  */
529 #define M_CMOVLE(a,b,c)         M_OP3 (0x11,0x64, a,b,c,0)     /* a<=0 ? c=b  */
530 #define M_CMOVGT(a,b,c)         M_OP3 (0x11,0x66, a,b,c,0)     /* a> 0 ? c=b  */
531
532 #define M_CMOVEQ_IMM(a,b,c)     M_OP3 (0x11,0x24, a,b,c,1)     /* a==0 ? c=b  */
533 #define M_CMOVNE_IMM(a,b,c)     M_OP3 (0x11,0x26, a,b,c,1)     /* a!=0 ? c=b  */
534 #define M_CMOVLT_IMM(a,b,c)     M_OP3 (0x11,0x44, a,b,c,1)     /* a< 0 ? c=b  */
535 #define M_CMOVGE_IMM(a,b,c)     M_OP3 (0x11,0x46, a,b,c,1)     /* a>=0 ? c=b  */
536 #define M_CMOVLE_IMM(a,b,c)     M_OP3 (0x11,0x64, a,b,c,1)     /* a<=0 ? c=b  */
537 #define M_CMOVGT_IMM(a,b,c)     M_OP3 (0x11,0x66, a,b,c,1)     /* a> 0 ? c=b  */
538
539 /* macros for unused commands (see an Alpha-manual for description) ***********/
540
541 #define M_ANDNOT(a,b,c,const)   M_OP3 (0x11,0x08, a,b,c,const) /* c = a &~ b  */
542 #define M_ORNOT(a,b,c,const)    M_OP3 (0x11,0x28, a,b,c,const) /* c = a |~ b  */
543 #define M_XORNOT(a,b,c,const)   M_OP3 (0x11,0x48, a,b,c,const) /* c = a ^~ b  */
544
545 #define M_CMPBGE(a,b,c,const)   M_OP3 (0x10,0x0f, a,b,c,const)
546
547 #define M_FCMPUN(a,b,c)         M_FOP3 (0x16, 0x0a4, a,b,c)    /* unordered   */
548 #define M_FCMPLE(a,b,c)         M_FOP3 (0x16, 0x0a7, a,b,c)    /* c = a<=b    */
549
550 #define M_FCMPUNS(a,b,c)        M_FOP3 (0x16, 0x5a4, a,b,c)    /* unordered   */
551 #define M_FCMPLES(a,b,c)        M_FOP3 (0x16, 0x5a7, a,b,c)    /* c = a<=b    */
552
553 #define M_FBNEZ(fa,disp)        M_BRA (0x35,fa,disp)
554 #define M_FBLEZ(fa,disp)        M_BRA (0x33,fa,disp)
555
556 #define M_JMP_CO(a,b)           M_MEM (0x1a,a,b,0xc000)        /* call cosub  */
557
558 #endif /* _CODEGEN_H */
559
560
561 /*
562  * These are local overrides for various environment variables in Emacs.
563  * Please do not remove this and leave it at the end of the file, where
564  * Emacs will automagically detect them.
565  * ---------------------------------------------------------------------
566  * Local variables:
567  * mode: c
568  * indent-tabs-mode: t
569  * c-basic-offset: 4
570  * tab-width: 4
571  * End:
572  */