Skip to content

[ARC][CSKY][Lanai] TableGen-erate SDNode descriptions #138874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/lib/Target/ARC/ARCISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "ARC.h"
#include "ARCSelectionDAGInfo.h"
#include "ARCTargetMachine.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
Expand Down
19 changes: 1 addition & 18 deletions llvm/lib/Target/ARC/ARCISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ARCISelLowering.h"
#include "ARC.h"
#include "ARCMachineFunctionInfo.h"
#include "ARCSelectionDAGInfo.h"
#include "ARCSubtarget.h"
#include "ARCTargetMachine.h"
#include "MCTargetDesc/ARCInfo.h"
Expand Down Expand Up @@ -178,24 +179,6 @@ ARCTargetLowering::ARCTargetLowering(const TargetMachine &TM,
setMaxAtomicSizeInBitsSupported(0);
}

const char *ARCTargetLowering::getTargetNodeName(unsigned Opcode) const {
switch (Opcode) {
case ARCISD::BL:
return "ARCISD::BL";
case ARCISD::CMOV:
return "ARCISD::CMOV";
case ARCISD::CMP:
return "ARCISD::CMP";
case ARCISD::BRcc:
return "ARCISD::BRcc";
case ARCISD::RET:
return "ARCISD::RET";
case ARCISD::GAWRAPPER:
return "ARCISD::GAWRAPPER";
}
return nullptr;
}

//===----------------------------------------------------------------------===//
// Misc Lower Operation implementation
//===----------------------------------------------------------------------===//
Expand Down
33 changes: 0 additions & 33 deletions llvm/lib/Target/ARC/ARCISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,6 @@ namespace llvm {
class ARCSubtarget;
class ARCTargetMachine;

namespace ARCISD {

enum NodeType : unsigned {
// Start the numbering where the builtin ops and target ops leave off.
FIRST_NUMBER = ISD::BUILTIN_OP_END,

// Branch and link (call)
BL,

// Jump and link (indirect call)
JL,

// CMP
CMP,

// CMOV
CMOV,

// BRcc
BRcc,

// Global Address Wrapper
GAWRAPPER,

// return, (j_s [blink])
RET
};

} // end namespace ARCISD

//===--------------------------------------------------------------------===//
// TargetLowering Implementation
//===--------------------------------------------------------------------===//
Expand All @@ -65,9 +35,6 @@ class ARCTargetLowering : public TargetLowering {
/// Provide custom lowering hooks for some operations.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;

/// This method returns the name of a target specific DAG node.
const char *getTargetNodeName(unsigned Opcode) const override;

/// Return true if the addressing mode represented by AM is legal for this
/// target, for a load/store of the specified type.
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
Expand Down
19 changes: 19 additions & 0 deletions llvm/lib/Target/ARC/ARCSelectionDAGInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "ARCSelectionDAGInfo.h"

#define GET_SDNODE_DESC
#include "ARCGenSDNodeInfo.inc"

using namespace llvm;

ARCSelectionDAGInfo::ARCSelectionDAGInfo()
: SelectionDAGGenTargetInfo(ARCGenSDNodeInfo) {}

ARCSelectionDAGInfo::~ARCSelectionDAGInfo() = default;
28 changes: 28 additions & 0 deletions llvm/lib/Target/ARC/ARCSelectionDAGInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_TARGET_ARC_ARCSELECTIONDAGINFO_H
#define LLVM_LIB_TARGET_ARC_ARCSELECTIONDAGINFO_H

#include "llvm/CodeGen/SelectionDAGTargetInfo.h"

#define GET_SDNODE_ENUM
#include "ARCGenSDNodeInfo.inc"

namespace llvm {

class ARCSelectionDAGInfo : public SelectionDAGGenTargetInfo {
public:
ARCSelectionDAGInfo();

~ARCSelectionDAGInfo() override;
};

} // namespace llvm

#endif // LLVM_LIB_TARGET_ARC_ARCSELECTIONDAGINFO_H
11 changes: 10 additions & 1 deletion llvm/lib/Target/ARC/ARCSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "ARCSubtarget.h"
#include "ARC.h"
#include "ARCSelectionDAGInfo.h"
#include "llvm/MC/TargetRegistry.h"

using namespace llvm;
Expand All @@ -27,4 +28,12 @@ void ARCSubtarget::anchor() {}
ARCSubtarget::ARCSubtarget(const Triple &TT, const std::string &CPU,
const std::string &FS, const TargetMachine &TM)
: ARCGenSubtargetInfo(TT, CPU, /*TuneCPU=*/CPU, FS), InstrInfo(*this),
FrameLowering(*this), TLInfo(TM, *this) {}
FrameLowering(*this), TLInfo(TM, *this) {
TSInfo = std::make_unique<ARCSelectionDAGInfo>();
}

ARCSubtarget::~ARCSubtarget() = default;

const SelectionDAGTargetInfo *ARCSubtarget::getSelectionDAGInfo() const {
return TSInfo.get();
}
10 changes: 5 additions & 5 deletions llvm/lib/Target/ARC/ARCSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "ARCFrameLowering.h"
#include "ARCISelLowering.h"
#include "ARCInstrInfo.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include <string>

Expand All @@ -33,7 +32,7 @@ class ARCSubtarget : public ARCGenSubtargetInfo {
ARCInstrInfo InstrInfo;
ARCFrameLowering FrameLowering;
ARCTargetLowering TLInfo;
SelectionDAGTargetInfo TSInfo;
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;

// ARC processor extensions
bool Xnorm = false;
Expand All @@ -44,6 +43,8 @@ class ARCSubtarget : public ARCGenSubtargetInfo {
ARCSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
const TargetMachine &TM);

~ARCSubtarget() override;

/// Parses features string setting specified subtarget options.
/// Definition of function is auto generated by tblgen.
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
Expand All @@ -58,9 +59,8 @@ class ARCSubtarget : public ARCGenSubtargetInfo {
const ARCRegisterInfo *getRegisterInfo() const override {
return &InstrInfo.getRegisterInfo();
}
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
return &TSInfo;
}

const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;

bool hasNorm() const { return Xnorm; }
};
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/ARC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tablegen(LLVM ARCGenDAGISel.inc -gen-dag-isel)
tablegen(LLVM ARCGenDisassemblerTables.inc -gen-disassembler)
tablegen(LLVM ARCGenInstrInfo.inc -gen-instr-info)
tablegen(LLVM ARCGenRegisterInfo.inc -gen-register-info)
tablegen(LLVM ARCGenSDNodeInfo.inc -gen-sd-node-info)
tablegen(LLVM ARCGenSubtargetInfo.inc -gen-subtarget)

add_public_tablegen_target(ARCCommonTableGen)
Expand All @@ -24,6 +25,7 @@ add_llvm_target(ARCCodeGen
ARCMCInstLower.cpp
ARCOptAddrMode.cpp
ARCRegisterInfo.cpp
ARCSelectionDAGInfo.cpp
ARCSubtarget.cpp
ARCTargetMachine.cpp

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/CSKY/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tablegen(LLVM CSKYGenInstrInfo.inc -gen-instr-info)
tablegen(LLVM CSKYGenMCCodeEmitter.inc -gen-emitter)
tablegen(LLVM CSKYGenMCPseudoLowering.inc -gen-pseudo-lowering)
tablegen(LLVM CSKYGenRegisterInfo.inc -gen-register-info)
tablegen(LLVM CSKYGenSDNodeInfo.inc -gen-sd-node-info)
tablegen(LLVM CSKYGenSubtargetInfo.inc -gen-subtarget)

add_public_tablegen_target(CSKYCommonTableGen)
Expand All @@ -26,6 +27,7 @@ add_llvm_target(CSKYCodeGen
CSKYISelLowering.cpp
CSKYMCInstLower.cpp
CSKYRegisterInfo.cpp
CSKYSelectionDAGInfo.cpp
CSKYSubtarget.cpp
CSKYTargetMachine.cpp
CSKYTargetObjectFile.cpp
Expand Down
27 changes: 0 additions & 27 deletions llvm/lib/Target/CSKY/CSKYISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,33 +1117,6 @@ SDValue CSKYTargetLowering::getTargetNode(ConstantPoolSDNode *N, SDLoc DL,
N->getOffset(), Flags);
}

const char *CSKYTargetLowering::getTargetNodeName(unsigned Opcode) const {
switch (Opcode) {
default:
llvm_unreachable("unknown CSKYISD node");
case CSKYISD::NIE:
return "CSKYISD::NIE";
case CSKYISD::NIR:
return "CSKYISD::NIR";
case CSKYISD::RET:
return "CSKYISD::RET";
case CSKYISD::CALL:
return "CSKYISD::CALL";
case CSKYISD::CALLReg:
return "CSKYISD::CALLReg";
case CSKYISD::TAIL:
return "CSKYISD::TAIL";
case CSKYISD::TAILReg:
return "CSKYISD::TAILReg";
case CSKYISD::LOAD_ADDR:
return "CSKYISD::LOAD_ADDR";
case CSKYISD::BITCAST_TO_LOHI:
return "CSKYISD::BITCAST_TO_LOHI";
case CSKYISD::BITCAST_FROM_LOHI:
return "CSKYISD::BITCAST_FROM_LOHI";
}
}

SDValue CSKYTargetLowering::LowerGlobalAddress(SDValue Op,
SelectionDAG &DAG) const {
SDLoc DL(Op);
Expand Down
21 changes: 1 addition & 20 deletions llvm/lib/Target/CSKY/CSKYISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,14 @@
#ifndef LLVM_LIB_TARGET_CSKY_CSKYISELLOWERING_H
#define LLVM_LIB_TARGET_CSKY_CSKYISELLOWERING_H

#include "CSKYSelectionDAGInfo.h"
#include "MCTargetDesc/CSKYBaseInfo.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/TargetLowering.h"

namespace llvm {
class CSKYSubtarget;

namespace CSKYISD {
enum NodeType : unsigned {
FIRST_NUMBER = ISD::BUILTIN_OP_END,
NIE,
NIR,
RET,
CALL,
CALLReg,
TAIL,
TAILReg,
LOAD_ADDR,
// i32, i32 <-- f64
BITCAST_TO_LOHI,
// f64 < -- i32, i32
BITCAST_FROM_LOHI,
};
}

class CSKYTargetLowering : public TargetLowering {
const CSKYSubtarget &Subtarget;

Expand Down Expand Up @@ -71,8 +54,6 @@ class CSKYTargetLowering : public TargetLowering {
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
SmallVectorImpl<SDValue> &InVals) const override;

const char *getTargetNodeName(unsigned Opcode) const override;

/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
Expand Down
19 changes: 19 additions & 0 deletions llvm/lib/Target/CSKY/CSKYSelectionDAGInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "CSKYSelectionDAGInfo.h"

#define GET_SDNODE_DESC
#include "CSKYGenSDNodeInfo.inc"

using namespace llvm;

CSKYSelectionDAGInfo::CSKYSelectionDAGInfo()
: SelectionDAGGenTargetInfo(CSKYGenSDNodeInfo) {}

CSKYSelectionDAGInfo::~CSKYSelectionDAGInfo() = default;
28 changes: 28 additions & 0 deletions llvm/lib/Target/CSKY/CSKYSelectionDAGInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_TARGET_CSKY_CSKYSELECTIONDAGINFO_H
#define LLVM_LIB_TARGET_CSKY_CSKYSELECTIONDAGINFO_H

#include "llvm/CodeGen/SelectionDAGTargetInfo.h"

#define GET_SDNODE_ENUM
#include "CSKYGenSDNodeInfo.inc"

namespace llvm {

class CSKYSelectionDAGInfo : public SelectionDAGGenTargetInfo {
public:
CSKYSelectionDAGInfo();

~CSKYSelectionDAGInfo() override;
};

} // namespace llvm

#endif // LLVM_LIB_TARGET_CSKY_CSKYSELECTIONDAGINFO_H
11 changes: 10 additions & 1 deletion llvm/lib/Target/CSKY/CSKYSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "CSKYSubtarget.h"
#include "CSKYSelectionDAGInfo.h"
#include "llvm/CodeGen/MachineFrameInfo.h"

using namespace llvm;
Expand Down Expand Up @@ -91,7 +92,15 @@ CSKYSubtarget::CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
StringRef FS, const TargetMachine &TM)
: CSKYGenSubtargetInfo(TT, CPU, TuneCPU, FS),
FrameLowering(initializeSubtargetDependencies(TT, CPU, TuneCPU, FS)),
InstrInfo(*this), RegInfo(), TLInfo(TM, *this) {}
InstrInfo(*this), RegInfo(), TLInfo(TM, *this) {
TSInfo = std::make_unique<CSKYSelectionDAGInfo>();
}

CSKYSubtarget::~CSKYSubtarget() = default;

const SelectionDAGTargetInfo *CSKYSubtarget::getSelectionDAGInfo() const {
return TSInfo.get();
}

bool CSKYSubtarget::useHardFloatABI() const {
auto FloatABI = getTargetLowering()->getTargetMachine().Options.FloatABIType;
Expand Down
Loading