Skip to content

Commit

Permalink
tcg: Remove TCGV_UNUSED* and TCGV_IS_UNUSED*
Browse files Browse the repository at this point in the history
These are now trivial sets and tests against NULL.  Unwrap.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
  • Loading branch information
rth7680 committed Dec 29, 2017
1 parent 1f5940e commit f764718
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 144 deletions.
22 changes: 11 additions & 11 deletions target/alpha/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,34 +156,34 @@ void alpha_translate_init(void)

static TCGv load_zero(DisasContext *ctx)
{
if (TCGV_IS_UNUSED_I64(ctx->zero)) {
if (!ctx->zero) {
ctx->zero = tcg_const_i64(0);
}
return ctx->zero;
}

static TCGv dest_sink(DisasContext *ctx)
{
if (TCGV_IS_UNUSED_I64(ctx->sink)) {
if (!ctx->sink) {
ctx->sink = tcg_temp_new();
}
return ctx->sink;
}

static void free_context_temps(DisasContext *ctx)
{
if (!TCGV_IS_UNUSED_I64(ctx->sink)) {
if (ctx->sink) {
tcg_gen_discard_i64(ctx->sink);
tcg_temp_free(ctx->sink);
TCGV_UNUSED_I64(ctx->sink);
ctx->sink = NULL;
}
if (!TCGV_IS_UNUSED_I64(ctx->zero)) {
if (ctx->zero) {
tcg_temp_free(ctx->zero);
TCGV_UNUSED_I64(ctx->zero);
ctx->zero = NULL;
}
if (!TCGV_IS_UNUSED_I64(ctx->lit)) {
if (ctx->lit) {
tcg_temp_free(ctx->lit);
TCGV_UNUSED_I64(ctx->lit);
ctx->lit = NULL;
}
}

Expand Down Expand Up @@ -2948,9 +2948,9 @@ static int alpha_tr_init_disas_context(DisasContextBase *dcbase,
/* Similarly for flush-to-zero. */
ctx->tb_ftz = -1;

TCGV_UNUSED_I64(ctx->zero);
TCGV_UNUSED_I64(ctx->sink);
TCGV_UNUSED_I64(ctx->lit);
ctx->zero = NULL;
ctx->sink = NULL;
ctx->lit = NULL;

/* Bound the number of insns to execute to those left on the page. */
if (in_superpage(ctx, ctx->base.pc_first)) {
Expand Down
35 changes: 16 additions & 19 deletions target/arm/translate-a64.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,7 @@ static void unallocated_encoding(DisasContext *s)
static void init_tmp_a64_array(DisasContext *s)
{
#ifdef CONFIG_DEBUG_TCG
int i;
for (i = 0; i < ARRAY_SIZE(s->tmp_a64); i++) {
TCGV_UNUSED_I64(s->tmp_a64[i]);
}
memset(s->tmp_a64, 0, sizeof(s->tmp_a64));
#endif
s->tmp_a64_count = 0;
}
Expand Down Expand Up @@ -6276,7 +6273,7 @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
return;
}

TCGV_UNUSED_PTR(fpst);
fpst = NULL;
break;
case 0xc: /* FMAXNMP */
case 0xd: /* FADDP */
Expand Down Expand Up @@ -6371,7 +6368,7 @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
tcg_temp_free_i32(tcg_res);
}

if (!TCGV_IS_UNUSED_PTR(fpst)) {
if (fpst) {
tcg_temp_free_ptr(fpst);
}
}
Expand All @@ -6387,7 +6384,7 @@ static void handle_shri_with_rndacc(TCGv_i64 tcg_res, TCGv_i64 tcg_src,
bool is_u, int size, int shift)
{
bool extended_result = false;
bool round = !TCGV_IS_UNUSED_I64(tcg_rnd);
bool round = tcg_rnd != NULL;
int ext_lshift = 0;
TCGv_i64 tcg_src_hi;

Expand Down Expand Up @@ -6533,7 +6530,7 @@ static void handle_scalar_simd_shri(DisasContext *s,
uint64_t round_const = 1ULL << (shift - 1);
tcg_round = tcg_const_i64(round_const);
} else {
TCGV_UNUSED_I64(tcg_round);
tcg_round = NULL;
}

tcg_rn = read_fp_dreg(s, rn);
Expand Down Expand Up @@ -6649,7 +6646,7 @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q,
uint64_t round_const = 1ULL << (shift - 1);
tcg_round = tcg_const_i64(round_const);
} else {
TCGV_UNUSED_I64(tcg_round);
tcg_round = NULL;
}

for (i = 0; i < elements; i++) {
Expand Down Expand Up @@ -8239,8 +8236,8 @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn)
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
tcg_fpstatus = get_fpstatus_ptr();
} else {
TCGV_UNUSED_I32(tcg_rmode);
TCGV_UNUSED_PTR(tcg_fpstatus);
tcg_rmode = NULL;
tcg_fpstatus = NULL;
}

if (size == 3) {
Expand Down Expand Up @@ -8360,7 +8357,7 @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u,
uint64_t round_const = 1ULL << (shift - 1);
tcg_round = tcg_const_i64(round_const);
} else {
TCGV_UNUSED_I64(tcg_round);
tcg_round = NULL;
}

for (i = 0; i < elements; i++) {
Expand Down Expand Up @@ -8502,7 +8499,7 @@ static void handle_vec_simd_shrn(DisasContext *s, bool is_q,
uint64_t round_const = 1ULL << (shift - 1);
tcg_round = tcg_const_i64(round_const);
} else {
TCGV_UNUSED_I64(tcg_round);
tcg_round = NULL;
}

for (i = 0; i < elements; i++) {
Expand Down Expand Up @@ -9168,7 +9165,7 @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,
if (opcode >= 0x58) {
fpst = get_fpstatus_ptr();
} else {
TCGV_UNUSED_PTR(fpst);
fpst = NULL;
}

if (!fp_access_check(s)) {
Expand Down Expand Up @@ -9305,7 +9302,7 @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,
}
}

if (!TCGV_IS_UNUSED_PTR(fpst)) {
if (fpst) {
tcg_temp_free_ptr(fpst);
}
}
Expand Down Expand Up @@ -10226,13 +10223,13 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
if (need_fpstatus) {
tcg_fpstatus = get_fpstatus_ptr();
} else {
TCGV_UNUSED_PTR(tcg_fpstatus);
tcg_fpstatus = NULL;
}
if (need_rmode) {
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
} else {
TCGV_UNUSED_I32(tcg_rmode);
tcg_rmode = NULL;
}

if (size == 3) {
Expand Down Expand Up @@ -10593,7 +10590,7 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
if (is_fp) {
fpst = get_fpstatus_ptr();
} else {
TCGV_UNUSED_PTR(fpst);
fpst = NULL;
}

if (size == 3) {
Expand Down Expand Up @@ -10917,7 +10914,7 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
}
}

if (!TCGV_IS_UNUSED_PTR(fpst)) {
if (fpst) {
tcg_temp_free_ptr(fpst);
}
}
Expand Down
29 changes: 14 additions & 15 deletions target/arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2169,8 +2169,8 @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
tmp3 = tcg_const_i32((insn & 1) << 5);
break;
default:
TCGV_UNUSED_I32(tmp2);
TCGV_UNUSED_I32(tmp3);
tmp2 = NULL;
tmp3 = NULL;
}
gen_helper_iwmmxt_insr(cpu_M0, cpu_M0, tmp, tmp2, tmp3);
tcg_temp_free_i32(tmp3);
Expand Down Expand Up @@ -4939,7 +4939,7 @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
}
} else /* size == 0 */ {
if (load) {
TCGV_UNUSED_I32(tmp2);
tmp2 = NULL;
for (n = 0; n < 4; n++) {
tmp = tcg_temp_new_i32();
gen_aa32_ld8u(s, tmp, addr, get_mem_index(s));
Expand Down Expand Up @@ -6643,11 +6643,11 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
tmp = neon_load_reg(rn, 1);
neon_store_scratch(2, tmp);
}
TCGV_UNUSED_I32(tmp3);
tmp3 = NULL;
for (pass = 0; pass < 2; pass++) {
if (src1_wide) {
neon_load_reg64(cpu_V0, rn + pass);
TCGV_UNUSED_I32(tmp);
tmp = NULL;
} else {
if (pass == 1 && rd == rn) {
tmp = neon_load_scratch(2);
Expand All @@ -6660,7 +6660,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
}
if (src2_wide) {
neon_load_reg64(cpu_V1, rm + pass);
TCGV_UNUSED_I32(tmp2);
tmp2 = NULL;
} else {
if (pass == 1 && rd == rm) {
tmp2 = neon_load_scratch(2);
Expand Down Expand Up @@ -7078,7 +7078,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
if (rm & 1) {
return 1;
}
TCGV_UNUSED_I32(tmp2);
tmp2 = NULL;
for (pass = 0; pass < 2; pass++) {
neon_load_reg64(cpu_V0, rm + pass);
tmp = tcg_temp_new_i32();
Expand Down Expand Up @@ -7217,7 +7217,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
if (neon_2rm_is_float_op(op)) {
tcg_gen_ld_f32(cpu_F0s, cpu_env,
neon_reg_offset(rm, pass));
TCGV_UNUSED_I32(tmp);
tmp = NULL;
} else {
tmp = neon_load_reg(rm, pass);
}
Expand Down Expand Up @@ -8666,7 +8666,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
rn = (insn >> 16) & 0xf;
tmp = load_reg(s, rn);
} else {
TCGV_UNUSED_I32(tmp);
tmp = NULL;
}
rd = (insn >> 12) & 0xf;
switch(op1) {
Expand Down Expand Up @@ -9505,7 +9505,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)

/* compute total size */
loaded_base = 0;
TCGV_UNUSED_I32(loaded_var);
loaded_var = NULL;
n = 0;
for(i=0;i<16;i++) {
if (insn & (1 << i))
Expand Down Expand Up @@ -10074,7 +10074,7 @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
tcg_gen_addi_i32(addr, addr, -offset);
}

TCGV_UNUSED_I32(loaded_var);
loaded_var = NULL;
for (i = 0; i < 16; i++) {
if ((insn & (1 << i)) == 0)
continue;
Expand Down Expand Up @@ -11355,7 +11355,7 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
} else if (op != 0xf) { /* mvn doesn't read its first operand */
tmp = load_reg(s, rd);
} else {
TCGV_UNUSED_I32(tmp);
tmp = NULL;
}

tmp2 = load_reg(s, rm);
Expand Down Expand Up @@ -11686,7 +11686,7 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
tcg_gen_addi_i32(addr, addr, 4);
}
}
TCGV_UNUSED_I32(tmp);
tmp = NULL;
if (insn & (1 << 8)) {
if (insn & (1 << 11)) {
/* pop pc */
Expand Down Expand Up @@ -11831,8 +11831,7 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
case 12:
{
/* load/store multiple */
TCGv_i32 loaded_var;
TCGV_UNUSED_I32(loaded_var);
TCGv_i32 loaded_var = NULL;
rn = (insn >> 8) & 0x7;
addr = load_reg(s, rn);
for (i = 0; i < 8; i++) {
Expand Down
2 changes: 1 addition & 1 deletion target/cris/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,7 +2603,7 @@ static int dec_movem_mr(CPUCRISState *env, DisasContext *dc)
tcg_gen_addi_tl(addr, cpu_R[dc->op1], i * 8);
gen_load(dc, tmp32, addr, 4, 0);
} else {
TCGV_UNUSED(tmp32);
tmp32 = NULL;
}
tcg_temp_free(addr);

Expand Down
Loading

0 comments on commit f764718

Please sign in to comment.