tcg-op.h 38.7 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
#ifndef CONFIG_NO_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 167 168 169
{
    tcg_gen_op2(INDEX_op_mov_i32, ret, arg);
}

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

/* 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 已提交
185
static inline void tcg_gen_helper_0_1(void *func, TCGv arg)
B
bellard 已提交
186 187 188 189 190 191
{
    tcg_gen_call(&tcg_ctx,
                 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
                 0, NULL, 1, &arg);
}

P
pbrook 已提交
192
static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2)
B
bellard 已提交
193
{
P
pbrook 已提交
194
    TCGv args[2];
B
bellard 已提交
195 196 197 198 199 200 201
    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);
}

202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
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 已提交
229 230
static inline void tcg_gen_helper_1_2(void *func, TCGv ret, 
                                      TCGv arg1, TCGv arg2)
B
bellard 已提交
231
{
P
pbrook 已提交
232
    TCGv args[2];
B
bellard 已提交
233 234 235 236 237 238 239
    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);
}

240 241 242 243 244 245 246 247 248 249 250 251 252 253
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 已提交
254 255
/* 32 bit ops */

P
pbrook 已提交
256
static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
257
{
P
pbrook 已提交
258
    tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
B
bellard 已提交
259 260
}

P
pbrook 已提交
261
static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
262
{
P
pbrook 已提交
263
    tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
B
bellard 已提交
264 265
}

P
pbrook 已提交
266
static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
267
{
P
pbrook 已提交
268
    tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
B
bellard 已提交
269 270
}

P
pbrook 已提交
271
static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
272
{
P
pbrook 已提交
273
    tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
B
bellard 已提交
274 275
}

P
pbrook 已提交
276
static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
277
{
P
pbrook 已提交
278
    tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
B
bellard 已提交
279 280
}

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

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

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

P
pbrook 已提交
296
static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
297 298 299 300
{
    tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
}

P
pbrook 已提交
301
static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
302
{
303 304 305 306 307 308
    /* 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 已提交
309 310
}

P
pbrook 已提交
311
static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
312 313 314 315
{
    tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
}

P
pbrook 已提交
316
static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
317
{
318 319 320 321 322 323
    /* 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 已提交
324 325
}

P
pbrook 已提交
326
static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
327 328 329 330
{
    tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2);
}

P
pbrook 已提交
331
static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
332 333 334 335 336 337 338 339 340 341 342
{
    /* 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 已提交
343
static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
344 345 346 347
{
    tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
}

P
pbrook 已提交
348
static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
349 350 351
{
    /* some cases can be optimized here */
    if (arg2 == 0xffffffff) {
352
        tcg_gen_movi_i32(ret, 0xffffffff);
B
bellard 已提交
353 354 355 356 357 358 359
    } else if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_or_i32(ret, arg1, tcg_const_i32(arg2));
    }
}

P
pbrook 已提交
360
static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
361 362 363 364
{
    tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2);
}

P
pbrook 已提交
365
static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
366 367 368 369 370 371 372 373 374
{
    /* 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 已提交
375
static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
376 377 378 379
{
    tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
}

P
pbrook 已提交
380
static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
381 382 383 384
{
    tcg_gen_shl_i32(ret, arg1, tcg_const_i32(arg2));
}

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

P
pbrook 已提交
390
static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
391 392 393 394
{
    tcg_gen_shr_i32(ret, arg1, tcg_const_i32(arg2));
}

P
pbrook 已提交
395
static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
396 397 398 399
{
    tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
}

P
pbrook 已提交
400
static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
401 402 403 404
{
    tcg_gen_sar_i32(ret, arg1, tcg_const_i32(arg2));
}

P
pbrook 已提交
405
static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
406 407
                                      int label_index)
{
P
pbrook 已提交
408
    tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
B
bellard 已提交
409 410
}

P
pbrook 已提交
411
static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
412 413 414 415 416
{
    tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
}

#ifdef TCG_TARGET_HAS_div_i32
P
pbrook 已提交
417
static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
418 419 420 421
{
    tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
}

P
pbrook 已提交
422
static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
423 424 425 426
{
    tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
}

P
pbrook 已提交
427
static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
428 429 430 431
{
    tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
}

P
pbrook 已提交
432
static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
433 434 435 436
{
    tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
}
#else
P
pbrook 已提交
437
static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
438
{
P
pbrook 已提交
439
    TCGv t0;
B
bellard 已提交
440 441 442 443 444
    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 已提交
445
static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
446
{
P
pbrook 已提交
447
    TCGv t0;
B
bellard 已提交
448 449 450 451 452
    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 已提交
453
static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
454
{
P
pbrook 已提交
455
    TCGv t0;
B
bellard 已提交
456 457 458 459 460
    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 已提交
461
static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
462
{
P
pbrook 已提交
463
    TCGv t0;
B
bellard 已提交
464 465 466 467 468 469 470 471
    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 已提交
472
static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
B
bellard 已提交
473 474
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
475
    tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
B
bellard 已提交
476 477
}

P
pbrook 已提交
478
static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
B
bellard 已提交
479 480
{
    tcg_gen_movi_i32(ret, arg);
P
pbrook 已提交
481
    tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
B
bellard 已提交
482 483
}

P
pbrook 已提交
484
static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
485 486
{
    tcg_gen_ld8u_i32(ret, arg2, offset);
P
pbrook 已提交
487
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
488 489
}

P
pbrook 已提交
490
static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
491 492
{
    tcg_gen_ld8s_i32(ret, arg2, offset);
P
pbrook 已提交
493
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
494 495
}

P
pbrook 已提交
496
static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
497 498
{
    tcg_gen_ld16u_i32(ret, arg2, offset);
P
pbrook 已提交
499
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
500 501
}

P
pbrook 已提交
502
static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
503 504
{
    tcg_gen_ld16s_i32(ret, arg2, offset);
P
pbrook 已提交
505
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
506 507
}

P
pbrook 已提交
508
static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
509 510
{
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
511
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
512 513
}

P
pbrook 已提交
514
static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
515 516
{
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
517
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
518 519
}

P
pbrook 已提交
520
static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
521 522 523 524
{
    /* since arg2 and ret have different types, they cannot be the
       same temporary */
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
525
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
B
bellard 已提交
526 527 528
    tcg_gen_ld_i32(ret, arg2, offset + 4);
#else
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
529
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
B
bellard 已提交
530 531 532
#endif
}

P
pbrook 已提交
533
static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
534 535 536 537
{
    tcg_gen_st8_i32(arg1, arg2, offset);
}

P
pbrook 已提交
538
static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
539 540 541 542
{
    tcg_gen_st16_i32(arg1, arg2, offset);
}

P
pbrook 已提交
543
static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
544 545 546 547
{
    tcg_gen_st_i32(arg1, arg2, offset);
}

P
pbrook 已提交
548
static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
549 550
{
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
551
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
B
bellard 已提交
552 553 554
    tcg_gen_st_i32(arg1, arg2, offset + 4);
#else
    tcg_gen_st_i32(arg1, arg2, offset);
P
pbrook 已提交
555
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
B
bellard 已提交
556 557 558
#endif
}

P
pbrook 已提交
559
static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
560
{
P
pbrook 已提交
561 562
    tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret), 
                arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
B
bellard 已提交
563 564
}

P
pbrook 已提交
565
static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
566 567 568 569
{
    tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
570
static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
571
{
P
pbrook 已提交
572 573
    tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret), 
                arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
B
bellard 已提交
574 575
}

P
pbrook 已提交
576
static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
577 578 579 580
{
    tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
581
static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
582 583
{
    tcg_gen_and_i32(ret, arg1, arg2);
P
pbrook 已提交
584
    tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
585 586
}

P
pbrook 已提交
587
static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
588 589
{
    tcg_gen_andi_i32(ret, arg1, arg2);
P
pbrook 已提交
590
    tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
591 592
}

P
pbrook 已提交
593
static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
594 595
{
    tcg_gen_or_i32(ret, arg1, arg2);
P
pbrook 已提交
596
    tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
597 598
}

P
pbrook 已提交
599
static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
600 601
{
    tcg_gen_ori_i32(ret, arg1, arg2);
P
pbrook 已提交
602
    tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
603 604
}

P
pbrook 已提交
605
static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
606 607
{
    tcg_gen_xor_i32(ret, arg1, arg2);
P
pbrook 已提交
608
    tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
609 610
}

P
pbrook 已提交
611
static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
612 613
{
    tcg_gen_xori_i32(ret, arg1, arg2);
P
pbrook 已提交
614
    tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
615 616 617 618
}

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

P
pbrook 已提交
624
static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
625 626 627 628
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
}

P
pbrook 已提交
629
static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
630 631 632 633
{
    tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
}

P
pbrook 已提交
634
static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
635 636 637 638
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
}

P
pbrook 已提交
639
static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
640 641 642 643
{
    tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
}

P
pbrook 已提交
644
static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
645 646 647 648
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
}

P
pbrook 已提交
649
static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
650 651
                                      int label_index)
{
P
pbrook 已提交
652 653 654
    tcg_gen_op6ii(INDEX_op_brcond2_i32, 
                  arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
                  cond, label_index);
B
bellard 已提交
655 656
}

P
pbrook 已提交
657
static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
658
{
P
pbrook 已提交
659
    TCGv t0, t1;
B
bellard 已提交
660 661 662 663
    
    t0 = tcg_temp_new(TCG_TYPE_I64);
    t1 = tcg_temp_new(TCG_TYPE_I32);

P
pbrook 已提交
664
    tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
B
bellard 已提交
665
    
P
pbrook 已提交
666 667 668 669
    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 已提交
670 671 672 673
    
    tcg_gen_mov_i64(ret, t0);
}

P
pbrook 已提交
674
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
675 676 677 678
{
    tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
}

P
pbrook 已提交
679
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
680 681 682 683
{
    tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
}

P
pbrook 已提交
684
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
685 686 687 688
{
    tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
}

P
pbrook 已提交
689
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
690 691 692 693 694 695
{
    tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
}

#else

P
pbrook 已提交
696
static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
B
bellard 已提交
697 698 699 700
{
    tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
}

P
pbrook 已提交
701
static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
B
bellard 已提交
702
{
P
pbrook 已提交
703
    tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
B
bellard 已提交
704 705
}

P
pbrook 已提交
706 707
static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
708
{
P
pbrook 已提交
709
    tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
B
bellard 已提交
710 711
}

P
pbrook 已提交
712 713
static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
714
{
P
pbrook 已提交
715
    tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
B
bellard 已提交
716 717
}

P
pbrook 已提交
718 719
static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
720
{
P
pbrook 已提交
721
    tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
B
bellard 已提交
722 723
}

P
pbrook 已提交
724 725
static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
726
{
P
pbrook 已提交
727
    tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
B
bellard 已提交
728 729
}

P
pbrook 已提交
730 731
static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
732
{
P
pbrook 已提交
733
    tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
B
bellard 已提交
734 735
}

P
pbrook 已提交
736 737
static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
738
{
P
pbrook 已提交
739
    tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
B
bellard 已提交
740 741
}

P
pbrook 已提交
742
static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
743
{
P
pbrook 已提交
744
    tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
B
bellard 已提交
745 746
}

P
pbrook 已提交
747 748
static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
                                   tcg_target_long offset)
B
bellard 已提交
749
{
P
pbrook 已提交
750
    tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
B
bellard 已提交
751 752
}

P
pbrook 已提交
753 754
static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
755
{
P
pbrook 已提交
756
    tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
B
bellard 已提交
757 758
}

P
pbrook 已提交
759 760
static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
761
{
P
pbrook 已提交
762
    tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
B
bellard 已提交
763 764
}

P
pbrook 已提交
765
static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
766
{
P
pbrook 已提交
767
    tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
B
bellard 已提交
768 769
}

P
pbrook 已提交
770
static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
771 772 773 774
{
    tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
}

P
pbrook 已提交
775
static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
776 777 778 779
{
    tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
780
static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
781 782 783 784
{
    tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
}

P
pbrook 已提交
785
static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
786 787 788 789
{
    tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
790
static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
791 792 793 794
{
    tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
}

P
pbrook 已提交
795
static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
796 797 798 799
{
    tcg_gen_and_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
800
static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
801 802 803 804
{
    tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
}

P
pbrook 已提交
805
static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
806 807 808 809
{
    tcg_gen_or_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
810
static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
811 812 813 814
{
    tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2);
}

P
pbrook 已提交
815
static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
816 817 818 819
{
    tcg_gen_xor_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
820
static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
821 822 823 824
{
    tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
}

P
pbrook 已提交
825
static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
826 827 828 829
{
    tcg_gen_shl_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
830
static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
831 832 833 834
{
    tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
}

P
pbrook 已提交
835
static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
836 837 838 839
{
    tcg_gen_shr_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
840
static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
841 842 843 844
{
    tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
}

P
pbrook 已提交
845
static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
846 847 848 849
{
    tcg_gen_sar_i64(ret, arg1, tcg_const_i64(arg2));
}

P
pbrook 已提交
850
static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
851 852
                                      int label_index)
{
P
pbrook 已提交
853
    tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
B
bellard 已提交
854 855
}

P
pbrook 已提交
856
static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
857 858 859 860 861
{
    tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
}

#ifdef TCG_TARGET_HAS_div_i64
P
pbrook 已提交
862
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
863 864 865 866
{
    tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
}

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

P
pbrook 已提交
872
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
873 874 875 876
{
    tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
}

P
pbrook 已提交
877
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
878 879 880 881
{
    tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
}
#else
P
pbrook 已提交
882
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
883
{
P
pbrook 已提交
884
    TCGv t0;
B
bellard 已提交
885 886 887 888 889
    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 已提交
890
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
891
{
P
pbrook 已提交
892
    TCGv t0;
B
bellard 已提交
893 894 895 896 897
    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 已提交
898
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
899
{
P
pbrook 已提交
900
    TCGv t0;
B
bellard 已提交
901 902 903 904 905
    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 已提交
906
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
907
{
P
pbrook 已提交
908
    TCGv t0;
B
bellard 已提交
909 910 911 912 913 914 915 916 917 918 919
    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 已提交
920
static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
B
bellard 已提交
921 922 923 924 925
{
#ifdef TCG_TARGET_HAS_ext8s_i32
    tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
#else
    tcg_gen_shli_i32(ret, arg, 24);
926
    tcg_gen_sari_i32(ret, ret, 24);
B
bellard 已提交
927 928 929
#endif
}

P
pbrook 已提交
930
static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
B
bellard 已提交
931 932 933 934 935
{
#ifdef TCG_TARGET_HAS_ext16s_i32
    tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
#else
    tcg_gen_shli_i32(ret, arg, 16);
936
    tcg_gen_sari_i32(ret, ret, 16);
B
bellard 已提交
937 938 939 940
#endif
}

/* Note: we assume the two high bytes are set to zero */
P
pbrook 已提交
941
static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
B
bellard 已提交
942 943 944 945
{
#ifdef TCG_TARGET_HAS_bswap16_i32
    tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
#else
P
pbrook 已提交
946
    TCGv t0, t1;
B
bellard 已提交
947 948 949 950 951 952 953 954 955 956
    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 已提交
957
static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
B
bellard 已提交
958 959 960 961
{
#ifdef TCG_TARGET_HAS_bswap_i32
    tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
#else
P
pbrook 已提交
962
    TCGv t0, t1;
B
bellard 已提交
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
    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 已提交
982
static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
983 984
{
    tcg_gen_ext8s_i32(ret, arg);
P
pbrook 已提交
985
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
986 987
}

P
pbrook 已提交
988
static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
989 990
{
    tcg_gen_ext16s_i32(ret, arg);
P
pbrook 已提交
991
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
992 993
}

P
pbrook 已提交
994
static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
995 996
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
997
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
998 999
}

P
pbrook 已提交
1000
static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1001 1002 1003 1004
{
    tcg_gen_mov_i32(ret, arg);
}

P
pbrook 已提交
1005
static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1006 1007
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1008
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1009 1010
}

P
pbrook 已提交
1011
static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1012 1013
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1014
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1015 1016
}

P
pbrook 已提交
1017
static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1018
{
P
pbrook 已提交
1019
    TCGv t0, t1;
B
bellard 已提交
1020 1021 1022 1023
    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);

    tcg_gen_bswap_i32(t0, arg);
P
pbrook 已提交
1024
    tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
B
bellard 已提交
1025
    tcg_gen_mov_i32(ret, t1);
P
pbrook 已提交
1026
    tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
B
bellard 已提交
1027 1028 1029
}
#else

P
pbrook 已提交
1030
static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1031 1032 1033 1034 1035
{
#ifdef TCG_TARGET_HAS_ext8s_i64
    tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 56);
1036
    tcg_gen_sari_i64(ret, ret, 56);
B
bellard 已提交
1037 1038 1039
#endif
}

P
pbrook 已提交
1040
static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1041 1042 1043 1044 1045
{
#ifdef TCG_TARGET_HAS_ext16s_i64
    tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 48);
1046
    tcg_gen_sari_i64(ret, ret, 48);
B
bellard 已提交
1047 1048 1049
#endif
}

P
pbrook 已提交
1050
static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1051 1052 1053 1054 1055
{
#ifdef TCG_TARGET_HAS_ext32s_i64
    tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 32);
1056
    tcg_gen_sari_i64(ret, ret, 32);
B
bellard 已提交
1057 1058 1059 1060
#endif
}

/* Note: we assume the target supports move between 32 and 64 bit
P
pbrook 已提交
1061 1062
   registers.  This will probably break MIPS64 targets.  */
static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1063 1064 1065 1066 1067 1068
{
    tcg_gen_mov_i32(ret, arg);
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1069
static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1070 1071 1072 1073 1074 1075
{
    tcg_gen_andi_i64(ret, arg, 0xffffffff);
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1076
static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1077 1078 1079 1080
{
    tcg_gen_ext32s_i64(ret, arg);
}

P
pbrook 已提交
1081
static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1082 1083 1084 1085
{
#ifdef TCG_TARGET_HAS_bswap_i64
    tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
#else
P
pbrook 已提交
1086
    TCGv t0, t1;
B
bellard 已提交
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122
    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

1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141

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 已提交
1142
/***************************************/
P
pbrook 已提交
1143
static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id)
B
bellard 已提交
1144
{
P
pbrook 已提交
1145
    tcg_gen_op3i(INDEX_op_macro_2, ret0, ret1, macro_id);
B
bellard 已提交
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
}

/***************************************/
/* 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 已提交
1157
    tcg_gen_op1i(INDEX_op_exit_tb, val);
B
bellard 已提交
1158 1159 1160 1161
}

static inline void tcg_gen_goto_tb(int idx)
{
P
pbrook 已提交
1162
    tcg_gen_op1i(INDEX_op_goto_tb, idx);
B
bellard 已提交
1163 1164 1165
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1166
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1167 1168
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1169
    tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1170
#else
P
pbrook 已提交
1171 1172
    tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1173 1174 1175
#endif
}

P
pbrook 已提交
1176
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1177 1178
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1179
    tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1180
#else
P
pbrook 已提交
1181
    tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
1182
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1183 1184 1185
#endif
}

P
pbrook 已提交
1186
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1187 1188
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1189
    tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1190
#else
P
pbrook 已提交
1191 1192
    tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1193 1194 1195
#endif
}

P
pbrook 已提交
1196
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1197 1198
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1199
    tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1200
#else
P
pbrook 已提交
1201
    tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
1202
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1203 1204 1205
#endif
}

P
pbrook 已提交
1206
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1207 1208
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1209
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1210
#else
P
pbrook 已提交
1211 1212
    tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1213 1214 1215
#endif
}

P
pbrook 已提交
1216
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1217 1218
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1219
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1220
#else
P
pbrook 已提交
1221 1222
    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 已提交
1223 1224 1225
#endif
}

P
pbrook 已提交
1226
static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1227 1228
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1229
    tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
B
bellard 已提交
1230
#else
P
pbrook 已提交
1231 1232
    tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
                 addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1233 1234 1235
#endif
}

P
pbrook 已提交
1236
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1237 1238
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1239
    tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1240
#else
P
pbrook 已提交
1241
    tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1242 1243 1244
#endif
}

P
pbrook 已提交
1245
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1246 1247
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1248
    tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1249
#else
P
pbrook 已提交
1250
    tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1251 1252 1253
#endif
}

P
pbrook 已提交
1254
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1255 1256
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1257
    tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1258
#else
P
pbrook 已提交
1259
    tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1260 1261 1262
#endif
}

P
pbrook 已提交
1263
static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1264 1265
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1266
    tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
B
bellard 已提交
1267
#else
P
pbrook 已提交
1268 1269
    tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
                 addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1270 1271 1272
#endif
}

B
blueswir1 已提交
1273
#define tcg_gen_ld_ptr tcg_gen_ld_i32
B
blueswir1 已提交
1274
#define tcg_gen_discard_ptr tcg_gen_discard_i32
1275

B
bellard 已提交
1276 1277
#else /* TCG_TARGET_REG_BITS == 32 */

P
pbrook 已提交
1278
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1279
{
P
pbrook 已提交
1280
    tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1281 1282
}

P
pbrook 已提交
1283
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1284
{
P
pbrook 已提交
1285
    tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1286 1287
}

P
pbrook 已提交
1288
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1289
{
P
pbrook 已提交
1290
    tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1291 1292
}

P
pbrook 已提交
1293
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1294
{
P
pbrook 已提交
1295
    tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1296 1297
}

P
pbrook 已提交
1298
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1299
{
P
pbrook 已提交
1300
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1301 1302
}

P
pbrook 已提交
1303
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1304
{
P
pbrook 已提交
1305
    tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
B
bellard 已提交
1306 1307
}

P
pbrook 已提交
1308
static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1309
{
P
pbrook 已提交
1310
    tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
B
bellard 已提交
1311 1312
}

P
pbrook 已提交
1313
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1314
{
P
pbrook 已提交
1315
    tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1316 1317
}

P
pbrook 已提交
1318
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1319
{
P
pbrook 已提交
1320
    tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1321 1322
}

P
pbrook 已提交
1323
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1324
{
P
pbrook 已提交
1325
    tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1326 1327
}

P
pbrook 已提交
1328
static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1329
{
P
pbrook 已提交
1330
    tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
B
bellard 已提交
1331 1332
}

B
blueswir1 已提交
1333
#define tcg_gen_ld_ptr tcg_gen_ld_i64
B
blueswir1 已提交
1334
#define tcg_gen_discard_ptr tcg_gen_discard_i64
1335

B
bellard 已提交
1336
#endif /* TCG_TARGET_REG_BITS != 32 */
1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368

#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 已提交
1369
#define tcg_gen_brcond_tl tcg_gen_brcond_i64
B
blueswir1 已提交
1370
#define tcg_gen_discard_tl tcg_gen_discard_i64
1371 1372 1373 1374 1375 1376
#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 已提交
1377
#define tcg_const_tl tcg_const_i64
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
#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 已提交
1409
#define tcg_gen_brcond_tl tcg_gen_brcond_i32
B
blueswir1 已提交
1410
#define tcg_gen_discard_tl tcg_gen_discard_i32
1411 1412 1413 1414 1415 1416
#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 已提交
1417
#define tcg_const_tl tcg_const_i32
1418
#endif