Skip to content

Commit 1e83d97

Browse files
authored
[RISCV] Use inheritance to reduce duplicated code in RISCVInstrInfoXCV.td. NFC (#130703)
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.
1 parent 72bb0a9 commit 1e83d97

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,30 +319,24 @@ class CVSIMDRRWb<bits<5> funct5, bit F, bit funct1, bits<3> funct3,
319319
let Constraints = "$rd = $rd_wb";
320320
}
321321

322-
class CVSIMDRI<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
322+
class CVSIMDRI<bits<5> funct5, bit F, bits<3> funct3, string opcodestr,
323+
Operand immtype = simm6>
323324
: CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3, (outs GPR:$rd),
324-
(ins GPR:$rs1, simm6:$imm6), opcodestr, "$rd, $rs1, $imm6">;
325+
(ins GPR:$rs1, immtype:$imm6), opcodestr, "$rd, $rs1, $imm6">;
325326

326-
class CVSIMDRIWb<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
327+
class CVSIMDRIWb<bits<5> funct5, bit F, bits<3> funct3, string opcodestr,
328+
Operand immtype = simm6>
327329
: CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3,
328-
(outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, simm6:$imm6),
330+
(outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, immtype:$imm6),
329331
opcodestr, "$rd, $rs1, $imm6"> {
330332
let Constraints = "$rd = $rd_wb";
331333
}
332334

333-
class CVSIMDRU<bits<5> funct5, bit F, bits<3> funct3, string opcodestr,
334-
Operand immtype = uimm6>
335-
: CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3,
336-
(outs GPR:$rd), (ins GPR:$rs1, immtype:$imm6),
337-
opcodestr, "$rd, $rs1, $imm6">;
335+
class CVSIMDRU<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
336+
: CVSIMDRI<funct5, F, funct3, opcodestr, uimm6>;
338337

339338
class CVSIMDRUWb<bits<5> funct5, bit F, bits<3> funct3, string opcodestr>
340-
: CVInstSIMDRI<funct5, F, funct3, OPC_CUSTOM_3,
341-
(outs GPR:$rd_wb),
342-
(ins GPR:$rd, GPR:$rs1, uimm6:$imm6),
343-
opcodestr, "$rd, $rs1, $imm6"> {
344-
let Constraints = "$rd = $rd_wb";
345-
}
339+
: CVSIMDRIWb<funct5, F, funct3, opcodestr, uimm6>;
346340

347341
class CVSIMDR<bits<5> funct5, bit F, bit funct1, bits<3> funct3,
348342
string opcodestr>
@@ -374,8 +368,8 @@ multiclass CVSIMDShift<bits<5> funct5, bit F, bit funct1, string mnemonic> {
374368
def CV_ # NAME # _B : CVSIMDRR<funct5, F, funct1, 0b001, "cv." # mnemonic # ".b">;
375369
def CV_ # NAME # _SC_H : CVSIMDRR<funct5, F, funct1, 0b100, "cv." # mnemonic # ".sc.h">;
376370
def CV_ # NAME # _SC_B : CVSIMDRR<funct5, F, funct1, 0b101, "cv." # mnemonic # ".sc.b">;
377-
def CV_ # NAME # _SCI_H : CVSIMDRU<funct5, F, 0b110, "cv." # mnemonic # ".sci.h", uimm4>;
378-
def CV_ # NAME # _SCI_B : CVSIMDRU<funct5, F, 0b111, "cv." # mnemonic # ".sci.b", uimm3>;
371+
def CV_ # NAME # _SCI_H : CVSIMDRI<funct5, F, 0b110, "cv." # mnemonic # ".sci.h", uimm4>;
372+
def CV_ # NAME # _SCI_B : CVSIMDRI<funct5, F, 0b111, "cv." # mnemonic # ".sci.b", uimm3>;
379373
}
380374

381375
multiclass CVSIMDBinarySignedWb<bits<5> funct5, bit F, bit funct1, string mnemonic> {

0 commit comments

Comments
 (0)