2 * Copyright (C) 2012-2019 Free Software Foundation, Inc.
4 * This file is part of GNU lightning.
6 * GNU lightning is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 3, or (at your option)
11 * GNU lightning is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
17 * Paulo Cesar Pereira de Andrade
22 #if __BYTE_ORDER == __LITTLE_ENDIAN
23 struct { jit_uint32_t _:26; jit_uint32_t b : 6; } hc;
24 struct { jit_uint32_t _:21; jit_uint32_t b : 5; } rs;
25 struct { jit_uint32_t _:21; jit_uint32_t b : 5; } fm;
26 struct { jit_uint32_t _:16; jit_uint32_t b : 5; } rt;
27 struct { jit_uint32_t _:16; jit_uint32_t b : 5; } ft;
28 struct { jit_uint32_t _:11; jit_uint32_t b : 5; } rd;
29 struct { jit_uint32_t _:11; jit_uint32_t b : 5; } fs;
30 struct { jit_uint32_t _: 6; jit_uint32_t b : 5; } ic;
31 struct { jit_uint32_t _: 6; jit_uint32_t b : 5; } fd;
32 struct { jit_uint32_t _: 6; jit_uint32_t b : 10; } tr;
33 struct { jit_uint32_t _: 6; jit_uint32_t b : 20; } br;
34 struct { jit_uint32_t b : 6; } tc;
35 struct { jit_uint32_t b : 11; } cc;
36 struct { jit_uint32_t b : 16; } is;
37 struct { jit_uint32_t b : 26; } ii;
39 struct { jit_uint32_t b : 6; } hc;
40 struct { jit_uint32_t _: 6; jit_uint32_t b : 5; } rs;
41 struct { jit_uint32_t _: 6; jit_uint32_t b : 5; } fm;
42 struct { jit_uint32_t _:11; jit_uint32_t b : 5; } rt;
43 struct { jit_uint32_t _:11; jit_uint32_t b : 5; } ft;
44 struct { jit_uint32_t _:16; jit_uint32_t b : 5; } rd;
45 struct { jit_uint32_t _:16; jit_uint32_t b : 5; } fs;
46 struct { jit_uint32_t _:21; jit_uint32_t b : 5; } ic;
47 struct { jit_uint32_t _:21; jit_uint32_t b : 5; } fd;
48 struct { jit_uint32_t _:21; jit_uint32_t b : 10; } tr;
49 struct { jit_uint32_t _:21; jit_uint32_t b : 20; } br;
50 struct { jit_uint32_t _:26; jit_uint32_t b : 6; } tc;
51 struct { jit_uint32_t _:21; jit_uint32_t b : 11; } cc;
52 struct { jit_uint32_t _:16; jit_uint32_t b : 16; } is;
53 struct { jit_uint32_t _: 6; jit_uint32_t b : 26; } ii;
57 #if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2)
58 # define jit_mips2_p() 1
60 # define jit_mips2_p() 0
62 # define _ZERO_REGNO 0
63 # define _T0_REGNO 0x08
64 # define _T1_REGNO 0x09
65 # define _T2_REGNO 0x0a
66 # define _T3_REGNO 0x0b
67 # define _T4_REGNO 0x0c
68 # define _T5_REGNO 0x0d
69 # define _T6_REGNO 0x0e
70 # define _T7_REGNO 0x0f
71 # define _S0_REGNO 0x10
72 # define _S1_REGNO 0x11
73 # define _S2_REGNO 0x12
74 # define _S3_REGNO 0x13
75 # define _S4_REGNO 0x14
76 # define _S5_REGNO 0x15
77 # define _S6_REGNO 0x16
78 # define _S7_REGNO 0x17
79 # define _T8_REGNO 0x18
80 # define _T9_REGNO 0x19
81 # define _SP_REGNO 0x1d
82 # define _BP_REGNO 0x1e
83 # define _RA_REGNO 0x1f
84 # define _F16_REGNO 16
85 # define _F18_REGNO 18
86 # define _F20_REGNO 20
87 # define _F22_REGNO 22
88 # define _F24_REGNO 24
89 # define _F26_REGNO 26
90 # define _F28_REGNO 28
91 # define _F30_REGNO 30
94 # define stack_framesize 144
96 # define stack_framesize 112
98 # define ldr(u,v) ldr_i(u,v)
99 # define ldi(u,v) ldi_i(u,v)
100 # define ldxi(u,v,w) ldxi_i(u,v,w)
101 # define sti(u,v) sti_i(u,v)
102 # define stxi(u,v,w) stxi_i(u,v,w)
104 # define stack_framesize 144
105 # define ldr(u,v) ldr_l(u,v)
106 # define ldi(u,v) ldi_l(u,v)
107 # define ldxi(u,v,w) ldxi_l(u,v,w)
108 # define sti(u,v) sti_l(u,v)
109 # define stxi(u,v,w) stxi_l(u,v,w)
111 # define can_sign_extend_short_p(im) ((im) >= -32678 && (im) <= 32767)
112 # define can_zero_extend_short_p(im) ((im) >= 0 && (im) <= 65535)
113 # define is_low_mask(im) (((im) & 1) ? (__builtin_popcountl((im) + 1) <= 1) : 0)
114 # define is_middle_mask(im) ((im) ? (__builtin_popcountl((im) + (1 << __builtin_ctzl(im))) <= 1) : 0)
115 # define is_high_mask(im) ((im) ? (__builtin_popcountl((im) + (1 << __builtin_ctzl(im))) == 0) : 0)
116 # define masked_bits_count(im) __builtin_popcountl(im)
117 # define unmasked_bits_count(im) (__WORDSIZE - masked_bits_count(im))
118 # if __WORDSIZE == 32
119 # define can_sign_extend_int_p(im) 1
120 # define can_zero_extend_int_p(im) 1
122 # define can_sign_extend_int_p(im) \
123 (((im) >= 0 && (im) <= 0x7fffffffL) || \
124 ((im) < 0 && (im) >= -0x80000000L))
125 # define can_zero_extend_int_p(im) ((im) >= 0 && (im) <= 0xffffffff)
127 # define MIPS_SPECIAL 0x00
128 # define MIPS_REGIMM 0x01
130 # define MIPS_SRL 0x02
131 # define MIPS_JAL 0x03
132 # define MIPS_SRA 0x03
133 # define MIPS_BEQ 0x04
134 # define MIPS_BNE 0x05
135 # define MIPS_BLEZ 0x06
136 # define MIPS_BGTZ 0x07
137 # define MIPS_ADDI 0x08
138 # define MIPS_ADDIU 0x09
139 # define MIPS_SLTI 0x0a
140 # define MIPS_SLTIU 0x0b
141 # define MIPS_ANDI 0x0c
142 # define MIPS_ORI 0x0d
143 # define MIPS_XORI 0x0e
144 # define MIPS_LUI 0x0f
145 # define MIPS_COP0 0x10
146 # define MIPS_COP1 0x11
147 # define MIPS_COP2 0x12
148 # define MIPS_COP1X 0x13
149 # define MIPS_BEQL 0x14
150 # define MIPS_BNEL 0x15
151 # define MIPS_BLEZL 0x16
152 # define MIPS_BGTZL 0x17
153 # define MIPS_DADDI 0x18
154 # define MIPS_DADDIU 0x19
155 # define MIPS_LDL 0x1a
156 # define MIPS_LDR 0x1b
157 # define MIPS_SPECIAL2 0x1c
158 # define MIPS_JALX 0x1d
159 # define MIPS_SPECIAL3 0x1f
160 # define MIPS_LB 0x20
161 # define MIPS_LH 0x21
162 # define MIPS_LWL 0x22
163 # define MIPS_LW 0x23
164 # define MIPS_LBU 0x24
165 # define MIPS_LHU 0x25
166 # define MIPS_LWR 0x26
167 # define MIPS_LWU 0x27
168 # define MIPS_SB 0x28
169 # define MIPS_SH 0x29
170 # define MIPS_SWL 0x2a
171 # define MIPS_SW 0x2b
172 # define MIPS_SWR 0x2e
173 # define MIPS_CACHE 0x2f
174 # define MIPS_LL 0x30
175 # define MIPS_LWC1 0x31
176 # define MIPS_LWC2 0x32
177 # define MIPS_PREF 0x33
178 # define MIPS_LLD 0x34
179 # define MIPS_LDC1 0x35
180 # define MIPS_LDC2 0x36
181 # define MIPS_LD 0x37
182 # define MIPS_SC 0x38
183 # define MIPS_SCD 0x3c
184 # define MIPS_SDC1 0x3d
185 # define MIPS_SDC2 0x3e
186 # define MIPS_SWC1 0x39
187 # define MIPS_SWC2 0x3a
188 # define MIPS_SD 0x3f
189 # define MIPS_MF 0x00
190 # define MIPS_DMF 0x01
191 # define MIPS_CF 0x02
192 # define MIPS_MFH 0x03
193 # define MIPS_MT 0x04
194 # define MIPS_DMT 0x05
195 # define MIPS_CT 0x06
196 # define MIPS_MTH 0x07
197 # define MIPS_BC 0x08
198 # define MIPS_WRPGPR 0x0e
199 # define MIPS_BGZAL 0x11
200 # define MIPS_MFMC0 0x11
201 # define MIPS_BCF 0x00
202 # define MIPS_BLTZ 0x00
203 # define MIPS_BCT 0x01
204 # define MIPS_BGEZ 0x01
205 # define MIPS_BCFL 0x02
206 # define MIPS_BLTZL 0x02
207 # define MIPS_BCTL 0x03
208 # define MIPS_BGEZL 0x03
209 # define MIPS_TGEI 0x08
210 # define MIPS_TGEIU 0x09
211 # define MIPS_TLTI 0x0a
212 # define MIPS_TLTIU 0x0b
213 # define MIPS_TEQI 0x0c
214 # define MIPS_TNEI 0x0e
215 # define MIPS_BLTZAL 0x10
216 # define MIPS_BGEZAL 0x11
217 # define MIPS_BLTZALL 0x12
218 # define MIPS_BGEZALL 0x13
219 # define MIPS_SYNCI 0x1f
220 # define MIPS_WSBH 0x02
221 # define MIPS_DBSH 0x02
222 # define MIPS_DSHD 0x05
223 # define MIPS_SEB 0x10
224 # define MIPS_SEH 0x18
225 # define MIPS_MADD 0x00
226 # define MIPS_SLL 0x00
227 # define MIPS_EXT 0x00
228 # define MIPS_DEXTM 0x01
229 # define MIPS_MADDU 0x01
230 # define MIPS_MOVFT 0x01
231 # define MIPS_TLBR 0x01
232 # define MIPS_MUL 0x02
233 # define MIPS_DEXTU 0x02
234 # define MIPS_TLBWI 0x02
235 # define MIPS_DEXT 0x03
236 # define MIPS_SLLV 0x04
237 # define MIPS_INS 0x04
238 # define MIPS_MSUB 0x04
239 # define MIPS_DINSM 0x05
240 # define MIPS_MSUBU 0x05
241 # define MIPS_SRLV 0x06
242 # define MIPS_DINSU 0x06
243 # define MIPS_TLBWR 0x06
244 # define MIPS_SRAV 0x07
245 # define MIPS_DINS 0x07
246 # define MIPS_JR 0x08
247 # define MIPS_TLBP 0x08
248 # define MIPS_JALR 0x09
249 # define MIPS_MOVZ 0x0a
250 # define MIPS_MOVN 0x0b
251 # define MIPS_SYSCALL 0x0c
252 # define MIPS_BREAK 0x0d
253 # define MIPS_PREFX 0x0f
254 # define MIPS_SYNC 0x0f
255 # define MIPS_MFHI 0x10
256 # define MIPS_MTHI 0x11
257 # define MIPS_MFLO 0x12
258 # define MIPS_MTLO 0x13
259 # define MIPS_DSLLV 0x14
260 # define MIPS_DSRLV 0x16
261 # define MIPS_DSRAV 0x17
262 # define MIPS_MULT 0x18
263 # define MIPS_ERET 0x18
264 # define MIPS_MULTU 0x19
265 # define MIPS_DIV 0x1a
266 # define MIPS_DIVU 0x1b
267 # define MIPS_DMULT 0x1c
268 # define MIPS_DMULTU 0x1d
269 # define MIPS_DDIV 0x1e
270 # define MIPS_DDIVU 0x1f
271 # define MIPS_DERET 0x1f
272 # define MIPS_ADD 0x20
273 # define MIPS_CLZ 0x20
274 # define MIPS_BSHFL 0x20
275 # define MIPS_ADDU 0x21
276 # define MIPS_CLO 0x21
277 # define MIPS_SUB 0x22
278 # define MIPS_SUBU 0x23
279 # define MIPS_AND 0x24
280 # define MIPS_DCLZ 0x24
281 # define MIPS_DBSHFL 0x24
282 # define MIPS_OR 0x25
283 # define MIPS_DCLO 0x25
284 # define MIPS_XOR 0x26
285 # define MIPS_NOR 0x27
286 # define MIPS_SLT 0x2a
287 # define MIPS_SLTU 0x2b
288 # define MIPS_DADD 0x2c
289 # define MIPS_DADDU 0x2d
290 # define MIPS_DSUB 0x2e
291 # define MIPS_DSUBU 0x2f
292 # define MIPS_TGE 0x30
293 # define MIPS_TGEU 0x31
294 # define MIPS_TLT 0x32
295 # define MIPS_TLTU 0x33
296 # define MIPS_TEQ 0x34
297 # define MIPS_TNE 0x36
298 # define MIPS_DSLL 0x38
299 # define MIPS_DSRL 0x3a
300 # define MIPS_DSRA 0x3b
301 # define MIPS_DSLL32 0x3c
302 # define MIPS_DSRL32 0x3e
303 # define MIPS_DSRA32 0x3f
304 # define MIPS_SDBPP 0x3f
305 # define ii(i) *_jit->pc.ui++ = i
307 _hrrrit(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t,
308 jit_int32_t,jit_int32_t);
309 # define hrrrit(hc,rs,rt,rd,im,tc) _hrrrit(_jit,hc,rs,rt,rd,im,tc)
310 # define hrrr_t(hc,rs,rt,rd,tc) hrrrit(hc,rs,rt,rd,0,tc)
311 # define rrr_t(rs,rt,rd,tc) hrrr_t(0,rs,rt,rd,tc)
312 # define hrri(hc,rs,rt,im) _hrri(_jit,hc,rs,rt,im)
313 static void _hrri(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
314 # define hi(hc,im) _hi(_jit,hc,im)
315 static void _hi(jit_state_t*,jit_int32_t,jit_int32_t);
316 # define NOP(i0) ii(0)
317 # define nop(i0) _nop(_jit,i0)
318 static void _nop(jit_state_t*,jit_int32_t);
319 # define h_ri(hc,rt,im) _hrri(_jit,hc,0,rt,im)
320 # define rrit(rt,rd,im,tc) _hrrrit(_jit,0,0,rt,rd,im,tc)
321 # define LUI(rt,im) h_ri(MIPS_LUI,rt,im)
322 # define ADDU(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_ADDU)
323 # define DADDU(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_DADDU)
324 # define ADDIU(rt,rs,im) hrri(MIPS_ADDIU,rs,rt,im)
325 # define DADDIU(rt,rs,im) hrri(MIPS_DADDIU,rs,rt,im)
326 # define SUBU(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_SUBU)
327 # define DSUBU(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_DSUBU)
328 # define MUL(rd,rs,rt) hrrr_t(MIPS_SPECIAL2,rs,rt,rd,MIPS_MUL)
329 # define MULT(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_MULT)
330 # define MULTU(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_MULTU)
331 # define DMULT(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_DMULT)
332 # define DMULTU(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_DMULTU)
333 # define DIV(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_DIV)
334 # define DIVU(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_DIVU)
335 # define DDIV(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_DDIV)
336 # define DDIVU(rs,rt) rrr_t(rs,rt,_ZERO_REGNO,MIPS_DDIVU)
337 # define SLLV(rd,rt,rs) rrr_t(rs,rt,rd,MIPS_SLLV)
338 # define SLL(rd,rt,sa) rrit(rt,rd,sa,MIPS_SLL)
339 # define DSLLV(rd,rt,rs) rrr_t(rs,rt,rd,MIPS_DSLLV)
340 # define DSLL(rd,rt,sa) rrit(rt,rd,sa,MIPS_DSLL)
341 # define DSLL32(rd,rt,sa) rrit(rt,rd,sa,MIPS_DSLL32)
342 # define SRAV(rd,rt,rs) rrr_t(rs,rt,rd,MIPS_SRAV)
343 # define SRA(rd,rt,sa) rrit(rt,rd,sa,MIPS_SRA)
344 # define SRLV(rd,rt,rs) rrr_t(rs,rt,rd,MIPS_SRLV)
345 # define SRL(rd,rt,sa) rrit(rt,rd,sa,MIPS_SRL)
346 # define DSRAV(rd,rt,rs) rrr_t(rs,rt,rd,MIPS_DSRAV)
347 # define DSRA(rd,rt,sa) rrit(rt,rd,sa,MIPS_DSRA)
348 # define DSRA32(rd,rt,sa) rrit(rt,rd,sa,MIPS_DSRA32)
349 # define DSRLV(rd,rt,rs) rrr_t(rs,rt,rd,MIPS_DSRLV)
350 # define DSRL(rd,rt,sa) rrit(rt,rd,sa,MIPS_DSRL)
351 # define DSRL32(rd,rt,sa) rrit(rt,rd,sa,MIPS_DSRL32)
352 # define INS(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,pos+size-1,pos,MIPS_INS)
353 # define DINS(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,pos+size-1,pos,MIPS_DINS)
354 # define DINSU(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,pos+size-32-1,pos-32,MIPS_DINSU)
355 # define DINSM(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,pos+size-32-1,pos,MIPS_DINSM)
356 # define EXT(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,size-1,pos,MIPS_EXT)
357 # define DEXT(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,size-1,pos,MIPS_DEXT)
358 # define DEXTU(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,size-1,pos-32,MIPS_DEXTU)
359 # define DEXTM(rt,rs,pos,size) hrrrit(MIPS_SPECIAL3,rs,rt,size-32-1,pos,MIPS_DEXTM)
360 # define ROTR(rd,rt,sa) hrrrit(MIPS_SPECIAL,1,rt,rd,sa,MIPS_SRL)
361 # define DROTR(rd,rt,sa) hrrrit(MIPS_SPECIAL,1,rt,rd,sa,MIPS_DSRL)
362 # define MFHI(rd) rrr_t(_ZERO_REGNO,_ZERO_REGNO,rd,MIPS_MFHI)
363 # define MFLO(rd) rrr_t(_ZERO_REGNO,_ZERO_REGNO,rd,MIPS_MFLO)
364 # define MTHI(rs) rrr_t(rs,_ZERO_REGNO,_ZERO_REGNO,MIPS_MTHI)
365 # define MTLO(rs) rrr_t(rs,_ZERO_REGNO,_ZERO_REGNO,MIPS_MTLO)
366 # define AND(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_AND)
367 # define ANDI(rt,rs,im) hrri(MIPS_ANDI,rs,rt,im)
368 # define OR(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_OR)
369 # define ORI(rt,rs,im) hrri(MIPS_ORI,rs,rt,im)
370 # define XOR(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_XOR)
371 # define XORI(rt,rs,im) hrri(MIPS_XORI,rs,rt,im)
372 # define LB(rt,of,rb) hrri(MIPS_LB,rb,rt,of)
373 # define LBU(rt,of,rb) hrri(MIPS_LBU,rb,rt,of)
374 # define LH(rt,of,rb) hrri(MIPS_LH,rb,rt,of)
375 # define LHU(rt,of,rb) hrri(MIPS_LHU,rb,rt,of)
376 # define LW(rt,of,rb) hrri(MIPS_LW,rb,rt,of)
377 # define LWU(rt,of,rb) hrri(MIPS_LWU,rb,rt,of)
378 # define LD(rt,of,rb) hrri(MIPS_LD,rb,rt,of)
379 # define SB(rt,of,rb) hrri(MIPS_SB,rb,rt,of)
380 # define SH(rt,of,rb) hrri(MIPS_SH,rb,rt,of)
381 # define SW(rt,of,rb) hrri(MIPS_SW,rb,rt,of)
382 # define SD(rt,of,rb) hrri(MIPS_SD,rb,rt,of)
383 # define WSBH(rd,rt) hrrrit(MIPS_SPECIAL3,0,rt,rd,MIPS_WSBH,MIPS_BSHFL)
384 # define SEB(rd,rt) hrrrit(MIPS_SPECIAL3,0,rt,rd,MIPS_SEB,MIPS_BSHFL)
385 # define SEH(rd,rt) hrrrit(MIPS_SPECIAL3,0,rt,rd,MIPS_SEH,MIPS_BSHFL)
386 # define SLT(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_SLT)
387 # define SLTU(rd,rs,rt) rrr_t(rs,rt,rd,MIPS_SLTU)
388 # define SLTI(rt,rs,im) hrri(MIPS_SLTI,rs,rt,im)
389 # define SLTIU(rt,rs,im) hrri(MIPS_SLTIU,rs,rt,im)
390 # define BLTZ(rs,im) hrri(MIPS_REGIMM,rs,MIPS_BLTZ,im)
391 # define BLEZ(rs,im) hrri(MIPS_BLEZ,rs,_ZERO_REGNO,im)
392 # define BEQ(rs,rt,im) hrri(MIPS_BEQ,rs,rt,im)
393 # define BGEZ(rs,im) hrri(MIPS_REGIMM,rs,MIPS_BGEZ,im)
394 # define BGTZ(rs,im) hrri(MIPS_BGTZ,rs,_ZERO_REGNO,im)
395 # define BNE(rs,rt,im) hrri(MIPS_BNE,rs,rt,im)
396 # define JALR(r0) hrrrit(MIPS_SPECIAL,r0,0,_RA_REGNO,0,MIPS_JALR)
397 # if 1 /* supports MIPS32 R6 */
398 # define JR(r0) hrrrit(MIPS_SPECIAL,r0,0,0,0,MIPS_JALR)
399 # else /* does not support MIPS32 R6 */
400 # define JR(r0) hrrrit(MIPS_SPECIAL,r0,0,0,0,MIPS_JR)
402 # define J(i0) hi(MIPS_J,i0)
403 # define MOVN(rd,rs,rt) hrrrit(0,rs,rt,rd,0,MIPS_MOVN)
404 # define MOVZ(rd,rs,rt) hrrrit(0,rs,rt,rd,0,MIPS_MOVZ)
405 # define comr(r0,r1) xori(r0,r1,-1)
406 # define negr(r0,r1) subr(r0,_ZERO_REGNO,r1)
407 # if __WORDSIZE == 32
408 # define addr(rd,rs,rt) ADDU(rd,rs,rt)
409 # define addiu(r0,r1,i0) ADDIU(r0,r1,i0)
410 # define subr(rd,rs,rt) SUBU(rd,rs,rt)
411 # define mult(rs,rt) MULT(rs,rt)
412 # define multu(rs,rt) MULTU(rs,rt)
413 # define div(rs,rt) DIV(rs,rt)
414 # define divu(rs,rt) DIVU(rs,rt)
416 # define addr(rd,rs,rt) DADDU(rd,rs,rt)
417 # define addiu(r0,r1,i0) DADDIU(r0,r1,i0)
418 # define subr(rd,rs,rt) DSUBU(rd,rs,rt)
419 # define mult(rs,rt) DMULT(rs,rt)
420 # define multu(rs,rt) DMULTU(rs,rt)
421 # define div(rs,rt) DDIV(rs,rt)
422 # define divu(rs,rt) DDIVU(rs,rt)
424 # define extr(rd,rt,lsb,nb) _extr(_jit,rd,rt,lsb,nb)
425 static void _extr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
426 # define insr(rd,rt,lsb,nb) _insr(_jit,rd,rt,lsb,nb)
427 static void _insr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
428 # define addi(r0,r1,i0) _addi(_jit,r0,r1,i0)
429 static void _addi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
430 #define addcr(r0,r1,r2) _addcr(_jit,r0,r1,r2)
431 static void _addcr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
432 #define addci(r0,r1,i0) _addci(_jit,r0,r1,i0)
433 static void _addci(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
434 # define addxr(r0,r1,r2) _addxr(_jit,r0,r1,r2)
435 static void _addxr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
436 # define addxi(r0,r1,i0) _addxi(_jit,r0,r1,i0)
437 static void _addxi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
438 # define subi(r0,r1,i0) _subi(_jit,r0,r1,i0)
439 static void _subi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
440 # define subcr(r0,r1,r2) _subcr(_jit,r0,r1,r2)
441 static void _subcr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
442 # define subci(r0,r1,i0) _subci(_jit,r0,r1,i0)
443 static void _subci(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
444 # define subxr(r0,r1,r2) _subxr(_jit,r0,r1,r2)
445 static void _subxr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
446 # define subxi(r0,r1,i0) _subxi(_jit,r0,r1,i0)
447 static void _subxi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
448 # define rsbi(r0, r1, i0) _rsbi(_jit, r0, r1, i0)
449 static void _rsbi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
450 # define mulr(r0,r1,r2) _mulr(_jit,r0,r1,r2)
451 static void _mulr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
452 # define muli(r0,r1,i0) _muli(_jit,r0,r1,i0)
453 static void _muli(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
454 # define qmulr(r0,r1,r2,r3) iqmulr(r0,r1,r2,r3,1)
455 # define qmulr_u(r0,r1,r2,r3) iqmulr(r0,r1,r2,r3,0)
456 # define iqmulr(r0,r1,r2,r3,cc) _iqmulr(_jit,r0,r1,r2,r3,cc)
457 static void _iqmulr(jit_state_t*,jit_int32_t,jit_int32_t,
458 jit_int32_t,jit_int32_t,jit_bool_t);
459 # define qmuli(r0,r1,r2,i0) iqmuli(r0,r1,r2,i0,1)
460 # define qmuli_u(r0,r1,r2,i0) iqmuli(r0,r1,r2,i0,0)
461 # define iqmuli(r0,r1,r2,i0,cc) _iqmuli(_jit,r0,r1,r2,i0,cc)
462 static void _iqmuli(jit_state_t*,jit_int32_t,jit_int32_t,
463 jit_int32_t,jit_word_t,jit_bool_t);
464 # define divr(r0,r1,r2) _divr(_jit,r0,r1,r2)
465 static void _divr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
466 # define divi(r0,r1,i0) _divi(_jit,r0,r1,i0)
467 static void _divi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
468 # define divr_u(r0,r1,r2) _divr_u(_jit,r0,r1,r2)
469 static void _divr_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
470 # define divi_u(r0,r1,i0) _divi_u(_jit,r0,r1,i0)
471 static void _divi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
472 # define qdivr(r0,r1,r2,r3) iqdivr(r0,r1,r2,r3,1)
473 # define qdivr_u(r0,r1,r2,r3) iqdivr(r0,r1,r2,r3,0)
474 # define iqdivr(r0,r1,r2,r3,cc) _iqdivr(_jit,r0,r1,r2,r3,cc)
475 static void _iqdivr(jit_state_t*,jit_int32_t,jit_int32_t,
476 jit_int32_t,jit_int32_t,jit_bool_t);
477 # define qdivi(r0,r1,r2,i0) iqdivi(r0,r1,r2,i0,1)
478 # define qdivi_u(r0,r1,r2,i0) iqdivi(r0,r1,r2,i0,0)
479 # define iqdivi(r0,r1,r2,i0,cc) _iqdivi(_jit,r0,r1,r2,i0,cc)
480 static void _iqdivi(jit_state_t*,jit_int32_t,jit_int32_t,
481 jit_int32_t,jit_word_t,jit_bool_t);
482 # define remr(r0,r1,r2) _remr(_jit,r0,r1,r2)
483 static void _remr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
484 # define remi(r0,r1,i0) _remi(_jit,r0,r1,i0)
485 static void _remi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
486 # define remr_u(r0,r1,r2) _remr_u(_jit,r0,r1,r2)
487 static void _remr_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
488 # define remi_u(r0,r1,i0) _remi_u(_jit,r0,r1,i0)
489 static void _remi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
490 # if __WORDSIZE == 32
491 # define lshr(r0,r1,r2) SLLV(r0,r1,r2)
492 # define lshi(r0,r1,i0) SLL(r0,r1,i0)
493 # define rshr(r0,r1,r2) SRAV(r0,r1,r2)
494 # define rshi(r0,r1,i0) SRA(r0,r1,i0)
495 # define rshr_u(r0,r1,r2) SRLV(r0,r1,r2)
496 # define rshi_u(r0,r1,i0) SRL(r0,r1,i0)
498 # define lshr(r0,r1,r2) DSLLV(r0,r1,r2)
499 # define lshi(r0,r1,i0) _lshi(_jit,r0,r1,i0)
500 static void _lshi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
501 # define rshr(r0,r1,r2) DSRAV(r0,r1,r2)
502 # define rshi(r0,r1,i0) _rshi(_jit,r0,r1,i0)
503 static void _rshi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
504 # define rshr_u(r0,r1,r2) DSRLV(r0,r1,r2)
505 # define rshi_u(r0,r1,i0) _rshi_u(_jit,r0,r1,i0)
506 static void _rshi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
508 # define andr(r0,r1,r2) AND(r0,r1,r2)
509 # define andi(r0,r1,i0) _andi(_jit,r0,r1,i0)
510 static void _andi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
511 # define orr(r0,r1,r2) OR(r0,r1,r2)
512 # define ori(r0,r1,i0) _ori(_jit,r0,r1,i0)
513 static void _ori(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
514 # define xorr(r0,r1,r2) XOR(r0,r1,r2)
515 # define xori(r0,r1,i0) _xori(_jit,r0,r1,i0)
516 static void _xori(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
517 # define movr(r0,r1) _movr(_jit,r0,r1)
518 static void _movr(jit_state_t*,jit_int32_t,jit_int32_t);
519 # define movi(r0,i0) _movi(_jit,r0,i0)
520 static void _movi(jit_state_t*,jit_int32_t,jit_word_t);
521 # define movi_p(r0,i0) _movi_p(_jit,r0,i0)
522 static jit_word_t _movi_p(jit_state_t*,jit_int32_t,jit_word_t);
523 # define movnr(r0,r1,r2) MOVN(r0, r1, r2)
524 # define movzr(r0,r1,r2) MOVZ(r0, r1, r2)
525 # define casx(r0, r1, r2, r3, i0) _casx(_jit, r0, r1, r2, r3, i0)
526 static void _casx(jit_state_t *_jit,jit_int32_t,jit_int32_t,
527 jit_int32_t,jit_int32_t,jit_word_t);
528 #define casr(r0, r1, r2, r3) casx(r0, r1, r2, r3, 0)
529 #define casi(r0, i0, r1, r2) casx(r0, _NOREG, r1, r2, i0)
530 # define ldr_c(r0,r1) LB(r0,0,r1)
531 # define ldi_c(r0,i0) _ldi_c(_jit,r0,i0)
532 static void _ldi_c(jit_state_t*,jit_int32_t,jit_word_t);
533 # define ldr_uc(r0,r1) LBU(r0,0,r1)
534 # define ldi_uc(r0,i0) _ldi_uc(_jit,r0,i0)
535 static void _ldi_uc(jit_state_t*,jit_int32_t,jit_word_t);
536 # define ldr_s(r0,r1) LH(r0,0,r1)
537 # define ldi_s(r0,i0) _ldi_s(_jit,r0,i0)
538 static void _ldi_s(jit_state_t*,jit_int32_t,jit_word_t);
539 # define ldr_us(r0,r1) LHU(r0,0,r1)
540 # define ldi_us(r0,i0) _ldi_us(_jit,r0,i0)
541 static void _ldi_us(jit_state_t*,jit_int32_t,jit_word_t);
542 # define ldr_i(r0,r1) LW(r0,0,r1)
543 # define ldi_i(r0,i0) _ldi_i(_jit,r0,i0)
544 static void _ldi_i(jit_state_t*,jit_int32_t,jit_word_t);
545 # if __WORDSIZE == 64
546 # define ldr_ui(r0,r1) LWU(r0,0,r1)
547 # define ldi_ui(r0,i0) _ldi_ui(_jit,r0,i0)
548 static void _ldi_ui(jit_state_t*,jit_int32_t,jit_word_t);
549 # define ldr_l(r0,r1) LD(r0,0,r1)
550 # define ldi_l(r0,i0) _ldi_l(_jit,r0,i0)
551 static void _ldi_l(jit_state_t*,jit_int32_t,jit_word_t);
553 # define ldxr_c(r0,r1,r2) _ldxr_c(_jit,r0,r1,r2)
554 static void _ldxr_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
555 # define ldxi_c(r0,r1,i0) _ldxi_c(_jit,r0,r1,i0)
556 static void _ldxi_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
557 # define ldxr_uc(r0,r1,r2) _ldxr_uc(_jit,r0,r1,r2)
558 static void _ldxr_uc(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
559 # define ldxi_uc(r0,r1,i0) _ldxi_uc(_jit,r0,r1,i0)
560 static void _ldxi_uc(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
561 # define ldxr_s(r0,r1,r2) _ldxr_s(_jit,r0,r1,r2)
562 static void _ldxr_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
563 # define ldxi_s(r0,r1,i0) _ldxi_s(_jit,r0,r1,i0)
564 static void _ldxi_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
565 # define ldxr_us(r0,r1,r2) _ldxr_us(_jit,r0,r1,r2)
566 static void _ldxr_us(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
567 # define ldxi_us(r0,r1,i0) _ldxi_us(_jit,r0,r1,i0)
568 static void _ldxi_us(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
569 # define ldxr_i(r0,r1,r2) _ldxr_i(_jit,r0,r1,r2)
570 static void _ldxr_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
571 # define ldxi_i(r0,r1,i0) _ldxi_i(_jit,r0,r1,i0)
572 static void _ldxi_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
573 # if __WORDSIZE == 64
574 # define ldxr_ui(r0,r1,r2) _ldxr_ui(_jit,r0,r1,r2)
575 static void _ldxr_ui(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
576 # define ldxi_ui(r0,r1,i0) _ldxi_ui(_jit,r0,r1,i0)
577 static void _ldxi_ui(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
578 # define ldxr_l(r0,r1,r2) _ldxr_l(_jit,r0,r1,r2)
579 static void _ldxr_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
580 # define ldxi_l(r0,r1,i0) _ldxi_l(_jit,r0,r1,i0)
581 static void _ldxi_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
583 # define str_c(r0,r1) SB(r1,0,r0)
584 # define sti_c(i0,r0) _sti_c(_jit,i0,r0)
585 static void _sti_c(jit_state_t*,jit_word_t,jit_int32_t);
586 # define str_s(r0,r1) SH(r1,0,r0)
587 # define sti_s(i0,r0) _sti_s(_jit,i0,r0)
588 static void _sti_s(jit_state_t*,jit_word_t,jit_int32_t);
589 # define str_i(r0,r1) SW(r1,0,r0)
590 # define sti_i(i0,r0) _sti_i(_jit,i0,r0)
591 static void _sti_i(jit_state_t*,jit_word_t,jit_int32_t);
592 # if __WORDSIZE == 64
593 # define str_l(r0,r1) SD(r1,0,r0)
594 # define sti_l(i0,r0) _sti_l(_jit,i0,r0)
595 static void _sti_l(jit_state_t*,jit_word_t,jit_int32_t);
597 # define stxr_c(r0,r1,r2) _stxr_c(_jit,r0,r1,r2)
598 static void _stxr_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
599 # define stxi_c(i0,r0,r1) _stxi_c(_jit,i0,r0,r1)
600 static void _stxi_c(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
601 # define stxr_s(r0,r1,r2) _stxr_s(_jit,r0,r1,r2)
602 static void _stxr_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
603 # define stxi_s(i0,r0,r1) _stxi_s(_jit,i0,r0,r1)
604 static void _stxi_s(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
605 # define stxr_i(r0,r1,r2) _stxr_i(_jit,r0,r1,r2)
606 static void _stxr_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
607 # define stxi_i(i0,r0,r1) _stxi_i(_jit,i0,r0,r1)
608 static void _stxi_i(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
609 # if __WORDSIZE == 64
610 # define stxr_l(r0,r1,r2) _stxr_l(_jit,r0,r1,r2)
611 static void _stxr_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
612 # define stxi_l(i0,r0,r1) _stxi_l(_jit,i0,r0,r1)
613 static void _stxi_l(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
615 # define bswapr_us(r0,r1) _bswapr_us(_jit,r0,r1)
616 static void _bswapr_us(jit_state_t*,jit_int32_t,jit_int32_t);
617 # define bswapr_ui(r0,r1) _bswapr_ui(_jit,r0,r1)
618 static void _bswapr_ui(jit_state_t*,jit_int32_t,jit_int32_t);
619 # if __WORDSIZE == 64
620 # define bswapr_ul(r0,r1) generic_bswapr_ul(_jit,r0,r1)
622 # define extr_c(r0,r1) _extr_c(_jit,r0,r1)
623 static void _extr_c(jit_state_t*,jit_int32_t,jit_int32_t);
624 # define extr_uc(r0,r1) ANDI(r0,r1,0xff)
625 # define extr_s(r0,r1) _extr_s(_jit,r0,r1)
626 static void _extr_s(jit_state_t*,jit_int32_t,jit_int32_t);
627 # define extr_us(r0,r1) ANDI(r0,r1,0xffff)
628 # if __WORDSIZE == 64
629 # define extr_i(r0,r1) SLL(r0,r1,0)
630 # define extr_ui(r0,r1) _extr_ui(_jit,r0,r1)
631 static void _extr_ui(jit_state_t*,jit_int32_t,jit_int32_t);
633 # define ltr(r0,r1,r2) SLT(r0,r1,r2)
634 # define lti(r0,r1,i0) _lti(_jit,r0,r1,i0)
635 static void _lti(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
636 # define ltr_u(r0,r1,r2) SLTU(r0,r1,r2)
637 # define lti_u(r0,r1,i0) _lti_u(_jit,r0,r1,i0)
638 static void _lti_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
639 #define ler(r0,r1,r2) _ler(_jit,r0,r1,r2)
640 static void _ler(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
641 #define lei(r0,r1,i0) _lei(_jit,r0,r1,i0)
642 static void _lei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
643 #define ler_u(r0,r1,r2) _ler_u(_jit,r0,r1,r2)
644 static void _ler_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
645 #define lei_u(r0,r1,i0) _lei_u(_jit,r0,r1,i0)
646 static void _lei_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
647 #define eqr(r0,r1,r2) _eqr(_jit,r0,r1,r2)
648 static void _eqr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
649 #define eqi(r0,r1,i0) _eqi(_jit,r0,r1,i0)
650 static void _eqi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
651 #define ger(r0,r1,r2) _ger(_jit,r0,r1,r2)
652 static void _ger(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
653 #define gei(r0,r1,i0) _gei(_jit,r0,r1,i0)
654 static void _gei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
655 #define ger_u(r0,r1,i0) _ger_u(_jit,r0,r1,i0)
656 static void _ger_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
657 #define gei_u(r0,r1,i0) _gei_u(_jit,r0,r1,i0)
658 static void _gei_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
659 # define gtr(r0,r1,r2) SLT(r0,r2,r1)
660 #define gti(r0,r1,i0) _gti(_jit,r0,r1,i0)
661 static void _gti(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
662 # define gtr_u(r0,r1,r2) SLTU(r0,r2,r1)
663 # define gti_u(r0,r1,i0) _gti_u(_jit,r0,r1,i0)
664 static void _gti_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
665 #define ner(r0,r1,r2) _ner(_jit,r0,r1,r2)
666 static void _ner(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
667 #define nei(r0,r1,i0) _nei(_jit,r0,r1,i0)
668 static void _nei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
669 #define bltr(i0,r0,r1) _bltr(_jit,i0,r0,r1)
670 static jit_word_t _bltr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
671 #define bltr_u(i0,r0,r1) _bltr_u(_jit,i0,r0,r1)
672 static jit_word_t _bltr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
673 #define blti(i0,r0,i1) _blti(_jit,i0,r0,i1)
674 static jit_word_t _blti(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
675 #define blti_u(i0,r0,i1) _blti_u(_jit,i0,r0,i1)
676 static jit_word_t _blti_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
677 #define bler(i0,r0,r1) _bler(_jit,i0,r0,r1)
678 static jit_word_t _bler(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
679 #define bler_u(i0,r0,r1) _bler_u(_jit,i0,r0,r1)
680 static jit_word_t _bler_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
681 #define blei(i0,r0,i1) _blei(_jit,i0,r0,i1)
682 static jit_word_t _blei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
683 #define blei_u(i0,r0,i1) _blei_u(_jit,i0,r0,i1)
684 static jit_word_t _blei_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
685 #define beqr(i0,r0,r1) _beqr(_jit,i0,r0,r1)
686 static jit_word_t _beqr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
687 #define beqi(i0,r0,i1) _beqi(_jit,i0,r0,i1)
688 static jit_word_t _beqi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
689 #define bger(i0,r0,r1) _bger(_jit,i0,r0,r1)
690 static jit_word_t _bger(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
691 #define bger_u(i0,r0,r1) _bger_u(_jit,i0,r0,r1)
692 static jit_word_t _bger_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
693 #define bgei(i0,r0,i1) _bgei(_jit,i0,r0,i1)
694 static jit_word_t _bgei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
695 #define bgei_u(i0,r0,i1) _bgei_u(_jit,i0,r0,i1)
696 static jit_word_t _bgei_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
697 #define bgtr(i0,r0,r1) _bgtr(_jit,i0,r0,r1)
698 static jit_word_t _bgtr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
699 #define bgtr_u(i0,r0,r1) _bgtr_u(_jit,i0,r0,r1)
700 static jit_word_t _bgtr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
701 #define bgti(i0,r0,i1) _bgti(_jit,i0,r0,i1)
702 static jit_word_t _bgti(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
703 #define bgti_u(i0,r0,i1) _bgti_u(_jit,i0,r0,i1)
704 static jit_word_t _bgti_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
705 #define bner(i0,r0,r1) _bner(_jit,i0,r0,r1)
706 static jit_word_t _bner(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
707 #define bnei(i0,r0,i1) _bnei(_jit,i0,r0,i1)
708 static jit_word_t _bnei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
709 # define jmpr(r0) _jmpr(_jit,r0)
710 static void _jmpr(jit_state_t*,jit_int32_t);
711 # define jmpi(i0) _jmpi(_jit,i0)
712 static jit_word_t _jmpi(jit_state_t*,jit_word_t);
713 # define boaddr(i0,r0,r1) _boaddr(_jit,i0,r0,r1)
714 static jit_word_t _boaddr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
715 # define boaddi(i0,r0,i1) _boaddi(_jit,i0,r0,i1)
716 static jit_word_t _boaddi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
717 # define boaddr_u(i0,r0,r1) _boaddr_u(_jit,i0,r0,r1)
718 static jit_word_t _boaddr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
719 # define boaddi_u(i0,r0,i1) _boaddi_u(_jit,i0,r0,i1)
720 static jit_word_t _boaddi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
721 # define bxaddr(i0,r0,r1) _bxaddr(_jit,i0,r0,r1)
722 static jit_word_t _bxaddr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
723 # define bxaddi(i0,r0,i1) _bxaddi(_jit,i0,r0,i1)
724 static jit_word_t _bxaddi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
725 # define bxaddr_u(i0,r0,r1) _bxaddr_u(_jit,i0,r0,r1)
726 static jit_word_t _bxaddr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
727 # define bxaddi_u(i0,r0,i1) _bxaddi_u(_jit,i0,r0,i1)
728 static jit_word_t _bxaddi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
729 # define bosubr(i0,r0,r1) _bosubr(_jit,i0,r0,r1)
730 static jit_word_t _bosubr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
731 # define bosubi(i0,r0,i1) _bosubi(_jit,i0,r0,i1)
732 static jit_word_t _bosubi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
733 # define bosubr_u(i0,r0,r1) _bosubr_u(_jit,i0,r0,r1)
734 static jit_word_t _bosubr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
735 # define bosubi_u(i0,r0,i1) _bosubi_u(_jit,i0,r0,i1)
736 static jit_word_t _bosubi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
737 # define bxsubr(i0,r0,r1) _bxsubr(_jit,i0,r0,r1)
738 static jit_word_t _bxsubr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
739 # define bxsubi(i0,r0,i1) _bxsubi(_jit,i0,r0,i1)
740 static jit_word_t _bxsubi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
741 # define bxsubr_u(i0,r0,r1) _bxsubr_u(_jit,i0,r0,r1)
742 static jit_word_t _bxsubr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
743 # define bxsubi_u(i0,r0,i1) _bxsubi_u(_jit,i0,r0,i1)
744 static jit_word_t _bxsubi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
745 # define bmsr(i0,r0,r1) _bmsr(_jit,i0,r0,r1)
746 static jit_word_t _bmsr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
747 # define bmsi(i0,r0,i1) _bmsi(_jit,i0,r0,i1)
748 static jit_word_t _bmsi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
749 # define bmcr(i0,r0,r1) _bmcr(_jit,i0,r0,r1)
750 static jit_word_t _bmcr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
751 # define bmci(i0,r0,i1) _bmci(_jit,i0,r0,i1)
752 static jit_word_t _bmci(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
753 # define callr(r0) _callr(_jit,r0)
754 static void _callr(jit_state_t*,jit_int32_t);
755 # define calli(i0) _calli(_jit,i0)
756 static void _calli(jit_state_t*,jit_word_t);
757 # define calli_p(i0) _calli_p(_jit,i0)
758 static jit_word_t _calli_p(jit_state_t*,jit_word_t);
759 # define prolog(node) _prolog(_jit,node)
760 static void _prolog(jit_state_t*,jit_node_t*);
761 # define epilog(node) _epilog(_jit,node)
762 static void _epilog(jit_state_t*,jit_node_t*);
763 # define vastart(r0) _vastart(_jit, r0)
764 static void _vastart(jit_state_t*, jit_int32_t);
765 # define vaarg(r0, r1) _vaarg(_jit, r0, r1)
766 static void _vaarg(jit_state_t*, jit_int32_t, jit_int32_t);
767 #define patch_abs(instr,label) _patch_abs(_jit,instr,label)
768 static void _patch_abs(jit_state_t*,jit_word_t,jit_word_t);
769 #define patch_at(jump,label) _patch_at(_jit,jump,label)
770 static void _patch_at(jit_state_t*,jit_word_t,jit_word_t);
775 _hrrrit(jit_state_t *_jit,jit_int32_t hc,
776 jit_int32_t rs, jit_int32_t rt, jit_int32_t rd,
777 jit_int32_t ic, jit_int32_t tc)
790 _hrri(jit_state_t *_jit, jit_int32_t hc,
791 jit_int32_t rs, jit_int32_t rt, jit_int32_t im)
803 _hi(jit_state_t *_jit, jit_int32_t hc, jit_int32_t im)
812 _nop(jit_state_t *_jit, jit_int32_t i0)
814 for (; i0 > 0; i0 -= 4)
820 _extr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
821 jit_int32_t pos, jit_int32_t size)
825 if (__WORDSIZE == 32)
826 EXT(r0, r1, pos, size);
828 DEXTU(r0, r1, pos, size);
830 DEXTM(r0, r1, pos, size);
832 DEXT(r0, r1, pos, size);
836 _insr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
837 jit_int32_t pos, jit_int32_t size)
841 if (__WORDSIZE == 32)
842 INS(r0, r1, pos, size);
844 DINSU(r0, r1, pos, size);
846 DINSM(r0, r1, pos, size);
848 DINS(r0, r1, pos, size);
852 _addi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
857 else if (can_sign_extend_short_p(i0))
860 reg = jit_get_reg(jit_class_gpr);
862 addr(r0, r1, rn(reg));
868 _addcr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
872 if (jit_carry == _NOREG)
873 jit_carry = jit_get_reg(jit_class_gpr);
875 t0 = jit_get_reg(jit_class_gpr);
876 addr(rn(t0), r1, r2);
877 SLTU(rn(jit_carry), rn(t0), r1);
883 SLTU(rn(jit_carry), r0, r1);
888 _addci(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
892 if (jit_carry == _NOREG)
893 jit_carry = jit_get_reg(jit_class_gpr);
894 t0 = jit_get_reg(jit_class_gpr);
896 if (can_sign_extend_short_p(i0))
897 addiu(rn(t0), r1, i0);
900 addr(rn(t0), r1, rn(t0));
902 SLTU(rn(jit_carry), rn(t0), r1);
906 if (can_sign_extend_short_p(i0))
910 addr(r0, r1, rn(t0));
912 SLTU(rn(jit_carry), r0, r1);
918 _addxr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
922 assert(jit_carry != _NOREG);
923 t0 = jit_get_reg(jit_class_gpr);
924 movr(rn(t0), rn(jit_carry));
926 addcr(r0, r0, rn(t0));
931 _addxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
935 assert(jit_carry != _NOREG);
936 t0 = jit_get_reg(jit_class_gpr);
937 movr(rn(t0), rn(jit_carry));
939 addcr(r0, r0, rn(t0));
944 _subi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
949 else if (can_sign_extend_short_p(i0) && (i0 & 0xffff) != 0x8000)
952 reg = jit_get_reg(jit_class_gpr);
954 subr(r0, r1, rn(reg));
960 _subcr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
964 if (jit_carry == _NOREG)
965 jit_carry = jit_get_reg(jit_class_gpr);
967 t0 = jit_get_reg(jit_class_gpr);
968 subr(rn(t0), r1, r2);
969 SLTU(rn(jit_carry), r1, rn(t0));
975 SLTU(rn(jit_carry), r1, r0);
980 _subci(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
984 if (jit_carry == _NOREG)
985 jit_carry = jit_get_reg(jit_class_gpr);
986 t0 = jit_get_reg(jit_class_gpr);
988 if (can_sign_extend_short_p(i0) && (i0 & 0xffff) != 0x8000)
989 addiu(rn(t0), r1, -i0);
992 subr(rn(t0), r1, rn(t0));
994 SLTU(rn(jit_carry), r1, rn(t0));
998 if (can_sign_extend_short_p(i0) && (i0 & 0xffff) != 0x8000)
1002 subr(r0, r1, rn(t0));
1004 SLTU(rn(jit_carry), r1, r0);
1010 _subxr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1014 assert(jit_carry != _NOREG);
1015 t0 = jit_get_reg(jit_class_gpr);
1016 movr(rn(t0), rn(jit_carry));
1018 subcr(r0, r0, rn(t0));
1023 _subxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1027 assert(jit_carry != _NOREG);
1028 t0 = jit_get_reg(jit_class_gpr);
1029 movr(rn(t0), rn(jit_carry));
1031 subcr(r0, r0, rn(t0));
1036 _rsbi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1043 _mulr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1045 if (__WORDSIZE == 32)
1054 _muli(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1058 reg = jit_get_reg(jit_class_gpr);
1060 mulr(r0, r1, rn(reg));
1065 _iqmulr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
1066 jit_int32_t r2, jit_int32_t r3, jit_bool_t sign)
1077 _iqmuli(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
1078 jit_int32_t r2, jit_word_t i0, jit_bool_t sign)
1081 reg = jit_get_reg(jit_class_gpr);
1083 iqmulr(r0, r1, r2, rn(reg), sign);
1088 _divr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1095 _divi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1098 reg = jit_get_reg(jit_class_gpr);
1100 divr(r0, r1, rn(reg));
1105 _divr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1112 _divi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1115 reg = jit_get_reg(jit_class_gpr);
1117 divr_u(r0, r1, rn(reg));
1122 _iqdivr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
1123 jit_int32_t r2, jit_int32_t r3, jit_bool_t sign)
1134 _iqdivi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
1135 jit_int32_t r2, jit_word_t i0, jit_bool_t sign)
1138 reg = jit_get_reg(jit_class_gpr);
1140 iqdivr(r0, r1, r2, rn(reg), sign);
1145 _remr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1152 _remi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1155 reg = jit_get_reg(jit_class_gpr);
1157 remr(r0, r1, rn(reg));
1162 _remr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1169 _remi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1172 reg = jit_get_reg(jit_class_gpr);
1174 remr_u(r0, r1, rn(reg));
1178 #if __WORDSIZE == 64
1180 _lshi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1182 assert(i0 >= 0 && i0 <= 63);
1186 DSLL32(r0, r1, i0 - 32);
1190 _rshi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1192 assert(i0 >= 0 && i0 <= 63);
1196 DSRA32(r0, r1, i0 - 32);
1200 _rshi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1202 assert(i0 >= 0 && i0 <= 63);
1206 DSRL32(r0, r1, i0 - 32);
1211 _andi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1214 if (can_zero_extend_short_p(i0))
1216 else if (is_low_mask(i0)) {
1218 extr(r0, r1, 0, masked_bits_count(i0));
1220 lshi(r0, r1, unmasked_bits_count(i0));
1221 rshi_u(r0, r0, unmasked_bits_count(i0));
1223 } else if (is_high_mask(i0)) {
1224 if (jit_mips2_p() && r0 == r1)
1225 insr(r0, _ZERO_REGNO, 0, unmasked_bits_count(i0));
1227 rshi(r0, r1, unmasked_bits_count(i0));
1228 lshi(r0, r0, unmasked_bits_count(i0));
1230 } else if (jit_mips2_p() && is_middle_mask(i0)) {
1231 extr(r0, r1, __builtin_ctzl(i0), masked_bits_count(i0));
1232 lshi(r0, r0, __builtin_ctzl(i0));
1233 } else if (jit_mips2_p() && is_middle_mask(~i0)) {
1236 insr(r0, _ZERO_REGNO, __builtin_ctzl(~i0), masked_bits_count(~i0));
1238 reg = jit_get_reg(jit_class_gpr);
1240 AND(r0, r1, rn(reg));
1246 _ori(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1249 if (can_zero_extend_short_p(i0))
1252 reg = jit_get_reg(jit_class_gpr);
1254 OR(r0, r1, rn(reg));
1260 _xori(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1263 if (can_zero_extend_short_p(i0))
1266 reg = jit_get_reg(jit_class_gpr);
1268 XOR(r0, r1, rn(reg));
1274 _movr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1277 orr(r0, r1, _ZERO_REGNO);
1281 _movi(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1284 OR(r0, _ZERO_REGNO, _ZERO_REGNO);
1285 else if (can_sign_extend_short_p(i0))
1286 addiu(r0, _ZERO_REGNO, i0);
1287 else if (can_zero_extend_short_p(i0))
1288 ORI(r0, _ZERO_REGNO, i0);
1290 if (can_sign_extend_int_p(i0))
1292 else if (can_zero_extend_int_p(i0)) {
1293 if (i0 & 0xffff0000) {
1294 ORI(r0, _ZERO_REGNO, i0 >> 16);
1298 # if __WORDSIZE == 64
1300 movi(r0, (jit_uword_t)i0 >> 32);
1301 if (i0 & 0xffff0000) {
1303 ORI(r0, r0, i0 >> 16);
1316 _movi_p(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1321 # if __WORDSIZE == 32
1326 ORI(r0, r0, i0 >> 32);
1328 ORI(r0, r0, i0 >> 16);
1337 _casx(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
1338 jit_int32_t r2, jit_int32_t r3, jit_word_t i0)
1340 fallback_casx(r0, r1, r2, r3, i0);
1344 _ldi_c(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1347 if (can_sign_extend_short_p(i0))
1348 LB(r0, i0, _ZERO_REGNO);
1350 reg = jit_get_reg(jit_class_gpr);
1358 _ldi_uc(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1361 if (can_sign_extend_short_p(i0))
1362 LBU(r0, i0, _ZERO_REGNO);
1364 reg = jit_get_reg(jit_class_gpr);
1366 ldr_uc(r0, rn(reg));
1372 _ldi_s(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1375 if (can_sign_extend_short_p(i0))
1376 LH(r0, i0, _ZERO_REGNO);
1378 reg = jit_get_reg(jit_class_gpr);
1386 _ldi_us(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1389 if (can_sign_extend_short_p(i0))
1390 LHU(r0, i0, _ZERO_REGNO);
1392 reg = jit_get_reg(jit_class_gpr);
1394 ldr_us(r0, rn(reg));
1400 _ldi_i(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1403 if (can_sign_extend_short_p(i0))
1404 LW(r0, i0, _ZERO_REGNO);
1406 reg = jit_get_reg(jit_class_gpr);
1413 #if __WORDSIZE == 64
1415 _ldi_ui(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1418 if (can_sign_extend_short_p(i0))
1419 LWU(r0, i0, _ZERO_REGNO);
1421 reg = jit_get_reg(jit_class_gpr);
1423 ldr_ui(r0, rn(reg));
1429 _ldi_l(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
1432 if (can_sign_extend_short_p(i0))
1433 LD(r0, i0, _ZERO_REGNO);
1435 reg = jit_get_reg(jit_class_gpr);
1444 _ldxr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1447 reg = jit_get_reg(jit_class_gpr);
1448 addr(rn(reg), r1, r2);
1454 _ldxi_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1457 if (can_sign_extend_short_p(i0))
1460 reg = jit_get_reg(jit_class_gpr);
1461 addi(rn(reg), r1, i0);
1468 _ldxr_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1471 reg = jit_get_reg(jit_class_gpr);
1472 addr(rn(reg), r1, r2);
1473 ldr_uc(r0, rn(reg));
1478 _ldxi_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1481 if (can_sign_extend_short_p(i0))
1484 reg = jit_get_reg(jit_class_gpr);
1485 addi(rn(reg), r1, i0);
1486 ldr_uc(r0, rn(reg));
1492 _ldxr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1495 reg = jit_get_reg(jit_class_gpr);
1496 addr(rn(reg), r1, r2);
1502 _ldxi_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1505 if (can_sign_extend_short_p(i0))
1508 reg = jit_get_reg(jit_class_gpr);
1509 addi(rn(reg), r1, i0);
1516 _ldxr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1519 reg = jit_get_reg(jit_class_gpr);
1520 addr(rn(reg), r1, r2);
1521 ldr_us(r0, rn(reg));
1526 _ldxi_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1529 if (can_sign_extend_short_p(i0))
1532 reg = jit_get_reg(jit_class_gpr);
1533 addi(rn(reg), r1, i0);
1534 ldr_us(r0, rn(reg));
1540 _ldxr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1543 reg = jit_get_reg(jit_class_gpr);
1544 addr(rn(reg), r1, r2);
1550 _ldxi_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1553 if (can_sign_extend_short_p(i0))
1556 reg = jit_get_reg(jit_class_gpr);
1557 addi(rn(reg), r1, i0);
1563 #if __WORDSIZE == 64
1565 _ldxr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1568 reg = jit_get_reg(jit_class_gpr);
1569 addr(rn(reg), r1, r2);
1570 ldr_ui(r0, rn(reg));
1575 _ldxi_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1578 if (can_sign_extend_short_p(i0))
1581 reg = jit_get_reg(jit_class_gpr);
1582 addi(rn(reg), r1, i0);
1583 ldr_ui(r0, rn(reg));
1589 _ldxr_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1592 reg = jit_get_reg(jit_class_gpr);
1593 addr(rn(reg), r1, r2);
1599 _ldxi_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1602 if (can_sign_extend_short_p(i0))
1605 reg = jit_get_reg(jit_class_gpr);
1606 addi(rn(reg), r1, i0);
1614 _sti_c(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
1617 if (can_sign_extend_short_p(i0))
1618 SB(r0, i0, _ZERO_REGNO);
1620 reg = jit_get_reg(jit_class_gpr);
1628 _sti_s(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
1631 if (can_sign_extend_short_p(i0))
1632 SH(r0, i0, _ZERO_REGNO);
1634 reg = jit_get_reg(jit_class_gpr);
1642 _sti_i(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
1645 if (can_sign_extend_short_p(i0))
1646 SW(r0, i0, _ZERO_REGNO);
1648 reg = jit_get_reg(jit_class_gpr);
1655 #if __WORDSIZE == 64
1657 _sti_l(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
1660 if (can_sign_extend_short_p(i0))
1661 SD(r0, i0, _ZERO_REGNO);
1663 reg = jit_get_reg(jit_class_gpr);
1672 _stxr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1675 reg = jit_get_reg(jit_class_gpr);
1676 addr(rn(reg), r0, r1);
1682 _stxi_c(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1685 if (can_sign_extend_short_p(i0))
1688 reg = jit_get_reg(jit_class_gpr);
1689 addi(rn(reg), r0, i0);
1696 _stxr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1699 reg = jit_get_reg(jit_class_gpr);
1700 addr(rn(reg), r0, r1);
1706 _stxi_s(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1709 if (can_sign_extend_short_p(i0))
1712 reg = jit_get_reg(jit_class_gpr);
1713 addi(rn(reg), r0, i0);
1720 _stxr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1723 reg = jit_get_reg(jit_class_gpr);
1724 addr(rn(reg), r0, r1);
1730 _stxi_i(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1733 if (can_sign_extend_short_p(i0))
1736 reg = jit_get_reg(jit_class_gpr);
1737 addi(rn(reg), r0, i0);
1743 #if __WORDSIZE == 64
1745 _stxr_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1 ,jit_int32_t r2)
1748 reg = jit_get_reg(jit_class_gpr);
1749 addr(rn(reg), r0, r1);
1755 _stxi_l(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1758 if (can_sign_extend_short_p(i0))
1761 reg = jit_get_reg(jit_class_gpr);
1762 addi(rn(reg), r0, i0);
1770 _bswapr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1772 if (jit_mips2_p()) {
1776 generic_bswapr_us(_jit, r0, r1);
1781 _bswapr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1783 if (jit_mips2_p()) {
1784 if (__WORDSIZE == 64) {
1788 extr(r0, r0, 0, 32);
1794 generic_bswapr_ui(_jit, r0, r1);
1799 _extr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1804 lshi(r0, r1, __WORDSIZE - 8);
1805 rshi(r0, r0, __WORDSIZE - 8);
1810 _extr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1815 lshi(r0, r1, __WORDSIZE - 16);
1816 rshi(r0, r0, __WORDSIZE - 16);
1820 # if __WORDSIZE == 64
1822 _extr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1825 DEXT(r0, r1, 0, 32);
1834 _lti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1838 if (can_sign_extend_short_p(i0))
1841 reg = jit_get_reg(jit_class_gpr);
1843 ltr(r0, r1, rn(reg));
1849 _lti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1853 if (can_sign_extend_short_p(i0))
1856 reg = jit_get_reg(jit_class_gpr);
1858 ltr_u(r0, r1, rn(reg));
1864 _ler(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1871 _lei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1875 if (can_sign_extend_short_p(i0 + 1))
1876 SLTI(r0, r1, i0 + 1);
1878 reg = jit_get_reg(jit_class_gpr);
1880 ler(r0, r1, rn(reg));
1886 _ler_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1893 _lei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1897 if (can_sign_extend_short_p(i0 + 1))
1898 SLTIU(r0, r1, i0 + 1);
1900 reg = jit_get_reg(jit_class_gpr);
1902 ler_u(r0, r1, rn(reg));
1908 _eqr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1911 SLTU(r0, _ZERO_REGNO, r0);
1916 _eqi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1920 SLTU(r0, _ZERO_REGNO, r0);
1923 SLTU(r0, _ZERO_REGNO, r1);
1928 _ger(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1935 _gei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1939 if (can_sign_extend_short_p(i0)) {
1943 reg = jit_get_reg(jit_class_gpr);
1945 ger(r0, r1, rn(reg));
1951 _ger_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1958 _gei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1962 if (can_sign_extend_short_p(i0)) {
1966 reg = jit_get_reg(jit_class_gpr);
1968 ger_u(r0, r1, rn(reg));
1974 _gti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1979 SLT(r0, _ZERO_REGNO, r1);
1981 reg = jit_get_reg(jit_class_gpr);
1983 SLT(r0, rn(reg), r1);
1989 _gti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1994 SLTU(r0, _ZERO_REGNO, r1);
1996 reg = jit_get_reg(jit_class_gpr);
1998 SLTU(r0, rn(reg), r1);
2004 _ner(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2007 SLTU(r0, _ZERO_REGNO, r0);
2011 _nei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2015 SLTU(r0, _ZERO_REGNO, r0);
2018 SLTU(r0, _ZERO_REGNO, r1);
2022 _bltr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2027 reg = jit_get_reg(jit_class_gpr);
2028 SLT(rn(reg), r0, r1);
2030 BNE(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2038 _bltr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2043 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2044 SLTU(rn(reg), r0, r1);
2046 BNE(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2054 _blti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2061 if (!(zero_p = i1 == 0))
2062 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2063 if (can_sign_extend_short_p(i1)) {
2065 SLTI(rn(reg), r0, i1);
2067 d = ((i0 - w) >> 2) - 1;
2069 BNE(rn(reg), _ZERO_REGNO, d);
2076 w = bltr(i0, r0, rn(reg));
2085 _blti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2090 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2091 if (can_sign_extend_short_p(i1)) {
2092 SLTIU(rn(reg), r0, i1);
2094 BNE(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2099 w = bltr_u(i0, r0, rn(reg));
2107 _bler(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2112 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2113 SLT(rn(reg), r1, r0);
2115 BEQ(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2123 _bler_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2128 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2129 SLTU(rn(reg), r1, r0);
2131 BEQ(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2139 _blei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2146 BLEZ(r0, ((i0 - w) >> 2) - 1);
2150 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2152 w = bler(i0, r0, rn(reg));
2160 _blei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2167 BEQ(r0, _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2171 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2173 w = bler_u(i0, r0, rn(reg));
2181 _beqr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2186 BEQ(r0, r1, ((i0 - w) >> 2) - 1);
2193 _beqi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2200 BEQ(r0, _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2204 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2206 w = beqr(i0, r0, rn(reg));
2214 _bger(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2219 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2220 SLT(rn(reg), r0, r1);
2222 BEQ(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2230 _bger_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2235 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2236 SLTU(rn(reg), r0, r1);
2238 BEQ(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2246 _bgei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2253 if (!(zero_p = i1 == 0))
2254 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2255 if (can_sign_extend_short_p(i1)) {
2257 SLTI(rn(reg), r0, i1);
2259 d = ((i0 - w) >> 2) - 1;
2261 BEQ(rn(reg), _ZERO_REGNO, d);
2268 w = bger(i0, r0, rn(reg));
2277 _bgei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2282 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2283 if (can_sign_extend_short_p(i1)) {
2284 SLTIU(rn(reg), r0, i1);
2286 BEQ(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2291 w = bger_u(i0, r0, rn(reg));
2299 _bgtr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2304 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2305 SLT(rn(reg), r1, r0);
2307 BNE(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2315 _bgtr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2320 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2321 SLTU(rn(reg), r1, r0);
2323 BNE(rn(reg), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2331 _bgti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2338 BGTZ(r0, ((i0 - w) >> 2) - 1);
2342 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2344 w = bgtr(i0, r0, rn(reg));
2352 _bgti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2359 BNE(r0, _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2363 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2365 w = bgtr_u(i0, r0, rn(reg));
2373 _bner(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2378 BNE(r0, r1, ((i0 - w) >> 2) - 1);
2385 _bnei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2392 BNE(r0, _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2396 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2398 w = bner(i0, r0, rn(reg));
2406 _jmpr(jit_state_t *_jit, jit_int32_t r0)
2413 _jmpi(jit_state_t *_jit, jit_word_t i0)
2419 if (((w + sizeof(jit_int32_t)) & 0xf0000000) == (i0 & 0xf0000000)) {
2420 J((i0 & ~0xf0000000) >> 2);
2424 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2425 movi_p(rn(reg), i0);
2434 _boaddr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2441 /* t1 = r0 + r1; overflow = r1 < 0 ? r0 < t1 : t1 < r0 */
2442 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2443 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2444 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2445 SLT(rn(t0), r1, _ZERO_REGNO); /* t0 = r1 < 0 */
2446 addr(rn(t1), r0, r1); /* t1 = r0 + r1 */
2447 SLT(rn(t2), rn(t1), r0); /* t2 = t1 < r0 */
2448 SLT(rn(t1), r0, rn(t1)); /* t1 = r0 < t1 */
2449 MOVZ(rn(t1), rn(t2), rn(t0)); /* if (r0 == 0) t1 = t2 */
2451 BNE(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2462 _boaddi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2469 if (can_sign_extend_short_p(i1)) {
2470 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2471 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2472 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2473 SLTI(rn(t0), _ZERO_REGNO, i1);
2474 addiu(rn(t1), r0, i1);
2475 SLT(rn(t2), r0, rn(t1));
2476 SLT(rn(t1), rn(t1), r0);
2477 MOVZ(rn(t1), rn(t2), rn(t0));
2479 BNE(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2487 t0 = jit_get_reg(jit_class_gpr);
2489 w = boaddr(i0, r0, rn(t0));
2496 _boaddr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2502 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2503 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2504 addr(rn(t0), r0, r1);
2505 SLTU(rn(t1), rn(t0), r0);
2507 BNE(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2516 _boaddi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2522 if (can_sign_extend_short_p(i0)) {
2523 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2524 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2525 addiu(rn(t0), r0, i1);
2526 SLTU(rn(t1), rn(t0), r0);
2528 BNE(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2535 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2537 w = boaddr_u(i0, r0, rn(t0));
2544 _bxaddr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2551 /* t1 = r0 + r1; overflow = r1 < 0 ? r0 < t1 : t1 < r0 */
2552 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2553 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2554 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2555 SLT(rn(t0), r1, _ZERO_REGNO); /* t0 = r1 < 0 */
2556 addr(rn(t1), r0, r1); /* t1 = r0 + r1 */
2557 SLT(rn(t2), rn(t1), r0); /* t2 = t1 < r0 */
2558 SLT(rn(t1), r0, rn(t1)); /* t1 = r0 < t1 */
2559 MOVZ(rn(t1), rn(t2), rn(t0)); /* if (r0 == 0) t1 = t2 */
2561 BEQ(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2572 _bxaddi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2579 if (can_sign_extend_short_p(i1)) {
2580 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2581 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2582 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2583 SLTI(rn(t0), _ZERO_REGNO, i1);
2584 addiu(rn(t1), r0, i1);
2585 SLT(rn(t2), r0, rn(t1));
2586 SLT(rn(t1), rn(t1), r0);
2587 MOVZ(rn(t1), rn(t2), rn(t0));
2589 BEQ(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2597 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2599 w = bxaddr(i0, r0, rn(t0));
2606 _bxaddr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2612 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2613 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2614 addr(rn(t0), r0, r1);
2615 SLTU(rn(t1), rn(t0), r0);
2617 BEQ(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2626 _bxaddi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2632 if (can_sign_extend_short_p(i0)) {
2633 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2634 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2635 addiu(rn(t0), r0, i1);
2636 SLTU(rn(t1), rn(t0), r0);
2638 BEQ(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2645 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2647 w = bxaddr_u(i0, r0, rn(t0));
2654 _bosubr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2661 /* t1 = r0 - r1; overflow = 0 < r1 ? r0 < t1 : t1 < r0 */
2662 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2663 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2664 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2665 SLT(rn(t0), _ZERO_REGNO, r1); /* t0 = 0 < r1 */
2666 subr(rn(t1), r0, r1); /* t1 = r0 - r1 */
2667 SLT(rn(t2), rn(t1), r0); /* t2 = t1 < r0 */
2668 SLT(rn(t1), r0, rn(t1)); /* t1 = r0 < t1 */
2669 MOVZ(rn(t1), rn(t2), rn(t0)); /* if (r0 == 0) t1 = t2 */
2671 BNE(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2682 _bosubi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2689 if (can_sign_extend_short_p(i1) && (i1 & 0xffff) != 0x8000) {
2690 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2691 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2692 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2693 SLTI(rn(t0), _ZERO_REGNO, i1);
2694 addiu(rn(t1), r0, -i1);
2695 SLT(rn(t2), rn(t1), r0);
2696 SLT(rn(t1), r0, rn(t1));
2697 MOVZ(rn(t1), rn(t2), rn(t0));
2699 BNE(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2707 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2709 w = bosubr(i0, r0, rn(t0));
2716 _bosubr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2722 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2723 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2724 subr(rn(t0), r0, r1);
2725 SLTU(rn(t1), r0, rn(t0));
2727 BNE(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2736 _bosubi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2742 if (can_sign_extend_short_p(i0) && (i0 & 0xffff) != 0x8000) {
2743 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2744 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2745 addiu(rn(t0), r0, -i1);
2746 SLTU(rn(t1), r0, rn(t0));
2748 BNE(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2755 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2757 w = bosubr_u(i0, r0, rn(t0));
2764 _bxsubr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2771 /* t1 = r0 - r1; overflow = 0 < r1 ? r0 < t1 : t1 < r0 */
2772 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2773 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2774 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2775 SLT(rn(t0), _ZERO_REGNO, r1); /* t0 = 0 < r1 */
2776 subr(rn(t1), r0, r1); /* t1 = r0 - r1 */
2777 SLT(rn(t2), rn(t1), r0); /* t2 = t1 < r0 */
2778 SLT(rn(t1), r0, rn(t1)); /* t1 = r0 < t1 */
2779 MOVZ(rn(t1), rn(t2), rn(t0)); /* if (t0 == 0) t1 = t2 */
2781 BEQ(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2792 _bxsubi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2799 if (can_sign_extend_short_p(i1) && (i1 & 0xffff) != 0x8000) {
2800 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2801 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2802 t2 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2803 SLTI(rn(t0), _ZERO_REGNO, i1);
2804 addiu(rn(t1), r0, -i1);
2805 SLT(rn(t2), rn(t1), r0);
2806 SLT(rn(t1), r0, rn(t1));
2807 MOVZ(rn(t1), rn(t2), rn(t0));
2809 BEQ(rn(t1), _ZERO_REGNO, ((i0 - w) >> 2) - 1);
2817 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2819 w = bxsubr(i0, r0, rn(t0));
2826 _bxsubr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2832 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2833 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2834 subr(rn(t0), r0, r1);
2835 SLTU(rn(t1), r0, rn(t0));
2837 BEQ(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2846 _bxsubi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2852 if (can_sign_extend_short_p(i0) && (i0 & 0xffff) != 0x8000) {
2853 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2854 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2855 addiu(rn(t0), r0, -i1);
2856 SLTU(rn(t1), r0, rn(t0));
2858 BEQ(_ZERO_REGNO, rn(t1), ((i0 - w) >> 2) - 1);
2865 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2867 w = bxsubr_u(i0, r0, rn(t0));
2874 _bmsr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2878 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2879 AND(rn(t0), r0, r1);
2881 BNE(_ZERO_REGNO, rn(t0), ((i0 - w) >> 2) - 1);
2888 _bmsi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2892 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2894 andi(rn(t0), r0, i1);
2896 BNE(_ZERO_REGNO, rn(t0), ((i0 - w) >> 2) - 1);
2904 _bmcr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2908 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2909 AND(rn(t0), r0, r1);
2911 BEQ(_ZERO_REGNO, rn(t0), ((i0 - w) >> 2) - 1);
2918 _bmci(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
2922 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
2924 andi(rn(t0), r0, i1);
2926 BEQ(_ZERO_REGNO, rn(t0), ((i0 - w) >> 2) - 1);
2934 _callr(jit_state_t *_jit, jit_int32_t r0)
2937 if (r0 != _T9_REGNO)
2938 movr(_T9_REGNO, r0);
2944 _calli(jit_state_t *_jit, jit_word_t i0)
2946 if (((_jit->pc.w + sizeof(jit_int32_t)) & 0xf0000000) == (i0 & 0xf0000000)) {
2947 if (can_sign_extend_short_p(i0)) {
2948 JAL((i0 & ~0xf0000000) >> 2);
2949 addiu(_T9_REGNO, _ZERO_REGNO, i0);
2953 if (can_zero_extend_short_p(i0)) {
2954 JAL((i0 & ~0xf0000000) >> 2);
2955 ORI(_T9_REGNO, _ZERO_REGNO, i0);
2959 if (can_sign_extend_int_p(i0)) {
2961 LUI(_T9_REGNO, i0 >> 16);
2962 JAL((i0 & ~0xf0000000) >> 2);
2963 ORI(_T9_REGNO, _T9_REGNO, i0);
2965 JAL((i0 & ~0xf0000000) >> 2);
2966 LUI(_T9_REGNO, i0 >> 16);
2972 movi(_T9_REGNO, i0);
2978 _calli_p(jit_state_t *_jit, jit_word_t i0)
2983 movi_p(_T9_REGNO, i0);
2990 static jit_int32_t fregs[] = {
2991 _F30, _F28, _F26, _F24, _F22, _F20,
2997 static jit_int32_t iregs[] = {
2998 _S7, _S6, _S5, _S4, _S3, _S2, _S1, _S0,
3002 _prolog(jit_state_t *_jit, jit_node_t *node)
3006 if (_jitc->function->define_frame || _jitc->function->assume_frame) {
3007 jit_int32_t frame = -_jitc->function->frame;
3008 assert(_jitc->function->self.aoff >= frame);
3009 if (_jitc->function->assume_frame)
3011 _jitc->function->self.aoff = frame;
3013 if (_jitc->function->allocar)
3014 _jitc->function->self.aoff &= -8;
3016 _jitc->function->stack = ((_jitc->function->self.alen -
3017 /* align stack at 16 bytes */
3018 _jitc->function->self.aoff) + 15) & -16;
3020 _jitc->function->stack = ((/* first 16 bytes must be allocated */
3021 (_jitc->function->self.alen > 16 ?
3022 _jitc->function->self.alen : 16) -
3023 /* align stack at 8 bytes */
3024 _jitc->function->self.aoff) + 7) & -8;
3026 /* callee save registers */
3028 if ((_jitc->function->self.call & jit_call_varargs) &&
3029 jit_arg_reg_p(_jitc->function->vagp))
3030 subi(_SP_REGNO, _SP_REGNO, stack_framesize + 64);
3033 subi(_SP_REGNO, _SP_REGNO, stack_framesize);
3034 offset = stack_framesize - (sizeof(jit_word_t) << 1);
3035 for (index = 0; index < jit_size(fregs); index++, offset -= 8) {
3036 if (jit_regset_tstbit(&_jitc->function->regset, fregs[index]))
3037 stxi_d(offset, _SP_REGNO, rn(fregs[index]));
3039 for (index = 0; index < jit_size(iregs);
3040 index++, offset -= sizeof(jit_word_t)) {
3041 if (jit_regset_tstbit(&_jitc->function->regset, iregs[index]))
3042 stxi(offset, _SP_REGNO, rn(iregs[index]));
3044 assert(offset >= sizeof(jit_word_t));
3045 stxi(offset, _SP_REGNO, _RA_REGNO);
3046 stxi(0, _SP_REGNO, _BP_REGNO);
3047 movr(_BP_REGNO, _SP_REGNO);
3050 if (_jitc->function->stack)
3051 subi(_SP_REGNO, _SP_REGNO, _jitc->function->stack);
3052 if (_jitc->function->allocar) {
3053 index = jit_get_reg(jit_class_gpr);
3054 movi(rn(index), _jitc->function->self.aoff);
3055 stxi_i(_jitc->function->aoffoff, _BP_REGNO, rn(index));
3056 jit_unget_reg(index);
3059 if (_jitc->function->self.call & jit_call_varargs) {
3061 index = _jitc->function->vagp;
3063 index = (_jitc->function->self.size - stack_framesize) >> STACK_SHIFT;
3065 offset = stack_framesize + index * STACK_SLOT;
3066 for (; jit_arg_reg_p(index); ++index, offset += STACK_SLOT) {
3068 SD(rn(_A0 - index), offset, _BP_REGNO);
3070 stxi(offset + WORD_ADJUST, _BP_REGNO, rn(_A0 - index));
3077 _epilog(jit_state_t *_jit, jit_node_t *node)
3081 if (_jitc->function->assume_frame)
3083 /* callee save registers */
3084 movr(_SP_REGNO, _BP_REGNO);
3085 offset = stack_framesize - (sizeof(jit_word_t) << 1);
3086 for (index = 0; index < jit_size(fregs); index++, offset -= 8) {
3087 if (jit_regset_tstbit(&_jitc->function->regset, fregs[index]))
3088 ldxi_d(rn(fregs[index]), _SP_REGNO, offset);
3090 for (index = 0; index < jit_size(iregs);
3091 index++, offset -= sizeof(jit_word_t)) {
3092 if (jit_regset_tstbit(&_jitc->function->regset, iregs[index]))
3093 ldxi(rn(iregs[index]), _SP_REGNO, offset);
3095 assert(offset >= sizeof(jit_word_t));
3096 ldxi(_RA_REGNO, _SP_REGNO, offset);
3097 ldxi(_BP_REGNO, _SP_REGNO, 0);
3101 if ((_jitc->function->self.call & jit_call_varargs) &&
3102 jit_arg_reg_p(_jitc->function->vagp))
3103 addi(_SP_REGNO, _SP_REGNO, stack_framesize + 64);
3106 addi(_SP_REGNO, _SP_REGNO, stack_framesize);
3110 _vastart(jit_state_t *_jit, jit_int32_t r0)
3112 assert(_jitc->function->self.call & jit_call_varargs);
3113 /* Initialize va_list to the first stack argument. */
3115 if (jit_arg_reg_p(_jitc->function->vagp))
3116 addi(r0, _BP_REGNO, stack_framesize + _jitc->function->vagp *
3117 sizeof(jit_int64_t));
3120 addi(r0, _BP_REGNO, _jitc->function->self.size);
3124 _vaarg(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3126 /* Load argument. */
3128 ldxi(r0, r1, WORD_ADJUST);
3133 /* Update va_list. */
3134 addi(r1, r1, STACK_SLOT);
3138 _patch_abs(jit_state_t *_jit, jit_word_t instr, jit_word_t label)
3147 #if __WORDSIZE == 32
3149 assert(i.hc.b == MIPS_LUI);
3150 i.is.b = label >> 16;
3153 assert(i.hc.b == MIPS_ORI);
3158 assert(i.hc.b == MIPS_LUI);
3159 i.is.b = label >> 48;
3162 assert(i.hc.b == MIPS_ORI);
3163 i.is.b = label >> 32;
3167 assert(i.hc.b == MIPS_ORI);
3168 i.is.b = label >> 16;
3172 assert(i.hc.b == MIPS_ORI);
3179 _patch_at(jit_state_t *_jit, jit_word_t instr, jit_word_t label)
3190 /* 16 bit immediate opcodes */
3193 case MIPS_BLTZ: case MIPS_BLTZL:
3194 case MIPS_BLTZAL: case MIPS_BLTZALL:
3195 case MIPS_BGEZ: case MIPS_BGEZAL:
3196 case MIPS_BGEZALL: case MIPS_BGEZL:
3197 case MIPS_TEQI: case MIPS_TGEI:
3198 case MIPS_TGEIU: case MIPS_TLTI:
3199 case MIPS_TLTIU: case MIPS_TNEI:
3200 i.is.b = ((label - instr) >> 2) - 1;
3204 assert(!"unhandled branch opcode");
3209 case MIPS_COP1: case MIPS_COP2:
3210 assert(i.rs.b == MIPS_BC);
3212 case MIPS_BCF: case MIPS_BCFL:
3213 case MIPS_BCT: case MIPS_BCTL:
3214 i.is.b = ((label - instr) >> 2) - 1;
3218 assert(!"unhandled branch opcode");
3223 case MIPS_BLEZ: case MIPS_BLEZL:
3224 case MIPS_BEQ: case MIPS_BEQL:
3225 case MIPS_BGTZ: case MIPS_BGTZL:
3226 case MIPS_BNE: case MIPS_BNEL:
3227 i.is.b = ((label - instr) >> 2) - 1;
3232 patch_abs(instr, label);
3235 case MIPS_J: case MIPS_JAL:
3237 assert(((instr + sizeof(jit_int32_t)) & 0xf0000000) ==
3238 (label & 0xf0000000));
3239 i.ii.b = (label & ~0xf0000000) >> 2;
3244 assert(!"unhandled branch opcode");