-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Use inheritance to reduce duplicated code in RISCVInstrInfoXCV.td. NFC #130703
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
Conversation
…V.td. NFC CVSIMDRU and CVSIMDRI were the same except for immediate type. Make it a default argument of CVSIMDRI so that CVSIMDRU can inherit from it and override the argument. Similar for CVSIMDRUWb.
@llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesCVSIMDRU and CVSIMDRI were the same except for immediate type. Make it a default argument of CVSIMDRI so that CVSIMDRU can inherit from it and override the argument. Similar for CVSIMDRUWb. Full diff: https://github.com/llvm/llvm-project/pull/130703.diff 1 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
index 4cf0bb94af347..9dc5e617364bf 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
@@ -319,30 +319,24 @@ class CVSIMDRRWb<bits<5> funct5, bit F, bit funct1, bits<3> funct3,
let Constraints = "$rd = $rd_wb";
}
-class CVSIMDRI<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
+class CVSIMDRI<bits<5> funct5, bit F, bits<3> funct3, string opcodestr,
+ Operand immtype = simm6>
: CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3, (outs GPR:$rd),
- (ins GPR:$rs1, simm6:$imm6), opcodestr, "$rd, $rs1, $imm6">;
+ (ins GPR:$rs1, immtype:$imm6), opcodestr, "$rd, $rs1, $imm6">;
-class CVSIMDRIWb<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
+class CVSIMDRIWb<bits<5> funct5, bit F, bits<3> funct3, string opcodestr,
+ Operand immtype = simm6>
: CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3,
- (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, simm6:$imm6),
+ (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, immtype:$imm6),
opcodestr, "$rd, $rs1, $imm6"> {
let Constraints = "$rd = $rd_wb";
}
-class CVSIMDRU<bits<5> funct5, bit F, bits<3> funct3, string opcodestr,
- Operand immtype = uimm6>
- : CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3,
- (outs GPR:$rd), (ins GPR:$rs1, immtype:$imm6),
- opcodestr, "$rd, $rs1, $imm6">;
+class CVSIMDRU<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
+ : CVSIMDRI<funct5, F, funct3, opcodestr, uimm6>;
class CVSIMDRUWb<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
- : CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3,
- (outs GPR:$rd_wb),
- (ins GPR:$rd, GPR:$rs1, uimm6:$imm6),
- opcodestr, "$rd, $rs1, $imm6"> {
- let Constraints = "$rd = $rd_wb";
-}
+ : CVSIMDRIWb<funct5, F, funct3, opcodestr, uimm6>;
class CVSIMDR<bits<5> funct5, bit F, bit funct1, bits<3> funct3,
string opcodestr>
@@ -374,8 +368,8 @@ multiclass CVSIMDShift<bits<5> funct5, bit F, bit funct1, string mnemonic> {
def CV_ # NAME # _B : CVSIMDRR<funct5, F, funct1, 0b001, "cv." # mnemonic # ".b">;
def CV_ # NAME # _SC_H : CVSIMDRR<funct5, F, funct1, 0b100, "cv." # mnemonic # ".sc.h">;
def CV_ # NAME # _SC_B : CVSIMDRR<funct5, F, funct1, 0b101, "cv." # mnemonic # ".sc.b">;
- def CV_ # NAME # _SCI_H : CVSIMDRU<funct5, F, 0b110, "cv." # mnemonic # ".sci.h", uimm4>;
- def CV_ # NAME # _SCI_B : CVSIMDRU<funct5, F, 0b111, "cv." # mnemonic # ".sci.b", uimm3>;
+ def CV_ # NAME # _SCI_H : CVSIMDRI<funct5, F, 0b110, "cv." # mnemonic # ".sci.h", uimm4>;
+ def CV_ # NAME # _SCI_B : CVSIMDRI<funct5, F, 0b111, "cv." # mnemonic # ".sci.b", uimm3>;
}
multiclass CVSIMDBinarySignedWb<bits<5> funct5, bit F, bit funct1, string mnemonic> {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/81/builds/5102 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/7212 Here is the relevant piece of the build log for the reference
|
CVSIMDRU and CVSIMDRI were the same except for immediate type. Make it a default argument of CVSIMDRI so that CVSIMDRU can inherit from it and override the argument.
Similar for CVSIMDRUWb.