Threads on Alpha Linux
[cacao.git] / src / vm / jit / alpha / codegen.h
1 /* jit/alpha/codegen.h - code generation macros and definitions for alpha
2
3    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4    Institut f. Computersprachen, TU Wien
5    R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
6    M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
7    P. Tomsich, J. Wenninger
8
9    This file is part of CACAO.
10
11    This program is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License as
13    published by the Free Software Foundation; either version 2, or (at
14    your option) any later version.
15
16    This program is distributed in the hope that it will be useful, but
17    WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24    02111-1307, USA.
25
26    Contact: cacao@complang.tuwien.ac.at
27
28    Authors: Andreas Krall
29             Reinhard Grafl
30
31    $Id: codegen.h 1054 2004-05-05 21:08:55Z stefan $
32
33 */
34
35
36 #ifndef _CODEGEN_H
37 #define _CODEGEN_H
38
39 #include <ucontext.h>
40
41 #include "jit.h"
42
43
44 /* see also file calling.doc for explanation of calling conventions           */
45
46 /* preallocated registers *****************************************************/
47
48 /* integer registers */
49   
50 #define REG_RESULT      0    /* to deliver method results                     */ 
51
52 #define REG_RA          26   /* return address                                */
53 #define REG_PV          27   /* procedure vector, must be provided by caller  */
54 #define REG_METHODPTR   28   /* pointer to the place from where the procedure */
55                              /* vector has been fetched                       */
56 #define REG_ITMP1       25   /* temporary register                            */
57 #define REG_ITMP2       28   /* temporary register and method pointer         */
58 #define REG_ITMP3       29   /* temporary register                            */
59
60 #define REG_ITMP1_XPTR  25   /* exception pointer = temporary register 1      */
61 #define REG_ITMP2_XPC   28   /* exception pc = temporary register 2           */
62
63 #define REG_SP          30   /* stack pointer                                 */
64 #define REG_ZERO        31   /* allways zero                                  */
65
66 /* floating point registers */
67
68 #define REG_FRESULT     0    /* to deliver floating point method results      */ 
69 #define REG_FTMP1       28   /* temporary floating point register             */
70 #define REG_FTMP2       29   /* temporary floating point register             */
71 #define REG_FTMP3       30   /* temporary floating point register             */
72
73 #define REG_IFTMP       28   /* temporary integer and floating point register */
74
75
76 #define INT_SAV_CNT      7   /* number of int callee saved registers          */
77 #define INT_ARG_CNT      6   /* number of int argument registers              */
78
79 #define FLT_SAV_CNT      8   /* number of flt callee saved registers          */
80 #define FLT_ARG_CNT      6   /* number of flt argument registers              */
81
82
83 /* macros to create code ******************************************************/
84
85 #define REG   0
86 #define CONST 1
87
88 /* 3-address-operations: M_OP3
89       op ..... opcode
90       fu ..... function-number
91       a  ..... register number source 1
92       b  ..... register number or constant integer source 2
93       c  ..... register number destination
94       const .. switch to use b as constant integer 
95                  (REG means: use b as register number)
96                  (CONST means: use b as constant 8-bit-integer)
97 */      
98 #define M_OP3(op,fu,a,b,c,const) \
99         *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((b)<<(16-3*(const)))| \
100         ((const)<<12)|((fu)<<5)|((c)) )
101
102 /* 3-address-floating-point-operation: M_FOP3 
103      op .... opcode
104      fu .... function-number
105      a,b ... source floating-point registers
106      c ..... destination register
107 */ 
108 #define M_FOP3(op,fu,a,b,c) \
109         *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((b)<<16)|((fu)<<5)|(c) )
110
111 /* branch instructions: M_BRA 
112       op ..... opcode
113       a ...... register to be tested
114       disp ... relative address to be jumped to (divided by 4)
115 */
116 #define M_BRA(op,a,disp) \
117         *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((disp)&0x1fffff) )
118
119
120 /* memory operations: M_MEM
121       op ..... opcode
122       a ...... source/target register for memory access
123       b ...... base register
124       disp ... displacement (16 bit signed) to be added to b
125 */ 
126 #define M_MEM(op,a,b,disp) \
127         *(mcodeptr++) = ( (((s4)(op))<<26)|((a)<<21)|((b)<<16)|((disp)&0xffff) )
128
129
130 /* macros for all used commands (see an Alpha-manual for description) *********/ 
131
132 #define M_LDA(a,b,disp)         M_MEM (0x08,a,b,disp)           /* low const  */
133 #define M_LDAH(a,b,disp)        M_MEM (0x09,a,b,disp)           /* high const */
134 #define M_BLDU(a,b,disp)        M_MEM (0x0a,a,b,disp)           /*  8 load    */
135 #define M_SLDU(a,b,disp)        M_MEM (0x0c,a,b,disp)           /* 16 load    */
136 #define M_ILD(a,b,disp)         M_MEM (0x28,a,b,disp)           /* 32 load    */
137 #define M_LLD(a,b,disp)         M_MEM (0x29,a,b,disp)           /* 64 load    */
138 #define M_ALD(a,b,disp)         M_MEM (0x29,a,b,disp)           /* addr load  */
139 #define M_BST(a,b,disp)         M_MEM (0x0e,a,b,disp)           /*  8 store   */
140 #define M_SST(a,b,disp)         M_MEM (0x0d,a,b,disp)           /* 16 store   */
141 #define M_IST(a,b,disp)         M_MEM (0x2c,a,b,disp)           /* 32 store   */
142 #define M_LST(a,b,disp)         M_MEM (0x2d,a,b,disp)           /* 64 store   */
143 #define M_AST(a,b,disp)         M_MEM (0x2d,a,b,disp)           /* addr store */
144
145 #define M_BSEXT(b,c)            M_OP3 (0x1c,0x0,REG_ZERO,b,c,0) /*  8 signext */
146 #define M_SSEXT(b,c)            M_OP3 (0x1c,0x1,REG_ZERO,b,c,0) /* 16 signext */
147
148 #define M_BR(disp)              M_BRA (0x30,REG_ZERO,disp)      /* branch     */
149 #define M_BSR(ra,disp)          M_BRA (0x34,ra,disp)            /* branch sbr */
150 #define M_BEQZ(a,disp)          M_BRA (0x39,a,disp)             /* br a == 0  */
151 #define M_BLTZ(a,disp)          M_BRA (0x3a,a,disp)             /* br a <  0  */
152 #define M_BLEZ(a,disp)          M_BRA (0x3b,a,disp)             /* br a <= 0  */
153 #define M_BNEZ(a,disp)          M_BRA (0x3d,a,disp)             /* br a != 0  */
154 #define M_BGEZ(a,disp)          M_BRA (0x3e,a,disp)             /* br a >= 0  */
155 #define M_BGTZ(a,disp)          M_BRA (0x3f,a,disp)             /* br a >  0  */
156
157 #define M_JMP(a,b)              M_MEM (0x1a,a,b,0x0000)         /* jump       */
158 #define M_JSR(a,b)              M_MEM (0x1a,a,b,0x4000)         /* call sbr   */
159 #define M_RET(a,b)              M_MEM (0x1a,a,b,0x8000)         /* return     */
160
161 #define M_IADD(a,b,c)           M_OP3 (0x10,0x0,  a,b,c,0)      /* 32 add     */
162 #define M_LADD(a,b,c)           M_OP3 (0x10,0x20, a,b,c,0)      /* 64 add     */
163 #define M_ISUB(a,b,c)           M_OP3 (0x10,0x09, a,b,c,0)      /* 32 sub     */
164 #define M_LSUB(a,b,c)           M_OP3 (0x10,0x29, a,b,c,0)      /* 64 sub     */
165 #define M_IMUL(a,b,c)           M_OP3 (0x13,0x00, a,b,c,0)      /* 32 mul     */
166 #define M_LMUL(a,b,c)           M_OP3 (0x13,0x20, a,b,c,0)      /* 64 mul     */
167
168 #define M_IADD_IMM(a,b,c)       M_OP3 (0x10,0x0,  a,b,c,1)      /* 32 add     */
169 #define M_LADD_IMM(a,b,c)       M_OP3 (0x10,0x20, a,b,c,1)      /* 64 add     */
170 #define M_ISUB_IMM(a,b,c)       M_OP3 (0x10,0x09, a,b,c,1)      /* 32 sub     */
171 #define M_LSUB_IMM(a,b,c)       M_OP3 (0x10,0x29, a,b,c,1)      /* 64 sub     */
172 #define M_IMUL_IMM(a,b,c)       M_OP3 (0x13,0x00, a,b,c,1)      /* 32 mul     */
173 #define M_LMUL_IMM(a,b,c)       M_OP3 (0x13,0x20, a,b,c,1)      /* 64 mul     */
174
175 #define M_CMPEQ(a,b,c)          M_OP3 (0x10,0x2d, a,b,c,0)      /* c = a == b */
176 #define M_CMPLT(a,b,c)          M_OP3 (0x10,0x4d, a,b,c,0)      /* c = a <  b */
177 #define M_CMPLE(a,b,c)          M_OP3 (0x10,0x6d, a,b,c,0)      /* c = a <= b */
178
179 #define M_CMPULE(a,b,c)         M_OP3 (0x10,0x3d, a,b,c,0)      /* c = a <= b */
180 #define M_CMPULT(a,b,c)         M_OP3 (0x10,0x1d, a,b,c,0)      /* c = a <= b */
181
182 #define M_CMPEQ_IMM(a,b,c)      M_OP3 (0x10,0x2d, a,b,c,1)      /* c = a == b */
183 #define M_CMPLT_IMM(a,b,c)      M_OP3 (0x10,0x4d, a,b,c,1)      /* c = a <  b */
184 #define M_CMPLE_IMM(a,b,c)      M_OP3 (0x10,0x6d, a,b,c,1)      /* c = a <= b */
185
186 #define M_CMPULE_IMM(a,b,c)     M_OP3 (0x10,0x3d, a,b,c,1)      /* c = a <= b */
187 #define M_CMPULT_IMM(a,b,c)     M_OP3 (0x10,0x1d, a,b,c,1)      /* c = a <= b */
188
189 #define M_AND(a,b,c)            M_OP3 (0x11,0x00, a,b,c,0)      /* c = a &  b */
190 #define M_OR( a,b,c)            M_OP3 (0x11,0x20, a,b,c,0)      /* c = a |  b */
191 #define M_XOR(a,b,c)            M_OP3 (0x11,0x40, a,b,c,0)      /* c = a ^  b */
192
193 #define M_AND_IMM(a,b,c)        M_OP3 (0x11,0x00, a,b,c,1)      /* c = a &  b */
194 #define M_OR_IMM( a,b,c)        M_OP3 (0x11,0x20, a,b,c,1)      /* c = a |  b */
195 #define M_XOR_IMM(a,b,c)        M_OP3 (0x11,0x40, a,b,c,1)      /* c = a ^  b */
196
197 #define M_MOV(a,c)              M_OR (a,a,c)                    /* c = a      */
198 #define M_CLR(c)                M_OR (31,31,c)                  /* c = 0      */
199 #define M_NOP                   M_OR (31,31,31)                 /* ;          */
200
201 #define M_SLL(a,b,c)            M_OP3 (0x12,0x39, a,b,c,0)      /* c = a << b */
202 #define M_SRA(a,b,c)            M_OP3 (0x12,0x3c, a,b,c,0)      /* c = a >> b */
203 #define M_SRL(a,b,c)            M_OP3 (0x12,0x34, a,b,c,0)      /* c = a >>>b */
204
205 #define M_SLL_IMM(a,b,c)        M_OP3 (0x12,0x39, a,b,c,1)      /* c = a << b */
206 #define M_SRA_IMM(a,b,c)        M_OP3 (0x12,0x3c, a,b,c,1)      /* c = a >> b */
207 #define M_SRL_IMM(a,b,c)        M_OP3 (0x12,0x34, a,b,c,1)      /* c = a >>>b */
208
209 #define M_FLD(a,b,disp)         M_MEM (0x22,a,b,disp)           /* load flt   */
210 #define M_DLD(a,b,disp)         M_MEM (0x23,a,b,disp)           /* load dbl   */
211 #define M_FST(a,b,disp)         M_MEM (0x26,a,b,disp)           /* store flt  */
212 #define M_DST(a,b,disp)         M_MEM (0x27,a,b,disp)           /* store dbl  */
213
214 #define M_FADD(a,b,c)           M_FOP3 (0x16, 0x080, a,b,c)     /* flt add    */
215 #define M_DADD(a,b,c)           M_FOP3 (0x16, 0x0a0, a,b,c)     /* dbl add    */
216 #define M_FSUB(a,b,c)           M_FOP3 (0x16, 0x081, a,b,c)     /* flt sub    */
217 #define M_DSUB(a,b,c)           M_FOP3 (0x16, 0x0a1, a,b,c)     /* dbl sub    */
218 #define M_FMUL(a,b,c)           M_FOP3 (0x16, 0x082, a,b,c)     /* flt mul    */
219 #define M_DMUL(a,b,c)           M_FOP3 (0x16, 0x0a2, a,b,c)     /* dbl mul    */
220 #define M_FDIV(a,b,c)           M_FOP3 (0x16, 0x083, a,b,c)     /* flt div    */
221 #define M_DDIV(a,b,c)           M_FOP3 (0x16, 0x0a3, a,b,c)     /* dbl div    */
222
223 #define M_FADDS(a,b,c)          M_FOP3 (0x16, 0x580, a,b,c)     /* flt add    */
224 #define M_DADDS(a,b,c)          M_FOP3 (0x16, 0x5a0, a,b,c)     /* dbl add    */
225 #define M_FSUBS(a,b,c)          M_FOP3 (0x16, 0x581, a,b,c)     /* flt sub    */
226 #define M_DSUBS(a,b,c)          M_FOP3 (0x16, 0x5a1, a,b,c)     /* dbl sub    */
227 #define M_FMULS(a,b,c)          M_FOP3 (0x16, 0x582, a,b,c)     /* flt mul    */
228 #define M_DMULS(a,b,c)          M_FOP3 (0x16, 0x5a2, a,b,c)     /* dbl mul    */
229 #define M_FDIVS(a,b,c)          M_FOP3 (0x16, 0x583, a,b,c)     /* flt div    */
230 #define M_DDIVS(a,b,c)          M_FOP3 (0x16, 0x5a3, a,b,c)     /* dbl div    */
231
232 #define M_CVTDF(b,c)            M_FOP3 (0x16, 0x0ac, 31,b,c)    /* dbl2flt    */
233 #define M_CVTLF(b,c)            M_FOP3 (0x16, 0x0bc, 31,b,c)    /* long2flt   */
234 #define M_CVTLD(b,c)            M_FOP3 (0x16, 0x0be, 31,b,c)    /* long2dbl   */
235 #define M_CVTDL(b,c)            M_FOP3 (0x16, 0x1af, 31,b,c)    /* dbl2long   */
236 #define M_CVTDL_C(b,c)          M_FOP3 (0x16, 0x12f, 31,b,c)    /* dbl2long   */
237 #define M_CVTLI(b,c)            M_FOP3 (0x17, 0x130, 31,b,c)    /* long2int   */
238
239 #define M_CVTDFS(b,c)           M_FOP3 (0x16, 0x5ac, 31,b,c)    /* dbl2flt    */
240 #define M_CVTFDS(b,c)           M_FOP3 (0x16, 0x6ac, 31,b,c)    /* flt2dbl    */
241 #define M_CVTDLS(b,c)           M_FOP3 (0x16, 0x5af, 31,b,c)    /* dbl2long   */
242 #define M_CVTDL_CS(b,c)         M_FOP3 (0x16, 0x52f, 31,b,c)    /* dbl2long   */
243 #define M_CVTLIS(b,c)           M_FOP3 (0x17, 0x530, 31,b,c)    /* long2int   */
244
245 #define M_FCMPEQ(a,b,c)         M_FOP3 (0x16, 0x0a5, a,b,c)     /* c = a==b   */
246 #define M_FCMPLT(a,b,c)         M_FOP3 (0x16, 0x0a6, a,b,c)     /* c = a<b    */
247
248 #define M_FCMPEQS(a,b,c)        M_FOP3 (0x16, 0x5a5, a,b,c)     /* c = a==b   */
249 #define M_FCMPLTS(a,b,c)        M_FOP3 (0x16, 0x5a6, a,b,c)     /* c = a<b    */
250
251 #define M_FMOV(fa,fb)           M_FOP3 (0x17, 0x020, fa,fa,fb)  /* b = a      */
252 #define M_FMOVN(fa,fb)          M_FOP3 (0x17, 0x021, fa,fa,fb)  /* b = -a     */
253
254 #define M_FNOP                  M_FMOV (31,31)
255
256 #define M_FBEQZ(fa,disp)        M_BRA (0x31,fa,disp)            /* br a == 0.0*/
257
258 /* macros for special commands (see an Alpha-manual for description) **********/ 
259
260 #define M_TRAPB                 M_MEM (0x18,0,0,0x0000)        /* trap barrier*/
261
262 #define M_S4ADDL(a,b,c)         M_OP3 (0x10,0x02, a,b,c,0)     /* c = a*4 + b */
263 #define M_S4ADDQ(a,b,c)         M_OP3 (0x10,0x22, a,b,c,0)     /* c = a*4 + b */
264 #define M_S4SUBL(a,b,c)         M_OP3 (0x10,0x0b, a,b,c,0)     /* c = a*4 - b */
265 #define M_S4SUBQ(a,b,c)         M_OP3 (0x10,0x2b, a,b,c,0)     /* c = a*4 - b */
266 #define M_S8ADDL(a,b,c)         M_OP3 (0x10,0x12, a,b,c,0)     /* c = a*8 + b */
267 #define M_S8ADDQ(a,b,c)         M_OP3 (0x10,0x32, a,b,c,0)     /* c = a*8 + b */
268 #define M_S8SUBL(a,b,c)         M_OP3 (0x10,0x1b, a,b,c,0)     /* c = a*8 - b */
269 #define M_S8SUBQ(a,b,c)         M_OP3 (0x10,0x3b, a,b,c,0)     /* c = a*8 - b */
270 #define M_SAADDQ(a,b,c)         M_S8ADDQ(a,b,c)                /* c = a*8 + b */
271
272 #define M_S4ADDL_IMM(a,b,c)     M_OP3 (0x10,0x02, a,b,c,1)     /* c = a*4 + b */
273 #define M_S4ADDQ_IMM(a,b,c)     M_OP3 (0x10,0x22, a,b,c,1)     /* c = a*4 + b */
274 #define M_S4SUBL_IMM(a,b,c)     M_OP3 (0x10,0x0b, a,b,c,1)     /* c = a*4 - b */
275 #define M_S4SUBQ_IMM(a,b,c)     M_OP3 (0x10,0x2b, a,b,c,1)     /* c = a*4 - b */
276 #define M_S8ADDL_IMM(a,b,c)     M_OP3 (0x10,0x12, a,b,c,1)     /* c = a*8 + b */
277 #define M_S8ADDQ_IMM(a,b,c)     M_OP3 (0x10,0x32, a,b,c,1)     /* c = a*8 + b */
278 #define M_S8SUBL_IMM(a,b,c)     M_OP3 (0x10,0x1b, a,b,c,1)     /* c = a*8 - b */
279 #define M_S8SUBQ_IMM(a,b,c)     M_OP3 (0x10,0x3b, a,b,c,1)     /* c = a*8 - b */
280
281 #define M_LLD_U(a,b,disp)       M_MEM (0x0b,a,b,disp)          /* unalign ld  */
282 #define M_LST_U(a,b,disp)       M_MEM (0x0f,a,b,disp)          /* unalign st  */
283
284 #define M_ZAP(a,b,c)            M_OP3 (0x12,0x30, a,b,c,0)
285 #define M_ZAPNOT(a,b,c)         M_OP3 (0x12,0x31, a,b,c,0)
286
287 #define M_ZAP_IMM(a,b,c)        M_OP3 (0x12,0x30, a,b,c,1)
288 #define M_ZAPNOT_IMM(a,b,c)     M_OP3 (0x12,0x31, a,b,c,1)
289
290 #define M_BZEXT(a,b)            M_ZAPNOT_IMM(a, 0x01, b)       /*  8 zeroext  */
291 #define M_CZEXT(a,b)            M_ZAPNOT_IMM(a, 0x03, b)       /* 16 zeroext  */
292 #define M_IZEXT(a,b)            M_ZAPNOT_IMM(a, 0x0f, b)       /* 32 zeroext  */
293
294 #define M_EXTBL(a,b,c)          M_OP3 (0x12,0x06, a,b,c,0)
295 #define M_EXTWL(a,b,c)          M_OP3 (0x12,0x16, a,b,c,0)
296 #define M_EXTLL(a,b,c)          M_OP3 (0x12,0x26, a,b,c,0)
297 #define M_EXTQL(a,b,c)          M_OP3 (0x12,0x36, a,b,c,0)
298 #define M_EXTWH(a,b,c)          M_OP3 (0x12,0x5a, a,b,c,0)
299 #define M_EXTLH(a,b,c)          M_OP3 (0x12,0x6a, a,b,c,0)
300 #define M_EXTQH(a,b,c)          M_OP3 (0x12,0x7a, a,b,c,0)
301 #define M_INSBL(a,b,c)          M_OP3 (0x12,0x0b, a,b,c,0)
302 #define M_INSWL(a,b,c)          M_OP3 (0x12,0x1b, a,b,c,0)
303 #define M_INSLL(a,b,c)          M_OP3 (0x12,0x2b, a,b,c,0)
304 #define M_INSQL(a,b,c)          M_OP3 (0x12,0x3b, a,b,c,0)
305 #define M_INSWH(a,b,c)          M_OP3 (0x12,0x57, a,b,c,0)
306 #define M_INSLH(a,b,c)          M_OP3 (0x12,0x67, a,b,c,0)
307 #define M_INSQH(a,b,c)          M_OP3 (0x12,0x77, a,b,c,0)
308 #define M_MSKBL(a,b,c)          M_OP3 (0x12,0x02, a,b,c,0)
309 #define M_MSKWL(a,b,c)          M_OP3 (0x12,0x12, a,b,c,0)
310 #define M_MSKLL(a,b,c)          M_OP3 (0x12,0x22, a,b,c,0)
311 #define M_MSKQL(a,b,c)          M_OP3 (0x12,0x32, a,b,c,0)
312 #define M_MSKWH(a,b,c)          M_OP3 (0x12,0x52, a,b,c,0)
313 #define M_MSKLH(a,b,c)          M_OP3 (0x12,0x62, a,b,c,0)
314 #define M_MSKQH(a,b,c)          M_OP3 (0x12,0x72, a,b,c,0)
315
316 #define M_EXTBL_IMM(a,b,c)      M_OP3 (0x12,0x06, a,b,c,1)
317 #define M_EXTWL_IMM(a,b,c)      M_OP3 (0x12,0x16, a,b,c,1)
318 #define M_EXTLL_IMM(a,b,c)      M_OP3 (0x12,0x26, a,b,c,1)
319 #define M_EXTQL_IMM(a,b,c)      M_OP3 (0x12,0x36, a,b,c,1)
320 #define M_EXTWH_IMM(a,b,c)      M_OP3 (0x12,0x5a, a,b,c,1)
321 #define M_EXTLH_IMM(a,b,c)      M_OP3 (0x12,0x6a, a,b,c,1)
322 #define M_EXTQH_IMM(a,b,c)      M_OP3 (0x12,0x7a, a,b,c,1)
323 #define M_INSBL_IMM(a,b,c)      M_OP3 (0x12,0x0b, a,b,c,1)
324 #define M_INSWL_IMM(a,b,c)      M_OP3 (0x12,0x1b, a,b,c,1)
325 #define M_INSLL_IMM(a,b,c)      M_OP3 (0x12,0x2b, a,b,c,1)
326 #define M_INSQL_IMM(a,b,c)      M_OP3 (0x12,0x3b, a,b,c,1)
327 #define M_INSWH_IMM(a,b,c)      M_OP3 (0x12,0x57, a,b,c,1)
328 #define M_INSLH_IMM(a,b,c)      M_OP3 (0x12,0x67, a,b,c,1)
329 #define M_INSQH_IMM(a,b,c)      M_OP3 (0x12,0x77, a,b,c,1)
330 #define M_MSKBL_IMM(a,b,c)      M_OP3 (0x12,0x02, a,b,c,1)
331 #define M_MSKWL_IMM(a,b,c)      M_OP3 (0x12,0x12, a,b,c,1)
332 #define M_MSKLL_IMM(a,b,c)      M_OP3 (0x12,0x22, a,b,c,1)
333 #define M_MSKQL_IMM(a,b,c)      M_OP3 (0x12,0x32, a,b,c,1)
334 #define M_MSKWH_IMM(a,b,c)      M_OP3 (0x12,0x52, a,b,c,1)
335 #define M_MSKLH_IMM(a,b,c)      M_OP3 (0x12,0x62, a,b,c,1)
336 #define M_MSKQH_IMM(a,b,c)      M_OP3 (0x12,0x72, a,b,c,1)
337
338 #define M_UMULH(a,b,c)          M_OP3 (0x13,0x30, a,b,c,0)     /* 64 umulh    */
339
340 #define M_UMULH_IMM(a,b,c)      M_OP3 (0x13,0x30, a,b,c,1)     /* 64 umulh    */
341
342 #define M_CMOVEQ(a,b,c)         M_OP3 (0x11,0x24, a,b,c,0)     /* a==0 ? c=b  */
343 #define M_CMOVNE(a,b,c)         M_OP3 (0x11,0x26, a,b,c,0)     /* a!=0 ? c=b  */
344 #define M_CMOVLT(a,b,c)         M_OP3 (0x11,0x44, a,b,c,0)     /* a< 0 ? c=b  */
345 #define M_CMOVGE(a,b,c)         M_OP3 (0x11,0x46, a,b,c,0)     /* a>=0 ? c=b  */
346 #define M_CMOVLE(a,b,c)         M_OP3 (0x11,0x64, a,b,c,0)     /* a<=0 ? c=b  */
347 #define M_CMOVGT(a,b,c)         M_OP3 (0x11,0x66, a,b,c,0)     /* a> 0 ? c=b  */
348
349 #define M_CMOVEQ_IMM(a,b,c)     M_OP3 (0x11,0x24, a,b,c,1)     /* a==0 ? c=b  */
350 #define M_CMOVNE_IMM(a,b,c)     M_OP3 (0x11,0x26, a,b,c,1)     /* a!=0 ? c=b  */
351 #define M_CMOVLT_IMM(a,b,c)     M_OP3 (0x11,0x44, a,b,c,1)     /* a< 0 ? c=b  */
352 #define M_CMOVGE_IMM(a,b,c)     M_OP3 (0x11,0x46, a,b,c,1)     /* a>=0 ? c=b  */
353 #define M_CMOVLE_IMM(a,b,c)     M_OP3 (0x11,0x64, a,b,c,1)     /* a<=0 ? c=b  */
354 #define M_CMOVGT_IMM(a,b,c)     M_OP3 (0x11,0x66, a,b,c,1)     /* a> 0 ? c=b  */
355
356 /* macros for unused commands (see an Alpha-manual for description) ***********/ 
357
358 #define M_ANDNOT(a,b,c,const)   M_OP3 (0x11,0x08, a,b,c,const) /* c = a &~ b  */
359 #define M_ORNOT(a,b,c,const)    M_OP3 (0x11,0x28, a,b,c,const) /* c = a |~ b  */
360 #define M_XORNOT(a,b,c,const)   M_OP3 (0x11,0x48, a,b,c,const) /* c = a ^~ b  */
361
362 #define M_CMPBGE(a,b,c,const)   M_OP3 (0x10,0x0f, a,b,c,const)
363
364 #define M_FCMPUN(a,b,c)         M_FOP3 (0x16, 0x0a4, a,b,c)    /* unordered   */
365 #define M_FCMPLE(a,b,c)         M_FOP3 (0x16, 0x0a7, a,b,c)    /* c = a<=b    */
366
367 #define M_FCMPUNS(a,b,c)        M_FOP3 (0x16, 0x5a4, a,b,c)    /* unordered   */
368 #define M_FCMPLES(a,b,c)        M_FOP3 (0x16, 0x5a7, a,b,c)    /* c = a<=b    */
369
370 #define M_FBNEZ(fa,disp)        M_BRA (0x35,fa,disp)
371 #define M_FBLEZ(fa,disp)        M_BRA (0x33,fa,disp)
372
373 #define M_JMP_CO(a,b)           M_MEM (0x1a,a,b,0xc000)        /* call cosub  */
374
375
376 /* function gen_resolvebranch **************************************************
377
378         backpatches a branch instruction; Alpha branch instructions are very
379         regular, so it is only necessary to overwrite some fixed bits in the
380         instruction.
381
382         parameters: ip ... pointer to instruction after branch (void*)
383                     so ... offset of instruction after branch  (s4)
384                     to ... offset of branch target             (s4)
385
386 *******************************************************************************/
387
388 #define gen_resolvebranch(ip,so,to) ((s4*)(ip))[-1]|=((s4)(to)-(so))>>2&0x1fffff
389
390 #define SOFTNULLPTRCHECK       /* soft null pointer check supportet as option */
391
392 /* function prototypes */
393
394 void codegen_init();
395 void init_exceptions();
396 void codegen();
397 void codegen_close();
398 void dseg_display(s4 *s4ptr);
399 void thread_restartcriticalsection(ucontext_t*);
400
401 #endif /* _CODEGEN_H */
402
403
404 /*
405  * These are local overrides for various environment variables in Emacs.
406  * Please do not remove this and leave it at the end of the file, where
407  * Emacs will automagically detect them.
408  * ---------------------------------------------------------------------
409  * Local variables:
410  * mode: c
411  * indent-tabs-mode: t
412  * c-basic-offset: 4
413  * tab-width: 4
414  * End:
415  */