Skip to content

Commit 326b966

Browse files
committed
tcg/arm: Standardize on tcg_out_<branch>_{reg,imm}
Some of the functions specified _reg, some _imm, and some left it blank. Make it clearer to which we are referring. Split tcg_out_b_reg from tcg_out_bx_reg, to indicate when we do not actually require BX semantics. Reviewed-by: Peter Maydell <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent e0e1ad6 commit 326b966

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

tcg/arm/tcg-target.c.inc

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -525,19 +525,19 @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct)
525525
return 0;
526526
}
527527

528-
static inline void tcg_out_b(TCGContext *s, int cond, int32_t offset)
528+
static inline void tcg_out_b_imm(TCGContext *s, int cond, int32_t offset)
529529
{
530530
tcg_out32(s, (cond << 28) | 0x0a000000 |
531531
(((offset - 8) >> 2) & 0x00ffffff));
532532
}
533533

534-
static inline void tcg_out_bl(TCGContext *s, int cond, int32_t offset)
534+
static inline void tcg_out_bl_imm(TCGContext *s, int cond, int32_t offset)
535535
{
536536
tcg_out32(s, (cond << 28) | 0x0b000000 |
537537
(((offset - 8) >> 2) & 0x00ffffff));
538538
}
539539

540-
static inline void tcg_out_blx(TCGContext *s, int cond, int rn)
540+
static inline void tcg_out_blx_reg(TCGContext *s, int cond, int rn)
541541
{
542542
tcg_out32(s, (cond << 28) | 0x012fff30 | rn);
543543
}
@@ -568,13 +568,19 @@ static inline void tcg_out_mov_reg(TCGContext *s, int cond, int rd, int rm)
568568
}
569569
}
570570

571-
static inline void tcg_out_bx(TCGContext *s, int cond, TCGReg rn)
571+
static void tcg_out_bx_reg(TCGContext *s, int cond, TCGReg rn)
572572
{
573-
/* Unless the C portion of QEMU is compiled as thumb, we don't
574-
actually need true BX semantics; merely a branch to an address
575-
held in a register. */
573+
tcg_out32(s, (cond << 28) | 0x012fff10 | rn);
574+
}
575+
576+
static void tcg_out_b_reg(TCGContext *s, int cond, TCGReg rn)
577+
{
578+
/*
579+
* Unless the C portion of QEMU is compiled as thumb, we don't need
580+
* true BX semantics; merely a branch to an address held in a register.
581+
*/
576582
if (use_armv5t_instructions) {
577-
tcg_out32(s, (cond << 28) | 0x012fff10 | rn);
583+
tcg_out_bx_reg(s, cond, rn);
578584
} else {
579585
tcg_out_mov_reg(s, cond, TCG_REG_PC, rn);
580586
}
@@ -1215,7 +1221,7 @@ static void tcg_out_goto(TCGContext *s, int cond, const tcg_insn_unit *addr)
12151221
ptrdiff_t disp = tcg_pcrel_diff(s, addr);
12161222

12171223
if ((addri & 1) == 0 && disp - 8 < 0x01fffffd && disp - 8 > -0x01fffffd) {
1218-
tcg_out_b(s, cond, disp);
1224+
tcg_out_b_imm(s, cond, disp);
12191225
return;
12201226
}
12211227
tcg_out_movi_pool(s, cond, TCG_REG_PC, addri);
@@ -1236,11 +1242,11 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr)
12361242
}
12371243
tcg_out_blx_imm(s, disp);
12381244
} else {
1239-
tcg_out_bl(s, COND_AL, disp);
1245+
tcg_out_bl_imm(s, COND_AL, disp);
12401246
}
12411247
} else if (use_armv7_instructions) {
12421248
tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri);
1243-
tcg_out_blx(s, COND_AL, TCG_REG_TMP);
1249+
tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP);
12441250
} else {
12451251
/* ??? Know that movi_pool emits exactly 1 insn. */
12461252
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R14, TCG_REG_PC, 0);
@@ -1254,7 +1260,7 @@ static inline void tcg_out_goto_label(TCGContext *s, int cond, TCGLabel *l)
12541260
tcg_out_goto(s, cond, l->u.value_ptr);
12551261
} else {
12561262
tcg_out_reloc(s, s->code_ptr, R_ARM_PC24, l, 0);
1257-
tcg_out_b(s, cond, 0);
1263+
tcg_out_b_imm(s, cond, 0);
12581264
}
12591265
}
12601266

@@ -1823,7 +1829,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64)
18231829
/* This a conditional BL only to load a pointer within this opcode into LR
18241830
for the slow path. We will not be using the value for a tail call. */
18251831
label_ptr = s->code_ptr;
1826-
tcg_out_bl(s, COND_NE, 0);
1832+
tcg_out_bl_imm(s, COND_NE, 0);
18271833

18281834
tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, addend);
18291835

@@ -1929,7 +1935,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64)
19291935

19301936
/* The conditional call must come last, as we're going to return here. */
19311937
label_ptr = s->code_ptr;
1932-
tcg_out_bl(s, COND_NE, 0);
1938+
tcg_out_bl_imm(s, COND_NE, 0);
19331939

19341940
add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi,
19351941
s->code_ptr, label_ptr);
@@ -1982,7 +1988,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
19821988
}
19831989
break;
19841990
case INDEX_op_goto_ptr:
1985-
tcg_out_bx(s, COND_AL, args[0]);
1991+
tcg_out_b_reg(s, COND_AL, args[0]);
19861992
break;
19871993
case INDEX_op_br:
19881994
tcg_out_goto_label(s, COND_AL, arg_label(args[0]));
@@ -3066,7 +3072,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
30663072

30673073
tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]);
30683074

3069-
tcg_out_bx(s, COND_AL, tcg_target_call_iarg_regs[1]);
3075+
tcg_out_b_reg(s, COND_AL, tcg_target_call_iarg_regs[1]);
30703076

30713077
/*
30723078
* Return path for goto_ptr. Set return value to 0, a-la exit_tb,

0 commit comments

Comments
 (0)