From a75e67b3b4885efdb6a0b0b2939cccb5a9e67b72 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Wed, 26 Aug 2020 14:53:41 +0100 Subject: [PATCH] [AMDGPU] Make more use of Subtarget reference in SIInstrInfo --- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp index 68b5b0e9a18b..0230bfe5fe79 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -991,8 +991,6 @@ void SIInstrInfo::insertVectorSelect(MachineBasicBlock &MBB, Register TrueReg, Register FalseReg) const { MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo(); - MachineFunction *MF = MBB.getParent(); - const GCNSubtarget &ST = MF->getSubtarget(); const TargetRegisterClass *BoolXExecRC = RI.getRegClass(AMDGPU::SReg_1_XEXECRegClassID); assert(MRI.getRegClass(DstReg) == &AMDGPU::VGPR_32RegClass && @@ -1496,7 +1494,6 @@ unsigned SIInstrInfo::calculateLDSSpillAddress( unsigned FrameOffset, unsigned Size) const { MachineFunction *MF = MBB.getParent(); SIMachineFunctionInfo *MFI = MF->getInfo(); - const GCNSubtarget &ST = MF->getSubtarget(); const DebugLoc &DL = MBB.findDebugLoc(MI); unsigned WorkGroupSize = MFI->getMaxFlatWorkGroupSize(); unsigned WavefrontSize = ST.getWavefrontSize(); @@ -3312,9 +3309,6 @@ bool SIInstrInfo::isImmOperandLegal(const MachineInstr &MI, unsigned OpNo, if (OpInfo.RegClass < 0) return false; - const MachineFunction *MF = MI.getParent()->getParent(); - const GCNSubtarget &ST = MF->getSubtarget(); - if (MO.isImm() && isInlineConstant(MO, OpInfo)) { if (isMAI(MI) && ST.hasMFMAInlineLiteralBug() && OpNo ==(unsigned)AMDGPU::getNamedOperandIdx(MI.getOpcode(), @@ -3849,7 +3843,6 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI, } } } - const GCNSubtarget &ST = MF->getSubtarget(); // v_writelane_b32 is an exception from constant bus restriction: // vsrc0 can be sgpr, const or m0 and lane select sgpr, m0 or inline-const if (ConstantBusCount > ST.getConstantBusLimit(Opcode) && @@ -4017,7 +4010,7 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI, } } - if (isFLAT(MI) && !MF->getSubtarget().hasFlatInstOffsets()) { + if (isFLAT(MI) && !ST.hasFlatInstOffsets()) { const MachineOperand *Offset = getNamedOperand(MI, AMDGPU::OpName::offset); if (Offset->getImm() != 0) { ErrInfo = "subtarget does not support offsets in flat instructions"; @@ -4236,11 +4229,9 @@ void SIInstrInfo::legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const { MachineBasicBlock *MBB = MI.getParent(); MachineOperand &MO = MI.getOperand(OpIdx); MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo(); - const SIRegisterInfo *TRI = - static_cast(MRI.getTargetRegisterInfo()); unsigned RCID = get(MI.getOpcode()).OpInfo[OpIdx].RegClass; const TargetRegisterClass *RC = RI.getRegClass(RCID); - unsigned Size = TRI->getRegSizeInBits(*RC); + unsigned Size = RI.getRegSizeInBits(*RC); unsigned Opcode = (Size == 64) ? AMDGPU::V_MOV_B64_PSEUDO : AMDGPU::V_MOV_B32_e32; if (MO.isReg()) Opcode = AMDGPU::COPY; @@ -4361,7 +4352,6 @@ bool SIInstrInfo::isOperandLegal(const MachineInstr &MI, unsigned OpIdx, const MachineRegisterInfo &MRI = MF.getRegInfo(); const MCInstrDesc &InstDesc = MI.getDesc(); const MCOperandInfo &OpInfo = InstDesc.OpInfo[OpIdx]; - const GCNSubtarget &ST = MF.getSubtarget(); const TargetRegisterClass *DefinedRC = OpInfo.RegClass != -1 ? RI.getRegClass(OpInfo.RegClass) : nullptr; if (!MO) @@ -5181,8 +5171,7 @@ void SIInstrInfo::legalizeOperands(MachineInstr &MI, } else if (!VAddr && ST.hasAddr64()) { // This instructions is the _OFFSET variant, so we need to convert it to // ADDR64. - assert(MBB.getParent()->getSubtarget().getGeneration() - < AMDGPUSubtarget::VOLCANIC_ISLANDS && + assert(ST.getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS && "FIXME: Need to emit flat atomics here"); unsigned RsrcPtr, NewSRsrc; @@ -6663,8 +6652,7 @@ unsigned SIInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const { case TargetOpcode::INLINEASM_BR: { const MachineFunction *MF = MI.getParent()->getParent(); const char *AsmStr = MI.getOperand(0).getSymbolName(); - return getInlineAsmLength(AsmStr, *MF->getTarget().getMCAsmInfo(), - &MF->getSubtarget()); + return getInlineAsmLength(AsmStr, *MF->getTarget().getMCAsmInfo(), &ST); } default: return DescSize;