Skip to content

Commit 05e94c9

Browse files
authored
[Xtensa] TableGen-erate SDNode descriptions (#166253)
Part of #119709.
1 parent 3f0ef27 commit 05e94c9

File tree

8 files changed

+66
-121
lines changed

8 files changed

+66
-121
lines changed

llvm/lib/Target/Xtensa/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tablegen(LLVM XtensaGenDisassemblerTables.inc -gen-disassembler)
1010
tablegen(LLVM XtensaGenInstrInfo.inc -gen-instr-info)
1111
tablegen(LLVM XtensaGenMCCodeEmitter.inc -gen-emitter)
1212
tablegen(LLVM XtensaGenRegisterInfo.inc -gen-register-info)
13+
tablegen(LLVM XtensaGenSDNodeInfo.inc -gen-sd-node-info)
1314
tablegen(LLVM XtensaGenSubtargetInfo.inc -gen-subtarget)
1415

1516
add_public_tablegen_target(XtensaCommonTableGen)
@@ -22,6 +23,7 @@ add_llvm_target(XtensaCodeGen
2223
XtensaISelDAGToDAG.cpp
2324
XtensaISelLowering.cpp
2425
XtensaRegisterInfo.cpp
26+
XtensaSelectionDAGInfo.cpp
2527
XtensaSubtarget.cpp
2628
XtensaTargetMachine.cpp
2729

llvm/lib/Target/Xtensa/XtensaISelDAGToDAG.cpp

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

1313
#include "MCTargetDesc/XtensaMCTargetDesc.h"
1414
#include "Xtensa.h"
15+
#include "XtensaSelectionDAGInfo.h"
1516
#include "XtensaTargetMachine.h"
1617
#include "llvm/CodeGen/MachineFunction.h"
1718
#include "llvm/CodeGen/MachineRegisterInfo.h"

llvm/lib/Target/Xtensa/XtensaISelLowering.cpp

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "XtensaConstantPoolValue.h"
1616
#include "XtensaInstrInfo.h"
1717
#include "XtensaMachineFunctionInfo.h"
18+
#include "XtensaSelectionDAGInfo.h"
1819
#include "XtensaSubtarget.h"
1920
#include "XtensaTargetMachine.h"
2021
#include "llvm/CodeGen/CallingConvLower.h"
@@ -1510,58 +1511,6 @@ SDValue XtensaTargetLowering::LowerOperation(SDValue Op,
15101511
}
15111512
}
15121513

1513-
const char *XtensaTargetLowering::getTargetNodeName(unsigned Opcode) const {
1514-
switch (Opcode) {
1515-
case XtensaISD::BR_JT:
1516-
return "XtensaISD::BR_JT";
1517-
case XtensaISD::CALL:
1518-
return "XtensaISD::CALL";
1519-
case XtensaISD::CALLW8:
1520-
return "XtensaISD::CALLW8";
1521-
case XtensaISD::EXTUI:
1522-
return "XtensaISD::EXTUI";
1523-
case XtensaISD::MOVSP:
1524-
return "XtensaISD::MOVSP";
1525-
case XtensaISD::PCREL_WRAPPER:
1526-
return "XtensaISD::PCREL_WRAPPER";
1527-
case XtensaISD::RET:
1528-
return "XtensaISD::RET";
1529-
case XtensaISD::RETW:
1530-
return "XtensaISD::RETW";
1531-
case XtensaISD::RUR:
1532-
return "XtensaISD::RUR";
1533-
case XtensaISD::SELECT_CC:
1534-
return "XtensaISD::SELECT_CC";
1535-
case XtensaISD::SELECT_CC_FP:
1536-
return "XtensaISD::SELECT_CC_FP";
1537-
case XtensaISD::SRCL:
1538-
return "XtensaISD::SRCL";
1539-
case XtensaISD::SRCR:
1540-
return "XtensaISD::SRCR";
1541-
case XtensaISD::CMPUO:
1542-
return "XtensaISD::CMPUO";
1543-
case XtensaISD::CMPUEQ:
1544-
return "XtensaISD::CMPUEQ";
1545-
case XtensaISD::CMPULE:
1546-
return "XtensaISD::CMPULE";
1547-
case XtensaISD::CMPULT:
1548-
return "XtensaISD::CMPULT";
1549-
case XtensaISD::CMPOEQ:
1550-
return "XtensaISD::CMPOEQ";
1551-
case XtensaISD::CMPOLE:
1552-
return "XtensaISD::CMPOLE";
1553-
case XtensaISD::CMPOLT:
1554-
return "XtensaISD::CMPOLT";
1555-
case XtensaISD::MADD:
1556-
return "XtensaISD::MADD";
1557-
case XtensaISD::MSUB:
1558-
return "XtensaISD::MSUB";
1559-
case XtensaISD::MOVS:
1560-
return "XtensaISD::MOVS";
1561-
}
1562-
return nullptr;
1563-
}
1564-
15651514
TargetLowering::AtomicExpansionKind
15661515
XtensaTargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
15671516
return AtomicExpansionKind::CmpXChg;

llvm/lib/Target/Xtensa/XtensaISelLowering.h

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -20,67 +20,6 @@
2020

2121
namespace llvm {
2222

23-
namespace XtensaISD {
24-
enum {
25-
FIRST_NUMBER = ISD::BUILTIN_OP_END,
26-
BR_JT,
27-
28-
// Calls a function. Operand 0 is the chain operand and operand 1
29-
// is the target address. The arguments start at operand 2.
30-
// There is an optional glue operand at the end.
31-
CALL,
32-
// Call with rotation window by 8 registers
33-
CALLW8,
34-
35-
// Extract unsigned immediate. Operand 0 is value, operand 1
36-
// is bit position of the field [0..31], operand 2 is bit size
37-
// of the field [1..16]
38-
EXTUI,
39-
40-
MOVSP,
41-
42-
// Wraps a TargetGlobalAddress that should be loaded using PC-relative
43-
// accesses. Operand 0 is the address.
44-
PCREL_WRAPPER,
45-
RET,
46-
RETW,
47-
48-
RUR,
49-
50-
// Select with condition operator - This selects between a true value and
51-
// a false value (ops #2 and #3) based on the boolean result of comparing
52-
// the lhs and rhs (ops #0 and #1) of a conditional expression with the
53-
// condition code in op #4
54-
SELECT_CC,
55-
// Select with condition operator - This selects between a true value and
56-
// a false value (ops #2 and #3) based on the boolean result of comparing
57-
// f32 operands lhs and rhs (ops #0 and #1) of a conditional expression
58-
// with the condition code in op #4 and boolean branch kind in op #5
59-
SELECT_CC_FP,
60-
61-
// SRCL(R) performs shift left(right) of the concatenation of 2 registers
62-
// and returns high(low) 32-bit part of 64-bit result
63-
SRCL,
64-
// Shift Right Combined
65-
SRCR,
66-
67-
// Floating point unordered compare conditions
68-
CMPUEQ,
69-
CMPULE,
70-
CMPULT,
71-
CMPUO,
72-
// Floating point compare conditions
73-
CMPOEQ,
74-
CMPOLE,
75-
CMPOLT,
76-
// FP multipy-add/sub
77-
MADD,
78-
MSUB,
79-
// FP move
80-
MOVS,
81-
};
82-
}
83-
8423
class XtensaSubtarget;
8524

8625
class XtensaTargetLowering : public TargetLowering {
@@ -104,8 +43,6 @@ class XtensaTargetLowering : public TargetLowering {
10443

10544
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
10645

107-
const char *getTargetNodeName(unsigned Opcode) const override;
108-
10946
bool isFPImmLegal(const APFloat &Imm, EVT VT,
11047
bool ForCodeSize) const override;
11148

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 "XtensaSelectionDAGInfo.h"
10+
11+
#define GET_SDNODE_DESC
12+
#include "XtensaGenSDNodeInfo.inc"
13+
14+
using namespace llvm;
15+
16+
XtensaSelectionDAGInfo::XtensaSelectionDAGInfo()
17+
: SelectionDAGGenTargetInfo(XtensaGenSDNodeInfo) {}
18+
19+
XtensaSelectionDAGInfo::~XtensaSelectionDAGInfo() = 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_XTENSA_XTENSASELECTIONDAGINFO_H
10+
#define LLVM_LIB_TARGET_XTENSA_XTENSASELECTIONDAGINFO_H
11+
12+
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
13+
14+
#define GET_SDNODE_ENUM
15+
#include "XtensaGenSDNodeInfo.inc"
16+
17+
namespace llvm {
18+
19+
class XtensaSelectionDAGInfo : public SelectionDAGGenTargetInfo {
20+
public:
21+
XtensaSelectionDAGInfo();
22+
23+
~XtensaSelectionDAGInfo() override;
24+
};
25+
26+
} // namespace llvm
27+
28+
#endif // LLVM_LIB_TARGET_XTENSA_XTENSASELECTIONDAGINFO_H

llvm/lib/Target/Xtensa/XtensaSubtarget.cpp

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

1313
#include "XtensaSubtarget.h"
14+
#include "XtensaSelectionDAGInfo.h"
1415
#include "llvm/IR/GlobalValue.h"
1516
#include "llvm/Support/Debug.h"
1617

@@ -39,4 +40,12 @@ XtensaSubtarget::XtensaSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
3940
const TargetMachine &TM)
4041
: XtensaGenSubtargetInfo(TT, CPU, /*TuneCPU=*/CPU, FS), TargetTriple(TT),
4142
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
42-
TSInfo(), FrameLowering(*this) {}
43+
FrameLowering(*this) {
44+
TSInfo = std::make_unique<SelectionDAGTargetInfo>();
45+
}
46+
47+
XtensaSubtarget::~XtensaSubtarget() = default;
48+
49+
const SelectionDAGTargetInfo *XtensaSubtarget::getSelectionDAGInfo() const {
50+
return TSInfo.get();
51+
}

llvm/lib/Target/Xtensa/XtensaSubtarget.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "XtensaISelLowering.h"
1818
#include "XtensaInstrInfo.h"
1919
#include "XtensaRegisterInfo.h"
20-
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
2120
#include "llvm/CodeGen/TargetSubtargetInfo.h"
2221
#include "llvm/IR/DataLayout.h"
2322
#include "llvm/Target/TargetMachine.h"
@@ -38,7 +37,7 @@ class XtensaSubtarget : public XtensaGenSubtargetInfo {
3837
const Triple &TargetTriple;
3938
XtensaInstrInfo InstrInfo;
4039
XtensaTargetLowering TLInfo;
41-
SelectionDAGTargetInfo TSInfo;
40+
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
4241
XtensaFrameLowering FrameLowering;
4342

4443
XtensaSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
@@ -47,6 +46,8 @@ class XtensaSubtarget : public XtensaGenSubtargetInfo {
4746
XtensaSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
4847
const TargetMachine &TM);
4948

49+
~XtensaSubtarget() override;
50+
5051
const Triple &getTargetTriple() const { return TargetTriple; }
5152

5253
const TargetFrameLowering *getFrameLowering() const override {
@@ -60,9 +61,8 @@ class XtensaSubtarget : public XtensaGenSubtargetInfo {
6061
const XtensaTargetLowering *getTargetLowering() const override {
6162
return &TLInfo;
6263
}
63-
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
64-
return &TSInfo;
65-
}
64+
65+
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
6666

6767
bool hasDensity() const { return HasDensity; }
6868
bool hasMAC16() const { return HasMAC16; }

0 commit comments

Comments
 (0)