Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
fix: add legalizer to subtarget
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgillett committed Apr 4, 2023
1 parent 186301f commit 4e20325
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
9 changes: 8 additions & 1 deletion llvm/lib/Target/Delendum/DelendumSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
///
//===----------------------------------------------------------------------===//

#include "DelendumSubtarget.h"

#include "Delendum.h"
#include "DelendumMachineFunction.h"
#include "DelendumRegisterInfo.h"
#include "DelendumTargetMachine.h"

#include "DelendumSubtarget.h"
#include "GISel/DelendumCallLowering.h"
#include "GISel/DelendumRegisterBankInfo.h"
#include "GISel/DelendumLegalizerInfo.h"

#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/IR/Attributes.h"
Expand Down Expand Up @@ -63,6 +65,7 @@ DelendumSubtarget::DelendumSubtarget(const Triple &TT, StringRef CPU, StringRef
InstrInfo(initializeSubtargetDependencies(CPU, FS)),
TLInfo(TM, *this), FrameLowering(*this) {
CallLoweringInfo.reset(new DelendumCallLowering(*getTargetLowering()));
Legalizer.reset(new DelendumLegalizerInfo(*this));
auto *RBI = new DelendumRegisterBankInfo(*getRegisterInfo());
RegBankInfo.reset(RBI);
InstSelector.reset(createDelendumInstructionSelector(TM, *this, *RBI));
Expand All @@ -72,6 +75,10 @@ const CallLowering *DelendumSubtarget::getCallLowering() const {
return CallLoweringInfo.get();
}

const LegalizerInfo *DelendumSubtarget::getLegalizerInfo() const {
return Legalizer.get();
}

const RegisterBankInfo *DelendumSubtarget::getRegBankInfo() const {
return RegBankInfo.get();
}
Expand Down
7 changes: 5 additions & 2 deletions llvm/lib/Target/Delendum/DelendumSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "DelendumFrameLowering.h"

#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
#include "llvm/CodeGen/RegisterBankInfo.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
Expand Down Expand Up @@ -69,13 +70,15 @@ class DelendumSubtarget : public DelendumGenSubtargetInfo {
protected:
// GlobalISel related APIs.
std::unique_ptr<CallLowering> CallLoweringInfo;
std::unique_ptr<InstructionSelector> InstSelector;
std::unique_ptr<LegalizerInfo> Legalizer;
std::unique_ptr<RegisterBankInfo> RegBankInfo;
std::unique_ptr<InstructionSelector> InstSelector;

public:
const CallLowering *getCallLowering() const override;
InstructionSelector *getInstructionSelector() const override;
const LegalizerInfo *getLegalizerInfo() const override;
const RegisterBankInfo *getRegBankInfo() const override;
InstructionSelector *getInstructionSelector() const override;

};
} // End llvm namespace
Expand Down
17 changes: 17 additions & 0 deletions llvm/lib/Target/Delendum/GISel/DelendumLegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,20 @@ DelendumLegalizerInfo::DelendumLegalizerInfo(const DelendumSubtarget &ST) {

getLegacyLegalizerInfo().computeTables();
}

bool DelendumLegalizerInfo::legalizeCustom(LegalizerHelper &Helper,
MachineInstr &MI) const {
// TODO
//using namespace TargetOpcode;

//switch (MI.getOpcode()) {
//case G_LOAD:
//case G_STORE: {
// MI.eraseFromParent();
// break;
//}
//default:
// return false;
//}
//return true;
}
2 changes: 2 additions & 0 deletions llvm/lib/Target/Delendum/GISel/DelendumLegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class DelendumSubtarget;
struct DelendumLegalizerInfo : public LegalizerInfo {
public:
DelendumLegalizerInfo(const DelendumSubtarget &ST);

bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI) const override;
};
} // end namespace llvm
#endif // LLVM_LIB_TARGET_DELENDUM_GLSEL_DELENDUMLEGALIZERINFO_H

0 comments on commit 4e20325

Please sign in to comment.