tcg-op.h 74.1 KB
Newer Older
B
bellard 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * Tiny Code Generator for QEMU
 *
 * Copyright (c) 2008 Fabrice Bellard
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#include "tcg.h"

int gen_new_label(void);

28
static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 arg1)
B
bellard 已提交
29 30
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
31 32 33
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
}

34
static inline void tcg_gen_op1_i64(TCGOpcode opc, TCGv_i64 arg1)
P
pbrook 已提交
35 36 37
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
B
bellard 已提交
38 39
}

40
static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg arg1)
B
bellard 已提交
41 42 43 44 45
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = arg1;
}

46
static inline void tcg_gen_op2_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2)
P
pbrook 已提交
47 48 49 50 51 52
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
}

53
static inline void tcg_gen_op2_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2)
P
pbrook 已提交
54 55 56 57 58 59
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
}

60
static inline void tcg_gen_op2i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGArg arg2)
B
bellard 已提交
61 62
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
63 64
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = arg2;
B
bellard 已提交
65 66
}

67
static inline void tcg_gen_op2i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGArg arg2)
B
bellard 已提交
68 69
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
70
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
B
bellard 已提交
71
    *gen_opparam_ptr++ = arg2;
P
pbrook 已提交
72 73
}

74
static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg arg1, TCGArg arg2)
P
pbrook 已提交
75 76 77 78 79 80
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = arg1;
    *gen_opparam_ptr++ = arg2;
}

81
static inline void tcg_gen_op3_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
P
pbrook 已提交
82 83 84 85 86 87 88 89
                                   TCGv_i32 arg3)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
}

90
static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
91 92 93 94 95 96 97 98
                                   TCGv_i64 arg3)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
}

99 100
static inline void tcg_gen_op3i_i32(TCGOpcode opc, TCGv_i32 arg1,
                                    TCGv_i32 arg2, TCGArg arg3)
P
pbrook 已提交
101 102
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
103 104 105
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = arg3;
P
pbrook 已提交
106 107
}

108 109
static inline void tcg_gen_op3i_i64(TCGOpcode opc, TCGv_i64 arg1,
                                    TCGv_i64 arg2, TCGArg arg3)
P
pbrook 已提交
110 111
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
112 113
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
B
bellard 已提交
114
    *gen_opparam_ptr++ = arg3;
P
pbrook 已提交
115 116
}

117 118
static inline void tcg_gen_ldst_op_i32(TCGOpcode opc, TCGv_i32 val,
                                       TCGv_ptr base, TCGArg offset)
P
pbrook 已提交
119 120 121 122 123 124 125
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(val);
    *gen_opparam_ptr++ = GET_TCGV_PTR(base);
    *gen_opparam_ptr++ = offset;
}

126 127
static inline void tcg_gen_ldst_op_i64(TCGOpcode opc, TCGv_i64 val,
                                       TCGv_ptr base, TCGArg offset)
P
pbrook 已提交
128 129
{
    *gen_opc_ptr++ = opc;
B
blueswir1 已提交
130
    *gen_opparam_ptr++ = GET_TCGV_I64(val);
P
pbrook 已提交
131 132 133 134
    *gen_opparam_ptr++ = GET_TCGV_PTR(base);
    *gen_opparam_ptr++ = offset;
}

135 136
static inline void tcg_gen_qemu_ldst_op_i64_i32(TCGOpcode opc, TCGv_i64 val,
                                                TCGv_i32 addr, TCGArg mem_index)
P
pbrook 已提交
137 138 139 140 141 142 143
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(val);
    *gen_opparam_ptr++ = GET_TCGV_I32(addr);
    *gen_opparam_ptr++ = mem_index;
}

144 145
static inline void tcg_gen_qemu_ldst_op_i64_i64(TCGOpcode opc, TCGv_i64 val,
                                                TCGv_i64 addr, TCGArg mem_index)
P
pbrook 已提交
146 147 148 149 150 151 152
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(val);
    *gen_opparam_ptr++ = GET_TCGV_I64(addr);
    *gen_opparam_ptr++ = mem_index;
}

153
static inline void tcg_gen_op4_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
P
pbrook 已提交
154 155 156 157 158 159 160 161 162
                                   TCGv_i32 arg3, TCGv_i32 arg4)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
}

163
static inline void tcg_gen_op4_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
B
blueswir1 已提交
164
                                   TCGv_i64 arg3, TCGv_i64 arg4)
P
pbrook 已提交
165 166 167 168 169 170 171 172
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
}

173
static inline void tcg_gen_op4i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
P
pbrook 已提交
174 175 176 177 178 179 180 181 182
                                    TCGv_i32 arg3, TCGArg arg4)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = arg4;
}

183
static inline void tcg_gen_op4i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
184
                                    TCGv_i64 arg3, TCGArg arg4)
P
pbrook 已提交
185 186
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
187 188 189 190
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = arg4;
P
pbrook 已提交
191 192
}

193
static inline void tcg_gen_op4ii_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
P
pbrook 已提交
194
                                     TCGArg arg3, TCGArg arg4)
P
pbrook 已提交
195 196
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
197 198 199
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = arg3;
B
bellard 已提交
200 201 202
    *gen_opparam_ptr++ = arg4;
}

203
static inline void tcg_gen_op4ii_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
204
                                     TCGArg arg3, TCGArg arg4)
B
bellard 已提交
205 206
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
207 208
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
B
bellard 已提交
209 210
    *gen_opparam_ptr++ = arg3;
    *gen_opparam_ptr++ = arg4;
P
pbrook 已提交
211 212
}

213
static inline void tcg_gen_op5_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
P
pbrook 已提交
214 215 216 217 218 219 220 221 222 223
                                   TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg5);
}

224
static inline void tcg_gen_op5_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
225 226 227 228 229 230 231 232 233 234
                                   TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg5);
}

235
static inline void tcg_gen_op5i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
P
pbrook 已提交
236
                                    TCGv_i32 arg3, TCGv_i32 arg4, TCGArg arg5)
P
pbrook 已提交
237 238
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
239 240 241 242 243
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
    *gen_opparam_ptr++ = arg5;
P
pbrook 已提交
244 245
}

246
static inline void tcg_gen_op5i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
247
                                    TCGv_i64 arg3, TCGv_i64 arg4, TCGArg arg5)
P
pbrook 已提交
248 249
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
250 251 252 253
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
B
bellard 已提交
254 255 256
    *gen_opparam_ptr++ = arg5;
}

257
static inline void tcg_gen_op6_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
P
pbrook 已提交
258 259 260 261 262 263 264 265 266 267 268 269
                                   TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5,
                                   TCGv_i32 arg6)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg5);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg6);
}

270
static inline void tcg_gen_op6_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
271 272
                                   TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5,
                                   TCGv_i64 arg6)
B
bellard 已提交
273 274
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
275 276 277 278 279 280
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg5);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg6);
P
pbrook 已提交
281 282
}

283
static inline void tcg_gen_op6i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
284 285 286 287 288 289 290 291 292 293 294 295
                                    TCGv_i32 arg3, TCGv_i32 arg4,
                                    TCGv_i32 arg5, TCGArg arg6)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg5);
    *gen_opparam_ptr++ = arg6;
}

296
static inline void tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
297 298 299 300 301 302 303 304 305 306 307 308
                                    TCGv_i64 arg3, TCGv_i64 arg4,
                                    TCGv_i64 arg5, TCGArg arg6)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg5);
    *gen_opparam_ptr++ = arg6;
}

309 310 311
static inline void tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 arg1,
                                     TCGv_i32 arg2, TCGv_i32 arg3,
                                     TCGv_i32 arg4, TCGArg arg5, TCGArg arg6)
P
pbrook 已提交
312 313
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
314 315 316 317 318 319 320 321
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
    *gen_opparam_ptr++ = arg5;
    *gen_opparam_ptr++ = arg6;
}

322 323 324
static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 arg1,
                                     TCGv_i64 arg2, TCGv_i64 arg3,
                                     TCGv_i64 arg4, TCGArg arg5, TCGArg arg6)
P
pbrook 已提交
325 326 327 328 329 330
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
B
bellard 已提交
331 332 333 334 335 336
    *gen_opparam_ptr++ = arg5;
    *gen_opparam_ptr++ = arg6;
}

static inline void gen_set_label(int n)
{
P
pbrook 已提交
337
    tcg_gen_op1i(INDEX_op_set_label, n);
B
bellard 已提交
338 339
}

B
blueswir1 已提交
340 341 342 343 344
static inline void tcg_gen_br(int label)
{
    tcg_gen_op1i(INDEX_op_br, label);
}

P
pbrook 已提交
345
static inline void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
346
{
A
aurel32 已提交
347
    if (!TCGV_EQUAL_I32(ret, arg))
P
pbrook 已提交
348
        tcg_gen_op2_i32(INDEX_op_mov_i32, ret, arg);
B
bellard 已提交
349 350
}

P
pbrook 已提交
351
static inline void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg)
B
bellard 已提交
352
{
P
pbrook 已提交
353
    tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg);
B
bellard 已提交
354 355
}

356 357 358 359 360 361 362
/* A version of dh_sizemask from def-helper.h that doesn't rely on
   preprocessor magic.  */
static inline int tcg_gen_sizemask(int n, int is_64bit, int is_signed)
{
    return (is_64bit << n*2) | (is_signed << (n*2 + 1));
}

B
bellard 已提交
363
/* helper calls */
P
pbrook 已提交
364 365 366 367 368 369 370 371 372
static inline void tcg_gen_helperN(void *func, int flags, int sizemask,
                                   TCGArg ret, int nargs, TCGArg *args)
{
    TCGv_ptr fn;
    fn = tcg_const_ptr((tcg_target_long)func);
    tcg_gen_callN(&tcg_ctx, fn, flags, sizemask, ret,
                  nargs, args);
    tcg_temp_free_ptr(fn);
}
B
bellard 已提交
373

374 375 376 377 378
/* Note: Both tcg_gen_helper32() and tcg_gen_helper64() are currently
   reserved for helpers in tcg-runtime.c. These helpers are all const
   and pure, hence the call to tcg_gen_callN() with TCG_CALL_CONST |
   TCG_CALL_PURE. This may need to be adjusted if these functions
   start to be used with other helpers. */
379
static inline void tcg_gen_helper32(void *func, int sizemask, TCGv_i32 ret,
A
Aurelien Jarno 已提交
380 381 382 383 384 385 386
                                    TCGv_i32 a, TCGv_i32 b)
{
    TCGv_ptr fn;
    TCGArg args[2];
    fn = tcg_const_ptr((tcg_target_long)func);
    args[0] = GET_TCGV_I32(a);
    args[1] = GET_TCGV_I32(b);
387 388
    tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
                  GET_TCGV_I32(ret), 2, args);
A
Aurelien Jarno 已提交
389 390 391
    tcg_temp_free_ptr(fn);
}

392
static inline void tcg_gen_helper64(void *func, int sizemask, TCGv_i64 ret,
P
pbrook 已提交
393
                                    TCGv_i64 a, TCGv_i64 b)
B
bellard 已提交
394
{
P
pbrook 已提交
395 396 397 398 399
    TCGv_ptr fn;
    TCGArg args[2];
    fn = tcg_const_ptr((tcg_target_long)func);
    args[0] = GET_TCGV_I64(a);
    args[1] = GET_TCGV_I64(b);
400 401
    tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
                  GET_TCGV_I64(ret), 2, args);
P
pbrook 已提交
402
    tcg_temp_free_ptr(fn);
403 404
}

B
bellard 已提交
405 406
/* 32 bit ops */

P
pbrook 已提交
407
static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
408
{
P
pbrook 已提交
409
    tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32, ret, arg2, offset);
B
bellard 已提交
410 411
}

P
pbrook 已提交
412
static inline void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
413
{
P
pbrook 已提交
414
    tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32, ret, arg2, offset);
B
bellard 已提交
415 416
}

P
pbrook 已提交
417
static inline void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
418
{
P
pbrook 已提交
419
    tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32, ret, arg2, offset);
B
bellard 已提交
420 421
}

P
pbrook 已提交
422
static inline void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
423
{
P
pbrook 已提交
424
    tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32, ret, arg2, offset);
B
bellard 已提交
425 426
}

P
pbrook 已提交
427
static inline void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
428
{
P
pbrook 已提交
429
    tcg_gen_ldst_op_i32(INDEX_op_ld_i32, ret, arg2, offset);
B
bellard 已提交
430 431
}

P
pbrook 已提交
432
static inline void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
433
{
P
pbrook 已提交
434
    tcg_gen_ldst_op_i32(INDEX_op_st8_i32, arg1, arg2, offset);
B
bellard 已提交
435 436
}

P
pbrook 已提交
437
static inline void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
438
{
P
pbrook 已提交
439
    tcg_gen_ldst_op_i32(INDEX_op_st16_i32, arg1, arg2, offset);
B
bellard 已提交
440 441
}

P
pbrook 已提交
442
static inline void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
443
{
P
pbrook 已提交
444
    tcg_gen_ldst_op_i32(INDEX_op_st_i32, arg1, arg2, offset);
B
bellard 已提交
445 446
}

P
pbrook 已提交
447
static inline void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
448
{
P
pbrook 已提交
449
    tcg_gen_op3_i32(INDEX_op_add_i32, ret, arg1, arg2);
B
bellard 已提交
450 451
}

P
pbrook 已提交
452
static inline void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
453
{
454 455 456 457
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
458
        TCGv_i32 t0 = tcg_const_i32(arg2);
459
        tcg_gen_add_i32(ret, arg1, t0);
P
pbrook 已提交
460
        tcg_temp_free_i32(t0);
461
    }
B
bellard 已提交
462 463
}

P
pbrook 已提交
464
static inline void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
465
{
P
pbrook 已提交
466
    tcg_gen_op3_i32(INDEX_op_sub_i32, ret, arg1, arg2);
B
bellard 已提交
467 468
}

P
pbrook 已提交
469
static inline void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2)
A
aurel32 已提交
470
{
P
pbrook 已提交
471
    TCGv_i32 t0 = tcg_const_i32(arg1);
A
aurel32 已提交
472
    tcg_gen_sub_i32(ret, t0, arg2);
P
pbrook 已提交
473
    tcg_temp_free_i32(t0);
A
aurel32 已提交
474 475
}

P
pbrook 已提交
476
static inline void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
477
{
478 479 480 481
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
482
        TCGv_i32 t0 = tcg_const_i32(arg2);
483
        tcg_gen_sub_i32(ret, arg1, t0);
P
pbrook 已提交
484
        tcg_temp_free_i32(t0);
485
    }
B
bellard 已提交
486 487
}

P
pbrook 已提交
488
static inline void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
489
{
A
aurel32 已提交
490 491 492 493 494
    if (TCGV_EQUAL_I32(arg1, arg2)) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_op3_i32(INDEX_op_and_i32, ret, arg1, arg2);
    }
B
bellard 已提交
495 496
}

P
pbrook 已提交
497
static inline void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
498 499 500 501 502 503 504
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_movi_i32(ret, 0);
    } else if (arg2 == 0xffffffff) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
505
        TCGv_i32 t0 = tcg_const_i32(arg2);
506
        tcg_gen_and_i32(ret, arg1, t0);
P
pbrook 已提交
507
        tcg_temp_free_i32(t0);
B
bellard 已提交
508 509 510
    }
}

P
pbrook 已提交
511
static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
512
{
A
aurel32 已提交
513 514 515 516 517
    if (TCGV_EQUAL_I32(arg1, arg2)) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2);
    }
B
bellard 已提交
518 519
}

P
pbrook 已提交
520
static inline void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
521 522 523
{
    /* some cases can be optimized here */
    if (arg2 == 0xffffffff) {
524
        tcg_gen_movi_i32(ret, 0xffffffff);
B
bellard 已提交
525 526 527
    } else if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
528
        TCGv_i32 t0 = tcg_const_i32(arg2);
529
        tcg_gen_or_i32(ret, arg1, t0);
P
pbrook 已提交
530
        tcg_temp_free_i32(t0);
B
bellard 已提交
531 532 533
    }
}

P
pbrook 已提交
534
static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
535
{
A
aurel32 已提交
536 537 538 539 540
    if (TCGV_EQUAL_I32(arg1, arg2)) {
        tcg_gen_movi_i32(ret, 0);
    } else {
        tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2);
    }
B
bellard 已提交
541 542
}

P
pbrook 已提交
543
static inline void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
544 545 546 547 548
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
549
        TCGv_i32 t0 = tcg_const_i32(arg2);
550
        tcg_gen_xor_i32(ret, arg1, t0);
P
pbrook 已提交
551
        tcg_temp_free_i32(t0);
B
bellard 已提交
552 553 554
    }
}

P
pbrook 已提交
555
static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
556
{
P
pbrook 已提交
557
    tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2);
B
bellard 已提交
558 559
}

P
pbrook 已提交
560
static inline void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
561
{
B
bellard 已提交
562 563 564
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
565
        TCGv_i32 t0 = tcg_const_i32(arg2);
566
        tcg_gen_shl_i32(ret, arg1, t0);
P
pbrook 已提交
567
        tcg_temp_free_i32(t0);
B
bellard 已提交
568
    }
B
bellard 已提交
569 570
}

P
pbrook 已提交
571
static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
572
{
P
pbrook 已提交
573
    tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2);
B
bellard 已提交
574 575
}

P
pbrook 已提交
576
static inline void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
577
{
B
bellard 已提交
578 579 580
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
581
        TCGv_i32 t0 = tcg_const_i32(arg2);
582
        tcg_gen_shr_i32(ret, arg1, t0);
P
pbrook 已提交
583
        tcg_temp_free_i32(t0);
B
bellard 已提交
584
    }
B
bellard 已提交
585 586
}

P
pbrook 已提交
587
static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
588
{
P
pbrook 已提交
589
    tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2);
B
bellard 已提交
590 591
}

P
pbrook 已提交
592
static inline void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
593
{
B
bellard 已提交
594 595 596
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
597
        TCGv_i32 t0 = tcg_const_i32(arg2);
598
        tcg_gen_sar_i32(ret, arg1, t0);
P
pbrook 已提交
599
        tcg_temp_free_i32(t0);
B
bellard 已提交
600
    }
B
bellard 已提交
601 602
}

603 604
static inline void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1,
                                      TCGv_i32 arg2, int label_index)
B
bellard 已提交
605
{
P
pbrook 已提交
606
    tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
B
bellard 已提交
607 608
}

609 610
static inline void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1,
                                       int32_t arg2, int label_index)
P
pbrook 已提交
611
{
P
pbrook 已提交
612
    TCGv_i32 t0 = tcg_const_i32(arg2);
P
pbrook 已提交
613
    tcg_gen_brcond_i32(cond, arg1, t0, label_index);
P
pbrook 已提交
614
    tcg_temp_free_i32(t0);
P
pbrook 已提交
615 616
}

617
static inline void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret,
618 619 620 621 622
                                       TCGv_i32 arg1, TCGv_i32 arg2)
{
    tcg_gen_op4i_i32(INDEX_op_setcond_i32, ret, arg1, arg2, cond);
}

623 624
static inline void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret,
                                        TCGv_i32 arg1, int32_t arg2)
625 626 627 628 629 630
{
    TCGv_i32 t0 = tcg_const_i32(arg2);
    tcg_gen_setcond_i32(cond, ret, arg1, t0);
    tcg_temp_free_i32(t0);
}

P
pbrook 已提交
631
static inline void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
632
{
P
pbrook 已提交
633
    tcg_gen_op3_i32(INDEX_op_mul_i32, ret, arg1, arg2);
B
bellard 已提交
634 635
}

P
pbrook 已提交
636
static inline void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
637
{
P
pbrook 已提交
638
    TCGv_i32 t0 = tcg_const_i32(arg2);
639
    tcg_gen_mul_i32(ret, arg1, t0);
P
pbrook 已提交
640
    tcg_temp_free_i32(t0);
641 642
}

B
bellard 已提交
643
#ifdef TCG_TARGET_HAS_div_i32
P
pbrook 已提交
644
static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
645
{
P
pbrook 已提交
646
    tcg_gen_op3_i32(INDEX_op_div_i32, ret, arg1, arg2);
B
bellard 已提交
647 648
}

P
pbrook 已提交
649
static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
650
{
P
pbrook 已提交
651
    tcg_gen_op3_i32(INDEX_op_rem_i32, ret, arg1, arg2);
B
bellard 已提交
652 653
}

P
pbrook 已提交
654
static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
655
{
P
pbrook 已提交
656
    tcg_gen_op3_i32(INDEX_op_divu_i32, ret, arg1, arg2);
B
bellard 已提交
657 658
}

P
pbrook 已提交
659
static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
660
{
P
pbrook 已提交
661
    tcg_gen_op3_i32(INDEX_op_remu_i32, ret, arg1, arg2);
B
bellard 已提交
662
}
A
Aurelien Jarno 已提交
663
#elif defined(TCG_TARGET_HAS_div2_i32)
P
pbrook 已提交
664
static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
665
{
P
pbrook 已提交
666 667
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
668
    tcg_gen_sari_i32(t0, arg1, 31);
P
pbrook 已提交
669 670
    tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
671 672
}

P
pbrook 已提交
673
static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
674
{
P
pbrook 已提交
675 676
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
677
    tcg_gen_sari_i32(t0, arg1, 31);
P
pbrook 已提交
678 679
    tcg_gen_op5_i32(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
680 681
}

P
pbrook 已提交
682
static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
683
{
P
pbrook 已提交
684 685
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
686
    tcg_gen_movi_i32(t0, 0);
P
pbrook 已提交
687 688
    tcg_gen_op5_i32(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
689 690
}

P
pbrook 已提交
691
static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
692
{
P
pbrook 已提交
693 694
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
695
    tcg_gen_movi_i32(t0, 0);
P
pbrook 已提交
696 697
    tcg_gen_op5_i32(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
698
}
A
Aurelien Jarno 已提交
699 700 701
#else
static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
{
702 703 704 705 706 707 708
    int sizemask = 0;
    /* Return value and both arguments are 32-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 0, 1);
    sizemask |= tcg_gen_sizemask(1, 0, 1);
    sizemask |= tcg_gen_sizemask(2, 0, 1);

    tcg_gen_helper32(tcg_helper_div_i32, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
709 710 711 712
}

static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
{
713 714 715 716 717 718 719
    int sizemask = 0;
    /* Return value and both arguments are 32-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 0, 1);
    sizemask |= tcg_gen_sizemask(1, 0, 1);
    sizemask |= tcg_gen_sizemask(2, 0, 1);

    tcg_gen_helper32(tcg_helper_rem_i32, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
720 721 722 723
}

static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
{
724 725 726 727 728 729
    int sizemask = 0;
    /* Return value and both arguments are 32-bit and unsigned.  */
    sizemask |= tcg_gen_sizemask(0, 0, 0);
    sizemask |= tcg_gen_sizemask(1, 0, 0);
    sizemask |= tcg_gen_sizemask(2, 0, 0);

730
    tcg_gen_helper32(tcg_helper_divu_i32, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
731 732 733 734
}

static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
{
735 736 737 738 739 740
    int sizemask = 0;
    /* Return value and both arguments are 32-bit and unsigned.  */
    sizemask |= tcg_gen_sizemask(0, 0, 0);
    sizemask |= tcg_gen_sizemask(1, 0, 0);
    sizemask |= tcg_gen_sizemask(2, 0, 0);

741
    tcg_gen_helper32(tcg_helper_remu_i32, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
742
}
B
bellard 已提交
743 744 745 746
#endif

#if TCG_TARGET_REG_BITS == 32

P
pbrook 已提交
747
static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
748
{
A
aurel32 已提交
749
    if (!TCGV_EQUAL_I64(ret, arg)) {
P
pbrook 已提交
750
        tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
751 752
        tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
    }
B
bellard 已提交
753 754
}

P
pbrook 已提交
755
static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
B
bellard 已提交
756
{
P
pbrook 已提交
757
    tcg_gen_movi_i32(TCGV_LOW(ret), arg);
P
pbrook 已提交
758
    tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
B
bellard 已提交
759 760
}

P
pbrook 已提交
761 762
static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
763
{
P
pbrook 已提交
764
    tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
765
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
766 767
}

P
pbrook 已提交
768 769
static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
770
{
P
pbrook 已提交
771 772
    tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), 31);
B
bellard 已提交
773 774
}

P
pbrook 已提交
775 776
static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
777
{
A
aurel32 已提交
778
    tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
779
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
780 781
}

P
pbrook 已提交
782 783
static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
784
{
P
pbrook 已提交
785 786
    tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
787 788
}

P
pbrook 已提交
789 790
static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
791
{
P
pbrook 已提交
792
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
793
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
794 795
}

P
pbrook 已提交
796 797
static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
798
{
P
pbrook 已提交
799 800
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
801 802
}

P
pbrook 已提交
803 804
static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                  tcg_target_long offset)
B
bellard 已提交
805 806 807 808
{
    /* since arg2 and ret have different types, they cannot be the
       same temporary */
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
809
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
P
pbrook 已提交
810
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4);
B
bellard 已提交
811
#else
P
pbrook 已提交
812
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
813
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
B
bellard 已提交
814 815 816
#endif
}

P
pbrook 已提交
817 818
static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                   tcg_target_long offset)
B
bellard 已提交
819
{
P
pbrook 已提交
820
    tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset);
B
bellard 已提交
821 822
}

P
pbrook 已提交
823 824
static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
825
{
P
pbrook 已提交
826
    tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset);
B
bellard 已提交
827 828
}

P
pbrook 已提交
829 830
static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
831
{
P
pbrook 已提交
832
    tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
B
bellard 已提交
833 834
}

P
pbrook 已提交
835 836
static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                  tcg_target_long offset)
B
bellard 已提交
837 838
{
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
839
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
P
pbrook 已提交
840
    tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4);
B
bellard 已提交
841
#else
P
pbrook 已提交
842
    tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
P
pbrook 已提交
843
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
B
bellard 已提交
844 845 846
#endif
}

P
pbrook 已提交
847
static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
848
{
P
pbrook 已提交
849 850 851
    tcg_gen_op6_i32(INDEX_op_add2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
                    TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
                    TCGV_HIGH(arg2));
B
bellard 已提交
852 853
}

P
pbrook 已提交
854
static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
855
{
P
pbrook 已提交
856 857 858
    tcg_gen_op6_i32(INDEX_op_sub2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
                    TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
                    TCGV_HIGH(arg2));
B
bellard 已提交
859 860
}

P
pbrook 已提交
861
static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
862
{
P
pbrook 已提交
863
    tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
P
pbrook 已提交
864
    tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
865 866
}

P
pbrook 已提交
867
static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
868
{
A
aurel32 已提交
869 870
    tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
    tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
871 872
}

P
pbrook 已提交
873
static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
874
{
A
aurel32 已提交
875 876
    tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
    tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
877 878
}

P
pbrook 已提交
879
static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
880
{
P
pbrook 已提交
881
    tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
P
pbrook 已提交
882
    tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
883 884
}

P
pbrook 已提交
885
static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
886
{
A
aurel32 已提交
887 888
    tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
    tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
889 890
}

P
pbrook 已提交
891
static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
892
{
P
pbrook 已提交
893
    tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
P
pbrook 已提交
894
    tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
895 896 897 898
}

/* XXX: use generic code when basic block handling is OK or CPU
   specific code (x86) */
P
pbrook 已提交
899
static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
900
{
901 902 903 904 905 906 907
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 1, 1);
    sizemask |= tcg_gen_sizemask(1, 1, 1);
    sizemask |= tcg_gen_sizemask(2, 1, 1);

    tcg_gen_helper64(tcg_helper_shl_i64, sizemask, ret, arg1, arg2);
B
bellard 已提交
908 909
}

P
pbrook 已提交
910
static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
911 912 913 914
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
}

P
pbrook 已提交
915
static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
916
{
917 918 919 920 921 922 923
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 1, 1);
    sizemask |= tcg_gen_sizemask(1, 1, 1);
    sizemask |= tcg_gen_sizemask(2, 1, 1);

    tcg_gen_helper64(tcg_helper_shr_i64, sizemask, ret, arg1, arg2);
B
bellard 已提交
924 925
}

P
pbrook 已提交
926
static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
927 928 929 930
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
}

P
pbrook 已提交
931
static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
932
{
933 934 935 936 937 938 939
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 1, 1);
    sizemask |= tcg_gen_sizemask(1, 1, 1);
    sizemask |= tcg_gen_sizemask(2, 1, 1);

    tcg_gen_helper64(tcg_helper_sar_i64, sizemask, ret, arg1, arg2);
B
bellard 已提交
940 941
}

P
pbrook 已提交
942
static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
943 944 945 946
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
}

947 948
static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1,
                                      TCGv_i64 arg2, int label_index)
B
bellard 已提交
949
{
P
pbrook 已提交
950 951 952
    tcg_gen_op6ii_i32(INDEX_op_brcond2_i32,
                      TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
                      TCGV_HIGH(arg2), cond, label_index);
B
bellard 已提交
953 954
}

955
static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
956 957 958 959 960 961 962 963
                                       TCGv_i64 arg1, TCGv_i64 arg2)
{
    tcg_gen_op6i_i32(INDEX_op_setcond2_i32, TCGV_LOW(ret),
                     TCGV_LOW(arg1), TCGV_HIGH(arg1),
                     TCGV_LOW(arg2), TCGV_HIGH(arg2), cond);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
964
static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
965
{
P
pbrook 已提交
966 967
    TCGv_i64 t0;
    TCGv_i32 t1;
B
bellard 已提交
968

P
pbrook 已提交
969 970 971 972 973 974 975
    t0 = tcg_temp_new_i64();
    t1 = tcg_temp_new_i32();

    tcg_gen_op4_i32(INDEX_op_mulu2_i32, TCGV_LOW(t0), TCGV_HIGH(t0),
                    TCGV_LOW(arg1), TCGV_LOW(arg2));

    tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2));
P
pbrook 已提交
976
    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
P
pbrook 已提交
977
    tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2));
P
pbrook 已提交
978
    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
P
pbrook 已提交
979

B
bellard 已提交
980
    tcg_gen_mov_i64(ret, t0);
P
pbrook 已提交
981 982
    tcg_temp_free_i64(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
983 984
}

P
pbrook 已提交
985
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
986
{
987 988 989 990 991 992 993
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 1, 1);
    sizemask |= tcg_gen_sizemask(1, 1, 1);
    sizemask |= tcg_gen_sizemask(2, 1, 1);

    tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
B
bellard 已提交
994 995
}

P
pbrook 已提交
996
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
997
{
998 999 1000 1001 1002 1003 1004
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 1, 1);
    sizemask |= tcg_gen_sizemask(1, 1, 1);
    sizemask |= tcg_gen_sizemask(2, 1, 1);

    tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
B
bellard 已提交
1005 1006
}

P
pbrook 已提交
1007
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1008
{
1009 1010 1011 1012 1013 1014 1015
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and unsigned.  */
    sizemask |= tcg_gen_sizemask(0, 1, 0);
    sizemask |= tcg_gen_sizemask(1, 1, 0);
    sizemask |= tcg_gen_sizemask(2, 1, 0);

    tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
B
bellard 已提交
1016 1017
}

P
pbrook 已提交
1018
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1019
{
1020 1021 1022 1023 1024 1025 1026
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and unsigned.  */
    sizemask |= tcg_gen_sizemask(0, 1, 0);
    sizemask |= tcg_gen_sizemask(1, 1, 0);
    sizemask |= tcg_gen_sizemask(2, 1, 0);

    tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
B
bellard 已提交
1027 1028 1029 1030
}

#else

P
pbrook 已提交
1031
static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1032
{
A
aurel32 已提交
1033
    if (!TCGV_EQUAL_I64(ret, arg))
P
pbrook 已提交
1034
        tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg);
B
bellard 已提交
1035 1036
}

P
pbrook 已提交
1037
static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
B
bellard 已提交
1038
{
P
pbrook 已提交
1039
    tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg);
B
bellard 已提交
1040 1041
}

P
pbrook 已提交
1042
static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
1043
                                    tcg_target_long offset)
B
bellard 已提交
1044
{
P
pbrook 已提交
1045
    tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset);
B
bellard 已提交
1046 1047
}

P
pbrook 已提交
1048
static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
1049
                                    tcg_target_long offset)
B
bellard 已提交
1050
{
P
pbrook 已提交
1051
    tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset);
B
bellard 已提交
1052 1053
}

P
pbrook 已提交
1054
static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
1055
                                     tcg_target_long offset)
B
bellard 已提交
1056
{
P
pbrook 已提交
1057
    tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset);
B
bellard 已提交
1058 1059
}

P
pbrook 已提交
1060
static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
1061
                                     tcg_target_long offset)
B
bellard 已提交
1062
{
P
pbrook 已提交
1063
    tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset);
B
bellard 已提交
1064 1065
}

P
pbrook 已提交
1066
static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
1067
                                     tcg_target_long offset)
B
bellard 已提交
1068
{
P
pbrook 已提交
1069
    tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset);
B
bellard 已提交
1070 1071
}

P
pbrook 已提交
1072
static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
1073
                                     tcg_target_long offset)
B
bellard 已提交
1074
{
P
pbrook 已提交
1075
    tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset);
B
bellard 已提交
1076 1077
}

P
pbrook 已提交
1078
static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_i64 arg2, tcg_target_long offset)
B
bellard 已提交
1079
{
P
pbrook 已提交
1080
    tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset);
B
bellard 已提交
1081 1082
}

P
pbrook 已提交
1083
static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
1084
                                   tcg_target_long offset)
B
bellard 已提交
1085
{
P
pbrook 已提交
1086
    tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset);
B
bellard 已提交
1087 1088
}

P
pbrook 已提交
1089
static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
1090
                                    tcg_target_long offset)
B
bellard 已提交
1091
{
P
pbrook 已提交
1092
    tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset);
B
bellard 已提交
1093 1094
}

P
pbrook 已提交
1095
static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
1096
                                    tcg_target_long offset)
B
bellard 已提交
1097
{
P
pbrook 已提交
1098
    tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset);
B
bellard 已提交
1099 1100
}

P
pbrook 已提交
1101
static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_i64 arg2, tcg_target_long offset)
B
bellard 已提交
1102
{
P
pbrook 已提交
1103
    tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset);
B
bellard 已提交
1104 1105
}

P
pbrook 已提交
1106
static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1107
{
P
pbrook 已提交
1108
    tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2);
B
bellard 已提交
1109 1110
}

P
pbrook 已提交
1111
static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1112
{
P
pbrook 已提交
1113
    tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2);
B
bellard 已提交
1114 1115
}

P
pbrook 已提交
1116
static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1117
{
A
aurel32 已提交
1118 1119 1120 1121 1122
    if (TCGV_EQUAL_I64(arg1, arg2)) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
        tcg_gen_op3_i64(INDEX_op_and_i64, ret, arg1, arg2);
    }
B
bellard 已提交
1123 1124
}

P
pbrook 已提交
1125
static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1126
{
P
pbrook 已提交
1127
    TCGv_i64 t0 = tcg_const_i64(arg2);
1128
    tcg_gen_and_i64(ret, arg1, t0);
P
pbrook 已提交
1129
    tcg_temp_free_i64(t0);
B
bellard 已提交
1130 1131
}

P
pbrook 已提交
1132
static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1133
{
A
aurel32 已提交
1134 1135 1136 1137 1138
    if (TCGV_EQUAL_I64(arg1, arg2)) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
        tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2);
    }
B
bellard 已提交
1139 1140
}

P
pbrook 已提交
1141
static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1142
{
P
pbrook 已提交
1143
    TCGv_i64 t0 = tcg_const_i64(arg2);
1144
    tcg_gen_or_i64(ret, arg1, t0);
P
pbrook 已提交
1145
    tcg_temp_free_i64(t0);
B
bellard 已提交
1146 1147
}

P
pbrook 已提交
1148
static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1149
{
A
aurel32 已提交
1150 1151 1152 1153 1154
    if (TCGV_EQUAL_I64(arg1, arg2)) {
        tcg_gen_movi_i64(ret, 0);
    } else {
        tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2);
    }
B
bellard 已提交
1155 1156
}

P
pbrook 已提交
1157
static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1158
{
P
pbrook 已提交
1159
    TCGv_i64 t0 = tcg_const_i64(arg2);
1160
    tcg_gen_xor_i64(ret, arg1, t0);
P
pbrook 已提交
1161
    tcg_temp_free_i64(t0);
B
bellard 已提交
1162 1163
}

P
pbrook 已提交
1164
static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1165
{
P
pbrook 已提交
1166
    tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2);
B
bellard 已提交
1167 1168
}

P
pbrook 已提交
1169
static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1170
{
B
bellard 已提交
1171 1172 1173
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1174
        TCGv_i64 t0 = tcg_const_i64(arg2);
1175
        tcg_gen_shl_i64(ret, arg1, t0);
P
pbrook 已提交
1176
        tcg_temp_free_i64(t0);
B
bellard 已提交
1177
    }
B
bellard 已提交
1178 1179
}

P
pbrook 已提交
1180
static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1181
{
P
pbrook 已提交
1182
    tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2);
B
bellard 已提交
1183 1184
}

P
pbrook 已提交
1185
static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1186
{
B
bellard 已提交
1187 1188 1189
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1190
        TCGv_i64 t0 = tcg_const_i64(arg2);
1191
        tcg_gen_shr_i64(ret, arg1, t0);
P
pbrook 已提交
1192
        tcg_temp_free_i64(t0);
B
bellard 已提交
1193
    }
B
bellard 已提交
1194 1195
}

P
pbrook 已提交
1196
static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1197
{
P
pbrook 已提交
1198
    tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2);
B
bellard 已提交
1199 1200
}

P
pbrook 已提交
1201
static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1202
{
B
bellard 已提交
1203 1204 1205
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1206
        TCGv_i64 t0 = tcg_const_i64(arg2);
1207
        tcg_gen_sar_i64(ret, arg1, t0);
P
pbrook 已提交
1208
        tcg_temp_free_i64(t0);
B
bellard 已提交
1209
    }
B
bellard 已提交
1210 1211
}

1212 1213
static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1,
                                      TCGv_i64 arg2, int label_index)
B
bellard 已提交
1214
{
P
pbrook 已提交
1215
    tcg_gen_op4ii_i64(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
B
bellard 已提交
1216 1217
}

1218
static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
1219 1220 1221 1222 1223
                                       TCGv_i64 arg1, TCGv_i64 arg2)
{
    tcg_gen_op4i_i64(INDEX_op_setcond_i64, ret, arg1, arg2, cond);
}

P
pbrook 已提交
1224
static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1225
{
P
pbrook 已提交
1226
    tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2);
B
bellard 已提交
1227 1228 1229
}

#ifdef TCG_TARGET_HAS_div_i64
P
pbrook 已提交
1230
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1231
{
P
pbrook 已提交
1232
    tcg_gen_op3_i64(INDEX_op_div_i64, ret, arg1, arg2);
B
bellard 已提交
1233 1234
}

P
pbrook 已提交
1235
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1236
{
P
pbrook 已提交
1237
    tcg_gen_op3_i64(INDEX_op_rem_i64, ret, arg1, arg2);
B
bellard 已提交
1238 1239
}

P
pbrook 已提交
1240
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1241
{
P
pbrook 已提交
1242
    tcg_gen_op3_i64(INDEX_op_divu_i64, ret, arg1, arg2);
B
bellard 已提交
1243 1244
}

P
pbrook 已提交
1245
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1246
{
P
pbrook 已提交
1247
    tcg_gen_op3_i64(INDEX_op_remu_i64, ret, arg1, arg2);
B
bellard 已提交
1248
}
A
Aurelien Jarno 已提交
1249
#elif defined(TCG_TARGET_HAS_div2_i64)
P
pbrook 已提交
1250
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1251
{
P
pbrook 已提交
1252 1253
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1254
    tcg_gen_sari_i64(t0, arg1, 63);
P
pbrook 已提交
1255 1256
    tcg_gen_op5_i64(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1257 1258
}

P
pbrook 已提交
1259
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1260
{
P
pbrook 已提交
1261 1262
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1263
    tcg_gen_sari_i64(t0, arg1, 63);
P
pbrook 已提交
1264 1265
    tcg_gen_op5_i64(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1266 1267
}

P
pbrook 已提交
1268
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1269
{
P
pbrook 已提交
1270 1271
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1272
    tcg_gen_movi_i64(t0, 0);
P
pbrook 已提交
1273 1274
    tcg_gen_op5_i64(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1275 1276
}

P
pbrook 已提交
1277
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1278
{
P
pbrook 已提交
1279 1280
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1281
    tcg_gen_movi_i64(t0, 0);
P
pbrook 已提交
1282 1283
    tcg_gen_op5_i64(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1284
}
A
Aurelien Jarno 已提交
1285 1286 1287
#else
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
{
1288 1289 1290 1291 1292 1293 1294
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 1, 1);
    sizemask |= tcg_gen_sizemask(1, 1, 1);
    sizemask |= tcg_gen_sizemask(2, 1, 1);

    tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
1295 1296 1297 1298
}

static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
{
1299 1300 1301 1302 1303 1304 1305
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and signed.  */
    sizemask |= tcg_gen_sizemask(0, 1, 1);
    sizemask |= tcg_gen_sizemask(1, 1, 1);
    sizemask |= tcg_gen_sizemask(2, 1, 1);

    tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
1306 1307 1308 1309
}

static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
{
1310 1311 1312 1313 1314 1315 1316
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and unsigned.  */
    sizemask |= tcg_gen_sizemask(0, 1, 0);
    sizemask |= tcg_gen_sizemask(1, 1, 0);
    sizemask |= tcg_gen_sizemask(2, 1, 0);

    tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
1317 1318 1319 1320
}

static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
{
1321 1322 1323 1324 1325 1326 1327
    int sizemask = 0;
    /* Return value and both arguments are 64-bit and unsigned.  */
    sizemask |= tcg_gen_sizemask(0, 1, 0);
    sizemask |= tcg_gen_sizemask(1, 1, 0);
    sizemask |= tcg_gen_sizemask(2, 1, 0);

    tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
A
Aurelien Jarno 已提交
1328
}
B
bellard 已提交
1329 1330 1331 1332
#endif

#endif

P
pbrook 已提交
1333
static inline void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1334 1335 1336 1337 1338
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1339
        TCGv_i64 t0 = tcg_const_i64(arg2);
1340
        tcg_gen_add_i64(ret, arg1, t0);
P
pbrook 已提交
1341
        tcg_temp_free_i64(t0);
1342 1343 1344
    }
}

P
pbrook 已提交
1345
static inline void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2)
A
aurel32 已提交
1346
{
P
pbrook 已提交
1347
    TCGv_i64 t0 = tcg_const_i64(arg1);
A
aurel32 已提交
1348
    tcg_gen_sub_i64(ret, t0, arg2);
P
pbrook 已提交
1349
    tcg_temp_free_i64(t0);
A
aurel32 已提交
1350 1351
}

P
pbrook 已提交
1352
static inline void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1353 1354 1355 1356 1357
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1358
        TCGv_i64 t0 = tcg_const_i64(arg2);
1359
        tcg_gen_sub_i64(ret, arg1, t0);
P
pbrook 已提交
1360
        tcg_temp_free_i64(t0);
1361 1362
    }
}
1363 1364
static inline void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1,
                                       int64_t arg2, int label_index)
1365
{
P
pbrook 已提交
1366
    TCGv_i64 t0 = tcg_const_i64(arg2);
1367
    tcg_gen_brcond_i64(cond, arg1, t0, label_index);
P
pbrook 已提交
1368
    tcg_temp_free_i64(t0);
1369 1370
}

1371 1372
static inline void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret,
                                        TCGv_i64 arg1, int64_t arg2)
1373 1374 1375 1376 1377 1378
{
    TCGv_i64 t0 = tcg_const_i64(arg2);
    tcg_gen_setcond_i64(cond, ret, arg1, t0);
    tcg_temp_free_i64(t0);
}

P
pbrook 已提交
1379
static inline void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1380
{
P
pbrook 已提交
1381
    TCGv_i64 t0 = tcg_const_i64(arg2);
1382
    tcg_gen_mul_i64(ret, arg1, t0);
P
pbrook 已提交
1383
    tcg_temp_free_i64(t0);
1384 1385
}

1386

B
bellard 已提交
1387 1388 1389
/***************************************/
/* optional operations */

P
pbrook 已提交
1390
static inline void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1391 1392
{
#ifdef TCG_TARGET_HAS_ext8s_i32
P
pbrook 已提交
1393
    tcg_gen_op2_i32(INDEX_op_ext8s_i32, ret, arg);
B
bellard 已提交
1394 1395
#else
    tcg_gen_shli_i32(ret, arg, 24);
1396
    tcg_gen_sari_i32(ret, ret, 24);
B
bellard 已提交
1397 1398 1399
#endif
}

P
pbrook 已提交
1400
static inline void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1401 1402
{
#ifdef TCG_TARGET_HAS_ext16s_i32
P
pbrook 已提交
1403
    tcg_gen_op2_i32(INDEX_op_ext16s_i32, ret, arg);
B
bellard 已提交
1404 1405
#else
    tcg_gen_shli_i32(ret, arg, 16);
1406
    tcg_gen_sari_i32(ret, ret, 16);
B
bellard 已提交
1407 1408 1409
#endif
}

P
pbrook 已提交
1410
static inline void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg)
P
pbrook 已提交
1411
{
1412 1413 1414
#ifdef TCG_TARGET_HAS_ext8u_i32
    tcg_gen_op2_i32(INDEX_op_ext8u_i32, ret, arg);
#else
P
pbrook 已提交
1415
    tcg_gen_andi_i32(ret, arg, 0xffu);
1416
#endif
P
pbrook 已提交
1417 1418
}

P
pbrook 已提交
1419
static inline void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg)
P
pbrook 已提交
1420
{
1421 1422 1423
#ifdef TCG_TARGET_HAS_ext16u_i32
    tcg_gen_op2_i32(INDEX_op_ext16u_i32, ret, arg);
#else
P
pbrook 已提交
1424
    tcg_gen_andi_i32(ret, arg, 0xffffu);
1425
#endif
P
pbrook 已提交
1426 1427
}

B
bellard 已提交
1428
/* Note: we assume the two high bytes are set to zero */
P
pbrook 已提交
1429
static inline void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1430 1431
{
#ifdef TCG_TARGET_HAS_bswap16_i32
P
pbrook 已提交
1432
    tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg);
B
bellard 已提交
1433
#else
A
aurel32 已提交
1434
    TCGv_i32 t0 = tcg_temp_new_i32();
B
bellard 已提交
1435
    
A
aurel32 已提交
1436 1437 1438 1439
    tcg_gen_ext8u_i32(t0, arg);
    tcg_gen_shli_i32(t0, t0, 8);
    tcg_gen_shri_i32(ret, arg, 8);
    tcg_gen_or_i32(ret, ret, t0);
P
pbrook 已提交
1440
    tcg_temp_free_i32(t0);
B
bellard 已提交
1441 1442 1443
#endif
}

A
aurel32 已提交
1444
static inline void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1445
{
A
aurel32 已提交
1446 1447
#ifdef TCG_TARGET_HAS_bswap32_i32
    tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg);
B
bellard 已提交
1448
#else
P
pbrook 已提交
1449 1450 1451
    TCGv_i32 t0, t1;
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
B
bellard 已提交
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464
    
    tcg_gen_shli_i32(t0, arg, 24);
    
    tcg_gen_andi_i32(t1, arg, 0x0000ff00);
    tcg_gen_shli_i32(t1, t1, 8);
    tcg_gen_or_i32(t0, t0, t1);
    
    tcg_gen_shri_i32(t1, arg, 8);
    tcg_gen_andi_i32(t1, t1, 0x0000ff00);
    tcg_gen_or_i32(t0, t0, t1);
    
    tcg_gen_shri_i32(t1, arg, 24);
    tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
1465 1466
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
1467 1468 1469 1470
#endif
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1471
static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1472
{
P
pbrook 已提交
1473 1474
    tcg_gen_ext8s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1475 1476
}

P
pbrook 已提交
1477
static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1478
{
P
pbrook 已提交
1479 1480
    tcg_gen_ext16s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1481 1482
}

P
pbrook 已提交
1483
static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1484
{
P
pbrook 已提交
1485 1486
    tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1487 1488
}

P
pbrook 已提交
1489
static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1490
{
P
pbrook 已提交
1491
    tcg_gen_ext8u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
P
pbrook 已提交
1492 1493 1494
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
1495
static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1496
{
P
pbrook 已提交
1497
    tcg_gen_ext16u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
P
pbrook 已提交
1498 1499 1500
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
1501
static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1502
{
P
pbrook 已提交
1503
    tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
P
pbrook 已提交
1504 1505 1506
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
1507
static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
B
bellard 已提交
1508
{
P
pbrook 已提交
1509
    tcg_gen_mov_i32(ret, TCGV_LOW(arg));
B
bellard 已提交
1510 1511
}

P
pbrook 已提交
1512
static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
B
bellard 已提交
1513
{
P
pbrook 已提交
1514
    tcg_gen_mov_i32(TCGV_LOW(ret), arg);
P
pbrook 已提交
1515
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1516 1517
}

P
pbrook 已提交
1518
static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
B
bellard 已提交
1519
{
P
pbrook 已提交
1520 1521
    tcg_gen_mov_i32(TCGV_LOW(ret), arg);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1522 1523
}

1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537
/* Note: we assume the six high bytes are set to zero */
static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg)
{
    tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
    tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg));
}

/* Note: we assume the four high bytes are set to zero */
static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg)
{
    tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
    tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg));
}

A
aurel32 已提交
1538
static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1539
{
P
pbrook 已提交
1540 1541 1542
    TCGv_i32 t0, t1;
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
B
bellard 已提交
1543

A
aurel32 已提交
1544 1545
    tcg_gen_bswap32_i32(t0, TCGV_LOW(arg));
    tcg_gen_bswap32_i32(t1, TCGV_HIGH(arg));
P
pbrook 已提交
1546
    tcg_gen_mov_i32(TCGV_LOW(ret), t1);
P
pbrook 已提交
1547
    tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
P
pbrook 已提交
1548 1549
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
1550 1551 1552
}
#else

P
pbrook 已提交
1553
static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1554 1555
{
#ifdef TCG_TARGET_HAS_ext8s_i64
P
pbrook 已提交
1556
    tcg_gen_op2_i64(INDEX_op_ext8s_i64, ret, arg);
B
bellard 已提交
1557 1558
#else
    tcg_gen_shli_i64(ret, arg, 56);
1559
    tcg_gen_sari_i64(ret, ret, 56);
B
bellard 已提交
1560 1561 1562
#endif
}

P
pbrook 已提交
1563
static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1564 1565
{
#ifdef TCG_TARGET_HAS_ext16s_i64
P
pbrook 已提交
1566
    tcg_gen_op2_i64(INDEX_op_ext16s_i64, ret, arg);
B
bellard 已提交
1567 1568
#else
    tcg_gen_shli_i64(ret, arg, 48);
1569
    tcg_gen_sari_i64(ret, ret, 48);
B
bellard 已提交
1570 1571 1572
#endif
}

P
pbrook 已提交
1573
static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1574 1575
{
#ifdef TCG_TARGET_HAS_ext32s_i64
P
pbrook 已提交
1576
    tcg_gen_op2_i64(INDEX_op_ext32s_i64, ret, arg);
B
bellard 已提交
1577 1578
#else
    tcg_gen_shli_i64(ret, arg, 32);
1579
    tcg_gen_sari_i64(ret, ret, 32);
B
bellard 已提交
1580 1581 1582
#endif
}

P
pbrook 已提交
1583
static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1584
{
1585 1586 1587
#ifdef TCG_TARGET_HAS_ext8u_i64
    tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg);
#else
P
pbrook 已提交
1588
    tcg_gen_andi_i64(ret, arg, 0xffu);
1589
#endif
P
pbrook 已提交
1590 1591
}

P
pbrook 已提交
1592
static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1593
{
1594 1595 1596
#ifdef TCG_TARGET_HAS_ext16u_i64
    tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg);
#else
P
pbrook 已提交
1597
    tcg_gen_andi_i64(ret, arg, 0xffffu);
1598
#endif
P
pbrook 已提交
1599 1600
}

P
pbrook 已提交
1601
static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1602
{
1603 1604 1605
#ifdef TCG_TARGET_HAS_ext32u_i64
    tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg);
#else
P
pbrook 已提交
1606
    tcg_gen_andi_i64(ret, arg, 0xffffffffu);
1607
#endif
P
pbrook 已提交
1608 1609
}

B
bellard 已提交
1610
/* Note: we assume the target supports move between 32 and 64 bit
P
pbrook 已提交
1611
   registers.  This will probably break MIPS64 targets.  */
P
pbrook 已提交
1612
static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
B
bellard 已提交
1613
{
P
pbrook 已提交
1614
    tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg)));
B
bellard 已提交
1615 1616 1617 1618
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1619
static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
B
bellard 已提交
1620
{
1621
    tcg_gen_ext32u_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)));
B
bellard 已提交
1622 1623 1624 1625
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1626
static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
B
bellard 已提交
1627
{
P
pbrook 已提交
1628
    tcg_gen_ext32s_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)));
B
bellard 已提交
1629 1630
}

1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674
/* Note: we assume the six high bytes are set to zero */
static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg)
{
#ifdef TCG_TARGET_HAS_bswap16_i64
    tcg_gen_op2_i64(INDEX_op_bswap16_i64, ret, arg);
#else
    TCGv_i64 t0 = tcg_temp_new_i64();

    tcg_gen_ext8u_i64(t0, arg);
    tcg_gen_shli_i64(t0, t0, 8);
    tcg_gen_shri_i64(ret, arg, 8);
    tcg_gen_or_i64(ret, ret, t0);
    tcg_temp_free_i64(t0);
#endif
}

/* Note: we assume the four high bytes are set to zero */
static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg)
{
#ifdef TCG_TARGET_HAS_bswap32_i64
    tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg);
#else
    TCGv_i64 t0, t1;
    t0 = tcg_temp_new_i64();
    t1 = tcg_temp_new_i64();

    tcg_gen_shli_i64(t0, arg, 24);
    tcg_gen_ext32u_i64(t0, t0);

    tcg_gen_andi_i64(t1, arg, 0x0000ff00);
    tcg_gen_shli_i64(t1, t1, 8);
    tcg_gen_or_i64(t0, t0, t1);

    tcg_gen_shri_i64(t1, arg, 8);
    tcg_gen_andi_i64(t1, t1, 0x0000ff00);
    tcg_gen_or_i64(t0, t0, t1);

    tcg_gen_shri_i64(t1, arg, 24);
    tcg_gen_or_i64(ret, t0, t1);
    tcg_temp_free_i64(t0);
    tcg_temp_free_i64(t1);
#endif
}

A
aurel32 已提交
1675
static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1676
{
A
aurel32 已提交
1677 1678
#ifdef TCG_TARGET_HAS_bswap64_i64
    tcg_gen_op2_i64(INDEX_op_bswap64_i64, ret, arg);
B
bellard 已提交
1679
#else
1680 1681
    TCGv_i64 t0 = tcg_temp_new_i64();
    TCGv_i64 t1 = tcg_temp_new_i64();
B
bellard 已提交
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710
    
    tcg_gen_shli_i64(t0, arg, 56);
    
    tcg_gen_andi_i64(t1, arg, 0x0000ff00);
    tcg_gen_shli_i64(t1, t1, 40);
    tcg_gen_or_i64(t0, t0, t1);
    
    tcg_gen_andi_i64(t1, arg, 0x00ff0000);
    tcg_gen_shli_i64(t1, t1, 24);
    tcg_gen_or_i64(t0, t0, t1);

    tcg_gen_andi_i64(t1, arg, 0xff000000);
    tcg_gen_shli_i64(t1, t1, 8);
    tcg_gen_or_i64(t0, t0, t1);

    tcg_gen_shri_i64(t1, arg, 8);
    tcg_gen_andi_i64(t1, t1, 0xff000000);
    tcg_gen_or_i64(t0, t0, t1);
    
    tcg_gen_shri_i64(t1, arg, 24);
    tcg_gen_andi_i64(t1, t1, 0x00ff0000);
    tcg_gen_or_i64(t0, t0, t1);

    tcg_gen_shri_i64(t1, arg, 40);
    tcg_gen_andi_i64(t1, t1, 0x0000ff00);
    tcg_gen_or_i64(t0, t0, t1);

    tcg_gen_shri_i64(t1, arg, 56);
    tcg_gen_or_i64(ret, t0, t1);
1711 1712
    tcg_temp_free_i64(t0);
    tcg_temp_free_i64(t1);
B
bellard 已提交
1713 1714 1715 1716 1717
#endif
}

#endif

P
pbrook 已提交
1718
static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg)
P
pbrook 已提交
1719 1720
{
#ifdef TCG_TARGET_HAS_neg_i32
P
pbrook 已提交
1721
    tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg);
P
pbrook 已提交
1722
#else
P
pbrook 已提交
1723
    TCGv_i32 t0 = tcg_const_i32(0);
1724
    tcg_gen_sub_i32(ret, t0, arg);
P
pbrook 已提交
1725
    tcg_temp_free_i32(t0);
P
pbrook 已提交
1726 1727 1728
#endif
}

P
pbrook 已提交
1729
static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1730 1731
{
#ifdef TCG_TARGET_HAS_neg_i64
P
pbrook 已提交
1732
    tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg);
P
pbrook 已提交
1733
#else
P
pbrook 已提交
1734
    TCGv_i64 t0 = tcg_const_i64(0);
1735
    tcg_gen_sub_i64(ret, t0, arg);
P
pbrook 已提交
1736
    tcg_temp_free_i64(t0);
P
pbrook 已提交
1737 1738 1739
#endif
}

P
pbrook 已提交
1740
static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1741
{
A
aurel32 已提交
1742 1743 1744
#ifdef TCG_TARGET_HAS_not_i32
    tcg_gen_op2_i32(INDEX_op_not_i32, ret, arg);
#else
1745
    tcg_gen_xori_i32(ret, arg, -1);
A
aurel32 已提交
1746
#endif
B
bellard 已提交
1747 1748
}

P
pbrook 已提交
1749
static inline void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1750
{
A
aurel32 已提交
1751
#ifdef TCG_TARGET_HAS_not_i64
A
aurel32 已提交
1752
    tcg_gen_op2_i64(INDEX_op_not_i64, ret, arg);
1753 1754 1755
#elif defined(TCG_TARGET_HAS_not_i32) && TCG_TARGET_REG_BITS == 32
    tcg_gen_not_i32(TCGV_LOW(ret), TCGV_LOW(arg));
    tcg_gen_not_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
A
aurel32 已提交
1756
#else
1757
    tcg_gen_xori_i64(ret, arg, -1);
A
aurel32 已提交
1758
#endif
B
bellard 已提交
1759
}
1760

P
pbrook 已提交
1761
static inline void tcg_gen_discard_i32(TCGv_i32 arg)
1762
{
P
pbrook 已提交
1763
    tcg_gen_op1_i32(INDEX_op_discard, arg);
1764 1765 1766
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1767
static inline void tcg_gen_discard_i64(TCGv_i64 arg)
1768
{
P
pbrook 已提交
1769
    tcg_gen_discard_i32(TCGV_LOW(arg));
1770 1771 1772
    tcg_gen_discard_i32(TCGV_HIGH(arg));
}
#else
P
pbrook 已提交
1773
static inline void tcg_gen_discard_i64(TCGv_i64 arg)
1774
{
P
pbrook 已提交
1775
    tcg_gen_op1_i64(INDEX_op_discard, arg);
1776 1777 1778
}
#endif

P
pbrook 已提交
1779
static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high)
P
pbrook 已提交
1780 1781
{
#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1782
    tcg_gen_mov_i32(TCGV_LOW(dest), low);
P
pbrook 已提交
1783 1784
    tcg_gen_mov_i32(TCGV_HIGH(dest), high);
#else
P
pbrook 已提交
1785
    TCGv_i64 tmp = tcg_temp_new_i64();
P
pbrook 已提交
1786 1787 1788 1789 1790 1791
    /* This extension is only needed for type correctness.
       We may be able to do better given target specific information.  */
    tcg_gen_extu_i32_i64(tmp, high);
    tcg_gen_shli_i64(tmp, tmp, 32);
    tcg_gen_extu_i32_i64(dest, low);
    tcg_gen_or_i64(dest, dest, tmp);
P
pbrook 已提交
1792
    tcg_temp_free_i64(tmp);
P
pbrook 已提交
1793 1794 1795
#endif
}

P
pbrook 已提交
1796
static inline void tcg_gen_concat32_i64(TCGv_i64 dest, TCGv_i64 low, TCGv_i64 high)
1797 1798
{
#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1799
    tcg_gen_concat_i32_i64(dest, TCGV_LOW(low), TCGV_LOW(high));
1800
#else
P
pbrook 已提交
1801
    TCGv_i64 tmp = tcg_temp_new_i64();
1802
    tcg_gen_ext32u_i64(dest, low);
1803
    tcg_gen_shli_i64(tmp, high, 32);
1804
    tcg_gen_or_i64(dest, dest, tmp);
P
pbrook 已提交
1805
    tcg_temp_free_i64(tmp);
1806 1807 1808
#endif
}

P
pbrook 已提交
1809
static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1810
{
1811 1812 1813
#ifdef TCG_TARGET_HAS_andc_i32
    tcg_gen_op3_i32(INDEX_op_andc_i32, ret, arg1, arg2);
#else
P
pbrook 已提交
1814 1815
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
1816 1817
    tcg_gen_not_i32(t0, arg2);
    tcg_gen_and_i32(ret, arg1, t0);
P
pbrook 已提交
1818
    tcg_temp_free_i32(t0);
1819
#endif
1820 1821
}

P
pbrook 已提交
1822
static inline void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1823
{
1824 1825 1826 1827 1828 1829
#ifdef TCG_TARGET_HAS_andc_i64
    tcg_gen_op3_i64(INDEX_op_andc_i64, ret, arg1, arg2);
#elif defined(TCG_TARGET_HAS_andc_i32) && TCG_TARGET_REG_BITS == 32
    tcg_gen_andc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
    tcg_gen_andc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
#else
P
pbrook 已提交
1830 1831
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
1832 1833
    tcg_gen_not_i64(t0, arg2);
    tcg_gen_and_i64(ret, arg1, t0);
P
pbrook 已提交
1834
    tcg_temp_free_i64(t0);
1835
#endif
1836 1837
}

P
pbrook 已提交
1838
static inline void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1839
{
1840 1841 1842
#ifdef TCG_TARGET_HAS_eqv_i32
    tcg_gen_op3_i32(INDEX_op_eqv_i32, ret, arg1, arg2);
#else
A
aurel32 已提交
1843 1844
    tcg_gen_xor_i32(ret, arg1, arg2);
    tcg_gen_not_i32(ret, ret);
1845
#endif
1846 1847
}

P
pbrook 已提交
1848
static inline void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1849
{
1850 1851 1852 1853 1854 1855
#ifdef TCG_TARGET_HAS_eqv_i64
    tcg_gen_op3_i64(INDEX_op_eqv_i64, ret, arg1, arg2);
#elif defined(TCG_TARGET_HAS_eqv_i32) && TCG_TARGET_REG_BITS == 32
    tcg_gen_eqv_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
    tcg_gen_eqv_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
#else
A
aurel32 已提交
1856 1857
    tcg_gen_xor_i64(ret, arg1, arg2);
    tcg_gen_not_i64(ret, ret);
1858
#endif
1859 1860
}

P
pbrook 已提交
1861
static inline void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1862
{
1863 1864 1865
#ifdef TCG_TARGET_HAS_nand_i32
    tcg_gen_op3_i32(INDEX_op_nand_i32, ret, arg1, arg2);
#else
A
aurel32 已提交
1866 1867
    tcg_gen_and_i32(ret, arg1, arg2);
    tcg_gen_not_i32(ret, ret);
1868
#endif
1869 1870
}

P
pbrook 已提交
1871
static inline void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1872
{
1873 1874 1875 1876 1877 1878
#ifdef TCG_TARGET_HAS_nand_i64
    tcg_gen_op3_i64(INDEX_op_nand_i64, ret, arg1, arg2);
#elif defined(TCG_TARGET_HAS_nand_i32) && TCG_TARGET_REG_BITS == 32
    tcg_gen_nand_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
    tcg_gen_nand_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
#else
A
aurel32 已提交
1879 1880
    tcg_gen_and_i64(ret, arg1, arg2);
    tcg_gen_not_i64(ret, ret);
1881
#endif
1882 1883
}

P
pbrook 已提交
1884
static inline void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1885
{
1886 1887 1888
#ifdef TCG_TARGET_HAS_nor_i32
    tcg_gen_op3_i32(INDEX_op_nor_i32, ret, arg1, arg2);
#else
A
aurel32 已提交
1889 1890
    tcg_gen_or_i32(ret, arg1, arg2);
    tcg_gen_not_i32(ret, ret);
1891
#endif
1892 1893
}

P
pbrook 已提交
1894
static inline void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1895
{
1896 1897 1898 1899 1900 1901
#ifdef TCG_TARGET_HAS_nor_i64
    tcg_gen_op3_i64(INDEX_op_nor_i64, ret, arg1, arg2);
#elif defined(TCG_TARGET_HAS_nor_i32) && TCG_TARGET_REG_BITS == 32
    tcg_gen_nor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
    tcg_gen_nor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
#else
A
aurel32 已提交
1902 1903
    tcg_gen_or_i64(ret, arg1, arg2);
    tcg_gen_not_i64(ret, ret);
1904
#endif
1905 1906
}

P
pbrook 已提交
1907
static inline void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1908
{
1909 1910 1911
#ifdef TCG_TARGET_HAS_orc_i32
    tcg_gen_op3_i32(INDEX_op_orc_i32, ret, arg1, arg2);
#else
P
pbrook 已提交
1912 1913
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
1914 1915
    tcg_gen_not_i32(t0, arg2);
    tcg_gen_or_i32(ret, arg1, t0);
P
pbrook 已提交
1916
    tcg_temp_free_i32(t0);
1917
#endif
1918 1919
}

P
pbrook 已提交
1920
static inline void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1921
{
1922 1923 1924 1925 1926 1927
#ifdef TCG_TARGET_HAS_orc_i64
    tcg_gen_op3_i64(INDEX_op_orc_i64, ret, arg1, arg2);
#elif defined(TCG_TARGET_HAS_orc_i32) && TCG_TARGET_REG_BITS == 32
    tcg_gen_orc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
    tcg_gen_orc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
#else
P
pbrook 已提交
1928 1929
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
1930 1931
    tcg_gen_not_i64(t0, arg2);
    tcg_gen_or_i64(ret, arg1, t0);
P
pbrook 已提交
1932
    tcg_temp_free_i64(t0);
1933
#endif
1934 1935
}

P
pbrook 已提交
1936
static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1937
{
A
aurel32 已提交
1938 1939 1940
#ifdef TCG_TARGET_HAS_rot_i32
    tcg_gen_op3_i32(INDEX_op_rotl_i32, ret, arg1, arg2);
#else
P
pbrook 已提交
1941
    TCGv_i32 t0, t1;
1942

P
pbrook 已提交
1943 1944
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
1945 1946 1947 1948
    tcg_gen_shl_i32(t0, arg1, arg2);
    tcg_gen_subfi_i32(t1, 32, arg2);
    tcg_gen_shr_i32(t1, arg1, t1);
    tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
1949 1950
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
A
aurel32 已提交
1951
#endif
1952 1953
}

P
pbrook 已提交
1954
static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1955
{
A
aurel32 已提交
1956 1957 1958
#ifdef TCG_TARGET_HAS_rot_i64
    tcg_gen_op3_i64(INDEX_op_rotl_i64, ret, arg1, arg2);
#else
P
pbrook 已提交
1959
    TCGv_i64 t0, t1;
1960

P
pbrook 已提交
1961 1962
    t0 = tcg_temp_new_i64();
    t1 = tcg_temp_new_i64();
1963 1964 1965 1966
    tcg_gen_shl_i64(t0, arg1, arg2);
    tcg_gen_subfi_i64(t1, 64, arg2);
    tcg_gen_shr_i64(t1, arg1, t1);
    tcg_gen_or_i64(ret, t0, t1);
P
pbrook 已提交
1967 1968
    tcg_temp_free_i64(t0);
    tcg_temp_free_i64(t1);
A
aurel32 已提交
1969
#endif
1970 1971
}

P
pbrook 已提交
1972
static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
1973 1974 1975 1976 1977
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
A
aurel32 已提交
1978 1979 1980 1981 1982
#ifdef TCG_TARGET_HAS_rot_i32
        TCGv_i32 t0 = tcg_const_i32(arg2);
        tcg_gen_rotl_i32(ret, arg1, t0);
        tcg_temp_free_i32(t0);
#else
P
pbrook 已提交
1983 1984 1985
        TCGv_i32 t0, t1;
        t0 = tcg_temp_new_i32();
        t1 = tcg_temp_new_i32();
1986 1987 1988
        tcg_gen_shli_i32(t0, arg1, arg2);
        tcg_gen_shri_i32(t1, arg1, 32 - arg2);
        tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
1989 1990
        tcg_temp_free_i32(t0);
        tcg_temp_free_i32(t1);
A
aurel32 已提交
1991
#endif
1992 1993 1994
    }
}

P
pbrook 已提交
1995
static inline void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1996 1997 1998 1999 2000
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
A
aurel32 已提交
2001 2002 2003 2004 2005
#ifdef TCG_TARGET_HAS_rot_i64
        TCGv_i64 t0 = tcg_const_i64(arg2);
        tcg_gen_rotl_i64(ret, arg1, t0);
        tcg_temp_free_i64(t0);
#else
P
pbrook 已提交
2006 2007 2008
        TCGv_i64 t0, t1;
        t0 = tcg_temp_new_i64();
        t1 = tcg_temp_new_i64();
2009 2010 2011
        tcg_gen_shli_i64(t0, arg1, arg2);
        tcg_gen_shri_i64(t1, arg1, 64 - arg2);
        tcg_gen_or_i64(ret, t0, t1);
P
pbrook 已提交
2012 2013
        tcg_temp_free_i64(t0);
        tcg_temp_free_i64(t1);
A
aurel32 已提交
2014
#endif
2015 2016 2017
    }
}

P
pbrook 已提交
2018
static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
2019
{
A
aurel32 已提交
2020 2021 2022
#ifdef TCG_TARGET_HAS_rot_i32
    tcg_gen_op3_i32(INDEX_op_rotr_i32, ret, arg1, arg2);
#else
P
pbrook 已提交
2023
    TCGv_i32 t0, t1;
2024

P
pbrook 已提交
2025 2026
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
2027 2028 2029 2030
    tcg_gen_shr_i32(t0, arg1, arg2);
    tcg_gen_subfi_i32(t1, 32, arg2);
    tcg_gen_shl_i32(t1, arg1, t1);
    tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
2031 2032
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
A
aurel32 已提交
2033
#endif
2034 2035
}

P
pbrook 已提交
2036
static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
2037
{
A
aurel32 已提交
2038 2039 2040
#ifdef TCG_TARGET_HAS_rot_i64
    tcg_gen_op3_i64(INDEX_op_rotr_i64, ret, arg1, arg2);
#else
P
pbrook 已提交
2041
    TCGv_i64 t0, t1;
2042

P
pbrook 已提交
2043 2044
    t0 = tcg_temp_new_i64();
    t1 = tcg_temp_new_i64();
A
Aurelien Jarno 已提交
2045
    tcg_gen_shr_i64(t0, arg1, arg2);
2046 2047 2048
    tcg_gen_subfi_i64(t1, 64, arg2);
    tcg_gen_shl_i64(t1, arg1, t1);
    tcg_gen_or_i64(ret, t0, t1);
P
pbrook 已提交
2049 2050
    tcg_temp_free_i64(t0);
    tcg_temp_free_i64(t1);
A
aurel32 已提交
2051
#endif
2052 2053
}

P
pbrook 已提交
2054
static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
2055 2056 2057 2058 2059 2060 2061 2062 2063
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_rotli_i32(ret, arg1, 32 - arg2);
    }
}

P
pbrook 已提交
2064
static inline void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
2065 2066 2067
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
P
pbrook 已提交
2068
        tcg_gen_mov_i64(ret, arg1);
2069 2070 2071 2072 2073
    } else {
        tcg_gen_rotli_i64(ret, arg1, 64 - arg2);
    }
}

B
bellard 已提交
2074 2075 2076 2077 2078 2079 2080
/***************************************/
/* QEMU specific operations. Their type depend on the QEMU CPU
   type. */
#ifndef TARGET_LONG_BITS
#error must include QEMU headers
#endif

P
pbrook 已提交
2081 2082 2083 2084 2085
#if TARGET_LONG_BITS == 32
#define TCGv TCGv_i32
#define tcg_temp_new() tcg_temp_new_i32()
#define tcg_global_reg_new tcg_global_reg_new_i32
#define tcg_global_mem_new tcg_global_mem_new_i32
2086
#define tcg_temp_local_new() tcg_temp_local_new_i32()
P
pbrook 已提交
2087 2088 2089 2090
#define tcg_temp_free tcg_temp_free_i32
#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
#define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
A
aurel32 已提交
2091
#define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
P
pbrook 已提交
2092 2093 2094 2095 2096
#else
#define TCGv TCGv_i64
#define tcg_temp_new() tcg_temp_new_i64()
#define tcg_global_reg_new tcg_global_reg_new_i64
#define tcg_global_mem_new tcg_global_mem_new_i64
2097
#define tcg_temp_local_new() tcg_temp_local_new_i64()
P
pbrook 已提交
2098 2099 2100 2101
#define tcg_temp_free tcg_temp_free_i64
#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
#define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
A
aurel32 已提交
2102
#define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
P
pbrook 已提交
2103 2104
#endif

2105 2106 2107 2108 2109
/* debug info: write the PC of the corresponding QEMU CPU instruction */
static inline void tcg_gen_debug_insn_start(uint64_t pc)
{
    /* XXX: must really use a 32 bit size for TCGArg in all cases */
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
P
pbrook 已提交
2110 2111
    tcg_gen_op2ii(INDEX_op_debug_insn_start, 
                  (uint32_t)(pc), (uint32_t)(pc >> 32));
2112 2113 2114 2115 2116
#else
    tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
#endif
}

B
bellard 已提交
2117 2118
static inline void tcg_gen_exit_tb(tcg_target_long val)
{
P
pbrook 已提交
2119
    tcg_gen_op1i(INDEX_op_exit_tb, val);
B
bellard 已提交
2120 2121 2122 2123
}

static inline void tcg_gen_goto_tb(int idx)
{
P
pbrook 已提交
2124
    tcg_gen_op1i(INDEX_op_goto_tb, idx);
B
bellard 已提交
2125 2126 2127
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
2128
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2129 2130
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2131
    tcg_gen_op3i_i32(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
2132
#else
P
pbrook 已提交
2133 2134
    tcg_gen_op4i_i32(INDEX_op_qemu_ld8u, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
P
pbrook 已提交
2135
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
2136 2137 2138
#endif
}

P
pbrook 已提交
2139
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2140 2141
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2142
    tcg_gen_op3i_i32(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
2143
#else
P
pbrook 已提交
2144 2145 2146
    tcg_gen_op4i_i32(INDEX_op_qemu_ld8s, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
2147 2148 2149
#endif
}

P
pbrook 已提交
2150
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2151 2152
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2153
    tcg_gen_op3i_i32(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
2154
#else
P
pbrook 已提交
2155 2156
    tcg_gen_op4i_i32(INDEX_op_qemu_ld16u, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
P
pbrook 已提交
2157
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
2158 2159 2160
#endif
}

P
pbrook 已提交
2161
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2162 2163
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2164
    tcg_gen_op3i_i32(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
2165
#else
P
pbrook 已提交
2166 2167 2168
    tcg_gen_op4i_i32(INDEX_op_qemu_ld16s, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
2169 2170 2171
#endif
}

P
pbrook 已提交
2172
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2173 2174
{
#if TARGET_LONG_BITS == 32
2175
    tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index);
B
bellard 已提交
2176
#else
2177
    tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr),
P
pbrook 已提交
2178
                     TCGV_HIGH(addr), mem_index);
P
pbrook 已提交
2179
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
2180 2181 2182
#endif
}

P
pbrook 已提交
2183
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2184 2185
{
#if TARGET_LONG_BITS == 32
2186
    tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index);
B
bellard 已提交
2187
#else
2188
    tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr),
P
pbrook 已提交
2189 2190
                     TCGV_HIGH(addr), mem_index);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
2191 2192 2193
#endif
}

P
pbrook 已提交
2194
static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
B
bellard 已提交
2195 2196
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2197
    tcg_gen_op4i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), addr, mem_index);
B
bellard 已提交
2198
#else
P
pbrook 已提交
2199 2200
    tcg_gen_op5i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret),
                     TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
B
bellard 已提交
2201 2202 2203
#endif
}

P
pbrook 已提交
2204
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
2205 2206
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2207
    tcg_gen_op3i_i32(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
2208
#else
P
pbrook 已提交
2209 2210
    tcg_gen_op4i_i32(INDEX_op_qemu_st8, TCGV_LOW(arg), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
B
bellard 已提交
2211 2212 2213
#endif
}

P
pbrook 已提交
2214
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
2215 2216
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2217
    tcg_gen_op3i_i32(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
2218
#else
P
pbrook 已提交
2219 2220
    tcg_gen_op4i_i32(INDEX_op_qemu_st16, TCGV_LOW(arg), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
B
bellard 已提交
2221 2222 2223
#endif
}

P
pbrook 已提交
2224
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
2225 2226
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2227
    tcg_gen_op3i_i32(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
2228
#else
P
pbrook 已提交
2229 2230
    tcg_gen_op4i_i32(INDEX_op_qemu_st32, TCGV_LOW(arg), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
B
bellard 已提交
2231 2232 2233
#endif
}

P
pbrook 已提交
2234
static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
B
bellard 已提交
2235 2236
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
2237 2238
    tcg_gen_op4i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), addr,
                     mem_index);
B
bellard 已提交
2239
#else
P
pbrook 已提交
2240 2241
    tcg_gen_op5i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg),
                     TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
B
bellard 已提交
2242 2243 2244
#endif
}

B
blueswir1 已提交
2245
#define tcg_gen_ld_ptr tcg_gen_ld_i32
B
blueswir1 已提交
2246
#define tcg_gen_discard_ptr tcg_gen_discard_i32
2247

B
bellard 已提交
2248 2249
#else /* TCG_TARGET_REG_BITS == 32 */

P
pbrook 已提交
2250
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2251
{
P
pbrook 已提交
2252
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
2253 2254
}

P
pbrook 已提交
2255
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2256
{
P
pbrook 已提交
2257
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
2258 2259
}

P
pbrook 已提交
2260
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2261
{
P
pbrook 已提交
2262
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
2263 2264
}

P
pbrook 已提交
2265
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2266
{
P
pbrook 已提交
2267
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
2268 2269
}

P
pbrook 已提交
2270
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2271
{
2272 2273 2274
#if TARGET_LONG_BITS == 32
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index);
#else
P
pbrook 已提交
2275
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u, ret, addr, mem_index);
2276
#endif
B
bellard 已提交
2277 2278
}

P
pbrook 已提交
2279
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
2280
{
2281 2282 2283
#if TARGET_LONG_BITS == 32
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index);
#else
P
pbrook 已提交
2284
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s, ret, addr, mem_index);
2285
#endif
B
bellard 已提交
2286 2287
}

P
pbrook 已提交
2288
static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
B
bellard 已提交
2289
{
P
pbrook 已提交
2290
    tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64, ret, addr, mem_index);
B
bellard 已提交
2291 2292
}

P
pbrook 已提交
2293
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
2294
{
P
pbrook 已提交
2295
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
2296 2297
}

P
pbrook 已提交
2298
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
2299
{
P
pbrook 已提交
2300
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
2301 2302
}

P
pbrook 已提交
2303
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
2304
{
P
pbrook 已提交
2305
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
2306 2307
}

P
pbrook 已提交
2308
static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
B
bellard 已提交
2309
{
P
pbrook 已提交
2310
    tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64, arg, addr, mem_index);
B
bellard 已提交
2311 2312
}

B
blueswir1 已提交
2313
#define tcg_gen_ld_ptr tcg_gen_ld_i64
B
blueswir1 已提交
2314
#define tcg_gen_discard_ptr tcg_gen_discard_i64
2315

B
bellard 已提交
2316
#endif /* TCG_TARGET_REG_BITS != 32 */
2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334

#if TARGET_LONG_BITS == 64
#define tcg_gen_movi_tl tcg_gen_movi_i64
#define tcg_gen_mov_tl tcg_gen_mov_i64
#define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
#define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
#define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
#define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
#define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
#define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
#define tcg_gen_ld_tl tcg_gen_ld_i64
#define tcg_gen_st8_tl tcg_gen_st8_i64
#define tcg_gen_st16_tl tcg_gen_st16_i64
#define tcg_gen_st32_tl tcg_gen_st32_i64
#define tcg_gen_st_tl tcg_gen_st_i64
#define tcg_gen_add_tl tcg_gen_add_i64
#define tcg_gen_addi_tl tcg_gen_addi_i64
#define tcg_gen_sub_tl tcg_gen_sub_i64
P
pbrook 已提交
2335
#define tcg_gen_neg_tl tcg_gen_neg_i64
P
pbrook 已提交
2336
#define tcg_gen_subfi_tl tcg_gen_subfi_i64
2337 2338 2339 2340 2341 2342 2343
#define tcg_gen_subi_tl tcg_gen_subi_i64
#define tcg_gen_and_tl tcg_gen_and_i64
#define tcg_gen_andi_tl tcg_gen_andi_i64
#define tcg_gen_or_tl tcg_gen_or_i64
#define tcg_gen_ori_tl tcg_gen_ori_i64
#define tcg_gen_xor_tl tcg_gen_xor_i64
#define tcg_gen_xori_tl tcg_gen_xori_i64
B
bellard 已提交
2344
#define tcg_gen_not_tl tcg_gen_not_i64
2345 2346 2347 2348 2349 2350
#define tcg_gen_shl_tl tcg_gen_shl_i64
#define tcg_gen_shli_tl tcg_gen_shli_i64
#define tcg_gen_shr_tl tcg_gen_shr_i64
#define tcg_gen_shri_tl tcg_gen_shri_i64
#define tcg_gen_sar_tl tcg_gen_sar_i64
#define tcg_gen_sari_tl tcg_gen_sari_i64
B
blueswir1 已提交
2351
#define tcg_gen_brcond_tl tcg_gen_brcond_i64
P
pbrook 已提交
2352
#define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
2353
#define tcg_gen_setcond_tl tcg_gen_setcond_i64
A
Aurelien Jarno 已提交
2354
#define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
2355 2356
#define tcg_gen_mul_tl tcg_gen_mul_i64
#define tcg_gen_muli_tl tcg_gen_muli_i64
2357 2358
#define tcg_gen_div_tl tcg_gen_div_i64
#define tcg_gen_rem_tl tcg_gen_rem_i64
A
aurel32 已提交
2359 2360
#define tcg_gen_divu_tl tcg_gen_divu_i64
#define tcg_gen_remu_tl tcg_gen_remu_i64
B
blueswir1 已提交
2361
#define tcg_gen_discard_tl tcg_gen_discard_i64
2362 2363 2364 2365 2366 2367
#define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
#define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
#define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
#define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
#define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
#define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
B
bellard 已提交
2368 2369 2370 2371 2372 2373
#define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
#define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
#define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
#define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
#define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
#define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
2374 2375 2376
#define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
#define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
#define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
2377
#define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
2378 2379 2380 2381 2382
#define tcg_gen_andc_tl tcg_gen_andc_i64
#define tcg_gen_eqv_tl tcg_gen_eqv_i64
#define tcg_gen_nand_tl tcg_gen_nand_i64
#define tcg_gen_nor_tl tcg_gen_nor_i64
#define tcg_gen_orc_tl tcg_gen_orc_i64
2383 2384 2385 2386
#define tcg_gen_rotl_tl tcg_gen_rotl_i64
#define tcg_gen_rotli_tl tcg_gen_rotli_i64
#define tcg_gen_rotr_tl tcg_gen_rotr_i64
#define tcg_gen_rotri_tl tcg_gen_rotri_i64
B
blueswir1 已提交
2387
#define tcg_const_tl tcg_const_i64
A
aurel32 已提交
2388
#define tcg_const_local_tl tcg_const_local_i64
2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405
#else
#define tcg_gen_movi_tl tcg_gen_movi_i32
#define tcg_gen_mov_tl tcg_gen_mov_i32
#define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
#define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
#define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
#define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
#define tcg_gen_ld32u_tl tcg_gen_ld_i32
#define tcg_gen_ld32s_tl tcg_gen_ld_i32
#define tcg_gen_ld_tl tcg_gen_ld_i32
#define tcg_gen_st8_tl tcg_gen_st8_i32
#define tcg_gen_st16_tl tcg_gen_st16_i32
#define tcg_gen_st32_tl tcg_gen_st_i32
#define tcg_gen_st_tl tcg_gen_st_i32
#define tcg_gen_add_tl tcg_gen_add_i32
#define tcg_gen_addi_tl tcg_gen_addi_i32
#define tcg_gen_sub_tl tcg_gen_sub_i32
P
pbrook 已提交
2406
#define tcg_gen_neg_tl tcg_gen_neg_i32
A
aurel32 已提交
2407
#define tcg_gen_subfi_tl tcg_gen_subfi_i32
2408 2409 2410 2411 2412 2413 2414
#define tcg_gen_subi_tl tcg_gen_subi_i32
#define tcg_gen_and_tl tcg_gen_and_i32
#define tcg_gen_andi_tl tcg_gen_andi_i32
#define tcg_gen_or_tl tcg_gen_or_i32
#define tcg_gen_ori_tl tcg_gen_ori_i32
#define tcg_gen_xor_tl tcg_gen_xor_i32
#define tcg_gen_xori_tl tcg_gen_xori_i32
B
bellard 已提交
2415
#define tcg_gen_not_tl tcg_gen_not_i32
2416 2417 2418 2419 2420 2421
#define tcg_gen_shl_tl tcg_gen_shl_i32
#define tcg_gen_shli_tl tcg_gen_shli_i32
#define tcg_gen_shr_tl tcg_gen_shr_i32
#define tcg_gen_shri_tl tcg_gen_shri_i32
#define tcg_gen_sar_tl tcg_gen_sar_i32
#define tcg_gen_sari_tl tcg_gen_sari_i32
B
blueswir1 已提交
2422
#define tcg_gen_brcond_tl tcg_gen_brcond_i32
P
pbrook 已提交
2423
#define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
2424
#define tcg_gen_setcond_tl tcg_gen_setcond_i32
A
Aurelien Jarno 已提交
2425
#define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
2426 2427
#define tcg_gen_mul_tl tcg_gen_mul_i32
#define tcg_gen_muli_tl tcg_gen_muli_i32
2428 2429
#define tcg_gen_div_tl tcg_gen_div_i32
#define tcg_gen_rem_tl tcg_gen_rem_i32
A
aurel32 已提交
2430 2431
#define tcg_gen_divu_tl tcg_gen_divu_i32
#define tcg_gen_remu_tl tcg_gen_remu_i32
B
blueswir1 已提交
2432
#define tcg_gen_discard_tl tcg_gen_discard_i32
2433 2434 2435 2436 2437 2438
#define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
#define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
#define tcg_gen_extu_i32_tl tcg_gen_mov_i32
#define tcg_gen_ext_i32_tl tcg_gen_mov_i32
#define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
#define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
B
bellard 已提交
2439 2440 2441 2442 2443 2444
#define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
#define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
#define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
#define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
#define tcg_gen_ext32u_tl tcg_gen_mov_i32
#define tcg_gen_ext32s_tl tcg_gen_mov_i32
2445 2446
#define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
#define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
2447
#define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
2448 2449 2450 2451 2452
#define tcg_gen_andc_tl tcg_gen_andc_i32
#define tcg_gen_eqv_tl tcg_gen_eqv_i32
#define tcg_gen_nand_tl tcg_gen_nand_i32
#define tcg_gen_nor_tl tcg_gen_nor_i32
#define tcg_gen_orc_tl tcg_gen_orc_i32
2453 2454 2455 2456
#define tcg_gen_rotl_tl tcg_gen_rotl_i32
#define tcg_gen_rotli_tl tcg_gen_rotli_i32
#define tcg_gen_rotr_tl tcg_gen_rotr_i32
#define tcg_gen_rotri_tl tcg_gen_rotri_i32
B
blueswir1 已提交
2457
#define tcg_const_tl tcg_const_i32
A
aurel32 已提交
2458
#define tcg_const_local_tl tcg_const_local_i32
2459
#endif
P
pbrook 已提交
2460 2461

#if TCG_TARGET_REG_BITS == 32
2462
#define tcg_gen_add_ptr tcg_gen_add_i32
P
pbrook 已提交
2463
#define tcg_gen_addi_ptr tcg_gen_addi_i32
2464
#define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
P
pbrook 已提交
2465
#else /* TCG_TARGET_REG_BITS == 32 */
2466
#define tcg_gen_add_ptr tcg_gen_add_i64
P
pbrook 已提交
2467
#define tcg_gen_addi_ptr tcg_gen_addi_i64
2468
#define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
P
pbrook 已提交
2469
#endif /* TCG_TARGET_REG_BITS != 32 */