aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-08-22 17:01:30 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-08-22 17:01:30 +0100
commitd013d220c710054a6d755941460f88c186fef7b5 (patch)
tree07f002eb88d0a414d9376c18ab9636b42484d178
parente1391340c77e206644f6ecaeab5df0b7b1a1bf93 (diff)
parentd4881da9b39df183f976349f223231ac1d81087b (diff)
downloadqemu-d013d220c710054a6d755941460f88c186fef7b5.zip
qemu-d013d220c710054a6d755941460f88c186fef7b5.tar.gz
qemu-d013d220c710054a6d755941460f88c186fef7b5.tar.bz2
Merge remote-tracking branch 'remotes/bkoppelmann2/tags/pull-tricore-20190822-1' into staging
Converted target/tricore to translate_loop # gpg: Signature made Thu 22 Aug 2019 11:17:37 BST # gpg: using RSA key 6E636A7E83F2DD0CFA6E6E370AD2C6396B69CA14 # gpg: issuer "kbastian@mail.uni-paderborn.de" # gpg: Good signature from "Bastian Koppelmann <kbastian@mail.uni-paderborn.de>" [full] # Primary key fingerprint: 6E63 6A7E 83F2 DD0C FA6E 6E37 0AD2 C639 6B69 CA14 * remotes/bkoppelmann2/tags/pull-tricore-20190822-1: target/tricore: Fix tricore_tr_translate_insn target/tricore: Implement a qemu excptions helper target/tricore: Use translate_loop target-tricore: Make env a member of DisasContext target/tricore: Use DisasContextBase API Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--target/tricore/helper.h1
-rw-r--r--target/tricore/op_helper.c7
-rw-r--r--target/tricore/translate.c577
3 files changed, 324 insertions, 261 deletions
diff --git a/target/tricore/helper.h b/target/tricore/helper.h
index b64780c..78176aa 100644
--- a/target/tricore/helper.h
+++ b/target/tricore/helper.h
@@ -153,3 +153,4 @@ DEF_HELPER_2(psw_write, void, env, i32)
DEF_HELPER_1(psw_read, i32, env)
/* Exceptions */
DEF_HELPER_3(raise_exception_sync, noreturn, env, i32, i32)
+DEF_HELPER_2(qemu_excp, noreturn, env, i32)
diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c
index 9476d10..32c2bc1 100644
--- a/target/tricore/op_helper.c
+++ b/target/tricore/op_helper.c
@@ -107,6 +107,13 @@ static void raise_exception_sync_helper(CPUTriCoreState *env, uint32_t class,
raise_exception_sync_internal(env, class, tin, pc, 0);
}
+void helper_qemu_excp(CPUTriCoreState *env, uint32_t excp)
+{
+ CPUState *cs = env_cpu(env);
+ cs->exception_index = excp;
+ cpu_loop_exit(cs);
+}
+
/* Addressing mode helper */
static uint16_t reverse16(uint16_t val)
diff --git a/target/tricore/translate.c b/target/tricore/translate.c
index dc2a65f..4f10407 100644
--- a/target/tricore/translate.c
+++ b/target/tricore/translate.c
@@ -30,6 +30,7 @@
#include "exec/helper-gen.h"
#include "tricore-opcodes.h"
+#include "exec/translator.h"
#include "exec/log.h"
/*
@@ -64,25 +65,16 @@ static const char *regnames_d[] = {
};
typedef struct DisasContext {
- struct TranslationBlock *tb;
- target_ulong pc, saved_pc, next_pc;
+ DisasContextBase base;
+ CPUTriCoreState *env;
+ target_ulong pc_succ_insn;
uint32_t opcode;
- int singlestep_enabled;
/* Routine used to access memory */
int mem_idx;
uint32_t hflags, saved_hflags;
- int bstate;
} DisasContext;
enum {
-
- BS_NONE = 0,
- BS_STOP = 1,
- BS_BRANCH = 2,
- BS_EXCP = 3,
-};
-
-enum {
MODE_LL = 0,
MODE_LU = 1,
MODE_UL = 2,
@@ -378,13 +370,13 @@ static void gen_swapmsk(DisasContext *ctx, int reg, TCGv ea)
These makros also specify in which ISA version the csfr was introduced. */
#define R(ADDRESS, REG, FEATURE) \
case ADDRESS: \
- if (tricore_feature(env, FEATURE)) { \
+ if (tricore_feature(ctx->env, FEATURE)) { \
tcg_gen_ld_tl(ret, cpu_env, offsetof(CPUTriCoreState, REG)); \
} \
break;
#define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
#define E(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
-static inline void gen_mfcr(CPUTriCoreState *env, TCGv ret, int32_t offset)
+static inline void gen_mfcr(DisasContext *ctx, TCGv ret, int32_t offset)
{
/* since we're caching PSW make this a special case */
if (offset == 0xfe04) {
@@ -403,7 +395,7 @@ static inline void gen_mfcr(CPUTriCoreState *env, TCGv ret, int32_t offset)
since no execption occurs */
#define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE) \
case ADDRESS: \
- if (tricore_feature(env, FEATURE)) { \
+ if (tricore_feature(ctx->env, FEATURE)) { \
tcg_gen_st_tl(r1, cpu_env, offsetof(CPUTriCoreState, REG)); \
} \
break;
@@ -412,7 +404,7 @@ static inline void gen_mfcr(CPUTriCoreState *env, TCGv ret, int32_t offset)
watchdog device, we handle endinit protected registers like
all-access registers for now. */
#define E(ADDRESS, REG, FEATURE) A(ADDRESS, REG, FEATURE)
-static inline void gen_mtcr(CPUTriCoreState *env, DisasContext *ctx, TCGv r1,
+static inline void gen_mtcr(DisasContext *ctx, TCGv r1,
int32_t offset)
{
if ((ctx->hflags & TRICORE_HFLAG_KUU) == TRICORE_HFLAG_SM) {
@@ -1102,7 +1094,7 @@ gen_maddrs_q(TCGv ret, TCGv r1, TCGv r2, TCGv r3, uint32_t n)
static inline void
gen_madd32_q(TCGv ret, TCGv arg1, TCGv arg2, TCGv arg3, uint32_t n,
- uint32_t up_shift, CPUTriCoreState *env)
+ uint32_t up_shift)
{
TCGv temp = tcg_temp_new();
TCGv temp2 = tcg_temp_new();
@@ -1263,7 +1255,7 @@ gen_m16adds64_q(TCGv rl, TCGv rh, TCGv arg1_low, TCGv arg1_high, TCGv arg2,
static inline void
gen_madd64_q(TCGv rl, TCGv rh, TCGv arg1_low, TCGv arg1_high, TCGv arg2,
- TCGv arg3, uint32_t n, CPUTriCoreState *env)
+ TCGv arg3, uint32_t n)
{
TCGv_i64 t1 = tcg_temp_new_i64();
TCGv_i64 t2 = tcg_temp_new_i64();
@@ -1961,7 +1953,7 @@ gen_msubrs_q(TCGv ret, TCGv r1, TCGv r2, TCGv r3, uint32_t n)
static inline void
gen_msub32_q(TCGv ret, TCGv arg1, TCGv arg2, TCGv arg3, uint32_t n,
- uint32_t up_shift, CPUTriCoreState *env)
+ uint32_t up_shift)
{
TCGv temp = tcg_temp_new();
TCGv temp2 = tcg_temp_new();
@@ -2116,7 +2108,7 @@ gen_m16subs64_q(TCGv rl, TCGv rh, TCGv arg1_low, TCGv arg1_high, TCGv arg2,
static inline void
gen_msub64_q(TCGv rl, TCGv rh, TCGv arg1_low, TCGv arg1_high, TCGv arg2,
- TCGv arg3, uint32_t n, CPUTriCoreState *env)
+ TCGv arg3, uint32_t n)
{
TCGv_i64 t1 = tcg_temp_new_i64();
TCGv_i64 t2 = tcg_temp_new_i64();
@@ -3162,11 +3154,11 @@ static inline void gen_unpack(TCGv rl, TCGv rh, TCGv r1)
}
static inline void
-gen_dvinit_b(CPUTriCoreState *env, TCGv rl, TCGv rh, TCGv r1, TCGv r2)
+gen_dvinit_b(DisasContext *ctx, TCGv rl, TCGv rh, TCGv r1, TCGv r2)
{
TCGv_i64 ret = tcg_temp_new_i64();
- if (!tricore_feature(env, TRICORE_FEATURE_131)) {
+ if (!tricore_feature(ctx->env, TRICORE_FEATURE_131)) {
gen_helper_dvinit_b_13(ret, cpu_env, r1, r2);
} else {
gen_helper_dvinit_b_131(ret, cpu_env, r1, r2);
@@ -3177,11 +3169,11 @@ gen_dvinit_b(CPUTriCoreState *env, TCGv rl, TCGv rh, TCGv r1, TCGv r2)
}
static inline void
-gen_dvinit_h(CPUTriCoreState *env, TCGv rl, TCGv rh, TCGv r1, TCGv r2)
+gen_dvinit_h(DisasContext *ctx, TCGv rl, TCGv rh, TCGv r1, TCGv r2)
{
TCGv_i64 ret = tcg_temp_new_i64();
- if (!tricore_feature(env, TRICORE_FEATURE_131)) {
+ if (!tricore_feature(ctx->env, TRICORE_FEATURE_131)) {
gen_helper_dvinit_h_13(ret, cpu_env, r1, r2);
} else {
gen_helper_dvinit_h_131(ret, cpu_env, r1, r2);
@@ -3230,12 +3222,12 @@ static inline void gen_save_pc(target_ulong pc)
static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest)
{
- if (unlikely(ctx->singlestep_enabled)) {
+ if (unlikely(ctx->base.singlestep_enabled)) {
return false;
}
#ifndef CONFIG_USER_ONLY
- return (ctx->tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK);
+ return (ctx->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK);
#else
return true;
#endif
@@ -3246,10 +3238,10 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
if (use_goto_tb(ctx, dest)) {
tcg_gen_goto_tb(n);
gen_save_pc(dest);
- tcg_gen_exit_tb(ctx->tb, n);
+ tcg_gen_exit_tb(ctx->base.tb, n);
} else {
gen_save_pc(dest);
- if (ctx->singlestep_enabled) {
+ if (ctx->base.singlestep_enabled) {
/* raise exception debug */
}
tcg_gen_exit_tb(NULL, 0);
@@ -3261,24 +3253,33 @@ static void generate_trap(DisasContext *ctx, int class, int tin)
TCGv_i32 classtemp = tcg_const_i32(class);
TCGv_i32 tintemp = tcg_const_i32(tin);
- gen_save_pc(ctx->pc);
+ gen_save_pc(ctx->base.pc_next);
gen_helper_raise_exception_sync(cpu_env, classtemp, tintemp);
- ctx->bstate = BS_EXCP;
+ ctx->base.is_jmp = DISAS_NORETURN;
tcg_temp_free(classtemp);
tcg_temp_free(tintemp);
}
+static void generate_qemu_excp(DisasContext *ctx, int excp)
+{
+ TCGv_i32 tmp = tcg_const_i32(excp);
+ gen_save_pc(ctx->base.pc_next);
+ gen_helper_qemu_excp(cpu_env, tmp);
+ ctx->base.is_jmp = DISAS_NORETURN;
+ tcg_temp_free(tmp);
+}
+
static inline void gen_branch_cond(DisasContext *ctx, TCGCond cond, TCGv r1,
TCGv r2, int16_t address)
{
TCGLabel *jumpLabel = gen_new_label();
tcg_gen_brcond_tl(cond, r1, r2, jumpLabel);
- gen_goto_tb(ctx, 1, ctx->next_pc);
+ gen_goto_tb(ctx, 1, ctx->pc_succ_insn);
gen_set_label(jumpLabel);
- gen_goto_tb(ctx, 0, ctx->pc + address * 2);
+ gen_goto_tb(ctx, 0, ctx->base.pc_next + address * 2);
}
static inline void gen_branch_condi(DisasContext *ctx, TCGCond cond, TCGv r1,
@@ -3295,9 +3296,9 @@ static void gen_loop(DisasContext *ctx, int r1, int32_t offset)
tcg_gen_subi_tl(cpu_gpr_a[r1], cpu_gpr_a[r1], 1);
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr_a[r1], -1, l1);
- gen_goto_tb(ctx, 1, ctx->pc + offset);
+ gen_goto_tb(ctx, 1, ctx->base.pc_next + offset);
gen_set_label(l1);
- gen_goto_tb(ctx, 0, ctx->next_pc);
+ gen_goto_tb(ctx, 0, ctx->pc_succ_insn);
}
static void gen_fcall_save_ctx(DisasContext *ctx)
@@ -3306,7 +3307,7 @@ static void gen_fcall_save_ctx(DisasContext *ctx)
tcg_gen_addi_tl(temp, cpu_gpr_a[10], -4);
tcg_gen_qemu_st_tl(cpu_gpr_a[11], temp, ctx->mem_idx, MO_LESL);
- tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc);
+ tcg_gen_movi_tl(cpu_gpr_a[11], ctx->pc_succ_insn);
tcg_gen_mov_tl(cpu_gpr_a[10], temp);
tcg_temp_free(temp);
@@ -3321,7 +3322,7 @@ static void gen_fret(DisasContext *ctx)
tcg_gen_addi_tl(cpu_gpr_a[10], cpu_gpr_a[10], 4);
tcg_gen_mov_tl(cpu_PC, temp);
tcg_gen_exit_tb(NULL, 0);
- ctx->bstate = BS_BRANCH;
+ ctx->base.is_jmp = DISAS_NORETURN;
tcg_temp_free(temp);
}
@@ -3336,12 +3337,12 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1,
/* SB-format jumps */
case OPC1_16_SB_J:
case OPC1_32_B_J:
- gen_goto_tb(ctx, 0, ctx->pc + offset * 2);
+ gen_goto_tb(ctx, 0, ctx->base.pc_next + offset * 2);
break;
case OPC1_32_B_CALL:
case OPC1_16_SB_CALL:
- gen_helper_1arg(call, ctx->next_pc);
- gen_goto_tb(ctx, 0, ctx->pc + offset * 2);
+ gen_helper_1arg(call, ctx->pc_succ_insn);
+ gen_goto_tb(ctx, 0, ctx->base.pc_next + offset * 2);
break;
case OPC1_16_SB_JZ:
gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[15], 0, offset);
@@ -3433,26 +3434,26 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1,
break;
/* B-format */
case OPC1_32_B_CALLA:
- gen_helper_1arg(call, ctx->next_pc);
+ gen_helper_1arg(call, ctx->pc_succ_insn);
gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset));
break;
case OPC1_32_B_FCALL:
gen_fcall_save_ctx(ctx);
- gen_goto_tb(ctx, 0, ctx->pc + offset * 2);
+ gen_goto_tb(ctx, 0, ctx->base.pc_next + offset * 2);
break;
case OPC1_32_B_FCALLA:
gen_fcall_save_ctx(ctx);
gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset));
break;
case OPC1_32_B_JLA:
- tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc);
+ tcg_gen_movi_tl(cpu_gpr_a[11], ctx->pc_succ_insn);
/* fall through */
case OPC1_32_B_JA:
gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset));
break;
case OPC1_32_B_JL:
- tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc);
- gen_goto_tb(ctx, 0, ctx->pc + offset * 2);
+ tcg_gen_movi_tl(cpu_gpr_a[11], ctx->pc_succ_insn);
+ gen_goto_tb(ctx, 0, ctx->base.pc_next + offset * 2);
break;
/* BOL format */
case OPCM_32_BRC_EQ_NEQ:
@@ -3551,7 +3552,7 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1,
gen_loop(ctx, r2, offset * 2);
} else {
/* OPC2_32_BRR_LOOPU */
- gen_goto_tb(ctx, 0, ctx->pc + offset * 2);
+ gen_goto_tb(ctx, 0, ctx->base.pc_next + offset * 2);
}
break;
case OPCM_32_BRR_JNE:
@@ -3585,7 +3586,7 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1,
default:
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
- ctx->bstate = BS_BRANCH;
+ ctx->base.is_jmp = DISAS_NORETURN;
}
@@ -3593,7 +3594,7 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1,
* Functions for decoding instructions
*/
-static void decode_src_opc(CPUTriCoreState *env, DisasContext *ctx, int op1)
+static void decode_src_opc(DisasContext *ctx, int op1)
{
int r1;
int32_t const4;
@@ -3655,7 +3656,7 @@ static void decode_src_opc(CPUTriCoreState *env, DisasContext *ctx, int op1)
tcg_gen_movi_tl(cpu_gpr_a[r1], const4);
break;
case OPC1_16_SRC_MOV_E:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
tcg_gen_movi_tl(cpu_gpr_d[r1], const4);
tcg_gen_sari_tl(cpu_gpr_d[r1+1], cpu_gpr_d[r1], 31);
} else {
@@ -3919,7 +3920,7 @@ static void decode_sro_opc(DisasContext *ctx, int op1)
}
}
-static void decode_sr_system(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_sr_system(DisasContext *ctx)
{
uint32_t op2;
op2 = MASK_OP_SR_OP2(ctx->opcode);
@@ -3933,7 +3934,7 @@ static void decode_sr_system(CPUTriCoreState *env, DisasContext *ctx)
case OPC2_16_SR_RFE:
gen_helper_rfe(cpu_env);
tcg_gen_exit_tb(NULL, 0);
- ctx->bstate = BS_BRANCH;
+ ctx->base.is_jmp = DISAS_NORETURN;
break;
case OPC2_16_SR_DEBUG:
/* raise EXCP_DEBUG */
@@ -3946,7 +3947,7 @@ static void decode_sr_system(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_sr_accu(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_sr_accu(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1;
@@ -3990,7 +3991,7 @@ static void decode_sr_accu(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_16Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_16Bit_opc(DisasContext *ctx)
{
int op1;
int r1, r2;
@@ -4021,7 +4022,7 @@ static void decode_16Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
case OPC1_16_SRC_MOV_E:
case OPC1_16_SRC_SH:
case OPC1_16_SRC_SHA:
- decode_src_opc(env, ctx, op1);
+ decode_src_opc(ctx, op1);
break;
/* SRR-format */
case OPC1_16_SRR_ADD:
@@ -4106,7 +4107,7 @@ static void decode_16Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
break;
case OPC1_16_SBC_JEQ2:
case OPC1_16_SBC_JNE2:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
address = MASK_OP_SBC_DISP4(ctx->opcode);
const16 = MASK_OP_SBC_CONST4_SEXT(ctx->opcode);
gen_compute_branch(ctx, op1, 0, 0, const16, address);
@@ -4124,7 +4125,7 @@ static void decode_16Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
/* SBR-format */
case OPC1_16_SBR_JEQ2:
case OPC1_16_SBR_JNE2:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
r1 = MASK_OP_SBR_S2(ctx->opcode);
address = MASK_OP_SBR_DISP4(ctx->opcode);
gen_compute_branch(ctx, op1, r1, 0, 0, address);
@@ -4204,10 +4205,10 @@ static void decode_16Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
break;
/* SR-format */
case OPCM_16_SR_SYSTEM:
- decode_sr_system(env, ctx);
+ decode_sr_system(ctx);
break;
case OPCM_16_SR_ACCU:
- decode_sr_accu(env, ctx);
+ decode_sr_accu(ctx);
break;
case OPC1_16_SR_JI:
r1 = MASK_OP_SR_S1D(ctx->opcode);
@@ -4227,7 +4228,7 @@ static void decode_16Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
*/
/* ABS-format */
-static void decode_abs_ldw(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_abs_ldw(DisasContext *ctx)
{
int32_t op2;
int32_t r1;
@@ -4262,7 +4263,7 @@ static void decode_abs_ldw(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_abs_ldb(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_abs_ldb(DisasContext *ctx)
{
int32_t op2;
int32_t r1;
@@ -4295,7 +4296,7 @@ static void decode_abs_ldb(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_abs_ldst_swap(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_abs_ldst_swap(DisasContext *ctx)
{
int32_t op2;
int32_t r1;
@@ -4322,7 +4323,7 @@ static void decode_abs_ldst_swap(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_abs_ldst_context(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_abs_ldst_context(DisasContext *ctx)
{
uint32_t op2;
int32_t off18;
@@ -4348,7 +4349,7 @@ static void decode_abs_ldst_context(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_abs_store(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_abs_store(DisasContext *ctx)
{
int32_t op2;
int32_t r1;
@@ -4382,7 +4383,7 @@ static void decode_abs_store(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_abs_storeb_h(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_abs_storeb_h(DisasContext *ctx)
{
int32_t op2;
int32_t r1;
@@ -4410,7 +4411,7 @@ static void decode_abs_storeb_h(CPUTriCoreState *env, DisasContext *ctx)
/* Bit-format */
-static void decode_bit_andacc(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_bit_andacc(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -4451,7 +4452,7 @@ static void decode_bit_andacc(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_bit_logical_t(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_bit_logical_t(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -4485,7 +4486,7 @@ static void decode_bit_logical_t(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_bit_insert(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_bit_insert(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -4508,7 +4509,7 @@ static void decode_bit_insert(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_bit_logical_t2(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_bit_logical_t2(DisasContext *ctx)
{
uint32_t op2;
@@ -4544,7 +4545,7 @@ static void decode_bit_logical_t2(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_bit_orand(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_bit_orand(DisasContext *ctx)
{
uint32_t op2;
@@ -4585,7 +4586,7 @@ static void decode_bit_orand(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_bit_sh_logic1(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_bit_sh_logic1(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -4626,7 +4627,7 @@ static void decode_bit_sh_logic1(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_bit_sh_logic2(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_bit_sh_logic2(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -4670,8 +4671,7 @@ static void decode_bit_sh_logic2(CPUTriCoreState *env, DisasContext *ctx)
/* BO-format */
-static void decode_bo_addrmode_post_pre_base(CPUTriCoreState *env,
- DisasContext *ctx)
+static void decode_bo_addrmode_post_pre_base(DisasContext *ctx)
{
uint32_t op2;
uint32_t off10;
@@ -4705,13 +4705,13 @@ static void decode_bo_addrmode_post_pre_base(CPUTriCoreState *env,
break;
case OPC2_32_BO_CACHEI_WI_SHORTOFF:
case OPC2_32_BO_CACHEI_W_SHORTOFF:
- if (!tricore_feature(env, TRICORE_FEATURE_131)) {
+ if (!tricore_feature(ctx->env, TRICORE_FEATURE_131)) {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
break;
case OPC2_32_BO_CACHEI_W_POSTINC:
case OPC2_32_BO_CACHEI_WI_POSTINC:
- if (tricore_feature(env, TRICORE_FEATURE_131)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_131)) {
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
@@ -4719,7 +4719,7 @@ static void decode_bo_addrmode_post_pre_base(CPUTriCoreState *env,
break;
case OPC2_32_BO_CACHEI_W_PREINC:
case OPC2_32_BO_CACHEI_WI_PREINC:
- if (tricore_feature(env, TRICORE_FEATURE_131)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_131)) {
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
@@ -4830,8 +4830,7 @@ static void decode_bo_addrmode_post_pre_base(CPUTriCoreState *env,
}
}
-static void decode_bo_addrmode_bitreverse_circular(CPUTriCoreState *env,
- DisasContext *ctx)
+static void decode_bo_addrmode_bitreverse_circular(DisasContext *ctx)
{
uint32_t op2;
uint32_t off10;
@@ -4941,8 +4940,7 @@ static void decode_bo_addrmode_bitreverse_circular(CPUTriCoreState *env,
tcg_temp_free(temp3);
}
-static void decode_bo_addrmode_ld_post_pre_base(CPUTriCoreState *env,
- DisasContext *ctx)
+static void decode_bo_addrmode_ld_post_pre_base(DisasContext *ctx)
{
uint32_t op2;
uint32_t off10;
@@ -5076,8 +5074,7 @@ static void decode_bo_addrmode_ld_post_pre_base(CPUTriCoreState *env,
}
}
-static void decode_bo_addrmode_ld_bitreverse_circular(CPUTriCoreState *env,
- DisasContext *ctx)
+static void decode_bo_addrmode_ld_bitreverse_circular(DisasContext *ctx)
{
uint32_t op2;
uint32_t off10;
@@ -5195,8 +5192,7 @@ static void decode_bo_addrmode_ld_bitreverse_circular(CPUTriCoreState *env,
tcg_temp_free(temp3);
}
-static void decode_bo_addrmode_stctx_post_pre_base(CPUTriCoreState *env,
- DisasContext *ctx)
+static void decode_bo_addrmode_stctx_post_pre_base(DisasContext *ctx)
{
uint32_t op2;
uint32_t off10;
@@ -5288,8 +5284,7 @@ static void decode_bo_addrmode_stctx_post_pre_base(CPUTriCoreState *env,
tcg_temp_free(temp2);
}
-static void decode_bo_addrmode_ldmst_bitreverse_circular(CPUTriCoreState *env,
- DisasContext *ctx)
+static void decode_bo_addrmode_ldmst_bitreverse_circular(DisasContext *ctx)
{
uint32_t op2;
uint32_t off10;
@@ -5351,7 +5346,7 @@ static void decode_bo_addrmode_ldmst_bitreverse_circular(CPUTriCoreState *env,
tcg_temp_free(temp3);
}
-static void decode_bol_opc(CPUTriCoreState *env, DisasContext *ctx, int32_t op1)
+static void decode_bol_opc(DisasContext *ctx, int32_t op1)
{
int r1, r2;
int32_t address;
@@ -5378,7 +5373,7 @@ static void decode_bol_opc(CPUTriCoreState *env, DisasContext *ctx, int32_t op1)
tcg_gen_addi_tl(cpu_gpr_a[r1], cpu_gpr_a[r2], address);
break;
case OPC1_32_BOL_ST_A_LONGOFF:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
gen_offset_st(ctx, cpu_gpr_a[r1], cpu_gpr_a[r2], address, MO_LEUL);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
@@ -5388,42 +5383,42 @@ static void decode_bol_opc(CPUTriCoreState *env, DisasContext *ctx, int32_t op1)
gen_offset_st(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], address, MO_LEUL);
break;
case OPC1_32_BOL_LD_B_LONGOFF:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
gen_offset_ld(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], address, MO_SB);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
break;
case OPC1_32_BOL_LD_BU_LONGOFF:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
gen_offset_ld(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], address, MO_UB);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
break;
case OPC1_32_BOL_LD_H_LONGOFF:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
gen_offset_ld(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], address, MO_LESW);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
break;
case OPC1_32_BOL_LD_HU_LONGOFF:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
gen_offset_ld(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], address, MO_LEUW);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
break;
case OPC1_32_BOL_ST_B_LONGOFF:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
gen_offset_st(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], address, MO_SB);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
break;
case OPC1_32_BOL_ST_H_LONGOFF:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
gen_offset_st(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], address, MO_LESW);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
@@ -5435,7 +5430,7 @@ static void decode_bol_opc(CPUTriCoreState *env, DisasContext *ctx, int32_t op1)
}
/* RC format */
-static void decode_rc_logical_shift(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rc_logical_shift(DisasContext *ctx)
{
uint32_t op2;
int r1, r2;
@@ -5502,7 +5497,7 @@ static void decode_rc_logical_shift(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_rc_accumulator(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rc_accumulator(DisasContext *ctx)
{
uint32_t op2;
int r1, r2;
@@ -5702,7 +5697,7 @@ static void decode_rc_accumulator(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_rc_serviceroutine(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rc_serviceroutine(DisasContext *ctx)
{
uint32_t op2;
uint32_t const9;
@@ -5722,7 +5717,7 @@ static void decode_rc_serviceroutine(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rc_mul(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rc_mul(DisasContext *ctx)
{
uint32_t op2;
int r1, r2;
@@ -5760,7 +5755,7 @@ static void decode_rc_mul(CPUTriCoreState *env, DisasContext *ctx)
}
/* RCPW format */
-static void decode_rcpw_insert(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rcpw_insert(DisasContext *ctx)
{
uint32_t op2;
int r1, r2;
@@ -5799,7 +5794,7 @@ static void decode_rcpw_insert(CPUTriCoreState *env, DisasContext *ctx)
/* RCRW format */
-static void decode_rcrw_insert(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rcrw_insert(DisasContext *ctx)
{
uint32_t op2;
int r1, r3, r4;
@@ -5844,7 +5839,7 @@ static void decode_rcrw_insert(CPUTriCoreState *env, DisasContext *ctx)
/* RCR format */
-static void decode_rcr_cond_select(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rcr_cond_select(DisasContext *ctx)
{
uint32_t op2;
int r1, r3, r4;
@@ -5888,7 +5883,7 @@ static void decode_rcr_cond_select(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rcr_madd(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rcr_madd(DisasContext *ctx)
{
uint32_t op2;
int r1, r3, r4;
@@ -5943,7 +5938,7 @@ static void decode_rcr_madd(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rcr_msub(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rcr_msub(DisasContext *ctx)
{
uint32_t op2;
int r1, r3, r4;
@@ -6000,7 +5995,7 @@ static void decode_rcr_msub(CPUTriCoreState *env, DisasContext *ctx)
/* RLC format */
-static void decode_rlc_opc(CPUTriCoreState *env, DisasContext *ctx,
+static void decode_rlc_opc(DisasContext *ctx,
uint32_t op1)
{
int32_t const16;
@@ -6022,13 +6017,13 @@ static void decode_rlc_opc(CPUTriCoreState *env, DisasContext *ctx,
break;
case OPC1_32_RLC_MFCR:
const16 = MASK_OP_RLC_CONST16(ctx->opcode);
- gen_mfcr(env, cpu_gpr_d[r2], const16);
+ gen_mfcr(ctx, cpu_gpr_d[r2], const16);
break;
case OPC1_32_RLC_MOV:
tcg_gen_movi_tl(cpu_gpr_d[r2], const16);
break;
case OPC1_32_RLC_MOV_64:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
CHECK_REG_PAIR(r2);
tcg_gen_movi_tl(cpu_gpr_d[r2], const16);
tcg_gen_movi_tl(cpu_gpr_d[r2+1], const16 >> 15);
@@ -6048,7 +6043,7 @@ static void decode_rlc_opc(CPUTriCoreState *env, DisasContext *ctx,
break;
case OPC1_32_RLC_MTCR:
const16 = MASK_OP_RLC_CONST16(ctx->opcode);
- gen_mtcr(env, ctx, cpu_gpr_d[r1], const16);
+ gen_mtcr(ctx, cpu_gpr_d[r1], const16);
break;
default:
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
@@ -6056,7 +6051,7 @@ static void decode_rlc_opc(CPUTriCoreState *env, DisasContext *ctx,
}
/* RR format */
-static void decode_rr_accumulator(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr_accumulator(DisasContext *ctx)
{
uint32_t op2;
int r3, r2, r1;
@@ -6254,7 +6249,7 @@ static void decode_rr_accumulator(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_mov_tl(cpu_gpr_d[r3], cpu_gpr_d[r2]);
break;
case OPC2_32_RR_MOV_64:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
temp = tcg_temp_new();
CHECK_REG_PAIR(r3);
@@ -6268,7 +6263,7 @@ static void decode_rr_accumulator(CPUTriCoreState *env, DisasContext *ctx)
}
break;
case OPC2_32_RR_MOVS_64:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
CHECK_REG_PAIR(r3);
tcg_gen_mov_tl(cpu_gpr_d[r3], cpu_gpr_d[r2]);
tcg_gen_sari_tl(cpu_gpr_d[r3 + 1], cpu_gpr_d[r2], 31);
@@ -6398,7 +6393,7 @@ static void decode_rr_accumulator(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rr_logical_shift(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr_logical_shift(DisasContext *ctx)
{
uint32_t op2;
int r3, r2, r1;
@@ -6476,7 +6471,7 @@ static void decode_rr_logical_shift(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp);
}
-static void decode_rr_address(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr_address(DisasContext *ctx)
{
uint32_t op2, n;
int r1, r2, r3;
@@ -6544,7 +6539,7 @@ static void decode_rr_address(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rr_idirect(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr_idirect(DisasContext *ctx)
{
uint32_t op2;
int r1;
@@ -6557,11 +6552,11 @@ static void decode_rr_idirect(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_andi_tl(cpu_PC, cpu_gpr_a[r1], ~0x1);
break;
case OPC2_32_RR_JLI:
- tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc);
+ tcg_gen_movi_tl(cpu_gpr_a[11], ctx->pc_succ_insn);
tcg_gen_andi_tl(cpu_PC, cpu_gpr_a[r1], ~0x1);
break;
case OPC2_32_RR_CALLI:
- gen_helper_1arg(call, ctx->next_pc);
+ gen_helper_1arg(call, ctx->pc_succ_insn);
tcg_gen_andi_tl(cpu_PC, cpu_gpr_a[r1], ~0x1);
break;
case OPC2_32_RR_FCALLI:
@@ -6572,10 +6567,10 @@ static void decode_rr_idirect(CPUTriCoreState *env, DisasContext *ctx)
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
tcg_gen_exit_tb(NULL, 0);
- ctx->bstate = BS_BRANCH;
+ ctx->base.is_jmp = DISAS_NORETURN;
}
-static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr_divide(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -6597,7 +6592,7 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
break;
case OPC2_32_RR_DVINIT_B:
CHECK_REG_PAIR(r3);
- gen_dvinit_b(env, cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1],
+ gen_dvinit_b(ctx, cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1],
cpu_gpr_d[r2]);
break;
case OPC2_32_RR_DVINIT_BU:
@@ -6608,7 +6603,7 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_shri_tl(temp3, cpu_gpr_d[r1], 8);
/* reset av */
tcg_gen_movi_tl(cpu_PSW_AV, 0);
- if (!tricore_feature(env, TRICORE_FEATURE_131)) {
+ if (!tricore_feature(ctx->env, TRICORE_FEATURE_131)) {
/* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
tcg_gen_abs_tl(temp, temp3);
tcg_gen_abs_tl(temp2, cpu_gpr_d[r2]);
@@ -6630,7 +6625,7 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
break;
case OPC2_32_RR_DVINIT_H:
CHECK_REG_PAIR(r3);
- gen_dvinit_h(env, cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1],
+ gen_dvinit_h(ctx, cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1],
cpu_gpr_d[r2]);
break;
case OPC2_32_RR_DVINIT_HU:
@@ -6641,7 +6636,7 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_shri_tl(temp3, cpu_gpr_d[r1], 16);
/* reset av */
tcg_gen_movi_tl(cpu_PSW_AV, 0);
- if (!tricore_feature(env, TRICORE_FEATURE_131)) {
+ if (!tricore_feature(ctx->env, TRICORE_FEATURE_131)) {
/* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
tcg_gen_abs_tl(temp, temp3);
tcg_gen_abs_tl(temp2, cpu_gpr_d[r2]);
@@ -6704,14 +6699,14 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
gen_unpack(cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1]);
break;
case OPC2_32_RR_CRC32:
- if (tricore_feature(env, TRICORE_FEATURE_161)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_161)) {
gen_helper_crc32(cpu_gpr_d[r3], cpu_gpr_d[r1], cpu_gpr_d[r2]);
} else {
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
break;
case OPC2_32_RR_DIV:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
GEN_HELPER_RR(divide, cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1],
cpu_gpr_d[r2]);
} else {
@@ -6719,7 +6714,7 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
}
break;
case OPC2_32_RR_DIV_U:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
GEN_HELPER_RR(divide_u, cpu_gpr_d[r3], cpu_gpr_d[r3+1],
cpu_gpr_d[r1], cpu_gpr_d[r2]);
} else {
@@ -6762,7 +6757,7 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
}
/* RR1 Format */
-static void decode_rr1_mul(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr1_mul(DisasContext *ctx)
{
uint32_t op2;
@@ -6876,7 +6871,7 @@ static void decode_rr1_mul(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(n);
}
-static void decode_rr1_mulq(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr1_mulq(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -6948,7 +6943,7 @@ static void decode_rr1_mulq(CPUTriCoreState *env, DisasContext *ctx)
}
/* RR2 format */
-static void decode_rr2_mul(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rr2_mul(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -6985,7 +6980,7 @@ static void decode_rr2_mul(CPUTriCoreState *env, DisasContext *ctx)
}
/* RRPW format */
-static void decode_rrpw_extract_insert(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrpw_extract_insert(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3;
@@ -7039,7 +7034,7 @@ static void decode_rrpw_extract_insert(CPUTriCoreState *env, DisasContext *ctx)
}
/* RRR format */
-static void decode_rrr_cond_select(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr_cond_select(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3, r4;
@@ -7085,7 +7080,7 @@ static void decode_rrr_cond_select(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rrr_divide(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr_divide(DisasContext *ctx)
{
uint32_t op2;
@@ -7165,7 +7160,7 @@ static void decode_rrr_divide(CPUTriCoreState *env, DisasContext *ctx)
}
/* RRR2 format */
-static void decode_rrr2_madd(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr2_madd(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4;
@@ -7217,7 +7212,7 @@ static void decode_rrr2_madd(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rrr2_msub(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr2_msub(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4;
@@ -7269,7 +7264,7 @@ static void decode_rrr2_msub(CPUTriCoreState *env, DisasContext *ctx)
}
/* RRR1 format */
-static void decode_rrr1_madd(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr1_madd(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4, n;
@@ -7415,7 +7410,7 @@ static void decode_rrr1_madd(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rrr1_maddq_h(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr1_maddq_h(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4, n;
@@ -7434,19 +7429,19 @@ static void decode_rrr1_maddq_h(CPUTriCoreState *env, DisasContext *ctx)
switch (op2) {
case OPC2_32_RRR1_MADD_Q_32:
gen_madd32_q(cpu_gpr_d[r4], cpu_gpr_d[r3], cpu_gpr_d[r1],
- cpu_gpr_d[r2], n, 32, env);
+ cpu_gpr_d[r2], n, 32);
break;
case OPC2_32_RRR1_MADD_Q_64:
CHECK_REG_PAIR(r4);
CHECK_REG_PAIR(r3);
gen_madd64_q(cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1], cpu_gpr_d[r2],
- n, env);
+ n);
break;
case OPC2_32_RRR1_MADD_Q_32_L:
tcg_gen_ext16s_tl(temp, cpu_gpr_d[r2]);
gen_madd32_q(cpu_gpr_d[r4], cpu_gpr_d[r3], cpu_gpr_d[r1],
- temp, n, 16, env);
+ temp, n, 16);
break;
case OPC2_32_RRR1_MADD_Q_64_L:
CHECK_REG_PAIR(r4);
@@ -7454,12 +7449,12 @@ static void decode_rrr1_maddq_h(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_ext16s_tl(temp, cpu_gpr_d[r2]);
gen_madd64_q(cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1], temp,
- n, env);
+ n);
break;
case OPC2_32_RRR1_MADD_Q_32_U:
tcg_gen_sari_tl(temp, cpu_gpr_d[r2], 16);
gen_madd32_q(cpu_gpr_d[r4], cpu_gpr_d[r3], cpu_gpr_d[r1],
- temp, n, 16, env);
+ temp, n, 16);
break;
case OPC2_32_RRR1_MADD_Q_64_U:
CHECK_REG_PAIR(r4);
@@ -7467,7 +7462,7 @@ static void decode_rrr1_maddq_h(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_sari_tl(temp, cpu_gpr_d[r2], 16);
gen_madd64_q(cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1], temp,
- n, env);
+ n);
break;
case OPC2_32_RRR1_MADD_Q_32_LL:
tcg_gen_ext16s_tl(temp, cpu_gpr_d[r1]);
@@ -7595,7 +7590,7 @@ static void decode_rrr1_maddq_h(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp2);
}
-static void decode_rrr1_maddsu_h(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr1_maddsu_h(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4, n;
@@ -7753,7 +7748,7 @@ static void decode_rrr1_maddsu_h(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rrr1_msub(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr1_msub(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4, n;
@@ -7899,7 +7894,7 @@ static void decode_rrr1_msub(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_rrr1_msubq_h(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr1_msubq_h(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4, n;
@@ -7918,19 +7913,19 @@ static void decode_rrr1_msubq_h(CPUTriCoreState *env, DisasContext *ctx)
switch (op2) {
case OPC2_32_RRR1_MSUB_Q_32:
gen_msub32_q(cpu_gpr_d[r4], cpu_gpr_d[r3], cpu_gpr_d[r1],
- cpu_gpr_d[r2], n, 32, env);
+ cpu_gpr_d[r2], n, 32);
break;
case OPC2_32_RRR1_MSUB_Q_64:
CHECK_REG_PAIR(r4);
CHECK_REG_PAIR(r3);
gen_msub64_q(cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1], cpu_gpr_d[r2],
- n, env);
+ n);
break;
case OPC2_32_RRR1_MSUB_Q_32_L:
tcg_gen_ext16s_tl(temp, cpu_gpr_d[r2]);
gen_msub32_q(cpu_gpr_d[r4], cpu_gpr_d[r3], cpu_gpr_d[r1],
- temp, n, 16, env);
+ temp, n, 16);
break;
case OPC2_32_RRR1_MSUB_Q_64_L:
CHECK_REG_PAIR(r4);
@@ -7938,12 +7933,12 @@ static void decode_rrr1_msubq_h(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_ext16s_tl(temp, cpu_gpr_d[r2]);
gen_msub64_q(cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1], temp,
- n, env);
+ n);
break;
case OPC2_32_RRR1_MSUB_Q_32_U:
tcg_gen_sari_tl(temp, cpu_gpr_d[r2], 16);
gen_msub32_q(cpu_gpr_d[r4], cpu_gpr_d[r3], cpu_gpr_d[r1],
- temp, n, 16, env);
+ temp, n, 16);
break;
case OPC2_32_RRR1_MSUB_Q_64_U:
CHECK_REG_PAIR(r4);
@@ -7951,7 +7946,7 @@ static void decode_rrr1_msubq_h(CPUTriCoreState *env, DisasContext *ctx)
tcg_gen_sari_tl(temp, cpu_gpr_d[r2], 16);
gen_msub64_q(cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1], temp,
- n, env);
+ n);
break;
case OPC2_32_RRR1_MSUB_Q_32_LL:
tcg_gen_ext16s_tl(temp, cpu_gpr_d[r1]);
@@ -8079,7 +8074,7 @@ static void decode_rrr1_msubq_h(CPUTriCoreState *env, DisasContext *ctx)
tcg_temp_free(temp2);
}
-static void decode_rrr1_msubad_h(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrr1_msubad_h(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1, r2, r3, r4, n;
@@ -8238,7 +8233,7 @@ static void decode_rrr1_msubad_h(CPUTriCoreState *env, DisasContext *ctx)
}
/* RRRR format */
-static void decode_rrrr_extract_insert(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrrr_extract_insert(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3, r4;
@@ -8295,7 +8290,7 @@ static void decode_rrrr_extract_insert(CPUTriCoreState *env, DisasContext *ctx)
}
/* RRRW format */
-static void decode_rrrw_extract_insert(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_rrrw_extract_insert(DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3, r4;
@@ -8356,7 +8351,7 @@ static void decode_rrrw_extract_insert(CPUTriCoreState *env, DisasContext *ctx)
}
/* SYS Format*/
-static void decode_sys_interrupts(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_sys_interrupts(DisasContext *ctx)
{
uint32_t op2;
uint32_t r1;
@@ -8391,7 +8386,7 @@ static void decode_sys_interrupts(CPUTriCoreState *env, DisasContext *ctx)
case OPC2_32_SYS_RFE:
gen_helper_rfe(cpu_env);
tcg_gen_exit_tb(NULL, 0);
- ctx->bstate = BS_BRANCH;
+ ctx->base.is_jmp = DISAS_NORETURN;
break;
case OPC2_32_SYS_RFM:
if ((ctx->hflags & TRICORE_HFLAG_KUU) == TRICORE_HFLAG_SM) {
@@ -8404,7 +8399,7 @@ static void decode_sys_interrupts(CPUTriCoreState *env, DisasContext *ctx)
gen_helper_rfm(cpu_env);
gen_set_label(l1);
tcg_gen_exit_tb(NULL, 0);
- ctx->bstate = BS_BRANCH;
+ ctx->base.is_jmp = DISAS_NORETURN;
tcg_temp_free(tmp);
} else {
/* generate privilege trap */
@@ -8417,7 +8412,7 @@ static void decode_sys_interrupts(CPUTriCoreState *env, DisasContext *ctx)
gen_helper_svlcx(cpu_env);
break;
case OPC2_32_SYS_RESTORE:
- if (tricore_feature(env, TRICORE_FEATURE_16)) {
+ if (tricore_feature(ctx->env, TRICORE_FEATURE_16)) {
if ((ctx->hflags & TRICORE_HFLAG_KUU) == TRICORE_HFLAG_SM ||
(ctx->hflags & TRICORE_HFLAG_KUU) == TRICORE_HFLAG_UM1) {
tcg_gen_deposit_tl(cpu_ICR, cpu_ICR, cpu_gpr_d[r1], 8, 1);
@@ -8443,7 +8438,7 @@ static void decode_sys_interrupts(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
+static void decode_32Bit_opc(DisasContext *ctx)
{
int op1;
int32_t r1, r2, r3;
@@ -8462,22 +8457,22 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
switch (op1) {
/* ABS-format */
case OPCM_32_ABS_LDW:
- decode_abs_ldw(env, ctx);
+ decode_abs_ldw(ctx);
break;
case OPCM_32_ABS_LDB:
- decode_abs_ldb(env, ctx);
+ decode_abs_ldb(ctx);
break;
case OPCM_32_ABS_LDMST_SWAP:
- decode_abs_ldst_swap(env, ctx);
+ decode_abs_ldst_swap(ctx);
break;
case OPCM_32_ABS_LDST_CONTEXT:
- decode_abs_ldst_context(env, ctx);
+ decode_abs_ldst_context(ctx);
break;
case OPCM_32_ABS_STORE:
- decode_abs_store(env, ctx);
+ decode_abs_store(ctx);
break;
case OPCM_32_ABS_STOREB_H:
- decode_abs_storeb_h(env, ctx);
+ decode_abs_storeb_h(ctx);
break;
case OPC1_32_ABS_STOREQ:
address = MASK_OP_ABS_OFF18(ctx->opcode);
@@ -8537,44 +8532,44 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
break;
/* Bit-format */
case OPCM_32_BIT_ANDACC:
- decode_bit_andacc(env, ctx);
+ decode_bit_andacc(ctx);
break;
case OPCM_32_BIT_LOGICAL_T1:
- decode_bit_logical_t(env, ctx);
+ decode_bit_logical_t(ctx);
break;
case OPCM_32_BIT_INSERT:
- decode_bit_insert(env, ctx);
+ decode_bit_insert(ctx);
break;
case OPCM_32_BIT_LOGICAL_T2:
- decode_bit_logical_t2(env, ctx);
+ decode_bit_logical_t2(ctx);
break;
case OPCM_32_BIT_ORAND:
- decode_bit_orand(env, ctx);
+ decode_bit_orand(ctx);
break;
case OPCM_32_BIT_SH_LOGIC1:
- decode_bit_sh_logic1(env, ctx);
+ decode_bit_sh_logic1(ctx);
break;
case OPCM_32_BIT_SH_LOGIC2:
- decode_bit_sh_logic2(env, ctx);
+ decode_bit_sh_logic2(ctx);
break;
/* BO Format */
case OPCM_32_BO_ADDRMODE_POST_PRE_BASE:
- decode_bo_addrmode_post_pre_base(env, ctx);
+ decode_bo_addrmode_post_pre_base(ctx);
break;
case OPCM_32_BO_ADDRMODE_BITREVERSE_CIRCULAR:
- decode_bo_addrmode_bitreverse_circular(env, ctx);
+ decode_bo_addrmode_bitreverse_circular(ctx);
break;
case OPCM_32_BO_ADDRMODE_LD_POST_PRE_BASE:
- decode_bo_addrmode_ld_post_pre_base(env, ctx);
+ decode_bo_addrmode_ld_post_pre_base(ctx);
break;
case OPCM_32_BO_ADDRMODE_LD_BITREVERSE_CIRCULAR:
- decode_bo_addrmode_ld_bitreverse_circular(env, ctx);
+ decode_bo_addrmode_ld_bitreverse_circular(ctx);
break;
case OPCM_32_BO_ADDRMODE_STCTX_POST_PRE_BASE:
- decode_bo_addrmode_stctx_post_pre_base(env, ctx);
+ decode_bo_addrmode_stctx_post_pre_base(ctx);
break;
case OPCM_32_BO_ADDRMODE_LDMST_BITREVERSE_CIRCULAR:
- decode_bo_addrmode_ldmst_bitreverse_circular(env, ctx);
+ decode_bo_addrmode_ldmst_bitreverse_circular(ctx);
break;
/* BOL-format */
case OPC1_32_BOL_LD_A_LONGOFF:
@@ -8588,7 +8583,7 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
case OPC1_32_BOL_LD_HU_LONGOFF:
case OPC1_32_BOL_ST_B_LONGOFF:
case OPC1_32_BOL_ST_H_LONGOFF:
- decode_bol_opc(env, ctx, op1);
+ decode_bol_opc(ctx, op1);
break;
/* BRC Format */
case OPCM_32_BRC_EQ_NEQ:
@@ -8621,20 +8616,20 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
break;
/* RC Format */
case OPCM_32_RC_LOGICAL_SHIFT:
- decode_rc_logical_shift(env, ctx);
+ decode_rc_logical_shift(ctx);
break;
case OPCM_32_RC_ACCUMULATOR:
- decode_rc_accumulator(env, ctx);
+ decode_rc_accumulator(ctx);
break;
case OPCM_32_RC_SERVICEROUTINE:
- decode_rc_serviceroutine(env, ctx);
+ decode_rc_serviceroutine(ctx);
break;
case OPCM_32_RC_MUL:
- decode_rc_mul(env, ctx);
+ decode_rc_mul(ctx);
break;
/* RCPW Format */
case OPCM_32_RCPW_MASK_INSERT:
- decode_rcpw_insert(env, ctx);
+ decode_rcpw_insert(ctx);
break;
/* RCRR Format */
case OPC1_32_RCRR_INSERT:
@@ -8659,17 +8654,17 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
break;
/* RCRW Format */
case OPCM_32_RCRW_MASK_INSERT:
- decode_rcrw_insert(env, ctx);
+ decode_rcrw_insert(ctx);
break;
/* RCR Format */
case OPCM_32_RCR_COND_SELECT:
- decode_rcr_cond_select(env, ctx);
+ decode_rcr_cond_select(ctx);
break;
case OPCM_32_RCR_MADD:
- decode_rcr_madd(env, ctx);
+ decode_rcr_madd(ctx);
break;
case OPCM_32_RCR_MSUB:
- decode_rcr_msub(env, ctx);
+ decode_rcr_msub(ctx);
break;
/* RLC Format */
case OPC1_32_RLC_ADDI:
@@ -8682,38 +8677,38 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
case OPC1_32_RLC_MOV_H:
case OPC1_32_RLC_MOVH_A:
case OPC1_32_RLC_MTCR:
- decode_rlc_opc(env, ctx, op1);
+ decode_rlc_opc(ctx, op1);
break;
/* RR Format */
case OPCM_32_RR_ACCUMULATOR:
- decode_rr_accumulator(env, ctx);
+ decode_rr_accumulator(ctx);
break;
case OPCM_32_RR_LOGICAL_SHIFT:
- decode_rr_logical_shift(env, ctx);
+ decode_rr_logical_shift(ctx);
break;
case OPCM_32_RR_ADDRESS:
- decode_rr_address(env, ctx);
+ decode_rr_address(ctx);
break;
case OPCM_32_RR_IDIRECT:
- decode_rr_idirect(env, ctx);
+ decode_rr_idirect(ctx);
break;
case OPCM_32_RR_DIVIDE:
- decode_rr_divide(env, ctx);
+ decode_rr_divide(ctx);
break;
/* RR1 Format */
case OPCM_32_RR1_MUL:
- decode_rr1_mul(env, ctx);
+ decode_rr1_mul(ctx);
break;
case OPCM_32_RR1_MULQ:
- decode_rr1_mulq(env, ctx);
+ decode_rr1_mulq(ctx);
break;
/* RR2 format */
case OPCM_32_RR2_MUL:
- decode_rr2_mul(env, ctx);
+ decode_rr2_mul(ctx);
break;
/* RRPW format */
case OPCM_32_RRPW_EXTRACT_INSERT:
- decode_rrpw_extract_insert(env, ctx);
+ decode_rrpw_extract_insert(ctx);
break;
case OPC1_32_RRPW_DEXTR:
r1 = MASK_OP_RRPW_S1(ctx->opcode);
@@ -8732,48 +8727,48 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
break;
/* RRR Format */
case OPCM_32_RRR_COND_SELECT:
- decode_rrr_cond_select(env, ctx);
+ decode_rrr_cond_select(ctx);
break;
case OPCM_32_RRR_DIVIDE:
- decode_rrr_divide(env, ctx);
+ decode_rrr_divide(ctx);
break;
/* RRR2 Format */
case OPCM_32_RRR2_MADD:
- decode_rrr2_madd(env, ctx);
+ decode_rrr2_madd(ctx);
break;
case OPCM_32_RRR2_MSUB:
- decode_rrr2_msub(env, ctx);
+ decode_rrr2_msub(ctx);
break;
/* RRR1 format */
case OPCM_32_RRR1_MADD:
- decode_rrr1_madd(env, ctx);
+ decode_rrr1_madd(ctx);
break;
case OPCM_32_RRR1_MADDQ_H:
- decode_rrr1_maddq_h(env, ctx);
+ decode_rrr1_maddq_h(ctx);
break;
case OPCM_32_RRR1_MADDSU_H:
- decode_rrr1_maddsu_h(env, ctx);
+ decode_rrr1_maddsu_h(ctx);
break;
case OPCM_32_RRR1_MSUB_H:
- decode_rrr1_msub(env, ctx);
+ decode_rrr1_msub(ctx);
break;
case OPCM_32_RRR1_MSUB_Q:
- decode_rrr1_msubq_h(env, ctx);
+ decode_rrr1_msubq_h(ctx);
break;
case OPCM_32_RRR1_MSUBAD_H:
- decode_rrr1_msubad_h(env, ctx);
+ decode_rrr1_msubad_h(ctx);
break;
/* RRRR format */
case OPCM_32_RRRR_EXTRACT_INSERT:
- decode_rrrr_extract_insert(env, ctx);
+ decode_rrrr_extract_insert(ctx);
break;
/* RRRW format */
case OPCM_32_RRRW_EXTRACT_INSERT:
- decode_rrrw_extract_insert(env, ctx);
+ decode_rrrw_extract_insert(ctx);
break;
/* SYS format */
case OPCM_32_SYS_INTERRUPTS:
- decode_sys_interrupts(env, ctx);
+ decode_sys_interrupts(ctx);
break;
case OPC1_32_SYS_RSTV:
tcg_gen_movi_tl(cpu_PSW_V, 0);
@@ -8786,70 +8781,130 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
}
}
-static void decode_opc(CPUTriCoreState *env, DisasContext *ctx, int *is_branch)
+static bool tricore_insn_is_16bit(uint32_t insn)
{
- /* 16-Bit Instruction */
- if ((ctx->opcode & 0x1) == 0) {
- ctx->next_pc = ctx->pc + 2;
- decode_16Bit_opc(env, ctx);
- /* 32-Bit Instruction */
- } else {
- ctx->next_pc = ctx->pc + 4;
- decode_32Bit_opc(env, ctx);
- }
+ return (insn & 0x1) == 0;
}
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
+static void tricore_tr_init_disas_context(DisasContextBase *dcbase,
+ CPUState *cs)
{
+ DisasContext *ctx = container_of(dcbase, DisasContext, base);
CPUTriCoreState *env = cs->env_ptr;
- DisasContext ctx;
- target_ulong pc_start;
- int num_insns = 0;
-
- pc_start = tb->pc;
- ctx.pc = pc_start;
- ctx.saved_pc = -1;
- ctx.tb = tb;
- ctx.singlestep_enabled = cs->singlestep_enabled;
- ctx.bstate = BS_NONE;
- ctx.mem_idx = cpu_mmu_index(env, false);
- ctx.hflags = (uint32_t)tb->flags;
-
- tcg_clear_temp_count();
- gen_tb_start(tb);
- while (ctx.bstate == BS_NONE) {
- tcg_gen_insn_start(ctx.pc);
- num_insns++;
-
- ctx.opcode = cpu_ldl_code(env, ctx.pc);
- decode_opc(env, &ctx, 0);
-
- if (num_insns >= max_insns || tcg_op_buf_full()) {
- gen_save_pc(ctx.next_pc);
- tcg_gen_exit_tb(NULL, 0);
- break;
- }
- ctx.pc = ctx.next_pc;
+ ctx->mem_idx = cpu_mmu_index(env, false);
+ ctx->hflags = (uint32_t)ctx->base.tb->flags;
+}
+
+static void tricore_tr_tb_start(DisasContextBase *db, CPUState *cpu)
+{
+}
+
+static void tricore_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
+{
+ DisasContext *ctx = container_of(dcbase, DisasContext, base);
+
+ tcg_gen_insn_start(ctx->base.pc_next);
+}
+
+static bool tricore_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,
+ const CPUBreakpoint *bp)
+{
+ DisasContext *ctx = container_of(dcbase, DisasContext, base);
+ generate_qemu_excp(ctx, EXCP_DEBUG);
+ /*
+ * The address covered by the breakpoint must be included in
+ * [tb->pc, tb->pc + tb->size) in order to for it to be
+ * properly cleared -- thus we increment the PC here so that
+ * the logic setting tb->size below does the right thing.
+ */
+ ctx->base.pc_next += 4;
+ return true;
+}
+
+static bool insn_crosses_page(CPUTriCoreState *env, DisasContext *ctx)
+{
+ /*
+ * Return true if the insn at ctx->base.pc_next might cross a page boundary.
+ * (False positives are OK, false negatives are not.)
+ * Our caller ensures we are only called if dc->base.pc_next is less than
+ * 4 bytes from the page boundary, so we cross the page if the first
+ * 16 bits indicate that this is a 32 bit insn.
+ */
+ uint16_t insn = cpu_lduw_code(env, ctx->base.pc_next);
+
+ return !tricore_insn_is_16bit(insn);
+}
+
+
+static void tricore_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
+{
+ DisasContext *ctx = container_of(dcbase, DisasContext, base);
+ CPUTriCoreState *env = cpu->env_ptr;
+ uint16_t insn_lo;
+ bool is_16bit;
+
+ insn_lo = cpu_lduw_code(env, ctx->base.pc_next);
+ is_16bit = tricore_insn_is_16bit(insn_lo);
+ if (is_16bit) {
+ ctx->opcode = insn_lo;
+ ctx->pc_succ_insn = ctx->base.pc_next + 2;
+ decode_16Bit_opc(ctx);
+ } else {
+ uint32_t insn_hi = cpu_lduw_code(env, ctx->base.pc_next + 2);
+ ctx->opcode = insn_hi << 16 | insn_lo;
+ ctx->pc_succ_insn = ctx->base.pc_next + 4;
+ decode_32Bit_opc(ctx);
}
+ ctx->base.pc_next = ctx->pc_succ_insn;
- gen_tb_end(tb, num_insns);
- tb->size = ctx.pc - pc_start;
- tb->icount = num_insns;
+ if (ctx->base.is_jmp == DISAS_NEXT) {
+ target_ulong page_start;
- if (tcg_check_temp_count()) {
- printf("LEAK at %08x\n", env->PC);
+ page_start = ctx->base.pc_first & TARGET_PAGE_MASK;
+ if (ctx->base.pc_next - page_start >= TARGET_PAGE_SIZE
+ || (ctx->base.pc_next - page_start >= TARGET_PAGE_SIZE - 3
+ && insn_crosses_page(env, ctx))) {
+ ctx->base.is_jmp = DISAS_TOO_MANY;
+ }
}
+}
-#ifdef DEBUG_DISAS
- if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
- && qemu_log_in_addr_range(pc_start)) {
- qemu_log_lock();
- qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(cs, pc_start, ctx.pc - pc_start);
- qemu_log("\n");
- qemu_log_unlock();
+static void tricore_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
+{
+ DisasContext *ctx = container_of(dcbase, DisasContext, base);
+
+ switch (ctx->base.is_jmp) {
+ case DISAS_TOO_MANY:
+ gen_goto_tb(ctx, 0, ctx->base.pc_next);
+ break;
+ case DISAS_NORETURN:
+ break;
+ default:
+ g_assert_not_reached();
}
-#endif
+}
+
+static void tricore_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu)
+{
+ qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first));
+ log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size);
+}
+
+static const TranslatorOps tricore_tr_ops = {
+ .init_disas_context = tricore_tr_init_disas_context,
+ .tb_start = tricore_tr_tb_start,
+ .insn_start = tricore_tr_insn_start,
+ .breakpoint_check = tricore_tr_breakpoint_check,
+ .translate_insn = tricore_tr_translate_insn,
+ .tb_stop = tricore_tr_tb_stop,
+ .disas_log = tricore_tr_disas_log,
+};
+
+
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
+{
+ DisasContext ctx;
+ translator_loop(&tricore_tr_ops, &ctx.base, cs, tb, max_insns);
}
void