tcg-op.h 52.8 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
}

P
pbrook 已提交
59 60 61 62 63 64 65
static inline void tcg_gen_op2ii(int opc, TCGArg arg1, TCGArg arg2)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = arg1;
    *gen_opparam_ptr++ = arg2;
}

P
pbrook 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78
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 已提交
79
    *gen_opparam_ptr++ = arg3;
P
pbrook 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
}

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 已提交
99 100 101
    *gen_opparam_ptr++ = arg4;
}

P
pbrook 已提交
102 103
static inline void tcg_gen_op4ii(int opc, TCGv arg1, TCGv arg2, TCGArg arg3, 
                                 TCGArg arg4)
B
bellard 已提交
104 105
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
106 107
    *gen_opparam_ptr++ = GET_TCGV(arg1);
    *gen_opparam_ptr++ = GET_TCGV(arg2);
B
bellard 已提交
108 109
    *gen_opparam_ptr++ = arg3;
    *gen_opparam_ptr++ = arg4;
P
pbrook 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
}

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 已提交
133 134 135
    *gen_opparam_ptr++ = arg5;
}

P
pbrook 已提交
136 137 138
static inline void tcg_gen_op6(int opc, TCGv arg1, TCGv arg2, 
                               TCGv arg3, TCGv arg4,
                               TCGv arg5, TCGv arg6)
B
bellard 已提交
139 140
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    *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 已提交
158 159 160 161 162 163
    *gen_opparam_ptr++ = arg5;
    *gen_opparam_ptr++ = arg6;
}

static inline void gen_set_label(int n)
{
P
pbrook 已提交
164
    tcg_gen_op1i(INDEX_op_set_label, n);
B
bellard 已提交
165 166
}

B
blueswir1 已提交
167 168 169 170 171
static inline void tcg_gen_br(int label)
{
    tcg_gen_op1i(INDEX_op_br, label);
}

P
pbrook 已提交
172
static inline void tcg_gen_mov_i32(TCGv ret, TCGv arg)
B
bellard 已提交
173
{
P
pbrook 已提交
174
    if (GET_TCGV(ret) != GET_TCGV(arg))
175
        tcg_gen_op2(INDEX_op_mov_i32, ret, arg);
B
bellard 已提交
176 177
}

P
pbrook 已提交
178
static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg)
B
bellard 已提交
179
{
P
pbrook 已提交
180
    tcg_gen_op2i(INDEX_op_movi_i32, ret, arg);
B
bellard 已提交
181 182 183 184 185 186 187
}

/* helper calls */
#define TCG_HELPER_CALL_FLAGS 0

static inline void tcg_gen_helper_0_0(void *func)
{
188 189
    TCGv t0;
    t0 = tcg_const_ptr((tcg_target_long)func);
B
bellard 已提交
190
    tcg_gen_call(&tcg_ctx, 
191
                 t0, TCG_HELPER_CALL_FLAGS,
B
bellard 已提交
192
                 0, NULL, 0, NULL);
193
    tcg_temp_free(t0);
B
bellard 已提交
194 195
}

P
pbrook 已提交
196
static inline void tcg_gen_helper_0_1(void *func, TCGv arg)
B
bellard 已提交
197
{
198 199
    TCGv t0;
    t0 = tcg_const_ptr((tcg_target_long)func);
B
bellard 已提交
200
    tcg_gen_call(&tcg_ctx,
201
                 t0, TCG_HELPER_CALL_FLAGS,
B
bellard 已提交
202
                 0, NULL, 1, &arg);
203
    tcg_temp_free(t0);
B
bellard 已提交
204 205
}

P
pbrook 已提交
206
static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2)
B
bellard 已提交
207
{
P
pbrook 已提交
208
    TCGv args[2];
209
    TCGv t0;
B
bellard 已提交
210 211
    args[0] = arg1;
    args[1] = arg2;
212
    t0 = tcg_const_ptr((tcg_target_long)func);
B
bellard 已提交
213
    tcg_gen_call(&tcg_ctx, 
214
                 t0, TCG_HELPER_CALL_FLAGS,
B
bellard 已提交
215
                 0, NULL, 2, args);
216
    tcg_temp_free(t0);
B
bellard 已提交
217 218
}

P
pbrook 已提交
219 220 221 222
static inline void tcg_gen_helper_0_3(void *func,
                                      TCGv arg1, TCGv arg2, TCGv arg3)
{
    TCGv args[3];
223
    TCGv t0;
P
pbrook 已提交
224 225 226
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
227
    t0 = tcg_const_ptr((tcg_target_long)func);
P
pbrook 已提交
228
    tcg_gen_call(&tcg_ctx,
229
                 t0, TCG_HELPER_CALL_FLAGS,
P
pbrook 已提交
230
                 0, NULL, 3, args);
231
    tcg_temp_free(t0);
P
pbrook 已提交
232 233
}

234 235 236 237
static inline void tcg_gen_helper_0_4(void *func, TCGv arg1, TCGv arg2,
                                      TCGv arg3, TCGv arg4)
{
    TCGv args[4];
238
    TCGv t0;
239 240 241 242
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
    args[3] = arg4;
243
    t0 = tcg_const_ptr((tcg_target_long)func);
244
    tcg_gen_call(&tcg_ctx,
245
                 t0, TCG_HELPER_CALL_FLAGS,
246
                 0, NULL, 4, args);
247
    tcg_temp_free(t0);
248 249 250 251
}

static inline void tcg_gen_helper_1_0(void *func, TCGv ret)
{
252 253
    TCGv t0;
    t0 = tcg_const_ptr((tcg_target_long)func);
254
    tcg_gen_call(&tcg_ctx,
255
                 t0, TCG_HELPER_CALL_FLAGS,
256
                 1, &ret, 0, NULL);
257
    tcg_temp_free(t0);
258 259 260 261
}

static inline void tcg_gen_helper_1_1(void *func, TCGv ret, TCGv arg1)
{
262 263
    TCGv t0;
    t0 = tcg_const_ptr((tcg_target_long)func);
264
    tcg_gen_call(&tcg_ctx,
265
                 t0, TCG_HELPER_CALL_FLAGS,
266
                 1, &ret, 1, &arg1);
267
    tcg_temp_free(t0);
268 269
}

P
pbrook 已提交
270 271
static inline void tcg_gen_helper_1_2(void *func, TCGv ret, 
                                      TCGv arg1, TCGv arg2)
B
bellard 已提交
272
{
P
pbrook 已提交
273
    TCGv args[2];
274
    TCGv t0;
B
bellard 已提交
275 276
    args[0] = arg1;
    args[1] = arg2;
277
    t0 = tcg_const_ptr((tcg_target_long)func);
B
bellard 已提交
278
    tcg_gen_call(&tcg_ctx, 
279
                 t0, TCG_HELPER_CALL_FLAGS,
B
bellard 已提交
280
                 1, &ret, 2, args);
281
    tcg_temp_free(t0);
B
bellard 已提交
282 283
}

P
pbrook 已提交
284 285 286 287
static inline void tcg_gen_helper_1_3(void *func, TCGv ret,
                                      TCGv arg1, TCGv arg2, TCGv arg3)
{
    TCGv args[3];
288
    TCGv t0;
P
pbrook 已提交
289 290 291
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
292
    t0 = tcg_const_ptr((tcg_target_long)func);
P
pbrook 已提交
293
    tcg_gen_call(&tcg_ctx,
294
                 t0, TCG_HELPER_CALL_FLAGS,
P
pbrook 已提交
295
                 1, &ret, 3, args);
296
    tcg_temp_free(t0);
P
pbrook 已提交
297 298
}

299 300 301 302 303
static inline void tcg_gen_helper_1_4(void *func, TCGv ret,
                                      TCGv arg1, TCGv arg2, TCGv arg3,
                                      TCGv arg4)
{
    TCGv args[4];
304
    TCGv t0;
305 306 307 308
    args[0] = arg1;
    args[1] = arg2;
    args[2] = arg3;
    args[3] = arg4;
309
    t0 = tcg_const_ptr((tcg_target_long)func);
310
    tcg_gen_call(&tcg_ctx,
311
                 t0, TCG_HELPER_CALL_FLAGS,
312
                 1, &ret, 4, args);
313
    tcg_temp_free(t0);
314 315
}

B
bellard 已提交
316 317
/* 32 bit ops */

P
pbrook 已提交
318
static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
319
{
P
pbrook 已提交
320
    tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
B
bellard 已提交
321 322
}

P
pbrook 已提交
323
static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
324
{
P
pbrook 已提交
325
    tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
B
bellard 已提交
326 327
}

P
pbrook 已提交
328
static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
329
{
P
pbrook 已提交
330
    tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
B
bellard 已提交
331 332
}

P
pbrook 已提交
333
static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
334
{
P
pbrook 已提交
335
    tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
B
bellard 已提交
336 337
}

P
pbrook 已提交
338
static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
339
{
P
pbrook 已提交
340
    tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
B
bellard 已提交
341 342
}

P
pbrook 已提交
343
static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
344
{
P
pbrook 已提交
345
    tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset);
B
bellard 已提交
346 347
}

P
pbrook 已提交
348
static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
349
{
P
pbrook 已提交
350
    tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset);
B
bellard 已提交
351 352
}

P
pbrook 已提交
353
static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
354
{
P
pbrook 已提交
355
    tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset);
B
bellard 已提交
356 357
}

P
pbrook 已提交
358
static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
359 360 361 362
{
    tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
}

P
pbrook 已提交
363
static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
364
{
365 366 367 368
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
369 370 371
        TCGv t0 = tcg_const_i32(arg2);
        tcg_gen_add_i32(ret, arg1, t0);
        tcg_temp_free(t0);
372
    }
B
bellard 已提交
373 374
}

P
pbrook 已提交
375
static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
376 377 378 379
{
    tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
}

A
aurel32 已提交
380 381 382 383 384 385 386
static inline void tcg_gen_subfi_i32(TCGv ret, int32_t arg1, TCGv arg2)
{
    TCGv t0 = tcg_const_i32(arg1);
    tcg_gen_sub_i32(ret, t0, arg2);
    tcg_temp_free(t0);
}

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

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

P
pbrook 已提交
404
static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
405 406 407 408 409 410 411
{
    /* 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 {
412 413 414
        TCGv t0 = tcg_const_i32(arg2);
        tcg_gen_and_i32(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
415 416 417
    }
}

P
pbrook 已提交
418
static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
419 420 421 422
{
    tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
}

P
pbrook 已提交
423
static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
424 425 426
{
    /* some cases can be optimized here */
    if (arg2 == 0xffffffff) {
427
        tcg_gen_movi_i32(ret, 0xffffffff);
B
bellard 已提交
428 429 430
    } else if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
431 432 433
        TCGv t0 = tcg_const_i32(arg2);
        tcg_gen_or_i32(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
434 435 436
    }
}

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

P
pbrook 已提交
442
static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
443 444 445 446 447
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
448 449 450
        TCGv t0 = tcg_const_i32(arg2);
        tcg_gen_xor_i32(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
451 452 453
    }
}

P
pbrook 已提交
454
static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
455 456 457 458
{
    tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
}

P
pbrook 已提交
459
static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
460
{
B
bellard 已提交
461 462 463
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
464 465 466
        TCGv t0 = tcg_const_i32(arg2);
        tcg_gen_shl_i32(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
467
    }
B
bellard 已提交
468 469
}

P
pbrook 已提交
470
static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
471 472 473 474
{
    tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2);
}

P
pbrook 已提交
475
static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
476
{
B
bellard 已提交
477 478 479
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
480 481 482
        TCGv t0 = tcg_const_i32(arg2);
        tcg_gen_shr_i32(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
483
    }
B
bellard 已提交
484 485
}

P
pbrook 已提交
486
static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
487 488 489 490
{
    tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
}

P
pbrook 已提交
491
static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
B
bellard 已提交
492
{
B
bellard 已提交
493 494 495
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
496 497 498
        TCGv t0 = tcg_const_i32(arg2);
        tcg_gen_sar_i32(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
499
    }
B
bellard 已提交
500 501
}

P
pbrook 已提交
502
static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
503 504
                                      int label_index)
{
P
pbrook 已提交
505
    tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
B
bellard 已提交
506 507
}

P
pbrook 已提交
508 509 510 511 512 513 514 515
static inline void tcg_gen_brcondi_i32(int cond, TCGv arg1, int32_t arg2, 
                                       int label_index)
{
    TCGv t0 = tcg_const_i32(arg2);
    tcg_gen_brcond_i32(cond, arg1, t0, label_index);
    tcg_temp_free(t0);
}

P
pbrook 已提交
516
static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
517 518 519 520
{
    tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
}

521 522
static inline void tcg_gen_muli_i32(TCGv ret, TCGv arg1, int32_t arg2)
{
523 524 525
    TCGv t0 = tcg_const_i32(arg2);
    tcg_gen_mul_i32(ret, arg1, t0);
    tcg_temp_free(t0);
526 527
}

B
bellard 已提交
528
#ifdef TCG_TARGET_HAS_div_i32
P
pbrook 已提交
529
static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
530 531 532 533
{
    tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
}

P
pbrook 已提交
534
static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
535 536 537 538
{
    tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
}

P
pbrook 已提交
539
static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
540 541 542 543
{
    tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
}

P
pbrook 已提交
544
static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
545 546 547 548
{
    tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
}
#else
P
pbrook 已提交
549
static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
550
{
P
pbrook 已提交
551
    TCGv t0;
B
bellard 已提交
552 553 554
    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);
555
    tcg_temp_free(t0);
B
bellard 已提交
556 557
}

P
pbrook 已提交
558
static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
559
{
P
pbrook 已提交
560
    TCGv t0;
B
bellard 已提交
561 562 563
    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);
564
    tcg_temp_free(t0);
B
bellard 已提交
565 566
}

P
pbrook 已提交
567
static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
568
{
P
pbrook 已提交
569
    TCGv t0;
B
bellard 已提交
570 571 572
    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);
573
    tcg_temp_free(t0);
B
bellard 已提交
574 575
}

P
pbrook 已提交
576
static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
577
{
P
pbrook 已提交
578
    TCGv t0;
B
bellard 已提交
579 580 581
    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);
582
    tcg_temp_free(t0);
B
bellard 已提交
583 584 585 586 587
}
#endif

#if TCG_TARGET_REG_BITS == 32

P
pbrook 已提交
588
static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
B
bellard 已提交
589
{
P
pbrook 已提交
590
    if (GET_TCGV(ret) != GET_TCGV(arg)) {
591 592 593
        tcg_gen_mov_i32(ret, arg);
        tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
    }
B
bellard 已提交
594 595
}

P
pbrook 已提交
596
static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
B
bellard 已提交
597 598
{
    tcg_gen_movi_i32(ret, arg);
P
pbrook 已提交
599
    tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
B
bellard 已提交
600 601
}

P
pbrook 已提交
602
static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
603 604
{
    tcg_gen_ld8u_i32(ret, arg2, offset);
P
pbrook 已提交
605
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
606 607
}

P
pbrook 已提交
608
static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
609 610
{
    tcg_gen_ld8s_i32(ret, arg2, offset);
P
pbrook 已提交
611
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
612 613
}

P
pbrook 已提交
614
static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
615 616
{
    tcg_gen_ld16u_i32(ret, arg2, offset);
P
pbrook 已提交
617
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
618 619
}

P
pbrook 已提交
620
static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
621 622
{
    tcg_gen_ld16s_i32(ret, arg2, offset);
P
pbrook 已提交
623
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
624 625
}

P
pbrook 已提交
626
static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
627 628
{
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
629
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
630 631
}

P
pbrook 已提交
632
static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
633 634
{
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
635
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
636 637
}

P
pbrook 已提交
638
static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
639 640 641 642
{
    /* since arg2 and ret have different types, they cannot be the
       same temporary */
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
643
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
B
bellard 已提交
644 645 646
    tcg_gen_ld_i32(ret, arg2, offset + 4);
#else
    tcg_gen_ld_i32(ret, arg2, offset);
P
pbrook 已提交
647
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
B
bellard 已提交
648 649 650
#endif
}

P
pbrook 已提交
651
static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
652 653 654 655
{
    tcg_gen_st8_i32(arg1, arg2, offset);
}

P
pbrook 已提交
656
static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
657 658 659 660
{
    tcg_gen_st16_i32(arg1, arg2, offset);
}

P
pbrook 已提交
661
static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
662 663 664 665
{
    tcg_gen_st_i32(arg1, arg2, offset);
}

P
pbrook 已提交
666
static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
667 668
{
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
669
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
B
bellard 已提交
670 671 672
    tcg_gen_st_i32(arg1, arg2, offset + 4);
#else
    tcg_gen_st_i32(arg1, arg2, offset);
P
pbrook 已提交
673
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
B
bellard 已提交
674 675 676
#endif
}

P
pbrook 已提交
677
static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
678
{
P
pbrook 已提交
679 680
    tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret), 
                arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
B
bellard 已提交
681 682
}

P
pbrook 已提交
683
static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
684
{
P
pbrook 已提交
685 686
    tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret), 
                arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
B
bellard 已提交
687 688
}

P
pbrook 已提交
689
static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
690 691
{
    tcg_gen_and_i32(ret, arg1, arg2);
P
pbrook 已提交
692
    tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
693 694
}

P
pbrook 已提交
695
static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
696 697
{
    tcg_gen_andi_i32(ret, arg1, arg2);
P
pbrook 已提交
698
    tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
699 700
}

P
pbrook 已提交
701
static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
702 703
{
    tcg_gen_or_i32(ret, arg1, arg2);
P
pbrook 已提交
704
    tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
705 706
}

P
pbrook 已提交
707
static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
708 709
{
    tcg_gen_ori_i32(ret, arg1, arg2);
P
pbrook 已提交
710
    tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
711 712
}

P
pbrook 已提交
713
static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
714 715
{
    tcg_gen_xor_i32(ret, arg1, arg2);
P
pbrook 已提交
716
    tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
717 718
}

P
pbrook 已提交
719
static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
720 721
{
    tcg_gen_xori_i32(ret, arg1, arg2);
P
pbrook 已提交
722
    tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
723 724 725 726
}

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

P
pbrook 已提交
732
static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
733 734 735 736
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
}

P
pbrook 已提交
737
static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
738 739 740 741
{
    tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
}

P
pbrook 已提交
742
static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
743 744 745 746
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
}

P
pbrook 已提交
747
static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
748 749 750 751
{
    tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
}

P
pbrook 已提交
752
static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
753 754 755 756
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
}

P
pbrook 已提交
757
static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
758 759
                                      int label_index)
{
P
pbrook 已提交
760 761 762
    tcg_gen_op6ii(INDEX_op_brcond2_i32, 
                  arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
                  cond, label_index);
B
bellard 已提交
763 764
}

P
pbrook 已提交
765
static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
766
{
P
pbrook 已提交
767
    TCGv t0, t1;
B
bellard 已提交
768 769 770 771
    
    t0 = tcg_temp_new(TCG_TYPE_I64);
    t1 = tcg_temp_new(TCG_TYPE_I32);

P
pbrook 已提交
772
    tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
B
bellard 已提交
773
    
P
pbrook 已提交
774 775 776 777
    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 已提交
778 779
    
    tcg_gen_mov_i64(ret, t0);
780 781
    tcg_temp_free(t0);
    tcg_temp_free(t1);
B
bellard 已提交
782 783
}

P
pbrook 已提交
784
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
785 786 787 788
{
    tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
}

P
pbrook 已提交
789
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
790 791 792 793
{
    tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
}

P
pbrook 已提交
794
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
795 796 797 798
{
    tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
}

P
pbrook 已提交
799
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
800 801 802 803 804 805
{
    tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
}

#else

P
pbrook 已提交
806
static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
B
bellard 已提交
807
{
P
pbrook 已提交
808
    if (GET_TCGV(ret) != GET_TCGV(arg))
809
        tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
B
bellard 已提交
810 811
}

P
pbrook 已提交
812
static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
B
bellard 已提交
813
{
P
pbrook 已提交
814
    tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
B
bellard 已提交
815 816
}

P
pbrook 已提交
817 818
static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
819
{
P
pbrook 已提交
820
    tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
B
bellard 已提交
821 822
}

P
pbrook 已提交
823 824
static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
825
{
P
pbrook 已提交
826
    tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
B
bellard 已提交
827 828
}

P
pbrook 已提交
829 830
static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
831
{
P
pbrook 已提交
832
    tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
B
bellard 已提交
833 834
}

P
pbrook 已提交
835 836
static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
837
{
P
pbrook 已提交
838
    tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
B
bellard 已提交
839 840
}

P
pbrook 已提交
841 842
static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
843
{
P
pbrook 已提交
844
    tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
B
bellard 已提交
845 846
}

P
pbrook 已提交
847 848
static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
                                     tcg_target_long offset)
B
bellard 已提交
849
{
P
pbrook 已提交
850
    tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
B
bellard 已提交
851 852
}

P
pbrook 已提交
853
static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
854
{
P
pbrook 已提交
855
    tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
B
bellard 已提交
856 857
}

P
pbrook 已提交
858 859
static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
                                   tcg_target_long offset)
B
bellard 已提交
860
{
P
pbrook 已提交
861
    tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
B
bellard 已提交
862 863
}

P
pbrook 已提交
864 865
static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
866
{
P
pbrook 已提交
867
    tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
B
bellard 已提交
868 869
}

P
pbrook 已提交
870 871
static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
                                    tcg_target_long offset)
B
bellard 已提交
872
{
P
pbrook 已提交
873
    tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
B
bellard 已提交
874 875
}

P
pbrook 已提交
876
static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
B
bellard 已提交
877
{
P
pbrook 已提交
878
    tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
B
bellard 已提交
879 880
}

P
pbrook 已提交
881
static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
882 883 884 885
{
    tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
}

P
pbrook 已提交
886
static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
887 888 889 890
{
    tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
}

P
pbrook 已提交
891
static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
892 893 894 895
{
    tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
}

P
pbrook 已提交
896
static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
897
{
898 899 900
    TCGv t0 = tcg_const_i64(arg2);
    tcg_gen_and_i64(ret, arg1, t0);
    tcg_temp_free(t0);
B
bellard 已提交
901 902
}

P
pbrook 已提交
903
static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
904 905 906 907
{
    tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
}

P
pbrook 已提交
908
static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
909
{
910 911 912
    TCGv t0 = tcg_const_i64(arg2);
    tcg_gen_or_i64(ret, arg1, t0);
    tcg_temp_free(t0);
B
bellard 已提交
913 914
}

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

P
pbrook 已提交
920
static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
921
{
922 923 924
    TCGv t0 = tcg_const_i64(arg2);
    tcg_gen_xor_i64(ret, arg1, t0);
    tcg_temp_free(t0);
B
bellard 已提交
925 926
}

P
pbrook 已提交
927
static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
928 929 930 931
{
    tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
}

P
pbrook 已提交
932
static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
933
{
B
bellard 已提交
934 935 936
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
937 938 939
        TCGv t0 = tcg_const_i64(arg2);
        tcg_gen_shl_i64(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
940
    }
B
bellard 已提交
941 942
}

P
pbrook 已提交
943
static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
944 945 946 947
{
    tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
}

P
pbrook 已提交
948
static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
949
{
B
bellard 已提交
950 951 952
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
953 954 955
        TCGv t0 = tcg_const_i64(arg2);
        tcg_gen_shr_i64(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
956
    }
B
bellard 已提交
957 958
}

P
pbrook 已提交
959
static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
960 961 962 963
{
    tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
}

P
pbrook 已提交
964
static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
B
bellard 已提交
965
{
B
bellard 已提交
966 967 968
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
969 970 971
        TCGv t0 = tcg_const_i64(arg2);
        tcg_gen_sar_i64(ret, arg1, t0);
        tcg_temp_free(t0);
B
bellard 已提交
972
    }
B
bellard 已提交
973 974
}

P
pbrook 已提交
975
static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, 
B
bellard 已提交
976 977
                                      int label_index)
{
P
pbrook 已提交
978
    tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
B
bellard 已提交
979 980
}

P
pbrook 已提交
981
static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
982 983 984 985 986
{
    tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
}

#ifdef TCG_TARGET_HAS_div_i64
P
pbrook 已提交
987
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
988 989 990 991
{
    tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
}

P
pbrook 已提交
992
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
993 994 995 996
{
    tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2);
}

P
pbrook 已提交
997
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
998 999 1000 1001
{
    tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
}

P
pbrook 已提交
1002
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
1003 1004 1005 1006
{
    tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
}
#else
P
pbrook 已提交
1007
static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
1008
{
P
pbrook 已提交
1009
    TCGv t0;
B
bellard 已提交
1010 1011 1012
    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);
1013
    tcg_temp_free(t0);
B
bellard 已提交
1014 1015
}

P
pbrook 已提交
1016
static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
1017
{
P
pbrook 已提交
1018
    TCGv t0;
B
bellard 已提交
1019 1020 1021
    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);
1022
    tcg_temp_free(t0);
B
bellard 已提交
1023 1024
}

P
pbrook 已提交
1025
static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
1026
{
P
pbrook 已提交
1027
    TCGv t0;
B
bellard 已提交
1028 1029 1030
    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);
1031
    tcg_temp_free(t0);
B
bellard 已提交
1032 1033
}

P
pbrook 已提交
1034
static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
B
bellard 已提交
1035
{
P
pbrook 已提交
1036
    TCGv t0;
B
bellard 已提交
1037 1038 1039
    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);
1040
    tcg_temp_free(t0);
B
bellard 已提交
1041 1042 1043 1044 1045
}
#endif

#endif

1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
        TCGv t0 = tcg_const_i64(arg2);
        tcg_gen_add_i64(ret, arg1, t0);
        tcg_temp_free(t0);
    }
}

A
aurel32 已提交
1058 1059 1060 1061 1062 1063 1064
static inline void tcg_gen_subfi_i64(TCGv ret, int64_t arg1, TCGv arg2)
{
    TCGv t0 = tcg_const_i64(arg1);
    tcg_gen_sub_i64(ret, t0, arg2);
    tcg_temp_free(t0);
}

1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
        TCGv t0 = tcg_const_i64(arg2);
        tcg_gen_sub_i64(ret, arg1, t0);
        tcg_temp_free(t0);
    }
}
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
static inline void tcg_gen_brcondi_i64(int cond, TCGv arg1, int64_t arg2,
                                       int label_index)
{
    TCGv t0 = tcg_const_i64(arg2);
    tcg_gen_brcond_i64(cond, arg1, t0, label_index);
    tcg_temp_free(t0);
}

static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2)
{
    TCGv t0 = tcg_const_i64(arg2);
    tcg_gen_mul_i64(ret, arg1, t0);
    tcg_temp_free(t0);
}

1091

B
bellard 已提交
1092 1093 1094
/***************************************/
/* optional operations */

P
pbrook 已提交
1095
static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1096 1097 1098 1099 1100
{
#ifdef TCG_TARGET_HAS_ext8s_i32
    tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
#else
    tcg_gen_shli_i32(ret, arg, 24);
1101
    tcg_gen_sari_i32(ret, ret, 24);
B
bellard 已提交
1102 1103 1104
#endif
}

P
pbrook 已提交
1105
static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1106 1107 1108 1109 1110
{
#ifdef TCG_TARGET_HAS_ext16s_i32
    tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
#else
    tcg_gen_shli_i32(ret, arg, 16);
1111
    tcg_gen_sari_i32(ret, ret, 16);
B
bellard 已提交
1112 1113 1114
#endif
}

P
pbrook 已提交
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
/* 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 已提交
1127
/* Note: we assume the two high bytes are set to zero */
P
pbrook 已提交
1128
static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1129 1130 1131 1132
{
#ifdef TCG_TARGET_HAS_bswap16_i32
    tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
#else
P
pbrook 已提交
1133
    TCGv t0, t1;
B
bellard 已提交
1134 1135 1136 1137 1138 1139 1140
    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);
1141 1142
    tcg_temp_free(t0);
    tcg_temp_free(t1);
B
bellard 已提交
1143 1144 1145
#endif
}

P
pbrook 已提交
1146
static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1147 1148 1149 1150
{
#ifdef TCG_TARGET_HAS_bswap_i32
    tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
#else
P
pbrook 已提交
1151
    TCGv t0, t1;
B
bellard 已提交
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
    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);
1167 1168
    tcg_temp_free(t0);
    tcg_temp_free(t1);
B
bellard 已提交
1169 1170 1171 1172
#endif
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1173
static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1174 1175
{
    tcg_gen_ext8s_i32(ret, arg);
P
pbrook 已提交
1176
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1177 1178
}

P
pbrook 已提交
1179
static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1180 1181
{
    tcg_gen_ext16s_i32(ret, arg);
P
pbrook 已提交
1182
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1183 1184
}

P
pbrook 已提交
1185
static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1186 1187
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1188
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1189 1190
}

P
pbrook 已提交
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208
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 已提交
1209
static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1210 1211 1212 1213
{
    tcg_gen_mov_i32(ret, arg);
}

P
pbrook 已提交
1214
static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1215 1216
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1217
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1218 1219
}

P
pbrook 已提交
1220
static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1221 1222
{
    tcg_gen_mov_i32(ret, arg);
P
pbrook 已提交
1223
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1224 1225
}

P
pbrook 已提交
1226
static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1227
{
P
pbrook 已提交
1228
    TCGv t0, t1;
B
bellard 已提交
1229 1230 1231 1232
    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);

    tcg_gen_bswap_i32(t0, arg);
P
pbrook 已提交
1233
    tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
B
bellard 已提交
1234
    tcg_gen_mov_i32(ret, t1);
P
pbrook 已提交
1235
    tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
1236 1237
    tcg_temp_free(t0);
    tcg_temp_free(t1);
B
bellard 已提交
1238 1239 1240
}
#else

P
pbrook 已提交
1241
static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1242 1243 1244 1245 1246
{
#ifdef TCG_TARGET_HAS_ext8s_i64
    tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 56);
1247
    tcg_gen_sari_i64(ret, ret, 56);
B
bellard 已提交
1248 1249 1250
#endif
}

P
pbrook 已提交
1251
static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1252 1253 1254 1255 1256
{
#ifdef TCG_TARGET_HAS_ext16s_i64
    tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 48);
1257
    tcg_gen_sari_i64(ret, ret, 48);
B
bellard 已提交
1258 1259 1260
#endif
}

P
pbrook 已提交
1261
static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1262 1263 1264 1265 1266
{
#ifdef TCG_TARGET_HAS_ext32s_i64
    tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
#else
    tcg_gen_shli_i64(ret, arg, 32);
1267
    tcg_gen_sari_i64(ret, ret, 32);
B
bellard 已提交
1268 1269 1270
#endif
}

P
pbrook 已提交
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285
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 已提交
1286
/* Note: we assume the target supports move between 32 and 64 bit
P
pbrook 已提交
1287 1288
   registers.  This will probably break MIPS64 targets.  */
static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
B
bellard 已提交
1289 1290 1291 1292 1293 1294
{
    tcg_gen_mov_i32(ret, arg);
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1295
static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1296
{
P
pbrook 已提交
1297
    tcg_gen_andi_i64(ret, arg, 0xffffffffu);
B
bellard 已提交
1298 1299 1300 1301
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1302
static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1303 1304 1305 1306
{
    tcg_gen_ext32s_i64(ret, arg);
}

P
pbrook 已提交
1307
static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
B
bellard 已提交
1308 1309 1310 1311
{
#ifdef TCG_TARGET_HAS_bswap_i64
    tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
#else
P
pbrook 已提交
1312
    TCGv t0, t1;
B
bellard 已提交
1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
    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);
1344 1345
    tcg_temp_free(t0);
    tcg_temp_free(t1);
B
bellard 已提交
1346 1347 1348 1349 1350
#endif
}

#endif

P
pbrook 已提交
1351 1352 1353 1354 1355
static inline void tcg_gen_neg_i32(TCGv ret, TCGv arg)
{
#ifdef TCG_TARGET_HAS_neg_i32
    tcg_gen_op2(INDEX_op_neg_i32, ret, arg);
#else
1356 1357 1358
    TCGv t0 = tcg_const_i32(0);
    tcg_gen_sub_i32(ret, t0, arg);
    tcg_temp_free(t0);
P
pbrook 已提交
1359 1360 1361 1362 1363 1364 1365 1366
#endif
}

static inline void tcg_gen_neg_i64(TCGv ret, TCGv arg)
{
#ifdef TCG_TARGET_HAS_neg_i64
    tcg_gen_op2(INDEX_op_neg_i64, ret, arg);
#else
1367 1368 1369
    TCGv t0 = tcg_const_i64(0);
    tcg_gen_sub_i64(ret, t0, arg);
    tcg_temp_free(t0);
P
pbrook 已提交
1370 1371 1372
#endif
}

B
bellard 已提交
1373 1374
static inline void tcg_gen_not_i32(TCGv ret, TCGv arg)
{
1375
    tcg_gen_xori_i32(ret, arg, -1);
B
bellard 已提交
1376 1377 1378 1379
}

static inline void tcg_gen_not_i64(TCGv ret, TCGv arg)
{
1380
    tcg_gen_xori_i64(ret, arg, -1);
B
bellard 已提交
1381
}
1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400

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

P
pbrook 已提交
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417
static inline void tcg_gen_concat_i32_i64(TCGv dest, TCGv low, TCGv high)
{
#if TCG_TARGET_REG_BITS == 32
    tcg_gen_mov_i32(dest, low);
    tcg_gen_mov_i32(TCGV_HIGH(dest), high);
#else
    TCGv tmp = tcg_temp_new (TCG_TYPE_I64);
    /* This extension is only needed for type correctness.
       We may be able to do better given target specific information.  */
    tcg_gen_extu_i32_i64(tmp, high);
    tcg_gen_shli_i64(tmp, tmp, 32);
    tcg_gen_extu_i32_i64(dest, low);
    tcg_gen_or_i64(dest, dest, tmp);
    tcg_temp_free(tmp);
#endif
}

1418 1419 1420 1421 1422 1423
static inline void tcg_gen_concat32_i64(TCGv dest, TCGv low, TCGv high)
{
#if TCG_TARGET_REG_BITS == 32
    tcg_gen_concat_i32_i64(dest, low, high);
#else
    TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
1424
    tcg_gen_ext32u_i64(dest, low);
1425
    tcg_gen_shli_i64(tmp, high, 32);
1426
    tcg_gen_or_i64(dest, dest, tmp);
1427 1428 1429 1430
    tcg_temp_free(tmp);
#endif
}

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 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 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 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520
static inline void tcg_gen_andc_i32(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_not_i32(t0, arg2);
    tcg_gen_and_i32(ret, arg1, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_andc_i64(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_not_i64(t0, arg2);
    tcg_gen_and_i64(ret, arg1, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_eqv_i32(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_xor_i32(t0, arg1, arg2);
    tcg_gen_not_i32(ret, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_eqv_i64(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_xor_i64(t0, arg1, arg2);
    tcg_gen_not_i64(ret, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_nand_i32(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_and_i32(t0, arg1, arg2);
    tcg_gen_not_i32(ret, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_nand_i64(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_and_i64(t0, arg1, arg2);
    tcg_gen_not_i64(ret, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_nor_i32(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_or_i32(t0, arg1, arg2);
    tcg_gen_not_i32(ret, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_nor_i64(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_or_i64(t0, arg1, arg2);
    tcg_gen_not_i64(ret, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_orc_i32(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_not_i32(t0, arg2);
    tcg_gen_or_i32(ret, arg1, t0);
    tcg_temp_free(t0);
}

static inline void tcg_gen_orc_i64(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0;
    t0 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_not_i64(t0, arg2);
    tcg_gen_or_i64(ret, arg1, t0);
    tcg_temp_free(t0);
}

1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
static inline void tcg_gen_rotl_i32(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0, t1;

    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_shl_i32(t0, arg1, arg2);
    tcg_gen_subfi_i32(t1, 32, arg2);
    tcg_gen_shr_i32(t1, arg1, t1);
    tcg_gen_or_i32(ret, t0, t1);
    tcg_temp_free(t0);
    tcg_temp_free(t1);
}

static inline void tcg_gen_rotl_i64(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0, t1;

    t0 = tcg_temp_new(TCG_TYPE_I64);
    t1 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_shl_i64(t0, arg1, arg2);
    tcg_gen_subfi_i64(t1, 64, arg2);
    tcg_gen_shr_i64(t1, arg1, t1);
    tcg_gen_or_i64(ret, t0, t1);
    tcg_temp_free(t0);
    tcg_temp_free(t1);
}

static inline void tcg_gen_rotli_i32(TCGv ret, TCGv arg1, int32_t arg2)
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        TCGv t0, t1;
        t0 = tcg_temp_new(TCG_TYPE_I32);
        t1 = tcg_temp_new(TCG_TYPE_I32);
        tcg_gen_shli_i32(t0, arg1, arg2);
        tcg_gen_shri_i32(t1, arg1, 32 - arg2);
        tcg_gen_or_i32(ret, t0, t1);
        tcg_temp_free(t0);
        tcg_temp_free(t1);
    }
}

static inline void tcg_gen_rotli_i64(TCGv ret, TCGv arg1, int64_t arg2)
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
        TCGv t0, t1;
        t0 = tcg_temp_new(TCG_TYPE_I64);
        t1 = tcg_temp_new(TCG_TYPE_I64);
        tcg_gen_shli_i64(t0, arg1, arg2);
        tcg_gen_shri_i64(t1, arg1, 64 - arg2);
        tcg_gen_or_i64(ret, t0, t1);
        tcg_temp_free(t0);
        tcg_temp_free(t1);
    }
}

static inline void tcg_gen_rotr_i32(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0, t1;

    t0 = tcg_temp_new(TCG_TYPE_I32);
    t1 = tcg_temp_new(TCG_TYPE_I32);
    tcg_gen_shr_i32(t0, arg1, arg2);
    tcg_gen_subfi_i32(t1, 32, arg2);
    tcg_gen_shl_i32(t1, arg1, t1);
    tcg_gen_or_i32(ret, t0, t1);
    tcg_temp_free(t0);
    tcg_temp_free(t1);
}

static inline void tcg_gen_rotr_i64(TCGv ret, TCGv arg1, TCGv arg2)
{
    TCGv t0, t1;

    t0 = tcg_temp_new(TCG_TYPE_I64);
    t1 = tcg_temp_new(TCG_TYPE_I64);
    tcg_gen_shl_i64(t0, arg1, arg2);
    tcg_gen_subfi_i64(t1, 64, arg2);
    tcg_gen_shl_i64(t1, arg1, t1);
    tcg_gen_or_i64(ret, t0, t1);
    tcg_temp_free(t0);
    tcg_temp_free(t1);
}

static inline void tcg_gen_rotri_i32(TCGv ret, TCGv arg1, int32_t arg2)
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_rotli_i32(ret, arg1, 32 - arg2);
    }
}

static inline void tcg_gen_rotri_i64(TCGv ret, TCGv arg1, int64_t arg2)
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_rotli_i64(ret, arg1, 64 - arg2);
    }
}

B
bellard 已提交
1631 1632 1633 1634 1635 1636 1637
/***************************************/
/* QEMU specific operations. Their type depend on the QEMU CPU
   type. */
#ifndef TARGET_LONG_BITS
#error must include QEMU headers
#endif

1638 1639 1640 1641 1642
/* debug info: write the PC of the corresponding QEMU CPU instruction */
static inline void tcg_gen_debug_insn_start(uint64_t pc)
{
    /* XXX: must really use a 32 bit size for TCGArg in all cases */
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
P
pbrook 已提交
1643 1644
    tcg_gen_op2ii(INDEX_op_debug_insn_start, 
                  (uint32_t)(pc), (uint32_t)(pc >> 32));
1645 1646 1647 1648 1649
#else
    tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
#endif
}

B
bellard 已提交
1650 1651
static inline void tcg_gen_exit_tb(tcg_target_long val)
{
P
pbrook 已提交
1652
    tcg_gen_op1i(INDEX_op_exit_tb, val);
B
bellard 已提交
1653 1654 1655 1656
}

static inline void tcg_gen_goto_tb(int idx)
{
P
pbrook 已提交
1657
    tcg_gen_op1i(INDEX_op_goto_tb, idx);
B
bellard 已提交
1658 1659 1660
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1661
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1662 1663
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1664
    tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1665
#else
P
pbrook 已提交
1666 1667
    tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1668 1669 1670
#endif
}

P
pbrook 已提交
1671
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1672 1673
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1674
    tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1675
#else
P
pbrook 已提交
1676
    tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
1677
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1678 1679 1680
#endif
}

P
pbrook 已提交
1681
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1682 1683
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1684
    tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1685
#else
P
pbrook 已提交
1686 1687
    tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1688 1689 1690
#endif
}

P
pbrook 已提交
1691
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1692 1693
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1694
    tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1695
#else
P
pbrook 已提交
1696
    tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
1697
    tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
B
bellard 已提交
1698 1699 1700
#endif
}

P
pbrook 已提交
1701
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1702 1703
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1704
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1705
#else
P
pbrook 已提交
1706 1707
    tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1708 1709 1710
#endif
}

P
pbrook 已提交
1711
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1712 1713
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1714
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1715
#else
P
pbrook 已提交
1716 1717
    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 已提交
1718 1719 1720
#endif
}

P
pbrook 已提交
1721
static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1722 1723
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1724
    tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
B
bellard 已提交
1725
#else
P
pbrook 已提交
1726 1727
    tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
                 addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1728 1729 1730
#endif
}

P
pbrook 已提交
1731
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1732 1733
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1734
    tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1735
#else
P
pbrook 已提交
1736
    tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1737 1738 1739
#endif
}

P
pbrook 已提交
1740
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1741 1742
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1743
    tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1744
#else
P
pbrook 已提交
1745
    tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1746 1747 1748
#endif
}

P
pbrook 已提交
1749
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1750 1751
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1752
    tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1753
#else
P
pbrook 已提交
1754
    tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1755 1756 1757
#endif
}

P
pbrook 已提交
1758
static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1759 1760
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1761
    tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
B
bellard 已提交
1762
#else
P
pbrook 已提交
1763 1764
    tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
                 addr, TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1765 1766 1767
#endif
}

B
blueswir1 已提交
1768
#define tcg_gen_ld_ptr tcg_gen_ld_i32
B
blueswir1 已提交
1769
#define tcg_gen_discard_ptr tcg_gen_discard_i32
1770

B
bellard 已提交
1771 1772
#else /* TCG_TARGET_REG_BITS == 32 */

P
pbrook 已提交
1773
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1774
{
P
pbrook 已提交
1775
    tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1776 1777
}

P
pbrook 已提交
1778
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1779
{
P
pbrook 已提交
1780
    tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1781 1782
}

P
pbrook 已提交
1783
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1784
{
P
pbrook 已提交
1785
    tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1786 1787
}

P
pbrook 已提交
1788
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1789
{
P
pbrook 已提交
1790
    tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1791 1792
}

P
pbrook 已提交
1793
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1794
{
P
pbrook 已提交
1795
    tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1796 1797
}

P
pbrook 已提交
1798
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1799
{
P
pbrook 已提交
1800
    tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
B
bellard 已提交
1801 1802
}

P
pbrook 已提交
1803
static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1804
{
P
pbrook 已提交
1805
    tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
B
bellard 已提交
1806 1807
}

P
pbrook 已提交
1808
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1809
{
P
pbrook 已提交
1810
    tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1811 1812
}

P
pbrook 已提交
1813
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1814
{
P
pbrook 已提交
1815
    tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1816 1817
}

P
pbrook 已提交
1818
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1819
{
P
pbrook 已提交
1820
    tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1821 1822
}

P
pbrook 已提交
1823
static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1824
{
P
pbrook 已提交
1825
    tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
B
bellard 已提交
1826 1827
}

B
blueswir1 已提交
1828
#define tcg_gen_ld_ptr tcg_gen_ld_i64
B
blueswir1 已提交
1829
#define tcg_gen_discard_ptr tcg_gen_discard_i64
1830

B
bellard 已提交
1831
#endif /* TCG_TARGET_REG_BITS != 32 */
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850

#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
P
pbrook 已提交
1851
#define tcg_gen_neg_tl tcg_gen_neg_i64
P
pbrook 已提交
1852
#define tcg_gen_subfi_tl tcg_gen_subfi_i64
1853 1854 1855 1856 1857 1858 1859
#define tcg_gen_subi_tl tcg_gen_subi_i64
#define tcg_gen_and_tl tcg_gen_and_i64
#define tcg_gen_andi_tl tcg_gen_andi_i64
#define tcg_gen_or_tl tcg_gen_or_i64
#define tcg_gen_ori_tl tcg_gen_ori_i64
#define tcg_gen_xor_tl tcg_gen_xor_i64
#define tcg_gen_xori_tl tcg_gen_xori_i64
B
bellard 已提交
1860
#define tcg_gen_not_tl tcg_gen_not_i64
1861 1862 1863 1864 1865 1866
#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 已提交
1867
#define tcg_gen_brcond_tl tcg_gen_brcond_i64
P
pbrook 已提交
1868
#define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
1869 1870
#define tcg_gen_mul_tl tcg_gen_mul_i64
#define tcg_gen_muli_tl tcg_gen_muli_i64
B
blueswir1 已提交
1871
#define tcg_gen_discard_tl tcg_gen_discard_i64
1872 1873 1874 1875 1876 1877
#define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
#define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
#define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
#define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
#define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
#define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
B
bellard 已提交
1878 1879 1880 1881 1882 1883
#define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
#define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
#define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
#define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
#define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
#define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
1884
#define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
1885 1886 1887 1888 1889
#define tcg_gen_andc_tl tcg_gen_andc_i64
#define tcg_gen_eqv_tl tcg_gen_eqv_i64
#define tcg_gen_nand_tl tcg_gen_nand_i64
#define tcg_gen_nor_tl tcg_gen_nor_i64
#define tcg_gen_orc_tl tcg_gen_orc_i64
1890 1891 1892 1893
#define tcg_gen_rotl_tl tcg_gen_rotl_i64
#define tcg_gen_rotli_tl tcg_gen_rotli_i64
#define tcg_gen_rotr_tl tcg_gen_rotr_i64
#define tcg_gen_rotri_tl tcg_gen_rotri_i64
B
blueswir1 已提交
1894
#define tcg_const_tl tcg_const_i64
A
aurel32 已提交
1895
#define tcg_const_local_tl tcg_const_local_i64
1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913
#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
P
pbrook 已提交
1914
#define tcg_gen_neg_tl tcg_gen_neg_i32
A
aurel32 已提交
1915
#define tcg_gen_subfi_tl tcg_gen_subfi_i32
1916 1917 1918 1919 1920 1921 1922
#define tcg_gen_subi_tl tcg_gen_subi_i32
#define tcg_gen_and_tl tcg_gen_and_i32
#define tcg_gen_andi_tl tcg_gen_andi_i32
#define tcg_gen_or_tl tcg_gen_or_i32
#define tcg_gen_ori_tl tcg_gen_ori_i32
#define tcg_gen_xor_tl tcg_gen_xor_i32
#define tcg_gen_xori_tl tcg_gen_xori_i32
B
bellard 已提交
1923
#define tcg_gen_not_tl tcg_gen_not_i32
1924 1925 1926 1927 1928 1929
#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 已提交
1930
#define tcg_gen_brcond_tl tcg_gen_brcond_i32
P
pbrook 已提交
1931
#define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
1932 1933
#define tcg_gen_mul_tl tcg_gen_mul_i32
#define tcg_gen_muli_tl tcg_gen_muli_i32
B
blueswir1 已提交
1934
#define tcg_gen_discard_tl tcg_gen_discard_i32
1935 1936 1937 1938 1939 1940
#define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
#define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
#define tcg_gen_extu_i32_tl tcg_gen_mov_i32
#define tcg_gen_ext_i32_tl tcg_gen_mov_i32
#define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
#define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
B
bellard 已提交
1941 1942 1943 1944 1945 1946
#define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
#define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
#define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
#define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
#define tcg_gen_ext32u_tl tcg_gen_mov_i32
#define tcg_gen_ext32s_tl tcg_gen_mov_i32
1947
#define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
1948 1949 1950 1951 1952
#define tcg_gen_andc_tl tcg_gen_andc_i32
#define tcg_gen_eqv_tl tcg_gen_eqv_i32
#define tcg_gen_nand_tl tcg_gen_nand_i32
#define tcg_gen_nor_tl tcg_gen_nor_i32
#define tcg_gen_orc_tl tcg_gen_orc_i32
1953 1954 1955 1956
#define tcg_gen_rotl_tl tcg_gen_rotl_i32
#define tcg_gen_rotli_tl tcg_gen_rotli_i32
#define tcg_gen_rotr_tl tcg_gen_rotr_i32
#define tcg_gen_rotri_tl tcg_gen_rotri_i32
B
blueswir1 已提交
1957
#define tcg_const_tl tcg_const_i32
A
aurel32 已提交
1958
#define tcg_const_local_tl tcg_const_local_i32
1959
#endif
P
pbrook 已提交
1960 1961

#if TCG_TARGET_REG_BITS == 32
1962
#define tcg_gen_add_ptr tcg_gen_add_i32
P
pbrook 已提交
1963
#define tcg_gen_addi_ptr tcg_gen_addi_i32
1964
#define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
P
pbrook 已提交
1965
#else /* TCG_TARGET_REG_BITS == 32 */
1966
#define tcg_gen_add_ptr tcg_gen_add_i64
P
pbrook 已提交
1967
#define tcg_gen_addi_ptr tcg_gen_addi_i64
1968
#define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
P
pbrook 已提交
1969 1970
#endif /* TCG_TARGET_REG_BITS != 32 */