forked from OSchip/llvm-project
Remove the need to cache the subtarget in the R600 TargetRegisterInfo
classes. llvm-svn: 231954
This commit is contained in:
parent
f4d9a5a964
commit
6c5b511b4d
|
@ -31,7 +31,7 @@ using namespace llvm;
|
|||
void AMDGPUInstrInfo::anchor() {}
|
||||
|
||||
AMDGPUInstrInfo::AMDGPUInstrInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUGenInstrInfo(-1,-1), RI(st), ST(st) { }
|
||||
: AMDGPUGenInstrInfo(-1, -1), ST(st) {}
|
||||
|
||||
const AMDGPURegisterInfo &AMDGPUInstrInfo::getRegisterInfo() const {
|
||||
return RI;
|
||||
|
@ -356,8 +356,8 @@ static enum SISubtarget AMDGPUSubtargetToSISubtarget(unsigned Gen) {
|
|||
}
|
||||
|
||||
int AMDGPUInstrInfo::pseudoToMCOpcode(int Opcode) const {
|
||||
int MCOp = AMDGPU::getMCOpcode(Opcode,
|
||||
AMDGPUSubtargetToSISubtarget(RI.ST.getGeneration()));
|
||||
int MCOp = AMDGPU::getMCOpcode(
|
||||
Opcode, AMDGPUSubtargetToSISubtarget(ST.getGeneration()));
|
||||
|
||||
// -1 means that Opcode is already a native instruction.
|
||||
if (MCOp == -1)
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
AMDGPURegisterInfo::AMDGPURegisterInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUGenRegisterInfo(0),
|
||||
ST(st)
|
||||
{ }
|
||||
AMDGPURegisterInfo::AMDGPURegisterInfo() : AMDGPUGenRegisterInfo(0) {}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Function handling callbacks - Functions are a seldom used feature of GPUS, so
|
||||
|
|
|
@ -30,9 +30,8 @@ class TargetInstrInfo;
|
|||
|
||||
struct AMDGPURegisterInfo : public AMDGPUGenRegisterInfo {
|
||||
static const MCPhysReg CalleeSavedReg;
|
||||
const AMDGPUSubtarget &ST;
|
||||
|
||||
AMDGPURegisterInfo(const AMDGPUSubtarget &st);
|
||||
AMDGPURegisterInfo();
|
||||
|
||||
BitVector getReservedRegs(const MachineFunction &MF) const override {
|
||||
assert(!"Unimplemented"); return BitVector();
|
||||
|
|
|
@ -29,9 +29,7 @@ using namespace llvm;
|
|||
#include "AMDGPUGenDFAPacketizer.inc"
|
||||
|
||||
R600InstrInfo::R600InstrInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUInstrInfo(st),
|
||||
RI(st)
|
||||
{ }
|
||||
: AMDGPUInstrInfo(st), RI() {}
|
||||
|
||||
const R600RegisterInfo &R600InstrInfo::getRegisterInfo() const {
|
||||
return RI;
|
||||
|
|
|
@ -20,14 +20,16 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
R600RegisterInfo::R600RegisterInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPURegisterInfo(st)
|
||||
{ RCW.RegWeight = 0; RCW.WeightLimit = 0;}
|
||||
R600RegisterInfo::R600RegisterInfo() : AMDGPURegisterInfo() {
|
||||
RCW.RegWeight = 0;
|
||||
RCW.WeightLimit = 0;
|
||||
}
|
||||
|
||||
BitVector R600RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
||||
BitVector Reserved(getNumRegs());
|
||||
|
||||
const R600InstrInfo *TII = static_cast<const R600InstrInfo*>(ST.getInstrInfo());
|
||||
const R600InstrInfo *TII =
|
||||
static_cast<const R600InstrInfo *>(MF.getSubtarget().getInstrInfo());
|
||||
|
||||
Reserved.set(AMDGPU::ZERO);
|
||||
Reserved.set(AMDGPU::HALF);
|
||||
|
|
|
@ -24,7 +24,7 @@ class AMDGPUSubtarget;
|
|||
struct R600RegisterInfo : public AMDGPURegisterInfo {
|
||||
RegClassWeight RCW;
|
||||
|
||||
R600RegisterInfo(const AMDGPUSubtarget &st);
|
||||
R600RegisterInfo();
|
||||
|
||||
BitVector getReservedRegs(const MachineFunction &MF) const override;
|
||||
|
||||
|
|
|
@ -1342,6 +1342,35 @@ SDValue SITargetLowering::performUCharToFloatCombine(SDNode *N,
|
|||
return SDValue();
|
||||
}
|
||||
|
||||
/// \brief Return true if the given offset Size in bytes can be folded into
|
||||
/// the immediate offsets of a memory instruction for the given address space.
|
||||
static bool canFoldOffset(unsigned OffsetSize, unsigned AS,
|
||||
const AMDGPUSubtarget &STI) {
|
||||
switch (AS) {
|
||||
case AMDGPUAS::GLOBAL_ADDRESS: {
|
||||
// MUBUF instructions a 12-bit offset in bytes.
|
||||
return isUInt<12>(OffsetSize);
|
||||
}
|
||||
case AMDGPUAS::CONSTANT_ADDRESS: {
|
||||
// SMRD instructions have an 8-bit offset in dwords on SI and
|
||||
// a 20-bit offset in bytes on VI.
|
||||
if (STI.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS)
|
||||
return isUInt<20>(OffsetSize);
|
||||
else
|
||||
return (OffsetSize % 4 == 0) && isUInt<8>(OffsetSize / 4);
|
||||
}
|
||||
case AMDGPUAS::LOCAL_ADDRESS:
|
||||
case AMDGPUAS::REGION_ADDRESS: {
|
||||
// The single offset versions have a 16-bit offset in bytes.
|
||||
return isUInt<16>(OffsetSize);
|
||||
}
|
||||
case AMDGPUAS::PRIVATE_ADDRESS:
|
||||
// Indirect register addressing does not use any offsets.
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// (shl (add x, c1), c2) -> add (shl x, c2), (shl c1, c2)
|
||||
|
||||
// This is a variant of
|
||||
|
@ -1373,13 +1402,10 @@ SDValue SITargetLowering::performSHLPtrCombine(SDNode *N,
|
|||
if (!CAdd)
|
||||
return SDValue();
|
||||
|
||||
const SIInstrInfo *TII =
|
||||
static_cast<const SIInstrInfo *>(Subtarget->getInstrInfo());
|
||||
|
||||
// If the resulting offset is too large, we can't fold it into the addressing
|
||||
// mode offset.
|
||||
APInt Offset = CAdd->getAPIntValue() << CN1->getAPIntValue();
|
||||
if (!TII->canFoldOffset(Offset.getZExtValue(), AddrSpace))
|
||||
if (!canFoldOffset(Offset.getZExtValue(), AddrSpace, *Subtarget))
|
||||
return SDValue();
|
||||
|
||||
SelectionDAG &DAG = DCI.DAG;
|
||||
|
|
|
@ -259,7 +259,8 @@ void SIInsertWaits::pushInstruction(MachineBasicBlock &MBB,
|
|||
return;
|
||||
}
|
||||
|
||||
if (TRI->ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) {
|
||||
if (MBB.getParent()->getSubtarget<AMDGPUSubtarget>().getGeneration() >=
|
||||
AMDGPUSubtarget::VOLCANIC_ISLANDS) {
|
||||
// Any occurence of consecutive VMEM or SMEM instructions forms a VMEM
|
||||
// or SMEM clause, respectively.
|
||||
//
|
||||
|
@ -412,7 +413,8 @@ Counters SIInsertWaits::handleOperands(MachineInstr &MI) {
|
|||
|
||||
void SIInsertWaits::handleSendMsg(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I) {
|
||||
if (TRI->ST.getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS)
|
||||
if (MBB.getParent()->getSubtarget<AMDGPUSubtarget>().getGeneration() <
|
||||
AMDGPUSubtarget::VOLCANIC_ISLANDS)
|
||||
return;
|
||||
|
||||
// There must be "S_NOP 0" between an instruction writing M0 and S_SENDMSG.
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
using namespace llvm;
|
||||
|
||||
SIInstrInfo::SIInstrInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPUInstrInfo(st), RI(st) {}
|
||||
: AMDGPUInstrInfo(st), RI() {}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TargetInstrInfo callbacks
|
||||
|
@ -1169,32 +1169,6 @@ bool SIInstrInfo::isImmOperandLegal(const MachineInstr *MI, unsigned OpNo,
|
|||
return RI.opCanUseInlineConstant(OpInfo.OperandType);
|
||||
}
|
||||
|
||||
bool SIInstrInfo::canFoldOffset(unsigned OffsetSize, unsigned AS) const {
|
||||
switch (AS) {
|
||||
case AMDGPUAS::GLOBAL_ADDRESS: {
|
||||
// MUBUF instructions a 12-bit offset in bytes.
|
||||
return isUInt<12>(OffsetSize);
|
||||
}
|
||||
case AMDGPUAS::CONSTANT_ADDRESS: {
|
||||
// SMRD instructions have an 8-bit offset in dwords on SI and
|
||||
// a 20-bit offset in bytes on VI.
|
||||
if (RI.ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS)
|
||||
return isUInt<20>(OffsetSize);
|
||||
else
|
||||
return (OffsetSize % 4 == 0) && isUInt<8>(OffsetSize / 4);
|
||||
}
|
||||
case AMDGPUAS::LOCAL_ADDRESS:
|
||||
case AMDGPUAS::REGION_ADDRESS: {
|
||||
// The single offset versions have a 16-bit offset in bytes.
|
||||
return isUInt<16>(OffsetSize);
|
||||
}
|
||||
case AMDGPUAS::PRIVATE_ADDRESS:
|
||||
// Indirect register addressing does not use any offsets.
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool SIInstrInfo::hasVALU32BitEncoding(unsigned Opcode) const {
|
||||
int Op32 = AMDGPU::getVOPe32(Opcode);
|
||||
if (Op32 == -1)
|
||||
|
@ -1918,7 +1892,9 @@ void SIInstrInfo::splitSMRD(MachineInstr *MI,
|
|||
|
||||
bool IsKill = SBase->isKill();
|
||||
if (OffOp) {
|
||||
bool isVI = RI.ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS;
|
||||
bool isVI =
|
||||
MBB->getParent()->getSubtarget<AMDGPUSubtarget>().getGeneration() >=
|
||||
AMDGPUSubtarget::VOLCANIC_ISLANDS;
|
||||
unsigned OffScale = isVI ? 1 : 4;
|
||||
// Handle the _IMM variant
|
||||
unsigned LoOffset = OffOp->getImm() * OffScale;
|
||||
|
@ -2011,7 +1987,8 @@ void SIInstrInfo::moveSMRDToVALU(MachineInstr *MI, MachineRegisterInfo &MRI) con
|
|||
// SMRD instructions take a dword offsets on SI and byte offset on VI
|
||||
// and MUBUF instructions always take a byte offset.
|
||||
ImmOffset = MI->getOperand(2).getImm();
|
||||
if (RI.ST.getGeneration() <= AMDGPUSubtarget::SEA_ISLANDS)
|
||||
if (MBB->getParent()->getSubtarget<AMDGPUSubtarget>().getGeneration() <=
|
||||
AMDGPUSubtarget::SEA_ISLANDS)
|
||||
ImmOffset <<= 2;
|
||||
RegOffset = MRI.createVirtualRegister(&AMDGPU::SGPR_32RegClass);
|
||||
|
||||
|
|
|
@ -218,10 +218,6 @@ public:
|
|||
bool isImmOperandLegal(const MachineInstr *MI, unsigned OpNo,
|
||||
const MachineOperand &MO) const;
|
||||
|
||||
/// \brief Return true if the given offset Size in bytes can be folded into
|
||||
/// the immediate offsets of a memory instruction for the given address space.
|
||||
bool canFoldOffset(unsigned OffsetSize, unsigned AS) const;
|
||||
|
||||
/// \brief Return true if this 64-bit VALU instruction has a 32-bit encoding.
|
||||
/// This function will return false if you pass it a 32-bit instruction.
|
||||
bool hasVALU32BitEncoding(unsigned Opcode) const;
|
||||
|
|
|
@ -24,9 +24,7 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
SIRegisterInfo::SIRegisterInfo(const AMDGPUSubtarget &st)
|
||||
: AMDGPURegisterInfo(st)
|
||||
{ }
|
||||
SIRegisterInfo::SIRegisterInfo() : AMDGPURegisterInfo() {}
|
||||
|
||||
BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
||||
BitVector Reserved(getNumRegs());
|
||||
|
@ -48,7 +46,7 @@ BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
|||
|
||||
// Tonga and Iceland can only allocate a fixed number of SGPRs due
|
||||
// to a hw bug.
|
||||
if (ST.hasSGPRInitBug()) {
|
||||
if (MF.getSubtarget<AMDGPUSubtarget>().hasSGPRInitBug()) {
|
||||
unsigned NumSGPRs = AMDGPU::SGPR_32RegClass.getNumRegs();
|
||||
// Reserve some SGPRs for FLAT_SCRATCH and VCC (4 SGPRs).
|
||||
// Assume XNACK_MASK is unused.
|
||||
|
@ -69,10 +67,11 @@ BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
|||
unsigned SIRegisterInfo::getRegPressureSetLimit(const MachineFunction &MF,
|
||||
unsigned Idx) const {
|
||||
|
||||
const AMDGPUSubtarget &STI = MF.getSubtarget<AMDGPUSubtarget>();
|
||||
// FIXME: We should adjust the max number of waves based on LDS size.
|
||||
unsigned SGPRLimit = getNumSGPRsAllowed(ST.getGeneration(),
|
||||
ST.getMaxWavesPerCU());
|
||||
unsigned VGPRLimit = getNumVGPRsAllowed(ST.getMaxWavesPerCU());
|
||||
unsigned SGPRLimit = getNumSGPRsAllowed(STI.getGeneration(),
|
||||
STI.getMaxWavesPerCU());
|
||||
unsigned VGPRLimit = getNumVGPRsAllowed(STI.getMaxWavesPerCU());
|
||||
|
||||
for (regclass_iterator I = regclass_begin(), E = regclass_end();
|
||||
I != E; ++I) {
|
||||
|
@ -143,9 +142,10 @@ void SIRegisterInfo::buildScratchLoadStore(MachineBasicBlock::iterator MI,
|
|||
int64_t Offset,
|
||||
RegScavenger *RS) const {
|
||||
|
||||
const SIInstrInfo *TII = static_cast<const SIInstrInfo*>(ST.getInstrInfo());
|
||||
MachineBasicBlock *MBB = MI->getParent();
|
||||
const MachineFunction *MF = MI->getParent()->getParent();
|
||||
const SIInstrInfo *TII =
|
||||
static_cast<const SIInstrInfo *>(MF->getSubtarget().getInstrInfo());
|
||||
LLVMContext &Ctx = MF->getFunction()->getContext();
|
||||
DebugLoc DL = MI->getDebugLoc();
|
||||
bool IsLoad = TII->get(LoadStoreOp).mayLoad();
|
||||
|
@ -196,7 +196,8 @@ void SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
|
|||
MachineBasicBlock *MBB = MI->getParent();
|
||||
SIMachineFunctionInfo *MFI = MF->getInfo<SIMachineFunctionInfo>();
|
||||
MachineFrameInfo *FrameInfo = MF->getFrameInfo();
|
||||
const SIInstrInfo *TII = static_cast<const SIInstrInfo*>(ST.getInstrInfo());
|
||||
const SIInstrInfo *TII =
|
||||
static_cast<const SIInstrInfo *>(MF->getSubtarget().getInstrInfo());
|
||||
DebugLoc DL = MI->getDebugLoc();
|
||||
|
||||
MachineOperand &FIOp = MI->getOperand(FIOperandNum);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace llvm {
|
|||
|
||||
struct SIRegisterInfo : public AMDGPURegisterInfo {
|
||||
|
||||
SIRegisterInfo(const AMDGPUSubtarget &st);
|
||||
SIRegisterInfo();
|
||||
|
||||
BitVector getReservedRegs(const MachineFunction &MF) const override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue