]>
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 | ||
a9751609 | 28 | static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 arg1) |
c896fe29 FB |
29 | { |
30 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
31 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
32 | } | |
33 | ||
a9751609 | 34 | static inline void tcg_gen_op1_i64(TCGOpcode opc, TCGv_i64 arg1) |
a7812ae4 PB |
35 | { |
36 | *gen_opc_ptr++ = opc; | |
37 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
c896fe29 FB |
38 | } |
39 | ||
a9751609 | 40 | static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg arg1) |
c896fe29 FB |
41 | { |
42 | *gen_opc_ptr++ = opc; | |
43 | *gen_opparam_ptr++ = arg1; | |
c896fe29 FB |
44 | } |
45 | ||
a9751609 | 46 | static inline void tcg_gen_op2_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2) |
a7812ae4 PB |
47 | { |
48 | *gen_opc_ptr++ = opc; | |
49 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
50 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
51 | } | |
52 | ||
a9751609 | 53 | static inline void tcg_gen_op2_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2) |
a7812ae4 PB |
54 | { |
55 | *gen_opc_ptr++ = opc; | |
56 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
57 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
58 | } | |
59 | ||
a9751609 | 60 | static inline void tcg_gen_op2i_i32(TCGOpcode 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 | ||
a9751609 | 67 | static inline void tcg_gen_op2i_i64(TCGOpcode 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 | ||
a9751609 | 74 | static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg arg1, TCGArg arg2) |
bcb0126f PB |
75 | { |
76 | *gen_opc_ptr++ = opc; | |
77 | *gen_opparam_ptr++ = arg1; | |
78 | *gen_opparam_ptr++ = arg2; | |
79 | } | |
80 | ||
a9751609 | 81 | static inline void tcg_gen_op3_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
a7812ae4 PB |
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 | ||
a9751609 | 90 | static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
a7812ae4 PB |
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 | ||
a9751609 RH |
99 | static inline void tcg_gen_op3i_i32(TCGOpcode opc, TCGv_i32 arg1, |
100 | TCGv_i32 arg2, 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 | ||
a9751609 RH |
108 | static inline void tcg_gen_op3i_i64(TCGOpcode opc, TCGv_i64 arg1, |
109 | TCGv_i64 arg2, 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 | ||
a9751609 RH |
117 | static inline void tcg_gen_ldst_op_i32(TCGOpcode opc, TCGv_i32 val, |
118 | TCGv_ptr base, TCGArg offset) | |
a7812ae4 PB |
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 | ||
a9751609 RH |
126 | static inline void tcg_gen_ldst_op_i64(TCGOpcode opc, TCGv_i64 val, |
127 | TCGv_ptr base, TCGArg offset) | |
a7812ae4 PB |
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 | ||
a9751609 RH |
135 | static inline void tcg_gen_qemu_ldst_op_i64_i32(TCGOpcode opc, TCGv_i64 val, |
136 | TCGv_i32 addr, TCGArg mem_index) | |
a7812ae4 PB |
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 | ||
a9751609 RH |
144 | static inline void tcg_gen_qemu_ldst_op_i64_i64(TCGOpcode opc, TCGv_i64 val, |
145 | TCGv_i64 addr, TCGArg mem_index) | |
a7812ae4 PB |
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 | ||
a9751609 | 153 | static inline void tcg_gen_op4_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
a7812ae4 PB |
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 | ||
a9751609 | 163 | static inline void tcg_gen_op4_i64(TCGOpcode 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 | ||
a9751609 | 173 | static inline void tcg_gen_op4i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
a7812ae4 PB |
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 | ||
a9751609 | 183 | static inline void tcg_gen_op4i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
a7812ae4 | 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 | ||
a9751609 | 193 | static inline void tcg_gen_op4ii_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
a7812ae4 | 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 | ||
a9751609 | 203 | static inline void tcg_gen_op4ii_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
a7812ae4 | 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 | ||
a9751609 | 213 | static inline void tcg_gen_op5_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
a7812ae4 PB |
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 | ||
a9751609 | 224 | static inline void tcg_gen_op5_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
a7812ae4 PB |
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 | ||
a9751609 | 235 | static inline void tcg_gen_op5i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
a7812ae4 | 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 | ||
a9751609 | 246 | static inline void tcg_gen_op5i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
a7812ae4 | 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 | ||
b7767f0f RH |
257 | static inline void tcg_gen_op5ii_i32(TCGOpcode opc, TCGv_i32 arg1, |
258 | TCGv_i32 arg2, TCGv_i32 arg3, | |
259 | TCGArg arg4, TCGArg arg5) | |
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++ = arg4; | |
266 | *gen_opparam_ptr++ = arg5; | |
267 | } | |
268 | ||
269 | static inline void tcg_gen_op5ii_i64(TCGOpcode opc, TCGv_i64 arg1, | |
270 | TCGv_i64 arg2, TCGv_i64 arg3, | |
271 | TCGArg arg4, TCGArg arg5) | |
272 | { | |
273 | *gen_opc_ptr++ = opc; | |
274 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
275 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
276 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
277 | *gen_opparam_ptr++ = arg4; | |
278 | *gen_opparam_ptr++ = arg5; | |
279 | } | |
280 | ||
a9751609 | 281 | static inline void tcg_gen_op6_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
a7812ae4 PB |
282 | TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5, |
283 | TCGv_i32 arg6) | |
284 | { | |
285 | *gen_opc_ptr++ = opc; | |
286 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
287 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
288 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
289 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
290 | *gen_opparam_ptr++ = GET_TCGV_I32(arg5); | |
291 | *gen_opparam_ptr++ = GET_TCGV_I32(arg6); | |
292 | } | |
293 | ||
a9751609 | 294 | static inline void tcg_gen_op6_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
a7812ae4 PB |
295 | TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5, |
296 | TCGv_i64 arg6) | |
c896fe29 FB |
297 | { |
298 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
299 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
300 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
301 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
302 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
303 | *gen_opparam_ptr++ = GET_TCGV_I64(arg5); | |
304 | *gen_opparam_ptr++ = GET_TCGV_I64(arg6); | |
ac56dd48 PB |
305 | } |
306 | ||
a9751609 | 307 | static inline void tcg_gen_op6i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
be210acb RH |
308 | TCGv_i32 arg3, TCGv_i32 arg4, |
309 | TCGv_i32 arg5, TCGArg arg6) | |
310 | { | |
311 | *gen_opc_ptr++ = opc; | |
312 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); | |
313 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
314 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
315 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
316 | *gen_opparam_ptr++ = GET_TCGV_I32(arg5); | |
317 | *gen_opparam_ptr++ = arg6; | |
318 | } | |
319 | ||
a9751609 | 320 | static inline void tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
be210acb RH |
321 | TCGv_i64 arg3, TCGv_i64 arg4, |
322 | TCGv_i64 arg5, TCGArg arg6) | |
323 | { | |
324 | *gen_opc_ptr++ = opc; | |
325 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
326 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
327 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
328 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
329 | *gen_opparam_ptr++ = GET_TCGV_I64(arg5); | |
330 | *gen_opparam_ptr++ = arg6; | |
331 | } | |
332 | ||
a9751609 RH |
333 | static inline void tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 arg1, |
334 | TCGv_i32 arg2, TCGv_i32 arg3, | |
335 | TCGv_i32 arg4, TCGArg arg5, TCGArg arg6) | |
ac56dd48 PB |
336 | { |
337 | *gen_opc_ptr++ = opc; | |
a7812ae4 PB |
338 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
339 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); | |
340 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); | |
341 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); | |
342 | *gen_opparam_ptr++ = arg5; | |
343 | *gen_opparam_ptr++ = arg6; | |
344 | } | |
345 | ||
a9751609 RH |
346 | static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 arg1, |
347 | TCGv_i64 arg2, TCGv_i64 arg3, | |
348 | TCGv_i64 arg4, TCGArg arg5, TCGArg arg6) | |
a7812ae4 PB |
349 | { |
350 | *gen_opc_ptr++ = opc; | |
351 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); | |
352 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); | |
353 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); | |
354 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); | |
c896fe29 FB |
355 | *gen_opparam_ptr++ = arg5; |
356 | *gen_opparam_ptr++ = arg6; | |
357 | } | |
358 | ||
359 | static inline void gen_set_label(int n) | |
360 | { | |
ac56dd48 | 361 | tcg_gen_op1i(INDEX_op_set_label, n); |
c896fe29 FB |
362 | } |
363 | ||
fb50d413 BS |
364 | static inline void tcg_gen_br(int label) |
365 | { | |
366 | tcg_gen_op1i(INDEX_op_br, label); | |
367 | } | |
368 | ||
a7812ae4 | 369 | static inline void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 | 370 | { |
fe75bcf7 | 371 | if (!TCGV_EQUAL_I32(ret, arg)) |
a7812ae4 | 372 | tcg_gen_op2_i32(INDEX_op_mov_i32, ret, arg); |
c896fe29 FB |
373 | } |
374 | ||
a7812ae4 | 375 | static inline void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg) |
c896fe29 | 376 | { |
a7812ae4 | 377 | tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg); |
c896fe29 FB |
378 | } |
379 | ||
2bece2c8 RH |
380 | /* A version of dh_sizemask from def-helper.h that doesn't rely on |
381 | preprocessor magic. */ | |
382 | static inline int tcg_gen_sizemask(int n, int is_64bit, int is_signed) | |
383 | { | |
384 | return (is_64bit << n*2) | (is_signed << (n*2 + 1)); | |
385 | } | |
386 | ||
c896fe29 | 387 | /* helper calls */ |
a7812ae4 PB |
388 | static inline void tcg_gen_helperN(void *func, int flags, int sizemask, |
389 | TCGArg ret, int nargs, TCGArg *args) | |
390 | { | |
391 | TCGv_ptr fn; | |
73f5e313 | 392 | fn = tcg_const_ptr(func); |
a7812ae4 PB |
393 | tcg_gen_callN(&tcg_ctx, fn, flags, sizemask, ret, |
394 | nargs, args); | |
395 | tcg_temp_free_ptr(fn); | |
396 | } | |
c896fe29 | 397 | |
dbfff4de AJ |
398 | /* Note: Both tcg_gen_helper32() and tcg_gen_helper64() are currently |
399 | reserved for helpers in tcg-runtime.c. These helpers are all const | |
400 | and pure, hence the call to tcg_gen_callN() with TCG_CALL_CONST | | |
401 | TCG_CALL_PURE. This may need to be adjusted if these functions | |
402 | start to be used with other helpers. */ | |
2bece2c8 | 403 | static inline void tcg_gen_helper32(void *func, int sizemask, TCGv_i32 ret, |
31d66551 AJ |
404 | TCGv_i32 a, TCGv_i32 b) |
405 | { | |
406 | TCGv_ptr fn; | |
407 | TCGArg args[2]; | |
73f5e313 | 408 | fn = tcg_const_ptr(func); |
31d66551 AJ |
409 | args[0] = GET_TCGV_I32(a); |
410 | args[1] = GET_TCGV_I32(b); | |
2bece2c8 RH |
411 | tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask, |
412 | GET_TCGV_I32(ret), 2, args); | |
31d66551 AJ |
413 | tcg_temp_free_ptr(fn); |
414 | } | |
415 | ||
2bece2c8 | 416 | static inline void tcg_gen_helper64(void *func, int sizemask, TCGv_i64 ret, |
a7812ae4 | 417 | TCGv_i64 a, TCGv_i64 b) |
c896fe29 | 418 | { |
a7812ae4 PB |
419 | TCGv_ptr fn; |
420 | TCGArg args[2]; | |
73f5e313 | 421 | fn = tcg_const_ptr(func); |
a7812ae4 PB |
422 | args[0] = GET_TCGV_I64(a); |
423 | args[1] = GET_TCGV_I64(b); | |
2bece2c8 RH |
424 | tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask, |
425 | GET_TCGV_I64(ret), 2, args); | |
a7812ae4 | 426 | tcg_temp_free_ptr(fn); |
f8422f52 BS |
427 | } |
428 | ||
c896fe29 FB |
429 | /* 32 bit ops */ |
430 | ||
a7812ae4 | 431 | static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 432 | { |
a7812ae4 | 433 | tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32, ret, arg2, offset); |
c896fe29 FB |
434 | } |
435 | ||
a7812ae4 | 436 | static inline void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 437 | { |
a7812ae4 | 438 | tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32, ret, arg2, offset); |
c896fe29 FB |
439 | } |
440 | ||
a7812ae4 | 441 | static inline void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 442 | { |
a7812ae4 | 443 | tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32, ret, arg2, offset); |
c896fe29 FB |
444 | } |
445 | ||
a7812ae4 | 446 | static inline void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 447 | { |
a7812ae4 | 448 | tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32, ret, arg2, offset); |
c896fe29 FB |
449 | } |
450 | ||
a7812ae4 | 451 | static inline void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 452 | { |
a7812ae4 | 453 | tcg_gen_ldst_op_i32(INDEX_op_ld_i32, ret, arg2, offset); |
c896fe29 FB |
454 | } |
455 | ||
a7812ae4 | 456 | static inline void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 457 | { |
a7812ae4 | 458 | tcg_gen_ldst_op_i32(INDEX_op_st8_i32, arg1, arg2, offset); |
c896fe29 FB |
459 | } |
460 | ||
a7812ae4 | 461 | static inline void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 462 | { |
a7812ae4 | 463 | tcg_gen_ldst_op_i32(INDEX_op_st16_i32, arg1, arg2, offset); |
c896fe29 FB |
464 | } |
465 | ||
a7812ae4 | 466 | static inline void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 467 | { |
a7812ae4 | 468 | tcg_gen_ldst_op_i32(INDEX_op_st_i32, arg1, arg2, offset); |
c896fe29 FB |
469 | } |
470 | ||
a7812ae4 | 471 | static inline void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 472 | { |
a7812ae4 | 473 | tcg_gen_op3_i32(INDEX_op_add_i32, ret, arg1, arg2); |
c896fe29 FB |
474 | } |
475 | ||
a7812ae4 | 476 | static inline void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 477 | { |
7089442c BS |
478 | /* some cases can be optimized here */ |
479 | if (arg2 == 0) { | |
480 | tcg_gen_mov_i32(ret, arg1); | |
481 | } else { | |
a7812ae4 | 482 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 483 | tcg_gen_add_i32(ret, arg1, t0); |
a7812ae4 | 484 | tcg_temp_free_i32(t0); |
7089442c | 485 | } |
c896fe29 FB |
486 | } |
487 | ||
a7812ae4 | 488 | static inline void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 489 | { |
a7812ae4 | 490 | tcg_gen_op3_i32(INDEX_op_sub_i32, ret, arg1, arg2); |
c896fe29 FB |
491 | } |
492 | ||
a7812ae4 | 493 | static inline void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2) |
0045734a | 494 | { |
a7812ae4 | 495 | TCGv_i32 t0 = tcg_const_i32(arg1); |
0045734a | 496 | tcg_gen_sub_i32(ret, t0, arg2); |
a7812ae4 | 497 | tcg_temp_free_i32(t0); |
0045734a AJ |
498 | } |
499 | ||
a7812ae4 | 500 | static inline void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 501 | { |
7089442c BS |
502 | /* some cases can be optimized here */ |
503 | if (arg2 == 0) { | |
504 | tcg_gen_mov_i32(ret, arg1); | |
505 | } else { | |
a7812ae4 | 506 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 507 | tcg_gen_sub_i32(ret, arg1, t0); |
a7812ae4 | 508 | tcg_temp_free_i32(t0); |
7089442c | 509 | } |
c896fe29 FB |
510 | } |
511 | ||
a7812ae4 | 512 | static inline void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 513 | { |
7fc81051 AJ |
514 | if (TCGV_EQUAL_I32(arg1, arg2)) { |
515 | tcg_gen_mov_i32(ret, arg1); | |
516 | } else { | |
517 | tcg_gen_op3_i32(INDEX_op_and_i32, ret, arg1, arg2); | |
518 | } | |
c896fe29 FB |
519 | } |
520 | ||
42ce3e20 | 521 | static inline void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2) |
c896fe29 | 522 | { |
42ce3e20 RH |
523 | TCGv_i32 t0; |
524 | /* Some cases can be optimized here. */ | |
525 | switch (arg2) { | |
526 | case 0: | |
c896fe29 | 527 | tcg_gen_movi_i32(ret, 0); |
42ce3e20 RH |
528 | return; |
529 | case 0xffffffffu: | |
c896fe29 | 530 | tcg_gen_mov_i32(ret, arg1); |
42ce3e20 RH |
531 | return; |
532 | case 0xffu: | |
533 | /* Don't recurse with tcg_gen_ext8u_i32. */ | |
534 | if (TCG_TARGET_HAS_ext8u_i32) { | |
535 | tcg_gen_op2_i32(INDEX_op_ext8u_i32, ret, arg1); | |
536 | return; | |
537 | } | |
538 | break; | |
539 | case 0xffffu: | |
540 | if (TCG_TARGET_HAS_ext16u_i32) { | |
541 | tcg_gen_op2_i32(INDEX_op_ext16u_i32, ret, arg1); | |
542 | return; | |
543 | } | |
544 | break; | |
c896fe29 | 545 | } |
42ce3e20 RH |
546 | t0 = tcg_const_i32(arg2); |
547 | tcg_gen_and_i32(ret, arg1, t0); | |
548 | tcg_temp_free_i32(t0); | |
c896fe29 FB |
549 | } |
550 | ||
a7812ae4 | 551 | static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 552 | { |
7fc81051 AJ |
553 | if (TCGV_EQUAL_I32(arg1, arg2)) { |
554 | tcg_gen_mov_i32(ret, arg1); | |
555 | } else { | |
556 | tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2); | |
557 | } | |
c896fe29 FB |
558 | } |
559 | ||
a7812ae4 | 560 | static inline void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 561 | { |
d81ada7f RH |
562 | /* Some cases can be optimized here. */ |
563 | if (arg2 == -1) { | |
564 | tcg_gen_movi_i32(ret, -1); | |
c896fe29 FB |
565 | } else if (arg2 == 0) { |
566 | tcg_gen_mov_i32(ret, arg1); | |
567 | } else { | |
a7812ae4 | 568 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 569 | tcg_gen_or_i32(ret, arg1, t0); |
a7812ae4 | 570 | tcg_temp_free_i32(t0); |
c896fe29 FB |
571 | } |
572 | } | |
573 | ||
a7812ae4 | 574 | static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 575 | { |
7fc81051 AJ |
576 | if (TCGV_EQUAL_I32(arg1, arg2)) { |
577 | tcg_gen_movi_i32(ret, 0); | |
578 | } else { | |
579 | tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2); | |
580 | } | |
c896fe29 FB |
581 | } |
582 | ||
a7812ae4 | 583 | static inline void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 584 | { |
6f3bb33e | 585 | /* Some cases can be optimized here. */ |
c896fe29 FB |
586 | if (arg2 == 0) { |
587 | tcg_gen_mov_i32(ret, arg1); | |
6f3bb33e RH |
588 | } else if (arg2 == -1 && TCG_TARGET_HAS_not_i32) { |
589 | /* Don't recurse with tcg_gen_not_i32. */ | |
590 | tcg_gen_op2_i32(INDEX_op_not_i32, ret, arg1); | |
c896fe29 | 591 | } else { |
a7812ae4 | 592 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 593 | tcg_gen_xor_i32(ret, arg1, t0); |
a7812ae4 | 594 | tcg_temp_free_i32(t0); |
c896fe29 FB |
595 | } |
596 | } | |
597 | ||
a7812ae4 | 598 | static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 599 | { |
a7812ae4 | 600 | tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2); |
c896fe29 FB |
601 | } |
602 | ||
a7812ae4 | 603 | static inline void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 604 | { |
34151a20 FB |
605 | if (arg2 == 0) { |
606 | tcg_gen_mov_i32(ret, arg1); | |
607 | } else { | |
a7812ae4 | 608 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 609 | tcg_gen_shl_i32(ret, arg1, t0); |
a7812ae4 | 610 | tcg_temp_free_i32(t0); |
34151a20 | 611 | } |
c896fe29 FB |
612 | } |
613 | ||
a7812ae4 | 614 | static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 615 | { |
a7812ae4 | 616 | tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2); |
c896fe29 FB |
617 | } |
618 | ||
a7812ae4 | 619 | static inline void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 620 | { |
34151a20 FB |
621 | if (arg2 == 0) { |
622 | tcg_gen_mov_i32(ret, arg1); | |
623 | } else { | |
a7812ae4 | 624 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 625 | tcg_gen_shr_i32(ret, arg1, t0); |
a7812ae4 | 626 | tcg_temp_free_i32(t0); |
34151a20 | 627 | } |
c896fe29 FB |
628 | } |
629 | ||
a7812ae4 | 630 | static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 631 | { |
a7812ae4 | 632 | tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2); |
c896fe29 FB |
633 | } |
634 | ||
a7812ae4 | 635 | static inline void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
c896fe29 | 636 | { |
34151a20 FB |
637 | if (arg2 == 0) { |
638 | tcg_gen_mov_i32(ret, arg1); | |
639 | } else { | |
a7812ae4 | 640 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 641 | tcg_gen_sar_i32(ret, arg1, t0); |
a7812ae4 | 642 | tcg_temp_free_i32(t0); |
34151a20 | 643 | } |
c896fe29 FB |
644 | } |
645 | ||
8a56e840 RH |
646 | static inline void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1, |
647 | TCGv_i32 arg2, int label_index) | |
c896fe29 | 648 | { |
a7812ae4 | 649 | tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_index); |
c896fe29 FB |
650 | } |
651 | ||
8a56e840 RH |
652 | static inline void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1, |
653 | int32_t arg2, int label_index) | |
cb63669a | 654 | { |
a7812ae4 | 655 | TCGv_i32 t0 = tcg_const_i32(arg2); |
cb63669a | 656 | tcg_gen_brcond_i32(cond, arg1, t0, label_index); |
a7812ae4 | 657 | tcg_temp_free_i32(t0); |
cb63669a PB |
658 | } |
659 | ||
8a56e840 | 660 | static inline void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret, |
5105c556 AJ |
661 | TCGv_i32 arg1, TCGv_i32 arg2) |
662 | { | |
663 | tcg_gen_op4i_i32(INDEX_op_setcond_i32, ret, arg1, arg2, cond); | |
664 | } | |
665 | ||
8a56e840 RH |
666 | static inline void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret, |
667 | TCGv_i32 arg1, int32_t arg2) | |
5105c556 AJ |
668 | { |
669 | TCGv_i32 t0 = tcg_const_i32(arg2); | |
670 | tcg_gen_setcond_i32(cond, ret, arg1, t0); | |
671 | tcg_temp_free_i32(t0); | |
672 | } | |
673 | ||
a7812ae4 | 674 | static inline void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 675 | { |
a7812ae4 | 676 | tcg_gen_op3_i32(INDEX_op_mul_i32, ret, arg1, arg2); |
c896fe29 FB |
677 | } |
678 | ||
a7812ae4 | 679 | static inline void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
f730fd27 | 680 | { |
a7812ae4 | 681 | TCGv_i32 t0 = tcg_const_i32(arg2); |
e8996ee0 | 682 | tcg_gen_mul_i32(ret, arg1, t0); |
a7812ae4 | 683 | tcg_temp_free_i32(t0); |
f730fd27 TS |
684 | } |
685 | ||
a7812ae4 | 686 | static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
c896fe29 | 687 | { |
25c4d9cc RH |
688 | if (TCG_TARGET_HAS_div_i32) { |
689 | tcg_gen_op3_i32(INDEX_op_div_i32, ret, arg1, arg2); | |
690 | } else if (TCG_TARGET_HAS_div2_i32) { | |
691 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
692 | tcg_gen_sari_i32(t0, arg1, 31); | |
693 | tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2); | |
694 | tcg_temp_free_i32(t0); | |
695 | } else { | |
696 | int sizemask = 0; | |
697 | /* Return value and both arguments are 32-bit and signed. */ | |
698 | sizemask |= tcg_gen_sizemask(0, 0, 1); | |
699 | sizemask |= tcg_gen_sizemask(1, 0, 1); | |
700 | sizemask |= tcg_gen_sizemask(2, 0, 1); | |
701 | tcg_gen_helper32(tcg_helper_div_i32, sizemask, ret, arg1, arg2); | |
702 | } | |
31d66551 AJ |
703 | } |
704 | ||
705 | static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) | |
706 | { | |
25c4d9cc RH |
707 | if (TCG_TARGET_HAS_div_i32) { |
708 | tcg_gen_op3_i32(INDEX_op_rem_i32, ret, arg1, arg2); | |
709 | } else if (TCG_TARGET_HAS_div2_i32) { | |
710 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
711 | tcg_gen_sari_i32(t0, arg1, 31); | |
712 | tcg_gen_op5_i32(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2); | |
713 | tcg_temp_free_i32(t0); | |
714 | } else { | |
715 | int sizemask = 0; | |
716 | /* Return value and both arguments are 32-bit and signed. */ | |
717 | sizemask |= tcg_gen_sizemask(0, 0, 1); | |
718 | sizemask |= tcg_gen_sizemask(1, 0, 1); | |
719 | sizemask |= tcg_gen_sizemask(2, 0, 1); | |
720 | tcg_gen_helper32(tcg_helper_rem_i32, sizemask, ret, arg1, arg2); | |
721 | } | |
31d66551 AJ |
722 | } |
723 | ||
724 | static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) | |
725 | { | |
25c4d9cc RH |
726 | if (TCG_TARGET_HAS_div_i32) { |
727 | tcg_gen_op3_i32(INDEX_op_divu_i32, ret, arg1, arg2); | |
728 | } else if (TCG_TARGET_HAS_div2_i32) { | |
729 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
730 | tcg_gen_movi_i32(t0, 0); | |
731 | tcg_gen_op5_i32(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2); | |
732 | tcg_temp_free_i32(t0); | |
733 | } else { | |
734 | int sizemask = 0; | |
735 | /* Return value and both arguments are 32-bit and unsigned. */ | |
736 | sizemask |= tcg_gen_sizemask(0, 0, 0); | |
737 | sizemask |= tcg_gen_sizemask(1, 0, 0); | |
738 | sizemask |= tcg_gen_sizemask(2, 0, 0); | |
739 | tcg_gen_helper32(tcg_helper_divu_i32, sizemask, ret, arg1, arg2); | |
740 | } | |
31d66551 AJ |
741 | } |
742 | ||
743 | static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) | |
744 | { | |
25c4d9cc RH |
745 | if (TCG_TARGET_HAS_div_i32) { |
746 | tcg_gen_op3_i32(INDEX_op_remu_i32, ret, arg1, arg2); | |
747 | } else if (TCG_TARGET_HAS_div2_i32) { | |
748 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
749 | tcg_gen_movi_i32(t0, 0); | |
750 | tcg_gen_op5_i32(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2); | |
751 | tcg_temp_free_i32(t0); | |
752 | } else { | |
753 | int sizemask = 0; | |
754 | /* Return value and both arguments are 32-bit and unsigned. */ | |
755 | sizemask |= tcg_gen_sizemask(0, 0, 0); | |
756 | sizemask |= tcg_gen_sizemask(1, 0, 0); | |
757 | sizemask |= tcg_gen_sizemask(2, 0, 0); | |
758 | tcg_gen_helper32(tcg_helper_remu_i32, sizemask, ret, arg1, arg2); | |
759 | } | |
31d66551 | 760 | } |
c896fe29 FB |
761 | |
762 | #if TCG_TARGET_REG_BITS == 32 | |
763 | ||
a7812ae4 | 764 | static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 765 | { |
fe75bcf7 | 766 | if (!TCGV_EQUAL_I64(ret, arg)) { |
a7812ae4 | 767 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
4d07272d BS |
768 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); |
769 | } | |
c896fe29 FB |
770 | } |
771 | ||
a7812ae4 | 772 | static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg) |
c896fe29 | 773 | { |
a7812ae4 | 774 | tcg_gen_movi_i32(TCGV_LOW(ret), arg); |
ac56dd48 | 775 | tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32); |
c896fe29 FB |
776 | } |
777 | ||
a7812ae4 PB |
778 | static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
779 | tcg_target_long offset) | |
c896fe29 | 780 | { |
a7812ae4 | 781 | tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 782 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
783 | } |
784 | ||
a7812ae4 PB |
785 | static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
786 | tcg_target_long offset) | |
c896fe29 | 787 | { |
a7812ae4 PB |
788 | tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset); |
789 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), 31); | |
c896fe29 FB |
790 | } |
791 | ||
a7812ae4 PB |
792 | static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
793 | tcg_target_long offset) | |
c896fe29 | 794 | { |
a747723b | 795 | tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 796 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
797 | } |
798 | ||
a7812ae4 PB |
799 | static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
800 | tcg_target_long offset) | |
c896fe29 | 801 | { |
a7812ae4 PB |
802 | tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset); |
803 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
804 | } |
805 | ||
a7812ae4 PB |
806 | static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
807 | tcg_target_long offset) | |
c896fe29 | 808 | { |
a7812ae4 | 809 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 810 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
811 | } |
812 | ||
a7812ae4 PB |
813 | static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
814 | tcg_target_long offset) | |
c896fe29 | 815 | { |
a7812ae4 PB |
816 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
817 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
818 | } |
819 | ||
a7812ae4 PB |
820 | static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, |
821 | tcg_target_long offset) | |
c896fe29 FB |
822 | { |
823 | /* since arg2 and ret have different types, they cannot be the | |
824 | same temporary */ | |
825 | #ifdef TCG_TARGET_WORDS_BIGENDIAN | |
ac56dd48 | 826 | tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset); |
a7812ae4 | 827 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4); |
c896fe29 | 828 | #else |
a7812ae4 | 829 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
ac56dd48 | 830 | tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4); |
c896fe29 FB |
831 | #endif |
832 | } | |
833 | ||
a7812ae4 PB |
834 | static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
835 | tcg_target_long offset) | |
c896fe29 | 836 | { |
a7812ae4 | 837 | tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset); |
c896fe29 FB |
838 | } |
839 | ||
a7812ae4 PB |
840 | static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
841 | tcg_target_long offset) | |
c896fe29 | 842 | { |
a7812ae4 | 843 | tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset); |
c896fe29 FB |
844 | } |
845 | ||
a7812ae4 PB |
846 | static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
847 | tcg_target_long offset) | |
c896fe29 | 848 | { |
a7812ae4 | 849 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); |
c896fe29 FB |
850 | } |
851 | ||
a7812ae4 PB |
852 | static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
853 | tcg_target_long offset) | |
c896fe29 FB |
854 | { |
855 | #ifdef TCG_TARGET_WORDS_BIGENDIAN | |
ac56dd48 | 856 | tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset); |
a7812ae4 | 857 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4); |
c896fe29 | 858 | #else |
a7812ae4 | 859 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); |
ac56dd48 | 860 | tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4); |
c896fe29 FB |
861 | #endif |
862 | } | |
863 | ||
a7812ae4 | 864 | static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 865 | { |
a7812ae4 PB |
866 | tcg_gen_op6_i32(INDEX_op_add2_i32, TCGV_LOW(ret), TCGV_HIGH(ret), |
867 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), | |
868 | TCGV_HIGH(arg2)); | |
c896fe29 FB |
869 | } |
870 | ||
a7812ae4 | 871 | static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 872 | { |
a7812ae4 PB |
873 | tcg_gen_op6_i32(INDEX_op_sub2_i32, TCGV_LOW(ret), TCGV_HIGH(ret), |
874 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), | |
875 | TCGV_HIGH(arg2)); | |
c896fe29 FB |
876 | } |
877 | ||
a7812ae4 | 878 | static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 879 | { |
a7812ae4 | 880 | tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
ac56dd48 | 881 | tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
c896fe29 FB |
882 | } |
883 | ||
a7812ae4 | 884 | static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 885 | { |
e5105083 AJ |
886 | tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
887 | tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); | |
c896fe29 FB |
888 | } |
889 | ||
a7812ae4 | 890 | static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 891 | { |
e5105083 AJ |
892 | tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
893 | tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
c896fe29 FB |
894 | } |
895 | ||
a7812ae4 | 896 | static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 897 | { |
a7812ae4 | 898 | tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
ac56dd48 | 899 | tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
c896fe29 FB |
900 | } |
901 | ||
a7812ae4 | 902 | static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 903 | { |
e5105083 AJ |
904 | tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
905 | tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
c896fe29 FB |
906 | } |
907 | ||
a7812ae4 | 908 | static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 909 | { |
a7812ae4 | 910 | tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
ac56dd48 | 911 | tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
c896fe29 FB |
912 | } |
913 | ||
914 | /* XXX: use generic code when basic block handling is OK or CPU | |
915 | specific code (x86) */ | |
a7812ae4 | 916 | static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 917 | { |
2bece2c8 RH |
918 | int sizemask = 0; |
919 | /* Return value and both arguments are 64-bit and signed. */ | |
920 | sizemask |= tcg_gen_sizemask(0, 1, 1); | |
921 | sizemask |= tcg_gen_sizemask(1, 1, 1); | |
922 | sizemask |= tcg_gen_sizemask(2, 1, 1); | |
923 | ||
924 | tcg_gen_helper64(tcg_helper_shl_i64, sizemask, ret, arg1, arg2); | |
c896fe29 FB |
925 | } |
926 | ||
a7812ae4 | 927 | static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 FB |
928 | { |
929 | tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0); | |
930 | } | |
931 | ||
a7812ae4 | 932 | static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 933 | { |
2bece2c8 RH |
934 | int sizemask = 0; |
935 | /* Return value and both arguments are 64-bit and signed. */ | |
936 | sizemask |= tcg_gen_sizemask(0, 1, 1); | |
937 | sizemask |= tcg_gen_sizemask(1, 1, 1); | |
938 | sizemask |= tcg_gen_sizemask(2, 1, 1); | |
939 | ||
940 | tcg_gen_helper64(tcg_helper_shr_i64, sizemask, ret, arg1, arg2); | |
c896fe29 FB |
941 | } |
942 | ||
a7812ae4 | 943 | static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 FB |
944 | { |
945 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0); | |
946 | } | |
947 | ||
a7812ae4 | 948 | static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 949 | { |
2bece2c8 RH |
950 | int sizemask = 0; |
951 | /* Return value and both arguments are 64-bit and signed. */ | |
952 | sizemask |= tcg_gen_sizemask(0, 1, 1); | |
953 | sizemask |= tcg_gen_sizemask(1, 1, 1); | |
954 | sizemask |= tcg_gen_sizemask(2, 1, 1); | |
955 | ||
956 | tcg_gen_helper64(tcg_helper_sar_i64, sizemask, ret, arg1, arg2); | |
c896fe29 FB |
957 | } |
958 | ||
a7812ae4 | 959 | static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 FB |
960 | { |
961 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1); | |
962 | } | |
963 | ||
8a56e840 RH |
964 | static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, |
965 | TCGv_i64 arg2, int label_index) | |
c896fe29 | 966 | { |
a7812ae4 PB |
967 | tcg_gen_op6ii_i32(INDEX_op_brcond2_i32, |
968 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), | |
969 | TCGV_HIGH(arg2), cond, label_index); | |
c896fe29 FB |
970 | } |
971 | ||
8a56e840 | 972 | static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret, |
5105c556 AJ |
973 | TCGv_i64 arg1, TCGv_i64 arg2) |
974 | { | |
975 | tcg_gen_op6i_i32(INDEX_op_setcond2_i32, TCGV_LOW(ret), | |
976 | TCGV_LOW(arg1), TCGV_HIGH(arg1), | |
977 | TCGV_LOW(arg2), TCGV_HIGH(arg2), cond); | |
978 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
979 | } | |
980 | ||
a7812ae4 | 981 | static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 982 | { |
a7812ae4 PB |
983 | TCGv_i64 t0; |
984 | TCGv_i32 t1; | |
c896fe29 | 985 | |
a7812ae4 PB |
986 | t0 = tcg_temp_new_i64(); |
987 | t1 = tcg_temp_new_i32(); | |
988 | ||
989 | tcg_gen_op4_i32(INDEX_op_mulu2_i32, TCGV_LOW(t0), TCGV_HIGH(t0), | |
990 | TCGV_LOW(arg1), TCGV_LOW(arg2)); | |
991 | ||
992 | tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2)); | |
ac56dd48 | 993 | tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); |
a7812ae4 | 994 | tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2)); |
ac56dd48 | 995 | tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); |
a7812ae4 | 996 | |
c896fe29 | 997 | tcg_gen_mov_i64(ret, t0); |
a7812ae4 PB |
998 | tcg_temp_free_i64(t0); |
999 | tcg_temp_free_i32(t1); | |
c896fe29 FB |
1000 | } |
1001 | ||
a7812ae4 | 1002 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1003 | { |
2bece2c8 RH |
1004 | int sizemask = 0; |
1005 | /* Return value and both arguments are 64-bit and signed. */ | |
1006 | sizemask |= tcg_gen_sizemask(0, 1, 1); | |
1007 | sizemask |= tcg_gen_sizemask(1, 1, 1); | |
1008 | sizemask |= tcg_gen_sizemask(2, 1, 1); | |
1009 | ||
1010 | tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2); | |
c896fe29 FB |
1011 | } |
1012 | ||
a7812ae4 | 1013 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1014 | { |
2bece2c8 RH |
1015 | int sizemask = 0; |
1016 | /* Return value and both arguments are 64-bit and signed. */ | |
1017 | sizemask |= tcg_gen_sizemask(0, 1, 1); | |
1018 | sizemask |= tcg_gen_sizemask(1, 1, 1); | |
1019 | sizemask |= tcg_gen_sizemask(2, 1, 1); | |
1020 | ||
1021 | tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2); | |
c896fe29 FB |
1022 | } |
1023 | ||
a7812ae4 | 1024 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1025 | { |
2bece2c8 RH |
1026 | int sizemask = 0; |
1027 | /* Return value and both arguments are 64-bit and unsigned. */ | |
1028 | sizemask |= tcg_gen_sizemask(0, 1, 0); | |
1029 | sizemask |= tcg_gen_sizemask(1, 1, 0); | |
1030 | sizemask |= tcg_gen_sizemask(2, 1, 0); | |
1031 | ||
1032 | tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2); | |
c896fe29 FB |
1033 | } |
1034 | ||
a7812ae4 | 1035 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1036 | { |
2bece2c8 RH |
1037 | int sizemask = 0; |
1038 | /* Return value and both arguments are 64-bit and unsigned. */ | |
1039 | sizemask |= tcg_gen_sizemask(0, 1, 0); | |
1040 | sizemask |= tcg_gen_sizemask(1, 1, 0); | |
1041 | sizemask |= tcg_gen_sizemask(2, 1, 0); | |
1042 | ||
1043 | tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2); | |
c896fe29 FB |
1044 | } |
1045 | ||
1046 | #else | |
1047 | ||
a7812ae4 | 1048 | static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1049 | { |
fe75bcf7 | 1050 | if (!TCGV_EQUAL_I64(ret, arg)) |
a7812ae4 | 1051 | tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg); |
c896fe29 FB |
1052 | } |
1053 | ||
a7812ae4 | 1054 | static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg) |
c896fe29 | 1055 | { |
a7812ae4 | 1056 | tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg); |
c896fe29 FB |
1057 | } |
1058 | ||
6bd4b08a | 1059 | static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
ac56dd48 | 1060 | tcg_target_long offset) |
c896fe29 | 1061 | { |
a7812ae4 | 1062 | tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset); |
c896fe29 FB |
1063 | } |
1064 | ||
6bd4b08a | 1065 | static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
ac56dd48 | 1066 | tcg_target_long offset) |
c896fe29 | 1067 | { |
a7812ae4 | 1068 | tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset); |
c896fe29 FB |
1069 | } |
1070 | ||
6bd4b08a | 1071 | static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
ac56dd48 | 1072 | tcg_target_long offset) |
c896fe29 | 1073 | { |
a7812ae4 | 1074 | tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset); |
c896fe29 FB |
1075 | } |
1076 | ||
6bd4b08a | 1077 | static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
ac56dd48 | 1078 | tcg_target_long offset) |
c896fe29 | 1079 | { |
a7812ae4 | 1080 | tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset); |
c896fe29 FB |
1081 | } |
1082 | ||
6bd4b08a | 1083 | static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
ac56dd48 | 1084 | tcg_target_long offset) |
c896fe29 | 1085 | { |
a7812ae4 | 1086 | tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset); |
c896fe29 FB |
1087 | } |
1088 | ||
6bd4b08a | 1089 | static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
ac56dd48 | 1090 | tcg_target_long offset) |
c896fe29 | 1091 | { |
a7812ae4 | 1092 | tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset); |
c896fe29 FB |
1093 | } |
1094 | ||
6bd4b08a | 1095 | static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 1096 | { |
a7812ae4 | 1097 | tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset); |
c896fe29 FB |
1098 | } |
1099 | ||
6bd4b08a | 1100 | static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
ac56dd48 | 1101 | tcg_target_long offset) |
c896fe29 | 1102 | { |
a7812ae4 | 1103 | tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset); |
c896fe29 FB |
1104 | } |
1105 | ||
6bd4b08a | 1106 | static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
ac56dd48 | 1107 | tcg_target_long offset) |
c896fe29 | 1108 | { |
a7812ae4 | 1109 | tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset); |
c896fe29 FB |
1110 | } |
1111 | ||
6bd4b08a | 1112 | static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
ac56dd48 | 1113 | tcg_target_long offset) |
c896fe29 | 1114 | { |
a7812ae4 | 1115 | tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset); |
c896fe29 FB |
1116 | } |
1117 | ||
6bd4b08a | 1118 | static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) |
c896fe29 | 1119 | { |
a7812ae4 | 1120 | tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset); |
c896fe29 FB |
1121 | } |
1122 | ||
a7812ae4 | 1123 | static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1124 | { |
a7812ae4 | 1125 | tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2); |
c896fe29 FB |
1126 | } |
1127 | ||
a7812ae4 | 1128 | static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1129 | { |
a7812ae4 | 1130 | tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2); |
c896fe29 FB |
1131 | } |
1132 | ||
a7812ae4 | 1133 | static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1134 | { |
7fc81051 AJ |
1135 | if (TCGV_EQUAL_I64(arg1, arg2)) { |
1136 | tcg_gen_mov_i64(ret, arg1); | |
1137 | } else { | |
1138 | tcg_gen_op3_i64(INDEX_op_and_i64, ret, arg1, arg2); | |
1139 | } | |
c896fe29 FB |
1140 | } |
1141 | ||
42ce3e20 | 1142 | static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2) |
c896fe29 | 1143 | { |
42ce3e20 RH |
1144 | TCGv_i64 t0; |
1145 | /* Some cases can be optimized here. */ | |
1146 | switch (arg2) { | |
1147 | case 0: | |
1148 | tcg_gen_movi_i64(ret, 0); | |
1149 | return; | |
1150 | case 0xffffffffffffffffull: | |
1151 | tcg_gen_mov_i64(ret, arg1); | |
1152 | return; | |
1153 | case 0xffull: | |
1154 | /* Don't recurse with tcg_gen_ext8u_i32. */ | |
1155 | if (TCG_TARGET_HAS_ext8u_i64) { | |
1156 | tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg1); | |
1157 | return; | |
1158 | } | |
1159 | break; | |
1160 | case 0xffffu: | |
1161 | if (TCG_TARGET_HAS_ext16u_i64) { | |
1162 | tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg1); | |
1163 | return; | |
1164 | } | |
1165 | break; | |
1166 | case 0xffffffffull: | |
1167 | if (TCG_TARGET_HAS_ext32u_i64) { | |
1168 | tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg1); | |
1169 | return; | |
1170 | } | |
1171 | break; | |
1172 | } | |
1173 | t0 = tcg_const_i64(arg2); | |
e8996ee0 | 1174 | tcg_gen_and_i64(ret, arg1, t0); |
a7812ae4 | 1175 | tcg_temp_free_i64(t0); |
c896fe29 FB |
1176 | } |
1177 | ||
a7812ae4 | 1178 | static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1179 | { |
7fc81051 AJ |
1180 | if (TCGV_EQUAL_I64(arg1, arg2)) { |
1181 | tcg_gen_mov_i64(ret, arg1); | |
1182 | } else { | |
1183 | tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2); | |
1184 | } | |
c896fe29 FB |
1185 | } |
1186 | ||
a7812ae4 | 1187 | static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 1188 | { |
d81ada7f RH |
1189 | /* Some cases can be optimized here. */ |
1190 | if (arg2 == -1) { | |
1191 | tcg_gen_movi_i64(ret, -1); | |
1192 | } else if (arg2 == 0) { | |
1193 | tcg_gen_mov_i64(ret, arg1); | |
1194 | } else { | |
1195 | TCGv_i64 t0 = tcg_const_i64(arg2); | |
1196 | tcg_gen_or_i64(ret, arg1, t0); | |
1197 | tcg_temp_free_i64(t0); | |
1198 | } | |
c896fe29 FB |
1199 | } |
1200 | ||
a7812ae4 | 1201 | static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1202 | { |
7fc81051 AJ |
1203 | if (TCGV_EQUAL_I64(arg1, arg2)) { |
1204 | tcg_gen_movi_i64(ret, 0); | |
1205 | } else { | |
1206 | tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2); | |
1207 | } | |
c896fe29 FB |
1208 | } |
1209 | ||
a7812ae4 | 1210 | static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 1211 | { |
6f3bb33e RH |
1212 | /* Some cases can be optimized here. */ |
1213 | if (arg2 == 0) { | |
1214 | tcg_gen_mov_i64(ret, arg1); | |
1215 | } else if (arg2 == -1 && TCG_TARGET_HAS_not_i64) { | |
1216 | /* Don't recurse with tcg_gen_not_i64. */ | |
1217 | tcg_gen_op2_i64(INDEX_op_not_i64, ret, arg1); | |
1218 | } else { | |
1219 | TCGv_i64 t0 = tcg_const_i64(arg2); | |
1220 | tcg_gen_xor_i64(ret, arg1, t0); | |
1221 | tcg_temp_free_i64(t0); | |
1222 | } | |
c896fe29 FB |
1223 | } |
1224 | ||
a7812ae4 | 1225 | static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1226 | { |
a7812ae4 | 1227 | tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2); |
c896fe29 FB |
1228 | } |
1229 | ||
a7812ae4 | 1230 | static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 1231 | { |
34151a20 FB |
1232 | if (arg2 == 0) { |
1233 | tcg_gen_mov_i64(ret, arg1); | |
1234 | } else { | |
a7812ae4 | 1235 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 1236 | tcg_gen_shl_i64(ret, arg1, t0); |
a7812ae4 | 1237 | tcg_temp_free_i64(t0); |
34151a20 | 1238 | } |
c896fe29 FB |
1239 | } |
1240 | ||
a7812ae4 | 1241 | static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1242 | { |
a7812ae4 | 1243 | tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2); |
c896fe29 FB |
1244 | } |
1245 | ||
a7812ae4 | 1246 | static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 1247 | { |
34151a20 FB |
1248 | if (arg2 == 0) { |
1249 | tcg_gen_mov_i64(ret, arg1); | |
1250 | } else { | |
a7812ae4 | 1251 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 1252 | tcg_gen_shr_i64(ret, arg1, t0); |
a7812ae4 | 1253 | tcg_temp_free_i64(t0); |
34151a20 | 1254 | } |
c896fe29 FB |
1255 | } |
1256 | ||
a7812ae4 | 1257 | static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1258 | { |
a7812ae4 | 1259 | tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2); |
c896fe29 FB |
1260 | } |
1261 | ||
a7812ae4 | 1262 | static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
c896fe29 | 1263 | { |
34151a20 FB |
1264 | if (arg2 == 0) { |
1265 | tcg_gen_mov_i64(ret, arg1); | |
1266 | } else { | |
a7812ae4 | 1267 | TCGv_i64 t0 = tcg_const_i64(arg2); |
e8996ee0 | 1268 | tcg_gen_sar_i64(ret, arg1, t0); |
a7812ae4 | 1269 | tcg_temp_free_i64(t0); |
34151a20 | 1270 | } |
c896fe29 FB |
1271 | } |
1272 | ||
8a56e840 RH |
1273 | static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, |
1274 | TCGv_i64 arg2, int label_index) | |
c896fe29 | 1275 | { |
a7812ae4 | 1276 | tcg_gen_op4ii_i64(INDEX_op_brcond_i64, arg1, arg2, cond, label_index); |
c896fe29 FB |
1277 | } |
1278 | ||
8a56e840 | 1279 | static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret, |
5105c556 AJ |
1280 | TCGv_i64 arg1, TCGv_i64 arg2) |
1281 | { | |
1282 | tcg_gen_op4i_i64(INDEX_op_setcond_i64, ret, arg1, arg2, cond); | |
1283 | } | |
1284 | ||
a7812ae4 | 1285 | static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
c896fe29 | 1286 | { |
a7812ae4 | 1287 | tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2); |
c896fe29 FB |
1288 | } |
1289 | ||
31d66551 AJ |
1290 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
1291 | { | |
25c4d9cc RH |
1292 | if (TCG_TARGET_HAS_div_i64) { |
1293 | tcg_gen_op3_i64(INDEX_op_div_i64, ret, arg1, arg2); | |
1294 | } else if (TCG_TARGET_HAS_div2_i64) { | |
1295 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
1296 | tcg_gen_sari_i64(t0, arg1, 63); | |
1297 | tcg_gen_op5_i64(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2); | |
1298 | tcg_temp_free_i64(t0); | |
1299 | } else { | |
1300 | int sizemask = 0; | |
1301 | /* Return value and both arguments are 64-bit and signed. */ | |
1302 | sizemask |= tcg_gen_sizemask(0, 1, 1); | |
1303 | sizemask |= tcg_gen_sizemask(1, 1, 1); | |
1304 | sizemask |= tcg_gen_sizemask(2, 1, 1); | |
1305 | tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2); | |
1306 | } | |
31d66551 AJ |
1307 | } |
1308 | ||
1309 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) | |
1310 | { | |
25c4d9cc RH |
1311 | if (TCG_TARGET_HAS_div_i64) { |
1312 | tcg_gen_op3_i64(INDEX_op_rem_i64, ret, arg1, arg2); | |
1313 | } else if (TCG_TARGET_HAS_div2_i64) { | |
1314 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
1315 | tcg_gen_sari_i64(t0, arg1, 63); | |
1316 | tcg_gen_op5_i64(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2); | |
1317 | tcg_temp_free_i64(t0); | |
1318 | } else { | |
1319 | int sizemask = 0; | |
1320 | /* Return value and both arguments are 64-bit and signed. */ | |
1321 | sizemask |= tcg_gen_sizemask(0, 1, 1); | |
1322 | sizemask |= tcg_gen_sizemask(1, 1, 1); | |
1323 | sizemask |= tcg_gen_sizemask(2, 1, 1); | |
1324 | tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2); | |
1325 | } | |
31d66551 AJ |
1326 | } |
1327 | ||
1328 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) | |
1329 | { | |
25c4d9cc RH |
1330 | if (TCG_TARGET_HAS_div_i64) { |
1331 | tcg_gen_op3_i64(INDEX_op_divu_i64, ret, arg1, arg2); | |
1332 | } else if (TCG_TARGET_HAS_div2_i64) { | |
1333 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
1334 | tcg_gen_movi_i64(t0, 0); | |
1335 | tcg_gen_op5_i64(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2); | |
1336 | tcg_temp_free_i64(t0); | |
1337 | } else { | |
1338 | int sizemask = 0; | |
1339 | /* Return value and both arguments are 64-bit and unsigned. */ | |
1340 | sizemask |= tcg_gen_sizemask(0, 1, 0); | |
1341 | sizemask |= tcg_gen_sizemask(1, 1, 0); | |
1342 | sizemask |= tcg_gen_sizemask(2, 1, 0); | |
1343 | tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2); | |
1344 | } | |
31d66551 AJ |
1345 | } |
1346 | ||
1347 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) | |
1348 | { | |
25c4d9cc RH |
1349 | if (TCG_TARGET_HAS_div_i64) { |
1350 | tcg_gen_op3_i64(INDEX_op_remu_i64, ret, arg1, arg2); | |
1351 | } else if (TCG_TARGET_HAS_div2_i64) { | |
1352 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
1353 | tcg_gen_movi_i64(t0, 0); | |
1354 | tcg_gen_op5_i64(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2); | |
1355 | tcg_temp_free_i64(t0); | |
1356 | } else { | |
1357 | int sizemask = 0; | |
1358 | /* Return value and both arguments are 64-bit and unsigned. */ | |
1359 | sizemask |= tcg_gen_sizemask(0, 1, 0); | |
1360 | sizemask |= tcg_gen_sizemask(1, 1, 0); | |
1361 | sizemask |= tcg_gen_sizemask(2, 1, 0); | |
1362 | tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2); | |
1363 | } | |
31d66551 | 1364 | } |
25c4d9cc | 1365 | #endif /* TCG_TARGET_REG_BITS == 32 */ |
c896fe29 | 1366 | |
a7812ae4 | 1367 | static inline void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
6359706f AJ |
1368 | { |
1369 | /* some cases can be optimized here */ | |
1370 | if (arg2 == 0) { | |
1371 | tcg_gen_mov_i64(ret, arg1); | |
1372 | } else { | |
a7812ae4 | 1373 | TCGv_i64 t0 = tcg_const_i64(arg2); |
6359706f | 1374 | tcg_gen_add_i64(ret, arg1, t0); |
a7812ae4 | 1375 | tcg_temp_free_i64(t0); |
6359706f AJ |
1376 | } |
1377 | } | |
1378 | ||
a7812ae4 | 1379 | static inline void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2) |
0045734a | 1380 | { |
a7812ae4 | 1381 | TCGv_i64 t0 = tcg_const_i64(arg1); |
0045734a | 1382 | tcg_gen_sub_i64(ret, t0, arg2); |
a7812ae4 | 1383 | tcg_temp_free_i64(t0); |
0045734a AJ |
1384 | } |
1385 | ||
a7812ae4 | 1386 | static inline void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
6359706f AJ |
1387 | { |
1388 | /* some cases can be optimized here */ | |
1389 | if (arg2 == 0) { | |
1390 | tcg_gen_mov_i64(ret, arg1); | |
1391 | } else { | |
a7812ae4 | 1392 | TCGv_i64 t0 = tcg_const_i64(arg2); |
6359706f | 1393 | tcg_gen_sub_i64(ret, arg1, t0); |
a7812ae4 | 1394 | tcg_temp_free_i64(t0); |
6359706f AJ |
1395 | } |
1396 | } | |
8a56e840 RH |
1397 | static inline void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, |
1398 | int64_t arg2, int label_index) | |
f02bb954 | 1399 | { |
a7812ae4 | 1400 | TCGv_i64 t0 = tcg_const_i64(arg2); |
f02bb954 | 1401 | tcg_gen_brcond_i64(cond, arg1, t0, label_index); |
a7812ae4 | 1402 | tcg_temp_free_i64(t0); |
f02bb954 AJ |
1403 | } |
1404 | ||
8a56e840 RH |
1405 | static inline void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret, |
1406 | TCGv_i64 arg1, int64_t arg2) | |
5105c556 AJ |
1407 | { |
1408 | TCGv_i64 t0 = tcg_const_i64(arg2); | |
1409 | tcg_gen_setcond_i64(cond, ret, arg1, t0); | |
1410 | tcg_temp_free_i64(t0); | |
1411 | } | |
1412 | ||
a7812ae4 | 1413 | static inline void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
f02bb954 | 1414 | { |
a7812ae4 | 1415 | TCGv_i64 t0 = tcg_const_i64(arg2); |
f02bb954 | 1416 | tcg_gen_mul_i64(ret, arg1, t0); |
a7812ae4 | 1417 | tcg_temp_free_i64(t0); |
f02bb954 AJ |
1418 | } |
1419 | ||
6359706f | 1420 | |
c896fe29 FB |
1421 | /***************************************/ |
1422 | /* optional operations */ | |
1423 | ||
a7812ae4 | 1424 | static inline void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 | 1425 | { |
25c4d9cc RH |
1426 | if (TCG_TARGET_HAS_ext8s_i32) { |
1427 | tcg_gen_op2_i32(INDEX_op_ext8s_i32, ret, arg); | |
1428 | } else { | |
1429 | tcg_gen_shli_i32(ret, arg, 24); | |
1430 | tcg_gen_sari_i32(ret, ret, 24); | |
1431 | } | |
c896fe29 FB |
1432 | } |
1433 | ||
a7812ae4 | 1434 | static inline void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 | 1435 | { |
25c4d9cc RH |
1436 | if (TCG_TARGET_HAS_ext16s_i32) { |
1437 | tcg_gen_op2_i32(INDEX_op_ext16s_i32, ret, arg); | |
1438 | } else { | |
1439 | tcg_gen_shli_i32(ret, arg, 16); | |
1440 | tcg_gen_sari_i32(ret, ret, 16); | |
1441 | } | |
c896fe29 FB |
1442 | } |
1443 | ||
a7812ae4 | 1444 | static inline void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg) |
86831435 | 1445 | { |
25c4d9cc RH |
1446 | if (TCG_TARGET_HAS_ext8u_i32) { |
1447 | tcg_gen_op2_i32(INDEX_op_ext8u_i32, ret, arg); | |
1448 | } else { | |
1449 | tcg_gen_andi_i32(ret, arg, 0xffu); | |
1450 | } | |
86831435 PB |
1451 | } |
1452 | ||
a7812ae4 | 1453 | static inline void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg) |
86831435 | 1454 | { |
25c4d9cc RH |
1455 | if (TCG_TARGET_HAS_ext16u_i32) { |
1456 | tcg_gen_op2_i32(INDEX_op_ext16u_i32, ret, arg); | |
1457 | } else { | |
1458 | tcg_gen_andi_i32(ret, arg, 0xffffu); | |
1459 | } | |
86831435 PB |
1460 | } |
1461 | ||
c896fe29 | 1462 | /* Note: we assume the two high bytes are set to zero */ |
a7812ae4 | 1463 | static inline void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 | 1464 | { |
25c4d9cc RH |
1465 | if (TCG_TARGET_HAS_bswap16_i32) { |
1466 | tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg); | |
1467 | } else { | |
1468 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
c896fe29 | 1469 | |
25c4d9cc RH |
1470 | tcg_gen_ext8u_i32(t0, arg); |
1471 | tcg_gen_shli_i32(t0, t0, 8); | |
1472 | tcg_gen_shri_i32(ret, arg, 8); | |
1473 | tcg_gen_or_i32(ret, ret, t0); | |
1474 | tcg_temp_free_i32(t0); | |
1475 | } | |
c896fe29 FB |
1476 | } |
1477 | ||
66896cb8 | 1478 | static inline void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg) |
c896fe29 | 1479 | { |
25c4d9cc RH |
1480 | if (TCG_TARGET_HAS_bswap32_i32) { |
1481 | tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg); | |
1482 | } else { | |
1483 | TCGv_i32 t0, t1; | |
1484 | t0 = tcg_temp_new_i32(); | |
1485 | t1 = tcg_temp_new_i32(); | |
c896fe29 | 1486 | |
25c4d9cc | 1487 | tcg_gen_shli_i32(t0, arg, 24); |
c896fe29 | 1488 | |
25c4d9cc RH |
1489 | tcg_gen_andi_i32(t1, arg, 0x0000ff00); |
1490 | tcg_gen_shli_i32(t1, t1, 8); | |
1491 | tcg_gen_or_i32(t0, t0, t1); | |
c896fe29 | 1492 | |
25c4d9cc RH |
1493 | tcg_gen_shri_i32(t1, arg, 8); |
1494 | tcg_gen_andi_i32(t1, t1, 0x0000ff00); | |
1495 | tcg_gen_or_i32(t0, t0, t1); | |
c896fe29 | 1496 | |
25c4d9cc RH |
1497 | tcg_gen_shri_i32(t1, arg, 24); |
1498 | tcg_gen_or_i32(ret, t0, t1); | |
1499 | tcg_temp_free_i32(t0); | |
1500 | tcg_temp_free_i32(t1); | |
1501 | } | |
c896fe29 FB |
1502 | } |
1503 | ||
1504 | #if TCG_TARGET_REG_BITS == 32 | |
a7812ae4 | 1505 | static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1506 | { |
a7812ae4 PB |
1507 | tcg_gen_ext8s_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
1508 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1509 | } |
1510 | ||
a7812ae4 | 1511 | static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1512 | { |
a7812ae4 PB |
1513 | tcg_gen_ext16s_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
1514 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1515 | } |
1516 | ||
a7812ae4 | 1517 | static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1518 | { |
a7812ae4 PB |
1519 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
1520 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1521 | } |
1522 | ||
a7812ae4 | 1523 | static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1524 | { |
a7812ae4 | 1525 | tcg_gen_ext8u_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
86831435 PB |
1526 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
1527 | } | |
1528 | ||
a7812ae4 | 1529 | static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1530 | { |
a7812ae4 | 1531 | tcg_gen_ext16u_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
86831435 PB |
1532 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
1533 | } | |
1534 | ||
a7812ae4 | 1535 | static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1536 | { |
a7812ae4 | 1537 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
86831435 PB |
1538 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
1539 | } | |
1540 | ||
a7812ae4 | 1541 | static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg) |
c896fe29 | 1542 | { |
a7812ae4 | 1543 | tcg_gen_mov_i32(ret, TCGV_LOW(arg)); |
c896fe29 FB |
1544 | } |
1545 | ||
a7812ae4 | 1546 | static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1547 | { |
a7812ae4 | 1548 | tcg_gen_mov_i32(TCGV_LOW(ret), arg); |
ac56dd48 | 1549 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
1550 | } |
1551 | ||
a7812ae4 | 1552 | static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1553 | { |
a7812ae4 PB |
1554 | tcg_gen_mov_i32(TCGV_LOW(ret), arg); |
1555 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
1556 | } |
1557 | ||
9a5c57fd AJ |
1558 | /* Note: we assume the six high bytes are set to zero */ |
1559 | static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg) | |
1560 | { | |
1561 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); | |
1562 | tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg)); | |
1563 | } | |
1564 | ||
1565 | /* Note: we assume the four high bytes are set to zero */ | |
1566 | static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) | |
1567 | { | |
1568 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); | |
1569 | tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg)); | |
1570 | } | |
1571 | ||
66896cb8 | 1572 | static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1573 | { |
a7812ae4 PB |
1574 | TCGv_i32 t0, t1; |
1575 | t0 = tcg_temp_new_i32(); | |
1576 | t1 = tcg_temp_new_i32(); | |
c896fe29 | 1577 | |
66896cb8 AJ |
1578 | tcg_gen_bswap32_i32(t0, TCGV_LOW(arg)); |
1579 | tcg_gen_bswap32_i32(t1, TCGV_HIGH(arg)); | |
a7812ae4 | 1580 | tcg_gen_mov_i32(TCGV_LOW(ret), t1); |
ac56dd48 | 1581 | tcg_gen_mov_i32(TCGV_HIGH(ret), t0); |
a7812ae4 PB |
1582 | tcg_temp_free_i32(t0); |
1583 | tcg_temp_free_i32(t1); | |
c896fe29 FB |
1584 | } |
1585 | #else | |
1586 | ||
a7812ae4 | 1587 | static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1588 | { |
25c4d9cc RH |
1589 | if (TCG_TARGET_HAS_ext8s_i64) { |
1590 | tcg_gen_op2_i64(INDEX_op_ext8s_i64, ret, arg); | |
1591 | } else { | |
1592 | tcg_gen_shli_i64(ret, arg, 56); | |
1593 | tcg_gen_sari_i64(ret, ret, 56); | |
1594 | } | |
c896fe29 FB |
1595 | } |
1596 | ||
a7812ae4 | 1597 | static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1598 | { |
25c4d9cc RH |
1599 | if (TCG_TARGET_HAS_ext16s_i64) { |
1600 | tcg_gen_op2_i64(INDEX_op_ext16s_i64, ret, arg); | |
1601 | } else { | |
1602 | tcg_gen_shli_i64(ret, arg, 48); | |
1603 | tcg_gen_sari_i64(ret, ret, 48); | |
1604 | } | |
c896fe29 FB |
1605 | } |
1606 | ||
a7812ae4 | 1607 | static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1608 | { |
25c4d9cc RH |
1609 | if (TCG_TARGET_HAS_ext32s_i64) { |
1610 | tcg_gen_op2_i64(INDEX_op_ext32s_i64, ret, arg); | |
1611 | } else { | |
1612 | tcg_gen_shli_i64(ret, arg, 32); | |
1613 | tcg_gen_sari_i64(ret, ret, 32); | |
1614 | } | |
c896fe29 FB |
1615 | } |
1616 | ||
a7812ae4 | 1617 | static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1618 | { |
25c4d9cc RH |
1619 | if (TCG_TARGET_HAS_ext8u_i64) { |
1620 | tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg); | |
1621 | } else { | |
1622 | tcg_gen_andi_i64(ret, arg, 0xffu); | |
1623 | } | |
86831435 PB |
1624 | } |
1625 | ||
a7812ae4 | 1626 | static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1627 | { |
25c4d9cc RH |
1628 | if (TCG_TARGET_HAS_ext16u_i64) { |
1629 | tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg); | |
1630 | } else { | |
1631 | tcg_gen_andi_i64(ret, arg, 0xffffu); | |
1632 | } | |
86831435 PB |
1633 | } |
1634 | ||
a7812ae4 | 1635 | static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) |
86831435 | 1636 | { |
25c4d9cc RH |
1637 | if (TCG_TARGET_HAS_ext32u_i64) { |
1638 | tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg); | |
1639 | } else { | |
1640 | tcg_gen_andi_i64(ret, arg, 0xffffffffu); | |
1641 | } | |
86831435 PB |
1642 | } |
1643 | ||
c896fe29 | 1644 | /* Note: we assume the target supports move between 32 and 64 bit |
ac56dd48 | 1645 | registers. This will probably break MIPS64 targets. */ |
a7812ae4 | 1646 | static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg) |
c896fe29 | 1647 | { |
a7812ae4 | 1648 | tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg))); |
c896fe29 FB |
1649 | } |
1650 | ||
1651 | /* Note: we assume the target supports move between 32 and 64 bit | |
1652 | registers */ | |
a7812ae4 | 1653 | static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1654 | { |
cfc86988 | 1655 | tcg_gen_ext32u_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg))); |
c896fe29 FB |
1656 | } |
1657 | ||
1658 | /* Note: we assume the target supports move between 32 and 64 bit | |
1659 | registers */ | |
a7812ae4 | 1660 | static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
c896fe29 | 1661 | { |
a7812ae4 | 1662 | tcg_gen_ext32s_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg))); |
c896fe29 FB |
1663 | } |
1664 | ||
9a5c57fd AJ |
1665 | /* Note: we assume the six high bytes are set to zero */ |
1666 | static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg) | |
1667 | { | |
25c4d9cc RH |
1668 | if (TCG_TARGET_HAS_bswap16_i64) { |
1669 | tcg_gen_op2_i64(INDEX_op_bswap16_i64, ret, arg); | |
1670 | } else { | |
1671 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
9a5c57fd | 1672 | |
25c4d9cc RH |
1673 | tcg_gen_ext8u_i64(t0, arg); |
1674 | tcg_gen_shli_i64(t0, t0, 8); | |
1675 | tcg_gen_shri_i64(ret, arg, 8); | |
1676 | tcg_gen_or_i64(ret, ret, t0); | |
1677 | tcg_temp_free_i64(t0); | |
1678 | } | |
9a5c57fd AJ |
1679 | } |
1680 | ||
1681 | /* Note: we assume the four high bytes are set to zero */ | |
1682 | static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) | |
1683 | { | |
25c4d9cc RH |
1684 | if (TCG_TARGET_HAS_bswap32_i64) { |
1685 | tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg); | |
1686 | } else { | |
1687 | TCGv_i64 t0, t1; | |
1688 | t0 = tcg_temp_new_i64(); | |
1689 | t1 = tcg_temp_new_i64(); | |
9a5c57fd | 1690 | |
25c4d9cc RH |
1691 | tcg_gen_shli_i64(t0, arg, 24); |
1692 | tcg_gen_ext32u_i64(t0, t0); | |
9a5c57fd | 1693 | |
25c4d9cc RH |
1694 | tcg_gen_andi_i64(t1, arg, 0x0000ff00); |
1695 | tcg_gen_shli_i64(t1, t1, 8); | |
1696 | tcg_gen_or_i64(t0, t0, t1); | |
9a5c57fd | 1697 | |
25c4d9cc RH |
1698 | tcg_gen_shri_i64(t1, arg, 8); |
1699 | tcg_gen_andi_i64(t1, t1, 0x0000ff00); | |
1700 | tcg_gen_or_i64(t0, t0, t1); | |
9a5c57fd | 1701 | |
25c4d9cc RH |
1702 | tcg_gen_shri_i64(t1, arg, 24); |
1703 | tcg_gen_or_i64(ret, t0, t1); | |
1704 | tcg_temp_free_i64(t0); | |
1705 | tcg_temp_free_i64(t1); | |
1706 | } | |
9a5c57fd AJ |
1707 | } |
1708 | ||
66896cb8 | 1709 | static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg) |
c896fe29 | 1710 | { |
25c4d9cc RH |
1711 | if (TCG_TARGET_HAS_bswap64_i64) { |
1712 | tcg_gen_op2_i64(INDEX_op_bswap64_i64, ret, arg); | |
1713 | } else { | |
1714 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
1715 | TCGv_i64 t1 = tcg_temp_new_i64(); | |
c896fe29 | 1716 | |
25c4d9cc | 1717 | tcg_gen_shli_i64(t0, arg, 56); |
c896fe29 | 1718 | |
25c4d9cc RH |
1719 | tcg_gen_andi_i64(t1, arg, 0x0000ff00); |
1720 | tcg_gen_shli_i64(t1, t1, 40); | |
1721 | tcg_gen_or_i64(t0, t0, t1); | |
c896fe29 | 1722 | |
25c4d9cc RH |
1723 | tcg_gen_andi_i64(t1, arg, 0x00ff0000); |
1724 | tcg_gen_shli_i64(t1, t1, 24); | |
1725 | tcg_gen_or_i64(t0, t0, t1); | |
c896fe29 | 1726 | |
25c4d9cc RH |
1727 | tcg_gen_andi_i64(t1, arg, 0xff000000); |
1728 | tcg_gen_shli_i64(t1, t1, 8); | |
1729 | tcg_gen_or_i64(t0, t0, t1); | |
c896fe29 | 1730 | |
25c4d9cc RH |
1731 | tcg_gen_shri_i64(t1, arg, 8); |
1732 | tcg_gen_andi_i64(t1, t1, 0xff000000); | |
1733 | tcg_gen_or_i64(t0, t0, t1); | |
c896fe29 | 1734 | |
25c4d9cc RH |
1735 | tcg_gen_shri_i64(t1, arg, 24); |
1736 | tcg_gen_andi_i64(t1, t1, 0x00ff0000); | |
1737 | tcg_gen_or_i64(t0, t0, t1); | |
c896fe29 | 1738 | |
25c4d9cc RH |
1739 | tcg_gen_shri_i64(t1, arg, 40); |
1740 | tcg_gen_andi_i64(t1, t1, 0x0000ff00); | |
1741 | tcg_gen_or_i64(t0, t0, t1); | |
c896fe29 | 1742 | |
25c4d9cc RH |
1743 | tcg_gen_shri_i64(t1, arg, 56); |
1744 | tcg_gen_or_i64(ret, t0, t1); | |
1745 | tcg_temp_free_i64(t0); | |
1746 | tcg_temp_free_i64(t1); | |
1747 | } | |
c896fe29 FB |
1748 | } |
1749 | ||
1750 | #endif | |
1751 | ||
a7812ae4 | 1752 | static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg) |
390efc54 | 1753 | { |
25c4d9cc RH |
1754 | if (TCG_TARGET_HAS_neg_i32) { |
1755 | tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg); | |
1756 | } else { | |
1757 | TCGv_i32 t0 = tcg_const_i32(0); | |
1758 | tcg_gen_sub_i32(ret, t0, arg); | |
1759 | tcg_temp_free_i32(t0); | |
1760 | } | |
390efc54 PB |
1761 | } |
1762 | ||
a7812ae4 | 1763 | static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg) |
390efc54 | 1764 | { |
25c4d9cc RH |
1765 | if (TCG_TARGET_HAS_neg_i64) { |
1766 | tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg); | |
1767 | } else { | |
1768 | TCGv_i64 t0 = tcg_const_i64(0); | |
1769 | tcg_gen_sub_i64(ret, t0, arg); | |
1770 | tcg_temp_free_i64(t0); | |
1771 | } | |
390efc54 PB |
1772 | } |
1773 | ||
a7812ae4 | 1774 | static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg) |
0b6ce4cf | 1775 | { |
25c4d9cc RH |
1776 | if (TCG_TARGET_HAS_not_i32) { |
1777 | tcg_gen_op2_i32(INDEX_op_not_i32, ret, arg); | |
1778 | } else { | |
1779 | tcg_gen_xori_i32(ret, arg, -1); | |
1780 | } | |
0b6ce4cf FB |
1781 | } |
1782 | ||
a7812ae4 | 1783 | static inline void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg) |
0b6ce4cf | 1784 | { |
25c4d9cc RH |
1785 | #if TCG_TARGET_REG_BITS == 64 |
1786 | if (TCG_TARGET_HAS_not_i64) { | |
1787 | tcg_gen_op2_i64(INDEX_op_not_i64, ret, arg); | |
1788 | } else { | |
1789 | tcg_gen_xori_i64(ret, arg, -1); | |
1790 | } | |
1791 | #else | |
a10f9f4f RH |
1792 | tcg_gen_not_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
1793 | tcg_gen_not_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); | |
d2604285 | 1794 | #endif |
0b6ce4cf | 1795 | } |
5ff9d6a4 | 1796 | |
a7812ae4 | 1797 | static inline void tcg_gen_discard_i32(TCGv_i32 arg) |
5ff9d6a4 | 1798 | { |
a7812ae4 | 1799 | tcg_gen_op1_i32(INDEX_op_discard, arg); |
5ff9d6a4 FB |
1800 | } |
1801 | ||
a7812ae4 | 1802 | static inline void tcg_gen_discard_i64(TCGv_i64 arg) |
5ff9d6a4 | 1803 | { |
25c4d9cc | 1804 | #if TCG_TARGET_REG_BITS == 32 |
a7812ae4 | 1805 | tcg_gen_discard_i32(TCGV_LOW(arg)); |
5ff9d6a4 | 1806 | tcg_gen_discard_i32(TCGV_HIGH(arg)); |
5ff9d6a4 | 1807 | #else |
a7812ae4 | 1808 | tcg_gen_op1_i64(INDEX_op_discard, arg); |
5ff9d6a4 | 1809 | #endif |
25c4d9cc | 1810 | } |
5ff9d6a4 | 1811 | |
a7812ae4 | 1812 | static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1813 | { |
25c4d9cc RH |
1814 | if (TCG_TARGET_HAS_andc_i32) { |
1815 | tcg_gen_op3_i32(INDEX_op_andc_i32, ret, arg1, arg2); | |
1816 | } else { | |
1817 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
1818 | tcg_gen_not_i32(t0, arg2); | |
1819 | tcg_gen_and_i32(ret, arg1, t0); | |
1820 | tcg_temp_free_i32(t0); | |
1821 | } | |
f24cb33e AJ |
1822 | } |
1823 | ||
a7812ae4 | 1824 | static inline void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1825 | { |
25c4d9cc RH |
1826 | #if TCG_TARGET_REG_BITS == 64 |
1827 | if (TCG_TARGET_HAS_andc_i64) { | |
1828 | tcg_gen_op3_i64(INDEX_op_andc_i64, ret, arg1, arg2); | |
1829 | } else { | |
1830 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
1831 | tcg_gen_not_i64(t0, arg2); | |
1832 | tcg_gen_and_i64(ret, arg1, t0); | |
1833 | tcg_temp_free_i64(t0); | |
1834 | } | |
1835 | #else | |
241cbed4 RH |
1836 | tcg_gen_andc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
1837 | tcg_gen_andc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
241cbed4 | 1838 | #endif |
f24cb33e AJ |
1839 | } |
1840 | ||
a7812ae4 | 1841 | static inline void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1842 | { |
25c4d9cc RH |
1843 | if (TCG_TARGET_HAS_eqv_i32) { |
1844 | tcg_gen_op3_i32(INDEX_op_eqv_i32, ret, arg1, arg2); | |
1845 | } else { | |
1846 | tcg_gen_xor_i32(ret, arg1, arg2); | |
1847 | tcg_gen_not_i32(ret, ret); | |
1848 | } | |
f24cb33e AJ |
1849 | } |
1850 | ||
a7812ae4 | 1851 | static inline void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1852 | { |
25c4d9cc RH |
1853 | #if TCG_TARGET_REG_BITS == 64 |
1854 | if (TCG_TARGET_HAS_eqv_i64) { | |
1855 | tcg_gen_op3_i64(INDEX_op_eqv_i64, ret, arg1, arg2); | |
1856 | } else { | |
1857 | tcg_gen_xor_i64(ret, arg1, arg2); | |
1858 | tcg_gen_not_i64(ret, ret); | |
1859 | } | |
1860 | #else | |
8d625cf1 RH |
1861 | tcg_gen_eqv_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
1862 | tcg_gen_eqv_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
8d625cf1 | 1863 | #endif |
f24cb33e AJ |
1864 | } |
1865 | ||
a7812ae4 | 1866 | static inline void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1867 | { |
25c4d9cc RH |
1868 | if (TCG_TARGET_HAS_nand_i32) { |
1869 | tcg_gen_op3_i32(INDEX_op_nand_i32, ret, arg1, arg2); | |
1870 | } else { | |
1871 | tcg_gen_and_i32(ret, arg1, arg2); | |
1872 | tcg_gen_not_i32(ret, ret); | |
1873 | } | |
f24cb33e AJ |
1874 | } |
1875 | ||
a7812ae4 | 1876 | static inline void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1877 | { |
25c4d9cc RH |
1878 | #if TCG_TARGET_REG_BITS == 64 |
1879 | if (TCG_TARGET_HAS_nand_i64) { | |
1880 | tcg_gen_op3_i64(INDEX_op_nand_i64, ret, arg1, arg2); | |
1881 | } else { | |
1882 | tcg_gen_and_i64(ret, arg1, arg2); | |
1883 | tcg_gen_not_i64(ret, ret); | |
1884 | } | |
1885 | #else | |
9940a96b RH |
1886 | tcg_gen_nand_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
1887 | tcg_gen_nand_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
9940a96b | 1888 | #endif |
f24cb33e AJ |
1889 | } |
1890 | ||
a7812ae4 | 1891 | static inline void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1892 | { |
25c4d9cc RH |
1893 | if (TCG_TARGET_HAS_nor_i32) { |
1894 | tcg_gen_op3_i32(INDEX_op_nor_i32, ret, arg1, arg2); | |
1895 | } else { | |
1896 | tcg_gen_or_i32(ret, arg1, arg2); | |
1897 | tcg_gen_not_i32(ret, ret); | |
1898 | } | |
f24cb33e AJ |
1899 | } |
1900 | ||
a7812ae4 | 1901 | static inline void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1902 | { |
25c4d9cc RH |
1903 | #if TCG_TARGET_REG_BITS == 64 |
1904 | if (TCG_TARGET_HAS_nor_i64) { | |
1905 | tcg_gen_op3_i64(INDEX_op_nor_i64, ret, arg1, arg2); | |
1906 | } else { | |
1907 | tcg_gen_or_i64(ret, arg1, arg2); | |
1908 | tcg_gen_not_i64(ret, ret); | |
1909 | } | |
1910 | #else | |
32d98fbd RH |
1911 | tcg_gen_nor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
1912 | tcg_gen_nor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
32d98fbd | 1913 | #endif |
f24cb33e AJ |
1914 | } |
1915 | ||
a7812ae4 | 1916 | static inline void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
f24cb33e | 1917 | { |
25c4d9cc RH |
1918 | if (TCG_TARGET_HAS_orc_i32) { |
1919 | tcg_gen_op3_i32(INDEX_op_orc_i32, ret, arg1, arg2); | |
1920 | } else { | |
1921 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
1922 | tcg_gen_not_i32(t0, arg2); | |
1923 | tcg_gen_or_i32(ret, arg1, t0); | |
1924 | tcg_temp_free_i32(t0); | |
1925 | } | |
f24cb33e AJ |
1926 | } |
1927 | ||
a7812ae4 | 1928 | static inline void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
f24cb33e | 1929 | { |
25c4d9cc RH |
1930 | #if TCG_TARGET_REG_BITS == 64 |
1931 | if (TCG_TARGET_HAS_orc_i64) { | |
1932 | tcg_gen_op3_i64(INDEX_op_orc_i64, ret, arg1, arg2); | |
1933 | } else { | |
1934 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
1935 | tcg_gen_not_i64(t0, arg2); | |
1936 | tcg_gen_or_i64(ret, arg1, t0); | |
1937 | tcg_temp_free_i64(t0); | |
1938 | } | |
1939 | #else | |
791d1262 RH |
1940 | tcg_gen_orc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
1941 | tcg_gen_orc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
791d1262 | 1942 | #endif |
f24cb33e AJ |
1943 | } |
1944 | ||
a7812ae4 | 1945 | static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
15824571 | 1946 | { |
25c4d9cc RH |
1947 | if (TCG_TARGET_HAS_rot_i32) { |
1948 | tcg_gen_op3_i32(INDEX_op_rotl_i32, ret, arg1, arg2); | |
1949 | } else { | |
1950 | TCGv_i32 t0, t1; | |
15824571 | 1951 | |
25c4d9cc RH |
1952 | t0 = tcg_temp_new_i32(); |
1953 | t1 = tcg_temp_new_i32(); | |
1954 | tcg_gen_shl_i32(t0, arg1, arg2); | |
1955 | tcg_gen_subfi_i32(t1, 32, arg2); | |
1956 | tcg_gen_shr_i32(t1, arg1, t1); | |
1957 | tcg_gen_or_i32(ret, t0, t1); | |
1958 | tcg_temp_free_i32(t0); | |
1959 | tcg_temp_free_i32(t1); | |
1960 | } | |
15824571 AJ |
1961 | } |
1962 | ||
a7812ae4 | 1963 | static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
15824571 | 1964 | { |
25c4d9cc RH |
1965 | if (TCG_TARGET_HAS_rot_i64) { |
1966 | tcg_gen_op3_i64(INDEX_op_rotl_i64, ret, arg1, arg2); | |
1967 | } else { | |
1968 | TCGv_i64 t0, t1; | |
1969 | t0 = tcg_temp_new_i64(); | |
1970 | t1 = tcg_temp_new_i64(); | |
1971 | tcg_gen_shl_i64(t0, arg1, arg2); | |
1972 | tcg_gen_subfi_i64(t1, 64, arg2); | |
1973 | tcg_gen_shr_i64(t1, arg1, t1); | |
1974 | tcg_gen_or_i64(ret, t0, t1); | |
1975 | tcg_temp_free_i64(t0); | |
1976 | tcg_temp_free_i64(t1); | |
1977 | } | |
15824571 AJ |
1978 | } |
1979 | ||
a7812ae4 | 1980 | static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
15824571 AJ |
1981 | { |
1982 | /* some cases can be optimized here */ | |
1983 | if (arg2 == 0) { | |
1984 | tcg_gen_mov_i32(ret, arg1); | |
25c4d9cc | 1985 | } else if (TCG_TARGET_HAS_rot_i32) { |
d42f183c AJ |
1986 | TCGv_i32 t0 = tcg_const_i32(arg2); |
1987 | tcg_gen_rotl_i32(ret, arg1, t0); | |
1988 | tcg_temp_free_i32(t0); | |
25c4d9cc | 1989 | } else { |
a7812ae4 PB |
1990 | TCGv_i32 t0, t1; |
1991 | t0 = tcg_temp_new_i32(); | |
1992 | t1 = tcg_temp_new_i32(); | |
15824571 AJ |
1993 | tcg_gen_shli_i32(t0, arg1, arg2); |
1994 | tcg_gen_shri_i32(t1, arg1, 32 - arg2); | |
1995 | tcg_gen_or_i32(ret, t0, t1); | |
a7812ae4 PB |
1996 | tcg_temp_free_i32(t0); |
1997 | tcg_temp_free_i32(t1); | |
15824571 AJ |
1998 | } |
1999 | } | |
2000 | ||
a7812ae4 | 2001 | static inline void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
15824571 AJ |
2002 | { |
2003 | /* some cases can be optimized here */ | |
2004 | if (arg2 == 0) { | |
2005 | tcg_gen_mov_i64(ret, arg1); | |
25c4d9cc | 2006 | } else if (TCG_TARGET_HAS_rot_i64) { |
d42f183c AJ |
2007 | TCGv_i64 t0 = tcg_const_i64(arg2); |
2008 | tcg_gen_rotl_i64(ret, arg1, t0); | |
2009 | tcg_temp_free_i64(t0); | |
25c4d9cc | 2010 | } else { |
a7812ae4 PB |
2011 | TCGv_i64 t0, t1; |
2012 | t0 = tcg_temp_new_i64(); | |
2013 | t1 = tcg_temp_new_i64(); | |
15824571 AJ |
2014 | tcg_gen_shli_i64(t0, arg1, arg2); |
2015 | tcg_gen_shri_i64(t1, arg1, 64 - arg2); | |
2016 | tcg_gen_or_i64(ret, t0, t1); | |
a7812ae4 PB |
2017 | tcg_temp_free_i64(t0); |
2018 | tcg_temp_free_i64(t1); | |
15824571 AJ |
2019 | } |
2020 | } | |
2021 | ||
a7812ae4 | 2022 | static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
15824571 | 2023 | { |
25c4d9cc RH |
2024 | if (TCG_TARGET_HAS_rot_i32) { |
2025 | tcg_gen_op3_i32(INDEX_op_rotr_i32, ret, arg1, arg2); | |
2026 | } else { | |
2027 | TCGv_i32 t0, t1; | |
15824571 | 2028 | |
25c4d9cc RH |
2029 | t0 = tcg_temp_new_i32(); |
2030 | t1 = tcg_temp_new_i32(); | |
2031 | tcg_gen_shr_i32(t0, arg1, arg2); | |
2032 | tcg_gen_subfi_i32(t1, 32, arg2); | |
2033 | tcg_gen_shl_i32(t1, arg1, t1); | |
2034 | tcg_gen_or_i32(ret, t0, t1); | |
2035 | tcg_temp_free_i32(t0); | |
2036 | tcg_temp_free_i32(t1); | |
2037 | } | |
15824571 AJ |
2038 | } |
2039 | ||
a7812ae4 | 2040 | static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
15824571 | 2041 | { |
25c4d9cc RH |
2042 | if (TCG_TARGET_HAS_rot_i64) { |
2043 | tcg_gen_op3_i64(INDEX_op_rotr_i64, ret, arg1, arg2); | |
2044 | } else { | |
2045 | TCGv_i64 t0, t1; | |
2046 | t0 = tcg_temp_new_i64(); | |
2047 | t1 = tcg_temp_new_i64(); | |
2048 | tcg_gen_shr_i64(t0, arg1, arg2); | |
2049 | tcg_gen_subfi_i64(t1, 64, arg2); | |
2050 | tcg_gen_shl_i64(t1, arg1, t1); | |
2051 | tcg_gen_or_i64(ret, t0, t1); | |
2052 | tcg_temp_free_i64(t0); | |
2053 | tcg_temp_free_i64(t1); | |
2054 | } | |
15824571 AJ |
2055 | } |
2056 | ||
a7812ae4 | 2057 | static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
15824571 AJ |
2058 | { |
2059 | /* some cases can be optimized here */ | |
2060 | if (arg2 == 0) { | |
2061 | tcg_gen_mov_i32(ret, arg1); | |
2062 | } else { | |
2063 | tcg_gen_rotli_i32(ret, arg1, 32 - arg2); | |
2064 | } | |
2065 | } | |
2066 | ||
a7812ae4 | 2067 | static inline void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
15824571 AJ |
2068 | { |
2069 | /* some cases can be optimized here */ | |
2070 | if (arg2 == 0) { | |
de3526b2 | 2071 | tcg_gen_mov_i64(ret, arg1); |
15824571 AJ |
2072 | } else { |
2073 | tcg_gen_rotli_i64(ret, arg1, 64 - arg2); | |
2074 | } | |
2075 | } | |
2076 | ||
b7767f0f | 2077 | static inline void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, |
0756e71c RH |
2078 | TCGv_i32 arg2, unsigned int ofs, |
2079 | unsigned int len) | |
b7767f0f | 2080 | { |
df072774 RH |
2081 | uint32_t mask; |
2082 | TCGv_i32 t1; | |
2083 | ||
717e7036 RH |
2084 | tcg_debug_assert(ofs < 32); |
2085 | tcg_debug_assert(len <= 32); | |
2086 | tcg_debug_assert(ofs + len <= 32); | |
2087 | ||
df072774 RH |
2088 | if (ofs == 0 && len == 32) { |
2089 | tcg_gen_mov_i32(ret, arg2); | |
2090 | return; | |
2091 | } | |
a4773324 | 2092 | if (TCG_TARGET_HAS_deposit_i32 && TCG_TARGET_deposit_i32_valid(ofs, len)) { |
25c4d9cc | 2093 | tcg_gen_op5ii_i32(INDEX_op_deposit_i32, ret, arg1, arg2, ofs, len); |
df072774 RH |
2094 | return; |
2095 | } | |
2096 | ||
2097 | mask = (1u << len) - 1; | |
2098 | t1 = tcg_temp_new_i32(); | |
b7767f0f | 2099 | |
df072774 | 2100 | if (ofs + len < 32) { |
25c4d9cc RH |
2101 | tcg_gen_andi_i32(t1, arg2, mask); |
2102 | tcg_gen_shli_i32(t1, t1, ofs); | |
df072774 RH |
2103 | } else { |
2104 | tcg_gen_shli_i32(t1, arg2, ofs); | |
25c4d9cc | 2105 | } |
df072774 RH |
2106 | tcg_gen_andi_i32(ret, arg1, ~(mask << ofs)); |
2107 | tcg_gen_or_i32(ret, ret, t1); | |
2108 | ||
2109 | tcg_temp_free_i32(t1); | |
b7767f0f RH |
2110 | } |
2111 | ||
2112 | static inline void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, | |
0756e71c RH |
2113 | TCGv_i64 arg2, unsigned int ofs, |
2114 | unsigned int len) | |
b7767f0f | 2115 | { |
df072774 RH |
2116 | uint64_t mask; |
2117 | TCGv_i64 t1; | |
2118 | ||
717e7036 RH |
2119 | tcg_debug_assert(ofs < 64); |
2120 | tcg_debug_assert(len <= 64); | |
2121 | tcg_debug_assert(ofs + len <= 64); | |
2122 | ||
df072774 RH |
2123 | if (ofs == 0 && len == 64) { |
2124 | tcg_gen_mov_i64(ret, arg2); | |
2125 | return; | |
2126 | } | |
a4773324 | 2127 | if (TCG_TARGET_HAS_deposit_i64 && TCG_TARGET_deposit_i64_valid(ofs, len)) { |
25c4d9cc | 2128 | tcg_gen_op5ii_i64(INDEX_op_deposit_i64, ret, arg1, arg2, ofs, len); |
df072774 RH |
2129 | return; |
2130 | } | |
b7767f0f | 2131 | |
df072774 RH |
2132 | #if TCG_TARGET_REG_BITS == 32 |
2133 | if (ofs >= 32) { | |
2f98c9db | 2134 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg1)); |
df072774 RH |
2135 | tcg_gen_deposit_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), |
2136 | TCGV_LOW(arg2), ofs - 32, len); | |
2137 | return; | |
2138 | } | |
2139 | if (ofs + len <= 32) { | |
2140 | tcg_gen_deposit_i32(TCGV_LOW(ret), TCGV_LOW(arg1), | |
2141 | TCGV_LOW(arg2), ofs, len); | |
2f98c9db | 2142 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1)); |
df072774 RH |
2143 | return; |
2144 | } | |
2145 | #endif | |
2146 | ||
2147 | mask = (1ull << len) - 1; | |
2148 | t1 = tcg_temp_new_i64(); | |
2149 | ||
2150 | if (ofs + len < 64) { | |
25c4d9cc RH |
2151 | tcg_gen_andi_i64(t1, arg2, mask); |
2152 | tcg_gen_shli_i64(t1, t1, ofs); | |
df072774 RH |
2153 | } else { |
2154 | tcg_gen_shli_i64(t1, arg2, ofs); | |
25c4d9cc | 2155 | } |
df072774 RH |
2156 | tcg_gen_andi_i64(ret, arg1, ~(mask << ofs)); |
2157 | tcg_gen_or_i64(ret, ret, t1); | |
2158 | ||
2159 | tcg_temp_free_i64(t1); | |
b7767f0f RH |
2160 | } |
2161 | ||
77276f65 RH |
2162 | static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, |
2163 | TCGv_i32 high) | |
2164 | { | |
2165 | #if TCG_TARGET_REG_BITS == 32 | |
2166 | tcg_gen_mov_i32(TCGV_LOW(dest), low); | |
2167 | tcg_gen_mov_i32(TCGV_HIGH(dest), high); | |
2168 | #else | |
2169 | TCGv_i64 tmp = tcg_temp_new_i64(); | |
2170 | /* These extensions are only needed for type correctness. | |
2171 | We may be able to do better given target specific information. */ | |
2172 | tcg_gen_extu_i32_i64(tmp, high); | |
2173 | tcg_gen_extu_i32_i64(dest, low); | |
2174 | /* If deposit is available, use it. Otherwise use the extra | |
2175 | knowledge that we have of the zero-extensions above. */ | |
2176 | if (TCG_TARGET_HAS_deposit_i64 && TCG_TARGET_deposit_i64_valid(32, 32)) { | |
2177 | tcg_gen_deposit_i64(dest, dest, tmp, 32, 32); | |
2178 | } else { | |
2179 | tcg_gen_shli_i64(tmp, tmp, 32); | |
2180 | tcg_gen_or_i64(dest, dest, tmp); | |
2181 | } | |
2182 | tcg_temp_free_i64(tmp); | |
2183 | #endif | |
2184 | } | |
2185 | ||
2186 | static inline void tcg_gen_concat32_i64(TCGv_i64 dest, TCGv_i64 low, | |
2187 | TCGv_i64 high) | |
2188 | { | |
2189 | tcg_gen_deposit_i64(dest, low, high, 32, 32); | |
2190 | } | |
2191 | ||
ffc5ea09 RH |
2192 | static inline void tcg_gen_movcond_i32(TCGCond cond, TCGv_i32 ret, |
2193 | TCGv_i32 c1, TCGv_i32 c2, | |
2194 | TCGv_i32 v1, TCGv_i32 v2) | |
2195 | { | |
2196 | if (TCG_TARGET_HAS_movcond_i32) { | |
2197 | tcg_gen_op6i_i32(INDEX_op_movcond_i32, ret, c1, c2, v1, v2, cond); | |
2198 | } else { | |
2199 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
2200 | TCGv_i32 t1 = tcg_temp_new_i32(); | |
2201 | tcg_gen_setcond_i32(cond, t0, c1, c2); | |
2202 | tcg_gen_neg_i32(t0, t0); | |
2203 | tcg_gen_and_i32(t1, v1, t0); | |
2204 | tcg_gen_andc_i32(ret, v2, t0); | |
2205 | tcg_gen_or_i32(ret, ret, t1); | |
2206 | tcg_temp_free_i32(t0); | |
2207 | tcg_temp_free_i32(t1); | |
2208 | } | |
2209 | } | |
2210 | ||
2211 | static inline void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, | |
2212 | TCGv_i64 c1, TCGv_i64 c2, | |
2213 | TCGv_i64 v1, TCGv_i64 v2) | |
2214 | { | |
2215 | if (TCG_TARGET_HAS_movcond_i64) { | |
2216 | tcg_gen_op6i_i64(INDEX_op_movcond_i64, ret, c1, c2, v1, v2, cond); | |
2217 | } else { | |
2218 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
2219 | TCGv_i64 t1 = tcg_temp_new_i64(); | |
2220 | tcg_gen_setcond_i64(cond, t0, c1, c2); | |
2221 | tcg_gen_neg_i64(t0, t0); | |
2222 | tcg_gen_and_i64(t1, v1, t0); | |
2223 | tcg_gen_andc_i64(ret, v2, t0); | |
2224 | tcg_gen_or_i64(ret, ret, t1); | |
2225 | tcg_temp_free_i64(t0); | |
2226 | tcg_temp_free_i64(t1); | |
2227 | } | |
2228 | } | |
2229 | ||
c896fe29 FB |
2230 | /***************************************/ |
2231 | /* QEMU specific operations. Their type depend on the QEMU CPU | |
2232 | type. */ | |
2233 | #ifndef TARGET_LONG_BITS | |
2234 | #error must include QEMU headers | |
2235 | #endif | |
2236 | ||
a7812ae4 PB |
2237 | #if TARGET_LONG_BITS == 32 |
2238 | #define TCGv TCGv_i32 | |
2239 | #define tcg_temp_new() tcg_temp_new_i32() | |
2240 | #define tcg_global_reg_new tcg_global_reg_new_i32 | |
2241 | #define tcg_global_mem_new tcg_global_mem_new_i32 | |
df9247b2 | 2242 | #define tcg_temp_local_new() tcg_temp_local_new_i32() |
a7812ae4 PB |
2243 | #define tcg_temp_free tcg_temp_free_i32 |
2244 | #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32 | |
2245 | #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32 | |
2246 | #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x) | |
fe75bcf7 | 2247 | #define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b) |
a7812ae4 PB |
2248 | #else |
2249 | #define TCGv TCGv_i64 | |
2250 | #define tcg_temp_new() tcg_temp_new_i64() | |
2251 | #define tcg_global_reg_new tcg_global_reg_new_i64 | |
2252 | #define tcg_global_mem_new tcg_global_mem_new_i64 | |
df9247b2 | 2253 | #define tcg_temp_local_new() tcg_temp_local_new_i64() |
a7812ae4 PB |
2254 | #define tcg_temp_free tcg_temp_free_i64 |
2255 | #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64 | |
2256 | #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64 | |
2257 | #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x) | |
fe75bcf7 | 2258 | #define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b) |
a7812ae4 PB |
2259 | #endif |
2260 | ||
7e4597d7 FB |
2261 | /* debug info: write the PC of the corresponding QEMU CPU instruction */ |
2262 | static inline void tcg_gen_debug_insn_start(uint64_t pc) | |
2263 | { | |
2264 | /* XXX: must really use a 32 bit size for TCGArg in all cases */ | |
2265 | #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS | |
bcb0126f PB |
2266 | tcg_gen_op2ii(INDEX_op_debug_insn_start, |
2267 | (uint32_t)(pc), (uint32_t)(pc >> 32)); | |
7e4597d7 FB |
2268 | #else |
2269 | tcg_gen_op1i(INDEX_op_debug_insn_start, pc); | |
2270 | #endif | |
2271 | } | |
2272 | ||
c896fe29 FB |
2273 | static inline void tcg_gen_exit_tb(tcg_target_long val) |
2274 | { | |
ac56dd48 | 2275 | tcg_gen_op1i(INDEX_op_exit_tb, val); |
c896fe29 FB |
2276 | } |
2277 | ||
0a209d4b RH |
2278 | static inline void tcg_gen_goto_tb(unsigned idx) |
2279 | { | |
2280 | /* We only support two chained exits. */ | |
2281 | tcg_debug_assert(idx <= 1); | |
2282 | #ifdef CONFIG_DEBUG_TCG | |
2283 | /* Verify that we havn't seen this numbered exit before. */ | |
2284 | tcg_debug_assert((tcg_ctx.goto_tb_issue_mask & (1 << idx)) == 0); | |
2285 | tcg_ctx.goto_tb_issue_mask |= 1 << idx; | |
2286 | #endif | |
ac56dd48 | 2287 | tcg_gen_op1i(INDEX_op_goto_tb, idx); |
c896fe29 FB |
2288 | } |
2289 | ||
2290 | #if TCG_TARGET_REG_BITS == 32 | |
ac56dd48 | 2291 | static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
2292 | { |
2293 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2294 | tcg_gen_op3i_i32(INDEX_op_qemu_ld8u, ret, addr, mem_index); |
c896fe29 | 2295 | #else |
a7812ae4 PB |
2296 | tcg_gen_op4i_i32(INDEX_op_qemu_ld8u, TCGV_LOW(ret), TCGV_LOW(addr), |
2297 | TCGV_HIGH(addr), mem_index); | |
ac56dd48 | 2298 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
2299 | #endif |
2300 | } | |
2301 | ||
ac56dd48 | 2302 | static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
2303 | { |
2304 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2305 | tcg_gen_op3i_i32(INDEX_op_qemu_ld8s, ret, addr, mem_index); |
c896fe29 | 2306 | #else |
a7812ae4 PB |
2307 | tcg_gen_op4i_i32(INDEX_op_qemu_ld8s, TCGV_LOW(ret), TCGV_LOW(addr), |
2308 | TCGV_HIGH(addr), mem_index); | |
2309 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
2310 | #endif |
2311 | } | |
2312 | ||
ac56dd48 | 2313 | static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
2314 | { |
2315 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2316 | tcg_gen_op3i_i32(INDEX_op_qemu_ld16u, ret, addr, mem_index); |
c896fe29 | 2317 | #else |
a7812ae4 PB |
2318 | tcg_gen_op4i_i32(INDEX_op_qemu_ld16u, TCGV_LOW(ret), TCGV_LOW(addr), |
2319 | TCGV_HIGH(addr), mem_index); | |
ac56dd48 | 2320 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
2321 | #endif |
2322 | } | |
2323 | ||
ac56dd48 | 2324 | static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
2325 | { |
2326 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2327 | tcg_gen_op3i_i32(INDEX_op_qemu_ld16s, ret, addr, mem_index); |
c896fe29 | 2328 | #else |
a7812ae4 PB |
2329 | tcg_gen_op4i_i32(INDEX_op_qemu_ld16s, TCGV_LOW(ret), TCGV_LOW(addr), |
2330 | TCGV_HIGH(addr), mem_index); | |
2331 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
2332 | #endif |
2333 | } | |
2334 | ||
ac56dd48 | 2335 | static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
2336 | { |
2337 | #if TARGET_LONG_BITS == 32 | |
86feb1c8 | 2338 | tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index); |
c896fe29 | 2339 | #else |
86feb1c8 | 2340 | tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr), |
a7812ae4 | 2341 | TCGV_HIGH(addr), mem_index); |
ac56dd48 | 2342 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
c896fe29 FB |
2343 | #endif |
2344 | } | |
2345 | ||
ac56dd48 | 2346 | static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 FB |
2347 | { |
2348 | #if TARGET_LONG_BITS == 32 | |
86feb1c8 | 2349 | tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index); |
c896fe29 | 2350 | #else |
86feb1c8 | 2351 | tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr), |
a7812ae4 PB |
2352 | TCGV_HIGH(addr), mem_index); |
2353 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); | |
c896fe29 FB |
2354 | #endif |
2355 | } | |
2356 | ||
a7812ae4 | 2357 | static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index) |
c896fe29 FB |
2358 | { |
2359 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2360 | tcg_gen_op4i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), addr, mem_index); |
c896fe29 | 2361 | #else |
a7812ae4 PB |
2362 | tcg_gen_op5i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), |
2363 | TCGV_LOW(addr), TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
2364 | #endif |
2365 | } | |
2366 | ||
ac56dd48 | 2367 | static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) |
c896fe29 FB |
2368 | { |
2369 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2370 | tcg_gen_op3i_i32(INDEX_op_qemu_st8, arg, addr, mem_index); |
c896fe29 | 2371 | #else |
a7812ae4 PB |
2372 | tcg_gen_op4i_i32(INDEX_op_qemu_st8, TCGV_LOW(arg), TCGV_LOW(addr), |
2373 | TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
2374 | #endif |
2375 | } | |
2376 | ||
ac56dd48 | 2377 | static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) |
c896fe29 FB |
2378 | { |
2379 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2380 | tcg_gen_op3i_i32(INDEX_op_qemu_st16, arg, addr, mem_index); |
c896fe29 | 2381 | #else |
a7812ae4 PB |
2382 | tcg_gen_op4i_i32(INDEX_op_qemu_st16, TCGV_LOW(arg), TCGV_LOW(addr), |
2383 | TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
2384 | #endif |
2385 | } | |
2386 | ||
ac56dd48 | 2387 | static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) |
c896fe29 FB |
2388 | { |
2389 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 | 2390 | tcg_gen_op3i_i32(INDEX_op_qemu_st32, arg, addr, mem_index); |
c896fe29 | 2391 | #else |
a7812ae4 PB |
2392 | tcg_gen_op4i_i32(INDEX_op_qemu_st32, TCGV_LOW(arg), TCGV_LOW(addr), |
2393 | TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
2394 | #endif |
2395 | } | |
2396 | ||
a7812ae4 | 2397 | static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) |
c896fe29 FB |
2398 | { |
2399 | #if TARGET_LONG_BITS == 32 | |
a7812ae4 PB |
2400 | tcg_gen_op4i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), addr, |
2401 | mem_index); | |
c896fe29 | 2402 | #else |
a7812ae4 PB |
2403 | tcg_gen_op5i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), |
2404 | TCGV_LOW(addr), TCGV_HIGH(addr), mem_index); | |
c896fe29 FB |
2405 | #endif |
2406 | } | |
2407 | ||
ebecf363 PM |
2408 | #define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i32(TCGV_PTR_TO_NAT(R), (A), (O)) |
2409 | #define tcg_gen_discard_ptr(A) tcg_gen_discard_i32(TCGV_PTR_TO_NAT(A)) | |
f8422f52 | 2410 | |
c896fe29 FB |
2411 | #else /* TCG_TARGET_REG_BITS == 32 */ |
2412 | ||
ac56dd48 | 2413 | static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 2414 | { |
a7812ae4 | 2415 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u, ret, addr, mem_index); |
c896fe29 FB |
2416 | } |
2417 | ||
ac56dd48 | 2418 | static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 2419 | { |
a7812ae4 | 2420 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s, ret, addr, mem_index); |
c896fe29 FB |
2421 | } |
2422 | ||
ac56dd48 | 2423 | static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 2424 | { |
a7812ae4 | 2425 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u, ret, addr, mem_index); |
c896fe29 FB |
2426 | } |
2427 | ||
ac56dd48 | 2428 | static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 2429 | { |
a7812ae4 | 2430 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s, ret, addr, mem_index); |
c896fe29 FB |
2431 | } |
2432 | ||
ac56dd48 | 2433 | static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 2434 | { |
3e1dbadd RH |
2435 | #if TARGET_LONG_BITS == 32 |
2436 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index); | |
2437 | #else | |
a7812ae4 | 2438 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u, ret, addr, mem_index); |
3e1dbadd | 2439 | #endif |
c896fe29 FB |
2440 | } |
2441 | ||
ac56dd48 | 2442 | static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) |
c896fe29 | 2443 | { |
3e1dbadd RH |
2444 | #if TARGET_LONG_BITS == 32 |
2445 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index); | |
2446 | #else | |
a7812ae4 | 2447 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s, ret, addr, mem_index); |
3e1dbadd | 2448 | #endif |
c896fe29 FB |
2449 | } |
2450 | ||
a7812ae4 | 2451 | static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index) |
c896fe29 | 2452 | { |
a7812ae4 | 2453 | tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64, ret, addr, mem_index); |
c896fe29 FB |
2454 | } |
2455 | ||
ac56dd48 | 2456 | static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) |
c896fe29 | 2457 | { |
a7812ae4 | 2458 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8, arg, addr, mem_index); |
c896fe29 FB |
2459 | } |
2460 | ||
ac56dd48 | 2461 | static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) |
c896fe29 | 2462 | { |
a7812ae4 | 2463 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16, arg, addr, mem_index); |
c896fe29 FB |
2464 | } |
2465 | ||
ac56dd48 | 2466 | static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) |
c896fe29 | 2467 | { |
a7812ae4 | 2468 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32, arg, addr, mem_index); |
c896fe29 FB |
2469 | } |
2470 | ||
a7812ae4 | 2471 | static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) |
c896fe29 | 2472 | { |
a7812ae4 | 2473 | tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64, arg, addr, mem_index); |
c896fe29 FB |
2474 | } |
2475 | ||
ebecf363 PM |
2476 | #define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i64(TCGV_PTR_TO_NAT(R), (A), (O)) |
2477 | #define tcg_gen_discard_ptr(A) tcg_gen_discard_i64(TCGV_PTR_TO_NAT(A)) | |
f8422f52 | 2478 | |
c896fe29 | 2479 | #endif /* TCG_TARGET_REG_BITS != 32 */ |
f8422f52 BS |
2480 | |
2481 | #if TARGET_LONG_BITS == 64 | |
f8422f52 BS |
2482 | #define tcg_gen_movi_tl tcg_gen_movi_i64 |
2483 | #define tcg_gen_mov_tl tcg_gen_mov_i64 | |
2484 | #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64 | |
2485 | #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64 | |
2486 | #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64 | |
2487 | #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64 | |
2488 | #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64 | |
2489 | #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64 | |
2490 | #define tcg_gen_ld_tl tcg_gen_ld_i64 | |
2491 | #define tcg_gen_st8_tl tcg_gen_st8_i64 | |
2492 | #define tcg_gen_st16_tl tcg_gen_st16_i64 | |
2493 | #define tcg_gen_st32_tl tcg_gen_st32_i64 | |
2494 | #define tcg_gen_st_tl tcg_gen_st_i64 | |
2495 | #define tcg_gen_add_tl tcg_gen_add_i64 | |
2496 | #define tcg_gen_addi_tl tcg_gen_addi_i64 | |
2497 | #define tcg_gen_sub_tl tcg_gen_sub_i64 | |
390efc54 | 2498 | #define tcg_gen_neg_tl tcg_gen_neg_i64 |
10460c8a | 2499 | #define tcg_gen_subfi_tl tcg_gen_subfi_i64 |
f8422f52 BS |
2500 | #define tcg_gen_subi_tl tcg_gen_subi_i64 |
2501 | #define tcg_gen_and_tl tcg_gen_and_i64 | |
2502 | #define tcg_gen_andi_tl tcg_gen_andi_i64 | |
2503 | #define tcg_gen_or_tl tcg_gen_or_i64 | |
2504 | #define tcg_gen_ori_tl tcg_gen_ori_i64 | |
2505 | #define tcg_gen_xor_tl tcg_gen_xor_i64 | |
2506 | #define tcg_gen_xori_tl tcg_gen_xori_i64 | |
0b6ce4cf | 2507 | #define tcg_gen_not_tl tcg_gen_not_i64 |
f8422f52 BS |
2508 | #define tcg_gen_shl_tl tcg_gen_shl_i64 |
2509 | #define tcg_gen_shli_tl tcg_gen_shli_i64 | |
2510 | #define tcg_gen_shr_tl tcg_gen_shr_i64 | |
2511 | #define tcg_gen_shri_tl tcg_gen_shri_i64 | |
2512 | #define tcg_gen_sar_tl tcg_gen_sar_i64 | |
2513 | #define tcg_gen_sari_tl tcg_gen_sari_i64 | |
0cf767d6 | 2514 | #define tcg_gen_brcond_tl tcg_gen_brcond_i64 |
cb63669a | 2515 | #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64 |
be210acb | 2516 | #define tcg_gen_setcond_tl tcg_gen_setcond_i64 |
add1e7ea | 2517 | #define tcg_gen_setcondi_tl tcg_gen_setcondi_i64 |
f730fd27 TS |
2518 | #define tcg_gen_mul_tl tcg_gen_mul_i64 |
2519 | #define tcg_gen_muli_tl tcg_gen_muli_i64 | |
ab36421e AJ |
2520 | #define tcg_gen_div_tl tcg_gen_div_i64 |
2521 | #define tcg_gen_rem_tl tcg_gen_rem_i64 | |
864951af AJ |
2522 | #define tcg_gen_divu_tl tcg_gen_divu_i64 |
2523 | #define tcg_gen_remu_tl tcg_gen_remu_i64 | |
a768e4b2 | 2524 | #define tcg_gen_discard_tl tcg_gen_discard_i64 |
e429073d BS |
2525 | #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32 |
2526 | #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64 | |
2527 | #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64 | |
2528 | #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64 | |
2529 | #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64 | |
2530 | #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64 | |
0b6ce4cf FB |
2531 | #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64 |
2532 | #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64 | |
2533 | #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64 | |
2534 | #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64 | |
2535 | #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64 | |
2536 | #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64 | |
911d79ba AJ |
2537 | #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64 |
2538 | #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64 | |
2539 | #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64 | |
945ca823 | 2540 | #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64 |
f24cb33e AJ |
2541 | #define tcg_gen_andc_tl tcg_gen_andc_i64 |
2542 | #define tcg_gen_eqv_tl tcg_gen_eqv_i64 | |
2543 | #define tcg_gen_nand_tl tcg_gen_nand_i64 | |
2544 | #define tcg_gen_nor_tl tcg_gen_nor_i64 | |
2545 | #define tcg_gen_orc_tl tcg_gen_orc_i64 | |
15824571 AJ |
2546 | #define tcg_gen_rotl_tl tcg_gen_rotl_i64 |
2547 | #define tcg_gen_rotli_tl tcg_gen_rotli_i64 | |
2548 | #define tcg_gen_rotr_tl tcg_gen_rotr_i64 | |
2549 | #define tcg_gen_rotri_tl tcg_gen_rotri_i64 | |
b7767f0f | 2550 | #define tcg_gen_deposit_tl tcg_gen_deposit_i64 |
a98824ac | 2551 | #define tcg_const_tl tcg_const_i64 |
bdffd4a9 | 2552 | #define tcg_const_local_tl tcg_const_local_i64 |
ffc5ea09 | 2553 | #define tcg_gen_movcond_tl tcg_gen_movcond_i64 |
f8422f52 | 2554 | #else |
f8422f52 BS |
2555 | #define tcg_gen_movi_tl tcg_gen_movi_i32 |
2556 | #define tcg_gen_mov_tl tcg_gen_mov_i32 | |
2557 | #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32 | |
2558 | #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32 | |
2559 | #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32 | |
2560 | #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32 | |
2561 | #define tcg_gen_ld32u_tl tcg_gen_ld_i32 | |
2562 | #define tcg_gen_ld32s_tl tcg_gen_ld_i32 | |
2563 | #define tcg_gen_ld_tl tcg_gen_ld_i32 | |
2564 | #define tcg_gen_st8_tl tcg_gen_st8_i32 | |
2565 | #define tcg_gen_st16_tl tcg_gen_st16_i32 | |
2566 | #define tcg_gen_st32_tl tcg_gen_st_i32 | |
2567 | #define tcg_gen_st_tl tcg_gen_st_i32 | |
2568 | #define tcg_gen_add_tl tcg_gen_add_i32 | |
2569 | #define tcg_gen_addi_tl tcg_gen_addi_i32 | |
2570 | #define tcg_gen_sub_tl tcg_gen_sub_i32 | |
390efc54 | 2571 | #define tcg_gen_neg_tl tcg_gen_neg_i32 |
0045734a | 2572 | #define tcg_gen_subfi_tl tcg_gen_subfi_i32 |
f8422f52 BS |
2573 | #define tcg_gen_subi_tl tcg_gen_subi_i32 |
2574 | #define tcg_gen_and_tl tcg_gen_and_i32 | |
2575 | #define tcg_gen_andi_tl tcg_gen_andi_i32 | |
2576 | #define tcg_gen_or_tl tcg_gen_or_i32 | |
2577 | #define tcg_gen_ori_tl tcg_gen_ori_i32 | |
2578 | #define tcg_gen_xor_tl tcg_gen_xor_i32 | |
2579 | #define tcg_gen_xori_tl tcg_gen_xori_i32 | |
0b6ce4cf | 2580 | #define tcg_gen_not_tl tcg_gen_not_i32 |
f8422f52 BS |
2581 | #define tcg_gen_shl_tl tcg_gen_shl_i32 |
2582 | #define tcg_gen_shli_tl tcg_gen_shli_i32 | |
2583 | #define tcg_gen_shr_tl tcg_gen_shr_i32 | |
2584 | #define tcg_gen_shri_tl tcg_gen_shri_i32 | |
2585 | #define tcg_gen_sar_tl tcg_gen_sar_i32 | |
2586 | #define tcg_gen_sari_tl tcg_gen_sari_i32 | |
0cf767d6 | 2587 | #define tcg_gen_brcond_tl tcg_gen_brcond_i32 |
cb63669a | 2588 | #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32 |
be210acb | 2589 | #define tcg_gen_setcond_tl tcg_gen_setcond_i32 |
add1e7ea | 2590 | #define tcg_gen_setcondi_tl tcg_gen_setcondi_i32 |
f730fd27 TS |
2591 | #define tcg_gen_mul_tl tcg_gen_mul_i32 |
2592 | #define tcg_gen_muli_tl tcg_gen_muli_i32 | |
ab36421e AJ |
2593 | #define tcg_gen_div_tl tcg_gen_div_i32 |
2594 | #define tcg_gen_rem_tl tcg_gen_rem_i32 | |
864951af AJ |
2595 | #define tcg_gen_divu_tl tcg_gen_divu_i32 |
2596 | #define tcg_gen_remu_tl tcg_gen_remu_i32 | |
a768e4b2 | 2597 | #define tcg_gen_discard_tl tcg_gen_discard_i32 |
e429073d BS |
2598 | #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32 |
2599 | #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32 | |
2600 | #define tcg_gen_extu_i32_tl tcg_gen_mov_i32 | |
2601 | #define tcg_gen_ext_i32_tl tcg_gen_mov_i32 | |
2602 | #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64 | |
2603 | #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64 | |
0b6ce4cf FB |
2604 | #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32 |
2605 | #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32 | |
2606 | #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32 | |
2607 | #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32 | |
2608 | #define tcg_gen_ext32u_tl tcg_gen_mov_i32 | |
2609 | #define tcg_gen_ext32s_tl tcg_gen_mov_i32 | |
911d79ba AJ |
2610 | #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32 |
2611 | #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32 | |
945ca823 | 2612 | #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64 |
f24cb33e AJ |
2613 | #define tcg_gen_andc_tl tcg_gen_andc_i32 |
2614 | #define tcg_gen_eqv_tl tcg_gen_eqv_i32 | |
2615 | #define tcg_gen_nand_tl tcg_gen_nand_i32 | |
2616 | #define tcg_gen_nor_tl tcg_gen_nor_i32 | |
2617 | #define tcg_gen_orc_tl tcg_gen_orc_i32 | |
15824571 AJ |
2618 | #define tcg_gen_rotl_tl tcg_gen_rotl_i32 |
2619 | #define tcg_gen_rotli_tl tcg_gen_rotli_i32 | |
2620 | #define tcg_gen_rotr_tl tcg_gen_rotr_i32 | |
2621 | #define tcg_gen_rotri_tl tcg_gen_rotri_i32 | |
b7767f0f | 2622 | #define tcg_gen_deposit_tl tcg_gen_deposit_i32 |
a98824ac | 2623 | #define tcg_const_tl tcg_const_i32 |
bdffd4a9 | 2624 | #define tcg_const_local_tl tcg_const_local_i32 |
ffc5ea09 | 2625 | #define tcg_gen_movcond_tl tcg_gen_movcond_i32 |
f8422f52 | 2626 | #endif |
6ddbc6e4 PB |
2627 | |
2628 | #if TCG_TARGET_REG_BITS == 32 | |
ebecf363 PM |
2629 | #define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i32(TCGV_PTR_TO_NAT(R), \ |
2630 | TCGV_PTR_TO_NAT(A), \ | |
2631 | TCGV_PTR_TO_NAT(B)) | |
2632 | #define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i32(TCGV_PTR_TO_NAT(R), \ | |
2633 | TCGV_PTR_TO_NAT(A), (B)) | |
2634 | #define tcg_gen_ext_i32_ptr(R, A) tcg_gen_mov_i32(TCGV_PTR_TO_NAT(R), (A)) | |
6ddbc6e4 | 2635 | #else /* TCG_TARGET_REG_BITS == 32 */ |
ebecf363 PM |
2636 | #define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i64(TCGV_PTR_TO_NAT(R), \ |
2637 | TCGV_PTR_TO_NAT(A), \ | |
2638 | TCGV_PTR_TO_NAT(B)) | |
2639 | #define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i64(TCGV_PTR_TO_NAT(R), \ | |
2640 | TCGV_PTR_TO_NAT(A), (B)) | |
2641 | #define tcg_gen_ext_i32_ptr(R, A) tcg_gen_ext_i32_i64(TCGV_PTR_TO_NAT(R), (A)) | |
6ddbc6e4 | 2642 | #endif /* TCG_TARGET_REG_BITS != 32 */ |