forked from OSchip/llvm-project
R600: Move AMDGPUInstrInfo from AMDGPUTargetMachine into AMDGPUSubtarget
llvm-svn: 210869
This commit is contained in:
parent
d881e9195a
commit
2e59a45f80
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "AMDGPUAsmPrinter.h"
|
||||
#include "AMDGPU.h"
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "R600Defines.h"
|
||||
#include "R600MachineFunctionInfo.h"
|
||||
#include "R600RegisterInfo.h"
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "AMDGPUInstrInfo.h"
|
||||
#include "AMDGPUISelLowering.h" // For AMDGPUISD
|
||||
#include "AMDGPURegisterInfo.h"
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "R600InstrInfo.h"
|
||||
#include "SIISelLowering.h"
|
||||
#include "llvm/CodeGen/FunctionLoweringInfo.h"
|
||||
|
|
|
@ -30,8 +30,8 @@ using namespace llvm;
|
|||
// Pin the vtable to this file.
|
||||
void AMDGPUInstrInfo::anchor() {}
|
||||
|
||||
AMDGPUInstrInfo::AMDGPUInstrInfo(TargetMachine &tm)
|
||||
: AMDGPUGenInstrInfo(-1,-1), RI(tm), TM(tm) { }
|
||||
AMDGPUInstrInfo::AMDGPUInstrInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUGenInstrInfo(-1,-1), RI(st), ST(st) { }
|
||||
|
||||
const AMDGPURegisterInfo &AMDGPUInstrInfo::getRegisterInfo() const {
|
||||
return RI;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace llvm {
|
||||
|
||||
class AMDGPUTargetMachine;
|
||||
class AMDGPUSubtarget;
|
||||
class MachineFunction;
|
||||
class MachineInstr;
|
||||
class MachineInstrBuilder;
|
||||
|
@ -45,9 +45,9 @@ private:
|
|||
MachineBasicBlock &MBB) const;
|
||||
virtual void anchor();
|
||||
protected:
|
||||
TargetMachine &TM;
|
||||
const AMDGPUSubtarget &ST;
|
||||
public:
|
||||
explicit AMDGPUInstrInfo(TargetMachine &tm);
|
||||
explicit AMDGPUInstrInfo(const AMDGPUSubtarget &st);
|
||||
|
||||
virtual const AMDGPURegisterInfo &getRegisterInfo() const = 0;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "AMDGPUMCInstLower.h"
|
||||
#include "AMDGPUAsmPrinter.h"
|
||||
#include "AMDGPUTargetMachine.h"
|
||||
#include "InstPrinter/AMDGPUInstPrinter.h"
|
||||
#include "R600InstrInfo.h"
|
||||
#include "SIInstrInfo.h"
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
AMDGPURegisterInfo::AMDGPURegisterInfo(TargetMachine &tm)
|
||||
AMDGPURegisterInfo::AMDGPURegisterInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUGenRegisterInfo(0),
|
||||
TM(tm)
|
||||
ST(st)
|
||||
{ }
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
|
||||
namespace llvm {
|
||||
|
||||
class AMDGPUTargetMachine;
|
||||
class AMDGPUSubtarget;
|
||||
class TargetInstrInfo;
|
||||
|
||||
struct AMDGPURegisterInfo : public AMDGPUGenRegisterInfo {
|
||||
TargetMachine &TM;
|
||||
static const MCPhysReg CalleeSavedReg;
|
||||
const AMDGPUSubtarget &ST;
|
||||
|
||||
AMDGPURegisterInfo(TargetMachine &tm);
|
||||
AMDGPURegisterInfo(const AMDGPUSubtarget &st);
|
||||
|
||||
BitVector getReservedRegs(const MachineFunction &MF) const override {
|
||||
assert(!"Unimplemented"); return BitVector();
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "R600InstrInfo.h"
|
||||
#include "SIInstrInfo.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -41,6 +43,12 @@ AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
|
|||
CFALUBug = false;
|
||||
ParseSubtargetFeatures(GPU, FS);
|
||||
DevName = GPU;
|
||||
|
||||
if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
|
||||
InstrInfo.reset(new R600InstrInfo(*this));
|
||||
} else {
|
||||
InstrInfo.reset(new SIInstrInfo(*this));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef AMDGPUSUBTARGET_H
|
||||
#define AMDGPUSUBTARGET_H
|
||||
#include "AMDGPU.h"
|
||||
#include "AMDGPUInstrInfo.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
|
@ -27,6 +28,9 @@
|
|||
namespace llvm {
|
||||
|
||||
class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
|
||||
|
||||
std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
|
||||
|
||||
public:
|
||||
enum Generation {
|
||||
R600 = 0,
|
||||
|
@ -58,6 +62,9 @@ private:
|
|||
public:
|
||||
AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
|
||||
|
||||
const AMDGPUInstrInfo *getInstrInfo() const {
|
||||
return InstrInfo.get();
|
||||
}
|
||||
const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
|
||||
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
|
||||
|
||||
|
|
|
@ -80,10 +80,8 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, StringRef TT,
|
|||
InstrItins(&Subtarget.getInstrItineraryData()) {
|
||||
// TLInfo uses InstrInfo so it must be initialized after.
|
||||
if (Subtarget.getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
|
||||
InstrInfo.reset(new R600InstrInfo(*this));
|
||||
TLInfo.reset(new R600TargetLowering(*this));
|
||||
} else {
|
||||
InstrInfo.reset(new SIInstrInfo(*this));
|
||||
TLInfo.reset(new SITargetLowering(*this));
|
||||
}
|
||||
setRequiresStructuredCFG(true);
|
||||
|
|
|
@ -30,7 +30,6 @@ class AMDGPUTargetMachine : public LLVMTargetMachine {
|
|||
const DataLayout Layout;
|
||||
AMDGPUFrameLowering FrameLowering;
|
||||
AMDGPUIntrinsicInfo IntrinsicInfo;
|
||||
std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
|
||||
std::unique_ptr<AMDGPUTargetLowering> TLInfo;
|
||||
const InstrItineraryData *InstrItins;
|
||||
|
||||
|
@ -46,13 +45,13 @@ public:
|
|||
return &IntrinsicInfo;
|
||||
}
|
||||
const AMDGPUInstrInfo *getInstrInfo() const override {
|
||||
return InstrInfo.get();
|
||||
return getSubtargetImpl()->getInstrInfo();
|
||||
}
|
||||
const AMDGPUSubtarget *getSubtargetImpl() const override {
|
||||
return &Subtarget;
|
||||
}
|
||||
const AMDGPURegisterInfo *getRegisterInfo() const override {
|
||||
return &InstrInfo->getRegisterInfo();
|
||||
return &getInstrInfo()->getRegisterInfo();
|
||||
}
|
||||
AMDGPUTargetLowering *getTargetLowering() const override {
|
||||
return TLInfo.get();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "AMDGPU.h"
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "R600Defines.h"
|
||||
#include "R600InstrInfo.h"
|
||||
#include "R600MachineFunctionInfo.h"
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "R600ISelLowering.h"
|
||||
#include "AMDILIntrinsicInfo.h"
|
||||
#include "AMDGPUFrameLowering.h"
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "R600Defines.h"
|
||||
#include "R600InstrInfo.h"
|
||||
#include "R600MachineFunctionInfo.h"
|
||||
|
|
|
@ -28,10 +28,9 @@ using namespace llvm;
|
|||
#define GET_INSTRINFO_CTOR_DTOR
|
||||
#include "AMDGPUGenDFAPacketizer.inc"
|
||||
|
||||
R600InstrInfo::R600InstrInfo(AMDGPUTargetMachine &tm)
|
||||
: AMDGPUInstrInfo(tm),
|
||||
RI(tm),
|
||||
ST(tm.getSubtarget<AMDGPUSubtarget>())
|
||||
R600InstrInfo::R600InstrInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUInstrInfo(st),
|
||||
RI(st)
|
||||
{ }
|
||||
|
||||
const R600RegisterInfo &R600InstrInfo::getRegisterInfo() const {
|
||||
|
@ -1221,7 +1220,6 @@ MachineInstr *R600InstrInfo::buildSlotOfVectorInstruction(
|
|||
const {
|
||||
assert (MI->getOpcode() == AMDGPU::DOT_4 && "Not Implemented");
|
||||
unsigned Opcode;
|
||||
const AMDGPUSubtarget &ST = TM.getSubtarget<AMDGPUSubtarget>();
|
||||
if (ST.getGeneration() <= AMDGPUSubtarget::R700)
|
||||
Opcode = AMDGPU::DOT4_r600;
|
||||
else
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace llvm {
|
|||
class R600InstrInfo : public AMDGPUInstrInfo {
|
||||
private:
|
||||
const R600RegisterInfo RI;
|
||||
const AMDGPUSubtarget &ST;
|
||||
|
||||
int getBranchInstr(const MachineOperand &op) const;
|
||||
std::vector<std::pair<int, unsigned> >
|
||||
|
@ -48,7 +47,7 @@ namespace llvm {
|
|||
ALU_VEC_210
|
||||
};
|
||||
|
||||
explicit R600InstrInfo(AMDGPUTargetMachine &tm);
|
||||
explicit R600InstrInfo(const AMDGPUSubtarget &st);
|
||||
|
||||
const R600RegisterInfo &getRegisterInfo() const override;
|
||||
void copyPhysReg(MachineBasicBlock &MBB,
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "R600MachineScheduler.h"
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/Pass.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "AMDGPU.h"
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "R600InstrInfo.h"
|
||||
#include "llvm/CodeGen/DFAPacketizer.h"
|
||||
#include "llvm/CodeGen/MachineDominators.h"
|
||||
|
|
|
@ -20,15 +20,14 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
R600RegisterInfo::R600RegisterInfo(AMDGPUTargetMachine &tm)
|
||||
: AMDGPURegisterInfo(tm),
|
||||
TM(tm)
|
||||
R600RegisterInfo::R600RegisterInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPURegisterInfo(st)
|
||||
{ RCW.RegWeight = 0; RCW.WeightLimit = 0;}
|
||||
|
||||
BitVector R600RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
||||
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::HALF);
|
||||
|
|
|
@ -16,17 +16,15 @@
|
|||
#define R600REGISTERINFO_H_
|
||||
|
||||
#include "AMDGPURegisterInfo.h"
|
||||
#include "AMDGPUTargetMachine.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class R600TargetMachine;
|
||||
class AMDGPUSubtarget;
|
||||
|
||||
struct R600RegisterInfo : public AMDGPURegisterInfo {
|
||||
AMDGPUTargetMachine &TM;
|
||||
RegClassWeight RCW;
|
||||
|
||||
R600RegisterInfo(AMDGPUTargetMachine &tm);
|
||||
R600RegisterInfo(const AMDGPUSubtarget &st);
|
||||
|
||||
BitVector getReservedRegs(const MachineFunction &MF) const override;
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
SIInstrInfo::SIInstrInfo(AMDGPUTargetMachine &tm)
|
||||
: AMDGPUInstrInfo(tm),
|
||||
RI(tm) { }
|
||||
SIInstrInfo::SIInstrInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUInstrInfo(st),
|
||||
RI(st) { }
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TargetInstrInfo callbacks
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
void addDescImplicitUseDef(const MCInstrDesc &Desc, MachineInstr *MI) const;
|
||||
|
||||
public:
|
||||
explicit SIInstrInfo(AMDGPUTargetMachine &tm);
|
||||
explicit SIInstrInfo(const AMDGPUSubtarget &st);
|
||||
|
||||
const SIRegisterInfo &getRegisterInfo() const override {
|
||||
return RI;
|
||||
|
|
|
@ -14,21 +14,20 @@
|
|||
|
||||
|
||||
#include "SIRegisterInfo.h"
|
||||
#include "AMDGPUTargetMachine.h"
|
||||
#include "AMDGPUSubtarget.h"
|
||||
#include "SIInstrInfo.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
SIRegisterInfo::SIRegisterInfo(AMDGPUTargetMachine &tm)
|
||||
: AMDGPURegisterInfo(tm),
|
||||
TM(tm)
|
||||
SIRegisterInfo::SIRegisterInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPURegisterInfo(st)
|
||||
{ }
|
||||
|
||||
BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
||||
BitVector Reserved(getNumRegs());
|
||||
Reserved.set(AMDGPU::EXEC);
|
||||
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);
|
||||
return Reserved;
|
||||
}
|
||||
|
|
|
@ -20,12 +20,9 @@
|
|||
|
||||
namespace llvm {
|
||||
|
||||
class AMDGPUTargetMachine;
|
||||
|
||||
struct SIRegisterInfo : public AMDGPURegisterInfo {
|
||||
AMDGPUTargetMachine &TM;
|
||||
|
||||
SIRegisterInfo(AMDGPUTargetMachine &tm);
|
||||
SIRegisterInfo(const AMDGPUSubtarget &st);
|
||||
|
||||
BitVector getReservedRegs(const MachineFunction &MF) const override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue