2 #define USE_BIT_TABLES 1
3 #define USE_BITSWAP_UNROLLED 0
4 #define USE_BITSWAP_LOOP 0
5 #define fallback_save(r0) _fallback_save(_jit, r0)
6 static void _fallback_save(jit_state_t*, jit_int32_t);
7 #define fallback_load(r0) _fallback_load(_jit, r0)
8 static void _fallback_load(jit_state_t*, jit_int32_t);
9 #define fallback_save_regs(r0) _fallback_save_regs(_jit, r0)
10 static void _fallback_save_regs(jit_state_t*, jit_int32_t);
11 #define fallback_load_regs(r0) _fallback_load_regs(_jit, r0)
12 static void _fallback_load_regs(jit_state_t*, jit_int32_t);
13 #define fallback_calli(i0, i1) _fallback_calli(_jit, i0, i1)
14 static void _fallback_calli(jit_state_t*, jit_word_t, jit_word_t);
15 #define fallback_casx(r0,r1,r2,r3,im) _fallback_casx(_jit,r0,r1,r2,r3,im)
16 static void _fallback_casx(jit_state_t *, jit_int32_t, jit_int32_t,
17 jit_int32_t, jit_int32_t, jit_word_t);
20 # define movr_w_f(r0, r1) fallback_movr_w_f(r0, r1)
21 # define fallback_movr_w_f(r0,r1) _fallback_movr_w_f(_jit,r0,r1)
22 static void _fallback_movr_w_f(jit_state_t*, jit_int32_t, jit_int32_t);
25 # define movr_f_w(r0, r1) fallback_movr_f_w(r0, r1)
26 # define fallback_movr_f_w(r0,r1) _fallback_movr_f_w(_jit,r0,r1)
27 static void _fallback_movr_f_w(jit_state_t*, jit_int32_t, jit_int32_t);
31 # define movr_ww_d(r0, r1, r2) fallback_movr_ww_d(r0, r1, r2)
32 # define fallback_movr_ww_d(r0,r1,r2) _fallback_movr_ww_d(_jit,r0,r1,r2)
33 static void _fallback_movr_ww_d(jit_state_t*,
34 jit_int32_t,jit_int32_t,jit_int32_t);
37 # define fallback_movr_d_ww(r0,r1,r2) _fallback_movr_d_ww(_jit,r0,r1,r2)
38 static void _fallback_movr_d_ww(jit_state_t*,
39 jit_int32_t,jit_int32_t,jit_int32_t);
40 # define movr_d_ww(r0, r1, r2) fallback_movr_d_ww(r0, r1, r2)
44 # define movr_w_d(r0, r1) fallback_movr_w_d(r0, r1);
45 # define fallback_movr_w_d(r0,r1) _fallback_movr_w_d(_jit,r0,r1)
46 static void _fallback_movr_w_d(jit_state_t*, jit_int32_t, jit_int32_t);
49 # define movr_d_w(r0, r1) fallback_movr_d_w(r0, r1);
50 # define fallback_movr_d_w(r0,r1) _fallback_movr_d_w(_jit,r0,r1)
51 static void _fallback_movr_d_w(jit_state_t*, jit_int32_t, jit_int32_t);
56 # define unldr(r0, r1, i0) fallback_unldr(r0, r1, i0)
59 # define unldi(r0, i0, i1) fallback_unldi(r0, i0, i1)
62 # define unstr(r0, r1, i0) fallback_unstr(r0, r1, i0)
65 # define unsti(i0, r0, i1) fallback_unsti(i0, r0, i1)
67 #define fallback_clo(r0,r1) _fallback_clo(_jit,r0,r1)
68 static void _fallback_clo(jit_state_t*, jit_int32_t, jit_int32_t);
69 #define fallback_clz(r0,r1) _fallback_clz(_jit,r0,r1)
70 static void _fallback_clz(jit_state_t*, jit_int32_t, jit_int32_t);
71 #define fallback_cto(r0,r1) _fallback_cto(_jit,r0,r1)
72 static void _fallback_cto(jit_state_t*, jit_int32_t, jit_int32_t);
73 #define fallback_ctz(r0,r1) _fallback_ctz(_jit,r0,r1)
74 static void _fallback_ctz(jit_state_t*, jit_int32_t, jit_int32_t);
75 #define fallback_rbit(r0,r1) _fallback_rbit(_jit, r0, r1)
76 static void _fallback_rbit(jit_state_t*, jit_int32_t, jit_int32_t);
77 #define fallback_popcnt(r0,r1) _fallback_popcnt(_jit, r0, r1)
78 static void _fallback_popcnt(jit_state_t*, jit_int32_t, jit_int32_t);
79 #define fallback_lrotr(r0, r1, r2) _fallback_lrotr(_jit, r0, r1, r2)
80 static void _fallback_lrotr(jit_state_t*, jit_int32_t,jit_int32_t,jit_int32_t);
81 #define fallback_lroti(r0, r1, i0) _fallback_lroti(_jit, r0, r1, i0)
82 static void _fallback_lroti(jit_state_t*, jit_int32_t,jit_int32_t,jit_word_t);
83 #define fallback_rrotr(r0, r1, r2) _fallback_rrotr(_jit, r0, r1, r2)
84 static void _fallback_rrotr(jit_state_t*, jit_int32_t,jit_int32_t,jit_int32_t);
85 #define fallback_rroti(r0, r1, i0) _fallback_rroti(_jit, r0, r1, i0)
86 static void _fallback_rroti(jit_state_t*, jit_int32_t,jit_int32_t,jit_word_t);
87 #define fallback_ext(r0,r1,i0,i1) _fallback_ext(_jit,r0,r1,i0,i1)
88 static void _fallback_ext(jit_state_t*,
89 jit_int32_t,jit_int32_t,jit_word_t,jit_word_t);
90 #define fallback_ext_u(r0,r1,i0,i1) _fallback_ext_u(_jit,r0,r1,i0,i1)
91 static void _fallback_ext_u(jit_state_t*,
92 jit_int32_t,jit_int32_t,jit_word_t,jit_word_t);
93 #define fallback_dep(r0,r1,i0,i1) _fallback_dep(_jit,r0,r1,i0,i1)
94 static void _fallback_dep(jit_state_t*,
95 jit_int32_t,jit_int32_t,jit_word_t,jit_word_t);
96 #define fallback_qlshr(r0,r1,r2,r3) _fallback_qlshr(_jit,r0,r1,r2,r3)
97 static void _fallback_qlshr(jit_state_t *_jit,
98 jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
99 #define fallback_qlshi(r0,r1,r2,i0) _fallback_qlshi(_jit,r0,r1,r2,i0)
100 static void _fallback_qlshi(jit_state_t *_jit,
101 jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
102 #define fallback_qlshr_u(r0,r1,r2,r3) _fallback_qlshr_u(_jit,r0,r1,r2,r3)
103 static void _fallback_qlshr_u(jit_state_t *_jit,
104 jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
105 #define fallback_qlshi_u(r0,r1,r2,i0) _fallback_qlshi_u(_jit,r0,r1,r2,i0)
106 static void _fallback_qlshi_u(jit_state_t *_jit,
107 jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
108 #define fallback_qrshr(r0,r1,r2,r3) _fallback_qrshr(_jit,r0,r1,r2,r3)
109 static void _fallback_qrshr(jit_state_t *_jit,
110 jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
111 #define fallback_qrshi(r0,r1,r2,i0) _fallback_qrshi(_jit,r0,r1,r2,i0)
112 static void _fallback_qrshi(jit_state_t *_jit,
113 jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
114 #define fallback_qrshr_u(r0,r1,r2,r3) _fallback_qrshr_u(_jit,r0,r1,r2,r3)
115 static void _fallback_qrshr_u(jit_state_t *_jit,
116 jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
117 #define fallback_qrshi_u(r0,r1,r2,i0) _fallback_qrshi_u(_jit,r0,r1,r2,i0)
118 static void _fallback_qrshi_u(jit_state_t *_jit,
119 jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
120 #define unldr2(r0, r1, sign) _unldr2(_jit, r0, r1, sign)
121 static void _unldr2(jit_state_t*,jit_int32_t,jit_int32_t,jit_bool_t);
122 #define unldi2(r0, i1, sign) _unldi2(_jit, r0, i1, sign)
123 static void _unldi2(jit_state_t*,jit_int32_t,jit_word_t,jit_bool_t);
124 #define unldr3(r0, r1, sign) _unldr3(_jit, r0, r1, sign)
125 static void _unldr3(jit_state_t*,jit_int32_t,jit_int32_t,jit_bool_t);
126 #define unldi3(r0, i1, sign) _unldi3(_jit, r0, i1, sign)
127 static void _unldi3(jit_state_t*,jit_int32_t,jit_word_t,jit_bool_t);
129 # define unldr4(r0, r1) _unldr4(_jit, r0, r1)
130 static void _unldr4(jit_state_t*,jit_int32_t,jit_int32_t);
131 # define unldi4(r0, i1) _unldi4(_jit, r0, i1)
132 static void _unldi4(jit_state_t*,jit_int32_t,jit_word_t);
134 # define unldr4(r0, r1, sign) _unldr4(_jit, r0, r1, sign)
135 static void _unldr4(jit_state_t*,jit_int32_t,jit_int32_t,jit_bool_t);
136 # define unldi4(r0, i1, sign) _unldi4(_jit, r0, i1, sign)
137 static void _unldi4(jit_state_t*,jit_int32_t,jit_word_t,jit_bool_t);
138 # define unldr5(r0, r1, sign) _unldr5(_jit, r0, r1, sign)
139 static void _unldr5(jit_state_t*,jit_int32_t,jit_int32_t,jit_bool_t);
140 # define unldi5(r0, i1, sign) _unldi5(_jit, r0, i1, sign)
141 static void _unldi5(jit_state_t*,jit_int32_t,jit_word_t,jit_bool_t);
142 # define unldr6(r0, r1, sign) _unldr6(_jit, r0, r1, sign)
143 static void _unldr6(jit_state_t*,jit_int32_t,jit_int32_t,jit_bool_t);
144 # define unldi6(r0, i1, sign) _unldi6(_jit, r0, i1, sign)
145 static void _unldi6(jit_state_t*,jit_int32_t,jit_word_t,jit_bool_t);
146 # define unldr7(r0, r1, sign) _unldr7(_jit, r0, r1, sign)
147 static void _unldr7(jit_state_t*,jit_int32_t,jit_int32_t,jit_bool_t);
148 # define unldi7(r0, i1, sign) _unldi7(_jit, r0, i1, sign)
149 static void _unldi7(jit_state_t*,jit_int32_t,jit_word_t,jit_bool_t);
150 # define unldr8(r0, r1) _unldr8(_jit, r0, r1)
151 static void _unldr8(jit_state_t*,jit_int32_t,jit_int32_t);
152 # define unldi8(r0, i1) _unldi8(_jit, r0, i1)
153 static void _unldi8(jit_state_t*,jit_int32_t,jit_word_t);
155 #define unstr2(r0, r1) _unstr2(_jit, r0, r1)
156 static void _unstr2(jit_state_t*,jit_int32_t,jit_int32_t);
157 #define unsti2(r0, i0) _unsti2(_jit, r0, i0)
158 static void _unsti2(jit_state_t*,jit_int32_t,jit_word_t);
159 #define unstr3(r0, r1) _unstr3(_jit, r0, r1)
160 static void _unstr3(jit_state_t*,jit_int32_t,jit_int32_t);
161 #define unsti3(r0, i0) _unsti3(_jit, r0, i0)
162 static void _unsti3(jit_state_t*,jit_int32_t,jit_word_t);
163 #define unstr4(r0, r1) _unstr4(_jit, r0, r1)
164 static void _unstr4(jit_state_t*,jit_int32_t,jit_int32_t);
165 #define unsti4(r0, i0) _unsti4(_jit, r0, i0)
166 static void _unsti4(jit_state_t*,jit_int32_t,jit_word_t);
168 # define unstr5(r0, r1) _unstr5(_jit, r0, r1)
169 static void _unstr5(jit_state_t*,jit_int32_t,jit_int32_t);
170 # define unsti5(r0, i0) _unsti5(_jit, r0, i0)
171 static void _unsti5(jit_state_t*,jit_int32_t,jit_word_t);
172 # define unstr6(r0, r1) _unstr6(_jit, r0, r1)
173 static void _unstr6(jit_state_t*,jit_int32_t,jit_int32_t);
174 # define unsti6(r0, i0) _unsti6(_jit, r0, i0)
175 static void _unsti6(jit_state_t*,jit_int32_t,jit_word_t);
176 # define unstr7(r0, r1) _unstr7(_jit, r0, r1)
177 static void _unstr7(jit_state_t*,jit_int32_t,jit_int32_t);
178 # define unsti7(r0, i0) _unsti7(_jit, r0, i0)
179 static void _unsti7(jit_state_t*,jit_int32_t,jit_word_t);
180 # define unstr8(r0, r1) _unstr8(_jit, r0, r1)
181 static void _unstr8(jit_state_t*,jit_int32_t,jit_int32_t);
182 # define unsti8(r0, i0) _unsti8(_jit, r0, i0)
183 static void _unsti8(jit_state_t*,jit_int32_t,jit_word_t);
185 #define unldrw(r0, r1, i0) _unldrw(_jit, r0, r1, i0)
186 static void _unldrw(jit_state_t*,jit_int32_t,jit_int32_t, jit_word_t);
187 #define unldiw(r0, i0, i1) _unldiw(_jit, r0, i0, i1)
188 static void _unldiw(jit_state_t*,jit_int32_t,jit_word_t, jit_word_t);
189 #define unldx(r0, i0) _unldx(_jit, r0, i0)
190 static void _unldx(jit_state_t*,jit_int32_t,jit_word_t);
191 #define unldx_u(r0, i0) _unldx_u(_jit, r0, i0)
192 static void _unldx_u(jit_state_t*,jit_int32_t,jit_word_t);
193 #define fallback_unldr(r0, r1, i0) _fallback_unldr(_jit, r0, r1, i0)
194 static void _fallback_unldr(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
195 #define fallback_unldi(r0, i0, i1) _fallback_unldi(_jit, r0, i0, i1)
196 static void _fallback_unldi(jit_state_t*,jit_int32_t,jit_word_t,jit_word_t);
197 #define fallback_unldr_u(r0, r1, i0) _fallback_unldr_u(_jit, r0, r1, i0)
198 static void _fallback_unldr_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
199 #define fallback_unldi_u(r0, i0, i1) _fallback_unldi_u(_jit, r0, i0, i1)
200 static void _fallback_unldi_u(jit_state_t*,jit_int32_t,jit_word_t,jit_word_t);
201 #define fallback_unstr(r0, r1, i0) _fallback_unstr(_jit, r0, r1, i0)
202 static void _fallback_unstr(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
203 #define fallback_unsti(i0, r0, i1) _fallback_unsti(_jit, i0, r0, i1)
204 static void _fallback_unsti(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
205 #if !defined(__arm__)
206 # define fallback_unldr_x(r0, r1, i0) _fallback_unldr_x(_jit, r0, r1, i0)
207 static void _fallback_unldr_x(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
208 # define fallback_unldi_x(r0, i0, i1) _fallback_unldi_x(_jit, r0, i0, i1)
209 static void _fallback_unldi_x(jit_state_t*,jit_int32_t,jit_word_t,jit_word_t);
210 # define fallback_unstr_x(r0, r1, i0) _fallback_unstr_x(_jit, r0, r1, i0)
211 static void _fallback_unstr_x(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
212 # define fallback_unsti_x(i0, r0, i1) _fallback_unsti_x(_jit, i0, r0, i1)
213 static void _fallback_unsti_x(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
215 # if defined(__s390__) || defined(__s390x__)
216 # define fallback_jit_get_reg(flags) jit_get_reg_but_zero(flags)
218 # define fallback_jit_get_reg(flags) jit_get_reg(flags)
220 # if defined(__ia64__)
221 # define fallback_flush() sync()
222 # elif defined(__mips__)
223 # define fallback_flush() flush()
225 # define fallback_flush() /**/
227 # if defined(__mips__)
228 # define fallback_jmpi(i0) jmpi(i0, 1)
229 # elif defined(__arm__)
230 # define fallback_jmpi(i0) jmpi_p(i0, 1)
231 # elif defined(__s390__) || defined(__s390x__)
232 # define fallback_jmpi(i0) jmpi(i0, 1)
234 # define fallback_jmpi(i0) jmpi(i0)
236 # if defined(__s390__) || defined(__s390x__)
237 # define fallback_beqr(i0,r0,i1) beqr_p(i0,r0,i1)
238 # define fallback_beqi(i0,r0,i1) beqi_p(i0,r0,i1)
239 # define fallback_bner(i0,r0,r1) bner_p(i0,r0,r1)
240 # define fallback_bnei(i0,r0,i1) bnei_p(i0,r0,i1)
241 # define fallback_blei(i0,r0,i1) blei_p(i0,r0,i1)
242 # define fallback_bmsr(i0,r0,r1) bmsr_p(i0,r0,r1)
243 # define fallback_bmsi(i0,r0,i1) bmsi_p(i0,r0,i1)
245 # define fallback_beqr(i0,r0,r1) beqr(i0,r0,r1)
246 # define fallback_beqi(i0,r0,i1) beqi(i0,r0,i1)
247 # define fallback_bner(i0,r0,r1) bner(i0,r0,r1)
248 # define fallback_bnei(i0,r0,i1) bnei(i0,r0,i1)
249 # define fallback_blei(i0,r0,i1) blei(i0,r0,i1)
250 # define fallback_bmsr(i0,r0,r1) bmsr(i0,r0,r1)
251 # define fallback_bmsi(i0,r0,i1) bmsi(i0,r0,i1)
253 # if defined(__ia64__)
254 # define fallback_patch_jmpi(inst, lbl) \
255 patch_at(jit_code_jmpi, inst, lbl)
256 # define fallback_patch_beqr(inst, lbl) \
257 patch_at(jit_code_beqr, inst, lbl)
258 # define fallback_patch_beqi(inst, lbl) \
259 patch_at(jit_code_beqi, inst, lbl)
260 # define fallback_patch_bner(inst, lbl) \
261 patch_at(jit_code_bner, inst, lbl)
262 # define fallback_patch_bnei(inst, lbl) \
263 patch_at(jit_code_bnei, inst, lbl)
264 # define fallback_patch_blei(inst, lbl) \
265 patch_at(jit_code_blei, inst, lbl)
266 # define fallback_patch_bmsr(inst, lbl) \
267 patch_at(jit_code_bmsr, inst, lbl)
268 # define fallback_patch_bmsi(inst, lbl) \
269 patch_at(jit_code_bmsi, inst, lbl)
270 # elif defined(__arm__)
271 # define fallback_patch_jmpi(inst, lbl) \
272 patch_at(arm_patch_jump,inst, lbl)
273 # define fallback_patch_beqr(inst, lbl) \
274 patch_at(arm_patch_jump,inst, lbl)
275 # define fallback_patch_beqi(inst, lbl) \
276 patch_at(arm_patch_jump,inst, lbl)
277 # define fallback_patch_bner(inst, lbl) \
278 patch_at(arm_patch_jump,inst, lbl)
279 # define fallback_patch_bnei(inst, lbl) \
280 patch_at(arm_patch_jump,inst, lbl)
281 # define fallback_patch_blei(inst, lbl) \
282 patch_at(arm_patch_jump,inst, lbl)
283 # define fallback_patch_bmsr(inst, lbl) \
284 patch_at(arm_patch_jump,inst, lbl)
285 # define fallback_patch_bmsi(inst, lbl) \
286 patch_at(arm_patch_jump,inst, lbl)
288 # define fallback_patch_jmpi(inst, lbl) \
290 # define fallback_patch_beqr(inst, lbl) \
292 # define fallback_patch_beqi(inst, lbl) \
294 # define fallback_patch_bner(inst, lbl) \
296 # define fallback_patch_bnei(inst, lbl) \
298 # define fallback_patch_blei(inst, lbl) \
300 # define fallback_patch_bmsr(inst, lbl) \
302 # define fallback_patch_bmsi(inst, lbl) \
309 _fallback_save(jit_state_t *_jit, jit_int32_t r0)
311 jit_int32_t offset, regno, spec;
312 for (offset = 0; offset < JIT_R_NUM; offset++) {
313 spec = _rvs[offset].spec;
314 regno = jit_regno(spec);
316 if (!(spec & jit_class_sav))
317 stxi(_jitc->function->regoff[JIT_R(offset)], rn(JIT_FP), regno);
324 _fallback_load(jit_state_t *_jit, jit_int32_t r0)
326 jit_int32_t offset, regno, spec;
327 for (offset = 0; offset < JIT_R_NUM; offset++) {
328 spec = _rvs[offset].spec;
329 regno = jit_regno(spec);
331 if (!(spec & jit_class_sav))
332 ldxi(regno, rn(JIT_FP), _jitc->function->regoff[JIT_R(offset)]);
339 _fallback_save_regs(jit_state_t *_jit, jit_int32_t r0)
341 jit_int32_t regno, spec;
342 for (regno = 0; regno < _jitc->reglen; regno++) {
343 spec = _rvs[regno].spec;
344 if ((jit_regset_tstbit(&_jitc->regarg, regno) ||
345 jit_regset_tstbit(&_jitc->reglive, regno)) &&
346 !(spec & jit_class_sav)) {
347 if (!_jitc->function->regoff[regno]) {
348 _jitc->function->regoff[regno] =
349 jit_allocai(spec & jit_class_gpr ?
350 sizeof(jit_word_t) : sizeof(jit_float64_t));
353 if ((spec & jit_class_gpr) && rn(regno) == r0)
355 jit_regset_setbit(&_jitc->regsav, regno);
356 if (spec & jit_class_gpr)
357 emit_stxi(_jitc->function->regoff[regno], JIT_FP, regno);
359 emit_stxi_d(_jitc->function->regoff[regno], JIT_FP, regno);
365 _fallback_load_regs(jit_state_t *_jit, jit_int32_t r0)
367 jit_int32_t regno, spec;
368 for (regno = 0; regno < _jitc->reglen; regno++) {
369 spec = _rvs[regno].spec;
370 if ((jit_regset_tstbit(&_jitc->regarg, regno) ||
371 jit_regset_tstbit(&_jitc->reglive, regno)) &&
372 !(spec & jit_class_sav)) {
373 if ((spec & jit_class_gpr) && rn(regno) == r0)
375 jit_regset_setbit(&_jitc->regsav, regno);
376 if (spec & jit_class_gpr)
377 emit_ldxi(regno, JIT_FP, _jitc->function->regoff[regno]);
379 emit_ldxi_d(regno, JIT_FP, _jitc->function->regoff[regno]);
385 _fallback_calli(jit_state_t *_jit, jit_word_t i0, jit_word_t i1)
387 # if defined(__arm__)
389 # elif defined(__hppa__)
390 movi(_R26_REGNO, i1);
392 # if defined(__arm__)
393 calli(i0, jit_exchange_p());
394 # elif defined(__mips__)
396 # elif defined(__powerpc__) && _CALL_SYSV
398 # elif defined(__s390__) || defined(__s390x__)
405 #ifdef NEED_FALLBACK_CASX
407 _fallback_casx(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
408 jit_int32_t r2, jit_int32_t r3, jit_word_t i0)
410 jit_int32_t r1_reg, iscasi;
411 jit_word_t jump, done;
412 /* XXX only attempts to fallback cas for lightning jit code */
413 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
414 if ((iscasi = r1 == _NOREG)) {
415 r1_reg = fallback_jit_get_reg(jit_class_gpr|jit_class_sav);
419 fallback_save_regs(r0);
420 fallback_calli((jit_word_t)pthread_mutex_lock, (jit_word_t)&mutex);
426 jump = fallback_bnei(_jit->pc.w, r0, 1);
428 # if __WORDSIZE == 32
436 fallback_calli((jit_word_t)pthread_mutex_unlock, (jit_word_t)&mutex);
439 fallback_patch_bnei(jump, done);
440 fallback_load_regs(r0);
442 jit_unget_reg(r1_reg);
446 #ifdef fallback_movr_w_f
448 _fallback_movr_w_f(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
450 if (!_jitc->function->cvt_offset) {
451 _jitc->function->cvt_offset = jit_allocai(8);
454 stxi_i(_jitc->function->cvt_offset, rn(JIT_FP), r1);
455 /* Useful for special debug builds */
456 # if defined(__i386__) || defined(__x86_64__)
458 sse_ldxi_f(r0, rn(JIT_FP), _jitc->function->cvt_offset);
460 x87_ldxi_f(r0, rn(JIT_FP), _jitc->function->cvt_offset);
462 ldxi_f(r0, rn(JIT_FP), _jitc->function->cvt_offset);
467 #ifdef fallback_movr_f_w
469 _fallback_movr_f_w(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
471 if (!_jitc->function->cvt_offset) {
472 _jitc->function->cvt_offset = jit_allocai(8);
475 # if defined(__i386__) || defined(__x86_64__)
477 sse_stxi_f(_jitc->function->cvt_offset, rn(JIT_FP), r1);
479 x87_stxi_f(_jitc->function->cvt_offset, rn(JIT_FP), r1);
481 stxi_f(_jitc->function->cvt_offset, rn(JIT_FP), r1);
483 ldxi_i(r0, rn(JIT_FP), _jitc->function->cvt_offset);
488 # ifdef fallback_movr_ww_d
490 _fallback_movr_ww_d(jit_state_t *_jit,
491 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
493 if (!_jitc->function->cvt_offset) {
494 _jitc->function->cvt_offset = jit_allocai(8);
497 stxi_i(_jitc->function->cvt_offset, rn(JIT_FP),
498 __BYTE_ORDER == __LITTLE_ENDIAN ? r1 : r2);
499 stxi_i(_jitc->function->cvt_offset + 4, rn(JIT_FP),
500 __BYTE_ORDER == __LITTLE_ENDIAN ? r2 : r1);
501 # if defined(__i386__) || defined(__x86_64__)
503 sse_ldxi_d(r0, rn(JIT_FP), _jitc->function->cvt_offset);
505 x87_ldxi_d(r0, rn(JIT_FP), _jitc->function->cvt_offset);
507 ldxi_d(r0, rn(JIT_FP), _jitc->function->cvt_offset);
512 # ifdef fallback_movr_d_ww
514 _fallback_movr_d_ww(jit_state_t *_jit,
515 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
517 if (!_jitc->function->cvt_offset) {
518 _jitc->function->cvt_offset = jit_allocai(8);
521 # if defined(__i386__) || defined(__x86_64__)
523 sse_stxi_d(_jitc->function->cvt_offset, rn(JIT_FP), r2);
525 x87_stxi_d(_jitc->function->cvt_offset, rn(JIT_FP), r2);
527 stxi_d(_jitc->function->cvt_offset, rn(JIT_FP), r2);
529 ldxi_i(__BYTE_ORDER == __LITTLE_ENDIAN ? r0 : r1,
530 rn(JIT_FP), _jitc->function->cvt_offset);
531 ldxi_i(__BYTE_ORDER == __LITTLE_ENDIAN ? r1 : r0,
532 rn(JIT_FP), _jitc->function->cvt_offset + 4);
537 # ifdef fallback_movr_w_d
539 _fallback_movr_w_d(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
541 if (!_jitc->function->cvt_offset) {
542 _jitc->function->cvt_offset = jit_allocai(8);
545 stxi_l(_jitc->function->cvt_offset, rn(JIT_FP), r1);
546 # if defined(__i386__) || defined(__x86_64__)
548 sse_ldxi_d(r0, rn(JIT_FP), _jitc->function->cvt_offset);
550 x87_ldxi_d(r0, rn(JIT_FP), _jitc->function->cvt_offset);
552 ldxi_d(r0, rn(JIT_FP), _jitc->function->cvt_offset);
557 # ifdef fallback_movr_d_w
559 _fallback_movr_d_w(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
561 if (!_jitc->function->cvt_offset) {
562 _jitc->function->cvt_offset = jit_allocai(8);
565 # if defined(__i386__) || defined(__x86_64__)
567 sse_stxi_d(_jitc->function->cvt_offset, rn(JIT_FP), r1);
569 x87_stxi_d(_jitc->function->cvt_offset, rn(JIT_FP), r1);
571 stxi_d(_jitc->function->cvt_offset, rn(JIT_FP), r1);
573 ldxi_l(r0, rn(JIT_FP), _jitc->function->cvt_offset);
579 _fallback_clo(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
581 jit_word_t clz, done;
583 clz = fallback_bnei(_jit->pc.w, r0, 0);
584 movi(r0, __WORDSIZE);
586 done = fallback_jmpi(_jit->pc.w);
588 fallback_patch_bnei(clz, _jit->pc.w);
589 fallback_clz(r0, r0);
591 fallback_patch_jmpi(done, _jit->pc.w);
595 _fallback_clz(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
598 /* t0 = __WORDSIZE - 8;
608 * r0 = __WORDSIZE - 8 - t0 + clz_tab[t1]
610 /* Table below is count of leading zeros of 8 bit values. */
611 static const jit_uint8_t clz_tab[256] = {
612 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
613 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
614 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
615 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
616 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
617 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
618 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
619 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
622 jit_word_t loop, done;
623 t0 = fallback_jit_get_reg(jit_class_gpr);
624 t1 = fallback_jit_get_reg(jit_class_gpr);
625 movi(rn(t0), __WORDSIZE - 8);
628 rshr_u(rn(t1), r1, rn(t0));
629 done = fallback_bnei(_jit->pc.w, rn(t1), 0);
630 subi(rn(t0), rn(t0), 8);
631 fallback_bnei(loop, rn(t0), 0);
634 fallback_patch_bnei(done, _jit->pc.w);
635 rsbi(r0, rn(t0), __WORDSIZE - 8);
636 movi(rn(t0), (jit_word_t)clz_tab);
637 ldxr_uc(rn(t1), rn(t0), rn(t1));
638 addr(r0, r0, rn(t1));
642 jit_int32_t r1_reg, r2, r2_reg;
643 jit_word_t clz, l32, l16, l8, l4, l2, l1;
644 l32 = fallback_bnei(_jit->pc.w, r1, 0);
645 movi(r0, __WORDSIZE);
646 clz = fallback_jmpi(_jit->pc.w);
648 fallback_patch_bnei(l32, _jit->pc.w);
649 r2_reg = fallback_jit_get_reg(jit_class_gpr);
651 r1_reg = fallback_jit_get_reg(jit_class_gpr);
652 movr(rn(r1_reg), r1);
655 # if __WORDSIZE == 64
656 movi(r2, 0xffffffff00000000UL);
657 l32 = fallback_bmsr(_jit->pc.w, r1, r2);
661 fallback_patch_bmsr(l32, _jit->pc.w);
664 movi(r2, 0xffff0000UL);
666 l16 = fallback_bmsr(_jit->pc.w, r1, r2);
670 fallback_patch_bmsr(l16, _jit->pc.w);
672 l8 = fallback_bmsr(_jit->pc.w, r1, r2);
676 fallback_patch_bmsr(l8, _jit->pc.w);
678 l4 = fallback_bmsr(_jit->pc.w, r1, r2);
682 fallback_patch_bmsr(l4, _jit->pc.w);
684 l2 = fallback_bmsr(_jit->pc.w, r1, r2);
688 fallback_patch_bmsr(l2, _jit->pc.w);
690 l1 = fallback_bmsr(_jit->pc.w, r1, r2);
693 fallback_patch_bmsr(l1, _jit->pc.w);
694 fallback_patch_jmpi(clz, _jit->pc.w);
695 jit_unget_reg(r2_reg);
696 jit_unget_reg(r1_reg);
701 _fallback_cto(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
703 jit_word_t ctz, done;
705 ctz = fallback_bnei(_jit->pc.w, r0, 0);
706 movi(r0, __WORDSIZE);
707 done = fallback_jmpi(_jit->pc.w);
709 fallback_patch_bnei(ctz, _jit->pc.w);
710 fallback_ctz(r0, r0);
712 fallback_patch_jmpi(done, _jit->pc.w);
716 _fallback_ctz(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
719 /* Adapted from http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
720 * Table for 64 bits was recomputed choosing 67 as next prime number.
721 * The cost of the modulo might not compensate and could be better to
722 * use the alternate version (or rbit and use clz).
725 # if __WORDSIZE == 32
726 static const jit_uint8_t mod37[] = {
727 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13,
728 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9,
731 /* return mod37[(-r1 & r1) % 37]; */
733 static const jit_uint8_t mod67[] = {
734 64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 59, 41, 19, 24, 54,
735 4, 0, 13, 10, 17, 62, 60, 28, 42, 30, 20, 51, 25, 44, 55, 47,
736 5, 32, 0, 38, 14, 22, 11, 58, 18, 53, 63, 9, 61, 27, 29, 50,
737 43, 46, 31, 37, 21, 57, 52, 8, 26, 49, 45, 36, 56, 7, 48, 35,
740 /* return mod67[(-r1 & r1) % 67]; */
742 t0 = fallback_jit_get_reg(jit_class_gpr);
745 andr(r0, rn(t0), r1);
751 # if __WORDSIZE == 32
753 movi(rn(t0), (jit_word_t)mod37);
756 movi(rn(t0), (jit_word_t)mod67);
758 ldxr_uc(r0, rn(t0), r0);
761 jit_int32_t r1_reg, r2, r2_reg;
762 jit_word_t ctz, l32, l16, l8, l4, l2, l1;
763 l32 = fallback_bnei(_jit->pc.w, r1, 0);
764 movi(r0, __WORDSIZE);
765 ctz = fallback_jmpi(_jit->pc.w);
767 fallback_patch_bnei(l32, _jit->pc.w);
768 r2_reg = fallback_jit_get_reg(jit_class_gpr);
770 r1_reg = fallback_jit_get_reg(jit_class_gpr);
771 movr(rn(r1_reg), r1);
774 # if __WORDSIZE == 64
775 movi(r2, 0xffffffffUL);
776 l32 = fallback_bmsr(_jit->pc.w, r1, r2);
780 fallback_patch_bmsr(l32, _jit->pc.w);
785 l16 = fallback_bmsr(_jit->pc.w, r1, r2);
789 fallback_patch_bmsr(l16, _jit->pc.w);
791 l8 = fallback_bmsr(_jit->pc.w, r1, r2);
795 fallback_patch_bmsr(l8, _jit->pc.w);
797 l4 = fallback_bmsr(_jit->pc.w, r1, r2);
801 fallback_patch_bmsr(l4, _jit->pc.w);
803 l2 = fallback_bmsr(_jit->pc.w, r1, r2);
807 fallback_patch_bmsr(l2, _jit->pc.w);
809 l1 = fallback_bmsr(_jit->pc.w, r1, r2);
812 fallback_patch_bmsr(l1, _jit->pc.w);
813 fallback_patch_jmpi(ctz, _jit->pc.w);
814 jit_unget_reg(r2_reg);
815 jit_unget_reg(r1_reg);
820 _fallback_rbit(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
834 * if (t3 < __WORDSIZE)
838 jit_int32_t t0, r1_reg, t1, t2, t3;
839 static const unsigned char swap_tab[256] = {
840 0, 128, 64, 192, 32, 160, 96, 224,
841 16, 144, 80, 208, 48, 176, 112, 240,
842 8, 136, 72, 200, 40, 168, 104, 232,
843 24, 152, 88, 216 ,56, 184, 120, 248,
844 4, 132, 68, 196, 36, 164, 100, 228,
845 20, 148, 84, 212, 52, 180, 116, 244,
846 12, 140, 76, 204, 44, 172, 108, 236,
847 28, 156, 92, 220, 60, 188, 124, 252,
848 2, 130, 66, 194, 34, 162, 98, 226,
849 18, 146, 82, 210, 50, 178, 114, 242,
850 10, 138, 74, 202, 42, 170, 106, 234,
851 26, 154, 90, 218, 58, 186, 122, 250,
852 6, 134, 70, 198, 38, 166, 102, 230,
853 22, 150, 86, 214, 54, 182, 118, 246,
854 14, 142, 78, 206, 46, 174, 110, 238,
855 30, 158, 94, 222, 62, 190, 126, 254,
856 1, 129, 65, 193, 33, 161, 97, 225,
857 17, 145, 81, 209, 49, 177, 113, 241,
858 9, 137, 73, 201, 41, 169, 105, 233,
859 25, 153, 89, 217, 57, 185, 121, 249,
860 5, 133, 69, 197, 37, 165, 101, 229,
861 21, 149, 85, 213, 53, 181, 117, 245,
862 13, 141, 77, 205, 45, 173, 109, 237,
863 29, 157, 93, 221, 61, 189, 125, 253,
864 3, 131, 67, 195, 35, 163, 99, 227,
865 19, 147, 83, 211, 51, 179, 115, 243,
866 11, 139, 75, 203, 43, 171, 107, 235,
867 27, 155, 91, 219, 59, 187, 123, 251,
868 7, 135, 71, 199, 39, 167, 103, 231,
869 23, 151, 87, 215, 55, 183, 119, 247,
870 15, 143, 79, 207, 47, 175, 111, 239,
871 31, 159, 95, 223, 63, 191, 127, 255
874 t0 = fallback_jit_get_reg(jit_class_gpr);
881 t1 = fallback_jit_get_reg(jit_class_gpr);
882 t2 = fallback_jit_get_reg(jit_class_gpr);
883 t3 = fallback_jit_get_reg(jit_class_gpr);
886 extr_uc(rn(t1), r1_reg);
887 movi(rn(t2), (jit_word_t)swap_tab);
888 ldxr_uc(r0, rn(t2), rn(t1));
892 rshr(rn(t1), r1_reg, rn(t3));
893 extr_uc(rn(t1), rn(t1));
895 ldxr_uc(rn(t1), rn(t2), rn(t1));
897 addi(rn(t3), rn(t3), 8);
898 blti(loop, rn(t3), __WORDSIZE);
904 # elif USE_BITSWAP_UNROLLED
905 /* http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */
907 unsigned int v; // 32-bit word to reverse bit order
909 // swap odd and even bits
910 v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
911 // swap consecutive pairs
912 v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2);
914 v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4);
916 v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8);
917 // swap 2-byte long pairs
918 v = ( v >> 16 ) | ( v << 16);
920 jit_int32_t t0, t1, t2, t3, t4;
922 t0 = fallback_jit_get_reg(jit_class_gpr);
923 t1 = fallback_jit_get_reg(jit_class_gpr);
924 t2 = fallback_jit_get_reg(jit_class_gpr);
925 movi(rn(t0), __WORDSIZE == 32 ? 0x55555555L : 0x5555555555555555L);
926 rshi_u(rn(t1), r0, 1); /* t1 = v >> 1 */
927 andr(rn(t1), rn(t1), rn(t0)); /* t1 &= t0 */
928 andr(rn(t2), r0, rn(t0)); /* t2 = v & t0*/
929 lshi(rn(t2), rn(t2), 1); /* t2 <<= 1 */
930 orr(r0, rn(t1), rn(t2)); /* v = t1 | t2 */
931 movi(rn(t0), __WORDSIZE == 32 ? 0x33333333L : 0x3333333333333333L);
932 rshi_u(rn(t1), r0, 2); /* t1 = v >> 2 */
933 andr(rn(t1), rn(t1), rn(t0)); /* t1 &= t0 */
934 andr(rn(t2), r0, rn(t0)); /* t2 = v & t0*/
935 lshi(rn(t2), rn(t2), 2); /* t2 <<= 2 */
936 orr(r0, rn(t1), rn(t2)); /* v = t1 | t2 */
937 movi(rn(t0), __WORDSIZE == 32 ? 0x0f0f0f0fL : 0x0f0f0f0f0f0f0f0fL);
938 rshi_u(rn(t1), r0, 4); /* t1 = v >> 4 */
939 andr(rn(t1), rn(t1), rn(t0)); /* t1 &= t0 */
940 andr(rn(t2), r0, rn(t0)); /* t2 = v & t0*/
941 lshi(rn(t2), rn(t2), 4); /* t2 <<= 4 */
942 orr(r0, rn(t1), rn(t2)); /* v = t1 | t2 */
943 movi(rn(t0), __WORDSIZE == 32 ? 0x00ff00ffL : 0x00ff00ff00ff00ffL);
944 rshi_u(rn(t1), r0, 8); /* t1 = v >> 8 */
945 andr(rn(t1), rn(t1), rn(t0)); /* t1 &= t0 */
946 andr(rn(t2), r0, rn(t0)); /* t2 = v & t0*/
947 lshi(rn(t2), rn(t2), 8); /* t2 <<= 8 */
948 orr(r0, rn(t1), rn(t2)); /* v = t1 | t2 */
949 # if __WORDSIZE == 32
950 rshi_u(rn(t1), r0, 16); /* t1 = v >> 16 */
951 lshi(rn(t2), r0, 16); /* t2 = v << 16 */
952 orr(r0, rn(t1), rn(t2)); /* v = t1 | t2 */
954 movi(rn(t0), 0x0000ffff0000ffffL);
955 rshi_u(rn(t1), r0, 16); /* t1 = v >> 16 */
956 andr(rn(t1), rn(t1), rn(t0)); /* t1 &= t0 */
957 andr(rn(t2), r0, rn(t0)); /* t2 = v & t0*/
958 lshi(rn(t2), rn(t2), 16); /* t2 <<= 16 */
959 orr(r0, rn(t1), rn(t2)); /* v = t1 | t2 */
960 rshi_u(rn(t1), r0, 32); /* t1 = v >> 32 */
961 lshi(rn(t2), r0, 32); /* t2 = v << 32 */
962 orr(r0, rn(t1), rn(t2)); /* v = t1 | t2 */
967 # elif USE_BITSWAP_LOOP
968 /* http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */
970 unsigned int s = sizeof(v) * CHAR_BIT; // bit size; must be power of 2
971 unsigned int mask = ~0;
972 while ((s >>= 1) > 0)
975 v = ((v >> s) & mask) | ((v << s) & ~mask);
979 jit_word_t loop, done, t0, t1;
981 s = fallback_jit_get_reg(jit_class_gpr);
982 movi(rn(s), __WORDSIZE); /* s = sizeof(v) * CHAR_BIT; */
983 mask = fallback_jit_get_reg(jit_class_gpr);
984 movi(rn(mask), ~0L); /* mask = ~0; */
986 loop = _jit->pc.w; /* while ((s >>= 1) > 0) */
987 rshi(rn(s), rn(s), 1); /* (s >>= 1) */
988 done = blei(_jit->pc.w, rn(s), 0); /* no loop if s <= 0 */
989 t0 = fallback_jit_get_reg(jit_class_gpr);
990 lshr(rn(t0), rn(mask), rn(s)); /* t0 = (mask << s) */
991 xorr(rn(mask), rn(mask), rn(t0)); /* mask ^= t0 */
992 rshr(rn(t0), v, rn(s)); /* t0 = v >> s */
993 andr(rn(t0), rn(t0), rn(mask)); /* t0 = t0 & mask */
994 t1 = fallback_jit_get_reg(jit_class_gpr);
995 lshr(rn(t1), v, rn(s)); /* t1 = v << s */
996 comr(v, rn(mask)); /* v = ~mask */
997 andr(rn(t1), v, rn(t1)); /* t1 = t1 & v */
998 orr(v, rn(t0), rn(t1)); /* v = t0 | t1 */
1001 patch_at(done, _jit->pc.w);
1004 jit_unget_reg(mask);
1010 _fallback_popcnt(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
1012 /* Same approach as rbitr */
1024 * if (t3 < __WORDSIZE)
1028 jit_int32_t t0, r1_reg, t1, t2, t3;
1029 static const unsigned char pop_tab[256] = {
1030 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
1031 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
1032 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
1033 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
1034 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
1035 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
1036 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
1037 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
1040 t0 = fallback_jit_get_reg(jit_class_gpr);
1047 t1 = fallback_jit_get_reg(jit_class_gpr);
1048 t2 = fallback_jit_get_reg(jit_class_gpr);
1049 t3 = fallback_jit_get_reg(jit_class_gpr);
1052 extr_uc(rn(t1), r1_reg);
1053 movi(rn(t2), (jit_word_t)pop_tab);
1054 ldxr_uc(r0, rn(t2), rn(t1));
1058 rshr(rn(t1), r1_reg, rn(t3));
1059 extr_uc(rn(t1), rn(t1));
1060 ldxr_uc(rn(t1), rn(t2), rn(t1));
1061 addr(r0, r0, rn(t1));
1062 addi(rn(t3), rn(t3), 8);
1063 blti(loop, rn(t3), __WORDSIZE);
1067 if (t0 != JIT_NOREG)
1072 _fallback_lrotr(jit_state_t *_jit,
1073 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1075 /* r0 = (r1 << r2) | (r1 >> (__WORDSIZE - r2)) */
1077 t0 = fallback_jit_get_reg(jit_class_gpr);
1078 if (r0 == r1 || r0 == r2) {
1079 t1 = fallback_jit_get_reg(jit_class_gpr);
1080 lshr(rn(t0), r1, r2);
1081 rsbi(rn(t1), r2, __WORDSIZE);
1082 rshr_u(rn(t1), r1, rn(t1));
1083 orr(r0, rn(t0), rn(t1));
1088 rsbi(rn(t0), r2, __WORDSIZE);
1089 rshr_u(rn(t0), r1, rn(t0));
1090 orr(r0, r0, rn(t0));
1096 _fallback_lroti(jit_state_t *_jit,
1097 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1100 t0 = fallback_jit_get_reg(jit_class_gpr);
1101 lshi(rn(t0), r1, i0);
1102 rshi_u(r0, r1, __WORDSIZE - i0);
1103 orr(r0, r0, rn(t0));
1108 _fallback_rrotr(jit_state_t *_jit,
1109 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
1111 /* r0 = (r1 >> r2) | (r1 << (__WORDSIZE - r2)) */
1113 t0 = fallback_jit_get_reg(jit_class_gpr);
1114 if (r0 == r1 || r0 == r2) {
1115 t1 = fallback_jit_get_reg(jit_class_gpr);
1116 rshr_u(rn(t0), r1, r2);
1117 rsbi(rn(t1), r2, __WORDSIZE);
1118 lshr(rn(t1), r1, rn(t1));
1119 orr(r0, rn(t0), rn(t1));
1124 rsbi(rn(t0), r2, __WORDSIZE);
1125 lshr(rn(t0), r1, rn(t0));
1126 orr(r0, r0, rn(t0));
1132 _fallback_rroti(jit_state_t *_jit,
1133 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
1136 t0 = fallback_jit_get_reg(jit_class_gpr);
1137 rshi_u(rn(t0), r1, i0);
1138 lshi(r0, r1, __WORDSIZE - i0);
1139 orr(r0, r0, rn(t0));
1144 _fallback_ext(jit_state_t *_jit,
1145 jit_int32_t r0, jit_int32_t r1, jit_word_t i0, jit_word_t i1)
1147 assert(i0 >= 0 && i1 >= 1 && i0 + i1 <= __WORDSIZE);
1148 if (i1 == __WORDSIZE)
1151 # if __BYTE_ORDER == __BIG_ENDIAN
1152 i0 = __WORDSIZE - (i0 + i1);
1154 if (__WORDSIZE - (i0 + i1)) {
1155 lshi(r0, r1, __WORDSIZE - (i0 + i1));
1156 rshi(r0, r0, __WORDSIZE - i1);
1159 rshi(r0, r1, __WORDSIZE - i1);
1164 _fallback_ext_u(jit_state_t *_jit,
1165 jit_int32_t r0, jit_int32_t r1, jit_word_t i0, jit_word_t i1)
1167 assert(i0 >= 0 && i1 >= 1 && i0 + i1 <= __WORDSIZE);
1168 if (i1 == __WORDSIZE)
1171 # if __BYTE_ORDER == __BIG_ENDIAN
1172 i0 = __WORDSIZE - (i0 + i1);
1176 andi(r0, r0, (1L << i1) - 1);
1181 _fallback_dep(jit_state_t *_jit,
1182 jit_int32_t r0, jit_int32_t r1, jit_word_t i0, jit_word_t i1)
1186 assert(i0 >= 0 && i1 >= 1 && i0 + i1 <= __WORDSIZE);
1187 if (i1 == __WORDSIZE)
1190 # if __BYTE_ORDER == __BIG_ENDIAN
1191 i0 = __WORDSIZE - (i0 + i1);
1193 mask = (1L << i1) - 1;
1194 t0 = fallback_jit_get_reg(jit_class_gpr);
1195 andi(rn(t0), r1, mask);
1197 lshi(rn(t0), rn(t0), i0);
1200 andi(r0, r0, ~mask);
1201 orr(r0, r0, rn(t0));
1207 _fallback_qlshr(jit_state_t *_jit,
1208 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1210 /* r1 = __WORDSIZE - r3;
1211 * if (r1 != __WORDSIZE) {
1223 jit_int32_t t0, s0, t2, s2, t3, s3;
1224 jit_word_t over, zero, done, done_over;
1225 s0 = fallback_jit_get_reg(jit_class_gpr);
1227 if (r0 == r2 || r1 == r2) {
1228 s2 = fallback_jit_get_reg(jit_class_gpr);
1234 if (r0 == r3 || r1 == r3) {
1235 s3 = fallback_jit_get_reg(jit_class_gpr);
1241 rsbi(t0, t3, __WORDSIZE);
1244 zero = fallback_beqi(_jit->pc.w, t3, 0);
1245 over = fallback_beqi(_jit->pc.w, t3, __WORDSIZE);
1246 done = fallback_jmpi(_jit->pc.w);
1248 fallback_patch_jmpi(over, _jit->pc.w);
1251 done_over = fallback_jmpi(_jit->pc.w);
1254 fallback_patch_beqi(zero, _jit->pc.w);
1255 rshi(r1, t2, __WORDSIZE - 1);
1257 fallback_patch_jmpi(done, _jit->pc.w);
1258 fallback_patch_jmpi(done_over, _jit->pc.w);
1267 _fallback_qlshi(jit_state_t *_jit,
1268 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1270 assert((jit_uword_t)i0 <= __WORDSIZE);
1274 rshi(r1, r2, __WORDSIZE - 1);
1277 rshi(r1, r2, __WORDSIZE - 1);
1279 else if (i0 != __WORDSIZE) {
1280 rshi(r1, r2, __WORDSIZE - i0);
1290 _fallback_qlshr_u(jit_state_t *_jit, jit_int32_t r0,
1291 jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1293 /* r1 = __WORDSIZE - r3;
1294 * if (r1 != __WORDSIZE) {
1297 * r1 = (unsigned)r2 >> r1;
1306 jit_int32_t t0, s0, t2, s2, t3, s3;
1307 jit_word_t over, zero, done, done_over;
1308 s0 = fallback_jit_get_reg(jit_class_gpr);
1310 if (r0 == r2 || r1 == r2) {
1311 s2 = fallback_jit_get_reg(jit_class_gpr);
1317 if (r0 == r3 || r1 == r3) {
1318 s3 = fallback_jit_get_reg(jit_class_gpr);
1324 rsbi(t0, t3, __WORDSIZE);
1327 zero = fallback_beqi(_jit->pc.w, t3, 0);
1328 over = fallback_beqi(_jit->pc.w, t3, __WORDSIZE);
1329 done = fallback_jmpi(_jit->pc.w);
1331 fallback_patch_jmpi(over, _jit->pc.w);
1334 done_over = fallback_jmpi(_jit->pc.w);
1337 fallback_patch_beqi(zero, _jit->pc.w);
1340 fallback_patch_jmpi(done, _jit->pc.w);
1341 fallback_patch_jmpi(done_over, _jit->pc.w);
1350 _fallback_qlshi_u(jit_state_t *_jit, jit_int32_t r0,
1351 jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1353 assert(i0 <= __WORDSIZE);
1358 else if (i0 != __WORDSIZE) {
1359 rshi_u(r1, r2, __WORDSIZE - i0);
1369 _fallback_qrshr(jit_state_t *_jit, jit_int32_t r0,
1370 jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1372 /* r1 = __WORDSIZE - r3;
1373 * if (r1 != __WORDSIZE) {
1378 * r1 = r2 >> (__WORDSIZE - 1);
1382 * r0 = r2 >> (__WORDSIZE - 1);
1385 jit_int32_t t0, s0, t2, s2, t3, s3;
1386 jit_word_t over, zero, done, done_over;
1387 s0 = fallback_jit_get_reg(jit_class_gpr);
1389 if (r0 == r2 || r1 == r2) {
1390 s2 = fallback_jit_get_reg(jit_class_gpr);
1396 if (r0 == r3 || r1 == r3) {
1397 s3 = fallback_jit_get_reg(jit_class_gpr);
1403 rsbi(t0, t3, __WORDSIZE);
1406 zero = fallback_beqi(_jit->pc.w, t3, 0);
1407 over = fallback_beqi(_jit->pc.w, t3, __WORDSIZE);
1408 done = fallback_jmpi(_jit->pc.w);
1410 fallback_patch_jmpi(over, _jit->pc.w);
1412 rshi(r0, t2, __WORDSIZE - 1);
1413 done_over = fallback_jmpi(_jit->pc.w);
1416 fallback_patch_beqi(zero, _jit->pc.w);
1419 fallback_patch_jmpi(done, _jit->pc.w);
1420 fallback_patch_jmpi(done_over, _jit->pc.w);
1429 _fallback_qrshi(jit_state_t *_jit, jit_int32_t r0,
1430 jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1432 assert((jit_uword_t)i0 <= __WORDSIZE);
1437 else if (i0 != __WORDSIZE) {
1438 lshi(r1, r2, __WORDSIZE - i0);
1443 rshi(r0, r2, __WORDSIZE - 1);
1448 _fallback_qrshr_u(jit_state_t *_jit, jit_int32_t r0,
1449 jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1451 /* r1 = __WORDSIZE - r3;
1452 * if (r1 != __WORDSIZE) {
1453 * r0 = (unsigned)r2 >> r3;
1464 jit_int32_t t0, s0, t2, s2, t3, s3;
1465 jit_word_t over, zero, done, done_over;
1466 s0 = fallback_jit_get_reg(jit_class_gpr);
1468 if (r0 == r2 || r1 == r2) {
1469 s2 = fallback_jit_get_reg(jit_class_gpr);
1475 if (r0 == r3 || r1 == r3) {
1476 s3 = fallback_jit_get_reg(jit_class_gpr);
1482 rsbi(t0, t3, __WORDSIZE);
1485 zero = fallback_beqi(_jit->pc.w, t3, 0);
1486 over = fallback_beqi(_jit->pc.w, t3, __WORDSIZE);
1487 done = fallback_jmpi(_jit->pc.w);
1489 fallback_patch_jmpi(over, _jit->pc.w);
1492 done_over = fallback_jmpi(_jit->pc.w);
1495 fallback_patch_beqi(zero, _jit->pc.w);
1498 fallback_patch_jmpi(done, _jit->pc.w);
1499 fallback_patch_jmpi(done_over, _jit->pc.w);
1508 _fallback_qrshi_u(jit_state_t *_jit, jit_int32_t r0,
1509 jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1511 assert((jit_uword_t)i0 <= __WORDSIZE);
1516 else if (i0 != __WORDSIZE) {
1517 lshi(r1, r2, __WORDSIZE - i0);
1527 _unldr2(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
1531 t0 = fallback_jit_get_reg(jit_class_gpr);
1534 un2 = fallback_bner(_jit->pc.w, r1, r2);
1539 al = fallback_jmpi(_jit->pc.w);
1541 fallback_patch_bner(un2, _jit->pc.w);
1542 # if __BYTE_ORDER == __LITTLE_ENDIAN
1559 fallback_patch_jmpi(al, _jit->pc.w);
1564 _unldi2(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
1567 if ((i1 & -2) == i1) {
1574 t0 = fallback_jit_get_reg(jit_class_gpr);
1576 # if __BYTE_ORDER == __LITTLE_ENDIAN
1597 _unldr3(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
1601 t0 = fallback_jit_get_reg(jit_class_gpr);
1604 un2 = fallback_bner(_jit->pc.w, r1, r2);
1605 # if __BYTE_ORDER == __LITTLE_ENDIAN
1620 or = fallback_jmpi(_jit->pc.w);
1622 fallback_patch_bner(un2, _jit->pc.w);
1623 # if __BYTE_ORDER == __LITTLE_ENDIAN
1639 fallback_patch_jmpi(or, _jit->pc.w);
1645 _unldi3(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
1648 t0 = fallback_jit_get_reg(jit_class_gpr);
1650 if ((i1 & -2) == i1) {
1651 # if __BYTE_ORDER == __LITTLE_ENDIAN
1668 # if __BYTE_ORDER == __LITTLE_ENDIAN
1689 _unldr4(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1
1690 # if __WORDSIZE == 64
1696 jit_word_t un4, un2, un3, al, or, or3;
1697 t0 = fallback_jit_get_reg(jit_class_gpr);
1700 un4 = fallback_bner(_jit->pc.w, r1, r2);
1701 # if __WORDSIZE == 64
1705 # if __WORDSIZE == 64
1709 al = fallback_jmpi(_jit->pc.w);
1711 fallback_patch_bner(un4, _jit->pc.w);
1713 un2 = fallback_bner(_jit->pc.w, r1, r2);
1714 # if __BYTE_ORDER == __LITTLE_ENDIAN
1716 # if __WORDSIZE == 64
1724 # if __WORDSIZE == 64
1733 or = fallback_jmpi(_jit->pc.w);
1735 fallback_patch_bner(un2, _jit->pc.w);
1737 un3 = fallback_bnei(_jit->pc.w, r2, 3);
1738 # if __BYTE_ORDER == __LITTLE_ENDIAN
1742 # if __WORDSIZE == 64
1749 # if __WORDSIZE == 64
1756 # if __WORDSIZE == 32
1763 or3 = fallback_jmpi(_jit->pc.w);
1765 fallback_patch_bnei(un3, _jit->pc.w);
1766 # if __BYTE_ORDER == __LITTLE_ENDIAN
1767 # if __WORDSIZE == 32
1770 ldxi_ui(r0, r1, -1);
1773 # if __WORDSIZE == 64
1783 # if __WORDSIZE == 64
1792 fallback_patch_jmpi(or, _jit->pc.w);
1793 fallback_patch_jmpi(or3, _jit->pc.w);
1796 fallback_patch_jmpi(al, _jit->pc.w);
1801 _unldi4(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1
1802 # if __WORDSIZE == 64
1808 if ((i1 & -4) == i1) {
1809 # if __WORDSIZE == 64
1813 # if __WORDSIZE == 64
1819 t0 = fallback_jit_get_reg(jit_class_gpr);
1821 if ((i1 & -2) == i1) {
1822 # if __BYTE_ORDER == __LITTLE_ENDIAN
1824 # if __WORDSIZE == 64
1832 # if __WORDSIZE == 64
1842 else if ((i1 & 3) == 3) {
1843 # if __BYTE_ORDER == __LITTLE_ENDIAN
1847 # if __WORDSIZE == 64
1854 # if __WORDSIZE == 64
1861 # if __WORDSIZE == 32
1870 # if __BYTE_ORDER == __LITTLE_ENDIAN
1871 # if __WORDSIZE == 32
1877 # if __WORDSIZE == 64
1887 # if __WORDSIZE == 64
1901 # if __WORDSIZE == 64
1903 _unldr5(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
1906 jit_word_t un4, un2, un3, or, or4, or3;
1907 t0 = fallback_jit_get_reg(jit_class_gpr);
1910 un4 = fallback_bner(_jit->pc.w, r1, r2);
1911 # if __BYTE_ORDER == __LITTLE_ENDIAN
1926 or = fallback_jmpi(_jit->pc.w);
1928 fallback_patch_bner(un4, _jit->pc.w);
1930 un2 = fallback_bner(_jit->pc.w, r1, r2);
1931 # if __BYTE_ORDER == __LITTLE_ENDIAN
1952 or4 = fallback_jmpi(_jit->pc.w);
1954 fallback_patch_bner(un2, _jit->pc.w);
1956 un3 = fallback_bnei(_jit->pc.w, r2, 3);
1957 # if __BYTE_ORDER == __LITTLE_ENDIAN
1972 or3 = fallback_jmpi(_jit->pc.w);
1974 fallback_patch_bnei(un3, _jit->pc.w);
1975 # if __BYTE_ORDER == __LITTLE_ENDIAN
1997 fallback_patch_jmpi(or, _jit->pc.w);
1998 fallback_patch_jmpi(or4, _jit->pc.w);
1999 fallback_patch_jmpi(or3, _jit->pc.w);
2005 _unldi5(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
2008 t0 = fallback_jit_get_reg(jit_class_gpr);
2010 if ((i1 & -4) == i1) {
2011 # if __BYTE_ORDER == __LITTLE_ENDIAN
2027 else if ((i1 & -2) == i1) {
2028 # if __BYTE_ORDER == __LITTLE_ENDIAN
2050 else if ((i1 & 3) == 3) {
2051 # if __BYTE_ORDER == __LITTLE_ENDIAN
2068 # if __BYTE_ORDER == __LITTLE_ENDIAN
2095 _unldr6(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
2098 jit_word_t un4, un2, un3, or, or2, or3;
2099 t0 = fallback_jit_get_reg(jit_class_gpr);
2102 un4 = fallback_bner(_jit->pc.w, r1, r2);
2103 # if __BYTE_ORDER == __LITTLE_ENDIAN
2118 or = fallback_jmpi(_jit->pc.w);
2120 fallback_patch_bner(un4, _jit->pc.w);
2122 un2 = fallback_bner(_jit->pc.w, r1, r2);
2123 # if __BYTE_ORDER == __LITTLE_ENDIAN
2138 or2 = fallback_jmpi(_jit->pc.w);
2140 fallback_patch_bner(un2, _jit->pc.w);
2142 un3 = fallback_bnei(_jit->pc.w, r2, 3);
2143 # if __BYTE_ORDER == __LITTLE_ENDIAN
2164 or3 = fallback_jmpi(_jit->pc.w);
2166 fallback_patch_bner(un3, _jit->pc.w);
2167 # if __BYTE_ORDER == __LITTLE_ENDIAN
2195 fallback_patch_jmpi(or, _jit->pc.w);
2196 fallback_patch_jmpi(or2, _jit->pc.w);
2197 fallback_patch_jmpi(or3, _jit->pc.w);
2203 _unldi6(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
2206 t0 = fallback_jit_get_reg(jit_class_gpr);
2208 if ((i1 & -4) == i1) {
2209 # if __BYTE_ORDER == __LITTLE_ENDIAN
2225 else if ((i1 & -2) == i1) {
2226 # if __BYTE_ORDER == __LITTLE_ENDIAN
2242 else if ((i1 & 3) == 3) {
2243 # if __BYTE_ORDER == __LITTLE_ENDIAN
2266 # if __BYTE_ORDER == __LITTLE_ENDIAN
2299 _unldr7(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
2302 jit_word_t un4, un2, un3, or, or2, or3;
2303 t0 = fallback_jit_get_reg(jit_class_gpr);
2306 un4 = fallback_bner(_jit->pc.w, r1, r2);
2307 # if __BYTE_ORDER == __LITTLE_ENDIAN
2328 or = fallback_jmpi(_jit->pc.w);
2330 fallback_patch_bner(un4, _jit->pc.w);
2332 un2 = fallback_bner(_jit->pc.w, r1, r2);
2333 # if __BYTE_ORDER == __LITTLE_ENDIAN
2354 or2 = fallback_jmpi(_jit->pc.w);
2356 fallback_patch_bner(un2, _jit->pc.w);
2358 un3 = fallback_bnei(_jit->pc.w, r2, 3);
2359 # if __BYTE_ORDER == __LITTLE_ENDIAN
2380 or3 = fallback_jmpi(_jit->pc.w);
2382 fallback_patch_bnei(un3, _jit->pc.w);
2383 # if __BYTE_ORDER == __LITTLE_ENDIAN
2405 fallback_patch_jmpi(or, _jit->pc.w);
2406 fallback_patch_jmpi(or2, _jit->pc.w);
2407 fallback_patch_jmpi(or3, _jit->pc.w);
2413 _unldi7(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
2416 t0 = fallback_jit_get_reg(jit_class_gpr);
2418 if ((i1 & -4) == i1) {
2419 # if __BYTE_ORDER == __LITTLE_ENDIAN
2441 else if ((i1 & -2) == i1) {
2442 # if __BYTE_ORDER == __LITTLE_ENDIAN
2464 else if ((i1 & 3) == 3) {
2465 # if __BYTE_ORDER == __LITTLE_ENDIAN
2488 # if __BYTE_ORDER == __LITTLE_ENDIAN
2515 _unldr8(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2518 jit_word_t un8, un4, un2, un7, un6, un5, un3, al,
2519 or, or2, or7, or6, or5, or3;
2520 t0 = fallback_jit_get_reg(jit_class_gpr);
2523 un8 = fallback_bner(_jit->pc.w, r1, r2);
2525 al = fallback_jmpi(_jit->pc.w);
2527 fallback_patch_bner(un8, _jit->pc.w);
2529 un4 = fallback_bner(_jit->pc.w, r1, r2);
2530 # if __BYTE_ORDER == __LITTLE_ENDIAN
2539 or = fallback_jmpi(_jit->pc.w);
2541 fallback_patch_bner(un4, _jit->pc.w);
2543 un2 = fallback_bner(_jit->pc.w, r1, r2);
2544 # if __BYTE_ORDER == __LITTLE_ENDIAN
2559 or2 = fallback_jmpi(_jit->pc.w);
2561 fallback_patch_bner(un2, _jit->pc.w);
2563 un7 = fallback_bnei(_jit->pc.w, r2, 7);
2564 # if __BYTE_ORDER == __LITTLE_ENDIAN
2574 or7 = fallback_jmpi(_jit->pc.w);
2576 fallback_patch_bnei(un7, _jit->pc.w);
2577 un6 = fallback_bnei(_jit->pc.w, r2, 6);
2578 # if __BYTE_ORDER == __LITTLE_ENDIAN
2588 or6 = fallback_jmpi(_jit->pc.w);
2590 fallback_patch_bnei(un6, _jit->pc.w);
2591 un5 = fallback_bnei(_jit->pc.w, r2, 5);
2592 # if __BYTE_ORDER == __LITTLE_ENDIAN
2593 ldxi_ui(r0, r1, -1);
2608 or5 = fallback_jmpi(_jit->pc.w);
2610 fallback_patch_bnei(un5, _jit->pc.w);
2611 un3 = fallback_bnei(_jit->pc.w, r2, 3);
2612 # if __BYTE_ORDER == __LITTLE_ENDIAN
2628 or3 = fallback_jmpi(_jit->pc.w);
2630 fallback_patch_bnei(un3, _jit->pc.w);
2631 # if __BYTE_ORDER == __LITTLE_ENDIAN
2653 fallback_patch_jmpi(or, _jit->pc.w);
2654 fallback_patch_jmpi(or2, _jit->pc.w);
2655 fallback_patch_jmpi(or7, _jit->pc.w);
2656 fallback_patch_jmpi(or6, _jit->pc.w);
2657 fallback_patch_jmpi(or5, _jit->pc.w);
2658 fallback_patch_jmpi(or3, _jit->pc.w);
2661 fallback_patch_jmpi(al, _jit->pc.w);
2666 _unldi8(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2669 if ((i1 & -8) == i1)
2672 t0 = fallback_jit_get_reg(jit_class_gpr);
2674 if ((i1 & -4) == i1) {
2675 # if __BYTE_ORDER == __LITTLE_ENDIAN
2685 else if ((i1 & -2) == i1) {
2686 # if __BYTE_ORDER == __LITTLE_ENDIAN
2702 else if ((i1 & 7) == 7) {
2703 # if __BYTE_ORDER == __LITTLE_ENDIAN
2714 else if ((i1 & 7) == 6) {
2715 # if __BYTE_ORDER == __LITTLE_ENDIAN
2726 else if ((i1 & 7) == 5) {
2727 # if __BYTE_ORDER == __LITTLE_ENDIAN
2744 else if ((i1 & 7) == 3) {
2745 # if __BYTE_ORDER == __LITTLE_ENDIAN
2763 # if __BYTE_ORDER == __LITTLE_ENDIAN
2792 _unstr2(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2796 t0 = fallback_jit_get_reg(jit_class_gpr);
2799 un2 = fallback_bner(_jit->pc.w, r2, r1);
2801 al = fallback_jmpi(_jit->pc.w);
2803 fallback_patch_bner(un2, _jit->pc.w);
2804 #if __BYTE_ORDER == __LITTLE_ENDIAN
2814 fallback_patch_jmpi(al, _jit->pc.w);
2819 _unsti2(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2822 if ((i1 & -2) == i1)
2825 t0 = fallback_jit_get_reg(jit_class_gpr);
2827 #if __BYTE_ORDER == __LITTLE_ENDIAN
2841 _unstr3(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2845 t0 = fallback_jit_get_reg(jit_class_gpr);
2848 un2 = fallback_bner(_jit->pc.w, r2, r1);
2849 # if __BYTE_ORDER == __LITTLE_ENDIAN
2858 al = fallback_jmpi(_jit->pc.w);
2860 fallback_patch_bner(un2, _jit->pc.w);
2861 # if __BYTE_ORDER == __LITTLE_ENDIAN
2871 fallback_patch_jmpi(al, _jit->pc.w);
2876 _unsti3(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2879 t0 = fallback_jit_get_reg(jit_class_gpr);
2881 if ((i1 & -2) == i1) {
2882 # if __BYTE_ORDER == __LITTLE_ENDIAN
2893 # if __BYTE_ORDER == __LITTLE_ENDIAN
2907 _unstr4(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2910 jit_word_t un4, un2, al, al2;
2911 t0 = fallback_jit_get_reg(jit_class_gpr);
2914 un4 = fallback_bner(_jit->pc.w, r2, r1);
2916 al = fallback_jmpi(_jit->pc.w);
2918 fallback_patch_bner(un4, _jit->pc.w);
2920 un2 = fallback_bner(_jit->pc.w, r2, r1);
2921 # if __BYTE_ORDER == __LITTLE_ENDIAN
2930 al2 = fallback_jmpi(_jit->pc.w);
2932 fallback_patch_bner(un2, _jit->pc.w);
2933 # if __BYTE_ORDER == __LITTLE_ENDIAN
2947 fallback_patch_jmpi(al, _jit->pc.w);
2948 fallback_patch_jmpi(al2, _jit->pc.w);
2953 _unsti4(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2956 if ((i1 & -4) == i1)
2959 t0 = fallback_jit_get_reg(jit_class_gpr);
2961 if ((i1 & -2) == i1) {
2962 # if __BYTE_ORDER == __LITTLE_ENDIAN
2973 # if __BYTE_ORDER == __LITTLE_ENDIAN
2991 # if __WORDSIZE == 64
2993 _unstr5(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2996 jit_word_t un3, un2, un1, al, al2, al1;
2997 t0 = fallback_jit_get_reg(jit_class_gpr);
3000 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3001 # if __BYTE_ORDER == __LITTLE_ENDIAN
3010 al = fallback_jmpi(_jit->pc.w);
3012 fallback_patch_bnei(un3, _jit->pc.w);
3013 un2 = fallback_bnei(_jit->pc.w, r2, 2);
3014 # if __BYTE_ORDER == __LITTLE_ENDIAN
3027 al2 = fallback_jmpi(_jit->pc.w);
3029 fallback_patch_bnei(un2, _jit->pc.w);
3030 un1 = fallback_bnei(_jit->pc.w, r2, 1);
3031 # if __BYTE_ORDER == __LITTLE_ENDIAN
3044 al1 = fallback_jmpi(_jit->pc.w);
3046 fallback_patch_bnei(un1, _jit->pc.w);
3047 # if __BYTE_ORDER == __LITTLE_ENDIAN
3057 fallback_patch_jmpi(al, _jit->pc.w);
3058 fallback_patch_jmpi(al2, _jit->pc.w);
3059 fallback_patch_jmpi(al1, _jit->pc.w);
3064 _unsti5(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3067 t0 = fallback_jit_get_reg(jit_class_gpr);
3069 if ((i1 & 3) == 3) {
3070 # if __BYTE_ORDER == __LITTLE_ENDIAN
3080 else if ((i1 & 3) == 2) {
3081 # if __BYTE_ORDER == __LITTLE_ENDIAN
3095 else if ((i1 & 3) == 1) {
3096 # if __BYTE_ORDER == __LITTLE_ENDIAN
3111 # if __BYTE_ORDER == __LITTLE_ENDIAN
3125 _unstr6(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3128 jit_word_t un3, un2, un1, al, al2, al1;
3129 t0 = fallback_jit_get_reg(jit_class_gpr);
3132 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3133 # if __BYTE_ORDER == __LITTLE_ENDIAN
3146 al = fallback_jmpi(_jit->pc.w);
3148 fallback_patch_bnei(un3, _jit->pc.w);
3149 un2 = fallback_bnei(_jit->pc.w, r2, 2);
3150 # if __BYTE_ORDER == __LITTLE_ENDIAN
3163 al2 = fallback_jmpi(_jit->pc.w);
3165 fallback_patch_bnei(un2, _jit->pc.w);
3166 un1 = fallback_bnei(_jit->pc.w, r2, 1);
3167 # if __BYTE_ORDER == __LITTLE_ENDIAN
3184 al1 = fallback_jmpi(_jit->pc.w);
3186 fallback_patch_bnei(un1, _jit->pc.w);
3187 # if __BYTE_ORDER == __LITTLE_ENDIAN
3197 fallback_patch_jmpi(al, _jit->pc.w);
3198 fallback_patch_jmpi(al2, _jit->pc.w);
3199 fallback_patch_jmpi(al1, _jit->pc.w);
3204 _unsti6(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3207 t0 = fallback_jit_get_reg(jit_class_gpr);
3209 if ((i1 & 3) == 3) {
3210 # if __BYTE_ORDER == __LITTLE_ENDIAN
3224 else if ((i1 & 3) == 2) {
3225 # if __BYTE_ORDER == __LITTLE_ENDIAN
3239 else if ((i1 & 3) == 1) {
3240 # if __BYTE_ORDER == __LITTLE_ENDIAN
3259 # if __BYTE_ORDER == __LITTLE_ENDIAN
3273 _unstr7(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3276 jit_word_t un3, un2, un1, al, al2, al1;
3277 t0 = fallback_jit_get_reg(jit_class_gpr);
3280 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3281 # if __BYTE_ORDER == __LITTLE_ENDIAN
3294 al = fallback_jmpi(_jit->pc.w);
3296 fallback_patch_bnei(un3, _jit->pc.w);
3297 un2 = fallback_bnei(_jit->pc.w, r2, 2);
3298 # if __BYTE_ORDER == __LITTLE_ENDIAN
3311 al2 = fallback_jmpi(_jit->pc.w);
3313 fallback_patch_bnei(un2, _jit->pc.w);
3314 un1 = fallback_bnei(_jit->pc.w, r2, 1);
3315 # if __BYTE_ORDER == __LITTLE_ENDIAN
3328 al1 = fallback_jmpi(_jit->pc.w);
3330 fallback_patch_bnei(un1, _jit->pc.w);
3331 # if __BYTE_ORDER == __LITTLE_ENDIAN
3345 fallback_patch_jmpi(al, _jit->pc.w);
3346 fallback_patch_jmpi(al2, _jit->pc.w);
3347 fallback_patch_jmpi(al1, _jit->pc.w);
3352 _unsti7(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3355 t0 = fallback_jit_get_reg(jit_class_gpr);
3357 if ((i1 & 3) == 3) {
3358 # if __BYTE_ORDER == __LITTLE_ENDIAN
3372 else if ((i1 & 3) == 2) {
3373 # if __BYTE_ORDER == __LITTLE_ENDIAN
3387 else if ((i1 & 3) == 1) {
3388 # if __BYTE_ORDER == __LITTLE_ENDIAN
3403 # if __BYTE_ORDER == __LITTLE_ENDIAN
3421 _unstr8(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3424 jit_word_t un8, un4, un2, un3, al, al4, al2, al3;
3425 t0 = fallback_jit_get_reg(jit_class_gpr);
3428 un8 = fallback_bner(_jit->pc.w, r2, r1);
3430 al = fallback_jmpi(_jit->pc.w);
3432 fallback_patch_bner(un8, _jit->pc.w);
3434 un4 = fallback_bner(_jit->pc.w, r2, r1);
3435 # if __BYTE_ORDER == __LITTLE_ENDIAN
3444 al4 = fallback_jmpi(_jit->pc.w);
3446 fallback_patch_bner(un4, _jit->pc.w);
3448 un2 = fallback_bner(_jit->pc.w, r2, r1);
3449 # if __BYTE_ORDER == __LITTLE_ENDIAN
3462 al2 = fallback_jmpi(_jit->pc.w);
3464 fallback_patch_bner(un2, _jit->pc.w);
3466 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3467 # if __BYTE_ORDER == __LITTLE_ENDIAN
3484 al3 = fallback_jmpi(_jit->pc.w);
3486 fallback_patch_bnei(un3, _jit->pc.w);
3487 # if __BYTE_ORDER == __LITTLE_ENDIAN
3505 fallback_patch_jmpi(al, _jit->pc.w);
3506 fallback_patch_jmpi(al4, _jit->pc.w);
3507 fallback_patch_jmpi(al2, _jit->pc.w);
3508 fallback_patch_jmpi(al3, _jit->pc.w);
3513 _unsti8(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3516 if ((i1 & -8) == i1)
3519 t0 = fallback_jit_get_reg(jit_class_gpr);
3521 if ((i1 & -4) == i1) {
3522 # if __BYTE_ORDER == __LITTLE_ENDIAN
3532 else if ((i1 & -2) == i1) {
3533 # if __BYTE_ORDER == __LITTLE_ENDIAN
3547 else if ((i1 & 3) == 3) {
3548 # if __BYTE_ORDER == __LITTLE_ENDIAN
3567 # if __BYTE_ORDER == __LITTLE_ENDIAN
3592 _unldrw(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3594 jit_word_t cross, done;
3595 jit_int32_t t0, t1, t2, t3;
3596 t0 = fallback_jit_get_reg(jit_class_gpr);
3598 t1 = fallback_jit_get_reg(jit_class_gpr);
3604 andi(rn(t0), r1, -(jit_word_t)sizeof(jit_word_t));
3606 done = fallback_beqr(_jit->pc.w, rn(t0), r1);
3607 t2 = fallback_jit_get_reg(jit_class_gpr);
3608 andi(rn(t2), r1, sizeof(jit_word_t) - 1);
3609 t3 = fallback_jit_get_reg(jit_class_gpr);
3610 addi(rn(t3), rn(t2), i0);
3611 cross = fallback_blei(_jit->pc.w, rn(t3), sizeof(jit_word_t));
3612 ldxi(rn(t0), rn(t0), sizeof(jit_word_t));
3614 fallback_patch_blei(cross, _jit->pc.w);
3616 lshi(rn(t2), rn(t2), 3);
3617 #if __BYTE_ORDER == __LITTLE_ENDIAN
3618 rshr_u(r0, r0, rn(t2));
3619 rsbi(rn(t2), rn(t2), __WORDSIZE);
3620 lshr(rn(t0), rn(t0), rn(t2));
3622 lshr(r0, r0, rn(t2));
3623 rsbi(rn(t2), rn(t2), __WORDSIZE);
3624 rshr_u(rn(t0), rn(t0), rn(t2));
3627 orr(r0, r0, rn(t0));
3629 fallback_patch_beqr(done, _jit->pc.w);
3631 if (t1 != JIT_NOREG)
3636 _unldiw(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0, jit_word_t i1)
3640 addr = i0 & -(jit_word_t)sizeof(jit_word_t);
3643 sh = (i0 & (sizeof(jit_word_t) - 1)) << 3;
3644 if (sh + i1 > sizeof(jit_word_t)) {
3645 t0 = fallback_jit_get_reg(jit_class_gpr);
3646 ldi(rn(t0), addr + sizeof(jit_word_t));
3647 #if __BYTE_ORDER == __LITTLE_ENDIAN
3649 lshi(rn(t0), rn(t0), __WORDSIZE - sh);
3652 rshi_u(rn(t0), rn(t0), __WORDSIZE - sh);
3654 orr(r0, r0, rn(t0));
3661 _unldx(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
3665 #if __BYTE_ORDER == __LITTLE_ENDIAN
3668 rshi(r0, r0, __WORDSIZE - 16);
3672 #if __BYTE_ORDER == __LITTLE_ENDIAN
3673 lshi(r0, r0, __WORDSIZE - 24);
3675 rshi(r0, r0, __WORDSIZE - 24);
3677 #if __WORDSIZE == 32
3681 # if __BYTE_ORDER == __LITTLE_ENDIAN
3684 rshi(r0, r0, __WORDSIZE - 32);
3688 #if __WORDSIZE == 64
3690 # if __BYTE_ORDER == __LITTLE_ENDIAN
3691 lshi(r0, r0, __WORDSIZE - 40);
3693 rshi(r0, r0, __WORDSIZE - 40);
3696 # if __BYTE_ORDER == __LITTLE_ENDIAN
3697 lshi(r0, r0, __WORDSIZE - 48);
3699 rshi(r0, r0, __WORDSIZE - 48);
3702 # if __BYTE_ORDER == __LITTLE_ENDIAN
3703 lshi(r0, r0, __WORDSIZE - 56);
3705 rshi(r0, r0, __WORDSIZE - 56);
3714 _unldx_u(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
3718 #if __BYTE_ORDER == __LITTLE_ENDIAN
3721 rshi_u(r0, r0, __WORDSIZE - 16);
3725 #if __BYTE_ORDER == __LITTLE_ENDIAN
3726 lshi(r0, r0, __WORDSIZE - 24);
3728 rshi_u(r0, r0, __WORDSIZE - 24);
3730 #if __WORDSIZE == 32
3734 # if __BYTE_ORDER == __LITTLE_ENDIAN
3737 rshi_u(r0, r0, __WORDSIZE - 32);
3741 #if __WORDSIZE == 64
3743 # if __BYTE_ORDER == __LITTLE_ENDIAN
3744 lshi(r0, r0, __WORDSIZE - 40);
3746 rshi_u(r0, r0, __WORDSIZE - 40);
3749 # if __BYTE_ORDER == __LITTLE_ENDIAN
3750 lshi(r0, r0, __WORDSIZE - 48);
3752 rshi_u(r0, r0, __WORDSIZE - 48);
3755 # if __BYTE_ORDER == __LITTLE_ENDIAN
3756 lshi(r0, r0, __WORDSIZE - 56);
3758 rshi_u(r0, r0, __WORDSIZE - 56);
3767 _fallback_unldr(jit_state_t *_jit,
3768 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3771 assert(i0 >= 1 && i0 <= (__WORDSIZE >> 3));
3774 else if (_jitc->unld_algorithm != 0) {
3776 t0 = fallback_jit_get_reg(jit_class_gpr);
3783 case 2: unldr2(r0, r2, 1); break;
3784 case 3: unldr3(r0, r2, 1); break;
3785 # if __WORDSIZE == 32
3786 default: unldr4(r0, r2); break;
3788 case 4: unldr4(r0, r2, 1); break;
3789 case 5: unldr5(r0, r2, 1); break;
3790 case 6: unldr6(r0, r2, 1); break;
3791 case 7: unldr7(r0, r2, 1); break;
3792 default: unldr8(r0, r2); break;
3795 if (i0 > 1 && r0 == r1)
3805 _fallback_unldi(jit_state_t *_jit,
3806 jit_int32_t r0, jit_word_t i0, jit_word_t i1)
3808 assert(i1 >= 1 && i1 <= (__WORDSIZE >> 3));
3811 else if (_jitc->unld_algorithm != 0) {
3813 case 2: unldi2(r0, i0, 1); break;
3814 case 3: unldi3(r0, i0, 1); break;
3815 # if __WORDSIZE == 32
3816 default: unldi4(r0, i0); break;
3818 case 4: unldi4(r0, i0, 1); break;
3819 case 5: unldi5(r0, i0, 1); break;
3820 case 6: unldi6(r0, i0, 1); break;
3821 case 7: unldi7(r0, i0, 1); break;
3822 default: unldi8(r0, i0); break;
3833 _fallback_unldr_u(jit_state_t *_jit,
3834 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3837 assert(i0 >= 1 && i0 <= (__WORDSIZE >> 3));
3840 else if (_jitc->unld_algorithm != 0) {
3842 t0 = fallback_jit_get_reg(jit_class_gpr);
3849 case 2: unldr2(r0, r2, 0); break;
3850 case 3: unldr3(r0, r2, 0); break;
3851 # if __WORDSIZE == 32
3852 default: unldr4(r0, r2); break;
3854 case 4: unldr4(r0, r2, 0); break;
3855 case 5: unldr5(r0, r2, 0); break;
3856 case 6: unldr6(r0, r2, 0); break;
3857 case 7: unldr7(r0, r2, 0); break;
3858 default: unldr8(r0, r2); break;
3861 if (i0 > 1 && r0 == r1)
3871 _fallback_unldi_u(jit_state_t *_jit,
3872 jit_int32_t r0, jit_word_t i0, jit_word_t i1)
3874 assert(i1 >= 1 && i1 <= (__WORDSIZE >> 3));
3877 else if (_jitc->unld_algorithm != 0) {
3879 case 2: unldi2(r0, i0, 0); break;
3880 case 3: unldi3(r0, i0, 0); break;
3881 # if __WORDSIZE == 32
3882 default: unldi4(r0, i0); break;
3884 case 4: unldi4(r0, i0, 0); break;
3885 case 5: unldi5(r0, i0, 0); break;
3886 case 6: unldi6(r0, i0, 0); break;
3887 case 7: unldi7(r0, i0, 0); break;
3888 default: unldi8(r0, i0); break;
3900 _fallback_unstr(jit_state_t *_jit,
3901 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3904 jit_int32_t t0, t1, t2, t3, t4, t5;
3905 assert(i0 > 0 && i0 <= (__WORDSIZE >> 3));
3908 else if (_jitc->unst_algorithm == 0) {
3910 case 2: unstr2(r1, r0); break;
3911 case 3: unstr3(r1, r0); break;
3912 # if __WORDSIZE == 32
3913 default: unstr4(r1, r0); break;
3915 case 4: unstr4(r1, r0); break;
3916 case 5: unstr5(r1, r0); break;
3917 case 6: unstr6(r1, r0); break;
3918 case 7: unstr7(r1, r0); break;
3919 default: unstr8(r1, r0); break;
3924 t0 = fallback_jit_get_reg(jit_class_gpr);
3925 t1 = fallback_jit_get_reg(jit_class_gpr);
3926 t2 = fallback_jit_get_reg(jit_class_gpr);
3927 t3 = fallback_jit_get_reg(jit_class_gpr);
3928 /* Zero out top bits and keep value to store in t0 */
3929 if (i0 != sizeof(jit_word_t)) {
3930 lshi(rn(t3), r1, (sizeof(jit_word_t) - i0) << 3);
3931 #if __BYTE_ORDER == __LITTLE_ENDIAN
3932 rshi_u(rn(t3), rn(t3), (sizeof(jit_word_t) - i0) << 3);
3937 /* Check alignment */
3938 andi(rn(t2), r0, sizeof(jit_word_t) - 1);
3940 lshi(rn(t2), rn(t2), 3);
3941 /* Split values to store (assume will need two stores) */
3942 #if __BYTE_ORDER == __LITTLE_ENDIAN
3943 qlshr_u(rn(t0), rn(t1), rn(t3), rn(t2));
3945 qrshr_u(rn(t0), rn(t1), rn(t3), rn(t2));
3947 /* Generate masks for values in memory */
3948 if (i0 == sizeof(jit_word_t))
3951 #if __BYTE_ORDER == __BIG_ENDIAN
3952 movi(rn(t3), ((1L << (i0 << 3)) - 1) <<
3953 ((sizeof(jit_word_t) - i0) << 3));
3955 movi(rn(t3), (1L << (i0 << 3)) - 1);
3958 #if __BYTE_ORDER == __LITTLE_ENDIAN
3959 qlshr_u(rn(t2), rn(t3), rn(t3), rn(t2));
3961 qrshr_u(rn(t2), rn(t3), rn(t3), rn(t2));
3963 comr(rn(t2), rn(t2));
3964 comr(rn(t3), rn(t3));
3965 /* Allocate two extra registers later in case need temps for *q?shr_u */
3966 t4 = fallback_jit_get_reg(jit_class_gpr);
3967 t5 = fallback_jit_get_reg(jit_class_gpr);
3969 andi(rn(t4), r0, -(jit_word_t)sizeof(jit_word_t));
3970 ldr(rn(t5), rn(t4));
3971 andr(rn(t5), rn(t5), rn(t2));
3972 orr(rn(t0), rn(t0), rn(t5));
3973 str(rn(t4), rn(t0));
3974 /* Make sure to not read/write on possibly unmaped memory */
3975 addi(rn(t5), rn(t4), i0);
3976 done = fallback_blei(_jit->pc.w, rn(t5), sizeof(jit_word_t));
3977 /* Store second word if vlaue crosses a word boundary */
3978 ldxi(rn(t5), rn(t4), sizeof(jit_word_t));
3979 andr(rn(t5), rn(t5), rn(t3));
3980 orr(rn(t1), rn(t1), rn(t5));
3981 stxi(sizeof(jit_word_t), rn(t4), rn(t1));
3984 fallback_patch_blei(done, _jit->pc.w);
3985 /* Generic/simple algorithm needs 6 temporaries, as it cannot
3986 * change any of the argument registers, might need to truncate
3987 * the value to store, and need a pair for values to store and
3988 * another for the masks. */
3999 _fallback_unsti(jit_state_t *_jit,
4000 jit_word_t i0, jit_int32_t r0, jit_word_t i1)
4002 jit_word_t done, address;
4003 jit_int32_t t0, t1, t2, t3, t4;
4004 assert(i1 > 0 && i1 <= (__WORDSIZE >> 3));
4007 else if (_jitc->unst_algorithm == 0) {
4009 case 1: sti_c(i0, r0); break;
4010 case 2: unsti2(r0, i0); break;
4011 case 3: unsti3(r0, i0); break;
4012 # if __WORDSIZE == 32
4013 default: unsti4(r0, i0); break;
4015 case 4: unsti4(r0, i0); break;
4016 case 5: unsti5(r0, i0); break;
4017 case 6: unsti6(r0, i0); break;
4018 case 7: unsti7(r0, i0); break;
4019 default: unsti8(r0, i0); break;
4024 t0 = fallback_jit_get_reg(jit_class_gpr);
4025 t1 = fallback_jit_get_reg(jit_class_gpr);
4026 t2 = fallback_jit_get_reg(jit_class_gpr);
4027 t3 = fallback_jit_get_reg(jit_class_gpr);
4028 t4 = fallback_jit_get_reg(jit_class_gpr);
4029 /* Zero out top bits and keep value to store in t0 */
4030 if (i1 != sizeof(jit_word_t)) {
4031 lshi(rn(t2), r0, (sizeof(jit_word_t) - i1) << 3);
4032 #if __BYTE_ORDER == __LITTLE_ENDIAN
4033 rshi_u(rn(t2), rn(t2), (sizeof(jit_word_t) - i1) << 3);
4034 qlshi_u(rn(t0), rn(t1), rn(t2),
4035 (i0 & (sizeof(jit_word_t) - 1)) << 3);
4037 qrshi_u(rn(t0), rn(t1), rn(t2),
4038 (i0 & (sizeof(jit_word_t)) - 1) << 3);
4042 #if __BYTE_ORDER == __LITTLE_ENDIAN
4043 qlshi_u(rn(t0), rn(t1), r0,
4044 (i0 & (sizeof(jit_word_t)) - 1) << 3);
4046 qrshi_u(rn(t0), rn(t1), r0,
4047 (i0 & (sizeof(jit_word_t)) - 1) << 3);
4050 /* Generate masks for values in memory */
4051 if (i1 == sizeof(jit_word_t))
4054 #if __BYTE_ORDER == __BIG_ENDIAN
4055 movi(rn(t2), ((1L << (i1 << 3)) - 1) <<
4056 ((sizeof(jit_word_t) - i1) << 3));
4058 movi(rn(t2), (1L << (i1 << 3)) - 1);
4061 #if __BYTE_ORDER == __LITTLE_ENDIAN
4062 qlshi_u(rn(t2), rn(t3), rn(t2), (i0 & (sizeof(jit_word_t)) - 1) << 3);
4064 qrshi_u(rn(t2), rn(t3), rn(t2), (i0 & (sizeof(jit_word_t)) - 1) << 3);
4066 comr(rn(t2), rn(t2));
4067 comr(rn(t3), rn(t3));
4069 address = i0 & -(jit_word_t)sizeof(jit_word_t);
4070 ldi(rn(t4), address);
4071 andr(rn(t4), rn(t4), rn(t2));
4072 orr(rn(t0), rn(t0), rn(t4));
4073 sti(address, rn(t0));
4074 if (address + i1 > sizeof(jit_word_t)) {
4075 address += sizeof(jit_word_t);
4076 ldi(rn(t4), address);
4077 andr(rn(t4), rn(t4), rn(t3));
4078 orr(rn(t1), rn(t1), rn(t4));
4079 sti(address, rn(t1));
4089 # ifdef fallback_unldr_x
4091 _fallback_unldr_x(jit_state_t *_jit,
4092 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
4095 # if __WORDSIZE == 32
4098 assert(i0 == 4 || i0 == 8);
4099 t0 = fallback_jit_get_reg(jit_class_gpr);
4106 # if __WORDSIZE == 32
4107 t1 = fallback_jit_get_reg(jit_class_gpr);
4109 # if __BYTE_ORDER == __LITTLE_ENDIAN
4118 movr_ww_d(r0, r2, r3);
4129 # ifdef fallback_unldi_x
4131 _fallback_unldi_x(jit_state_t *_jit,
4132 jit_int32_t r0, jit_word_t i0, jit_word_t i1)
4135 # if __WORDSIZE == 32
4138 assert(i1 == 4 || i1 == 8);
4139 t0 = fallback_jit_get_reg(jit_class_gpr);
4146 # if __WORDSIZE == 32
4147 t1 = fallback_jit_get_reg(jit_class_gpr);
4149 # if __BYTE_ORDER == __LITTLE_ENDIAN
4151 unldi(r3, i0 + 4, 4);
4154 unldi(r2, i0 + 4, 4);
4156 movr_ww_d(r0, r3, r2);
4167 # ifdef fallback_unstr_x
4169 _fallback_unstr_x(jit_state_t *_jit,
4170 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
4173 # if __WORDSIZE == 32
4176 assert(i0 == 4 || i0 == 8);
4177 t0 = fallback_jit_get_reg(jit_class_gpr);
4184 # if __WORDSIZE == 32
4185 t1 = fallback_jit_get_reg(jit_class_gpr);
4187 movr_d_ww(r2, r3, r1);
4188 # if __BYTE_ORDER == __LITTLE_ENDIAN
4207 # ifdef fallback_unsti_x
4209 _fallback_unsti_x(jit_state_t *_jit,
4210 jit_word_t i0, jit_int32_t r0, jit_word_t i1)
4213 # if __WORDSIZE == 32
4216 assert(i1 == 4 || i1 == 8);
4217 t0 = fallback_jit_get_reg(jit_class_gpr);
4224 # if __WORDSIZE == 32
4225 t1 = fallback_jit_get_reg(jit_class_gpr);
4227 movr_d_ww(r2, r3, r0);
4228 # if __BYTE_ORDER == __LITTLE_ENDIAN
4230 unsti(i0 + 4, r2, 4);
4233 unsti(i0 + 4, r3, 4);