4 Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
5 Copyright (C) 2003-2005 Fabrice Bellard
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 Rest of V9 instructions, VIS instructions
26 NPC/PC static optimisations (use JUMP_TB when possible)
27 Optimize synthetic instructions
44 #define DYNAMIC_PC 1 /* dynamic pc value */
45 #define JUMP_PC 2 /* dynamic pc value which takes only two values
46 according to jump_pc[T2] */
48 /* global register indexes */
49 static TCGv cpu_env, cpu_T[3], cpu_regwptr, cpu_cc_src, cpu_cc_src2, cpu_cc_dst;
50 static TCGv cpu_psr, cpu_fsr, cpu_pc, cpu_npc, cpu_gregs[8];
51 static TCGv cpu_cond, cpu_src1, cpu_src2, cpu_dst, cpu_addr, cpu_val;
55 /* local register indexes (only used inside old micro ops) */
56 static TCGv cpu_tmp0, cpu_tmp32, cpu_tmp64;
58 typedef struct DisasContext {
59 target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */
60 target_ulong npc; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
61 target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */
65 struct TranslationBlock *tb;
71 // This function uses non-native bit order
72 #define GET_FIELD(X, FROM, TO) \
73 ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
75 // This function uses the order in the manuals, i.e. bit 0 is 2^0
76 #define GET_FIELD_SP(X, FROM, TO) \
77 GET_FIELD(X, 31 - (TO), 31 - (FROM))
79 #define GET_FIELDs(x,a,b) sign_extend (GET_FIELD(x,a,b), (b) - (a) + 1)
80 #define GET_FIELD_SPs(x,a,b) sign_extend (GET_FIELD_SP(x,a,b), ((b) - (a) + 1))
84 #define DFPREG(r) (((r & 1) << 5) | (r & 0x1e))
85 #define QFPREG(r) (((r & 1) << 5) | (r & 0x1c))
88 #define DFPREG(r) (r & 0x1e)
89 #define QFPREG(r) (r & 0x1c)
92 static int sign_extend(int x, int len)
95 return (x << len) >> len;
98 #define IS_IMM (insn & (1<<13))
100 /* floating point registers moves */
101 static void gen_op_load_fpr_FT0(unsigned int src)
103 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src]));
104 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ft0));
107 static void gen_op_load_fpr_FT1(unsigned int src)
109 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src]));
110 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ft1));
113 static void gen_op_store_FT0_fpr(unsigned int dst)
115 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ft0));
116 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst]));
119 static void gen_op_load_fpr_DT0(unsigned int src)
121 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src]));
122 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + offsetof(CPU_DoubleU, l.upper));
123 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
124 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + offsetof(CPU_DoubleU, l.lower));
127 static void gen_op_load_fpr_DT1(unsigned int src)
129 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src]));
130 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt1) + offsetof(CPU_DoubleU, l.upper));
131 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
132 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt1) + offsetof(CPU_DoubleU, l.lower));
135 static void gen_op_store_DT0_fpr(unsigned int dst)
137 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + offsetof(CPU_DoubleU, l.upper));
138 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst]));
139 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + offsetof(CPU_DoubleU, l.lower));
140 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 1]));
143 #ifdef CONFIG_USER_ONLY
144 static void gen_op_load_fpr_QT0(unsigned int src)
146 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src]));
147 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.upmost));
148 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
149 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.upper));
150 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 2]));
151 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.lower));
152 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 3]));
153 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.lowest));
156 static void gen_op_load_fpr_QT1(unsigned int src)
158 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src]));
159 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + offsetof(CPU_QuadU, l.upmost));
160 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
161 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + offsetof(CPU_QuadU, l.upper));
162 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 2]));
163 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + offsetof(CPU_QuadU, l.lower));
164 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 3]));
165 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + offsetof(CPU_QuadU, l.lowest));
168 static void gen_op_store_QT0_fpr(unsigned int dst)
170 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.upmost));
171 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst]));
172 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.upper));
173 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 1]));
174 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.lower));
175 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 2]));
176 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + offsetof(CPU_QuadU, l.lowest));
177 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 3]));
182 #ifdef CONFIG_USER_ONLY
183 #define supervisor(dc) 0
184 #ifdef TARGET_SPARC64
185 #define hypervisor(dc) 0
187 #define gen_op_ldst(name) gen_op_##name##_raw()
189 #define supervisor(dc) (dc->mem_idx >= 1)
190 #ifdef TARGET_SPARC64
191 #define hypervisor(dc) (dc->mem_idx == 2)
192 #define OP_LD_TABLE(width) \
193 static GenOpFunc * const gen_op_##width[] = { \
194 &gen_op_##width##_user, \
195 &gen_op_##width##_kernel, \
196 &gen_op_##width##_hypv, \
199 #define OP_LD_TABLE(width) \
200 static GenOpFunc * const gen_op_##width[] = { \
201 &gen_op_##width##_user, \
202 &gen_op_##width##_kernel, \
205 #define gen_op_ldst(name) (*gen_op_##name[dc->mem_idx])()
208 #ifndef CONFIG_USER_ONLY
211 #endif /* __i386__ */
217 #define ABI32_MASK(addr) tcg_gen_andi_tl(addr, addr, 0xffffffffULL);
219 #define ABI32_MASK(addr)
222 static inline void gen_movl_reg_TN(int reg, TCGv tn)
225 tcg_gen_movi_tl(tn, 0);
227 tcg_gen_mov_tl(tn, cpu_gregs[reg]);
229 tcg_gen_ld_tl(tn, cpu_regwptr, (reg - 8) * sizeof(target_ulong));
233 static inline void gen_movl_TN_reg(int reg, TCGv tn)
238 tcg_gen_mov_tl(cpu_gregs[reg], tn);
240 tcg_gen_st_tl(tn, cpu_regwptr, (reg - 8) * sizeof(target_ulong));
244 static inline void gen_goto_tb(DisasContext *s, int tb_num,
245 target_ulong pc, target_ulong npc)
247 TranslationBlock *tb;
250 if ((pc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) &&
251 (npc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK)) {
252 /* jump to same page: we can use a direct jump */
253 tcg_gen_goto_tb(tb_num);
254 tcg_gen_movi_tl(cpu_pc, pc);
255 tcg_gen_movi_tl(cpu_npc, npc);
256 tcg_gen_exit_tb((long)tb + tb_num);
258 /* jump to another page: currently not optimized */
259 tcg_gen_movi_tl(cpu_pc, pc);
260 tcg_gen_movi_tl(cpu_npc, npc);
266 static inline void gen_mov_reg_N(TCGv reg, TCGv src)
268 tcg_gen_extu_i32_tl(reg, src);
269 tcg_gen_shri_tl(reg, reg, 23);
270 tcg_gen_andi_tl(reg, reg, 0x1);
273 static inline void gen_mov_reg_Z(TCGv reg, TCGv src)
275 tcg_gen_extu_i32_tl(reg, src);
276 tcg_gen_shri_tl(reg, reg, 22);
277 tcg_gen_andi_tl(reg, reg, 0x1);
280 static inline void gen_mov_reg_V(TCGv reg, TCGv src)
282 tcg_gen_extu_i32_tl(reg, src);
283 tcg_gen_shri_tl(reg, reg, 21);
284 tcg_gen_andi_tl(reg, reg, 0x1);
287 static inline void gen_mov_reg_C(TCGv reg, TCGv src)
289 tcg_gen_extu_i32_tl(reg, src);
290 tcg_gen_shri_tl(reg, reg, 20);
291 tcg_gen_andi_tl(reg, reg, 0x1);
294 static inline void gen_cc_clear_icc(void)
296 tcg_gen_movi_i32(cpu_psr, 0);
299 #ifdef TARGET_SPARC64
300 static inline void gen_cc_clear_xcc(void)
302 tcg_gen_movi_i32(cpu_xcc, 0);
308 env->psr |= PSR_ZERO;
309 if ((int32_t) T0 < 0)
312 static inline void gen_cc_NZ_icc(TCGv dst)
317 l1 = gen_new_label();
318 l2 = gen_new_label();
319 r_temp = tcg_temp_new(TCG_TYPE_TL);
320 tcg_gen_andi_tl(r_temp, dst, 0xffffffffULL);
321 tcg_gen_brcond_tl(TCG_COND_NE, r_temp, tcg_const_tl(0), l1);
322 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_ZERO);
324 tcg_gen_ext_i32_tl(r_temp, dst);
325 tcg_gen_brcond_tl(TCG_COND_GE, r_temp, tcg_const_tl(0), l2);
326 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_NEG);
330 #ifdef TARGET_SPARC64
331 static inline void gen_cc_NZ_xcc(TCGv dst)
335 l1 = gen_new_label();
336 l2 = gen_new_label();
337 tcg_gen_brcond_tl(TCG_COND_NE, dst, tcg_const_tl(0), l1);
338 tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_ZERO);
340 tcg_gen_brcond_tl(TCG_COND_GE, dst, tcg_const_tl(0), l2);
341 tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_NEG);
348 env->psr |= PSR_CARRY;
350 static inline void gen_cc_C_add_icc(TCGv dst, TCGv src1)
355 l1 = gen_new_label();
356 r_temp = tcg_temp_new(TCG_TYPE_TL);
357 tcg_gen_andi_tl(r_temp, dst, 0xffffffffULL);
358 tcg_gen_brcond_tl(TCG_COND_GEU, dst, src1, l1);
359 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_CARRY);
363 #ifdef TARGET_SPARC64
364 static inline void gen_cc_C_add_xcc(TCGv dst, TCGv src1)
368 l1 = gen_new_label();
369 tcg_gen_brcond_tl(TCG_COND_GEU, dst, src1, l1);
370 tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_CARRY);
376 if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
379 static inline void gen_cc_V_add_icc(TCGv dst, TCGv src1, TCGv src2)
384 l1 = gen_new_label();
386 r_temp = tcg_temp_new(TCG_TYPE_TL);
387 tcg_gen_xor_tl(r_temp, src1, src2);
388 tcg_gen_xori_tl(r_temp, r_temp, -1);
389 tcg_gen_xor_tl(cpu_tmp0, src1, dst);
390 tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0);
391 tcg_gen_andi_tl(r_temp, r_temp, (1 << 31));
392 tcg_gen_brcond_tl(TCG_COND_EQ, r_temp, tcg_const_tl(0), l1);
393 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF);
397 #ifdef TARGET_SPARC64
398 static inline void gen_cc_V_add_xcc(TCGv dst, TCGv src1, TCGv src2)
403 l1 = gen_new_label();
405 r_temp = tcg_temp_new(TCG_TYPE_TL);
406 tcg_gen_xor_tl(r_temp, src1, src2);
407 tcg_gen_xori_tl(r_temp, r_temp, -1);
408 tcg_gen_xor_tl(cpu_tmp0, src1, dst);
409 tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0);
410 tcg_gen_andi_tl(r_temp, r_temp, (1ULL << 63));
411 tcg_gen_brcond_tl(TCG_COND_EQ, r_temp, tcg_const_tl(0), l1);
412 tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_OVF);
417 static inline void gen_add_tv(TCGv dst, TCGv src1, TCGv src2)
422 l1 = gen_new_label();
424 r_temp = tcg_temp_new(TCG_TYPE_TL);
425 tcg_gen_xor_tl(r_temp, src1, src2);
426 tcg_gen_xori_tl(r_temp, r_temp, -1);
427 tcg_gen_xor_tl(cpu_tmp0, src1, dst);
428 tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0);
429 tcg_gen_andi_tl(r_temp, r_temp, (1 << 31));
430 tcg_gen_brcond_tl(TCG_COND_EQ, r_temp, tcg_const_tl(0), l1);
431 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_TOVF));
435 static inline void gen_cc_V_tag(TCGv src1, TCGv src2)
439 l1 = gen_new_label();
440 tcg_gen_or_tl(cpu_tmp0, src1, src2);
441 tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0x3);
442 tcg_gen_brcond_tl(TCG_COND_EQ, cpu_tmp0, tcg_const_tl(0), l1);
443 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF);
447 static inline void gen_tag_tv(TCGv src1, TCGv src2)
451 l1 = gen_new_label();
452 tcg_gen_or_tl(cpu_tmp0, src1, src2);
453 tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0x3);
454 tcg_gen_brcond_tl(TCG_COND_EQ, cpu_tmp0, tcg_const_tl(0), l1);
455 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_TOVF));
459 static inline void gen_op_add_cc(TCGv dst, TCGv src1, TCGv src2)
461 tcg_gen_mov_tl(cpu_cc_src, src1);
462 tcg_gen_add_tl(dst, src1, src2);
465 gen_cc_C_add_icc(dst, cpu_cc_src);
466 gen_cc_V_add_icc(dst, cpu_cc_src, src2);
467 #ifdef TARGET_SPARC64
470 gen_cc_C_add_xcc(dst, cpu_cc_src);
471 gen_cc_V_add_xcc(dst, cpu_cc_src, src2);
475 static inline void gen_op_addx_cc(TCGv dst, TCGv src1, TCGv src2)
477 tcg_gen_mov_tl(cpu_cc_src, src1);
478 gen_mov_reg_C(cpu_tmp0, cpu_psr);
479 tcg_gen_add_tl(dst, src1, cpu_tmp0);
481 gen_cc_C_add_icc(dst, cpu_cc_src);
482 #ifdef TARGET_SPARC64
484 gen_cc_C_add_xcc(dst, cpu_cc_src);
486 tcg_gen_add_tl(dst, dst, src2);
488 gen_cc_C_add_icc(dst, cpu_cc_src);
489 gen_cc_V_add_icc(dst, cpu_cc_src, src2);
490 #ifdef TARGET_SPARC64
492 gen_cc_C_add_xcc(dst, cpu_cc_src);
493 gen_cc_V_add_xcc(dst, cpu_cc_src, src2);
497 static inline void gen_op_tadd_cc(TCGv dst, TCGv src1, TCGv src2)
499 tcg_gen_mov_tl(cpu_cc_src, src1);
500 tcg_gen_add_tl(dst, src1, src2);
503 gen_cc_C_add_icc(dst, cpu_cc_src);
504 gen_cc_V_add_icc(dst, cpu_cc_src, src2);
505 gen_cc_V_tag(cpu_cc_src, src2);
506 #ifdef TARGET_SPARC64
509 gen_cc_C_add_xcc(dst, cpu_cc_src);
510 gen_cc_V_add_xcc(dst, cpu_cc_src, src2);
514 static inline void gen_op_tadd_ccTV(TCGv dst, TCGv src1, TCGv src2)
516 gen_tag_tv(src1, src2);
517 tcg_gen_mov_tl(cpu_cc_src, src1);
518 tcg_gen_add_tl(dst, src1, src2);
519 gen_add_tv(dst, cpu_cc_src, src2);
522 gen_cc_C_add_icc(dst, cpu_cc_src);
523 #ifdef TARGET_SPARC64
526 gen_cc_C_add_xcc(dst, cpu_cc_src);
527 gen_cc_V_add_xcc(dst, cpu_cc_src, src2);
533 env->psr |= PSR_CARRY;
535 static inline void gen_cc_C_sub_icc(TCGv src1, TCGv src2)
537 TCGv r_temp1, r_temp2;
540 l1 = gen_new_label();
541 r_temp1 = tcg_temp_new(TCG_TYPE_TL);
542 r_temp2 = tcg_temp_new(TCG_TYPE_TL);
543 tcg_gen_andi_tl(r_temp1, src1, 0xffffffffULL);
544 tcg_gen_andi_tl(r_temp2, src2, 0xffffffffULL);
545 tcg_gen_brcond_tl(TCG_COND_GEU, r_temp1, r_temp2, l1);
546 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_CARRY);
550 #ifdef TARGET_SPARC64
551 static inline void gen_cc_C_sub_xcc(TCGv src1, TCGv src2)
555 l1 = gen_new_label();
556 tcg_gen_brcond_tl(TCG_COND_GEU, src1, src2, l1);
557 tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_CARRY);
563 if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
566 static inline void gen_cc_V_sub_icc(TCGv dst, TCGv src1, TCGv src2)
571 l1 = gen_new_label();
573 r_temp = tcg_temp_new(TCG_TYPE_TL);
574 tcg_gen_xor_tl(r_temp, src1, src2);
575 tcg_gen_xor_tl(cpu_tmp0, src1, dst);
576 tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0);
577 tcg_gen_andi_tl(r_temp, r_temp, (1 << 31));
578 tcg_gen_brcond_tl(TCG_COND_EQ, r_temp, tcg_const_tl(0), l1);
579 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF);
583 #ifdef TARGET_SPARC64
584 static inline void gen_cc_V_sub_xcc(TCGv dst, TCGv src1, TCGv src2)
589 l1 = gen_new_label();
591 r_temp = tcg_temp_new(TCG_TYPE_TL);
592 tcg_gen_xor_tl(r_temp, src1, src2);
593 tcg_gen_xor_tl(cpu_tmp0, src1, dst);
594 tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0);
595 tcg_gen_andi_tl(r_temp, r_temp, (1ULL << 63));
596 tcg_gen_brcond_tl(TCG_COND_EQ, r_temp, tcg_const_tl(0), l1);
597 tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_OVF);
602 static inline void gen_sub_tv(TCGv dst, TCGv src1, TCGv src2)
607 l1 = gen_new_label();
609 r_temp = tcg_temp_new(TCG_TYPE_TL);
610 tcg_gen_xor_tl(r_temp, src1, src2);
611 tcg_gen_xor_tl(cpu_tmp0, src1, dst);
612 tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0);
613 tcg_gen_andi_tl(r_temp, r_temp, (1 << 31));
614 tcg_gen_brcond_tl(TCG_COND_EQ, r_temp, tcg_const_tl(0), l1);
615 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_TOVF));
617 tcg_gen_discard_tl(r_temp);
620 static inline void gen_op_sub_cc(TCGv dst, TCGv src1, TCGv src2)
622 tcg_gen_mov_tl(cpu_cc_src, src1);
623 tcg_gen_sub_tl(dst, src1, src2);
626 gen_cc_C_sub_icc(cpu_cc_src, src2);
627 gen_cc_V_sub_icc(dst, cpu_cc_src, src2);
628 #ifdef TARGET_SPARC64
631 gen_cc_C_sub_xcc(cpu_cc_src, src2);
632 gen_cc_V_sub_xcc(dst, cpu_cc_src, src2);
636 static inline void gen_op_subx_cc(TCGv dst, TCGv src1, TCGv src2)
638 tcg_gen_mov_tl(cpu_cc_src, src1);
639 gen_mov_reg_C(cpu_tmp0, cpu_psr);
640 tcg_gen_sub_tl(dst, src1, cpu_tmp0);
642 gen_cc_C_sub_icc(dst, cpu_cc_src);
643 #ifdef TARGET_SPARC64
645 gen_cc_C_sub_xcc(dst, cpu_cc_src);
647 tcg_gen_sub_tl(dst, dst, src2);
649 gen_cc_C_sub_icc(dst, cpu_cc_src);
650 gen_cc_V_sub_icc(dst, cpu_cc_src, src2);
651 #ifdef TARGET_SPARC64
653 gen_cc_C_sub_xcc(dst, cpu_cc_src);
654 gen_cc_V_sub_xcc(dst, cpu_cc_src, src2);
658 static inline void gen_op_tsub_cc(TCGv dst, TCGv src1, TCGv src2)
660 tcg_gen_mov_tl(cpu_cc_src, src1);
661 tcg_gen_sub_tl(dst, src1, src2);
664 gen_cc_C_sub_icc(cpu_cc_src, src2);
665 gen_cc_V_sub_icc(dst, cpu_cc_src, src2);
666 gen_cc_V_tag(cpu_cc_src, src2);
667 #ifdef TARGET_SPARC64
670 gen_cc_C_sub_xcc(cpu_cc_src, src2);
671 gen_cc_V_sub_xcc(dst, cpu_cc_src, src2);
675 static inline void gen_op_tsub_ccTV(TCGv dst, TCGv src1, TCGv src2)
677 gen_tag_tv(src1, src2);
678 tcg_gen_mov_tl(cpu_cc_src, src1);
679 tcg_gen_sub_tl(dst, src1, src2);
680 gen_sub_tv(dst, cpu_cc_src, src2);
683 gen_cc_C_sub_icc(cpu_cc_src, src2);
684 #ifdef TARGET_SPARC64
687 gen_cc_C_sub_xcc(cpu_cc_src, src2);
688 gen_cc_V_sub_xcc(dst, cpu_cc_src, src2);
692 static inline void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2)
694 TCGv r_temp, r_temp2;
697 l1 = gen_new_label();
698 l2 = gen_new_label();
699 r_temp = tcg_temp_new(TCG_TYPE_TL);
700 r_temp2 = tcg_temp_new(TCG_TYPE_I32);
706 tcg_gen_ld32u_tl(r_temp, cpu_env, offsetof(CPUSPARCState, y));
707 tcg_gen_trunc_tl_i32(r_temp2, r_temp);
708 tcg_gen_andi_i32(r_temp2, r_temp2, 0x1);
709 tcg_gen_brcond_i32(TCG_COND_EQ, r_temp2, tcg_const_i32(0), l1);
710 tcg_gen_mov_tl(cpu_cc_src2, src2);
713 tcg_gen_movi_tl(cpu_cc_src2, 0);
717 // env->y = (b2 << 31) | (env->y >> 1);
718 tcg_gen_trunc_tl_i32(r_temp2, src1);
719 tcg_gen_andi_i32(r_temp2, r_temp2, 0x1);
720 tcg_gen_shli_i32(r_temp2, r_temp2, 31);
721 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, y));
722 tcg_gen_shri_i32(cpu_tmp32, cpu_tmp32, 1);
723 tcg_gen_or_i32(cpu_tmp32, cpu_tmp32, r_temp2);
724 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, y));
727 gen_mov_reg_N(cpu_tmp0, cpu_psr);
728 gen_mov_reg_V(r_temp, cpu_psr);
729 tcg_gen_xor_tl(cpu_tmp0, cpu_tmp0, r_temp);
731 // T0 = (b1 << 31) | (T0 >> 1);
733 tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, 31);
734 tcg_gen_shri_tl(cpu_cc_src, src1, 1);
735 tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_tmp0);
737 /* do addition and update flags */
738 tcg_gen_add_tl(dst, cpu_cc_src, cpu_cc_src2);
739 tcg_gen_discard_tl(r_temp);
743 gen_cc_V_add_icc(dst, cpu_cc_src, cpu_cc_src2);
744 gen_cc_C_add_icc(dst, cpu_cc_src);
747 static inline void gen_op_umul(TCGv dst, TCGv src1, TCGv src2)
749 TCGv r_temp, r_temp2;
751 r_temp = tcg_temp_new(TCG_TYPE_I64);
752 r_temp2 = tcg_temp_new(TCG_TYPE_I64);
754 tcg_gen_extu_tl_i64(r_temp, src2);
755 tcg_gen_extu_tl_i64(r_temp2, src1);
756 tcg_gen_mul_i64(r_temp2, r_temp, r_temp2);
758 tcg_gen_shri_i64(r_temp, r_temp2, 32);
759 tcg_gen_trunc_i64_i32(r_temp, r_temp);
760 tcg_gen_st_i32(r_temp, cpu_env, offsetof(CPUSPARCState, y));
761 #ifdef TARGET_SPARC64
762 tcg_gen_mov_i64(dst, r_temp2);
764 tcg_gen_trunc_i64_tl(dst, r_temp2);
767 tcg_gen_discard_i64(r_temp);
768 tcg_gen_discard_i64(r_temp2);
771 static inline void gen_op_smul(TCGv dst, TCGv src1, TCGv src2)
773 TCGv r_temp, r_temp2;
775 r_temp = tcg_temp_new(TCG_TYPE_I64);
776 r_temp2 = tcg_temp_new(TCG_TYPE_I64);
778 tcg_gen_ext_tl_i64(r_temp, src2);
779 tcg_gen_ext_tl_i64(r_temp2, src1);
780 tcg_gen_mul_i64(r_temp2, r_temp, r_temp2);
782 tcg_gen_shri_i64(r_temp, r_temp2, 32);
783 tcg_gen_trunc_i64_i32(r_temp, r_temp);
784 tcg_gen_st_i32(r_temp, cpu_env, offsetof(CPUSPARCState, y));
785 #ifdef TARGET_SPARC64
786 tcg_gen_mov_i64(dst, r_temp2);
788 tcg_gen_trunc_i64_tl(dst, r_temp2);
791 tcg_gen_discard_i64(r_temp);
792 tcg_gen_discard_i64(r_temp2);
795 #ifdef TARGET_SPARC64
796 static inline void gen_trap_ifdivzero_tl(TCGv divisor)
800 l1 = gen_new_label();
801 tcg_gen_brcond_tl(TCG_COND_NE, divisor, tcg_const_tl(0), l1);
802 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_DIV_ZERO));
806 static inline void gen_op_sdivx(TCGv dst, TCGv src1, TCGv src2)
810 l1 = gen_new_label();
811 l2 = gen_new_label();
812 gen_trap_ifdivzero_tl(src2);
813 tcg_gen_brcond_tl(TCG_COND_NE, src1, tcg_const_tl(INT64_MIN), l1);
814 tcg_gen_brcond_tl(TCG_COND_NE, src2, tcg_const_tl(-1), l1);
815 tcg_gen_movi_i64(dst, INT64_MIN);
818 tcg_gen_div_i64(dst, src1, src2);
823 static inline void gen_op_div_cc(TCGv dst)
829 l1 = gen_new_label();
830 tcg_gen_ld_tl(cpu_tmp0, cpu_env, offsetof(CPUSPARCState, cc_src2));
831 tcg_gen_brcond_tl(TCG_COND_EQ, cpu_tmp0, tcg_const_tl(0), l1);
832 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF);
836 static inline void gen_op_logic_cc(TCGv dst)
840 #ifdef TARGET_SPARC64
847 static inline void gen_op_eval_ba(TCGv dst)
849 tcg_gen_movi_tl(dst, 1);
853 static inline void gen_op_eval_be(TCGv dst, TCGv src)
855 gen_mov_reg_Z(dst, src);
859 static inline void gen_op_eval_ble(TCGv dst, TCGv src)
861 gen_mov_reg_N(cpu_tmp0, src);
862 gen_mov_reg_V(dst, src);
863 tcg_gen_xor_tl(dst, dst, cpu_tmp0);
864 gen_mov_reg_Z(cpu_tmp0, src);
865 tcg_gen_or_tl(dst, dst, cpu_tmp0);
869 static inline void gen_op_eval_bl(TCGv dst, TCGv src)
871 gen_mov_reg_V(cpu_tmp0, src);
872 gen_mov_reg_N(dst, src);
873 tcg_gen_xor_tl(dst, dst, cpu_tmp0);
877 static inline void gen_op_eval_bleu(TCGv dst, TCGv src)
879 gen_mov_reg_Z(cpu_tmp0, src);
880 gen_mov_reg_C(dst, src);
881 tcg_gen_or_tl(dst, dst, cpu_tmp0);
885 static inline void gen_op_eval_bcs(TCGv dst, TCGv src)
887 gen_mov_reg_C(dst, src);
891 static inline void gen_op_eval_bvs(TCGv dst, TCGv src)
893 gen_mov_reg_V(dst, src);
897 static inline void gen_op_eval_bn(TCGv dst)
899 tcg_gen_movi_tl(dst, 0);
903 static inline void gen_op_eval_bneg(TCGv dst, TCGv src)
905 gen_mov_reg_N(dst, src);
909 static inline void gen_op_eval_bne(TCGv dst, TCGv src)
911 gen_mov_reg_Z(dst, src);
912 tcg_gen_xori_tl(dst, dst, 0x1);
916 static inline void gen_op_eval_bg(TCGv dst, TCGv src)
918 gen_mov_reg_N(cpu_tmp0, src);
919 gen_mov_reg_V(dst, src);
920 tcg_gen_xor_tl(dst, dst, cpu_tmp0);
921 gen_mov_reg_Z(cpu_tmp0, src);
922 tcg_gen_or_tl(dst, dst, cpu_tmp0);
923 tcg_gen_xori_tl(dst, dst, 0x1);
927 static inline void gen_op_eval_bge(TCGv dst, TCGv src)
929 gen_mov_reg_V(cpu_tmp0, src);
930 gen_mov_reg_N(dst, src);
931 tcg_gen_xor_tl(dst, dst, cpu_tmp0);
932 tcg_gen_xori_tl(dst, dst, 0x1);
936 static inline void gen_op_eval_bgu(TCGv dst, TCGv src)
938 gen_mov_reg_Z(cpu_tmp0, src);
939 gen_mov_reg_C(dst, src);
940 tcg_gen_or_tl(dst, dst, cpu_tmp0);
941 tcg_gen_xori_tl(dst, dst, 0x1);
945 static inline void gen_op_eval_bcc(TCGv dst, TCGv src)
947 gen_mov_reg_C(dst, src);
948 tcg_gen_xori_tl(dst, dst, 0x1);
952 static inline void gen_op_eval_bpos(TCGv dst, TCGv src)
954 gen_mov_reg_N(dst, src);
955 tcg_gen_xori_tl(dst, dst, 0x1);
959 static inline void gen_op_eval_bvc(TCGv dst, TCGv src)
961 gen_mov_reg_V(dst, src);
962 tcg_gen_xori_tl(dst, dst, 0x1);
966 FPSR bit field FCC1 | FCC0:
972 static inline void gen_mov_reg_FCC0(TCGv reg, TCGv src,
973 unsigned int fcc_offset)
975 tcg_gen_extu_i32_tl(reg, src);
976 tcg_gen_shri_tl(reg, reg, 10 + fcc_offset);
977 tcg_gen_andi_tl(reg, reg, 0x1);
980 static inline void gen_mov_reg_FCC1(TCGv reg, TCGv src,
981 unsigned int fcc_offset)
983 tcg_gen_extu_i32_tl(reg, src);
984 tcg_gen_shri_tl(reg, reg, 11 + fcc_offset);
985 tcg_gen_andi_tl(reg, reg, 0x1);
989 static inline void gen_op_eval_fbne(TCGv dst, TCGv src,
990 unsigned int fcc_offset)
992 gen_mov_reg_FCC0(dst, src, fcc_offset);
993 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
994 tcg_gen_or_tl(dst, dst, cpu_tmp0);
997 // 1 or 2: FCC0 ^ FCC1
998 static inline void gen_op_eval_fblg(TCGv dst, TCGv src,
999 unsigned int fcc_offset)
1001 gen_mov_reg_FCC0(dst, src, fcc_offset);
1002 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1003 tcg_gen_xor_tl(dst, dst, cpu_tmp0);
1007 static inline void gen_op_eval_fbul(TCGv dst, TCGv src,
1008 unsigned int fcc_offset)
1010 gen_mov_reg_FCC0(dst, src, fcc_offset);
1014 static inline void gen_op_eval_fbl(TCGv dst, TCGv src,
1015 unsigned int fcc_offset)
1017 gen_mov_reg_FCC0(dst, src, fcc_offset);
1018 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1019 tcg_gen_xori_tl(cpu_tmp0, cpu_tmp0, 0x1);
1020 tcg_gen_and_tl(dst, dst, cpu_tmp0);
1024 static inline void gen_op_eval_fbug(TCGv dst, TCGv src,
1025 unsigned int fcc_offset)
1027 gen_mov_reg_FCC1(dst, src, fcc_offset);
1031 static inline void gen_op_eval_fbg(TCGv dst, TCGv src,
1032 unsigned int fcc_offset)
1034 gen_mov_reg_FCC0(dst, src, fcc_offset);
1035 tcg_gen_xori_tl(dst, dst, 0x1);
1036 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1037 tcg_gen_and_tl(dst, dst, cpu_tmp0);
1041 static inline void gen_op_eval_fbu(TCGv dst, TCGv src,
1042 unsigned int fcc_offset)
1044 gen_mov_reg_FCC0(dst, src, fcc_offset);
1045 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1046 tcg_gen_and_tl(dst, dst, cpu_tmp0);
1049 // 0: !(FCC0 | FCC1)
1050 static inline void gen_op_eval_fbe(TCGv dst, TCGv src,
1051 unsigned int fcc_offset)
1053 gen_mov_reg_FCC0(dst, src, fcc_offset);
1054 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1055 tcg_gen_or_tl(dst, dst, cpu_tmp0);
1056 tcg_gen_xori_tl(dst, dst, 0x1);
1059 // 0 or 3: !(FCC0 ^ FCC1)
1060 static inline void gen_op_eval_fbue(TCGv dst, TCGv src,
1061 unsigned int fcc_offset)
1063 gen_mov_reg_FCC0(dst, src, fcc_offset);
1064 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1065 tcg_gen_xor_tl(dst, dst, cpu_tmp0);
1066 tcg_gen_xori_tl(dst, dst, 0x1);
1070 static inline void gen_op_eval_fbge(TCGv dst, TCGv src,
1071 unsigned int fcc_offset)
1073 gen_mov_reg_FCC0(dst, src, fcc_offset);
1074 tcg_gen_xori_tl(dst, dst, 0x1);
1077 // !1: !(FCC0 & !FCC1)
1078 static inline void gen_op_eval_fbuge(TCGv dst, TCGv src,
1079 unsigned int fcc_offset)
1081 gen_mov_reg_FCC0(dst, src, fcc_offset);
1082 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1083 tcg_gen_xori_tl(cpu_tmp0, cpu_tmp0, 0x1);
1084 tcg_gen_and_tl(dst, dst, cpu_tmp0);
1085 tcg_gen_xori_tl(dst, dst, 0x1);
1089 static inline void gen_op_eval_fble(TCGv dst, TCGv src,
1090 unsigned int fcc_offset)
1092 gen_mov_reg_FCC1(dst, src, fcc_offset);
1093 tcg_gen_xori_tl(dst, dst, 0x1);
1096 // !2: !(!FCC0 & FCC1)
1097 static inline void gen_op_eval_fbule(TCGv dst, TCGv src,
1098 unsigned int fcc_offset)
1100 gen_mov_reg_FCC0(dst, src, fcc_offset);
1101 tcg_gen_xori_tl(dst, dst, 0x1);
1102 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1103 tcg_gen_and_tl(dst, dst, cpu_tmp0);
1104 tcg_gen_xori_tl(dst, dst, 0x1);
1107 // !3: !(FCC0 & FCC1)
1108 static inline void gen_op_eval_fbo(TCGv dst, TCGv src,
1109 unsigned int fcc_offset)
1111 gen_mov_reg_FCC0(dst, src, fcc_offset);
1112 gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
1113 tcg_gen_and_tl(dst, dst, cpu_tmp0);
1114 tcg_gen_xori_tl(dst, dst, 0x1);
1117 static inline void gen_branch2(DisasContext *dc, target_ulong pc1,
1118 target_ulong pc2, TCGv r_cond)
1122 l1 = gen_new_label();
1124 tcg_gen_brcond_tl(TCG_COND_EQ, r_cond, tcg_const_tl(0), l1);
1126 gen_goto_tb(dc, 0, pc1, pc1 + 4);
1129 gen_goto_tb(dc, 1, pc2, pc2 + 4);
1132 static inline void gen_branch_a(DisasContext *dc, target_ulong pc1,
1133 target_ulong pc2, TCGv r_cond)
1137 l1 = gen_new_label();
1139 tcg_gen_brcond_tl(TCG_COND_EQ, r_cond, tcg_const_tl(0), l1);
1141 gen_goto_tb(dc, 0, pc2, pc1);
1144 gen_goto_tb(dc, 1, pc2 + 4, pc2 + 8);
1147 static inline void gen_generic_branch(target_ulong npc1, target_ulong npc2,
1152 l1 = gen_new_label();
1153 l2 = gen_new_label();
1155 tcg_gen_brcond_tl(TCG_COND_EQ, r_cond, tcg_const_tl(0), l1);
1157 tcg_gen_movi_tl(cpu_npc, npc1);
1161 tcg_gen_movi_tl(cpu_npc, npc2);
1165 /* call this function before using the condition register as it may
1166 have been set for a jump */
1167 static inline void flush_cond(DisasContext *dc, TCGv cond)
1169 if (dc->npc == JUMP_PC) {
1170 gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1], cond);
1171 dc->npc = DYNAMIC_PC;
1175 static inline void save_npc(DisasContext *dc, TCGv cond)
1177 if (dc->npc == JUMP_PC) {
1178 gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1], cond);
1179 dc->npc = DYNAMIC_PC;
1180 } else if (dc->npc != DYNAMIC_PC) {
1181 tcg_gen_movi_tl(cpu_npc, dc->npc);
1185 static inline void save_state(DisasContext *dc, TCGv cond)
1187 tcg_gen_movi_tl(cpu_pc, dc->pc);
1191 static inline void gen_mov_pc_npc(DisasContext *dc, TCGv cond)
1193 if (dc->npc == JUMP_PC) {
1194 gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1], cond);
1195 tcg_gen_mov_tl(cpu_pc, cpu_npc);
1196 dc->pc = DYNAMIC_PC;
1197 } else if (dc->npc == DYNAMIC_PC) {
1198 tcg_gen_mov_tl(cpu_pc, cpu_npc);
1199 dc->pc = DYNAMIC_PC;
1205 static inline void gen_op_next_insn(void)
1207 tcg_gen_mov_tl(cpu_pc, cpu_npc);
1208 tcg_gen_addi_tl(cpu_npc, cpu_npc, 4);
1211 static inline void gen_cond(TCGv r_dst, unsigned int cc, unsigned int cond)
1215 #ifdef TARGET_SPARC64
1225 gen_op_eval_bn(r_dst);
1228 gen_op_eval_be(r_dst, r_src);
1231 gen_op_eval_ble(r_dst, r_src);
1234 gen_op_eval_bl(r_dst, r_src);
1237 gen_op_eval_bleu(r_dst, r_src);
1240 gen_op_eval_bcs(r_dst, r_src);
1243 gen_op_eval_bneg(r_dst, r_src);
1246 gen_op_eval_bvs(r_dst, r_src);
1249 gen_op_eval_ba(r_dst);
1252 gen_op_eval_bne(r_dst, r_src);
1255 gen_op_eval_bg(r_dst, r_src);
1258 gen_op_eval_bge(r_dst, r_src);
1261 gen_op_eval_bgu(r_dst, r_src);
1264 gen_op_eval_bcc(r_dst, r_src);
1267 gen_op_eval_bpos(r_dst, r_src);
1270 gen_op_eval_bvc(r_dst, r_src);
1275 static inline void gen_fcond(TCGv r_dst, unsigned int cc, unsigned int cond)
1277 unsigned int offset;
1297 gen_op_eval_bn(r_dst);
1300 gen_op_eval_fbne(r_dst, cpu_fsr, offset);
1303 gen_op_eval_fblg(r_dst, cpu_fsr, offset);
1306 gen_op_eval_fbul(r_dst, cpu_fsr, offset);
1309 gen_op_eval_fbl(r_dst, cpu_fsr, offset);
1312 gen_op_eval_fbug(r_dst, cpu_fsr, offset);
1315 gen_op_eval_fbg(r_dst, cpu_fsr, offset);
1318 gen_op_eval_fbu(r_dst, cpu_fsr, offset);
1321 gen_op_eval_ba(r_dst);
1324 gen_op_eval_fbe(r_dst, cpu_fsr, offset);
1327 gen_op_eval_fbue(r_dst, cpu_fsr, offset);
1330 gen_op_eval_fbge(r_dst, cpu_fsr, offset);
1333 gen_op_eval_fbuge(r_dst, cpu_fsr, offset);
1336 gen_op_eval_fble(r_dst, cpu_fsr, offset);
1339 gen_op_eval_fbule(r_dst, cpu_fsr, offset);
1342 gen_op_eval_fbo(r_dst, cpu_fsr, offset);
1347 #ifdef TARGET_SPARC64
1349 static const int gen_tcg_cond_reg[8] = {
1360 static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src)
1364 l1 = gen_new_label();
1365 tcg_gen_movi_tl(r_dst, 0);
1366 tcg_gen_brcond_tl(gen_tcg_cond_reg[cond], r_src, tcg_const_tl(0), l1);
1367 tcg_gen_movi_tl(r_dst, 1);
1372 /* XXX: potentially incorrect if dynamic npc */
1373 static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
1376 unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
1377 target_ulong target = dc->pc + offset;
1380 /* unconditional not taken */
1382 dc->pc = dc->npc + 4;
1383 dc->npc = dc->pc + 4;
1386 dc->npc = dc->pc + 4;
1388 } else if (cond == 0x8) {
1389 /* unconditional taken */
1392 dc->npc = dc->pc + 4;
1398 flush_cond(dc, r_cond);
1399 gen_cond(r_cond, cc, cond);
1401 gen_branch_a(dc, target, dc->npc, r_cond);
1405 dc->jump_pc[0] = target;
1406 dc->jump_pc[1] = dc->npc + 4;
1412 /* XXX: potentially incorrect if dynamic npc */
1413 static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
1416 unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
1417 target_ulong target = dc->pc + offset;
1420 /* unconditional not taken */
1422 dc->pc = dc->npc + 4;
1423 dc->npc = dc->pc + 4;
1426 dc->npc = dc->pc + 4;
1428 } else if (cond == 0x8) {
1429 /* unconditional taken */
1432 dc->npc = dc->pc + 4;
1438 flush_cond(dc, r_cond);
1439 gen_fcond(r_cond, cc, cond);
1441 gen_branch_a(dc, target, dc->npc, r_cond);
1445 dc->jump_pc[0] = target;
1446 dc->jump_pc[1] = dc->npc + 4;
1452 #ifdef TARGET_SPARC64
1453 /* XXX: potentially incorrect if dynamic npc */
1454 static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,
1455 TCGv r_cond, TCGv r_reg)
1457 unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29));
1458 target_ulong target = dc->pc + offset;
1460 flush_cond(dc, r_cond);
1461 gen_cond_reg(r_cond, cond, r_reg);
1463 gen_branch_a(dc, target, dc->npc, r_cond);
1467 dc->jump_pc[0] = target;
1468 dc->jump_pc[1] = dc->npc + 4;
1473 static GenOpFunc * const gen_fcmps[4] = {
1480 static GenOpFunc * const gen_fcmpd[4] = {
1487 #if defined(CONFIG_USER_ONLY)
1488 static GenOpFunc * const gen_fcmpq[4] = {
1496 static GenOpFunc * const gen_fcmpes[4] = {
1503 static GenOpFunc * const gen_fcmped[4] = {
1510 #if defined(CONFIG_USER_ONLY)
1511 static GenOpFunc * const gen_fcmpeq[4] = {
1519 static inline void gen_op_fcmps(int fccno)
1521 tcg_gen_helper_0_0(gen_fcmps[fccno]);
1524 static inline void gen_op_fcmpd(int fccno)
1526 tcg_gen_helper_0_0(gen_fcmpd[fccno]);
1529 #if defined(CONFIG_USER_ONLY)
1530 static inline void gen_op_fcmpq(int fccno)
1532 tcg_gen_helper_0_0(gen_fcmpq[fccno]);
1536 static inline void gen_op_fcmpes(int fccno)
1538 tcg_gen_helper_0_0(gen_fcmpes[fccno]);
1541 static inline void gen_op_fcmped(int fccno)
1543 tcg_gen_helper_0_0(gen_fcmped[fccno]);
1546 #if defined(CONFIG_USER_ONLY)
1547 static inline void gen_op_fcmpeq(int fccno)
1549 tcg_gen_helper_0_0(gen_fcmpeq[fccno]);
1555 static inline void gen_op_fcmps(int fccno)
1557 tcg_gen_helper_0_0(helper_fcmps);
1560 static inline void gen_op_fcmpd(int fccno)
1562 tcg_gen_helper_0_0(helper_fcmpd);
1565 #if defined(CONFIG_USER_ONLY)
1566 static inline void gen_op_fcmpq(int fccno)
1568 tcg_gen_helper_0_0(helper_fcmpq);
1572 static inline void gen_op_fcmpes(int fccno)
1574 tcg_gen_helper_0_0(helper_fcmpes);
1577 static inline void gen_op_fcmped(int fccno)
1579 tcg_gen_helper_0_0(helper_fcmped);
1582 #if defined(CONFIG_USER_ONLY)
1583 static inline void gen_op_fcmpeq(int fccno)
1585 tcg_gen_helper_0_0(helper_fcmpeq);
1591 static inline void gen_op_fpexception_im(int fsr_flags)
1593 tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK);
1594 tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags);
1595 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_FP_EXCP));
1598 static int gen_trap_ifnofpu(DisasContext *dc, TCGv r_cond)
1600 #if !defined(CONFIG_USER_ONLY)
1601 if (!dc->fpu_enabled) {
1602 save_state(dc, r_cond);
1603 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_NFPU_INSN));
1611 static inline void gen_op_clear_ieee_excp_and_FTT(void)
1613 tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));
1616 static inline void gen_clear_float_exceptions(void)
1618 tcg_gen_helper_0_0(helper_clear_float_exceptions);
1622 #ifdef TARGET_SPARC64
1623 static inline TCGv gen_get_asi(int insn, TCGv r_addr)
1629 r_asi = tcg_temp_new(TCG_TYPE_I32);
1630 offset = GET_FIELD(insn, 25, 31);
1631 tcg_gen_addi_tl(r_addr, r_addr, offset);
1632 tcg_gen_ld_i32(r_asi, cpu_env, offsetof(CPUSPARCState, asi));
1634 asi = GET_FIELD(insn, 19, 26);
1635 r_asi = tcg_const_i32(asi);
1640 static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size, int sign)
1644 r_asi = gen_get_asi(insn, addr);
1645 tcg_gen_helper_1_4(helper_ld_asi, dst, addr, r_asi,
1646 tcg_const_i32(size), tcg_const_i32(sign));
1647 tcg_gen_discard_i32(r_asi);
1650 static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size)
1654 r_asi = gen_get_asi(insn, addr);
1655 tcg_gen_helper_0_4(helper_st_asi, addr, src, r_asi, tcg_const_i32(size));
1656 tcg_gen_discard_i32(r_asi);
1659 static inline void gen_ldf_asi(TCGv addr, int insn, int size, int rd)
1663 r_asi = gen_get_asi(insn, addr);
1664 tcg_gen_helper_0_4(helper_ldf_asi, addr, r_asi, tcg_const_i32(size),
1666 tcg_gen_discard_i32(r_asi);
1669 static inline void gen_stf_asi(TCGv addr, int insn, int size, int rd)
1673 r_asi = gen_get_asi(insn, addr);
1674 tcg_gen_helper_0_4(helper_stf_asi, addr, r_asi, tcg_const_i32(size),
1676 tcg_gen_discard_i32(r_asi);
1679 static inline void gen_swap_asi(TCGv dst, TCGv addr, int insn)
1683 r_temp = tcg_temp_new(TCG_TYPE_I32);
1684 r_asi = gen_get_asi(insn, addr);
1685 tcg_gen_helper_1_4(helper_ld_asi, r_temp, addr, r_asi,
1686 tcg_const_i32(4), tcg_const_i32(0));
1687 tcg_gen_helper_0_4(helper_st_asi, addr, dst, r_asi,
1689 tcg_gen_extu_i32_tl(dst, r_temp);
1690 tcg_gen_discard_i32(r_asi);
1691 tcg_gen_discard_i32(r_temp);
1694 static inline void gen_ldda_asi(TCGv lo, TCGv hi, TCGv addr, int insn)
1698 r_asi = gen_get_asi(insn, addr);
1699 tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, r_asi,
1700 tcg_const_i32(8), tcg_const_i32(0));
1701 tcg_gen_andi_i64(lo, cpu_tmp64, 0xffffffffULL);
1702 tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);
1703 tcg_gen_andi_i64(hi, cpu_tmp64, 0xffffffffULL);
1704 tcg_gen_discard_i32(r_asi);
1707 static inline void gen_stda_asi(TCGv hi, TCGv addr, int insn, int rd)
1711 r_temp = tcg_temp_new(TCG_TYPE_I32);
1712 gen_movl_reg_TN(rd + 1, r_temp);
1713 tcg_gen_helper_1_2(helper_pack64, cpu_tmp64, hi,
1715 r_asi = gen_get_asi(insn, addr);
1716 tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, r_asi,
1718 tcg_gen_discard_i32(r_asi);
1719 tcg_gen_discard_i32(r_temp);
1722 static inline void gen_cas_asi(TCGv dst, TCGv addr, TCGv val2, int insn, int rd)
1726 r_val1 = tcg_temp_new(TCG_TYPE_I32);
1727 gen_movl_reg_TN(rd, r_val1);
1728 r_asi = gen_get_asi(insn, addr);
1729 tcg_gen_helper_1_4(helper_cas_asi, dst, addr, r_val1, val2, r_asi);
1730 tcg_gen_discard_i32(r_asi);
1731 tcg_gen_discard_i32(r_val1);
1734 static inline void gen_casx_asi(TCGv dst, TCGv addr, TCGv val2, int insn, int rd)
1738 gen_movl_reg_TN(rd, cpu_tmp64);
1739 r_asi = gen_get_asi(insn, addr);
1740 tcg_gen_helper_1_4(helper_casx_asi, dst, addr, cpu_tmp64, val2, r_asi);
1741 tcg_gen_discard_i32(r_asi);
1744 #elif !defined(CONFIG_USER_ONLY)
1746 static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size, int sign)
1750 asi = GET_FIELD(insn, 19, 26);
1751 tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, tcg_const_i32(asi),
1752 tcg_const_i32(size), tcg_const_i32(sign));
1753 tcg_gen_trunc_i64_tl(dst, cpu_tmp64);
1756 static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size)
1760 tcg_gen_extu_tl_i64(cpu_tmp64, src);
1761 asi = GET_FIELD(insn, 19, 26);
1762 tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, tcg_const_i32(asi),
1763 tcg_const_i32(size));
1766 static inline void gen_swap_asi(TCGv dst, TCGv addr, int insn)
1771 r_temp = tcg_temp_new(TCG_TYPE_I32);
1772 asi = GET_FIELD(insn, 19, 26);
1773 tcg_gen_helper_1_4(helper_ld_asi, r_temp, addr, tcg_const_i32(asi),
1774 tcg_const_i32(4), tcg_const_i32(0));
1775 tcg_gen_helper_0_4(helper_st_asi, addr, dst, tcg_const_i32(asi),
1777 tcg_gen_extu_i32_tl(dst, r_temp);
1778 tcg_gen_discard_i32(r_temp);
1781 static inline void gen_ldda_asi(TCGv lo, TCGv hi, TCGv addr, int insn)
1785 asi = GET_FIELD(insn, 19, 26);
1786 tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, tcg_const_i32(asi),
1787 tcg_const_i32(8), tcg_const_i32(0));
1788 tcg_gen_trunc_i64_tl(lo, cpu_tmp64);
1789 tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);
1790 tcg_gen_trunc_i64_tl(hi, cpu_tmp64);
1793 static inline void gen_stda_asi(TCGv hi, TCGv addr, int insn, int rd)
1798 r_temp = tcg_temp_new(TCG_TYPE_I32);
1799 gen_movl_reg_TN(rd + 1, r_temp);
1800 tcg_gen_helper_1_2(helper_pack64, cpu_tmp64, hi, r_temp);
1801 asi = GET_FIELD(insn, 19, 26);
1802 tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, tcg_const_i32(asi),
1807 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
1808 static inline void gen_ldstub_asi(TCGv dst, TCGv addr, int insn)
1812 gen_ld_asi(dst, addr, insn, 1, 0);
1814 asi = GET_FIELD(insn, 19, 26);
1815 tcg_gen_helper_0_4(helper_st_asi, addr, tcg_const_i64(0xffULL),
1816 tcg_const_i32(asi), tcg_const_i32(1));
1820 static inline TCGv get_src1(unsigned int insn, TCGv def)
1825 rs1 = GET_FIELD(insn, 13, 17);
1827 //r_rs1 = tcg_const_tl(0);
1828 tcg_gen_movi_tl(def, 0);
1830 //r_rs1 = cpu_gregs[rs1];
1831 tcg_gen_mov_tl(def, cpu_gregs[rs1]);
1833 tcg_gen_ld_tl(def, cpu_regwptr, (rs1 - 8) * sizeof(target_ulong));
1837 static inline TCGv get_src2(unsigned int insn, TCGv def)
1842 if (IS_IMM) { /* immediate */
1843 rs2 = GET_FIELDs(insn, 19, 31);
1844 r_rs2 = tcg_const_tl((int)rs2);
1845 } else { /* register */
1846 rs2 = GET_FIELD(insn, 27, 31);
1848 r_rs2 = tcg_const_tl(0);
1850 r_rs2 = cpu_gregs[rs2];
1852 tcg_gen_ld_tl(def, cpu_regwptr, (rs2 - 8) * sizeof(target_ulong));
1857 /* before an instruction, dc->pc must be static */
1858 static void disas_sparc_insn(DisasContext * dc)
1860 unsigned int insn, opc, rs1, rs2, rd;
1862 insn = ldl_code(dc->pc);
1863 opc = GET_FIELD(insn, 0, 1);
1865 rd = GET_FIELD(insn, 2, 6);
1868 cpu_src1 = cpu_T[0]; // const
1869 cpu_src2 = cpu_T[1]; // const
1872 cpu_addr = cpu_T[0];
1876 case 0: /* branches/sethi */
1878 unsigned int xop = GET_FIELD(insn, 7, 9);
1881 #ifdef TARGET_SPARC64
1882 case 0x1: /* V9 BPcc */
1886 target = GET_FIELD_SP(insn, 0, 18);
1887 target = sign_extend(target, 18);
1889 cc = GET_FIELD_SP(insn, 20, 21);
1891 do_branch(dc, target, insn, 0, cpu_cond);
1893 do_branch(dc, target, insn, 1, cpu_cond);
1898 case 0x3: /* V9 BPr */
1900 target = GET_FIELD_SP(insn, 0, 13) |
1901 (GET_FIELD_SP(insn, 20, 21) << 14);
1902 target = sign_extend(target, 16);
1904 cpu_src1 = get_src1(insn, cpu_src1);
1905 do_branch_reg(dc, target, insn, cpu_cond, cpu_src1);
1908 case 0x5: /* V9 FBPcc */
1910 int cc = GET_FIELD_SP(insn, 20, 21);
1911 if (gen_trap_ifnofpu(dc, cpu_cond))
1913 target = GET_FIELD_SP(insn, 0, 18);
1914 target = sign_extend(target, 19);
1916 do_fbranch(dc, target, insn, cc, cpu_cond);
1920 case 0x7: /* CBN+x */
1925 case 0x2: /* BN+x */
1927 target = GET_FIELD(insn, 10, 31);
1928 target = sign_extend(target, 22);
1930 do_branch(dc, target, insn, 0, cpu_cond);
1933 case 0x6: /* FBN+x */
1935 if (gen_trap_ifnofpu(dc, cpu_cond))
1937 target = GET_FIELD(insn, 10, 31);
1938 target = sign_extend(target, 22);
1940 do_fbranch(dc, target, insn, 0, cpu_cond);
1943 case 0x4: /* SETHI */
1948 uint32_t value = GET_FIELD(insn, 10, 31);
1949 tcg_gen_movi_tl(cpu_dst, value << 10);
1950 gen_movl_TN_reg(rd, cpu_dst);
1955 case 0x0: /* UNIMPL */
1964 target_long target = GET_FIELDs(insn, 2, 31) << 2;
1966 gen_movl_TN_reg(15, tcg_const_tl(dc->pc));
1968 gen_mov_pc_npc(dc, cpu_cond);
1972 case 2: /* FPU & Logical Operations */
1974 unsigned int xop = GET_FIELD(insn, 7, 12);
1975 if (xop == 0x3a) { /* generate trap */
1978 cpu_src1 = get_src1(insn, cpu_src1);
1980 rs2 = GET_FIELD(insn, 25, 31);
1981 tcg_gen_addi_tl(cpu_dst, cpu_src1, rs2);
1983 rs2 = GET_FIELD(insn, 27, 31);
1987 gen_movl_reg_TN(rs2, cpu_src2);
1988 tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2);
1993 cond = GET_FIELD(insn, 3, 6);
1995 save_state(dc, cpu_cond);
1996 tcg_gen_helper_0_1(helper_trap, cpu_dst);
1997 } else if (cond != 0) {
1998 TCGv r_cond = tcg_temp_new(TCG_TYPE_TL);
1999 #ifdef TARGET_SPARC64
2001 int cc = GET_FIELD_SP(insn, 11, 12);
2003 save_state(dc, cpu_cond);
2005 gen_cond(r_cond, 0, cond);
2007 gen_cond(r_cond, 1, cond);
2011 save_state(dc, cpu_cond);
2012 gen_cond(r_cond, 0, cond);
2014 tcg_gen_helper_0_2(helper_trapcc, cpu_dst, r_cond);
2015 tcg_gen_discard_tl(r_cond);
2021 } else if (xop == 0x28) {
2022 rs1 = GET_FIELD(insn, 13, 17);
2025 #ifndef TARGET_SPARC64
2026 case 0x01 ... 0x0e: /* undefined in the SPARCv8
2027 manual, rdy on the microSPARC
2029 case 0x0f: /* stbar in the SPARCv8 manual,
2030 rdy on the microSPARC II */
2031 case 0x10 ... 0x1f: /* implementation-dependent in the
2032 SPARCv8 manual, rdy on the
2035 tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, y));
2036 gen_movl_TN_reg(rd, cpu_dst);
2038 #ifdef TARGET_SPARC64
2039 case 0x2: /* V9 rdccr */
2040 tcg_gen_helper_1_0(helper_rdccr, cpu_dst);
2041 gen_movl_TN_reg(rd, cpu_dst);
2043 case 0x3: /* V9 rdasi */
2044 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, asi));
2045 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2046 gen_movl_TN_reg(rd, cpu_dst);
2048 case 0x4: /* V9 rdtick */
2052 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
2053 tcg_gen_ld_ptr(r_tickptr, cpu_env,
2054 offsetof(CPUState, tick));
2055 tcg_gen_helper_1_1(helper_tick_get_count, cpu_dst,
2057 gen_movl_TN_reg(rd, cpu_dst);
2058 tcg_gen_discard_ptr(r_tickptr);
2061 case 0x5: /* V9 rdpc */
2062 tcg_gen_movi_tl(cpu_dst, dc->pc);
2063 gen_movl_TN_reg(rd, cpu_dst);
2065 case 0x6: /* V9 rdfprs */
2066 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fprs));
2067 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2068 gen_movl_TN_reg(rd, cpu_dst);
2070 case 0xf: /* V9 membar */
2071 break; /* no effect */
2072 case 0x13: /* Graphics Status */
2073 if (gen_trap_ifnofpu(dc, cpu_cond))
2075 tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, gsr));
2076 gen_movl_TN_reg(rd, cpu_dst);
2078 case 0x17: /* Tick compare */
2079 tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, tick_cmpr));
2080 gen_movl_TN_reg(rd, cpu_dst);
2082 case 0x18: /* System tick */
2086 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
2087 tcg_gen_ld_ptr(r_tickptr, cpu_env,
2088 offsetof(CPUState, stick));
2089 tcg_gen_helper_1_1(helper_tick_get_count, cpu_dst,
2091 gen_movl_TN_reg(rd, cpu_dst);
2092 tcg_gen_discard_ptr(r_tickptr);
2095 case 0x19: /* System tick compare */
2096 tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, stick_cmpr));
2097 gen_movl_TN_reg(rd, cpu_dst);
2099 case 0x10: /* Performance Control */
2100 case 0x11: /* Performance Instrumentation Counter */
2101 case 0x12: /* Dispatch Control */
2102 case 0x14: /* Softint set, WO */
2103 case 0x15: /* Softint clear, WO */
2104 case 0x16: /* Softint write */
2109 #if !defined(CONFIG_USER_ONLY)
2110 } else if (xop == 0x29) { /* rdpsr / UA2005 rdhpr */
2111 #ifndef TARGET_SPARC64
2112 if (!supervisor(dc))
2114 tcg_gen_helper_1_0(helper_rdpsr, cpu_dst);
2116 if (!hypervisor(dc))
2118 rs1 = GET_FIELD(insn, 13, 17);
2121 // gen_op_rdhpstate();
2124 // gen_op_rdhtstate();
2127 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, hintp));
2128 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2131 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, htba));
2132 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2135 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, hver));
2136 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2138 case 31: // hstick_cmpr
2139 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
2140 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, hstick_cmpr));
2146 gen_movl_TN_reg(rd, cpu_dst);
2148 } else if (xop == 0x2a) { /* rdwim / V9 rdpr */
2149 if (!supervisor(dc))
2151 #ifdef TARGET_SPARC64
2152 rs1 = GET_FIELD(insn, 13, 17);
2158 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
2159 tcg_gen_ld_ptr(r_tsptr, cpu_env,
2160 offsetof(CPUState, tsptr));
2161 tcg_gen_ld_tl(cpu_dst, r_tsptr,
2162 offsetof(trap_state, tpc));
2163 tcg_gen_discard_ptr(r_tsptr);
2170 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
2171 tcg_gen_ld_ptr(r_tsptr, cpu_env,
2172 offsetof(CPUState, tsptr));
2173 tcg_gen_ld_tl(cpu_dst, r_tsptr,
2174 offsetof(trap_state, tnpc));
2175 tcg_gen_discard_ptr(r_tsptr);
2182 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
2183 tcg_gen_ld_ptr(r_tsptr, cpu_env,
2184 offsetof(CPUState, tsptr));
2185 tcg_gen_ld_tl(cpu_dst, r_tsptr,
2186 offsetof(trap_state, tstate));
2187 tcg_gen_discard_ptr(r_tsptr);
2194 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
2195 tcg_gen_ld_ptr(r_tsptr, cpu_env,
2196 offsetof(CPUState, tsptr));
2197 tcg_gen_ld_i32(cpu_dst, r_tsptr,
2198 offsetof(trap_state, tt));
2199 tcg_gen_discard_ptr(r_tsptr);
2206 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
2207 tcg_gen_ld_ptr(r_tickptr, cpu_env,
2208 offsetof(CPUState, tick));
2209 tcg_gen_helper_1_1(helper_tick_get_count, cpu_dst,
2211 gen_movl_TN_reg(rd, cpu_dst);
2212 tcg_gen_discard_ptr(r_tickptr);
2216 tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, tbr));
2219 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, pstate));
2220 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2223 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, tl));
2224 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2227 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, psrpil));
2228 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2231 tcg_gen_helper_1_0(helper_rdcwp, cpu_dst);
2234 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cansave));
2235 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2237 case 11: // canrestore
2238 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, canrestore));
2239 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2241 case 12: // cleanwin
2242 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cleanwin));
2243 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2245 case 13: // otherwin
2246 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, otherwin));
2247 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2250 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, wstate));
2251 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2253 case 16: // UA2005 gl
2254 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, gl));
2255 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2257 case 26: // UA2005 strand status
2258 if (!hypervisor(dc))
2260 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ssr));
2261 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2264 tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, version));
2271 tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, wim));
2272 tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32);
2274 gen_movl_TN_reg(rd, cpu_dst);
2276 } else if (xop == 0x2b) { /* rdtbr / V9 flushw */
2277 #ifdef TARGET_SPARC64
2278 tcg_gen_helper_0_0(helper_flushw);
2280 if (!supervisor(dc))
2282 tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, tbr));
2283 gen_movl_TN_reg(rd, cpu_dst);
2287 } else if (xop == 0x34) { /* FPU Operations */
2288 if (gen_trap_ifnofpu(dc, cpu_cond))
2290 gen_op_clear_ieee_excp_and_FTT();
2291 rs1 = GET_FIELD(insn, 13, 17);
2292 rs2 = GET_FIELD(insn, 27, 31);
2293 xop = GET_FIELD(insn, 18, 26);
2295 case 0x1: /* fmovs */
2296 gen_op_load_fpr_FT0(rs2);
2297 gen_op_store_FT0_fpr(rd);
2299 case 0x5: /* fnegs */
2300 gen_op_load_fpr_FT1(rs2);
2301 tcg_gen_helper_0_0(helper_fnegs);
2302 gen_op_store_FT0_fpr(rd);
2304 case 0x9: /* fabss */
2305 gen_op_load_fpr_FT1(rs2);
2306 tcg_gen_helper_0_0(helper_fabss);
2307 gen_op_store_FT0_fpr(rd);
2309 case 0x29: /* fsqrts */
2310 gen_op_load_fpr_FT1(rs2);
2311 gen_clear_float_exceptions();
2312 tcg_gen_helper_0_0(helper_fsqrts);
2313 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2314 gen_op_store_FT0_fpr(rd);
2316 case 0x2a: /* fsqrtd */
2317 gen_op_load_fpr_DT1(DFPREG(rs2));
2318 gen_clear_float_exceptions();
2319 tcg_gen_helper_0_0(helper_fsqrtd);
2320 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2321 gen_op_store_DT0_fpr(DFPREG(rd));
2323 case 0x2b: /* fsqrtq */
2324 #if defined(CONFIG_USER_ONLY)
2325 gen_op_load_fpr_QT1(QFPREG(rs2));
2326 gen_clear_float_exceptions();
2327 tcg_gen_helper_0_0(helper_fsqrtq);
2328 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2329 gen_op_store_QT0_fpr(QFPREG(rd));
2335 gen_op_load_fpr_FT0(rs1);
2336 gen_op_load_fpr_FT1(rs2);
2337 gen_clear_float_exceptions();
2338 tcg_gen_helper_0_0(helper_fadds);
2339 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2340 gen_op_store_FT0_fpr(rd);
2343 gen_op_load_fpr_DT0(DFPREG(rs1));
2344 gen_op_load_fpr_DT1(DFPREG(rs2));
2345 gen_clear_float_exceptions();
2346 tcg_gen_helper_0_0(helper_faddd);
2347 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2348 gen_op_store_DT0_fpr(DFPREG(rd));
2350 case 0x43: /* faddq */
2351 #if defined(CONFIG_USER_ONLY)
2352 gen_op_load_fpr_QT0(QFPREG(rs1));
2353 gen_op_load_fpr_QT1(QFPREG(rs2));
2354 gen_clear_float_exceptions();
2355 tcg_gen_helper_0_0(helper_faddq);
2356 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2357 gen_op_store_QT0_fpr(QFPREG(rd));
2363 gen_op_load_fpr_FT0(rs1);
2364 gen_op_load_fpr_FT1(rs2);
2365 gen_clear_float_exceptions();
2366 tcg_gen_helper_0_0(helper_fsubs);
2367 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2368 gen_op_store_FT0_fpr(rd);
2371 gen_op_load_fpr_DT0(DFPREG(rs1));
2372 gen_op_load_fpr_DT1(DFPREG(rs2));
2373 gen_clear_float_exceptions();
2374 tcg_gen_helper_0_0(helper_fsubd);
2375 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2376 gen_op_store_DT0_fpr(DFPREG(rd));
2378 case 0x47: /* fsubq */
2379 #if defined(CONFIG_USER_ONLY)
2380 gen_op_load_fpr_QT0(QFPREG(rs1));
2381 gen_op_load_fpr_QT1(QFPREG(rs2));
2382 gen_clear_float_exceptions();
2383 tcg_gen_helper_0_0(helper_fsubq);
2384 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2385 gen_op_store_QT0_fpr(QFPREG(rd));
2391 gen_op_load_fpr_FT0(rs1);
2392 gen_op_load_fpr_FT1(rs2);
2393 gen_clear_float_exceptions();
2394 tcg_gen_helper_0_0(helper_fmuls);
2395 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2396 gen_op_store_FT0_fpr(rd);
2399 gen_op_load_fpr_DT0(DFPREG(rs1));
2400 gen_op_load_fpr_DT1(DFPREG(rs2));
2401 gen_clear_float_exceptions();
2402 tcg_gen_helper_0_0(helper_fmuld);
2403 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2404 gen_op_store_DT0_fpr(DFPREG(rd));
2406 case 0x4b: /* fmulq */
2407 #if defined(CONFIG_USER_ONLY)
2408 gen_op_load_fpr_QT0(QFPREG(rs1));
2409 gen_op_load_fpr_QT1(QFPREG(rs2));
2410 gen_clear_float_exceptions();
2411 tcg_gen_helper_0_0(helper_fmulq);
2412 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2413 gen_op_store_QT0_fpr(QFPREG(rd));
2419 gen_op_load_fpr_FT0(rs1);
2420 gen_op_load_fpr_FT1(rs2);
2421 gen_clear_float_exceptions();
2422 tcg_gen_helper_0_0(helper_fdivs);
2423 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2424 gen_op_store_FT0_fpr(rd);
2427 gen_op_load_fpr_DT0(DFPREG(rs1));
2428 gen_op_load_fpr_DT1(DFPREG(rs2));
2429 gen_clear_float_exceptions();
2430 tcg_gen_helper_0_0(helper_fdivd);
2431 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2432 gen_op_store_DT0_fpr(DFPREG(rd));
2434 case 0x4f: /* fdivq */
2435 #if defined(CONFIG_USER_ONLY)
2436 gen_op_load_fpr_QT0(QFPREG(rs1));
2437 gen_op_load_fpr_QT1(QFPREG(rs2));
2438 gen_clear_float_exceptions();
2439 tcg_gen_helper_0_0(helper_fdivq);
2440 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2441 gen_op_store_QT0_fpr(QFPREG(rd));
2447 gen_op_load_fpr_FT0(rs1);
2448 gen_op_load_fpr_FT1(rs2);
2449 gen_clear_float_exceptions();
2450 tcg_gen_helper_0_0(helper_fsmuld);
2451 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2452 gen_op_store_DT0_fpr(DFPREG(rd));
2454 case 0x6e: /* fdmulq */
2455 #if defined(CONFIG_USER_ONLY)
2456 gen_op_load_fpr_DT0(DFPREG(rs1));
2457 gen_op_load_fpr_DT1(DFPREG(rs2));
2458 gen_clear_float_exceptions();
2459 tcg_gen_helper_0_0(helper_fdmulq);
2460 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2461 gen_op_store_QT0_fpr(QFPREG(rd));
2467 gen_op_load_fpr_FT1(rs2);
2468 gen_clear_float_exceptions();
2469 tcg_gen_helper_0_0(helper_fitos);
2470 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2471 gen_op_store_FT0_fpr(rd);
2474 gen_op_load_fpr_DT1(DFPREG(rs2));
2475 gen_clear_float_exceptions();
2476 tcg_gen_helper_0_0(helper_fdtos);
2477 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2478 gen_op_store_FT0_fpr(rd);
2480 case 0xc7: /* fqtos */
2481 #if defined(CONFIG_USER_ONLY)
2482 gen_op_load_fpr_QT1(QFPREG(rs2));
2483 gen_clear_float_exceptions();
2484 tcg_gen_helper_0_0(helper_fqtos);
2485 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2486 gen_op_store_FT0_fpr(rd);
2492 gen_op_load_fpr_FT1(rs2);
2493 tcg_gen_helper_0_0(helper_fitod);
2494 gen_op_store_DT0_fpr(DFPREG(rd));
2497 gen_op_load_fpr_FT1(rs2);
2498 tcg_gen_helper_0_0(helper_fstod);
2499 gen_op_store_DT0_fpr(DFPREG(rd));
2501 case 0xcb: /* fqtod */
2502 #if defined(CONFIG_USER_ONLY)
2503 gen_op_load_fpr_QT1(QFPREG(rs2));
2504 gen_clear_float_exceptions();
2505 tcg_gen_helper_0_0(helper_fqtod);
2506 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2507 gen_op_store_DT0_fpr(DFPREG(rd));
2512 case 0xcc: /* fitoq */
2513 #if defined(CONFIG_USER_ONLY)
2514 gen_op_load_fpr_FT1(rs2);
2515 tcg_gen_helper_0_0(helper_fitoq);
2516 gen_op_store_QT0_fpr(QFPREG(rd));
2521 case 0xcd: /* fstoq */
2522 #if defined(CONFIG_USER_ONLY)
2523 gen_op_load_fpr_FT1(rs2);
2524 tcg_gen_helper_0_0(helper_fstoq);
2525 gen_op_store_QT0_fpr(QFPREG(rd));
2530 case 0xce: /* fdtoq */
2531 #if defined(CONFIG_USER_ONLY)
2532 gen_op_load_fpr_DT1(DFPREG(rs2));
2533 tcg_gen_helper_0_0(helper_fdtoq);
2534 gen_op_store_QT0_fpr(QFPREG(rd));
2540 gen_op_load_fpr_FT1(rs2);
2541 gen_clear_float_exceptions();
2542 tcg_gen_helper_0_0(helper_fstoi);
2543 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2544 gen_op_store_FT0_fpr(rd);
2547 gen_op_load_fpr_DT1(DFPREG(rs2));
2548 gen_clear_float_exceptions();
2549 tcg_gen_helper_0_0(helper_fdtoi);
2550 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2551 gen_op_store_FT0_fpr(rd);
2553 case 0xd3: /* fqtoi */
2554 #if defined(CONFIG_USER_ONLY)
2555 gen_op_load_fpr_QT1(QFPREG(rs2));
2556 gen_clear_float_exceptions();
2557 tcg_gen_helper_0_0(helper_fqtoi);
2558 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2559 gen_op_store_FT0_fpr(rd);
2564 #ifdef TARGET_SPARC64
2565 case 0x2: /* V9 fmovd */
2566 gen_op_load_fpr_DT0(DFPREG(rs2));
2567 gen_op_store_DT0_fpr(DFPREG(rd));
2569 case 0x3: /* V9 fmovq */
2570 #if defined(CONFIG_USER_ONLY)
2571 gen_op_load_fpr_QT0(QFPREG(rs2));
2572 gen_op_store_QT0_fpr(QFPREG(rd));
2577 case 0x6: /* V9 fnegd */
2578 gen_op_load_fpr_DT1(DFPREG(rs2));
2579 tcg_gen_helper_0_0(helper_fnegd);
2580 gen_op_store_DT0_fpr(DFPREG(rd));
2582 case 0x7: /* V9 fnegq */
2583 #if defined(CONFIG_USER_ONLY)
2584 gen_op_load_fpr_QT1(QFPREG(rs2));
2585 tcg_gen_helper_0_0(helper_fnegq);
2586 gen_op_store_QT0_fpr(QFPREG(rd));
2591 case 0xa: /* V9 fabsd */
2592 gen_op_load_fpr_DT1(DFPREG(rs2));
2593 tcg_gen_helper_0_0(helper_fabsd);
2594 gen_op_store_DT0_fpr(DFPREG(rd));
2596 case 0xb: /* V9 fabsq */
2597 #if defined(CONFIG_USER_ONLY)
2598 gen_op_load_fpr_QT1(QFPREG(rs2));
2599 tcg_gen_helper_0_0(helper_fabsq);
2600 gen_op_store_QT0_fpr(QFPREG(rd));
2605 case 0x81: /* V9 fstox */
2606 gen_op_load_fpr_FT1(rs2);
2607 gen_clear_float_exceptions();
2608 tcg_gen_helper_0_0(helper_fstox);
2609 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2610 gen_op_store_DT0_fpr(DFPREG(rd));
2612 case 0x82: /* V9 fdtox */
2613 gen_op_load_fpr_DT1(DFPREG(rs2));
2614 gen_clear_float_exceptions();
2615 tcg_gen_helper_0_0(helper_fdtox);
2616 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2617 gen_op_store_DT0_fpr(DFPREG(rd));
2619 case 0x83: /* V9 fqtox */
2620 #if defined(CONFIG_USER_ONLY)
2621 gen_op_load_fpr_QT1(QFPREG(rs2));
2622 gen_clear_float_exceptions();
2623 tcg_gen_helper_0_0(helper_fqtox);
2624 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2625 gen_op_store_DT0_fpr(DFPREG(rd));
2630 case 0x84: /* V9 fxtos */
2631 gen_op_load_fpr_DT1(DFPREG(rs2));
2632 gen_clear_float_exceptions();
2633 tcg_gen_helper_0_0(helper_fxtos);
2634 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2635 gen_op_store_FT0_fpr(rd);
2637 case 0x88: /* V9 fxtod */
2638 gen_op_load_fpr_DT1(DFPREG(rs2));
2639 gen_clear_float_exceptions();
2640 tcg_gen_helper_0_0(helper_fxtod);
2641 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2642 gen_op_store_DT0_fpr(DFPREG(rd));
2644 case 0x8c: /* V9 fxtoq */
2645 #if defined(CONFIG_USER_ONLY)
2646 gen_op_load_fpr_DT1(DFPREG(rs2));
2647 gen_clear_float_exceptions();
2648 tcg_gen_helper_0_0(helper_fxtoq);
2649 tcg_gen_helper_0_0(helper_check_ieee_exceptions);
2650 gen_op_store_QT0_fpr(QFPREG(rd));
2659 } else if (xop == 0x35) { /* FPU Operations */
2660 #ifdef TARGET_SPARC64
2663 if (gen_trap_ifnofpu(dc, cpu_cond))
2665 gen_op_clear_ieee_excp_and_FTT();
2666 rs1 = GET_FIELD(insn, 13, 17);
2667 rs2 = GET_FIELD(insn, 27, 31);
2668 xop = GET_FIELD(insn, 18, 26);
2669 #ifdef TARGET_SPARC64
2670 if ((xop & 0x11f) == 0x005) { // V9 fmovsr
2673 l1 = gen_new_label();
2674 cond = GET_FIELD_SP(insn, 14, 17);
2675 cpu_src1 = get_src1(insn, cpu_src1);
2676 tcg_gen_brcond_tl(gen_tcg_cond_reg[cond], cpu_src1,
2677 tcg_const_tl(0), l1);
2678 gen_op_load_fpr_FT0(rs2);
2679 gen_op_store_FT0_fpr(rd);
2682 } else if ((xop & 0x11f) == 0x006) { // V9 fmovdr
2685 l1 = gen_new_label();
2686 cond = GET_FIELD_SP(insn, 14, 17);
2687 cpu_src1 = get_src1(insn, cpu_src1);
2688 tcg_gen_brcond_tl(gen_tcg_cond_reg[cond], cpu_src1,
2689 tcg_const_tl(0), l1);
2690 gen_op_load_fpr_DT0(DFPREG(rs2));
2691 gen_op_store_DT0_fpr(DFPREG(rd));
2694 } else if ((xop & 0x11f) == 0x007) { // V9 fmovqr
2695 #if defined(CONFIG_USER_ONLY)
2698 l1 = gen_new_label();
2699 cond = GET_FIELD_SP(insn, 14, 17);
2700 cpu_src1 = get_src1(insn, cpu_src1);
2701 tcg_gen_brcond_tl(gen_tcg_cond_reg[cond], cpu_src1,
2702 tcg_const_tl(0), l1);
2703 gen_op_load_fpr_QT0(QFPREG(rs2));
2704 gen_op_store_QT0_fpr(QFPREG(rd));
2713 #ifdef TARGET_SPARC64
2714 #define FMOVCC(size_FDQ, fcc) \
2719 l1 = gen_new_label(); \
2720 r_cond = tcg_temp_new(TCG_TYPE_TL); \
2721 cond = GET_FIELD_SP(insn, 14, 17); \
2722 gen_fcond(r_cond, fcc, cond); \
2723 tcg_gen_brcond_tl(TCG_COND_EQ, r_cond, \
2724 tcg_const_tl(0), l1); \
2725 glue(glue(gen_op_load_fpr_, size_FDQ), T0)(glue(size_FDQ, FPREG(rs2))); \
2726 glue(glue(gen_op_store_, size_FDQ), T0_fpr)(glue(size_FDQ, FPREG(rd))); \
2727 gen_set_label(l1); \
2728 tcg_gen_discard_tl(r_cond); \
2730 case 0x001: /* V9 fmovscc %fcc0 */
2733 case 0x002: /* V9 fmovdcc %fcc0 */
2736 case 0x003: /* V9 fmovqcc %fcc0 */
2737 #if defined(CONFIG_USER_ONLY)
2743 case 0x041: /* V9 fmovscc %fcc1 */
2746 case 0x042: /* V9 fmovdcc %fcc1 */
2749 case 0x043: /* V9 fmovqcc %fcc1 */
2750 #if defined(CONFIG_USER_ONLY)
2756 case 0x081: /* V9 fmovscc %fcc2 */
2759 case 0x082: /* V9 fmovdcc %fcc2 */
2762 case 0x083: /* V9 fmovqcc %fcc2 */
2763 #if defined(CONFIG_USER_ONLY)
2769 case 0x0c1: /* V9 fmovscc %fcc3 */
2772 case 0x0c2: /* V9 fmovdcc %fcc3 */
2775 case 0x0c3: /* V9 fmovqcc %fcc3 */
2776 #if defined(CONFIG_USER_ONLY)
2783 #define FMOVCC(size_FDQ, icc) \
2788 l1 = gen_new_label(); \
2789 r_cond = tcg_temp_new(TCG_TYPE_TL); \
2790 cond = GET_FIELD_SP(insn, 14, 17); \
2791 gen_cond(r_cond, icc, cond); \
2792 tcg_gen_brcond_tl(TCG_COND_EQ, r_cond, \
2793 tcg_const_tl(0), l1); \
2794 glue(glue(gen_op_load_fpr_, size_FDQ), T0)(glue(size_FDQ, FPREG(rs2))); \
2795 glue(glue(gen_op_store_, size_FDQ), T0_fpr)(glue(size_FDQ, FPREG(rd))); \
2796 gen_set_label(l1); \
2797 tcg_gen_discard_tl(r_cond); \
2800 case 0x101: /* V9 fmovscc %icc */
2803 case 0x102: /* V9 fmovdcc %icc */
2805 case 0x103: /* V9 fmovqcc %icc */
2806 #if defined(CONFIG_USER_ONLY)
2812 case 0x181: /* V9 fmovscc %xcc */
2815 case 0x182: /* V9 fmovdcc %xcc */
2818 case 0x183: /* V9 fmovqcc %xcc */
2819 #if defined(CONFIG_USER_ONLY)
2827 case 0x51: /* fcmps, V9 %fcc */
2828 gen_op_load_fpr_FT0(rs1);
2829 gen_op_load_fpr_FT1(rs2);
2830 gen_op_fcmps(rd & 3);
2832 case 0x52: /* fcmpd, V9 %fcc */
2833 gen_op_load_fpr_DT0(DFPREG(rs1));
2834 gen_op_load_fpr_DT1(DFPREG(rs2));
2835 gen_op_fcmpd(rd & 3);
2837 case 0x53: /* fcmpq, V9 %fcc */
2838 #if defined(CONFIG_USER_ONLY)
2839 gen_op_load_fpr_QT0(QFPREG(rs1));
2840 gen_op_load_fpr_QT1(QFPREG(rs2));
2841 gen_op_fcmpq(rd & 3);
2843 #else /* !defined(CONFIG_USER_ONLY) */
2846 case 0x55: /* fcmpes, V9 %fcc */
2847 gen_op_load_fpr_FT0(rs1);
2848 gen_op_load_fpr_FT1(rs2);
2849 gen_op_fcmpes(rd & 3);
2851 case 0x56: /* fcmped, V9 %fcc */
2852 gen_op_load_fpr_DT0(DFPREG(rs1));
2853 gen_op_load_fpr_DT1(DFPREG(rs2));
2854 gen_op_fcmped(rd & 3);
2856 case 0x57: /* fcmpeq, V9 %fcc */
2857 #if defined(CONFIG_USER_ONLY)
2858 gen_op_load_fpr_QT0(QFPREG(rs1));
2859 gen_op_load_fpr_QT1(QFPREG(rs2));
2860 gen_op_fcmpeq(rd & 3);
2862 #else/* !defined(CONFIG_USER_ONLY) */
2869 } else if (xop == 0x2) {
2872 rs1 = GET_FIELD(insn, 13, 17);
2874 // or %g0, x, y -> mov T0, x; mov y, T0
2875 if (IS_IMM) { /* immediate */
2876 rs2 = GET_FIELDs(insn, 19, 31);
2877 tcg_gen_movi_tl(cpu_dst, (int)rs2);
2878 } else { /* register */
2879 rs2 = GET_FIELD(insn, 27, 31);
2880 gen_movl_reg_TN(rs2, cpu_dst);
2883 cpu_src1 = get_src1(insn, cpu_src1);
2884 if (IS_IMM) { /* immediate */
2885 rs2 = GET_FIELDs(insn, 19, 31);
2886 tcg_gen_ori_tl(cpu_dst, cpu_src1, (int)rs2);
2887 } else { /* register */
2888 // or x, %g0, y -> mov T1, x; mov y, T1
2889 rs2 = GET_FIELD(insn, 27, 31);
2891 gen_movl_reg_TN(rs2, cpu_src2);
2892 tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_src2);
2896 gen_movl_TN_reg(rd, cpu_dst);
2898 #ifdef TARGET_SPARC64
2899 } else if (xop == 0x25) { /* sll, V9 sllx */
2900 cpu_src1 = get_src1(insn, cpu_src1);
2901 if (IS_IMM) { /* immediate */
2902 rs2 = GET_FIELDs(insn, 20, 31);
2903 if (insn & (1 << 12)) {
2904 tcg_gen_shli_i64(cpu_dst, cpu_src1, rs2 & 0x3f);
2906 tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
2907 tcg_gen_shli_i64(cpu_dst, cpu_dst, rs2 & 0x1f);
2909 } else { /* register */
2910 rs2 = GET_FIELD(insn, 27, 31);
2911 gen_movl_reg_TN(rs2, cpu_src2);
2912 if (insn & (1 << 12)) {
2913 tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
2914 tcg_gen_shl_i64(cpu_dst, cpu_src1, cpu_tmp0);
2916 tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
2917 tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
2918 tcg_gen_shl_i64(cpu_dst, cpu_dst, cpu_tmp0);
2921 gen_movl_TN_reg(rd, cpu_dst);
2922 } else if (xop == 0x26) { /* srl, V9 srlx */
2923 cpu_src1 = get_src1(insn, cpu_src1);
2924 if (IS_IMM) { /* immediate */
2925 rs2 = GET_FIELDs(insn, 20, 31);
2926 if (insn & (1 << 12)) {
2927 tcg_gen_shri_i64(cpu_dst, cpu_src1, rs2 & 0x3f);
2929 tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
2930 tcg_gen_shri_i64(cpu_dst, cpu_dst, rs2 & 0x1f);
2932 } else { /* register */
2933 rs2 = GET_FIELD(insn, 27, 31);
2934 gen_movl_reg_TN(rs2, cpu_src2);
2935 if (insn & (1 << 12)) {
2936 tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
2937 tcg_gen_shr_i64(cpu_dst, cpu_src1, cpu_tmp0);
2939 tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
2940 tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
2941 tcg_gen_shr_i64(cpu_dst, cpu_dst, cpu_tmp0);
2944 gen_movl_TN_reg(rd, cpu_dst);
2945 } else if (xop == 0x27) { /* sra, V9 srax */
2946 cpu_src1 = get_src1(insn, cpu_src1);
2947 if (IS_IMM) { /* immediate */
2948 rs2 = GET_FIELDs(insn, 20, 31);
2949 if (insn & (1 << 12)) {
2950 tcg_gen_sari_i64(cpu_dst, cpu_src1, rs2 & 0x3f);
2952 tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
2953 tcg_gen_ext_i32_i64(cpu_dst, cpu_dst);
2954 tcg_gen_sari_i64(cpu_dst, cpu_dst, rs2 & 0x1f);
2956 } else { /* register */
2957 rs2 = GET_FIELD(insn, 27, 31);
2958 gen_movl_reg_TN(rs2, cpu_src2);
2959 if (insn & (1 << 12)) {
2960 tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
2961 tcg_gen_sar_i64(cpu_dst, cpu_src1, cpu_tmp0);
2963 tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
2964 tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
2965 tcg_gen_sar_i64(cpu_dst, cpu_dst, cpu_tmp0);
2968 gen_movl_TN_reg(rd, cpu_dst);
2970 } else if (xop < 0x36) {
2971 cpu_src1 = get_src1(insn, cpu_src1);
2972 cpu_src2 = get_src2(insn, cpu_src2);
2974 switch (xop & ~0x10) {
2977 gen_op_add_cc(cpu_dst, cpu_src1, cpu_src2);
2979 tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2);
2982 tcg_gen_and_tl(cpu_dst, cpu_src1, cpu_src2);
2984 gen_op_logic_cc(cpu_dst);
2987 tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_src2);
2989 gen_op_logic_cc(cpu_dst);
2992 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
2994 gen_op_logic_cc(cpu_dst);
2998 gen_op_sub_cc(cpu_dst, cpu_src1, cpu_src2);
3000 tcg_gen_sub_tl(cpu_dst, cpu_src1, cpu_src2);
3003 tcg_gen_xori_tl(cpu_tmp0, cpu_src2, -1);
3004 tcg_gen_and_tl(cpu_dst, cpu_src1, cpu_tmp0);
3006 gen_op_logic_cc(cpu_dst);
3009 tcg_gen_xori_tl(cpu_tmp0, cpu_src2, -1);
3010 tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_tmp0);
3012 gen_op_logic_cc(cpu_dst);
3015 tcg_gen_xori_tl(cpu_tmp0, cpu_src2, -1);
3016 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_tmp0);
3018 gen_op_logic_cc(cpu_dst);
3022 gen_op_addx_cc(cpu_dst, cpu_src1, cpu_src2);
3024 gen_mov_reg_C(cpu_tmp0, cpu_psr);
3025 tcg_gen_add_tl(cpu_tmp0, cpu_src2, cpu_tmp0);
3026 tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_tmp0);
3029 #ifdef TARGET_SPARC64
3030 case 0x9: /* V9 mulx */
3031 tcg_gen_mul_i64(cpu_dst, cpu_src1, cpu_src2);
3035 gen_op_umul(cpu_dst, cpu_src1, cpu_src2);
3037 gen_op_logic_cc(cpu_dst);
3040 gen_op_smul(cpu_dst, cpu_src1, cpu_src2);
3042 gen_op_logic_cc(cpu_dst);
3046 gen_op_subx_cc(cpu_dst, cpu_src1, cpu_src2);
3048 gen_mov_reg_C(cpu_tmp0, cpu_psr);
3049 tcg_gen_add_tl(cpu_tmp0, cpu_src2, cpu_tmp0);
3050 tcg_gen_sub_tl(cpu_dst, cpu_src1, cpu_tmp0);
3053 #ifdef TARGET_SPARC64
3054 case 0xd: /* V9 udivx */
3055 gen_trap_ifdivzero_tl(cpu_src2);
3056 tcg_gen_divu_i64(cpu_dst, cpu_src1, cpu_src2);
3060 tcg_gen_helper_1_2(helper_udiv, cpu_dst, cpu_src1, cpu_src2);
3062 gen_op_div_cc(cpu_dst);
3065 tcg_gen_helper_1_2(helper_sdiv, cpu_dst, cpu_src1, cpu_src2);
3067 gen_op_div_cc(cpu_dst);
3072 gen_movl_TN_reg(rd, cpu_dst);
3075 case 0x20: /* taddcc */
3076 gen_op_tadd_cc(cpu_dst, cpu_src1, cpu_src2);
3077 gen_movl_TN_reg(rd, cpu_dst);
3079 case 0x21: /* tsubcc */
3080 gen_op_tsub_cc(cpu_dst, cpu_src1, cpu_src2);
3081 gen_movl_TN_reg(rd, cpu_dst);
3083 case 0x22: /* taddcctv */
3084 save_state(dc, cpu_cond);
3085 gen_op_tadd_ccTV(cpu_dst, cpu_src1, cpu_src2);
3086 gen_movl_TN_reg(rd, cpu_dst);
3088 case 0x23: /* tsubcctv */
3089 save_state(dc, cpu_cond);
3090 gen_op_tsub_ccTV(cpu_dst, cpu_src1, cpu_src2);
3091 gen_movl_TN_reg(rd, cpu_dst);
3093 case 0x24: /* mulscc */
3094 gen_op_mulscc(cpu_dst, cpu_src1, cpu_src2);
3095 gen_movl_TN_reg(rd, cpu_dst);
3097 #ifndef TARGET_SPARC64
3098 case 0x25: /* sll */
3099 tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
3100 tcg_gen_shl_tl(cpu_dst, cpu_src1, cpu_tmp0);
3101 gen_movl_TN_reg(rd, cpu_dst);
3103 case 0x26: /* srl */
3104 tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
3105 tcg_gen_shr_tl(cpu_dst, cpu_src1, cpu_tmp0);
3106 gen_movl_TN_reg(rd, cpu_dst);
3108 case 0x27: /* sra */
3109 tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
3110 tcg_gen_sar_tl(cpu_dst, cpu_src1, cpu_tmp0);
3111 gen_movl_TN_reg(rd, cpu_dst);
3118 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
3119 tcg_gen_st_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, y));
3121 #ifndef TARGET_SPARC64
3122 case 0x01 ... 0x0f: /* undefined in the
3126 case 0x10 ... 0x1f: /* implementation-dependent
3132 case 0x2: /* V9 wrccr */
3133 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
3134 tcg_gen_helper_0_1(helper_wrccr, cpu_dst);
3136 case 0x3: /* V9 wrasi */
3137 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
3138 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3139 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, asi));
3141 case 0x6: /* V9 wrfprs */
3142 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
3143 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3144 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fprs));
3145 save_state(dc, cpu_cond);
3150 case 0xf: /* V9 sir, nop if user */
3151 #if !defined(CONFIG_USER_ONLY)
3156 case 0x13: /* Graphics Status */
3157 if (gen_trap_ifnofpu(dc, cpu_cond))
3159 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
3160 tcg_gen_st_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, gsr));
3162 case 0x17: /* Tick compare */
3163 #if !defined(CONFIG_USER_ONLY)
3164 if (!supervisor(dc))
3170 tcg_gen_xor_tl(cpu_dst, cpu_src1,
3172 tcg_gen_st_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState,
3174 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
3175 tcg_gen_ld_ptr(r_tickptr, cpu_env,
3176 offsetof(CPUState, tick));
3177 tcg_gen_helper_0_2(helper_tick_set_limit,
3178 r_tickptr, cpu_dst);
3179 tcg_gen_discard_ptr(r_tickptr);
3182 case 0x18: /* System tick */
3183 #if !defined(CONFIG_USER_ONLY)
3184 if (!supervisor(dc))
3190 tcg_gen_xor_tl(cpu_dst, cpu_src1,
3192 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
3193 tcg_gen_ld_ptr(r_tickptr, cpu_env,
3194 offsetof(CPUState, stick));
3195 tcg_gen_helper_0_2(helper_tick_set_count,
3196 r_tickptr, cpu_dst);
3197 tcg_gen_discard_ptr(r_tickptr);
3200 case 0x19: /* System tick compare */
3201 #if !defined(CONFIG_USER_ONLY)
3202 if (!supervisor(dc))
3208 tcg_gen_xor_tl(cpu_dst, cpu_src1,
3210 tcg_gen_st_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState,
3212 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
3213 tcg_gen_ld_ptr(r_tickptr, cpu_env,
3214 offsetof(CPUState, stick));
3215 tcg_gen_helper_0_2(helper_tick_set_limit,
3216 r_tickptr, cpu_dst);
3217 tcg_gen_discard_ptr(r_tickptr);
3221 case 0x10: /* Performance Control */
3222 case 0x11: /* Performance Instrumentation Counter */
3223 case 0x12: /* Dispatch Control */
3224 case 0x14: /* Softint set */
3225 case 0x15: /* Softint clear */
3226 case 0x16: /* Softint write */
3233 #if !defined(CONFIG_USER_ONLY)
3234 case 0x31: /* wrpsr, V9 saved, restored */
3236 if (!supervisor(dc))
3238 #ifdef TARGET_SPARC64
3241 tcg_gen_helper_0_0(helper_saved);
3244 tcg_gen_helper_0_0(helper_restored);
3246 case 2: /* UA2005 allclean */
3247 case 3: /* UA2005 otherw */
3248 case 4: /* UA2005 normalw */
3249 case 5: /* UA2005 invalw */
3255 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
3256 tcg_gen_helper_0_1(helper_wrpsr, cpu_dst);
3257 save_state(dc, cpu_cond);
3264 case 0x32: /* wrwim, V9 wrpr */
3266 if (!supervisor(dc))
3268 tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
3269 #ifdef TARGET_SPARC64
3275 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
3276 tcg_gen_ld_ptr(r_tsptr, cpu_env,
3277 offsetof(CPUState, tsptr));
3278 tcg_gen_st_tl(cpu_dst, r_tsptr,
3279 offsetof(trap_state, tpc));
3280 tcg_gen_discard_ptr(r_tsptr);
3287 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
3288 tcg_gen_ld_ptr(r_tsptr, cpu_env,
3289 offsetof(CPUState, tsptr));
3290 tcg_gen_st_tl(cpu_dst, r_tsptr,
3291 offsetof(trap_state, tnpc));
3292 tcg_gen_discard_ptr(r_tsptr);
3299 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
3300 tcg_gen_ld_ptr(r_tsptr, cpu_env,
3301 offsetof(CPUState, tsptr));
3302 tcg_gen_st_tl(cpu_dst, r_tsptr,
3303 offsetof(trap_state, tstate));
3304 tcg_gen_discard_ptr(r_tsptr);
3311 r_tsptr = tcg_temp_new(TCG_TYPE_PTR);
3312 tcg_gen_ld_ptr(r_tsptr, cpu_env,
3313 offsetof(CPUState, tsptr));
3314 tcg_gen_st_i32(cpu_dst, r_tsptr,
3315 offsetof(trap_state, tt));
3316 tcg_gen_discard_ptr(r_tsptr);
3323 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
3324 tcg_gen_ld_ptr(r_tickptr, cpu_env,
3325 offsetof(CPUState, tick));
3326 tcg_gen_helper_0_2(helper_tick_set_count,
3327 r_tickptr, cpu_dst);
3328 tcg_gen_discard_ptr(r_tickptr);
3332 tcg_gen_st_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, tbr));
3335 save_state(dc, cpu_cond);
3336 tcg_gen_helper_0_1(helper_wrpstate, cpu_dst);
3342 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3343 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, tl));
3346 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3347 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, psrpil));
3350 tcg_gen_helper_0_1(helper_wrcwp, cpu_dst);
3353 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3354 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cansave));
3356 case 11: // canrestore
3357 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3358 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, canrestore));
3360 case 12: // cleanwin
3361 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3362 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cleanwin));
3364 case 13: // otherwin
3365 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3366 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, otherwin));
3369 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3370 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, wstate));
3372 case 16: // UA2005 gl
3373 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3374 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, gl));
3376 case 26: // UA2005 strand status
3377 if (!hypervisor(dc))
3379 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3380 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ssr));
3386 tcg_gen_andi_tl(cpu_dst, cpu_dst, ((1 << NWINDOWS) - 1));
3387 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3388 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, wim));
3392 case 0x33: /* wrtbr, UA2005 wrhpr */
3394 #ifndef TARGET_SPARC64
3395 if (!supervisor(dc))
3397 tcg_gen_xor_tl(cpu_dst, cpu_dst, cpu_src2);
3398 tcg_gen_st_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, tbr));
3400 if (!hypervisor(dc))
3402 tcg_gen_xor_tl(cpu_dst, cpu_dst, cpu_src2);
3405 // XXX gen_op_wrhpstate();
3406 save_state(dc, cpu_cond);
3412 // XXX gen_op_wrhtstate();
3415 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3416 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, hintp));
3419 tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
3420 tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, htba));
3422 case 31: // hstick_cmpr
3426 tcg_gen_st_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState,
3428 r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
3429 tcg_gen_ld_ptr(r_tickptr, cpu_env,
3430 offsetof(CPUState, hstick));
3431 tcg_gen_helper_0_2(helper_tick_set_limit,
3432 r_tickptr, cpu_dst);
3433 tcg_gen_discard_ptr(r_tickptr);
3436 case 6: // hver readonly
3444 #ifdef TARGET_SPARC64
3445 case 0x2c: /* V9 movcc */
3447 int cc = GET_FIELD_SP(insn, 11, 12);
3448 int cond = GET_FIELD_SP(insn, 14, 17);
3452 r_cond = tcg_temp_new(TCG_TYPE_TL);
3453 if (insn & (1 << 18)) {
3455 gen_cond(r_cond, 0, cond);
3457 gen_cond(r_cond, 1, cond);
3461 gen_fcond(r_cond, cc, cond);
3464 l1 = gen_new_label();
3466 tcg_gen_brcond_tl(TCG_COND_EQ, r_cond,
3467 tcg_const_tl(0), l1);
3468 if (IS_IMM) { /* immediate */
3469 rs2 = GET_FIELD_SPs(insn, 0, 10);
3470 tcg_gen_movi_tl(cpu_dst, (int)rs2);
3472 rs2 = GET_FIELD_SP(insn, 0, 4);
3473 gen_movl_reg_TN(rs2, cpu_dst);
3475 gen_movl_TN_reg(rd, cpu_dst);
3477 tcg_gen_discard_tl(r_cond);
3480 case 0x2d: /* V9 sdivx */
3481 gen_op_sdivx(cpu_dst, cpu_src1, cpu_src2);
3482 gen_movl_TN_reg(rd, cpu_dst);
3484 case 0x2e: /* V9 popc */
3486 cpu_src2 = get_src2(insn, cpu_src2);
3487 tcg_gen_helper_1_1(helper_popc, cpu_dst,
3489 gen_movl_TN_reg(rd, cpu_dst);
3491 case 0x2f: /* V9 movr */
3493 int cond = GET_FIELD_SP(insn, 10, 12);
3496 cpu_src1 = get_src1(insn, cpu_src1);
3498 l1 = gen_new_label();
3500 tcg_gen_brcond_tl(gen_tcg_cond_reg[cond], cpu_src1,
3501 tcg_const_tl(0), l1);
3502 if (IS_IMM) { /* immediate */
3503 rs2 = GET_FIELD_SPs(insn, 0, 9);
3504 tcg_gen_movi_tl(cpu_dst, (int)rs2);
3506 rs2 = GET_FIELD_SP(insn, 0, 4);
3507 gen_movl_reg_TN(rs2, cpu_dst);
3509 gen_movl_TN_reg(rd, cpu_dst);
3518 } else if (xop == 0x36) { /* UltraSparc shutdown, VIS, V8 CPop1 */
3519 #ifdef TARGET_SPARC64
3520 int opf = GET_FIELD_SP(insn, 5, 13);
3521 rs1 = GET_FIELD(insn, 13, 17);
3522 rs2 = GET_FIELD(insn, 27, 31);
3523 if (gen_trap_ifnofpu(dc, cpu_cond))
3527 case 0x000: /* VIS I edge8cc */
3528 case 0x001: /* VIS II edge8n */
3529 case 0x002: /* VIS I edge8lcc */
3530 case 0x003: /* VIS II edge8ln */
3531 case 0x004: /* VIS I edge16cc */
3532 case 0x005: /* VIS II edge16n */
3533 case 0x006: /* VIS I edge16lcc */
3534 case 0x007: /* VIS II edge16ln */
3535 case 0x008: /* VIS I edge32cc */
3536 case 0x009: /* VIS II edge32n */
3537 case 0x00a: /* VIS I edge32lcc */
3538 case 0x00b: /* VIS II edge32ln */
3541 case 0x010: /* VIS I array8 */
3542 cpu_src1 = get_src1(insn, cpu_src1);
3543 gen_movl_reg_TN(rs2, cpu_src2);
3544 tcg_gen_helper_1_2(helper_array8, cpu_dst, cpu_src1,
3546 gen_movl_TN_reg(rd, cpu_dst);
3548 case 0x012: /* VIS I array16 */
3549 cpu_src1 = get_src1(insn, cpu_src1);
3550 gen_movl_reg_TN(rs2, cpu_src2);
3551 tcg_gen_helper_1_2(helper_array8, cpu_dst, cpu_src1,
3553 tcg_gen_shli_i64(cpu_dst, cpu_dst, 1);
3554 gen_movl_TN_reg(rd, cpu_dst);
3556 case 0x014: /* VIS I array32 */
3557 cpu_src1 = get_src1(insn, cpu_src1);
3558 gen_movl_reg_TN(rs2, cpu_src2);
3559 tcg_gen_helper_1_2(helper_array8, cpu_dst, cpu_src1,
3561 tcg_gen_shli_i64(cpu_dst, cpu_dst, 2);
3562 gen_movl_TN_reg(rd, cpu_dst);
3564 case 0x018: /* VIS I alignaddr */
3565 cpu_src1 = get_src1(insn, cpu_src1);
3566 gen_movl_reg_TN(rs2, cpu_src2);
3567 tcg_gen_helper_1_2(helper_alignaddr, cpu_dst, cpu_src1,
3569 gen_movl_TN_reg(rd, cpu_dst);
3571 case 0x019: /* VIS II bmask */
3572 case 0x01a: /* VIS I alignaddrl */
3575 case 0x020: /* VIS I fcmple16 */
3576 gen_op_load_fpr_DT0(DFPREG(rs1));
3577 gen_op_load_fpr_DT1(DFPREG(rs2));
3578 tcg_gen_helper_0_0(helper_fcmple16);
3579 gen_op_store_DT0_fpr(DFPREG(rd));
3581 case 0x022: /* VIS I fcmpne16 */
3582 gen_op_load_fpr_DT0(DFPREG(rs1));
3583 gen_op_load_fpr_DT1(DFPREG(rs2));
3584 tcg_gen_helper_0_0(helper_fcmpne16);
3585 gen_op_store_DT0_fpr(DFPREG(rd));
3587 case 0x024: /* VIS I fcmple32 */
3588 gen_op_load_fpr_DT0(DFPREG(rs1));
3589 gen_op_load_fpr_DT1(DFPREG(rs2));
3590 tcg_gen_helper_0_0(helper_fcmple32);
3591 gen_op_store_DT0_fpr(DFPREG(rd));
3593 case 0x026: /* VIS I fcmpne32 */
3594 gen_op_load_fpr_DT0(DFPREG(rs1));
3595 gen_op_load_fpr_DT1(DFPREG(rs2));
3596 tcg_gen_helper_0_0(helper_fcmpne32);
3597 gen_op_store_DT0_fpr(DFPREG(rd));
3599 case 0x028: /* VIS I fcmpgt16 */
3600 gen_op_load_fpr_DT0(DFPREG(rs1));
3601 gen_op_load_fpr_DT1(DFPREG(rs2));
3602 tcg_gen_helper_0_0(helper_fcmpgt16);
3603 gen_op_store_DT0_fpr(DFPREG(rd));
3605 case 0x02a: /* VIS I fcmpeq16 */
3606 gen_op_load_fpr_DT0(DFPREG(rs1));
3607 gen_op_load_fpr_DT1(DFPREG(rs2));
3608 tcg_gen_helper_0_0(helper_fcmpeq16);
3609 gen_op_store_DT0_fpr(DFPREG(rd));
3611 case 0x02c: /* VIS I fcmpgt32 */
3612 gen_op_load_fpr_DT0(DFPREG(rs1));
3613 gen_op_load_fpr_DT1(DFPREG(rs2));
3614 tcg_gen_helper_0_0(helper_fcmpgt32);
3615 gen_op_store_DT0_fpr(DFPREG(rd));
3617 case 0x02e: /* VIS I fcmpeq32 */
3618 gen_op_load_fpr_DT0(DFPREG(rs1));
3619 gen_op_load_fpr_DT1(DFPREG(rs2));
3620 tcg_gen_helper_0_0(helper_fcmpeq32);
3621 gen_op_store_DT0_fpr(DFPREG(rd));
3623 case 0x031: /* VIS I fmul8x16 */
3624 gen_op_load_fpr_DT0(DFPREG(rs1));
3625 gen_op_load_fpr_DT1(DFPREG(rs2));
3626 tcg_gen_helper_0_0(helper_fmul8x16);
3627 gen_op_store_DT0_fpr(DFPREG(rd));
3629 case 0x033: /* VIS I fmul8x16au */
3630 gen_op_load_fpr_DT0(DFPREG(rs1));
3631 gen_op_load_fpr_DT1(DFPREG(rs2));
3632 tcg_gen_helper_0_0(helper_fmul8x16au);
3633 gen_op_store_DT0_fpr(DFPREG(rd));
3635 case 0x035: /* VIS I fmul8x16al */
3636 gen_op_load_fpr_DT0(DFPREG(rs1));
3637 gen_op_load_fpr_DT1(DFPREG(rs2));
3638 tcg_gen_helper_0_0(helper_fmul8x16al);
3639 gen_op_store_DT0_fpr(DFPREG(rd));
3641 case 0x036: /* VIS I fmul8sux16 */
3642 gen_op_load_fpr_DT0(DFPREG(rs1));
3643 gen_op_load_fpr_DT1(DFPREG(rs2));
3644 tcg_gen_helper_0_0(helper_fmul8sux16);
3645 gen_op_store_DT0_fpr(DFPREG(rd));
3647 case 0x037: /* VIS I fmul8ulx16 */
3648 gen_op_load_fpr_DT0(DFPREG(rs1));
3649 gen_op_load_fpr_DT1(DFPREG(rs2));
3650 tcg_gen_helper_0_0(helper_fmul8ulx16);
3651 gen_op_store_DT0_fpr(DFPREG(rd));
3653 case 0x038: /* VIS I fmuld8sux16 */
3654 gen_op_load_fpr_DT0(DFPREG(rs1));
3655 gen_op_load_fpr_DT1(DFPREG(rs2));
3656 tcg_gen_helper_0_0(helper_fmuld8sux16);
3657 gen_op_store_DT0_fpr(DFPREG(rd));
3659 case 0x039: /* VIS I fmuld8ulx16 */
3660 gen_op_load_fpr_DT0(DFPREG(rs1));
3661 gen_op_load_fpr_DT1(DFPREG(rs2));
3662 tcg_gen_helper_0_0(helper_fmuld8ulx16);
3663 gen_op_store_DT0_fpr(DFPREG(rd));
3665 case 0x03a: /* VIS I fpack32 */
3666 case 0x03b: /* VIS I fpack16 */
3667 case 0x03d: /* VIS I fpackfix */
3668 case 0x03e: /* VIS I pdist */
3671 case 0x048: /* VIS I faligndata */
3672 gen_op_load_fpr_DT0(DFPREG(rs1));
3673 gen_op_load_fpr_DT1(DFPREG(rs2));
3674 tcg_gen_helper_0_0(helper_faligndata);
3675 gen_op_store_DT0_fpr(DFPREG(rd));
3677 case 0x04b: /* VIS I fpmerge */
3678 gen_op_load_fpr_DT0(DFPREG(rs1));
3679 gen_op_load_fpr_DT1(DFPREG(rs2));
3680 tcg_gen_helper_0_0(helper_fpmerge);
3681 gen_op_store_DT0_fpr(DFPREG(rd));
3683 case 0x04c: /* VIS II bshuffle */
3686 case 0x04d: /* VIS I fexpand */
3687 gen_op_load_fpr_DT0(DFPREG(rs1));
3688 gen_op_load_fpr_DT1(DFPREG(rs2));
3689 tcg_gen_helper_0_0(helper_fexpand);
3690 gen_op_store_DT0_fpr(DFPREG(rd));
3692 case 0x050: /* VIS I fpadd16 */
3693 gen_op_load_fpr_DT0(DFPREG(rs1));
3694 gen_op_load_fpr_DT1(DFPREG(rs2));
3695 tcg_gen_helper_0_0(helper_fpadd16);
3696 gen_op_store_DT0_fpr(DFPREG(rd));
3698 case 0x051: /* VIS I fpadd16s */
3699 gen_op_load_fpr_FT0(rs1);
3700 gen_op_load_fpr_FT1(rs2);
3701 tcg_gen_helper_0_0(helper_fpadd16s);
3702 gen_op_store_FT0_fpr(rd);
3704 case 0x052: /* VIS I fpadd32 */
3705 gen_op_load_fpr_DT0(DFPREG(rs1));
3706 gen_op_load_fpr_DT1(DFPREG(rs2));
3707 tcg_gen_helper_0_0(helper_fpadd32);
3708 gen_op_store_DT0_fpr(DFPREG(rd));
3710 case 0x053: /* VIS I fpadd32s */
3711 gen_op_load_fpr_FT0(rs1);
3712 gen_op_load_fpr_FT1(rs2);
3713 tcg_gen_helper_0_0(helper_fpadd32s);
3714 gen_op_store_FT0_fpr(rd);
3716 case 0x054: /* VIS I fpsub16 */
3717 gen_op_load_fpr_DT0(DFPREG(rs1));
3718 gen_op_load_fpr_DT1(DFPREG(rs2));
3719 tcg_gen_helper_0_0(helper_fpsub16);
3720 gen_op_store_DT0_fpr(DFPREG(rd));
3722 case 0x055: /* VIS I fpsub16s */
3723 gen_op_load_fpr_FT0(rs1);
3724 gen_op_load_fpr_FT1(rs2);
3725 tcg_gen_helper_0_0(helper_fpsub16s);
3726 gen_op_store_FT0_fpr(rd);
3728 case 0x056: /* VIS I fpsub32 */
3729 gen_op_load_fpr_DT0(DFPREG(rs1));
3730 gen_op_load_fpr_DT1(DFPREG(rs2));
3731 tcg_gen_helper_0_0(helper_fpadd32);
3732 gen_op_store_DT0_fpr(DFPREG(rd));
3734 case 0x057: /* VIS I fpsub32s */
3735 gen_op_load_fpr_FT0(rs1);
3736 gen_op_load_fpr_FT1(rs2);
3737 tcg_gen_helper_0_0(helper_fpsub32s);
3738 gen_op_store_FT0_fpr(rd);
3740 case 0x060: /* VIS I fzero */
3741 tcg_gen_helper_0_0(helper_movl_DT0_0);
3742 gen_op_store_DT0_fpr(DFPREG(rd));
3744 case 0x061: /* VIS I fzeros */
3745 tcg_gen_helper_0_0(helper_movl_FT0_0);
3746 gen_op_store_FT0_fpr(rd);
3748 case 0x062: /* VIS I fnor */
3749 gen_op_load_fpr_DT0(DFPREG(rs1));
3750 gen_op_load_fpr_DT1(DFPREG(rs2));
3751 tcg_gen_helper_0_0(helper_fnor);
3752 gen_op_store_DT0_fpr(DFPREG(rd));
3754 case 0x063: /* VIS I fnors */
3755 gen_op_load_fpr_FT0(rs1);
3756 gen_op_load_fpr_FT1(rs2);
3757 tcg_gen_helper_0_0(helper_fnors);
3758 gen_op_store_FT0_fpr(rd);
3760 case 0x064: /* VIS I fandnot2 */
3761 gen_op_load_fpr_DT1(DFPREG(rs1));
3762 gen_op_load_fpr_DT0(DFPREG(rs2));
3763 tcg_gen_helper_0_0(helper_fandnot);
3764 gen_op_store_DT0_fpr(DFPREG(rd));
3766 case 0x065: /* VIS I fandnot2s */
3767 gen_op_load_fpr_FT1(rs1);
3768 gen_op_load_fpr_FT0(rs2);
3769 tcg_gen_helper_0_0(helper_fandnots);
3770 gen_op_store_FT0_fpr(rd);
3772 case 0x066: /* VIS I fnot2 */
3773 gen_op_load_fpr_DT1(DFPREG(rs2));
3774 tcg_gen_helper_0_0(helper_fnot);
3775 gen_op_store_DT0_fpr(DFPREG(rd));
3777 case 0x067: /* VIS I fnot2s */
3778 gen_op_load_fpr_FT1(rs2);
3779 tcg_gen_helper_0_0(helper_fnot);
3780 gen_op_store_FT0_fpr(rd);
3782 case 0x068: /* VIS I fandnot1 */
3783 gen_op_load_fpr_DT0(DFPREG(rs1));
3784 gen_op_load_fpr_DT1(DFPREG(rs2));
3785 tcg_gen_helper_0_0(helper_fandnot);
3786 gen_op_store_DT0_fpr(DFPREG(rd));
3788 case 0x069: /* VIS I fandnot1s */
3789 gen_op_load_fpr_FT0(rs1);
3790 gen_op_load_fpr_FT1(rs2);
3791 tcg_gen_helper_0_0(helper_fandnots);
3792 gen_op_store_FT0_fpr(rd);
3794 case 0x06a: /* VIS I fnot1 */
3795 gen_op_load_fpr_DT1(DFPREG(rs1));
3796 tcg_gen_helper_0_0(helper_fnot);
3797 gen_op_store_DT0_fpr(DFPREG(rd));
3799 case 0x06b: /* VIS I fnot1s */
3800 gen_op_load_fpr_FT1(rs1);
3801 tcg_gen_helper_0_0(helper_fnot);
3802 gen_op_store_FT0_fpr(rd);
3804 case 0x06c: /* VIS I fxor */
3805 gen_op_load_fpr_DT0(DFPREG(rs1));
3806 gen_op_load_fpr_DT1(DFPREG(rs2));
3807 tcg_gen_helper_0_0(helper_fxor);
3808 gen_op_store_DT0_fpr(DFPREG(rd));
3810 case 0x06d: /* VIS I fxors */
3811 gen_op_load_fpr_FT0(rs1);
3812 gen_op_load_fpr_FT1(rs2);
3813 tcg_gen_helper_0_0(helper_fxors);
3814 gen_op_store_FT0_fpr(rd);
3816 case 0x06e: /* VIS I fnand */
3817 gen_op_load_fpr_DT0(DFPREG(rs1));
3818 gen_op_load_fpr_DT1(DFPREG(rs2));
3819 tcg_gen_helper_0_0(helper_fnand);
3820 gen_op_store_DT0_fpr(DFPREG(rd));
3822 case 0x06f: /* VIS I fnands */
3823 gen_op_load_fpr_FT0(rs1);
3824 gen_op_load_fpr_FT1(rs2);
3825 tcg_gen_helper_0_0(helper_fnands);
3826 gen_op_store_FT0_fpr(rd);
3828 case 0x070: /* VIS I fand */
3829 gen_op_load_fpr_DT0(DFPREG(rs1));
3830 gen_op_load_fpr_DT1(DFPREG(rs2));
3831 tcg_gen_helper_0_0(helper_fand);
3832 gen_op_store_DT0_fpr(DFPREG(rd));
3834 case 0x071: /* VIS I fands */
3835 gen_op_load_fpr_FT0(rs1);
3836 gen_op_load_fpr_FT1(rs2);
3837 tcg_gen_helper_0_0(helper_fands);
3838 gen_op_store_FT0_fpr(rd);
3840 case 0x072: /* VIS I fxnor */
3841 gen_op_load_fpr_DT0(DFPREG(rs1));
3842 gen_op_load_fpr_DT1(DFPREG(rs2));
3843 tcg_gen_helper_0_0(helper_fxnor);
3844 gen_op_store_DT0_fpr(DFPREG(rd));
3846 case 0x073: /* VIS I fxnors */
3847 gen_op_load_fpr_FT0(rs1);
3848 gen_op_load_fpr_FT1(rs2);
3849 tcg_gen_helper_0_0(helper_fxnors);
3850 gen_op_store_FT0_fpr(rd);
3852 case 0x074: /* VIS I fsrc1 */
3853 gen_op_load_fpr_DT0(DFPREG(rs1));
3854 gen_op_store_DT0_fpr(DFPREG(rd));
3856 case 0x075: /* VIS I fsrc1s */
3857 gen_op_load_fpr_FT0(rs1);
3858 gen_op_store_FT0_fpr(rd);
3860 case 0x076: /* VIS I fornot2 */
3861 gen_op_load_fpr_DT1(DFPREG(rs1));
3862 gen_op_load_fpr_DT0(DFPREG(rs2));
3863 tcg_gen_helper_0_0(helper_fornot);
3864 gen_op_store_DT0_fpr(DFPREG(rd));
3866 case 0x077: /* VIS I fornot2s */
3867 gen_op_load_fpr_FT1(rs1);
3868 gen_op_load_fpr_FT0(rs2);
3869 tcg_gen_helper_0_0(helper_fornots);
3870 gen_op_store_FT0_fpr(rd);
3872 case 0x078: /* VIS I fsrc2 */
3873 gen_op_load_fpr_DT0(DFPREG(rs2));
3874 gen_op_store_DT0_fpr(DFPREG(rd));
3876 case 0x079: /* VIS I fsrc2s */
3877 gen_op_load_fpr_FT0(rs2);
3878 gen_op_store_FT0_fpr(rd);
3880 case 0x07a: /* VIS I fornot1 */
3881 gen_op_load_fpr_DT0(DFPREG(rs1));
3882 gen_op_load_fpr_DT1(DFPREG(rs2));
3883 tcg_gen_helper_0_0(helper_fornot);
3884 gen_op_store_DT0_fpr(DFPREG(rd));
3886 case 0x07b: /* VIS I fornot1s */
3887 gen_op_load_fpr_FT0(rs1);
3888 gen_op_load_fpr_FT1(rs2);
3889 tcg_gen_helper_0_0(helper_fornots);
3890 gen_op_store_FT0_fpr(rd);
3892 case 0x07c: /* VIS I for */
3893 gen_op_load_fpr_DT0(DFPREG(rs1));
3894 gen_op_load_fpr_DT1(DFPREG(rs2));
3895 tcg_gen_helper_0_0(helper_for);
3896 gen_op_store_DT0_fpr(DFPREG(rd));
3898 case 0x07d: /* VIS I fors */
3899 gen_op_load_fpr_FT0(rs1);
3900 gen_op_load_fpr_FT1(rs2);
3901 tcg_gen_helper_0_0(helper_fors);
3902 gen_op_store_FT0_fpr(rd);
3904 case 0x07e: /* VIS I fone */
3905 tcg_gen_helper_0_0(helper_movl_DT0_1);
3906 gen_op_store_DT0_fpr(DFPREG(rd));
3908 case 0x07f: /* VIS I fones */
3909 tcg_gen_helper_0_0(helper_movl_FT0_1);
3910 gen_op_store_FT0_fpr(rd);
3912 case 0x080: /* VIS I shutdown */
3913 case 0x081: /* VIS II siam */
3922 } else if (xop == 0x37) { /* V8 CPop2, V9 impdep2 */
3923 #ifdef TARGET_SPARC64
3928 #ifdef TARGET_SPARC64
3929 } else if (xop == 0x39) { /* V9 return */
3930 save_state(dc, cpu_cond);
3931 cpu_src1 = get_src1(insn, cpu_src1);
3932 if (IS_IMM) { /* immediate */
3933 rs2 = GET_FIELDs(insn, 19, 31);
3934 tcg_gen_addi_tl(cpu_dst, cpu_src1, (int)rs2);
3935 } else { /* register */
3936 rs2 = GET_FIELD(insn, 27, 31);
3940 gen_movl_reg_TN(rs2, cpu_src2);
3941 tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2);
3946 tcg_gen_helper_0_0(helper_restore);
3947 gen_mov_pc_npc(dc, cpu_cond);
3948 tcg_gen_helper_0_2(helper_check_align, cpu_dst, tcg_const_i32(3));
3949 tcg_gen_mov_tl(cpu_npc, cpu_dst);
3950 dc->npc = DYNAMIC_PC;
3954 cpu_src1 = get_src1(insn, cpu_src1);
3955 if (IS_IMM) { /* immediate */
3956 rs2 = GET_FIELDs(insn, 19, 31);
3957 tcg_gen_addi_tl(cpu_dst, cpu_src1, (int)rs2);
3958 } else { /* register */
3959 rs2 = GET_FIELD(insn, 27, 31);
3963 gen_movl_reg_TN(rs2, cpu_src2);
3964 tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2);
3970 case 0x38: /* jmpl */
3973 tcg_gen_movi_tl(cpu_tmp0, dc->pc);
3974 gen_movl_TN_reg(rd, cpu_tmp0);
3976 gen_mov_pc_npc(dc, cpu_cond);
3977 tcg_gen_helper_0_2(helper_check_align, cpu_dst, tcg_const_i32(3));
3978 tcg_gen_mov_tl(cpu_npc, cpu_dst);
3979 dc->npc = DYNAMIC_PC;
3982 #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
3983 case 0x39: /* rett, V9 return */
3985 if (!supervisor(dc))
3987 gen_mov_pc_npc(dc, cpu_cond);
3988 tcg_gen_helper_0_2(helper_check_align, cpu_dst, tcg_const_i32(3));
3989 tcg_gen_mov_tl(cpu_npc, cpu_dst);
3990 dc->npc = DYNAMIC_PC;
3991 tcg_gen_helper_0_0(helper_rett);
3995 case 0x3b: /* flush */
3996 tcg_gen_helper_0_1(helper_flush, cpu_dst);
3998 case 0x3c: /* save */
3999 save_state(dc, cpu_cond);
4000 tcg_gen_helper_0_0(helper_save);
4001 gen_movl_TN_reg(rd, cpu_dst);
4003 case 0x3d: /* restore */
4004 save_state(dc, cpu_cond);
4005 tcg_gen_helper_0_0(helper_restore);
4006 gen_movl_TN_reg(rd, cpu_dst);
4008 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
4009 case 0x3e: /* V9 done/retry */
4013 if (!supervisor(dc))
4015 dc->npc = DYNAMIC_PC;
4016 dc->pc = DYNAMIC_PC;
4017 tcg_gen_helper_0_0(helper_done);
4020 if (!supervisor(dc))
4022 dc->npc = DYNAMIC_PC;
4023 dc->pc = DYNAMIC_PC;
4024 tcg_gen_helper_0_0(helper_retry);
4039 case 3: /* load/store instructions */
4041 unsigned int xop = GET_FIELD(insn, 7, 12);
4043 save_state(dc, cpu_cond);
4044 cpu_src1 = get_src1(insn, cpu_src1);
4045 if (xop == 0x3c || xop == 0x3e)
4047 rs2 = GET_FIELD(insn, 27, 31);
4048 gen_movl_reg_TN(rs2, cpu_src2);
4050 else if (IS_IMM) { /* immediate */
4051 rs2 = GET_FIELDs(insn, 19, 31);
4052 tcg_gen_addi_tl(cpu_addr, cpu_src1, (int)rs2);
4053 } else { /* register */
4054 rs2 = GET_FIELD(insn, 27, 31);
4058 gen_movl_reg_TN(rs2, cpu_src2);
4059 tcg_gen_add_tl(cpu_addr, cpu_src1, cpu_src2);
4064 if (xop < 4 || (xop > 7 && xop < 0x14 && xop != 0x0e) ||
4065 (xop > 0x17 && xop <= 0x1d ) ||
4066 (xop > 0x2c && xop <= 0x33) || xop == 0x1f || xop == 0x3d) {
4068 case 0x0: /* load unsigned word */
4069 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4070 ABI32_MASK(cpu_addr);
4071 tcg_gen_qemu_ld32u(cpu_val, cpu_addr, dc->mem_idx);
4073 case 0x1: /* load unsigned byte */
4074 ABI32_MASK(cpu_addr);
4075 tcg_gen_qemu_ld8u(cpu_val, cpu_addr, dc->mem_idx);
4077 case 0x2: /* load unsigned halfword */
4078 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(1));
4079 ABI32_MASK(cpu_addr);
4080 tcg_gen_qemu_ld16u(cpu_val, cpu_addr, dc->mem_idx);
4082 case 0x3: /* load double word */
4086 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4087 ABI32_MASK(cpu_addr);
4088 tcg_gen_qemu_ld64(cpu_tmp64, cpu_addr, dc->mem_idx);
4089 tcg_gen_trunc_i64_tl(cpu_tmp0, cpu_tmp64);
4090 tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0xffffffffULL);
4091 gen_movl_TN_reg(rd + 1, cpu_tmp0);
4092 tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);
4093 tcg_gen_trunc_i64_tl(cpu_val, cpu_tmp64);
4094 tcg_gen_andi_tl(cpu_val, cpu_val, 0xffffffffULL);
4097 case 0x9: /* load signed byte */
4098 ABI32_MASK(cpu_addr);
4099 tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx);
4101 case 0xa: /* load signed halfword */
4102 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(1));
4103 ABI32_MASK(cpu_addr);
4104 tcg_gen_qemu_ld16s(cpu_val, cpu_addr, dc->mem_idx);
4106 case 0xd: /* ldstub -- XXX: should be atomically */
4107 ABI32_MASK(cpu_addr);
4108 tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx);
4109 tcg_gen_qemu_st8(tcg_const_tl(0xff), cpu_addr, dc->mem_idx);
4111 case 0x0f: /* swap register with memory. Also atomically */
4112 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4113 gen_movl_reg_TN(rd, cpu_val);
4114 ABI32_MASK(cpu_addr);
4115 tcg_gen_qemu_ld32u(cpu_tmp32, cpu_addr, dc->mem_idx);
4116 tcg_gen_qemu_st32(cpu_val, cpu_addr, dc->mem_idx);
4117 tcg_gen_extu_i32_tl(cpu_val, cpu_tmp32);
4119 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
4120 case 0x10: /* load word alternate */
4121 #ifndef TARGET_SPARC64
4124 if (!supervisor(dc))
4127 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4128 gen_ld_asi(cpu_val, cpu_addr, insn, 4, 0);
4130 case 0x11: /* load unsigned byte alternate */
4131 #ifndef TARGET_SPARC64
4134 if (!supervisor(dc))
4137 gen_ld_asi(cpu_val, cpu_addr, insn, 1, 0);
4139 case 0x12: /* load unsigned halfword alternate */
4140 #ifndef TARGET_SPARC64
4143 if (!supervisor(dc))
4146 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(1));
4147 gen_ld_asi(cpu_val, cpu_addr, insn, 2, 0);
4149 case 0x13: /* load double word alternate */
4150 #ifndef TARGET_SPARC64
4153 if (!supervisor(dc))
4158 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4159 gen_ldda_asi(cpu_tmp0, cpu_val, cpu_addr, insn);
4160 gen_movl_TN_reg(rd + 1, cpu_tmp0);
4162 case 0x19: /* load signed byte alternate */
4163 #ifndef TARGET_SPARC64
4166 if (!supervisor(dc))
4169 gen_ld_asi(cpu_val, cpu_addr, insn, 1, 1);
4171 case 0x1a: /* load signed halfword alternate */
4172 #ifndef TARGET_SPARC64
4175 if (!supervisor(dc))
4178 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(1));
4179 gen_ld_asi(cpu_val, cpu_addr, insn, 2, 1);
4181 case 0x1d: /* ldstuba -- XXX: should be atomically */
4182 #ifndef TARGET_SPARC64
4185 if (!supervisor(dc))
4188 gen_ldstub_asi(cpu_val, cpu_addr, insn);
4190 case 0x1f: /* swap reg with alt. memory. Also atomically */
4191 #ifndef TARGET_SPARC64
4194 if (!supervisor(dc))
4197 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4198 gen_movl_reg_TN(rd, cpu_val);
4199 gen_swap_asi(cpu_val, cpu_addr, insn);
4202 #ifndef TARGET_SPARC64
4203 case 0x30: /* ldc */
4204 case 0x31: /* ldcsr */
4205 case 0x33: /* lddc */
4209 #ifdef TARGET_SPARC64
4210 case 0x08: /* V9 ldsw */
4211 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4212 ABI32_MASK(cpu_addr);
4213 tcg_gen_qemu_ld32s(cpu_val, cpu_addr, dc->mem_idx);
4215 case 0x0b: /* V9 ldx */
4216 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4217 ABI32_MASK(cpu_addr);
4218 tcg_gen_qemu_ld64(cpu_val, cpu_addr, dc->mem_idx);
4220 case 0x18: /* V9 ldswa */
4221 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4222 gen_ld_asi(cpu_val, cpu_addr, insn, 4, 1);
4224 case 0x1b: /* V9 ldxa */
4225 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4226 gen_ld_asi(cpu_val, cpu_addr, insn, 8, 0);
4228 case 0x2d: /* V9 prefetch, no effect */
4230 case 0x30: /* V9 ldfa */
4231 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4232 gen_ldf_asi(cpu_addr, insn, 4, rd);
4234 case 0x33: /* V9 lddfa */
4235 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4236 gen_ldf_asi(cpu_addr, insn, 8, DFPREG(rd));
4238 case 0x3d: /* V9 prefetcha, no effect */
4240 case 0x32: /* V9 ldqfa */
4241 #if defined(CONFIG_USER_ONLY)
4242 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4243 gen_ldf_asi(cpu_addr, insn, 16, QFPREG(rd));
4252 gen_movl_TN_reg(rd, cpu_val);
4253 #ifdef TARGET_SPARC64
4256 } else if (xop >= 0x20 && xop < 0x24) {
4257 if (gen_trap_ifnofpu(dc, cpu_cond))
4260 case 0x20: /* load fpreg */
4261 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4262 tcg_gen_qemu_ld32u(cpu_tmp32, cpu_addr, dc->mem_idx);
4263 tcg_gen_st_i32(cpu_tmp32, cpu_env,
4264 offsetof(CPUState, fpr[rd]));
4266 case 0x21: /* load fsr */
4267 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4268 tcg_gen_qemu_ld32u(cpu_tmp32, cpu_addr, dc->mem_idx);
4269 tcg_gen_st_i32(cpu_tmp32, cpu_env,
4270 offsetof(CPUState, ft0));
4271 tcg_gen_helper_0_0(helper_ldfsr);
4273 case 0x22: /* load quad fpreg */
4274 #if defined(CONFIG_USER_ONLY)
4275 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4277 gen_op_store_QT0_fpr(QFPREG(rd));
4282 case 0x23: /* load double fpreg */
4283 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4285 gen_op_store_DT0_fpr(DFPREG(rd));
4290 } else if (xop < 8 || (xop >= 0x14 && xop < 0x18) || \
4291 xop == 0xe || xop == 0x1e) {
4292 gen_movl_reg_TN(rd, cpu_val);
4294 case 0x4: /* store word */
4295 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4296 ABI32_MASK(cpu_addr);
4297 tcg_gen_qemu_st32(cpu_val, cpu_addr, dc->mem_idx);
4299 case 0x5: /* store byte */
4300 ABI32_MASK(cpu_addr);
4301 tcg_gen_qemu_st8(cpu_val, cpu_addr, dc->mem_idx);
4303 case 0x6: /* store halfword */
4304 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(1));
4305 ABI32_MASK(cpu_addr);
4306 tcg_gen_qemu_st16(cpu_val, cpu_addr, dc->mem_idx);
4308 case 0x7: /* store double word */
4315 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4316 r_low = tcg_temp_new(TCG_TYPE_I32);
4317 gen_movl_reg_TN(rd + 1, r_low);
4318 tcg_gen_helper_1_2(helper_pack64, cpu_tmp64, cpu_val,
4320 tcg_gen_qemu_st64(cpu_tmp64, cpu_addr, dc->mem_idx);
4322 #else /* __i386__ */
4323 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4324 flush_cond(dc, cpu_cond);
4325 gen_movl_reg_TN(rd + 1, cpu_cond);
4327 #endif /* __i386__ */
4329 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
4330 case 0x14: /* store word alternate */
4331 #ifndef TARGET_SPARC64
4334 if (!supervisor(dc))
4337 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4338 gen_st_asi(cpu_val, cpu_addr, insn, 4);
4340 case 0x15: /* store byte alternate */
4341 #ifndef TARGET_SPARC64
4344 if (!supervisor(dc))
4347 gen_st_asi(cpu_val, cpu_addr, insn, 1);
4349 case 0x16: /* store halfword alternate */
4350 #ifndef TARGET_SPARC64
4353 if (!supervisor(dc))
4356 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(1));
4357 gen_st_asi(cpu_val, cpu_addr, insn, 2);
4359 case 0x17: /* store double word alternate */
4360 #ifndef TARGET_SPARC64
4363 if (!supervisor(dc))
4369 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4370 gen_stda_asi(cpu_val, cpu_addr, insn, rd);
4374 #ifdef TARGET_SPARC64
4375 case 0x0e: /* V9 stx */
4376 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4377 ABI32_MASK(cpu_addr);
4378 tcg_gen_qemu_st64(cpu_val, cpu_addr, dc->mem_idx);
4380 case 0x1e: /* V9 stxa */
4381 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4382 gen_st_asi(cpu_val, cpu_addr, insn, 8);
4388 } else if (xop > 0x23 && xop < 0x28) {
4389 if (gen_trap_ifnofpu(dc, cpu_cond))
4392 case 0x24: /* store fpreg */
4393 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4394 tcg_gen_ld_i32(cpu_tmp32, cpu_env,
4395 offsetof(CPUState, fpr[rd]));
4396 tcg_gen_qemu_st32(cpu_tmp32, cpu_addr, dc->mem_idx);
4398 case 0x25: /* stfsr, V9 stxfsr */
4399 #ifdef CONFIG_USER_ONLY
4400 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4402 tcg_gen_helper_0_0(helper_stfsr);
4403 tcg_gen_ld_i32(cpu_tmp32, cpu_env,
4404 offsetof(CPUState, ft0));
4405 tcg_gen_qemu_st32(cpu_tmp32, cpu_addr, dc->mem_idx);
4408 #ifdef TARGET_SPARC64
4409 #if defined(CONFIG_USER_ONLY)
4410 /* V9 stqf, store quad fpreg */
4411 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4412 gen_op_load_fpr_QT0(QFPREG(rd));
4418 #else /* !TARGET_SPARC64 */
4419 /* stdfq, store floating point queue */
4420 #if defined(CONFIG_USER_ONLY)
4423 if (!supervisor(dc))
4425 if (gen_trap_ifnofpu(dc, cpu_cond))
4431 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4432 gen_op_load_fpr_DT0(DFPREG(rd));
4438 } else if (xop > 0x33 && xop < 0x3f) {
4440 #ifdef TARGET_SPARC64
4441 case 0x34: /* V9 stfa */
4442 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4443 gen_op_load_fpr_FT0(rd);
4444 gen_stf_asi(cpu_addr, insn, 4, rd);
4446 case 0x36: /* V9 stqfa */
4447 #if defined(CONFIG_USER_ONLY)
4448 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4449 gen_op_load_fpr_QT0(QFPREG(rd));
4450 gen_stf_asi(cpu_addr, insn, 16, QFPREG(rd));
4455 case 0x37: /* V9 stdfa */
4456 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4457 gen_op_load_fpr_DT0(DFPREG(rd));
4458 gen_stf_asi(cpu_addr, insn, 8, DFPREG(rd));
4460 case 0x3c: /* V9 casa */
4461 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(3));
4462 gen_cas_asi(cpu_val, cpu_addr, cpu_val, insn, rd);
4463 gen_movl_TN_reg(rd, cpu_val);
4465 case 0x3e: /* V9 casxa */
4466 tcg_gen_helper_0_2(helper_check_align, cpu_addr, tcg_const_i32(7));
4467 gen_casx_asi(cpu_val, cpu_addr, cpu_val, insn, rd);
4468 gen_movl_TN_reg(rd, cpu_val);
4471 case 0x34: /* stc */
4472 case 0x35: /* stcsr */
4473 case 0x36: /* stdcq */
4474 case 0x37: /* stdc */
4486 /* default case for non jump instructions */
4487 if (dc->npc == DYNAMIC_PC) {
4488 dc->pc = DYNAMIC_PC;
4490 } else if (dc->npc == JUMP_PC) {
4491 /* we can do a static jump */
4492 gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], cpu_cond);
4496 dc->npc = dc->npc + 4;
4501 save_state(dc, cpu_cond);
4502 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_ILL_INSN));
4505 #if !defined(CONFIG_USER_ONLY)
4507 save_state(dc, cpu_cond);
4508 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_PRIV_INSN));
4512 save_state(dc, cpu_cond);
4513 gen_op_fpexception_im(FSR_FTT_UNIMPFPOP);
4516 #ifndef TARGET_SPARC64
4518 save_state(dc, cpu_cond);
4519 gen_op_fpexception_im(FSR_FTT_SEQ_ERROR);
4524 #ifndef TARGET_SPARC64
4526 save_state(dc, cpu_cond);
4527 tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_NCP_INSN));
4533 static void tcg_macro_func(TCGContext *s, int macro_id, const int *dead_args)
4537 static inline int gen_intermediate_code_internal(TranslationBlock * tb,
4538 int spc, CPUSPARCState *env)
4540 target_ulong pc_start, last_pc;
4541 uint16_t *gen_opc_end;
4542 DisasContext dc1, *dc = &dc1;
4545 memset(dc, 0, sizeof(DisasContext));
4550 dc->npc = (target_ulong) tb->cs_base;
4551 dc->mem_idx = cpu_mmu_index(env);
4552 dc->fpu_enabled = cpu_fpu_enabled(env);
4553 gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
4555 cpu_tmp0 = tcg_temp_new(TCG_TYPE_TL);
4556 cpu_tmp32 = tcg_temp_new(TCG_TYPE_I32);
4557 cpu_tmp64 = tcg_temp_new(TCG_TYPE_I64);
4559 cpu_cond = cpu_T[2];
4562 if (env->nb_breakpoints > 0) {
4563 for(j = 0; j < env->nb_breakpoints; j++) {
4564 if (env->breakpoints[j] == dc->pc) {
4565 if (dc->pc != pc_start)
4566 save_state(dc, cpu_cond);
4567 tcg_gen_helper_0_0(helper_debug);
4576 fprintf(logfile, "Search PC...\n");
4577 j = gen_opc_ptr - gen_opc_buf;
4581 gen_opc_instr_start[lj++] = 0;
4582 gen_opc_pc[lj] = dc->pc;
4583 gen_opc_npc[lj] = dc->npc;
4584 gen_opc_instr_start[lj] = 1;
4588 disas_sparc_insn(dc);
4592 /* if the next PC is different, we abort now */
4593 if (dc->pc != (last_pc + 4))
4595 /* if we reach a page boundary, we stop generation so that the
4596 PC of a TT_TFAULT exception is always in the right page */
4597 if ((dc->pc & (TARGET_PAGE_SIZE - 1)) == 0)
4599 /* if single step mode, we generate only one instruction and
4600 generate an exception */
4601 if (env->singlestep_enabled) {
4602 tcg_gen_movi_tl(cpu_pc, dc->pc);
4606 } while ((gen_opc_ptr < gen_opc_end) &&
4607 (dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32));
4611 if (dc->pc != DYNAMIC_PC &&
4612 (dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
4613 /* static PC and NPC: we can use direct chaining */
4614 gen_goto_tb(dc, 0, dc->pc, dc->npc);
4616 if (dc->pc != DYNAMIC_PC)
4617 tcg_gen_movi_tl(cpu_pc, dc->pc);
4618 save_npc(dc, cpu_cond);
4622 *gen_opc_ptr = INDEX_op_end;
4624 j = gen_opc_ptr - gen_opc_buf;
4627 gen_opc_instr_start[lj++] = 0;
4633 gen_opc_jump_pc[0] = dc->jump_pc[0];
4634 gen_opc_jump_pc[1] = dc->jump_pc[1];
4636 tb->size = last_pc + 4 - pc_start;
4639 if (loglevel & CPU_LOG_TB_IN_ASM) {
4640 fprintf(logfile, "--------------\n");
4641 fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
4642 target_disas(logfile, pc_start, last_pc + 4 - pc_start, 0);
4643 fprintf(logfile, "\n");
4649 int gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
4651 return gen_intermediate_code_internal(tb, 0, env);
4654 int gen_intermediate_code_pc(CPUSPARCState * env, TranslationBlock * tb)
4656 return gen_intermediate_code_internal(tb, 1, env);
4659 void gen_intermediate_code_init(CPUSPARCState *env)
4663 static const char * const gregnames[8] = {
4664 NULL, // g0 not used
4674 /* init various static tables */
4678 tcg_set_macro_func(&tcg_ctx, tcg_macro_func);
4679 cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
4680 cpu_regwptr = tcg_global_mem_new(TCG_TYPE_PTR, TCG_AREG0,
4681 offsetof(CPUState, regwptr),
4683 //#if TARGET_LONG_BITS > HOST_LONG_BITS
4684 #ifdef TARGET_SPARC64
4685 cpu_T[0] = tcg_global_mem_new(TCG_TYPE_TL,
4686 TCG_AREG0, offsetof(CPUState, t0), "T0");
4687 cpu_T[1] = tcg_global_mem_new(TCG_TYPE_TL,
4688 TCG_AREG0, offsetof(CPUState, t1), "T1");
4689 cpu_T[2] = tcg_global_mem_new(TCG_TYPE_TL,
4690 TCG_AREG0, offsetof(CPUState, t2), "T2");
4691 cpu_xcc = tcg_global_mem_new(TCG_TYPE_I32,
4692 TCG_AREG0, offsetof(CPUState, xcc),
4695 cpu_T[0] = tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG1, "T0");
4696 cpu_T[1] = tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG2, "T1");
4697 cpu_T[2] = tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG3, "T2");
4699 cpu_cc_src = tcg_global_mem_new(TCG_TYPE_TL,
4700 TCG_AREG0, offsetof(CPUState, cc_src),
4702 cpu_cc_src2 = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
4703 offsetof(CPUState, cc_src2),
4705 cpu_cc_dst = tcg_global_mem_new(TCG_TYPE_TL,
4706 TCG_AREG0, offsetof(CPUState, cc_dst),
4708 cpu_psr = tcg_global_mem_new(TCG_TYPE_I32,
4709 TCG_AREG0, offsetof(CPUState, psr),
4711 cpu_fsr = tcg_global_mem_new(TCG_TYPE_TL,
4712 TCG_AREG0, offsetof(CPUState, fsr),
4714 cpu_pc = tcg_global_mem_new(TCG_TYPE_TL,
4715 TCG_AREG0, offsetof(CPUState, pc),
4717 cpu_npc = tcg_global_mem_new(TCG_TYPE_TL,
4718 TCG_AREG0, offsetof(CPUState, npc),
4720 for (i = 1; i < 8; i++)
4721 cpu_gregs[i] = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
4722 offsetof(CPUState, gregs[i]),