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