Skip to content

Commit f9f2bf8

Browse files
authored
[MSP430] TableGen-erate SDNode descriptions (#138878)
This consolidates node definitions into one place and enables automatic node verification. Part of #119709.
1 parent fd8b84e commit f9f2bf8

File tree

8 files changed

+66
-81
lines changed

8 files changed

+66
-81
lines changed

llvm/lib/Target/MSP430/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tablegen(LLVM MSP430GenDisassemblerTables.inc -gen-disassembler)
1010
tablegen(LLVM MSP430GenInstrInfo.inc -gen-instr-info)
1111
tablegen(LLVM MSP430GenMCCodeEmitter.inc -gen-emitter)
1212
tablegen(LLVM MSP430GenRegisterInfo.inc -gen-register-info)
13+
tablegen(LLVM MSP430GenSDNodeInfo.inc -gen-sd-node-info)
1314
tablegen(LLVM MSP430GenSubtargetInfo.inc -gen-subtarget)
1415

1516
add_public_tablegen_target(MSP430CommonTableGen)
@@ -22,6 +23,7 @@ add_llvm_target(MSP430CodeGen
2223
MSP430FrameLowering.cpp
2324
MSP430MachineFunctionInfo.cpp
2425
MSP430RegisterInfo.cpp
26+
MSP430SelectionDAGInfo.cpp
2527
MSP430Subtarget.cpp
2628
MSP430TargetMachine.cpp
2729
MSP430AsmPrinter.cpp

llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "MSP430.h"
14+
#include "MSP430SelectionDAGInfo.h"
1415
#include "MSP430TargetMachine.h"
1516
#include "llvm/CodeGen/MachineFrameInfo.h"
1617
#include "llvm/CodeGen/MachineFunction.h"

llvm/lib/Target/MSP430/MSP430ISelLowering.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "MSP430ISelLowering.h"
1414
#include "MSP430.h"
1515
#include "MSP430MachineFunctionInfo.h"
16+
#include "MSP430SelectionDAGInfo.h"
1617
#include "MSP430Subtarget.h"
1718
#include "MSP430TargetMachine.h"
1819
#include "llvm/CodeGen/CallingConvLower.h"
@@ -1361,27 +1362,6 @@ bool MSP430TargetLowering::getPostIndexedAddressParts(SDNode *N, SDNode *Op,
13611362
return false;
13621363
}
13631364

1364-
1365-
const char *MSP430TargetLowering::getTargetNodeName(unsigned Opcode) const {
1366-
switch ((MSP430ISD::NodeType)Opcode) {
1367-
case MSP430ISD::FIRST_NUMBER: break;
1368-
case MSP430ISD::RET_GLUE: return "MSP430ISD::RET_GLUE";
1369-
case MSP430ISD::RETI_GLUE: return "MSP430ISD::RETI_GLUE";
1370-
case MSP430ISD::RRA: return "MSP430ISD::RRA";
1371-
case MSP430ISD::RLA: return "MSP430ISD::RLA";
1372-
case MSP430ISD::RRC: return "MSP430ISD::RRC";
1373-
case MSP430ISD::RRCL: return "MSP430ISD::RRCL";
1374-
case MSP430ISD::CALL: return "MSP430ISD::CALL";
1375-
case MSP430ISD::Wrapper: return "MSP430ISD::Wrapper";
1376-
case MSP430ISD::BR_CC: return "MSP430ISD::BR_CC";
1377-
case MSP430ISD::CMP: return "MSP430ISD::CMP";
1378-
case MSP430ISD::SETCC: return "MSP430ISD::SETCC";
1379-
case MSP430ISD::SELECT_CC: return "MSP430ISD::SELECT_CC";
1380-
case MSP430ISD::DADD: return "MSP430ISD::DADD";
1381-
}
1382-
return nullptr;
1383-
}
1384-
13851365
bool MSP430TargetLowering::isTruncateFree(Type *Ty1,
13861366
Type *Ty2) const {
13871367
if (!Ty1->isIntegerTy() || !Ty2->isIntegerTy())

llvm/lib/Target/MSP430/MSP430ISelLowering.h

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,6 @@
1919
#include "llvm/CodeGen/TargetLowering.h"
2020

2121
namespace llvm {
22-
namespace MSP430ISD {
23-
enum NodeType : unsigned {
24-
FIRST_NUMBER = ISD::BUILTIN_OP_END,
25-
26-
/// Return with a glue operand. Operand 0 is the chain operand.
27-
RET_GLUE,
28-
29-
/// Same as RET_GLUE, but used for returning from ISRs.
30-
RETI_GLUE,
31-
32-
/// Y = R{R,L}A X, rotate right (left) arithmetically
33-
RRA, RLA,
34-
35-
/// Y = RRC X, rotate right via carry
36-
RRC,
37-
38-
/// Rotate right via carry, carry gets cleared beforehand by clrc
39-
RRCL,
40-
41-
/// CALL - These operations represent an abstract call
42-
/// instruction, which includes a bunch of information.
43-
CALL,
44-
45-
/// Wrapper - A wrapper node for TargetConstantPool, TargetExternalSymbol,
46-
/// and TargetGlobalAddress.
47-
Wrapper,
48-
49-
/// CMP - Compare instruction.
50-
CMP,
51-
52-
/// SetCC - Operand 0 is condition code, and operand 1 is the flag
53-
/// operand produced by a CMP instruction.
54-
SETCC,
55-
56-
/// MSP430 conditional branches. Operand 0 is the chain operand, operand 1
57-
/// is the block to branch if condition is true, operand 2 is the
58-
/// condition code, and operand 3 is the flag operand produced by a CMP
59-
/// instruction.
60-
BR_CC,
61-
62-
/// SELECT_CC - Operand 0 and operand 1 are selection variable, operand 3
63-
/// is condition code and operand 4 is flag operand.
64-
SELECT_CC,
65-
66-
/// DADD - Decimal addition with carry
67-
/// TODO Nothing generates a node of this type yet.
68-
DADD,
69-
};
70-
}
71-
7222
class MSP430Subtarget;
7323
class MSP430TargetLowering : public TargetLowering {
7424
public:
@@ -86,10 +36,6 @@ namespace llvm {
8636
/// LowerOperation - Provide custom lowering hooks for some operations.
8737
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
8838

89-
/// getTargetNodeName - This method returns the name of a target specific
90-
/// DAG node.
91-
const char *getTargetNodeName(unsigned Opcode) const override;
92-
9339
SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const;
9440
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
9541
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "MSP430SelectionDAGInfo.h"
10+
11+
#define GET_SDNODE_DESC
12+
#include "MSP430GenSDNodeInfo.inc"
13+
14+
using namespace llvm;
15+
16+
MSP430SelectionDAGInfo::MSP430SelectionDAGInfo()
17+
: SelectionDAGGenTargetInfo(MSP430GenSDNodeInfo) {}
18+
19+
MSP430SelectionDAGInfo::~MSP430SelectionDAGInfo() = default;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIB_TARGET_MSP430_MSP430SELECTIONDAGINFO_H
10+
#define LLVM_LIB_TARGET_MSP430_MSP430SELECTIONDAGINFO_H
11+
12+
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
13+
14+
#define GET_SDNODE_ENUM
15+
#include "MSP430GenSDNodeInfo.inc"
16+
17+
namespace llvm {
18+
19+
class MSP430SelectionDAGInfo : public SelectionDAGGenTargetInfo {
20+
public:
21+
MSP430SelectionDAGInfo();
22+
23+
~MSP430SelectionDAGInfo() override;
24+
};
25+
26+
} // namespace llvm
27+
28+
#endif // LLVM_LIB_TARGET_MSP430_MSP430SELECTIONDAGINFO_H

llvm/lib/Target/MSP430/MSP430Subtarget.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "MSP430Subtarget.h"
14+
#include "MSP430SelectionDAGInfo.h"
1415
#include "llvm/MC/TargetRegistry.h"
1516

1617
using namespace llvm;
@@ -58,4 +59,12 @@ MSP430Subtarget::MSP430Subtarget(const Triple &TT, const std::string &CPU,
5859
const std::string &FS, const TargetMachine &TM)
5960
: MSP430GenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
6061
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
61-
FrameLowering(*this) {}
62+
FrameLowering(*this) {
63+
TSInfo = std::make_unique<MSP430SelectionDAGInfo>();
64+
}
65+
66+
MSP430Subtarget::~MSP430Subtarget() = default;
67+
68+
const SelectionDAGTargetInfo *MSP430Subtarget::getSelectionDAGInfo() const {
69+
return TSInfo.get();
70+
}

llvm/lib/Target/MSP430/MSP430Subtarget.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "MSP430ISelLowering.h"
1818
#include "MSP430InstrInfo.h"
1919
#include "MSP430RegisterInfo.h"
20-
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
2120
#include "llvm/CodeGen/TargetSubtargetInfo.h"
2221
#include "llvm/IR/DataLayout.h"
2322
#include <string>
@@ -40,7 +39,7 @@ class MSP430Subtarget : public MSP430GenSubtargetInfo {
4039
HWMultEnum HWMultMode = NoHWMult;
4140
MSP430InstrInfo InstrInfo;
4241
MSP430TargetLowering TLInfo;
43-
SelectionDAGTargetInfo TSInfo;
42+
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
4443
MSP430FrameLowering FrameLowering;
4544

4645
public:
@@ -50,6 +49,8 @@ class MSP430Subtarget : public MSP430GenSubtargetInfo {
5049
MSP430Subtarget(const Triple &TT, const std::string &CPU,
5150
const std::string &FS, const TargetMachine &TM);
5251

52+
~MSP430Subtarget() override;
53+
5354
MSP430Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
5455

5556
/// ParseSubtargetFeatures - Parses features string setting specified
@@ -71,9 +72,8 @@ class MSP430Subtarget : public MSP430GenSubtargetInfo {
7172
const MSP430TargetLowering *getTargetLowering() const override {
7273
return &TLInfo;
7374
}
74-
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
75-
return &TSInfo;
76-
}
75+
76+
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
7777
};
7878
} // End llvm namespace
7979

0 commit comments

Comments
 (0)