constants, it must also accept registers in order to have a fallback.
The constraint '``i``' is defined generically to accept any constant.
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.
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 {
unsigned ct : 16;
TCG_AREG0 = TCG_REG_X19,
} TCGReg;
+#define TCG_REG_ZERO TCG_REG_XZR
+
#define TCG_TARGET_NB_REGS 64
#endif /* AARCH64_TCG_TARGET_H */
TCG_VEC_TMP0 = TCG_REG_V23,
} TCGReg;
+#define TCG_REG_ZERO TCG_REG_ZERO
+
#endif /* LOONGARCH_TCG_TARGET_H */
TCG_AREG0 = TCG_REG_S8,
} TCGReg;
+#define TCG_REG_ZERO TCG_REG_ZERO
+
#endif
TCG_REG_TMP2 = TCG_REG_T4,
} TCGReg;
+#define TCG_REG_ZERO TCG_REG_ZERO
+
#endif
TCG_REG_I7,
} TCGReg;
-#define TCG_AREG0 TCG_REG_I0
+#define TCG_AREG0 TCG_REG_I0
+#define TCG_REG_ZERO TCG_REG_G0
#endif
case 'i':
args_ct[i].ct |= TCG_CT_CONST;
break;
+#ifdef TCG_REG_ZERO
+ case 'z':
+ args_ct[i].ct |= TCG_CT_REG_ZERO;
+ break;
+#endif
/* Include all of the target-specific constraints. */
arg_ct = &args_ct[i];
ts = arg_temp(arg);
- if (ts->val_type == TEMP_VAL_CONST
- && 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;
+ if (ts->val_type == TEMP_VAL_CONST) {
+#ifdef TCG_REG_ZERO
+ if (ts->val == 0 && (arg_ct->ct & TCG_CT_REG_ZERO)) {
+ /* Hardware zero register: indicate register via non-const. */
+ const_args[i] = 0;
+ new_args[i] = TCG_REG_ZERO;
+ 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;