]>
Commit | Line | Data |
---|---|---|
c896fe29 FB |
1 | /* |
2 | * Tiny Code Generator for QEMU | |
3 | * | |
4 | * Copyright (c) 2008 Fabrice Bellard | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | #include "tcg.h" | |
25 | ||
c896fe29 FB |
26 | int gen_new_label(void); |
27 | ||
a7812ae4 | 28 | static inline void tcg_gen_op1_i32(int opc, TCGv_i32 arg1) |
c896fe29 FB |
29 | { |
30 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
31 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
32 | } | |
33 | ||
34 | static inline void tcg_gen_op1_i64(int opc, TCGv_i64 arg1) | |
35 | { | |
36 | *gen_opc_ptr++ = opc; | |
37 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
c896fe29 FB |
38 | } |
39 | ||
ac56dd48 | 40 | static inline void tcg_gen_op1i(int opc, TCGArg arg1) |
c896fe29 FB |
41 | { |
42 | *gen_opc_ptr++ = opc; | |
43 | *gen_opparam_ptr++ = arg1; | |
c896fe29 FB |
44 | } |
45 | ||
a7812ae4 PB |
46 | static inline void tcg_gen_op2_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2) |
47 | { | |
48 | *gen_opc_ptr++ = opc; | |
49 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
50 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
51 | } | |
52 | ||
53 | static inline void tcg_gen_op2_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2) | |
54 | { | |
55 | *gen_opc_ptr++ = opc; | |
56 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
57 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
58 | } | |
59 | ||
60 | static inline void tcg_gen_op2i_i32(int opc, TCGv_i32 arg1, TCGArg arg2) | |
c896fe29 FB |
61 | { |
62 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
63 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
64 | *gen_opparam_ptr++ = arg2; | |
c896fe29 FB |
65 | } |
66 | ||
a7812ae4 | 67 | static inline void tcg_gen_op2i_i64(int opc, TCGv_i64 arg1, TCGArg arg2) |
c896fe29 FB |
68 | { |
69 | *gen_opc_ptr++ = opc; | |
a7812ae4 | 70 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
c896fe29 | 71 | *gen_opparam_ptr++ = arg2; |
ac56dd48 PB |
72 | } |
73 | ||
bcb0126f PB |
74 | static inline void tcg_gen_op2ii(int opc, TCGArg arg1, TCGArg arg2) |
75 | { | |
76 | *gen_opc_ptr++ = opc; | |
77 | *gen_opparam_ptr++ = arg1; | |
78 | *gen_opparam_ptr++ = arg2; | |
79 | } | |
80 | ||
a7812ae4 PB |
81 | static inline void tcg_gen_op3_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, |
82 | TCGv_i32 arg3) | |
83 | { | |
84 | *gen_opc_ptr++ = opc; | |
85 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
86 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
87 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
88 | } | |
89 | ||
90 | static inline void tcg_gen_op3_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, | |
91 | TCGv_i64 arg3) | |
92 | { | |
93 | *gen_opc_ptr++ = opc; | |
94 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
95 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
96 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
97 | } | |
98 | ||
99 | static inline void tcg_gen_op3i_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, | |
100 | TCGArg arg3) | |
ac56dd48 PB |
101 | { |
102 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
103 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
104 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
105 | *gen_opparam_ptr++ = arg3; | |
ac56dd48 PB |
106 | } |
107 | ||
a7812ae4 PB |
108 | static inline void tcg_gen_op3i_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, |
109 | TCGArg arg3) | |
ac56dd48 PB |
110 | { |
111 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
112 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
113 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
c896fe29 | 114 | *gen_opparam_ptr++ = arg3; |
ac56dd48 PB |
115 | } |
116 | ||
a7812ae4 PB |
117 | static inline void tcg_gen_ldst_op_i32(int opc, TCGv_i32 val, TCGv_ptr base, |
118 | TCGArg offset) | |
119 | { | |
120 | *gen_opc_ptr++ = opc; | |
121 | *gen_opparam_ptr++ = GET_TCGV_I32(val); | |
122 | *gen_opparam_ptr++ = GET_TCGV_PTR(base); | |
123 | *gen_opparam_ptr++ = offset; | |
124 | } | |
125 | ||
126 | static inline void tcg_gen_ldst_op_i64(int opc, TCGv_i64 val, TCGv_ptr base, | |
127 | TCGArg offset) | |
128 | { | |
129 | *gen_opc_ptr++ = opc; | |
a810a2de | 130 | *gen_opparam_ptr++ = GET_TCGV_I64(val); |
a7812ae4 PB |
131 | *gen_opparam_ptr++ = GET_TCGV_PTR(base); |
132 | *gen_opparam_ptr++ = offset; | |
133 | } | |
134 | ||
135 | static inline void tcg_gen_qemu_ldst_op_i64_i32(int opc, TCGv_i64 val, TCGv_i32 addr, | |
136 | TCGArg mem_index) | |
137 | { | |
138 | *gen_opc_ptr++ = opc; | |
139 | *gen_opparam_ptr++ = GET_TCGV_I64(val); | |
140 | *gen_opparam_ptr++ = GET_TCGV_I32(addr); | |
141 | *gen_opparam_ptr++ = mem_index; | |
142 | } | |
143 | ||
144 | static inline void tcg_gen_qemu_ldst_op_i64_i64(int opc, TCGv_i64 val, TCGv_i64 addr, | |
145 | TCGArg mem_index) | |
146 | { | |
147 | *gen_opc_ptr++ = opc; | |
148 | *gen_opparam_ptr++ = GET_TCGV_I64(val); | |
149 | *gen_opparam_ptr++ = GET_TCGV_I64(addr); | |
150 | *gen_opparam_ptr++ = mem_index; | |
151 | } | |
152 | ||
153 | static inline void tcg_gen_op4_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, | |
154 | TCGv_i32 arg3, TCGv_i32 arg4) | |
155 | { | |
156 | *gen_opc_ptr++ = opc; | |
157 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
158 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
159 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
160 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
161 | } | |
162 | ||
163 | static inline void tcg_gen_op4_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, | |
a810a2de | 164 | TCGv_i64 arg3, TCGv_i64 arg4) |
a7812ae4 PB |
165 | { |
166 | *gen_opc_ptr++ = opc; | |
167 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
168 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
169 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
170 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
171 | } | |
172 | ||
173 | static inline void tcg_gen_op4i_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, | |
174 | TCGv_i32 arg3, TCGArg arg4) | |
175 | { | |
176 | *gen_opc_ptr++ = opc; | |
177 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
178 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
179 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
180 | *gen_opparam_ptr++ = arg4; | |
181 | } | |
182 | ||
183 | static inline void tcg_gen_op4i_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, | |
184 | TCGv_i64 arg3, TCGArg arg4) | |
ac56dd48 PB |
185 | { |
186 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
187 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
188 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
189 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
190 | *gen_opparam_ptr++ = arg4; | |
ac56dd48 PB |
191 | } |
192 | ||
a7812ae4 PB |
193 | static inline void tcg_gen_op4ii_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, |
194 | TCGArg arg3, TCGArg arg4) | |
ac56dd48 PB |
195 | { |
196 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
197 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
198 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
199 | *gen_opparam_ptr++ = arg3; | |
c896fe29 FB |
200 | *gen_opparam_ptr++ = arg4; |
201 | } | |
202 | ||
a7812ae4 PB |
203 | static inline void tcg_gen_op4ii_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, |
204 | TCGArg arg3, TCGArg arg4) | |
c896fe29 FB |
205 | { |
206 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
207 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
208 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
c896fe29 FB |
209 | *gen_opparam_ptr++ = arg3; |
210 | *gen_opparam_ptr++ = arg4; | |
ac56dd48 PB |
211 | } |
212 | ||
a7812ae4 PB |
213 | static inline void tcg_gen_op5_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, |
214 | TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5) | |
215 | { | |
216 | *gen_opc_ptr++ = opc; | |
217 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
218 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
219 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
220 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
221 | *gen_opparam_ptr++ = GET_TCGV_I32(arg5); | |
222 | } | |
223 | ||
224 | static inline void tcg_gen_op5_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, | |
225 | TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5) | |
226 | { | |
227 | *gen_opc_ptr++ = opc; | |
228 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
229 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
230 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
231 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
232 | *gen_opparam_ptr++ = GET_TCGV_I64(arg5); | |
233 | } | |
234 | ||
235 | static inline void tcg_gen_op5i_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, | |
236 | TCGv_i32 arg3, TCGv_i32 arg4, TCGArg arg5) | |
ac56dd48 PB |
237 | { |
238 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
239 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
240 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
241 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
242 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
243 | *gen_opparam_ptr++ = arg5; | |
ac56dd48 PB |
244 | } |
245 | ||
a7812ae4 PB |
246 | static inline void tcg_gen_op5i_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, |
247 | TCGv_i64 arg3, TCGv_i64 arg4, TCGArg arg5) | |
ac56dd48 PB |
248 | { |
249 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
250 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
251 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
252 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
253 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
c896fe29 FB |
254 | *gen_opparam_ptr++ = arg5; |
255 | } | |
256 | ||
a7812ae4 PB |
257 | static inline void tcg_gen_op6_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, |
258 | TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5, | |
259 | TCGv_i32 arg6) | |
260 | { | |
261 | *gen_opc_ptr++ = opc; | |
262 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
263 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
264 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
265 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
266 | *gen_opparam_ptr++ = GET_TCGV_I32(arg5); | |
267 | *gen_opparam_ptr++ = GET_TCGV_I32(arg6); | |
268 | } | |
269 | ||
270 | static inline void tcg_gen_op6_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, | |
271 | TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5, | |
272 | TCGv_i64 arg6) | |
c896fe29 FB |
273 | { |
274 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
275 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
276 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
277 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
278 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
279 | *gen_opparam_ptr++ = GET_TCGV_I64(arg5); | |
280 | *gen_opparam_ptr++ = GET_TCGV_I64(arg6); | |
ac56dd48 PB |
281 | } |
282 | ||
a7812ae4 PB |
283 | static inline void tcg_gen_op6ii_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2, |
284 | TCGv_i32 arg3, TCGv_i32 arg4, TCGArg arg5, | |
285 | TCGArg arg6) | |
ac56dd48 PB |
286 | { |
287 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
288 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
289 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
290 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
291 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
292 | *gen_opparam_ptr++ = arg5; | |
293 | *gen_opparam_ptr++ = arg6; | |
294 | } | |
295 | ||
296 | static inline void tcg_gen_op6ii_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2, | |
297 | TCGv_i64 arg3, TCGv_i64 arg4, TCGArg arg5, | |
298 | TCGArg arg6) | |
299 | { | |
300 | *gen_opc_ptr++ = opc; | |
301 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
302 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
303 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
304 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
c896fe29 FB |
305 | *gen_opparam_ptr++ = arg5; |
306 | *gen_opparam_ptr++ = arg6; | |
307 | } | |
308 | ||
309 | static inline void gen_set_label(int n) | |
310 | { | |
ac56dd48 | 311 | tcg_gen_op1i(INDEX_op_set_label, n); |
c896fe29 FB |
312 | } |
313 | ||
fb50d413 BS |
314 | static inline void tcg_gen_br(int label) |
315 | { | |
316 | tcg_gen_op1i(INDEX_op_br, label); | |
317 | } | |
318 | ||
a7812ae4 | 319 | static inline void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 | 320 | { |
a7812ae4 PB |
321 | if (GET_TCGV_I32(ret) != GET_TCGV_I32(arg)) |
322 | tcg_gen_op2_i32(INDEX_op_mov_i32, ret, arg); | |
c896fe29 FB |
323 | } |
324 | ||
a7812ae4 | 325 | static inline void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg) |
c896fe29 | 326 | { |
a7812ae4 | 327 | tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg); |
c896fe29 FB |
328 | } |
329 | ||
330 | /* helper calls */ | |
a7812ae4 PB |
331 | static inline void tcg_gen_helperN(void *func, int flags, int sizemask, |
332 | TCGArg ret, int nargs, TCGArg *args) | |
333 | { | |
334 | TCGv_ptr fn; | |
335 | fn = tcg_const_ptr((tcg_target_long)func); | |
336 | tcg_gen_callN(&tcg_ctx, fn, flags, sizemask, ret, | |
337 | nargs, args); | |
338 | tcg_temp_free_ptr(fn); | |
339 | } | |
c896fe29 | 340 | |
a7812ae4 PB |
341 | /* FIXME: Should this be pure? */ |
342 | static inline void tcg_gen_helper64(void *func, TCGv_i64 ret, | |
343 | TCGv_i64 a, TCGv_i64 b) | |
c896fe29 | 344 | { |
a7812ae4 PB |
345 | TCGv_ptr fn; |
346 | TCGArg args[2]; | |
347 | fn = tcg_const_ptr((tcg_target_long)func); | |
348 | args[0] = GET_TCGV_I64(a); | |
349 | args[1] = GET_TCGV_I64(b); | |
350 | tcg_gen_callN(&tcg_ctx, fn, 0, 7, GET_TCGV_I64(ret), 2, args); | |
351 | tcg_temp_free_ptr(fn); | |
f8422f52 BS |
352 | } |
353 | ||
c896fe29 FB |
354 | /* 32 bit ops */ |
355 | ||
a7812ae4 | 356 | static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 357 | { |
a7812ae4 | 358 | tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32, ret, arg2, offset); |
c896fe29 FB |
359 | } |
360 | ||
a7812ae4 | 361 | static inline void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 362 | { |
a7812ae4 | 363 | tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32, ret, arg2, offset); |
c896fe29 FB |
364 | } |
365 | ||
a7812ae4 | 366 | static inline void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 367 | { |
a7812ae4 | 368 | tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32, ret, arg2, offset); |
c896fe29 FB |
369 | } |
370 | ||
a7812ae4 | 371 | static inline void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 372 | { |
a7812ae4 | 373 | tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32, ret, arg2, offset); |
c896fe29 FB |
374 | } |
375 | ||
a7812ae4 | 376 | static inline void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 377 | { |
a7812ae4 | 378 | tcg_gen_ldst_op_i32(INDEX_op_ld_i32, ret, arg2, offset); |
c896fe29 FB |
379 | } |
380 | ||
a7812ae4 | 381 | static inline void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 382 | { |
a7812ae4 | 383 | tcg_gen_ldst_op_i32(INDEX_op_st8_i32, arg1, arg2, offset); |
c896fe29 FB |
384 | } |
385 | ||
a7812ae4 | 386 | static inline void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 387 | { |
a7812ae4 | 388 | tcg_gen_ldst_op_i32(INDEX_op_st16_i32, arg1, arg2, offset); |
c896fe29 FB |
389 | } |
390 | ||
a7812ae4 | 391 | static inline void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 392 | { |
a7812ae4 | 393 | tcg_gen_ldst_op_i32(INDEX_op_st_i32, arg1, arg2, offset); |
c896fe29 FB |
394 | } |
395 | ||
a7812ae4 | 396 | static inline void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 397 | { |
a7812ae4 | 398 | tcg_gen_op3_i32(INDEX_op_add_i32, ret, arg1, arg2); |
c896fe29 FB |
399 | } |
400 | ||
a7812ae4 | 401 | static inline void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 402 | { |
7089442c BS |
403 | /* some cases can be optimized here */ |
404 | if (arg2 == 0) { | |
405 | tcg_gen_mov_i32(ret, arg1); | |
406 | } else { | |
a7812ae4 | 407 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 408 | tcg_gen_add_i32(ret, arg1, t0); |
a7812ae4 | 409 | tcg_temp_free_i32(t0); |
7089442c | 410 | } |
c896fe29 FB |
411 | } |
412 | ||
a7812ae4 | 413 | static inline void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 414 | { |
a7812ae4 | 415 | tcg_gen_op3_i32(INDEX_op_sub_i32, ret, arg1, arg2); |
c896fe29 FB |
416 | } |
417 | ||
a7812ae4 | 418 | static inline void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2) |
0045734a | 419 | { |
a7812ae4 | 420 | TCGv_i32 t0 = tcg_const_i32(arg1); |
0045734a | 421 | tcg_gen_sub_i32(ret, t0, arg2); |
a7812ae4 | 422 | tcg_temp_free_i32(t0); |
0045734a AJ |
423 | } |
424 | ||
a7812ae4 | 425 | static inline void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 426 | { |
7089442c BS |
427 | /* some cases can be optimized here */ |
428 | if (arg2 == 0) { | |
429 | tcg_gen_mov_i32(ret, arg1); | |
430 | } else { | |
a7812ae4 | 431 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 432 | tcg_gen_sub_i32(ret, arg1, t0); |
a7812ae4 | 433 | tcg_temp_free_i32(t0); |
7089442c | 434 | } |
c896fe29 FB |
435 | } |
436 | ||
a7812ae4 | 437 | static inline void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 438 | { |
a7812ae4 | 439 | tcg_gen_op3_i32(INDEX_op_and_i32, ret, arg1, arg2); |
c896fe29 FB |
440 | } |
441 | ||
a7812ae4 | 442 | static inline void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 FB |
443 | { |
444 | /* some cases can be optimized here */ | |
445 | if (arg2 == 0) { | |
446 | tcg_gen_movi_i32(ret, 0); | |
447 | } else if (arg2 == 0xffffffff) { | |
448 | tcg_gen_mov_i32(ret, arg1); | |
449 | } else { | |
a7812ae4 | 450 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 451 | tcg_gen_and_i32(ret, arg1, t0); |
a7812ae4 | 452 | tcg_temp_free_i32(t0); |
c896fe29 FB |
453 | } |
454 | } | |
455 | ||
a7812ae4 | 456 | static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 457 | { |
a7812ae4 | 458 | tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2); |
c896fe29 FB |
459 | } |
460 | ||
a7812ae4 | 461 | static inline void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 FB |
462 | { |
463 | /* some cases can be optimized here */ | |
464 | if (arg2 == 0xffffffff) { | |
7089442c | 465 | tcg_gen_movi_i32(ret, 0xffffffff); |
c896fe29 FB |
466 | } else if (arg2 == 0) { |
467 | tcg_gen_mov_i32(ret, arg1); | |
468 | } else { | |
a7812ae4 | 469 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 470 | tcg_gen_or_i32(ret, arg1, t0); |
a7812ae4 | 471 | tcg_temp_free_i32(t0); |
c896fe29 FB |
472 | } |
473 | } | |
474 | ||
a7812ae4 | 475 | static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 476 | { |
a7812ae4 | 477 | tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2); |
c896fe29 FB |
478 | } |
479 | ||
a7812ae4 | 480 | static inline void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 FB |
481 | { |
482 | /* some cases can be optimized here */ | |
483 | if (arg2 == 0) { | |
484 | tcg_gen_mov_i32(ret, arg1); | |
485 | } else { | |
a7812ae4 | 486 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 487 | tcg_gen_xor_i32(ret, arg1, t0); |
a7812ae4 | 488 | tcg_temp_free_i32(t0); |
c896fe29 FB |
489 | } |
490 | } | |
491 | ||
a7812ae4 | 492 | static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 493 | { |
a7812ae4 | 494 | tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2); |
c896fe29 FB |
495 | } |
496 | ||
a7812ae4 | 497 | static inline void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 498 | { |
34151a20 FB |
499 | if (arg2 == 0) { |
500 | tcg_gen_mov_i32(ret, arg1); | |
501 | } else { | |
a7812ae4 | 502 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 503 | tcg_gen_shl_i32(ret, arg1, t0); |
a7812ae4 | 504 | tcg_temp_free_i32(t0); |
34151a20 | 505 | } |
c896fe29 FB |
506 | } |
507 | ||
a7812ae4 | 508 | static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 509 | { |
a7812ae4 | 510 | tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2); |
c896fe29 FB |
511 | } |
512 | ||
a7812ae4 | 513 | static inline void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 514 | { |
34151a20 FB |
515 | if (arg2 == 0) { |
516 | tcg_gen_mov_i32(ret, arg1); | |
517 | } else { | |
a7812ae4 | 518 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 519 | tcg_gen_shr_i32(ret, arg1, t0); |
a7812ae4 | 520 | tcg_temp_free_i32(t0); |
34151a20 | 521 | } |
c896fe29 FB |
522 | } |
523 | ||
a7812ae4 | 524 | static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 525 | { |
a7812ae4 | 526 | tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2); |
c896fe29 FB |
527 | } |
528 | ||
a7812ae4 | 529 | static inline void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 530 | { |
34151a20 FB |
531 | if (arg2 == 0) { |
532 | tcg_gen_mov_i32(ret, arg1); | |
533 | } else { | |
a7812ae4 | 534 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 535 | tcg_gen_sar_i32(ret, arg1, t0); |
a7812ae4 | 536 | tcg_temp_free_i32(t0); |
34151a20 | 537 | } |
c896fe29 FB |
538 | } |
539 | ||
a7812ae4 | 540 | static inline void tcg_gen_brcond_i32(int cond, TCGv_i32 arg1, TCGv_i32 arg2, |
c896fe29 FB |
541 | int label_index) |
542 | { | |
a7812ae4 | 543 | tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_index); |
c896fe29 FB |
544 | } |
545 | ||
a7812ae4 | 546 | static inline void tcg_gen_brcondi_i32(int cond, TCGv_i32 arg1, int32_t arg2, |
cb63669a PB |
547 | int label_index) |
548 | { | |
a7812ae4 | 549 | TCGv_i32 t0 = tcg_const_i32(arg2); |
cb63669a | 550 | tcg_gen_brcond_i32(cond, arg1, t0, label_index); |
a7812ae4 | 551 | tcg_temp_free_i32(t0); |
cb63669a PB |
552 | } |
553 | ||
a7812ae4 | 554 | static inline void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 555 | { |
a7812ae4 | 556 | tcg_gen_op3_i32(INDEX_op_mul_i32, ret, arg1, arg2); |
c896fe29 FB |
557 | } |
558 | ||
a7812ae4 | 559 | static inline void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
f730fd27 | 560 | { |
a7812ae4 | 561 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 562 | tcg_gen_mul_i32(ret, arg1, t0); |
a7812ae4 | 563 | tcg_temp_free_i32(t0); |
f730fd27 TS |
564 | } |
565 | ||
c896fe29 | 566 | #ifdef TCG_TARGET_HAS_div_i32 |
a7812ae4 | 567 | static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 568 | { |
a7812ae4 | 569 | tcg_gen_op3_i32(INDEX_op_div_i32, ret, arg1, arg2); |
c896fe29 FB |
570 | } |
571 | ||
a7812ae4 | 572 | static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 573 | { |
a7812ae4 | 574 | tcg_gen_op3_i32(INDEX_op_rem_i32, ret, arg1, arg2); |
c896fe29 FB |
575 | } |
576 | ||
a7812ae4 | 577 | static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 578 | { |
a7812ae4 | 579 | tcg_gen_op3_i32(INDEX_op_divu_i32, ret, arg1, arg2); |
c896fe29 FB |
580 | } |
581 | ||
a7812ae4 | 582 | static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 583 | { |
a7812ae4 | 584 | tcg_gen_op3_i32(INDEX_op_remu_i32, ret, arg1, arg2); |
c896fe29 FB |
585 | } |
586 | #else | |
a7812ae4 | 587 | static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 588 | { |
a7812ae4 PB |
589 | TCGv_i32 t0; |
590 | t0 = tcg_temp_new_i32(); | |
c896fe29 | 591 | tcg_gen_sari_i32(t0, arg1, 31); |
a7812ae4 PB |
592 | tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2); |
593 | tcg_temp_free_i32(t0); | |
c896fe29 FB |
594 | } |
595 | ||
a7812ae4 | 596 | static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 597 | { |
a7812ae4 PB |
598 | TCGv_i32 t0; |
599 | t0 = tcg_temp_new_i32(); | |
c896fe29 | 600 | tcg_gen_sari_i32(t0, arg1, 31); |
a7812ae4 PB |
601 | tcg_gen_op5_i32(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2); |
602 | tcg_temp_free_i32(t0); | |
c896fe29 FB |
603 | } |
604 | ||
a7812ae4 | 605 | static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 606 | { |
a7812ae4 PB |
607 | TCGv_i32 t0; |
608 | t0 = tcg_temp_new_i32(); | |
c896fe29 | 609 | tcg_gen_movi_i32(t0, 0); |
a7812ae4 PB |
610 | tcg_gen_op5_i32(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2); |
611 | tcg_temp_free_i32(t0); | |
c896fe29 FB |
612 | } |
613 | ||
a7812ae4 | 614 | static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 615 | { |
a7812ae4 PB |
616 | TCGv_i32 t0; |
617 | t0 = tcg_temp_new_i32(); | |
c896fe29 | 618 | tcg_gen_movi_i32(t0, 0); |
a7812ae4 PB |
619 | tcg_gen_op5_i32(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2); |
620 | tcg_temp_free_i32(t0); | |
c896fe29 FB |
621 | } |
622 | #endif | |
623 | ||
624 | #if TCG_TARGET_REG_BITS == 32 | |
625 | ||
a7812ae4 | 626 | static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 627 | { |
a7812ae4 PB |
628 | if (GET_TCGV_I64(ret) != GET_TCGV_I64(arg)) { |
629 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); | |
4d07272d BS |
630 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); |
631 | } | |
c896fe29 FB |
632 | } |
633 | ||
a7812ae4 | 634 | static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg) |
c896fe29 | 635 | { |
a7812ae4 | 636 | tcg_gen_movi_i32(TCGV_LOW(ret), arg); |
ac56dd48 | 637 | tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32); |
c896fe29 FB |
638 | } |
639 | ||
a7812ae4 PB |
640 | static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
641 | tcg_target_long offset) | |
c896fe29 | 642 | { |
a7812ae4 | 643 | tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 644 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
645 | } |
646 | ||
a7812ae4 PB |
647 | static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
648 | tcg_target_long offset) | |
c896fe29 | 649 | { |
a7812ae4 PB |
650 | tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset); |
651 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), 31); | |
c896fe29 FB |
652 | } |
653 | ||
a7812ae4 PB |
654 | static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
655 | tcg_target_long offset) | |
c896fe29 | 656 | { |
a747723b | 657 | tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 658 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
659 | } |
660 | ||
a7812ae4 PB |
661 | static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
662 | tcg_target_long offset) | |
c896fe29 | 663 | { |
a7812ae4 PB |
664 | tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset); |
665 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
666 | } |
667 | ||
a7812ae4 PB |
668 | static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
669 | tcg_target_long offset) | |
c896fe29 | 670 | { |
a7812ae4 | 671 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 672 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
673 | } |
674 | ||
a7812ae4 PB |
675 | static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
676 | tcg_target_long offset) | |
c896fe29 | 677 | { |
a7812ae4 PB |
678 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
679 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
680 | } |
681 | ||
a7812ae4 PB |
682 | static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, |
683 | tcg_target_long offset) | |
c896fe29 FB |
684 | { |
685 | /* since arg2 and ret have different types, they cannot be the | |
686 | same temporary */ | |
687 | #ifdef TCG_TARGET_WORDS_BIGENDIAN | |
ac56dd48 | 688 | tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset); |
a7812ae4 | 689 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4); |
c896fe29 | 690 | #else |
a7812ae4 | 691 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 692 | tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4); |
c896fe29 FB |
693 | #endif |
694 | } | |
695 | ||
a7812ae4 PB |
696 | static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
697 | tcg_target_long offset) | |
c896fe29 | 698 | { |
a7812ae4 | 699 | tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset); |
c896fe29 FB |
700 | } |
701 | ||
a7812ae4 PB |
702 | static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
703 | tcg_target_long offset) | |
c896fe29 | 704 | { |
a7812ae4 | 705 | tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset); |
c896fe29 FB |
706 | } |
707 | ||
a7812ae4 PB |
708 | static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
709 | tcg_target_long offset) | |
c896fe29 | 710 | { |
a7812ae4 | 711 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); |
c896fe29 FB |
712 | } |
713 | ||
a7812ae4 PB |
714 | static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
715 | tcg_target_long offset) | |
c896fe29 FB |
716 | { |
717 | #ifdef TCG_TARGET_WORDS_BIGENDIAN | |
ac56dd48 | 718 | tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset); |
a7812ae4 | 719 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4); |
c896fe29 | 720 | #else |
a7812ae4 | 721 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); |
ac56dd48 | 722 | tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4); |
c896fe29 FB |
723 | #endif |
724 | } | |
725 | ||
a7812ae4 | 726 | static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 727 | { |
a7812ae4 PB |
728 | tcg_gen_op6_i32(INDEX_op_add2_i32, TCGV_LOW(ret), TCGV_HIGH(ret), |
729 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), | |
730 | TCGV_HIGH(arg2)); | |
c896fe29 FB |
731 | } |
732 | ||
a7812ae4 | 733 | static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 734 | { |
a7812ae4 PB |
735 | tcg_gen_op6_i32(INDEX_op_sub2_i32, TCGV_LOW(ret), TCGV_HIGH(ret), |
736 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), | |
737 | TCGV_HIGH(arg2)); | |
c896fe29 FB |
738 | } |
739 | ||
a7812ae4 | 740 | static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 741 | { |
a7812ae4 | 742 | tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
ac56dd48 | 743 | tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
c896fe29 FB |
744 | } |
745 | ||
a7812ae4 | 746 | static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 747 | { |
a7812ae4 | 748 | tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
ac56dd48 | 749 | tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
c896fe29 FB |
750 | } |
751 | ||
a7812ae4 | 752 | static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 753 | { |
a7812ae4 | 754 | tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
ac56dd48 | 755 | tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
c896fe29 FB |
756 | } |
757 | ||
a7812ae4 | 758 | static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 759 | { |
a7812ae4 | 760 | tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
ac56dd48 | 761 | tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
c896fe29 FB |
762 | } |
763 | ||
a7812ae4 | 764 | static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 765 | { |
a7812ae4 | 766 | tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
ac56dd48 | 767 | tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
c896fe29 FB |
768 | } |
769 | ||
a7812ae4 | 770 | static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 771 | { |
a7812ae4 | 772 | tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
ac56dd48 | 773 | tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
c896fe29 FB |
774 | } |
775 | ||
776 | /* XXX: use generic code when basic block handling is OK or CPU | |
777 | specific code (x86) */ | |
a7812ae4 | 778 | static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 779 | { |
a7812ae4 | 780 | tcg_gen_helper64(tcg_helper_shl_i64, ret, arg1, arg2); |
c896fe29 FB |
781 | } |
782 | ||
a7812ae4 | 783 | static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 FB |
784 | { |
785 | tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0); | |
786 | } | |
787 | ||
a7812ae4 | 788 | static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 789 | { |
a7812ae4 | 790 | tcg_gen_helper64(tcg_helper_shr_i64, ret, arg1, arg2); |
c896fe29 FB |
791 | } |
792 | ||
a7812ae4 | 793 | static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 FB |
794 | { |
795 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0); | |
796 | } | |
797 | ||
a7812ae4 | 798 | static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 799 | { |
a7812ae4 | 800 | tcg_gen_helper64(tcg_helper_sar_i64, ret, arg1, arg2); |
c896fe29 FB |
801 | } |
802 | ||
a7812ae4 | 803 | static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 FB |
804 | { |
805 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1); | |
806 | } | |
807 | ||
a7812ae4 | 808 | static inline void tcg_gen_brcond_i64(int cond, TCGv_i64 arg1, TCGv_i64 arg2, |
c896fe29 FB |
809 | int label_index) |
810 | { | |
a7812ae4 PB |
811 | tcg_gen_op6ii_i32(INDEX_op_brcond2_i32, |
812 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), | |
813 | TCGV_HIGH(arg2), cond, label_index); | |
c896fe29 FB |
814 | } |
815 | ||
a7812ae4 | 816 | static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 817 | { |
a7812ae4 PB |
818 | TCGv_i64 t0; |
819 | TCGv_i32 t1; | |
c896fe29 | 820 | |
a7812ae4 PB |
821 | t0 = tcg_temp_new_i64(); |
822 | t1 = tcg_temp_new_i32(); | |
823 | ||
824 | tcg_gen_op4_i32(INDEX_op_mulu2_i32, TCGV_LOW(t0), TCGV_HIGH(t0), | |
825 | TCGV_LOW(arg1), TCGV_LOW(arg2)); | |
826 | ||
827 | tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2)); | |
ac56dd48 | 828 | tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); |
a7812ae4 | 829 | tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2)); |
ac56dd48 | 830 | tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); |
a7812ae4 | 831 | |
c896fe29 | 832 | tcg_gen_mov_i64(ret, t0); |
a7812ae4 PB |
833 | tcg_temp_free_i64(t0); |
834 | tcg_temp_free_i32(t1); | |
c896fe29 FB |
835 | } |
836 | ||
a7812ae4 | 837 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 838 | { |
a7812ae4 | 839 | tcg_gen_helper64(tcg_helper_div_i64, ret, arg1, arg2); |
c896fe29 FB |
840 | } |
841 | ||
a7812ae4 | 842 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 843 | { |
a7812ae4 | 844 | tcg_gen_helper64(tcg_helper_rem_i64, ret, arg1, arg2); |
c896fe29 FB |
845 | } |
846 | ||
a7812ae4 | 847 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 848 | { |
a7812ae4 | 849 | tcg_gen_helper64(tcg_helper_divu_i64, ret, arg1, arg2); |
c896fe29 FB |
850 | } |
851 | ||
a7812ae4 | 852 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 853 | { |
a7812ae4 | 854 | tcg_gen_helper64(tcg_helper_remu_i64, ret, arg1, arg2); |
c896fe29 FB |
855 | } |
856 | ||
857 | #else | |
858 | ||
a7812ae4 | 859 | static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 860 | { |
a7812ae4 PB |
861 | if (GET_TCGV_I64(ret) != GET_TCGV_I64(arg)) |
862 | tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg); | |
c896fe29 FB |
863 | } |
864 | ||
a7812ae4 | 865 | static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg) |
c896fe29 | 866 | { |
a7812ae4 | 867 | tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg); |
c896fe29 FB |
868 | } |
869 | ||
a7812ae4 | 870 | static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_i64 arg2, |
ac56dd48 | 871 | tcg_target_long offset) |
c896fe29 | 872 | { |
a7812ae4 | 873 | tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset); |
c896fe29 FB |
874 | } |
875 | ||
a7812ae4 | 876 | static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_i64 arg2, |
ac56dd48 | 877 | tcg_target_long offset) |
c896fe29 | 878 | { |
a7812ae4 | 879 | tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset); |
c896fe29 FB |
880 | } |
881 | ||
a7812ae4 | 882 | static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_i64 arg2, |
ac56dd48 | 883 | tcg_target_long offset) |
c896fe29 | 884 | { |
a7812ae4 | 885 | tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset); |
c896fe29 FB |
886 | } |
887 | ||
a7812ae4 | 888 | static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_i64 arg2, |
ac56dd48 | 889 | tcg_target_long offset) |
c896fe29 | 890 | { |
a7812ae4 | 891 | tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset); |
c896fe29 FB |
892 | } |
893 | ||
a7812ae4 | 894 | static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_i64 arg2, |
ac56dd48 | 895 | tcg_target_long offset) |
c896fe29 | 896 | { |
a7812ae4 | 897 | tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset); |
c896fe29 FB |
898 | } |
899 | ||
a7812ae4 | 900 | static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_i64 arg2, |
ac56dd48 | 901 | tcg_target_long offset) |
c896fe29 | 902 | { |
a7812ae4 | 903 | tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset); |
c896fe29 FB |
904 | } |
905 | ||
a7812ae4 | 906 | static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_i64 arg2, tcg_target_long offset) |
c896fe29 | 907 | { |
a7812ae4 | 908 | tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset); |
c896fe29 FB |
909 | } |
910 | ||
a7812ae4 | 911 | static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_i64 arg2, |
ac56dd48 | 912 | tcg_target_long offset) |
c896fe29 | 913 | { |
a7812ae4 | 914 | tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset); |
c896fe29 FB |
915 | } |
916 | ||
a7812ae4 | 917 | static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_i64 arg2, |
ac56dd48 | 918 | tcg_target_long offset) |
c896fe29 | 919 | { |
a7812ae4 | 920 | tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset); |
c896fe29 FB |
921 | } |
922 | ||
a7812ae4 | 923 | static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_i64 arg2, |
ac56dd48 | 924 | tcg_target_long offset) |
c896fe29 | 925 | { |
a7812ae4 | 926 | tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset); |
c896fe29 FB |
927 | } |
928 | ||
a7812ae4 | 929 | static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_i64 arg2, tcg_target_long offset) |
c896fe29 | 930 | { |
a7812ae4 | 931 | tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset); |
c896fe29 FB |
932 | } |
933 | ||
a7812ae4 | 934 | static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 935 | { |
a7812ae4 | 936 | tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2); |
c896fe29 FB |
937 | } |
938 | ||
a7812ae4 | 939 | static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 940 | { |
a7812ae4 | 941 | tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2); |
c896fe29 FB |
942 | } |
943 | ||
a7812ae4 | 944 | static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 945 | { |
a7812ae4 | 946 | tcg_gen_op3_i64(INDEX_op_and_i64, ret, arg1, arg2); |
c896fe29 FB |
947 | } |
948 | ||
a7812ae4 | 949 | static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 950 | { |
a7812ae4 | 951 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 952 | tcg_gen_and_i64(ret, arg1, t0); |
a7812ae4 | 953 | tcg_temp_free_i64(t0); |
c896fe29 FB |
954 | } |
955 | ||
a7812ae4 | 956 | static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 957 | { |
a7812ae4 | 958 | tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2); |
c896fe29 FB |
959 | } |
960 | ||
a7812ae4 | 961 | static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 962 | { |
a7812ae4 | 963 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 964 | tcg_gen_or_i64(ret, arg1, t0); |
a7812ae4 | 965 | tcg_temp_free_i64(t0); |
c896fe29 FB |
966 | } |
967 | ||
a7812ae4 | 968 | static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 969 | { |
a7812ae4 | 970 | tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2); |
c896fe29 FB |
971 | } |
972 | ||
a7812ae4 | 973 | static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 974 | { |
a7812ae4 | 975 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 976 | tcg_gen_xor_i64(ret, arg1, t0); |
a7812ae4 | 977 | tcg_temp_free_i64(t0); |
c896fe29 FB |
978 | } |
979 | ||
a7812ae4 | 980 | static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 981 | { |
a7812ae4 | 982 | tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2); |
c896fe29 FB |
983 | } |
984 | ||
a7812ae4 | 985 | static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 986 | { |
34151a20 FB |
987 | if (arg2 == 0) { |
988 | tcg_gen_mov_i64(ret, arg1); | |
989 | } else { | |
a7812ae4 | 990 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 991 | tcg_gen_shl_i64(ret, arg1, t0); |
a7812ae4 | 992 | tcg_temp_free_i64(t0); |
34151a20 | 993 | } |
c896fe29 FB |
994 | } |
995 | ||
a7812ae4 | 996 | static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 997 | { |
a7812ae4 | 998 | tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2); |
c896fe29 FB |
999 | } |
1000 | ||
a7812ae4 | 1001 | static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 1002 | { |
34151a20 FB |
1003 | if (arg2 == 0) { |
1004 | tcg_gen_mov_i64(ret, arg1); | |
1005 | } else { | |
a7812ae4 | 1006 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 1007 | tcg_gen_shr_i64(ret, arg1, t0); |
a7812ae4 | 1008 | tcg_temp_free_i64(t0); |
34151a20 | 1009 | } |
c896fe29 FB |
1010 | } |
1011 | ||
a7812ae4 | 1012 | static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1013 | { |
a7812ae4 | 1014 | tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2); |
c896fe29 FB |
1015 | } |
1016 | ||
a7812ae4 | 1017 | static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 1018 | { |
34151a20 FB |
1019 | if (arg2 == 0) { |
1020 | tcg_gen_mov_i64(ret, arg1); | |
1021 | } else { | |
a7812ae4 | 1022 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 1023 | tcg_gen_sar_i64(ret, arg1, t0); |
a7812ae4 | 1024 | tcg_temp_free_i64(t0); |
34151a20 | 1025 | } |
c896fe29 FB |
1026 | } |
1027 | ||
a7812ae4 | 1028 | static inline void tcg_gen_brcond_i64(int cond, TCGv_i64 arg1, TCGv_i64 arg2, |
c896fe29 FB |
1029 | int label_index) |
1030 | { | |
a7812ae4 | 1031 | tcg_gen_op4ii_i64(INDEX_op_brcond_i64, arg1, arg2, cond, label_index); |
c896fe29 FB |
1032 | } |
1033 | ||
a7812ae4 | 1034 | static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1035 | { |
a7812ae4 | 1036 | tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2); |
c896fe29 FB |
1037 | } |
1038 | ||
1039 | #ifdef TCG_TARGET_HAS_div_i64 | |
a7812ae4 | 1040 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1041 | { |
a7812ae4 | 1042 | tcg_gen_op3_i64(INDEX_op_div_i64, ret, arg1, arg2); |
c896fe29 FB |
1043 | } |
1044 | ||
a7812ae4 | 1045 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1046 | { |
a7812ae4 | 1047 | tcg_gen_op3_i64(INDEX_op_rem_i64, ret, arg1, arg2); |
c896fe29 FB |
1048 | } |
1049 | ||
a7812ae4 | 1050 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1051 | { |
a7812ae4 | 1052 | tcg_gen_op3_i64(INDEX_op_divu_i64, ret, arg1, arg2); |
c896fe29 FB |
1053 | } |
1054 | ||
a7812ae4 | 1055 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1056 | { |
a7812ae4 | 1057 | tcg_gen_op3_i64(INDEX_op_remu_i64, ret, arg1, arg2); |
c896fe29 FB |
1058 | } |
1059 | #else | |
a7812ae4 | 1060 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1061 | { |
a7812ae4 PB |
1062 | TCGv_i64 t0; |
1063 | t0 = tcg_temp_new_i64(); | |
c896fe29 | 1064 | tcg_gen_sari_i64(t0, arg1, 63); |
a7812ae4 PB |
1065 | tcg_gen_op5_i64(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2); |
1066 | tcg_temp_free_i64(t0); | |
c896fe29 FB |
1067 | } |
1068 | ||
a7812ae4 | 1069 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1070 | { |
a7812ae4 PB |
1071 | TCGv_i64 t0; |
1072 | t0 = tcg_temp_new_i64(); | |
c896fe29 | 1073 | tcg_gen_sari_i64(t0, arg1, 63); |
a7812ae4 PB |
1074 | tcg_gen_op5_i64(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2); |
1075 | tcg_temp_free_i64(t0); | |
c896fe29 FB |
1076 | } |
1077 | ||
a7812ae4 | 1078 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1079 | { |
a7812ae4 PB |
1080 | TCGv_i64 t0; |
1081 | t0 = tcg_temp_new_i64(); | |
c896fe29 | 1082 | tcg_gen_movi_i64(t0, 0); |
a7812ae4 PB |
1083 | tcg_gen_op5_i64(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2); |
1084 | tcg_temp_free_i64(t0); | |
c896fe29 FB |
1085 | } |
1086 | ||
a7812ae4 | 1087 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1088 | { |
a7812ae4 PB |
1089 | TCGv_i64 t0; |
1090 | t0 = tcg_temp_new_i64(); | |
c896fe29 | 1091 | tcg_gen_movi_i64(t0, 0); |
a7812ae4 PB |
1092 | tcg_gen_op5_i64(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2); |
1093 | tcg_temp_free_i64(t0); | |
c896fe29 FB |
1094 | } |
1095 | #endif | |
1096 | ||
1097 | #endif | |
1098 | ||
a7812ae4 | 1099 | static inline void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
6359706f AJ |
1100 | { |
1101 | /* some cases can be optimized here */ | |
1102 | if (arg2 == 0) { | |
1103 | tcg_gen_mov_i64(ret, arg1); | |
1104 | } else { | |
a7812ae4 | 1105 | TCGv_i64 t0 = tcg_const_i64(arg2); |
6359706f | 1106 | tcg_gen_add_i64(ret, arg1, t0); |
a7812ae4 | 1107 | tcg_temp_free_i64(t0); |
6359706f AJ |
1108 | } |
1109 | } | |
1110 | ||
a7812ae4 | 1111 | static inline void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2) |
0045734a | 1112 | { |
a7812ae4 | 1113 | TCGv_i64 t0 = tcg_const_i64(arg1); |
0045734a | 1114 | tcg_gen_sub_i64(ret, t0, arg2); |
a7812ae4 | 1115 | tcg_temp_free_i64(t0); |
0045734a AJ |
1116 | } |
1117 | ||
a7812ae4 | 1118 | static inline void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
6359706f AJ |
1119 | { |
1120 | /* some cases can be optimized here */ | |
1121 | if (arg2 == 0) { | |
1122 | tcg_gen_mov_i64(ret, arg1); | |
1123 | } else { | |
a7812ae4 | 1124 | TCGv_i64 t0 = tcg_const_i64(arg2); |
6359706f | 1125 | tcg_gen_sub_i64(ret, arg1, t0); |
a7812ae4 | 1126 | tcg_temp_free_i64(t0); |
6359706f AJ |
1127 | } |
1128 | } | |
a7812ae4 | 1129 | static inline void tcg_gen_brcondi_i64(int cond, TCGv_i64 arg1, int64_t arg2, |
f02bb954 AJ |
1130 | int label_index) |
1131 | { | |
a7812ae4 | 1132 | TCGv_i64 t0 = tcg_const_i64(arg2); |
f02bb954 | 1133 | tcg_gen_brcond_i64(cond, arg1, t0, label_index); |
a7812ae4 | 1134 | tcg_temp_free_i64(t0); |
f02bb954 AJ |
1135 | } |
1136 | ||
a7812ae4 | 1137 | static inline void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
f02bb954 | 1138 | { |
a7812ae4 | 1139 | TCGv_i64 t0 = tcg_const_i64(arg2); |
f02bb954 | 1140 | tcg_gen_mul_i64(ret, arg1, t0); |
a7812ae4 | 1141 | tcg_temp_free_i64(t0); |
f02bb954 AJ |
1142 | } |
1143 | ||
6359706f | 1144 | |
c896fe29 FB |
1145 | /***************************************/ |
1146 | /* optional operations */ | |
1147 | ||
a7812ae4 | 1148 | static inline void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 FB |
1149 | { |
1150 | #ifdef TCG_TARGET_HAS_ext8s_i32 | |
a7812ae4 | 1151 | tcg_gen_op2_i32(INDEX_op_ext8s_i32, ret, arg); |
c896fe29 FB |
1152 | #else |
1153 | tcg_gen_shli_i32(ret, arg, 24); | |
5ff9d6a4 | 1154 | tcg_gen_sari_i32(ret, ret, 24); |
c896fe29 FB |
1155 | #endif |
1156 | } | |
1157 | ||
a7812ae4 | 1158 | static inline void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 FB |
1159 | { |
1160 | #ifdef TCG_TARGET_HAS_ext16s_i32 | |
a7812ae4 | 1161 | tcg_gen_op2_i32(INDEX_op_ext16s_i32, ret, arg); |
c896fe29 FB |
1162 | #else |
1163 | tcg_gen_shli_i32(ret, arg, 16); | |
5ff9d6a4 | 1164 | tcg_gen_sari_i32(ret, ret, 16); |
c896fe29 FB |
1165 | #endif |
1166 | } | |
1167 | ||
86831435 PB |
1168 | /* These are currently just for convenience. |
1169 | We assume a target will recognise these automatically . */ | |
a7812ae4 | 1170 | static inline void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg) |
86831435 PB |
1171 | { |
1172 | tcg_gen_andi_i32(ret, arg, 0xffu); | |
1173 | } | |
1174 | ||
a7812ae4 | 1175 | static inline void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg) |
86831435 PB |
1176 | { |
1177 | tcg_gen_andi_i32(ret, arg, 0xffffu); | |
1178 | } | |
1179 | ||
c896fe29 | 1180 | /* Note: we assume the two high bytes are set to zero */ |
a7812ae4 | 1181 | static inline void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 FB |
1182 | { |
1183 | #ifdef TCG_TARGET_HAS_bswap16_i32 | |
a7812ae4 | 1184 | tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg); |
c896fe29 | 1185 | #else |
a7812ae4 PB |
1186 | TCGv_i32 t0, t1; |
1187 | t0 = tcg_temp_new_i32(); | |
1188 | t1 = tcg_temp_new_i32(); | |
c896fe29 FB |
1189 | |
1190 | tcg_gen_shri_i32(t0, arg, 8); | |
1191 | tcg_gen_andi_i32(t1, arg, 0x000000ff); | |
1192 | tcg_gen_shli_i32(t1, t1, 8); | |
1193 | tcg_gen_or_i32(ret, t0, t1); | |
a7812ae4 PB |
1194 | tcg_temp_free_i32(t0); |
1195 | tcg_temp_free_i32(t1); | |
c896fe29 FB |
1196 | #endif |
1197 | } | |
1198 | ||
a7812ae4 | 1199 | static inline void tcg_gen_bswap_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 FB |
1200 | { |
1201 | #ifdef TCG_TARGET_HAS_bswap_i32 | |
a7812ae4 | 1202 | tcg_gen_op2_i32(INDEX_op_bswap_i32, ret, arg); |
c896fe29 | 1203 | #else |
a7812ae4 PB |
1204 | TCGv_i32 t0, t1; |
1205 | t0 = tcg_temp_new_i32(); | |
1206 | t1 = tcg_temp_new_i32(); | |
c896fe29 FB |
1207 | |
1208 | tcg_gen_shli_i32(t0, arg, 24); | |
1209 | ||
1210 | tcg_gen_andi_i32(t1, arg, 0x0000ff00); | |
1211 | tcg_gen_shli_i32(t1, t1, 8); | |
1212 | tcg_gen_or_i32(t0, t0, t1); | |
1213 | ||
1214 | tcg_gen_shri_i32(t1, arg, 8); | |
1215 | tcg_gen_andi_i32(t1, t1, 0x0000ff00); | |
1216 | tcg_gen_or_i32(t0, t0, t1); | |
1217 | ||
1218 | tcg_gen_shri_i32(t1, arg, 24); | |
1219 | tcg_gen_or_i32(ret, t0, t1); | |
a7812ae4 PB |
1220 | tcg_temp_free_i32(t0); |
1221 | tcg_temp_free_i32(t1); | |
c896fe29 FB |
1222 | #endif |
1223 | } | |
1224 | ||
1225 | #if TCG_TARGET_REG_BITS == 32 | |
a7812ae4 | 1226 | static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1227 | { |
a7812ae4 PB |
1228 | tcg_gen_ext8s_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
1229 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1230 | } |
1231 | ||
a7812ae4 | 1232 | static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1233 | { |
a7812ae4 PB |
1234 | tcg_gen_ext16s_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
1235 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1236 | } |
1237 | ||
a7812ae4 | 1238 | static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1239 | { |
a7812ae4 PB |
1240 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
1241 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1242 | } |
1243 | ||
a7812ae4 | 1244 | static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1245 | { |
a7812ae4 | 1246 | tcg_gen_ext8u_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
86831435 PB |
1247 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
1248 | } | |
1249 | ||
a7812ae4 | 1250 | static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1251 | { |
a7812ae4 | 1252 | tcg_gen_ext16u_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
86831435 PB |
1253 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
1254 | } | |
1255 | ||
a7812ae4 | 1256 | static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1257 | { |
a7812ae4 | 1258 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
86831435 PB |
1259 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
1260 | } | |
1261 | ||
a7812ae4 | 1262 | static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg) |
c896fe29 | 1263 | { |
a7812ae4 | 1264 | tcg_gen_mov_i32(ret, TCGV_LOW(arg)); |
c896fe29 FB |
1265 | } |
1266 | ||
a7812ae4 | 1267 | static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1268 | { |
a7812ae4 | 1269 | tcg_gen_mov_i32(TCGV_LOW(ret), arg); |
ac56dd48 | 1270 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
1271 | } |
1272 | ||
a7812ae4 | 1273 | static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1274 | { |
a7812ae4 PB |
1275 | tcg_gen_mov_i32(TCGV_LOW(ret), arg); |
1276 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1277 | } |
1278 | ||
a7812ae4 | 1279 | static inline void tcg_gen_bswap_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1280 | { |
a7812ae4 PB |
1281 | TCGv_i32 t0, t1; |
1282 | t0 = tcg_temp_new_i32(); | |
1283 | t1 = tcg_temp_new_i32(); | |
c896fe29 | 1284 | |
a7812ae4 | 1285 | tcg_gen_bswap_i32(t0, TCGV_LOW(arg)); |
ac56dd48 | 1286 | tcg_gen_bswap_i32(t1, TCGV_HIGH(arg)); |
a7812ae4 | 1287 | tcg_gen_mov_i32(TCGV_LOW(ret), t1); |
ac56dd48 | 1288 | tcg_gen_mov_i32(TCGV_HIGH(ret), t0); |
a7812ae4 PB |
1289 | tcg_temp_free_i32(t0); |
1290 | tcg_temp_free_i32(t1); | |
c896fe29 FB |
1291 | } |
1292 | #else | |
1293 | ||
a7812ae4 | 1294 | static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 FB |
1295 | { |
1296 | #ifdef TCG_TARGET_HAS_ext8s_i64 | |
a7812ae4 | 1297 | tcg_gen_op2_i64(INDEX_op_ext8s_i64, ret, arg); |
c896fe29 FB |
1298 | #else |
1299 | tcg_gen_shli_i64(ret, arg, 56); | |
5ff9d6a4 | 1300 | tcg_gen_sari_i64(ret, ret, 56); |
c896fe29 FB |
1301 | #endif |
1302 | } | |
1303 | ||
a7812ae4 | 1304 | static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 FB |
1305 | { |
1306 | #ifdef TCG_TARGET_HAS_ext16s_i64 | |
a7812ae4 | 1307 | tcg_gen_op2_i64(INDEX_op_ext16s_i64, ret, arg); |
c896fe29 FB |
1308 | #else |
1309 | tcg_gen_shli_i64(ret, arg, 48); | |
5ff9d6a4 | 1310 | tcg_gen_sari_i64(ret, ret, 48); |
c896fe29 FB |
1311 | #endif |
1312 | } | |
1313 | ||
a7812ae4 | 1314 | static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 FB |
1315 | { |
1316 | #ifdef TCG_TARGET_HAS_ext32s_i64 | |
a7812ae4 | 1317 | tcg_gen_op2_i64(INDEX_op_ext32s_i64, ret, arg); |
c896fe29 FB |
1318 | #else |
1319 | tcg_gen_shli_i64(ret, arg, 32); | |
5ff9d6a4 | 1320 | tcg_gen_sari_i64(ret, ret, 32); |
c896fe29 FB |
1321 | #endif |
1322 | } | |
1323 | ||
a7812ae4 | 1324 | static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 PB |
1325 | { |
1326 | tcg_gen_andi_i64(ret, arg, 0xffu); | |
1327 | } | |
1328 | ||
a7812ae4 | 1329 | static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 PB |
1330 | { |
1331 | tcg_gen_andi_i64(ret, arg, 0xffffu); | |
1332 | } | |
1333 | ||
a7812ae4 | 1334 | static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 PB |
1335 | { |
1336 | tcg_gen_andi_i64(ret, arg, 0xffffffffu); | |
1337 | } | |
1338 | ||
c896fe29 | 1339 | /* Note: we assume the target supports move between 32 and 64 bit |
ac56dd48 | 1340 | registers. This will probably break MIPS64 targets. */ |
a7812ae4 | 1341 | static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg) |
c896fe29 | 1342 | { |
a7812ae4 | 1343 | tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg))); |
c896fe29 FB |
1344 | } |
1345 | ||
1346 | /* Note: we assume the target supports move between 32 and 64 bit | |
1347 | registers */ | |
a7812ae4 | 1348 | static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1349 | { |
a7812ae4 | 1350 | tcg_gen_andi_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)), 0xffffffffu); |
c896fe29 FB |
1351 | } |
1352 | ||
1353 | /* Note: we assume the target supports move between 32 and 64 bit | |
1354 | registers */ | |
a7812ae4 | 1355 | static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1356 | { |
a7812ae4 | 1357 | tcg_gen_ext32s_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg))); |
c896fe29 FB |
1358 | } |
1359 | ||
a7812ae4 | 1360 | static inline void tcg_gen_bswap_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 FB |
1361 | { |
1362 | #ifdef TCG_TARGET_HAS_bswap_i64 | |
a7812ae4 | 1363 | tcg_gen_op2_i64(INDEX_op_bswap_i64, ret, arg); |
c896fe29 | 1364 | #else |
a7812ae4 PB |
1365 | TCGv_i32 t0, t1; |
1366 | t0 = tcg_temp_new_i32(); | |
1367 | t1 = tcg_temp_new_i32(); | |
c896fe29 FB |
1368 | |
1369 | tcg_gen_shli_i64(t0, arg, 56); | |
1370 | ||
1371 | tcg_gen_andi_i64(t1, arg, 0x0000ff00); | |
1372 | tcg_gen_shli_i64(t1, t1, 40); | |
1373 | tcg_gen_or_i64(t0, t0, t1); | |
1374 | ||
1375 | tcg_gen_andi_i64(t1, arg, 0x00ff0000); | |
1376 | tcg_gen_shli_i64(t1, t1, 24); | |
1377 | tcg_gen_or_i64(t0, t0, t1); | |
1378 | ||
1379 | tcg_gen_andi_i64(t1, arg, 0xff000000); | |
1380 | tcg_gen_shli_i64(t1, t1, 8); | |
1381 | tcg_gen_or_i64(t0, t0, t1); | |
1382 | ||
1383 | tcg_gen_shri_i64(t1, arg, 8); | |
1384 | tcg_gen_andi_i64(t1, t1, 0xff000000); | |
1385 | tcg_gen_or_i64(t0, t0, t1); | |
1386 | ||
1387 | tcg_gen_shri_i64(t1, arg, 24); | |
1388 | tcg_gen_andi_i64(t1, t1, 0x00ff0000); | |
1389 | tcg_gen_or_i64(t0, t0, t1); | |
1390 | ||
1391 | tcg_gen_shri_i64(t1, arg, 40); | |
1392 | tcg_gen_andi_i64(t1, t1, 0x0000ff00); | |
1393 | tcg_gen_or_i64(t0, t0, t1); | |
1394 | ||
1395 | tcg_gen_shri_i64(t1, arg, 56); | |
1396 | tcg_gen_or_i64(ret, t0, t1); | |
a7812ae4 PB |
1397 | tcg_temp_free_i32(t0); |
1398 | tcg_temp_free_i32(t1); | |
c896fe29 FB |
1399 | #endif |
1400 | } | |
1401 | ||
1402 | #endif | |
1403 | ||
a7812ae4 | 1404 | static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg) |
390efc54 PB |
1405 | { |
1406 | #ifdef TCG_TARGET_HAS_neg_i32 | |
a7812ae4 | 1407 | tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg); |
390efc54 | 1408 | #else |
a7812ae4 | 1409 | TCGv_i32 t0 = tcg_const_i32(0); |
e8996ee0 | 1410 | tcg_gen_sub_i32(ret, t0, arg); |
a7812ae4 | 1411 | tcg_temp_free_i32(t0); |
390efc54 PB |
1412 | #endif |
1413 | } | |
1414 | ||
a7812ae4 | 1415 | static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg) |
390efc54 PB |
1416 | { |
1417 | #ifdef TCG_TARGET_HAS_neg_i64 | |
a7812ae4 | 1418 | tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg); |
390efc54 | 1419 | #else |
a7812ae4 | 1420 | TCGv_i64 t0 = tcg_const_i64(0); |
e8996ee0 | 1421 | tcg_gen_sub_i64(ret, t0, arg); |
a7812ae4 | 1422 | tcg_temp_free_i64(t0); |
390efc54 PB |
1423 | #endif |
1424 | } | |
1425 | ||
a7812ae4 | 1426 | static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg) |
0b6ce4cf | 1427 | { |
e8996ee0 | 1428 | tcg_gen_xori_i32(ret, arg, -1); |
0b6ce4cf FB |
1429 | } |
1430 | ||
a7812ae4 | 1431 | static inline void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg) |
0b6ce4cf | 1432 | { |
e8996ee0 | 1433 | tcg_gen_xori_i64(ret, arg, -1); |
0b6ce4cf | 1434 | } |
5ff9d6a4 | 1435 | |
a7812ae4 | 1436 | static inline void tcg_gen_discard_i32(TCGv_i32 arg) |
5ff9d6a4 | 1437 | { |
a7812ae4 | 1438 | tcg_gen_op1_i32(INDEX_op_discard, arg); |
5ff9d6a4 FB |
1439 | } |
1440 | ||
1441 | #if TCG_TARGET_REG_BITS == 32 | |
a7812ae4 | 1442 | static inline void tcg_gen_discard_i64(TCGv_i64 arg) |
5ff9d6a4 | 1443 | { |
a7812ae4 | 1444 | tcg_gen_discard_i32(TCGV_LOW(arg)); |
5ff9d6a4 FB |
1445 | tcg_gen_discard_i32(TCGV_HIGH(arg)); |
1446 | } | |
1447 | #else | |
a7812ae4 | 1448 | static inline void tcg_gen_discard_i64(TCGv_i64 arg) |
5ff9d6a4 | 1449 | { |
a7812ae4 | 1450 | tcg_gen_op1_i64(INDEX_op_discard, arg); |
5ff9d6a4 FB |
1451 | } |
1452 | #endif | |
1453 | ||
a7812ae4 | 1454 | static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high) |
36aa55dc PB |
1455 | { |
1456 | #if TCG_TARGET_REG_BITS == 32 | |
a7812ae4 | 1457 | tcg_gen_mov_i32(TCGV_LOW(dest), low); |
36aa55dc PB |
1458 | tcg_gen_mov_i32(TCGV_HIGH(dest), high); |
1459 | #else | |
a7812ae4 | 1460 | TCGv_i64 tmp = tcg_temp_new_i64(); |
36aa55dc PB |
1461 | /* This extension is only needed for type correctness. |
1462 | We may be able to do better given target specific information. */ | |
1463 | tcg_gen_extu_i32_i64(tmp, high); | |
1464 | tcg_gen_shli_i64(tmp, tmp, 32); | |
1465 | tcg_gen_extu_i32_i64(dest, low); | |
1466 | tcg_gen_or_i64(dest, dest, tmp); | |
a7812ae4 | 1467 | tcg_temp_free_i64(tmp); |
36aa55dc PB |
1468 | #endif |
1469 | } | |
1470 | ||
a7812ae4 | 1471 | static inline void tcg_gen_concat32_i64(TCGv_i64 dest, TCGv_i64 low, TCGv_i64 high) |
945ca823 BS |
1472 | { |
1473 | #if TCG_TARGET_REG_BITS == 32 | |
a7812ae4 | 1474 | tcg_gen_concat_i32_i64(dest, TCGV_LOW(low), TCGV_LOW(high)); |
945ca823 | 1475 | #else |
a7812ae4 | 1476 | TCGv_i64 tmp = tcg_temp_new_i64(); |
88422e2e | 1477 | tcg_gen_ext32u_i64(dest, low); |
945ca823 | 1478 | tcg_gen_shli_i64(tmp, high, 32); |
88422e2e | 1479 | tcg_gen_or_i64(dest, dest, tmp); |
a7812ae4 | 1480 | tcg_temp_free_i64(tmp); |
945ca823 BS |
1481 | #endif |
1482 | } | |
1483 | ||
a7812ae4 | 1484 | static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1485 | { |
a7812ae4 PB |
1486 | TCGv_i32 t0; |
1487 | t0 = tcg_temp_new_i32(); | |
f24cb33e AJ |
1488 | tcg_gen_not_i32(t0, arg2); |
1489 | tcg_gen_and_i32(ret, arg1, t0); | |
a7812ae4 | 1490 | tcg_temp_free_i32(t0); |
f24cb33e AJ |
1491 | } |
1492 | ||
a7812ae4 | 1493 | static inline void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1494 | { |
a7812ae4 PB |
1495 | TCGv_i64 t0; |
1496 | t0 = tcg_temp_new_i64(); | |
f24cb33e AJ |
1497 | tcg_gen_not_i64(t0, arg2); |
1498 | tcg_gen_and_i64(ret, arg1, t0); | |
a7812ae4 | 1499 | tcg_temp_free_i64(t0); |
f24cb33e AJ |
1500 | } |
1501 | ||
a7812ae4 | 1502 | static inline void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1503 | { |
a7812ae4 PB |
1504 | TCGv_i32 t0; |
1505 | t0 = tcg_temp_new_i32(); | |
f24cb33e AJ |
1506 | tcg_gen_xor_i32(t0, arg1, arg2); |
1507 | tcg_gen_not_i32(ret, t0); | |
a7812ae4 | 1508 | tcg_temp_free_i32(t0); |
f24cb33e AJ |
1509 | } |
1510 | ||
a7812ae4 | 1511 | static inline void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1512 | { |
a7812ae4 PB |
1513 | TCGv_i64 t0; |
1514 | t0 = tcg_temp_new_i64(); | |
f24cb33e AJ |
1515 | tcg_gen_xor_i64(t0, arg1, arg2); |
1516 | tcg_gen_not_i64(ret, t0); | |
a7812ae4 | 1517 | tcg_temp_free_i64(t0); |
f24cb33e AJ |
1518 | } |
1519 | ||
a7812ae4 | 1520 | static inline void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1521 | { |
a7812ae4 PB |
1522 | TCGv_i32 t0; |
1523 | t0 = tcg_temp_new_i32(); | |
f24cb33e AJ |
1524 | tcg_gen_and_i32(t0, arg1, arg2); |
1525 | tcg_gen_not_i32(ret, t0); | |
a7812ae4 | 1526 | tcg_temp_free_i32(t0); |
f24cb33e AJ |
1527 | } |
1528 | ||
a7812ae4 | 1529 | static inline void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1530 | { |
a7812ae4 PB |
1531 | TCGv_i64 t0; |
1532 | t0 = tcg_temp_new_i64(); | |
f24cb33e AJ |
1533 | tcg_gen_and_i64(t0, arg1, arg2); |
1534 | tcg_gen_not_i64(ret, t0); | |
a7812ae4 | 1535 | tcg_temp_free_i64(t0); |
f24cb33e AJ |
1536 | } |
1537 | ||
a7812ae4 | 1538 | static inline void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1539 | { |
a7812ae4 PB |
1540 | TCGv_i32 t0; |
1541 | t0 = tcg_temp_new_i32(); | |
f24cb33e AJ |
1542 | tcg_gen_or_i32(t0, arg1, arg2); |
1543 | tcg_gen_not_i32(ret, t0); | |
a7812ae4 | 1544 | tcg_temp_free_i32(t0); |
f24cb33e AJ |
1545 | } |
1546 | ||
a7812ae4 | 1547 | static inline void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1548 | { |
a7812ae4 PB |
1549 | TCGv_i64 t0; |
1550 | t0 = tcg_temp_new_i64(); | |
f24cb33e AJ |
1551 | tcg_gen_or_i64(t0, arg1, arg2); |
1552 | tcg_gen_not_i64(ret, t0); | |
a7812ae4 | 1553 | tcg_temp_free_i64(t0); |
f24cb33e AJ |
1554 | } |
1555 | ||
a7812ae4 | 1556 | static inline void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1557 | { |
a7812ae4 PB |
1558 | TCGv_i32 t0; |
1559 | t0 = tcg_temp_new_i32(); | |
f24cb33e AJ |
1560 | tcg_gen_not_i32(t0, arg2); |
1561 | tcg_gen_or_i32(ret, arg1, t0); | |
a7812ae4 | 1562 | tcg_temp_free_i32(t0); |
f24cb33e AJ |
1563 | } |
1564 | ||
a7812ae4 | 1565 | static inline void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1566 | { |
a7812ae4 PB |
1567 | TCGv_i64 t0; |
1568 | t0 = tcg_temp_new_i64(); | |
f24cb33e AJ |
1569 | tcg_gen_not_i64(t0, arg2); |
1570 | tcg_gen_or_i64(ret, arg1, t0); | |
a7812ae4 | 1571 | tcg_temp_free_i64(t0); |
f24cb33e AJ |
1572 | } |
1573 | ||
a7812ae4 | 1574 | static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
15824571 | 1575 | { |
a7812ae4 | 1576 | TCGv_i32 t0, t1; |
15824571 | 1577 | |
a7812ae4 PB |
1578 | t0 = tcg_temp_new_i32(); |
1579 | t1 = tcg_temp_new_i32(); | |
15824571 AJ |
1580 | tcg_gen_shl_i32(t0, arg1, arg2); |
1581 | tcg_gen_subfi_i32(t1, 32, arg2); | |
1582 | tcg_gen_shr_i32(t1, arg1, t1); | |
1583 | tcg_gen_or_i32(ret, t0, t1); | |
a7812ae4 PB |
1584 | tcg_temp_free_i32(t0); |
1585 | tcg_temp_free_i32(t1); | |
15824571 AJ |
1586 | } |
1587 | ||
a7812ae4 | 1588 | static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
15824571 | 1589 | { |
a7812ae4 | 1590 | TCGv_i64 t0, t1; |
15824571 | 1591 | |
a7812ae4 PB |
1592 | t0 = tcg_temp_new_i64(); |
1593 | t1 = tcg_temp_new_i64(); | |
15824571 AJ |
1594 | tcg_gen_shl_i64(t0, arg1, arg2); |
1595 | tcg_gen_subfi_i64(t1, 64, arg2); | |
1596 | tcg_gen_shr_i64(t1, arg1, t1); | |
1597 | tcg_gen_or_i64(ret, t0, t1); | |
a7812ae4 PB |
1598 | tcg_temp_free_i64(t0); |
1599 | tcg_temp_free_i64(t1); | |
15824571 AJ |
1600 | } |
1601 | ||
a7812ae4 | 1602 | static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
15824571 AJ |
1603 | { |
1604 | /* some cases can be optimized here */ | |
1605 | if (arg2 == 0) { | |
1606 | tcg_gen_mov_i32(ret, arg1); | |
1607 | } else { | |
a7812ae4 PB |
1608 | TCGv_i32 t0, t1; |
1609 | t0 = tcg_temp_new_i32(); | |
1610 | t1 = tcg_temp_new_i32(); | |
15824571 AJ |
1611 | tcg_gen_shli_i32(t0, arg1, arg2); |
1612 | tcg_gen_shri_i32(t1, arg1, 32 - arg2); | |
1613 | tcg_gen_or_i32(ret, t0, t1); | |
a7812ae4 PB |
1614 | tcg_temp_free_i32(t0); |
1615 | tcg_temp_free_i32(t1); | |
15824571 AJ |
1616 | } |
1617 | } | |
1618 | ||
a7812ae4 | 1619 | static inline void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
15824571 AJ |
1620 | { |
1621 | /* some cases can be optimized here */ | |
1622 | if (arg2 == 0) { | |
1623 | tcg_gen_mov_i64(ret, arg1); | |
1624 | } else { | |
a7812ae4 PB |
1625 | TCGv_i64 t0, t1; |
1626 | t0 = tcg_temp_new_i64(); | |
1627 | t1 = tcg_temp_new_i64(); | |
15824571 AJ |
1628 | tcg_gen_shli_i64(t0, arg1, arg2); |
1629 | tcg_gen_shri_i64(t1, arg1, 64 - arg2); | |
1630 | tcg_gen_or_i64(ret, t0, t1); | |
a7812ae4 PB |
1631 | tcg_temp_free_i64(t0); |
1632 | tcg_temp_free_i64(t1); | |
15824571 AJ |
1633 | } |
1634 | } | |
1635 | ||
a7812ae4 | 1636 | static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
15824571 | 1637 | { |
a7812ae4 | 1638 | TCGv_i32 t0, t1; |
15824571 | 1639 | |
a7812ae4 PB |
1640 | t0 = tcg_temp_new_i32(); |
1641 | t1 = tcg_temp_new_i32(); | |
15824571 AJ |
1642 | tcg_gen_shr_i32(t0, arg1, arg2); |
1643 | tcg_gen_subfi_i32(t1, 32, arg2); | |
1644 | tcg_gen_shl_i32(t1, arg1, t1); | |
1645 | tcg_gen_or_i32(ret, t0, t1); | |
a7812ae4 PB |
1646 | tcg_temp_free_i32(t0); |
1647 | tcg_temp_free_i32(t1); | |
15824571 AJ |
1648 | } |
1649 | ||
a7812ae4 | 1650 | static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
15824571 | 1651 | { |
a7812ae4 | 1652 | TCGv_i64 t0, t1; |
15824571 | 1653 | |
a7812ae4 PB |
1654 | t0 = tcg_temp_new_i64(); |
1655 | t1 = tcg_temp_new_i64(); | |
15824571 AJ |
1656 | tcg_gen_shl_i64(t0, arg1, arg2); |
1657 | tcg_gen_subfi_i64(t1, 64, arg2); | |
1658 | tcg_gen_shl_i64(t1, arg1, t1); | |
1659 | tcg_gen_or_i64(ret, t0, t1); | |
a7812ae4 PB |
1660 | tcg_temp_free_i64(t0); |
1661 | tcg_temp_free_i64(t1); | |
15824571 AJ |
1662 | } |
1663 | ||
a7812ae4 | 1664 | static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
15824571 AJ |
1665 | { |
1666 | /* some cases can be optimized here */ | |
1667 | if (arg2 == 0) { | |
1668 | tcg_gen_mov_i32(ret, arg1); | |
1669 | } else { | |
1670 | tcg_gen_rotli_i32(ret, arg1, 32 - arg2); | |
1671 | } | |
1672 | } | |
1673 | ||
a7812ae4 | 1674 | static inline void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
15824571 AJ |
1675 | { |
1676 | /* some cases can be optimized here */ | |
1677 | if (arg2 == 0) { | |
de3526b2 | 1678 | tcg_gen_mov_i64(ret, arg1); |
15824571 AJ |
1679 | } else { |
1680 | tcg_gen_rotli_i64(ret, arg1, 64 - arg2); | |
1681 | } | |
1682 | } | |
1683 | ||
c896fe29 FB |
1684 | /***************************************/ |
1685 | /* QEMU specific operations. Their type depend on the QEMU CPU | |
1686 | type. */ | |
1687 | #ifndef TARGET_LONG_BITS | |
1688 | #error must include QEMU headers | |
1689 | #endif | |
1690 | ||
a7812ae4 PB |
1691 | #if TARGET_LONG_BITS == 32 |
1692 | #define TCGv TCGv_i32 | |
1693 | #define tcg_temp_new() tcg_temp_new_i32() | |
1694 | #define tcg_global_reg_new tcg_global_reg_new_i32 | |
1695 | #define tcg_global_mem_new tcg_global_mem_new_i32 | |
df9247b2 | 1696 | #define tcg_temp_local_new() tcg_temp_local_new_i32() |
a7812ae4 PB |
1697 | #define tcg_temp_free tcg_temp_free_i32 |
1698 | #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32 | |
1699 | #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32 | |
1700 | #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x) | |
1701 | #define TCGV_EQUAL(a, b) (GET_TCGV_I32(a) == GET_TCGV_I32(b)) | |
1702 | #else | |
1703 | #define TCGv TCGv_i64 | |
1704 | #define tcg_temp_new() tcg_temp_new_i64() | |
1705 | #define tcg_global_reg_new tcg_global_reg_new_i64 | |
1706 | #define tcg_global_mem_new tcg_global_mem_new_i64 | |
df9247b2 | 1707 | #define tcg_temp_local_new() tcg_temp_local_new_i64() |
a7812ae4 PB |
1708 | #define tcg_temp_free tcg_temp_free_i64 |
1709 | #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64 | |
1710 | #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64 | |
1711 | #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x) | |
1712 | #define TCGV_EQUAL(a, b) (GET_TCGV_I64(a) == GET_TCGV_I64(b)) | |
1713 | #endif | |
1714 | ||
7e4597d7 FB |
1715 | /* debug info: write the PC of the corresponding QEMU CPU instruction */ |
1716 | static inline void tcg_gen_debug_insn_start(uint64_t pc) | |
1717 | { | |
1718 | /* XXX: must really use a 32 bit size for TCGArg in all cases */ | |
1719 | #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS | |
bcb0126f PB |
1720 | tcg_gen_op2ii(INDEX_op_debug_insn_start, |
1721 | (uint32_t)(pc), (uint32_t)(pc >> 32)); | |
7e4597d7 FB |
1722 | #else |
1723 | tcg_gen_op1i(INDEX_op_debug_insn_start, pc); | |
1724 | #endif | |
1725 | } | |
1726 | ||
c896fe29 FB |
1727 | static inline void tcg_gen_exit_tb(tcg_target_long val) |
1728 | { | |
ac56dd48 | 1729 | tcg_gen_op1i(INDEX_op_exit_tb, val); |
c896fe29 FB |
1730 | } |
1731 | ||
1732 | static inline void tcg_gen_goto_tb(int idx) | |
1733 | { | |
ac56dd48 | 1734 | tcg_gen_op1i(INDEX_op_goto_tb, idx); |
c896fe29 FB |
1735 | } |
1736 | ||
1737 | #if TCG_TARGET_REG_BITS == 32 | |
ac56dd48 | 1738 | static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
1739 | { |
1740 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1741 | tcg_gen_op3i_i32(INDEX_op_qemu_ld8u, ret, addr, mem_index); |
c896fe29 | 1742 | #else |
a7812ae4 PB |
1743 | tcg_gen_op4i_i32(INDEX_op_qemu_ld8u, TCGV_LOW(ret), TCGV_LOW(addr), |
1744 | TCGV_HIGH(addr), mem_index); | |
ac56dd48 | 1745 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
1746 | #endif |
1747 | } | |
1748 | ||
ac56dd48 | 1749 | static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
1750 | { |
1751 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1752 | tcg_gen_op3i_i32(INDEX_op_qemu_ld8s, ret, addr, mem_index); |
c896fe29 | 1753 | #else |
a7812ae4 PB |
1754 | tcg_gen_op4i_i32(INDEX_op_qemu_ld8s, TCGV_LOW(ret), TCGV_LOW(addr), |
1755 | TCGV_HIGH(addr), mem_index); | |
1756 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1757 | #endif |
1758 | } | |
1759 | ||
ac56dd48 | 1760 | static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
1761 | { |
1762 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1763 | tcg_gen_op3i_i32(INDEX_op_qemu_ld16u, ret, addr, mem_index); |
c896fe29 | 1764 | #else |
a7812ae4 PB |
1765 | tcg_gen_op4i_i32(INDEX_op_qemu_ld16u, TCGV_LOW(ret), TCGV_LOW(addr), |
1766 | TCGV_HIGH(addr), mem_index); | |
ac56dd48 | 1767 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
1768 | #endif |
1769 | } | |
1770 | ||
ac56dd48 | 1771 | static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
1772 | { |
1773 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1774 | tcg_gen_op3i_i32(INDEX_op_qemu_ld16s, ret, addr, mem_index); |
c896fe29 | 1775 | #else |
a7812ae4 PB |
1776 | tcg_gen_op4i_i32(INDEX_op_qemu_ld16s, TCGV_LOW(ret), TCGV_LOW(addr), |
1777 | TCGV_HIGH(addr), mem_index); | |
1778 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1779 | #endif |
1780 | } | |
1781 | ||
ac56dd48 | 1782 | static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
1783 | { |
1784 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1785 | tcg_gen_op3i_i32(INDEX_op_qemu_ld32u, ret, addr, mem_index); |
c896fe29 | 1786 | #else |
a7812ae4 PB |
1787 | tcg_gen_op4i_i32(INDEX_op_qemu_ld32u, TCGV_LOW(ret), TCGV_LOW(addr), |
1788 | TCGV_HIGH(addr), mem_index); | |
ac56dd48 | 1789 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
1790 | #endif |
1791 | } | |
1792 | ||
ac56dd48 | 1793 | static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
1794 | { |
1795 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1796 | tcg_gen_op3i_i32(INDEX_op_qemu_ld32u, ret, addr, mem_index); |
c896fe29 | 1797 | #else |
a7812ae4 PB |
1798 | tcg_gen_op4i_i32(INDEX_op_qemu_ld32u, TCGV_LOW(ret), TCGV_LOW(addr), |
1799 | TCGV_HIGH(addr), mem_index); | |
1800 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1801 | #endif |
1802 | } | |
1803 | ||
a7812ae4 | 1804 | static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index) |
c896fe29 FB |
1805 | { |
1806 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1807 | tcg_gen_op4i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), addr, mem_index); |
c896fe29 | 1808 | #else |
a7812ae4 PB |
1809 | tcg_gen_op5i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), |
1810 | TCGV_LOW(addr), TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
1811 | #endif |
1812 | } | |
1813 | ||
ac56dd48 | 1814 | static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) |
c896fe29 FB |
1815 | { |
1816 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1817 | tcg_gen_op3i_i32(INDEX_op_qemu_st8, arg, addr, mem_index); |
c896fe29 | 1818 | #else |
a7812ae4 PB |
1819 | tcg_gen_op4i_i32(INDEX_op_qemu_st8, TCGV_LOW(arg), TCGV_LOW(addr), |
1820 | TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
1821 | #endif |
1822 | } | |
1823 | ||
ac56dd48 | 1824 | static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) |
c896fe29 FB |
1825 | { |
1826 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1827 | tcg_gen_op3i_i32(INDEX_op_qemu_st16, arg, addr, mem_index); |
c896fe29 | 1828 | #else |
a7812ae4 PB |
1829 | tcg_gen_op4i_i32(INDEX_op_qemu_st16, TCGV_LOW(arg), TCGV_LOW(addr), |
1830 | TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
1831 | #endif |
1832 | } | |
1833 | ||
ac56dd48 | 1834 | static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) |
c896fe29 FB |
1835 | { |
1836 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 1837 | tcg_gen_op3i_i32(INDEX_op_qemu_st32, arg, addr, mem_index); |
c896fe29 | 1838 | #else |
a7812ae4 PB |
1839 | tcg_gen_op4i_i32(INDEX_op_qemu_st32, TCGV_LOW(arg), TCGV_LOW(addr), |
1840 | TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
1841 | #endif |
1842 | } | |
1843 | ||
a7812ae4 | 1844 | static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) |
c896fe29 FB |
1845 | { |
1846 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 PB |
1847 | tcg_gen_op4i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), addr, |
1848 | mem_index); | |
c896fe29 | 1849 | #else |
a7812ae4 PB |
1850 | tcg_gen_op5i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), |
1851 | TCGV_LOW(addr), TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
1852 | #endif |
1853 | } | |
1854 | ||
56b8f567 | 1855 | #define tcg_gen_ld_ptr tcg_gen_ld_i32 |
a768e4b2 | 1856 | #define tcg_gen_discard_ptr tcg_gen_discard_i32 |
f8422f52 | 1857 | |
c896fe29 FB |
1858 | #else /* TCG_TARGET_REG_BITS == 32 */ |
1859 | ||
ac56dd48 | 1860 | static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 1861 | { |
a7812ae4 | 1862 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u, ret, addr, mem_index); |
c896fe29 FB |
1863 | } |
1864 | ||
ac56dd48 | 1865 | static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 1866 | { |
a7812ae4 | 1867 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s, ret, addr, mem_index); |
c896fe29 FB |
1868 | } |
1869 | ||
ac56dd48 | 1870 | static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 1871 | { |
a7812ae4 | 1872 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u, ret, addr, mem_index); |
c896fe29 FB |
1873 | } |
1874 | ||
ac56dd48 | 1875 | static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 1876 | { |
a7812ae4 | 1877 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s, ret, addr, mem_index); |
c896fe29 FB |
1878 | } |
1879 | ||
ac56dd48 | 1880 | static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 1881 | { |
a7812ae4 | 1882 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u, ret, addr, mem_index); |
c896fe29 FB |
1883 | } |
1884 | ||
ac56dd48 | 1885 | static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 1886 | { |
a7812ae4 | 1887 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s, ret, addr, mem_index); |
c896fe29 FB |
1888 | } |
1889 | ||
a7812ae4 | 1890 | static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index) |
c896fe29 | 1891 | { |
a7812ae4 | 1892 | tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64, ret, addr, mem_index); |
c896fe29 FB |
1893 | } |
1894 | ||
ac56dd48 | 1895 | static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) |
c896fe29 | 1896 | { |
a7812ae4 | 1897 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8, arg, addr, mem_index); |
c896fe29 FB |
1898 | } |
1899 | ||
ac56dd48 | 1900 | static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) |
c896fe29 | 1901 | { |
a7812ae4 | 1902 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16, arg, addr, mem_index); |
c896fe29 FB |
1903 | } |
1904 | ||
ac56dd48 | 1905 | static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) |
c896fe29 | 1906 | { |
a7812ae4 | 1907 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32, arg, addr, mem_index); |
c896fe29 FB |
1908 | } |
1909 | ||
a7812ae4 | 1910 | static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) |
c896fe29 | 1911 | { |
a7812ae4 | 1912 | tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64, arg, addr, mem_index); |
c896fe29 FB |
1913 | } |
1914 | ||
56b8f567 | 1915 | #define tcg_gen_ld_ptr tcg_gen_ld_i64 |
a768e4b2 | 1916 | #define tcg_gen_discard_ptr tcg_gen_discard_i64 |
f8422f52 | 1917 | |
c896fe29 | 1918 | #endif /* TCG_TARGET_REG_BITS != 32 */ |
f8422f52 BS |
1919 | |
1920 | #if TARGET_LONG_BITS == 64 | |
1921 | #define TCG_TYPE_TL TCG_TYPE_I64 | |
1922 | #define tcg_gen_movi_tl tcg_gen_movi_i64 | |
1923 | #define tcg_gen_mov_tl tcg_gen_mov_i64 | |
1924 | #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64 | |
1925 | #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64 | |
1926 | #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64 | |
1927 | #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64 | |
1928 | #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64 | |
1929 | #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64 | |
1930 | #define tcg_gen_ld_tl tcg_gen_ld_i64 | |
1931 | #define tcg_gen_st8_tl tcg_gen_st8_i64 | |
1932 | #define tcg_gen_st16_tl tcg_gen_st16_i64 | |
1933 | #define tcg_gen_st32_tl tcg_gen_st32_i64 | |
1934 | #define tcg_gen_st_tl tcg_gen_st_i64 | |
1935 | #define tcg_gen_add_tl tcg_gen_add_i64 | |
1936 | #define tcg_gen_addi_tl tcg_gen_addi_i64 | |
1937 | #define tcg_gen_sub_tl tcg_gen_sub_i64 | |
390efc54 | 1938 | #define tcg_gen_neg_tl tcg_gen_neg_i64 |
10460c8a | 1939 | #define tcg_gen_subfi_tl tcg_gen_subfi_i64 |
f8422f52 BS |
1940 | #define tcg_gen_subi_tl tcg_gen_subi_i64 |
1941 | #define tcg_gen_and_tl tcg_gen_and_i64 | |
1942 | #define tcg_gen_andi_tl tcg_gen_andi_i64 | |
1943 | #define tcg_gen_or_tl tcg_gen_or_i64 | |
1944 | #define tcg_gen_ori_tl tcg_gen_ori_i64 | |
1945 | #define tcg_gen_xor_tl tcg_gen_xor_i64 | |
1946 | #define tcg_gen_xori_tl tcg_gen_xori_i64 | |
0b6ce4cf | 1947 | #define tcg_gen_not_tl tcg_gen_not_i64 |
f8422f52 BS |
1948 | #define tcg_gen_shl_tl tcg_gen_shl_i64 |
1949 | #define tcg_gen_shli_tl tcg_gen_shli_i64 | |
1950 | #define tcg_gen_shr_tl tcg_gen_shr_i64 | |
1951 | #define tcg_gen_shri_tl tcg_gen_shri_i64 | |
1952 | #define tcg_gen_sar_tl tcg_gen_sar_i64 | |
1953 | #define tcg_gen_sari_tl tcg_gen_sari_i64 | |
0cf767d6 | 1954 | #define tcg_gen_brcond_tl tcg_gen_brcond_i64 |
cb63669a | 1955 | #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64 |
f730fd27 TS |
1956 | #define tcg_gen_mul_tl tcg_gen_mul_i64 |
1957 | #define tcg_gen_muli_tl tcg_gen_muli_i64 | |
a768e4b2 | 1958 | #define tcg_gen_discard_tl tcg_gen_discard_i64 |
e429073d BS |
1959 | #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32 |
1960 | #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64 | |
1961 | #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64 | |
1962 | #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64 | |
1963 | #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64 | |
1964 | #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64 | |
0b6ce4cf FB |
1965 | #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64 |
1966 | #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64 | |
1967 | #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64 | |
1968 | #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64 | |
1969 | #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64 | |
1970 | #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64 | |
945ca823 | 1971 | #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64 |
f24cb33e AJ |
1972 | #define tcg_gen_andc_tl tcg_gen_andc_i64 |
1973 | #define tcg_gen_eqv_tl tcg_gen_eqv_i64 | |
1974 | #define tcg_gen_nand_tl tcg_gen_nand_i64 | |
1975 | #define tcg_gen_nor_tl tcg_gen_nor_i64 | |
1976 | #define tcg_gen_orc_tl tcg_gen_orc_i64 | |
15824571 AJ |
1977 | #define tcg_gen_rotl_tl tcg_gen_rotl_i64 |
1978 | #define tcg_gen_rotli_tl tcg_gen_rotli_i64 | |
1979 | #define tcg_gen_rotr_tl tcg_gen_rotr_i64 | |
1980 | #define tcg_gen_rotri_tl tcg_gen_rotri_i64 | |
a98824ac | 1981 | #define tcg_const_tl tcg_const_i64 |
bdffd4a9 | 1982 | #define tcg_const_local_tl tcg_const_local_i64 |
f8422f52 BS |
1983 | #else |
1984 | #define TCG_TYPE_TL TCG_TYPE_I32 | |
1985 | #define tcg_gen_movi_tl tcg_gen_movi_i32 | |
1986 | #define tcg_gen_mov_tl tcg_gen_mov_i32 | |
1987 | #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32 | |
1988 | #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32 | |
1989 | #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32 | |
1990 | #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32 | |
1991 | #define tcg_gen_ld32u_tl tcg_gen_ld_i32 | |
1992 | #define tcg_gen_ld32s_tl tcg_gen_ld_i32 | |
1993 | #define tcg_gen_ld_tl tcg_gen_ld_i32 | |
1994 | #define tcg_gen_st8_tl tcg_gen_st8_i32 | |
1995 | #define tcg_gen_st16_tl tcg_gen_st16_i32 | |
1996 | #define tcg_gen_st32_tl tcg_gen_st_i32 | |
1997 | #define tcg_gen_st_tl tcg_gen_st_i32 | |
1998 | #define tcg_gen_add_tl tcg_gen_add_i32 | |
1999 | #define tcg_gen_addi_tl tcg_gen_addi_i32 | |
2000 | #define tcg_gen_sub_tl tcg_gen_sub_i32 | |
390efc54 | 2001 | #define tcg_gen_neg_tl tcg_gen_neg_i32 |
0045734a | 2002 | #define tcg_gen_subfi_tl tcg_gen_subfi_i32 |
f8422f52 BS |
2003 | #define tcg_gen_subi_tl tcg_gen_subi_i32 |
2004 | #define tcg_gen_and_tl tcg_gen_and_i32 | |
2005 | #define tcg_gen_andi_tl tcg_gen_andi_i32 | |
2006 | #define tcg_gen_or_tl tcg_gen_or_i32 | |
2007 | #define tcg_gen_ori_tl tcg_gen_ori_i32 | |
2008 | #define tcg_gen_xor_tl tcg_gen_xor_i32 | |
2009 | #define tcg_gen_xori_tl tcg_gen_xori_i32 | |
0b6ce4cf | 2010 | #define tcg_gen_not_tl tcg_gen_not_i32 |
f8422f52 BS |
2011 | #define tcg_gen_shl_tl tcg_gen_shl_i32 |
2012 | #define tcg_gen_shli_tl tcg_gen_shli_i32 | |
2013 | #define tcg_gen_shr_tl tcg_gen_shr_i32 | |
2014 | #define tcg_gen_shri_tl tcg_gen_shri_i32 | |
2015 | #define tcg_gen_sar_tl tcg_gen_sar_i32 | |
2016 | #define tcg_gen_sari_tl tcg_gen_sari_i32 | |
0cf767d6 | 2017 | #define tcg_gen_brcond_tl tcg_gen_brcond_i32 |
cb63669a | 2018 | #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32 |
f730fd27 TS |
2019 | #define tcg_gen_mul_tl tcg_gen_mul_i32 |
2020 | #define tcg_gen_muli_tl tcg_gen_muli_i32 | |
a768e4b2 | 2021 | #define tcg_gen_discard_tl tcg_gen_discard_i32 |
e429073d BS |
2022 | #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32 |
2023 | #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32 | |
2024 | #define tcg_gen_extu_i32_tl tcg_gen_mov_i32 | |
2025 | #define tcg_gen_ext_i32_tl tcg_gen_mov_i32 | |
2026 | #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64 | |
2027 | #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64 | |
0b6ce4cf FB |
2028 | #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32 |
2029 | #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32 | |
2030 | #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32 | |
2031 | #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32 | |
2032 | #define tcg_gen_ext32u_tl tcg_gen_mov_i32 | |
2033 | #define tcg_gen_ext32s_tl tcg_gen_mov_i32 | |
945ca823 | 2034 | #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64 |
f24cb33e AJ |
2035 | #define tcg_gen_andc_tl tcg_gen_andc_i32 |
2036 | #define tcg_gen_eqv_tl tcg_gen_eqv_i32 | |
2037 | #define tcg_gen_nand_tl tcg_gen_nand_i32 | |
2038 | #define tcg_gen_nor_tl tcg_gen_nor_i32 | |
2039 | #define tcg_gen_orc_tl tcg_gen_orc_i32 | |
15824571 AJ |
2040 | #define tcg_gen_rotl_tl tcg_gen_rotl_i32 |
2041 | #define tcg_gen_rotli_tl tcg_gen_rotli_i32 | |
2042 | #define tcg_gen_rotr_tl tcg_gen_rotr_i32 | |
2043 | #define tcg_gen_rotri_tl tcg_gen_rotri_i32 | |
a98824ac | 2044 | #define tcg_const_tl tcg_const_i32 |
bdffd4a9 | 2045 | #define tcg_const_local_tl tcg_const_local_i32 |
f8422f52 | 2046 | #endif |
6ddbc6e4 PB |
2047 | |
2048 | #if TCG_TARGET_REG_BITS == 32 | |
48d38ca5 | 2049 | #define tcg_gen_add_ptr tcg_gen_add_i32 |
6ddbc6e4 | 2050 | #define tcg_gen_addi_ptr tcg_gen_addi_i32 |
48d38ca5 | 2051 | #define tcg_gen_ext_i32_ptr tcg_gen_mov_i32 |
6ddbc6e4 | 2052 | #else /* TCG_TARGET_REG_BITS == 32 */ |
48d38ca5 | 2053 | #define tcg_gen_add_ptr tcg_gen_add_i64 |
6ddbc6e4 | 2054 | #define tcg_gen_addi_ptr tcg_gen_addi_i64 |
48d38ca5 | 2055 | #define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64 |
6ddbc6e4 | 2056 | #endif /* TCG_TARGET_REG_BITS != 32 */ |