Statistics
| Branch: | Revision:

root / tcg / sparc / tcg-target.c @ 26cc915c

History | View | Annotate | Download (32.2 kB)

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

    
25
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
26
    "%g0",
27
    "%g1",
28
    "%g2",
29
    "%g3",
30
    "%g4",
31
    "%g5",
32
    "%g6",
33
    "%g7",
34
    "%o0",
35
    "%o1",
36
    "%o2",
37
    "%o3",
38
    "%o4",
39
    "%o5",
40
    "%o6",
41
    "%o7",
42
    "%l0",
43
    "%l1",
44
    "%l2",
45
    "%l3",
46
    "%l4",
47
    "%l5",
48
    "%l6",
49
    "%l7",
50
    "%i0",
51
    "%i1",
52
    "%i2",
53
    "%i3",
54
    "%i4",
55
    "%i5",
56
    "%i6",
57
    "%i7",
58
};
59

    
60
static const int tcg_target_reg_alloc_order[] = {
61
    TCG_REG_L0,
62
    TCG_REG_L1,
63
    TCG_REG_L2,
64
    TCG_REG_L3,
65
    TCG_REG_L4,
66
    TCG_REG_L5,
67
    TCG_REG_L6,
68
    TCG_REG_L7,
69
    TCG_REG_I0,
70
    TCG_REG_I1,
71
    TCG_REG_I2,
72
    TCG_REG_I3,
73
    TCG_REG_I4,
74
};
75

    
76
static const int tcg_target_call_iarg_regs[6] = {
77
    TCG_REG_O0,
78
    TCG_REG_O1,
79
    TCG_REG_O2,
80
    TCG_REG_O3,
81
    TCG_REG_O4,
82
    TCG_REG_O5,
83
};
84

    
85
static const int tcg_target_call_oarg_regs[2] = {
86
    TCG_REG_O0,
87
    TCG_REG_O1,
88
};
89

    
90
static inline int check_fit_tl(tcg_target_long val, unsigned int bits)
91
{
92
    return (val << ((sizeof(tcg_target_long) * 8 - bits))
93
            >> (sizeof(tcg_target_long) * 8 - bits)) == val;
94
}
95

    
96
static inline int check_fit_i32(uint32_t val, unsigned int bits)
97
{
98
    return ((val << (32 - bits)) >> (32 - bits)) == val;
99
}
100

    
101
static void patch_reloc(uint8_t *code_ptr, int type,
102
                        tcg_target_long value, tcg_target_long addend)
103
{
104
    value += addend;
105
    switch (type) {
106
    case R_SPARC_32:
107
        if (value != (uint32_t)value)
108
            tcg_abort();
109
        *(uint32_t *)code_ptr = value;
110
        break;
111
    case R_SPARC_WDISP22:
112
        value -= (long)code_ptr;
113
        value >>= 2;
114
        if (!check_fit_tl(value, 22))
115
            tcg_abort();
116
        *(uint32_t *)code_ptr = ((*(uint32_t *)code_ptr) & ~0x3fffff) | value;
117
        break;
118
    default:
119
        tcg_abort();
120
    }
121
}
122

    
123
/* maximum number of register used for input function arguments */
124
static inline int tcg_target_get_call_iarg_regs_count(int flags)
125
{
126
    return 6;
127
}
128

    
129
/* parse target specific constraints */
130
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
131
{
132
    const char *ct_str;
133

    
134
    ct_str = *pct_str;
135
    switch (ct_str[0]) {
136
    case 'r':
137
    case 'L': /* qemu_ld/st constraint */
138
        ct->ct |= TCG_CT_REG;
139
        tcg_regset_set32(ct->u.regs, 0, 0xffffffff);
140
        tcg_regset_reset_reg(ct->u.regs, TCG_REG_I0);
141
        tcg_regset_reset_reg(ct->u.regs, TCG_REG_I1);
142
        break;
143
    case 'I':
144
        ct->ct |= TCG_CT_CONST_S11;
145
        break;
146
    case 'J':
147
        ct->ct |= TCG_CT_CONST_S13;
148
        break;
149
    default:
150
        return -1;
151
    }
152
    ct_str++;
153
    *pct_str = ct_str;
154
    return 0;
155
}
156

    
157
/* test if a constant matches the constraint */
158
static inline int tcg_target_const_match(tcg_target_long val,
159
                                         const TCGArgConstraint *arg_ct)
160
{
161
    int ct;
162

    
163
    ct = arg_ct->ct;
164
    if (ct & TCG_CT_CONST)
165
        return 1;
166
    else if ((ct & TCG_CT_CONST_S11) && check_fit_tl(val, 11))
167
        return 1;
168
    else if ((ct & TCG_CT_CONST_S13) && check_fit_tl(val, 13))
169
        return 1;
170
    else
171
        return 0;
172
}
173

    
174
#define INSN_OP(x)  ((x) << 30)
175
#define INSN_OP2(x) ((x) << 22)
176
#define INSN_OP3(x) ((x) << 19)
177
#define INSN_OPF(x) ((x) << 5)
178
#define INSN_RD(x)  ((x) << 25)
179
#define INSN_RS1(x) ((x) << 14)
180
#define INSN_RS2(x) (x)
181

    
182
#define INSN_IMM13(x) ((1 << 13) | ((x) & 0x1fff))
183
#define INSN_OFF22(x) (((x) >> 2) & 0x3fffff)
184

    
185
#define INSN_COND(x, a) (((x) << 25) | ((a) << 29))
186
#define COND_N     0x0
187
#define COND_E     0x1
188
#define COND_LE    0x2
189
#define COND_L     0x3
190
#define COND_LEU   0x4
191
#define COND_CS    0x5
192
#define COND_NEG   0x6
193
#define COND_VS    0x7
194
#define COND_A     0x8
195
#define COND_NE    0x9
196
#define COND_G     0xa
197
#define COND_GE    0xb
198
#define COND_GU    0xc
199
#define COND_CC    0xd
200
#define COND_POS   0xe
201
#define COND_VC    0xf
202
#define BA         (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2))
203

    
204
#define ARITH_ADD  (INSN_OP(2) | INSN_OP3(0x00))
205
#define ARITH_AND  (INSN_OP(2) | INSN_OP3(0x01))
206
#define ARITH_OR   (INSN_OP(2) | INSN_OP3(0x02))
207
#define ARITH_ORCC (INSN_OP(2) | INSN_OP3(0x12))
208
#define ARITH_XOR  (INSN_OP(2) | INSN_OP3(0x03))
209
#define ARITH_SUB  (INSN_OP(2) | INSN_OP3(0x04))
210
#define ARITH_SUBCC (INSN_OP(2) | INSN_OP3(0x14))
211
#define ARITH_ADDX (INSN_OP(2) | INSN_OP3(0x10))
212
#define ARITH_SUBX (INSN_OP(2) | INSN_OP3(0x0c))
213
#define ARITH_UMUL (INSN_OP(2) | INSN_OP3(0x0a))
214
#define ARITH_UDIV (INSN_OP(2) | INSN_OP3(0x0e))
215
#define ARITH_SDIV (INSN_OP(2) | INSN_OP3(0x0f))
216
#define ARITH_MULX (INSN_OP(2) | INSN_OP3(0x09))
217
#define ARITH_UDIVX (INSN_OP(2) | INSN_OP3(0x0d))
218
#define ARITH_SDIVX (INSN_OP(2) | INSN_OP3(0x2d))
219

    
220
#define SHIFT_SLL  (INSN_OP(2) | INSN_OP3(0x25))
221
#define SHIFT_SRL  (INSN_OP(2) | INSN_OP3(0x26))
222
#define SHIFT_SRA  (INSN_OP(2) | INSN_OP3(0x27))
223

    
224
#define SHIFT_SLLX (INSN_OP(2) | INSN_OP3(0x25) | (1 << 12))
225
#define SHIFT_SRLX (INSN_OP(2) | INSN_OP3(0x26) | (1 << 12))
226
#define SHIFT_SRAX (INSN_OP(2) | INSN_OP3(0x27) | (1 << 12))
227

    
228
#define WRY        (INSN_OP(2) | INSN_OP3(0x30))
229
#define JMPL       (INSN_OP(2) | INSN_OP3(0x38))
230
#define SAVE       (INSN_OP(2) | INSN_OP3(0x3c))
231
#define RESTORE    (INSN_OP(2) | INSN_OP3(0x3d))
232
#define SETHI      (INSN_OP(0) | INSN_OP2(0x4))
233
#define CALL       INSN_OP(1)
234
#define LDUB       (INSN_OP(3) | INSN_OP3(0x01))
235
#define LDSB       (INSN_OP(3) | INSN_OP3(0x09))
236
#define LDUH       (INSN_OP(3) | INSN_OP3(0x02))
237
#define LDSH       (INSN_OP(3) | INSN_OP3(0x0a))
238
#define LDUW       (INSN_OP(3) | INSN_OP3(0x00))
239
#define LDSW       (INSN_OP(3) | INSN_OP3(0x08))
240
#define LDX        (INSN_OP(3) | INSN_OP3(0x0b))
241
#define STB        (INSN_OP(3) | INSN_OP3(0x05))
242
#define STH        (INSN_OP(3) | INSN_OP3(0x06))
243
#define STW        (INSN_OP(3) | INSN_OP3(0x04))
244
#define STX        (INSN_OP(3) | INSN_OP3(0x0e))
245

    
246
static inline void tcg_out_arith(TCGContext *s, int rd, int rs1, int rs2,
247
                                 int op)
248
{
249
    tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) |
250
              INSN_RS2(rs2));
251
}
252

    
253
static inline void tcg_out_arithi(TCGContext *s, int rd, int rs1, int offset,
254
                                  int op)
255
{
256
    tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) |
257
              INSN_IMM13(offset));
258
}
259

    
260
static inline void tcg_out_mov(TCGContext *s, int ret, int arg)
261
{
262
    tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR);
263
}
264

    
265
static inline void tcg_out_sethi(TCGContext *s, int ret, uint32_t arg)
266
{
267
    tcg_out32(s, SETHI | INSN_RD(ret) | ((arg & 0xfffffc00) >> 10));
268
}
269

    
270
static inline void tcg_out_movi(TCGContext *s, TCGType type,
271
                                int ret, tcg_target_long arg)
272
{
273
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
274
    if (!check_fit_tl(arg, 32) && (arg & ~0xffffffff) != 0)
275
        fprintf(stderr, "unimplemented %s with constant %ld\n", __func__, arg);
276
#endif
277
    if (check_fit_i32(arg, 13))
278
        tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(TCG_REG_G0) |
279
                  INSN_IMM13(arg));
280
    else {
281
        tcg_out_sethi(s, ret, arg);
282
        if (arg & 0x3ff)
283
            tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(ret) |
284
                      INSN_IMM13(arg & 0x3ff));
285
    }
286
}
287

    
288
static inline void tcg_out_ld_raw(TCGContext *s, int ret,
289
                                  tcg_target_long arg)
290
{
291
    tcg_out_sethi(s, ret, arg);
292
    tcg_out32(s, LDUW | INSN_RD(ret) | INSN_RS1(ret) |
293
              INSN_IMM13(arg & 0x3ff));
294
}
295

    
296
static inline void tcg_out_ld_ptr(TCGContext *s, int ret,
297
                                  tcg_target_long arg)
298
{
299
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
300
    if (!check_fit_tl(arg, 32) && (arg & ~0xffffffff) != 0)
301
        fprintf(stderr, "unimplemented %s with offset %ld\n", __func__, arg);
302
    if (!check_fit_i32(arg, 13))
303
        tcg_out_sethi(s, ret, arg);
304
    tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(ret) |
305
              INSN_IMM13(arg & 0x3ff));
306
#else
307
    tcg_out_ld_raw(s, ret, arg);
308
#endif
309
}
310

    
311
static inline void tcg_out_ldst(TCGContext *s, int ret, int addr, int offset, int op)
312
{
313
    if (check_fit_tl(offset, 13))
314
        tcg_out32(s, op | INSN_RD(ret) | INSN_RS1(addr) |
315
                  INSN_IMM13(offset));
316
    else {
317
        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I5, offset);
318
        tcg_out32(s, op | INSN_RD(ret) | INSN_RS1(TCG_REG_I5) |
319
                  INSN_RS2(addr));
320
    }
321
}
322

    
323
static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret,
324
                              int arg1, tcg_target_long arg2)
325
{
326
    if (type == TCG_TYPE_I32)
327
        tcg_out_ldst(s, ret, arg1, arg2, LDUW);
328
    else
329
        tcg_out_ldst(s, ret, arg1, arg2, LDX);
330
}
331

    
332
static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
333
                              int arg1, tcg_target_long arg2)
334
{
335
    if (type == TCG_TYPE_I32)
336
        tcg_out_ldst(s, arg, arg1, arg2, STW);
337
    else
338
        tcg_out_ldst(s, arg, arg1, arg2, STX);
339
}
340

    
341
static inline void tcg_out_sety(TCGContext *s, tcg_target_long val)
342
{
343
    if (val == 0 || val == -1)
344
        tcg_out32(s, WRY | INSN_IMM13(val));
345
    else
346
        fprintf(stderr, "unimplemented sety %ld\n", (long)val);
347
}
348

    
349
static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)
350
{
351
    if (val != 0) {
352
        if (check_fit_tl(val, 13))
353
            tcg_out_arithi(s, reg, reg, val, ARITH_ADD);
354
        else {
355
            tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I5, val);
356
            tcg_out_arith(s, reg, reg, TCG_REG_I5, ARITH_ADD);
357
        }
358
    }
359
}
360

    
361
static inline void tcg_out_nop(TCGContext *s)
362
{
363
    tcg_out_sethi(s, TCG_REG_G0, 0);
364
}
365

    
366
static void tcg_out_branch(TCGContext *s, int opc, int label_index)
367
{
368
    int32_t val;
369
    TCGLabel *l = &s->labels[label_index];
370

    
371
    if (l->has_value) {
372
        val = l->u.value - (tcg_target_long)s->code_ptr;
373
        tcg_out32(s, (INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x2)
374
                      | INSN_OFF22(l->u.value - (unsigned long)s->code_ptr)));
375
    } else {
376
        tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP22, label_index, 0);
377
        tcg_out32(s, (INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x2) | 0));
378
    }
379
}
380

    
381
static const uint8_t tcg_cond_to_bcond[10] = {
382
    [TCG_COND_EQ] = COND_E,
383
    [TCG_COND_NE] = COND_NE,
384
    [TCG_COND_LT] = COND_L,
385
    [TCG_COND_GE] = COND_GE,
386
    [TCG_COND_LE] = COND_LE,
387
    [TCG_COND_GT] = COND_G,
388
    [TCG_COND_LTU] = COND_CS,
389
    [TCG_COND_GEU] = COND_CC,
390
    [TCG_COND_LEU] = COND_LEU,
391
    [TCG_COND_GTU] = COND_GU,
392
};
393

    
394
static void tcg_out_brcond(TCGContext *s, int cond,
395
                           TCGArg arg1, TCGArg arg2, int const_arg2,
396
                           int label_index)
397
{
398
    if (const_arg2 && arg2 == 0)
399
        /* orcc %g0, r, %g0 */
400
        tcg_out_arith(s, TCG_REG_G0, TCG_REG_G0, arg1, ARITH_ORCC);
401
    else
402
        /* subcc r1, r2, %g0 */
403
        tcg_out_arith(s, TCG_REG_G0, arg1, arg2, ARITH_SUBCC);
404
    tcg_out_branch(s, tcg_cond_to_bcond[cond], label_index);
405
    tcg_out_nop(s);
406
}
407

    
408
/* Generate global QEMU prologue and epilogue code */
409
void tcg_target_qemu_prologue(TCGContext *s)
410
{
411
    tcg_out32(s, SAVE | INSN_RD(TCG_REG_O6) | INSN_RS1(TCG_REG_O6) |
412
              INSN_IMM13(-TCG_TARGET_STACK_MINFRAME));
413
    tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I0) |
414
              INSN_RS2(TCG_REG_G0));
415
    tcg_out_nop(s);
416
}
417

    
418
#if defined(CONFIG_SOFTMMU)
419
extern void __ldb_mmu(void);
420
extern void __ldw_mmu(void);
421
extern void __ldl_mmu(void);
422
extern void __ldq_mmu(void);
423

    
424
extern void __stb_mmu(void);
425
extern void __stw_mmu(void);
426
extern void __stl_mmu(void);
427
extern void __stq_mmu(void);
428

    
429

    
430
static const void * const qemu_ld_helpers[4] = {
431
    __ldb_mmu,
432
    __ldw_mmu,
433
    __ldl_mmu,
434
    __ldq_mmu,
435
};
436

    
437
static const void * const qemu_st_helpers[4] = {
438
    __stb_mmu,
439
    __stw_mmu,
440
    __stl_mmu,
441
    __stq_mmu,
442
};
443
#endif
444

    
445
static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
446
                            int opc)
447
{
448
    int addr_reg, data_reg, r0, r1, mem_index, s_bits, bswap, ld_op;
449
#if defined(CONFIG_SOFTMMU)
450
    uint8_t *label1_ptr, *label2_ptr;
451
#endif
452

    
453
    data_reg = *args++;
454
    addr_reg = *args++;
455
    mem_index = *args;
456
    s_bits = opc & 3;
457

    
458
    r0 = TCG_REG_I0;
459
    r1 = TCG_REG_I1;
460

    
461
#if TARGET_LONG_BITS == 32
462
    ld_op = LDUW;
463
#else
464
    ld_op = LDX;
465
#endif
466

    
467
#if defined(CONFIG_SOFTMMU)
468
    /* srl addr_reg, x, r1 */
469
    tcg_out_arithi(s, r1, addr_reg, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS,
470
                   SHIFT_SRL);
471
    /* and addr_reg, x, r0 */
472
    tcg_out_arithi(s, r0, addr_reg, TARGET_PAGE_MASK | ((1 << s_bits) - 1),
473
                   ARITH_AND);
474

    
475
    /* and r1, x, r1 */
476
    tcg_out_arithi(s, r1, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS,
477
                   ARITH_AND);
478

    
479
    /* add r1, x, r1 */
480
    tcg_out_arithi(s, r1, r1, offsetof(CPUState, tlb_table[mem_index][0].addr_read),
481
                   ARITH_ADD);
482

    
483
    /* ld [env + r1], r1 */
484
    tcg_out_ldst(s, r1, TCG_AREG0, r1, ld_op);
485

    
486
    /* subcc r0, r1, %g0 */
487
    tcg_out_arith(s, TCG_REG_G0, r0, r1, ARITH_SUBCC);
488

    
489
    /* will become:
490
       be label1 */
491
    label1_ptr = s->code_ptr;
492
    tcg_out32(s, 0);
493

    
494
    /* mov (delay slot)*/
495
    tcg_out_mov(s, r0, addr_reg);
496

    
497
    /* XXX: move that code at the end of the TB */
498
    tcg_out32(s, CALL | ((((tcg_target_ulong)qemu_ld_helpers[s_bits]
499
                           - (tcg_target_ulong)s->code_ptr) >> 2)
500
                         & 0x3fffffff));
501
    /* mov (delay slot)*/
502
    tcg_out_movi(s, TCG_TYPE_I32, r1, mem_index);
503

    
504
    switch(opc) {
505
    case 0 | 4:
506
        /* sll i0, 24/56, i0 */
507
        tcg_out_arithi(s, TCG_REG_I0, TCG_REG_I0,
508
                       sizeof(tcg_target_long) * 8 - 8, SHIFT_SLL);
509
        /* sra i0, 24/56, data_reg */
510
        tcg_out_arithi(s, data_reg, TCG_REG_I0,
511
                       sizeof(tcg_target_long) * 8 - 8, SHIFT_SRA);
512
        break;
513
    case 1 | 4:
514
        /* sll i0, 16/48, i0 */
515
        tcg_out_arithi(s, TCG_REG_I0, TCG_REG_I0,
516
                       sizeof(tcg_target_long) * 8 - 16, SHIFT_SLL);
517
        /* sra i0, 16/48, data_reg */
518
        tcg_out_arithi(s, data_reg, TCG_REG_I0,
519
                       sizeof(tcg_target_long) * 8 - 16, SHIFT_SRA);
520
        break;
521
    case 2 | 4:
522
        /* sll i0, 32, i0 */
523
        tcg_out_arithi(s, TCG_REG_I0, TCG_REG_I0, 32, SHIFT_SLL);
524
        /* sra i0, 32, data_reg */
525
        tcg_out_arithi(s, data_reg, TCG_REG_I0, 32, SHIFT_SRA);
526
        break;
527
    case 0:
528
    case 1:
529
    case 2:
530
    case 3:
531
    default:
532
        /* mov */
533
        tcg_out_mov(s, data_reg, TCG_REG_I0);
534
        break;
535
    }
536

    
537
    /* will become:
538
       ba label2 */
539
    label2_ptr = s->code_ptr;
540
    tcg_out32(s, 0);
541

    
542
    /* label1: */
543
    *label1_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
544
                   INSN_OFF22((unsigned long)label1_ptr -
545
                              (unsigned long)s->code_ptr));
546

    
547
    /* ld [r1 + x], r1 */
548
    tcg_out_ldst(s, r1, r1, offsetof(CPUTLBEntry, addend) -
549
                 offsetof(CPUTLBEntry, addr_read), ld_op);
550
    /* add x(r1), r0 */
551
    tcg_out_arith(s, r0, r1, r0, ARITH_ADD);
552
#else
553
    r0 = addr_reg;
554
#endif
555

    
556
#ifdef TARGET_WORDS_BIGENDIAN
557
    bswap = 0;
558
#else
559
    bswap = 1;
560
#endif
561
    switch(opc) {
562
    case 0:
563
        /* ldub [r0], data_reg */
564
        tcg_out_ldst(s, data_reg, r0, 0, LDUB);
565
        break;
566
    case 0 | 4:
567
        /* ldsb [r0], data_reg */
568
        tcg_out_ldst(s, data_reg, r0, 0, LDSB);
569
        break;
570
    case 1:
571
        /* lduh [r0], data_reg */
572
        tcg_out_ldst(s, data_reg, r0, 0, LDUH);
573
        if (bswap) {
574
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
575
        }
576
        break;
577
    case 1 | 4:
578
        /* ldsh [r0], data_reg */
579
        tcg_out_ldst(s, data_reg, r0, 0, LDSH);
580
        if (bswap) {
581
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
582
        }
583
        break;
584
    case 2:
585
        /* lduw [r0], data_reg */
586
        tcg_out_ldst(s, data_reg, r0, 0, LDUW);
587
        if (bswap) {
588
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
589
        }
590
        break;
591
    case 2 | 4:
592
        /* ldsw [r0], data_reg */
593
        tcg_out_ldst(s, data_reg, r0, 0, LDSW);
594
        if (bswap) {
595
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
596
        }
597
        break;
598
    case 3:
599
        /* ldx [r0], data_reg */
600
        tcg_out_ldst(s, data_reg, r0, 0, LDX);
601
        if (bswap) {
602
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
603
        }
604
        break;
605
    default:
606
        tcg_abort();
607
    }
608

    
609
#if defined(CONFIG_SOFTMMU)
610
    /* label2: */
611
    *label2_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
612
                   INSN_OFF22((unsigned long)label2_ptr -
613
                              (unsigned long)s->code_ptr));
614
#endif
615
}
616

    
617
static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
618
                            int opc)
619
{
620
    int addr_reg, data_reg, r0, r1, mem_index, s_bits, bswap, ld_op;
621
#if defined(CONFIG_SOFTMMU)
622
    uint8_t *label1_ptr, *label2_ptr;
623
#endif
624

    
625
    data_reg = *args++;
626
    addr_reg = *args++;
627
    mem_index = *args;
628

    
629
    s_bits = opc;
630

    
631
    r0 = TCG_REG_I5;
632
    r1 = TCG_REG_I4;
633

    
634
#if TARGET_LONG_BITS == 32
635
    ld_op = LDUW;
636
#else
637
    ld_op = LDX;
638
#endif
639

    
640
#if defined(CONFIG_SOFTMMU)
641
    /* srl addr_reg, x, r1 */
642
    tcg_out_arithi(s, r1, addr_reg, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS,
643
                   SHIFT_SRL);
644
    /* and addr_reg, x, r0 */
645
    tcg_out_arithi(s, r0, addr_reg, TARGET_PAGE_MASK | ((1 << s_bits) - 1),
646
                   ARITH_AND);
647

    
648
    /* and r1, x, r1 */
649
    tcg_out_arithi(s, r1, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS,
650
                   ARITH_AND);
651

    
652
    /* add r1, x, r1 */
653
    tcg_out_arithi(s, r1, r1,
654
                   offsetof(CPUState, tlb_table[mem_index][0].addr_write),
655
                   ARITH_ADD);
656

    
657
    /* ld [env + r1], r1 */
658
    tcg_out_ldst(s, r1, TCG_AREG0, r1, ld_op);
659

    
660
    /* subcc r0, r1, %g0 */
661
    tcg_out_arith(s, TCG_REG_G0, r0, r1, ARITH_SUBCC);
662

    
663
    /* will become:
664
       be label1 */
665
    label1_ptr = s->code_ptr;
666
    tcg_out32(s, 0);
667
    /* mov (delay slot)*/
668
    tcg_out_mov(s, r0, addr_reg);
669

    
670
    switch(opc) {
671
    case 0 | 4:
672
        /* sll i0, 24/56, i0 */
673
        tcg_out_arithi(s, TCG_REG_I0, TCG_REG_I0,
674
                       sizeof(tcg_target_long) * 8 - 8, SHIFT_SLL);
675
        /* sra i0, 24/56, data_reg */
676
        tcg_out_arithi(s, data_reg, TCG_REG_I0,
677
                       sizeof(tcg_target_long) * 8 - 8, SHIFT_SRA);
678
        break;
679
    case 1 | 4:
680
        /* sll i0, 16/48, i0 */
681
        tcg_out_arithi(s, TCG_REG_I0, TCG_REG_I0,
682
                       sizeof(tcg_target_long) * 8 - 16, SHIFT_SLL);
683
        /* sra i0, 16/48, data_reg */
684
        tcg_out_arithi(s, data_reg, TCG_REG_I0,
685
                       sizeof(tcg_target_long) * 8 - 16, SHIFT_SRA);
686
        break;
687
    case 2 | 4:
688
        /* sll i0, 32, i0 */
689
        tcg_out_arithi(s, TCG_REG_I0, TCG_REG_I0, 32, SHIFT_SLL);
690
        /* sra i0, 32, data_reg */
691
        tcg_out_arithi(s, data_reg, TCG_REG_I0, 32, SHIFT_SRA);
692
        break;
693
    case 0:
694
    case 1:
695
    case 2:
696
    case 3:
697
    default:
698
        /* mov */
699
        tcg_out_mov(s, data_reg, TCG_REG_I0);
700
        break;
701
    }
702

    
703
    tcg_out32(s, CALL | ((((tcg_target_ulong)qemu_st_helpers[s_bits]
704
                           - (tcg_target_ulong)s->code_ptr) >> 2)
705
                         & 0x3fffffff));
706
    /* mov (delay slot)*/
707
    tcg_out_movi(s, TCG_TYPE_I32, r1, mem_index);
708

    
709
    /* will become:
710
       ba label2 */
711
    label2_ptr = s->code_ptr;
712
    tcg_out32(s, 0);
713

    
714
    /* label1: */
715
    *label1_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
716
                   INSN_OFF22((unsigned long)label1_ptr -
717
                              (unsigned long)s->code_ptr));
718

    
719
    /* ld [r1 + x], r1 */
720
    tcg_out_ldst(s, r1, r1, offsetof(CPUTLBEntry, addend) -
721
                 offsetof(CPUTLBEntry, addr_write), ld_op);
722
    /* add x(r1), r0 */
723
    tcg_out_arith(s, r0, r1, r0, ARITH_ADD);
724
#else
725
    r0 = addr_reg;
726
#endif
727

    
728
#ifdef TARGET_WORDS_BIGENDIAN
729
    bswap = 0;
730
#else
731
    bswap = 1;
732
#endif
733
    switch(opc) {
734
    case 0:
735
        /* stb data_reg, [r0] */
736
        tcg_out_ldst(s, data_reg, r0, 0, STB);
737
        break;
738
    case 1:
739
        if (bswap) {
740
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
741
        }
742
        /* sth data_reg, [r0] */
743
        tcg_out_ldst(s, data_reg, r0, 0, STH);
744
        break;
745
    case 2:
746
        if (bswap) {
747
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
748
        }
749
        /* stw data_reg, [r0] */
750
        tcg_out_ldst(s, data_reg, r0, 0, STW);
751
        break;
752
    case 3:
753
        if (bswap) {
754
            fprintf(stderr, "unimplemented %s with bswap\n", __func__);
755
        }
756
        /* stx data_reg, [r0] */
757
        tcg_out_ldst(s, data_reg, r0, 0, STX);
758
        break;
759
    default:
760
        tcg_abort();
761
    }
762

    
763
#if defined(CONFIG_SOFTMMU)
764
    /* label2: */
765
    *label2_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
766
                   INSN_OFF22((unsigned long)label2_ptr -
767
                              (unsigned long)s->code_ptr));
768
#endif
769
}
770

    
771
static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
772
                              const int *const_args)
773
{
774
    int c;
775

    
776
    switch (opc) {
777
    case INDEX_op_exit_tb:
778
        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I0, args[0]);
779
        tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I7) |
780
                  INSN_IMM13(8));
781
        tcg_out32(s, RESTORE | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_G0) |
782
                      INSN_RS2(TCG_REG_G0));
783
        break;
784
    case INDEX_op_goto_tb:
785
        if (s->tb_jmp_offset) {
786
            /* direct jump method */
787
            tcg_out_sethi(s, TCG_REG_I5, args[0] & 0xffffe000);
788
            tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
789
                      INSN_IMM13((args[0] & 0x1fff)));
790
            s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
791
        } else {
792
            /* indirect jump method */
793
            tcg_out_ld_ptr(s, TCG_REG_I5, (tcg_target_long)(s->tb_next + args[0]));
794
            tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
795
                      INSN_RS2(TCG_REG_G0));
796
        }
797
        tcg_out_nop(s);
798
        s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
799
        break;
800
    case INDEX_op_call:
801
        if (const_args[0]) {
802
            tcg_out32(s, CALL | ((((tcg_target_ulong)args[0]
803
                                  - (tcg_target_ulong)s->code_ptr) >> 2)
804
                                 & 0x3fffffff));
805
            tcg_out_nop(s);
806
        } else {
807
            tcg_out_ld_ptr(s, TCG_REG_I5, (tcg_target_long)(s->tb_next + args[0]));
808
            tcg_out32(s, JMPL | INSN_RD(TCG_REG_O7) | INSN_RS1(TCG_REG_I5) |
809
                      INSN_RS2(TCG_REG_G0));
810
            tcg_out_nop(s);
811
        }
812
        break;
813
    case INDEX_op_jmp:
814
    case INDEX_op_br:
815
        tcg_out_branch(s, COND_A, args[0]);
816
        tcg_out_nop(s);
817
        break;
818
    case INDEX_op_movi_i32:
819
        tcg_out_movi(s, TCG_TYPE_I32, args[0], (uint32_t)args[1]);
820
        break;
821

    
822
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
823
#define OP_32_64(x)                             \
824
        glue(glue(case INDEX_op_, x), _i32:)    \
825
        glue(glue(case INDEX_op_, x), _i64:)
826
#else
827
#define OP_32_64(x)                             \
828
        glue(glue(case INDEX_op_, x), _i32:)
829
#endif
830
        OP_32_64(ld8u);
831
        tcg_out_ldst(s, args[0], args[1], args[2], LDUB);
832
        break;
833
        OP_32_64(ld8s);
834
        tcg_out_ldst(s, args[0], args[1], args[2], LDSB);
835
        break;
836
        OP_32_64(ld16u);
837
        tcg_out_ldst(s, args[0], args[1], args[2], LDUH);
838
        break;
839
        OP_32_64(ld16s);
840
        tcg_out_ldst(s, args[0], args[1], args[2], LDSH);
841
        break;
842
    case INDEX_op_ld_i32:
843
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
844
    case INDEX_op_ld32u_i64:
845
#endif
846
        tcg_out_ldst(s, args[0], args[1], args[2], LDUW);
847
        break;
848
        OP_32_64(st8);
849
        tcg_out_ldst(s, args[0], args[1], args[2], STB);
850
        break;
851
        OP_32_64(st16);
852
        tcg_out_ldst(s, args[0], args[1], args[2], STH);
853
        break;
854
    case INDEX_op_st_i32:
855
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
856
    case INDEX_op_st32_i64:
857
#endif
858
        tcg_out_ldst(s, args[0], args[1], args[2], STW);
859
        break;
860
        OP_32_64(add);
861
        c = ARITH_ADD;
862
        goto gen_arith32;
863
        OP_32_64(sub);
864
        c = ARITH_SUB;
865
        goto gen_arith32;
866
        OP_32_64(and);
867
        c = ARITH_AND;
868
        goto gen_arith32;
869
        OP_32_64(or);
870
        c = ARITH_OR;
871
        goto gen_arith32;
872
        OP_32_64(xor);
873
        c = ARITH_XOR;
874
        goto gen_arith32;
875
    case INDEX_op_shl_i32:
876
        c = SHIFT_SLL;
877
        goto gen_arith32;
878
    case INDEX_op_shr_i32:
879
        c = SHIFT_SRL;
880
        goto gen_arith32;
881
    case INDEX_op_sar_i32:
882
        c = SHIFT_SRA;
883
        goto gen_arith32;
884
    case INDEX_op_mul_i32:
885
        c = ARITH_UMUL;
886
        goto gen_arith32;
887
    case INDEX_op_div2_i32:
888
#if defined(__sparc_v9__) || defined(__sparc_v8plus__)
889
        c = ARITH_SDIVX;
890
        goto gen_arith32;
891
#else
892
        tcg_out_sety(s, 0);
893
        c = ARITH_SDIV;
894
        goto gen_arith32;
895
#endif
896
    case INDEX_op_divu2_i32:
897
#if defined(__sparc_v9__) || defined(__sparc_v8plus__)
898
        c = ARITH_UDIVX;
899
        goto gen_arith32;
900
#else
901
        tcg_out_sety(s, 0);
902
        c = ARITH_UDIV;
903
        goto gen_arith32;
904
#endif
905

    
906
    case INDEX_op_brcond_i32:
907
        tcg_out_brcond(s, args[2], args[0], args[1], const_args[1],
908
                       args[3]);
909
        break;
910

    
911
    case INDEX_op_qemu_ld8u:
912
        tcg_out_qemu_ld(s, args, 0);
913
        break;
914
    case INDEX_op_qemu_ld8s:
915
        tcg_out_qemu_ld(s, args, 0 | 4);
916
        break;
917
    case INDEX_op_qemu_ld16u:
918
        tcg_out_qemu_ld(s, args, 1);
919
        break;
920
    case INDEX_op_qemu_ld16s:
921
        tcg_out_qemu_ld(s, args, 1 | 4);
922
        break;
923
    case INDEX_op_qemu_ld32u:
924
        tcg_out_qemu_ld(s, args, 2);
925
        break;
926
    case INDEX_op_qemu_ld32s:
927
        tcg_out_qemu_ld(s, args, 2 | 4);
928
        break;
929
    case INDEX_op_qemu_st8:
930
        tcg_out_qemu_st(s, args, 0);
931
        break;
932
    case INDEX_op_qemu_st16:
933
        tcg_out_qemu_st(s, args, 1);
934
        break;
935
    case INDEX_op_qemu_st32:
936
        tcg_out_qemu_st(s, args, 2);
937
        break;
938

    
939
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
940
    case INDEX_op_movi_i64:
941
        tcg_out_movi(s, TCG_TYPE_I64, args[0], args[1]);
942
        break;
943
    case INDEX_op_ld32s_i64:
944
        tcg_out_ldst(s, args[0], args[1], args[2], LDSW);
945
        break;
946
    case INDEX_op_ld_i64:
947
        tcg_out_ldst(s, args[0], args[1], args[2], LDX);
948
        break;
949
    case INDEX_op_st_i64:
950
        tcg_out_ldst(s, args[0], args[1], args[2], STX);
951
        break;
952
    case INDEX_op_shl_i64:
953
        c = SHIFT_SLLX;
954
        goto gen_arith32;
955
    case INDEX_op_shr_i64:
956
        c = SHIFT_SRLX;
957
        goto gen_arith32;
958
    case INDEX_op_sar_i64:
959
        c = SHIFT_SRAX;
960
        goto gen_arith32;
961
    case INDEX_op_mul_i64:
962
        c = ARITH_MULX;
963
        goto gen_arith32;
964
    case INDEX_op_div2_i64:
965
        c = ARITH_SDIVX;
966
        goto gen_arith32;
967
    case INDEX_op_divu2_i64:
968
        c = ARITH_UDIVX;
969
        goto gen_arith32;
970

    
971
    case INDEX_op_brcond_i64:
972
        tcg_out_brcond(s, args[2], args[0], args[1], const_args[1],
973
                       args[3]);
974
        break;
975
    case INDEX_op_qemu_ld64:
976
        tcg_out_qemu_ld(s, args, 3);
977
        break;
978
    case INDEX_op_qemu_st64:
979
        tcg_out_qemu_st(s, args, 3);
980
        break;
981

    
982
#endif
983
    gen_arith32:
984
        if (const_args[2]) {
985
            tcg_out_arithi(s, args[0], args[1], args[2], c);
986
        } else {
987
            tcg_out_arith(s, args[0], args[1], args[2], c);
988
        }
989
        break;
990

    
991
    default:
992
        fprintf(stderr, "unknown opcode 0x%x\n", opc);
993
        tcg_abort();
994
    }
995
}
996

    
997
static const TCGTargetOpDef sparc_op_defs[] = {
998
    { INDEX_op_exit_tb, { } },
999
    { INDEX_op_goto_tb, { } },
1000
    { INDEX_op_call, { "ri" } },
1001
    { INDEX_op_jmp, { "ri" } },
1002
    { INDEX_op_br, { } },
1003

    
1004
    { INDEX_op_mov_i32, { "r", "r" } },
1005
    { INDEX_op_movi_i32, { "r" } },
1006
    { INDEX_op_ld8u_i32, { "r", "r" } },
1007
    { INDEX_op_ld8s_i32, { "r", "r" } },
1008
    { INDEX_op_ld16u_i32, { "r", "r" } },
1009
    { INDEX_op_ld16s_i32, { "r", "r" } },
1010
    { INDEX_op_ld_i32, { "r", "r" } },
1011
    { INDEX_op_st8_i32, { "r", "r" } },
1012
    { INDEX_op_st16_i32, { "r", "r" } },
1013
    { INDEX_op_st_i32, { "r", "r" } },
1014

    
1015
    { INDEX_op_add_i32, { "r", "r", "rJ" } },
1016
    { INDEX_op_mul_i32, { "r", "r", "rJ" } },
1017
    { INDEX_op_div2_i32, { "r", "r", "0", "1", "r" } },
1018
    { INDEX_op_divu2_i32, { "r", "r", "0", "1", "r" } },
1019
    { INDEX_op_sub_i32, { "r", "r", "rJ" } },
1020
    { INDEX_op_and_i32, { "r", "r", "rJ" } },
1021
    { INDEX_op_or_i32, { "r", "r", "rJ" } },
1022
    { INDEX_op_xor_i32, { "r", "r", "rJ" } },
1023

    
1024
    { INDEX_op_shl_i32, { "r", "r", "rJ" } },
1025
    { INDEX_op_shr_i32, { "r", "r", "rJ" } },
1026
    { INDEX_op_sar_i32, { "r", "r", "rJ" } },
1027

    
1028
    { INDEX_op_brcond_i32, { "r", "ri" } },
1029

    
1030
    { INDEX_op_qemu_ld8u, { "r", "L" } },
1031
    { INDEX_op_qemu_ld8s, { "r", "L" } },
1032
    { INDEX_op_qemu_ld16u, { "r", "L" } },
1033
    { INDEX_op_qemu_ld16s, { "r", "L" } },
1034
    { INDEX_op_qemu_ld32u, { "r", "L" } },
1035
    { INDEX_op_qemu_ld32s, { "r", "L" } },
1036

    
1037
    { INDEX_op_qemu_st8, { "L", "L" } },
1038
    { INDEX_op_qemu_st16, { "L", "L" } },
1039
    { INDEX_op_qemu_st32, { "L", "L" } },
1040

    
1041
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
1042
    { INDEX_op_mov_i64, { "r", "r" } },
1043
    { INDEX_op_movi_i64, { "r" } },
1044
    { INDEX_op_ld8u_i64, { "r", "r" } },
1045
    { INDEX_op_ld8s_i64, { "r", "r" } },
1046
    { INDEX_op_ld16u_i64, { "r", "r" } },
1047
    { INDEX_op_ld16s_i64, { "r", "r" } },
1048
    { INDEX_op_ld32u_i64, { "r", "r" } },
1049
    { INDEX_op_ld32s_i64, { "r", "r" } },
1050
    { INDEX_op_ld_i64, { "r", "r" } },
1051
    { INDEX_op_st8_i64, { "r", "r" } },
1052
    { INDEX_op_st16_i64, { "r", "r" } },
1053
    { INDEX_op_st32_i64, { "r", "r" } },
1054
    { INDEX_op_st_i64, { "r", "r" } },
1055

    
1056
    { INDEX_op_add_i64, { "r", "r", "rJ" } },
1057
    { INDEX_op_mul_i64, { "r", "r", "rJ" } },
1058
    { INDEX_op_div2_i64, { "r", "r", "0", "1", "r" } },
1059
    { INDEX_op_divu2_i64, { "r", "r", "0", "1", "r" } },
1060
    { INDEX_op_sub_i64, { "r", "r", "rJ" } },
1061
    { INDEX_op_and_i64, { "r", "r", "rJ" } },
1062
    { INDEX_op_or_i64, { "r", "r", "rJ" } },
1063
    { INDEX_op_xor_i64, { "r", "r", "rJ" } },
1064

    
1065
    { INDEX_op_shl_i64, { "r", "r", "rJ" } },
1066
    { INDEX_op_shr_i64, { "r", "r", "rJ" } },
1067
    { INDEX_op_sar_i64, { "r", "r", "rJ" } },
1068

    
1069
    { INDEX_op_brcond_i64, { "r", "ri" } },
1070
#endif
1071
    { -1 },
1072
};
1073

    
1074
void tcg_target_init(TCGContext *s)
1075
{
1076
    tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);
1077
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
1078
    tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff);
1079
#endif
1080
    tcg_regset_set32(tcg_target_call_clobber_regs, 0,
1081
                     (1 << TCG_REG_G1) |
1082
                     (1 << TCG_REG_G2) |
1083
                     (1 << TCG_REG_G3) |
1084
                     (1 << TCG_REG_G4) |
1085
                     (1 << TCG_REG_G5) |
1086
                     (1 << TCG_REG_G6) |
1087
                     (1 << TCG_REG_G7) |
1088
                     (1 << TCG_REG_O0) |
1089
                     (1 << TCG_REG_O1) |
1090
                     (1 << TCG_REG_O2) |
1091
                     (1 << TCG_REG_O3) |
1092
                     (1 << TCG_REG_O4) |
1093
                     (1 << TCG_REG_O5) |
1094
                     (1 << TCG_REG_O7));
1095

    
1096
    tcg_regset_clear(s->reserved_regs);
1097
    tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0);
1098
    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I5); // for internal use
1099
    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6);
1100
    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7);
1101
    tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6);
1102
    tcg_regset_set_reg(s->reserved_regs, TCG_REG_O7);
1103
    tcg_add_target_add_op_defs(sparc_op_defs);
1104
}