89 std::unique_ptr<MCStreamer> &&Streamer) {
101 std::unique_ptr<MCStreamer> Streamer)
110 return "AMDGPU Assembly Printer";
125 std::string ExpectedTarget;
137 HSAMetadataStream->begin(M);
162 std::string ISAVersionString;
170 HSAMetadataStream->end();
173 assert(Success &&
"Malformed HSA Metadata");
202 getAmdKernelCode(KernelCode, CurrentProgramInfo, *
MF);
207 HSAMetadataStream->emitKernel(*
MF, CurrentProgramInfo);
220 auto &
Context = Streamer.getContext();
221 auto &ObjectFileInfo = *
Context.getObjectFileInfo();
222 auto &ReadOnlySection = *ObjectFileInfo.getReadOnlySection();
224 Streamer.PushSection();
225 Streamer.SwitchSection(&ReadOnlySection);
229 Streamer.EmitValueToAlignment(64, 0, 1, 0);
230 if (ReadOnlySection.getAlignment() < 64)
231 ReadOnlySection.setAlignment(
Align(64));
238 STI, KernelName, getAmdhsaKernelDescriptor(*
MF, CurrentProgramInfo),
247 Streamer.PopSection();
265 if (DumpCodeInstEmitter) {
292 ": unsupported initializer for address space");
306 "' is already defined");
317 TS->emitAMDGPULDS(GVSym, Size, Align);
325 CallGraphResourceInfo.clear();
342 void AMDGPUAsmPrinter::emitCommonFunctionComments(
347 uint64_t ScratchSize,
363 uint16_t AMDGPUAsmPrinter::getAmdhsaKernelCodeProperties(
369 KernelCodeProperties |=
370 amdhsa::KERNEL_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER;
373 KernelCodeProperties |=
374 amdhsa::KERNEL_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_PTR;
377 KernelCodeProperties |=
378 amdhsa::KERNEL_CODE_PROPERTY_ENABLE_SGPR_QUEUE_PTR;
381 KernelCodeProperties |=
382 amdhsa::KERNEL_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR;
385 KernelCodeProperties |=
386 amdhsa::KERNEL_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_ID;
389 KernelCodeProperties |=
390 amdhsa::KERNEL_CODE_PROPERTY_ENABLE_SGPR_FLAT_SCRATCH_INIT;
393 KernelCodeProperties |=
394 amdhsa::KERNEL_CODE_PROPERTY_ENABLE_WAVEFRONT_SIZE32;
397 return KernelCodeProperties;
404 memset(&KernelDescriptor, 0x0,
sizeof(KernelDescriptor));
416 return KernelDescriptor;
440 getSIProgramInfo(CurrentProgramInfo, MF);
442 auto I = CallGraphResourceInfo.insert(
443 std::make_pair(&MF.
getFunction(), SIFunctionResourceInfo()));
444 SIFunctionResourceInfo &
Info =
I.first->second;
445 assert(
I.second &&
"should only be called once per function");
446 Info = analyzeResourceUsage(MF);
450 EmitPALMetadata(MF, CurrentProgramInfo);
452 EmitProgramInfoSI(MF, CurrentProgramInfo);
455 DumpCodeInstEmitter =
nullptr;
459 bool SaveFlag =
OutStreamer->getUseAssemblerInfoForParsing();
462 OutStreamer->setUseAssemblerInfoForParsing(SaveFlag);
479 OutStreamer->emitRawComment(
" Function info:",
false);
480 SIFunctionResourceInfo &
Info = CallGraphResourceInfo[&MF.
getFunction()];
481 emitCommonFunctionComments(
484 Info.getTotalNumVGPRs(STM),
486 Info.PrivateSegmentSize,
487 getFunctionCodeSize(MF), MFI);
491 OutStreamer->emitRawComment(
" Kernel info:",
false);
492 emitCommonFunctionComments(CurrentProgramInfo.
NumArchVGPR,
499 getFunctionCodeSize(MF), MFI);
507 " bytes/workgroup (compile time only)",
false);
515 " NumSGPRsForWavesPerEU: " +
518 " NumVGPRsForWavesPerEU: " +
529 " COMPUTE_PGM_RSRC2:USER_SGPR: " +
532 " COMPUTE_PGM_RSRC2:TRAP_HANDLER: " +
535 " COMPUTE_PGM_RSRC2:TGID_X_EN: " +
538 " COMPUTE_PGM_RSRC2:TGID_Y_EN: " +
541 " COMPUTE_PGM_RSRC2:TGID_Z_EN: " +
544 " COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: " +
549 if (DumpCodeInstEmitter) {
555 std::string Comment =
"\n";
558 Comment +=
" ; " +
HexLines[i] +
"\n";
569 uint64_t AMDGPUAsmPrinter::getFunctionCodeSize(
const MachineFunction &MF)
const {
573 uint64_t CodeSize = 0;
580 if (
MI.isDebugInstr())
594 if (!UseOp.isImplicit() || !TII.
isFLAT(*UseOp.getParent()))
604 UsesVCC, UsesFlatScratch);
612 AMDGPUAsmPrinter::SIFunctionResourceInfo AMDGPUAsmPrinter::analyzeResourceUsage(
614 SIFunctionResourceInfo
Info;
623 Info.UsesFlatScratch = MRI.
isPhysRegUsed(AMDGPU::FLAT_SCR_LO) ||
636 Info.UsesFlatScratch =
false;
639 Info.HasDynamicallySizedStack = FrameInfo.hasVarSizedObjects();
640 Info.PrivateSegmentSize = FrameInfo.getStackSize();
642 Info.PrivateSegmentSize += FrameInfo.getMaxAlignment();
651 if (!FrameInfo.hasCalls() && !FrameInfo.hasTailCall()) {
652 MCPhysReg HighestVGPRReg = AMDGPU::NoRegister;
655 HighestVGPRReg =
Reg;
660 if (ST.hasMAIInsts()) {
661 MCPhysReg HighestAGPRReg = AMDGPU::NoRegister;
664 HighestAGPRReg =
Reg;
668 Info.NumAGPR = HighestAGPRReg == AMDGPU::NoRegister ? 0 :
672 MCPhysReg HighestSGPRReg = AMDGPU::NoRegister;
675 HighestSGPRReg =
Reg;
682 Info.NumVGPR = HighestVGPRReg == AMDGPU::NoRegister ? 0 :
684 Info.NumExplicitSGPR = HighestSGPRReg == AMDGPU::NoRegister ? 0 :
690 int32_t MaxVGPR = -1;
691 int32_t MaxAGPR = -1;
692 int32_t MaxSGPR = -1;
693 uint64_t CalleeFrameSize = 0;
709 case AMDGPU::EXEC_LO:
710 case AMDGPU::EXEC_HI:
713 case AMDGPU::SRC_SHARED_BASE:
714 case AMDGPU::SRC_SHARED_LIMIT:
715 case AMDGPU::SRC_PRIVATE_BASE:
716 case AMDGPU::SRC_PRIVATE_LIMIT:
717 case AMDGPU::SGPR_NULL:
720 case AMDGPU::SRC_POPS_EXITING_WAVE_ID:
723 case AMDGPU::NoRegister:
733 case AMDGPU::FLAT_SCR:
734 case AMDGPU::FLAT_SCR_LO:
735 case AMDGPU::FLAT_SCR_HI:
738 case AMDGPU::XNACK_MASK:
739 case AMDGPU::XNACK_MASK_LO:
740 case AMDGPU::XNACK_MASK_HI:
743 case AMDGPU::LDS_DIRECT:
754 case AMDGPU::SRC_VCCZ:
757 case AMDGPU::SRC_EXECZ:
760 case AMDGPU::SRC_SCC:
767 if (AMDGPU::SReg_32RegClass.
contains(Reg)) {
769 "trap handler registers should not be used");
772 }
else if (AMDGPU::VGPR_32RegClass.
contains(Reg)) {
775 }
else if (AMDGPU::AGPR_32RegClass.
contains(Reg)) {
779 }
else if (AMDGPU::SReg_64RegClass.
contains(Reg)) {
781 "trap handler registers should not be used");
784 }
else if (AMDGPU::VReg_64RegClass.
contains(Reg)) {
787 }
else if (AMDGPU::AReg_64RegClass.
contains(Reg)) {
791 }
else if (AMDGPU::VReg_96RegClass.
contains(Reg)) {
794 }
else if (AMDGPU::SReg_96RegClass.
contains(Reg)) {
797 }
else if (AMDGPU::SReg_128RegClass.
contains(Reg)) {
799 "trap handler registers should not be used");
802 }
else if (AMDGPU::VReg_128RegClass.
contains(Reg)) {
805 }
else if (AMDGPU::AReg_128RegClass.
contains(Reg)) {
809 }
else if (AMDGPU::VReg_160RegClass.
contains(Reg)) {
812 }
else if (AMDGPU::SReg_160RegClass.
contains(Reg)) {
815 }
else if (AMDGPU::SReg_256RegClass.
contains(Reg)) {
817 "trap handler registers should not be used");
820 }
else if (AMDGPU::VReg_256RegClass.
contains(Reg)) {
823 }
else if (AMDGPU::SReg_512RegClass.
contains(Reg)) {
825 "trap handler registers should not be used");
828 }
else if (AMDGPU::VReg_512RegClass.
contains(Reg)) {
831 }
else if (AMDGPU::AReg_512RegClass.
contains(Reg)) {
835 }
else if (AMDGPU::SReg_1024RegClass.
contains(Reg)) {
838 }
else if (AMDGPU::VReg_1024RegClass.
contains(Reg)) {
841 }
else if (AMDGPU::AReg_1024RegClass.
contains(Reg)) {
849 int MaxUsed = HWReg + Width - 1;
851 MaxSGPR = MaxUsed > MaxSGPR ? MaxUsed : MaxSGPR;
853 MaxAGPR = MaxUsed > MaxAGPR ? MaxUsed : MaxAGPR;
855 MaxVGPR = MaxUsed > MaxVGPR ? MaxUsed : MaxVGPR;
873 MaxSGPR =
std::max(MaxSGPR, MaxSGPRGuess);
877 CalleeFrameSize =
std::max(CalleeFrameSize, UINT64_C(16384));
879 Info.UsesFlatScratch = ST.hasFlatAddressSpace();
880 Info.HasDynamicallySizedStack =
true;
885 auto I = CallGraphResourceInfo.find(Callee);
886 if (
I == CallGraphResourceInfo.end()) {
898 MaxSGPR =
std::max(
I->second.NumExplicitSGPR - 1, MaxSGPR);
899 MaxVGPR =
std::max(
I->second.NumVGPR - 1, MaxVGPR);
900 MaxAGPR =
std::max(
I->second.NumAGPR - 1, MaxAGPR);
902 =
std::max(
I->second.PrivateSegmentSize, CalleeFrameSize);
903 Info.UsesVCC |=
I->second.UsesVCC;
904 Info.UsesFlatScratch |=
I->second.UsesFlatScratch;
905 Info.HasDynamicallySizedStack |=
I->second.HasDynamicallySizedStack;
906 Info.HasRecursion |=
I->second.HasRecursion;
910 Info.HasRecursion =
true;
915 Info.NumExplicitSGPR = MaxSGPR + 1;
916 Info.NumVGPR = MaxVGPR + 1;
917 Info.NumAGPR = MaxAGPR + 1;
918 Info.PrivateSegmentSize += CalleeFrameSize;
923 void AMDGPUAsmPrinter::getSIProgramInfo(
SIProgramInfo &ProgInfo,
925 SIFunctionResourceInfo
Info = analyzeResourceUsage(MF);
930 ProgInfo.
NumVGPR = Info.getTotalNumVGPRs(STM);
931 ProgInfo.
NumSGPR = Info.NumExplicitSGPR;
933 ProgInfo.
VCCUsed = Info.UsesVCC;
934 ProgInfo.
FlatUsed = Info.UsesFlatScratch;
935 ProgInfo.
DynamicCallStack = Info.HasDynamicallySizedStack || Info.HasRecursion;
955 if (ProgInfo.
NumSGPR > MaxAddressableNumSGPRs) {
959 "addressable scalar registers",
962 MaxAddressableNumSGPRs);
964 ProgInfo.
NumSGPR = MaxAddressableNumSGPRs - 1;
969 ProgInfo.
NumSGPR += ExtraSGPRs;
973 unsigned WaveDispatchNumSGPR = 0, WaveDispatchNumVGPR = 0;
975 unsigned NumRegs = (
Arg.getType()->getPrimitiveSizeInBits() + 31) / 32;
976 if (
Arg.hasAttribute(Attribute::InReg))
977 WaveDispatchNumSGPR += NumRegs;
979 WaveDispatchNumVGPR += NumRegs;
994 if (ProgInfo.
NumSGPR > MaxAddressableNumSGPRs) {
1002 MaxAddressableNumSGPRs);
1004 ProgInfo.
NumSGPR = MaxAddressableNumSGPRs;
1046 unsigned LDSAlignShift;
1055 unsigned LDSSpillSize =
1060 alignTo(ProgInfo.
LDSSize, 1ULL << LDSAlignShift) >> LDSAlignShift;
1063 unsigned ScratchAlignShift = 10;
1069 1ULL << ScratchAlignShift) >>
1090 unsigned TIDIGCompCnt = 0;
1245 if (MFI->hasPrivateSegmentBuffer()) {
1250 if (MFI->hasDispatchPtr())
1253 if (MFI->hasQueuePtr())
1256 if (MFI->hasKernargSegmentPtr())
1259 if (MFI->hasDispatchID())
1262 if (MFI->hasFlatScratchInit())
1265 if (MFI->hasDispatchPtr())
1268 if (STM.isXNACKEnabled())
1271 Align MaxKernArgAlign;
1289 if (ExtraCode && ExtraCode[0]) {
1290 if (ExtraCode[1] != 0)
1293 switch (ExtraCode[0]) {
virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
bool hasDispatchPtr() const
unsigned Log2(Align A)
Returns the log2 of the alignment.
constexpr bool isUInt< 32 >(uint64_t x)
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
unsigned getAlignment() const
void EmitGlobalVariable(const GlobalVariable *GV) override
Emit the specified global variable to the .s file.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Interface definition for SIRegisterInfo.
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
Target & getTheGCNTarget()
The target for GCN GPUs.
bool hasPrivateSegmentBuffer() const
#define S_00B848_VGPRS(x)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
AMDGPU specific subclass of TargetSubtarget.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
#define FP_DENORM_MODE_SP(x)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
bool isVariable() const
isVariable - Check if this is a variable symbol.
#define R_00B228_SPI_SHADER_PGM_RSRC1_GS
#define G_00B84C_USER_SGPR(x)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MCSubtargetInfo * getGlobalSTI() const
A Module instance is used to store all the information related to an LLVM module. ...
void redefineIfPossible()
Prepare this symbol to be redefined.
bool doFinalization(Module &M) override
Shut down the asmprinter.
unsigned getMaxFlatWorkGroupSize() const
MCContext & OutContext
This is the context for the output file that we are streaming.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
void EmitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
Target & getTheAMDGPUTarget()
The target which supports all AMD GPUs.
#define G_00B84C_TGID_Z_EN(x)
#define R_00B028_SPI_SHADER_PGM_RSRC1_PS
iterator_range< reg_iterator > reg_operands(unsigned Reg) const
virtual void EmitAmdhsaKernelDescriptor(const MCSubtargetInfo &STI, StringRef KernelName, const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR, uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr, bool ReserveXNACK)=0
Instruction set architecture version.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
#define S_00B84C_SCRATCH_EN(x)
const SIInstrInfo * getInstrInfo() const override
#define S_00B84C_TG_SIZE_EN(x)
#define S_00B848_DX10_CLAMP(x)
unsigned getPSInputAddr() const
bool hasWorkItemIDZ() const
#define S_00B848_WGP_MODE(x)
uint32_t NumSGPRsForWavesPerEU
unsigned const TargetRegisterInfo * TRI
MachineFunction * MF
The current machine function.
#define G_00B84C_TGID_Y_EN(x)
Calling convention used for AMDPAL vertex shader if tessellation is in use.
Interface definition for R600RegisterInfo.
unsigned getMinNumSGPRs(unsigned WavesPerEU) const
#define R_0286CC_SPI_PS_INPUT_ENA
bool hasDispatchID() const
#define S_00B028_SGPRS(x)
AsmPrinter * createR600AsmPrinterPass(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer)
Track resource usage for kernels / entry functions.
Calling convention used for Mesa/AMDPAL geometry shaders.
virtual void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type)=0
const SIRegisterInfo & getRegisterInfo() const
return AArch64::GPR64RegClass contains(Reg)
const Triple & getTargetTriple() const
bool hasFlatScratchInit() const
static amd_element_byte_size_t getElementByteSizeValue(unsigned Size)
#define S_00B848_MEM_ORDERED(x)
#define FP_DENORM_FLUSH_NONE
uint32_t code_properties
Code properties.
void setAlignment(Align A)
setAlignment - Set the alignment of the function.
SPIR_KERNEL - Calling convention for SPIR kernel functions.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
static bool isFLAT(const MachineInstr &MI)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
const HexagonInstrInfo * TII
int getLocalMemorySize() const
AMD Kernel Code Object (amd_kernel_code_t).
bool isEntryFunction() const
static void printRegOperand(unsigned RegNo, raw_ostream &O, const MCRegisterInfo &MRI)
bool IEEE
Floating point opcodes that support exception flag gathering quiet and propagate signaling NaN inputs...
#define G_00B84C_TRAP_HANDLER(x)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
AMDGPUAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool isTrapHandlerEnabled() const
uint32_t compute_pgm_rsrc2
#define FP_ROUND_MODE_SP(x)
Diagnostic information for stack size etc.
#define S_00B84C_TGID_Y_EN(x)
uint32_t private_segment_fixed_size
bool hasCodeObjectV3(const MCSubtargetInfo *STI)
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI)
Context object for machine code objects.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
#define S_00B848_FLOAT_MODE(x)
#define R_00B848_COMPUTE_PGM_RSRC1
uint32_t group_segment_fixed_size
uint8_t kernarg_segment_alignment
The maximum byte alignment of variables used by the kernel in the specified memory segment...
void EmitFunctionBody()
This method emits the body and trailer for a function.
virtual bool EmitCodeEnd()=0
unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed, bool FlatScrUsed, bool XNACKUsed)
unsigned getNumSpilledSGPRs() const
unsigned getAddressableNumSGPRs() const
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
#define S_00B84C_TRAP_HANDLER(x)
unsigned getMaxWavesPerEU() const
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
uint16_t kernel_code_properties
bool isVerbose() const
Return true if assembly output should contain comments.
bool hasWorkGroupIDX() const
uint64_t compute_pgm_resource_registers
Shader program settings for CS.
Analysis containing CSE Info
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Calling convention used for Mesa/AMDPAL compute shaders.
uint32_t NumVGPRsForWavesPerEU
bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const override
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
#define S_00B848_IEEE_MODE(x)
bool isCompute(CallingConv::ID cc)
#define S_00B028_VGPRS(x)
uint16_t wavefront_sgpr_count
Number of scalar registers used by a wavefront.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
unsigned const MachineRegisterInfo * MRI
VisibilityTypes getVisibility() const
bool isGFX10(const MCSubtargetInfo &STI)
AMDGPUPALMetadata * getPALMetadata()
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
#define G_00B84C_TGID_X_EN(x)
#define S_00B84C_TIDIG_COMP_CNT(x)
#define FP_ROUND_MODE_DP(x)
const GlobalValue * getGlobal() const
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
bool isEntryFunctionCC(CallingConv::ID CC)
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
void EmitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
AMDGPU::SIModeRegisterDefaults getMode() const
bool isCuModeEnabled() const
unsigned getAddressSpace() const
#define S_00B84C_EXCP_EN_MSB(x)
bool DX10Clamp
Used by the vector ALU to force DX10-style treatment of NaNs: when set, clamp NaN to zero; otherwise...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void reportError(SMLoc L, const Twine &Msg)
bool hasWorkItemIDY() const
Generation getGeneration() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
MCContext & getContext() const
const Triple & getTargetTriple() const
#define R_00B02C_SPI_SHADER_PGM_RSRC2_PS
#define FP_DENORM_FLUSH_IN_FLUSH_OUT
bool hasWorkGroupIDY() const
#define S_00B84C_TGID_Z_EN(x)
The AMDGPU TargetMachine interface definition for hw codgen targets.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
#define R_00B328_SPI_SHADER_PGM_RSRC1_ES
#define S_00B84C_LDS_SIZE(x)
virtual void EmitDirectiveHSACodeObjectISA(uint32_t Major, uint32_t Minor, uint32_t Stepping, StringRef VendorName, StringRef ArchName)=0
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
amd_element_byte_size_t
The values used to define the number of bytes to use for the swizzle element size.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
#define FP_ROUND_ROUND_TO_NEAREST
bool doesNotRecurse() const
Determine if the function is known not to recurse, directly or indirectly.
#define S_00B84C_EXCP_EN(x)
IsaVersion getIsaVersion(StringRef GPU)
unsigned getWavefrontSize() const
#define R_00B428_SPI_SHADER_PGM_RSRC1_HS
AMDGPUTargetStreamer * getTargetStreamer() const
unsigned getFunctionNumber() const
Return a unique ID for the current function.
#define G_00B84C_TIDIG_COMP_CNT(x)
MCStreamer & getStreamer()
void EmitBasicBlockStart(const MachineBasicBlock &MBB) override
Targets can override this to emit stuff at the start of a basic block.
std::vector< std::string > HexLines
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
bool hasKernargSegmentPtr() const
Align max(MaybeAlign Lhs, Align Rhs)
#define R_00B128_SPI_SHADER_PGM_RSRC1_VS
uint64_t kernarg_segment_byte_size
The size in bytes of the kernarg segment that holds the values of the arguments to the kernel...
unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI)
unsigned getLDSSize() const
MCSymbol * getSymbol(const GlobalValue *GV) const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Address space for local memory.
R600 Assembly printer class.
MachineOperand class - Representation of each machine instruction operand.
Calling convention used for Mesa/AMDPAL pixel shaders.
bool isStackRealigned() const
const MCSubtargetInfo * getMCSubtargetInfo() const
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
virtual void EmitAMDKernelCodeT(const amd_kernel_code_t &Header)=0
uint16_t workitem_vgpr_count
Number of vector registers used by each work-item.
bool hasSGPRInitBug() const
#define LLVM_EXTERNAL_VISIBILITY
#define S_00B848_DEBUG_MODE(x)
#define FP_DENORM_MODE_DP(x)
#define S_0286E8_WAVESIZE(x)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
#define S_00B84C_TGID_X_EN(x)
unsigned getNumSpilledVGPRs() const
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
bool isPhysRegUsed(unsigned PhysReg) const
Return true if the specified register is modified or read in this function.
uint32_t workgroup_group_segment_byte_size
The amount of group segment memory required by a work-group in bytes.
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
#define AMD_HSA_BITS_SET(dst, mask, val)
amdgpu Simplify well known AMD library false FunctionCallee Callee
std::vector< std::string > DisasmLines
virtual void EmitDirectiveHSACodeObjectVersion(uint32_t Major, uint32_t Minor)=0
unsigned computeOccupancy(const MachineFunction &MF, unsigned LDSSize=0, unsigned NumSGPRs=0, unsigned NumVGPRs=0) const
Return occupancy for the given function.
unsigned getNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumVGPRs, Optional< bool > EnableWavefrontSize32)
bool isMemoryBound() const
void EmitFunctionEntryLabel() override
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
static AsmPrinter * createAMDGPUAsmPrinterPass(TargetMachine &tm, std::unique_ptr< MCStreamer > &&Streamer)
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
unsigned getLDSWaveSpillSize() const
unsigned getPSInputEnable() const
uint32_t compute_pgm_rsrc1
virtual bool EmitISAVersion(StringRef IsaVersionString)=0
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
void EmitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
virtual void EmitDirectiveAMDGCNTarget(StringRef Target)=0
bool doFinalization(Module &M) override
Shut down the asmprinter.
void EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target...
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Interface definition for SIInstrInfo.
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
void LLVM_EXTERNAL_VISIBILITY LLVMInitializeAMDGPUAsmPrinter()
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs)
#define S_00B848_SGPRS(x)
bool hasXNACK(const MCSubtargetInfo &STI)
StringRef getName() const
Return a constant reference to the value's name.
uint32_t workitem_private_segment_byte_size
The amount of memory required for the combined private, spill and arg segments for a work-item in byt...
Calling convention used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (ve...
#define S_00B84C_USER_SGPR(x)
AMDGPU Assembly printer class.
#define R_00B860_COMPUTE_TMPRING_SIZE
Generic base class for all target subtargets.
bool isAmdHsaOrMesa(const Function &F) const
This represents a section on linux, lots of unix variants and some bare metal systems.
Type * getValueType() const
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
static bool hasAnyNonFlatUseOfReg(const MachineRegisterInfo &MRI, const SIInstrInfo &TII, unsigned Reg)
virtual void EmitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
unsigned getMinNumVGPRs(unsigned WavesPerEU) const
bool hasWorkGroupInfo() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
StringRef getName() const
getName - Get the symbol name.
static unsigned getRsrcReg(CallingConv::ID CallConv)
static StringRef getCPU(StringRef CPU)
Processes a CPU name.
unsigned getMaxNumUserSGPRs() const
#define S_00B860_WAVESIZE(x)
unsigned getNumUserSGPRs() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool needsWaveLimiter() const
#define R_00B84C_COMPUTE_PGM_RSRC2
#define S_00B848_PRIORITY(x)
A raw_ostream that writes to an std::string.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
void EmitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
Module * getParent()
Get the module that this global value is contained inside of...
bool hasInitializer() const
Definitions have initializers, declarations don't.
#define R_0286E8_SPI_TMPRING_SIZE
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
unsigned getHWRegIndex(unsigned Reg) const
#define S_00B02C_EXTRA_LDS_SIZE(x)
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
bool hasWorkGroupIDZ() const
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
#define R_00B528_SPI_SHADER_PGM_RSRC1_LS
StringRef - Represent a constant reference to a string, i.e.
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the start of a basic block.
#define R_0286D0_SPI_PS_INPUT_ADDR
Register getReg() const
getReg - Returns the register number.
void EmitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
const MachineOperand & getOperand(unsigned i) const
void initDefaultAMDKernelCodeT(amd_kernel_code_t &Header, const MCSubtargetInfo *STI)
static uint32_t getFPMode(AMDGPU::SIModeRegisterDefaults Mode)
Calling convention for AMDGPU code object kernels.
MCCodeEmitter * getEmitterPtr() const
void streamIsaVersion(const MCSubtargetInfo *STI, raw_ostream &Stream)
Streams isa version string for given subtarget STI into Stream.
iterator_range< arg_iterator > args()
Wrapper class representing virtual and physical registers.
Calling convention used for AMDPAL shader stage before geometry shader if geometry is in use...
bool hasCodeObjectV3() const