mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
target-tricore: Add instructions of RR opcode format, that have 0x4b as the first opcode
Add instructions of RR opcode format, that have 0x4b as the first opcode. Add helper functions: * parity: Calculates the parity bits for every byte of a 32 int. * bmerge/bsplit: Merges two regs into one bitwise/Splits one reg into two bitwise. * unpack: unpack a IEEE 754 single precision floating point number as exponent and mantissa. * dvinit_b_13/131: (ISA v1.3/v1.31)Prepare operands for a divide operation, where the quotient result is guaranteed to fit into 8 bit. * dvinit_h_13/131: (ISA v1.3/v1.31)Prepare operands for a divide operation, where the quotient result is guaranteed to fit into 16 bit. OPCM_32_RR_FLOAT -> OPCM_32_RR_DIVIDE. Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> Reviewed-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
f2f1585f60
commit
e2bed107c6
4 changed files with 390 additions and 1 deletions
|
@ -1356,6 +1356,56 @@ static inline void gen_insert(TCGv ret, TCGv r1, TCGv r2, TCGv width, TCGv pos)
|
|||
tcg_temp_free(temp2);
|
||||
}
|
||||
|
||||
static inline void gen_bsplit(TCGv rl, TCGv rh, TCGv r1)
|
||||
{
|
||||
TCGv_i64 temp = tcg_temp_new_i64();
|
||||
|
||||
gen_helper_bsplit(temp, r1);
|
||||
tcg_gen_extr_i64_i32(rl, rh, temp);
|
||||
|
||||
tcg_temp_free_i64(temp);
|
||||
}
|
||||
|
||||
static inline void gen_unpack(TCGv rl, TCGv rh, TCGv r1)
|
||||
{
|
||||
TCGv_i64 temp = tcg_temp_new_i64();
|
||||
|
||||
gen_helper_unpack(temp, r1);
|
||||
tcg_gen_extr_i64_i32(rl, rh, temp);
|
||||
|
||||
tcg_temp_free_i64(temp);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gen_dvinit_b(CPUTriCoreState *env, TCGv rl, TCGv rh, TCGv r1, TCGv r2)
|
||||
{
|
||||
TCGv_i64 ret = tcg_temp_new_i64();
|
||||
|
||||
if (!tricore_feature(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);
|
||||
}
|
||||
tcg_gen_extr_i64_i32(rl, rh, ret);
|
||||
|
||||
tcg_temp_free_i64(ret);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gen_dvinit_h(CPUTriCoreState *env, TCGv rl, TCGv rh, TCGv r1, TCGv r2)
|
||||
{
|
||||
TCGv_i64 ret = tcg_temp_new_i64();
|
||||
|
||||
if (!tricore_feature(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);
|
||||
}
|
||||
tcg_gen_extr_i64_i32(rl, rh, ret);
|
||||
|
||||
tcg_temp_free_i64(ret);
|
||||
}
|
||||
|
||||
/* helpers for generating program flow micro-ops */
|
||||
|
||||
static inline void gen_save_pc(target_ulong pc)
|
||||
|
@ -4362,6 +4412,136 @@ static void decode_rr_idirect(CPUTriCoreState *env, DisasContext *ctx)
|
|||
ctx->bstate = BS_BRANCH;
|
||||
}
|
||||
|
||||
static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx)
|
||||
{
|
||||
uint32_t op2;
|
||||
int r1, r2, r3;
|
||||
|
||||
TCGv temp, temp2;
|
||||
|
||||
op2 = MASK_OP_RR_OP2(ctx->opcode);
|
||||
r3 = MASK_OP_RR_D(ctx->opcode);
|
||||
r2 = MASK_OP_RR_S2(ctx->opcode);
|
||||
r1 = MASK_OP_RR_S1(ctx->opcode);
|
||||
|
||||
switch (op2) {
|
||||
case OPC2_32_RR_BMERGE:
|
||||
gen_helper_bmerge(cpu_gpr_d[r3], cpu_gpr_d[r1], cpu_gpr_d[r2]);
|
||||
break;
|
||||
case OPC2_32_RR_BSPLIT:
|
||||
gen_bsplit(cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1]);
|
||||
break;
|
||||
case OPC2_32_RR_DVINIT_B:
|
||||
gen_dvinit_b(env, cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1],
|
||||
cpu_gpr_d[r2]);
|
||||
break;
|
||||
case OPC2_32_RR_DVINIT_BU:
|
||||
temp = tcg_temp_new();
|
||||
temp2 = tcg_temp_new();
|
||||
/* reset av */
|
||||
tcg_gen_movi_tl(cpu_PSW_AV, 0);
|
||||
if (!tricore_feature(env, TRICORE_FEATURE_131)) {
|
||||
/* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
|
||||
tcg_gen_neg_tl(temp, cpu_gpr_d[r3+1]);
|
||||
/* use cpu_PSW_AV to compare against 0 */
|
||||
tcg_gen_movcond_tl(TCG_COND_LT, temp, cpu_gpr_d[r3+1], cpu_PSW_AV,
|
||||
temp, cpu_gpr_d[r3+1]);
|
||||
tcg_gen_neg_tl(temp2, cpu_gpr_d[r2]);
|
||||
tcg_gen_movcond_tl(TCG_COND_LT, temp2, cpu_gpr_d[r2], cpu_PSW_AV,
|
||||
temp2, cpu_gpr_d[r2]);
|
||||
tcg_gen_setcond_tl(TCG_COND_GE, cpu_PSW_V, temp, temp2);
|
||||
} else {
|
||||
/* overflow = (D[b] == 0) */
|
||||
tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_PSW_V, cpu_gpr_d[r2], 0);
|
||||
}
|
||||
tcg_gen_shli_tl(cpu_PSW_V, cpu_PSW_V, 31);
|
||||
/* sv */
|
||||
tcg_gen_or_tl(cpu_PSW_SV, cpu_PSW_SV, cpu_PSW_V);
|
||||
/* write result */
|
||||
tcg_gen_shri_tl(temp, cpu_gpr_d[r1], 8);
|
||||
tcg_gen_shli_tl(cpu_gpr_d[r3], cpu_gpr_d[r1], 24);
|
||||
tcg_gen_mov_tl(cpu_gpr_d[r3+1], temp);
|
||||
|
||||
tcg_temp_free(temp);
|
||||
tcg_temp_free(temp2);
|
||||
break;
|
||||
case OPC2_32_RR_DVINIT_H:
|
||||
gen_dvinit_h(env, cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1],
|
||||
cpu_gpr_d[r2]);
|
||||
break;
|
||||
case OPC2_32_RR_DVINIT_HU:
|
||||
temp = tcg_temp_new();
|
||||
temp2 = tcg_temp_new();
|
||||
/* reset av */
|
||||
tcg_gen_movi_tl(cpu_PSW_AV, 0);
|
||||
if (!tricore_feature(env, TRICORE_FEATURE_131)) {
|
||||
/* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
|
||||
tcg_gen_neg_tl(temp, cpu_gpr_d[r3+1]);
|
||||
/* use cpu_PSW_AV to compare against 0 */
|
||||
tcg_gen_movcond_tl(TCG_COND_LT, temp, cpu_gpr_d[r3+1], cpu_PSW_AV,
|
||||
temp, cpu_gpr_d[r3+1]);
|
||||
tcg_gen_neg_tl(temp2, cpu_gpr_d[r2]);
|
||||
tcg_gen_movcond_tl(TCG_COND_LT, temp2, cpu_gpr_d[r2], cpu_PSW_AV,
|
||||
temp2, cpu_gpr_d[r2]);
|
||||
tcg_gen_setcond_tl(TCG_COND_GE, cpu_PSW_V, temp, temp2);
|
||||
} else {
|
||||
/* overflow = (D[b] == 0) */
|
||||
tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_PSW_V, cpu_gpr_d[r2], 0);
|
||||
}
|
||||
tcg_gen_shli_tl(cpu_PSW_V, cpu_PSW_V, 31);
|
||||
/* sv */
|
||||
tcg_gen_or_tl(cpu_PSW_SV, cpu_PSW_SV, cpu_PSW_V);
|
||||
/* write result */
|
||||
tcg_gen_mov_tl(temp, cpu_gpr_d[r1]);
|
||||
tcg_gen_shri_tl(cpu_gpr_d[r3+1], temp, 16);
|
||||
tcg_gen_shli_tl(cpu_gpr_d[r3], temp, 16);
|
||||
tcg_temp_free(temp);
|
||||
tcg_temp_free(temp2);
|
||||
break;
|
||||
case OPC2_32_RR_DVINIT:
|
||||
temp = tcg_temp_new();
|
||||
temp2 = tcg_temp_new();
|
||||
/* overflow = ((D[b] == 0) ||
|
||||
((D[b] == 0xFFFFFFFF) && (D[a] == 0x80000000))) */
|
||||
tcg_gen_setcondi_tl(TCG_COND_EQ, temp, cpu_gpr_d[r2], 0xffffffff);
|
||||
tcg_gen_setcondi_tl(TCG_COND_EQ, temp2, cpu_gpr_d[r1], 0x80000000);
|
||||
tcg_gen_and_tl(temp, temp, temp2);
|
||||
tcg_gen_setcondi_tl(TCG_COND_EQ, temp2, cpu_gpr_d[r2], 0);
|
||||
tcg_gen_or_tl(cpu_PSW_V, temp, temp2);
|
||||
tcg_gen_shli_tl(cpu_PSW_V, cpu_PSW_V, 31);
|
||||
/* sv */
|
||||
tcg_gen_or_tl(cpu_PSW_SV, cpu_PSW_SV, cpu_PSW_V);
|
||||
/* reset av */
|
||||
tcg_gen_movi_tl(cpu_PSW_AV, 0);
|
||||
/* write result */
|
||||
tcg_gen_mov_tl(cpu_gpr_d[r3], cpu_gpr_d[r1]);
|
||||
/* sign extend to high reg */
|
||||
tcg_gen_sari_tl(cpu_gpr_d[r3+1], cpu_gpr_d[r1], 31);
|
||||
tcg_temp_free(temp);
|
||||
tcg_temp_free(temp2);
|
||||
break;
|
||||
case OPC2_32_RR_DVINIT_U:
|
||||
/* overflow = (D[b] == 0) */
|
||||
tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_PSW_V, cpu_gpr_d[r2], 0);
|
||||
tcg_gen_shli_tl(cpu_PSW_V, cpu_PSW_V, 31);
|
||||
/* sv */
|
||||
tcg_gen_or_tl(cpu_PSW_SV, cpu_PSW_SV, cpu_PSW_V);
|
||||
/* reset av */
|
||||
tcg_gen_movi_tl(cpu_PSW_AV, 0);
|
||||
/* write result */
|
||||
tcg_gen_mov_tl(cpu_gpr_d[r3], cpu_gpr_d[r1]);
|
||||
/* zero extend to high reg*/
|
||||
tcg_gen_movi_tl(cpu_gpr_d[r3+1], 0);
|
||||
break;
|
||||
case OPC2_32_RR_PARITY:
|
||||
gen_helper_parity(cpu_gpr_d[r3], cpu_gpr_d[r1]);
|
||||
break;
|
||||
case OPC2_32_RR_UNPACK:
|
||||
gen_unpack(cpu_gpr_d[r3], cpu_gpr_d[r3+1], cpu_gpr_d[r1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
|
||||
{
|
||||
int op1;
|
||||
|
@ -4606,6 +4786,9 @@ static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
|
|||
case OPCM_32_RR_IDIRECT:
|
||||
decode_rr_idirect(env, ctx);
|
||||
break;
|
||||
case OPCM_32_RR_DIVIDE:
|
||||
decode_rr_divide(env, ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue