R600: Move AMDGPUInstrInfo from AMDGPUTargetMachine into AMDGPUSubtarget

llvm-svn: 210869
This commit is contained in:
Tom Stellard 2014-06-13 01:32:00 +00:00
parent d881e9195a
commit 2e59a45f80
23 changed files with 54 additions and 43 deletions

View File

@ -19,6 +19,7 @@
#include "AMDGPUAsmPrinter.h" #include "AMDGPUAsmPrinter.h"
#include "AMDGPU.h" #include "AMDGPU.h"
#include "AMDGPUSubtarget.h"
#include "R600Defines.h" #include "R600Defines.h"
#include "R600MachineFunctionInfo.h" #include "R600MachineFunctionInfo.h"
#include "R600RegisterInfo.h" #include "R600RegisterInfo.h"

View File

@ -14,6 +14,7 @@
#include "AMDGPUInstrInfo.h" #include "AMDGPUInstrInfo.h"
#include "AMDGPUISelLowering.h" // For AMDGPUISD #include "AMDGPUISelLowering.h" // For AMDGPUISD
#include "AMDGPURegisterInfo.h" #include "AMDGPURegisterInfo.h"
#include "AMDGPUSubtarget.h"
#include "R600InstrInfo.h" #include "R600InstrInfo.h"
#include "SIISelLowering.h" #include "SIISelLowering.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h" #include "llvm/CodeGen/FunctionLoweringInfo.h"

View File

@ -30,8 +30,8 @@ using namespace llvm;
// Pin the vtable to this file. // Pin the vtable to this file.
void AMDGPUInstrInfo::anchor() {} void AMDGPUInstrInfo::anchor() {}
AMDGPUInstrInfo::AMDGPUInstrInfo(TargetMachine &tm) AMDGPUInstrInfo::AMDGPUInstrInfo(const AMDGPUSubtarget &st)
: AMDGPUGenInstrInfo(-1,-1), RI(tm), TM(tm) { } : AMDGPUGenInstrInfo(-1,-1), RI(st), ST(st) { }
const AMDGPURegisterInfo &AMDGPUInstrInfo::getRegisterInfo() const { const AMDGPURegisterInfo &AMDGPUInstrInfo::getRegisterInfo() const {
return RI; return RI;

View File

@ -33,7 +33,7 @@
namespace llvm { namespace llvm {
class AMDGPUTargetMachine; class AMDGPUSubtarget;
class MachineFunction; class MachineFunction;
class MachineInstr; class MachineInstr;
class MachineInstrBuilder; class MachineInstrBuilder;
@ -45,9 +45,9 @@ private:
MachineBasicBlock &MBB) const; MachineBasicBlock &MBB) const;
virtual void anchor(); virtual void anchor();
protected: protected:
TargetMachine &TM; const AMDGPUSubtarget &ST;
public: public:
explicit AMDGPUInstrInfo(TargetMachine &tm); explicit AMDGPUInstrInfo(const AMDGPUSubtarget &st);
virtual const AMDGPURegisterInfo &getRegisterInfo() const = 0; virtual const AMDGPURegisterInfo &getRegisterInfo() const = 0;

View File

@ -15,6 +15,7 @@
#include "AMDGPUMCInstLower.h" #include "AMDGPUMCInstLower.h"
#include "AMDGPUAsmPrinter.h" #include "AMDGPUAsmPrinter.h"
#include "AMDGPUTargetMachine.h"
#include "InstPrinter/AMDGPUInstPrinter.h" #include "InstPrinter/AMDGPUInstPrinter.h"
#include "R600InstrInfo.h" #include "R600InstrInfo.h"
#include "SIInstrInfo.h" #include "SIInstrInfo.h"

View File

@ -17,9 +17,9 @@
using namespace llvm; using namespace llvm;
AMDGPURegisterInfo::AMDGPURegisterInfo(TargetMachine &tm) AMDGPURegisterInfo::AMDGPURegisterInfo(const AMDGPUSubtarget &st)
: AMDGPUGenRegisterInfo(0), : AMDGPUGenRegisterInfo(0),
TM(tm) ST(st)
{ } { }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -25,14 +25,14 @@
namespace llvm { namespace llvm {
class AMDGPUTargetMachine; class AMDGPUSubtarget;
class TargetInstrInfo; class TargetInstrInfo;
struct AMDGPURegisterInfo : public AMDGPUGenRegisterInfo { struct AMDGPURegisterInfo : public AMDGPUGenRegisterInfo {
TargetMachine &TM;
static const MCPhysReg CalleeSavedReg; static const MCPhysReg CalleeSavedReg;
const AMDGPUSubtarget &ST;
AMDGPURegisterInfo(TargetMachine &tm); AMDGPURegisterInfo(const AMDGPUSubtarget &st);
BitVector getReservedRegs(const MachineFunction &MF) const override { BitVector getReservedRegs(const MachineFunction &MF) const override {
assert(!"Unimplemented"); return BitVector(); assert(!"Unimplemented"); return BitVector();

View File

@ -13,6 +13,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "AMDGPUSubtarget.h" #include "AMDGPUSubtarget.h"
#include "R600InstrInfo.h"
#include "SIInstrInfo.h"
using namespace llvm; using namespace llvm;
@ -41,6 +43,12 @@ AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
CFALUBug = false; CFALUBug = false;
ParseSubtargetFeatures(GPU, FS); ParseSubtargetFeatures(GPU, FS);
DevName = GPU; DevName = GPU;
if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
InstrInfo.reset(new R600InstrInfo(*this));
} else {
InstrInfo.reset(new SIInstrInfo(*this));
}
} }
bool bool

View File

@ -15,6 +15,7 @@
#ifndef AMDGPUSUBTARGET_H #ifndef AMDGPUSUBTARGET_H
#define AMDGPUSUBTARGET_H #define AMDGPUSUBTARGET_H
#include "AMDGPU.h" #include "AMDGPU.h"
#include "AMDGPUInstrInfo.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Target/TargetSubtargetInfo.h"
@ -27,6 +28,9 @@
namespace llvm { namespace llvm {
class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo { class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
public: public:
enum Generation { enum Generation {
R600 = 0, R600 = 0,
@ -58,6 +62,9 @@ private:
public: public:
AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS); AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
const AMDGPUInstrInfo *getInstrInfo() const {
return InstrInfo.get();
}
const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
void ParseSubtargetFeatures(StringRef CPU, StringRef FS); void ParseSubtargetFeatures(StringRef CPU, StringRef FS);

View File

@ -80,10 +80,8 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, StringRef TT,
InstrItins(&Subtarget.getInstrItineraryData()) { InstrItins(&Subtarget.getInstrItineraryData()) {
// TLInfo uses InstrInfo so it must be initialized after. // TLInfo uses InstrInfo so it must be initialized after.
if (Subtarget.getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) { if (Subtarget.getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
InstrInfo.reset(new R600InstrInfo(*this));
TLInfo.reset(new R600TargetLowering(*this)); TLInfo.reset(new R600TargetLowering(*this));
} else { } else {
InstrInfo.reset(new SIInstrInfo(*this));
TLInfo.reset(new SITargetLowering(*this)); TLInfo.reset(new SITargetLowering(*this));
} }
setRequiresStructuredCFG(true); setRequiresStructuredCFG(true);

View File

@ -30,7 +30,6 @@ class AMDGPUTargetMachine : public LLVMTargetMachine {
const DataLayout Layout; const DataLayout Layout;
AMDGPUFrameLowering FrameLowering; AMDGPUFrameLowering FrameLowering;
AMDGPUIntrinsicInfo IntrinsicInfo; AMDGPUIntrinsicInfo IntrinsicInfo;
std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
std::unique_ptr<AMDGPUTargetLowering> TLInfo; std::unique_ptr<AMDGPUTargetLowering> TLInfo;
const InstrItineraryData *InstrItins; const InstrItineraryData *InstrItins;
@ -46,13 +45,13 @@ public:
return &IntrinsicInfo; return &IntrinsicInfo;
} }
const AMDGPUInstrInfo *getInstrInfo() const override { const AMDGPUInstrInfo *getInstrInfo() const override {
return InstrInfo.get(); return getSubtargetImpl()->getInstrInfo();
} }
const AMDGPUSubtarget *getSubtargetImpl() const override { const AMDGPUSubtarget *getSubtargetImpl() const override {
return &Subtarget; return &Subtarget;
} }
const AMDGPURegisterInfo *getRegisterInfo() const override { const AMDGPURegisterInfo *getRegisterInfo() const override {
return &InstrInfo->getRegisterInfo(); return &getInstrInfo()->getRegisterInfo();
} }
AMDGPUTargetLowering *getTargetLowering() const override { AMDGPUTargetLowering *getTargetLowering() const override {
return TLInfo.get(); return TLInfo.get();

View File

@ -14,6 +14,7 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "AMDGPU.h" #include "AMDGPU.h"
#include "AMDGPUSubtarget.h"
#include "R600Defines.h" #include "R600Defines.h"
#include "R600InstrInfo.h" #include "R600InstrInfo.h"
#include "R600MachineFunctionInfo.h" #include "R600MachineFunctionInfo.h"

View File

@ -13,6 +13,9 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "R600ISelLowering.h" #include "R600ISelLowering.h"
#include "AMDILIntrinsicInfo.h"
#include "AMDGPUFrameLowering.h"
#include "AMDGPUSubtarget.h"
#include "R600Defines.h" #include "R600Defines.h"
#include "R600InstrInfo.h" #include "R600InstrInfo.h"
#include "R600MachineFunctionInfo.h" #include "R600MachineFunctionInfo.h"

View File

@ -28,10 +28,9 @@ using namespace llvm;
#define GET_INSTRINFO_CTOR_DTOR #define GET_INSTRINFO_CTOR_DTOR
#include "AMDGPUGenDFAPacketizer.inc" #include "AMDGPUGenDFAPacketizer.inc"
R600InstrInfo::R600InstrInfo(AMDGPUTargetMachine &tm) R600InstrInfo::R600InstrInfo(const AMDGPUSubtarget &st)
: AMDGPUInstrInfo(tm), : AMDGPUInstrInfo(st),
RI(tm), RI(st)
ST(tm.getSubtarget<AMDGPUSubtarget>())
{ } { }
const R600RegisterInfo &R600InstrInfo::getRegisterInfo() const { const R600RegisterInfo &R600InstrInfo::getRegisterInfo() const {
@ -1221,7 +1220,6 @@ MachineInstr *R600InstrInfo::buildSlotOfVectorInstruction(
const { const {
assert (MI->getOpcode() == AMDGPU::DOT_4 && "Not Implemented"); assert (MI->getOpcode() == AMDGPU::DOT_4 && "Not Implemented");
unsigned Opcode; unsigned Opcode;
const AMDGPUSubtarget &ST = TM.getSubtarget<AMDGPUSubtarget>();
if (ST.getGeneration() <= AMDGPUSubtarget::R700) if (ST.getGeneration() <= AMDGPUSubtarget::R700)
Opcode = AMDGPU::DOT4_r600; Opcode = AMDGPU::DOT4_r600;
else else

View File

@ -32,7 +32,6 @@ namespace llvm {
class R600InstrInfo : public AMDGPUInstrInfo { class R600InstrInfo : public AMDGPUInstrInfo {
private: private:
const R600RegisterInfo RI; const R600RegisterInfo RI;
const AMDGPUSubtarget &ST;
int getBranchInstr(const MachineOperand &op) const; int getBranchInstr(const MachineOperand &op) const;
std::vector<std::pair<int, unsigned> > std::vector<std::pair<int, unsigned> >
@ -48,7 +47,7 @@ namespace llvm {
ALU_VEC_210 ALU_VEC_210
}; };
explicit R600InstrInfo(AMDGPUTargetMachine &tm); explicit R600InstrInfo(const AMDGPUSubtarget &st);
const R600RegisterInfo &getRegisterInfo() const override; const R600RegisterInfo &getRegisterInfo() const override;
void copyPhysReg(MachineBasicBlock &MBB, void copyPhysReg(MachineBasicBlock &MBB,

View File

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "R600MachineScheduler.h" #include "R600MachineScheduler.h"
#include "AMDGPUSubtarget.h"
#include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h"
#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"

View File

@ -16,6 +16,7 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "AMDGPU.h" #include "AMDGPU.h"
#include "AMDGPUSubtarget.h"
#include "R600InstrInfo.h" #include "R600InstrInfo.h"
#include "llvm/CodeGen/DFAPacketizer.h" #include "llvm/CodeGen/DFAPacketizer.h"
#include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineDominators.h"

View File

@ -20,15 +20,14 @@
using namespace llvm; using namespace llvm;
R600RegisterInfo::R600RegisterInfo(AMDGPUTargetMachine &tm) R600RegisterInfo::R600RegisterInfo(const AMDGPUSubtarget &st)
: AMDGPURegisterInfo(tm), : AMDGPURegisterInfo(st)
TM(tm)
{ RCW.RegWeight = 0; RCW.WeightLimit = 0;} { RCW.RegWeight = 0; RCW.WeightLimit = 0;}
BitVector R600RegisterInfo::getReservedRegs(const MachineFunction &MF) const { BitVector R600RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
BitVector Reserved(getNumRegs()); BitVector Reserved(getNumRegs());
const R600InstrInfo *TII = static_cast<const R600InstrInfo*>(TM.getInstrInfo()); const R600InstrInfo *TII = static_cast<const R600InstrInfo*>(ST.getInstrInfo());
Reserved.set(AMDGPU::ZERO); Reserved.set(AMDGPU::ZERO);
Reserved.set(AMDGPU::HALF); Reserved.set(AMDGPU::HALF);

View File

@ -16,17 +16,15 @@
#define R600REGISTERINFO_H_ #define R600REGISTERINFO_H_
#include "AMDGPURegisterInfo.h" #include "AMDGPURegisterInfo.h"
#include "AMDGPUTargetMachine.h"
namespace llvm { namespace llvm {
class R600TargetMachine; class AMDGPUSubtarget;
struct R600RegisterInfo : public AMDGPURegisterInfo { struct R600RegisterInfo : public AMDGPURegisterInfo {
AMDGPUTargetMachine &TM;
RegClassWeight RCW; RegClassWeight RCW;
R600RegisterInfo(AMDGPUTargetMachine &tm); R600RegisterInfo(const AMDGPUSubtarget &st);
BitVector getReservedRegs(const MachineFunction &MF) const override; BitVector getReservedRegs(const MachineFunction &MF) const override;

View File

@ -24,9 +24,9 @@
using namespace llvm; using namespace llvm;
SIInstrInfo::SIInstrInfo(AMDGPUTargetMachine &tm) SIInstrInfo::SIInstrInfo(const AMDGPUSubtarget &st)
: AMDGPUInstrInfo(tm), : AMDGPUInstrInfo(st),
RI(tm) { } RI(st) { }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// TargetInstrInfo callbacks // TargetInstrInfo callbacks

View File

@ -56,7 +56,7 @@ private:
void addDescImplicitUseDef(const MCInstrDesc &Desc, MachineInstr *MI) const; void addDescImplicitUseDef(const MCInstrDesc &Desc, MachineInstr *MI) const;
public: public:
explicit SIInstrInfo(AMDGPUTargetMachine &tm); explicit SIInstrInfo(const AMDGPUSubtarget &st);
const SIRegisterInfo &getRegisterInfo() const override { const SIRegisterInfo &getRegisterInfo() const override {
return RI; return RI;

View File

@ -14,21 +14,20 @@
#include "SIRegisterInfo.h" #include "SIRegisterInfo.h"
#include "AMDGPUTargetMachine.h" #include "AMDGPUSubtarget.h"
#include "SIInstrInfo.h" #include "SIInstrInfo.h"
using namespace llvm; using namespace llvm;
SIRegisterInfo::SIRegisterInfo(AMDGPUTargetMachine &tm) SIRegisterInfo::SIRegisterInfo(const AMDGPUSubtarget &st)
: AMDGPURegisterInfo(tm), : AMDGPURegisterInfo(st)
TM(tm)
{ } { }
BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const { BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
BitVector Reserved(getNumRegs()); BitVector Reserved(getNumRegs());
Reserved.set(AMDGPU::EXEC); Reserved.set(AMDGPU::EXEC);
Reserved.set(AMDGPU::INDIRECT_BASE_ADDR); Reserved.set(AMDGPU::INDIRECT_BASE_ADDR);
const SIInstrInfo *TII = static_cast<const SIInstrInfo*>(TM.getInstrInfo()); const SIInstrInfo *TII = static_cast<const SIInstrInfo*>(ST.getInstrInfo());
TII->reserveIndirectRegisters(Reserved, MF); TII->reserveIndirectRegisters(Reserved, MF);
return Reserved; return Reserved;
} }

View File

@ -20,12 +20,9 @@
namespace llvm { namespace llvm {
class AMDGPUTargetMachine;
struct SIRegisterInfo : public AMDGPURegisterInfo { struct SIRegisterInfo : public AMDGPURegisterInfo {
AMDGPUTargetMachine &TM;
SIRegisterInfo(AMDGPUTargetMachine &tm); SIRegisterInfo(const AMDGPUSubtarget &st);
BitVector getReservedRegs(const MachineFunction &MF) const override; BitVector getReservedRegs(const MachineFunction &MF) const override;