Skip to content

Commit

Permalink
Make stubs for the rest of GISel
Browse files Browse the repository at this point in the history
  • Loading branch information
SupernaviX committed Aug 23, 2024
1 parent 09e7db9 commit 135033b
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 3 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/Target/V810/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ tablegen(LLVM V810GenAsmWriter.inc -gen-asm-writer)
tablegen(LLVM V810GenCallingConv.inc -gen-callingconv)
tablegen(LLVM V810GenDAGISel.inc -gen-dag-isel)
tablegen(LLVM V810GenDisassemblerTables.inc -gen-disassembler)
tablegen(LLVM V810GenGlobalISel.inc -gen-global-isel)
tablegen(LLVM V810GenInstrInfo.inc -gen-instr-info)
tablegen(LLVM V810GenMCCodeEmitter.inc -gen-emitter)
tablegen(LLVM V810GenRegisterBank.inc -gen-register-bank)
Expand All @@ -32,6 +33,8 @@ add_llvm_target(V810CodeGen
V810TargetObjectFile.cpp
V810TargetTransformInfo.cpp
GISel/V810CallLowering.cpp
GISel/V810InstructionSelector.cpp
GISel/V810LegalizerInfo.cpp
GISel/V810RegisterBankInfo.cpp

LINK_COMPONENTS
Expand Down
67 changes: 67 additions & 0 deletions llvm/lib/Target/V810/GISel/V810InstructionSelector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "V810InstructionSelector.h"
#include "llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"

using namespace llvm;

#define DEBUG_TYPE "v810-isel"

namespace {

#define GET_GLOBALISEL_PREDICATE_BITSET
#include "V810GenGlobalISel.inc"
#undef GET_GLOBALISEL_PREDICATE_BITSET

class V810InstructionSelector : public InstructionSelector {
public:
V810InstructionSelector(const V810TargetMachine &TM,
V810Subtarget &STI,
V810RegisterBankInfo &RBI);
bool select(MachineInstr &MI) override;
static const char *getName() { return DEBUG_TYPE; }
private:
const V810Subtarget &STI;
const V810InstrInfo &TII;
const V810RegisterInfo &TRI;
const V810RegisterBankInfo &RBI;

/// tblgen-erated 'select' implementation, used as the initial selector for
/// the patterns that don't require complex C++.
bool selectImpl(MachineInstr &MI, CodeGenCoverage &CoverageInfo) const;

#define GET_GLOBALISEL_PREDICATES_DECL
#include "V810GenGlobalISel.inc"
#undef GET_GLOBALISEL_PREDICATES_DECL

#define GET_GLOBALISEL_TEMPORARIES_DECL
#include "V810GenGlobalISel.inc"
#undef GET_GLOBALISEL_TEMPORARIES_DECL
};

} // namespace

#define GET_GLOBALISEL_IMPL
#include "V810GenGlobalISel.inc"
#undef GET_GLOBALISEL_IMPL

V810InstructionSelector::V810InstructionSelector(const V810TargetMachine &TM,
V810Subtarget &STI,
V810RegisterBankInfo &RBI)
: STI(STI), TII(*STI.getInstrInfo()), TRI(*STI.getRegisterInfo()), RBI(RBI),
#define GET_GLOBALISEL_PREDICATES_INIT
#include "V810GenGlobalISel.inc"
#undef GET_GLOBALISEL_PREDICATES_INIT
#define GET_GLOBALISEL_TEMPORARIES_INIT
#include "V810GenGlobalISel.inc"
#undef GET_GLOBALISEL_TEMPORARIES_INIT
{
}

bool V810InstructionSelector::select(MachineInstr &MI) {
return selectImpl(MI, *CoverageInfo);
}

InstructionSelector *llvm::createV810InstructionSelector(
const V810TargetMachine &TM, V810Subtarget &STI, V810RegisterBankInfo &RBI) {
return new V810InstructionSelector(TM, STI, RBI);
}
18 changes: 18 additions & 0 deletions llvm/lib/Target/V810/GISel/V810InstructionSelector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef LLVM_LIB_TARGET_V810_V810INSTRUCTIONSELECTOR_H
#define LLVM_LIB_TARGET_V810_V810INSTRUCTIONSELECTOR_H

#include "V810RegisterBankInfo.h"
#include "V810Subtarget.h"
#include "V810TargetMachine.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"

namespace llvm {

InstructionSelector *
createV810InstructionSelector(const V810TargetMachine &TM,
V810Subtarget &STI,
V810RegisterBankInfo &RBI);

}

#endif
9 changes: 9 additions & 0 deletions llvm/lib/Target/V810/GISel/V810LegalizerInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "V810LegalizerInfo.h"
#include "V810Subtarget.h"

using namespace llvm;

V810LegalizerInfo::V810LegalizerInfo(const V810Subtarget &STI) {
getLegacyLegalizerInfo().computeTables();
verify(*STI.getInstrInfo());
}
17 changes: 17 additions & 0 deletions llvm/lib/Target/V810/GISel/V810LegalizerInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef LLVM_LIB_TARGET_V810_V810LEGALIZERINFO_H
#define LLVM_LIB_TARGET_V810_V810LEGALIZERINFO_H

#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"

namespace llvm {

class V810Subtarget;

class V810LegalizerInfo : public LegalizerInfo {
public:
V810LegalizerInfo(const V810Subtarget &STI);
};

}

#endif
17 changes: 15 additions & 2 deletions llvm/lib/Target/V810/V810Subtarget.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "V810Subtarget.h"
#include "GISel/V810CallLowering.h"
#include "GISel/V810InstructionSelector.h"
#include "GISel/V810LegalizerInfo.h"
#include "GISel/V810RegisterBankInfo.h"
#include "V810.h"

Expand Down Expand Up @@ -31,18 +33,29 @@ V810Subtarget &V810Subtarget::initializeSubtargetDependencies(const Triple &TT,
}

V810Subtarget::V810Subtarget(const Triple &TT, const std::string &CPU,
const std::string &FS, const TargetMachine &TM)
const std::string &FS, const V810TargetMachine &TM)
: V810GenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
InstrInfo(), TLInfo(TM, initializeSubtargetDependencies(TT, CPU, FS)), FrameLowering(),
InstrItins(getInstrItineraryForCPU(getCPUName(TT, CPU))) {
CallLoweringInfo.reset(new V810CallLowering(*getTargetLowering()));
RegBankInfo.reset(new V810RegisterBankInfo());
Legalizer.reset(new V810LegalizerInfo(*this));
V810RegisterBankInfo *RBI = static_cast<V810RegisterBankInfo*>(RegBankInfo.get());
InstSelector.reset(createV810InstructionSelector(TM, *this, *RBI));
}

const CallLowering *V810Subtarget::getCallLowering() const {
return CallLoweringInfo.get();
}

InstructionSelector *V810Subtarget::getInstructionSelector() const {
return InstSelector.get();
}

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

const RegisterBankInfo *V810Subtarget::getRegBankInfo() const {
return RegBankInfo.get();
}
}
9 changes: 8 additions & 1 deletion llvm/lib/Target/V810/V810Subtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "V810ISelLowering.h"
#include "V810SelectionDAGInfo.h"
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"

Expand All @@ -28,10 +29,12 @@ class V810Subtarget : public V810GenSubtargetInfo {
InstrItineraryData InstrItins;

std::unique_ptr<CallLowering> CallLoweringInfo;
std::unique_ptr<InstructionSelector> InstSelector;
std::unique_ptr<LegalizerInfo> Legalizer;
std::unique_ptr<RegisterBankInfo> RegBankInfo;
public:
V810Subtarget(const Triple &TT, const std::string &CPU,
const std::string &FS, const TargetMachine &TM);
const std::string &FS, const V810TargetMachine &TM);

const InstrItineraryData *getInstrItineraryData() const override {
return &InstrItins;
Expand All @@ -52,6 +55,10 @@ class V810Subtarget : public V810GenSubtargetInfo {

const CallLowering *getCallLowering() const override;

InstructionSelector *getInstructionSelector() const override;

const LegalizerInfo *getLegalizerInfo() const override;

const RegisterBankInfo *getRegBankInfo() const override;

bool isNintendo() const { return IsNintendo; }
Expand Down

0 comments on commit 135033b

Please sign in to comment.