Reviewed-by: Matt Turner <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
---
tcg/loongarch64/tcg-target-has.h | 4 ++--
tcg/loongarch64/tcg-target.c.inc | 13 ++++++++++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/tcg/loongarch64/tcg-target-has.h b/tcg/loongarch64/tcg-target-has.h
index 31e6ea9632d..53b7ca40571 100644
--- a/tcg/loongarch64/tcg-target-has.h
+++ b/tcg/loongarch64/tcg-target-has.h
@@ -54,7 +54,7 @@ tcg_target_sextract_valid(TCGType type, unsigned ofs,
unsigned len)
}
#define TCG_TARGET_sextract_valid tcg_target_sextract_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) >= 1 && (sh) <= 4)
+#define TCG_TARGET_lea_imm_valid(type, imm) ((imm) == 0)
#endif
diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index 17784d8bbe2..377cd9ec08d 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -2098,8 +2098,19 @@ static const TCGOutOpStore outop_st = {
.out_r = tcg_out_st,
};
+static void tgen_lea(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1,
+ TCGReg a2, unsigned sh, tcg_target_long imm)
+{
+ if (type == TCG_TYPE_I32) {
+ tcg_out_opc_sladd_w(s, a0, a2, a1, sh - 1);
+ } else {
+ tcg_out_opc_sladd_d(s, a0, a2, a1, sh - 1);
+ }
+}
+
static const TCGOutOpLea outop_lea = {
- .base.static_constraint = C_NotImplemented,
+ .base.static_constraint = C_O1_I2(r, r, r),
+ .out = tgen_lea,
};
static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece,
--
2.53.0