tcg-op.h 41.2 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
/*
 * 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"

26
#ifdef CONFIG_DYNGEN_OP
B
bellard 已提交
27 28
/* legacy dyngen operations */
#include "gen-op.h"
29
#endif
B
bellard 已提交
30 31 32

int gen_new_label(void);

P
pbrook 已提交
33
static inline void tcg_gen_op1(int opc, TCGv arg1)
B
bellard 已提交
34 35
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
36
    *gen_opparam_ptr++ = GET_TCGV(arg1);
B
bellard 已提交
37 38
}

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

P
pbrook 已提交
45
static inline void tcg_gen_op2(int opc, TCGv arg1, TCGv arg2)
B
bellard 已提交
46 47
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
48 49
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
B
bellard 已提交
50 51
}

P
pbrook 已提交
52
static inline void tcg_gen_op2i(int opc, TCGv arg1, TCGArg arg2)
B
bellard 已提交
53 54
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
55
    *gen_opparam_ptr++ = GET_TCGV(arg1);
B
bellard 已提交
56
    *gen_opparam_ptr++ = arg2;
P
pbrook 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
}

static inline void tcg_gen_op3(int opc, TCGv arg1, TCGv arg2, TCGv arg3)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
    *gen_opparam_ptr++ = GET_TCGV(arg3);
}

static inline void tcg_gen_op3i(int opc, TCGv arg1, TCGv arg2, TCGArg arg3)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
B
bellard 已提交
72
    *gen_opparam_ptr++ = arg3;
P
pbrook 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
}

static inline void tcg_gen_op4(int opc, TCGv arg1, TCGv arg2, TCGv arg3, 
                               TCGv arg4)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
    *gen_opparam_ptr++ = GET_TCGV(arg3);
    *gen_opparam_ptr++ = GET_TCGV(arg4);
}

static inline void tcg_gen_op4i(int opc, TCGv arg1, TCGv arg2, TCGv arg3, 
                                TCGArg arg4)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
    *gen_opparam_ptr++ = GET_TCGV(arg3);
B
bellard 已提交
92 93 94
    *gen_opparam_ptr++ = arg4;
}

P
pbrook 已提交
95 96
static inline void tcg_gen_op4ii(int opc, TCGv arg1, TCGv arg2, TCGArg arg3, 
                                 TCGArg arg4)
B
bellard 已提交
97 98
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
99 100
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
B
bellard 已提交
101 102
    *gen_opparam_ptr++ = arg3;
    *gen_opparam_ptr++ = arg4;
P
pbrook 已提交
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
}

static inline void tcg_gen_op5(int opc, TCGv arg1, TCGv arg2, 
                               TCGv arg3, TCGv arg4,
                               TCGv arg5)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
    *gen_opparam_ptr++ = GET_TCGV(arg3);
    *gen_opparam_ptr++ = GET_TCGV(arg4);
    *gen_opparam_ptr++ = GET_TCGV(arg5);
}

static inline void tcg_gen_op5i(int opc, TCGv arg1, TCGv arg2, 
                                TCGv arg3, TCGv arg4,
                                TCGArg arg5)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
    *gen_opparam_ptr++ = GET_TCGV(arg3);
    *gen_opparam_ptr++ = GET_TCGV(arg4);
B
bellard 已提交
126 127 128
    *gen_opparam_ptr++ = arg5;
}

P
pbrook 已提交
129 130 131
static inline void tcg_gen_op6(int opc, TCGv arg1, TCGv arg2, 
                               TCGv arg3, TCGv arg4,
                               TCGv arg5, TCGv arg6)
B
bellard 已提交
132 133
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
    *gen_opparam_ptr++ = GET_TCGV(arg3);
    *gen_opparam_ptr++ = GET_TCGV(arg4);
    *gen_opparam_ptr++ = GET_TCGV(arg5);
    *gen_opparam_ptr++ = GET_TCGV(arg6);
}

static inline void tcg_gen_op6ii(int opc, TCGv arg1, TCGv arg2, 
                                 TCGv arg3, TCGv arg4,
                                 TCGArg arg5, TCGArg arg6)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
    *gen_opparam_ptr++ = GET_TCGV(arg3);
    *gen_opparam_ptr++ = GET_TCGV(arg4);
B
bellard 已提交
151 152 153 154 155 156
    *gen_opparam_ptr++ = arg5;
    *gen_opparam_ptr++ = arg6;
}

static inline void gen_set_label(int n)
{
P
pbrook 已提交
157
    tcg_gen_op1i(INDEX_op_set_label, n);
B
bellard 已提交
158 159
}

B
blueswir1 已提交
160 161 162 163 164
static inline void tcg_gen_br(int label)
{
    tcg_gen_op1i(INDEX_op_br, label);
}

P
pbrook 已提交
165
static inline void tcg_gen_mov_i32(TCGv ret, TCGv arg)
B
bellard 已提交
166
{
P
pbrook 已提交
167
    if (GET_TCGV(ret) != GET_TCGV(arg))
168
        tcg_gen_op2(INDEX_op_mov_i32, ret, arg);
B
bellard 已提交
169 170
}

P
pbrook 已提交
171
static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg)
B
bellard 已提交
172
{
P
pbrook 已提交
173
    tcg_gen_op2i(INDEX_op_movi_i32, ret, arg);
B
bellard 已提交
174 175 176 177 178 179 180 181 182 183 184 185
}

/* helper calls */
#define TCG_HELPER_CALL_FLAGS 0

static inline void tcg_gen_helper_0_0(void *func)
{
    tcg_gen_call(&tcg_ctx, 
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 0, NULL, 0, NULL);
}

P
pbrook 已提交
186
static inline void tcg_gen_helper_0_1(void *func, TCGv arg)
B
bellard 已提交
187 188 189 190 191 192
{
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 0, NULL, 1, &arg);
}

P
pbrook 已提交
193
static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2)
B
bellard 已提交
194
{
P
pbrook 已提交
195
    TCGv args[2];
B
bellard 已提交
196 197 198 199 200 201 202
    args[0] = arg1;
    args[1] = arg2;
    tcg_gen_call(&tcg_ctx, 
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 0, NULL, 2, args);
}

P
pbrook 已提交
203 204 205 206 207 208 209 210 211 212 213 214
static inline void tcg_gen_helper_0_3(void *func,
                                      TCGv arg1, TCGv arg2, TCGv arg3)
{
    TCGv args[3];
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 0, NULL, 3, args);
}

215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
static inline void tcg_gen_helper_0_4(void *func, TCGv arg1, TCGv arg2,
                                      TCGv arg3, TCGv arg4)
{
    TCGv args[4];
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
    args[3] = arg4;
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 0, NULL, 4, args);
}

static inline void tcg_gen_helper_1_0(void *func, TCGv ret)
{
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 1, &ret, 0, NULL);
}

static inline void tcg_gen_helper_1_1(void *func, TCGv ret, TCGv arg1)
{
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 1, &ret, 1, &arg1);
}

P
pbrook 已提交
242 243
static inline void tcg_gen_helper_1_2(void *func, TCGv ret, 
                                      TCGv arg1, TCGv arg2)
B
bellard 已提交
244
{
P
pbrook 已提交
245
    TCGv args[2];
B
bellard 已提交
246 247 248 249 250 251 252
    args[0] = arg1;
    args[1] = arg2;
    tcg_gen_call(&tcg_ctx, 
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 1, &ret, 2, args);
}

P
pbrook 已提交
253 254 255 256 257 258 259 260 261 262 263 264
static inline void tcg_gen_helper_1_3(void *func, TCGv ret,
                                      TCGv arg1, TCGv arg2, TCGv arg3)
{
    TCGv args[3];
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 1, &ret, 3, args);
}

265 266 267 268 269 270 271 272 273 274 275 276 277 278
static inline void tcg_gen_helper_1_4(void *func, TCGv ret,
                                      TCGv arg1, TCGv arg2, TCGv arg3,
                                      TCGv arg4)
{
    TCGv args[4];
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
    args[3] = arg4;
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 1, &ret, 4, args);
}

B
bellard 已提交
279 280
/* 32 bit ops */

P
pbrook 已提交
281
static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
282
{
P
pbrook 已提交
283
    tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
B
bellard 已提交
284 285
}

P
pbrook 已提交
286
static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
287
{
P
pbrook 已提交
288
    tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
B
bellard 已提交
289 290
}

P
pbrook 已提交
291
static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
292
{
P
pbrook 已提交
293
    tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
B
bellard 已提交
294 295
}

P
pbrook 已提交
296
static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
297
{
P
pbrook 已提交
298
    tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
B
bellard 已提交
299 300
}

P
pbrook 已提交
301
static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
302
{
P
pbrook 已提交
303
    tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
B
bellard 已提交
304 305
}

P
pbrook 已提交
306
static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
307
{
P
pbrook 已提交
308
    tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset);
B
bellard 已提交
309 310
}

P
pbrook 已提交
311
static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
312
{
P
pbrook 已提交
313
    tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset);
B
bellard 已提交
314 315
}

P
pbrook 已提交
316
static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
317
{
P
pbrook 已提交
318
    tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset);
B
bellard 已提交
319 320
}

P
pbrook 已提交
321
static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
322 323 324 325
{
    tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
}

P
pbrook 已提交
326
static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
327
{
328 329 330 331 332 333
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2));
    }
B
bellard 已提交
334 335
}

P
pbrook 已提交
336
static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
337 338 339 340
{
    tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
}

P
pbrook 已提交
341
static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
342
{
343 344 345 346 347 348
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2));
    }
B
bellard 已提交
349 350
}

P
pbrook 已提交
351
static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
352 353 354 355
{
    tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2);
}

P
pbrook 已提交
356
static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
357 358 359 360 361 362 363 364 365 366 367
{
    /* 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 {
        tcg_gen_and_i32(ret, arg1, tcg_const_i32(arg2));
    }
}

P
pbrook 已提交
368
static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
369 370 371 372
{
    tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
}

P
pbrook 已提交
373
static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
374 375 376
{
    /* some cases can be optimized here */
    if (arg2 == 0xffffffff) {
377
        tcg_gen_movi_i32(ret, 0xffffffff);
B
bellard 已提交
378 379 380 381 382 383 384
    } else if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_or_i32(ret, arg1, tcg_const_i32(arg2));
    }
}

P
pbrook 已提交
385
static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
386 387 388 389
{
    tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2);
}

P
pbrook 已提交
390
static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
391 392 393 394 395 396 397 398 399
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_xor_i32(ret, arg1, tcg_const_i32(arg2));
    }
}

P
pbrook 已提交
400
static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
401 402 403 404
{
    tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
}

P
pbrook 已提交
405
static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
406 407 408 409
{
    tcg_gen_shl_i32(ret, arg1, tcg_const_i32(arg2));
}

P
pbrook 已提交
410
static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
411 412 413 414
{
    tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2);
}

P
pbrook 已提交
415
static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
416 417 418 419
{
    tcg_gen_shr_i32(ret, arg1, tcg_const_i32(arg2));
}

P
pbrook 已提交
420
static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
421 422 423 424
{
    tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
}

P
pbrook 已提交
425
static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
426 427 428 429
{
    tcg_gen_sar_i32(ret, arg1, tcg_const_i32(arg2));
}

P
pbrook 已提交
430
static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
431 432
                                      int label_index)
{
P
pbrook 已提交
433
    tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
B
bellard 已提交
434 435
}

P
pbrook 已提交
436
static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
437 438 439 440
{
    tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
}

441 442 443 444 445
static inline void tcg_gen_muli_i32(TCGv ret, TCGv arg1, int32_t arg2)
{
    tcg_gen_mul_i32(ret, arg1, tcg_const_i32(arg2));
}

B
bellard 已提交
446
#ifdef TCG_TARGET_HAS_div_i32
P
pbrook 已提交
447
static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
448 449 450 451
{
    tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
}

P
pbrook 已提交
452
static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
453 454 455 456
{
    tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
}

P
pbrook 已提交
457
static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
458 459 460 461
{
    tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
}

P
pbrook 已提交
462
static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
463 464 465 466
{
    tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
}
#else
P
pbrook 已提交
467
static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
468
{
P
pbrook 已提交
469
    TCGv t0;
B
bellard 已提交
470 471 472 473 474
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_sari_i32(t0, arg1, 31);
    tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
}

P
pbrook 已提交
475
static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
476
{
P
pbrook 已提交
477
    TCGv t0;
B
bellard 已提交
478 479 480 481 482
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_sari_i32(t0, arg1, 31);
    tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
}

P
pbrook 已提交
483
static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
484
{
P
pbrook 已提交
485
    TCGv t0;
B
bellard 已提交
486 487 488 489 490
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_movi_i32(t0, 0);
    tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
}

P
pbrook 已提交
491
static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
492
{
P
pbrook 已提交
493
    TCGv t0;
B
bellard 已提交
494 495 496 497 498 499 500 501
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_movi_i32(t0, 0);
    tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
}
#endif

#if TCG_TARGET_REG_BITS == 32

P
pbrook 已提交
502
static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
B
bellard 已提交
503
{
P
pbrook 已提交
504
    if (GET_TCGV(ret) != GET_TCGV(arg)) {
505 506 507
        tcg_gen_mov_i32(ret, arg);
        tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
    }
B
bellard 已提交
508 509
}

P
pbrook 已提交
510
static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
B
bellard 已提交
511 512
{
    tcg_gen_movi_i32(ret, arg);
P
pbrook 已提交
513
    tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
B
bellard 已提交
514 515
}

P
pbrook 已提交
516
static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
517 518
{
    tcg_gen_ld8u_i32(ret, arg2, offset);
P
pbrook 已提交
519
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
520 521
}

P
pbrook 已提交
522
static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
523 524
{
    tcg_gen_ld8s_i32(ret, arg2, offset);
P
pbrook 已提交
525
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
526 527
}

P
pbrook 已提交
528
static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
529 530
{
    tcg_gen_ld16u_i32(ret, arg2, offset);
P
pbrook 已提交
531
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
532 533
}

P
pbrook 已提交
534
static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
535 536
{
    tcg_gen_ld16s_i32(ret, arg2, offset);
P
pbrook 已提交
537
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
538 539
}

P
pbrook 已提交
540
static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
541 542
{
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
543
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
544 545
}

P
pbrook 已提交
546
static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
547 548
{
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
549
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
550 551
}

P
pbrook 已提交
552
static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
553 554 555 556
{
    /* since arg2 and ret have different types, they cannot be the
       same temporary */
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
557
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
B
bellard 已提交
558 559 560
    tcg_gen_ld_i32(ret, arg2, offset + 4);
#else
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
561
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
B
bellard 已提交
562 563 564
#endif
}

P
pbrook 已提交
565
static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
566 567 568 569
{
    tcg_gen_st8_i32(arg1, arg2, offset);
}

P
pbrook 已提交
570
static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
571 572 573 574
{
    tcg_gen_st16_i32(arg1, arg2, offset);
}

P
pbrook 已提交
575
static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
576 577 578 579
{
    tcg_gen_st_i32(arg1, arg2, offset);
}

P
pbrook 已提交
580
static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
581 582
{
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
583
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
B
bellard 已提交
584 585 586
    tcg_gen_st_i32(arg1, arg2, offset + 4);
#else
    tcg_gen_st_i32(arg1, arg2, offset);
P
pbrook 已提交
587
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
B
bellard 已提交
588 589 590
#endif
}

P
pbrook 已提交
591
static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
592
{
P
pbrook 已提交
593 594
    tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret), 
                arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
B
bellard 已提交
595 596
}

P
pbrook 已提交
597
static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
598 599 600 601
{
    tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
602
static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
603
{
P
pbrook 已提交
604 605
    tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret), 
                arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
B
bellard 已提交
606 607
}

P
pbrook 已提交
608
static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
609 610 611 612
{
    tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
613
static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
614 615
{
    tcg_gen_and_i32(ret, arg1, arg2);
P
pbrook 已提交
616
    tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
617 618
}

P
pbrook 已提交
619
static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
620 621
{
    tcg_gen_andi_i32(ret, arg1, arg2);
P
pbrook 已提交
622
    tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
623 624
}

P
pbrook 已提交
625
static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
626 627
{
    tcg_gen_or_i32(ret, arg1, arg2);
P
pbrook 已提交
628
    tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
629 630
}

P
pbrook 已提交
631
static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
632 633
{
    tcg_gen_ori_i32(ret, arg1, arg2);
P
pbrook 已提交
634
    tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
635 636
}

P
pbrook 已提交
637
static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
638 639
{
    tcg_gen_xor_i32(ret, arg1, arg2);
P
pbrook 已提交
640
    tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
641 642
}

P
pbrook 已提交
643
static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
644 645
{
    tcg_gen_xori_i32(ret, arg1, arg2);
P
pbrook 已提交
646
    tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
647 648 649 650
}

/* XXX: use generic code when basic block handling is OK or CPU
   specific code (x86) */
P
pbrook 已提交
651
static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
652 653 654 655
{
    tcg_gen_helper_1_2(tcg_helper_shl_i64, ret, arg1, arg2);
}

P
pbrook 已提交
656
static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
657 658 659 660
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
}

P
pbrook 已提交
661
static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
662 663 664 665
{
    tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
}

P
pbrook 已提交
666
static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
667 668 669 670
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
}

P
pbrook 已提交
671
static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
672 673 674 675
{
    tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
}

P
pbrook 已提交
676
static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
677 678 679 680
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
}

P
pbrook 已提交
681
static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
682 683
                                      int label_index)
{
P
pbrook 已提交
684 685 686
    tcg_gen_op6ii(INDEX_op_brcond2_i32, 
                  arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
                  cond, label_index);
B
bellard 已提交
687 688
}

P
pbrook 已提交
689
static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
690
{
P
pbrook 已提交
691
    TCGv t0, t1;
B
bellard 已提交
692 693 694 695
    
    t0 = tcg_temp_new(TCG_TYPE_I64);
    t1 = tcg_temp_new(TCG_TYPE_I32);

P
pbrook 已提交
696
    tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
B
bellard 已提交
697
    
P
pbrook 已提交
698 699 700 701
    tcg_gen_mul_i32(t1, arg1, TCGV_HIGH(arg2));
    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
    tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), arg2);
    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
B
bellard 已提交
702 703 704 705
    
    tcg_gen_mov_i64(ret, t0);
}

706 707 708 709 710
static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2)
{
    tcg_gen_mul_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
711
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
712 713 714 715
{
    tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
}

P
pbrook 已提交
716
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
717 718 719 720
{
    tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
}

P
pbrook 已提交
721
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
722 723 724 725
{
    tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
}

P
pbrook 已提交
726
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
727 728 729 730 731 732
{
    tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
}

#else

P
pbrook 已提交
733
static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
B
bellard 已提交
734
{
P
pbrook 已提交
735
    if (GET_TCGV(ret) != GET_TCGV(arg))
736
        tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
B
bellard 已提交
737 738
}

P
pbrook 已提交
739
static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
B
bellard 已提交
740
{
P
pbrook 已提交
741
    tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
B
bellard 已提交
742 743
}

P
pbrook 已提交
744 745
static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
746
{
P
pbrook 已提交
747
    tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
B
bellard 已提交
748 749
}

P
pbrook 已提交
750 751
static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
752
{
P
pbrook 已提交
753
    tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
B
bellard 已提交
754 755
}

P
pbrook 已提交
756 757
static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
758
{
P
pbrook 已提交
759
    tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
B
bellard 已提交
760 761
}

P
pbrook 已提交
762 763
static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
764
{
P
pbrook 已提交
765
    tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
B
bellard 已提交
766 767
}

P
pbrook 已提交
768 769
static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
770
{
P
pbrook 已提交
771
    tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
B
bellard 已提交
772 773
}

P
pbrook 已提交
774 775
static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
776
{
P
pbrook 已提交
777
    tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
B
bellard 已提交
778 779
}

P
pbrook 已提交
780
static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
781
{
P
pbrook 已提交
782
    tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
B
bellard 已提交
783 784
}

P
pbrook 已提交
785 786
static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
                                   tcg_target_long offset)
B
bellard 已提交
787
{
P
pbrook 已提交
788
    tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
B
bellard 已提交
789 790
}

P
pbrook 已提交
791 792
static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
793
{
P
pbrook 已提交
794
    tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
B
bellard 已提交
795 796
}

P
pbrook 已提交
797 798
static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
799
{
P
pbrook 已提交
800
    tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
B
bellard 已提交
801 802
}

P
pbrook 已提交
803
static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
804
{
P
pbrook 已提交
805
    tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
B
bellard 已提交
806 807
}

P
pbrook 已提交
808
static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
809 810 811 812
{
    tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
}

P
pbrook 已提交
813
static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
814 815 816 817
{
    tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
818
static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
819 820 821 822
{
    tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
}

P
pbrook 已提交
823
static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
824 825 826 827
{
    tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
828
static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
829 830 831 832
{
    tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
}

P
pbrook 已提交
833
static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
834 835 836 837
{
    tcg_gen_and_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
838
static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
839 840 841 842
{
    tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
}

P
pbrook 已提交
843
static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
844 845 846 847
{
    tcg_gen_or_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
848
static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
849 850 851 852
{
    tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2);
}

P
pbrook 已提交
853
static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
854 855 856 857
{
    tcg_gen_xor_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
858
static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
859 860 861 862
{
    tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
}

P
pbrook 已提交
863
static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
864 865 866 867
{
    tcg_gen_shl_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
868
static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
869 870 871 872
{
    tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
}

P
pbrook 已提交
873
static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
874 875 876 877
{
    tcg_gen_shr_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
878
static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
879 880 881 882
{
    tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
}

P
pbrook 已提交
883
static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
884 885 886 887
{
    tcg_gen_sar_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
888
static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
889 890
                                      int label_index)
{
P
pbrook 已提交
891
    tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
B
bellard 已提交
892 893
}

P
pbrook 已提交
894
static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
895 896 897 898
{
    tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
}

899 900 901 902 903
static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2)
{
    tcg_gen_mul_i64(ret, arg1, tcg_const_i64(arg2));
}

B
bellard 已提交
904
#ifdef TCG_TARGET_HAS_div_i64
P
pbrook 已提交
905
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
906 907 908 909
{
    tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
}

P
pbrook 已提交
910
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
911 912 913 914
{
    tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2);
}

P
pbrook 已提交
915
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
916 917 918 919
{
    tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
}

P
pbrook 已提交
920
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
921 922 923 924
{
    tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
}
#else
P
pbrook 已提交
925
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
926
{
P
pbrook 已提交
927
    TCGv t0;
B
bellard 已提交
928 929 930 931 932
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_sari_i64(t0, arg1, 63);
    tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
}

P
pbrook 已提交
933
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
934
{
P
pbrook 已提交
935
    TCGv t0;
B
bellard 已提交
936 937 938 939 940
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_sari_i64(t0, arg1, 63);
    tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
}

P
pbrook 已提交
941
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
942
{
P
pbrook 已提交
943
    TCGv t0;
B
bellard 已提交
944 945 946 947 948
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_movi_i64(t0, 0);
    tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
}

P
pbrook 已提交
949
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
950
{
P
pbrook 已提交
951
    TCGv t0;
B
bellard 已提交
952 953 954 955 956 957 958 959 960 961 962
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_movi_i64(t0, 0);
    tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
}
#endif

#endif

/***************************************/
/* optional operations */

P
pbrook 已提交
963
static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
B
bellard 已提交
964 965 966 967 968
{
#ifdef TCG_TARGET_HAS_ext8s_i32
    tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
#else
    tcg_gen_shli_i32(ret, arg, 24);
969
    tcg_gen_sari_i32(ret, ret, 24);
B
bellard 已提交
970 971 972
#endif
}

P
pbrook 已提交
973
static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
B
bellard 已提交
974 975 976 977 978
{
#ifdef TCG_TARGET_HAS_ext16s_i32
    tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
#else
    tcg_gen_shli_i32(ret, arg, 16);
979
    tcg_gen_sari_i32(ret, ret, 16);
B
bellard 已提交
980 981 982
#endif
}

P
pbrook 已提交
983 984 985 986 987 988 989 990 991 992 993 994
/* These are currently just for convenience.
   We assume a target will recognise these automatically .  */
static inline void tcg_gen_ext8u_i32(TCGv ret, TCGv arg)
{
    tcg_gen_andi_i32(ret, arg, 0xffu);
}

static inline void tcg_gen_ext16u_i32(TCGv ret, TCGv arg)
{
    tcg_gen_andi_i32(ret, arg, 0xffffu);
}

B
bellard 已提交
995
/* Note: we assume the two high bytes are set to zero */
P
pbrook 已提交
996
static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
B
bellard 已提交
997 998 999 1000
{
#ifdef TCG_TARGET_HAS_bswap16_i32
    tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
#else
P
pbrook 已提交
1001
    TCGv t0, t1;
B
bellard 已提交
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);
    
    tcg_gen_shri_i32(t0, arg, 8);
    tcg_gen_andi_i32(t1, arg, 0x000000ff);
    tcg_gen_shli_i32(t1, t1, 8);
    tcg_gen_or_i32(ret, t0, t1);
#endif
}

P
pbrook 已提交
1012
static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1013 1014 1015 1016
{
#ifdef TCG_TARGET_HAS_bswap_i32
    tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
#else
P
pbrook 已提交
1017
    TCGv t0, t1;
B
bellard 已提交
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);
    
    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);
#endif
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1037
static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1038 1039
{
    tcg_gen_ext8s_i32(ret, arg);
P
pbrook 已提交
1040
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1041 1042
}

P
pbrook 已提交
1043
static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1044 1045
{
    tcg_gen_ext16s_i32(ret, arg);
P
pbrook 已提交
1046
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1047 1048
}

P
pbrook 已提交
1049
static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1050 1051
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1052
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1053 1054
}

P
pbrook 已提交
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
static inline void tcg_gen_ext8u_i64(TCGv ret, TCGv arg)
{
    tcg_gen_ext8u_i32(ret, arg);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

static inline void tcg_gen_ext16u_i64(TCGv ret, TCGv arg)
{
    tcg_gen_ext16u_i32(ret, arg);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

static inline void tcg_gen_ext32u_i64(TCGv ret, TCGv arg)
{
    tcg_gen_mov_i32(ret, arg);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
1073
static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1074 1075 1076 1077
{
    tcg_gen_mov_i32(ret, arg);
}

P
pbrook 已提交
1078
static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1079 1080
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1081
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1082 1083
}

P
pbrook 已提交
1084
static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1085 1086
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1087
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1088 1089
}

P
pbrook 已提交
1090
static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1091
{
P
pbrook 已提交
1092
    TCGv t0, t1;
B
bellard 已提交
1093 1094 1095 1096
    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);

    tcg_gen_bswap_i32(t0, arg);
P
pbrook 已提交
1097
    tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
B
bellard 已提交
1098
    tcg_gen_mov_i32(ret, t1);
P
pbrook 已提交
1099
    tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
B
bellard 已提交
1100 1101 1102
}
#else

P
pbrook 已提交
1103
static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1104 1105 1106 1107 1108
{
#ifdef TCG_TARGET_HAS_ext8s_i64
    tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 56);
1109
    tcg_gen_sari_i64(ret, ret, 56);
B
bellard 已提交
1110 1111 1112
#endif
}

P
pbrook 已提交
1113
static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1114 1115 1116 1117 1118
{
#ifdef TCG_TARGET_HAS_ext16s_i64
    tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 48);
1119
    tcg_gen_sari_i64(ret, ret, 48);
B
bellard 已提交
1120 1121 1122
#endif
}

P
pbrook 已提交
1123
static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1124 1125 1126 1127 1128
{
#ifdef TCG_TARGET_HAS_ext32s_i64
    tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 32);
1129
    tcg_gen_sari_i64(ret, ret, 32);
B
bellard 已提交
1130 1131 1132
#endif
}

P
pbrook 已提交
1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
static inline void tcg_gen_ext8u_i64(TCGv ret, TCGv arg)
{
    tcg_gen_andi_i64(ret, arg, 0xffu);
}

static inline void tcg_gen_ext16u_i64(TCGv ret, TCGv arg)
{
    tcg_gen_andi_i64(ret, arg, 0xffffu);
}

static inline void tcg_gen_ext32u_i64(TCGv ret, TCGv arg)
{
    tcg_gen_andi_i64(ret, arg, 0xffffffffu);
}

B
bellard 已提交
1148
/* Note: we assume the target supports move between 32 and 64 bit
P
pbrook 已提交
1149 1150
   registers.  This will probably break MIPS64 targets.  */
static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1151 1152 1153 1154 1155 1156
{
    tcg_gen_mov_i32(ret, arg);
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1157
static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1158
{
P
pbrook 已提交
1159
    tcg_gen_andi_i64(ret, arg, 0xffffffffu);
B
bellard 已提交
1160 1161 1162 1163
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1164
static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1165 1166 1167 1168
{
    tcg_gen_ext32s_i64(ret, arg);
}

P
pbrook 已提交
1169
static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1170 1171 1172 1173
{
#ifdef TCG_TARGET_HAS_bswap_i64
    tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
#else
P
pbrook 已提交
1174
    TCGv t0, t1;
B
bellard 已提交
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);
    
    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);
#endif
}

#endif

1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229

static inline void tcg_gen_discard_i32(TCGv arg)
{
    tcg_gen_op1(INDEX_op_discard, arg);
}

#if TCG_TARGET_REG_BITS == 32
static inline void tcg_gen_discard_i64(TCGv arg)
{
    tcg_gen_discard_i32(arg);
    tcg_gen_discard_i32(TCGV_HIGH(arg));
}
#else
static inline void tcg_gen_discard_i64(TCGv arg)
{
    tcg_gen_op1(INDEX_op_discard, arg);
}
#endif

B
bellard 已提交
1230
/***************************************/
P
pbrook 已提交
1231
static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id)
B
bellard 已提交
1232
{
P
pbrook 已提交
1233
    tcg_gen_op3i(INDEX_op_macro_2, ret0, ret1, macro_id);
B
bellard 已提交
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
}

/***************************************/
/* QEMU specific operations. Their type depend on the QEMU CPU
   type. */
#ifndef TARGET_LONG_BITS
#error must include QEMU headers
#endif

static inline void tcg_gen_exit_tb(tcg_target_long val)
{
P
pbrook 已提交
1245
    tcg_gen_op1i(INDEX_op_exit_tb, val);
B
bellard 已提交
1246 1247 1248 1249
}

static inline void tcg_gen_goto_tb(int idx)
{
P
pbrook 已提交
1250
    tcg_gen_op1i(INDEX_op_goto_tb, idx);
B
bellard 已提交
1251 1252 1253
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1254
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1255 1256
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1257
    tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1258
#else
P
pbrook 已提交
1259 1260
    tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1261 1262 1263
#endif
}

P
pbrook 已提交
1264
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1265 1266
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1267
    tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1268
#else
P
pbrook 已提交
1269
    tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
1270
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1271 1272 1273
#endif
}

P
pbrook 已提交
1274
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1275 1276
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1277
    tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1278
#else
P
pbrook 已提交
1279 1280
    tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1281 1282 1283
#endif
}

P
pbrook 已提交
1284
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1285 1286
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1287
    tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1288
#else
P
pbrook 已提交
1289
    tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
1290
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1291 1292 1293
#endif
}

P
pbrook 已提交
1294
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1295 1296
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1297
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1298
#else
P
pbrook 已提交
1299 1300
    tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1301 1302 1303
#endif
}

P
pbrook 已提交
1304
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1305 1306
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1307
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1308
#else
P
pbrook 已提交
1309 1310
    tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1311 1312 1313
#endif
}

P
pbrook 已提交
1314
static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1315 1316
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1317
    tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
B
bellard 已提交
1318
#else
P
pbrook 已提交
1319 1320
    tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
                 addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1321 1322 1323
#endif
}

P
pbrook 已提交
1324
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1325 1326
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1327
    tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1328
#else
P
pbrook 已提交
1329
    tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1330 1331 1332
#endif
}

P
pbrook 已提交
1333
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1334 1335
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1336
    tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1337
#else
P
pbrook 已提交
1338
    tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1339 1340 1341
#endif
}

P
pbrook 已提交
1342
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1343 1344
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1345
    tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1346
#else
P
pbrook 已提交
1347
    tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1348 1349 1350
#endif
}

P
pbrook 已提交
1351
static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1352 1353
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1354
    tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
B
bellard 已提交
1355
#else
P
pbrook 已提交
1356 1357
    tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
                 addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1358 1359 1360
#endif
}

B
blueswir1 已提交
1361
#define tcg_gen_ld_ptr tcg_gen_ld_i32
B
blueswir1 已提交
1362
#define tcg_gen_discard_ptr tcg_gen_discard_i32
1363

B
bellard 已提交
1364 1365
#else /* TCG_TARGET_REG_BITS == 32 */

P
pbrook 已提交
1366
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1367
{
P
pbrook 已提交
1368
    tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1369 1370
}

P
pbrook 已提交
1371
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1372
{
P
pbrook 已提交
1373
    tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1374 1375
}

P
pbrook 已提交
1376
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1377
{
P
pbrook 已提交
1378
    tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1379 1380
}

P
pbrook 已提交
1381
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1382
{
P
pbrook 已提交
1383
    tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1384 1385
}

P
pbrook 已提交
1386
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1387
{
P
pbrook 已提交
1388
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1389 1390
}

P
pbrook 已提交
1391
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1392
{
P
pbrook 已提交
1393
    tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
B
bellard 已提交
1394 1395
}

P
pbrook 已提交
1396
static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1397
{
P
pbrook 已提交
1398
    tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
B
bellard 已提交
1399 1400
}

P
pbrook 已提交
1401
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1402
{
P
pbrook 已提交
1403
    tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1404 1405
}

P
pbrook 已提交
1406
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1407
{
P
pbrook 已提交
1408
    tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1409 1410
}

P
pbrook 已提交
1411
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1412
{
P
pbrook 已提交
1413
    tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1414 1415
}

P
pbrook 已提交
1416
static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1417
{
P
pbrook 已提交
1418
    tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
B
bellard 已提交
1419 1420
}

B
blueswir1 已提交
1421
#define tcg_gen_ld_ptr tcg_gen_ld_i64
B
blueswir1 已提交
1422
#define tcg_gen_discard_ptr tcg_gen_discard_i64
1423

B
bellard 已提交
1424
#endif /* TCG_TARGET_REG_BITS != 32 */
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456

#if TARGET_LONG_BITS == 64
#define TCG_TYPE_TL TCG_TYPE_I64
#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
#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
#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 已提交
1457
#define tcg_gen_brcond_tl tcg_gen_brcond_i64
1458 1459
#define tcg_gen_mul_tl tcg_gen_mul_i64
#define tcg_gen_muli_tl tcg_gen_muli_i64
B
blueswir1 已提交
1460
#define tcg_gen_discard_tl tcg_gen_discard_i64
1461 1462 1463 1464 1465 1466
#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
blueswir1 已提交
1467
#define tcg_const_tl tcg_const_i64
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498
#else
#define TCG_TYPE_TL TCG_TYPE_I32
#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
#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
#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 已提交
1499
#define tcg_gen_brcond_tl tcg_gen_brcond_i32
1500 1501
#define tcg_gen_mul_tl tcg_gen_mul_i32
#define tcg_gen_muli_tl tcg_gen_muli_i32
B
blueswir1 已提交
1502
#define tcg_gen_discard_tl tcg_gen_discard_i32
1503 1504 1505 1506 1507 1508
#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
blueswir1 已提交
1509
#define tcg_const_tl tcg_const_i32
1510
#endif
P
pbrook 已提交
1511 1512 1513 1514 1515 1516 1517

#if TCG_TARGET_REG_BITS == 32
#define tcg_gen_addi_ptr tcg_gen_addi_i32
#else /* TCG_TARGET_REG_BITS == 32 */
#define tcg_gen_addi_ptr tcg_gen_addi_i64
#endif /* TCG_TARGET_REG_BITS != 32 */