Skip to content

Commit c60db55

Browse files
lenarys-barannikov
andauthored
[RISCV] TableGen-erate RISC-V SDNodes (#138381)
This commit moves RISC-V to auto-generate its target-specific SDNode types. The biggest change is that SDNodes can now be validated against their expected type profiles, and that we don't need to edit several different files when declaring a new one. This takes Sergei's work in #119709 and "finishes" it - by moving the final five RISCVISD opcodes into tablegen (including defining their types), and by ensuring the tablegen has expected closing scope comments. Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
1 parent 8c6c525 commit c60db55

25 files changed

+776
-1253
lines changed

llvm/include/llvm/CodeGen/SDNodeInfo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ struct SDTypeConstraint {
5555
MVT::SimpleValueType VT;
5656
};
5757

58+
using SDNodeTSFlags = uint32_t;
59+
5860
struct SDNodeDesc {
5961
uint16_t NumResults;
6062
int16_t NumOperands;
6163
uint32_t Properties;
6264
uint32_t Flags;
63-
uint32_t TSFlags;
65+
SDNodeTSFlags TSFlags;
6466
unsigned NameOffset;
6567
unsigned ConstraintOffset;
6668
unsigned ConstraintCount;

llvm/lib/Target/RISCV/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tablegen(LLVM RISCVGenRegisterInfo.inc -gen-register-info)
1616
tablegen(LLVM RISCVGenSearchableTables.inc -gen-searchable-tables)
1717
tablegen(LLVM RISCVGenSubtargetInfo.inc -gen-subtarget)
1818
tablegen(LLVM RISCVGenExegesis.inc -gen-exegesis)
19+
tablegen(LLVM RISCVGenSDNodeInfo.inc -gen-sd-node-info)
1920

2021
set(LLVM_TARGET_DEFINITIONS RISCVGISel.td)
2122
tablegen(LLVM RISCVGenGlobalISel.inc -gen-global-isel)

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "MCTargetDesc/RISCVMatInt.h"
1717
#include "RISCVISelLowering.h"
1818
#include "RISCVInstrInfo.h"
19+
#include "RISCVSelectionDAGInfo.h"
1920
#include "llvm/CodeGen/MachineFrameInfo.h"
2021
#include "llvm/IR/IntrinsicsRISCV.h"
2122
#include "llvm/Support/Alignment.h"
@@ -34,6 +35,9 @@ static cl::opt<bool> UsePseudoMovImm(
3435
"constant materialization"),
3536
cl::init(false));
3637

38+
#define GET_DAGISEL_BODY RISCVDAGToDAGISel
39+
#include "RISCVGenDAGISel.inc"
40+
3741
void RISCVDAGToDAGISel::PreprocessISelDAG() {
3842
SelectionDAG::allnodes_iterator Position = CurDAG->allnodes_end();
3943

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class RISCVDAGToDAGISel : public SelectionDAGISel {
191191
}
192192

193193
// Include the pieces autogenerated from the target description.
194+
#define GET_DAGISEL_DECL
194195
#include "RISCVGenDAGISel.inc"
195196

196197
private:

0 commit comments

Comments
 (0)