[llvm] [RISCV] Implement codegen for XAndesPerf lea instructions (PR #137925)
Jim Lin via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 30 23:49:55 PDT 2025
================
@@ -659,30 +659,103 @@ def : Pat<(i32 (and GPR:$rs, 0xFFFF)), (PACK GPR:$rs, (XLenVT X0))>;
let Predicates = [HasStdExtZbkb, NoStdExtZbb, IsRV64] in
def : Pat<(i64 (and GPR:$rs, 0xFFFF)), (PACKW GPR:$rs, (XLenVT X0))>;
-let Predicates = [HasStdExtZba] in {
+multiclass ShxAddPat<int i, Instruction shxadd> {
+def : Pat<(XLenVT (add_like_non_imm12 (shl GPR:$rs1, (XLenVT i)), GPR:$rs2)),
+ (shxadd GPR:$rs1, GPR:$rs2)>;
+def : Pat<(XLenVT (riscv_shl_add GPR:$rs1, (XLenVT i), GPR:$rs2)),
+ (shxadd GPR:$rs1, GPR:$rs2)>;
-foreach i = {1,2,3} in {
- defvar shxadd = !cast<Instruction>("SH"#i#"ADD");
- def : Pat<(XLenVT (add_like_non_imm12 (shl GPR:$rs1, (XLenVT i)), GPR:$rs2)),
- (shxadd GPR:$rs1, GPR:$rs2)>;
- def : Pat<(XLenVT (riscv_shl_add GPR:$rs1, (XLenVT i), GPR:$rs2)),
- (shxadd GPR:$rs1, GPR:$rs2)>;
-
- defvar pat = !cast<ComplexPattern>("sh"#i#"add_op");
- // More complex cases use a ComplexPattern.
- def : Pat<(XLenVT (add_like_non_imm12 pat:$rs1, GPR:$rs2)),
- (shxadd pat:$rs1, GPR:$rs2)>;
+defvar pat = !cast<ComplexPattern>("sh"#i#"add_op");
+// More complex cases use a ComplexPattern.
+def : Pat<(XLenVT (add_like_non_imm12 pat:$rs1, GPR:$rs2)),
+ (shxadd pat:$rs1, GPR:$rs2)>;
}
-def : Pat<(add_like (XLenVT GPR:$r), CSImm12MulBy4:$i),
- (SH2ADD (XLenVT (ADDI (XLenVT X0), CSImm12MulBy4:$i)),
+class CSImm12MulBy4Pat<Instruction sh2add>
+ : Pat<(add_like (XLenVT GPR:$r), CSImm12MulBy4:$i),
+ (sh2add (XLenVT (ADDI (XLenVT X0), CSImm12MulBy4:$i)),
GPR:$r)>;
-def : Pat<(add_like (XLenVT GPR:$r), CSImm12MulBy8:$i),
- (SH3ADD (XLenVT (ADDI (XLenVT X0), CSImm12MulBy8:$i)),
+
+class CSImm12MulBy8Pat<Instruction sh3add>
+ : Pat<(add_like (XLenVT GPR:$r), CSImm12MulBy8:$i),
+ (sh3add (XLenVT (ADDI (XLenVT X0), CSImm12MulBy8:$i)),
GPR:$r)>;
+let Predicates = [HasStdExtZba] in {
+
----------------
tclin914 wrote:
The bodies of the other `let` in this .td file don't have 2 spaces indentation. If I only make the change here, it won't have a consistent style throughout the file.
https://github.com/llvm/llvm-project/pull/137925
More information about the llvm-commits
mailing list