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

int gen_new_label(void);

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

static inline void tcg_gen_op1_i64(int opc, TCGv_i64 arg1)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
B
bellard 已提交
38 39
}

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

P
pbrook 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
static inline void tcg_gen_op2_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
}

static inline void tcg_gen_op2_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
}

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

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

P
pbrook 已提交
74 75 76 77 78 79 80
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 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
static inline void tcg_gen_op3_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2,
                                   TCGv_i32 arg3)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
}

static inline void tcg_gen_op3_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2,
                                   TCGv_i64 arg3)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
}

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

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

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

static inline void tcg_gen_ldst_op_i64(int opc, TCGv_i64 val, TCGv_ptr base,
                                       TCGArg offset)
{
    *gen_opc_ptr++ = opc;
B
blueswir1 已提交
130
    *gen_opparam_ptr++ = GET_TCGV_I64(val);
P
pbrook 已提交
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
    *gen_opparam_ptr++ = GET_TCGV_PTR(base);
    *gen_opparam_ptr++ = offset;
}

static inline void tcg_gen_qemu_ldst_op_i64_i32(int opc, TCGv_i64 val, TCGv_i32 addr,
                                                TCGArg mem_index)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(val);
    *gen_opparam_ptr++ = GET_TCGV_I32(addr);
    *gen_opparam_ptr++ = mem_index;
}

static inline void tcg_gen_qemu_ldst_op_i64_i64(int opc, TCGv_i64 val, TCGv_i64 addr,
                                                TCGArg mem_index)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(val);
    *gen_opparam_ptr++ = GET_TCGV_I64(addr);
    *gen_opparam_ptr++ = mem_index;
}

static inline void tcg_gen_op4_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2,
                                   TCGv_i32 arg3, TCGv_i32 arg4)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
}

static inline void tcg_gen_op4_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2,
B
blueswir1 已提交
164
                                   TCGv_i64 arg3, TCGv_i64 arg4)
P
pbrook 已提交
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
}

static inline void tcg_gen_op4i_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2,
                                    TCGv_i32 arg3, TCGArg arg4)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = arg4;
}

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

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

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

P
pbrook 已提交
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
static inline void tcg_gen_op5_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2,
                                   TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg5);
}

static inline void tcg_gen_op5_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2,
                                   TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg5);
}

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

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

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

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

P
pbrook 已提交
283 284 285
static inline void tcg_gen_op6ii_i32(int opc, TCGv_i32 arg1, TCGv_i32 arg2,
                                     TCGv_i32 arg3, TCGv_i32 arg4, TCGArg arg5,
                                     TCGArg arg6)
P
pbrook 已提交
286 287
{
    *gen_opc_ptr++ = opc;
P
pbrook 已提交
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
    *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
    *gen_opparam_ptr++ = arg5;
    *gen_opparam_ptr++ = arg6;
}

static inline void tcg_gen_op6ii_i64(int opc, TCGv_i64 arg1, TCGv_i64 arg2,
                                     TCGv_i64 arg3, TCGv_i64 arg4, TCGArg arg5,
                                     TCGArg arg6)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
B
bellard 已提交
305 306 307 308 309 310
    *gen_opparam_ptr++ = arg5;
    *gen_opparam_ptr++ = arg6;
}

static inline void gen_set_label(int n)
{
P
pbrook 已提交
311
    tcg_gen_op1i(INDEX_op_set_label, n);
B
bellard 已提交
312 313
}

B
blueswir1 已提交
314 315 316 317 318
static inline void tcg_gen_br(int label)
{
    tcg_gen_op1i(INDEX_op_br, label);
}

P
pbrook 已提交
319
static inline void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
320
{
P
pbrook 已提交
321 322
    if (GET_TCGV_I32(ret) != GET_TCGV_I32(arg))
        tcg_gen_op2_i32(INDEX_op_mov_i32, ret, arg);
B
bellard 已提交
323 324
}

P
pbrook 已提交
325
static inline void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg)
B
bellard 已提交
326
{
P
pbrook 已提交
327
    tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg);
B
bellard 已提交
328 329 330
}

/* helper calls */
P
pbrook 已提交
331 332 333 334 335 336 337 338 339
static inline void tcg_gen_helperN(void *func, int flags, int sizemask,
                                   TCGArg ret, int nargs, TCGArg *args)
{
    TCGv_ptr fn;
    fn = tcg_const_ptr((tcg_target_long)func);
    tcg_gen_callN(&tcg_ctx, fn, flags, sizemask, ret,
                  nargs, args);
    tcg_temp_free_ptr(fn);
}
B
bellard 已提交
340

P
pbrook 已提交
341 342 343
/* FIXME: Should this be pure?  */
static inline void tcg_gen_helper64(void *func, TCGv_i64 ret,
                                    TCGv_i64 a, TCGv_i64 b)
B
bellard 已提交
344
{
P
pbrook 已提交
345 346 347 348 349 350 351
    TCGv_ptr fn;
    TCGArg args[2];
    fn = tcg_const_ptr((tcg_target_long)func);
    args[0] = GET_TCGV_I64(a);
    args[1] = GET_TCGV_I64(b);
    tcg_gen_callN(&tcg_ctx, fn, 0, 7, GET_TCGV_I64(ret), 2, args);
    tcg_temp_free_ptr(fn);
352 353
}

B
bellard 已提交
354 355
/* 32 bit ops */

P
pbrook 已提交
356
static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
357
{
P
pbrook 已提交
358
    tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32, ret, arg2, offset);
B
bellard 已提交
359 360
}

P
pbrook 已提交
361
static inline void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
362
{
P
pbrook 已提交
363
    tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32, ret, arg2, offset);
B
bellard 已提交
364 365
}

P
pbrook 已提交
366
static inline void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
367
{
P
pbrook 已提交
368
    tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32, ret, arg2, offset);
B
bellard 已提交
369 370
}

P
pbrook 已提交
371
static inline void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
372
{
P
pbrook 已提交
373
    tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32, ret, arg2, offset);
B
bellard 已提交
374 375
}

P
pbrook 已提交
376
static inline void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
377
{
P
pbrook 已提交
378
    tcg_gen_ldst_op_i32(INDEX_op_ld_i32, ret, arg2, offset);
B
bellard 已提交
379 380
}

P
pbrook 已提交
381
static inline void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
382
{
P
pbrook 已提交
383
    tcg_gen_ldst_op_i32(INDEX_op_st8_i32, arg1, arg2, offset);
B
bellard 已提交
384 385
}

P
pbrook 已提交
386
static inline void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
387
{
P
pbrook 已提交
388
    tcg_gen_ldst_op_i32(INDEX_op_st16_i32, arg1, arg2, offset);
B
bellard 已提交
389 390
}

P
pbrook 已提交
391
static inline void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
B
bellard 已提交
392
{
P
pbrook 已提交
393
    tcg_gen_ldst_op_i32(INDEX_op_st_i32, arg1, arg2, offset);
B
bellard 已提交
394 395
}

P
pbrook 已提交
396
static inline void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
397
{
P
pbrook 已提交
398
    tcg_gen_op3_i32(INDEX_op_add_i32, ret, arg1, arg2);
B
bellard 已提交
399 400
}

P
pbrook 已提交
401
static inline void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
402
{
403 404 405 406
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
407
        TCGv_i32 t0 = tcg_const_i32(arg2);
408
        tcg_gen_add_i32(ret, arg1, t0);
P
pbrook 已提交
409
        tcg_temp_free_i32(t0);
410
    }
B
bellard 已提交
411 412
}

P
pbrook 已提交
413
static inline void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
414
{
P
pbrook 已提交
415
    tcg_gen_op3_i32(INDEX_op_sub_i32, ret, arg1, arg2);
B
bellard 已提交
416 417
}

P
pbrook 已提交
418
static inline void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2)
A
aurel32 已提交
419
{
P
pbrook 已提交
420
    TCGv_i32 t0 = tcg_const_i32(arg1);
A
aurel32 已提交
421
    tcg_gen_sub_i32(ret, t0, arg2);
P
pbrook 已提交
422
    tcg_temp_free_i32(t0);
A
aurel32 已提交
423 424
}

P
pbrook 已提交
425
static inline void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
426
{
427 428 429 430
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
431
        TCGv_i32 t0 = tcg_const_i32(arg2);
432
        tcg_gen_sub_i32(ret, arg1, t0);
P
pbrook 已提交
433
        tcg_temp_free_i32(t0);
434
    }
B
bellard 已提交
435 436
}

P
pbrook 已提交
437
static inline void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
438
{
P
pbrook 已提交
439
    tcg_gen_op3_i32(INDEX_op_and_i32, ret, arg1, arg2);
B
bellard 已提交
440 441
}

P
pbrook 已提交
442
static inline void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
443 444 445 446 447 448 449
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_movi_i32(ret, 0);
    } else if (arg2 == 0xffffffff) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
450
        TCGv_i32 t0 = tcg_const_i32(arg2);
451
        tcg_gen_and_i32(ret, arg1, t0);
P
pbrook 已提交
452
        tcg_temp_free_i32(t0);
B
bellard 已提交
453 454 455
    }
}

P
pbrook 已提交
456
static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
457
{
P
pbrook 已提交
458
    tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2);
B
bellard 已提交
459 460
}

P
pbrook 已提交
461
static inline void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
462 463 464
{
    /* some cases can be optimized here */
    if (arg2 == 0xffffffff) {
465
        tcg_gen_movi_i32(ret, 0xffffffff);
B
bellard 已提交
466 467 468
    } else if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
469
        TCGv_i32 t0 = tcg_const_i32(arg2);
470
        tcg_gen_or_i32(ret, arg1, t0);
P
pbrook 已提交
471
        tcg_temp_free_i32(t0);
B
bellard 已提交
472 473 474
    }
}

P
pbrook 已提交
475
static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
476
{
P
pbrook 已提交
477
    tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2);
B
bellard 已提交
478 479
}

P
pbrook 已提交
480
static inline void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
481 482 483 484 485
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
486
        TCGv_i32 t0 = tcg_const_i32(arg2);
487
        tcg_gen_xor_i32(ret, arg1, t0);
P
pbrook 已提交
488
        tcg_temp_free_i32(t0);
B
bellard 已提交
489 490 491
    }
}

P
pbrook 已提交
492
static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
493
{
P
pbrook 已提交
494
    tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2);
B
bellard 已提交
495 496
}

P
pbrook 已提交
497
static inline void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
498
{
B
bellard 已提交
499 500 501
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
502
        TCGv_i32 t0 = tcg_const_i32(arg2);
503
        tcg_gen_shl_i32(ret, arg1, t0);
P
pbrook 已提交
504
        tcg_temp_free_i32(t0);
B
bellard 已提交
505
    }
B
bellard 已提交
506 507
}

P
pbrook 已提交
508
static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
509
{
P
pbrook 已提交
510
    tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2);
B
bellard 已提交
511 512
}

P
pbrook 已提交
513
static inline void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
514
{
B
bellard 已提交
515 516 517
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
518
        TCGv_i32 t0 = tcg_const_i32(arg2);
519
        tcg_gen_shr_i32(ret, arg1, t0);
P
pbrook 已提交
520
        tcg_temp_free_i32(t0);
B
bellard 已提交
521
    }
B
bellard 已提交
522 523
}

P
pbrook 已提交
524
static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
525
{
P
pbrook 已提交
526
    tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2);
B
bellard 已提交
527 528
}

P
pbrook 已提交
529
static inline void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
B
bellard 已提交
530
{
B
bellard 已提交
531 532 533
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
P
pbrook 已提交
534
        TCGv_i32 t0 = tcg_const_i32(arg2);
535
        tcg_gen_sar_i32(ret, arg1, t0);
P
pbrook 已提交
536
        tcg_temp_free_i32(t0);
B
bellard 已提交
537
    }
B
bellard 已提交
538 539
}

P
pbrook 已提交
540
static inline void tcg_gen_brcond_i32(int cond, TCGv_i32 arg1, TCGv_i32 arg2,
B
bellard 已提交
541 542
                                      int label_index)
{
P
pbrook 已提交
543
    tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
B
bellard 已提交
544 545
}

P
pbrook 已提交
546
static inline void tcg_gen_brcondi_i32(int cond, TCGv_i32 arg1, int32_t arg2,
P
pbrook 已提交
547 548
                                       int label_index)
{
P
pbrook 已提交
549
    TCGv_i32 t0 = tcg_const_i32(arg2);
P
pbrook 已提交
550
    tcg_gen_brcond_i32(cond, arg1, t0, label_index);
P
pbrook 已提交
551
    tcg_temp_free_i32(t0);
P
pbrook 已提交
552 553
}

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

P
pbrook 已提交
559
static inline void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
560
{
P
pbrook 已提交
561
    TCGv_i32 t0 = tcg_const_i32(arg2);
562
    tcg_gen_mul_i32(ret, arg1, t0);
P
pbrook 已提交
563
    tcg_temp_free_i32(t0);
564 565
}

B
bellard 已提交
566
#ifdef TCG_TARGET_HAS_div_i32
P
pbrook 已提交
567
static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
568
{
P
pbrook 已提交
569
    tcg_gen_op3_i32(INDEX_op_div_i32, ret, arg1, arg2);
B
bellard 已提交
570 571
}

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

P
pbrook 已提交
577
static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
578
{
P
pbrook 已提交
579
    tcg_gen_op3_i32(INDEX_op_divu_i32, ret, arg1, arg2);
B
bellard 已提交
580 581
}

P
pbrook 已提交
582
static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
583
{
P
pbrook 已提交
584
    tcg_gen_op3_i32(INDEX_op_remu_i32, ret, arg1, arg2);
B
bellard 已提交
585 586
}
#else
P
pbrook 已提交
587
static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
588
{
P
pbrook 已提交
589 590
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
591
    tcg_gen_sari_i32(t0, arg1, 31);
P
pbrook 已提交
592 593
    tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
594 595
}

P
pbrook 已提交
596
static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
597
{
P
pbrook 已提交
598 599
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
600
    tcg_gen_sari_i32(t0, arg1, 31);
P
pbrook 已提交
601 602
    tcg_gen_op5_i32(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
603 604
}

P
pbrook 已提交
605
static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
606
{
P
pbrook 已提交
607 608
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
609
    tcg_gen_movi_i32(t0, 0);
P
pbrook 已提交
610 611
    tcg_gen_op5_i32(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
612 613
}

P
pbrook 已提交
614
static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
B
bellard 已提交
615
{
P
pbrook 已提交
616 617
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
B
bellard 已提交
618
    tcg_gen_movi_i32(t0, 0);
P
pbrook 已提交
619 620
    tcg_gen_op5_i32(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i32(t0);
B
bellard 已提交
621 622 623 624 625
}
#endif

#if TCG_TARGET_REG_BITS == 32

P
pbrook 已提交
626
static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
627
{
P
pbrook 已提交
628 629
    if (GET_TCGV_I64(ret) != GET_TCGV_I64(arg)) {
        tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
630 631
        tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
    }
B
bellard 已提交
632 633
}

P
pbrook 已提交
634
static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
B
bellard 已提交
635
{
P
pbrook 已提交
636
    tcg_gen_movi_i32(TCGV_LOW(ret), arg);
P
pbrook 已提交
637
    tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
B
bellard 已提交
638 639
}

P
pbrook 已提交
640 641
static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
642
{
P
pbrook 已提交
643
    tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
644
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
645 646
}

P
pbrook 已提交
647 648
static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
649
{
P
pbrook 已提交
650 651
    tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), 31);
B
bellard 已提交
652 653
}

P
pbrook 已提交
654 655
static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
656
{
A
aurel32 已提交
657
    tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
658
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
659 660
}

P
pbrook 已提交
661 662
static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
663
{
P
pbrook 已提交
664 665
    tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
666 667
}

P
pbrook 已提交
668 669
static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
670
{
P
pbrook 已提交
671
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
672
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
673 674
}

P
pbrook 已提交
675 676
static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                     tcg_target_long offset)
B
bellard 已提交
677
{
P
pbrook 已提交
678 679
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
680 681
}

P
pbrook 已提交
682 683
static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2,
                                  tcg_target_long offset)
B
bellard 已提交
684 685 686 687
{
    /* since arg2 and ret have different types, they cannot be the
       same temporary */
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
688
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
P
pbrook 已提交
689
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4);
B
bellard 已提交
690
#else
P
pbrook 已提交
691
    tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
P
pbrook 已提交
692
    tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
B
bellard 已提交
693 694 695
#endif
}

P
pbrook 已提交
696 697
static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                   tcg_target_long offset)
B
bellard 已提交
698
{
P
pbrook 已提交
699
    tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset);
B
bellard 已提交
700 701
}

P
pbrook 已提交
702 703
static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
704
{
P
pbrook 已提交
705
    tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset);
B
bellard 已提交
706 707
}

P
pbrook 已提交
708 709
static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                    tcg_target_long offset)
B
bellard 已提交
710
{
P
pbrook 已提交
711
    tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
B
bellard 已提交
712 713
}

P
pbrook 已提交
714 715
static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2,
                                  tcg_target_long offset)
B
bellard 已提交
716 717
{
#ifdef TCG_TARGET_WORDS_BIGENDIAN
P
pbrook 已提交
718
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
P
pbrook 已提交
719
    tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4);
B
bellard 已提交
720
#else
P
pbrook 已提交
721
    tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
P
pbrook 已提交
722
    tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
B
bellard 已提交
723 724 725
#endif
}

P
pbrook 已提交
726
static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
727
{
P
pbrook 已提交
728 729 730
    tcg_gen_op6_i32(INDEX_op_add2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
                    TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
                    TCGV_HIGH(arg2));
B
bellard 已提交
731 732
}

P
pbrook 已提交
733
static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
734
{
P
pbrook 已提交
735 736 737
    tcg_gen_op6_i32(INDEX_op_sub2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
                    TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
                    TCGV_HIGH(arg2));
B
bellard 已提交
738 739
}

P
pbrook 已提交
740
static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
741
{
P
pbrook 已提交
742
    tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
P
pbrook 已提交
743
    tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
744 745
}

P
pbrook 已提交
746
static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
747
{
P
pbrook 已提交
748
    tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
P
pbrook 已提交
749
    tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
750 751
}

P
pbrook 已提交
752
static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
753
{
P
pbrook 已提交
754
    tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
P
pbrook 已提交
755
    tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
756 757
}

P
pbrook 已提交
758
static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
759
{
P
pbrook 已提交
760
    tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
P
pbrook 已提交
761
    tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
762 763
}

P
pbrook 已提交
764
static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
765
{
P
pbrook 已提交
766
    tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
P
pbrook 已提交
767
    tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
B
bellard 已提交
768 769
}

P
pbrook 已提交
770
static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
771
{
P
pbrook 已提交
772
    tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
P
pbrook 已提交
773
    tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
B
bellard 已提交
774 775 776 777
}

/* XXX: use generic code when basic block handling is OK or CPU
   specific code (x86) */
P
pbrook 已提交
778
static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
779
{
P
pbrook 已提交
780
    tcg_gen_helper64(tcg_helper_shl_i64, ret, arg1, arg2);
B
bellard 已提交
781 782
}

P
pbrook 已提交
783
static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
784 785 786 787
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
}

P
pbrook 已提交
788
static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
789
{
P
pbrook 已提交
790
    tcg_gen_helper64(tcg_helper_shr_i64, ret, arg1, arg2);
B
bellard 已提交
791 792
}

P
pbrook 已提交
793
static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
794 795 796 797
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
}

P
pbrook 已提交
798
static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
799
{
P
pbrook 已提交
800
    tcg_gen_helper64(tcg_helper_sar_i64, ret, arg1, arg2);
B
bellard 已提交
801 802
}

P
pbrook 已提交
803
static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
804 805 806 807
{
    tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
}

P
pbrook 已提交
808
static inline void tcg_gen_brcond_i64(int cond, TCGv_i64 arg1, TCGv_i64 arg2,
B
bellard 已提交
809 810
                                      int label_index)
{
P
pbrook 已提交
811 812 813
    tcg_gen_op6ii_i32(INDEX_op_brcond2_i32,
                      TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
                      TCGV_HIGH(arg2), cond, label_index);
B
bellard 已提交
814 815
}

P
pbrook 已提交
816
static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
817
{
P
pbrook 已提交
818 819
    TCGv_i64 t0;
    TCGv_i32 t1;
B
bellard 已提交
820

P
pbrook 已提交
821 822 823 824 825 826 827
    t0 = tcg_temp_new_i64();
    t1 = tcg_temp_new_i32();

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

    tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2));
P
pbrook 已提交
828
    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
P
pbrook 已提交
829
    tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2));
P
pbrook 已提交
830
    tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
P
pbrook 已提交
831

B
bellard 已提交
832
    tcg_gen_mov_i64(ret, t0);
P
pbrook 已提交
833 834
    tcg_temp_free_i64(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
835 836
}

P
pbrook 已提交
837
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
838
{
P
pbrook 已提交
839
    tcg_gen_helper64(tcg_helper_div_i64, ret, arg1, arg2);
B
bellard 已提交
840 841
}

P
pbrook 已提交
842
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
843
{
P
pbrook 已提交
844
    tcg_gen_helper64(tcg_helper_rem_i64, ret, arg1, arg2);
B
bellard 已提交
845 846
}

P
pbrook 已提交
847
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
848
{
P
pbrook 已提交
849
    tcg_gen_helper64(tcg_helper_divu_i64, ret, arg1, arg2);
B
bellard 已提交
850 851
}

P
pbrook 已提交
852
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
853
{
P
pbrook 已提交
854
    tcg_gen_helper64(tcg_helper_remu_i64, ret, arg1, arg2);
B
bellard 已提交
855 856 857 858
}

#else

P
pbrook 已提交
859
static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
860
{
P
pbrook 已提交
861 862
    if (GET_TCGV_I64(ret) != GET_TCGV_I64(arg))
        tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg);
B
bellard 已提交
863 864
}

P
pbrook 已提交
865
static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
B
bellard 已提交
866
{
P
pbrook 已提交
867
    tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg);
B
bellard 已提交
868 869
}

P
pbrook 已提交
870
static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
871
                                    tcg_target_long offset)
B
bellard 已提交
872
{
P
pbrook 已提交
873
    tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset);
B
bellard 已提交
874 875
}

P
pbrook 已提交
876
static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
877
                                    tcg_target_long offset)
B
bellard 已提交
878
{
P
pbrook 已提交
879
    tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset);
B
bellard 已提交
880 881
}

P
pbrook 已提交
882
static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
883
                                     tcg_target_long offset)
B
bellard 已提交
884
{
P
pbrook 已提交
885
    tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset);
B
bellard 已提交
886 887
}

P
pbrook 已提交
888
static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
889
                                     tcg_target_long offset)
B
bellard 已提交
890
{
P
pbrook 已提交
891
    tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset);
B
bellard 已提交
892 893
}

P
pbrook 已提交
894
static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
895
                                     tcg_target_long offset)
B
bellard 已提交
896
{
P
pbrook 已提交
897
    tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset);
B
bellard 已提交
898 899
}

P
pbrook 已提交
900
static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_i64 arg2,
P
pbrook 已提交
901
                                     tcg_target_long offset)
B
bellard 已提交
902
{
P
pbrook 已提交
903
    tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset);
B
bellard 已提交
904 905
}

P
pbrook 已提交
906
static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_i64 arg2, tcg_target_long offset)
B
bellard 已提交
907
{
P
pbrook 已提交
908
    tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset);
B
bellard 已提交
909 910
}

P
pbrook 已提交
911
static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
912
                                   tcg_target_long offset)
B
bellard 已提交
913
{
P
pbrook 已提交
914
    tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset);
B
bellard 已提交
915 916
}

P
pbrook 已提交
917
static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
918
                                    tcg_target_long offset)
B
bellard 已提交
919
{
P
pbrook 已提交
920
    tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset);
B
bellard 已提交
921 922
}

P
pbrook 已提交
923
static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_i64 arg2,
P
pbrook 已提交
924
                                    tcg_target_long offset)
B
bellard 已提交
925
{
P
pbrook 已提交
926
    tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset);
B
bellard 已提交
927 928
}

P
pbrook 已提交
929
static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_i64 arg2, tcg_target_long offset)
B
bellard 已提交
930
{
P
pbrook 已提交
931
    tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset);
B
bellard 已提交
932 933
}

P
pbrook 已提交
934
static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
935
{
P
pbrook 已提交
936
    tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2);
B
bellard 已提交
937 938
}

P
pbrook 已提交
939
static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
940
{
P
pbrook 已提交
941
    tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2);
B
bellard 已提交
942 943
}

P
pbrook 已提交
944
static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
945
{
P
pbrook 已提交
946
    tcg_gen_op3_i64(INDEX_op_and_i64, ret, arg1, arg2);
B
bellard 已提交
947 948
}

P
pbrook 已提交
949
static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
950
{
P
pbrook 已提交
951
    TCGv_i64 t0 = tcg_const_i64(arg2);
952
    tcg_gen_and_i64(ret, arg1, t0);
P
pbrook 已提交
953
    tcg_temp_free_i64(t0);
B
bellard 已提交
954 955
}

P
pbrook 已提交
956
static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
957
{
P
pbrook 已提交
958
    tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2);
B
bellard 已提交
959 960
}

P
pbrook 已提交
961
static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
962
{
P
pbrook 已提交
963
    TCGv_i64 t0 = tcg_const_i64(arg2);
964
    tcg_gen_or_i64(ret, arg1, t0);
P
pbrook 已提交
965
    tcg_temp_free_i64(t0);
B
bellard 已提交
966 967
}

P
pbrook 已提交
968
static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
969
{
P
pbrook 已提交
970
    tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2);
B
bellard 已提交
971 972
}

P
pbrook 已提交
973
static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
974
{
P
pbrook 已提交
975
    TCGv_i64 t0 = tcg_const_i64(arg2);
976
    tcg_gen_xor_i64(ret, arg1, t0);
P
pbrook 已提交
977
    tcg_temp_free_i64(t0);
B
bellard 已提交
978 979
}

P
pbrook 已提交
980
static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
981
{
P
pbrook 已提交
982
    tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2);
B
bellard 已提交
983 984
}

P
pbrook 已提交
985
static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
986
{
B
bellard 已提交
987 988 989
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
990
        TCGv_i64 t0 = tcg_const_i64(arg2);
991
        tcg_gen_shl_i64(ret, arg1, t0);
P
pbrook 已提交
992
        tcg_temp_free_i64(t0);
B
bellard 已提交
993
    }
B
bellard 已提交
994 995
}

P
pbrook 已提交
996
static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
997
{
P
pbrook 已提交
998
    tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2);
B
bellard 已提交
999 1000
}

P
pbrook 已提交
1001
static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1002
{
B
bellard 已提交
1003 1004 1005
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1006
        TCGv_i64 t0 = tcg_const_i64(arg2);
1007
        tcg_gen_shr_i64(ret, arg1, t0);
P
pbrook 已提交
1008
        tcg_temp_free_i64(t0);
B
bellard 已提交
1009
    }
B
bellard 已提交
1010 1011
}

P
pbrook 已提交
1012
static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1013
{
P
pbrook 已提交
1014
    tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2);
B
bellard 已提交
1015 1016
}

P
pbrook 已提交
1017
static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
B
bellard 已提交
1018
{
B
bellard 已提交
1019 1020 1021
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1022
        TCGv_i64 t0 = tcg_const_i64(arg2);
1023
        tcg_gen_sar_i64(ret, arg1, t0);
P
pbrook 已提交
1024
        tcg_temp_free_i64(t0);
B
bellard 已提交
1025
    }
B
bellard 已提交
1026 1027
}

P
pbrook 已提交
1028
static inline void tcg_gen_brcond_i64(int cond, TCGv_i64 arg1, TCGv_i64 arg2,
B
bellard 已提交
1029 1030
                                      int label_index)
{
P
pbrook 已提交
1031
    tcg_gen_op4ii_i64(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
B
bellard 已提交
1032 1033
}

P
pbrook 已提交
1034
static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1035
{
P
pbrook 已提交
1036
    tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2);
B
bellard 已提交
1037 1038 1039
}

#ifdef TCG_TARGET_HAS_div_i64
P
pbrook 已提交
1040
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1041
{
P
pbrook 已提交
1042
    tcg_gen_op3_i64(INDEX_op_div_i64, ret, arg1, arg2);
B
bellard 已提交
1043 1044
}

P
pbrook 已提交
1045
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1046
{
P
pbrook 已提交
1047
    tcg_gen_op3_i64(INDEX_op_rem_i64, ret, arg1, arg2);
B
bellard 已提交
1048 1049
}

P
pbrook 已提交
1050
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1051
{
P
pbrook 已提交
1052
    tcg_gen_op3_i64(INDEX_op_divu_i64, ret, arg1, arg2);
B
bellard 已提交
1053 1054
}

P
pbrook 已提交
1055
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1056
{
P
pbrook 已提交
1057
    tcg_gen_op3_i64(INDEX_op_remu_i64, ret, arg1, arg2);
B
bellard 已提交
1058 1059
}
#else
P
pbrook 已提交
1060
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1061
{
P
pbrook 已提交
1062 1063
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1064
    tcg_gen_sari_i64(t0, arg1, 63);
P
pbrook 已提交
1065 1066
    tcg_gen_op5_i64(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1067 1068
}

P
pbrook 已提交
1069
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1070
{
P
pbrook 已提交
1071 1072
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1073
    tcg_gen_sari_i64(t0, arg1, 63);
P
pbrook 已提交
1074 1075
    tcg_gen_op5_i64(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1076 1077
}

P
pbrook 已提交
1078
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1079
{
P
pbrook 已提交
1080 1081
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1082
    tcg_gen_movi_i64(t0, 0);
P
pbrook 已提交
1083 1084
    tcg_gen_op5_i64(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1085 1086
}

P
pbrook 已提交
1087
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
B
bellard 已提交
1088
{
P
pbrook 已提交
1089 1090
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
B
bellard 已提交
1091
    tcg_gen_movi_i64(t0, 0);
P
pbrook 已提交
1092 1093
    tcg_gen_op5_i64(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
    tcg_temp_free_i64(t0);
B
bellard 已提交
1094 1095 1096 1097 1098
}
#endif

#endif

P
pbrook 已提交
1099
static inline void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1100 1101 1102 1103 1104
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1105
        TCGv_i64 t0 = tcg_const_i64(arg2);
1106
        tcg_gen_add_i64(ret, arg1, t0);
P
pbrook 已提交
1107
        tcg_temp_free_i64(t0);
1108 1109 1110
    }
}

P
pbrook 已提交
1111
static inline void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2)
A
aurel32 已提交
1112
{
P
pbrook 已提交
1113
    TCGv_i64 t0 = tcg_const_i64(arg1);
A
aurel32 已提交
1114
    tcg_gen_sub_i64(ret, t0, arg2);
P
pbrook 已提交
1115
    tcg_temp_free_i64(t0);
A
aurel32 已提交
1116 1117
}

P
pbrook 已提交
1118
static inline void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1119 1120 1121 1122 1123
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
P
pbrook 已提交
1124
        TCGv_i64 t0 = tcg_const_i64(arg2);
1125
        tcg_gen_sub_i64(ret, arg1, t0);
P
pbrook 已提交
1126
        tcg_temp_free_i64(t0);
1127 1128
    }
}
P
pbrook 已提交
1129
static inline void tcg_gen_brcondi_i64(int cond, TCGv_i64 arg1, int64_t arg2,
1130 1131
                                       int label_index)
{
P
pbrook 已提交
1132
    TCGv_i64 t0 = tcg_const_i64(arg2);
1133
    tcg_gen_brcond_i64(cond, arg1, t0, label_index);
P
pbrook 已提交
1134
    tcg_temp_free_i64(t0);
1135 1136
}

P
pbrook 已提交
1137
static inline void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1138
{
P
pbrook 已提交
1139
    TCGv_i64 t0 = tcg_const_i64(arg2);
1140
    tcg_gen_mul_i64(ret, arg1, t0);
P
pbrook 已提交
1141
    tcg_temp_free_i64(t0);
1142 1143
}

1144

B
bellard 已提交
1145 1146 1147
/***************************************/
/* optional operations */

P
pbrook 已提交
1148
static inline void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1149 1150
{
#ifdef TCG_TARGET_HAS_ext8s_i32
P
pbrook 已提交
1151
    tcg_gen_op2_i32(INDEX_op_ext8s_i32, ret, arg);
B
bellard 已提交
1152 1153
#else
    tcg_gen_shli_i32(ret, arg, 24);
1154
    tcg_gen_sari_i32(ret, ret, 24);
B
bellard 已提交
1155 1156 1157
#endif
}

P
pbrook 已提交
1158
static inline void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1159 1160
{
#ifdef TCG_TARGET_HAS_ext16s_i32
P
pbrook 已提交
1161
    tcg_gen_op2_i32(INDEX_op_ext16s_i32, ret, arg);
B
bellard 已提交
1162 1163
#else
    tcg_gen_shli_i32(ret, arg, 16);
1164
    tcg_gen_sari_i32(ret, ret, 16);
B
bellard 已提交
1165 1166 1167
#endif
}

P
pbrook 已提交
1168 1169
/* These are currently just for convenience.
   We assume a target will recognise these automatically .  */
P
pbrook 已提交
1170
static inline void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg)
P
pbrook 已提交
1171 1172 1173 1174
{
    tcg_gen_andi_i32(ret, arg, 0xffu);
}

P
pbrook 已提交
1175
static inline void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg)
P
pbrook 已提交
1176 1177 1178 1179
{
    tcg_gen_andi_i32(ret, arg, 0xffffu);
}

B
bellard 已提交
1180
/* Note: we assume the two high bytes are set to zero */
P
pbrook 已提交
1181
static inline void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1182 1183
{
#ifdef TCG_TARGET_HAS_bswap16_i32
P
pbrook 已提交
1184
    tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg);
B
bellard 已提交
1185
#else
P
pbrook 已提交
1186 1187 1188
    TCGv_i32 t0, t1;
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
B
bellard 已提交
1189 1190 1191 1192 1193
    
    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);
P
pbrook 已提交
1194 1195
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
1196 1197 1198
#endif
}

P
pbrook 已提交
1199
static inline void tcg_gen_bswap_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1200 1201
{
#ifdef TCG_TARGET_HAS_bswap_i32
P
pbrook 已提交
1202
    tcg_gen_op2_i32(INDEX_op_bswap_i32, ret, arg);
B
bellard 已提交
1203
#else
P
pbrook 已提交
1204 1205 1206
    TCGv_i32 t0, t1;
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
B
bellard 已提交
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219
    
    tcg_gen_shli_i32(t0, arg, 24);
    
    tcg_gen_andi_i32(t1, arg, 0x0000ff00);
    tcg_gen_shli_i32(t1, t1, 8);
    tcg_gen_or_i32(t0, t0, t1);
    
    tcg_gen_shri_i32(t1, arg, 8);
    tcg_gen_andi_i32(t1, t1, 0x0000ff00);
    tcg_gen_or_i32(t0, t0, t1);
    
    tcg_gen_shri_i32(t1, arg, 24);
    tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
1220 1221
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
1222 1223 1224 1225
#endif
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1226
static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1227
{
P
pbrook 已提交
1228 1229
    tcg_gen_ext8s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1230 1231
}

P
pbrook 已提交
1232
static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1233
{
P
pbrook 已提交
1234 1235
    tcg_gen_ext16s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1236 1237
}

P
pbrook 已提交
1238
static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1239
{
P
pbrook 已提交
1240 1241
    tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1242 1243
}

P
pbrook 已提交
1244
static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1245
{
P
pbrook 已提交
1246
    tcg_gen_ext8u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
P
pbrook 已提交
1247 1248 1249
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
1250
static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1251
{
P
pbrook 已提交
1252
    tcg_gen_ext16u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
P
pbrook 已提交
1253 1254 1255
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
1256
static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1257
{
P
pbrook 已提交
1258
    tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
P
pbrook 已提交
1259 1260 1261
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
}

P
pbrook 已提交
1262
static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
B
bellard 已提交
1263
{
P
pbrook 已提交
1264
    tcg_gen_mov_i32(ret, TCGV_LOW(arg));
B
bellard 已提交
1265 1266
}

P
pbrook 已提交
1267
static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
B
bellard 已提交
1268
{
P
pbrook 已提交
1269
    tcg_gen_mov_i32(TCGV_LOW(ret), arg);
P
pbrook 已提交
1270
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1271 1272
}

P
pbrook 已提交
1273
static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
B
bellard 已提交
1274
{
P
pbrook 已提交
1275 1276
    tcg_gen_mov_i32(TCGV_LOW(ret), arg);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1277 1278
}

P
pbrook 已提交
1279
static inline void tcg_gen_bswap_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1280
{
P
pbrook 已提交
1281 1282 1283
    TCGv_i32 t0, t1;
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
B
bellard 已提交
1284

P
pbrook 已提交
1285
    tcg_gen_bswap_i32(t0, TCGV_LOW(arg));
P
pbrook 已提交
1286
    tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
P
pbrook 已提交
1287
    tcg_gen_mov_i32(TCGV_LOW(ret), t1);
P
pbrook 已提交
1288
    tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
P
pbrook 已提交
1289 1290
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
1291 1292 1293
}
#else

P
pbrook 已提交
1294
static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1295 1296
{
#ifdef TCG_TARGET_HAS_ext8s_i64
P
pbrook 已提交
1297
    tcg_gen_op2_i64(INDEX_op_ext8s_i64, ret, arg);
B
bellard 已提交
1298 1299
#else
    tcg_gen_shli_i64(ret, arg, 56);
1300
    tcg_gen_sari_i64(ret, ret, 56);
B
bellard 已提交
1301 1302 1303
#endif
}

P
pbrook 已提交
1304
static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1305 1306
{
#ifdef TCG_TARGET_HAS_ext16s_i64
P
pbrook 已提交
1307
    tcg_gen_op2_i64(INDEX_op_ext16s_i64, ret, arg);
B
bellard 已提交
1308 1309
#else
    tcg_gen_shli_i64(ret, arg, 48);
1310
    tcg_gen_sari_i64(ret, ret, 48);
B
bellard 已提交
1311 1312 1313
#endif
}

P
pbrook 已提交
1314
static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1315 1316
{
#ifdef TCG_TARGET_HAS_ext32s_i64
P
pbrook 已提交
1317
    tcg_gen_op2_i64(INDEX_op_ext32s_i64, ret, arg);
B
bellard 已提交
1318 1319
#else
    tcg_gen_shli_i64(ret, arg, 32);
1320
    tcg_gen_sari_i64(ret, ret, 32);
B
bellard 已提交
1321 1322 1323
#endif
}

P
pbrook 已提交
1324
static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1325 1326 1327 1328
{
    tcg_gen_andi_i64(ret, arg, 0xffu);
}

P
pbrook 已提交
1329
static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1330 1331 1332 1333
{
    tcg_gen_andi_i64(ret, arg, 0xffffu);
}

P
pbrook 已提交
1334
static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1335 1336 1337 1338
{
    tcg_gen_andi_i64(ret, arg, 0xffffffffu);
}

B
bellard 已提交
1339
/* Note: we assume the target supports move between 32 and 64 bit
P
pbrook 已提交
1340
   registers.  This will probably break MIPS64 targets.  */
P
pbrook 已提交
1341
static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
B
bellard 已提交
1342
{
P
pbrook 已提交
1343
    tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg)));
B
bellard 已提交
1344 1345 1346 1347
}

/* Note: we assume the target supports move between 32 and 64 bit
   registers */
P
pbrook 已提交
1348
static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
B
bellard 已提交
1349
{
P
pbrook 已提交
1350
    tcg_gen_andi_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)), 0xffffffffu);
B
bellard 已提交
1351 1352 1353 1354
}

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

P
pbrook 已提交
1360
static inline void tcg_gen_bswap_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1361 1362
{
#ifdef TCG_TARGET_HAS_bswap_i64
P
pbrook 已提交
1363
    tcg_gen_op2_i64(INDEX_op_bswap_i64, ret, arg);
B
bellard 已提交
1364
#else
P
pbrook 已提交
1365 1366 1367
    TCGv_i32 t0, t1;
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
B
bellard 已提交
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
    
    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);
P
pbrook 已提交
1397 1398
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
B
bellard 已提交
1399 1400 1401 1402 1403
#endif
}

#endif

P
pbrook 已提交
1404
static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg)
P
pbrook 已提交
1405 1406
{
#ifdef TCG_TARGET_HAS_neg_i32
P
pbrook 已提交
1407
    tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg);
P
pbrook 已提交
1408
#else
P
pbrook 已提交
1409
    TCGv_i32 t0 = tcg_const_i32(0);
1410
    tcg_gen_sub_i32(ret, t0, arg);
P
pbrook 已提交
1411
    tcg_temp_free_i32(t0);
P
pbrook 已提交
1412 1413 1414
#endif
}

P
pbrook 已提交
1415
static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg)
P
pbrook 已提交
1416 1417
{
#ifdef TCG_TARGET_HAS_neg_i64
P
pbrook 已提交
1418
    tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg);
P
pbrook 已提交
1419
#else
P
pbrook 已提交
1420
    TCGv_i64 t0 = tcg_const_i64(0);
1421
    tcg_gen_sub_i64(ret, t0, arg);
P
pbrook 已提交
1422
    tcg_temp_free_i64(t0);
P
pbrook 已提交
1423 1424 1425
#endif
}

P
pbrook 已提交
1426
static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg)
B
bellard 已提交
1427
{
1428
    tcg_gen_xori_i32(ret, arg, -1);
B
bellard 已提交
1429 1430
}

P
pbrook 已提交
1431
static inline void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg)
B
bellard 已提交
1432
{
1433
    tcg_gen_xori_i64(ret, arg, -1);
B
bellard 已提交
1434
}
1435

P
pbrook 已提交
1436
static inline void tcg_gen_discard_i32(TCGv_i32 arg)
1437
{
P
pbrook 已提交
1438
    tcg_gen_op1_i32(INDEX_op_discard, arg);
1439 1440 1441
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1442
static inline void tcg_gen_discard_i64(TCGv_i64 arg)
1443
{
P
pbrook 已提交
1444
    tcg_gen_discard_i32(TCGV_LOW(arg));
1445 1446 1447
    tcg_gen_discard_i32(TCGV_HIGH(arg));
}
#else
P
pbrook 已提交
1448
static inline void tcg_gen_discard_i64(TCGv_i64 arg)
1449
{
P
pbrook 已提交
1450
    tcg_gen_op1_i64(INDEX_op_discard, arg);
1451 1452 1453
}
#endif

P
pbrook 已提交
1454
static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high)
P
pbrook 已提交
1455 1456
{
#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1457
    tcg_gen_mov_i32(TCGV_LOW(dest), low);
P
pbrook 已提交
1458 1459
    tcg_gen_mov_i32(TCGV_HIGH(dest), high);
#else
P
pbrook 已提交
1460
    TCGv_i64 tmp = tcg_temp_new_i64();
P
pbrook 已提交
1461 1462 1463 1464 1465 1466
    /* This extension is only needed for type correctness.
       We may be able to do better given target specific information.  */
    tcg_gen_extu_i32_i64(tmp, high);
    tcg_gen_shli_i64(tmp, tmp, 32);
    tcg_gen_extu_i32_i64(dest, low);
    tcg_gen_or_i64(dest, dest, tmp);
P
pbrook 已提交
1467
    tcg_temp_free_i64(tmp);
P
pbrook 已提交
1468 1469 1470
#endif
}

P
pbrook 已提交
1471
static inline void tcg_gen_concat32_i64(TCGv_i64 dest, TCGv_i64 low, TCGv_i64 high)
1472 1473
{
#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1474
    tcg_gen_concat_i32_i64(dest, TCGV_LOW(low), TCGV_LOW(high));
1475
#else
P
pbrook 已提交
1476
    TCGv_i64 tmp = tcg_temp_new_i64();
1477
    tcg_gen_ext32u_i64(dest, low);
1478
    tcg_gen_shli_i64(tmp, high, 32);
1479
    tcg_gen_or_i64(dest, dest, tmp);
P
pbrook 已提交
1480
    tcg_temp_free_i64(tmp);
1481 1482 1483
#endif
}

P
pbrook 已提交
1484
static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1485
{
P
pbrook 已提交
1486 1487
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
1488 1489
    tcg_gen_not_i32(t0, arg2);
    tcg_gen_and_i32(ret, arg1, t0);
P
pbrook 已提交
1490
    tcg_temp_free_i32(t0);
1491 1492
}

P
pbrook 已提交
1493
static inline void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1494
{
P
pbrook 已提交
1495 1496
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
1497 1498
    tcg_gen_not_i64(t0, arg2);
    tcg_gen_and_i64(ret, arg1, t0);
P
pbrook 已提交
1499
    tcg_temp_free_i64(t0);
1500 1501
}

P
pbrook 已提交
1502
static inline void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1503
{
P
pbrook 已提交
1504 1505
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
1506 1507
    tcg_gen_xor_i32(t0, arg1, arg2);
    tcg_gen_not_i32(ret, t0);
P
pbrook 已提交
1508
    tcg_temp_free_i32(t0);
1509 1510
}

P
pbrook 已提交
1511
static inline void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1512
{
P
pbrook 已提交
1513 1514
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
1515 1516
    tcg_gen_xor_i64(t0, arg1, arg2);
    tcg_gen_not_i64(ret, t0);
P
pbrook 已提交
1517
    tcg_temp_free_i64(t0);
1518 1519
}

P
pbrook 已提交
1520
static inline void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1521
{
P
pbrook 已提交
1522 1523
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
1524 1525
    tcg_gen_and_i32(t0, arg1, arg2);
    tcg_gen_not_i32(ret, t0);
P
pbrook 已提交
1526
    tcg_temp_free_i32(t0);
1527 1528
}

P
pbrook 已提交
1529
static inline void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1530
{
P
pbrook 已提交
1531 1532
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
1533 1534
    tcg_gen_and_i64(t0, arg1, arg2);
    tcg_gen_not_i64(ret, t0);
P
pbrook 已提交
1535
    tcg_temp_free_i64(t0);
1536 1537
}

P
pbrook 已提交
1538
static inline void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1539
{
P
pbrook 已提交
1540 1541
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
1542 1543
    tcg_gen_or_i32(t0, arg1, arg2);
    tcg_gen_not_i32(ret, t0);
P
pbrook 已提交
1544
    tcg_temp_free_i32(t0);
1545 1546
}

P
pbrook 已提交
1547
static inline void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1548
{
P
pbrook 已提交
1549 1550
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
1551 1552
    tcg_gen_or_i64(t0, arg1, arg2);
    tcg_gen_not_i64(ret, t0);
P
pbrook 已提交
1553
    tcg_temp_free_i64(t0);
1554 1555
}

P
pbrook 已提交
1556
static inline void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1557
{
P
pbrook 已提交
1558 1559
    TCGv_i32 t0;
    t0 = tcg_temp_new_i32();
1560 1561
    tcg_gen_not_i32(t0, arg2);
    tcg_gen_or_i32(ret, arg1, t0);
P
pbrook 已提交
1562
    tcg_temp_free_i32(t0);
1563 1564
}

P
pbrook 已提交
1565
static inline void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1566
{
P
pbrook 已提交
1567 1568
    TCGv_i64 t0;
    t0 = tcg_temp_new_i64();
1569 1570
    tcg_gen_not_i64(t0, arg2);
    tcg_gen_or_i64(ret, arg1, t0);
P
pbrook 已提交
1571
    tcg_temp_free_i64(t0);
1572 1573
}

P
pbrook 已提交
1574
static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1575
{
A
aurel32 已提交
1576 1577 1578
#ifdef TCG_TARGET_HAS_rot_i32
    tcg_gen_op3_i32(INDEX_op_rotl_i32, ret, arg1, arg2);
#else
P
pbrook 已提交
1579
    TCGv_i32 t0, t1;
1580

P
pbrook 已提交
1581 1582
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
1583 1584 1585 1586
    tcg_gen_shl_i32(t0, arg1, arg2);
    tcg_gen_subfi_i32(t1, 32, arg2);
    tcg_gen_shr_i32(t1, arg1, t1);
    tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
1587 1588
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
A
aurel32 已提交
1589
#endif
1590 1591
}

P
pbrook 已提交
1592
static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1593
{
A
aurel32 已提交
1594 1595 1596
#ifdef TCG_TARGET_HAS_rot_i64
    tcg_gen_op3_i64(INDEX_op_rotl_i64, ret, arg1, arg2);
#else
P
pbrook 已提交
1597
    TCGv_i64 t0, t1;
1598

P
pbrook 已提交
1599 1600
    t0 = tcg_temp_new_i64();
    t1 = tcg_temp_new_i64();
1601 1602 1603 1604
    tcg_gen_shl_i64(t0, arg1, arg2);
    tcg_gen_subfi_i64(t1, 64, arg2);
    tcg_gen_shr_i64(t1, arg1, t1);
    tcg_gen_or_i64(ret, t0, t1);
P
pbrook 已提交
1605 1606
    tcg_temp_free_i64(t0);
    tcg_temp_free_i64(t1);
A
aurel32 已提交
1607
#endif
1608 1609
}

P
pbrook 已提交
1610
static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
1611 1612 1613 1614 1615
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
A
aurel32 已提交
1616 1617 1618 1619 1620
#ifdef TCG_TARGET_HAS_rot_i32
        TCGv_i32 t0 = tcg_const_i32(arg2);
        tcg_gen_rotl_i32(ret, arg1, t0);
        tcg_temp_free_i32(t0);
#else
P
pbrook 已提交
1621 1622 1623
        TCGv_i32 t0, t1;
        t0 = tcg_temp_new_i32();
        t1 = tcg_temp_new_i32();
1624 1625 1626
        tcg_gen_shli_i32(t0, arg1, arg2);
        tcg_gen_shri_i32(t1, arg1, 32 - arg2);
        tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
1627 1628
        tcg_temp_free_i32(t0);
        tcg_temp_free_i32(t1);
A
aurel32 已提交
1629
#endif
1630 1631 1632
    }
}

P
pbrook 已提交
1633
static inline void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1634 1635 1636 1637 1638
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i64(ret, arg1);
    } else {
A
aurel32 已提交
1639 1640 1641 1642 1643
#ifdef TCG_TARGET_HAS_rot_i64
        TCGv_i64 t0 = tcg_const_i64(arg2);
        tcg_gen_rotl_i64(ret, arg1, t0);
        tcg_temp_free_i64(t0);
#else
P
pbrook 已提交
1644 1645 1646
        TCGv_i64 t0, t1;
        t0 = tcg_temp_new_i64();
        t1 = tcg_temp_new_i64();
1647 1648 1649
        tcg_gen_shli_i64(t0, arg1, arg2);
        tcg_gen_shri_i64(t1, arg1, 64 - arg2);
        tcg_gen_or_i64(ret, t0, t1);
P
pbrook 已提交
1650 1651
        tcg_temp_free_i64(t0);
        tcg_temp_free_i64(t1);
A
aurel32 已提交
1652
#endif
1653 1654 1655
    }
}

P
pbrook 已提交
1656
static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
1657
{
A
aurel32 已提交
1658 1659 1660
#ifdef TCG_TARGET_HAS_rot_i32
    tcg_gen_op3_i32(INDEX_op_rotr_i32, ret, arg1, arg2);
#else
P
pbrook 已提交
1661
    TCGv_i32 t0, t1;
1662

P
pbrook 已提交
1663 1664
    t0 = tcg_temp_new_i32();
    t1 = tcg_temp_new_i32();
1665 1666 1667 1668
    tcg_gen_shr_i32(t0, arg1, arg2);
    tcg_gen_subfi_i32(t1, 32, arg2);
    tcg_gen_shl_i32(t1, arg1, t1);
    tcg_gen_or_i32(ret, t0, t1);
P
pbrook 已提交
1669 1670
    tcg_temp_free_i32(t0);
    tcg_temp_free_i32(t1);
A
aurel32 已提交
1671
#endif
1672 1673
}

P
pbrook 已提交
1674
static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1675
{
A
aurel32 已提交
1676 1677 1678
#ifdef TCG_TARGET_HAS_rot_i64
    tcg_gen_op3_i64(INDEX_op_rotr_i64, ret, arg1, arg2);
#else
P
pbrook 已提交
1679
    TCGv_i64 t0, t1;
1680

P
pbrook 已提交
1681 1682
    t0 = tcg_temp_new_i64();
    t1 = tcg_temp_new_i64();
1683 1684 1685 1686
    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);
P
pbrook 已提交
1687 1688
    tcg_temp_free_i64(t0);
    tcg_temp_free_i64(t1);
A
aurel32 已提交
1689
#endif
1690 1691
}

P
pbrook 已提交
1692
static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
1693 1694 1695 1696 1697 1698 1699 1700 1701
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
        tcg_gen_mov_i32(ret, arg1);
    } else {
        tcg_gen_rotli_i32(ret, arg1, 32 - arg2);
    }
}

P
pbrook 已提交
1702
static inline void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
1703 1704 1705
{
    /* some cases can be optimized here */
    if (arg2 == 0) {
P
pbrook 已提交
1706
        tcg_gen_mov_i64(ret, arg1);
1707 1708 1709 1710 1711
    } else {
        tcg_gen_rotli_i64(ret, arg1, 64 - arg2);
    }
}

B
bellard 已提交
1712 1713 1714 1715 1716 1717 1718
/***************************************/
/* QEMU specific operations. Their type depend on the QEMU CPU
   type. */
#ifndef TARGET_LONG_BITS
#error must include QEMU headers
#endif

P
pbrook 已提交
1719 1720 1721 1722 1723
#if TARGET_LONG_BITS == 32
#define TCGv TCGv_i32
#define tcg_temp_new() tcg_temp_new_i32()
#define tcg_global_reg_new tcg_global_reg_new_i32
#define tcg_global_mem_new tcg_global_mem_new_i32
1724
#define tcg_temp_local_new() tcg_temp_local_new_i32()
P
pbrook 已提交
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734
#define tcg_temp_free tcg_temp_free_i32
#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
#define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
#define TCGV_EQUAL(a, b) (GET_TCGV_I32(a) == GET_TCGV_I32(b))
#else
#define TCGv TCGv_i64
#define tcg_temp_new() tcg_temp_new_i64()
#define tcg_global_reg_new tcg_global_reg_new_i64
#define tcg_global_mem_new tcg_global_mem_new_i64
1735
#define tcg_temp_local_new() tcg_temp_local_new_i64()
P
pbrook 已提交
1736 1737 1738 1739 1740 1741 1742
#define tcg_temp_free tcg_temp_free_i64
#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
#define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
#define TCGV_EQUAL(a, b) (GET_TCGV_I64(a) == GET_TCGV_I64(b))
#endif

1743 1744 1745 1746 1747
/* 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 已提交
1748 1749
    tcg_gen_op2ii(INDEX_op_debug_insn_start, 
                  (uint32_t)(pc), (uint32_t)(pc >> 32));
1750 1751 1752 1753 1754
#else
    tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
#endif
}

B
bellard 已提交
1755 1756
static inline void tcg_gen_exit_tb(tcg_target_long val)
{
P
pbrook 已提交
1757
    tcg_gen_op1i(INDEX_op_exit_tb, val);
B
bellard 已提交
1758 1759 1760 1761
}

static inline void tcg_gen_goto_tb(int idx)
{
P
pbrook 已提交
1762
    tcg_gen_op1i(INDEX_op_goto_tb, idx);
B
bellard 已提交
1763 1764 1765
}

#if TCG_TARGET_REG_BITS == 32
P
pbrook 已提交
1766
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1767 1768
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1769
    tcg_gen_op3i_i32(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1770
#else
P
pbrook 已提交
1771 1772
    tcg_gen_op4i_i32(INDEX_op_qemu_ld8u, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
P
pbrook 已提交
1773
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1774 1775 1776
#endif
}

P
pbrook 已提交
1777
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1778 1779
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1780
    tcg_gen_op3i_i32(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1781
#else
P
pbrook 已提交
1782 1783 1784
    tcg_gen_op4i_i32(INDEX_op_qemu_ld8s, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1785 1786 1787
#endif
}

P
pbrook 已提交
1788
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1789 1790
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1791
    tcg_gen_op3i_i32(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1792
#else
P
pbrook 已提交
1793 1794
    tcg_gen_op4i_i32(INDEX_op_qemu_ld16u, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
P
pbrook 已提交
1795
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1796 1797 1798
#endif
}

P
pbrook 已提交
1799
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1800 1801
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1802
    tcg_gen_op3i_i32(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1803
#else
P
pbrook 已提交
1804 1805 1806
    tcg_gen_op4i_i32(INDEX_op_qemu_ld16s, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1807 1808 1809
#endif
}

P
pbrook 已提交
1810
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1811 1812
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1813
    tcg_gen_op3i_i32(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1814
#else
P
pbrook 已提交
1815 1816
    tcg_gen_op4i_i32(INDEX_op_qemu_ld32u, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
P
pbrook 已提交
1817
    tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
B
bellard 已提交
1818 1819 1820
#endif
}

P
pbrook 已提交
1821
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1822 1823
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1824
    tcg_gen_op3i_i32(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1825
#else
P
pbrook 已提交
1826 1827 1828
    tcg_gen_op4i_i32(INDEX_op_qemu_ld32u, TCGV_LOW(ret), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
    tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
B
bellard 已提交
1829 1830 1831
#endif
}

P
pbrook 已提交
1832
static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
B
bellard 已提交
1833 1834
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1835
    tcg_gen_op4i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), addr, mem_index);
B
bellard 已提交
1836
#else
P
pbrook 已提交
1837 1838
    tcg_gen_op5i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret),
                     TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1839 1840 1841
#endif
}

P
pbrook 已提交
1842
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1843 1844
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1845
    tcg_gen_op3i_i32(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1846
#else
P
pbrook 已提交
1847 1848
    tcg_gen_op4i_i32(INDEX_op_qemu_st8, TCGV_LOW(arg), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1849 1850 1851
#endif
}

P
pbrook 已提交
1852
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1853 1854
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1855
    tcg_gen_op3i_i32(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1856
#else
P
pbrook 已提交
1857 1858
    tcg_gen_op4i_i32(INDEX_op_qemu_st16, TCGV_LOW(arg), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1859 1860 1861
#endif
}

P
pbrook 已提交
1862
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1863 1864
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1865
    tcg_gen_op3i_i32(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1866
#else
P
pbrook 已提交
1867 1868
    tcg_gen_op4i_i32(INDEX_op_qemu_st32, TCGV_LOW(arg), TCGV_LOW(addr),
                     TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1869 1870 1871
#endif
}

P
pbrook 已提交
1872
static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
B
bellard 已提交
1873 1874
{
#if TARGET_LONG_BITS == 32
P
pbrook 已提交
1875 1876
    tcg_gen_op4i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), addr,
                     mem_index);
B
bellard 已提交
1877
#else
P
pbrook 已提交
1878 1879
    tcg_gen_op5i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg),
                     TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
B
bellard 已提交
1880 1881 1882
#endif
}

B
blueswir1 已提交
1883
#define tcg_gen_ld_ptr tcg_gen_ld_i32
B
blueswir1 已提交
1884
#define tcg_gen_discard_ptr tcg_gen_discard_i32
1885

B
bellard 已提交
1886 1887
#else /* TCG_TARGET_REG_BITS == 32 */

P
pbrook 已提交
1888
static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1889
{
P
pbrook 已提交
1890
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u, ret, addr, mem_index);
B
bellard 已提交
1891 1892
}

P
pbrook 已提交
1893
static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1894
{
P
pbrook 已提交
1895
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s, ret, addr, mem_index);
B
bellard 已提交
1896 1897
}

P
pbrook 已提交
1898
static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1899
{
P
pbrook 已提交
1900
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u, ret, addr, mem_index);
B
bellard 已提交
1901 1902
}

P
pbrook 已提交
1903
static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1904
{
P
pbrook 已提交
1905
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s, ret, addr, mem_index);
B
bellard 已提交
1906 1907
}

P
pbrook 已提交
1908
static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1909
{
P
pbrook 已提交
1910
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u, ret, addr, mem_index);
B
bellard 已提交
1911 1912
}

P
pbrook 已提交
1913
static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
B
bellard 已提交
1914
{
P
pbrook 已提交
1915
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s, ret, addr, mem_index);
B
bellard 已提交
1916 1917
}

P
pbrook 已提交
1918
static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
B
bellard 已提交
1919
{
P
pbrook 已提交
1920
    tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64, ret, addr, mem_index);
B
bellard 已提交
1921 1922
}

P
pbrook 已提交
1923
static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1924
{
P
pbrook 已提交
1925
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8, arg, addr, mem_index);
B
bellard 已提交
1926 1927
}

P
pbrook 已提交
1928
static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1929
{
P
pbrook 已提交
1930
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16, arg, addr, mem_index);
B
bellard 已提交
1931 1932
}

P
pbrook 已提交
1933
static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
B
bellard 已提交
1934
{
P
pbrook 已提交
1935
    tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32, arg, addr, mem_index);
B
bellard 已提交
1936 1937
}

P
pbrook 已提交
1938
static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
B
bellard 已提交
1939
{
P
pbrook 已提交
1940
    tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64, arg, addr, mem_index);
B
bellard 已提交
1941 1942
}

B
blueswir1 已提交
1943
#define tcg_gen_ld_ptr tcg_gen_ld_i64
B
blueswir1 已提交
1944
#define tcg_gen_discard_ptr tcg_gen_discard_i64
1945

B
bellard 已提交
1946
#endif /* TCG_TARGET_REG_BITS != 32 */
1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965

#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 已提交
1966
#define tcg_gen_neg_tl tcg_gen_neg_i64
P
pbrook 已提交
1967
#define tcg_gen_subfi_tl tcg_gen_subfi_i64
1968 1969 1970 1971 1972 1973 1974
#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 已提交
1975
#define tcg_gen_not_tl tcg_gen_not_i64
1976 1977 1978 1979 1980 1981
#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 已提交
1982
#define tcg_gen_brcond_tl tcg_gen_brcond_i64
P
pbrook 已提交
1983
#define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
1984 1985
#define tcg_gen_mul_tl tcg_gen_mul_i64
#define tcg_gen_muli_tl tcg_gen_muli_i64
B
blueswir1 已提交
1986
#define tcg_gen_discard_tl tcg_gen_discard_i64
1987 1988 1989 1990 1991 1992
#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 已提交
1993 1994 1995 1996 1997 1998
#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
1999
#define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
2000 2001 2002 2003 2004
#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
2005 2006 2007 2008
#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 已提交
2009
#define tcg_const_tl tcg_const_i64
A
aurel32 已提交
2010
#define tcg_const_local_tl tcg_const_local_i64
2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028
#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 已提交
2029
#define tcg_gen_neg_tl tcg_gen_neg_i32
A
aurel32 已提交
2030
#define tcg_gen_subfi_tl tcg_gen_subfi_i32
2031 2032 2033 2034 2035 2036 2037
#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 已提交
2038
#define tcg_gen_not_tl tcg_gen_not_i32
2039 2040 2041 2042 2043 2044
#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 已提交
2045
#define tcg_gen_brcond_tl tcg_gen_brcond_i32
P
pbrook 已提交
2046
#define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
2047 2048
#define tcg_gen_mul_tl tcg_gen_mul_i32
#define tcg_gen_muli_tl tcg_gen_muli_i32
B
blueswir1 已提交
2049
#define tcg_gen_discard_tl tcg_gen_discard_i32
2050 2051 2052 2053 2054 2055
#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 已提交
2056 2057 2058 2059 2060 2061
#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
2062
#define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
2063 2064 2065 2066 2067
#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
2068 2069 2070 2071
#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 已提交
2072
#define tcg_const_tl tcg_const_i32
A
aurel32 已提交
2073
#define tcg_const_local_tl tcg_const_local_i32
2074
#endif
P
pbrook 已提交
2075 2076

#if TCG_TARGET_REG_BITS == 32
2077
#define tcg_gen_add_ptr tcg_gen_add_i32
P
pbrook 已提交
2078
#define tcg_gen_addi_ptr tcg_gen_addi_i32
2079
#define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
P
pbrook 已提交
2080
#else /* TCG_TARGET_REG_BITS == 32 */
2081
#define tcg_gen_add_ptr tcg_gen_add_i64
P
pbrook 已提交
2082
#define tcg_gen_addi_ptr tcg_gen_addi_i64
2083
#define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
P
pbrook 已提交
2084
#endif /* TCG_TARGET_REG_BITS != 32 */