<s> AAPointerInfo :: OffsetAndSize OAS ( <STR_LIT> :: QUEUE_PTR_OFFSET , <NUM_LIT> ) ; return funcRetrievesImplicitKernelArg ( A , OAS ) ;


<s> bool funcRetrievesQueuePtr ( Attributor & A ) { if ( <STR_LIT> ( ) != <NUM_LIT> ) return false ; AAPointerInfo :: OffsetAndSize OAS ( <STR_LIT> :: QUEUE_PTR_OFFSET , <NUM_LIT> ) ; return funcRetrievesImplicitKernelArg ( A , OAS ) ;


<s> auto & InfoCache = static_cast < <ISA_LIT>InformationCache & > ( A . getInfoCache ( ) ) ; unsigned MinGroupSize , MaxGroupSize ; std :: tie ( MinGroupSize , MaxGroupSize ) = InfoCache . getFlatWorkGroupSizes ( * F ) ;

intersectKnown ( ConstantRange ( APInt ( <NUM_LIT> , MinGroupSize ) , APInt ( <NUM_LIT> , MaxGroupSize + <NUM_LIT> ) ) ) ;


<s> static ImplicitArgumentMask intrinsicToAttrMask ( <STR_LIT> ID , bool & NonKernelOnly , bool & NeedsImplicit , bool HasApertureRegs , bool SupportsGetDoorBellID ) { unsigned CodeObjectVersion = <STR_LIT> ( ) ; switch ( ID ) { case <STR_LIT> : NonKernelOnly = true ; return WORKITEM_ID_X ; case <STR_LIT> : NonKernelOnly = true ; return WORKGROUP_ID_X ; case <STR_LIT> : case <STR_LIT> : return WORKITEM_ID_Y ; case <STR_LIT> : case <STR_LIT> : return WORKITEM_ID_Z ; case <STR_LIT> : case <STR_LIT> : return WORKGROUP_ID_Y ; case <STR_LIT> : case <STR_LIT> : return WORKGROUP_ID_Z ; case <STR_LIT> : return DISPATCH_PTR ; case <STR_LIT> : return DISPATCH_ID ; case <STR_LIT> : return IMPLICIT_ARG_PTR ; case <STR_LIT> : NeedsImplicit = ( CodeObjectVersion == <NUM_LIT> ) ; return QUEUE_PTR ; case <STR_LIT> : case <STR_LIT> : if ( HasApertureRegs ) return NOT_IMPLICIT_INPUT ; return CodeObjectVersion == <NUM_LIT> ? IMPLICIT_ARG_PTR : QUEUE_PTR ; case <STR_LIT> :

if ( SupportsGetDoorBellID ) return CodeObjectVersion >= <NUM_LIT> ? NOT_IMPLICIT_INPUT : QUEUE_PTR ;


<s> DenseSet < const char * > Allowed ( { & AAAMDAttributes :: ID , & AAUniformWorkGroupSize :: ID , & AAAMDFlatWorkGroupSize :: ID , & AACallEdges :: ID , & AAPointerInfo :: ID } ) ; Attributor A ( Functions , InfoCache , CGUpdater , & Allowed ) ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) { A . getOrCreateAAFor < AAAMDAttributes > ( IRPosition :: function ( F ) ) ; A . getOrCreateAAFor < AAUniformWorkGroupSize > ( IRPosition :: function ( F ) ) ;

if ( ! <STR_LIT> ( F . getCallingConv ( ) ) ) {


<s> const GCNSubtarget & ST = TM . getSubtarget < GCNSubtarget > ( F ) ;


<s> ChangeStatus updateImpl ( Attributor & A ) override { Function * F = getAssociatedFunction ( ) ; auto OrigAssumed = getAssumed ( ) ; const AACallEdges & AAEdges = A . getAAFor < AACallEdges > ( * this , this -> getIRPosition ( ) , DepClassTy :: REQUIRED ) ; if ( AAEdges . hasNonAsmUnknownCallee ( ) ) return indicatePessimisticFixpoint ( ) ; bool IsNonEntryFunc = ! <STR_LIT> ( F -> getCallingConv ( ) ) ; bool NeedsImplicit = false ; auto & InfoCache = static_cast < <ISA_LIT>InformationCache & > ( A . getInfoCache ( ) ) ; bool HasApertureRegs = InfoCache . hasApertureRegs ( * F ) ; bool SupportsGetDoorbellID = InfoCache . supportsGetDoorbellID ( * F ) ; for ( Function * Callee : AAEdges . getOptimisticEdges ( ) ) { <STR_LIT> IID = Callee -> getIntrinsicID ( ) ; if ( IID == <STR_LIT> ) { const AAAMDAttributes & AAAMD = A . getAAFor < AAAMDAttributes > ( * this , IRPosition :: function ( * Callee ) , DepClassTy :: REQUIRED ) ; * this &= AAAMD ; continue ;


<s> AAPointerInfo :: OffsetAndSize OAS ( Pos , <NUM_LIT> ) ;

return funcRetrievesImplicitKernelArg ( A , OAS ) ;


<s> auto Pos = llvm :: <STR_LIT> ( ) ; AAPointerInfo :: OffsetAndSize OAS ( Pos , <NUM_LIT> ) ;


<s> for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) Functions . insert ( & F ) ; } CallGraphUpdater CGUpdater ; BumpPtrAllocator Allocator ; <ISA_LIT>InformationCache InfoCache ( M , AG , Allocator , nullptr , * TM ) ; DenseSet < const char * > Allowed ( { & AAAMDAttributes :: ID , & AAUniformWorkGroupSize :: ID , & AAAMDFlatWorkGroupSize :: ID , & AACallEdges :: ID , & AAPointerInfo :: ID } ) ; AttributorConfig AC ( CGUpdater ) ; AC . Allowed = & Allowed ; AC . IsModulePass = true ; AC . DefaultInitializeLiveInternals = false ; Attributor A ( Functions , InfoCache , AC ) ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) { A . getOrCreateAAFor < AAAMDAttributes > ( IRPosition :: function ( F ) ) ; A . getOrCreateAAFor < AAUniformWorkGroupSize > ( IRPosition :: function ( F ) ) ; if ( ! <STR_LIT> ( F . getCallingConv ( ) ) ) {

A . getOrCreateAAFor < AAAMDFlatWorkGroupSize > ( IRPosition :: function ( F ) ) ;


<s> for ( Function * Callee : AAEdges . getOptimisticEdges ( ) ) { <STR_LIT> IID = Callee -> getIntrinsicID ( ) ; if ( IID == <STR_LIT> ) { const AAAMDAttributes & AAAMD = A . getAAFor < AAAMDAttributes > ( * this , IRPosition :: function ( * Callee ) , DepClassTy :: REQUIRED ) ; * this &= AAAMD ; continue ; } bool NonKernelOnly = false ; ImplicitArgumentMask AttrMask = intrinsicToAttrMask ( IID , NonKernelOnly , NeedsImplicit , HasApertureRegs , SupportsGetDoorbellID ) ; if ( AttrMask != NOT_IMPLICIT_INPUT ) { if ( ( IsNonEntryFunc || ! NonKernelOnly ) ) removeAssumedBits ( AttrMask ) ; } } if ( NeedsImplicit ) removeAssumedBits ( IMPLICIT_ARG_PTR ) ; if ( isAssumed ( QUEUE_PTR ) && checkForQueuePtr ( A ) ) { if ( <STR_LIT> ( ) == <NUM_LIT> ) removeAssumedBits ( IMPLICIT_ARG_PTR ) ; else removeAssumedBits ( QUEUE_PTR ) ; } if ( funcRetrievesMultigridSyncArg ( A ) ) { assert ( ! isAssumed ( IMPLICIT_ARG_PTR ) && <STR_LIT> ) ; removeAssumedBits ( MULTIGRID_SYNC_ARG ) ; } if ( funcRetrievesHostcallPtr ( A ) ) { assert ( ! isAssumed ( IMPLICIT_ARG_PTR ) && <STR_LIT> ) ; removeAssumedBits ( HOSTCALL_PTR ) ;


<s> ChangeStatus updateImpl ( Attributor & A ) override { Function * F = getAssociatedFunction ( ) ; auto OrigAssumed = getAssumed ( ) ; const AACallEdges & AAEdges = A . getAAFor < AACallEdges > ( * this , this -> getIRPosition ( ) , DepClassTy :: REQUIRED ) ; if ( AAEdges . hasNonAsmUnknownCallee ( ) ) return indicatePessimisticFixpoint ( ) ; bool IsNonEntryFunc = ! <STR_LIT> ( F -> getCallingConv ( ) ) ; bool NeedsImplicit = false ; auto & InfoCache = static_cast < <ISA_LIT>InformationCache & > ( A . getInfoCache ( ) ) ; bool HasApertureRegs = InfoCache . hasApertureRegs ( * F ) ; bool SupportsGetDoorbellID = InfoCache . supportsGetDoorbellID ( * F ) ; for ( Function * Callee : AAEdges . getOptimisticEdges ( ) ) { <STR_LIT> IID = Callee -> getIntrinsicID ( ) ; if ( IID == <STR_LIT> ) { const AAAMDAttributes & AAAMD = A . getAAFor < AAAMDAttributes > ( * this , IRPosition :: function ( * Callee ) , DepClassTy :: REQUIRED ) ; * this &= AAAMD ; continue ; } bool NonKernelOnly = false ; ImplicitArgumentMask AttrMask = intrinsicToAttrMask ( IID , NonKernelOnly , NeedsImplicit , HasApertureRegs , SupportsGetDoorbellID ) ; if ( AttrMask != NOT_IMPLICIT_INPUT ) { if ( ( IsNonEntryFunc || ! NonKernelOnly ) ) removeAssumedBits ( AttrMask ) ; } } if ( NeedsImplicit ) removeAssumedBits ( IMPLICIT_ARG_PTR ) ; if ( isAssumed ( QUEUE_PTR ) && checkForQueuePtr ( A ) ) { if ( <STR_LIT> ( ) == <NUM_LIT> ) removeAssumedBits ( IMPLICIT_ARG_PTR ) ; else removeAssumedBits ( QUEUE_PTR ) ; } if ( funcRetrievesMultigridSyncArg ( A ) ) { assert ( ! isAssumed ( IMPLICIT_ARG_PTR ) && <STR_LIT> ) ; removeAssumedBits ( MULTIGRID_SYNC_ARG ) ; } if ( funcRetrievesHostcallPtr ( A ) ) { assert ( ! isAssumed ( IMPLICIT_ARG_PTR ) && <STR_LIT> ) ;


<s> AAAMDWorkGroupSize ( const IRPosition & IRP , Attributor & A ) : Base ( IRP ) {


<s> AAAMDWorkGroupSizeFunction ( const IRPosition & IRP , Attributor & A ) : AAAMDWorkGroupSize ( IRP , A ) {


<s> if ( IRP . getPositionKind ( ) == IRPosition :: IRP_FUNCTION ) return * new ( A . Allocator ) AAAMDWorkGroupSizeFunction ( IRP , A ) ;


<s> if ( IRP . getPositionKind ( ) == IRPosition :: IRP_FUNCTION ) return * new ( A . Allocator ) AAAMDWorkGroupSizeFunction ( IRP , A ) ; llvm_unreachable ( <STR_LIT> ) ;


<s> return <STR_LIT> + std :: to_string ( Attributes . size ( ) ) + <STR_LIT> ;


<s> const DenseSet < StringRef > & getAttributes ( ) const override {


<s> const std :: string getName ( ) const override {


<s> bool CallingConvSupportsAllImplicits = ( CC != CallingConv :: <ISA_LIT>_Gfx ) ; if ( <STR_LIT> ( F -> getCallingConv ( ) ) ) { indicatePessimisticFixpoint ( ) ; return ; } for ( StringRef Attr : ImplicitAttrNames ) { if ( F -> hasFnAttribute ( Attr ) ) Attributes . insert ( Attr ) ; } if ( CallingConvSupportsAllImplicits && F -> hasAddressTaken ( nullptr , true , true , true ) ) { for ( StringRef AttrName : ImplicitAttrNames ) {


<s> for ( StringRef Attr : ImplicitAttrNames ) { if ( F -> hasFnAttribute ( Attr ) ) Attributes . insert ( Attr ) ; } if ( CallingConvSupportsAllImplicits && F -> hasAddressTaken ( nullptr , true , true , true ) ) { for ( StringRef AttrName : ImplicitAttrNames ) { Attributes . insert ( AttrName ) ;


<s> ChangeStatus manifest ( Attributor & A ) override { SmallVector < Attribute , <NUM_LIT> > AttrList ; LLVMContext & Ctx = getAssociatedFunction ( ) -> getContext ( ) ;

for ( StringRef AttrName : Attributes ) AttrList . push_back ( Attribute :: get ( Ctx , AttrName ) ) ;


<s> for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) { A . getOrCreateAAFor < AAAMDAttributes > ( IRPosition :: function ( F ) ) ; A . getOrCreateAAFor < AAAMDWorkGroupSize > ( IRPosition :: function ( F ) ) ; } } ChangeStatus Change = A . run ( ) ; return Change == ChangeStatus :: CHANGED ;


<s> if ( IID != <STR_LIT> ) { if ( ! IsNonEntryFunc && IID == <STR_LIT> ) { AddAttribute ( <STR_LIT> ) ; continue ; } bool NonKernelOnly = false ; StringRef AttrName = intrinsicToAttrName ( IID , NonKernelOnly , NeedsQueuePtr ) ; if ( ! AttrName . empty ( ) && ( IsNonEntryFunc || ! NonKernelOnly ) ) AddAttribute ( AttrName ) ; continue ; } HasCall = true ; const AAAMDAttributes & AAAMD = A . getAAFor < AAAMDAttributes > ( * this , IRPosition :: function ( * Callee ) , DepClassTy :: REQUIRED ) ; const DenseSet < StringRef > & CalleeAttributes = AAAMD . getAttributes ( ) ; for ( StringRef AttrName : ImplicitAttrNames ) if ( CalleeAttributes . count ( AttrName ) ) AddAttribute ( AttrName ) ; } HasCall |= AAEdges . hasUnknownCallee ( ) ; if ( ! IsNonEntryFunc && HasCall ) AddAttribute ( <STR_LIT> ) ; auto CheckAlloca = [ & ] ( Instruction & I ) { AddAttribute ( <STR_LIT> ) ; return false ; } ; bool UsedAssumedInformation = false ; A . checkForAllInstructions ( CheckAlloca , * this , { Instruction :: Alloca } , UsedAssumedInformation ) ; if ( NeedsQueuePtr || Attributes . count ( <STR_LIT> ) ) { AddAttribute ( <STR_LIT> ) ; return Change ; } auto CheckAddrSpaceCasts = [ & ] ( Instruction & I ) { unsigned SrcAS = static_cast < AddrSpaceCastInst & > ( I ) . getSrcAddressSpace ( ) ; if ( castRequiresQueuePtr ( SrcAS ) ) { NeedsQueuePtr = true ;


<s> for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) Functions . insert ( & F ) ; } CallGraphUpdater CGUpdater ; BumpPtrAllocator Allocator ; <ISA_LIT>InformationCache InfoCache ( M , AG , Allocator , nullptr , * TM ) ; DenseSet < const char * > Allowed ( { & AAAMDAttributes :: ID , & AAAMDWorkGroupSize :: ID , & AACallEdges :: ID } ) ; Attributor A ( Functions , InfoCache , CGUpdater , & Allowed ) ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) { A . getOrCreateAAFor < AAAMDAttributes > ( IRPosition :: function ( F ) ) ; A . getOrCreateAAFor < AAAMDWorkGroupSize > ( IRPosition :: function ( F ) ) ; } } ChangeStatus Change = A . run ( ) ;

return Change == ChangeStatus :: CHANGED ;


<s> if ( F -> isIntrinsic ( ) ) { indicatePessimisticFixpoint ( ) ; return ; } if ( <STR_LIT> ( F -> getCallingConv ( ) ) ) { indicatePessimisticFixpoint ( ) ; return ; } for ( StringRef Attr : ImplicitAttrNames ) { if ( F -> hasFnAttribute ( Attr ) ) Attributes . insert ( Attr ) ;


<s> indicatePessimisticFixpoint ( ) ; return ; } if ( <STR_LIT> ( F -> getCallingConv ( ) ) ) { indicatePessimisticFixpoint ( ) ; return ; } for ( StringRef Attr : ImplicitAttrNames ) { if ( F -> hasFnAttribute ( Attr ) ) Attributes . insert ( Attr ) ; } if ( CallingConvSupportsAllImplicits && F -> hasAddressTaken ( nullptr , true , true , true ) ) { for ( StringRef AttrName : ImplicitAttrNames ) {


<s> return F . hasFnAttribute ( Attribute :: SanitizeAddress ) || F . hasFnAttribute ( Attribute :: SanitizeThread ) || F . hasFnAttribute ( Attribute :: SanitizeMemory ) || F . hasFnAttribute ( Attribute :: SanitizeHWAddress ) || F . hasFnAttribute ( Attribute :: SanitizeMemTag ) ;


<s> Function * F = getAssociatedFunction ( ) ; const bool NeedsImplicit = funcRequiresImplicitArgPtr ( * F ) ; if ( NeedsImplicit ) removeAssumedBits ( IMPLICIT_ARG_PTR ) ; for ( auto Attr : ImplicitAttrs ) { if ( NeedsImplicit && Attr . first == IMPLICIT_ARG_PTR ) continue ; if ( F -> hasFnAttribute ( Attr . second ) ) addKnownBits ( Attr . first ) ; } if ( F -> isDeclaration ( ) ) return ;

if ( <STR_LIT> ( F -> getCallingConv ( ) ) ) {


<s> DenseSet < const char * > Allowed ( { & AAAMDAttributes :: ID , & AAUniformWorkGroupSize :: ID , & AACallEdges :: ID } ) ; Attributor A ( Functions , InfoCache , CGUpdater , & Allowed ) ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) { A . getOrCreateAAFor < AAAMDAttributes > ( IRPosition :: function ( F ) ) ;

A . getOrCreateAAFor < AAUniformWorkGroupSize > ( IRPosition :: function ( F ) ) ;


<s> AAAMDAttributes ( const IRPosition & IRP , Attributor & A ) : Base ( IRP ) {


<s> AAAMDAttributesFunction ( const IRPosition & IRP , Attributor & A ) : AAAMDAttributes ( IRP , A ) {


<s> AAAMDFlatWorkGroupSize ( const IRPosition & IRP , Attributor & A ) : Base ( IRP , <NUM_LIT> ) {


<s> AAUniformWorkGroupSize ( const IRPosition & IRP , Attributor & A ) : Base ( IRP ) {


<s> AAUniformWorkGroupSizeFunction ( const IRPosition & IRP , Attributor & A ) : AAUniformWorkGroupSize ( IRP , A ) {


<s> <ISA_LIT>Attributor ( ) : ModulePass ( ID ) {


<s> <ISA_LIT>InformationCache ( const Module & M , AnalysisGetter & AG , BumpPtrAllocator & Allocator , SetVector < Function * > * CGSCC , TargetMachine & TM ) : InformationCache ( M , AG , Allocator , CGSCC ) , TM ( TM ) {


<s> static bool classof ( const AbstractAttribute * AA ) {

return ( AA -> getIdAddr ( ) == & ID ) ;


<s> Pass * llvm :: create<ISA_LIT>AttributorPass ( ) { return new <ISA_LIT>Attributor ( ) ;


<s> AAAMDFlatWorkGroupSize & AAAMDFlatWorkGroupSize :: createForPosition ( const IRPosition & IRP , Attributor & A ) {

if ( IRP . getPositionKind ( ) == IRPosition :: IRP_FUNCTION ) return * new ( A . Allocator ) AAAMDFlatWorkGroupSize ( IRP , A ) ;


<s> AAAMDFlatWorkGroupSize & AAAMDFlatWorkGroupSize :: createForPosition ( const IRPosition & IRP , Attributor & A ) { if ( IRP . getPositionKind ( ) == IRPosition :: IRP_FUNCTION ) return * new ( A . Allocator ) AAAMDFlatWorkGroupSize ( IRP , A ) ;


<s> auto * TPC = getAnalysisIfAvailable < TargetPassConfig > ( ) ; if ( ! TPC ) report_fatal_error ( <STR_LIT> ) ; TM = & TPC -> getTM < TargetMachine > ( ) ; return false ;


<s> bool doInitialization ( Module & ) override {

auto * TPC = getAnalysisIfAvailable < TargetPassConfig > ( ) ;


<s> raw_string_ostream OS ( Str ) ; OS << <STR_LIT> ; OS << getAssumed ( ) . getLower ( ) << ',' << getAssumed ( ) . getUpper ( ) - <NUM_LIT> ; OS << ']' ;


<s> for ( const Use & U : C -> operands ( ) ) { const auto * OpC = dyn_cast < Constant > ( U ) ; if ( ! OpC ) continue ; Result |= getConstantAccess ( OpC ) ; }


<s> const GCNSubtarget & ST = TM . getSubtarget < GCNSubtarget > ( F ) ; return ST . getFlatWorkGroupSizes ( F ) ;


<s> std :: pair < unsigned , unsigned > getFlatWorkGroupSizes ( const Function & F ) {

const GCNSubtarget & ST = TM . getSubtarget < GCNSubtarget > ( F ) ;


<s> const char * getIdAddr ( ) const override { return & ID ;


<s> std :: pair < unsigned , unsigned > getMaximumFlatWorkGroupRange ( const Function & F ) { const GCNSubtarget & ST = TM . getSubtarget < GCNSubtarget > ( F ) ; return { ST . getMinFlatWorkGroupSize ( ) , ST . getMaxFlatWorkGroupSize ( ) } ;


<s> const std :: string getName ( ) const override { return <STR_LIT> ;


<s> StringRef getPassName ( ) const override { return <STR_LIT> ;


<s> const IntegerRangeState & getState ( ) const override { return * this ;


<s> void initialize ( Attributor & A ) override { Function * F = getAssociatedFunction ( ) ; auto & InfoCache = static_cast < <ISA_LIT>InformationCache & > ( A . getInfoCache ( ) ) ; unsigned MinGroupSize , MaxGroupSize ;

std :: tie ( MinGroupSize , MaxGroupSize ) = InfoCache . getFlatWorkGroupSizes ( * F ) ;


<s> Function * F = getAssociatedFunction ( ) ; auto & InfoCache = static_cast < <ISA_LIT>InformationCache & > ( A . getInfoCache ( ) ) ; unsigned MinGroupSize , MaxGroupSize ; std :: tie ( MinGroupSize , MaxGroupSize ) = InfoCache . getFlatWorkGroupSizes ( * F ) ;


<s> return WORKITEM_ID_X ; case <STR_LIT> : NonKernelOnly = true ; return WORKGROUP_ID_X ; case <STR_LIT> : case <STR_LIT> : return WORKITEM_ID_Y ; case <STR_LIT> : case <STR_LIT> : return WORKITEM_ID_Z ; case <STR_LIT> : case <STR_LIT> : return WORKGROUP_ID_Y ; case <STR_LIT> : case <STR_LIT> : return WORKGROUP_ID_Z ; case <STR_LIT> : return DISPATCH_PTR ; case <STR_LIT> : return DISPATCH_ID ; case <STR_LIT> : return IMPLICIT_ARG_PTR ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> case <STR_LIT> : NonKernelOnly = true ; return WORKITEM_ID_X ; case <STR_LIT> : NonKernelOnly = true ; return WORKGROUP_ID_X ; case <STR_LIT> : case <STR_LIT> : return WORKITEM_ID_Y ; case <STR_LIT> : case <STR_LIT> : return WORKITEM_ID_Z ; case <STR_LIT> : case <STR_LIT> : return WORKGROUP_ID_Y ; case <STR_LIT> : case <STR_LIT> : return WORKGROUP_ID_Z ; case <STR_LIT> : return DISPATCH_PTR ; case <STR_LIT> : return DISPATCH_ID ; case <STR_LIT> : return IMPLICIT_ARG_PTR ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> bool isValidState ( ) const override {


<s> OS << getAssumed ( ) . getLower ( ) << ',' << getAssumed ( ) . getUpper ( ) - <NUM_LIT> ; AttrList . push_back ( Attribute :: get ( Ctx , <STR_LIT> , OS . str ( ) ) ) ;

return IRAttributeManifest :: manifestAttrs ( A , getIRPosition ( ) , AttrList , true ) ;


<s> bool IsNonEntryFunc = ! <STR_LIT> ( Fn . getCallingConv ( ) ) ; bool HasAperture = hasApertureRegs ( Fn ) ; if ( ! IsNonEntryFunc && HasAperture ) return false ; uint8_t Access = getConstantAccess ( C ) ; if ( IsNonEntryFunc && ( Access & DS_GLOBAL ) ) return true ; return ! HasAperture && ( Access & ADDR_SPACE_CAST ) ;


<s> if ( IsNonEntryFunc && ( Access & DS_GLOBAL ) ) return true ; return ! HasAperture && ( Access & ADDR_SPACE_CAST ) ;


<s> bool runOnModule ( Module & M ) override { SetVector < Function * > Functions ; AnalysisGetter AG ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) Functions . insert ( & F ) ; } CallGraphUpdater CGUpdater ; BumpPtrAllocator Allocator ; <ISA_LIT>InformationCache InfoCache ( M , AG , Allocator , nullptr , * TM ) ; DenseSet < const char * > Allowed ( { & AAAMDAttributes :: ID , & AAUniformWorkGroupSize :: ID , & AAAMDFlatWorkGroupSize :: ID , & AACallEdges :: ID } ) ; Attributor A ( Functions , InfoCache , CGUpdater , & Allowed ) ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) {

A . getOrCreateAAFor < AAAMDAttributes > ( IRPosition :: function ( F ) ) ;


<s> AnalysisGetter AG ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) Functions . insert ( & F ) ; } CallGraphUpdater CGUpdater ; BumpPtrAllocator Allocator ; <ISA_LIT>InformationCache InfoCache ( M , AG , Allocator , nullptr , * TM ) ; DenseSet < const char * > Allowed ( { & AAAMDAttributes :: ID , & AAUniformWorkGroupSize :: ID , & AAAMDFlatWorkGroupSize :: ID , & AACallEdges :: ID } ) ; Attributor A ( Functions , InfoCache , CGUpdater , & Allowed ) ; for ( Function & F : M ) { if ( ! F . isIntrinsic ( ) ) { A . getOrCreateAAFor < AAAMDAttributes > ( IRPosition :: function ( F ) ) ; A . getOrCreateAAFor < AAUniformWorkGroupSize > ( IRPosition :: function ( F ) ) ; if ( ! <STR_LIT> ( F . getCallingConv ( ) ) ) { A . getOrCreateAAFor < AAAMDFlatWorkGroupSize > ( IRPosition :: function ( F ) ) ; } } } ChangeStatus Change = A . run ( ) ; return Change == ChangeStatus :: CHANGED ;


<s> void trackStatistics ( ) const override {


<s> ChangeStatus updateImpl ( Attributor & A ) override { ChangeStatus Change = ChangeStatus :: UNCHANGED ; auto CheckCallSite = [ & ] ( AbstractCallSite CS ) { Function * Caller = CS . getInstruction ( ) -> getFunction ( ) ; LLVM_DEBUG ( dbgs ( ) << <STR_LIT> << Caller -> getName ( ) << <STR_LIT> << getAssociatedFunction ( ) -> getName ( ) << '\n' ) ;

const auto & CallerInfo = A . getAAFor < AAAMDFlatWorkGroupSize > ( * this , IRPosition :: function ( * Caller ) , DepClassTy :: REQUIRED ) ;


<s> Function * Caller = CS . getInstruction ( ) -> getFunction ( ) ; LLVM_DEBUG ( dbgs ( ) << <STR_LIT> << Caller -> getName ( ) << <STR_LIT> << getAssociatedFunction ( ) -> getName ( ) << '\n' ) ; const auto & CallerInfo = A . getAAFor < AAAMDFlatWorkGroupSize > ( * this , IRPosition :: function ( * Caller ) , DepClassTy :: REQUIRED ) ; Change |= clampStateAndIndicateChange ( this -> getState ( ) , CallerInfo . getState ( ) ) ; return true ; } ; bool AllCallSitesKnown = true ;

if ( ! A . checkForAllCallSites ( CheckCallSite , * this , true , AllCallSitesKnown ) ) return indicatePessimisticFixpoint ( ) ;


<s> unsigned SrcAS = CE -> getOperand ( <NUM_LIT> ) -> getType ( ) -> getPointerAddressSpace ( ) ; return castRequiresQueuePtr ( SrcAS ) ; }


<s> if ( CE -> getOpcode ( ) == Instruction :: AddrSpaceCast ) { unsigned SrcAS = CE -> getOperand ( <NUM_LIT> ) -> getType ( ) -> getPointerAddressSpace ( ) ; return castRequiresQueuePtr ( SrcAS ) ;


<s> return FP32InputDenormals && FP32OutputDenormals ;


<s> bool allFP64FP16Denormals ( ) const {


<s> static Waitcnt allZero ( bool HasVscnt ) { return Waitcnt ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , HasVscnt ? <NUM_LIT> : ~ <NUM_LIT> ) ;


<s> return Waitcnt ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , ~ <NUM_LIT> ) ;


<s> static Waitcnt allZeroExceptVsCnt ( ) {

return Waitcnt ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , ~ <NUM_LIT> ) ;


<s> return Waitcnt ( std :: min ( VmCnt , Other . VmCnt ) , std :: min ( ExpCnt , Other . ExpCnt ) , std :: min ( LgkmCnt , Other . LgkmCnt ) , std :: min ( VsCnt , Other . VsCnt ) ) ;


<s> bool dominates ( const Waitcnt & Other ) const { return VmCnt <= Other . VmCnt && ExpCnt <= Other . ExpCnt && LgkmCnt <= Other . LgkmCnt && VsCnt <= Other . VsCnt ;


<s> bool dominates ( const Waitcnt & Other ) const {

return VmCnt <= Other . VmCnt && ExpCnt <= Other . ExpCnt && LgkmCnt <= Other . LgkmCnt && VsCnt <= Other . VsCnt ;


<s> uint32_t fpDenormModeDPValue ( ) const {

if ( FP64FP16InputDenormals && FP64FP16OutputDenormals ) return FP_DENORM_FLUSH_NONE ;


<s> if ( FP64FP16InputDenormals ) return FP_DENORM_FLUSH_OUT ; if ( FP64FP16OutputDenormals ) return FP_DENORM_FLUSH_IN ; return FP_DENORM_FLUSH_IN_FLUSH_OUT ;


<s> if ( FP32InputDenormals && FP32OutputDenormals ) return FP_DENORM_FLUSH_NONE ; if ( FP32InputDenormals ) return FP_DENORM_FLUSH_OUT ; if ( FP32OutputDenormals ) return FP_DENORM_FLUSH_IN ; return FP_DENORM_FLUSH_IN_FLUSH_OUT ;


<s> if ( FP32OutputDenormals ) return FP_DENORM_FLUSH_IN ;


<s> <ISA_LIT>ModeRegisterDefaults Mode ; Mode . IEEE = ! <STR_LIT> ( CC ) ;


<s> return getOperandSize ( Desc . OpInfo [ OpNo ] ) ;


<s> TargetIDSetting getSramEccSetting ( ) const {


<s> TargetIDSetting getXnackSetting ( ) const {


<s> bool hasWait ( ) const { return VmCnt != ~ <NUM_LIT> || ExpCnt != ~ <NUM_LIT> || LgkmCnt != ~ <NUM_LIT> || VsCnt != ~ <NUM_LIT> ;


<s> return VmCnt != ~ <NUM_LIT> || ExpCnt != ~ <NUM_LIT> || LgkmCnt != ~ <NUM_LIT> ;


<s> bool isInlineCompatible ( <ISA_LIT>ModeRegisterDefaults CalleeMode ) const { if ( DX10Clamp != CalleeMode . DX10Clamp ) return false ; if ( IEEE != CalleeMode . IEEE ) return false ;

return oneWayCompatible ( FP64FP16InputDenormals , CalleeMode . FP64FP16InputDenormals ) && oneWayCompatible ( FP64FP16OutputDenormals , CalleeMode . FP64FP16OutputDenormals ) && oneWayCompatible ( FP32InputDenormals , CalleeMode . FP32InputDenormals ) && oneWayCompatible ( FP32OutputDenormals , CalleeMode . FP32OutputDenormals ) ;


<s> LLVM_READNONE inline bool isKernel ( CallingConv :: ID CC ) { switch ( CC ) { case CallingConv :: <ISA_LIT>_KERNEL : case CallingConv :: SPIR_KERNEL : return true ; default : return false ; }


<s> return DC >= DPP :: ROW_NEWBCAST_FIRST && DC <= DPP :: ROW_NEWBCAST_LAST ;


<s> LLVM_READNONE inline bool isLegal64BitDPPControl ( unsigned DC ) { return DC >= DPP :: ROW_NEWBCAST_FIRST && DC <= DPP :: ROW_NEWBCAST_LAST ;


return SramEccSetting == TargetIDSetting :: On || SramEccSetting == TargetIDSetting :: Any ;


<s> return SramEccSetting == TargetIDSetting :: On || SramEccSetting == TargetIDSetting :: Any ;


<s> return getSramEccSetting ( ) == TargetIDSetting :: On || getSramEccSetting ( ) == TargetIDSetting :: Off ;


<s> bool isSramEccSupported ( ) const { return SramEccSetting != TargetIDSetting :: Unsupported ;


<s> return XnackSetting == TargetIDSetting :: On || XnackSetting == TargetIDSetting :: Any ;


<s> return getXnackSetting ( ) == TargetIDSetting :: On || getXnackSetting ( ) == TargetIDSetting :: Off ;


<s> return XnackSetting != TargetIDSetting :: Unsupported ;


<s> SramEccSetting = NewSramEccSetting ;


<s> void setXnackSetting ( TargetIDSetting NewXnackSetting ) {


<s> <ISA_LIT>ModeRegisterDefaults ( ) : IEEE ( true ) , DX10Clamp ( true ) , FP32InputDenormals ( true ) , FP32OutputDenormals ( true ) , FP64FP16InputDenormals ( true ) , FP64FP16OutputDenormals ( true ) {


<s> IEEE ( true ) , DX10Clamp ( true ) , FP32InputDenormals ( true ) , FP32OutputDenormals ( true ) , FP64FP16InputDenormals ( true ) , FP64FP16OutputDenormals ( true ) {


<s> Waitcnt ( unsigned VmCnt , unsigned ExpCnt , unsigned LgkmCnt , unsigned VsCnt ) : VmCnt ( VmCnt ) , ExpCnt ( ExpCnt ) , LgkmCnt ( LgkmCnt ) , VsCnt ( VsCnt ) {


<s> MCSection * getHSADataGlobalAgentSection ( MCContext & Ctx ) { return Ctx . getELFSection ( <STR_LIT> , ELF :: SHT_PROGBITS , ELF :: SHF_ALLOC | ELF :: SHF_WRITE | ELF :: SHF_<ISA_LIT>_HSA_GLOBAL | ELF :: SHF_<ISA_LIT>_HSA_AGENT ) ;


<s> MCSection * getHSADataGlobalAgentSection ( MCContext & Ctx ) {

return Ctx . getELFSection ( <STR_LIT> , ELF :: SHT_PROGBITS , ELF :: SHF_ALLOC | ELF :: SHF_WRITE | ELF :: SHF_<ISA_LIT>_HSA_GLOBAL | ELF :: SHF_<ISA_LIT>_HSA_AGENT ) ;


<s> return Ctx . getELFSection ( <STR_LIT> , ELF :: SHT_PROGBITS , ELF :: SHF_ALLOC | ELF :: SHF_WRITE | ELF :: SHF_<ISA_LIT>_HSA_GLOBAL ) ;


<s> MCSection * getHSATextSection ( MCContext & Ctx ) { return Ctx . getELFSection ( <STR_LIT> , ELF :: SHT_PROGBITS , ELF :: SHF_ALLOC | ELF :: SHF_WRITE | ELF :: SHF_EXECINSTR | ELF :: SHF_<ISA_LIT>_HSA_AGENT | ELF :: SHF_<ISA_LIT>_HSA_CODE ) ;


<s> if ( Features . test ( FeatureISAVersion8_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> if ( Features . test ( FeatureISAVersion7_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> assert ( ! is<ISA_LIT> ( STI ) ) ; return isCI ( STI ) ? <STR_LIT> : <STR_LIT> ; case <STR_LIT> : assert ( ! is<ISA_LIT> ( STI ) ) ; return isCI ( STI ) ? <STR_LIT> : <STR_LIT> ;


<s> unsigned ShaderType = ShaderType :: COMPUTE ; if ( A . isStringAttribute ( ) ) {

StringRef Str = A . getValueAsString ( ) ;


<s> IsaVersion ISA = getIsaVersion ( Features ) ; memset ( & Header , <NUM_LIT> , sizeof ( Header ) ) ; Header . amd_kernel_code_version_major = <NUM_LIT> ; Header . amd_kernel_code_version_minor = <NUM_LIT> ; Header . amd_machine_kind = <NUM_LIT> ; Header . amd_machine_version_major = ISA . Major ;

Header . amd_machine_version_minor = ISA . Minor ;


<s> bool isCI ( const MCSubtargetInfo & STI ) {

return STI . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> bool isGlobalSegment ( const GlobalValue * GV ) {

return GV -> getType ( ) -> getAddressSpace ( ) == <ISA_LIT>AS :: GLOBAL_ADDRESS ;


<s> return GV -> getType ( ) -> getAddressSpace ( ) == <ISA_LIT>AS :: GLOBAL_ADDRESS ;


<s> bool isGroupSegment ( const GlobalValue * GV ) {

return GV -> getType ( ) -> getAddressSpace ( ) == <ISA_LIT>AS :: LOCAL_ADDRESS ;


<s> return GV -> getType ( ) -> getAddressSpace ( ) == <ISA_LIT>AS :: LOCAL_ADDRESS ;


<s> return STI . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> bool isVI ( const MCSubtargetInfo & STI ) { return STI . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> return Waitcnt ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , Version . Major >= <NUM_LIT> ? <NUM_LIT> : ~ <NUM_LIT> ) ;


<s> unsigned getAddressableNumVGPRs ( const MCSubtargetInfo * STI ) {


<s> Mode . IEEE = IsCompute ; Mode . FP32Denormals = false ; Mode . FP64FP16Denormals = true ; return Mode ;


<s> const bool IsCompute = <STR_LIT> ( CC ) ; <ISA_LIT>ModeRegisterDefaults Mode ; Mode . DX10Clamp = true ; Mode . IEEE = IsCompute ; Mode . FP32Denormals = false ; Mode . FP64FP16Denormals = true ;


<s> if ( isGFX10 ( * STI ) && STI -> getFeatureBits ( ) . test ( FeatureCuMode ) ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> return isGFX10 ( STI ) ? getGfx10PlusBufferFormatInfo ( Format ) : getGfx9BufferFormatInfo ( Format ) ;


<s> if ( is<ISA_LIT> ( STI ) || isCI ( STI ) || isVI ( STI ) ) return ID_SYMBOLIC_FIRST_GFX9_ ; else if ( isGFX9 ( STI ) ) return ID_SYMBOLIC_FIRST_GFX10_ ;


<s> static unsigned getLastSymbolicHwreg ( const MCSubtargetInfo & STI ) { if ( is<ISA_LIT> ( STI ) || isCI ( STI ) || isVI ( STI ) ) return ID_SYMBOLIC_FIRST_GFX9_ ; else if ( isGFX9 ( STI ) ) return ID_SYMBOLIC_FIRST_GFX10_ ; else return ID_SYMBOLIC_LAST_ ;


<s> return isValidMsgId ( MsgId ) ? IdSymbolic [ MsgId ] : <STR_LIT> ;


<s> if ( Version . Major >= <NUM_LIT> ) return ExtraSGPRs ; if ( Version . Major < <NUM_LIT> ) { if ( FlatScrUsed ) ExtraSGPRs = <NUM_LIT> ; } else {

if ( XNACKUsed ) ExtraSGPRs = <NUM_LIT> ;


<s> if ( VCCUsed ) ExtraSGPRs = <NUM_LIT> ; IsaVersion Version = getIsaVersion ( STI -> getCPU ( ) ) ; if ( Version . Major >= <NUM_LIT> ) return ExtraSGPRs ; if ( Version . Major < <NUM_LIT> ) { if ( FlatScrUsed ) ExtraSGPRs = <NUM_LIT> ;


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> unsigned getTotalNumVGPRs ( const MCSubtargetInfo * STI ) { if ( ! isGFX10 ( * STI ) ) return <NUM_LIT> ; return STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ? <NUM_LIT> : <NUM_LIT> ;


<s> STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ; return IsWave32 ? <NUM_LIT> : <NUM_LIT> ;


<s> bool IsWave32 = EnableWavefrontSize32 ? * EnableWavefrontSize32 : STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ; return IsWave32 ? <NUM_LIT> : <NUM_LIT> ;


<s> unsigned getVGPREncodingGranule ( const MCSubtargetInfo * STI , Optional < bool > EnableWavefrontSize32 ) { return getVGPRAllocGranule ( STI , EnableWavefrontSize32 ) ;


<s> static bool hasSMEMByteOffset ( const MCSubtargetInfo & ST ) {

return isGCN3Encoding ( ST ) || isGFX10 ( ST ) ;


<s> static bool hasSMRDSignedImmOffset ( const MCSubtargetInfo & ST ) {

return isGFX9 ( ST ) || isGFX10 ( ST ) ;


<s> bool isInlineCompatible ( <ISA_LIT>ModeRegisterDefaults CalleeMode ) const { return * this == CalleeMode ;


<s> bool isInlineCompatible ( <ISA_LIT>ModeRegisterDefaults CalleeMode ) const {


<s> static bool isLegalSMRDEncodedUnsignedOffset ( const MCSubtargetInfo & ST , int64_t EncodedOffset ) {

return hasSMEMByteOffset ( ST ) ? isUInt < <NUM_LIT> > ( EncodedOffset ) : isUInt < <NUM_LIT> > ( EncodedOffset ) ;


<s> 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> : return true ; default : return false ; }


<s> else return isValidMsgId ( MsgId ) ; } else { return <NUM_LIT> <= MsgId && isUInt < ID_WIDTH_ > ( MsgId ) ; }


<s> return ( OP_GS_FIRST_ <= OpId && OpId < OP_GS_LAST_ ) && OpId != OP_GS_NOP ; case ID_GS_DONE : return OP_GS_FIRST_ <= OpId && OpId < OP_GS_LAST_ ;


<s> return ( OpId == OP_GS_NOP ) ? ( StreamId == STREAM_ID_NONE_ ) : ( STREAM_ID_FIRST_ <= StreamId && StreamId < STREAM_ID_LAST_ ) ; default : return StreamId == STREAM_ID_NONE_ ; }


<s> if ( ! Strict ) return <NUM_LIT> <= StreamId && isUInt < STREAM_ID_WIDTH_ > ( StreamId ) ; switch ( MsgId ) { case ID_GS : return STREAM_ID_FIRST_ <= StreamId && StreamId < STREAM_ID_LAST_ ; case ID_GS_DONE : return ( OpId == OP_GS_NOP ) ? ( StreamId == STREAM_ID_NONE_ ) :

( STREAM_ID_FIRST_ <= StreamId && StreamId < STREAM_ID_LAST_ ) ;


IEEE ( true ) , DX10Clamp ( true ) , FP32Denormals ( true ) , FP64FP16Denormals ( true ) {


<s> <ISA_LIT>ModeRegisterDefaults ( ) : IEEE ( true ) , DX10Clamp ( true ) , FP32Denormals ( true ) , FP64FP16Denormals ( true ) {


<s> unsigned getMaxWavesPerCU ( const MCSubtargetInfo * STI ) { return getMaxWavesPerEU ( STI ) * getEUsPerCU ( STI ) ;


<s> return getMaxWavesPerEU ( STI ) * getEUsPerCU ( STI ) ;


<s> int64_t getSMRDEncodedOffset ( const MCSubtargetInfo & ST , int64_t ByteOffset ) { if ( hasSMEMByteOffset ( ST ) ) return ByteOffset ;


<s> if ( hasSMEMByteOffset ( ST ) ) return ByteOffset ; return ByteOffset >> <NUM_LIT> ;


<s> bool isLegalSMRDImmOffset ( const MCSubtargetInfo & ST , int64_t ByteOffset ) { int64_t EncodedOffset = getSMRDEncodedOffset ( ST , ByteOffset ) ;

return ( hasSMEMByteOffset ( ST ) ) ? isUInt < <NUM_LIT> > ( EncodedOffset ) : isUInt < <NUM_LIT> > ( EncodedOffset ) ;


<s> int64_t EncodedOffset = getSMRDEncodedOffset ( ST , ByteOffset ) ; return ( hasSMEMByteOffset ( ST ) ) ? isUInt < <NUM_LIT> > ( EncodedOffset ) : isUInt < <NUM_LIT> > ( EncodedOffset ) ;


<s> return TT . getOS ( ) == Triple :: AMDPAL ;


<s> bool shouldEmitConstantsToTextSection ( const Triple & TT ) {

return TT . getOS ( ) == Triple :: AMDPAL ;


<s> if ( ! IEEEAttr . empty ( ) ) IEEE = IEEEAttr == <STR_LIT> ;

StringRef DX10ClampAttr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ;


<s> <STR_LIT> ( const Function & F ) { * this = getDefaultForCallingConv ( F . getCallingConv ( ) ) ; StringRef IEEEAttr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ; if ( ! IEEEAttr . empty ( ) ) IEEE = IEEEAttr == <STR_LIT> ; StringRef DX10ClampAttr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ; if ( ! DX10ClampAttr . empty ( ) ) DX10Clamp = DX10ClampAttr == <STR_LIT> ;


<s> unsigned decodeExpcnt ( const IsaInfo :: IsaVersion & Version , unsigned Waitcnt ) { return unpackBits ( Waitcnt , getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ;


<s> unsigned decodeLgkmcnt ( const IsaInfo :: IsaVersion & Version , unsigned Waitcnt ) {

return unpackBits ( Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> return unpackBits ( Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> unsigned VmcntHi = unpackBits ( Waitcnt , getVmcntBitShiftHi ( ) , getVmcntBitWidthHi ( ) ) ;


<s> unsigned VmcntHi = unpackBits ( Waitcnt , getVmcntBitShiftHi ( ) , getVmcntBitWidthHi ( ) ) ; VmcntHi <<= getVmcntBitWidthLo ( ) ; return VmcntLo | VmcntHi ;


<s> Expcnt = decodeExpcnt ( Version , Waitcnt ) ; Lgkmcnt = decodeLgkmcnt ( Version , Waitcnt ) ;


<s> unsigned encodeExpcnt ( const IsaInfo :: IsaVersion & Version , unsigned Waitcnt , unsigned Expcnt ) { return packBits ( Expcnt , Waitcnt , getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ;


<s> return packBits ( Expcnt , Waitcnt , getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ;


<s> return packBits ( Lgkmcnt , Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> if ( Version . Major < <NUM_LIT> ) return Waitcnt ; Vmcnt >>= getVmcntBitWidthLo ( ) ; return packBits ( Vmcnt , Waitcnt , getVmcntBitShiftHi ( ) , getVmcntBitWidthHi ( ) ) ;


<s> Waitcnt = encodeExpcnt ( Version , Waitcnt , Expcnt ) ; Waitcnt = encodeLgkmcnt ( Version , Waitcnt , Lgkmcnt ) ; return Waitcnt ;


<s> Waitcnt = encodeVmcnt ( Version , Waitcnt , Vmcnt ) ; Waitcnt = encodeExpcnt ( Version , Waitcnt , Expcnt ) ; Waitcnt = encodeLgkmcnt ( Version , Waitcnt , Lgkmcnt ) ;


<s> if ( Features . test ( FeatureSGPRInitBug ) ) return FIXED_NUM_SGPRS_FOR_INIT_BUG ; IsaVersion Version = getIsaVersion ( Features ) ; if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> return getTotalNumVGPRs ( Features ) ;


<s> unsigned getEUsPerCU ( const FeatureBitset & Features ) {


<s> unsigned getExpcntBitMask ( const IsaInfo :: IsaVersion & Version ) { return ( <NUM_LIT> << getExpcntBitWidth ( ) ) - <NUM_LIT> ;


<s> return ( <NUM_LIT> << getExpcntBitWidth ( ) ) - <NUM_LIT> ;


<s> if ( Features . test ( FeatureISAVersion8_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_4 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_1_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( ! Features . test ( FeatureGCN ) || Features . test ( FeatureSouthernIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> unsigned getLgkmcntBitMask ( const IsaInfo :: IsaVersion & Version ) {

return ( <NUM_LIT> << getLgkmcntBitWidth ( ) ) - <NUM_LIT> ;


<s> unsigned getLocalMemorySize ( const FeatureBitset & Features ) { if ( Features . test ( FeatureLocalMemorySize32768 ) ) return <NUM_LIT> ; if ( Features . test ( FeatureLocalMemorySize65536 ) ) return <NUM_LIT> ;


<s> if ( Features . test ( FeatureLocalMemorySize65536 ) ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> unsigned getMaxFlatWorkGroupSize ( const FeatureBitset & Features ) { return <NUM_LIT> ;


<s> unsigned MaxNumSGPRs = alignDown ( getTotalNumSGPRs ( Features ) / WavesPerEU , getSGPRAllocGranule ( Features ) ) ; unsigned AddressableNumSGPRs = getAddressableNumSGPRs ( Features ) ;

if ( Version . Major >= <NUM_LIT> && ! Addressable ) AddressableNumSGPRs = <NUM_LIT> ;


<s> unsigned MaxNumVGPRs = alignDown ( getTotalNumVGPRs ( Features ) / WavesPerEU , getVGPRAllocGranule ( Features ) ) ;

unsigned AddressableNumVGPRs = getAddressableNumVGPRs ( Features ) ;


<s> assert ( WavesPerEU != <NUM_LIT> ) ;

unsigned MaxNumVGPRs = alignDown ( getTotalNumVGPRs ( Features ) / WavesPerEU , getVGPRAllocGranule ( Features ) ) ;


<s> return getWavesPerWorkGroup ( Features , FlatWorkGroupSize ) ;


<s> return alignTo ( getMaxWavesPerCU ( Features , FlatWorkGroupSize ) , getEUsPerCU ( Features ) ) / getEUsPerCU ( Features ) ;


<s> if ( N == <NUM_LIT> ) return <NUM_LIT> ; N = <NUM_LIT> / N ;


<s> unsigned MinNumSGPRs = alignDown ( getTotalNumSGPRs ( Features ) / ( WavesPerEU + <NUM_LIT> ) , getSGPRAllocGranule ( Features ) ) + <NUM_LIT> ;

return std :: min ( MinNumSGPRs , getAddressableNumSGPRs ( Features ) ) ;


<s> assert ( WavesPerEU != <NUM_LIT> ) ; if ( WavesPerEU >= getMaxWavesPerEU ( Features ) ) return <NUM_LIT> ; unsigned MinNumVGPRs = alignDown ( getTotalNumVGPRs ( Features ) / ( WavesPerEU + <NUM_LIT> ) , getVGPRAllocGranule ( Features ) ) + <NUM_LIT> ; return std :: min ( MinNumVGPRs , getAddressableNumVGPRs ( Features ) ) ;


<s> if ( WavesPerEU >= getMaxWavesPerEU ( Features ) ) return <NUM_LIT> ; unsigned MinNumVGPRs = alignDown ( getTotalNumVGPRs ( Features ) / ( WavesPerEU + <NUM_LIT> ) , getVGPRAllocGranule ( Features ) ) + <NUM_LIT> ; return std :: min ( MinNumVGPRs , getAddressableNumVGPRs ( Features ) ) ;


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> :


<s> if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> unsigned getSGPREncodingGranule ( const FeatureBitset & Features ) { return <NUM_LIT> ;


<s> int64_t getSMRDEncodedOffset ( const MCSubtargetInfo & ST , int64_t ByteOffset ) { if ( is<ISA_LIT> ( ST ) || isCI ( ST ) ) return ByteOffset >> <NUM_LIT> ;


<s> if ( is<ISA_LIT> ( ST ) || isCI ( ST ) ) return ByteOffset >> <NUM_LIT> ; return ByteOffset ;


<s> if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ;


<s> unsigned getTotalNumVGPRs ( const FeatureBitset & Features ) { return <NUM_LIT> ;


<s> return getVGPRAllocGranule ( Features ) ;


<s> unsigned VmcntHi = ( ( <NUM_LIT> << getVmcntBitWidthHi ( ) ) - <NUM_LIT> ) << getVmcntBitWidthLo ( ) ; return VmcntLo | VmcntHi ;


<s> unsigned VmcntLo = ( <NUM_LIT> << getVmcntBitWidthLo ( ) ) - <NUM_LIT> ; if ( Version . Major < <NUM_LIT> ) return VmcntLo ; unsigned VmcntHi = ( ( <NUM_LIT> << getVmcntBitWidthHi ( ) ) - <NUM_LIT> ) << getVmcntBitWidthLo ( ) ;


<s> unsigned Expcnt = getBitMask ( getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ;

unsigned Lgkmcnt = getBitMask ( getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> unsigned VmcntLo = getBitMask ( getVmcntBitShiftLo ( ) , getVmcntBitWidthLo ( ) ) ; unsigned Expcnt = getBitMask ( getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ; unsigned Lgkmcnt = getBitMask ( getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ; unsigned Waitcnt = VmcntLo | Expcnt | Lgkmcnt ; if ( Version . Major < <NUM_LIT> ) return Waitcnt ; unsigned VmcntHi = getBitMask ( getVmcntBitShiftHi ( ) , getVmcntBitWidthHi ( ) ) ; return Waitcnt | VmcntHi ;


<s> if ( Features . test ( FeatureWavefrontSize32 ) ) return <NUM_LIT> ;


<s> unsigned getWavesPerWorkGroup ( const FeatureBitset & Features , unsigned FlatWorkGroupSize ) { return alignTo ( FlatWorkGroupSize , getWavefrontSize ( Features ) ) / getWavefrontSize ( Features ) ;


<s> Header . amd_machine_version_stepping = ISA . Stepping ; Header . kernel_code_entry_byte_offset = sizeof ( Header ) ; Header . wavefront_size = <NUM_LIT> ; Header . call_convention = - <NUM_LIT> ; Header . kernarg_segment_alignment = <NUM_LIT> ; Header . group_segment_alignment = <NUM_LIT> ; Header . private_segment_alignment = <NUM_LIT> ;


<s> switch ( CC ) { case CallingConv :: <ISA_LIT>_KERNEL : case CallingConv :: SPIR_KERNEL : case CallingConv :: <ISA_LIT>_VS : case CallingConv :: <ISA_LIT>_GS : case CallingConv :: <ISA_LIT>_PS : case CallingConv :: <ISA_LIT>_CS :


<s> return GV -> getType ( ) -> getAddressSpace ( ) == AS . LOCAL_ADDRESS ;


<s> bool isInlinableLiteralV216 ( int32_t Literal , bool HasInv2Pi ) { assert ( HasInv2Pi ) ; if ( ! EnablePackedInlinableLiterals ) return false ; int16_t Lo16 = static_cast < int16_t > ( Literal ) ; int16_t Hi16 = static_cast < int16_t > ( Literal >> <NUM_LIT> ) ; return Lo16 == Hi16 && isInlinableLiteral16 ( Lo16 , HasInv2Pi ) ;


<s> bool isLegalSMRDImmOffset ( const MCSubtargetInfo & ST , int64_t ByteOffset ) { int64_t EncodedOffset = getSMRDEncodedOffset ( ST , ByteOffset ) ;

return is<ISA_LIT> ( ST ) || isCI ( ST ) ? isUInt < <NUM_LIT> > ( EncodedOffset ) :


<s> bool isLegalSMRDImmOffset ( const MCSubtargetInfo & ST , int64_t ByteOffset ) { int64_t EncodedOffset = getSMRDEncodedOffset ( ST , ByteOffset ) ; return is<ISA_LIT> ( ST ) || isCI ( ST ) ? isUInt < <NUM_LIT> > ( EncodedOffset ) : isUInt < <NUM_LIT> > ( EncodedOffset ) ;


<s> bool isReadOnlySegment ( const GlobalValue * GV , <ISA_LIT>AS AS ) {

return GV -> getType ( ) -> getAddressSpace ( ) == AS . CONSTANT_ADDRESS ;


<s> return GV -> getType ( ) -> getAddressSpace ( ) == AS . CONSTANT_ADDRESS ;


<s> case CallingConv :: <ISA_LIT>_HS : case CallingConv :: <ISA_LIT>_GS : case CallingConv :: <ISA_LIT>_PS : case CallingConv :: <ISA_LIT>_CS :


<s> bool is<ISA_LIT>SrcOperand ( const MCInstrDesc & Desc , unsigned OpNo ) { assert ( OpNo < Desc . NumOperands ) ; unsigned OpType = Desc . OpInfo [ OpNo ] . OperandType ;

return OpType >= <STR_LIT> && OpType <= <STR_LIT> ;


<s> assert ( OpNo < Desc . NumOperands ) ; unsigned OpType = Desc . OpInfo [ OpNo ] . OperandType ;


<s> if ( ! Ptr || isa < UndefValue > ( Ptr ) || isa < Argument > ( Ptr ) || isa < Constant > ( Ptr ) || isa < GlobalValue > ( Ptr ) ) return true ;

const Instruction * I = dyn_cast < Instruction > ( Ptr ) ;


<s> bool isUniformMMO ( const MachineMemOperand * MMO ) { const Value * Ptr = MMO -> getValue ( ) ; if ( ! Ptr || isa < UndefValue > ( Ptr ) || isa < Argument > ( Ptr ) || isa < Constant > ( Ptr ) || isa < GlobalValue > ( Ptr ) ) return true ; const Instruction * I = dyn_cast < Instruction > ( Ptr ) ; return I && I -> getMetadata ( <STR_LIT> ) ;


<s> unsigned mc2PseudoReg ( unsigned Reg ) { switch ( Reg ) { case <STR_LIT> : case <STR_LIT> : return FLAT_SCR ; case <STR_LIT> : case <STR_LIT> : return <STR_LIT> ;


<s> unsigned MinNumSGPRs = getTotalNumSGPRs ( STI ) / ( WavesPerEU + <NUM_LIT> ) ; if ( STI -> getFeatureBits ( ) . test ( FeatureTrapHandler ) ) MinNumSGPRs -= std :: min ( MinNumSGPRs , ( unsigned ) TRAP_NUM_SGPRS ) ; MinNumSGPRs = alignDown ( MinNumSGPRs , getSGPRAllocGranule ( STI ) ) + <NUM_LIT> ; return std :: min ( MinNumSGPRs , getAddressableNumSGPRs ( STI ) ) ;


<s> unsigned getMinNumSGPRs ( const MCSubtargetInfo * STI , unsigned WavesPerEU ) { assert ( WavesPerEU != <NUM_LIT> ) ; IsaVersion Version = getIsaVersion ( STI -> getCPU ( ) ) ; if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ; if ( WavesPerEU >= getMaxWavesPerEU ( ) ) return <NUM_LIT> ; unsigned MinNumSGPRs = getTotalNumSGPRs ( STI ) / ( WavesPerEU + <NUM_LIT> ) ;

if ( STI -> getFeatureBits ( ) . test ( FeatureTrapHandler ) ) MinNumSGPRs -= std :: min ( MinNumSGPRs , ( unsigned ) TRAP_NUM_SGPRS ) ;


<s> bool isValidMsgId ( int64_t MsgId , const MCSubtargetInfo & STI , bool Strict ) { return Strict ? isValidMsgId ( MsgId ) && ( MsgId != ID_GS_ALLOC_REQ || isGFX9 ( STI ) || isGFX10 ( STI ) ) : <NUM_LIT> <= MsgId && isUInt < ID_WIDTH_ > ( MsgId ) ;


<s> bool isValidMsgId ( int64_t MsgId , const MCSubtargetInfo & STI , bool Strict ) { return Strict ? isValidMsgId ( MsgId ) && ( MsgId != ID_GS_ALLOC_REQ || isGFX9 ( STI ) || isGFX10 ( STI ) ) :

<NUM_LIT> <= MsgId && isUInt < ID_WIDTH_ > ( MsgId ) ;


<s> const bool IsCompute = <STR_LIT> ( CC ) ;


<s> if ( Features . test ( FeatureISAVersion7_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_4 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;

if ( Features . test ( FeatureISAVersion8_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> if ( NewChannels == OrigChannels ) return Opc ; switch ( OrigChannels ) { case <NUM_LIT> : return <STR_LIT> ( Opc , Channel ) ; case <NUM_LIT> : return <STR_LIT> ( Opc , Channel ) ; case <NUM_LIT> : return <STR_LIT> ( Opc , Channel ) ; case <NUM_LIT> : return <STR_LIT> ( Opc , Channel ) ; default : llvm_unreachable ( <STR_LIT> ) ;


<s> bool hasCodeObjectV3 ( const FeatureBitset & Features ) {

return Features . test ( FeatureCodeObjectV3 ) ;


<s> case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; default :


<s> if ( ! Ptr || isa < UndefValue > ( Ptr ) || isa < Constant > ( Ptr ) || isa < GlobalValue > ( Ptr ) ) return true ; if ( const Argument * Arg = dyn_cast < Argument > ( Ptr ) ) return isArgPassedInSGPR ( Arg ) ; const Instruction * I = dyn_cast < Instruction > ( Ptr ) ; return I && I -> getMetadata ( <STR_LIT> ) ;


<s> case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : return <NUM_LIT> ;


<s> Stream << TargetTriple . getArchName ( ) << '-' << TargetTriple . getVendorName ( ) << '-' << TargetTriple . getOSName ( ) << '-' << TargetTriple . getEnvironmentName ( ) << '-' << <STR_LIT> << ISAVersion . Major << ISAVersion . Minor << ISAVersion . Stepping ;


<s> void streamIsaVersion ( const MCSubtargetInfo * STI , raw_ostream & Stream ) { auto TargetTriple = STI -> getTargetTriple ( ) ; auto ISAVersion = IsaInfo :: getIsaVersion ( STI -> getFeatureBits ( ) ) ;

Stream << TargetTriple . getArchName ( ) << '-' << TargetTriple . getVendorName ( ) << '-' << TargetTriple . getOSName ( ) << '-' << TargetTriple . getEnvironmentName ( ) << '-' << <STR_LIT> << ISAVersion . Major << ISAVersion . Minor << ISAVersion . Stepping ;


<s> unsigned getMaxWavesPerEU ( const MCSubtargetInfo * STI ) {

if ( ! isGFX10 ( * STI ) ) return <NUM_LIT> ;


<s> bool IsWave32 = EnableWavefrontSize32 ? * EnableWavefrontSize32 : STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ; if ( hasGFX10_3Insts ( * STI ) ) return IsWave32 ? <NUM_LIT> : <NUM_LIT> ; return IsWave32 ? <NUM_LIT> : <NUM_LIT> ;


<s> bool IsWave32 = EnableWavefrontSize32 ? * EnableWavefrontSize32 : STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ; return IsWave32 ? <NUM_LIT> : <NUM_LIT> ;


<s> STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ;


<s> return ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V4 ; case <NUM_LIT> : return ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V5 ; default : report_fatal_error ( Twine ( <STR_LIT> ) + Twine ( AmdhsaCodeObjectVersion ) ) ;


<s> return isHsaAbiVersion3 ( STI ) || isHsaAbiVersion4 ( STI ) || isHsaAbiVersion5 ( STI ) ;


<s> if ( Optional < uint8_t > HsaAbiVer = getHsaAbiVersion ( STI ) ) return * HsaAbiVer == ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V5 ; return false ;


<s> std :: string Processor ; if ( Version . Major >= <NUM_LIT> ) Processor = STI . getCPU ( ) . str ( ) ; else Processor = ( Twine ( <STR_LIT> ) + Twine ( Version . Major ) + Twine ( Version . Minor ) + Twine ( Version . Stepping ) ) . str ( ) ; std :: string Features ; if ( Optional < uint8_t > HsaAbiVersion = getHsaAbiVersion ( & STI ) ) { switch ( * HsaAbiVersion ) { case ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V2 : if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { if ( ! isXnackOnOrAny ( ) ) report_fatal_error ( <STR_LIT> + Twine ( Processor ) + <STR_LIT> ) ; } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { if ( ! isXnackOnOrAny ( ) ) report_fatal_error ( <STR_LIT> + Twine ( Processor ) + <STR_LIT> ) ; } else if ( Processor == <STR_LIT> ) { if ( isXnackOnOrAny ( ) ) Processor = <STR_LIT> ; } else if ( Processor == <STR_LIT> ) { if ( isXnackOnOrAny ( ) ) Processor = <STR_LIT> ; } else if ( Processor == <STR_LIT> ) { if ( isXnackOnOrAny ( ) ) Processor = <STR_LIT> ; } else if ( Processor == <STR_LIT> ) { if ( isXnackOnOrAny ( ) ) Processor = <STR_LIT> ; } else if ( Processor == <STR_LIT> ) { if ( isXnackOnOrAny ( ) ) report_fatal_error ( <STR_LIT> + Twine ( Processor ) + <STR_LIT> ) ; } else { report_fatal_error ( <STR_LIT> + Twine ( Processor ) ) ; } break ; case ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V3 : if ( isXnackOnOrAny ( ) ) Features += <STR_LIT> ; if ( isSramEccOnOrAny ( ) ) Features += <STR_LIT> ;


return Waitcnt ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ;


<s> if ( ! STI . getFeatureBits ( ) . test ( FeatureSupportsXNACK ) ) XnackSetting = TargetIDSetting :: Unsupported ;

if ( ! STI . getFeatureBits ( ) . test ( FeatureSupportsSRAMECC ) ) SramEccSetting = TargetIDSetting :: Unsupported ;


<s> return Waitcnt ( std :: min ( VmCnt , Other . VmCnt ) , std :: min ( ExpCnt , Other . ExpCnt ) , std :: min ( LgkmCnt , Other . LgkmCnt ) ) ;


<s> int64_t Fmt = encodeDfmtNfmt ( Dfmt , Nfmt ) ; for ( int Id = UFMT_FIRST ; Id <= UFMT_LAST ; ++ Id ) { if ( Fmt == DfmtNfmt2UFmt [ Id ] ) return Id ; } return UFMT_UNDEF ;


<s> assert ( isDwordAligned ( ByteOffset ) ) ; return ByteOffset >> <NUM_LIT> ;


<s> if ( hasSMEMByteOffset ( ST ) ) return ByteOffset ; assert ( isDwordAligned ( ByteOffset ) ) ; return ByteOffset >> <NUM_LIT> ;


<s> void decodeDfmtNfmt ( unsigned Format , unsigned & Dfmt , unsigned & Nfmt ) { Dfmt = ( Format >> DFMT_SHIFT ) & DFMT_MASK ;

Nfmt = ( Format >> NFMT_SHIFT ) & NFMT_MASK ;


<s> Id = ( Val & ID_MASK_ ) >> ID_SHIFT_ ;

Offset = ( Val & OFFSET_MASK_ ) >> OFFSET_SHIFT_ ;


<s> return unpackBits ( Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( Version . Major ) ) ;


<s> OpId = ( Val & OP_MASK_ ) >> OP_SHIFT_ ;

StreamId = ( Val & STREAM_ID_MASK_ ) >> STREAM_ID_SHIFT_ ;


<s> bool dominates ( const Waitcnt & Other ) const {

return VmCnt <= Other . VmCnt && ExpCnt <= Other . ExpCnt && LgkmCnt <= Other . LgkmCnt ;


<s> return ( Dfmt << DFMT_SHIFT ) | ( Nfmt << NFMT_SHIFT ) ;


<s> return ( Id << ID_SHIFT_ ) | ( Offset << OFFSET_SHIFT_ ) | ( ( Width - <NUM_LIT> ) << WIDTH_M1_SHIFT_ ) ;


<s> unsigned encodeLgkmcnt ( const IsaVersion & Version , unsigned Waitcnt , unsigned Lgkmcnt ) {

return packBits ( Lgkmcnt , Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( Version . Major ) ) ;


<s> return ( MsgId << ID_SHIFT_ ) | ( OpId << OP_SHIFT_ ) | ( StreamId << STREAM_ID_SHIFT_ ) ;


<s> IsaVersion Version = getIsaVersion ( STI -> getCPU ( ) ) ; if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ; if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> unsigned getAddressableNumVGPRs ( const MCSubtargetInfo * STI ) { if ( STI -> getFeatureBits ( ) . test ( FeatureGFX90AInsts ) ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> if ( STI -> getFeatureBits ( ) . test ( FeatureGFX90AInsts ) ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> unsigned AddrComponents = ( BaseOpcode -> Coordinates ? Dim -> NumCoords : <NUM_LIT> ) + ( BaseOpcode -> LodOrClampOrMip ? <NUM_LIT> : <NUM_LIT> ) ; if ( IsA16 ) AddrWords += divideCeil ( AddrComponents , <NUM_LIT> ) ; else AddrWords += AddrComponents ; if ( BaseOpcode -> Gradients ) { if ( ( IsA16 && ! IsG16Supported ) || BaseOpcode -> G16 ) AddrWords += alignTo < <NUM_LIT> > ( Dim -> NumGradients / <NUM_LIT> ) ;


AMDHSA_BITS_SET ( KD . compute_pgm_rsrc3 , amdhsa :: COMPUTE_PGM_RSRC3_GFX90A_TG_SPLIT , STI -> getFeatureBits ( ) . test ( FeatureTgSplit ) ? <NUM_LIT> : <NUM_LIT> ) ;


<s> if ( isGFX10Plus ( STI ) ) return UFMT_DEFAULT ;


<s> int64_t getDfmt ( const StringRef Name ) { for ( int Id = DFMT_MIN ; Id <= DFMT_MAX ; ++ Id ) {

if ( Name == DfmtSymbolic [ Id ] ) return Id ;


<s> if ( isGFX10Plus ( * STI ) && STI -> getFeatureBits ( ) . test ( FeatureCuMode ) ) return <NUM_LIT> ;


<s> return isGFX10Plus ( STI ) ? getGfx10PlusBufferFormatInfo ( Format ) : getGfx9BufferFormatInfo ( Format ) ;


<s> return getIntegerAttribute ( F , <STR_LIT> , F . getCallingConv ( ) == CallingConv :: <ISA_LIT>_PS ? <NUM_LIT> : <NUM_LIT> ) != <NUM_LIT> ;


<s> bool getHasDepthExport ( const Function & F ) { return getIntegerAttribute ( F , <STR_LIT> , <NUM_LIT> ) != <NUM_LIT> ;


<s> return ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V2 ; case <NUM_LIT> : return ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V3 ; case <NUM_LIT> : return ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V4 ; default :

report_fatal_error ( Twine ( <STR_LIT> ) + Twine ( AmdhsaCodeObjectVersion ) ) ;


<s> return isValidHwreg ( Id , STI ) ? IdSymbolic [ Id ] : <STR_LIT> ;


<s> int64_t getHwregId ( const StringRef Name ) { for ( int Id = ID_SYMBOLIC_FIRST_ ; Id < ID_SYMBOLIC_LAST_ ; ++ Id ) {

if ( IdSymbolic [ Id ] && Name == IdSymbolic [ Id ] ) return Id ;


<s> if ( IdSymbolic [ Id ] && Name == IdSymbolic [ Id ] ) return Id ; } return ID_UNKNOWN_ ;


<s> else if ( isGFX9 ( STI ) ) return ID_SYMBOLIC_FIRST_GFX10_ ; else if ( isGFX10 ( STI ) && ! isGFX10_BEncoding ( STI ) ) return ID_SYMBOLIC_FIRST_GFX1030_ ;


<s> static unsigned getLastSymbolicHwreg ( const MCSubtargetInfo & STI ) { if ( is<ISA_LIT> ( STI ) || isCI ( STI ) || isVI ( STI ) ) return ID_SYMBOLIC_FIRST_GFX9_ ; else if ( isGFX9 ( STI ) ) return ID_SYMBOLIC_FIRST_GFX10_ ;

else if ( isGFX10 ( STI ) && ! isGFX10_BEncoding ( STI ) ) return ID_SYMBOLIC_FIRST_GFX1030_ ;


<s> unsigned getLgkmcntBitMask ( const IsaVersion & Version ) { return ( <NUM_LIT> << getLgkmcntBitWidth ( Version . Major ) ) - <NUM_LIT> ;


<s> return ( VersionMajor >= <NUM_LIT> ) ? <NUM_LIT> : <NUM_LIT> ;


<s> assert ( WavesPerEU != <NUM_LIT> ) ; unsigned AddressableNumSGPRs = getAddressableNumSGPRs ( STI ) ; IsaVersion Version = getIsaVersion ( STI -> getCPU ( ) ) ; if ( Version . Major >= <NUM_LIT> ) return Addressable ? AddressableNumSGPRs : <NUM_LIT> ; if ( Version . Major >= <NUM_LIT> && ! Addressable ) AddressableNumSGPRs = <NUM_LIT> ; unsigned MaxNumSGPRs = getTotalNumSGPRs ( STI ) / WavesPerEU ; if ( STI -> getFeatureBits ( ) . test ( FeatureTrapHandler ) ) MaxNumSGPRs -= std :: min ( MaxNumSGPRs , ( unsigned ) TRAP_NUM_SGPRS ) ; MaxNumSGPRs = alignDown ( MaxNumSGPRs , getSGPRAllocGranule ( STI ) ) ; return std :: min ( MaxNumSGPRs , AddressableNumSGPRs ) ;


<s> if ( ! isGFX10Plus ( * STI ) ) return <NUM_LIT> ;

return hasGFX10_3Insts ( * STI ) ? <NUM_LIT> : <NUM_LIT> ;


<s> if ( STI -> getTargetTriple ( ) . getArch ( ) != Triple :: amdgcn ) return <NUM_LIT> ;

unsigned N = getWavesPerWorkGroup ( STI , FlatWorkGroupSize ) ;


<s> if ( STI -> getTargetTriple ( ) . getArch ( ) != Triple :: amdgcn ) return <NUM_LIT> ; unsigned N = getWavesPerWorkGroup ( STI , FlatWorkGroupSize ) ; if ( N == <NUM_LIT> ) return <NUM_LIT> ; N = <NUM_LIT> / N ;


<s> return Info ? getMIMGBaseOpcodeInfo ( Info -> BaseOpcode ) : nullptr ;


<s> const MIMGBaseOpcodeInfo * getMIMGBaseOpcode ( unsigned Opc ) {

const MIMGInfo * Info = getMIMGInfo ( Opc ) ;


<s> if ( STI -> getFeatureBits ( ) . test ( FeatureTrapHandler ) ) MinNumSGPRs -= std :: min ( MinNumSGPRs , ( unsigned ) TRAP_NUM_SGPRS ) ; MinNumSGPRs = alignDown ( MinNumSGPRs , getSGPRAllocGranule ( STI ) ) + <NUM_LIT> ; return std :: min ( MinNumSGPRs , getAddressableNumSGPRs ( STI ) ) ;


<s> if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ; if ( WavesPerEU >= getMaxWavesPerEU ( STI ) ) return <NUM_LIT> ; unsigned MinNumSGPRs = getTotalNumSGPRs ( STI ) / ( WavesPerEU + <NUM_LIT> ) ; if ( STI -> getFeatureBits ( ) . test ( FeatureTrapHandler ) ) MinNumSGPRs -= std :: min ( MinNumSGPRs , ( unsigned ) TRAP_NUM_SGPRS ) ; MinNumSGPRs = alignDown ( MinNumSGPRs , getSGPRAllocGranule ( STI ) ) + <NUM_LIT> ;

return std :: min ( MinNumSGPRs , getAddressableNumSGPRs ( STI ) ) ;


<s> unsigned MinNumVGPRs = alignDown ( getTotalNumVGPRs ( STI ) / ( WavesPerEU + <NUM_LIT> ) , getVGPRAllocGranule ( STI ) ) + <NUM_LIT> ;

return std :: min ( MinNumVGPRs , getAddressableNumVGPRs ( STI ) ) ;


<s> for ( int i = ID_GAPS_FIRST_ ; i < ID_GAPS_LAST_ ; ++ i ) { if ( IdSymbolic [ i ] && Name == IdSymbolic [ i ] ) return i ; } return ID_UNKNOWN_ ;


<s> assert ( <NUM_LIT> <= MsgId && MsgId < ID_GAPS_LAST_ ) ; return IdSymbolic [ MsgId ] ;


<s> assert ( <NUM_LIT> <= MsgId && MsgId < ID_GAPS_LAST_ ) ;


<s> for ( int i = F ; i < L ; ++ i ) { if ( Name == S [ i ] ) { return i ; } } return OP_UNKNOWN_ ;


<s> assert ( msgRequiresOp ( MsgId ) ) ; return ( MsgId == ID_SYSMSG ) ? OpSysSymbolic [ OpId ] : OpGsSymbolic [ OpId ] ;


<s> const MTBUFInfo * Info = getMTBUFOpcodeHelper ( Opc ) ;

return Info ? Info -> elements : <NUM_LIT> ;


<s> bool getMTBUFHasSrsrc ( unsigned Opc ) { const MTBUFInfo * Info = getMTBUFOpcodeHelper ( Opc ) ;

return Info ? Info -> has_srsrc : false ;


<s> return Info ? Info -> has_vaddr : false ;


<s> int getMTBUFOpcode ( unsigned BaseOpc , unsigned Elements ) { const MTBUFInfo * Info = getMTBUFInfoFromBaseOpcodeAndElements ( BaseOpc , Elements ) ;

return Info ? Info -> Opcode : - <NUM_LIT> ;


<s> return Info ? Info -> Opcode : - <NUM_LIT> ;


<s> int getMUBUFElements ( unsigned Opc ) {

const MUBUFInfo * Info = getMUBUFOpcodeHelper ( Opc ) ;


<s> const MUBUFInfo * Info = getMUBUFOpcodeHelper ( Opc ) ; return Info ? Info -> elements : <NUM_LIT> ;


<s> const MUBUFInfo * Info = getMUBUFOpcodeHelper ( Opc ) ;

return Info ? Info -> IsBufferInv : false ;


<s> return Info ? Info -> IsBufferInv : false ;


<s> int getMUBUFOpcode ( unsigned BaseOpc , unsigned Elements ) { const MUBUFInfo * Info = getMUBUFInfoFromBaseOpcodeAndElements ( BaseOpc , Elements ) ;


<s> if ( Name == lookupTable [ Id ] ) return Id ; } return NFMT_UNDEF ;


<s> int64_t getNfmt ( const StringRef Name , const MCSubtargetInfo & STI ) { auto lookupTable = getNfmtLookupTable ( STI ) ; for ( int Id = NFMT_MIN ; Id <= NFMT_MAX ; ++ Id ) { if ( Name == lookupTable [ Id ] ) return Id ;


<s> return getNfmtLookupTable ( STI ) [ Id ] ;


<s> } else { if ( XNACKUsed ) ExtraSGPRs = <NUM_LIT> ; if ( FlatScrUsed || STI -> getFeatureBits ( ) . test ( <STR_LIT> ) ) ExtraSGPRs = <NUM_LIT> ; } return ExtraSGPRs ;


<s> if ( VCCUsed ) ExtraSGPRs = <NUM_LIT> ; IsaVersion Version = getIsaVersion ( STI -> getCPU ( ) ) ; if ( Version . Major >= <NUM_LIT> ) return ExtraSGPRs ; if ( Version . Major < <NUM_LIT> ) { if ( FlatScrUsed ) ExtraSGPRs = <NUM_LIT> ; } else { if ( XNACKUsed ) ExtraSGPRs = <NUM_LIT> ; if ( FlatScrUsed || STI -> getFeatureBits ( ) . test ( <STR_LIT> ) ) ExtraSGPRs = <NUM_LIT> ; } return ExtraSGPRs ;


<s> if ( <STR_LIT> ( ST ) ) return Signed ? <NUM_LIT> : <NUM_LIT> ;


<s> NumVGPRs = alignTo ( std :: max ( <NUM_LIT> , NumVGPRs ) , getVGPREncodingGranule ( STI , EnableWavefrontSize32 ) ) ;

return NumVGPRs / getVGPREncodingGranule ( STI , EnableWavefrontSize32 ) - <NUM_LIT> ;


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_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> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ;


<s> IsaVersion Version = getIsaVersion ( STI -> getCPU ( ) ) ; if ( Version . Major >= <NUM_LIT> ) return getAddressableNumSGPRs ( STI ) ; if ( Version . Major >= <NUM_LIT> ) return <NUM_LIT> ; return <NUM_LIT> ;


<s> const SMInfo * Info = getSMEMOpcodeHelper ( Opc ) ; return Info ? Info -> IsBuffer : false ;


<s> int64_t EncodedOffset = convertSMRDOffsetUnits ( ST , ByteOffset ) ; return isUInt < <NUM_LIT> > ( EncodedOffset ) ? Optional < int64_t > ( EncodedOffset ) : None ;


<s> if ( ! IsBuffer && hasSMRDSignedImmOffset ( ST ) ) { assert ( hasSMEMByteOffset ( ST ) ) ; return isInt < <NUM_LIT> > ( ByteOffset ) ? Optional < int64_t > ( ByteOffset ) : None ; } if ( ! isDwordAligned ( ByteOffset ) && ! hasSMEMByteOffset ( ST ) ) return None ; int64_t EncodedOffset = convertSMRDOffsetUnits ( ST , ByteOffset ) ;

return isLegalSMRDEncodedUnsignedOffset ( ST , EncodedOffset ) ? Optional < int64_t > ( EncodedOffset ) : None ;


<s> static TargetIDSetting getTargetIDSettingFromFeatureString ( StringRef FeatureString ) { if ( FeatureString . endswith ( <STR_LIT> ) ) return TargetIDSetting :: Off ;

if ( FeatureString . endswith ( <STR_LIT> ) ) return TargetIDSetting :: On ;


<s> if ( Val . MaxIndex == <NUM_LIT> && Name == Val . Name ) return Val . Tgt ; if ( Val . MaxIndex > <NUM_LIT> && Name . startswith ( Val . Name ) ) { StringRef Suffix = Name . drop_front ( Val . Name . size ( ) ) ;


<s> if ( Val . MaxIndex == <NUM_LIT> && Name == Val . Name ) return Val . Tgt ; if ( Val . MaxIndex > <NUM_LIT> && Name . startswith ( Val . Name ) ) { StringRef Suffix = Name . drop_front ( Val . Name . size ( ) ) ; unsigned Id ; if ( Suffix . getAsInteger ( <NUM_LIT> , Id ) || Id > Val . MaxIndex ) return ET_INVALID ; if ( Suffix . size ( ) > <NUM_LIT> && Suffix [ <NUM_LIT> ] == '0' ) return ET_INVALID ; return Val . Tgt + Id ;


<s> for ( const ExpTgt & Val : ExpTgtInfo ) { if ( Val . Tgt <= Id && Id <= Val . Tgt + Val . MaxIndex ) {

Index = ( Val . MaxIndex == <NUM_LIT> ) ? - <NUM_LIT> : ( Id - Val . Tgt ) ;


<s> Index = ( Val . MaxIndex == <NUM_LIT> ) ? - <NUM_LIT> : ( Id - Val . Tgt ) ; Name = Val . Name ;


<s> if ( ! isGFX10Plus ( * STI ) ) return <NUM_LIT> ;

return STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ? <NUM_LIT> : <NUM_LIT> ;


<s> int64_t getUnifiedFormat ( const StringRef Name ) { for ( int Id = UFMT_FIRST ; Id <= UFMT_LAST ; ++ Id ) { if ( Name == UfmtSymbolic [ Id ] ) return Id ; } return UFMT_UNDEF ;


<s> return isValidUnifiedFormat ( Id ) ? UfmtSymbolic [ Id ] : <STR_LIT> ;


<s> StringRef getUnifiedFormatName ( unsigned Id ) {

return isValidUnifiedFormat ( Id ) ? UfmtSymbolic [ Id ] : <STR_LIT> ;


<s> if ( hasGFX10_3Insts ( * STI ) ) return IsWave32 ? <NUM_LIT> : <NUM_LIT> ;


<s> bool IsWave32 = EnableWavefrontSize32 ? * EnableWavefrontSize32 : STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ; if ( hasGFX10_3Insts ( * STI ) ) return IsWave32 ? <NUM_LIT> : <NUM_LIT> ; return IsWave32 ? <NUM_LIT> : <NUM_LIT> ;


<s> STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ; return IsWave32 ? <NUM_LIT> : <NUM_LIT> ;


<s> if ( STI -> getFeatureBits ( ) . test ( FeatureGFX90AInsts ) ) return <NUM_LIT> ; bool IsWave32 = EnableWavefrontSize32 ? * EnableWavefrontSize32 : STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ;


<s> const VOPInfo * Info = getVOP1OpcodeHelper ( Opc ) ;

return Info ? Info -> IsSingle : false ;


<s> return Info ? Info -> IsSingle : false ;


<s> bool getVOP2IsSingle ( unsigned Opc ) {

const VOPInfo * Info = getVOP2OpcodeHelper ( Opc ) ;


<s> const VOPInfo * Info = getVOP3OpcodeHelper ( Opc ) ; return Info ? Info -> IsSingle : false ;


<s> unsigned Expcnt = getBitMask ( getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ; unsigned Lgkmcnt = getBitMask ( getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( Version . Major ) ) ; unsigned Waitcnt = VmcntLo | Expcnt | Lgkmcnt ; if ( Version . Major < <NUM_LIT> ) return Waitcnt ;

unsigned VmcntHi = getBitMask ( getVmcntBitShiftHi ( ) , getVmcntBitWidthHi ( ) ) ;


<s> unsigned Lgkmcnt = getBitMask ( getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( Version . Major ) ) ; unsigned Waitcnt = VmcntLo | Expcnt | Lgkmcnt ; if ( Version . Major < <NUM_LIT> ) return Waitcnt ;


<s> unsigned getWavesPerEUForWorkGroup ( const MCSubtargetInfo * STI , unsigned FlatWorkGroupSize ) {

return divideCeil ( getWavesPerWorkGroup ( STI , FlatWorkGroupSize ) , getEUsPerCU ( STI ) ) ;


<s> unsigned getWavesPerWorkGroup ( const MCSubtargetInfo * STI , unsigned FlatWorkGroupSize ) {

return divideCeil ( FlatWorkGroupSize , getWavefrontSize ( STI ) ) ;


<s> return STI . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> bool hasGFX10_3Insts ( const MCSubtargetInfo & STI ) {

return STI . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> return STI . getFeatureBits ( ) [ <STR_LIT> ] && ! STI . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> static bool hasSMEMByteOffset ( const MCSubtargetInfo & ST ) {

return isGCN3Encoding ( ST ) || isGFX10Plus ( ST ) ;


<s> static bool hasSMRDSignedImmOffset ( const MCSubtargetInfo & ST ) { return isGFX9Plus ( ST ) ;


<s> static bool hasSMRDSignedImmOffset ( const MCSubtargetInfo & ST ) {


<s> bool isArgPassedInSGPR ( const Argument * A ) { const Function * F = A -> getParent ( ) ; CallingConv :: ID CC = F -> getCallingConv ( ) ; switch ( CC ) { case CallingConv :: <ISA_LIT>_KERNEL : case CallingConv :: SPIR_KERNEL : return true ; case CallingConv :: <ISA_LIT>_VS : case CallingConv :: <ISA_LIT>_LS : case CallingConv :: <ISA_LIT>_HS : case CallingConv :: <ISA_LIT>_ES : case CallingConv :: <ISA_LIT>_GS :


return F -> getAttributes ( ) . hasParamAttr ( A -> getArgNo ( ) , Attribute :: InReg ) || F -> getAttributes ( ) . hasParamAttr ( A -> getArgNo ( ) , Attribute :: ByVal ) ;


<s> return ! isGraphics ( cc ) || cc == CallingConv :: <ISA_LIT>_CS ;


<s> bool isCompute ( CallingConv :: ID cc ) {

return ! isGraphics ( cc ) || cc == CallingConv :: <ISA_LIT>_CS ;


<s> int16_t Hi16 = static_cast < int16_t > ( Literal >> <NUM_LIT> ) ; if ( ! ( Literal & <NUM_LIT> ) ) return true ;


<s> bool isGFX10 ( const MCSubtargetInfo & STI ) {


<s> bool isGFX10Plus ( const MCSubtargetInfo & STI ) { return isGFX10 ( STI ) ;


<s> bool isGFX10_AEncoding ( const MCSubtargetInfo & STI ) {


<s> bool isGFX10_BEncoding ( const MCSubtargetInfo & STI ) {


<s> bool isGFX90A ( const MCSubtargetInfo & STI ) {


<s> bool isGFX9Plus ( const MCSubtargetInfo & STI ) { return isGFX9 ( STI ) || isGFX10Plus ( STI ) ;


<s> bool isGFX9Plus ( const MCSubtargetInfo & STI ) {

return isGFX9 ( STI ) || isGFX10Plus ( STI ) ;


<s> return GV -> getAddressSpace ( ) == <ISA_LIT>AS :: GLOBAL_ADDRESS ;


<s> return isShader ( cc ) || cc == CallingConv :: <ISA_LIT>_Gfx ;


<s> bool isGroupSegment ( const GlobalValue * GV ) {

return GV -> getAddressSpace ( ) == <ISA_LIT>AS :: LOCAL_ADDRESS ;


<s> bool isHsaAbiVersion2 ( const MCSubtargetInfo * STI ) { if ( Optional < uint8_t > HsaAbiVer = getHsaAbiVersion ( STI ) ) return * HsaAbiVer == ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V2 ; return false ;


<s> bool isHsaAbiVersion2 ( const MCSubtargetInfo * STI ) {

if ( Optional < uint8_t > HsaAbiVer = getHsaAbiVersion ( STI ) ) return * HsaAbiVer == ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V2 ;


<s> bool isHsaAbiVersion3 ( const MCSubtargetInfo * STI ) { if ( Optional < uint8_t > HsaAbiVer = getHsaAbiVersion ( STI ) ) return * HsaAbiVer == ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V3 ; return false ;


<s> bool isHsaAbiVersion3Or4 ( const MCSubtargetInfo * STI ) { return isHsaAbiVersion3 ( STI ) || isHsaAbiVersion4 ( STI ) ;


<s> if ( Optional < uint8_t > HsaAbiVer = getHsaAbiVersion ( STI ) ) return * HsaAbiVer == ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V4 ; return false ;


<s> bool isInlinableIntLiteralV216 ( int32_t Literal ) { int16_t Lo16 = static_cast < int16_t > ( Literal ) ; if ( isInt < <NUM_LIT> > ( Literal ) || isUInt < <NUM_LIT> > ( Literal ) ) return isInlinableIntLiteral ( Lo16 ) ;


<s> if ( isInlinableIntLiteral ( Literal ) ) return true ; uint16_t Val = static_cast < uint16_t > ( Literal ) ; return Val == <NUM_LIT> || Val == <NUM_LIT> || Val == <NUM_LIT> || Val == <NUM_LIT> || Val == <NUM_LIT> || Val == <NUM_LIT> || Val == <NUM_LIT> || Val == <NUM_LIT> || Val == <NUM_LIT> ;


<s> bool isInlinableLiteral16 ( int16_t Literal , bool HasInv2Pi ) { if ( ! HasInv2Pi ) return false ;

if ( isInlinableIntLiteral ( Literal ) ) return true ;


<s> uint32_t Val = static_cast < uint32_t > ( Literal ) ; return ( Val == FloatToBits ( <NUM_LIT> ) ) || ( Val == FloatToBits ( <NUM_LIT> ) ) || ( Val == FloatToBits ( - <NUM_LIT> ) ) || ( Val == FloatToBits ( <NUM_LIT> ) ) || ( Val == FloatToBits ( - <NUM_LIT> ) ) || ( Val == FloatToBits ( <NUM_LIT> ) ) || ( Val == FloatToBits ( - <NUM_LIT> ) ) || ( Val == FloatToBits ( <NUM_LIT> ) ) || ( Val == FloatToBits ( - <NUM_LIT> ) ) || ( Val == <NUM_LIT> && HasInv2Pi ) ;


<s> if ( isInlinableIntLiteral ( Literal ) ) return true ; uint64_t Val = static_cast < uint64_t > ( Literal ) ;

return ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == <NUM_LIT> && HasInv2Pi ) ;


<s> return ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == DoubleToBits ( <NUM_LIT> ) ) || ( Val == DoubleToBits ( - <NUM_LIT> ) ) || ( Val == <NUM_LIT> && HasInv2Pi ) ;


<s> if ( ! ( Literal & <NUM_LIT> ) ) return <STR_LIT> ( Literal >> <NUM_LIT> , HasInv2Pi ) ; int16_t Lo16 = static_cast < int16_t > ( Literal ) ; int16_t Hi16 = static_cast < int16_t > ( Literal >> <NUM_LIT> ) ; return Lo16 == Hi16 && isInlinableLiteral16 ( Lo16 , HasInv2Pi ) ;


<s> assert ( HasInv2Pi ) ; if ( isInt < <NUM_LIT> > ( Literal ) || isUInt < <NUM_LIT> > ( Literal ) ) {

int16_t Trunc = static_cast < int16_t > ( Literal ) ;


<s> bool isLegalSMRDEncodedSignedOffset ( const MCSubtargetInfo & ST , int64_t EncodedOffset , bool IsBuffer ) { return ! IsBuffer && hasSMRDSignedImmOffset ( ST ) && isInt < <NUM_LIT> > ( EncodedOffset ) ;


<s> return hasSMEMByteOffset ( ST ) ? isUInt < <NUM_LIT> > ( EncodedOffset ) : isUInt < <NUM_LIT> > ( EncodedOffset ) ;


<s> bool isLegalSMRDEncodedUnsignedOffset ( const MCSubtargetInfo & ST , int64_t EncodedOffset ) {

return hasSMEMByteOffset ( ST ) ? isUInt < <NUM_LIT> > ( EncodedOffset ) : isUInt < <NUM_LIT> > ( EncodedOffset ) ;


<s> bool isModuleEntryFunctionCC ( CallingConv :: ID CC ) { switch ( CC ) { case CallingConv :: <ISA_LIT>_Gfx : return true ;


<s> return AS == <ISA_LIT>AS :: CONSTANT_ADDRESS || AS == <ISA_LIT>AS :: CONSTANT_ADDRESS_32BIT ;


<s> bool isReadOnlySegment ( const GlobalValue * GV ) { unsigned AS = GV -> getAddressSpace ( ) ; return AS == <ISA_LIT>AS :: CONSTANT_ADDRESS || AS == <ISA_LIT>AS :: CONSTANT_ADDRESS_32BIT ;


<s> const MCRegisterClass SGPRClass = TRI -> getRegClass ( <STR_LIT> ) ; const unsigned FirstSubReg = TRI -> getSubReg ( Reg , <STR_LIT> ) ; return SGPRClass . contains ( FirstSubReg != <NUM_LIT> ? FirstSubReg : Reg ) || Reg == <STR_LIT> ;


<s> bool isSGPR ( unsigned Reg , const MCRegisterInfo * TRI ) { const MCRegisterClass SGPRClass = TRI -> getRegClass ( <STR_LIT> ) ; const unsigned FirstSubReg = TRI -> getSubReg ( Reg , <STR_LIT> ) ; return SGPRClass . contains ( FirstSubReg != <NUM_LIT> ? FirstSubReg : Reg ) || Reg == <STR_LIT> ;


<s> return ( Id != ET_POS4 && Id != ET_PRIM ) || isGFX10Plus ( STI ) ;


<s> decodeDfmtNfmt ( Id , Dfmt , Nfmt ) ;


return <NUM_LIT> <= Id && isUInt < ID_WIDTH_ > ( Id ) ;


<s> bool isValidHwregOffset ( int64_t Offset ) {

return <NUM_LIT> <= Offset && isUInt < OFFSET_WIDTH_ > ( Offset ) ;


<s> return <NUM_LIT> <= ( Width - <NUM_LIT> ) && isUInt < WIDTH_M1_WIDTH_ > ( Width - <NUM_LIT> ) ;


<s> return isGFX9 ( STI ) ; case ID_GET_DDID : return isGFX10Plus ( STI ) ; default : return <NUM_LIT> <= MsgId && MsgId < ID_GAPS_LAST_ && IdSymbolic [ MsgId ] ; } } else { return <NUM_LIT> <= MsgId && isUInt < ID_WIDTH_ > ( MsgId ) ;


<s> bool isValidMsgOp ( int64_t MsgId , int64_t OpId , const MCSubtargetInfo & STI , bool Strict ) { assert ( isValidMsgId ( MsgId , STI , Strict ) ) ; if ( ! Strict ) return <NUM_LIT> <= OpId && isUInt < OP_WIDTH_ > ( OpId ) ; switch ( MsgId ) { case ID_GS : return ( OP_GS_FIRST_ <= OpId && OpId < OP_GS_LAST_ ) && OpId != OP_GS_NOP ; case ID_GS_DONE : return OP_GS_FIRST_ <= OpId && OpId < OP_GS_LAST_ ;


<s> return ( OP_GS_FIRST_ <= OpId && OpId < OP_GS_LAST_ ) && OpId != OP_GS_NOP ; case ID_GS_DONE : return OP_GS_FIRST_ <= OpId && OpId < OP_GS_LAST_ ; case ID_SYSMSG : return OP_SYS_FIRST_ <= OpId && OpId < OP_SYS_LAST_ ; default :


<s> return ! getNfmtName ( Id , STI ) . empty ( ) ;


<s> bool isValidUnifiedFormat ( unsigned Id ) { return Id <= UFMT_LAST ;


<s> return MsgId == ID_GS || MsgId == ID_GS_DONE || MsgId == ID_SYSMSG ;


<s> bool msgSupportsStream ( int64_t MsgId , int64_t OpId ) {

return ( MsgId == ID_GS || MsgId == ID_GS_DONE ) && OpId != OP_GS_NOP ;


<s> for ( const std :: string & Feature : Features . getFeatures ( ) ) { if ( Feature == <STR_LIT> ) XnackRequested = true ; else if ( Feature == <STR_LIT> ) XnackRequested = false ; else if ( Feature == <STR_LIT> ) SramEccRequested = true ; else if ( Feature == <STR_LIT> ) SramEccRequested = false ; } bool XnackSupported = isXnackSupported ( ) ; bool SramEccSupported = isSramEccSupported ( ) ; if ( XnackRequested ) { if ( XnackSupported ) { XnackSetting = * XnackRequested ? TargetIDSetting :: On : TargetIDSetting :: Off ; } else { if ( * XnackRequested ) { errs ( ) << <STR_LIT> <STR_LIT> ; } else { errs ( ) << <STR_LIT> <STR_LIT> ; } }


<s> if ( XnackSupported ) { XnackSetting = * XnackRequested ? TargetIDSetting :: On : TargetIDSetting :: Off ; } else { if ( * XnackRequested ) { errs ( ) << <STR_LIT> <STR_LIT> ; } else { errs ( ) << <STR_LIT> <STR_LIT> ; } } } if ( SramEccRequested ) { if ( SramEccSupported ) { SramEccSetting = * SramEccRequested ? TargetIDSetting :: On : TargetIDSetting :: Off ; } else {


<s> SmallVector < StringRef , <NUM_LIT> > TargetIDSplit ; TargetID . split ( TargetIDSplit , ':' ) ; for ( const auto & FeatureString : TargetIDSplit ) { if ( FeatureString . startswith ( <STR_LIT> ) ) XnackSetting = getTargetIDSettingFromFeatureString ( FeatureString ) ;

if ( FeatureString . startswith ( <STR_LIT> ) ) SramEccSetting = getTargetIDSettingFromFeatureString ( FeatureString ) ;


<s> void <ISA_LIT>TargetID :: setTargetIDFromTargetIDStream ( StringRef TargetID ) { SmallVector < StringRef , <NUM_LIT> > TargetIDSplit ;

TargetID . split ( TargetIDSplit , ':' ) ;


<s> } StringRef DenormAttr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ; if ( ! DenormAttr . empty ( ) ) { DenormalMode DenormMode = parseDenormalFPAttribute ( DenormAttr ) ; if ( DenormF32Attr . empty ( ) ) { FP32InputDenormals = DenormMode . Input == DenormalMode :: IEEE ; FP32OutputDenormals = DenormMode . Output == DenormalMode :: IEEE ; } FP64FP16InputDenormals = DenormMode . Input == DenormalMode :: IEEE ; FP64FP16OutputDenormals = DenormMode . Output == DenormalMode :: IEEE ; }


<s> <STR_LIT> ( const Function & F ) { * this = getDefaultForCallingConv ( F . getCallingConv ( ) ) ; StringRef IEEEAttr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ; if ( ! IEEEAttr . empty ( ) ) IEEE = IEEEAttr == <STR_LIT> ; StringRef DX10ClampAttr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ; if ( ! DX10ClampAttr . empty ( ) ) DX10Clamp = DX10ClampAttr == <STR_LIT> ; StringRef DenormF32Attr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ; if ( ! DenormF32Attr . empty ( ) ) { DenormalMode DenormMode = parseDenormalFPAttribute ( DenormF32Attr ) ; FP32InputDenormals = DenormMode . Input == DenormalMode :: IEEE ; FP32OutputDenormals = DenormMode . Output == DenormalMode :: IEEE ; } StringRef DenormAttr = F . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) ; if ( ! DenormAttr . empty ( ) ) {

DenormalMode DenormMode = parseDenormalFPAttribute ( DenormAttr ) ;


<s> if ( Imm <= MaxImm + <NUM_LIT> ) { Overflow = Imm - MaxImm ; Imm = MaxImm ; } else { uint32_t High = ( Imm + Alignment . value ( ) ) & ~ <NUM_LIT> ; uint32_t Low = ( Imm + Alignment . value ( ) ) & <NUM_LIT> ; Imm = Low ; Overflow = High - Alignment . value ( ) ; } } if ( Overflow > <NUM_LIT> && Subtarget -> getGeneration ( ) <= <ISA_LIT>Subtarget :: SEA_ISLANDS ) return false ; ImmOffset = Imm ;


<s> bool splitMUBUFOffset ( uint32_t Imm , uint32_t & SOffset , uint32_t & ImmOffset , const GCNSubtarget * Subtarget , Align Alignment ) { const uint32_t MaxImm = alignDown ( <NUM_LIT> , Alignment . value ( ) ) ; uint32_t Overflow = <NUM_LIT> ; if ( Imm > MaxImm ) { if ( Imm <= MaxImm + <NUM_LIT> ) { Overflow = Imm - MaxImm ; Imm = MaxImm ; } else { uint32_t High = ( Imm + Alignment . value ( ) ) & ~ <NUM_LIT> ; uint32_t Low = ( Imm + Alignment . value ( ) ) & <NUM_LIT> ; Imm = Low ; Overflow = High - Alignment . value ( ) ; }


<s> std :: string Processor = <STR_LIT> ; if ( Version . Major >= <NUM_LIT> ) Processor = STI . getCPU ( ) . str ( ) ; else Processor = ( Twine ( <STR_LIT> ) + Twine ( Version . Major ) + Twine ( Version . Minor ) + Twine ( Version . Stepping ) ) . str ( ) ; std :: string Features = <STR_LIT> ; if ( Optional < uint8_t > HsaAbiVersion = getHsaAbiVersion ( & STI ) ) { switch ( * HsaAbiVersion ) { case ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V2 : if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { } else if ( Processor == <STR_LIT> ) { if ( ! isXnackOnOrAny ( ) ) report_fatal_error ( <STR_LIT> + Twine ( Processor ) + <STR_LIT> ) ; } else if ( Processor == <STR_LIT> ) {


<s> Waitcnt ( unsigned VmCnt , unsigned ExpCnt , unsigned LgkmCnt ) : VmCnt ( VmCnt ) , ExpCnt ( ExpCnt ) , LgkmCnt ( LgkmCnt ) {


<s> switch ( OpInfo . OperandType ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> if ( Features . test ( FeatureISAVersion8_1_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;

if ( ! Features . test ( FeatureGCN ) || Features . test ( FeatureSouthernIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> <ISA_LIT>AS get<ISA_LIT>AS ( Triple T ) {


<s> AS . PRIVATE_ADDRESS = <NUM_LIT> ; AS . REGION_ADDRESS = <NUM_LIT> ; return AS ;


<s> if ( Features . test ( FeatureISAVersion8_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_1_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureVolcanicIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_4 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_6 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureGFX9 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( ! Features . test ( FeatureGCN ) || Features . test ( FeatureSouthernIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> if ( Features . test ( FeatureISAVersion6_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_4 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureSeaIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_1_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureVolcanicIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_4 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_6 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureGFX9 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( ! Features . test ( FeatureGCN ) || Features . test ( FeatureSouthernIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> assert ( OrigChannels == <NUM_LIT> || OrigChannels == <NUM_LIT> || OrigChannels == <NUM_LIT> ) ; if ( NewChannels == OrigChannels ) return Opc ; if ( OrigChannels <= <NUM_LIT> && NewChannels <= <NUM_LIT> ) { return ( OrigChannels == <NUM_LIT> ) ? <STR_LIT> ( Opc ) : <STR_LIT> ( Opc ) ; } else if ( OrigChannels >= <NUM_LIT> && NewChannels >= <NUM_LIT> ) { return ( OrigChannels == <NUM_LIT> ) ? <STR_LIT> ( Opc ) : <STR_LIT> ( Opc ) ; } else { return - <NUM_LIT> ; }


<s> unsigned AddressableNumSGPRs = getAddressableNumSGPRs ( Features ) ; if ( Version . Major >= <NUM_LIT> && ! Addressable ) AddressableNumSGPRs = <NUM_LIT> ; unsigned MaxNumSGPRs = getTotalNumSGPRs ( Features ) / WavesPerEU ;

if ( Features . test ( FeatureTrapHandler ) ) MaxNumSGPRs -= std :: min ( MaxNumSGPRs , ( unsigned ) TRAP_NUM_SGPRS ) ;


<s> if ( WavesPerEU >= getMaxWavesPerEU ( Features ) ) return <NUM_LIT> ; unsigned MinNumSGPRs = getTotalNumSGPRs ( Features ) / ( WavesPerEU + <NUM_LIT> ) ; if ( Features . test ( FeatureTrapHandler ) ) MinNumSGPRs -= std :: min ( MinNumSGPRs , ( unsigned ) TRAP_NUM_SGPRS ) ; MinNumSGPRs = alignDown ( MinNumSGPRs , getSGPRAllocGranule ( Features ) ) + <NUM_LIT> ; return std :: min ( MinNumSGPRs , getAddressableNumSGPRs ( Features ) ) ;


<s> Header . amd_machine_version_stepping = ISA . Stepping ; Header . kernel_code_entry_byte_offset = sizeof ( Header ) ; Header . wavefront_size = <NUM_LIT> ; Header . call_convention = - <NUM_LIT> ; Header . kernarg_segment_alignment = <NUM_LIT> ; Header . group_segment_alignment = <NUM_LIT> ;

Header . private_segment_alignment = <NUM_LIT> ;


<s> IsaInfo :: IsaVersion ISA = IsaInfo :: getIsaVersion ( Features ) ; memset ( & Header , <NUM_LIT> , sizeof ( Header ) ) ; Header . amd_kernel_code_version_major = <NUM_LIT> ; Header . amd_kernel_code_version_minor = <NUM_LIT> ; Header . amd_machine_kind = <NUM_LIT> ; Header . amd_machine_version_major = ISA . Major ; Header . amd_machine_version_minor = ISA . Minor ; Header . amd_machine_version_stepping = ISA . Stepping ; Header . kernel_code_entry_byte_offset = sizeof ( Header ) ; Header . wavefront_size = <NUM_LIT> ; Header . call_convention = - <NUM_LIT> ;

Header . kernarg_segment_alignment = <NUM_LIT> ;


<s> bool isIntrinsicSourceOfDivergence ( unsigned IntrID ) {

return lookupSourceOfDivergenceByIntr ( IntrID ) ;


<s> return lookupSourceOfDivergenceByIntr ( IntrID ) ;


<s> IsaVersion getIsaVersion ( const FeatureBitset & Features ) { if ( Features . test ( FeatureISAVersion7_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion7_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;

if ( Features . test ( FeatureISAVersion8_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> switch ( OpInfo . OperandType ) { 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> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> unsigned decodeExpcnt ( IsaVersion Version , unsigned Waitcnt ) {

return unpackBits ( Waitcnt , getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ;


<s> return unpackBits ( Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> unsigned decodeLgkmcnt ( IsaVersion Version , unsigned Waitcnt ) { return unpackBits ( Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> return unpackBits ( Waitcnt , getVmcntBitShift ( ) , getVmcntBitWidth ( ) ) ;


<s> Vmcnt = decodeVmcnt ( Version , Waitcnt ) ; Expcnt = decodeExpcnt ( Version , Waitcnt ) ;

Lgkmcnt = decodeLgkmcnt ( Version , Waitcnt ) ;


<s> void decodeWaitcnt ( IsaVersion Version , unsigned Waitcnt , unsigned & Vmcnt , unsigned & Expcnt , unsigned & Lgkmcnt ) {

Vmcnt = decodeVmcnt ( Version , Waitcnt ) ;


<s> unsigned encodeExpcnt ( IsaVersion Version , unsigned Waitcnt , unsigned Expcnt ) {

return packBits ( Expcnt , Waitcnt , getExpcntBitShift ( ) , getExpcntBitWidth ( ) ) ;


<s> unsigned encodeLgkmcnt ( IsaVersion Version , unsigned Waitcnt , unsigned Lgkmcnt ) {

return packBits ( Lgkmcnt , Waitcnt , getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> return packBits ( Vmcnt , Waitcnt , getVmcntBitShift ( ) , getVmcntBitWidth ( ) ) ;


<s> unsigned encodeVmcnt ( IsaVersion Version , unsigned Waitcnt , unsigned Vmcnt ) {

return packBits ( Vmcnt , Waitcnt , getVmcntBitShift ( ) , getVmcntBitWidth ( ) ) ;


<s> Waitcnt = encodeExpcnt ( Version , Waitcnt , Expcnt ) ; Waitcnt = encodeLgkmcnt ( Version , Waitcnt , Lgkmcnt ) ; return Waitcnt ;


<s> unsigned Waitcnt = getWaitcntBitMask ( Version ) ; Waitcnt = encodeVmcnt ( Version , Waitcnt , Vmcnt ) ; Waitcnt = encodeExpcnt ( Version , Waitcnt , Expcnt ) ; Waitcnt = encodeLgkmcnt ( Version , Waitcnt , Lgkmcnt ) ;


<s> <ISA_LIT>ModeRegisterDefaults Mode ; Mode . DX10Clamp = true ;


<s> if ( Strs . first . trim ( ) . getAsInteger ( <NUM_LIT> , Ints . first ) ) { Ctx . emitError ( <STR_LIT> + Name ) ; return Default ; } if ( Strs . second . trim ( ) . getAsInteger ( <NUM_LIT> , Ints . second ) ) { if ( ! OnlyFirstRequired || Strs . second . trim ( ) . size ( ) ) { Ctx . emitError ( <STR_LIT> + Name ) ; return Default ; }


<s> if ( Features . test ( FeatureISAVersion8_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_4 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;

if ( Features . test ( FeatureISAVersion8_1_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> if ( Features . test ( FeatureISAVersion8_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_4 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_1_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> return ( <NUM_LIT> << getLgkmcntBitWidth ( ) ) - <NUM_LIT> ;


<s> unsigned getLgkmcntBitMask ( IsaVersion Version ) { return ( <NUM_LIT> << getLgkmcntBitWidth ( ) ) - <NUM_LIT> ;


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_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> :


<s> unsigned RCID = Desc . OpInfo [ OpNo ] . RegClass ;

return getRegBitWidth ( MRI -> getRegClass ( RCID ) ) / <NUM_LIT> ;


<s> unsigned getVmcntBitMask ( IsaVersion Version ) { return ( <NUM_LIT> << getVmcntBitWidth ( ) ) - <NUM_LIT> ;


<s> unsigned Lgkmcnt = getBitMask ( getLgkmcntBitShift ( ) , getLgkmcntBitWidth ( ) ) ;


<s> IsaVersion ISA = getIsaVersion ( Features ) ; memset ( & Header , <NUM_LIT> , sizeof ( Header ) ) ; Header . amd_kernel_code_version_major = <NUM_LIT> ; Header . amd_kernel_code_version_minor = <NUM_LIT> ; Header . amd_machine_kind = <NUM_LIT> ;

Header . amd_machine_version_major = ISA . Major ;


<s> Header . amd_machine_version_stepping = ISA . Stepping ; Header . kernel_code_entry_byte_offset = sizeof ( Header ) ; Header . wavefront_size = <NUM_LIT> ; Header . call_convention = - <NUM_LIT> ; Header . kernarg_segment_alignment = <NUM_LIT> ;

Header . group_segment_alignment = <NUM_LIT> ;


<s> bool is<ISA_LIT>SrcFPOperand ( const MCInstrDesc & Desc , unsigned OpNo ) { assert ( OpNo <= Desc . NumOperands ) ; unsigned OpType = Desc . OpInfo [ OpNo ] . OperandType ; switch ( OpType ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return true ; default :


<s> unsigned OpType = Desc . OpInfo [ OpNo ] . OperandType ; return OpType >= <STR_LIT> && OpType <= <STR_LIT> ;


<s> bool is<ISA_LIT>SrcInlinableOperand ( const MCInstrDesc & Desc , unsigned OpNo ) { assert ( OpNo <= Desc . NumOperands ) ; unsigned OpType = Desc . OpInfo [ OpNo ] . OperandType ;

return OpType >= <STR_LIT> && OpType <= <STR_LIT> ;


<s> bool is<ISA_LIT>SrcOperand ( const MCInstrDesc & Desc , unsigned OpNo ) { assert ( OpNo <= Desc . NumOperands ) ; unsigned OpType = Desc . OpInfo [ OpNo ] . OperandType ;


<s> <ISA_LIT>ModeRegisterDefaults ( ) : IEEE ( true ) , DX10Clamp ( true ) {


<s> if ( Features . test ( FeatureISAVersion8_0_1 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_0_3 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion8_1_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureVolcanicIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_0 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureISAVersion9_0_2 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; if ( Features . test ( FeatureGFX9 ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;

if ( ! Features . test ( FeatureGCN ) || Features . test ( FeatureSouthernIslands ) ) return { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ;


<s> 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> : 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> : 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> :


<s> if ( ! STI . getFeatureBits ( ) . test ( FeatureSupportsSRAMECC ) ) SramEccSetting = TargetIDSetting :: Unsupported ;


<s> Optional < uint8_t > getHsaAbiVersion ( const MCSubtargetInfo * STI ) { if ( STI && STI -> getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) return None ; switch ( AmdhsaCodeObjectVersion ) { case <NUM_LIT> : return ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V2 ; case <NUM_LIT> :

return ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V3 ;


<s> if ( ! isGFX10Plus ( * STI ) ) return <NUM_LIT> ;

return hasGFX10_3Insts ( * STI ) ? <NUM_LIT> : <NUM_LIT> ;


<s> return STI -> getFeatureBits ( ) . test ( FeatureWavefrontSize32 ) ? <NUM_LIT> : <NUM_LIT> ;


<s> const Function * F = A -> getParent ( ) ; CallingConv :: ID CC = F -> getCallingConv ( ) ; switch ( CC ) { case CallingConv :: <ISA_LIT>_KERNEL : case CallingConv :: SPIR_KERNEL : return true ; case CallingConv :: <ISA_LIT>_VS : case CallingConv :: <ISA_LIT>_LS : case CallingConv :: <ISA_LIT>_HS : case CallingConv :: <ISA_LIT>_ES : case CallingConv :: <ISA_LIT>_GS : case CallingConv :: <ISA_LIT>_PS : case CallingConv :: <ISA_LIT>_CS : case CallingConv :: <ISA_LIT>_Gfx : return F -> getAttributes ( ) . hasParamAttribute ( A -> getArgNo ( ) , Attribute :: InReg ) || F -> getAttributes ( ) . hasParamAttribute ( A -> getArgNo ( ) , Attribute :: ByVal ) ; default : return false ;


<s> bool isArgPassedInSGPR ( const Argument * A ) { const Function * F = A -> getParent ( ) ; CallingConv :: ID CC = F -> getCallingConv ( ) ; switch ( CC ) { case CallingConv :: <ISA_LIT>_KERNEL : case CallingConv :: SPIR_KERNEL : return true ; case CallingConv :: <ISA_LIT>_VS :


<s> if ( const auto && HsaAbiVer = getHsaAbiVersion ( STI ) ) return HsaAbiVer . getValue ( ) == ELF :: ELFABIVER<ISA_LIT>ON_AMDGPU_HSA_V3 ; return false ;


<s> else return isValidMsgId ( MsgId ) ; } else { return <NUM_LIT> <= MsgId && isUInt < ID_WIDTH_ > ( MsgId ) ;


<s> Stream << TargetTriple . getArchName ( ) << '-' << TargetTriple . getVendorName ( ) << '-' << TargetTriple . getOSName ( ) << '-' << TargetTriple . getEnvironmentName ( ) << '-' << <STR_LIT> << Version . Major << Version . Minor << Version . Stepping ;

if ( hasXNACK ( * STI ) ) Stream << <STR_LIT> ;


<s> Stream << TargetTriple . getArchName ( ) << '-' << TargetTriple . getVendorName ( ) << '-' << TargetTriple . getOSName ( ) << '-' << TargetTriple . getEnvironmentName ( ) << '-' << <STR_LIT> << Version . Major << Version . Minor << Version . Stepping ; if ( hasXNACK ( * STI ) ) Stream << <STR_LIT> ; if ( hasSRAMECC ( * STI ) ) Stream << <STR_LIT> ;


<s> return <NUM_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> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :