Skip to content

Commit 828fcdc

Browse files
committed
[XCore] TableGen-erate SDNode descriptions
This consolidates node definitions into one place and allows automatic node verification. Part of #119709.
1 parent 5dd1421 commit 828fcdc

File tree

5 files changed

+15
-91
lines changed

5 files changed

+15
-91
lines changed

llvm/lib/Target/XCore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tablegen(LLVM XCoreGenDAGISel.inc -gen-dag-isel)
88
tablegen(LLVM XCoreGenDisassemblerTables.inc -gen-disassembler)
99
tablegen(LLVM XCoreGenInstrInfo.inc -gen-instr-info)
1010
tablegen(LLVM XCoreGenRegisterInfo.inc -gen-register-info)
11+
tablegen(LLVM XCoreGenSDNodeInfo.inc -gen-sd-node-info)
1112
tablegen(LLVM XCoreGenSubtargetInfo.inc -gen-subtarget)
1213

1314
add_public_tablegen_target(XCoreCommonTableGen)

llvm/lib/Target/XCore/XCoreISelLowering.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,6 @@ using namespace llvm;
4040

4141
#define DEBUG_TYPE "xcore-lower"
4242

43-
const char *XCoreTargetLowering::
44-
getTargetNodeName(unsigned Opcode) const
45-
{
46-
switch ((XCoreISD::NodeType)Opcode)
47-
{
48-
case XCoreISD::FIRST_NUMBER : break;
49-
case XCoreISD::BL : return "XCoreISD::BL";
50-
case XCoreISD::PCRelativeWrapper : return "XCoreISD::PCRelativeWrapper";
51-
case XCoreISD::DPRelativeWrapper : return "XCoreISD::DPRelativeWrapper";
52-
case XCoreISD::CPRelativeWrapper : return "XCoreISD::CPRelativeWrapper";
53-
case XCoreISD::LDWSP : return "XCoreISD::LDWSP";
54-
case XCoreISD::STWSP : return "XCoreISD::STWSP";
55-
case XCoreISD::RETSP : return "XCoreISD::RETSP";
56-
case XCoreISD::LADD : return "XCoreISD::LADD";
57-
case XCoreISD::LSUB : return "XCoreISD::LSUB";
58-
case XCoreISD::LMUL : return "XCoreISD::LMUL";
59-
case XCoreISD::MACCU : return "XCoreISD::MACCU";
60-
case XCoreISD::MACCS : return "XCoreISD::MACCS";
61-
case XCoreISD::CRC8 : return "XCoreISD::CRC8";
62-
case XCoreISD::BR_JT : return "XCoreISD::BR_JT";
63-
case XCoreISD::BR_JT32 : return "XCoreISD::BR_JT32";
64-
case XCoreISD::FRAME_TO_ARGS_OFFSET : return "XCoreISD::FRAME_TO_ARGS_OFFSET";
65-
case XCoreISD::EH_RETURN : return "XCoreISD::EH_RETURN";
66-
}
67-
return nullptr;
68-
}
69-
7043
XCoreTargetLowering::XCoreTargetLowering(const TargetMachine &TM,
7144
const XCoreSubtarget &Subtarget)
7245
: TargetLowering(TM), TM(TM), Subtarget(Subtarget) {

llvm/lib/Target/XCore/XCoreISelLowering.h

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -23,65 +23,6 @@ namespace llvm {
2323
// Forward delcarations
2424
class XCoreSubtarget;
2525

26-
namespace XCoreISD {
27-
enum NodeType : unsigned {
28-
// Start the numbering where the builtin ops and target ops leave off.
29-
FIRST_NUMBER = ISD::BUILTIN_OP_END,
30-
31-
// Branch and link (call)
32-
BL,
33-
34-
// pc relative address
35-
PCRelativeWrapper,
36-
37-
// dp relative address
38-
DPRelativeWrapper,
39-
40-
// cp relative address
41-
CPRelativeWrapper,
42-
43-
// Load word from stack
44-
LDWSP,
45-
46-
// Store word to stack
47-
STWSP,
48-
49-
// Corresponds to retsp instruction
50-
RETSP,
51-
52-
// Corresponds to LADD instruction
53-
LADD,
54-
55-
// Corresponds to LSUB instruction
56-
LSUB,
57-
58-
// Corresponds to LMUL instruction
59-
LMUL,
60-
61-
// Corresponds to MACCU instruction
62-
MACCU,
63-
64-
// Corresponds to MACCS instruction
65-
MACCS,
66-
67-
// Corresponds to CRC8 instruction
68-
CRC8,
69-
70-
// Jumptable branch.
71-
BR_JT,
72-
73-
// Jumptable branch using long branches for each entry.
74-
BR_JT32,
75-
76-
// Offset from frame pointer to the first (possible) on-stack argument
77-
FRAME_TO_ARGS_OFFSET,
78-
79-
// Exception handler return. The stack is restored to the first
80-
// followed by a jump to the second argument.
81-
EH_RETURN,
82-
};
83-
}
84-
8526
//===--------------------------------------------------------------------===//
8627
// TargetLowering Implementation
8728
//===--------------------------------------------------------------------===//
@@ -109,10 +50,6 @@ namespace llvm {
10950
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
11051
SelectionDAG &DAG) const override;
11152

112-
/// getTargetNodeName - This method returns the name of a target specific
113-
// DAG node.
114-
const char *getTargetNodeName(unsigned Opcode) const override;
115-
11653
MachineBasicBlock *
11754
EmitInstrWithCustomInserter(MachineInstr &MI,
11855
MachineBasicBlock *MBB) const override;

llvm/lib/Target/XCore/XCoreSelectionDAGInfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "XCoreSelectionDAGInfo.h"
1314
#include "XCoreTargetMachine.h"
15+
16+
#define GET_SDNODE_DESC
17+
#include "XCoreGenSDNodeInfo.inc"
18+
1419
using namespace llvm;
1520

1621
#define DEBUG_TYPE "xcore-selectiondag-info"
1722

23+
XCoreSelectionDAGInfo::XCoreSelectionDAGInfo()
24+
: SelectionDAGGenTargetInfo(XCoreGenSDNodeInfo) {}
25+
1826
SDValue XCoreSelectionDAGInfo::EmitTargetCodeForMemcpy(
1927
SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
2028
SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,

llvm/lib/Target/XCore/XCoreSelectionDAGInfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515

1616
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
1717

18+
#define GET_SDNODE_ENUM
19+
#include "XCoreGenSDNodeInfo.inc"
20+
1821
namespace llvm {
1922

20-
class XCoreSelectionDAGInfo : public SelectionDAGTargetInfo {
23+
class XCoreSelectionDAGInfo : public SelectionDAGGenTargetInfo {
2124
public:
25+
XCoreSelectionDAGInfo();
26+
2227
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
2328
SDValue Chain, SDValue Op1, SDValue Op2,
2429
SDValue Op3, Align Alignment, bool isVolatile,

0 commit comments

Comments
 (0)