1 /* vm/jit/alpha/codegen.h - code generation macros and definitions for alpha
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Andreas Krall
30 $Id: codegen.h 2222 2005-04-05 17:38:04Z christian $
40 /* Macro for stack.c to set Argument Stackslots */
42 #define SET_ARG_STACKSLOTS { \
43 s4 stacksize; /* Stackoffset for spilled arg */ \
44 stacksize = (i < rd->intreg_argnum)? 0 : (i - rd->intreg_argnum); \
47 if (rd->ifmemuse < stacksize) \
48 rd->ifmemuse = stacksize; \
51 if (!(copy->flags & SAVEDVAR)) { \
53 copy->varkind = ARGVAR; \
54 if (IS_FLT_DBL_TYPE(copy->type)) { \
55 if (i < rd->fltreg_argnum) { \
57 copy->regoff = rd->argfltregs[i]; \
59 copy->flags = INMEMORY; \
60 copy->regoff = --stacksize; \
62 } else { /* int arg */ \
63 if (i < rd->intreg_argnum) { \
65 copy->regoff = rd->argintregs[i]; \
67 copy->flags = INMEMORY; \
68 copy->regoff = --stacksize; \
76 /* additional functions and macros to generate code ***************************/
78 /* #define BlockPtrOfPC(pc) block+block_index[pc] */
79 #define BlockPtrOfPC(pc) ((basicblock *) iptr->target)
83 #define COUNT_SPILLS count_spills++
89 /* gen_nullptr_check(objreg) */
91 #define gen_nullptr_check(objreg) \
93 M_BEQZ((objreg), 0); \
94 codegen_addxnullrefs(cd, mcodeptr); \
97 #define gen_bound_check \
99 M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
100 M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
101 M_BEQZ(REG_ITMP3, 0);\
102 codegen_addxboundrefs(cd, mcodeptr, s2); \
106 /* MCODECHECK(icnt) */
108 #define MCODECHECK(icnt) \
109 if ((mcodeptr + (icnt)) > cd->mcodeend) \
110 mcodeptr = codegen_increase(cd, (u1 *) mcodeptr)
113 generates an integer-move from register a to b.
114 if a and b are the same int-register, no code will be generated.
117 #define M_INTMOVE(a,b) if (a != b) { M_MOV(a, b); }
121 generates a floating-point-move from register a to b.
122 if a and b are the same float-register, no code will be generated
125 #define M_FLTMOVE(a,b) if (a != b) { M_FMOV(a, b); }
129 this function generates code to fetch data from a pseudo-register
130 into a real register.
131 If the pseudo-register has actually been assigned to a real
132 register, no code will be emitted, since following operations
133 can use this register directly.
135 v: pseudoregister to be fetched from
136 tempregnum: temporary register to be used if v is actually spilled to ram
138 return: the register number, where the operand can be found after
139 fetching (this wil be either tempregnum or the register
140 number allready given to v)
143 #define var_to_reg_int(regnr,v,tempnr) { \
144 if ((v)->flags & INMEMORY) { \
146 M_LLD(tempnr, REG_SP, 8 * (v)->regoff); \
148 } else regnr = (v)->regoff; \
152 #define var_to_reg_flt(regnr,v,tempnr) { \
153 if ((v)->flags & INMEMORY) { \
155 M_DLD(tempnr, REG_SP, 8 * (v)->regoff); \
157 } else regnr = (v)->regoff; \
161 /* store_reg_to_var_xxx:
162 This function generates the code to store the result of an operation
163 back into a spilled pseudo-variable.
164 If the pseudo-variable has not been spilled in the first place, this
165 function will generate nothing.
167 v ............ Pseudovariable
168 tempregnum ... Number of the temporary registers as returned by
172 #define store_reg_to_var_int(sptr, tempregnum) { \
173 if ((sptr)->flags & INMEMORY) { \
175 M_LST(tempregnum, REG_SP, 8 * (sptr)->regoff); \
179 #define store_reg_to_var_flt(sptr, tempregnum) { \
180 if ((sptr)->flags & INMEMORY) { \
182 M_DST(tempregnum, REG_SP, 8 * (sptr)->regoff); \
187 #define M_COPY(from,to) \
188 d = reg_of_var(rd, to, REG_IFTMP); \
189 if ((from->regoff != to->regoff) || \
190 ((from->flags ^ to->flags) & INMEMORY)) { \
191 if (IS_FLT_DBL_TYPE(from->type)) { \
192 var_to_reg_flt(s1, from, d); \
194 store_reg_to_var_flt(to, d); \
197 var_to_reg_int(s1, from, d); \
199 store_reg_to_var_int(to, d); \
204 #define ICONST(r,c) \
205 if ((c) >= -32768 && (c) <= 32767) { \
206 M_LDA((r), REG_ZERO, c); \
208 a = dseg_adds4(cd, (c)); \
209 M_ILD((r), REG_PV, a); \
212 #define LCONST(r,c) \
213 if ((c) >= -32768 && (c) <= 32767) { \
214 M_LDA((r), REG_ZERO, (c)); \
216 a = dseg_adds8(cd, (c)); \
217 M_LLD((r), REG_PV, a); \
221 /* macros to create code ******************************************************/
226 /* 3-address-operations: M_OP3
228 fu ..... function-number
229 a ..... register number source 1
230 b ..... register number or constant integer source 2
231 c ..... register number destination
232 const .. switch to use b as constant integer
233 (REG means: use b as register number)
234 (CONST means: use b as constant 8-bit-integer)
236 #define M_OP3(op,fu,a,b,c,const) \
237 *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((b)<<(16-3*(const)))| \
238 ((const)<<12)|((fu)<<5)|((c)) )
240 /* 3-address-floating-point-operation: M_FOP3
242 fu .... function-number
243 a,b ... source floating-point registers
244 c ..... destination register
246 #define M_FOP3(op,fu,a,b,c) \
247 *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((b)<<16)|((fu)<<5)|(c) )
249 /* branch instructions: M_BRA
251 a ...... register to be tested
252 disp ... relative address to be jumped to (divided by 4)
254 #define M_BRA(op,a,disp) \
255 *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((disp)&0x1fffff) )
258 /* memory operations: M_MEM
260 a ...... source/target register for memory access
261 b ...... base register
262 disp ... displacement (16 bit signed) to be added to b
264 #define M_MEM(op,a,b,disp) \
265 *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((b)<<16)|((disp)&0xffff) )
268 /* macros for all used commands (see an Alpha-manual for description) *********/
270 #define M_LDA(a,b,disp) M_MEM (0x08,a,b,disp) /* low const */
271 #define M_LDAH(a,b,disp) M_MEM (0x09,a,b,disp) /* high const */
272 #define M_BLDU(a,b,disp) M_MEM (0x0a,a,b,disp) /* 8 load */
273 #define M_SLDU(a,b,disp) M_MEM (0x0c,a,b,disp) /* 16 load */
274 #define M_ILD(a,b,disp) M_MEM (0x28,a,b,disp) /* 32 load */
275 #define M_LLD(a,b,disp) M_MEM (0x29,a,b,disp) /* 64 load */
276 #define M_ALD(a,b,disp) M_MEM (0x29,a,b,disp) /* addr load */
277 #define M_BST(a,b,disp) M_MEM (0x0e,a,b,disp) /* 8 store */
278 #define M_SST(a,b,disp) M_MEM (0x0d,a,b,disp) /* 16 store */
279 #define M_IST(a,b,disp) M_MEM (0x2c,a,b,disp) /* 32 store */
280 #define M_LST(a,b,disp) M_MEM (0x2d,a,b,disp) /* 64 store */
281 #define M_AST(a,b,disp) M_MEM (0x2d,a,b,disp) /* addr store */
283 #define M_BSEXT(b,c) M_OP3 (0x1c,0x0,REG_ZERO,b,c,0) /* 8 signext */
284 #define M_SSEXT(b,c) M_OP3 (0x1c,0x1,REG_ZERO,b,c,0) /* 16 signext */
286 #define M_BR(disp) M_BRA (0x30,REG_ZERO,disp) /* branch */
287 #define M_BSR(ra,disp) M_BRA (0x34,ra,disp) /* branch sbr */
288 #define M_BEQZ(a,disp) M_BRA (0x39,a,disp) /* br a == 0 */
289 #define M_BLTZ(a,disp) M_BRA (0x3a,a,disp) /* br a < 0 */
290 #define M_BLEZ(a,disp) M_BRA (0x3b,a,disp) /* br a <= 0 */
291 #define M_BNEZ(a,disp) M_BRA (0x3d,a,disp) /* br a != 0 */
292 #define M_BGEZ(a,disp) M_BRA (0x3e,a,disp) /* br a >= 0 */
293 #define M_BGTZ(a,disp) M_BRA (0x3f,a,disp) /* br a > 0 */
295 #define M_JMP(a,b) M_MEM (0x1a,a,b,0x0000) /* jump */
296 #define M_JSR(a,b) M_MEM (0x1a,a,b,0x4000) /* call sbr */
297 #define M_RET(a,b) M_MEM (0x1a,a,b,0x8000) /* return */
299 #define M_IADD(a,b,c) M_OP3 (0x10,0x0, a,b,c,0) /* 32 add */
300 #define M_LADD(a,b,c) M_OP3 (0x10,0x20, a,b,c,0) /* 64 add */
301 #define M_ISUB(a,b,c) M_OP3 (0x10,0x09, a,b,c,0) /* 32 sub */
302 #define M_LSUB(a,b,c) M_OP3 (0x10,0x29, a,b,c,0) /* 64 sub */
303 #define M_IMUL(a,b,c) M_OP3 (0x13,0x00, a,b,c,0) /* 32 mul */
304 #define M_LMUL(a,b,c) M_OP3 (0x13,0x20, a,b,c,0) /* 64 mul */
306 #define M_IADD_IMM(a,b,c) M_OP3 (0x10,0x0, a,b,c,1) /* 32 add */
307 #define M_LADD_IMM(a,b,c) M_OP3 (0x10,0x20, a,b,c,1) /* 64 add */
308 #define M_ISUB_IMM(a,b,c) M_OP3 (0x10,0x09, a,b,c,1) /* 32 sub */
309 #define M_LSUB_IMM(a,b,c) M_OP3 (0x10,0x29, a,b,c,1) /* 64 sub */
310 #define M_IMUL_IMM(a,b,c) M_OP3 (0x13,0x00, a,b,c,1) /* 32 mul */
311 #define M_LMUL_IMM(a,b,c) M_OP3 (0x13,0x20, a,b,c,1) /* 64 mul */
313 #define M_CMPEQ(a,b,c) M_OP3 (0x10,0x2d, a,b,c,0) /* c = a == b */
314 #define M_CMPLT(a,b,c) M_OP3 (0x10,0x4d, a,b,c,0) /* c = a < b */
315 #define M_CMPLE(a,b,c) M_OP3 (0x10,0x6d, a,b,c,0) /* c = a <= b */
317 #define M_CMPULE(a,b,c) M_OP3 (0x10,0x3d, a,b,c,0) /* c = a <= b */
318 #define M_CMPULT(a,b,c) M_OP3 (0x10,0x1d, a,b,c,0) /* c = a <= b */
320 #define M_CMPEQ_IMM(a,b,c) M_OP3 (0x10,0x2d, a,b,c,1) /* c = a == b */
321 #define M_CMPLT_IMM(a,b,c) M_OP3 (0x10,0x4d, a,b,c,1) /* c = a < b */
322 #define M_CMPLE_IMM(a,b,c) M_OP3 (0x10,0x6d, a,b,c,1) /* c = a <= b */
324 #define M_CMPULE_IMM(a,b,c) M_OP3 (0x10,0x3d, a,b,c,1) /* c = a <= b */
325 #define M_CMPULT_IMM(a,b,c) M_OP3 (0x10,0x1d, a,b,c,1) /* c = a <= b */
327 #define M_AND(a,b,c) M_OP3 (0x11,0x00, a,b,c,0) /* c = a & b */
328 #define M_OR( a,b,c) M_OP3 (0x11,0x20, a,b,c,0) /* c = a | b */
329 #define M_XOR(a,b,c) M_OP3 (0x11,0x40, a,b,c,0) /* c = a ^ b */
331 #define M_AND_IMM(a,b,c) M_OP3 (0x11,0x00, a,b,c,1) /* c = a & b */
332 #define M_OR_IMM( a,b,c) M_OP3 (0x11,0x20, a,b,c,1) /* c = a | b */
333 #define M_XOR_IMM(a,b,c) M_OP3 (0x11,0x40, a,b,c,1) /* c = a ^ b */
335 #define M_MOV(a,c) M_OR (a,a,c) /* c = a */
336 #define M_CLR(c) M_OR (31,31,c) /* c = 0 */
337 #define M_NOP M_OR (31,31,31) /* ; */
339 #define M_SLL(a,b,c) M_OP3 (0x12,0x39, a,b,c,0) /* c = a << b */
340 #define M_SRA(a,b,c) M_OP3 (0x12,0x3c, a,b,c,0) /* c = a >> b */
341 #define M_SRL(a,b,c) M_OP3 (0x12,0x34, a,b,c,0) /* c = a >>>b */
343 #define M_SLL_IMM(a,b,c) M_OP3 (0x12,0x39, a,b,c,1) /* c = a << b */
344 #define M_SRA_IMM(a,b,c) M_OP3 (0x12,0x3c, a,b,c,1) /* c = a >> b */
345 #define M_SRL_IMM(a,b,c) M_OP3 (0x12,0x34, a,b,c,1) /* c = a >>>b */
347 #define M_FLD(a,b,disp) M_MEM (0x22,a,b,disp) /* load flt */
348 #define M_DLD(a,b,disp) M_MEM (0x23,a,b,disp) /* load dbl */
349 #define M_FST(a,b,disp) M_MEM (0x26,a,b,disp) /* store flt */
350 #define M_DST(a,b,disp) M_MEM (0x27,a,b,disp) /* store dbl */
352 #define M_FADD(a,b,c) M_FOP3 (0x16, 0x080, a,b,c) /* flt add */
353 #define M_DADD(a,b,c) M_FOP3 (0x16, 0x0a0, a,b,c) /* dbl add */
354 #define M_FSUB(a,b,c) M_FOP3 (0x16, 0x081, a,b,c) /* flt sub */
355 #define M_DSUB(a,b,c) M_FOP3 (0x16, 0x0a1, a,b,c) /* dbl sub */
356 #define M_FMUL(a,b,c) M_FOP3 (0x16, 0x082, a,b,c) /* flt mul */
357 #define M_DMUL(a,b,c) M_FOP3 (0x16, 0x0a2, a,b,c) /* dbl mul */
358 #define M_FDIV(a,b,c) M_FOP3 (0x16, 0x083, a,b,c) /* flt div */
359 #define M_DDIV(a,b,c) M_FOP3 (0x16, 0x0a3, a,b,c) /* dbl div */
361 #define M_FADDS(a,b,c) M_FOP3 (0x16, 0x580, a,b,c) /* flt add */
362 #define M_DADDS(a,b,c) M_FOP3 (0x16, 0x5a0, a,b,c) /* dbl add */
363 #define M_FSUBS(a,b,c) M_FOP3 (0x16, 0x581, a,b,c) /* flt sub */
364 #define M_DSUBS(a,b,c) M_FOP3 (0x16, 0x5a1, a,b,c) /* dbl sub */
365 #define M_FMULS(a,b,c) M_FOP3 (0x16, 0x582, a,b,c) /* flt mul */
366 #define M_DMULS(a,b,c) M_FOP3 (0x16, 0x5a2, a,b,c) /* dbl mul */
367 #define M_FDIVS(a,b,c) M_FOP3 (0x16, 0x583, a,b,c) /* flt div */
368 #define M_DDIVS(a,b,c) M_FOP3 (0x16, 0x5a3, a,b,c) /* dbl div */
370 #define M_CVTDF(b,c) M_FOP3 (0x16, 0x0ac, 31,b,c) /* dbl2flt */
371 #define M_CVTLF(b,c) M_FOP3 (0x16, 0x0bc, 31,b,c) /* long2flt */
372 #define M_CVTLD(b,c) M_FOP3 (0x16, 0x0be, 31,b,c) /* long2dbl */
373 #define M_CVTDL(b,c) M_FOP3 (0x16, 0x1af, 31,b,c) /* dbl2long */
374 #define M_CVTDL_C(b,c) M_FOP3 (0x16, 0x12f, 31,b,c) /* dbl2long */
375 #define M_CVTLI(b,c) M_FOP3 (0x17, 0x130, 31,b,c) /* long2int */
377 #define M_CVTDFS(b,c) M_FOP3 (0x16, 0x5ac, 31,b,c) /* dbl2flt */
378 #define M_CVTFDS(b,c) M_FOP3 (0x16, 0x6ac, 31,b,c) /* flt2dbl */
379 #define M_CVTDLS(b,c) M_FOP3 (0x16, 0x5af, 31,b,c) /* dbl2long */
380 #define M_CVTDL_CS(b,c) M_FOP3 (0x16, 0x52f, 31,b,c) /* dbl2long */
381 #define M_CVTLIS(b,c) M_FOP3 (0x17, 0x530, 31,b,c) /* long2int */
383 #define M_FCMPEQ(a,b,c) M_FOP3 (0x16, 0x0a5, a,b,c) /* c = a==b */
384 #define M_FCMPLT(a,b,c) M_FOP3 (0x16, 0x0a6, a,b,c) /* c = a<b */
386 #define M_FCMPEQS(a,b,c) M_FOP3 (0x16, 0x5a5, a,b,c) /* c = a==b */
387 #define M_FCMPLTS(a,b,c) M_FOP3 (0x16, 0x5a6, a,b,c) /* c = a<b */
389 #define M_FMOV(fa,fb) M_FOP3 (0x17, 0x020, fa,fa,fb) /* b = a */
390 #define M_FMOVN(fa,fb) M_FOP3 (0x17, 0x021, fa,fa,fb) /* b = -a */
392 #define M_FNOP M_FMOV (31,31)
394 #define M_FBEQZ(fa,disp) M_BRA (0x31,fa,disp) /* br a == 0.0*/
396 /* macros for special commands (see an Alpha-manual for description) **********/
398 #define M_TRAPB M_MEM (0x18,0,0,0x0000) /* trap barrier*/
400 #define M_S4ADDL(a,b,c) M_OP3 (0x10,0x02, a,b,c,0) /* c = a*4 + b */
401 #define M_S4ADDQ(a,b,c) M_OP3 (0x10,0x22, a,b,c,0) /* c = a*4 + b */
402 #define M_S4SUBL(a,b,c) M_OP3 (0x10,0x0b, a,b,c,0) /* c = a*4 - b */
403 #define M_S4SUBQ(a,b,c) M_OP3 (0x10,0x2b, a,b,c,0) /* c = a*4 - b */
404 #define M_S8ADDL(a,b,c) M_OP3 (0x10,0x12, a,b,c,0) /* c = a*8 + b */
405 #define M_S8ADDQ(a,b,c) M_OP3 (0x10,0x32, a,b,c,0) /* c = a*8 + b */
406 #define M_S8SUBL(a,b,c) M_OP3 (0x10,0x1b, a,b,c,0) /* c = a*8 - b */
407 #define M_S8SUBQ(a,b,c) M_OP3 (0x10,0x3b, a,b,c,0) /* c = a*8 - b */
408 #define M_SAADDQ(a,b,c) M_S8ADDQ(a,b,c) /* c = a*8 + b */
410 #define M_S4ADDL_IMM(a,b,c) M_OP3 (0x10,0x02, a,b,c,1) /* c = a*4 + b */
411 #define M_S4ADDQ_IMM(a,b,c) M_OP3 (0x10,0x22, a,b,c,1) /* c = a*4 + b */
412 #define M_S4SUBL_IMM(a,b,c) M_OP3 (0x10,0x0b, a,b,c,1) /* c = a*4 - b */
413 #define M_S4SUBQ_IMM(a,b,c) M_OP3 (0x10,0x2b, a,b,c,1) /* c = a*4 - b */
414 #define M_S8ADDL_IMM(a,b,c) M_OP3 (0x10,0x12, a,b,c,1) /* c = a*8 + b */
415 #define M_S8ADDQ_IMM(a,b,c) M_OP3 (0x10,0x32, a,b,c,1) /* c = a*8 + b */
416 #define M_S8SUBL_IMM(a,b,c) M_OP3 (0x10,0x1b, a,b,c,1) /* c = a*8 - b */
417 #define M_S8SUBQ_IMM(a,b,c) M_OP3 (0x10,0x3b, a,b,c,1) /* c = a*8 - b */
419 #define M_LLD_U(a,b,disp) M_MEM (0x0b,a,b,disp) /* unalign ld */
420 #define M_LST_U(a,b,disp) M_MEM (0x0f,a,b,disp) /* unalign st */
422 #define M_ZAP(a,b,c) M_OP3 (0x12,0x30, a,b,c,0)
423 #define M_ZAPNOT(a,b,c) M_OP3 (0x12,0x31, a,b,c,0)
425 #define M_ZAP_IMM(a,b,c) M_OP3 (0x12,0x30, a,b,c,1)
426 #define M_ZAPNOT_IMM(a,b,c) M_OP3 (0x12,0x31, a,b,c,1)
428 #define M_BZEXT(a,b) M_ZAPNOT_IMM(a, 0x01, b) /* 8 zeroext */
429 #define M_CZEXT(a,b) M_ZAPNOT_IMM(a, 0x03, b) /* 16 zeroext */
430 #define M_IZEXT(a,b) M_ZAPNOT_IMM(a, 0x0f, b) /* 32 zeroext */
432 #define M_EXTBL(a,b,c) M_OP3 (0x12,0x06, a,b,c,0)
433 #define M_EXTWL(a,b,c) M_OP3 (0x12,0x16, a,b,c,0)
434 #define M_EXTLL(a,b,c) M_OP3 (0x12,0x26, a,b,c,0)
435 #define M_EXTQL(a,b,c) M_OP3 (0x12,0x36, a,b,c,0)
436 #define M_EXTWH(a,b,c) M_OP3 (0x12,0x5a, a,b,c,0)
437 #define M_EXTLH(a,b,c) M_OP3 (0x12,0x6a, a,b,c,0)
438 #define M_EXTQH(a,b,c) M_OP3 (0x12,0x7a, a,b,c,0)
439 #define M_INSBL(a,b,c) M_OP3 (0x12,0x0b, a,b,c,0)
440 #define M_INSWL(a,b,c) M_OP3 (0x12,0x1b, a,b,c,0)
441 #define M_INSLL(a,b,c) M_OP3 (0x12,0x2b, a,b,c,0)
442 #define M_INSQL(a,b,c) M_OP3 (0x12,0x3b, a,b,c,0)
443 #define M_INSWH(a,b,c) M_OP3 (0x12,0x57, a,b,c,0)
444 #define M_INSLH(a,b,c) M_OP3 (0x12,0x67, a,b,c,0)
445 #define M_INSQH(a,b,c) M_OP3 (0x12,0x77, a,b,c,0)
446 #define M_MSKBL(a,b,c) M_OP3 (0x12,0x02, a,b,c,0)
447 #define M_MSKWL(a,b,c) M_OP3 (0x12,0x12, a,b,c,0)
448 #define M_MSKLL(a,b,c) M_OP3 (0x12,0x22, a,b,c,0)
449 #define M_MSKQL(a,b,c) M_OP3 (0x12,0x32, a,b,c,0)
450 #define M_MSKWH(a,b,c) M_OP3 (0x12,0x52, a,b,c,0)
451 #define M_MSKLH(a,b,c) M_OP3 (0x12,0x62, a,b,c,0)
452 #define M_MSKQH(a,b,c) M_OP3 (0x12,0x72, a,b,c,0)
454 #define M_EXTBL_IMM(a,b,c) M_OP3 (0x12,0x06, a,b,c,1)
455 #define M_EXTWL_IMM(a,b,c) M_OP3 (0x12,0x16, a,b,c,1)
456 #define M_EXTLL_IMM(a,b,c) M_OP3 (0x12,0x26, a,b,c,1)
457 #define M_EXTQL_IMM(a,b,c) M_OP3 (0x12,0x36, a,b,c,1)
458 #define M_EXTWH_IMM(a,b,c) M_OP3 (0x12,0x5a, a,b,c,1)
459 #define M_EXTLH_IMM(a,b,c) M_OP3 (0x12,0x6a, a,b,c,1)
460 #define M_EXTQH_IMM(a,b,c) M_OP3 (0x12,0x7a, a,b,c,1)
461 #define M_INSBL_IMM(a,b,c) M_OP3 (0x12,0x0b, a,b,c,1)
462 #define M_INSWL_IMM(a,b,c) M_OP3 (0x12,0x1b, a,b,c,1)
463 #define M_INSLL_IMM(a,b,c) M_OP3 (0x12,0x2b, a,b,c,1)
464 #define M_INSQL_IMM(a,b,c) M_OP3 (0x12,0x3b, a,b,c,1)
465 #define M_INSWH_IMM(a,b,c) M_OP3 (0x12,0x57, a,b,c,1)
466 #define M_INSLH_IMM(a,b,c) M_OP3 (0x12,0x67, a,b,c,1)
467 #define M_INSQH_IMM(a,b,c) M_OP3 (0x12,0x77, a,b,c,1)
468 #define M_MSKBL_IMM(a,b,c) M_OP3 (0x12,0x02, a,b,c,1)
469 #define M_MSKWL_IMM(a,b,c) M_OP3 (0x12,0x12, a,b,c,1)
470 #define M_MSKLL_IMM(a,b,c) M_OP3 (0x12,0x22, a,b,c,1)
471 #define M_MSKQL_IMM(a,b,c) M_OP3 (0x12,0x32, a,b,c,1)
472 #define M_MSKWH_IMM(a,b,c) M_OP3 (0x12,0x52, a,b,c,1)
473 #define M_MSKLH_IMM(a,b,c) M_OP3 (0x12,0x62, a,b,c,1)
474 #define M_MSKQH_IMM(a,b,c) M_OP3 (0x12,0x72, a,b,c,1)
476 #define M_UMULH(a,b,c) M_OP3 (0x13,0x30, a,b,c,0) /* 64 umulh */
478 #define M_UMULH_IMM(a,b,c) M_OP3 (0x13,0x30, a,b,c,1) /* 64 umulh */
480 #define M_CMOVEQ(a,b,c) M_OP3 (0x11,0x24, a,b,c,0) /* a==0 ? c=b */
481 #define M_CMOVNE(a,b,c) M_OP3 (0x11,0x26, a,b,c,0) /* a!=0 ? c=b */
482 #define M_CMOVLT(a,b,c) M_OP3 (0x11,0x44, a,b,c,0) /* a< 0 ? c=b */
483 #define M_CMOVGE(a,b,c) M_OP3 (0x11,0x46, a,b,c,0) /* a>=0 ? c=b */
484 #define M_CMOVLE(a,b,c) M_OP3 (0x11,0x64, a,b,c,0) /* a<=0 ? c=b */
485 #define M_CMOVGT(a,b,c) M_OP3 (0x11,0x66, a,b,c,0) /* a> 0 ? c=b */
487 #define M_CMOVEQ_IMM(a,b,c) M_OP3 (0x11,0x24, a,b,c,1) /* a==0 ? c=b */
488 #define M_CMOVNE_IMM(a,b,c) M_OP3 (0x11,0x26, a,b,c,1) /* a!=0 ? c=b */
489 #define M_CMOVLT_IMM(a,b,c) M_OP3 (0x11,0x44, a,b,c,1) /* a< 0 ? c=b */
490 #define M_CMOVGE_IMM(a,b,c) M_OP3 (0x11,0x46, a,b,c,1) /* a>=0 ? c=b */
491 #define M_CMOVLE_IMM(a,b,c) M_OP3 (0x11,0x64, a,b,c,1) /* a<=0 ? c=b */
492 #define M_CMOVGT_IMM(a,b,c) M_OP3 (0x11,0x66, a,b,c,1) /* a> 0 ? c=b */
494 /* macros for unused commands (see an Alpha-manual for description) ***********/
496 #define M_ANDNOT(a,b,c,const) M_OP3 (0x11,0x08, a,b,c,const) /* c = a &~ b */
497 #define M_ORNOT(a,b,c,const) M_OP3 (0x11,0x28, a,b,c,const) /* c = a |~ b */
498 #define M_XORNOT(a,b,c,const) M_OP3 (0x11,0x48, a,b,c,const) /* c = a ^~ b */
500 #define M_CMPBGE(a,b,c,const) M_OP3 (0x10,0x0f, a,b,c,const)
502 #define M_FCMPUN(a,b,c) M_FOP3 (0x16, 0x0a4, a,b,c) /* unordered */
503 #define M_FCMPLE(a,b,c) M_FOP3 (0x16, 0x0a7, a,b,c) /* c = a<=b */
505 #define M_FCMPUNS(a,b,c) M_FOP3 (0x16, 0x5a4, a,b,c) /* unordered */
506 #define M_FCMPLES(a,b,c) M_FOP3 (0x16, 0x5a7, a,b,c) /* c = a<=b */
508 #define M_FBNEZ(fa,disp) M_BRA (0x35,fa,disp)
509 #define M_FBLEZ(fa,disp) M_BRA (0x33,fa,disp)
511 #define M_JMP_CO(a,b) M_MEM (0x1a,a,b,0xc000) /* call cosub */
514 /* function gen_resolvebranch **************************************************
516 backpatches a branch instruction; Alpha branch instructions are very
517 regular, so it is only necessary to overwrite some fixed bits in the
520 parameters: ip ... pointer to instruction after branch (void*)
521 so ... offset of instruction after branch (s4)
522 to ... offset of branch target (s4)
524 *******************************************************************************/
526 #define gen_resolvebranch(ip,so,to) \
527 ((s4 *) (ip))[-1] |= ((s4) (to) - (so)) >> 2 & 0x1fffff
530 /* function prototypes */
532 void thread_restartcriticalsection(ucontext_t*);
534 #endif /* _CODEGEN_H */
538 * These are local overrides for various environment variables in Emacs.
539 * Please do not remove this and leave it at the end of the file, where
540 * Emacs will automagically detect them.
541 * ---------------------------------------------------------------------
544 * indent-tabs-mode: t