mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 05:51:53 -06:00
tcg: Introduce the 'z' constraint for a hardware zero register
For loongarch, mips, riscv and sparc, a zero register is available all the time. For aarch64, register index 31 depends on context: sometimes it is the stack pointer, and sometimes it is the zero register. Introduce a new general-purpose constraint which maps 0 to TCG_REG_ZERO, if defined. This differs from existing constant constraints in that const_arg[*] is recorded as false, indicating that the value is in a register. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
bf455ec50b
commit
6b8abd244b
8 changed files with 37 additions and 10 deletions
|
@ -927,7 +927,9 @@ operation uses a constant input constraint which does not allow all
|
||||||
constants, it must also accept registers in order to have a fallback.
|
constants, it must also accept registers in order to have a fallback.
|
||||||
The constraint '``i``' is defined generically to accept any constant.
|
The constraint '``i``' is defined generically to accept any constant.
|
||||||
The constraint '``r``' is not defined generically, but is consistently
|
The constraint '``r``' is not defined generically, but is consistently
|
||||||
used by each backend to indicate all registers.
|
used by each backend to indicate all registers. If ``TCG_REG_ZERO``
|
||||||
|
is defined by the backend, the constraint '``z``' is defined generically
|
||||||
|
to map constant 0 to the hardware zero register.
|
||||||
|
|
||||||
The movi_i32 and movi_i64 operations must accept any constants.
|
The movi_i32 and movi_i64 operations must accept any constants.
|
||||||
|
|
||||||
|
|
|
@ -713,7 +713,8 @@ void tb_target_set_jmp_target(const TranslationBlock *, int,
|
||||||
|
|
||||||
void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size);
|
void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size);
|
||||||
|
|
||||||
#define TCG_CT_CONST 1 /* any constant of register size */
|
#define TCG_CT_CONST 1 /* any constant of register size */
|
||||||
|
#define TCG_CT_REG_ZERO 2 /* zero, in TCG_REG_ZERO */
|
||||||
|
|
||||||
typedef struct TCGArgConstraint {
|
typedef struct TCGArgConstraint {
|
||||||
unsigned ct : 16;
|
unsigned ct : 16;
|
||||||
|
|
|
@ -45,6 +45,8 @@ typedef enum {
|
||||||
TCG_AREG0 = TCG_REG_X19,
|
TCG_AREG0 = TCG_REG_X19,
|
||||||
} TCGReg;
|
} TCGReg;
|
||||||
|
|
||||||
|
#define TCG_REG_ZERO TCG_REG_XZR
|
||||||
|
|
||||||
#define TCG_TARGET_NB_REGS 64
|
#define TCG_TARGET_NB_REGS 64
|
||||||
|
|
||||||
#endif /* AARCH64_TCG_TARGET_H */
|
#endif /* AARCH64_TCG_TARGET_H */
|
||||||
|
|
|
@ -85,4 +85,6 @@ typedef enum {
|
||||||
TCG_VEC_TMP0 = TCG_REG_V23,
|
TCG_VEC_TMP0 = TCG_REG_V23,
|
||||||
} TCGReg;
|
} TCGReg;
|
||||||
|
|
||||||
|
#define TCG_REG_ZERO TCG_REG_ZERO
|
||||||
|
|
||||||
#endif /* LOONGARCH_TCG_TARGET_H */
|
#endif /* LOONGARCH_TCG_TARGET_H */
|
||||||
|
|
|
@ -70,4 +70,6 @@ typedef enum {
|
||||||
TCG_AREG0 = TCG_REG_S8,
|
TCG_AREG0 = TCG_REG_S8,
|
||||||
} TCGReg;
|
} TCGReg;
|
||||||
|
|
||||||
|
#define TCG_REG_ZERO TCG_REG_ZERO
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,4 +57,6 @@ typedef enum {
|
||||||
TCG_REG_TMP2 = TCG_REG_T4,
|
TCG_REG_TMP2 = TCG_REG_T4,
|
||||||
} TCGReg;
|
} TCGReg;
|
||||||
|
|
||||||
|
#define TCG_REG_ZERO TCG_REG_ZERO
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,6 +64,7 @@ typedef enum {
|
||||||
TCG_REG_I7,
|
TCG_REG_I7,
|
||||||
} TCGReg;
|
} TCGReg;
|
||||||
|
|
||||||
#define TCG_AREG0 TCG_REG_I0
|
#define TCG_AREG0 TCG_REG_I0
|
||||||
|
#define TCG_REG_ZERO TCG_REG_G0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
29
tcg/tcg.c
29
tcg/tcg.c
|
@ -3223,6 +3223,11 @@ static void process_constraint_sets(void)
|
||||||
case 'i':
|
case 'i':
|
||||||
args_ct[i].ct |= TCG_CT_CONST;
|
args_ct[i].ct |= TCG_CT_CONST;
|
||||||
break;
|
break;
|
||||||
|
#ifdef TCG_REG_ZERO
|
||||||
|
case 'z':
|
||||||
|
args_ct[i].ct |= TCG_CT_REG_ZERO;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Include all of the target-specific constraints. */
|
/* Include all of the target-specific constraints. */
|
||||||
|
|
||||||
|
@ -5074,13 +5079,23 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
|
||||||
arg_ct = &args_ct[i];
|
arg_ct = &args_ct[i];
|
||||||
ts = arg_temp(arg);
|
ts = arg_temp(arg);
|
||||||
|
|
||||||
if (ts->val_type == TEMP_VAL_CONST
|
if (ts->val_type == TEMP_VAL_CONST) {
|
||||||
&& tcg_target_const_match(ts->val, arg_ct->ct, ts->type,
|
#ifdef TCG_REG_ZERO
|
||||||
op_cond, TCGOP_VECE(op))) {
|
if (ts->val == 0 && (arg_ct->ct & TCG_CT_REG_ZERO)) {
|
||||||
/* constant is OK for instruction */
|
/* Hardware zero register: indicate register via non-const. */
|
||||||
const_args[i] = 1;
|
const_args[i] = 0;
|
||||||
new_args[i] = ts->val;
|
new_args[i] = TCG_REG_ZERO;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (tcg_target_const_match(ts->val, arg_ct->ct, ts->type,
|
||||||
|
op_cond, TCGOP_VECE(op))) {
|
||||||
|
/* constant is OK for instruction */
|
||||||
|
const_args[i] = 1;
|
||||||
|
new_args[i] = ts->val;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reg = ts->reg;
|
reg = ts->reg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue