Skip to content

Commit 7aa6737

Browse files
authored
[Sparc] TableGen-erate SDNode descriptions (llvm#138450)
Part of llvm#119709.
1 parent 29e4fb6 commit 7aa6737

9 files changed

+69
-90
lines changed

llvm/lib/Target/Sparc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tablegen(LLVM SparcGenDisassemblerTables.inc -gen-disassembler)
1010
tablegen(LLVM SparcGenInstrInfo.inc -gen-instr-info)
1111
tablegen(LLVM SparcGenMCCodeEmitter.inc -gen-emitter)
1212
tablegen(LLVM SparcGenRegisterInfo.inc -gen-register-info)
13+
tablegen(LLVM SparcGenSDNodeInfo.inc -gen-sd-node-info -sdnode-namespace=SPISD)
1314
tablegen(LLVM SparcGenSearchableTables.inc -gen-searchable-tables)
1415
tablegen(LLVM SparcGenSubtargetInfo.inc -gen-subtarget)
1516

@@ -25,6 +26,7 @@ add_llvm_target(SparcCodeGen
2526
SparcFrameLowering.cpp
2627
SparcMachineFunctionInfo.cpp
2728
SparcRegisterInfo.cpp
29+
SparcSelectionDAGInfo.cpp
2830
SparcSubtarget.cpp
2931
SparcTargetMachine.cpp
3032
SparcTargetObjectFile.cpp

llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp

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

13+
#include "SparcSelectionDAGInfo.h"
1314
#include "SparcTargetMachine.h"
1415
#include "llvm/CodeGen/MachineRegisterInfo.h"
1516
#include "llvm/CodeGen/SelectionDAGISel.h"

llvm/lib/Target/Sparc/SparcISelLowering.cpp

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "MCTargetDesc/SparcMCTargetDesc.h"
1717
#include "SparcMachineFunctionInfo.h"
1818
#include "SparcRegisterInfo.h"
19+
#include "SparcSelectionDAGInfo.h"
1920
#include "SparcTargetMachine.h"
2021
#include "SparcTargetObjectFile.h"
2122
#include "llvm/ADT/StringExtras.h"
@@ -2034,47 +2035,6 @@ bool SparcTargetLowering::useSoftFloat() const {
20342035
return Subtarget->useSoftFloat();
20352036
}
20362037

2037-
const char *SparcTargetLowering::getTargetNodeName(unsigned Opcode) const {
2038-
switch ((SPISD::NodeType)Opcode) {
2039-
case SPISD::FIRST_NUMBER: break;
2040-
case SPISD::CMPICC: return "SPISD::CMPICC";
2041-
case SPISD::CMPFCC: return "SPISD::CMPFCC";
2042-
case SPISD::CMPFCC_V9:
2043-
return "SPISD::CMPFCC_V9";
2044-
case SPISD::BRICC: return "SPISD::BRICC";
2045-
case SPISD::BPICC:
2046-
return "SPISD::BPICC";
2047-
case SPISD::BPXCC:
2048-
return "SPISD::BPXCC";
2049-
case SPISD::BRFCC: return "SPISD::BRFCC";
2050-
case SPISD::BRFCC_V9:
2051-
return "SPISD::BRFCC_V9";
2052-
case SPISD::BR_REG:
2053-
return "SPISD::BR_REG";
2054-
case SPISD::SELECT_ICC: return "SPISD::SELECT_ICC";
2055-
case SPISD::SELECT_XCC: return "SPISD::SELECT_XCC";
2056-
case SPISD::SELECT_FCC: return "SPISD::SELECT_FCC";
2057-
case SPISD::SELECT_REG:
2058-
return "SPISD::SELECT_REG";
2059-
case SPISD::Hi: return "SPISD::Hi";
2060-
case SPISD::Lo: return "SPISD::Lo";
2061-
case SPISD::FTOI: return "SPISD::FTOI";
2062-
case SPISD::ITOF: return "SPISD::ITOF";
2063-
case SPISD::FTOX: return "SPISD::FTOX";
2064-
case SPISD::XTOF: return "SPISD::XTOF";
2065-
case SPISD::CALL: return "SPISD::CALL";
2066-
case SPISD::RET_GLUE: return "SPISD::RET_GLUE";
2067-
case SPISD::GLOBAL_BASE_REG: return "SPISD::GLOBAL_BASE_REG";
2068-
case SPISD::FLUSHW: return "SPISD::FLUSHW";
2069-
case SPISD::TLS_ADD: return "SPISD::TLS_ADD";
2070-
case SPISD::TLS_LD: return "SPISD::TLS_LD";
2071-
case SPISD::TLS_CALL: return "SPISD::TLS_CALL";
2072-
case SPISD::TAIL_CALL: return "SPISD::TAIL_CALL";
2073-
case SPISD::LOAD_GDOP: return "SPISD::LOAD_GDOP";
2074-
}
2075-
return nullptr;
2076-
}
2077-
20782038
EVT SparcTargetLowering::getSetCCResultType(const DataLayout &, LLVMContext &,
20792039
EVT VT) const {
20802040
if (!VT.isVector())

llvm/lib/Target/Sparc/SparcISelLowering.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,6 @@
2020
namespace llvm {
2121
class SparcSubtarget;
2222

23-
namespace SPISD {
24-
enum NodeType : unsigned {
25-
FIRST_NUMBER = ISD::BUILTIN_OP_END,
26-
CMPICC, // Compare two GPR operands, set icc+xcc.
27-
CMPFCC, // Compare two FP operands, set fcc.
28-
CMPFCC_V9, // Compare two FP operands, set fcc (v9 variant).
29-
BRICC, // Branch to dest on icc condition
30-
BPICC, // Branch to dest on icc condition, with prediction (64-bit only).
31-
BPXCC, // Branch to dest on xcc condition, with prediction (64-bit only).
32-
BRFCC, // Branch to dest on fcc condition
33-
BRFCC_V9, // Branch to dest on fcc condition (v9 variant).
34-
BR_REG, // Branch to dest using the comparison of a register with zero.
35-
SELECT_ICC, // Select between two values using the current ICC flags.
36-
SELECT_XCC, // Select between two values using the current XCC flags.
37-
SELECT_FCC, // Select between two values using the current FCC flags.
38-
SELECT_REG, // Select between two values using the comparison of a register
39-
// with zero.
40-
41-
Hi,
42-
Lo, // Hi/Lo operations, typically on a global address.
43-
44-
FTOI, // FP to Int within a FP register.
45-
ITOF, // Int to FP within a FP register.
46-
FTOX, // FP to Int64 within a FP register.
47-
XTOF, // Int64 to FP within a FP register.
48-
49-
CALL, // A call instruction.
50-
RET_GLUE, // Return with a glue operand.
51-
GLOBAL_BASE_REG, // Global base reg for PIC.
52-
FLUSHW, // FLUSH register windows to stack.
53-
54-
TAIL_CALL, // Tail call
55-
56-
TLS_ADD, // For Thread Local Storage (TLS).
57-
TLS_LD,
58-
TLS_CALL,
59-
60-
LOAD_GDOP, // Load operation w/ gdop relocation.
61-
};
62-
}
63-
6423
class SparcTargetLowering : public TargetLowering {
6524
const SparcSubtarget *Subtarget;
6625
public:
@@ -82,8 +41,6 @@ namespace llvm {
8241
EmitInstrWithCustomInserter(MachineInstr &MI,
8342
MachineBasicBlock *MBB) const override;
8443

85-
const char *getTargetNodeName(unsigned Opcode) const override;
86-
8744
ConstraintType getConstraintType(StringRef Constraint) const override;
8845
ConstraintWeight
8946
getSingleConstraintMatchWeight(AsmOperandInfo &info,

llvm/lib/Target/Sparc/SparcInstrInfo.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ def SDT_SPRet : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
321321
def retglue : SDNode<"SPISD::RET_GLUE", SDT_SPRet,
322322
[SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
323323

324+
def global_base_reg : SDNode<"SPISD::GLOBAL_BASE_REG",
325+
SDTypeProfile<1, 0, [SDTCisVT<0, iPTR>]>>;
326+
324327
def flushw : SDNode<"SPISD::FLUSHW", SDTNone,
325328
[SDNPHasChain, SDNPSideEffect, SDNPMayStore]>;
326329

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

llvm/lib/Target/Sparc/SparcSubtarget.cpp

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

1313
#include "SparcSubtarget.h"
14+
#include "SparcSelectionDAGInfo.h"
1415
#include "llvm/ADT/StringRef.h"
1516
#include "llvm/MC/TargetRegistry.h"
1617
#include "llvm/Support/MathExtras.h"
@@ -52,7 +53,15 @@ SparcSubtarget::SparcSubtarget(const StringRef &CPU, const StringRef &TuneCPU,
5253
ReserveRegister(TM.getMCRegisterInfo()->getNumRegs()),
5354
TargetTriple(TM.getTargetTriple()), Is64Bit(is64Bit),
5455
InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
55-
TLInfo(TM, *this), FrameLowering(*this) {}
56+
TLInfo(TM, *this), FrameLowering(*this) {
57+
TSInfo = std::make_unique<SparcSelectionDAGInfo>();
58+
}
59+
60+
SparcSubtarget::~SparcSubtarget() = default;
61+
62+
const SelectionDAGTargetInfo *SparcSubtarget::getSelectionDAGInfo() const {
63+
return TSInfo.get();
64+
}
5665

5766
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
5867

llvm/lib/Target/Sparc/SparcSubtarget.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "SparcFrameLowering.h"
1818
#include "SparcISelLowering.h"
1919
#include "SparcInstrInfo.h"
20-
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
2120
#include "llvm/CodeGen/TargetSubtargetInfo.h"
2221
#include "llvm/IR/DataLayout.h"
2322
#include "llvm/Support/ErrorHandling.h"
@@ -46,13 +45,15 @@ class SparcSubtarget : public SparcGenSubtargetInfo {
4645

4746
SparcInstrInfo InstrInfo;
4847
SparcTargetLowering TLInfo;
49-
SelectionDAGTargetInfo TSInfo;
48+
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
5049
SparcFrameLowering FrameLowering;
5150

5251
public:
5352
SparcSubtarget(const StringRef &CPU, const StringRef &TuneCPU,
5453
const StringRef &FS, const TargetMachine &TM, bool is64bit);
5554

55+
~SparcSubtarget() override;
56+
5657
const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
5758
const TargetFrameLowering *getFrameLowering() const override {
5859
return &FrameLowering;
@@ -63,9 +64,8 @@ class SparcSubtarget : public SparcGenSubtargetInfo {
6364
const SparcTargetLowering *getTargetLowering() const override {
6465
return &TLInfo;
6566
}
66-
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
67-
return &TSInfo;
68-
}
67+
68+
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
6969

7070
bool enableMachineScheduler() const override;
7171

0 commit comments

Comments
 (0)