Reviewed-by: Matt Turner <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
---
tcg/x86_64/tcg-target-con-set.h | 1 +
tcg/x86_64/tcg-target-has.h | 4 ++--
tcg/x86_64/tcg-target.h | 2 ++
tcg/x86_64/tcg-target.c.inc | 11 ++++++++++-
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tcg/x86_64/tcg-target-con-set.h b/tcg/x86_64/tcg-target-con-set.h
index 458d69c3c07..5af8c1cb2cd 100644
--- a/tcg/x86_64/tcg-target-con-set.h
+++ b/tcg/x86_64/tcg-target-con-set.h
@@ -46,6 +46,7 @@ C_O1_I2(r, r, r)
C_O1_I2(r, r, re)
C_O1_I2(r, r, ri)
C_O1_I2(r, rO, re)
+C_O1_I2(r, rz, r)
C_O1_I2(x, x, x)
C_N1_I2(r, r, r)
C_N1_I2(r, r, rW)
diff --git a/tcg/x86_64/tcg-target-has.h b/tcg/x86_64/tcg-target-has.h
index 6ffae51f923..f1d3d256eeb 100644
--- a/tcg/x86_64/tcg-target-has.h
+++ b/tcg/x86_64/tcg-target-has.h
@@ -105,7 +105,7 @@ tcg_target_extract_valid(TCGType type, unsigned ofs,
unsigned len)
}
#define TCG_TARGET_extract_valid tcg_target_extract_valid
-#define TCG_TARGET_lea_sh_valid(type, sh) 0
-#define TCG_TARGET_lea_imm_valid(type, imm) 0
+#define TCG_TARGET_lea_sh_valid(type, sh) ((sh) <= 3)
+#define TCG_TARGET_lea_imm_valid(type, imm) ((imm) == (int32_t)(imm))
#endif
diff --git a/tcg/x86_64/tcg-target.h b/tcg/x86_64/tcg-target.h
index 7109722f240..3444bcdca0a 100644
--- a/tcg/x86_64/tcg-target.h
+++ b/tcg/x86_64/tcg-target.h
@@ -80,4 +80,6 @@ typedef enum {
TCG_REG_CALL_STACK = TCG_REG_ESP
} TCGReg;
+#define TCG_REG_ZERO TCG_REG_NONE
+
#endif
diff --git a/tcg/x86_64/tcg-target.c.inc b/tcg/x86_64/tcg-target.c.inc
index ec397e287c0..a41252782e1 100644
--- a/tcg/x86_64/tcg-target.c.inc
+++ b/tcg/x86_64/tcg-target.c.inc
@@ -3331,8 +3331,17 @@ static const TCGOutOpStore outop_st = {
.out_i = tgen_st_i,
};
+static void tgen_lea(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1,
+ TCGReg a2, unsigned sh, tcg_target_long imm)
+{
+ int rexw = type == TCG_TYPE_I32 ? 0 : P_REXW;
+ tcg_out_modrm_sib_offset(s, OPC_LEA + rexw, a0, a1, a2, sh, imm);
+}
+
static const TCGOutOpLea outop_lea = {
- .base.static_constraint = C_NotImplemented,
+ /* Allow "lea imm(, a2, sh), a0" via TCG_REG_ZERO constraint */
+ .base.static_constraint = C_O1_I2(r, rz, r),
+ .out = tgen_lea,
};
static int const umin_insn[4] = {
--
2.53.0