char *p;
static int done_init = 0;
- if (done_init)
+ if (done_init) {
return;
+ }
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
int i;
for (i = 0; i < 8; ++i) {
- if ((lit >> i) & 1)
+ if ((lit >> i) & 1) {
mask |= 0xffull << (i * 8);
+ }
}
return mask;
}
static inline void gen_zapnot(int ra, int rb, int rc, int islit, uint8_t lit)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31))
+ } else if (unlikely(ra == 31)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else if (islit)
+ } else if (islit) {
gen_zapnoti(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
gen_helper_zapnot (cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
}
static inline void gen_zap(int ra, int rb, int rc, int islit, uint8_t lit)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31))
+ } else if (unlikely(ra == 31)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else if (islit)
+ } else if (islit) {
gen_zapnoti(cpu_ir[rc], cpu_ir[ra], ~lit);
- else
+ } else {
gen_helper_zap (cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
}
static void gen_ext_h(int ra, int rb, int rc, int islit,
uint8_t lit, uint8_t byte_mask)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31))
+ } else if (unlikely(ra == 31)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else {
+ } else {
if (islit) {
lit = (64 - (lit & 7) * 8) & 0x3f;
tcg_gen_shli_i64(cpu_ir[rc], cpu_ir[ra], lit);
static void gen_ext_l(int ra, int rb, int rc, int islit,
uint8_t lit, uint8_t byte_mask)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31))
+ } else if (unlikely(ra == 31)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else {
+ } else {
if (islit) {
tcg_gen_shri_i64(cpu_ir[rc], cpu_ir[ra], (lit & 7) * 8);
} else {
static void gen_ins_h(int ra, int rb, int rc, int islit,
uint8_t lit, uint8_t byte_mask)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31) || (islit && (lit & 7) == 0))
+ } else if (unlikely(ra == 31) || (islit && (lit & 7) == 0)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else {
+ } else {
TCGv tmp = tcg_temp_new();
/* The instruction description has us left-shift the byte mask
static void gen_ins_l(int ra, int rb, int rc, int islit,
uint8_t lit, uint8_t byte_mask)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31))
+ } else if (unlikely(ra == 31)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else {
+ } else {
TCGv tmp = tcg_temp_new();
/* The instruction description has us left-shift the byte mask
static void gen_msk_h(int ra, int rb, int rc, int islit,
uint8_t lit, uint8_t byte_mask)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31))
+ } else if (unlikely(ra == 31)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else if (islit) {
+ } else if (islit) {
gen_zapnoti (cpu_ir[rc], cpu_ir[ra], ~((byte_mask << (lit & 7)) >> 8));
} else {
TCGv shift = tcg_temp_new();
static void gen_msk_l(int ra, int rb, int rc, int islit,
uint8_t lit, uint8_t byte_mask)
{
- if (unlikely(rc == 31))
+ if (unlikely(rc == 31)) {
return;
- else if (unlikely(ra == 31))
+ } else if (unlikely(ra == 31)) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else if (islit) {
+ } else if (islit) {
gen_zapnoti (cpu_ir[rc], cpu_ir[ra], ~(byte_mask << (lit & 7)));
} else {
TCGv shift = tcg_temp_new();
case 0x08:
/* LDA */
if (likely(ra != 31)) {
- if (rb != 31)
+ if (rb != 31) {
tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16);
- else
+ } else {
tcg_gen_movi_i64(cpu_ir[ra], disp16);
+ }
}
break;
case 0x09:
/* LDAH */
if (likely(ra != 31)) {
- if (rb != 31)
+ if (rb != 31) {
tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16 << 16);
- else
+ } else {
tcg_gen_movi_i64(cpu_ir[ra], disp16 << 16);
+ }
}
break;
case 0x0A:
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
- if (islit)
+ if (islit) {
tcg_gen_addi_i64(tmp, tmp, lit);
- else
+ } else {
tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]);
+ }
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
/* SUBL */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], -lit);
- else {
+ } else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
- if (islit)
+ if (islit) {
tcg_gen_subi_i64(tmp, tmp, lit);
- else
+ } else {
tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]);
+ }
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], -lit);
- else {
+ } else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
- if (islit)
+ if (islit) {
tcg_gen_addi_i64(tmp, tmp, lit);
- else
+ } else {
tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]);
+ }
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
- if (islit)
+ if (islit) {
tcg_gen_subi_i64(tmp, tmp, lit);
- else
+ } else {
tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]);
+ }
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], -lit);
- else {
+ } else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
/* ADDQ */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_addi_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_add_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
- if (islit)
+ if (islit) {
tcg_gen_addi_i64(cpu_ir[rc], tmp, lit);
- else
+ } else {
tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
+ }
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
/* SUBQ */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], -lit);
- else
+ } else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
- if (islit)
+ if (islit) {
tcg_gen_subi_i64(cpu_ir[rc], tmp, lit);
- else
+ } else {
tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
+ }
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], -lit);
- else
+ } else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
- if (islit)
+ if (islit) {
tcg_gen_addi_i64(cpu_ir[rc], tmp, lit);
- else
+ } else {
tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
+ }
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
if (ra != 31) {
TCGv tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
- if (islit)
+ if (islit) {
tcg_gen_subi_i64(cpu_ir[rc], tmp, lit);
- else
+ } else {
tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
+ }
tcg_temp_free(tmp);
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], -lit);
- else
+ } else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
case 0x00:
/* AND */
if (likely(rc != 31)) {
- if (ra == 31)
+ if (ra == 31) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else if (islit)
+ } else if (islit) {
tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_and_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
}
break;
case 0x08:
/* BIC */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
- else
+ } else {
tcg_gen_andc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
/* BIS */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_or_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
/* ORNOT */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
- else
+ } else {
tcg_gen_orc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], ~lit);
- else
+ } else {
tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
/* XOR */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_xor_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], lit);
- else
+ } else {
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
/* EQV */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
- else
+ } else {
tcg_gen_eqv_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
} else {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], ~lit);
- else
+ } else {
tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
}
break;
/* SRL */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_shri_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
- else {
+ } else {
TCGv shift = tcg_temp_new();
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_shr_i64(cpu_ir[rc], cpu_ir[ra], shift);
/* SLL */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_shli_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
- else {
+ } else {
TCGv shift = tcg_temp_new();
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_shl_i64(cpu_ir[rc], cpu_ir[ra], shift);
/* SRA */
if (likely(rc != 31)) {
if (ra != 31) {
- if (islit)
+ if (islit) {
tcg_gen_sari_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
- else {
+ } else {
TCGv shift = tcg_temp_new();
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_sar_i64(cpu_ir[rc], cpu_ir[ra], shift);
case 0x00:
/* MULL */
if (likely(rc != 31)) {
- if (ra == 31)
+ if (ra == 31) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else {
- if (islit)
+ } else {
+ if (islit) {
tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
case 0x20:
/* MULQ */
if (likely(rc != 31)) {
- if (ra == 31)
+ if (ra == 31) {
tcg_gen_movi_i64(cpu_ir[rc], 0);
- else if (islit)
+ } else if (islit) {
tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit);
- else
+ } else {
tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
+ }
}
break;
case 0x30:
goto invalid_opc;
}
if (likely(rc != 31)) {
- if (ra != 31)
+ if (ra != 31) {
tcg_gen_mov_i64(cpu_fir[rc], cpu_ir[ra]);
- else
+ } else {
tcg_gen_movi_i64(cpu_fir[rc], 0);
+ }
}
break;
case 0x2A:
if (likely(rc != 31)) {
if (ra == rb) {
/* FMOV */
- if (ra == 31)
+ if (ra == 31) {
tcg_gen_movi_i64(cpu_fir[rc], 0);
- else
+ } else {
tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);
+ }
} else {
/* CPYS */
gen_fcpys(ra, rb, rc);
break;
case 0x024:
/* MT_FPCR */
- if (likely(ra != 31))
+ if (likely(ra != 31)) {
gen_helper_store_fpcr(cpu_env, cpu_fir[ra]);
- else {
+ } else {
TCGv tmp = tcg_const_i64(0);
gen_helper_store_fpcr(cpu_env, tmp);
tcg_temp_free(tmp);
break;
case 0x025:
/* MF_FPCR */
- if (likely(ra != 31))
+ if (likely(ra != 31)) {
gen_helper_load_fpcr(cpu_fir[ra], cpu_env);
+ }
break;
case 0x02A:
/* FCMOVEQ */
}
addr = tcg_temp_new();
- if (rb != 31)
+ if (rb != 31) {
tcg_gen_addi_i64(addr, cpu_ir[rb], disp12);
- else
+ } else {
tcg_gen_movi_i64(addr, disp12);
+ }
switch ((insn >> 12) & 0xF) {
case 0x0:
/* Longword physical access (hw_ldl/p) */
goto invalid_opc;
}
if (likely(rc != 31)) {
- if (islit)
+ if (islit) {
tcg_gen_movi_i64(cpu_ir[rc], (int64_t)((int8_t)lit));
- else
+ } else {
tcg_gen_ext8s_i64(cpu_ir[rc], cpu_ir[rb]);
+ }
}
break;
case 0x01:
goto invalid_opc;
}
if (likely(rc != 31)) {
- if (ra != 31)
+ if (ra != 31) {
tcg_gen_mov_i64(cpu_ir[rc], cpu_fir[ra]);
- else
+ } else {
tcg_gen_movi_i64(cpu_ir[rc], 0);
+ }
}
break;
case 0x78:
}
if (rc != 31) {
TCGv_i32 tmp1 = tcg_temp_new_i32();
- if (ra != 31)
+ if (ra != 31) {
gen_helper_s_to_memory(tmp1, cpu_fir[ra]);
- else {
+ } else {
TCGv tmp2 = tcg_const_i64(0);
gen_helper_s_to_memory(tmp1, tmp2);
tcg_temp_free(tmp2);
if (ctx->tb->flags & TB_FLAGS_PAL_MODE) {
TCGv addr, val;
addr = tcg_temp_new();
- if (rb != 31)
+ if (rb != 31) {
tcg_gen_addi_i64(addr, cpu_ir[rb], disp12);
- else
+ } else {
tcg_gen_movi_i64(addr, disp12);
- if (ra != 31)
+ }
+ if (ra != 31) {
val = cpu_ir[ra];
- else {
+ } else {
val = tcg_temp_new();
tcg_gen_movi_i64(val, 0);
}
/* Invalid */
goto invalid_opc;
}
- if (ra == 31)
+ if (ra == 31) {
tcg_temp_free(val);
+ }
tcg_temp_free(addr);
break;
}
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
- if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
+ if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
+ }
insn = cpu_ldl_code(env, ctx.pc);
num_insns++;