[PATCH] D155744: [RISCV] Introduce a common tablegen base class for RVInst and RVInst16.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 12:56:02 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: asb, reames, jrtc27, wangpc.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: eopXD, MaskRay.
Herald added a project: LLVM.
This gives us a common place to put the TSFlags and the Namespace.
Removes TSFlags declaration duplication for D155690 <https://reviews.llvm.org/D155690>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155744
Files:
llvm/lib/Target/RISCV/RISCVInstrFormats.td
llvm/lib/Target/RISCV/RISCVInstrFormatsC.td
Index: llvm/lib/Target/RISCV/RISCVInstrFormatsC.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrFormatsC.td
+++ llvm/lib/Target/RISCV/RISCVInstrFormatsC.td
@@ -12,7 +12,7 @@
class RVInst16<dag outs, dag ins, string opcodestr, string argstr,
list<dag> pattern, InstFormat format>
- : Instruction {
+ : RVInstCommon<format> {
field bits<16> Inst;
// SoftFail is a field the disassembler can use to provide a way for
// instructions to not match without killing the whole decode process. It is
@@ -23,14 +23,10 @@
bits<2> Opcode = 0;
- let Namespace = "RISCV";
-
dag OutOperandList = outs;
dag InOperandList = ins;
let AsmString = opcodestr # "\t" # argstr;
let Pattern = pattern;
-
- let TSFlags{4-0} = format.Value;
}
class RVInst16CR<bits<4> funct4, bits<2> opcode, dag outs, dag ins,
Index: llvm/lib/Target/RISCV/RISCVInstrFormats.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrFormats.td
+++ llvm/lib/Target/RISCV/RISCVInstrFormats.td
@@ -156,28 +156,9 @@
def OPC_OP_P : RISCVOpcode<"OP_P", 0b1110111>;
def OPC_CUSTOM_3 : RISCVOpcode<"CUSTOM_3", 0b1111011>;
-class RVInst<dag outs, dag ins, string opcodestr, string argstr,
- list<dag> pattern, InstFormat format>
- : Instruction {
- field bits<32> Inst;
- // SoftFail is a field the disassembler can use to provide a way for
- // instructions to not match without killing the whole decode process. It is
- // mainly used for ARM, but Tablegen expects this field to exist or it fails
- // to build the decode table.
- field bits<32> SoftFail = 0;
- let Size = 4;
-
- bits<7> Opcode = 0;
-
- let Inst{6-0} = Opcode;
-
+class RVInstCommon<InstFormat format> : Instruction {
let Namespace = "RISCV";
- dag OutOperandList = outs;
- dag InOperandList = ins;
- let AsmString = opcodestr # "\t" # argstr;
- let Pattern = pattern;
-
let TSFlags{4-0} = format.Value;
// Defaults
@@ -227,6 +208,27 @@
let TSFlags{20} = UsesVXRM;
}
+class RVInst<dag outs, dag ins, string opcodestr, string argstr,
+ list<dag> pattern, InstFormat format>
+ : RVInstCommon<format> {
+ field bits<32> Inst;
+ // SoftFail is a field the disassembler can use to provide a way for
+ // instructions to not match without killing the whole decode process. It is
+ // mainly used for ARM, but Tablegen expects this field to exist or it fails
+ // to build the decode table.
+ field bits<32> SoftFail = 0;
+ let Size = 4;
+
+ bits<7> Opcode = 0;
+
+ let Inst{6-0} = Opcode;
+
+ dag OutOperandList = outs;
+ dag InOperandList = ins;
+ let AsmString = opcodestr # "\t" # argstr;
+ let Pattern = pattern;
+}
+
// Pseudo instructions
class Pseudo<dag outs, dag ins, list<dag> pattern, string opcodestr = "", string argstr = "">
: RVInst<outs, ins, opcodestr, argstr, pattern, InstFormatPseudo> {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155744.542163.patch
Type: text/x-patch
Size: 2984 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230719/57d3894a/attachment.bin>
More information about the llvm-commits
mailing list