2 * Copyright (C) 2014-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
21 # define _u2(v) ((v) & 0x3)
22 # define _s2_p(v) ((v) >= -0x2 && (v) <= 0x1)
23 # define _u2_p(v) ((v) >= 0 && (v) <= 0x3)
24 # define _u5(v) ((v) & 0x1f)
25 # define _s5_p(v) ((v) >= -0x10 && (v) <= 0xf)
26 # define _u5_p(v) ((v) >= 0 && (v) <= 0x1f)
27 # define _u6(v) ((v) & 0x3f)
28 # define _s6_p(v) ((v) >= -0x20 && (v) <= 0x1f)
29 # define _u6_p(v) ((v) >= 0 && (v) <= 0x3f)
30 # define _u7(v) ((v) & 0x7f)
31 # define _s7_p(v) ((v) >= -0x40 && (v) <= 0x3f)
32 # define _u7_p(v) ((v) >= 0 && (v) <= 0x7f)
33 # define _u8(v) ((v) & 0xff)
34 # define _s8_p(v) ((v) >= -0x80 && (v) <= 0x7f)
35 # define _u8_p(v) ((v) >= 0 && (v) <= 0xff)
36 # define _u11(v) ((v) & 0x7ff)
37 # define _s11_p(v) ((v) >= -0x400 && (v) <= 0x3ff)
38 # define _u11_p(v) ((v) >= 0 && (v) <= 0x7ff)
39 # define _u14(v) ((v) & 0x3fff)
40 # define _s14_p(v) ((v) >= -0x2000 && (v) <= 0x1fff)
41 # define _u14_p(v) ((v) >= 0 && (v) <= 0x3fff)
42 # define _u16(v) ((v) & 0xffff)
43 # define _s16_p(v) ((v) >= -0x8000 && (v) <= 0x7fff)
44 # define _u16_p(v) ((v) >= 0 && (v) <= 0xffff)
45 # define _u21(v) ((v) & 0x1fffff)
46 # define _s21_p(v) ((v) >= -0x100000 && (v) <= 0xfffff)
47 # define _u21_p(v) ((v) >= 0 && (v) <= 0x1fffff)
48 # define _u26(v) ((v) & 0x3ffffff)
49 # define _s26_p(v) ((v) >= -0x2000000 && (v) <= 0x1ffffff)
50 # define _u26_p(v) ((v) >= 0 && (v) <= 0x3ffffff)
51 # define _u32(v) ((v) & 0xffffffff)
52 # define _s32_p(v) ((v) >= -0x80000000 && (v) <= 0x7fffffff)
53 # define _u32_p(v) ((v) >= 0 && (v) <= 0xffffffff)
54 # define ii(i) *_jit->pc.ui++ = i
55 # define stack_framesize 224
56 # define _S0_REGNO 0x09
57 # define _S1_REGNO 0x0a
58 # define _S2_REGNO 0x0b
59 # define _S3_REGNO 0x0c
60 # define _S4_REGNO 0x0d
61 # define _S5_REGNO 0x0e
62 # define _FP_REGNO 0x0f
63 # define _A0_REGNO 0x10
64 # define _A1_REGNO 0x11
65 # define _A2_REGNO 0x12
66 # define _V0_REGNO 0x00
67 # define _T0_REGNO 0x01
68 # define _T1_REGNO 0x02
69 # define _RA_REGNO 0x1a
70 # define _PV_REGNO 0x1b
71 # define _GP_REGNO 0x1d
72 # define _SP_REGNO 0x1e
73 # define _R31_REGNO 0x1f
74 # define Pcd(o,n) _Pcd(_jit,o,n)
75 static void _Pcd(jit_state_t*,int,unsigned int) maybe_unused;
76 # define Bra(o,ra,d) _Bra(_jit,o,ra,d)
77 static void _Bra(jit_state_t*,int,int,int);
78 # define Mem(o,ra,rb,d) _Mem(_jit,o,ra,rb,d)
79 static void _Mem(jit_state_t*,int,int,int,unsigned int);
80 # define Mbr(o,ra,rb,h,d) _Mbr(_jit,o,ra,rb,h,d)
81 static void _Mbr(jit_state_t*,int,int,int,int,int);
82 # define Opr(o,ra,rb,f,rc) _Opr(_jit,o,ra,rb,f,rc)
83 static void _Opr(jit_state_t*,int,int,int,unsigned int,int);
84 # define Opi(o,ra,i,f,rc) _Opi(_jit,o,ra,i,f,rc)
85 static void _Opi(jit_state_t*,int,int,unsigned int,unsigned int,int);
86 # define ADDL(ra,rb,rc) Opr(0x10,ra,rb,0x00,rc)
87 # define ADDLi(ra,im,rc) Opi(0x10,ra,im,0x00,rc)
88 # define ADDL_V(ra,rb,rc) Opr(0x10,ra,rb,0x40,rc)
89 # define ADDL_Vi(ra,im,rc) Opi(0x10,ra,im,0x40,rc)
90 # define ADDQ(ra,rb,rc) Opr(0x10,ra,rb,0x20,rc)
91 # define ADDQi(ra,im,rc) Opi(0x10,ra,im,0x20,rc)
92 # define ADDQ_V(ra,rb,rc) Opr(0x10,ra,rb,0x60,rc)
93 # define ADDQ_Vi(ra,im,rc) Opi(0x10,ra,im,0x60,rc)
94 # define AMASK(rb,rc) Opr(0x11,_R31_REGNO,rb,0x61,rc)
95 # define AND(ra,rb,rc) Opr(0x11,ra,rb,0x00,rc)
96 # define ANDi(ra,im,rc) Opi(0x11,ra,im,0x00,rc)
97 # define BEQ(ra,d) Bra(0x39,ra,d)
98 # define BGE(ra,d) Bra(0x3e,ra,d)
99 # define BGT(ra,d) Bra(0x3f,ra,d)
100 # define BIC(ra,rb,rc) Opr(0x11,ra,rb,0x08,rc)
101 # define ANDNOT(ra,rb,rc) BIC(ra,rb,rc)
102 # define BICi(ra,im,rc) Opi(0x11,ra,im,0x08,rc)
103 # define ANDNOTi(ra,im,rc) BICi(ra,im,rc)
104 # define BIS(ra,rb,rc) Opr(0x11,ra,rb,0x20,rc)
105 # define BISi(ra,im,rc) Opi(0x11,ra,im,0x20,rc)
106 # define OR(ra,rb,rc) BIS(ra,rb,rc)
107 # define ORi(ra,im,rc) BISi(ra,im,rc)
108 # define BLBC(ra,d) Bra(0x38,ra,d)
109 # define BLBS(ra,d) Bra(0x3c,ra,d)
110 # define BLE(ra,d) Bra(0x3b,ra,d)
111 # define BLT(ra,d) Bra(0x3a,ra,d)
112 # define BNE(ra,d) Bra(0x3d,ra,d)
113 # define BR(ra,d) Bra(0x30,ra,d)
114 # define BSR(ra,d) Bra(0x34,ra,d)
115 # define CALL_PAL(c) Pcd(0x00,c)
116 # define CMOVEQ(ra,rb,rc) Opr(0x11,ra,rb,0x24,rc)
117 # define CMOVEQi(ra,im,rc) Opi(0x11,ra,im,0x24,rc)
118 # define CMOVGE(ra,rb,rc) Opr(0x11,ra,rb,0x46,rc)
119 # define CMOVGEi(ra,im,rc) Opi(0x11,ra,im,0x46,rc)
120 # define CMOVGT(ra,rb,rc) Opr(0x11,ra,rb,0x66,rc)
121 # define CMOVGTi(ra,im,rc) Opi(0x11,ra,im,0x66,rc)
122 # define CMOVLBC(ra,rb,rc) Opr(0x11,ra,rb,0x16,rc)
123 # define CMOVLBCi(ra,im,rc) Opi(0x11,ra,im,0x16,rc)
124 # define CMOVLBS(ra,rb,rc) Opr(0x11,ra,rb,0x14,rc)
125 # define CMOVLBSi(ra,im,rc) Opi(0x11,ra,im,0x14,rc)
126 # define CMOVLE(ra,rb,rc) Opr(0x11,ra,rb,0x64,rc)
127 # define CMOVLEi(ra,im,rc) Opi(0x11,ra,im,0x64,rc)
128 # define CMOVLT(ra,rb,rc) Opr(0x11,ra,rb,0x44,rc)
129 # define CMOVLTi(ra,im,rc) Opi(0x11,ra,im,0x44,rc)
130 # define CMOVNE(ra,rb,rc) Opr(0x11,ra,rb,0x26,rc)
131 # define CMOVNEi(ra,im,rc) Opi(0x11,ra,im,0x26,rc)
132 # define CMPBGE(ra,rb,rc) Opr(0x10,ra,rb,0x0f,rc)
133 # define CMPBGEi(ra,im,rc) Opi(0x10,ra,im,0x0f,rc)
134 # define CMPEQ(ra,rb,rc) Opr(0x10,ra,rb,0x2d,rc)
135 # define CMPEQi(ra,im,rc) Opi(0x10,ra,im,0x2d,rc)
136 # define CMPLE(ra,rb,rc) Opr(0x10,ra,rb,0x6d,rc)
137 # define CMPLEi(ra,im,rc) Opi(0x10,ra,im,0x6d,rc)
138 # define CMPLT(ra,rb,rc) Opr(0x10,ra,rb,0x4d,rc)
139 # define CMPLTi(ra,im,rc) Opi(0x10,ra,im,0x4d,rc)
140 # define CMPULE(ra,rb,rc) Opr(0x10,ra,rb,0x3d,rc)
141 # define CMPULEi(ra,im,rc) Opi(0x10,ra,im,0x3d,rc)
142 # define CMPULT(ra,rb,rc) Opr(0x10,ra,rb,0x1d,rc)
143 # define CMPULTi(ra,im,rc) Opi(0x10,ra,im,0x1d,rc)
144 # define CTLZ(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x32,rc)
145 # define CTPOP(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x30,rc)
146 # define CTTZ(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x33,rc)
147 # define ECB(rb,d) Mem(0x18,_R31_REGNO,rb,0xe800)
148 # define EQV(ra,rb,rc) Opr(0x11,ra,rb,0x48,rc)
149 # define XORNOT(ra,rb,rc) EQV(ra,rb,rc)
150 # define EQVi(ra,im,rc) Opi(0x11,ra,im,0x48,rc)
151 # define XORNOTi(ra,im,rc) EQVi(ra,im,rc)
152 # define EXCB() Mem(0x18,0,0,0x0400)
153 # define EXTBL(ra,rb,rc) Opr(0x12,ra,rb,0x06,rc)
154 # define EXTBLi(ra,im,rc) Opi(0x12,ra,im,0x06,rc)
155 # define EXTLH(ra,rb,rc) Opr(0x12,ra,rb,0x6a,rc)
156 # define EXTLHi(ra,im,rc) Opi(0x12,ra,im,0x6a,rc)
157 # define EXTLL(ra,rb,rc) Opr(0x12,ra,rb,0x26,rc)
158 # define EXTLLi(ra,im,rc) Opi(0x12,ra,im,0x26,rc)
159 # define EXTQH(ra,rb,rc) Opr(0x12,ra,rb,0x7a,rc)
160 # define EXTQHi(ra,im,rc) Opi(0x12,ra,im,0x7a,rc)
161 # define EXTQL(ra,rb,rc) Opr(0x12,ra,rb,0x36,rc)
162 # define EXTQLi(ra,im,rc) Opi(0x12,ra,im,0x36,rc)
163 # define EXTWH(ra,rb,rc) Opr(0x12,ra,rb,0x5a,rc)
164 # define EXTWHi(ra,im,rc) Opi(0x12,ra,im,0x5a,rc)
165 # define EXTWL(ra,rb,rc) Opr(0x12,ra,rb,0x16,rc)
166 # define EXTWLi(ra,im,rc) Opi(0x12,ra,im,0x16,rc)
167 # define FETCH(rb,d) Mem(0x18,_R31_REGNO,rb,0x8000)
168 # define FETCH_Mem(rb,d) Mem(0x18,_R31_REGNO,rb,0xa000)
169 /* FIXME IMPLVER not disassembled */
170 # define IMPLVER(rc) Opr(0x11,_R31_REGNO,1,0x6c,rc)
171 # define INSBL(ra,rb,rc) Opr(0x12,ra,rb,0x0b,rc)
172 # define INSBLi(ra,im,rc) Opi(0x12,ra,im,0x0b,rc)
173 # define INSLH(ra,rb,rc) Opr(0x12,ra,rb,0x67,rc)
174 # define INSLHi(ra,im,rc) Opi(0x12,ra,im,0x67,rc)
175 # define INSLL(ra,rb,rc) Opr(0x12,ra,rb,0x2b,rc)
176 # define INSLLi(ra,im,rc) Opi(0x12,ra,im,0x2b,rc)
177 # define INSQH(ra,rb,rc) Opr(0x12,ra,rb,0x77,rc)
178 # define INSQHi(ra,im,rc) Opi(0x12,ra,im,0x77,rc)
179 # define INSQL(ra,rb,rc) Opr(0x12,ra,rb,0x3b,rc)
180 # define INSQLi(ra,im,rc) Opi(0x12,ra,im,0x3b,rc)
181 # define INSWH(ra,rb,rc) Opr(0x12,ra,rb,0x57,rc)
182 # define INSWHi(ra,im,rc) Opi(0x12,ra,im,0x57,rc)
183 # define INSWL(ra,rb,rc) Opr(0x12,ra,rb,0x1b,rc)
184 # define INSWLi(ra,im,rc) Opi(0x12,ra,im,0x1b,rc)
185 # define JMP(ra,rb,d) Mbr(0x1a,ra,rb,0,d)
186 # define JSR(ra,rb,d) Mbr(0x1a,ra,rb,1,d)
187 # define JSR_COROUTINE(ra,rb,d) Mbr(0x1a,ra,rb,3,d)
188 # define JCR(ra,rb,rd) JSR_COROUTINE(ra,rb,d)
189 # define LDA(ra,rb,d) Mem(0x08,ra,rb,d)
190 # define LDAH(ra,rb,d) Mem(0x09,ra,rb,d)
191 # define LDBU(ra,rb,d) Mem(0x0a,ra,rb,d)
192 # define LDWU(ra,rb,d) Mem(0x0c,ra,rb,d)
193 # define LDL(ra,rb,d) Mem(0x28,ra,rb,d)
194 # define LDL_L(ra,rb,d) Mem(0x2a,ra,rb,d)
195 # define LDQ(ra,rb,d) Mem(0x29,ra,rb,d)
196 # define LDQ_L(ra,rb,d) Mem(0x2b,ra,rb,d)
197 # define LDQ_U(ra,rb,d) Mem(0x0b,ra,rb,d)
198 # define MAXSB8(ra,rb,rc) Opr(0x1c,ra,rb,0x3e,rc)
199 # define MAXSW4(ra,rb,rc) Opr(0x1c,ra,rb,0x3f,rc)
200 # define MAXSUB8(ra,rb,rc) Opr(0x1c,ra,rb,0x3c,rc)
201 # define MAXSUW4(ra,rb,rc) Opr(0x1c,ra,rb,0x3d,rc)
202 # define MB() Mem(0x18,_R31_REGNO,_R31_REGNO,0x4000)
203 # define MINSB8(ra,rb,rc) Opr(0x1c,ra,rb,0x38,rc)
204 # define MINSW4(ra,rb,rc) Opr(0x1c,ra,rb,0x39,rc)
205 # define MINSUB8(ra,rb,rc) Opr(0x1c,ra,rb,0x3a,rc)
206 # define MINSUW4(ra,rb,rc) Opr(0x1c,ra,rb,0x3b,rc)
207 # define MSKBL(ra,rb,rc) Opr(0x12,ra,rb,0x02,rc)
208 # define MSKBLi(ra,im,rc) Opi(0x12,ra,im,0x02,rc)
209 # define MSKLH(ra,rb,rc) Opr(0x12,ra,rb,0x62,rc)
210 # define MSKLHi(ra,im,rc) Opi(0x12,ra,im,0x62,rc)
211 # define MSKLL(ra,rb,rc) Opr(0x12,ra,rb,0x22,rc)
212 # define MSKLLi(ra,im,rc) Opi(0x12,ra,im,0x22,rc)
213 # define MSKQH(ra,rb,rc) Opr(0x12,ra,rb,0x72,rc)
214 # define MSKQHi(ra,im,rc) Opi(0x12,ra,im,0x72,rc)
215 # define MSKQL(ra,rb,rc) Opr(0x12,ra,rb,0x32,rc)
216 # define MSKQLi(ra,im,rc) Opi(0x12,ra,im,0x32,rc)
217 # define MSKWH(ra,rb,rc) Opr(0x12,ra,rb,0x52,rc)
218 # define MSKWHi(ra,im,rc) Opi(0x12,ra,im,0x52,rc)
219 # define MSKWL(ra,rb,rc) Opr(0x12,ra,rb,0x12,rc)
220 # define MSKWLi(ra,im,rc) Opi(0x12,ra,im,0x12,rc)
221 # define MULL(ra,rb,rc) Opr(0x13,ra,rb,0x00,rc)
222 # define MULLi(ra,im,rc) Opi(0x13,ra,im,0x00,rc)
223 # define MULL_V(ra,rb,rc) Opr(0x13,ra,rb,0x40,rc)
224 # define MULL_Vi(ra,im,rc) Opi(0x13,ra,im,0x40,rc)
225 # define MULQ(ra,rb,rc) Opr(0x13,ra,rb,0x20,rc)
226 # define MULQi(ra,im,rc) Opi(0x13,ra,im,0x20,rc)
227 # define MULQ_V(ra,rb,rc) Opr(0x13,ra,rb,0x60,rc)
228 # define MULQ_Vi(ra,im,rc) Opi(0x13,ra,im,0x60,rc)
229 # define ORNOT(ra,rb,rc) Opr(0x11,ra,rb,0x28,rc)
230 # define ORNOTi(ra,im,rc) Opi(0x11,ra,im,0x28,rc)
231 # define PERR(ra,rb,rc) Opr(0x1c,ra,rb,0x31,rc)
232 # define PKLB(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x37,rc)
233 # define PKWB(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x36,rc)
234 /* FIXME PREFETCH* not disassembled */
235 # define PREFETCH(rb,d) Mem(0x28,_R31_REGNO,rb,d)
236 # define PREFETCH_EN(rb,d) Mem(0x29,_R31_REGNO,rb,d)
237 # define PREFETCH_M(rb,d) Mem(0x22,_R31_REGNO,rb,d)
238 # define PREFETCH_MEN(rb,d) Mem(0x23,_R31_REGNO,rb,d)
239 # define RC(ra) Mem(0x18,ra,_R31_REGNO,0xe000)
240 # define RET(ra,rb,d) Mbr(0x1a,ra,rb,2,d)
241 # define RPCC(ra) Mem(0x18,ra,_R31_REGNO,0xc000)
242 # define RS(ra) Mem(0x18,ra,_R31_REGNO,0xf000)
243 # define S4ADDL(ra,rb,rc) Opr(0x10,ra,rb,0x02,rc)
244 # define S4ADDi(ra,im,rc) Opi(0x10,ra,im,0x02,rc)
245 # define S4ADDQ(ra,rb,rc) Opr(0x10,ra,rb,0x22,rc)
246 # define S4ADDQi(ra,im,rc) Opi(0x10,ra,im,0x22,rc)
247 # define S4SUBL(ra,rb,rc) Opr(0x10,ra,rb,0x0b,rc)
248 # define S4SUBLi(ra,im,rc) Opi(0x10,ra,im,0x0b,rc)
249 # define S4SUBQ(ra,rb,rc) Opr(0x10,ra,rb,0x2b,rc)
250 # define S4SUBQi(ra,im,rc) Opi(0x10,ra,im,0x2b,rc)
251 # define S8ADDL(ra,rb,rc) Opr(0x10,ra,rb,0x12,rc)
252 # define S8ADDLi(ra,im,rc) Opi(0x10,ra,im,0x12,rc)
253 # define S8ADDQ(ra,rb,rc) Opr(0x10,ra,rb,0x32,rc)
254 # define S8ADDQi(ra,im,rc) Opi(0x10,ra,im,0x32,rc)
255 # define S8SUBL(ra,rb,rc) Opr(0x10,ra,rb,0x1b,rc)
256 # define S8SUBLi(ra,im,rc) Opi(0x10,ra,im,0x1b,rc)
257 # define S8SUBQ(ra,rb,rc) Opr(0x10,ra,rb,0x3b,rc)
258 # define S8SUBQi(ra,im,rc) Opi(0x10,ra,im,0x3b,rc)
259 # define SEXTB(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x00,rc)
260 /* FIXME not disassembled */
261 # define SEXTBi(im,rc) Opi(0x1c,_R31_REGNO,im,0x00,rc)
262 # define SEXTW(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x01,rc)
263 /* FIXME not disassembled */
264 # define SEXTWi(im,rc) Opi(0x1c,_R31_REGNO,im,0x01,rc)
265 # define SLL(ra,rb,rc) Opr(0x12,ra,rb,0x39,rc)
266 # define SLLi(ra,im,rc) Opi(0x12,ra,im,0x39,rc)
267 # define SRA(ra,rb,rc) Opr(0x12,ra,rb,0x3c,rc)
268 # define SRAi(ra,im,rc) Opi(0x12,ra,im,0x3c,rc)
269 # define SRL(ra,rb,rc) Opr(0x12,ra,rb,0x34,rc)
270 # define SRLi(ra,im,rc) Opi(0x12,ra,im,0x34,rc)
271 # define STB(ra,rb,d) Mem(0x0e,ra,rb,d)
272 # define STL(ra,rb,d) Mem(0x2c,ra,rb,d)
273 # define STL_C(ra,rb,d) Mem(0x2e,ra,rb,d)
274 # define STQ(ra,rb,d) Mem(0x2d,ra,rb,d)
275 # define STQ_C(ra,rb,d) Mem(0x2f,ra,rb,d)
276 # define STQ_U(ra,rb,d) Mem(0x0f,ra,rb,d)
277 # define STW(ra,rb,d) Mem(0x0d,ra,rb,d)
278 # define SUBL(ra,rb,rc) Opr(0x10,ra,rb,0x09,rc)
279 # define SUBLi(ra,im,rc) Opi(0x10,ra,im,0x09,rc)
280 # define SUBL_V(ra,rb,rc) Opr(0x10,ra,rb,0x49,rc)
281 # define SUBL_Vi(ra,im,rc) Opi(0x10,ra,im,0x49,rc)
282 # define SUBQ(ra,rb,rc) Opr(0x10,ra,rb,0x29,rc)
283 # define SUBQi(ra,im,rc) Opi(0x10,ra,im,0x29,rc)
284 # define SUBQ_V(ra,rb,rc) Opr(0x10,ra,rb,0x69,rc)
285 # define SUBQ_Vi(ra,im,rc) Opi(0x10,ra,im,0x69,rc)
286 # define TRAPB() Mem(0x18,_R31_REGNO,_R31_REGNO,0x0000)
287 # define UMULH(ra,rb,rc) Opr(0x13,ra,rb,0x30,rc)
288 # define UMULHi(ra,im,rc) Opi(0x13,ra,im,0x30,rc)
289 # define UNPKBL(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x35,rc)
290 # define UNPKBW(rb,rc) Opr(0x1c,_R31_REGNO,rb,0x34,rc)
291 # define WH64(ra) Mem(0x18,ra,_R31_REGNO,0xf800)
292 # define WH64EN(ra) Mem(0x18,ra,_R31_REGNO,0xfc00)
293 # define WMB() Mem(0x18,_R31_REGNO,_R31_REGNO,0x4400)
294 # define XOR(ra,rb,rc) Opr(0x11,ra,rb,0x40,rc)
295 # define XORi(ra,im,rc) Opi(0x11,ra,im,0x40,rc)
296 # define ZAP(ra,rb,rc) Opr(0x12,ra,rb,0x30,rc)
297 # define ZAPi(ra,im,rc) Opi(0x12,ra,im,0x30,rc)
298 # define ZAPNOT(ra,rb,rc) Opr(0x12,ra,rb,0x31,rc)
299 # define ZAPNOTi(ra,im,rc) Opi(0x12,ra,im,0x31,rc)
300 # define NOP() BIS(_R31_REGNO,_R31_REGNO,_R31_REGNO)
301 # define MOV(ra,rc) BIS(ra,ra,rc)
302 # define MOVi(im,rc) BISi(_R31_REGNO,im,rc)
303 # define NEGL(ra,rc) SUBL(_R31_REGNO,ra,rc)
304 # define NEGQ(ra,rc) SUBQ(_R31_REGNO,ra,rc)
305 # define NOT(ra,rc) ORNOT(_R31_REGNO,ra,rc)
306 # define nop(i0) _nop(_jit,i0)
307 static void _nop(jit_state_t*,jit_int32_t);
308 # define movr(r0,r1) _movr(_jit,r0,r1)
309 static void _movr(jit_state_t*,jit_int32_t,jit_int32_t);
310 # define movi(r0,i0) _movi(_jit,r0,i0)
311 static void _movi(jit_state_t*,jit_int32_t,jit_word_t);
312 # define movi_p(r0,i0) _movi_p(_jit,r0,i0)
313 static jit_word_t _movi_p(jit_state_t*,jit_int32_t,jit_word_t);
314 # define movnr(r0,r1,r2) _movnr(_jit,r0,r1,r2)
315 static void _movnr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
316 # define movzr(r0,r1,r2) _movzr(_jit,r0,r1,r2)
317 static void _movzr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
318 # define casx(r0, r1, r2, r3, i0) _casx(_jit, r0, r1, r2, r3, i0)
319 static void _casx(jit_state_t *_jit,jit_int32_t,jit_int32_t,
320 jit_int32_t,jit_int32_t,jit_word_t);
321 # define negr(r0,r1) NEGQ(r1,r0)
322 # define comr(r0,r1) NOT(r1,r0)
323 # define addr(r0,r1,r2) ADDQ(r1,r2,r0)
324 # define addi(r0,r1,i0) _addi(_jit,r0,r1,i0)
325 static void _addi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
326 # define addcr(r0,r1,i0) _addcr(_jit,r0,r1,i0)
327 static void _addcr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
328 # define addci(r0,r1,i0) _addci(_jit,r0,r1,i0)
329 static void _addci(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
330 # define addxr(r0,r1,i0) _addxr(_jit,r0,r1,i0)
331 static void _addxr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
332 # define addxi(r0,r1,i0) _addxi(_jit,r0,r1,i0)
333 static void _addxi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
334 # define subr(r0,r1,r2) SUBQ(r1,r2,r0)
335 # define subi(r0,r1,i0) _subi(_jit,r0,r1,i0)
336 static void _subi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
337 # define subcr(r0,r1,i0) _subcr(_jit,r0,r1,i0)
338 static void _subcr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
339 # define subci(r0,r1,i0) _subci(_jit,r0,r1,i0)
340 static void _subci(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
341 # define subxr(r0,r1,i0) _subxr(_jit,r0,r1,i0)
342 static void _subxr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
343 # define subxi(r0,r1,i0) _subxi(_jit,r0,r1,i0)
344 static void _subxi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
345 # define rsbi(r0, r1, i0) _rsbi(_jit, r0, r1, i0)
346 static void _rsbi(jit_state_t*,jit_int32_t,jit_int32_t, jit_word_t);
347 # define mulr(r0,r1,r2) MULQ(r1,r2,r0)
348 # define muli(r0,r1,i0) _muli(_jit,r0,r1,i0)
349 static void _muli(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
350 # define qmulr(r0,r1,r2,r3) _qmulr(_jit,r0,r1,r2,r3)
351 static void _qmulr(jit_state_t*,jit_int32_t,
352 jit_int32_t,jit_int32_t,jit_int32_t);
353 # define qmuli(r0,r1,r2,i0) _qmuli(_jit,r0,r1,r2,i0)
354 static void _qmuli(jit_state_t*,jit_int32_t,
355 jit_int32_t,jit_int32_t,jit_word_t);
356 # define qmulr_u(r0,r1,r2,r3) _qmulr_u(_jit,r0,r1,r2,r3)
357 static void _qmulr_u(jit_state_t*,jit_int32_t,
358 jit_int32_t,jit_int32_t,jit_int32_t);
359 # define qmuli_u(r0,r1,r2,i0) _qmuli_u(_jit,r0,r1,r2,i0)
360 static void _qmuli_u(jit_state_t*,jit_int32_t,
361 jit_int32_t,jit_int32_t,jit_word_t);
362 static jit_word_t __idiv(jit_word_t, jit_word_t);
363 # define divr(r0,r1,r2) _divr(_jit,r0,r1,r2)
364 static void _divr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
365 # define divi(r0,r1,i0) _divi(_jit,r0,r1,i0)
366 static void _divi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
367 static jit_uword_t __udiv(jit_uword_t, jit_uword_t);
368 # define divr_u(r0,r1,r2) _divr_u(_jit,r0,r1,r2)
369 static void _divr_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
370 # define divi_u(r0,r1,i0) _divi_u(_jit,r0,r1,i0)
371 static void _divi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
372 static jit_word_t __irem(jit_word_t, jit_word_t);
373 # define remr(r0,r1,r2) _remr(_jit,r0,r1,r2)
374 static void _remr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
375 # define remi(r0,r1,i0) _remi(_jit,r0,r1,i0)
376 static void _remi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
377 static jit_uword_t __urem(jit_uword_t, jit_uword_t);
378 # define remr_u(r0,r1,r2) _remr_u(_jit,r0,r1,r2)
379 static void _remr_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
380 # define remi_u(r0,r1,i0) _remi_u(_jit,r0,r1,i0)
381 static void _remi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
382 static jit_word_t __idivrem(jit_word_t, jit_word_t, jit_word_t*);
383 # define qdivr(r0,r1,r2,r3) _qdivr(_jit,r0,r1,r2,r3)
384 static void _qdivr(jit_state_t*,
385 jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
386 # define qdivi(r0,r1,r2,i0) _qdivi(_jit,r0,r1,r2,i0)
387 static void _qdivi(jit_state_t*,
388 jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
389 static jit_word_t __udivrem(jit_uword_t, jit_uword_t, jit_uword_t*);
390 # define qdivr_u(r0,r1,r2,r3) _qdivr_u(_jit,r0,r1,r2,r3)
391 static void _qdivr_u(jit_state_t*,
392 jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
393 # define qdivi_u(r0,r1,r2,i0) _qdivi_u(_jit,r0,r1,r2,i0)
394 static void _qdivi_u(jit_state_t*,
395 jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
396 # define lshr(r0,r1,r2) SLL(r1,r2,r0)
397 # define lshi(r0,r1,i0) _lshi(_jit,r0,r1,i0)
398 static void _lshi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
399 # define rshr(r0,r1,r2) SRA(r1,r2,r0)
400 # define rshi(r0,r1,i0) _rshi(_jit,r0,r1,i0)
401 static void _rshi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
402 # define rshr_u(r0,r1,r2) SRL(r1,r2,r0)
403 # define rshi_u(r0,r1,i0) _rshi_u(_jit,r0,r1,i0)
404 static void _rshi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
405 # define andr(r0,r1,r2) AND(r1,r2,r0)
406 # define andi(r0,r1,i0) _andi(_jit,r0,r1,i0)
407 static void _andi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
408 # define orr(r0,r1,r2) OR(r1,r2,r0)
409 # define ori(r0,r1,i0) _ori(_jit,r0,r1,i0)
410 static void _ori(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
411 # define xorr(r0,r1,r2) XOR(r1,r2,r0)
412 # define xori(r0,r1,i0) _xori(_jit,r0,r1,i0)
413 static void _xori(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
414 # define ltr(r0,r1,r2) CMPLT(r1,r2,r0)
415 # define lti(r0,r1,i0) _lti(_jit,r0,r1,i0)
416 static void _lti(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
417 # define ltr_u(r0,r1,r2) CMPULT(r1,r2,r0)
418 # define lti_u(r0,r1,i0) _lti_u(_jit,r0,r1,i0)
419 static void _lti_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
420 # define ler(r0,r1,r2) CMPLE(r1,r2,r0)
421 # define lei(r0,r1,i0) _lei(_jit,r0,r1,i0)
422 static void _lei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
423 # define ler_u(r0,r1,r2) CMPULE(r1,r2,r0)
424 # define lei_u(r0,r1,i0) _lei_u(_jit,r0,r1,i0)
425 static void _lei_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
426 # define eqr(r0,r1,r2) CMPEQ(r1,r2,r0)
427 # define eqi(r0,r1,i0) _eqi(_jit,r0,r1,i0)
428 static void _eqi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
429 # define ger(r0,r1,r2) CMPLE(r2,r1,r0)
430 # define gei(r0,r1,i0) _gei(_jit,r0,r1,i0)
431 static void _gei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
432 # define ger_u(r0,r1,r2) CMPULE(r2,r1,r0)
433 # define gei_u(r0,r1,i0) _gei_u(_jit,r0,r1,i0)
434 static void _gei_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
435 # define gtr(r0,r1,r2) CMPLT(r2,r1,r0)
436 # define gti(r0,r1,i0) _gti(_jit,r0,r1,i0)
437 static void _gti(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
438 # define gtr_u(r0,r1,r2) CMPULT(r2,r1,r0)
439 # define gti_u(r0,r1,i0) _gti_u(_jit,r0,r1,i0)
440 static void _gti_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
441 # define ner(r0,r1,r2) _ner(_jit,r0,r1,r2)
442 static void _ner(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
443 # define nei(r0,r1,i0) _nei(_jit,r0,r1,i0)
444 static void _nei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
445 # define bltr(i0,r0,r1) _bltr(_jit,i0,r0,r1)
446 static jit_word_t _bltr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
447 # define blti(i0,r0,i1) _blti(_jit,i0,r0,i1)
448 static jit_word_t _blti(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
449 # define bltr_u(i0,r0,r1) _bltr_u(_jit,i0,r0,r1)
450 static jit_word_t _bltr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
451 # define blti_u(i0,r0,i1) _blti_u(_jit,i0,r0,i1)
452 static jit_word_t _blti_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
453 # define bler(i0,r0,r1) _bler(_jit,i0,r0,r1)
454 static jit_word_t _bler(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
455 # define blei(i0,r0,i1) _blei(_jit,i0,r0,i1)
456 static jit_word_t _blei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
457 # define bler_u(i0,r0,r1) _bler_u(_jit,i0,r0,r1)
458 static jit_word_t _bler_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
459 # define blei_u(i0,r0,i1) _blei_u(_jit,i0,r0,i1)
460 static jit_word_t _blei_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
461 # define beqr(i0,r0,r1) _beqr(_jit,i0,r0,r1)
462 static jit_word_t _beqr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
463 # define beqi(i0,r0,i1) _beqi(_jit,i0,r0,i1)
464 static jit_word_t _beqi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
465 # define bger(i0,r0,r1) _bger(_jit,i0,r0,r1)
466 static jit_word_t _bger(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
467 # define bgei(i0,r0,i1) _bgei(_jit,i0,r0,i1)
468 static jit_word_t _bgei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
469 # define bger_u(i0,r0,r1) _bger_u(_jit,i0,r0,r1)
470 static jit_word_t _bger_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
471 # define bgei_u(i0,r0,i1) _bgei_u(_jit,i0,r0,i1)
472 static jit_word_t _bgei_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
473 # define bgtr(i0,r0,r1) _bgtr(_jit,i0,r0,r1)
474 static jit_word_t _bgtr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
475 # define bgti(i0,r0,i1) _bgti(_jit,i0,r0,i1)
476 static jit_word_t _bgti(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
477 # define bgtr_u(i0,r0,r1) _bgtr_u(_jit,i0,r0,r1)
478 static jit_word_t _bgtr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
479 # define bgti_u(i0,r0,i1) _bgti_u(_jit,i0,r0,i1)
480 static jit_word_t _bgti_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
481 # define bner(i0,r0,r1) _bner(_jit,i0,r0,r1)
482 static jit_word_t _bner(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
483 # define bnei(i0,r0,i1) _bnei(_jit,i0,r0,i1)
484 static jit_word_t _bnei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
485 # define baddr(i0,r0,r1,cc) _baddr(_jit,i0,r0,r1,cc)
486 static jit_word_t _baddr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
488 # define baddi(i0,r0,i1,cc) _baddi(_jit,i0,r0,i1,cc)
489 static jit_word_t _baddi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
491 # define baddr_u(i0,r0,r1,cc) _baddr_u(_jit,i0,r0,r1,cc)
492 static jit_word_t _baddr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
494 # define baddi_u(i0,r0,i1,cc) _baddi_u(_jit,i0,r0,i1,cc)
495 static jit_word_t _baddi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
497 # define boaddr(i0,r0,r1) baddr(i0,r0,r1,1)
498 # define boaddi(i0,r0,i1) baddi(i0,r0,i1,1)
499 # define boaddr_u(i0,r0,r1) baddr_u(i0,r0,r1,1)
500 # define boaddi_u(i0,r0,i1) baddi_u(i0,r0,i1,1)
501 # define bxaddr(i0,r0,r1) baddr(i0,r0,r1,0)
502 # define bxaddi(i0,r0,i1) baddi(i0,r0,i1,0)
503 # define bxaddr_u(i0,r0,r1) baddr_u(i0,r0,r1,0)
504 # define bxaddi_u(i0,r0,i1) baddi_u(i0,r0,i1,0)
505 # define bsubr(i0,r0,r1,cc) _bsubr(_jit,i0,r0,r1,cc)
506 static jit_word_t _bsubr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
508 # define bsubi(i0,r0,i1,cc) _bsubi(_jit,i0,r0,i1,cc)
509 static jit_word_t _bsubi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
511 # define bsubr_u(i0,r0,r1,cc) _bsubr_u(_jit,i0,r0,r1,cc)
512 static jit_word_t _bsubr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
514 # define bsubi_u(i0,r0,i1,cc) _bsubi_u(_jit,i0,r0,i1,cc)
515 static jit_word_t _bsubi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
517 # define bosubr(i0,r0,r1) bsubr(i0,r0,r1,1)
518 # define bosubi(i0,r0,i1) bsubi(i0,r0,i1,1)
519 # define bosubr_u(i0,r0,r1) bsubr_u(i0,r0,r1,1)
520 # define bosubi_u(i0,r0,i1) bsubi_u(i0,r0,i1,1)
521 # define bxsubr(i0,r0,r1) bsubr(i0,r0,r1,0)
522 # define bxsubi(i0,r0,i1) bsubi(i0,r0,i1,0)
523 # define bxsubr_u(i0,r0,r1) bsubr_u(i0,r0,r1,0)
524 # define bxsubi_u(i0,r0,i1) bsubi_u(i0,r0,i1,0)
525 # define bmxr(i0,r0,r1,cc) _bmxr(_jit,i0,r0,r1,cc)
526 static jit_word_t _bmxr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
528 # define bmxi(i0,r0,i1,cc) _bmxi(_jit,i0,r0,i1,cc)
529 static jit_word_t _bmxi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
531 # define bmsr(i0,r0,r1) bmxr(i0,r0,r1,1)
532 # define bmsi(i0,r0,i1) bmxi(i0,r0,i1,1)
533 # define bmcr(i0,r0,r1) bmxr(i0,r0,r1,0)
534 # define bmci(i0,r0,i1) bmxi(i0,r0,i1,0)
535 # define ldr_c(r0,r1) _ldr_c(_jit,r0,r1)
536 static void _ldr_c(jit_state_t*,jit_int32_t,jit_int32_t);
537 # define ldi_c(r0,i0) _ldi_c(_jit,r0,i0)
538 static void _ldi_c(jit_state_t*,jit_int32_t,jit_word_t);
539 # define ldr_uc(r0,r1) LDBU(r0,r1,0)
540 # define ldi_uc(r0,i0) _ldi_uc(_jit,r0,i0)
541 static void _ldi_uc(jit_state_t*,jit_int32_t,jit_word_t);
542 # define ldr_s(r0,r1) _ldr_s(_jit,r0,r1)
543 static void _ldr_s(jit_state_t*,jit_int32_t,jit_int32_t);
544 # define ldi_s(r0,i0) _ldi_s(_jit,r0,i0)
545 static void _ldi_s(jit_state_t*,jit_int32_t,jit_word_t);
546 # define ldr_us(r0,r1) LDWU(r0,r1,0)
547 # define ldi_us(r0,i0) _ldi_us(_jit,r0,i0)
548 static void _ldi_us(jit_state_t*,jit_int32_t,jit_word_t);
549 # define ldr_i(r0,r1) LDL(r0,r1,0)
550 # define ldi_i(r0,i0) _ldi_i(_jit,r0,i0)
551 static void _ldi_i(jit_state_t*,jit_int32_t,jit_word_t);
552 # define ldr_ui(r0,r1) _ldr_ui(_jit,r0,r1)
553 static void _ldr_ui(jit_state_t*,jit_int32_t,jit_int32_t);
554 # define ldi_ui(r0,i0) _ldi_ui(_jit,r0,i0)
555 static void _ldi_ui(jit_state_t*,jit_int32_t,jit_word_t);
556 # define ldr(r0,r1) ldr_l(r0,r1)
557 # define ldr_l(r0,r1) LDQ(r0,r1,0)
558 # define ldi_l(r0,i0) _ldi_l(_jit,r0,i0)
559 static void _ldi_l(jit_state_t*,jit_int32_t,jit_word_t);
560 # define ldxr_c(r0,r1,r2) _ldxr_c(_jit,r0,r1,r2)
561 static void _ldxr_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
562 # define ldxi_c(r0,r1,i0) _ldxi_c(_jit,r0,r1,i0)
563 static void _ldxi_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
564 # define ldxr_uc(r0,r1,r2) _ldxr_uc(_jit,r0,r1,r2)
565 static void _ldxr_uc(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
566 # define ldxi_uc(r0,r1,i0) _ldxi_uc(_jit,r0,r1,i0)
567 static void _ldxi_uc(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
568 # define ldxr_s(r0,r1,r2) _ldxr_s(_jit,r0,r1,r2)
569 static void _ldxr_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
570 # define ldxi_s(r0,r1,i0) _ldxi_s(_jit,r0,r1,i0)
571 static void _ldxi_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
572 # define ldxr_us(r0,r1,r2) _ldxr_us(_jit,r0,r1,r2)
573 static void _ldxr_us(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
574 # define ldxi_us(r0,r1,i0) _ldxi_us(_jit,r0,r1,i0)
575 static void _ldxi_us(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
576 # define ldxr_i(r0,r1,r2) _ldxr_i(_jit,r0,r1,r2)
577 static void _ldxr_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
578 # define ldxi_i(r0,r1,i0) _ldxi_i(_jit,r0,r1,i0)
579 static void _ldxi_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
580 # define ldxr_ui(r0,r1,r2) _ldxr_ui(_jit,r0,r1,r2)
581 static void _ldxr_ui(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
582 # define ldxi_ui(r0,r1,i0) _ldxi_ui(_jit,r0,r1,i0)
583 static void _ldxi_ui(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
584 # define ldxr(r0,r1,r2) ldxr_l(r0,r1,r2)
585 # define ldxr_l(r0,r1,r2) _ldxr_l(_jit,r0,r1,r2)
586 static void _ldxr_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
587 # define ldxi(r0,r1,i0) ldxi_l(r0,r1,i0)
588 # define ldxi_l(r0,r1,i0) _ldxi_l(_jit,r0,r1,i0)
589 static void _ldxi_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
590 # define str_c(r0,r1) STB(r1,r0,0)
591 # define sti_c(i0,r0) _sti_c(_jit,i0,r0)
592 static void _sti_c(jit_state_t*,jit_word_t,jit_int32_t);
593 # define str_s(r0,r1) STW(r1,r0,0)
594 # define sti_s(i0,r0) _sti_s(_jit,i0,r0)
595 static void _sti_s(jit_state_t*,jit_word_t,jit_int32_t);
596 # define str_i(r0,r1) STL(r1,r0,0)
597 # define sti_i(i0,r0) _sti_i(_jit,i0,r0)
598 static void _sti_i(jit_state_t*,jit_word_t,jit_int32_t);
599 # define str(r0,r1) str_l(r0,r1)
600 # define str_l(r0,r1) STQ(r1,r0,0)
601 # define sti_l(i0,r0) _sti_l(_jit,i0,r0)
602 static void _sti_l(jit_state_t*,jit_word_t,jit_int32_t);
603 # define stxr_c(r0,r1,r2) _stxr_c(_jit,r0,r1,r2)
604 static void _stxr_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
605 # define stxi_c(i0,r0,r1) _stxi_c(_jit,i0,r0,r1)
606 static void _stxi_c(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
607 # define stxr_s(r0,r1,r2) _stxr_s(_jit,r0,r1,r2)
608 static void _stxr_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
609 # define stxi_s(i0,r0,r1) _stxi_s(_jit,i0,r0,r1)
610 static void _stxi_s(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
611 # define stxr_i(r0,r1,r2) _stxr_i(_jit,r0,r1,r2)
612 static void _stxr_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
613 # define stxi_i(i0,r0,r1) _stxi_i(_jit,i0,r0,r1)
614 static void _stxi_i(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
615 # define stxr_l(r0,r1,r2) _stxr_l(_jit,r0,r1,r2)
616 static void _stxr_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
617 # define stxi(i0,r0,r1) stxi_l(i0,r0,r1)
618 # define stxi_l(i0,r0,r1) _stxi_l(_jit,i0,r0,r1)
619 static void _stxi_l(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
620 # define extr_c(r0,r1) _extr_c(_jit,r0,r1)
621 static void _extr_c(jit_state_t*,jit_int32_t,jit_int32_t);
622 # define extr_uc(r0,r1) _extr_uc(_jit,r0,r1)
623 static void _extr_uc(jit_state_t*,jit_int32_t,jit_int32_t);
624 # define extr_s(r0,r1) _extr_s(_jit,r0,r1)
625 static void _extr_s(jit_state_t*,jit_int32_t,jit_int32_t);
626 # define extr_us(r0,r1) _extr_us(_jit,r0,r1)
627 static void _extr_us(jit_state_t*,jit_int32_t,jit_int32_t);
628 # define extr_i(r0,r1) _extr_i(_jit,r0,r1)
629 static void _extr_i(jit_state_t*,jit_int32_t,jit_int32_t);
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);
632 # define bswapr_us(r0,r1) _bswapr_us(_jit,r0,r1)
633 static void _bswapr_us(jit_state_t*,jit_int32_t,jit_int32_t);
634 # define bswapr_ui(r0,r1) _bswapr_ui(_jit,r0,r1)
635 static void _bswapr_ui(jit_state_t*,jit_int32_t,jit_int32_t);
636 # define bswapr_ul(r0,r1) _bswapr_ul(_jit,r0,r1)
637 static void _bswapr_ul(jit_state_t*,jit_int32_t,jit_int32_t);
638 # define jmpr(r0) JMP(_R31_REGNO,r0,0)
639 # define jmpi(i0) _jmpi(_jit,i0)
640 static void _jmpi(jit_state_t*, jit_word_t);
641 # define jmpi_p(i0) _jmpi_p(_jit,i0)
642 static jit_word_t _jmpi_p(jit_state_t*, jit_word_t);
643 #define callr(r0) _callr(_jit,r0)
644 static void _callr(jit_state_t*, jit_int32_t);
645 # define calli(i0) _calli(_jit,i0)
646 static void _calli(jit_state_t*, jit_word_t);
647 # define calli_p(i0) _calli_p(_jit,i0)
648 static jit_word_t _calli_p(jit_state_t*, jit_word_t);
649 # define prolog(node) _prolog(_jit,node)
650 static void _prolog(jit_state_t*,jit_node_t*);
651 # define epilog(node) _epilog(_jit,node)
652 static void _epilog(jit_state_t*,jit_node_t*);
653 # define vastart(r0) _vastart(_jit, r0)
654 static void _vastart(jit_state_t*, jit_int32_t);
655 # define vaarg(r0, r1) _vaarg(_jit, r0, r1)
656 static void _vaarg(jit_state_t*, jit_int32_t, jit_int32_t);
657 # define patch_at(jump,label) _patch_at(_jit,jump,label)
658 static void _patch_at(jit_state_t*,jit_word_t,jit_word_t);
663 _Pcd(jit_state_t *_jit, int o, unsigned int n)
671 _Bra(jit_state_t *_jit, int o, int ra, int d)
676 ii((o<<26)|(ra<<21)|_u21(d));
680 _Mem(jit_state_t *_jit, int o, int ra, int rb, unsigned int d)
686 ii((o<<26)|(ra<<21)|(rb<<16)|_u16(d));
690 _Mbr(jit_state_t *_jit, int o, int ra, int rb, int h, int d)
697 ii((o<<26)|(ra<<21)|(rb<<16)|(h<<14)|_u14(d));
701 _Opr(jit_state_t *_jit, int o, int ra, int rb, unsigned int f, int rc)
708 ii((o<<26)|(ra<<21)|(rb<<16)|(_u11(f)<<5)|rc);
712 _Opi(jit_state_t *_jit, int o, int ra, unsigned int i, unsigned int f, int rc)
719 ii((o<<26)|(ra<<21)|(_u8(i)<<13)|(1<<12)|(_u7(f)<<5)|rc);
723 _nop(jit_state_t *_jit, jit_int32_t i0)
725 for (; i0 > 0; i0 -= 4)
731 _movr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
738 _movi(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
741 jit_int16_t s0, s1, s2, s3;
753 LDA(r0, _R31_REGNO, _u16(s0));
754 else if (_s32_p(i0)) {
755 LDA(r0, _R31_REGNO, _u16(s0));
756 LDAH(r0, r0, _u16(s1));
758 else if (_u32_p(i0)) {
759 LDA(r0, _R31_REGNO, _u16(s0));
761 LDAH(r0, r0, _u16(s1));
765 else if (_u32(i0) == 0) {
766 LDA(r0, _R31_REGNO, _u16(s2));
768 LDAH(r0, r0, _u16(s3));
772 reg = jit_get_reg(jit_class_gpr);
773 LDA(r0, _R31_REGNO, _u16(s0));
774 LDA(rn(reg), _R31_REGNO, _u16(s2));
776 LDAH(r0, r0, _u16(s1));
778 LDAH(rn(reg), rn(reg), _u16(s3));
781 lshi(rn(reg), rn(reg), 32);
782 orr(r0, r0, rn(reg));
788 _movi_p(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
792 jit_int16_t s0, s1, s2, s3;
794 reg = jit_get_reg(jit_class_gpr);
803 LDA(r0, _R31_REGNO, _u16(s0));
804 LDA(rn(reg), _R31_REGNO, _u16(s2));
805 LDAH(r0, r0, _u16(s1));
806 LDAH(rn(reg), rn(reg), _u16(s3));
809 lshi(rn(reg), rn(reg), 32);
810 orr(r0, r0, rn(reg));
816 _movnr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
819 w = beqi(_jit->pc.w, r2, 0);
821 patch_at(w, _jit->pc.w);
825 _movzr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
828 w = bnei(_jit->pc.w, r2, 0);
830 patch_at(w, _jit->pc.w);
834 _casx(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
835 jit_int32_t r2, jit_int32_t r3, jit_word_t i0)
837 fallback_casx(r0, r1, r2, r3, i0);
841 _addi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
847 LDA(r0, r1, _u16(i0));
849 reg = jit_get_reg(jit_class_gpr);
851 addr(r0, r1, rn(reg));
857 _addcr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
860 if (jit_carry == _NOREG)
861 jit_carry = jit_get_reg(jit_class_gpr);
863 reg = jit_get_reg(jit_class_gpr);
864 addr(rn(reg), r1, r2);
865 ltr_u(rn(jit_carry), rn(reg), r1);
871 ltr_u(rn(jit_carry), r0, r1);
876 _addci(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
879 if (jit_carry == _NOREG)
880 jit_carry = jit_get_reg(jit_class_gpr);
882 reg = jit_get_reg(jit_class_gpr);
883 addi(rn(reg), r1, i0);
884 ltr_u(rn(jit_carry), rn(reg), r1);
890 ltr_u(rn(jit_carry), r0, r1);
895 _addxr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
898 assert(jit_carry != _NOREG);
899 reg = jit_get_reg(jit_class_gpr);
900 movr(rn(reg), rn(jit_carry));
902 addcr(r0, r0, rn(reg));
907 _addxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
910 assert(jit_carry != _NOREG);
911 reg = jit_get_reg(jit_class_gpr);
912 movr(rn(reg), rn(jit_carry));
914 addcr(r0, r0, rn(reg));
919 _subi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
924 else if (_s16_p(-i0))
925 LDA(r0, r1, _u16(-i0));
927 reg = jit_get_reg(jit_class_gpr);
929 subr(r0, r1, rn(reg));
935 _subcr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
938 if (jit_carry == _NOREG)
939 jit_carry = jit_get_reg(jit_class_gpr);
941 reg = jit_get_reg(jit_class_gpr);
942 subr(rn(reg), r1, r2);
943 ltr_u(rn(jit_carry), r1, rn(reg));
949 ltr_u(rn(jit_carry), r1, r0);
954 _subci(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
957 if (jit_carry == _NOREG)
958 jit_carry = jit_get_reg(jit_class_gpr);
960 reg = jit_get_reg(jit_class_gpr);
961 addi(rn(reg), r1, -i0);
962 ltr_u(rn(jit_carry), r1, rn(reg));
968 ltr_u(rn(jit_carry), r1, r0);
973 _subxr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
976 assert(jit_carry != _NOREG);
977 reg = jit_get_reg(jit_class_gpr);
978 movr(rn(reg), rn(jit_carry));
980 subcr(r0, r0, rn(reg));
985 _subxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
988 assert(jit_carry != _NOREG);
989 reg = jit_get_reg(jit_class_gpr);
990 movr(rn(reg), rn(jit_carry));
992 subcr(r0, r0, rn(reg));
997 _rsbi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1004 _muli(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1010 reg = jit_get_reg(jit_class_gpr);
1012 mulr(r0, r1, rn(reg));
1018 _qmulr(jit_state_t *_jit, jit_int32_t r0,
1019 jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1022 /* The only invalid condition is r0 == r1 */
1023 jit_int32_t t2, t3, s2, s3;
1024 if (r2 == r0 || r2 == r1) {
1025 s2 = jit_get_reg(jit_class_gpr);
1031 if (r3 == r0 || r3 == r1) {
1032 s3 = jit_get_reg(jit_class_gpr);
1038 qmulr_u(r0, r1, r2, r3);
1039 reg = jit_get_reg(jit_class_gpr);
1041 rshi(rn(reg), t2, 63);
1042 mulr(rn(reg), rn(reg), t3);
1043 addr(r1, r1, rn(reg));
1045 rshi(rn(reg), t3, 63);
1046 mulr(rn(reg), rn(reg), t2);
1047 addr(r1, r1, rn(reg));
1056 _qmuli(jit_state_t *_jit, jit_int32_t r0,
1057 jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1060 reg = jit_get_reg(jit_class_gpr);
1062 qmulr(r0, r1, r2, rn(reg));
1067 _qmulr_u(jit_state_t *_jit, jit_int32_t r0,
1068 jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1071 if (r0 == r2 || r0 == r3) {
1072 reg = jit_get_reg(jit_class_gpr);
1073 mulr(rn(reg), r2, r3);
1078 if (r0 == r2 || r0 == r3) {
1085 _qmuli_u(jit_state_t *_jit, jit_int32_t r0,
1086 jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1091 reg = jit_get_reg(jit_class_gpr);
1092 muli(rn(reg), r2, i0);
1103 reg = jit_get_reg(jit_class_gpr);
1105 qmulr_u(r0, r1, r2, rn(reg));
1111 __idiv(jit_word_t u, jit_word_t v)
1117 _divr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1119 movr(_A0_REGNO, r1);
1120 movr(_A1_REGNO, r2);
1121 calli((jit_word_t)__idiv);
1122 movr(r0, _V0_REGNO);
1126 _divi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1128 movr(_A0_REGNO, r1);
1129 movi(_A1_REGNO, i0);
1130 calli((jit_word_t)__idiv);
1131 movr(r0, _V0_REGNO);
1135 __udiv(jit_uword_t u, jit_uword_t v)
1141 _divr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1143 movr(_A0_REGNO, r1);
1144 movr(_A1_REGNO, r2);
1145 calli((jit_word_t)__udiv);
1146 movr(r0, _V0_REGNO);
1150 _divi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1152 movr(_A0_REGNO, r1);
1153 movi(_A1_REGNO, i0);
1154 calli((jit_word_t)__udiv);
1155 movr(r0, _V0_REGNO);
1159 __irem(jit_word_t u, jit_word_t v)
1165 _remr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1167 movr(_A0_REGNO, r1);
1168 movr(_A1_REGNO, r2);
1169 calli((jit_word_t)__irem);
1170 movr(r0, _V0_REGNO);
1174 _remi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1176 movr(_A0_REGNO, r1);
1177 movi(_A1_REGNO, i0);
1178 calli((jit_word_t)__irem);
1179 movr(r0, _V0_REGNO);
1183 __urem(jit_uword_t u, jit_uword_t v)
1189 _remr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1191 movr(_A0_REGNO, r1);
1192 movr(_A1_REGNO, r2);
1193 calli((jit_word_t)__urem);
1194 movr(r0, _V0_REGNO);
1198 _remi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1200 movr(_A0_REGNO, r1);
1201 movi(_A1_REGNO, i0);
1202 calli((jit_word_t)__urem);
1203 movr(r0, _V0_REGNO);
1207 __idivrem(jit_word_t u, jit_word_t v, jit_word_t *rem)
1214 _qdivr(jit_state_t *_jit,
1215 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1217 movr(_A0_REGNO, r2);
1218 movr(_A1_REGNO, r3);
1219 subi(_A2_REGNO, _FP_REGNO, 8);
1220 calli((jit_word_t)__idivrem);
1221 movr(r0, _V0_REGNO);
1222 ldxi(r1, _FP_REGNO, -8);
1226 _qdivi(jit_state_t *_jit,
1227 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1229 movr(_A0_REGNO, r2);
1230 movi(_A1_REGNO, i0);
1231 subi(_A2_REGNO, _FP_REGNO, 8);
1232 calli((jit_word_t)__idivrem);
1233 movr(r0, _V0_REGNO);
1234 ldxi(r1, _FP_REGNO, -8);
1238 __udivrem(jit_uword_t u, jit_uword_t v, jit_uword_t *rem)
1245 _qdivr_u(jit_state_t *_jit,
1246 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1248 movr(_A0_REGNO, r2);
1249 movr(_A1_REGNO, r3);
1250 subi(_A2_REGNO, _FP_REGNO, 8);
1251 calli((jit_word_t)__udivrem);
1252 movr(r0, _V0_REGNO);
1253 ldxi(r1, _FP_REGNO, -8);
1257 _qdivi_u(jit_state_t *_jit,
1258 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1260 movr(_A0_REGNO, r2);
1261 movi(_A1_REGNO, i0);
1262 subi(_A2_REGNO, _FP_REGNO, 8);
1263 calli((jit_word_t)__udivrem);
1264 movr(r0, _V0_REGNO);
1265 ldxi(r1, _FP_REGNO, -8);
1269 _lshi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1271 assert(i0 >= 0 && i0 < 64);
1276 _rshi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1278 assert(i0 >= 0 && i0 < 64);
1283 _rshi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1285 assert(i0 >= 0 && i0 < 64);
1290 _andi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1296 reg = jit_get_reg(jit_class_gpr);
1298 andr(r0, r1, rn(reg));
1304 _ori(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1310 reg = jit_get_reg(jit_class_gpr);
1312 orr(r0, r1, rn(reg));
1318 _xori(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1324 reg = jit_get_reg(jit_class_gpr);
1326 xorr(r0, r1, rn(reg));
1332 _lti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1338 reg = jit_get_reg(jit_class_gpr);
1340 ltr(r0, r1, rn(reg));
1346 _lti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1350 CMPULTi(r1, i0, r0);
1352 reg = jit_get_reg(jit_class_gpr);
1354 ltr_u(r0, r1, rn(reg));
1360 _lei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1366 reg = jit_get_reg(jit_class_gpr);
1368 ler(r0, r1, rn(reg));
1374 _lei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1380 CMPULEi(r1, i0, r0);
1382 reg = jit_get_reg(jit_class_gpr);
1384 ler_u(r0, r1, rn(reg));
1390 _eqi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1396 reg = jit_get_reg(jit_class_gpr);
1398 eqr(r0, r1, rn(reg));
1404 _gei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1407 reg = jit_get_reg(jit_class_gpr);
1409 ger(r0, r1, rn(reg));
1414 _gei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1417 reg = jit_get_reg(jit_class_gpr);
1419 ger_u(r0, r1, rn(reg));
1424 _gti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1427 reg = jit_get_reg(jit_class_gpr);
1429 gtr(r0, r1, rn(reg));
1434 _gti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1437 reg = jit_get_reg(jit_class_gpr);
1439 gtr_u(r0, r1, rn(reg));
1444 _ner(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1451 _nei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1459 reg = jit_get_reg(jit_class_gpr);
1461 ner(r0, r1, rn(reg));
1467 _bltr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1471 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1472 ltr(rn(reg), r0, r1);
1474 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1480 _blti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1486 BLT(r0, ((i0 - w) >> 2) - 1);
1489 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1490 lti(rn(reg), r0, i1);
1492 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1499 _bltr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1503 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1504 ltr_u(rn(reg), r0, r1);
1506 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1512 _blti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1516 /* FIXME cannot optimize zero because need to return a patcheable address */
1517 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1518 lti_u(rn(reg), r0, i1);
1520 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1526 _bler(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1530 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1531 ler(rn(reg), r0, r1);
1533 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1539 _blei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1545 BLE(r0, ((i0 - w) >> 2) - 1);
1548 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1549 lei(rn(reg), r0, i1);
1551 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1558 _bler_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1562 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1563 ler_u(rn(reg), r0, r1);
1565 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1571 _blei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1577 BEQ(r0, ((i0 - w) >> 2) - 1);
1580 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1581 lei_u(rn(reg), r0, i1);
1583 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1590 _beqr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1594 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1595 eqr(rn(reg), r0, r1);
1597 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1603 _beqi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1609 BEQ(r0, ((i0 - w) >> 2) - 1);
1612 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1613 eqi(rn(reg), r0, i1);
1615 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1622 _bger(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1626 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1627 ger(rn(reg), r0, r1);
1629 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1635 _bgei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1641 BGE(r0, ((i0 - w) >> 2) - 1);
1644 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1645 gei(rn(reg), r0, i1);
1647 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1654 _bger_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1658 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1659 ger_u(rn(reg), r0, r1);
1661 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1667 _bgei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1671 /* always true if i1 == 0 */
1674 BR(r0, ((i0 - w) >> 2) - 1);
1677 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1678 gei_u(rn(reg), r0, i1);
1680 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1687 _bgtr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1691 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1692 gtr(rn(reg), r0, r1);
1694 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1700 _bgti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1706 BGT(r0, ((i0 - w) >> 2) - 1);
1709 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1710 gti(rn(reg), r0, i1);
1712 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1719 _bgtr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1723 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1724 gtr_u(rn(reg), r0, r1);
1726 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1732 _bgti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1736 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1737 gti_u(rn(reg), r0, i1);
1739 BNE(rn(reg), ((i0 - w) >> 2) - 1);
1745 _bner(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
1749 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1750 eqr(rn(reg), r0, r1);
1752 BEQ(rn(reg), ((i0 - w) >> 2) - 1);
1758 _bnei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
1764 BNE(r0, ((i0 - w) >> 2) - 1);
1767 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1768 eqi(rn(reg), r0, i1);
1770 BEQ(rn(reg), ((i0 - w) >> 2) - 1);
1777 _baddr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
1785 /* t0 = r0 + r1; overflow = r1 < 0 ? r0 < t0 : t0 < r0 */
1786 t0 = jit_get_reg(jit_class_gpr);
1787 t1 = jit_get_reg(jit_class_gpr);
1788 t2 = jit_get_reg(jit_class_gpr);
1789 t3 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1790 addr(rn(t0), r0, r1); /* t0 = r0 + r1 */
1791 ltr(rn(t1), r1, _R31_REGNO); /* t1 = r1 < 0 */
1792 ltr(rn(t2), r0, rn(t0)); /* t2 = r0 < t0 */
1793 ltr(rn(t3), rn(t0), r0); /* t3 = t0 < r0 */
1794 movr(r0, rn(t0)); /* r0 += r1 */
1795 CMOVNE(rn(t1), rn(t2), rn(t3)); /* if (t1 == 0) t3 = t2; */
1801 BNE(rn(t3), ((i0 - w) >> 2) - 1);
1803 BEQ(rn(t3), ((i0 - w) >> 2) - 1);
1809 _baddi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
1814 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1816 w = baddr(i0, r0, rn(reg), carry);
1822 _baddr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
1828 t0 = jit_get_reg(jit_class_gpr);
1829 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1830 addr(rn(t0), r0, r1);
1831 ltr_u(rn(t1), rn(t0), r0);
1836 BNE(rn(t1), ((i0 - w) >> 2) - 1);
1838 BEQ(rn(t1), ((i0 - w) >> 2) - 1);
1844 _baddi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
1850 t0 = jit_get_reg(jit_class_gpr);
1851 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1852 addi(rn(t0), r0, i1);
1853 ltr_u(rn(t1), rn(t0), r0);
1858 BNE(rn(t1), ((i0 - w) >> 2) - 1);
1860 BEQ(rn(t1), ((i0 - w) >> 2) - 1);
1866 _bsubr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
1874 /* t0 = r0 - r1; overflow = 0 < r1 ? r0 < t0 : t0 < r0 */
1875 t0 = jit_get_reg(jit_class_gpr);
1876 t1 = jit_get_reg(jit_class_gpr);
1877 t2 = jit_get_reg(jit_class_gpr);
1878 t3 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1879 subr(rn(t0), r0, r1); /* r0 = r0 - r1 */
1880 ltr(rn(t1), _R31_REGNO, r1); /* t1 = 0 < r1 */
1881 ltr(rn(t2), r0, rn(t0)); /* t2 = r0 < t0 */
1882 ltr(rn(t3), rn(t0), r0); /* t3 = t0 < r0 */
1883 movr(r0, rn(t0)); /* r0 -= r1 */
1884 CMOVNE(rn(t1), rn(t2), rn(t3)); /* if (t1 == 0) t3 = t2; */
1890 BNE(rn(t3), ((i0 - w) >> 2) - 1);
1892 BEQ(rn(t3), ((i0 - w) >> 2) - 1);
1898 _bsubi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
1903 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
1905 w = bsubr(i0, r0, rn(reg), carry);
1911 _bsubr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
1917 t0 = jit_get_reg(jit_class_gpr);
1918 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1919 subr(rn(t0), r0, r1);
1920 ltr_u(rn(t1), r0, rn(t0));
1925 BNE(rn(t1), ((i0 - w) >> 2) - 1);
1927 BEQ(rn(t1), ((i0 - w) >> 2) - 1);
1933 _bsubi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
1939 t0 = jit_get_reg(jit_class_gpr);
1940 t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1941 subi(rn(t0), r0, i1);
1942 ltr_u(rn(t1), r0, rn(t0));
1947 BNE(rn(t1), ((i0 - w) >> 2) - 1);
1949 BEQ(rn(t1), ((i0 - w) >> 2) - 1);
1955 _bmxr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
1960 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1961 andr(rn(t0), r0, r1);
1964 BNE(rn(t0), ((i0 - w) >> 2) - 1);
1966 BEQ(rn(t0), ((i0 - w) >> 2) - 1);
1972 _bmxi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
1977 t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
1978 andi(rn(t0), r0, i1);
1981 BNE(rn(t0), ((i0 - w) >> 2) - 1);
1983 BEQ(rn(t0), ((i0 - w) >> 2) - 1);
1989 _ldr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1996 _ldi_c(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
2000 LDBU(r0, _R31_REGNO, _u16(i0));
2004 reg = jit_get_reg(jit_class_gpr);
2012 _ldi_uc(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
2016 LDBU(r0, _R31_REGNO, _u16(i0));
2018 reg = jit_get_reg(jit_class_gpr);
2020 ldr_uc(r0, rn(reg));
2026 _ldr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2033 _ldi_s(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
2037 LDWU(r0, _R31_REGNO, _u16(i0));
2041 reg = jit_get_reg(jit_class_gpr);
2049 _ldi_us(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
2053 LDWU(r0, _R31_REGNO, _u16(i0));
2055 reg = jit_get_reg(jit_class_gpr);
2057 ldr_us(r0, rn(reg));
2063 _ldi_i(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
2067 LDL(r0, _R31_REGNO, _u16(i0));
2069 reg = jit_get_reg(jit_class_gpr);
2077 _ldr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2084 _ldi_ui(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
2088 LDL(r0, _R31_REGNO, _u16(i0));
2092 reg = jit_get_reg(jit_class_gpr);
2094 ldr_ui(r0, rn(reg));
2100 _ldi_l(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
2104 LDQ(r0, _R31_REGNO, _u16(i0));
2106 reg = jit_get_reg(jit_class_gpr);
2114 _ldxr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2117 reg = jit_get_reg(jit_class_gpr);
2118 addr(rn(reg), r1, r2);
2124 _ldxi_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2128 LDBU(r0, r1, _u16(i0));
2132 reg = jit_get_reg(jit_class_gpr);
2133 addi(rn(reg), r1, i0);
2140 _ldxr_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2143 reg = jit_get_reg(jit_class_gpr);
2144 addr(rn(reg), r1, r2);
2145 ldr_uc(r0, rn(reg));
2150 _ldxi_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2154 LDBU(r0, r1, _u16(i0));
2156 reg = jit_get_reg(jit_class_gpr);
2157 addi(rn(reg), r1, i0);
2158 ldr_uc(r0, rn(reg));
2164 _ldxr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2167 reg = jit_get_reg(jit_class_gpr);
2168 addr(rn(reg), r1, r2);
2174 _ldxi_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2178 LDWU(r0, r1, _u16(i0));
2182 reg = jit_get_reg(jit_class_gpr);
2183 addi(rn(reg), r1, i0);
2190 _ldxr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2193 reg = jit_get_reg(jit_class_gpr);
2194 addr(rn(reg), r1, r2);
2195 ldr_us(r0, rn(reg));
2200 _ldxi_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2204 LDWU(r0, r1, _u16(i0));
2206 reg = jit_get_reg(jit_class_gpr);
2207 addi(rn(reg), r1, i0);
2208 ldr_us(r0, rn(reg));
2214 _ldxr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2217 reg = jit_get_reg(jit_class_gpr);
2218 addr(rn(reg), r1, r2);
2224 _ldxi_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2228 LDL(r0, r1, _u16(i0));
2230 reg = jit_get_reg(jit_class_gpr);
2231 addi(rn(reg), r1, i0);
2238 _ldxr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2241 reg = jit_get_reg(jit_class_gpr);
2242 addr(rn(reg), r1, r2);
2243 ldr_ui(r0, rn(reg));
2248 _ldxi_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2252 LDL(r0, r1, _u16(i0));
2256 reg = jit_get_reg(jit_class_gpr);
2257 addi(rn(reg), r1, i0);
2258 ldr_ui(r0, rn(reg));
2264 _ldxr_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2267 reg = jit_get_reg(jit_class_gpr);
2268 addr(rn(reg), r1, r2);
2274 _ldxi_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
2278 LDQ(r0, r1, _u16(i0));
2280 reg = jit_get_reg(jit_class_gpr);
2281 addi(rn(reg), r1, i0);
2288 _sti_c(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
2292 STB(r0, _R31_REGNO, _u16(i0));
2294 reg = jit_get_reg(jit_class_gpr);
2302 _sti_s(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
2306 STW(r0, _R31_REGNO, _u16(i0));
2308 reg = jit_get_reg(jit_class_gpr);
2316 _sti_i(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
2320 STL(r0, _R31_REGNO, _u16(i0));
2322 reg = jit_get_reg(jit_class_gpr);
2330 _sti_l(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
2334 STQ(r0, _R31_REGNO, _u16(i0));
2336 reg = jit_get_reg(jit_class_gpr);
2344 _stxr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2347 reg = jit_get_reg(jit_class_gpr);
2348 addr(rn(reg), r0, r1);
2354 _stxi_c(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2358 STB(r1, r0, _u16(i0));
2360 reg = jit_get_reg(jit_class_gpr);
2361 addi(rn(reg), r0, i0);
2368 _stxr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2371 reg = jit_get_reg(jit_class_gpr);
2372 addr(rn(reg), r0, r1);
2378 _stxi_s(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2382 STW(r1, r0, _u16(i0));
2384 reg = jit_get_reg(jit_class_gpr);
2385 addi(rn(reg), r0, i0);
2392 _stxr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2395 reg = jit_get_reg(jit_class_gpr);
2396 addr(rn(reg), r0, r1);
2402 _stxi_i(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2406 STL(r1, r0, _u16(i0));
2408 reg = jit_get_reg(jit_class_gpr);
2409 addi(rn(reg), r0, i0);
2416 _stxr_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
2419 reg = jit_get_reg(jit_class_gpr);
2420 addr(rn(reg), r0, r1);
2426 _stxi_l(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
2430 STQ(r1, r0, _u16(i0));
2432 reg = jit_get_reg(jit_class_gpr);
2433 addi(rn(reg), r0, i0);
2440 _extr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2447 _extr_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2454 _extr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2461 _extr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2468 _extr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2475 _extr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2482 _bswapr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2485 t0 = jit_get_reg(jit_class_gpr);
2486 EXTBLi(r1, 0, rn(t0));
2488 SLLi(rn(t0), 8, rn(t0));
2494 _bswapr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2500 t0 = jit_get_reg(jit_class_gpr);
2501 t1 = jit_get_reg(jit_class_gpr);
2502 t2 = jit_get_reg(jit_class_gpr);
2503 t3 = jit_get_reg(jit_class_gpr);
2504 EXTBLi(r1, 3, rn(t0));
2505 INSBLi(r1, 3, rn(t1));
2506 SLLi(r1, 8, rn(t2));
2507 ZAPNOTi(rn(t2), 4, rn(t2));
2508 SRLi(r1, 8, rn(t3));
2509 OR(rn(t0), rn(t1), r0);
2511 ZAPNOTi(rn(t3), 2, rn(t3));
2520 _bswapr_ul(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2525 assert(_jitc->function != NULL);
2526 t0 = jit_get_reg(jit_class_fpr);
2527 t1 = jit_get_reg(jit_class_gpr);
2528 t2 = jit_get_reg(jit_class_gpr);
2529 stxi(-8, _FP_REGNO, r1); /* r1 = ABCD EFGH */
2530 LDG(rn(t0), _FP_REGNO, _u16(-8)); /* t0 = GHEF CDAB */
2531 STT(rn(t0), _FP_REGNO, _u16(-8));
2532 ldxi(rn(t1), _FP_REGNO, -8); /* t1 = GHEF CDAB */
2533 lshi(rn(t2), rn(t1), 8); /* t2 = HEFC DAB. */
2534 rshi_u(rn(t1), rn(t1), 8); /* t1 = .GHE FCDA */
2535 ZAPi(rn(t2), 0x55, rn(t2)); /* t2 = H.F. D.B. */
2536 ZAPi(rn(t1), 0xaa, rn(t1)); /* t1 = .G.E .C.A */
2537 orr(r0, rn(t1), rn(t2)); /* r0 = HGFE DCBA */
2544 _jmpi(jit_state_t *_jit, jit_word_t i0)
2549 d = ((i0 - w) >> 2) - 1;
2557 _jmpi_p(jit_state_t *_jit, jit_word_t i0)
2561 reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
2562 w = movi_p(rn(reg), i0);
2569 _callr(jit_state_t *_jit, jit_int32_t r0)
2571 if (r0 != _PV_REGNO)
2573 JSR(_RA_REGNO, _PV_REGNO, 0);
2577 _calli(jit_state_t *_jit, jit_word_t i0)
2579 /* FIXME use a small buffer to load constants - using gp */
2584 d = ((i0 - w) >> 2) - 1;
2590 movi(_PV_REGNO, i0);
2596 _calli_p(jit_state_t *_jit, jit_word_t i0)
2599 w = movi_p(_PV_REGNO, i0);
2605 _prolog(jit_state_t *_jit, jit_node_t *node)
2608 if (_jitc->function->define_frame || _jitc->function->assume_frame) {
2609 jit_int32_t frame = -_jitc->function->frame;
2610 assert(_jitc->function->self.aoff >= frame);
2611 if (_jitc->function->assume_frame)
2613 _jitc->function->self.aoff = frame;
2615 if (_jitc->function->allocar)
2616 _jitc->function->self.aoff &= -8;
2617 _jitc->function->stack = ((_jitc->function->self.alen -
2618 _jitc->function->self.aoff) + 7) & -8;
2619 /* ldgp gp, 0(pv) */
2620 LDAH(_PV_REGNO, _GP_REGNO, 0);
2621 LDA(_GP_REGNO, _GP_REGNO, 0);
2622 /* callee save registers */
2623 subi(_SP_REGNO, _SP_REGNO, stack_framesize);
2624 stxi(0, _SP_REGNO, _RA_REGNO);
2625 stxi(8, _SP_REGNO, _FP_REGNO);
2626 # define SPILL(N, O) \
2627 if (jit_regset_tstbit(&_jitc->function->regset, N)) \
2628 stxi(O, _SP_REGNO, N##_REGNO)
2629 # define SPILLD(N, O) \
2630 if (jit_regset_tstbit(&_jitc->function->regset, N)) \
2631 stxi_d(O, _SP_REGNO, N##_REGNO)
2648 movr(_FP_REGNO, _SP_REGNO);
2650 if (_jitc->function->stack)
2651 subi(_SP_REGNO, _SP_REGNO, _jitc->function->stack);
2652 if (_jitc->function->allocar) {
2653 reg = jit_get_reg(jit_class_gpr);
2654 movi(rn(reg), _jitc->function->self.aoff);
2655 stxi_i(_jitc->function->aoffoff, _FP_REGNO, rn(reg));
2659 if (_jitc->function->self.call & jit_call_varargs) {
2660 for (reg = _jitc->function->self.argi; jit_arg_reg_p(reg); ++reg)
2661 stxi(stack_framesize - 48 + reg * 8, _FP_REGNO, rn(_A0 - reg));
2662 for (reg = _jitc->function->self.argi; jit_arg_reg_p(reg); ++reg)
2663 stxi_d(stack_framesize - 96 + reg * 8, _FP_REGNO, rn(_F16 - reg));
2668 _epilog(jit_state_t *_jit, jit_node_t *node)
2670 if (_jitc->function->assume_frame)
2672 movr(_SP_REGNO, _FP_REGNO);
2673 ldxi(_RA_REGNO, _SP_REGNO, 0);
2674 ldxi(_FP_REGNO, _SP_REGNO, 8);
2675 # define LOAD(N, O) \
2676 if (jit_regset_tstbit(&_jitc->function->regset, N)) \
2677 ldxi(N##_REGNO, _SP_REGNO, O)
2678 # define LOADD(N, O) \
2679 if (jit_regset_tstbit(&_jitc->function->regset, N)) \
2680 ldxi_d(N##_REGNO, _SP_REGNO, O)
2697 addi(_SP_REGNO, _SP_REGNO, stack_framesize);
2698 RET(_R31_REGNO, _RA_REGNO, 1); /* 1 means procedure return
2699 * 0 means no procedure return
2700 * other values are reserved */
2704 _vastart(jit_state_t *_jit, jit_int32_t r0)
2708 /* Return jit_va_list_t in the register argument */
2709 addi(r0, _FP_REGNO, _jitc->function->vaoff);
2711 reg = jit_get_reg(jit_class_gpr);
2713 /* The base field is constant. */
2714 addi(rn(reg), _FP_REGNO, stack_framesize - 48);
2715 stxi(offsetof(jit_va_list_t, base), r0, rn(reg));
2717 /* Initialize the offset field */
2718 if (_jitc->function->vagp < 6)
2719 movi(rn(reg), _jitc->function->vagp * 8);
2721 movi(rn(reg), _jitc->function->self.size - (stack_framesize - 48));
2722 stxi(offsetof(jit_va_list_t, offset), r0, rn(reg));
2728 _vaarg(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2730 jit_int32_t rg0, rg1;
2732 assert(_jitc->function->self.call & jit_call_varargs);
2734 rg0 = jit_get_reg(jit_class_gpr);
2735 rg1 = jit_get_reg(jit_class_gpr);
2737 /* Load the base in first temporary. */
2738 ldxi(rn(rg0), r1, offsetof(jit_va_list_t, base));
2740 /* Load the offset in the second temporary. */
2741 ldxi(rn(rg1), r1, offsetof(jit_va_list_t, offset));
2743 /* Load the argument */
2744 ldxr(r0, rn(rg0), rn(rg1));
2746 /* No longer needed. */
2749 /* Update offset. */
2750 addi(rn(rg1), rn(rg1), 8);
2751 stxi(offsetof(jit_va_list_t, offset), r1, rn(rg1));
2756 _patch_at(jit_state_t *_jit, jit_word_t instr, jit_word_t label)
2763 jit_int16_t s0, s1, s2, s3;
2765 switch (_u6(u.i[0] >> 26)) {
2766 /* BLT BLE BEQ BGE */
2767 case 0x3a: case 0x3b: case 0x39: case 0x3e:
2768 /* BGT BNE BLBC BLBS */
2769 case 0x3f: case 0x3d: case 0x38: case 0x3c:
2771 case 0x30: case 0x34:
2772 /* FBLT FBLE FBEQ FBGE */
2773 case 0x32: case 0x33: case 0x31: case 0x36:
2775 case 0x37: case 0x35:
2776 d = ((label - instr) >> 2) - 1;
2778 u.i[0] &= ~0x1fffff;
2782 case 0x08: /* movi_p */
2794 assert(_u6(u.i[1] >> 26) == 0x08);
2798 assert(_u6(u.i[2] >> 26) == 0x09);
2802 assert(_u6(u.i[3] >> 26) == 0x09);
2806 assert(_u6(u.i[4] >> 26) == 0x12 && _u7(u.i[4] >> 5) == 0x39);
2808 assert(_u6(u.i[5] >> 26) == 0x12 && _u7(u.i[5] >> 5) == 0x34);
2810 assert(_u6(u.i[6] >> 26) == 0x12 && _u7(u.i[6] >> 5) == 0x39);
2812 assert(_u6(u.i[7] >> 26) == 0x11 && _u7(u.i[7] >> 5) == 0x20);