Skip to content

[MSP430] TableGen-erate SDNode descriptions #138878

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 1 commit into from
May 9, 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
2 changes: 2 additions & 0 deletions llvm/lib/Target/MSP430/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tablegen(LLVM MSP430GenDisassemblerTables.inc -gen-disassembler)
tablegen(LLVM MSP430GenInstrInfo.inc -gen-instr-info)
tablegen(LLVM MSP430GenMCCodeEmitter.inc -gen-emitter)
tablegen(LLVM MSP430GenRegisterInfo.inc -gen-register-info)
tablegen(LLVM MSP430GenSDNodeInfo.inc -gen-sd-node-info)
tablegen(LLVM MSP430GenSubtargetInfo.inc -gen-subtarget)

add_public_tablegen_target(MSP430CommonTableGen)
Expand All @@ -22,6 +23,7 @@ add_llvm_target(MSP430CodeGen
MSP430FrameLowering.cpp
MSP430MachineFunctionInfo.cpp
MSP430RegisterInfo.cpp
MSP430SelectionDAGInfo.cpp
MSP430Subtarget.cpp
MSP430TargetMachine.cpp
MSP430AsmPrinter.cpp
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "MSP430.h"
#include "MSP430SelectionDAGInfo.h"
#include "MSP430TargetMachine.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
Expand Down
22 changes: 1 addition & 21 deletions llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "MSP430ISelLowering.h"
#include "MSP430.h"
#include "MSP430MachineFunctionInfo.h"
#include "MSP430SelectionDAGInfo.h"
#include "MSP430Subtarget.h"
#include "MSP430TargetMachine.h"
#include "llvm/CodeGen/CallingConvLower.h"
Expand Down Expand Up @@ -1361,27 +1362,6 @@ bool MSP430TargetLowering::getPostIndexedAddressParts(SDNode *N, SDNode *Op,
return false;
}


const char *MSP430TargetLowering::getTargetNodeName(unsigned Opcode) const {
switch ((MSP430ISD::NodeType)Opcode) {
case MSP430ISD::FIRST_NUMBER: break;
case MSP430ISD::RET_GLUE: return "MSP430ISD::RET_GLUE";
case MSP430ISD::RETI_GLUE: return "MSP430ISD::RETI_GLUE";
case MSP430ISD::RRA: return "MSP430ISD::RRA";
case MSP430ISD::RLA: return "MSP430ISD::RLA";
case MSP430ISD::RRC: return "MSP430ISD::RRC";
case MSP430ISD::RRCL: return "MSP430ISD::RRCL";
case MSP430ISD::CALL: return "MSP430ISD::CALL";
case MSP430ISD::Wrapper: return "MSP430ISD::Wrapper";
case MSP430ISD::BR_CC: return "MSP430ISD::BR_CC";
case MSP430ISD::CMP: return "MSP430ISD::CMP";
case MSP430ISD::SETCC: return "MSP430ISD::SETCC";
case MSP430ISD::SELECT_CC: return "MSP430ISD::SELECT_CC";
case MSP430ISD::DADD: return "MSP430ISD::DADD";
}
return nullptr;
}

bool MSP430TargetLowering::isTruncateFree(Type *Ty1,
Type *Ty2) const {
if (!Ty1->isIntegerTy() || !Ty2->isIntegerTy())
Expand Down
54 changes: 0 additions & 54 deletions llvm/lib/Target/MSP430/MSP430ISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,6 @@
#include "llvm/CodeGen/TargetLowering.h"

namespace llvm {
namespace MSP430ISD {
enum NodeType : unsigned {
FIRST_NUMBER = ISD::BUILTIN_OP_END,

/// Return with a glue operand. Operand 0 is the chain operand.
RET_GLUE,

/// Same as RET_GLUE, but used for returning from ISRs.
RETI_GLUE,

/// Y = R{R,L}A X, rotate right (left) arithmetically
RRA, RLA,

/// Y = RRC X, rotate right via carry
RRC,

/// Rotate right via carry, carry gets cleared beforehand by clrc
RRCL,

/// CALL - These operations represent an abstract call
/// instruction, which includes a bunch of information.
CALL,

/// Wrapper - A wrapper node for TargetConstantPool, TargetExternalSymbol,
/// and TargetGlobalAddress.
Wrapper,

/// CMP - Compare instruction.
CMP,

/// SetCC - Operand 0 is condition code, and operand 1 is the flag
/// operand produced by a CMP instruction.
SETCC,

/// MSP430 conditional branches. Operand 0 is the chain operand, operand 1
/// is the block to branch if condition is true, operand 2 is the
/// condition code, and operand 3 is the flag operand produced by a CMP
/// instruction.
BR_CC,

/// SELECT_CC - Operand 0 and operand 1 are selection variable, operand 3
/// is condition code and operand 4 is flag operand.
SELECT_CC,

/// DADD - Decimal addition with carry
/// TODO Nothing generates a node of this type yet.
DADD,
};
}

class MSP430Subtarget;
class MSP430TargetLowering : public TargetLowering {
public:
Expand All @@ -86,10 +36,6 @@ namespace llvm {
/// LowerOperation - Provide custom lowering hooks for some operations.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;

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

SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
Expand Down
19 changes: 19 additions & 0 deletions llvm/lib/Target/MSP430/MSP430SelectionDAGInfo.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 "MSP430SelectionDAGInfo.h"

#define GET_SDNODE_DESC
#include "MSP430GenSDNodeInfo.inc"

using namespace llvm;

MSP430SelectionDAGInfo::MSP430SelectionDAGInfo()
: SelectionDAGGenTargetInfo(MSP430GenSDNodeInfo) {}

MSP430SelectionDAGInfo::~MSP430SelectionDAGInfo() = default;
28 changes: 28 additions & 0 deletions llvm/lib/Target/MSP430/MSP430SelectionDAGInfo.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_MSP430_MSP430SELECTIONDAGINFO_H
#define LLVM_LIB_TARGET_MSP430_MSP430SELECTIONDAGINFO_H

#include "llvm/CodeGen/SelectionDAGTargetInfo.h"

#define GET_SDNODE_ENUM
#include "MSP430GenSDNodeInfo.inc"

namespace llvm {

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

~MSP430SelectionDAGInfo() override;
};

} // namespace llvm

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

#include "MSP430Subtarget.h"
#include "MSP430SelectionDAGInfo.h"
#include "llvm/MC/TargetRegistry.h"

using namespace llvm;
Expand Down Expand Up @@ -58,4 +59,12 @@ MSP430Subtarget::MSP430Subtarget(const Triple &TT, const std::string &CPU,
const std::string &FS, const TargetMachine &TM)
: MSP430GenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
FrameLowering(*this) {}
FrameLowering(*this) {
TSInfo = std::make_unique<MSP430SelectionDAGInfo>();
}

MSP430Subtarget::~MSP430Subtarget() = default;

const SelectionDAGTargetInfo *MSP430Subtarget::getSelectionDAGInfo() const {
return TSInfo.get();
}
10 changes: 5 additions & 5 deletions llvm/lib/Target/MSP430/MSP430Subtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "MSP430ISelLowering.h"
#include "MSP430InstrInfo.h"
#include "MSP430RegisterInfo.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DataLayout.h"
#include <string>
Expand All @@ -40,7 +39,7 @@ class MSP430Subtarget : public MSP430GenSubtargetInfo {
HWMultEnum HWMultMode = NoHWMult;
MSP430InstrInfo InstrInfo;
MSP430TargetLowering TLInfo;
SelectionDAGTargetInfo TSInfo;
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
MSP430FrameLowering FrameLowering;

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

~MSP430Subtarget() override;

MSP430Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);

/// ParseSubtargetFeatures - Parses features string setting specified
Expand All @@ -71,9 +72,8 @@ class MSP430Subtarget : public MSP430GenSubtargetInfo {
const MSP430TargetLowering *getTargetLowering() const override {
return &TLInfo;
}
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
return &TSInfo;
}

const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
};
} // End llvm namespace

Expand Down
Loading