-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV] Implement codegen for XAndesPerf lea instructions #137925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
253317e
ffb5d39
1dea0f3
9fb0458
15980a1
4d20459
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
|
||
|
||
| foreach i = {1,2,3} in { | ||
| defvar shxadd = !cast<Instruction>("SH"#i#"ADD"); | ||
| defm : ShxAddPat<i, shxadd>; | ||
| } | ||
|
|
||
| def : CSImm12MulBy4Pat<SH2ADD>; | ||
| def : CSImm12MulBy8Pat<SH3ADD>; | ||
| } // Predicates = [HasStdExtZba] | ||
|
|
||
| multiclass ADD_UWPat<Instruction add_uw> { | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFFF), GPR:$rs2)), | ||
tclin914 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (add_uw GPR:$rs1, GPR:$rs2)>; | ||
| def : Pat<(i64 (and GPR:$rs, 0xFFFFFFFF)), (add_uw GPR:$rs, (XLenVT X0))>; | ||
| } | ||
|
|
||
| multiclass ShxAdd_UWPat<int i, Instruction shxadd_uw> { | ||
| def : Pat<(i64 (add_like_non_imm12 (shl (and GPR:$rs1, 0xFFFFFFFF), (i64 i)), | ||
tclin914 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (XLenVT GPR:$rs2))), | ||
| (shxadd_uw GPR:$rs1, GPR:$rs2)>; | ||
| def : Pat<(i64 (riscv_shl_add (and GPR:$rs1, 0xFFFFFFFF), (i64 i), GPR:$rs2)), | ||
| (shxadd_uw GPR:$rs1, GPR:$rs2)>; | ||
|
|
||
| defvar pat = !cast<ComplexPattern>("sh"#i#"add_uw_op"); | ||
| // More complex cases use a ComplexPattern. | ||
| def : Pat<(i64 (add_like_non_imm12 pat:$rs1, (XLenVT GPR:$rs2))), | ||
| (shxadd_uw pat:$rs1, GPR:$rs2)>; | ||
| } | ||
|
|
||
| multiclass Sh1Add_UWPat<Instruction sh1add_uw> { | ||
| def : Pat<(i64 (add_like_non_imm12 (and (shl GPR:$rs1, (i64 1)), 0x1FFFFFFFF), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh1add_uw GPR:$rs1, GPR:$rs2)>; | ||
| // Use SRLI to clear the LSBs and SHXADD_UW to mask and shift. | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0x1FFFFFFFE), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh1add_uw (XLenVT (SRLI GPR:$rs1, 1)), GPR:$rs2)>; | ||
| } | ||
|
|
||
| multiclass Sh2Add_UWPat<Instruction sh2add_uw> { | ||
| def : Pat<(i64 (add_like_non_imm12 (and (shl GPR:$rs1, (i64 2)), 0x3FFFFFFFF), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh2add_uw GPR:$rs1, GPR:$rs2)>; | ||
| // Use SRLI to clear the LSBs and SHXADD_UW to mask and shift. | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0x3FFFFFFFC), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh2add_uw (XLenVT (SRLI GPR:$rs1, 2)), GPR:$rs2)>; | ||
| } | ||
|
|
||
| multiclass Sh3Add_UWPat<Instruction sh3add_uw> { | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFF8), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh3add_uw (XLenVT (SRLIW GPR:$rs1, 3)), GPR:$rs2)>; | ||
| // Use SRLI to clear the LSBs and SHXADD_UW to mask and shift. | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0x7FFFFFFF8), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh3add_uw (XLenVT (SRLI GPR:$rs1, 3)), GPR:$rs2)>; | ||
| } | ||
|
|
||
| class Sh1AddPat<Instruction sh1add> | ||
| : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFFE), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh1add (XLenVT (SRLIW GPR:$rs1, 1)), GPR:$rs2)>; | ||
|
|
||
| class Sh2AddPat<Instruction sh2add> | ||
| : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFFC), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh2add (XLenVT (SRLIW GPR:$rs1, 2)), GPR:$rs2)>; | ||
|
|
||
| class Sh3AddPat<Instruction sh3add> | ||
| : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFF8), | ||
| (XLenVT GPR:$rs2))), | ||
| (sh3add (XLenVT (SRLIW GPR:$rs1, 3)), GPR:$rs2)>; | ||
|
|
||
| let Predicates = [HasStdExtZba, IsRV64] in { | ||
| def : Pat<(i64 (shl (and GPR:$rs1, 0xFFFFFFFF), uimm5:$shamt)), | ||
| (SLLI_UW GPR:$rs1, uimm5:$shamt)>; | ||
|
|
@@ -691,47 +764,21 @@ def : Pat<(i64 (shl (and GPR:$rs1, 0xFFFFFFFF), uimm5:$shamt)), | |
| def : Pat<(i64 (and GPR:$rs1, Shifted32OnesMask:$mask)), | ||
| (SLLI_UW (XLenVT (SRLI GPR:$rs1, Shifted32OnesMask:$mask)), | ||
| Shifted32OnesMask:$mask)>; | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFFF), GPR:$rs2)), | ||
| (ADD_UW GPR:$rs1, GPR:$rs2)>; | ||
| def : Pat<(i64 (and GPR:$rs, 0xFFFFFFFF)), (ADD_UW GPR:$rs, (XLenVT X0))>; | ||
|
|
||
| foreach i = {1,2,3} in { | ||
| defvar shxadd_uw = !cast<Instruction>("SH"#i#"ADD_UW"); | ||
| def : Pat<(i64 (add_like_non_imm12 (shl (and GPR:$rs1, 0xFFFFFFFF), (i64 i)), (XLenVT GPR:$rs2))), | ||
| (shxadd_uw GPR:$rs1, GPR:$rs2)>; | ||
| def : Pat<(i64 (riscv_shl_add (and GPR:$rs1, 0xFFFFFFFF), (i64 i), GPR:$rs2)), | ||
| (shxadd_uw GPR:$rs1, GPR:$rs2)>; | ||
| } | ||
|
|
||
| def : Pat<(i64 (add_like_non_imm12 (and (shl GPR:$rs1, (i64 1)), 0x1FFFFFFFF), (XLenVT GPR:$rs2))), | ||
| (SH1ADD_UW GPR:$rs1, GPR:$rs2)>; | ||
| def : Pat<(i64 (add_like_non_imm12 (and (shl GPR:$rs1, (i64 2)), 0x3FFFFFFFF), (XLenVT GPR:$rs2))), | ||
| (SH2ADD_UW GPR:$rs1, GPR:$rs2)>; | ||
| def : Pat<(i64 (add_like_non_imm12 (and (shl GPR:$rs1, (i64 3)), 0x7FFFFFFFF), (XLenVT GPR:$rs2))), | ||
| (SH3ADD_UW GPR:$rs1, GPR:$rs2)>; | ||
| defm : ADD_UWPat<ADD_UW>; | ||
|
|
||
| // More complex cases use a ComplexPattern. | ||
| foreach i = {1,2,3} in { | ||
| defvar pat = !cast<ComplexPattern>("sh"#i#"add_uw_op"); | ||
| def : Pat<(i64 (add_like_non_imm12 pat:$rs1, (XLenVT GPR:$rs2))), | ||
| (!cast<Instruction>("SH"#i#"ADD_UW") pat:$rs1, GPR:$rs2)>; | ||
| defvar shxadd_uw = !cast<Instruction>("SH"#i#"ADD_UW"); | ||
| defm : ShxAdd_UWPat<i, shxadd_uw>; | ||
| } | ||
|
|
||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFFE), (XLenVT GPR:$rs2))), | ||
| (SH1ADD (XLenVT (SRLIW GPR:$rs1, 1)), GPR:$rs2)>; | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFFC), (XLenVT GPR:$rs2))), | ||
| (SH2ADD (XLenVT (SRLIW GPR:$rs1, 2)), GPR:$rs2)>; | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFF8), (XLenVT GPR:$rs2))), | ||
| (SH3ADD (XLenVT (SRLIW GPR:$rs1, 3)), GPR:$rs2)>; | ||
|
|
||
| // Use SRLI to clear the LSBs and SHXADD_UW to mask and shift. | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0x1FFFFFFFE), (XLenVT GPR:$rs2))), | ||
| (SH1ADD_UW (XLenVT (SRLI GPR:$rs1, 1)), GPR:$rs2)>; | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0x3FFFFFFFC), (XLenVT GPR:$rs2))), | ||
| (SH2ADD_UW (XLenVT (SRLI GPR:$rs1, 2)), GPR:$rs2)>; | ||
| def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0x7FFFFFFF8), (XLenVT GPR:$rs2))), | ||
| (SH3ADD_UW (XLenVT (SRLI GPR:$rs1, 3)), GPR:$rs2)>; | ||
| defm : Sh1Add_UWPat<SH1ADD_UW>; | ||
| defm : Sh2Add_UWPat<SH2ADD_UW>; | ||
| defm : Sh3Add_UWPat<SH3ADD_UW>; | ||
|
|
||
| def : Sh1AddPat<SH1ADD>; | ||
| def : Sh2AddPat<SH2ADD>; | ||
| def : Sh3AddPat<SH3ADD>; | ||
| } // Predicates = [HasStdExtZba, IsRV64] | ||
|
|
||
| let Predicates = [HasStdExtZbcOrZbkc] in { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.