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);
1417 rshi(r1, t2, __WORDSIZE - 1);
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);
1436 rshi(r1, r2, __WORDSIZE - 1);
1439 rshi(r1, r2, __WORDSIZE - 1);
1441 else if (i0 != __WORDSIZE) {
1442 lshi(r1, r2, __WORDSIZE - i0);
1447 rshi(r0, r2, __WORDSIZE - 1);
1452 _fallback_qrshr_u(jit_state_t *_jit, jit_int32_t r0,
1453 jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
1455 /* r1 = __WORDSIZE - r3;
1456 * if (r1 != __WORDSIZE) {
1457 * r0 = (unsigned)r2 >> r3;
1468 jit_int32_t t0, s0, t2, s2, t3, s3;
1469 jit_word_t over, zero, done, done_over;
1470 s0 = fallback_jit_get_reg(jit_class_gpr);
1472 if (r0 == r2 || r1 == r2) {
1473 s2 = fallback_jit_get_reg(jit_class_gpr);
1479 if (r0 == r3 || r1 == r3) {
1480 s3 = fallback_jit_get_reg(jit_class_gpr);
1486 rsbi(t0, t3, __WORDSIZE);
1489 zero = fallback_beqi(_jit->pc.w, t3, 0);
1490 over = fallback_beqi(_jit->pc.w, t3, __WORDSIZE);
1491 done = fallback_jmpi(_jit->pc.w);
1493 fallback_patch_jmpi(over, _jit->pc.w);
1496 done_over = fallback_jmpi(_jit->pc.w);
1499 fallback_patch_beqi(zero, _jit->pc.w);
1502 fallback_patch_jmpi(done, _jit->pc.w);
1503 fallback_patch_jmpi(done_over, _jit->pc.w);
1512 _fallback_qrshi_u(jit_state_t *_jit, jit_int32_t r0,
1513 jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
1515 assert((jit_uword_t)i0 <= __WORDSIZE);
1520 else if (i0 != __WORDSIZE) {
1521 lshi(r1, r2, __WORDSIZE - i0);
1531 _unldr2(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
1535 t0 = fallback_jit_get_reg(jit_class_gpr);
1538 un2 = fallback_bner(_jit->pc.w, r1, r2);
1543 al = fallback_jmpi(_jit->pc.w);
1545 fallback_patch_bner(un2, _jit->pc.w);
1546 # if __BYTE_ORDER == __LITTLE_ENDIAN
1563 fallback_patch_jmpi(al, _jit->pc.w);
1568 _unldi2(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
1571 if ((i1 & -2) == i1) {
1578 t0 = fallback_jit_get_reg(jit_class_gpr);
1580 # if __BYTE_ORDER == __LITTLE_ENDIAN
1601 _unldr3(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
1605 t0 = fallback_jit_get_reg(jit_class_gpr);
1608 un2 = fallback_bner(_jit->pc.w, r1, r2);
1609 # if __BYTE_ORDER == __LITTLE_ENDIAN
1624 or = fallback_jmpi(_jit->pc.w);
1626 fallback_patch_bner(un2, _jit->pc.w);
1627 # if __BYTE_ORDER == __LITTLE_ENDIAN
1643 fallback_patch_jmpi(or, _jit->pc.w);
1649 _unldi3(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
1652 t0 = fallback_jit_get_reg(jit_class_gpr);
1654 if ((i1 & -2) == i1) {
1655 # if __BYTE_ORDER == __LITTLE_ENDIAN
1672 # if __BYTE_ORDER == __LITTLE_ENDIAN
1693 _unldr4(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1
1694 # if __WORDSIZE == 64
1700 jit_word_t un4, un2, un3, al, or, or3;
1701 t0 = fallback_jit_get_reg(jit_class_gpr);
1704 un4 = fallback_bner(_jit->pc.w, r1, r2);
1705 # if __WORDSIZE == 64
1709 # if __WORDSIZE == 64
1713 al = fallback_jmpi(_jit->pc.w);
1715 fallback_patch_bner(un4, _jit->pc.w);
1717 un2 = fallback_bner(_jit->pc.w, r1, r2);
1718 # if __BYTE_ORDER == __LITTLE_ENDIAN
1720 # if __WORDSIZE == 64
1728 # if __WORDSIZE == 64
1737 or = fallback_jmpi(_jit->pc.w);
1739 fallback_patch_bner(un2, _jit->pc.w);
1741 un3 = fallback_bnei(_jit->pc.w, r2, 3);
1742 # if __BYTE_ORDER == __LITTLE_ENDIAN
1746 # if __WORDSIZE == 64
1753 # if __WORDSIZE == 64
1760 # if __WORDSIZE == 32
1767 or3 = fallback_jmpi(_jit->pc.w);
1769 fallback_patch_bnei(un3, _jit->pc.w);
1770 # if __BYTE_ORDER == __LITTLE_ENDIAN
1771 # if __WORDSIZE == 32
1774 ldxi_ui(r0, r1, -1);
1777 # if __WORDSIZE == 64
1787 # if __WORDSIZE == 64
1796 fallback_patch_jmpi(or, _jit->pc.w);
1797 fallback_patch_jmpi(or3, _jit->pc.w);
1800 fallback_patch_jmpi(al, _jit->pc.w);
1805 _unldi4(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1
1806 # if __WORDSIZE == 64
1812 if ((i1 & -4) == i1) {
1813 # if __WORDSIZE == 64
1817 # if __WORDSIZE == 64
1823 t0 = fallback_jit_get_reg(jit_class_gpr);
1825 if ((i1 & -2) == i1) {
1826 # if __BYTE_ORDER == __LITTLE_ENDIAN
1828 # if __WORDSIZE == 64
1836 # if __WORDSIZE == 64
1846 else if ((i1 & 3) == 3) {
1847 # if __BYTE_ORDER == __LITTLE_ENDIAN
1851 # if __WORDSIZE == 64
1858 # if __WORDSIZE == 64
1865 # if __WORDSIZE == 32
1874 # if __BYTE_ORDER == __LITTLE_ENDIAN
1875 # if __WORDSIZE == 32
1881 # if __WORDSIZE == 64
1891 # if __WORDSIZE == 64
1905 # if __WORDSIZE == 64
1907 _unldr5(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
1910 jit_word_t un4, un2, un3, or, or4, or3;
1911 t0 = fallback_jit_get_reg(jit_class_gpr);
1914 un4 = fallback_bner(_jit->pc.w, r1, r2);
1915 # if __BYTE_ORDER == __LITTLE_ENDIAN
1930 or = fallback_jmpi(_jit->pc.w);
1932 fallback_patch_bner(un4, _jit->pc.w);
1934 un2 = fallback_bner(_jit->pc.w, r1, r2);
1935 # if __BYTE_ORDER == __LITTLE_ENDIAN
1956 or4 = fallback_jmpi(_jit->pc.w);
1958 fallback_patch_bner(un2, _jit->pc.w);
1960 un3 = fallback_bnei(_jit->pc.w, r2, 3);
1961 # if __BYTE_ORDER == __LITTLE_ENDIAN
1976 or3 = fallback_jmpi(_jit->pc.w);
1978 fallback_patch_bnei(un3, _jit->pc.w);
1979 # if __BYTE_ORDER == __LITTLE_ENDIAN
2001 fallback_patch_jmpi(or, _jit->pc.w);
2002 fallback_patch_jmpi(or4, _jit->pc.w);
2003 fallback_patch_jmpi(or3, _jit->pc.w);
2009 _unldi5(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
2012 t0 = fallback_jit_get_reg(jit_class_gpr);
2014 if ((i1 & -4) == i1) {
2015 # if __BYTE_ORDER == __LITTLE_ENDIAN
2031 else if ((i1 & -2) == i1) {
2032 # if __BYTE_ORDER == __LITTLE_ENDIAN
2054 else if ((i1 & 3) == 3) {
2055 # if __BYTE_ORDER == __LITTLE_ENDIAN
2072 # if __BYTE_ORDER == __LITTLE_ENDIAN
2099 _unldr6(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
2102 jit_word_t un4, un2, un3, or, or2, or3;
2103 t0 = fallback_jit_get_reg(jit_class_gpr);
2106 un4 = fallback_bner(_jit->pc.w, r1, r2);
2107 # if __BYTE_ORDER == __LITTLE_ENDIAN
2122 or = fallback_jmpi(_jit->pc.w);
2124 fallback_patch_bner(un4, _jit->pc.w);
2126 un2 = fallback_bner(_jit->pc.w, r1, r2);
2127 # if __BYTE_ORDER == __LITTLE_ENDIAN
2142 or2 = fallback_jmpi(_jit->pc.w);
2144 fallback_patch_bner(un2, _jit->pc.w);
2146 un3 = fallback_bnei(_jit->pc.w, r2, 3);
2147 # if __BYTE_ORDER == __LITTLE_ENDIAN
2168 or3 = fallback_jmpi(_jit->pc.w);
2170 fallback_patch_bner(un3, _jit->pc.w);
2171 # if __BYTE_ORDER == __LITTLE_ENDIAN
2199 fallback_patch_jmpi(or, _jit->pc.w);
2200 fallback_patch_jmpi(or2, _jit->pc.w);
2201 fallback_patch_jmpi(or3, _jit->pc.w);
2207 _unldi6(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
2210 t0 = fallback_jit_get_reg(jit_class_gpr);
2212 if ((i1 & -4) == i1) {
2213 # if __BYTE_ORDER == __LITTLE_ENDIAN
2229 else if ((i1 & -2) == i1) {
2230 # if __BYTE_ORDER == __LITTLE_ENDIAN
2246 else if ((i1 & 3) == 3) {
2247 # if __BYTE_ORDER == __LITTLE_ENDIAN
2270 # if __BYTE_ORDER == __LITTLE_ENDIAN
2303 _unldr7(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_bool_t sign)
2306 jit_word_t un4, un2, un3, or, or2, or3;
2307 t0 = fallback_jit_get_reg(jit_class_gpr);
2310 un4 = fallback_bner(_jit->pc.w, r1, r2);
2311 # if __BYTE_ORDER == __LITTLE_ENDIAN
2332 or = fallback_jmpi(_jit->pc.w);
2334 fallback_patch_bner(un4, _jit->pc.w);
2336 un2 = fallback_bner(_jit->pc.w, r1, r2);
2337 # if __BYTE_ORDER == __LITTLE_ENDIAN
2358 or2 = fallback_jmpi(_jit->pc.w);
2360 fallback_patch_bner(un2, _jit->pc.w);
2362 un3 = fallback_bnei(_jit->pc.w, r2, 3);
2363 # if __BYTE_ORDER == __LITTLE_ENDIAN
2384 or3 = fallback_jmpi(_jit->pc.w);
2386 fallback_patch_bnei(un3, _jit->pc.w);
2387 # if __BYTE_ORDER == __LITTLE_ENDIAN
2409 fallback_patch_jmpi(or, _jit->pc.w);
2410 fallback_patch_jmpi(or2, _jit->pc.w);
2411 fallback_patch_jmpi(or3, _jit->pc.w);
2417 _unldi7(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1, jit_bool_t sign)
2420 t0 = fallback_jit_get_reg(jit_class_gpr);
2422 if ((i1 & -4) == i1) {
2423 # if __BYTE_ORDER == __LITTLE_ENDIAN
2445 else if ((i1 & -2) == i1) {
2446 # if __BYTE_ORDER == __LITTLE_ENDIAN
2468 else if ((i1 & 3) == 3) {
2469 # if __BYTE_ORDER == __LITTLE_ENDIAN
2492 # if __BYTE_ORDER == __LITTLE_ENDIAN
2519 _unldr8(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2522 jit_word_t un8, un4, un2, un7, un6, un5, un3, al,
2523 or, or2, or7, or6, or5, or3;
2524 t0 = fallback_jit_get_reg(jit_class_gpr);
2527 un8 = fallback_bner(_jit->pc.w, r1, r2);
2529 al = fallback_jmpi(_jit->pc.w);
2531 fallback_patch_bner(un8, _jit->pc.w);
2533 un4 = fallback_bner(_jit->pc.w, r1, r2);
2534 # if __BYTE_ORDER == __LITTLE_ENDIAN
2543 or = fallback_jmpi(_jit->pc.w);
2545 fallback_patch_bner(un4, _jit->pc.w);
2547 un2 = fallback_bner(_jit->pc.w, r1, r2);
2548 # if __BYTE_ORDER == __LITTLE_ENDIAN
2563 or2 = fallback_jmpi(_jit->pc.w);
2565 fallback_patch_bner(un2, _jit->pc.w);
2567 un7 = fallback_bnei(_jit->pc.w, r2, 7);
2568 # if __BYTE_ORDER == __LITTLE_ENDIAN
2578 or7 = fallback_jmpi(_jit->pc.w);
2580 fallback_patch_bnei(un7, _jit->pc.w);
2581 un6 = fallback_bnei(_jit->pc.w, r2, 6);
2582 # if __BYTE_ORDER == __LITTLE_ENDIAN
2592 or6 = fallback_jmpi(_jit->pc.w);
2594 fallback_patch_bnei(un6, _jit->pc.w);
2595 un5 = fallback_bnei(_jit->pc.w, r2, 5);
2596 # if __BYTE_ORDER == __LITTLE_ENDIAN
2597 ldxi_ui(r0, r1, -1);
2612 or5 = fallback_jmpi(_jit->pc.w);
2614 fallback_patch_bnei(un5, _jit->pc.w);
2615 un3 = fallback_bnei(_jit->pc.w, r2, 3);
2616 # if __BYTE_ORDER == __LITTLE_ENDIAN
2632 or3 = fallback_jmpi(_jit->pc.w);
2634 fallback_patch_bnei(un3, _jit->pc.w);
2635 # if __BYTE_ORDER == __LITTLE_ENDIAN
2657 fallback_patch_jmpi(or, _jit->pc.w);
2658 fallback_patch_jmpi(or2, _jit->pc.w);
2659 fallback_patch_jmpi(or7, _jit->pc.w);
2660 fallback_patch_jmpi(or6, _jit->pc.w);
2661 fallback_patch_jmpi(or5, _jit->pc.w);
2662 fallback_patch_jmpi(or3, _jit->pc.w);
2665 fallback_patch_jmpi(al, _jit->pc.w);
2670 _unldi8(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2673 if ((i1 & -8) == i1)
2676 t0 = fallback_jit_get_reg(jit_class_gpr);
2678 if ((i1 & -4) == i1) {
2679 # if __BYTE_ORDER == __LITTLE_ENDIAN
2689 else if ((i1 & -2) == i1) {
2690 # if __BYTE_ORDER == __LITTLE_ENDIAN
2706 else if ((i1 & 7) == 7) {
2707 # if __BYTE_ORDER == __LITTLE_ENDIAN
2718 else if ((i1 & 7) == 6) {
2719 # if __BYTE_ORDER == __LITTLE_ENDIAN
2730 else if ((i1 & 7) == 5) {
2731 # if __BYTE_ORDER == __LITTLE_ENDIAN
2748 else if ((i1 & 7) == 3) {
2749 # if __BYTE_ORDER == __LITTLE_ENDIAN
2767 # if __BYTE_ORDER == __LITTLE_ENDIAN
2796 _unstr2(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2800 t0 = fallback_jit_get_reg(jit_class_gpr);
2803 un2 = fallback_bner(_jit->pc.w, r2, r1);
2805 al = fallback_jmpi(_jit->pc.w);
2807 fallback_patch_bner(un2, _jit->pc.w);
2808 #if __BYTE_ORDER == __LITTLE_ENDIAN
2818 fallback_patch_jmpi(al, _jit->pc.w);
2823 _unsti2(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2826 if ((i1 & -2) == i1)
2829 t0 = fallback_jit_get_reg(jit_class_gpr);
2831 #if __BYTE_ORDER == __LITTLE_ENDIAN
2845 _unstr3(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2849 t0 = fallback_jit_get_reg(jit_class_gpr);
2852 un2 = fallback_bner(_jit->pc.w, r2, r1);
2853 # if __BYTE_ORDER == __LITTLE_ENDIAN
2862 al = fallback_jmpi(_jit->pc.w);
2864 fallback_patch_bner(un2, _jit->pc.w);
2865 # if __BYTE_ORDER == __LITTLE_ENDIAN
2875 fallback_patch_jmpi(al, _jit->pc.w);
2880 _unsti3(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2883 t0 = fallback_jit_get_reg(jit_class_gpr);
2885 if ((i1 & -2) == i1) {
2886 # if __BYTE_ORDER == __LITTLE_ENDIAN
2897 # if __BYTE_ORDER == __LITTLE_ENDIAN
2911 _unstr4(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
2914 jit_word_t un4, un2, al, al2;
2915 t0 = fallback_jit_get_reg(jit_class_gpr);
2918 un4 = fallback_bner(_jit->pc.w, r2, r1);
2920 al = fallback_jmpi(_jit->pc.w);
2922 fallback_patch_bner(un4, _jit->pc.w);
2924 un2 = fallback_bner(_jit->pc.w, r2, r1);
2925 # if __BYTE_ORDER == __LITTLE_ENDIAN
2934 al2 = fallback_jmpi(_jit->pc.w);
2936 fallback_patch_bner(un2, _jit->pc.w);
2937 # if __BYTE_ORDER == __LITTLE_ENDIAN
2951 fallback_patch_jmpi(al, _jit->pc.w);
2952 fallback_patch_jmpi(al2, _jit->pc.w);
2957 _unsti4(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
2960 if ((i1 & -4) == i1)
2963 t0 = fallback_jit_get_reg(jit_class_gpr);
2965 if ((i1 & -2) == i1) {
2966 # if __BYTE_ORDER == __LITTLE_ENDIAN
2977 # if __BYTE_ORDER == __LITTLE_ENDIAN
2995 # if __WORDSIZE == 64
2997 _unstr5(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3000 jit_word_t un3, un2, un1, al, al2, al1;
3001 t0 = fallback_jit_get_reg(jit_class_gpr);
3004 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3005 # if __BYTE_ORDER == __LITTLE_ENDIAN
3014 al = fallback_jmpi(_jit->pc.w);
3016 fallback_patch_bnei(un3, _jit->pc.w);
3017 un2 = fallback_bnei(_jit->pc.w, r2, 2);
3018 # if __BYTE_ORDER == __LITTLE_ENDIAN
3031 al2 = fallback_jmpi(_jit->pc.w);
3033 fallback_patch_bnei(un2, _jit->pc.w);
3034 un1 = fallback_bnei(_jit->pc.w, r2, 1);
3035 # if __BYTE_ORDER == __LITTLE_ENDIAN
3048 al1 = fallback_jmpi(_jit->pc.w);
3050 fallback_patch_bnei(un1, _jit->pc.w);
3051 # if __BYTE_ORDER == __LITTLE_ENDIAN
3061 fallback_patch_jmpi(al, _jit->pc.w);
3062 fallback_patch_jmpi(al2, _jit->pc.w);
3063 fallback_patch_jmpi(al1, _jit->pc.w);
3068 _unsti5(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3071 t0 = fallback_jit_get_reg(jit_class_gpr);
3073 if ((i1 & 3) == 3) {
3074 # if __BYTE_ORDER == __LITTLE_ENDIAN
3084 else if ((i1 & 3) == 2) {
3085 # if __BYTE_ORDER == __LITTLE_ENDIAN
3099 else if ((i1 & 3) == 1) {
3100 # if __BYTE_ORDER == __LITTLE_ENDIAN
3115 # if __BYTE_ORDER == __LITTLE_ENDIAN
3129 _unstr6(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3132 jit_word_t un3, un2, un1, al, al2, al1;
3133 t0 = fallback_jit_get_reg(jit_class_gpr);
3136 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3137 # if __BYTE_ORDER == __LITTLE_ENDIAN
3150 al = fallback_jmpi(_jit->pc.w);
3152 fallback_patch_bnei(un3, _jit->pc.w);
3153 un2 = fallback_bnei(_jit->pc.w, r2, 2);
3154 # if __BYTE_ORDER == __LITTLE_ENDIAN
3167 al2 = fallback_jmpi(_jit->pc.w);
3169 fallback_patch_bnei(un2, _jit->pc.w);
3170 un1 = fallback_bnei(_jit->pc.w, r2, 1);
3171 # if __BYTE_ORDER == __LITTLE_ENDIAN
3188 al1 = fallback_jmpi(_jit->pc.w);
3190 fallback_patch_bnei(un1, _jit->pc.w);
3191 # if __BYTE_ORDER == __LITTLE_ENDIAN
3201 fallback_patch_jmpi(al, _jit->pc.w);
3202 fallback_patch_jmpi(al2, _jit->pc.w);
3203 fallback_patch_jmpi(al1, _jit->pc.w);
3208 _unsti6(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3211 t0 = fallback_jit_get_reg(jit_class_gpr);
3213 if ((i1 & 3) == 3) {
3214 # if __BYTE_ORDER == __LITTLE_ENDIAN
3228 else if ((i1 & 3) == 2) {
3229 # if __BYTE_ORDER == __LITTLE_ENDIAN
3243 else if ((i1 & 3) == 1) {
3244 # if __BYTE_ORDER == __LITTLE_ENDIAN
3263 # if __BYTE_ORDER == __LITTLE_ENDIAN
3277 _unstr7(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3280 jit_word_t un3, un2, un1, al, al2, al1;
3281 t0 = fallback_jit_get_reg(jit_class_gpr);
3284 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3285 # if __BYTE_ORDER == __LITTLE_ENDIAN
3298 al = fallback_jmpi(_jit->pc.w);
3300 fallback_patch_bnei(un3, _jit->pc.w);
3301 un2 = fallback_bnei(_jit->pc.w, r2, 2);
3302 # if __BYTE_ORDER == __LITTLE_ENDIAN
3315 al2 = fallback_jmpi(_jit->pc.w);
3317 fallback_patch_bnei(un2, _jit->pc.w);
3318 un1 = fallback_bnei(_jit->pc.w, r2, 1);
3319 # if __BYTE_ORDER == __LITTLE_ENDIAN
3332 al1 = fallback_jmpi(_jit->pc.w);
3334 fallback_patch_bnei(un1, _jit->pc.w);
3335 # if __BYTE_ORDER == __LITTLE_ENDIAN
3349 fallback_patch_jmpi(al, _jit->pc.w);
3350 fallback_patch_jmpi(al2, _jit->pc.w);
3351 fallback_patch_jmpi(al1, _jit->pc.w);
3356 _unsti7(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3359 t0 = fallback_jit_get_reg(jit_class_gpr);
3361 if ((i1 & 3) == 3) {
3362 # if __BYTE_ORDER == __LITTLE_ENDIAN
3376 else if ((i1 & 3) == 2) {
3377 # if __BYTE_ORDER == __LITTLE_ENDIAN
3391 else if ((i1 & 3) == 1) {
3392 # if __BYTE_ORDER == __LITTLE_ENDIAN
3407 # if __BYTE_ORDER == __LITTLE_ENDIAN
3425 _unstr8(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
3428 jit_word_t un8, un4, un2, un3, al, al4, al2, al3;
3429 t0 = fallback_jit_get_reg(jit_class_gpr);
3432 un8 = fallback_bner(_jit->pc.w, r2, r1);
3434 al = fallback_jmpi(_jit->pc.w);
3436 fallback_patch_bner(un8, _jit->pc.w);
3438 un4 = fallback_bner(_jit->pc.w, r2, r1);
3439 # if __BYTE_ORDER == __LITTLE_ENDIAN
3448 al4 = fallback_jmpi(_jit->pc.w);
3450 fallback_patch_bner(un4, _jit->pc.w);
3452 un2 = fallback_bner(_jit->pc.w, r2, r1);
3453 # if __BYTE_ORDER == __LITTLE_ENDIAN
3466 al2 = fallback_jmpi(_jit->pc.w);
3468 fallback_patch_bner(un2, _jit->pc.w);
3470 un3 = fallback_bnei(_jit->pc.w, r2, 3);
3471 # if __BYTE_ORDER == __LITTLE_ENDIAN
3488 al3 = fallback_jmpi(_jit->pc.w);
3490 fallback_patch_bnei(un3, _jit->pc.w);
3491 # if __BYTE_ORDER == __LITTLE_ENDIAN
3509 fallback_patch_jmpi(al, _jit->pc.w);
3510 fallback_patch_jmpi(al4, _jit->pc.w);
3511 fallback_patch_jmpi(al2, _jit->pc.w);
3512 fallback_patch_jmpi(al3, _jit->pc.w);
3517 _unsti8(jit_state_t *_jit, jit_int32_t r0, jit_word_t i1)
3520 if ((i1 & -8) == i1)
3523 t0 = fallback_jit_get_reg(jit_class_gpr);
3525 if ((i1 & -4) == i1) {
3526 # if __BYTE_ORDER == __LITTLE_ENDIAN
3536 else if ((i1 & -2) == i1) {
3537 # if __BYTE_ORDER == __LITTLE_ENDIAN
3551 else if ((i1 & 3) == 3) {
3552 # if __BYTE_ORDER == __LITTLE_ENDIAN
3571 # if __BYTE_ORDER == __LITTLE_ENDIAN
3596 _unldrw(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3598 jit_word_t cross, done;
3599 jit_int32_t t0, t1, t2, t3;
3600 t0 = fallback_jit_get_reg(jit_class_gpr);
3602 t1 = fallback_jit_get_reg(jit_class_gpr);
3608 andi(rn(t0), r1, -(jit_word_t)sizeof(jit_word_t));
3610 done = fallback_beqr(_jit->pc.w, rn(t0), r1);
3611 t2 = fallback_jit_get_reg(jit_class_gpr);
3612 andi(rn(t2), r1, sizeof(jit_word_t) - 1);
3613 t3 = fallback_jit_get_reg(jit_class_gpr);
3614 addi(rn(t3), rn(t2), i0);
3615 cross = fallback_blei(_jit->pc.w, rn(t3), sizeof(jit_word_t));
3616 ldxi(rn(t0), rn(t0), sizeof(jit_word_t));
3618 fallback_patch_blei(cross, _jit->pc.w);
3620 lshi(rn(t2), rn(t2), 3);
3621 #if __BYTE_ORDER == __LITTLE_ENDIAN
3622 rshr_u(r0, r0, rn(t2));
3623 rsbi(rn(t2), rn(t2), __WORDSIZE);
3624 lshr(rn(t0), rn(t0), rn(t2));
3626 lshr(r0, r0, rn(t2));
3627 rsbi(rn(t2), rn(t2), __WORDSIZE);
3628 rshr_u(rn(t0), rn(t0), rn(t2));
3631 orr(r0, r0, rn(t0));
3633 fallback_patch_beqr(done, _jit->pc.w);
3635 if (t1 != JIT_NOREG)
3640 _unldiw(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0, jit_word_t i1)
3644 addr = i0 & -(jit_word_t)sizeof(jit_word_t);
3647 sh = (i0 & (sizeof(jit_word_t) - 1)) << 3;
3648 if (sh + i1 > sizeof(jit_word_t)) {
3649 t0 = fallback_jit_get_reg(jit_class_gpr);
3650 ldi(rn(t0), addr + sizeof(jit_word_t));
3651 #if __BYTE_ORDER == __LITTLE_ENDIAN
3653 lshi(rn(t0), rn(t0), __WORDSIZE - sh);
3656 rshi_u(rn(t0), rn(t0), __WORDSIZE - sh);
3658 orr(r0, r0, rn(t0));
3665 _unldx(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
3669 #if __BYTE_ORDER == __LITTLE_ENDIAN
3672 rshi(r0, r0, __WORDSIZE - 16);
3676 #if __BYTE_ORDER == __LITTLE_ENDIAN
3677 lshi(r0, r0, __WORDSIZE - 24);
3679 rshi(r0, r0, __WORDSIZE - 24);
3681 #if __WORDSIZE == 32
3685 # if __BYTE_ORDER == __LITTLE_ENDIAN
3688 rshi(r0, r0, __WORDSIZE - 32);
3692 #if __WORDSIZE == 64
3694 # if __BYTE_ORDER == __LITTLE_ENDIAN
3695 lshi(r0, r0, __WORDSIZE - 40);
3697 rshi(r0, r0, __WORDSIZE - 40);
3700 # if __BYTE_ORDER == __LITTLE_ENDIAN
3701 lshi(r0, r0, __WORDSIZE - 48);
3703 rshi(r0, r0, __WORDSIZE - 48);
3706 # if __BYTE_ORDER == __LITTLE_ENDIAN
3707 lshi(r0, r0, __WORDSIZE - 56);
3709 rshi(r0, r0, __WORDSIZE - 56);
3718 _unldx_u(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
3722 #if __BYTE_ORDER == __LITTLE_ENDIAN
3725 rshi_u(r0, r0, __WORDSIZE - 16);
3729 #if __BYTE_ORDER == __LITTLE_ENDIAN
3730 lshi(r0, r0, __WORDSIZE - 24);
3732 rshi_u(r0, r0, __WORDSIZE - 24);
3734 #if __WORDSIZE == 32
3738 # if __BYTE_ORDER == __LITTLE_ENDIAN
3741 rshi_u(r0, r0, __WORDSIZE - 32);
3745 #if __WORDSIZE == 64
3747 # if __BYTE_ORDER == __LITTLE_ENDIAN
3748 lshi(r0, r0, __WORDSIZE - 40);
3750 rshi_u(r0, r0, __WORDSIZE - 40);
3753 # if __BYTE_ORDER == __LITTLE_ENDIAN
3754 lshi(r0, r0, __WORDSIZE - 48);
3756 rshi_u(r0, r0, __WORDSIZE - 48);
3759 # if __BYTE_ORDER == __LITTLE_ENDIAN
3760 lshi(r0, r0, __WORDSIZE - 56);
3762 rshi_u(r0, r0, __WORDSIZE - 56);
3771 _fallback_unldr(jit_state_t *_jit,
3772 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3775 assert(i0 >= 1 && i0 <= (__WORDSIZE >> 3));
3778 else if (_jitc->unld_algorithm != 0) {
3780 t0 = fallback_jit_get_reg(jit_class_gpr);
3787 case 2: unldr2(r0, r2, 1); break;
3788 case 3: unldr3(r0, r2, 1); break;
3789 # if __WORDSIZE == 32
3790 default: unldr4(r0, r2); break;
3792 case 4: unldr4(r0, r2, 1); break;
3793 case 5: unldr5(r0, r2, 1); break;
3794 case 6: unldr6(r0, r2, 1); break;
3795 case 7: unldr7(r0, r2, 1); break;
3796 default: unldr8(r0, r2); break;
3799 if (i0 > 1 && r0 == r1)
3809 _fallback_unldi(jit_state_t *_jit,
3810 jit_int32_t r0, jit_word_t i0, jit_word_t i1)
3812 assert(i1 >= 1 && i1 <= (__WORDSIZE >> 3));
3815 else if (_jitc->unld_algorithm != 0) {
3817 case 2: unldi2(r0, i0, 1); break;
3818 case 3: unldi3(r0, i0, 1); break;
3819 # if __WORDSIZE == 32
3820 default: unldi4(r0, i0); break;
3822 case 4: unldi4(r0, i0, 1); break;
3823 case 5: unldi5(r0, i0, 1); break;
3824 case 6: unldi6(r0, i0, 1); break;
3825 case 7: unldi7(r0, i0, 1); break;
3826 default: unldi8(r0, i0); break;
3837 _fallback_unldr_u(jit_state_t *_jit,
3838 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3841 assert(i0 >= 1 && i0 <= (__WORDSIZE >> 3));
3844 else if (_jitc->unld_algorithm != 0) {
3846 t0 = fallback_jit_get_reg(jit_class_gpr);
3853 case 2: unldr2(r0, r2, 0); break;
3854 case 3: unldr3(r0, r2, 0); break;
3855 # if __WORDSIZE == 32
3856 default: unldr4(r0, r2); break;
3858 case 4: unldr4(r0, r2, 0); break;
3859 case 5: unldr5(r0, r2, 0); break;
3860 case 6: unldr6(r0, r2, 0); break;
3861 case 7: unldr7(r0, r2, 0); break;
3862 default: unldr8(r0, r2); break;
3865 if (i0 > 1 && r0 == r1)
3875 _fallback_unldi_u(jit_state_t *_jit,
3876 jit_int32_t r0, jit_word_t i0, jit_word_t i1)
3878 assert(i1 >= 1 && i1 <= (__WORDSIZE >> 3));
3881 else if (_jitc->unld_algorithm != 0) {
3883 case 2: unldi2(r0, i0, 0); break;
3884 case 3: unldi3(r0, i0, 0); break;
3885 # if __WORDSIZE == 32
3886 default: unldi4(r0, i0); break;
3888 case 4: unldi4(r0, i0, 0); break;
3889 case 5: unldi5(r0, i0, 0); break;
3890 case 6: unldi6(r0, i0, 0); break;
3891 case 7: unldi7(r0, i0, 0); break;
3892 default: unldi8(r0, i0); break;
3904 _fallback_unstr(jit_state_t *_jit,
3905 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
3908 jit_int32_t t0, t1, t2, t3, t4, t5;
3909 assert(i0 > 0 && i0 <= (__WORDSIZE >> 3));
3912 else if (_jitc->unst_algorithm == 0) {
3914 case 2: unstr2(r1, r0); break;
3915 case 3: unstr3(r1, r0); break;
3916 # if __WORDSIZE == 32
3917 default: unstr4(r1, r0); break;
3919 case 4: unstr4(r1, r0); break;
3920 case 5: unstr5(r1, r0); break;
3921 case 6: unstr6(r1, r0); break;
3922 case 7: unstr7(r1, r0); break;
3923 default: unstr8(r1, r0); break;
3928 t0 = fallback_jit_get_reg(jit_class_gpr);
3929 t1 = fallback_jit_get_reg(jit_class_gpr);
3930 t2 = fallback_jit_get_reg(jit_class_gpr);
3931 t3 = fallback_jit_get_reg(jit_class_gpr);
3932 /* Zero out top bits and keep value to store in t0 */
3933 if (i0 != sizeof(jit_word_t)) {
3934 lshi(rn(t3), r1, (sizeof(jit_word_t) - i0) << 3);
3935 #if __BYTE_ORDER == __LITTLE_ENDIAN
3936 rshi_u(rn(t3), rn(t3), (sizeof(jit_word_t) - i0) << 3);
3941 /* Check alignment */
3942 andi(rn(t2), r0, sizeof(jit_word_t) - 1);
3944 lshi(rn(t2), rn(t2), 3);
3945 /* Split values to store (assume will need two stores) */
3946 #if __BYTE_ORDER == __LITTLE_ENDIAN
3947 qlshr_u(rn(t0), rn(t1), rn(t3), rn(t2));
3949 qrshr_u(rn(t0), rn(t1), rn(t3), rn(t2));
3951 /* Generate masks for values in memory */
3952 if (i0 == sizeof(jit_word_t))
3955 #if __BYTE_ORDER == __BIG_ENDIAN
3956 movi(rn(t3), ((1L << (i0 << 3)) - 1) <<
3957 ((sizeof(jit_word_t) - i0) << 3));
3959 movi(rn(t3), (1L << (i0 << 3)) - 1);
3962 #if __BYTE_ORDER == __LITTLE_ENDIAN
3963 qlshr_u(rn(t2), rn(t3), rn(t3), rn(t2));
3965 qrshr_u(rn(t2), rn(t3), rn(t3), rn(t2));
3967 comr(rn(t2), rn(t2));
3968 comr(rn(t3), rn(t3));
3969 /* Allocate two extra registers later in case need temps for *q?shr_u */
3970 t4 = fallback_jit_get_reg(jit_class_gpr);
3971 t5 = fallback_jit_get_reg(jit_class_gpr);
3973 andi(rn(t4), r0, -(jit_word_t)sizeof(jit_word_t));
3974 ldr(rn(t5), rn(t4));
3975 andr(rn(t5), rn(t5), rn(t2));
3976 orr(rn(t0), rn(t0), rn(t5));
3977 str(rn(t4), rn(t0));
3978 /* Make sure to not read/write on possibly unmaped memory */
3979 addi(rn(t5), rn(t4), i0);
3980 done = fallback_blei(_jit->pc.w, rn(t5), sizeof(jit_word_t));
3981 /* Store second word if vlaue crosses a word boundary */
3982 ldxi(rn(t5), rn(t4), sizeof(jit_word_t));
3983 andr(rn(t5), rn(t5), rn(t3));
3984 orr(rn(t1), rn(t1), rn(t5));
3985 stxi(sizeof(jit_word_t), rn(t4), rn(t1));
3988 fallback_patch_blei(done, _jit->pc.w);
3989 /* Generic/simple algorithm needs 6 temporaries, as it cannot
3990 * change any of the argument registers, might need to truncate
3991 * the value to store, and need a pair for values to store and
3992 * another for the masks. */
4003 _fallback_unsti(jit_state_t *_jit,
4004 jit_word_t i0, jit_int32_t r0, jit_word_t i1)
4006 jit_word_t done, address;
4007 jit_int32_t t0, t1, t2, t3, t4;
4008 assert(i1 > 0 && i1 <= (__WORDSIZE >> 3));
4011 else if (_jitc->unst_algorithm == 0) {
4013 case 1: sti_c(i0, r0); break;
4014 case 2: unsti2(r0, i0); break;
4015 case 3: unsti3(r0, i0); break;
4016 # if __WORDSIZE == 32
4017 default: unsti4(r0, i0); break;
4019 case 4: unsti4(r0, i0); break;
4020 case 5: unsti5(r0, i0); break;
4021 case 6: unsti6(r0, i0); break;
4022 case 7: unsti7(r0, i0); break;
4023 default: unsti8(r0, i0); break;
4028 t0 = fallback_jit_get_reg(jit_class_gpr);
4029 t1 = fallback_jit_get_reg(jit_class_gpr);
4030 t2 = fallback_jit_get_reg(jit_class_gpr);
4031 t3 = fallback_jit_get_reg(jit_class_gpr);
4032 t4 = fallback_jit_get_reg(jit_class_gpr);
4033 /* Zero out top bits and keep value to store in t0 */
4034 if (i1 != sizeof(jit_word_t)) {
4035 lshi(rn(t2), r0, (sizeof(jit_word_t) - i1) << 3);
4036 #if __BYTE_ORDER == __LITTLE_ENDIAN
4037 rshi_u(rn(t2), rn(t2), (sizeof(jit_word_t) - i1) << 3);
4038 qlshi_u(rn(t0), rn(t1), rn(t2),
4039 (i0 & (sizeof(jit_word_t) - 1)) << 3);
4041 qrshi_u(rn(t0), rn(t1), rn(t2),
4042 (i0 & (sizeof(jit_word_t)) - 1) << 3);
4046 #if __BYTE_ORDER == __LITTLE_ENDIAN
4047 qlshi_u(rn(t0), rn(t1), r0,
4048 (i0 & (sizeof(jit_word_t)) - 1) << 3);
4050 qrshi_u(rn(t0), rn(t1), r0,
4051 (i0 & (sizeof(jit_word_t)) - 1) << 3);
4054 /* Generate masks for values in memory */
4055 if (i1 == sizeof(jit_word_t))
4058 #if __BYTE_ORDER == __BIG_ENDIAN
4059 movi(rn(t2), ((1L << (i1 << 3)) - 1) <<
4060 ((sizeof(jit_word_t) - i1) << 3));
4062 movi(rn(t2), (1L << (i1 << 3)) - 1);
4065 #if __BYTE_ORDER == __LITTLE_ENDIAN
4066 qlshi_u(rn(t2), rn(t3), rn(t2), (i0 & (sizeof(jit_word_t)) - 1) << 3);
4068 qrshi_u(rn(t2), rn(t3), rn(t2), (i0 & (sizeof(jit_word_t)) - 1) << 3);
4070 comr(rn(t2), rn(t2));
4071 comr(rn(t3), rn(t3));
4073 address = i0 & -(jit_word_t)sizeof(jit_word_t);
4074 ldi(rn(t4), address);
4075 andr(rn(t4), rn(t4), rn(t2));
4076 orr(rn(t0), rn(t0), rn(t4));
4077 sti(address, rn(t0));
4078 if (address + i1 > sizeof(jit_word_t)) {
4079 address += sizeof(jit_word_t);
4080 ldi(rn(t4), address);
4081 andr(rn(t4), rn(t4), rn(t3));
4082 orr(rn(t1), rn(t1), rn(t4));
4083 sti(address, rn(t1));
4093 # ifdef fallback_unldr_x
4095 _fallback_unldr_x(jit_state_t *_jit,
4096 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
4099 # if __WORDSIZE == 32
4102 assert(i0 == 4 || i0 == 8);
4103 t0 = fallback_jit_get_reg(jit_class_gpr);
4110 # if __WORDSIZE == 32
4111 t1 = fallback_jit_get_reg(jit_class_gpr);
4113 # if __BYTE_ORDER == __LITTLE_ENDIAN
4122 movr_ww_d(r0, r2, r3);
4133 # ifdef fallback_unldi_x
4135 _fallback_unldi_x(jit_state_t *_jit,
4136 jit_int32_t r0, jit_word_t i0, jit_word_t i1)
4139 # if __WORDSIZE == 32
4142 assert(i1 == 4 || i1 == 8);
4143 t0 = fallback_jit_get_reg(jit_class_gpr);
4150 # if __WORDSIZE == 32
4151 t1 = fallback_jit_get_reg(jit_class_gpr);
4153 # if __BYTE_ORDER == __LITTLE_ENDIAN
4155 unldi(r3, i0 + 4, 4);
4158 unldi(r2, i0 + 4, 4);
4160 movr_ww_d(r0, r3, r2);
4171 # ifdef fallback_unstr_x
4173 _fallback_unstr_x(jit_state_t *_jit,
4174 jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
4177 # if __WORDSIZE == 32
4180 assert(i0 == 4 || i0 == 8);
4181 t0 = fallback_jit_get_reg(jit_class_gpr);
4188 # if __WORDSIZE == 32
4189 t1 = fallback_jit_get_reg(jit_class_gpr);
4191 movr_d_ww(r2, r3, r1);
4192 # if __BYTE_ORDER == __LITTLE_ENDIAN
4211 # ifdef fallback_unsti_x
4213 _fallback_unsti_x(jit_state_t *_jit,
4214 jit_word_t i0, jit_int32_t r0, jit_word_t i1)
4217 # if __WORDSIZE == 32
4220 assert(i1 == 4 || i1 == 8);
4221 t0 = fallback_jit_get_reg(jit_class_gpr);
4228 # if __WORDSIZE == 32
4229 t1 = fallback_jit_get_reg(jit_class_gpr);
4231 movr_d_ww(r2, r3, r0);
4232 # if __BYTE_ORDER == __LITTLE_ENDIAN
4234 unsti(i0 + 4, r2, 4);
4237 unsti(i0 + 4, r3, 4);