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