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