diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -1113,7 +1113,8 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const MachineFunction &MF) { auto *MD = getTargetStreamer()->getPALMetadata(); const MachineFrameInfo &MFI = MF.getFrameInfo(); - MD->setFunctionScratchSize(MF, MFI.getStackSize()); + StringRef FnName = MF.getFunction().getName(); + MD->setFunctionScratchSize(FnName, MFI.getStackSize()); // Set compute registers MD->setRsrc1(CallingConv::AMDGPU_CS, @@ -1121,9 +1122,9 @@ MD->setRsrc2(CallingConv::AMDGPU_CS, CurrentProgramInfo.getComputePGMRSrc2()); // Set optional info - MD->setFunctionLdsSize(MF, CurrentProgramInfo.LDSSize); - MD->setFunctionNumUsedVgprs(MF, CurrentProgramInfo.NumVGPRsForWavesPerEU); - MD->setFunctionNumUsedSgprs(MF, CurrentProgramInfo.NumSGPRsForWavesPerEU); + MD->setFunctionLdsSize(FnName, CurrentProgramInfo.LDSSize); + MD->setFunctionNumUsedVgprs(FnName, CurrentProgramInfo.NumVGPRsForWavesPerEU); + MD->setFunctionNumUsedSgprs(FnName, CurrentProgramInfo.NumSGPRsForWavesPerEU); } // This is supposed to be log2(Size) diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp @@ -193,6 +193,7 @@ }; } + AMDGPURegisterBankInfo::AMDGPURegisterBankInfo(const GCNSubtarget &ST) : Subtarget(ST), TRI(Subtarget.getRegisterInfo()), TII(Subtarget.getInstrInfo()) { diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp @@ -10,13 +10,13 @@ #include "AMDGPUInstPrinter.h" #include "MCTargetDesc/AMDGPUMCTargetDesc.h" #include "SIDefines.h" -#include "SIRegisterInfo.h" #include "Utils/AMDGPUAsmUtils.h" #include "Utils/AMDGPUBaseInfo.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstrDesc.h" #include "llvm/MC/MCInstrInfo.h" +#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/TargetParser/TargetParser.h" diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h --- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h +++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h @@ -445,6 +445,11 @@ unsigned SubReg) const; }; +namespace AMDGPU { +/// Get the size in bits of a register from the register class \p RC. +unsigned getRegBitWidth(const TargetRegisterClass &RC); +} // namespace AMDGPU + } // End namespace llvm #endif diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp @@ -2568,6 +2568,10 @@ return AMDGPUInstPrinter::getRegisterName(Reg); } +unsigned AMDGPU::getRegBitWidth(const TargetRegisterClass &RC) { + return getRegBitWidth(RC.getID()); +} + static const TargetRegisterClass * getAnyVGPRClassForBitWidth(unsigned BitWidth) { if (BitWidth == 64) diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h @@ -31,7 +31,6 @@ class MCRegisterInfo; class MCSubtargetInfo; class StringRef; -class TargetRegisterClass; class Triple; class raw_ostream; @@ -1202,9 +1201,6 @@ /// Get the size in bits of a register from the register class \p RC. unsigned getRegBitWidth(const MCRegisterClass &RC); -/// Get the size in bits of a register from the register class \p RC. -unsigned getRegBitWidth(const TargetRegisterClass &RC); - /// Get size of register operand unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc, unsigned OpNo); diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp @@ -12,7 +12,6 @@ #include "AMDKernelCodeT.h" #include "MCTargetDesc/AMDGPUMCTargetDesc.h" #include "llvm/BinaryFormat/ELF.h" -#include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Function.h" @@ -2423,10 +2422,6 @@ return getRegBitWidth(RC.getID()); } -unsigned getRegBitWidth(const TargetRegisterClass &RC) { - return getRegBitWidth(RC.getID()); -} - unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc, unsigned OpNo) { assert(OpNo < Desc.NumOperands); diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h @@ -17,7 +17,6 @@ namespace llvm { -class MachineFunction; class Module; class StringRef; @@ -87,22 +86,22 @@ void setScratchSize(unsigned CC, unsigned Val); // Set the stack frame size of a function in the metadata. - void setFunctionScratchSize(const MachineFunction &MF, unsigned Val); + void setFunctionScratchSize(StringRef FnName, unsigned Val); // Set the amount of LDS used in bytes in the metadata. This is an optional // advisory record for logging etc; wave dispatch actually uses the rsrc1 // register for the shader stage to determine the amount of LDS to allocate. - void setFunctionLdsSize(const MachineFunction &MF, unsigned Val); + void setFunctionLdsSize(StringRef FnName, unsigned Val); // Set the number of used vgprs in the metadata. This is an optional advisory // record for logging etc; wave dispatch actually uses the rsrc1 register for // the shader stage to determine the number of vgprs to allocate. - void setFunctionNumUsedVgprs(const MachineFunction &MF, unsigned Val); + void setFunctionNumUsedVgprs(StringRef FnName, unsigned Val); // Set the number of used sgprs in the metadata. This is an optional advisory // record for logging etc; wave dispatch actually uses the rsrc1 register for // the shader stage to determine the number of sgprs to allocate. - void setFunctionNumUsedSgprs(const MachineFunction &MF, unsigned Val); + void setFunctionNumUsedSgprs(StringRef FnName, unsigned Val); // Set the hardware register bit in PAL metadata to enable wave32 on the // shader of the given calling convention. diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp @@ -18,7 +18,6 @@ #include "AMDGPUPTNote.h" #include "SIDefines.h" #include "llvm/BinaryFormat/ELF.h" -#include "llvm/CodeGen/MachineFunction.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Module.h" #include "llvm/Support/AMDGPUMetadata.h" @@ -242,30 +241,28 @@ } // Set the stack frame size of a function in the metadata. -void AMDGPUPALMetadata::setFunctionScratchSize(const MachineFunction &MF, - unsigned Val) { - auto Node = getShaderFunction(MF.getFunction().getName()); +void AMDGPUPALMetadata::setFunctionScratchSize(StringRef FnName, unsigned Val) { + auto Node = getShaderFunction(FnName); Node[".stack_frame_size_in_bytes"] = MsgPackDoc.getNode(Val); } // Set the amount of LDS used in bytes in the metadata. -void AMDGPUPALMetadata::setFunctionLdsSize(const MachineFunction &MF, - unsigned Val) { - auto Node = getShaderFunction(MF.getFunction().getName()); +void AMDGPUPALMetadata::setFunctionLdsSize(StringRef FnName, unsigned Val) { + auto Node = getShaderFunction(FnName); Node[".lds_size"] = MsgPackDoc.getNode(Val); } // Set the number of used vgprs in the metadata. -void AMDGPUPALMetadata::setFunctionNumUsedVgprs(const MachineFunction &MF, +void AMDGPUPALMetadata::setFunctionNumUsedVgprs(StringRef FnName, unsigned Val) { - auto Node = getShaderFunction(MF.getFunction().getName()); + auto Node = getShaderFunction(FnName); Node[".vgpr_count"] = MsgPackDoc.getNode(Val); } // Set the number of used vgprs in the metadata. -void AMDGPUPALMetadata::setFunctionNumUsedSgprs(const MachineFunction &MF, +void AMDGPUPALMetadata::setFunctionNumUsedSgprs(StringRef FnName, unsigned Val) { - auto Node = getShaderFunction(MF.getFunction().getName()); + auto Node = getShaderFunction(FnName); Node[".sgpr_count"] = MsgPackDoc.getNode(Val); }