<s> break ; } if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else { llvm_unreachable ( <STR_LIT> ) ; } unsigned hwReg = RI -> getEncodingValue ( reg ) & <NUM_LIT> ; unsigned maxUsed = hwReg + width - <NUM_LIT> ; if ( isSGPR ) { MaxSGPR = maxUsed > MaxSGPR ? maxUsed : MaxSGPR ; } else { MaxVGPR = maxUsed > MaxVGPR ? maxUsed : MaxVGPR ; } } } } unsigned ExtraSGPRs = <NUM_LIT> ; if ( VCCUsed ) ExtraSGPRs = <NUM_LIT> ; if ( STM . getGeneration ( ) < <ISA_LIT>Subtarget :: VOLCANIC_ISLANDS ) { if ( FlatUsed ) ExtraSGPRs = <NUM_LIT> ; } else { if ( STM . isXNACKEnabled ( ) ) ExtraSGPRs = <NUM_LIT> ; if ( FlatUsed ) ExtraSGPRs = <NUM_LIT> ; } MaxSGPR += ExtraSGPRs ; ProgInfo . NumVGPR = MaxVGPR + <NUM_LIT> ; ProgInfo . NumSGPR = MaxSGPR + <NUM_LIT> ; if ( STM . hasSGPRInitBug ( ) ) { if ( ProgInfo . NumSGPR > <ISA_LIT>Subtarget :: FIXED_SGPR_COUNT_FOR_INIT_BUG ) { LLVMContext & Ctx = MF . getFunction ( ) -> getContext ( ) ; Ctx . emitError ( <STR_LIT> ) ; } ProgInfo . NumSGPR = <ISA_LIT>Subtarget :: FIXED_SGPR_COUNT_FOR_INIT_BUG ;


<s> void <ISA_LIT>AsmPrinter :: EmitBasicBlockStart ( const MachineBasicBlock & MBB ) const { const <ISA_LIT>Subtarget & STI = MBB . getParent ( ) -> getSubtarget < <ISA_LIT>Subtarget > ( ) ; if ( STI . dumpCode ( ) && ! isBlockOnlyReachableByFallthrough ( & MBB ) ) { DisasmLines . push_back ( ( Twine ( <STR_LIT> ) + Twine ( getFunctionNumber ( ) ) + <STR_LIT> + Twine ( MBB . getNumber ( ) ) + <STR_LIT> ) . str ( ) ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; }

AsmPrinter :: EmitBasicBlockStart ( MBB ) ;


<s> OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( NumVGPR ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( ScratchSize ) , false ) ;


<s> raw_string_ostream ISAVersionStream ( ISAVersionString ) ; IsaInfo :: streamIsaVersion ( getSTI ( ) , ISAVersionStream ) ; getTargetStreamer ( ) -> EmitISAVersion ( ISAVersionStream . str ( ) ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) { HSAMetadataStream . end ( ) ; getTargetStreamer ( ) -> EmitHSAMetadata ( HSAMetadataStream . getHSAMetadata ( ) ) ; }

if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) {


<s> } if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ; HSAMetadataStream . emitKernel ( MF -> getFunction ( ) , getHSACodeProps ( * MF , CurrentProgramInfo ) , getHSADebugProps ( * MF , CurrentProgramInfo ) ) ;


<s> const <ISA_LIT>MachineFunction * MFI = MF -> getInfo < <ISA_LIT>MachineFunction > ( ) ; if ( ! MFI -> isEntryFunction ( ) ) return ; const <ISA_LIT>Subtarget & STM = MF -> getSubtarget < <ISA_LIT>Subtarget > ( ) ; amd_kernel_code_t KernelCode ; if ( STM . isAmdCodeObjectV2 ( * MF ) ) { getAmdKernelCode ( KernelCode , CurrentProgramInfo , * MF ) ;

OutStreamer -> SwitchSection ( getObjFileLowering ( ) . getTextSection ( ) ) ;


<s> if ( MFI -> isEntryFunction ( ) && STM . isAmdCodeObjectV2 ( * MF ) ) { SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , & MF -> getFunction ( ) ) , getTargetStreamer ( ) -> Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ;


<s> if ( MFI -> isEntryFunction ( ) && STM . isAmdCodeObjectV2 ( * MF ) ) { SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , & MF -> getFunction ( ) ) , getTargetStreamer ( ) -> Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ; } const <ISA_LIT>Subtarget & STI = MF -> getSubtarget < <ISA_LIT>Subtarget > ( ) ; if ( STI . dumpCode ( ) ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ;


<s> switch ( MF . getFunction ( ) . getCallingConv ( ) ) { default : LLVM_FALLTHROUGH ; case CallingConv :: <ISA_LIT>_CS : RsrcReg = R_0288D4_SQ_PGM_RESOURCES_LS ; break ; case CallingConv :: <ISA_LIT>_GS : RsrcReg = R_028878_SQ_PGM_RESOURCES_GS ; break ; case CallingConv :: <ISA_LIT>_PS : RsrcReg = R_028844_SQ_PGM_RESOURCES_PS ; break ; case CallingConv :: <ISA_LIT>_VS : RsrcReg = R_028860_SQ_PGM_RESOURCES_VS ; break ; } } else { switch ( MF . getFunction ( ) . getCallingConv ( ) ) { default : LLVM_FALLTHROUGH ; case CallingConv :: <ISA_LIT>_GS : LLVM_FALLTHROUGH ; case CallingConv :: <ISA_LIT>_CS : LLVM_FALLTHROUGH ; case CallingConv :: <ISA_LIT>_VS : RsrcReg = R_028868_SQ_PGM_RESOURCES_VS ; break ; case CallingConv :: <ISA_LIT>_PS : RsrcReg = R_028850_SQ_PGM_RESOURCES_PS ; break ; } } OutStreamer -> EmitIntValue ( RsrcReg , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_NUM_GPRS ( MaxGPR + <NUM_LIT> ) | S_STACK_<ISA_LIT>ZE ( MFI -> CFStackSize ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_02880C_DB_SHADER_CONTROL , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_02880C_KILL_ENABLE ( killPixel ) , <NUM_LIT> ) ; if ( <STR_LIT> ( MF . getFunction ( ) . getCallingConv ( ) ) ) { OutStreamer -> EmitIntValue ( R_0288E8_SQ_LDS_ALLOC , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( alignTo ( MFI -> getLDSSize ( ) , <NUM_LIT> ) >> <NUM_LIT> , <NUM_LIT> ) ;


<s> OutStreamer -> EmitIntValue ( R_00B860_COMPUTE_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B860_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } else { OutStreamer -> EmitIntValue ( RsrcReg , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B028_VGPRS ( CurrentProgramInfo . VGPRBlocks ) | S_00B028_SGPRS ( CurrentProgramInfo . SGPRBlocks ) , <NUM_LIT> ) ; if ( STM . isVGPRSpillingEnabled ( MF . getFunction ( ) ) ) { OutStreamer -> EmitIntValue ( R_0286E8_SPI_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_0286E8_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } } if ( MF . getFunction ( ) . getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ) { OutStreamer -> EmitIntValue ( R_00B02C_SPI_SHADER_PGM_RSRC2_PS , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B02C_EXTRA_LDS_<ISA_LIT>ZE ( CurrentProgramInfo . LDSBlocks ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_0286CC_SPI_PS_INPUT_ENA , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputEnable ( ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_0286D0_SPI_PS_INPUT_ADDR , <NUM_LIT> ) ;

OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputAddr ( ) , <NUM_LIT> ) ;


<s> if ( TM . getTargetTriple ( ) . getArch ( ) != Triple :: amdgcn ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA && TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream . begin ( M ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) readPALMetadata ( M ) ; if ( IsaInfo :: hasCodeObjectV3 ( getSTI ( ) -> getFeatureBits ( ) ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; IsaInfo :: IsaVersion ISA = IsaInfo :: getIsaVersion ( getSTI ( ) -> getFeatureBits ( ) ) ; getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectISA ( ISA . Major , ISA . Minor , ISA . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA && TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream . begin ( M ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) readPALMetadata ( M ) ;

if ( IsaInfo :: hasCodeObjectV3 ( getSTI ( ) -> getFeatureBits ( ) ) ) return ;


<s> uint64_t CodeSize = <NUM_LIT> ; for ( const MachineBasicBlock & MBB : MF ) { for ( const MachineInstr & MI : MBB ) { if ( MI . isDebugValue ( ) ) continue ; CodeSize += TII -> getInstSizeInBytes ( MI ) ;


<s> for ( const MachineBasicBlock & MBB : MF ) { for ( const MachineInstr & MI : MBB ) { if ( MI . isDebugValue ( ) ) continue ; CodeSize += TII -> getInstSizeInBytes ( MI ) ; }


<s> HSACodeProps . mKernargSegmentAlign = std :: max ( uint32_t ( <NUM_LIT> ) , MFI . getMaxKernArgAlign ( ) ) ; HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = CurrentProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = CurrentProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ; HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ; HSACodeProps . mIsXNACKEnabled = STM . isXNACKEnabled ( ) ;

HSACodeProps . mNumSpilledSGPRs = MFI . getNumSpilledSGPRs ( ) ;


<s> <STR_LIT> :: Kernel :: CodeProps :: Metadata <ISA_LIT>AsmPrinter :: getHSACodeProps ( const MachineFunction & MF , const <ISA_LIT>ProgramInfo & ProgramInfo ) const { const <ISA_LIT>Subtarget & STM = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const <ISA_LIT>MachineFunctionInfo & MFI = * MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; HSAMD :: Kernel :: CodeProps :: Metadata HSACodeProps ; HSACodeProps . mKernargSegmentSize = STM . getKernArgSegmentSize ( MF , MFI . getABIArgOffset ( ) ) ; HSACodeProps . mGroupSegmentFixedSize = ProgramInfo . LDSSize ; HSACodeProps . mPrivateSegmentFixedSize = ProgramInfo . ScratchSize ; HSACodeProps . mKernargSegmentAlign = std :: max ( uint32_t ( <NUM_LIT> ) , MFI . getMaxKernArgAlign ( ) ) ; HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = CurrentProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = CurrentProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ;

HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ;


<s> if ( VCCUsed ) ExtraSGPRs = <NUM_LIT> ; if ( ST . getGeneration ( ) < <ISA_LIT>Subtarget :: VOLCANIC_ISLANDS ) { if ( FlatScrUsed ) ExtraSGPRs = <NUM_LIT> ;


<s> if ( ST . getGeneration ( ) < <ISA_LIT>Subtarget :: VOLCANIC_ISLANDS ) { if ( FlatScrUsed ) ExtraSGPRs = <NUM_LIT> ; } else {

if ( ST . isXNACKEnabled ( ) ) ExtraSGPRs = <NUM_LIT> ;


<s> if ( ! isUInt < <NUM_LIT> > ( ProgInfo . ScratchSize ) ) { DiagnosticInfoStackSize DiagStackSize ( MF . getFunction ( ) , ProgInfo . ScratchSize , DS_Error ) ; MF . getFunction ( ) . getContext ( ) . diagnose ( DiagStackSize ) ; } const <ISA_LIT>Subtarget & STM = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const <ISA_LIT>MachineFunctionInfo * MFI = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const <ISA_LIT>InstrInfo * TII = STM . getInstrInfo ( ) ; const <ISA_LIT>RegisterInfo * RI = & TII -> getRegisterInfo ( ) ; unsigned ExtraSGPRs = getNumExtraSGPRs ( STM , ProgInfo . VCCUsed , ProgInfo . FlatUsed ) ; unsigned ExtraVGPRs = STM . getReservedNumVGPRs ( MF ) ; if ( STM . getGeneration ( ) >= <ISA_LIT>Subtarget :: VOLCANIC_ISLANDS && ! STM . hasSGPRInitBug ( ) ) { unsigned MaxAddressableNumSGPRs = STM . getAddressableNumSGPRs ( ) ; if ( ProgInfo . NumSGPR > MaxAddressableNumSGPRs ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , ProgInfo . NumSGPR , DS_Error , DK_ResourceLimit , MaxAddressableNumSGPRs ) ; Ctx . diagnose ( Diag ) ; ProgInfo . NumSGPR = MaxAddressableNumSGPRs - <NUM_LIT> ; } } ProgInfo . NumSGPR += ExtraSGPRs ; ProgInfo . NumVGPR += ExtraVGPRs ; unsigned WaveDispatchNumSGPR = <NUM_LIT> , WaveDispatchNumVGPR = <NUM_LIT> ; for ( auto & Arg : MF . getFunction ( ) . args ( ) ) { unsigned NumRegs = ( Arg . getType ( ) -> getPrimitiveSizeInBits ( ) + <NUM_LIT> ) / <NUM_LIT> ; if ( Arg . hasAttribute ( Attribute :: InReg ) ) WaveDispatchNumSGPR += NumRegs ; else WaveDispatchNumVGPR += NumRegs ; } ProgInfo . NumSGPR = std :: max ( ProgInfo . NumSGPR , WaveDispatchNumSGPR ) ; ProgInfo . NumVGPR = std :: max ( ProgInfo . NumVGPR , WaveDispatchNumVGPR ) ; ProgInfo . NumSGPRsForWavesPerEU = std :: max ( std :: max ( ProgInfo . NumSGPR , <NUM_LIT> ) , STM . getMinNumSGPRs ( MFI -> getMaxWavesPerEU ( ) ) ) ; ProgInfo . NumVGPRsForWavesPerEU = std :: max ( std :: max ( ProgInfo . NumVGPR , <NUM_LIT> ) , STM . getMinNumVGPRs ( MFI -> getMaxWavesPerEU ( ) ) ) ; if ( STM . getGeneration ( ) <= <ISA_LIT>Subtarget :: SEA_ISLANDS || STM . hasSGPRInitBug ( ) ) { unsigned MaxAddressableNumSGPRs = STM . getAddressableNumSGPRs ( ) ; if ( ProgInfo . NumSGPR > MaxAddressableNumSGPRs ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , ProgInfo . NumSGPR , DS_Error , DK_ResourceLimit , MaxAddressableNumSGPRs ) ;


<s> default : case CallingConv :: <ISA_LIT>_GS : case CallingConv :: <ISA_LIT>_CS : case CallingConv :: <ISA_LIT>_VS : RsrcReg = R_028868_SQ_PGM_RESOURCES_VS ; break ; case CallingConv :: <ISA_LIT>_PS : RsrcReg = R_028850_SQ_PGM_RESOURCES_PS ; break ; } } OutStreamer -> EmitIntValue ( RsrcReg , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_NUM_GPRS ( MaxGPR + <NUM_LIT> ) | S_STACK_<ISA_LIT>ZE ( MFI -> StackSize ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_02880C_DB_SHADER_CONTROL , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_02880C_KILL_ENABLE ( killPixel ) , <NUM_LIT> ) ; if ( <STR_LIT> ( MF . getFunction ( ) -> getCallingConv ( ) ) ) { OutStreamer -> EmitIntValue ( R_0288E8_SQ_LDS_ALLOC , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( alignTo ( MFI -> LDSSize , <NUM_LIT> ) >> <NUM_LIT> , <NUM_LIT> ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ;

std :: unique_ptr < MCSubtargetInfo > STI ( TM . getTarget ( ) . createMCSubtargetInfo ( TM . getTargetTriple ( ) . str ( ) , TM . getTargetCPU ( ) , TM . getTargetFeatureString ( ) ) ) ;


<s> case CallingConv :: <ISA_LIT>_GS : return R_00B228_SPI_SHADER_PGM_RSRC1_GS ; case CallingConv :: <ISA_LIT>_PS : return R_00B028_SPI_SHADER_PGM_RSRC1_PS ; case CallingConv :: <ISA_LIT>_VS : return R_00B128_SPI_SHADER_PGM_RSRC1_VS ;


<s> case CallingConv :: <ISA_LIT>_CS : return R_00B848_COMPUTE_PGM_RSRC1 ; case CallingConv :: <ISA_LIT>_GS : return R_00B228_SPI_SHADER_PGM_RSRC1_GS ; case CallingConv :: <ISA_LIT>_PS : return R_00B028_SPI_SHADER_PGM_RSRC1_PS ; case CallingConv :: <ISA_LIT>_VS : return R_00B128_SPI_SHADER_PGM_RSRC1_VS ; }


OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_USER_SGPR ( KernelInfo . ComputePGMRSrc2 ) ) , false ) ;


<s> IsaInfo :: streamIsaVersion ( getGlobalSTI ( ) , ISAVersionStream ) ; getTargetStreamer ( ) -> EmitISAVersion ( ISAVersionStream . str ( ) ) ; }

if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) {


<s> auto & Streamer = getTargetStreamer ( ) -> getStreamer ( ) ; auto & Context = Streamer . getContext ( ) ; auto & ObjectFileInfo = * Context . getObjectFileInfo ( ) ; auto & ReadOnlySection = * ObjectFileInfo . getReadOnlySection ( ) ; Streamer . PushSection ( ) ; Streamer . SwitchSection ( & ReadOnlySection ) ; Streamer . emitValueToAlignment ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ; if ( ReadOnlySection . getAlignment ( ) < <NUM_LIT> ) ReadOnlySection . setAlignment ( Align ( <NUM_LIT> ) ) ; const MCSubtargetInfo & STI = MF -> getSubtarget ( ) ; SmallString < <NUM_LIT> > KernelName ;

getNameWithPrefix ( KernelName , & MF -> getFunction ( ) ) ;


<s> const GCNSubtarget & STM = MF -> getSubtarget < GCNSubtarget > ( ) ; const Function & F = MF -> getFunction ( ) ;

if ( ! STM . hasCodeObjectV3 ( ) && STM . isAmdHsaOrMesa ( F ) && ( F . getCallingConv ( ) == CallingConv :: <ISA_LIT>_KERNEL || F . getCallingConv ( ) == CallingConv :: SPIR_KERNEL ) ) {


<s> const Function & F = MF -> getFunction ( ) ; if ( ! STM . hasCodeObjectV3 ( ) && STM . isAmdHsaOrMesa ( F ) && ( F . getCallingConv ( ) == CallingConv :: <ISA_LIT>_KERNEL || F . getCallingConv ( ) == CallingConv :: SPIR_KERNEL ) ) { amd_kernel_code_t KernelCode ;

getAmdKernelCode ( KernelCode , CurrentProgramInfo , * MF ) ;


<s> if ( DumpCodeInstEmitter ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; }

AsmPrinter :: emitFunctionEntryLabel ( ) ;


<s> const DataLayout & DL = GV -> getParent ( ) -> getDataLayout ( ) ; uint64_t Size = DL . getTypeAllocSize ( GV -> getValueType ( ) ) ; unsigned Align = GV -> getAlignment ( ) ; if ( ! Align ) Align = <NUM_LIT> ; emitVisibility ( GVSym , GV -> getVisibility ( ) , ! GV -> isDeclaration ( ) ) ; emitLinkage ( GV , GVSym ) ; if ( auto TS = getTargetStreamer ( ) ) TS -> emit<ISA_LIT>LDS ( GVSym , Size , Align ) ;


<s> OutStreamer -> emitInt32 ( R_00B860_COMPUTE_TMPRING_<ISA_LIT>ZE ) ; OutStreamer -> emitInt32 ( S_00B860_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) ) ; } else { OutStreamer -> emitInt32 ( RsrcReg ) ; OutStreamer -> emitIntValue ( S_00B028_VGPRS ( CurrentProgramInfo . VGPRBlocks ) | S_00B028_SGPRS ( CurrentProgramInfo . SGPRBlocks ) , <NUM_LIT> ) ; OutStreamer -> emitInt32 ( R_0286E8_SPI_TMPRING_<ISA_LIT>ZE ) ; OutStreamer -> emitIntValue ( S_0286E8_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } if ( MF . getFunction ( ) . getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ) { OutStreamer -> emitInt32 ( R_00B02C_SPI_SHADER_PGM_RSRC2_PS ) ;

OutStreamer -> emitInt32 ( S_00B02C_EXTRA_LDS_<ISA_LIT>ZE ( CurrentProgramInfo . LDSBlocks ) ) ;


<s> if ( <STR_LIT> ( MF . getFunction ( ) . getCallingConv ( ) ) ) { OutStreamer -> emitInt32 ( R_00B848_COMPUTE_PGM_RSRC1 ) ; OutStreamer -> emitInt32 ( CurrentProgramInfo . ComputePGMRSrc1 ) ; OutStreamer -> emitInt32 ( R_00B84C_COMPUTE_PGM_RSRC2 ) ; OutStreamer -> emitInt32 ( CurrentProgramInfo . ComputePGMRSrc2 ) ; OutStreamer -> emitInt32 ( R_00B860_COMPUTE_TMPRING_<ISA_LIT>ZE ) ; OutStreamer -> emitInt32 ( S_00B860_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) ) ; } else { OutStreamer -> emitInt32 ( RsrcReg ) ; OutStreamer -> emitIntValue ( S_00B028_VGPRS ( CurrentProgramInfo . VGPRBlocks ) | S_00B028_SGPRS ( CurrentProgramInfo . SGPRBlocks ) , <NUM_LIT> ) ; OutStreamer -> emitInt32 ( R_0286E8_SPI_TMPRING_<ISA_LIT>ZE ) ; OutStreamer -> emitIntValue ( S_0286E8_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } if ( MF . getFunction ( ) . getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ) { OutStreamer -> emitInt32 ( R_00B02C_SPI_SHADER_PGM_RSRC2_PS ) ; OutStreamer -> emitInt32 ( S_00B02C_EXTRA_LDS_<ISA_LIT>ZE ( CurrentProgramInfo . LDSBlocks ) ) ; OutStreamer -> emitInt32 ( R_0286CC_SPI_PS_INPUT_ENA ) ; OutStreamer -> emitInt32 ( MFI -> getP<ISA_LIT>nputEnable ( ) ) ; OutStreamer -> emitInt32 ( R_0286D0_SPI_PS_INPUT_ADDR ) ; OutStreamer -> emitInt32 ( MFI -> getP<ISA_LIT>nputAddr ( ) ) ; } OutStreamer -> emitInt32 ( R_SPILLED_SGPRS ) ;

OutStreamer -> emitInt32 ( MFI -> getNumSpilledSGPRs ( ) ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) getTargetStreamer ( ) -> getPALMetadata ( ) -> readFromIR ( M ) ; if ( IsaInfo :: hasCodeObjectV3 ( getGlobalSTI ( ) ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ;

IsaVersion Version = getIsaVersion ( getGlobalSTI ( ) -> getCPU ( ) ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; IsaVersion Version = getIsaVersion ( getGlobalSTI ( ) -> getCPU ( ) ) ; getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectISA ( Version . Major , Version . Minor , Version . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> if ( Op . isImm ( ) ) { assert ( Op . getImm ( ) == <NUM_LIT> ) ;


<s> assert ( Op . getImm ( ) == <NUM_LIT> ) ; return nullptr ; } return cast < Function > ( Op . getGlobal ( ) ) ;


<s> OutStreamer -> setUseAssemblerInfoForParsing ( SaveFlag ) ; if ( Assembler ) DumpCodeInstEmitter = Assembler -> getEmitterPtr ( ) ; } DisasmLines . clear ( ) ; HexLines . clear ( ) ; DisasmLineMaxLen = <NUM_LIT> ; emitFunctionBody ( ) ; if ( isVerbose ( ) ) { MCSectionELF * CommentSection = Context . getELFSection ( <STR_LIT> , ELF :: SHT_PROGBITS , <NUM_LIT> ) ; OutStreamer -> SwitchSection ( CommentSection ) ; if ( ! MFI -> isEntryFunction ( ) ) { OutStreamer -> emitRawComment ( <STR_LIT> , false ) ; <ISA_LIT>FunctionResourceInfo & Info = CallGraphResourceInfo [ & MF . getFunction ( ) ] ; emitCommonFunctionComments ( Info . NumVGPR , STM . hasMAIInsts ( ) ? Info . NumAGPR : Optional < uint32_t > ( ) , Info . getTotalNumVGPRs ( STM ) , Info . getTotalNumSGPRs ( MF . getSubtarget < GCNSubtarget > ( ) ) , Info . PrivateSegmentSize , getFunctionCodeSize ( MF ) , MFI ) ; return false ; } OutStreamer -> emitRawComment ( <STR_LIT> , false ) ; emitCommonFunctionComments ( CurrentProgramInfo . NumArchVGPR , STM . hasMAIInsts ( ) ? CurrentProgramInfo . NumAccVGPR : Optional < uint32_t > ( ) , CurrentProgramInfo . NumVGPR , CurrentProgramInfo . NumSGPR , CurrentProgramInfo . ScratchSize , getFunctionCodeSize ( MF ) , MFI ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . FloatMode ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . IEEEMode ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . LDSSize ) + <STR_LIT> , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . SGPRBlocks ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . VGPRBlocks ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . NumSGPRsForWavesPerEU ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . NumVGPRsForWavesPerEU ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . Occupancy ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( MFI -> needsWaveLimiter ( ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_USER_SGPR ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TRAP_HANDLER ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TGID_X_EN ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ;

OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TGID_Y_EN ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ;


<s> OutStreamer -> EmitIntValue ( S_0286E8_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) Rsrc2Val = S_00B84C_SCRATCH_EN ( CurrentProgramInfo . ScratchBlocks > <NUM_LIT> ) ; } if ( MF . getFunction ( ) . getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ) { OutStreamer -> EmitIntValue ( R_0286CC_SPI_PS_INPUT_ENA , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputEnable ( ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_0286D0_SPI_PS_INPUT_ADDR , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputAddr ( ) , <NUM_LIT> ) ; Rsrc2Val |= S_00B02C_EXTRA_LDS_<ISA_LIT>ZE ( CurrentProgramInfo . LDSBlocks ) ; } if ( Rsrc2Val ) { OutStreamer -> EmitIntValue ( RsrcReg + <NUM_LIT> , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( Rsrc2Val , <NUM_LIT> ) ; } } OutStreamer -> EmitIntValue ( R_SPILLED_SGPRS , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getNumSpilledSGPRs ( ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_SPILLED_VGPRS , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getNumSpilledVGPRs ( ) , <NUM_LIT> ) ;


header . kernarg_segment_byte_size = MFI -> ABIArgOffset ;


<s> AsmPrinter :: EmitGlobalVariable ( GV ) ; return ; } if ( GV -> isDeclaration ( ) || GV -> getLinkage ( ) == GlobalValue :: PrivateLinkage ) { AsmPrinter :: EmitGlobalVariable ( GV ) ; return ; } if ( <STR_LIT> ( GV ) ) return ; <ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ; if ( isModuleLinkage ( GV ) ) { TS -> Emit<ISA_LIT>HsaModuleScopeGlobal ( GV -> getName ( ) ) ; } else {

TS -> Emit<ISA_LIT>HsaProgramScopeGlobal ( GV -> getName ( ) ) ;


<s> } if ( <STR_LIT> ( GV ) ) return ; <ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ; if ( isModuleLinkage ( GV ) ) { TS -> Emit<ISA_LIT>HsaModuleScopeGlobal ( GV -> getName ( ) ) ; } else { TS -> Emit<ISA_LIT>HsaProgramScopeGlobal ( GV -> getName ( ) ) ; } MCSymbolELF * GVSym = cast < MCSymbolELF > ( getSymbol ( GV ) ) ; const DataLayout & DL = getDataLayout ( ) ; uint64_t Size = DL . getTypeAllocSize ( GV -> getType ( ) -> getElementType ( ) ) ; OutStreamer -> emitELFSize ( GVSym , MCConstantExpr :: create ( Size , OutContext ) ) ; OutStreamer -> PushSection ( ) ; OutStreamer -> SwitchSection ( getObjFileLowering ( ) . SectionForGlobal ( GV , * Mang , TM ) ) ; const Constant * C = GV -> getInitializer ( ) ;


<s> <ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ; TS -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; <STR_LIT> ISA = <STR_LIT> ( STI -> getFeatureBits ( ) ) ; TS -> EmitDirectiveHSACodeObjectISA ( ISA . Major , ISA . Minor , ISA . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ;


<s> case <STR_LIT> : case <STR_LIT> : FlatUsed = true ; continue ; default : break ; } if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else { llvm_unreachable ( <STR_LIT> ) ; } unsigned hwReg = RI -> getEncodingValue ( reg ) & <NUM_LIT> ; unsigned maxUsed = hwReg + width - <NUM_LIT> ; if ( isSGPR ) { MaxSGPR = maxUsed > MaxSGPR ? maxUsed : MaxSGPR ; } else { MaxVGPR = maxUsed > MaxVGPR ? maxUsed : MaxVGPR ; } } } } unsigned ExtraSGPRs = <NUM_LIT> ; if ( VCCUsed ) ExtraSGPRs = <NUM_LIT> ; if ( STM . getGeneration ( ) < <ISA_LIT>Subtarget :: VOLCANIC_ISLANDS ) { if ( FlatUsed ) ExtraSGPRs = <NUM_LIT> ; } else { if ( STM . isXNACKEnabled ( ) ) ExtraSGPRs = <NUM_LIT> ; if ( FlatUsed ) ExtraSGPRs = <NUM_LIT> ; } MaxSGPR += ExtraSGPRs ; ProgInfo . NumVGPR = MaxVGPR + <NUM_LIT> ; ProgInfo . NumSGPR = MaxSGPR + <NUM_LIT> ; if ( STM . hasSGPRInitBug ( ) ) { if ( ProgInfo . NumSGPR > <ISA_LIT>Subtarget :: FIXED_SGPR_COUNT_FOR_INIT_BUG ) { LLVMContext & Ctx = MF . getFunction ( ) -> getContext ( ) ;


<s>
if
(
!
STM
.
isAmdHsaOS
(
)
)
{
EmitProgramInfo<ISA_LIT>
(
MF
,
KernelInfo
)
;
}
}
else
{
EmitProgramInfo<ISA_LIT>
(
MF
)
;
}
DisasmLines
.
clear
(
)
;
HexLines
.
clear
(
)
;
DisasmLineMaxLen
=
<NUM_LIT>
;
EmitFunctionBody
(
)
;
if
(
isVerbose
(
)
)
{
MCSectionELF
*
CommentSection
=
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_PROGBITS
,
<NUM_LIT>
)
;
OutStreamer
->
SwitchSection
(
CommentSection
)
;
if
(
STM
.
getGeneration
(
)
>=
<ISA_LIT>Subtarget
::
SOUTHERN_ISLANDS
)
{
OutStreamer
->
emitRawComment
(
<STR_LIT>
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
CodeLen
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
NumSGPR
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
NumVGPR
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
FloatMode
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
IEEEMode
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
ScratchSize
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_USER_SGPR
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TGID_X_EN
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TGID_Y_EN
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TGID_Z_EN
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TIDIG_COMP_CNT
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
}
else
{
<ISA_LIT>MachineFunctionInfo
*
MFI
=
MF
.
getInfo
<
<ISA_LIT>MachineFunctionInfo
>
(
)
;
OutStreamer
->
emitRawComment
(
Twine
(
<STR_LIT>
+
Twine
(
MFI
->
StackSize
)
)
)
;
}
}
if
(
STM
.
dumpCode
(
)
)
{
OutStreamer
->
SwitchSection
(
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_NOTE
,
<NUM_LIT>
)
)
;
for
(
size_t
i
=
<NUM_LIT>
;
i
<
DisasmLines
.
size
(
)
;
++
i
)
{
std
::
string
Comment
(
DisasmLineMaxLen
DisasmLines
[
i
]
.
size
(
)
,
' '
)
;
Comment
+=
<STR_LIT>
+
HexLines
[
i
]
+
<STR_LIT>
;
OutStreamer
->
EmitBytes
(
StringRef
(
DisasmLines
[
i
]
)
)
;
OutStreamer
->
EmitBytes
(
StringRef
(
Comment
)
)
;
}


<s> } else if ( isHsaAbiVersion3 ( getGlobalSTI ( ) ) ) { HSAMetadataStream . reset ( new HSAMD :: MetadataStreamerV3 ( ) ) ; } else if ( isHsaAbiVersion5 ( getGlobalSTI ( ) ) ) { HSAMetadataStream . reset ( new HSAMD :: MetadataStreamerV5 ( ) ) ; } else {

HSAMetadataStream . reset ( new HSAMD :: MetadataStreamerV4 ( ) ) ;


<s> HSAMetadataStream . reset ( new HSAMD :: MetadataStreamerV2 ( ) ) ; } else if ( isHsaAbiVersion3 ( getGlobalSTI ( ) ) ) { HSAMetadataStream . reset ( new HSAMD :: MetadataStreamerV3 ( ) ) ; } else if ( isHsaAbiVersion5 ( getGlobalSTI ( ) ) ) {

HSAMetadataStream . reset ( new HSAMD :: MetadataStreamerV5 ( ) ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA && isHsaAbiVersion3AndAbove ( getGlobalSTI ( ) ) ) { AsmPrinter :: emitFunctionEntryLabel ( ) ; return ; } const <ISA_LIT>MachineFunctionInfo * MFI = MF -> getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const GCNSubtarget & STM = MF -> getSubtarget < GCNSubtarget > ( ) ; if ( MFI -> isEntryFunction ( ) && STM . isAmdHsaOrMesa ( MF -> getFunction ( ) ) ) { SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , & MF -> getFunction ( ) ) , getTargetStreamer ( ) -> Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ; } if ( DumpCodeInstEmitter ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; }


<s> SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , & MF -> getFunction ( ) ) , getTargetStreamer ( ) -> Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ; } if ( DumpCodeInstEmitter ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream -> begin ( M , * getTargetStreamer ( ) -> getTargetID ( ) ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) getTargetStreamer ( ) -> getPALMetadata ( ) -> readFromIR ( M ) ; if ( isHsaAbiVersion3AndAbove ( getGlobalSTI ( ) ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; IsaVersion Version = getIsaVersion ( getGlobalSTI ( ) -> getCPU ( ) ) ; getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectISAV2 ( Version . Major , Version . Minor , Version . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> <ISA_LIT>FunctionResourceInfo Info ; const <ISA_LIT>MachineFunctionInfo * MFI = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const <ISA_LIT>Subtarget & ST = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const MachineFrameInfo & FrameInfo = MF . getFrameInfo ( ) ; const MachineRegisterInfo & MRI = MF . getRegInfo ( ) ; const <ISA_LIT>InstrInfo * TII = ST . getInstrInfo ( ) ; const <ISA_LIT>RegisterInfo & TRI = TII -> getRegisterInfo ( ) ; Info . UsesFlatScratch = MRI . isPhysRegUsed ( <STR_LIT> ) || MRI . isPhysRegUsed ( <STR_LIT> ) ; if ( Info . UsesFlatScratch && ! MFI -> hasFlatScratchInit ( ) && ( ! hasAnyNonFlatUseOfReg ( MRI , * TII , <STR_LIT> ) && ! hasAnyNonFlatUseOfReg ( MRI , * TII , <STR_LIT> ) && ! hasAnyNonFlatUseOfReg ( MRI , * TII , <STR_LIT> ) ) ) { Info . UsesFlatScratch = false ; } Info . HasDynamicallySizedStack = FrameInfo . hasVarSizedObjects ( ) ; Info . PrivateSegmentSize = FrameInfo . getStackSize ( ) ; Info . UsesVCC = MRI . isPhysRegUsed ( <STR_LIT> ) || MRI . isPhysRegUsed ( <STR_LIT> ) ; MCPhysReg HighestVGPRReg = <STR_LIT> ; for ( MCPhysReg Reg : reverse ( <STR_LIT> . getRegisters ( ) ) ) { if ( MRI . isPhysRegUsed ( Reg ) ) { HighestVGPRReg = Reg ; break ; } } MCPhysReg HighestSGPRReg = <STR_LIT> ; for ( MCPhysReg Reg : reverse ( <STR_LIT> . getRegisters ( ) ) ) { if ( MRI . isPhysRegUsed ( Reg ) ) { HighestSGPRReg = Reg ;


<s> Info . PrivateSegmentSize = FrameInfo . getStackSize ( ) ; Info . UsesVCC = MRI . isPhysRegUsed ( <STR_LIT> ) || MRI . isPhysRegUsed ( <STR_LIT> ) ; MCPhysReg HighestVGPRReg = <STR_LIT> ; for ( MCPhysReg Reg : reverse ( <STR_LIT> . getRegisters ( ) ) ) { if ( MRI . isPhysRegUsed ( Reg ) ) { HighestVGPRReg = Reg ; break ; } } MCPhysReg HighestSGPRReg = <STR_LIT> ; for ( MCPhysReg Reg : reverse ( <STR_LIT> . getRegisters ( ) ) ) { if ( MRI . isPhysRegUsed ( Reg ) ) { HighestSGPRReg = Reg ; break ; } } Info . NumVGPR = HighestVGPRReg == <STR_LIT> ? <NUM_LIT> : TRI . getHWRegIndex ( HighestVGPRReg ) + <NUM_LIT> ; Info . NumExplicitSGPR = HighestSGPRReg == <STR_LIT> ? <NUM_LIT> :

TRI . getHWRegIndex ( HighestSGPRReg ) + <NUM_LIT> ;


<s> OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( NumVGPR ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( ScratchSize ) , false ) ;


<s> OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( NumSGPR ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( NumVGPR ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( ScratchSize ) , false ) ;


<s> void <ISA_LIT>AsmPrinter :: EmitEndOfAsmFile ( Module & M ) { if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ; getTargetStreamer ( ) . EmitEndOfCodeObjectMetadata ( ) ;


<s> void <ISA_LIT>AsmPrinter :: EmitFunctionBodyStart ( ) { const <ISA_LIT>MachineFunction * MFI = MF -> getInfo < <ISA_LIT>MachineFunction > ( ) ; if ( ! MFI -> isEntryFunction ( ) ) return ; const <ISA_LIT>Subtarget & STM = MF -> getSubtarget < <ISA_LIT>Subtarget > ( ) ; amd_kernel_code_t KernelCode ; if ( STM . isAmdCodeObjectV2 ( * MF ) ) { getAmdKernelCode ( KernelCode , CurrentProgramInfo , * MF ) ; OutStreamer -> SwitchSection ( getObjFileLowering ( ) . getTextSection ( ) ) ; getTargetStreamer ( ) . EmitAMDKernelCodeT ( KernelCode ) ;


<s> SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , MF -> getFunction ( ) ) , getTargetStreamer ( ) . Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ; }

AsmPrinter :: EmitFunctionEntryLabel ( ) ;


<s> if ( <STR_LIT> ( GV , AMDGPUA<ISA_LIT> ) ) return ; AsmPrinter :: EmitGlobalVariable ( GV ) ;


<s> bool killPixel = false ; const <ISA_LIT>Subtarget & STM = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const <ISA_LIT>RegisterInfo * RI = STM . getRegisterInfo ( ) ; const <ISA_LIT>MachineFunctionInfo * MFI = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; for ( const MachineBasicBlock & MBB : MF ) { for ( const MachineInstr & MI : MBB ) { if ( MI . getOpcode ( ) == <STR_LIT> ) killPixel = true ; unsigned numOperands = MI . getNumOperands ( ) ; for ( unsigned op_idx = <NUM_LIT> ; op_idx < numOperands ; op_idx ++ ) { const MachineOperand & MO = MI . getOperand ( op_idx ) ; if ( ! MO . isReg ( ) ) continue ; unsigned HWReg = RI -> getHWRegIndex ( MO . getReg ( ) ) ; if ( HWReg > <NUM_LIT> ) continue ; MaxGPR = std :: max ( MaxGPR , HWReg ) ; } } } unsigned RsrcReg ; if ( STM . getGeneration ( ) >= <ISA_LIT>Subtarget :: EVERGREEN ) {

switch ( MF . getFunction ( ) -> getCallingConv ( ) ) {


<s> const <ISA_LIT>Subtarget & STM = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const <ISA_LIT>MachineFunctionInfo * MFI = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; unsigned RsrcReg = getRsrcReg ( MF . getFunction ( ) -> getCallingConv ( ) ) ; if ( <STR_LIT> ( MF . getFunction ( ) -> getCallingConv ( ) ) ) { OutStreamer -> EmitIntValue ( R_00B848_COMPUTE_PGM_RSRC1 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( CurrentProgramInfo . ComputePGMRSrc1 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_00B84C_COMPUTE_PGM_RSRC2 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( CurrentProgramInfo . ComputePGMRSrc2 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_00B860_COMPUTE_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B860_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } else { OutStreamer -> EmitIntValue ( RsrcReg , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B028_VGPRS ( CurrentProgramInfo . VGPRBlocks ) | S_00B028_SGPRS ( CurrentProgramInfo . SGPRBlocks ) , <NUM_LIT> ) ; if ( STM . isVGPRSpillingEnabled ( * MF . getFunction ( ) ) ) { OutStreamer -> EmitIntValue ( R_0286E8_SPI_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_0286E8_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } } if ( MF . getFunction ( ) -> getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ) { OutStreamer -> EmitIntValue ( R_00B02C_SPI_SHADER_PGM_RSRC2_PS , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B02C_EXTRA_LDS_<ISA_LIT>ZE ( CurrentProgramInfo . LDSBlocks ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_0286CC_SPI_PS_INPUT_ENA , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputEnable ( ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_0286D0_SPI_PS_INPUT_ADDR , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputAddr ( ) , <NUM_LIT> ) ; } OutStreamer -> EmitIntValue ( R_SPILLED_SGPRS , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getNumSpilledSGPRs ( ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_SPILLED_VGPRS , <NUM_LIT> ) ;

OutStreamer -> EmitIntValue ( MFI -> getNumSpilledVGPRs ( ) , <NUM_LIT> ) ;


<s> void <ISA_LIT>AsmPrinter :: EmitStartOfAsmFile ( Module & M ) { if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ; <STR_LIT> :: IsaVersion ISA = <STR_LIT> :: getIsaVersion ( getSTI ( ) -> getFeatureBits ( ) ) ;

getTargetStreamer ( ) . EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ;


<s> case CallingConv :: <ISA_LIT>_HS : return R_00B428_SPI_SHADER_PGM_RSRC1_HS ; case CallingConv :: <ISA_LIT>_GS : return R_00B228_SPI_SHADER_PGM_RSRC1_GS ;

case CallingConv :: <ISA_LIT>_PS : return R_00B028_SPI_SHADER_PGM_RSRC1_PS ;


<s> case CallingConv :: <ISA_LIT>_HS : return R_00B428_SPI_SHADER_PGM_RSRC1_HS ; case CallingConv :: <ISA_LIT>_GS : return R_00B228_SPI_SHADER_PGM_RSRC1_GS ; case CallingConv :: <ISA_LIT>_PS : return R_00B028_SPI_SHADER_PGM_RSRC1_PS ; case CallingConv :: <ISA_LIT>_VS : return R_00B128_SPI_SHADER_PGM_RSRC1_VS ;


<s> return static_cast < <ISA_LIT>TargetStreamer & > ( * OutStreamer -> getTargetStreamer ( ) ) ;


<s> OutStreamer -> EmitIntValue ( R_00B84C_COMPUTE_PGM_RSRC2 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( CurrentProgramInfo . ComputePGMRSrc2 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_00B860_COMPUTE_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B860_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } else { OutStreamer -> EmitIntValue ( RsrcReg , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B028_VGPRS ( CurrentProgramInfo . VGPRBlocks ) | S_00B028_SGPRS ( CurrentProgramInfo . SGPRBlocks ) , <NUM_LIT> ) ; unsigned Rsrc2Val = <NUM_LIT> ; if ( STM . isVGPRSpillingEnabled ( * MF . getFunction ( ) ) ) { OutStreamer -> EmitIntValue ( R_0286E8_SPI_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_0286E8_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) Rsrc2Val = S_00B84C_SCRATCH_EN ( CurrentProgramInfo . ScratchBlocks > <NUM_LIT> ) ; } if ( MF . getFunction ( ) -> getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ) {

OutStreamer -> EmitIntValue ( R_0286CC_SPI_PS_INPUT_ENA , <NUM_LIT> ) ;


<s> OutStreamer -> EmitIntValue ( R_00B84C_COMPUTE_PGM_RSRC2 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( CurrentProgramInfo . ComputePGMRSrc2 , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_00B860_COMPUTE_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B860_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; } else { OutStreamer -> EmitIntValue ( RsrcReg , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_00B028_VGPRS ( CurrentProgramInfo . VGPRBlocks ) | S_00B028_SGPRS ( CurrentProgramInfo . SGPRBlocks ) , <NUM_LIT> ) ; unsigned Rsrc2Val = <NUM_LIT> ; if ( STM . isVGPRSpillingEnabled ( * MF . getFunction ( ) ) ) { OutStreamer -> EmitIntValue ( R_0286E8_SPI_TMPRING_<ISA_LIT>ZE , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( S_0286E8_WAVE<ISA_LIT>ZE ( CurrentProgramInfo . ScratchBlocks ) , <NUM_LIT> ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) Rsrc2Val = S_00B84C_SCRATCH_EN ( CurrentProgramInfo . ScratchBlocks > <NUM_LIT> ) ; } if ( MF . getFunction ( ) -> getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ) { OutStreamer -> EmitIntValue ( R_0286CC_SPI_PS_INPUT_ENA , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputEnable ( ) , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( R_0286D0_SPI_PS_INPUT_ADDR , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getP<ISA_LIT>nputAddr ( ) , <NUM_LIT> ) ; Rsrc2Val |= S_00B02C_EXTRA_LDS_<ISA_LIT>ZE ( CurrentProgramInfo . LDSBlocks ) ; } if ( Rsrc2Val ) { OutStreamer -> EmitIntValue ( RsrcReg + <NUM_LIT> , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( Rsrc2Val , <NUM_LIT> ) ; } } OutStreamer -> EmitIntValue ( R_SPILLED_SGPRS , <NUM_LIT> ) ; OutStreamer -> EmitIntValue ( MFI -> getNumSpilledSGPRs ( ) , <NUM_LIT> ) ;

OutStreamer -> EmitIntValue ( R_SPILLED_VGPRS , <NUM_LIT> ) ;


<s> } else if ( <STR_LIT> . contains ( Reg ) ) { assert ( ! <STR_LIT> . contains ( Reg ) && <STR_LIT> ) ; IsSGPR = true ; Width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( Reg ) ) { IsSGPR = false ; Width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( Reg ) ) { assert ( ! <STR_LIT> . contains ( Reg ) && <STR_LIT> ) ; IsSGPR = true ; Width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( Reg ) ) { IsSGPR = false ; Width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( Reg ) ) { assert ( ! <STR_LIT> . contains ( Reg ) && <STR_LIT> ) ; IsSGPR = true ; Width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( Reg ) ) { IsSGPR = false ; Width = <NUM_LIT> ; } else { llvm_unreachable ( <STR_LIT> ) ; } unsigned HWReg = TRI . getHWRegIndex ( Reg ) ; int MaxUsed = HWReg + Width - <NUM_LIT> ; if ( IsSGPR ) { MaxSGPR = MaxUsed > MaxSGPR ? MaxUsed : MaxSGPR ; } else { MaxVGPR = MaxUsed > MaxVGPR ? MaxUsed : MaxVGPR ; } } if ( MI . isCall ( ) ) { const MachineOperand * CalleeOp = TII -> getNamedOperand ( MI , <STR_LIT> :: callee ) ; const Function * Callee = cast < Function > ( CalleeOp -> getGlobal ( ) ) ; if ( Callee -> isDeclaration ( ) ) { int MaxSGPRGuess = <NUM_LIT> - getNumExtraSGPRs ( ST , true , ST . hasFlatAddressSpace ( ) ) ; MaxSGPR = std :: max ( MaxSGPR , MaxSGPRGuess ) ; MaxVGPR = std :: max ( MaxVGPR , <NUM_LIT> ) ; CalleeFrameSize = std :: max ( CalleeFrameSize , UINT64_C ( <NUM_LIT> ) ) ; Info . UsesVCC = true ; Info . UsesFlatScratch = ST . hasFlatAddressSpace ( ) ; Info . HasDynamicallySizedStack = true ; } else { auto I = CallGraphResourceInfo . find ( Callee ) ; assert ( I != CallGraphResourceInfo . end ( ) && <STR_LIT> ) ; MaxSGPR = std :: max ( I -> second . NumExplicitSGPR - <NUM_LIT> , MaxSGPR ) ; MaxVGPR = std :: max ( I -> second . NumVGPR - <NUM_LIT> , MaxVGPR ) ; CalleeFrameSize = std :: max ( I -> second . PrivateSegmentSize , CalleeFrameSize ) ; Info . UsesVCC |= I -> second . UsesVCC ; Info . UsesFlatScratch |= I -> second . UsesFlatScratch ; Info . HasDynamicallySizedStack |= I -> second . HasDynamicallySizedStack ; Info . HasRecursion |= I -> second . HasRecursion ; } if ( ! Callee -> doesNotRecurse ( ) ) Info . HasRecursion = true ; }


<s> getAmdKernelCode ( KernelCode , CurrentProgramInfo , * MF ) ; getTargetStreamer ( ) -> EmitAMDKernelCodeT ( KernelCode ) ; } if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ;

HSAMetadataStream . emitKernel ( MF -> getFunction ( ) , getHSACodeProps ( * MF , CurrentProgramInfo ) , getHSADebugProps ( * MF , CurrentProgramInfo ) ) ;


<s> const <ISA_LIT>MachineFunction * MFI = MF -> getInfo < <ISA_LIT>MachineFunction > ( ) ; if ( ! MFI -> isEntryFunction ( ) ) return ; const <ISA_LIT>Subtarget & STM = MF -> getSubtarget < <ISA_LIT>Subtarget > ( ) ; amd_kernel_code_t KernelCode ; if ( STM . isAmdCodeObjectV2 ( * MF ) ) { getAmdKernelCode ( KernelCode , CurrentProgramInfo , * MF ) ;

getTargetStreamer ( ) -> EmitAMDKernelCodeT ( KernelCode ) ;


<s> uint64_t <ISA_LIT>AsmPrinter :: getFunctionCodeSize ( const MachineFunction & MF ) const { const <ISA_LIT>Subtarget & STM = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const <ISA_LIT>InstrInfo * TII = STM . getInstrInfo ( ) ; uint64_t CodeSize = <NUM_LIT> ; for ( const MachineBasicBlock & MBB : MF ) { for ( const MachineInstr & MI : MBB ) { if ( MI . isDebugInstr ( ) ) continue ;

CodeSize += TII -> getInstSizeInBytes ( MI ) ;


<s> uint64_t CodeSize = <NUM_LIT> ; for ( const MachineBasicBlock & MBB : MF ) { for ( const MachineInstr & MI : MBB ) { if ( MI . isDebugInstr ( ) ) continue ; CodeSize += TII -> getInstSizeInBytes ( MI ) ; }


<s> if ( ReadOnlySection . getAlignment ( ) < <NUM_LIT> ) ReadOnlySection . setAlignment ( <NUM_LIT> ) ; SmallString < <NUM_LIT> > KernelName ; getNameWithPrefix ( KernelName , & MF -> getFunction ( ) ) ; getTargetStreamer ( ) -> EmitAmdhsaKernelDescriptor ( * getSTI ( ) , KernelName , getAmdhsaKernelDescriptor ( * MF , CurrentProgramInfo ) , CurrentProgramInfo . NumVGPRsForWavesPerEU , CurrentProgramInfo . NumSGPRsForWavesPerEU - IsaInfo :: getNumExtraSGPRs ( getSTI ( ) , CurrentProgramInfo . VCCUsed , CurrentProgramInfo . FlatUsed ) , CurrentProgramInfo . VCCUsed , CurrentProgramInfo . FlatUsed , hasXNACK ( * getSTI ( ) ) ) ;


<s> if ( IsaInfo :: hasCodeObjectV3 ( getSTI ( ) ) && TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) return ;

if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA && TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) return ;


if ( STM . isXNACKEnabled ( ) ) Out . code_properties |= AMD_CODE_PROPERTY_IS_XNACK_SUPPORTED ;


<s> } if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) { HSAMetadataStream -> end ( ) ; bool Success = HSAMetadataStream -> emitTo ( * getTargetStreamer ( ) ) ; ( void ) Success ; assert ( Success && <STR_LIT> ) ; } if ( ! IsaInfo :: hasCodeObjectV3 ( getSTI ( ) ) ) { if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) { PALMD :: Metadata PALMetadataVector ; for ( auto i : PALMetadataMap ) {

PALMetadataVector . push_back ( i . first ) ;


<s> } const GCNSubtarget & STI = MF -> getSubtarget < GCNSubtarget > ( ) ; if ( STI . dumpCode ( ) ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; } AsmPrinter :: EmitFunctionEntryLabel ( ) ;


<s> const GCNSubtarget & STI = MF -> getSubtarget < GCNSubtarget > ( ) ; if ( STI . dumpCode ( ) ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; }


<s> IsaInfo :: streamIsaVersion ( getSTI ( ) , ExpectedTargetOS ) ; getTargetStreamer ( ) -> EmitDirectiveAMDGCNTarget ( ExpectedTarget ) ; } if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA && TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream -> begin ( M ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) readPALMetadata ( M ) ; if ( IsaInfo :: hasCodeObjectV3 ( getSTI ( ) ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; IsaVersion Version = getIsaVersion ( getSTI ( ) -> getCPU ( ) ) ;

getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectISA ( Version . Major , Version . Minor , Version . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> getTargetStreamer ( ) -> EmitDirectiveAMDGCNTarget ( ExpectedTarget ) ; } if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA && TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream -> begin ( M ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) readPALMetadata ( M ) ; if ( IsaInfo :: hasCodeObjectV3 ( getSTI ( ) ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; IsaVersion Version = getIsaVersion ( getSTI ( ) -> getCPU ( ) ) ; getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectISA ( Version . Major , Version . Minor , Version . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> const MCSubtargetInfo * STI = TM . getMCSubtargetInfo ( ) ; <STR_LIT> ISA = <STR_LIT> ( STI -> getFeatureBits ( ) ) ; TS -> EmitDirectiveHSACodeObjectISA ( ISA . Major , ISA . Minor , ISA . Stepping , <STR_LIT> , <STR_LIT> ) ; TS -> EmitRuntimeMetadata ( M ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ; <ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ;

TS -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ;


<s>
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TGID_X_EN
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TGID_Y_EN
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TGID_Z_EN
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
G_00B84C_TIDIG_COMP_CNT
(
KernelInfo
.
ComputePGMRSrc2
)
)
,
false
)
;
}
else
{
<ISA_LIT>MachineFunctionInfo
*
MFI
=
MF
.
getInfo
<
<ISA_LIT>MachineFunctionInfo
>
(
)
;
OutStreamer
->
emitRawComment
(
Twine
(
<STR_LIT>
+
Twine
(
MFI
->
CFStackSize
)
)
)
;
}
}
if
(
STM
.
dumpCode
(
)
)
{
OutStreamer
->
SwitchSection
(
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_NOTE
,
<NUM_LIT>
)
)
;
for
(
size_t
i
=
<NUM_LIT>
;
i
<
DisasmLines
.
size
(
)
;
++
i
)
{
std
::
string
Comment
(
DisasmLineMaxLen
DisasmLines
[
i
]
.
size
(
)
,
' '
)
;
Comment
+=
<STR_LIT>
+
HexLines
[
i
]
+
<STR_LIT>
;
OutStreamer
->
EmitBytes
(
StringRef
(
DisasmLines
[
i
]
)
)
;
OutStreamer
->
EmitBytes
(
StringRef
(
Comment
)
)
;
}
}


<s> bool <ISA_LIT>AsmPrinter :: PrintAsmOperand ( const MachineInstr * MI , unsigned OpNo , const char * ExtraCode , raw_ostream & O ) { if ( ! AsmPrinter :: PrintAsmOperand ( MI , OpNo , ExtraCode , O ) ) return false ; if ( ExtraCode && ExtraCode [ <NUM_LIT> ] ) { if ( ExtraCode [ <NUM_LIT> ] != <NUM_LIT> ) return true ; switch ( ExtraCode [ <NUM_LIT> ] ) { case 'r' : break ; default : return true ;


<s> if ( ProgInfo . NumSGPR > MaxAddressableNumSGPRs ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , ProgInfo . NumSGPR , DS_Error , DK_ResourceLimit , MaxAddressableNumSGPRs ) ; Ctx . diagnose ( Diag ) ; ProgInfo . NumSGPR = MaxAddressableNumSGPRs ; ProgInfo . NumSGPRsForWavesPerEU = MaxAddressableNumSGPRs ; } } if ( STM . hasSGPRInitBug ( ) ) { ProgInfo . NumSGPR = <STR_LIT> :: FIXED_NUM_SGPRS_FOR_INIT_BUG ; ProgInfo . NumSGPRsForWavesPerEU = <STR_LIT> :: FIXED_NUM_SGPRS_FOR_INIT_BUG ; } if ( MFI -> getNumUserSGPRs ( ) > STM . getMaxNumUserSGPRs ( ) ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , MFI -> getNumUserSGPRs ( ) , DS_Error ) ; Ctx . diagnose ( Diag ) ; } if ( MFI -> getLDSSize ( ) > static_cast < unsigned > ( STM . getLocalMemorySize ( ) ) ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , MFI -> getLDSSize ( ) , DS_Error ) ; Ctx . diagnose ( Diag ) ; } ProgInfo . SGPRBlocks = IsaInfo :: getNumSGPRBlocks ( & STM , ProgInfo . NumSGPRsForWavesPerEU ) ; ProgInfo . VGPRBlocks = IsaInfo :: getNumVGPRBlocks ( & STM , ProgInfo . NumVGPRsForWavesPerEU ) ; ProgInfo . FloatMode = getFPMode ( MF ) ; const <ISA_LIT>ModeRegisterDefaults Mode = MFI -> getMode ( ) ; ProgInfo . IEEEMode = Mode . IEEE ; ProgInfo . DX10Clamp = Mode . DX10Clamp ; unsigned LDSAlignShift ; if ( STM . getGeneration ( ) < <ISA_LIT>Subtarget :: SEA_ISLANDS ) { LDSAlignShift = <NUM_LIT> ; } else { LDSAlignShift = <NUM_LIT> ; } unsigned LDSSpillSize = MFI -> getLDSWaveSpillSize ( ) * MFI -> getMaxFlatWorkGroupSize ( ) ; ProgInfo . LDSSize = MFI -> getLDSSize ( ) + LDSSpillSize ;

ProgInfo . LDSBlocks = alignTo ( ProgInfo . LDSSize , <NUM_LIT> << LDSAlignShift ) >> LDSAlignShift ;


<s> <ISA_LIT>ProgramInfo ( ) : VGPRBlocks ( <NUM_LIT> ) , SGPRBlocks ( <NUM_LIT> ) , Priority ( <NUM_LIT> ) , FloatMode ( <NUM_LIT> ) , Priv ( <NUM_LIT> ) , DX10Clamp ( <NUM_LIT> ) , DebugMode ( <NUM_LIT> ) , IEEEMode ( <NUM_LIT> ) , ScratchSize ( <NUM_LIT> ) , ComputePGMRSrc1 ( <NUM_LIT> ) , LDSBlocks ( <NUM_LIT> ) , ScratchBlocks ( <NUM_LIT> ) , ComputePGMRSrc2 ( <NUM_LIT> ) , NumVGPR ( <NUM_LIT> ) , NumSGPR ( <NUM_LIT> ) , FlatUsed ( false ) , ReservedVGPRFirst ( <NUM_LIT> ) , ReservedVGPRCount ( <NUM_LIT> ) , VCCUsed ( false ) , CodeLen ( <NUM_LIT> ) {


<s> OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . SGPRBlocks ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . VGPRBlocks ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . NumSGPRsForWavesPerEU ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . NumVGPRsForWavesPerEU ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . Occupancy ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( MFI -> needsWaveLimiter ( ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_USER_SGPR ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TRAP_HANDLER ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TGID_X_EN ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TGID_Y_EN ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TGID_Z_EN ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TIDIG_COMP_CNT ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; } if ( DumpCodeInstEmitter ) { OutStreamer -> SwitchSection ( Context . getELFSection ( <STR_LIT> , ELF :: SHT_NOTE , <NUM_LIT> ) ) ;

for ( size_t i = <NUM_LIT> ; i < DisasmLines . size ( ) ; ++ i ) {


<s> std :: unique_ptr < MCSubtargetInfo > STI ( TM . getTarget ( ) . createMCSubtargetInfo ( TM . getTargetTriple ( ) . str ( ) , TM . getTargetCPU ( ) , TM . getTargetFeatureString ( ) ) ) ; <ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ; TS -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; <STR_LIT> ISA = <STR_LIT> ( STI -> getFeatureBits ( ) ) ; TS -> EmitDirectiveHSACodeObjectISA ( ISA . Major , ISA . Minor , ISA . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> std :: unique_ptr < MCSubtargetInfo > STI ( TM . getTarget ( ) . createMCSubtargetInfo ( TM . getTargetTriple ( ) . str ( ) , TM . getTargetCPU ( ) , TM . getTargetFeatureString ( ) ) ) ;

<ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ;


<s> header . kernarg_segment_byte_size = MFI -> ABIArgOffset ; header . wavefront_sgpr_count = KernelInfo . NumSGPR ; header . workitem_vgpr_count = KernelInfo . NumVGPR ; <ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ;


<s> MCSymbol * EndOfTextLabel = OutContext . getOrCreateSymbol ( StringRef ( END_OF_TEXT_LABEL_NAME ) ) ;

OutStreamer -> EmitLabel ( EndOfTextLabel ) ;


<s> if ( reg == <STR_LIT> || reg == <STR_LIT> || reg == <STR_LIT> ) { VCCUsed = true ; continue ; } else if ( reg == <STR_LIT> || reg == <STR_LIT> || reg == <STR_LIT> ) { FlatUsed = true ; continue ; } switch ( reg ) { default : break ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : continue ; } if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else { llvm_unreachable ( <STR_LIT> ) ; } unsigned hwReg = RI -> getEncodingValue ( reg ) & <NUM_LIT> ; unsigned maxUsed = hwReg + width - <NUM_LIT> ; if ( isSGPR ) { MaxSGPR = maxUsed > MaxSGPR ? maxUsed : MaxSGPR ; } else { MaxVGPR = maxUsed > MaxVGPR ? maxUsed : MaxVGPR ; } } } } if ( VCCUsed ) MaxSGPR += <NUM_LIT> ;


<s>
MCSectionELF
*
ConfigSection
=
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_PROGBITS
,
<NUM_LIT>
)
;
OutStreamer
->
SwitchSection
(
ConfigSection
)
;
const
<ISA_LIT>Subtarget
&
STM
=
MF
.
getSubtarget
<
<ISA_LIT>Subtarget
>
(
)
;
<ISA_LIT>ProgramInfo
KernelInfo
;
if
(
STM
.
getGeneration
(
)
>=
<ISA_LIT>Subtarget
::
SOUTHERN_ISLANDS
)
{
if
(
!
STM
.
isAmdHsaOS
(
)
)
{
get<ISA_LIT>ProgramInfo
(
KernelInfo
,
MF
)
;
EmitProgramInfo<ISA_LIT>
(
MF
,
KernelInfo
)
;
}
<ISA_LIT>TargetStreamer
*
TS
=
static_cast
<
<ISA_LIT>TargetStreamer
*
>
(
OutStreamer
->
getTargetStreamer
(
)
)
;
TS
->
EmitDirectiveHSACodeObjectVersion
(
<NUM_LIT>
,
<NUM_LIT>
)
;
<STR_LIT>
ISA
=
STM
.
getIsaVersion
(
)
;
TS
->
EmitDirectiveHSACodeObjectISA
(
ISA
.
Major
,
ISA
.
Minor
,
ISA
.
Stepping
,
<STR_LIT>
,
<STR_LIT>
)
;
}
else
{
EmitProgramInfo<ISA_LIT>
(
MF
)
;
}
DisasmLines
.
clear
(
)
;
HexLines
.
clear
(
)
;
DisasmLineMaxLen
=
<NUM_LIT>
;
EmitFunctionBody
(
)
;
if
(
isVerbose
(
)
)
{
MCSectionELF
*
CommentSection
=
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_PROGBITS
,
<NUM_LIT>
)
;
OutStreamer
->
SwitchSection
(
CommentSection
)
;
if
(
STM
.
getGeneration
(
)
>=
<ISA_LIT>Subtarget
::
SOUTHERN_ISLANDS
)
{
OutStreamer
->
emitRawComment
(
<STR_LIT>
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
CodeLen
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
NumSGPR
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
NumVGPR
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
FloatMode
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
IEEEMode
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
ScratchSize
)
,
false
)
;
}
else
{
<ISA_LIT>MachineFunctionInfo
*
MFI
=
MF
.
getInfo
<
<ISA_LIT>MachineFunctionInfo
>
(
)
;
OutStreamer
->
emitRawComment
(
Twine
(
<STR_LIT>
+
Twine
(
MFI
->
StackSize
)
)
)
;
}
}
if
(
STM
.
dumpCode
(
)
)
{
OutStreamer
->
SwitchSection
(
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_NOTE
,
<NUM_LIT>
)
)
;
for
(
size_t
i
=
<NUM_LIT>
;
i
<
DisasmLines
.
size
(
)
;
++
i
)
{
std
::
string
Comment
(
DisasmLineMaxLen
DisasmLines
[
i
]
.
size
(
)
,
' '
)
;

Comment += <STR_LIT> + HexLines [ i ] + <STR_LIT> ;


<s>
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
FloatMode
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
IEEEMode
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
ScratchSize
)
,
false
)
;
}
else
{
<ISA_LIT>MachineFunctionInfo
*
MFI
=
MF
.
getInfo
<
<ISA_LIT>MachineFunctionInfo
>
(
)
;
OutStreamer
->
emitRawComment
(
Twine
(
<STR_LIT>
+
Twine
(
MFI
->
StackSize
)
)
)
;
}
}
if
(
STM
.
dumpCode
(
)
)
{
OutStreamer
->
SwitchSection
(
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_NOTE
,
<NUM_LIT>
)
)
;
for
(
size_t
i
=
<NUM_LIT>
;
i
<
DisasmLines
.
size
(
)
;
++
i
)
{
std
::
string
Comment
(
DisasmLineMaxLen
DisasmLines
[
i
]
.
size
(
)
,
' '
)
;
Comment
+=
<STR_LIT>
+
HexLines
[
i
]
+
<STR_LIT>
;
OutStreamer
->
EmitBytes
(
StringRef
(
DisasmLines
[
i
]
)
)
;
OutStreamer
->
EmitBytes
(
StringRef
(
Comment
)
)
;
}
}


<s> if ( ( <STR_LIT> ( STI ) || <STR_LIT> ( STI ) ) && ( STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA || STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) ) { OutStreamer -> SwitchSection ( getObjFileLowering ( ) . getTextSection ( ) ) ; getTargetStreamer ( ) -> EmitCodeEnd ( STI ) ;


<s> const MCSubtargetInfo & STI = * getGlobalSTI ( ) ; if ( ( <STR_LIT> ( STI ) || <STR_LIT> ( STI ) ) && ( STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA || STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) ) { OutStreamer -> SwitchSection ( getObjFileLowering ( ) . getTextSection ( ) ) ; getTargetStreamer ( ) -> EmitCodeEnd ( STI ) ;


<s> auto * MD = getTargetStreamer ( ) -> getPALMetadata ( ) ; const MachineFrameInfo & MFI = MF . getFrameInfo ( ) ; MD -> setFunctionScratchSize ( MF , MFI . getStackSize ( ) ) ;

MD -> setRsrc1 ( CallingConv :: <ISA_LIT>_CS , CurrentProgramInfo . getPGMRSrc1 ( CallingConv :: <ISA_LIT>_CS ) ) ;


<s> Ctx . diagnose ( Diag ) ; ProgInfo . NumSGPR = MaxAddressableNumSGPRs - <NUM_LIT> ; } } ProgInfo . NumSGPR += ExtraSGPRs ; const Function & F = MF . getFunction ( ) ; unsigned WaveDispatchNumSGPR = <NUM_LIT> , WaveDispatchNumVGPR = <NUM_LIT> ; if ( isShader ( F . getCallingConv ( ) ) ) { const DataLayout & DL = F . getParent ( ) -> getDataLayout ( ) ; for ( auto & Arg : F . args ( ) ) { unsigned NumRegs = ( DL . getTypeSizeInBits ( Arg . getType ( ) ) + <NUM_LIT> ) / <NUM_LIT> ; if ( Arg . hasAttribute ( Attribute :: InReg ) ) WaveDispatchNumSGPR += NumRegs ; else WaveDispatchNumVGPR += NumRegs ; } ProgInfo . NumSGPR = std :: max ( ProgInfo . NumSGPR , WaveDispatchNumSGPR ) ; ProgInfo . NumVGPR = std :: max ( ProgInfo . NumVGPR , WaveDispatchNumVGPR ) ; } ProgInfo . NumSGPRsForWavesPerEU = std :: max ( std :: max ( ProgInfo . NumSGPR , <NUM_LIT> ) , STM . getMinNumSGPRs ( MFI -> getMaxWavesPerEU ( ) ) ) ; ProgInfo . NumVGPRsForWavesPerEU = std :: max ( std :: max ( ProgInfo . NumVGPR , <NUM_LIT> ) , STM . getMinNumVGPRs ( MFI -> getMaxWavesPerEU ( ) ) ) ; if ( STM . getGeneration ( ) <= <ISA_LIT>Subtarget :: SEA_ISLANDS || STM . hasSGPRInitBug ( ) ) { unsigned MaxAddressableNumSGPRs = STM . getAddressableNumSGPRs ( ) ; if ( ProgInfo . NumSGPR > MaxAddressableNumSGPRs ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , ProgInfo . NumSGPR , DS_Error , DK_ResourceLimit , MaxAddressableNumSGPRs ) ; Ctx . diagnose ( Diag ) ; ProgInfo . NumSGPR = MaxAddressableNumSGPRs ; ProgInfo . NumSGPRsForWavesPerEU = MaxAddressableNumSGPRs ; } } if ( STM . hasSGPRInitBug ( ) ) { ProgInfo . NumSGPR = <STR_LIT> :: FIXED_NUM_SGPRS_FOR_INIT_BUG ; ProgInfo . NumSGPRsForWavesPerEU = <STR_LIT> :: FIXED_NUM_SGPRS_FOR_INIT_BUG ; } if ( MFI -> getNumUserSGPRs ( ) > STM . getMaxNumUserSGPRs ( ) ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , MFI -> getNumUserSGPRs ( ) , DS_Error ) ; Ctx . diagnose ( Diag ) ; } if ( MFI -> getLDSSize ( ) > static_cast < unsigned > ( STM . getLocalMemorySize ( ) ) ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , MFI -> getLDSSize ( ) , DS_Error ) ; Ctx . diagnose ( Diag ) ; } ProgInfo . SGPRBlocks = IsaInfo :: getNumSGPRBlocks ( & STM , ProgInfo . NumSGPRsForWavesPerEU ) ; ProgInfo . VGPRBlocks = IsaInfo :: getNumVGPRBlocks ( & STM , ProgInfo . NumVGPRsForWavesPerEU ) ;

const <ISA_LIT>ModeRegisterDefaults Mode = MFI -> getMode ( ) ;


<s> DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; } AsmPrinter :: EmitBasicBlockStart ( MBB ) ;


<s> } if ( MFI -> isEntryFunction ( ) ) { get<ISA_LIT>ProgramInfo ( CurrentProgramInfo , MF ) ; } else { auto I = CallGraphResourceInfo . insert ( std :: make_pair ( & MF . getFunction ( ) , <ISA_LIT>FunctionResourceInfo ( ) ) ) ; <ISA_LIT>FunctionResourceInfo & Info = I . first -> second ; assert ( I . second && <STR_LIT> ) ; Info = analyzeResourceUsage ( MF ) ; } if ( STM . isAmdPalOS ( ) ) EmitPALMetadata ( MF , CurrentProgramInfo ) ; else if ( ! STM . isAmdHsaOS ( ) ) { EmitProgramInfo<ISA_LIT> ( MF , CurrentProgramInfo ) ; } DumpCodeInstEmitter = nullptr ; if ( STM . dumpCode ( ) ) { bool SaveFlag = OutStreamer -> getUseAssemblerInfoForParsing ( ) ; OutStreamer -> setUseAssemblerInfoForParsing ( true ) ; MCAssembler * Assembler = OutStreamer -> getAssemblerPtr ( ) ; OutStreamer -> setUseAssemblerInfoForParsing ( SaveFlag ) ; if ( Assembler ) DumpCodeInstEmitter = Assembler -> getEmitterPtr ( ) ; } DisasmLines . clear ( ) ; HexLines . clear ( ) ; DisasmLineMaxLen = <NUM_LIT> ; EmitFunctionBody ( ) ; if ( isVerbose ( ) ) { MCSectionELF * CommentSection = Context . getELFSection ( <STR_LIT> , ELF :: SHT_PROGBITS , <NUM_LIT> ) ; OutStreamer -> SwitchSection ( CommentSection ) ; if ( ! MFI -> isEntryFunction ( ) ) { OutStreamer -> emitRawComment ( <STR_LIT> , false ) ; <ISA_LIT>FunctionResourceInfo & Info = CallGraphResourceInfo [ & MF . getFunction ( ) ] ; emitCommonFunctionComments ( Info . NumVGPR , Info . getTotalNumSGPRs ( MF . getSubtarget < GCNSubtarget > ( ) ) , Info . PrivateSegmentSize , getFunctionCodeSize ( MF ) , MFI ) ; return false ; }


<s> unsigned MaxGPR = <NUM_LIT> ; bool killPixel = false ; const <ISA_LIT>Subtarget & STM = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const <ISA_LIT>RegisterInfo * RI = STM . getRegisterInfo ( ) ; const <ISA_LIT>MachineFunctionInfo * MFI = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; for ( const MachineBasicBlock & MBB : MF ) { for ( const MachineInstr & MI : MBB ) { if ( MI . getOpcode ( ) == <STR_LIT> ) killPixel = true ; unsigned numOperands = MI . getNumOperands ( ) ; for ( unsigned op_idx = <NUM_LIT> ; op_idx < numOperands ; op_idx ++ ) { const MachineOperand & MO = MI . getOperand ( op_idx ) ; if ( ! MO . isReg ( ) ) continue ; unsigned HWReg = RI -> getEncodingValue ( MO . getReg ( ) ) & <NUM_LIT> ; if ( HWReg > <NUM_LIT> ) continue ; MaxGPR = std :: max ( MaxGPR , HWReg ) ; } } } unsigned RsrcReg ; if ( STM . getGeneration ( ) >= <ISA_LIT>Subtarget :: EVERGREEN ) { switch ( MF . getFunction ( ) -> getCallingConv ( ) ) { default : case CallingConv :: <ISA_LIT>_CS : RsrcReg = R_0288D4_SQ_PGM_RESOURCES_LS ; break ; case CallingConv :: <ISA_LIT>_GS : RsrcReg = R_028878_SQ_PGM_RESOURCES_GS ; break ; case CallingConv :: <ISA_LIT>_PS : RsrcReg = R_028844_SQ_PGM_RESOURCES_PS ; break ; case CallingConv :: <ISA_LIT>_VS : RsrcReg = R_028860_SQ_PGM_RESOURCES_VS ; break ; } } else { switch ( MF . getFunction ( ) -> getCallingConv ( ) ) { default : case CallingConv :: <ISA_LIT>_GS : case CallingConv :: <ISA_LIT>_CS : case CallingConv :: <ISA_LIT>_VS : RsrcReg = R_028868_SQ_PGM_RESOURCES_VS ; break ; case CallingConv :: <ISA_LIT>_PS : RsrcReg = R_028850_SQ_PGM_RESOURCES_PS ; break ; } } OutStreamer -> EmitIntValue ( RsrcReg , <NUM_LIT> ) ;

OutStreamer -> EmitIntValue ( S_NUM_GPRS ( MaxGPR + <NUM_LIT> ) | S_STACK_<ISA_LIT>ZE ( MFI -> CFStackSize ) , <NUM_LIT> ) ;


<s> static void emitRuntimeMDIntValue ( MCStreamer & Streamer , RuntimeMD :: Key K , uint64_t V , unsigned Size ) { Streamer . EmitIntValue ( K , <NUM_LIT> ) ; Streamer . EmitIntValue ( V , Size ) ;


<s> Streamer . EmitIntValue ( K , <NUM_LIT> ) ; Streamer . EmitIntValue ( S . size ( ) , <NUM_LIT> ) ; Streamer . EmitBytes ( S ) ;


<s> for ( const MDOperand & Op : Node -> operands ( ) ) {

const ConstantInt * CI = mdconst :: extract < ConstantInt > ( Op ) ;


<s> auto TypeKind = StringSwitch < RuntimeMD :: KernelArg :: TypeKind > ( BaseTypeName ) . Case ( <STR_LIT> , RuntimeMD :: KernelArg :: Sampler ) . Case ( <STR_LIT> , RuntimeMD :: KernelArg :: Queue ) . Cases ( <STR_LIT> , <STR_LIT> , <STR_LIT> , <STR_LIT> , <STR_LIT> , RuntimeMD :: KernelArg :: Image ) . Cases ( <STR_LIT> , <STR_LIT> , <STR_LIT> , <STR_LIT> , <STR_LIT> , RuntimeMD :: KernelArg :: Image ) . Cases ( <STR_LIT> , <STR_LIT> , RuntimeMD :: KernelArg :: Image ) . Default ( isa < PointerType > ( T ) ? RuntimeMD :: KernelArg :: Pointer : RuntimeMD :: KernelArg :: Value ) ; emitRuntimeMDIntValue ( * OutStreamer , RuntimeMD :: KeyArgTypeKind , TypeKind , <NUM_LIT> ) ; emitRuntimeMDIntValue ( * OutStreamer , RuntimeMD :: KeyArgValueType , getRuntimeMDValueType ( T , BaseTypeName ) , <NUM_LIT> ) ; auto AccQual = cast < MDString > ( F . getMetadata ( <STR_LIT> ) -> getOperand ( I ) ) -> getString ( ) ; auto AQ = StringSwitch < RuntimeMD :: KernelArg :: AccessQualifer > ( AccQual ) . Case ( <STR_LIT> , RuntimeMD :: KernelArg :: ReadOnly ) . Case ( <STR_LIT> , RuntimeMD :: KernelArg :: WriteOnly ) . Case ( <STR_LIT> , RuntimeMD :: KernelArg :: ReadWrite ) . Default ( RuntimeMD :: KernelArg :: None ) ; emitRuntimeMDIntValue ( * OutStreamer , RuntimeMD :: KeyArgAccQual , AQ , <NUM_LIT> ) ; if ( auto * PT = dyn_cast < PointerType > ( T ) ) { emitRuntimeMDIntValue ( * OutStreamer , RuntimeMD :: KeyArgAddrQual , PT -> getAddressSpace ( ) , <NUM_LIT> ) ; } OutStreamer -> EmitIntValue ( RuntimeMD :: KeyArgEnd , <NUM_LIT> ) ; }

if ( auto RWGS = F . getMetadata ( <STR_LIT> ) ) {


<s> TS -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; <STR_LIT> ISA = <STR_LIT> ( STI -> getFeatureBits ( ) ) ; TS -> EmitDirectiveHSACodeObjectISA ( ISA . Major , ISA . Minor , ISA . Stepping , <STR_LIT> , <STR_LIT> ) ; emitStartOfRuntimeMetadata ( M ) ;


<s> std :: unique_ptr < MCSubtargetInfo > STI ( TM . getTarget ( ) . createMCSubtargetInfo ( TM . getTargetTriple ( ) . str ( ) , TM . getTargetCPU ( ) , TM . getTargetFeatureString ( ) ) ) ; <ISA_LIT>TargetStreamer * TS = static_cast < <ISA_LIT>TargetStreamer * > ( OutStreamer -> getTargetStreamer ( ) ) ; TS -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ;

<STR_LIT> ISA = <STR_LIT> ( STI -> getFeatureBits ( ) ) ;


<s> emitRuntimeMDIntValue ( * OutStreamer , RuntimeMD :: KeyMDVersion , RuntimeMD :: MDVersion << <NUM_LIT> | RuntimeMD :: MDRevision , <NUM_LIT> ) ; if ( auto MD = M . getNamedMetadata ( <STR_LIT> ) ) { if ( MD -> getNumOperands ( ) != <NUM_LIT> ) { auto Node = MD -> getOperand ( <NUM_LIT> ) ;

if ( Node -> getNumOperands ( ) > <NUM_LIT> ) {


<s> uint16_t Major = mdconst :: extract < ConstantInt > ( Node -> getOperand ( <NUM_LIT> ) ) -> getZExtValue ( ) ; uint16_t Minor = mdconst :: extract < ConstantInt > ( Node -> getOperand ( <NUM_LIT> ) ) -> getZExtValue ( ) ; emitRuntimeMDIntValue ( * OutStreamer , RuntimeMD :: KeyLanguageVersion , Major * <NUM_LIT> + Minor * <NUM_LIT> , <NUM_LIT> ) ;


<s> if ( ! Signed ) return ( Twine ( 'u' ) + getOCLTypeName ( Ty , true ) ) . str ( ) ; unsigned BW = Ty -> getIntegerBitWidth ( ) ; switch ( BW ) { case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; default : return ( Twine ( 'i' ) + Twine ( BW ) ) . str ( ) ; } } case Type :: VectorTyID : { VectorType * VecTy = cast < VectorType > ( Ty ) ; Type * EleTy = VecTy -> getElementType ( ) ;

unsigned Size = VecTy -> getVectorNumElements ( ) ;


<s> const char * <ISA_LIT>AsmPrinter :: getPassName ( ) const {


<s> switch ( Ty -> getIntegerBitWidth ( ) ) { case <NUM_LIT> : return Signed ? RuntimeMD :: KernelArg :: I8 : RuntimeMD :: KernelArg :: U8 ; case <NUM_LIT> : return Signed ? RuntimeMD :: KernelArg :: I16 : RuntimeMD :: KernelArg :: U16 ; case <NUM_LIT> : return Signed ? RuntimeMD :: KernelArg :: I32 : RuntimeMD :: KernelArg :: U32 ; case <NUM_LIT> : return Signed ? RuntimeMD :: KernelArg :: I64 : RuntimeMD :: KernelArg :: U64 ; default : return RuntimeMD :: KernelArg :: Struct ; } } case Type :: VectorTyID : return getRuntimeMDValueType ( Ty -> getVectorElementType ( ) , TypeName ) ; case Type :: PointerTyID : return getRuntimeMDValueType ( Ty -> getPointerElementType ( ) , TypeName ) ;


<s> case Type :: FloatTyID : return RuntimeMD :: KernelArg :: F32 ; case Type :: DoubleTyID : return RuntimeMD :: KernelArg :: F64 ; case Type :: IntegerTyID : { bool Signed = ! TypeName . startswith ( <STR_LIT> ) ; switch ( Ty -> getIntegerBitWidth ( ) ) { case <NUM_LIT> : return Signed ? RuntimeMD :: KernelArg :: I8 : RuntimeMD :: KernelArg :: U8 ; case <NUM_LIT> :

return Signed ? RuntimeMD :: KernelArg :: I16 : RuntimeMD :: KernelArg :: U16 ;


OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( KernelInfo . DebuggerPrivateSegmentBufferSGPR ) , false ) ;


<s> if ( isHsaAbiVersion2 ( getGlobalSTI ( ) ) ) { HSAMetadataStream . reset ( new MetadataStreamerV2 ( ) ) ; } else { HSAMetadataStream . reset ( new MetadataStreamerV3 ( ) ) ; } }


<s> if ( <STR_LIT> ( STI ) && ( STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA || STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) ) { OutStreamer -> SwitchSection ( getObjFileLowering ( ) . getTextSection ( ) ) ; getTargetStreamer ( ) -> EmitCodeEnd ( ) ;


<s> if ( <STR_LIT> ( STI ) && ( STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA || STI . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) ) { OutStreamer -> SwitchSection ( getObjFileLowering ( ) . getTextSection ( ) ) ; getTargetStreamer ( ) -> EmitCodeEnd ( ) ; } return AsmPrinter :: doFinalization ( M ) ;


<s> } if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) { HSAMetadataStream -> end ( ) ; bool Success = HSAMetadataStream -> emitTo ( * getTargetStreamer ( ) ) ; ( void ) Success ; assert ( Success && <STR_LIT> ) ; }


<s> Streamer . emitValueToAlignment ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ; if ( ReadOnlySection . getAlignment ( ) < <NUM_LIT> ) ReadOnlySection . setAlignment ( Align ( <NUM_LIT> ) ) ; const MCSubtargetInfo & STI = MF -> getSubtarget ( ) ; SmallString < <NUM_LIT> > KernelName ; getNameWithPrefix ( KernelName , & MF -> getFunction ( ) ) ; getTargetStreamer ( ) -> EmitAmdhsaKernelDescriptor ( STI , KernelName , getAmdhsaKernelDescriptor ( * MF , CurrentProgramInfo ) , CurrentProgramInfo . NumVGPRsForWavesPerEU , CurrentProgramInfo . NumSGPRsForWavesPerEU - IsaInfo :: getNumExtraSGPRs ( & STI , CurrentProgramInfo . VCCUsed , CurrentProgramInfo . FlatUsed ) , CurrentProgramInfo . VCCUsed , CurrentProgramInfo . FlatUsed , hasXNACK ( STI ) ) ; Streamer . PopSection ( ) ;


<s> auto & ObjectFileInfo = * Context . getObjectFileInfo ( ) ; auto & ReadOnlySection = * ObjectFileInfo . getReadOnlySection ( ) ; Streamer . PushSection ( ) ; Streamer . SwitchSection ( & ReadOnlySection ) ; Streamer . emitValueToAlignment ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ; if ( ReadOnlySection . getAlignment ( ) < <NUM_LIT> ) ReadOnlySection . setAlignment ( Align ( <NUM_LIT> ) ) ; const MCSubtargetInfo & STI = MF -> getSubtarget ( ) ; SmallString < <NUM_LIT> > KernelName ; getNameWithPrefix ( KernelName , & MF -> getFunction ( ) ) ;

getTargetStreamer ( ) -> EmitAmdhsaKernelDescriptor ( STI , KernelName , getAmdhsaKernelDescriptor ( * MF , CurrentProgramInfo ) , CurrentProgramInfo . NumVGPRsForWavesPerEU , CurrentProgramInfo . NumSGPRsForWavesPerEU - IsaInfo :: getNumExtraSGPRs ( & STI , CurrentProgramInfo . VCCUsed , CurrentProgramInfo . FlatUsed ) , CurrentProgramInfo . VCCUsed , CurrentProgramInfo . FlatUsed , hasXNACK ( STI ) ) ;


<s> void <ISA_LIT>AsmPrinter :: emitFunctionBodyStart ( ) { const <ISA_LIT>MachineFunctionInfo & MFI = * MF -> getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; if ( ! MFI . isEntryFunction ( ) ) return ;

const GCNSubtarget & STM = MF -> getSubtarget < GCNSubtarget > ( ) ;


<s> } const <ISA_LIT>MachineFunctionInfo * MFI = MF -> getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const GCNSubtarget & STM = MF -> getSubtarget < GCNSubtarget > ( ) ; if ( MFI -> isEntryFunction ( ) && STM . isAmdHsaOrMesa ( MF -> getFunction ( ) ) ) { SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , & MF -> getFunction ( ) ) , getTargetStreamer ( ) -> Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ; } if ( DumpCodeInstEmitter ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; } AsmPrinter :: emitFunctionEntryLabel ( ) ;


<s> return ; } const <ISA_LIT>MachineFunctionInfo * MFI = MF -> getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const GCNSubtarget & STM = MF -> getSubtarget < GCNSubtarget > ( ) ; if ( MFI -> isEntryFunction ( ) && STM . isAmdHsaOrMesa ( MF -> getFunction ( ) ) ) { SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , & MF -> getFunction ( ) ) , getTargetStreamer ( ) -> Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ; } if ( DumpCodeInstEmitter ) { DisasmLines . push_back ( MF -> getName ( ) . str ( ) + <STR_LIT> ) ; DisasmLineMaxLen = std :: max ( DisasmLineMaxLen , DisasmLines . back ( ) . size ( ) ) ; HexLines . push_back ( <STR_LIT> ) ; }

AsmPrinter :: emitFunctionEntryLabel ( ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream -> begin ( M ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) getTargetStreamer ( ) -> getPALMetadata ( ) -> readFromIR ( M ) ; if ( isHsaAbiVersion3 ( getGlobalSTI ( ) ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ;

IsaVersion Version = getIsaVersion ( getGlobalSTI ( ) -> getCPU ( ) ) ;


<s> getTargetStreamer ( ) -> EmitDirectiveAMDGCNTarget ( ExpectedTarget ) ; } if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA && TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream -> begin ( M ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) getTargetStreamer ( ) -> getPALMetadata ( ) -> readFromIR ( M ) ;

if ( isHsaAbiVersion3 ( getGlobalSTI ( ) ) ) return ;


<s> assert ( isUInt < <NUM_LIT> > ( PI . ScratchSize ) ) ; assert ( isUInt < <NUM_LIT> > ( PI . getComputePGMRSrc1 ( ) ) ) ; assert ( isUInt < <NUM_LIT> > ( PI . ComputePGMRSrc2 ) ) ; KernelDescriptor . group_segment_fixed_size = PI . LDSSize ; KernelDescriptor . private_segment_fixed_size = PI . ScratchSize ;

KernelDescriptor . compute_pgm_rsrc1 = PI . getComputePGMRSrc1 ( ) ;


<s> ProgInfo . VGPRBlocks = IsaInfo :: getNumVGPRBlocks ( & STM , ProgInfo . NumVGPRsForWavesPerEU ) ; const <ISA_LIT>ModeRegisterDefaults Mode = MFI -> getMode ( ) ; ProgInfo . FloatMode = getFPMode ( Mode ) ; ProgInfo . IEEEMode = Mode . IEEE ; ProgInfo . DX10Clamp = Mode . DX10Clamp ; unsigned LDSAlignShift ; if ( STM . getGeneration ( ) < <ISA_LIT>Subtarget :: SEA_ISLANDS ) { LDSAlignShift = <NUM_LIT> ; } else { LDSAlignShift = <NUM_LIT> ; } unsigned LDSSpillSize = MFI -> getLDSWaveSpillSize ( ) * MFI -> getMaxFlatWorkGroupSize ( ) ; ProgInfo . LDSSize = MFI -> getLDSSize ( ) + LDSSpillSize ; ProgInfo . LDSBlocks = alignTo ( ProgInfo . LDSSize , <NUM_LIT> << LDSAlignShift ) >> LDSAlignShift ; unsigned ScratchAlignShift = <NUM_LIT> ; ProgInfo . ScratchBlocks = alignTo ( ProgInfo . ScratchSize * STM . getWavefrontSize ( ) , <NUM_LIT> << ScratchAlignShift ) >> ScratchAlignShift ; if ( getIsaVersion ( getGlobalSTI ( ) -> getCPU ( ) ) . Major >= <NUM_LIT> ) { ProgInfo . WgpMode = STM . isCuModeEnabled ( ) ? <NUM_LIT> : <NUM_LIT> ; ProgInfo . MemOrdered = <NUM_LIT> ; } unsigned TIDIGCompCnt = <NUM_LIT> ; if ( MFI -> hasWorkItemIDZ ( ) ) TIDIGCompCnt = <NUM_LIT> ; else if ( MFI -> hasWorkItemIDY ( ) ) TIDIGCompCnt = <NUM_LIT> ; ProgInfo . ComputePGMRSrc2 = S_00B84C_SCRATCH_EN ( ProgInfo . ScratchBlocks > <NUM_LIT> ) | S_00B84C_USER_SGPR ( MFI -> getNumUserSGPRs ( ) ) | S_00B84C_TRAP_HANDLER ( STM . isAmdHsaOS ( ) ? <NUM_LIT> : STM . isTrapHandlerEnabled ( ) ) | S_00B84C_TGID_X_EN ( MFI -> hasWorkGroupIDX ( ) ) | S_00B84C_TGID_Y_EN ( MFI -> hasWorkGroupIDY ( ) ) | S_00B84C_TGID_Z_EN ( MFI -> hasWorkGroupIDZ ( ) ) | S_00B84C_TG_<ISA_LIT>ZE_EN ( MFI -> hasWorkGroupInfo ( ) ) | S_00B84C_TIDIG_COMP_CNT ( TIDIGCompCnt ) | S_00B84C_EXCP_EN_MSB ( <NUM_LIT> ) | S_00B84C_LDS_<ISA_LIT>ZE ( STM . isAmdHsaOS ( ) ? <NUM_LIT> : ProgInfo . LDSBlocks ) | S_00B84C_EXCP_EN ( <NUM_LIT> ) ;

ProgInfo . Occupancy = STM . computeOccupancy ( MF . getFunction ( ) , ProgInfo . LDSSize , ProgInfo . NumSGPRsForWavesPerEU , ProgInfo . NumVGPRsForWavesPerEU ) ;


<s> DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , ProgInfo . NumSGPR , DS_Error , DK_ResourceLimit , MaxAddressableNumSGPRs ) ; Ctx . diagnose ( Diag ) ; ProgInfo . NumSGPR = MaxAddressableNumSGPRs - <NUM_LIT> ; } } ProgInfo . NumSGPR += ExtraSGPRs ; const Function & F = MF . getFunction ( ) ; unsigned WaveDispatchNumSGPR = <NUM_LIT> , WaveDispatchNumVGPR = <NUM_LIT> ; if ( isShader ( F . getCallingConv ( ) ) ) { const DataLayout & DL = F . getParent ( ) -> getDataLayout ( ) ; for ( auto & Arg : F . args ( ) ) { unsigned NumRegs = ( DL . getTypeSizeInBits ( Arg . getType ( ) ) + <NUM_LIT> ) / <NUM_LIT> ; if ( Arg . hasAttribute ( Attribute :: InReg ) ) WaveDispatchNumSGPR += NumRegs ; else WaveDispatchNumVGPR += NumRegs ; } ProgInfo . NumSGPR = std :: max ( ProgInfo . NumSGPR , WaveDispatchNumSGPR ) ; ProgInfo . NumVGPR = std :: max ( ProgInfo . NumVGPR , WaveDispatchNumVGPR ) ; } ProgInfo . NumSGPRsForWavesPerEU = std :: max ( std :: max ( ProgInfo . NumSGPR , <NUM_LIT> ) , STM . getMinNumSGPRs ( MFI -> getMaxWavesPerEU ( ) ) ) ; ProgInfo . NumVGPRsForWavesPerEU = std :: max ( std :: max ( ProgInfo . NumVGPR , <NUM_LIT> ) , STM . getMinNumVGPRs ( MFI -> getMaxWavesPerEU ( ) ) ) ; if ( STM . getGeneration ( ) <= <ISA_LIT>Subtarget :: SEA_ISLANDS || STM . hasSGPRInitBug ( ) ) { unsigned MaxAddressableNumSGPRs = STM . getAddressableNumSGPRs ( ) ; if ( ProgInfo . NumSGPR > MaxAddressableNumSGPRs ) { LLVMContext & Ctx = MF . getFunction ( ) . getContext ( ) ; DiagnosticInfoResourceLimit Diag ( MF . getFunction ( ) , <STR_LIT> , ProgInfo . NumSGPR , DS_Error , DK_ResourceLimit , MaxAddressableNumSGPRs ) ; Ctx . diagnose ( Diag ) ; ProgInfo . NumSGPR = MaxAddressableNumSGPRs ; ProgInfo . NumSGPRsForWavesPerEU = MaxAddressableNumSGPRs ; } } if ( STM . hasSGPRInitBug ( ) ) { ProgInfo . NumSGPR = <STR_LIT> :: FIXED_NUM_SGPRS_FOR_INIT_BUG ; ProgInfo . NumSGPRsForWavesPerEU = <STR_LIT> :: FIXED_NUM_SGPRS_FOR_INIT_BUG ; }

if ( MFI -> getNumUserSGPRs ( ) > STM . getMaxNumUserSGPRs ( ) ) {


<s> if ( ! getTargetStreamer ( ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA || isHsaAbiVersion2 ( getGlobalSTI ( ) ) ) getTargetStreamer ( ) -> EmitISAVersion ( ) ;

if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) {


<s> const GCNSubtarget & STM = MF . getSubtarget < GCNSubtarget > ( ) ; if ( STM . hasMAIInsts ( ) ) { MD -> setNumUsedAgprs ( CC , CurrentProgramInfo . NumAccVGPR ) ; } MD -> setNumUsedSgprs ( CC , CurrentProgramInfo . NumSGPRsForWavesPerEU ) ; MD -> setRsrc1 ( CC , CurrentProgramInfo . getPGMRSrc1 ( CC ) ) ; if ( <STR_LIT> ( CC ) ) { MD -> setRsrc2 ( CC , CurrentProgramInfo . ComputePGMRSrc2 ) ; } else {

if ( CurrentProgramInfo . ScratchBlocks > <NUM_LIT> ) MD -> setRsrc2 ( CC , S_00B84C_SCRATCH_EN ( <NUM_LIT> ) ) ;


<s> IsTargetStreamerInitialized = false ;


Out . wavefront_sgpr_count = CurrentProgramInfo . NumSGPR ;


<s> IsTargetStreamerInitialized = true ; if ( getTargetStreamer ( ) && ! getTargetStreamer ( ) -> getTargetID ( ) ) initializeTargetID ( M ) ; if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA && TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) return ; if ( isHsaAbiVersion3AndAbove ( getGlobalSTI ( ) ) ) getTargetStreamer ( ) -> EmitDirectiveAMDGCNTarget ( ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) HSAMetadataStream -> begin ( M , * getTargetStreamer ( ) -> getTargetID ( ) ) ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDPAL ) getTargetStreamer ( ) -> getPALMetadata ( ) -> readFromIR ( M ) ; if ( isHsaAbiVersion3AndAbove ( getGlobalSTI ( ) ) ) return ; if ( TM . getTargetTriple ( ) . getOS ( ) == Triple :: AMDHSA ) getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectVersion ( <NUM_LIT> , <NUM_LIT> ) ; IsaVersion Version = getIsaVersion ( getGlobalSTI ( ) -> getCPU ( ) ) ;

getTargetStreamer ( ) -> EmitDirectiveHSACodeObjectISAV2 ( Version . Major , Version . Minor , Version . Stepping , <STR_LIT> , <STR_LIT> ) ;


<s> } OutStreamer -> emitRawComment ( <STR_LIT> , false ) ; emitCommonFunctionComments ( CurrentProgramInfo . NumArchVGPR , STM . hasMAIInsts ( ) ? CurrentProgramInfo . NumAccVGPR : Optional < uint32_t > ( ) , CurrentProgramInfo . NumVGPR , CurrentProgramInfo . NumSGPR , CurrentProgramInfo . ScratchSize , getFunctionCodeSize ( MF ) , MFI ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . FloatMode ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . IEEEMode ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . LDSSize ) + <STR_LIT> , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . SGPRBlocks ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . VGPRBlocks ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . NumSGPRsForWavesPerEU ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . NumVGPRsForWavesPerEU ) , false ) ; if ( STM . hasGFX90AInsts ( ) ) OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( ( CurrentProgramInfo . AccumOffset + <NUM_LIT> ) * <NUM_LIT> ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( CurrentProgramInfo . Occupancy ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( MFI -> needsWaveLimiter ( ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_SCRATCH_EN ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_USER_SGPR ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TRAP_HANDLER ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ;

OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( G_00B84C_TGID_X_EN ( CurrentProgramInfo . ComputePGMRSrc2 ) ) , false ) ;


<s> const <ISA_LIT>Subtarget & ST = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) ; const MachineFrameInfo & FrameInfo = MF . getFrameInfo ( ) ; const MachineRegisterInfo & MRI = MF . getRegInfo ( ) ; const <ISA_LIT>InstrInfo * TII = ST . getInstrInfo ( ) ; const <ISA_LIT>RegisterInfo & TRI = TII -> getRegisterInfo ( ) ; Info . UsesFlatScratch = MRI . isPhysRegUsed ( <STR_LIT> ) || MRI . isPhysRegUsed ( <STR_LIT> ) ; if ( Info . UsesFlatScratch && ! MFI -> hasFlatScratchInit ( ) && ( ! hasAnyNonFlatUseOfReg ( MRI , * TII , <STR_LIT> ) && ! hasAnyNonFlatUseOfReg ( MRI , * TII , <STR_LIT> ) && ! hasAnyNonFlatUseOfReg ( MRI , * TII , <STR_LIT> ) ) ) { Info . UsesFlatScratch = false ; } Info . HasDynamicallySizedStack = FrameInfo . hasVarSizedObjects ( ) ; Info . PrivateSegmentSize = FrameInfo . getStackSize ( ) ; Info . UsesVCC = MRI . isPhysRegUsed ( <STR_LIT> ) || MRI . isPhysRegUsed ( <STR_LIT> ) ; if ( ! FrameInfo . hasCalls ( ) && ! FrameInfo . hasTailCall ( ) ) { MCPhysReg HighestVGPRReg = <STR_LIT> ; for ( MCPhysReg Reg : reverse ( <STR_LIT> . getRegisters ( ) ) ) { if ( MRI . isPhysRegUsed ( Reg ) ) { HighestVGPRReg = Reg ; break ; } } MCPhysReg HighestSGPRReg = <STR_LIT> ; for ( MCPhysReg Reg : reverse ( <STR_LIT> . getRegisters ( ) ) ) { if ( MRI . isPhysRegUsed ( Reg ) ) { HighestSGPRReg = Reg ; break ; } } Info . NumVGPR = HighestVGPRReg == <STR_LIT> ? <NUM_LIT> : TRI . getHWRegIndex ( HighestVGPRReg ) + <NUM_LIT> ; Info . NumExplicitSGPR = HighestSGPRReg == <STR_LIT> ? <NUM_LIT> : TRI . getHWRegIndex ( HighestSGPRReg ) + <NUM_LIT> ; return Info ; } int32_t MaxVGPR = - <NUM_LIT> ; int32_t MaxSGPR = - <NUM_LIT> ; uint64_t CalleeFrameSize = <NUM_LIT> ; for ( const MachineBasicBlock & MBB : MF ) { for ( const MachineInstr & MI : MBB ) { for ( const MachineOperand & MO : MI . operands ( ) ) { unsigned Width = <NUM_LIT> ; bool IsSGPR = false ; if ( ! MO . isReg ( ) ) continue ; unsigned Reg = MO . getReg ( ) ; switch ( Reg ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : continue ; case <STR_LIT> : assert ( MI . isDebugValue ( ) ) ; continue ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : Info . UsesVCC = true ; continue ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : continue ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> if ( ! MFI -> isEntryFunction ( ) ) return ; const <ISA_LIT>Subtarget & STM = MF -> getSubtarget < <ISA_LIT>Subtarget > ( ) ; amd_kernel_code_t KernelCode ; if ( STM . isAmdCodeObjectV2 ( * MF ) ) { getAmdKernelCode ( KernelCode , CurrentProgramInfo , * MF ) ; OutStreamer -> SwitchSection ( getObjFileLowering ( ) . getTextSection ( ) ) ; getTargetStreamer ( ) -> EmitAMDKernelCodeT ( KernelCode ) ;


<s> if ( TM . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return ; HSAMetadataStream . emitKernel ( * MF -> getFunction ( ) , getHSACodeProps ( * MF , CurrentProgramInfo ) , getHSADebugProps ( * MF , CurrentProgramInfo ) ) ;


<s> SmallString < <NUM_LIT> > SymbolName ; getNameWithPrefix ( SymbolName , MF -> getFunction ( ) ) , getTargetStreamer ( ) -> Emit<ISA_LIT>SymbolType ( SymbolName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ; }

AsmPrinter :: EmitFunctionEntryLabel ( ) ;


<s> ScratchSizeKey = PALMD :: Key :: GS_SCRATCH_<ISA_LIT>ZE ; break ; case CallingConv :: <ISA_LIT>_ES : ScratchSizeKey = PALMD :: Key :: ES_SCRATCH_<ISA_LIT>ZE ; break ; case CallingConv :: <ISA_LIT>_HS : ScratchSizeKey = PALMD :: Key :: HS_SCRATCH_<ISA_LIT>ZE ; break ; case CallingConv :: <ISA_LIT>_LS : ScratchSizeKey = PALMD :: Key :: LS_SCRATCH_<ISA_LIT>ZE ; break ; } unsigned NumUsedVgprsKey = ScratchSizeKey + PALMD :: Key :: VS_NUM_USED_VGPRS - PALMD :: Key :: VS_SCRATCH_<ISA_LIT>ZE ; unsigned NumUsedSgprsKey = ScratchSizeKey + PALMD :: Key :: VS_NUM_USED_SGPRS - PALMD :: Key :: VS_SCRATCH_<ISA_LIT>ZE ; PALMetadataMap [ NumUsedVgprsKey ] = CurrentProgramInfo . NumVGPRsForWavesPerEU ; PALMetadataMap [ NumUsedSgprsKey ] = CurrentProgramInfo . NumSGPRsForWavesPerEU ; if ( <STR_LIT> ( MF . getFunction ( ) -> getCallingConv ( ) ) ) { PALMetadataMap [ Rsrc1Reg ] |= CurrentProgramInfo . ComputePGMRSrc1 ; PALMetadataMap [ Rsrc2Reg ] |= CurrentProgramInfo . ComputePGMRSrc2 ; PALMetadataMap [ ScratchSizeKey ] |= alignTo ( CurrentProgramInfo . ScratchSize , <NUM_LIT> ) ; } else { PALMetadataMap [ Rsrc1Reg ] |= S_00B028_VGPRS ( CurrentProgramInfo . VGPRBlocks ) | S_00B028_SGPRS ( CurrentProgramInfo . SGPRBlocks ) ; if ( CurrentProgramInfo . ScratchBlocks > <NUM_LIT> ) PALMetadataMap [ Rsrc2Reg ] |= S_00B84C_SCRATCH_EN ( <NUM_LIT> ) ;


<s> HSACodeProps . mGroupSegmentFixedSize = ProgramInfo . LDSSize ; HSACodeProps . mPrivateSegmentFixedSize = ProgramInfo . ScratchSize ; HSACodeProps . mKernargSegmentAlign = std :: max ( uint32_t ( <NUM_LIT> ) , MFI . getMaxKernArgAlign ( ) ) ; HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = CurrentProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = CurrentProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ; HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ; HSACodeProps . mIsXNACKEnabled = STM . isXNACKEnabled ( ) ;


<s> isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = true ; width = <NUM_LIT> ; } else if ( <STR_LIT> . contains ( reg ) ) { isSGPR = false ; width = <NUM_LIT> ; } else { llvm_unreachable ( <STR_LIT> ) ; } unsigned hwReg = RI -> getEncodingValue ( reg ) & <NUM_LIT> ; unsigned maxUsed = hwReg + width - <NUM_LIT> ; if ( isSGPR ) { MaxSGPR = maxUsed > MaxSGPR ? maxUsed : MaxSGPR ; } else { MaxVGPR = maxUsed > MaxVGPR ? maxUsed : MaxVGPR ; } } } } if ( VCCUsed ) MaxSGPR += <NUM_LIT> ; if ( FlatUsed ) MaxSGPR += <NUM_LIT> ; ProgInfo . NumVGPR = MaxVGPR + <NUM_LIT> ; ProgInfo . NumSGPR = MaxSGPR + <NUM_LIT> ; if ( STM . hasSGPRInitBug ( ) ) { if ( ProgInfo . NumSGPR > <ISA_LIT>Subtarget :: FIXED_SGPR_COUNT_FOR_INIT_BUG ) { LLVMContext & Ctx = MF . getFunction ( ) -> getContext ( ) ; Ctx . emitError ( <STR_LIT> ) ; } ProgInfo . NumSGPR = <ISA_LIT>Subtarget :: FIXED_SGPR_COUNT_FOR_INIT_BUG ; } ProgInfo . VGPRBlocks = ( ProgInfo . NumVGPR - <NUM_LIT> ) / <NUM_LIT> ; ProgInfo . SGPRBlocks = ( ProgInfo . NumSGPR - <NUM_LIT> ) / <NUM_LIT> ; ProgInfo . FloatMode = getFPMode ( MF ) ; ProgInfo . IEEEMode = <NUM_LIT> ; ProgInfo . DX10Clamp = <NUM_LIT> ; const MachineFrameInfo * FrameInfo = MF . getFrameInfo ( ) ; ProgInfo . ScratchSize = FrameInfo -> estimateStackSize ( MF ) ; ProgInfo . FlatUsed = FlatUsed ; ProgInfo . VCCUsed = VCCUsed ; ProgInfo . CodeLen = CodeSize ; unsigned LDSAlignShift ; if ( STM . getGeneration ( ) < <ISA_LIT>Subtarget :: SEA_ISLANDS ) { LDSAlignShift = <NUM_LIT> ; } else { LDSAlignShift = <NUM_LIT> ; } unsigned LDSSpillSize = MFI -> LDSWaveSpillSize * MFI -> getMaximumWorkGroupSize ( MF ) ; ProgInfo . LDSSize = MFI -> LDSSize + LDSSpillSize ; ProgInfo . LDSBlocks = RoundUpToAlignment ( ProgInfo . LDSSize , <NUM_LIT> << LDSAlignShift ) >> LDSAlignShift ; unsigned ScratchAlignShift = <NUM_LIT> ;

ProgInfo . ScratchBlocks = RoundUpToAlignment ( ProgInfo . ScratchSize * STM . getWavefrontSize ( ) , <NUM_LIT> << ScratchAlignShift ) >> ScratchAlignShift ;


<s>
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
IEEEMode
)
,
false
)
;
OutStreamer
->
emitRawComment
(
<STR_LIT>
+
Twine
(
KernelInfo
.
ScratchSize
)
,
false
)
;
}
else
{
<ISA_LIT>MachineFunctionInfo
*
MFI
=
MF
.
getInfo
<
<ISA_LIT>MachineFunctionInfo
>
(
)
;
OutStreamer
->
emitRawComment
(
Twine
(
<STR_LIT>
+
Twine
(
MFI
->
StackSize
)
)
)
;
}
}
if
(
STM
.
dumpCode
(
)
)
{
OutStreamer
->
SwitchSection
(
Context
.
getELFSection
(
<STR_LIT>
,
ELF
::
SHT_NOTE
,
<NUM_LIT>
)
)
;
for
(
size_t
i
=
<NUM_LIT>
;
i
<
DisasmLines
.
size
(
)
;
++
i
)
{
std
::
string
Comment
(
DisasmLineMaxLen
DisasmLines
[
i
]
.
size
(
)
,
' '
)
;
Comment
+=
<STR_LIT>
+
HexLines
[
i
]
+
<STR_LIT>
;

OutStreamer -> EmitBytes ( StringRef ( DisasmLines [ i ] ) ) ;


<s> if ( isVerbose ( ) ) { MCSectionELF * CommentSection = Context . getELFSection ( <STR_LIT> , ELF :: SHT_PROGBITS , <NUM_LIT> ) ; OutStreamer -> SwitchSection ( CommentSection ) ; if ( STM . getGeneration ( ) >= <ISA_LIT>Subtarget :: SOUTHERN_ISLANDS ) { OutStreamer -> emitRawComment ( <STR_LIT> , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( KernelInfo . CodeLen ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( KernelInfo . NumSGPR ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( KernelInfo . NumVGPR ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( KernelInfo . FloatMode ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( KernelInfo . IEEEMode ) , false ) ; OutStreamer -> emitRawComment ( <STR_LIT> + Twine ( KernelInfo . ScratchSize ) , false ) ; } else { <ISA_LIT>MachineFunctionInfo * MFI = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; OutStreamer -> emitRawComment ( Twine ( <STR_LIT> + Twine ( MFI -> StackSize ) ) ) ; } }