<s> MCObjectWriter * llvm :: create<ISA_LIT>ELFObjectWriter ( bool Is64Bit , bool HasRelocationAddend , raw_pwrite_stream & OS ) { MCELFObjectTargetWriter * MOTW = new <ISA_LIT>ELFObjectWriter ( Is64Bit , HasRelocationAddend ) ; return createELFObjectWriter ( MOTW , OS


<s> return llvm :: make_unique < <ISA_LIT>ELFObjectWriter > ( Is64Bit ,

OSABI , HasRelocationAddend , ABIVersion ) ;


<s> std :: unique_ptr < MCObjectTargetWriter > llvm :: create<ISA_LIT>ELFObjectWriter ( bool Is64Bit , uint8_t OSABI , bool HasRelocationAddend , uint8_t ABIVersion ) { return llvm :: make_unique < <ISA_LIT>ELFObjectWriter > ( Is64Bit ,


<s> case FK_Data_8 : return ELF :: R_<ISA_LIT>_ABS64 ; } if ( Fixup . getTargetKind ( ) == <STR_LIT> ) { const auto * SymA = Target . getSymA ( ) ; assert ( SymA ) ; if ( SymA -> getSymbol ( ) . isUndefined ( ) ) { Ctx . reportError ( Fixup . getLoc ( ) , Twine ( <STR_LIT> ) + SymA -> getSymbol ( ) . getName ( ) + <STR_LIT> ) ; return ELF :: R_<ISA_LIT>_NONE ; } return ELF ::


<s> std :: unique_ptr < MCObjectTargetWriter > llvm :: create<ISA_LIT>ELFObjectWriter ( bool Is64Bit , uint8_t OSABI ,


<s> return new <ISA_LIT>ELFStreamer ( Context , MAB


<s> MCELFStreamer * llvm :: create<ISA_LIT>ELFStreamer ( MCContext & Context , MCAsmBackend & MAB , raw_pwrite_stream & OS , MCCodeEmitter * Emitter ,


<s> void <ISA_LIT>ELFStreamer :: InitSections ( bool NoExecStack ) { SwitchSection ( <STR_LIT> ( getContext ( ) )


<s> return new <ISA_LIT>ELFStreamer ( T , Context , std :: move ( MAB ) , OS , std ::


<s> return new <ISA_LIT>ELFStreamer ( T , Context , std :: move ( MAB ) , std

:: move ( OW ) , std :: move ( Emitter ) ) ;


<s> return new <ISA_LIT>ELFStreamer ( T , Context , std :: move ( MAB ) , std :: move


<s> static bool isPositionExport ( const <ISA_LIT>InstrInfo * TII , SUnit * SU ) { const MachineInstr * MI = SU -> getInstr (


<s> static bool isExport ( const SUnit & SU ) { const MachineInstr * MI = SU . getInstr ( ) ; return MI -> getOpcode ( ) == <STR_LIT> || MI -> getOpcode (


<s> static bool isPositionExport ( const <ISA_LIT>InstrInfo * TII , SUnit * SU ) { const MachineInstr * MI = SU -> getInstr ( ) ; int Imm = TII -> getNamedOperand ( * MI , <STR_LIT> :: tgt ) ->


<s> if ( isPositionExport ( TII , & SU ) ) PosCount ++ ; removeExportDependencies ( DAG , SU ) ; SmallVector < SDep , <NUM_LIT> > Succs ( SU . Succs ) ; for ( SDep Succ : Succs ) removeExportDependencies ( DAG , * Succ . getSUnit ( ) ) ; } if ( Chain . size ( ) > <NUM_LIT> ) { sortChain ( TII , Chain , PosCount


<s> SUnit * ChainHead = Exports . front ( ) ; for ( unsigned Idx = <NUM_LIT> , End = Exports . size ( ) - <NUM_LIT> ; Idx < End ; ++ Idx ) { SUnit * SUa = Exports [ Idx ] ; SUnit * SUb = Exports


<s> if ( ! isExport ( * PredSU ) && ! Pred . isWeak ( ) ) DAG -> addEdge ( ChainHead , SDep ( PredSU , SDep :: Artificial ) ) ; } DAG -> addEdge ( SUb , SDep ( SUa , SDep :: Barrier ) ) ; DAG -> addEdge ( SUb , SDep ( SUa , SDep :: Cluster )


<s> return std :: make_unique < ExportClustering


<s> return <ISA_LIT>InstrInfo :: isEXP ( * SU . getInstr


<s> void visitCallBase ( CallBase & CB ) { if ( CB . getCalledFunction ( ) ) return ; auto * Callee = dyn_cast < Function > ( CB . getCalledOperand ( ) -> stripPointerCasts ( ) ) ; if ( Callee && isLegalToPromote ( CB , Callee ) ) { promoteCall ( CB , Callee ) ; Modified = true


<s> if ( CB . getCalledFunction ( ) ) return ; auto * Callee = dyn_cast < Function > ( CB . getCalledOperand ( ) -> stripPointerCasts ( ) ) ; if ( Callee && isLegalToPromote ( CB ,


<s> if ( CS . getCalledFunction ( ) ) return ; auto Callee = dyn_cast < Function > ( CS . getCalledValue ( ) -> stripPointerCasts ( ) ) ; if ( Callee && isLegalToPromote ( CS , Callee ) ) { promoteCall ( CS ,


<s> return new <ISA_LIT>FixFunctionBitcasts (


<s> bool <ISA_LIT>FixFunctionBitcasts :: runOnModule ( Module & M ) { Modified =


<s> bool <ISA_LIT>FixFunctionBitcasts :: runOnModule ( Module & M ) { Modified = false ; visit ( M ) ; return Modified


<s> if ( Callee && isLegalToPromote ( CS , Callee ) ) { promoteCall ( CS , Callee ) ; Modified = true


<s> const TargetFrameLowering :: SpillSlot * <ISA_LIT>FrameLowering :: getCalleeSavedSpillSlots ( unsigned & NumEntries


<s> int <ISA_LIT>FrameLowering :: getFrameIndexReference ( const MachineFunction & MF , int FI , unsigned & FrameReg ) const { const MachineFrameInfo * MFI = MF . getFrameInfo ( ) ; const TargetRegisterInfo * RI = MF . getSubtarget ( ) . getRegisterInfo ( ) ; FrameReg = RI -> getFrameRegister (


<s> int <ISA_LIT>FrameLowering :: getFrameIndexReference ( const MachineFunction & MF , int FI , unsigned & FrameReg ) const { const MachineFrameInfo * MFI = MF . getFrameInfo ( ) ; const TargetRegisterInfo * RI = MF . getSubtarget ( ) . getRegisterInfo ( ) ; FrameReg = RI -> getFrameRegister ( MF ) ; unsigned OffsetBytes = <NUM_LIT> * ( getStackWidth ( MF ) * <NUM_LIT> ) ; int UpperBound = FI == - <NUM_LIT> ? MFI -> getNumObjects ( ) : FI ; for ( int i = MFI -> getObjectIndexBegin ( ) ; i < UpperBound ; ++ i ) { OffsetBytes = RoundUpToAlignment ( OffsetBytes , MFI -> getObjectAlignment ( i ) ) ; OffsetBytes += MFI -> getObjectSize ( i ) ; OffsetBytes = RoundUpToAlignment ( OffsetBytes , <NUM_LIT> ) ; } if ( FI != - <NUM_LIT> ) OffsetBytes = RoundUpToAlignment ( OffsetBytes , MFI -> getObjectAlignment ( FI ) ) ; return OffsetBytes / ( getStackWidth ( MF


<s> unsigned <ISA_LIT>FrameLowering :: getStackWidth ( const MachineFunction & MF )


<s> unsigned <ISA_LIT>FrameLowering :: getStackWidth ( const MachineFunction & MF ) const { return <NUM_LIT>


<s> unsigned OffsetBytes = <NUM_LIT> * ( getStackWidth ( MF ) * <NUM_LIT> ) ; int UpperBound = FI == - <NUM_LIT> ? MFI -> getNumObjects ( ) : FI ; for ( int i = MFI -> getObjectIndexBegin ( ) ; i < UpperBound ; ++ i ) { OffsetBytes = alignTo ( OffsetBytes , MFI -> getObjectAlignment ( i ) ) ; OffsetBytes += MFI -> getObjectSize


<s> unsigned OffsetBytes = <NUM_LIT> * ( getStackWidth ( MF ) * <NUM_LIT> ) ; int UpperBound = FI == - <NUM_LIT> ? MFI -> getNumObjects ( ) : FI ; for ( int i = MFI -> getObjectIndexBegin ( ) ; i < UpperBound ; ++ i ) { OffsetBytes = alignTo ( OffsetBytes , MFI -> getObjectAlignment ( i ) ) ; OffsetBytes += MFI -> getObjectSize ( i ) ; OffsetBytes = alignTo ( OffsetBytes , <NUM_LIT> ) ; } if ( FI != - <NUM_LIT> ) OffsetBytes = alignTo ( OffsetBytes , MFI -> getObjectAlignment ( FI ) ) ; return OffsetBytes / ( getStackWidth ( MF ) * <NUM_LIT>


<s> unsigned OffsetBytes = <NUM_LIT> * ( getStackWidth ( MF ) * <NUM_LIT> ) ; int UpperBound = FI == - <NUM_LIT> ? MFI -> getNumObjects ( ) : FI ; for ( int i = MFI -> getObjectIndexBegin ( ) ; i < UpperBound ; ++ i ) { OffsetBytes = RoundUpToAlignment ( OffsetBytes , MFI -> getObjectAlignment ( i ) ) ; OffsetBytes += MFI -> getObjectSize ( i ) ; OffsetBytes = RoundUpToAlignment ( OffsetBytes , <NUM_LIT> ) ; } if ( FI != - <NUM_LIT> ) OffsetBytes = RoundUpToAlignment ( OffsetBytes , MFI -> getObjectAlignment ( FI ) ) ; return OffsetBytes / ( getStackWidth ( MF ) * <NUM_LIT>


<s> int <ISA_LIT>FrameLowering :: getFrameIndexReference ( const MachineFunction & MF , int FI , unsigned & FrameReg ) const { const MachineFrameInfo & MFI = MF . getFrameInfo ( ) ; const <ISA_LIT>RegisterInfo * RI = MF . getSubtarget < <ISA_LIT>Subtarget > ( ) . getRegisterInfo ( ) ; FrameReg = RI -> getFrameRegister ( MF ) ; unsigned OffsetBytes = <NUM_LIT> * ( getStackWidth ( MF ) * <NUM_LIT> ) ; int UpperBound = FI == - <NUM_LIT> ? MFI . getNumObjects ( ) : FI ; for ( int i = MFI . getObjectIndexBegin ( ) ; i < UpperBound ; ++ i ) { OffsetBytes = alignTo ( OffsetBytes , MFI . getObjectAlignment ( i ) ) ; OffsetBytes += MFI . getObjectSize ( i ) ; OffsetBytes = alignTo ( OffsetBytes , <NUM_LIT>


<s> FrameReg = RI -> getFrameRegister ( MF ) ; unsigned OffsetBytes = <NUM_LIT> * ( getStackWidth ( MF ) * <NUM_LIT> ) ; int UpperBound = FI == - <NUM_LIT> ? MFI -> getNumObjects ( ) : FI ; for ( int i = MFI -> getObjectIndexBegin ( ) ; i < UpperBound ; ++ i ) { OffsetBytes = alignTo ( OffsetBytes , MFI -> getObjectAlignment ( i ) ) ; OffsetBytes += MFI -> getObjectSize ( i ) ; OffsetBytes = alignTo ( OffsetBytes , <NUM_LIT>


<s> } int64_t Offset ; if ( Def -> getOpcode ( ) == TargetOpcode :: G_ADD ) { if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_ICst ( Offset ) ) ) return std :: make_tuple ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , Offset , Def ) ; if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_Copy ( m_ICst ( Offset ) ) ) ) return std :: make_tuple ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , Offset , Def ) ; } return std :: make_tuple ( Reg , <NUM_LIT> , Def


<s> MachineInstr * Def = getDefIgnoringCopies ( Reg , MRI ) ; if ( ! Def ) return std :: make_tuple ( Reg , <NUM_LIT> , nullptr ) ; if ( Def -> getOpcode ( ) == TargetOpcode :: G_CONSTANT ) { unsigned Offset ; const MachineOperand & Op = Def -> getOperand ( <NUM_LIT> ) ; if ( Op . isImm ( ) ) Offset = Op . getImm ( ) ; else Offset = Op . getCImm ( ) -> getZExtValue ( ) ; return std :: make_tuple ( Register ( ) , Offset , Def ) ; } int64_t Offset ; if ( Def -> getOpcode ( ) == TargetOpcode :: G_ADD


<s> inline int getDMaskIdx ( const <STR_LIT> * BaseOpcode , int NumDefs ) { assert ( ! BaseOpcode -> Atomic ) ; return NumDefs + <NUM_LIT> + ( BaseOpcode -> Store


<s> return NumDefs + <NUM_LIT> + ( BaseOpcode -> Store ?


<s> inline std :: pair < int , int > getImageNumVAddr ( const <STR_LIT> * ImageDimIntr , const <STR_LIT> * BaseOpcode ) { const <STR_LIT> * DimInfo = <STR_LIT> ( ImageDimIntr -> Dim ) ; int NumGradients = BaseOpcode -> Gradients ? DimInfo -> NumGradients : <NUM_LIT> ; int NumCoords = BaseOpcode -> Coordinates ? DimInfo -> NumCoords : <NUM_LIT> ; int NumLCM = BaseOpcode -> LodOrClampOrMip ? <NUM_LIT> : <NUM_LIT> ; int NumVAddr = BaseOpcode -> NumExtraArgs + NumGradients + NumCoords + NumLCM ; return { NumVAddr , NumGradients


<s> if ( BaseOpcode -> Atomic ) return NumDefs + <NUM_LIT> + ( BaseOpcode -> AtomicX2 ? <NUM_LIT> : <NUM_LIT> ) ; return getDMaskIdx ( BaseOpcode ,


<s> MachineInstr * Def = getDefIgnoringCopies ( Reg , MRI ) ; if ( ! Def ) return std :: make_pair ( Reg , <NUM_LIT> ) ; if ( Def -> getOpcode ( ) == TargetOpcode :: G_CONSTANT ) { unsigned Offset ; const MachineOperand & Op = Def -> getOperand ( <NUM_LIT> ) ; if ( Op . isImm ( ) ) Offset = Op . getImm ( ) ; else Offset = Op . getCImm ( ) -> getZExtValue ( ) ; return std :: make_pair ( Register ( ) , Offset ) ; } int64_t Offset ; if ( Def -> getOpcode ( ) == TargetOpcode :: G_ADD ) { if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_ICst ( Offset ) ) ) return std :: make_pair ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , Offset ) ; if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_Copy ( m_ICst ( Offset ) ) ) ) return std :: make_pair ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , Offset ) ; } if ( Def -> getOpcode ( ) == TargetOpcode :: G_PTRTOINT ) { MachineInstr * Base ; if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_GPtrAdd ( m_MInstr ( Base ) , m_ICst ( Offset ) ) ) ) { if ( Base -> getOpcode ( ) == TargetOpcode :: G_INTTOPTR ) return std :: make_pair ( Base -> getOperand ( <NUM_LIT> ) . getReg ( ) , Offset ) ; return std :: make_pair ( Base -> getOperand ( <NUM_LIT> ) . getReg ( )


<s> if ( Op . isImm ( ) ) Offset = Op . getImm ( ) ; else Offset = Op . getCImm ( ) -> getZExtValue ( ) ; return std :: make_pair ( Register ( ) , Offset ) ; } int64_t Offset ; if ( Def -> getOpcode ( ) == TargetOpcode :: G_ADD ) { if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_ICst ( Offset ) ) ) return std :: make_pair ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , Offset ) ; if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_Copy ( m_ICst ( Offset ) ) )


<s> return std :: make_pair ( Register ( ) , Offset ) ; } int64_t Offset ; if ( Def -> getOpcode ( ) == TargetOpcode :: G_ADD ) { if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_ICst ( Offset ) ) ) return std :: make_pair ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , Offset ) ; if ( mi_match ( Def -> getOperand ( <NUM_LIT> ) . getReg ( ) , MRI , m_Copy ( m_ICst ( Offset ) ) ) ) return


<s> assert ( Mask . size ( ) == <NUM_LIT> ) ; if ( Mask [ <NUM_LIT> ] == - <NUM_LIT> || Mask [ <NUM_LIT> ] == - <NUM_LIT> ) return true ; return ( Mask [ <NUM_LIT> ] & <NUM_LIT> ) == ( Mask


<s> getRootMetadata ( <STR_LIT> ) = HSAMetadataDoc ->


<s> void MetadataStreamerV3 :: begin ( const Module & Mod ) { emitVersion ( ) ; emitPrintf ( Mod )


<s> auto & DL = Func . getParent ( ) -> getDataLayout ( ) ; auto Int64Ty = Type :: getInt64Ty ( Func . getContext ( ) ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; else if ( Func . getParent ( ) -> getFunction ( <STR_LIT> ) ) { assert ( ! Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . hasFnAttribute ( <STR_LIT>


<s> void MetadataStreamerV3 :: emitKernelAttrs ( const Function & Func , msgpack :: MapDocNode Kern ) { if ( auto Node = Func . getMetadata ( <STR_LIT> ) ) Kern [ <STR_LIT> ] = getWorkGroupDimensions ( Node ) ; if ( auto Node = Func . getMetadata ( <STR_LIT> ) ) Kern [ <STR_LIT> ] = getWorkGroupDimensions ( Node ) ; if ( auto Node = Func . getMetadata ( <STR_LIT> ) ) { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( getTypeName ( cast < ValueAsMetadata > ( Node -> getOperand ( <NUM_LIT> ) ) -> getType ( ) , mdconst :: extract < ConstantInt > ( Node -> getOperand ( <NUM_LIT> ) ) -> getZExtValue ( ) ) , true ) ; } if ( Func . hasFnAttribute ( <STR_LIT> ) ) { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( Func . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) . str


<s> void MetadataStreamerV3 :: emitVersion ( ) { auto Version = HSAMetadataDoc -> getArrayNode ( ) ; Version . push_back ( Version . getDocument ( ) -> getNode ( VersionMajor ) ) ; Version . push_back ( Version . getDocument ( ) -> getNode ( VersionMinor ) ) ; getRootMetadata ( <STR_LIT> )


<s> const Module * M = Func . getParent ( ) ; auto & DL = M -> getDataLayout ( ) ; const <ISA_LIT>MachineFunctionInfo & MFI = * MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; auto Int64Ty = Type :: getInt64Ty ( Func . getContext ( ) ) ; auto Int32Ty = Type :: getInt32Ty ( Func . getContext ( ) ) ; auto Int16Ty = Type :: getInt16Ty ( Func . getContext ( ) ) ; Offset = alignTo ( Offset , ST . getAlignmentForImplicitArgPtr ( ) ) ; emitKernelArg ( DL , Int32Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int32Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int32Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; Offset += <NUM_LIT> ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( M -> getNamedMetadata ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) ,


<s> void MetadataStreamerV2 :: verify ( StringRef HSAMetadataString ) const { errs ( ) << <STR_LIT> ; HSAMD :: Metadata FromHSAMetadataString ; if ( fromString ( std :: string ( HSAMetadataString ) , FromHSAMetadataString ) ) { errs ( ) << <STR_LIT> ; return ; } std :: string ToHSAMetadataString ; if ( toString ( FromHSAMetadataString , ToHSAMetadataString ) ) { errs ( ) <<


<s> errs ( ) << <STR_LIT> ; return ; } std :: string ToHSAMetadataString ; if ( toString ( FromHSAMetadataString , ToHSAMetadataString ) ) { errs ( ) << <STR_LIT> ; return ; } errs ( ) << ( HSAMetadataString == ToHSAMetadataString ? <STR_LIT> : <STR_LIT> ) << '\n' ; if ( HSAMetadataString != ToHSAMetadataString ) { errs ( ) << <STR_LIT> << HSAMetadataString << '\n' << <STR_LIT>


<s> void MetadataStreamerV3 :: emitHiddenKernelArgs ( const Function & Func , unsigned & Offset , msgpack :: ArrayDocNode Args ) { int HiddenArgNumBytes = getIntegerAttribute ( Func , <STR_LIT> , <NUM_LIT> ) ; if ( ! HiddenArgNumBytes ) return ; auto & DL = Func . getParent ( ) -> getDataLayout ( ) ; auto Int64Ty = Type :: getInt64Ty ( Func . getContext ( ) ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , <STR_LIT> , Offset , Args ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , <STR_LIT> , Offset , Args ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , <STR_LIT> , Offset , Args ) ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; else if ( Func . getParent ( ) -> getFunction ( <STR_LIT> ) ) { assert ( ! Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) ; emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset ,


<s> default : return <STR_LIT> ; } } case Type :: HalfTyID : return <STR_LIT> ; case Type :: FloatTyID : return <STR_LIT> ; case Type :: DoubleTyID : return <STR_LIT> ; case Type :: PointerTyID : return getValueType ( Ty -> getPointerElementType ( ) , TypeName ) ; case Type :: FixedVectorTyID


<s> void emitHiddenKernelArgs ( const MachineFunction & MF , unsigned & Offset , msgpack :: ArrayDocNode Args ) override { llvm_unreachable ( <STR_LIT>


<s> if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , <STR_LIT> , Offset , Args ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , <STR_LIT> , Offset , Args ) ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; else emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; } if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset


<s> if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; else emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; } if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; } else { emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int8PtrTy , <STR_LIT>


<s> HSAMetadata . mKernels . push_back ( Kernel :: Metadata ( ) ) ; auto & Kernel = HSAMetadata . mKernels . back ( ) ; Kernel . mName = Func . getName ( ) ; Kernel . mSymbolName = ( Twine ( Func . getName ( ) ) + Twine ( <STR_LIT> )


<s> HSAMetadata . mKernels . back ( ) . mArgs . push_back ( Kernel :: Arg :: Metadata ( ) ) ; auto & Arg = HSAMetadata . mKernels . back ( ) . mArgs . back ( ) ; Arg . mName = Name ; Arg . mTypeName = TypeName ; Arg . mSize = DL . getTypeAllocSize ( Ty ) ; Arg . mAlign = DL . getABITypeAlignment ( Ty ) ; Arg . mValueKind = ValueKind ; Arg . mValueType = getValueType ( Ty , BaseTypeName ) ; Arg . mPointeeAlign = PointeeAlign ; if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) Arg . mAddrSpaceQual = getAddressSpaceQualifier ( PtrTy -> getAddressSpace ( ) ) ; Arg . mAccQual = getAccessQualifier ( AccQual ) ; SmallVector < StringRef , <NUM_LIT> > SplitTypeQuals ; TypeQual . split ( SplitTypeQuals , <STR_LIT> , -


<s> std :: shared_ptr < msgpack :: Node > & getHSAMetadataRoot ( ) { return HSAMetadataRoot


<s> std :: shared_ptr < msgpack :: Node > & getRootMetadata ( StringRef Key ) { return ( * cast < msgpack :: MapNode > ( HSAMetadataRoot . get (


<s> case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; default : return ( Twine ( 'i' ) + Twine ( BitWidth ) ) . str ( ) ; } } case Type :: HalfTyID : return <STR_LIT> ; case Type :: FloatTyID : return <STR_LIT> ; case Type :: DoubleTyID : return <STR_LIT> ; case Type :: FixedVectorTyID : { auto VecTy = cast < VectorType > ( Ty ) ; auto ElTy = VecTy ->


<s> emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; Offset += <NUM_LIT> ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( M -> getNamedMetadata ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; if ( ! Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset +=


<s> Offset += <NUM_LIT> ; Offset += <NUM_LIT> ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( M -> getNamedMetadata ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; if ( ! Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; if ( ! Func . hasFnAttribute ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> )


<s> Version . push_back ( Version . getDocument ( ) -> getNode ( VersionMinorV5 ) ) ; getRootMetadata ( <STR_LIT>


<s> void MetadataStreamerV5 :: emitVersion ( ) { auto Version = HSAMetadataDoc -> getArrayNode ( ) ; Version . push_back ( Version . getDocument ( ) -> getNode ( VersionMajorV5 ) ) ; Version . push_back ( Version . getDocument ( )


<s> HSACodeProps . mGroupSegmentFixedSize = ProgramInfo . LDSSize ; HSACodeProps . mPrivateSegmentFixedSize = ProgramInfo . ScratchSize ; HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = ProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = ProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ; HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ; HSACodeProps . mIsXNACKEnabled = STM . isXNACKEnabled ( ) ; HSACodeProps . mNumSpilledSGPRs = MFI .


<s> msgpack :: MapDocNode MetadataStreamerV3 :: getHSAKernelProps ( const MachineFunction & MF , const <ISA_LIT>ProgramInfo & ProgramInfo ) const { const GCNSubtarget & STM = MF . getSubtarget < GCNSubtarget > ( ) ; const <ISA_LIT>MachineFunctionInfo & MFI = * MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const Function & F = MF . getFunction ( ) ; auto Kern = HSAMetadataDoc -> getMapNode ( ) ; Align MaxKernArgAlign ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( STM . getKernArgSegmentSize ( F , MaxKernArgAlign ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . LDSSize ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . ScratchSize ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( std :: max ( Align ( <NUM_LIT> ) , MaxKernArgAlign ) . value ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( STM . getWavefrontSize ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumSGPR ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumVGPR ) ; if ( STM . hasMAIInsts ( ) ) { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumAccVGPR ) ; } Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getMaxFlatWorkGroupSize ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getNumSpilledSGPRs ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getNumSpilledVGPRs ( ) ) ; return Kern


<s> if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) { auto ElTy = PtrTy -> getElementType ( ) ; if ( PtrTy -> getAddressSpace ( ) == AMDGPUA<ISA_LIT> . LOCAL_ADDRESS && ElTy -> isSized ( ) ) Arg . mPointeeAlign = DL . getABITypeAlignment ( ElTy ) ; } if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) Arg . mAddrSpaceQual = getAddressSpaceQualifer ( PtrTy -> getAddressSpace ( ) ) ; Arg . mAccQual = getAccessQualifier ( AccQual ) ; SmallVector < StringRef , <NUM_LIT> > SplitTypeQuals ; TypeQual . split ( SplitTypeQuals , <STR_LIT> , - <NUM_LIT> , false


<s> emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetX ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetY ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetZ ) ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , AMDGPUA<ISA_LIT> . GLOBAL_ADDRESS ) ; auto CallsPrintf = Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ; if ( CallsPrintf ) emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenPrintfBuffer ) ; if ( Func . hasFnAttribute ( <STR_LIT> ) ) { if ( ! CallsPrintf ) { emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenNone ) ; } emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenDefaultQueue ) ; emitKernelArg ( DL , Int8PtrTy , ValueKind


<s> const MDNode * Node ; StringRef Name ; Node = Func -> getMetadata ( <STR_LIT> ) ; if ( Node && ArgNo < Node -> getNumOperands ( ) ) Name = cast < MDString > ( Node -> getOperand ( ArgNo ) ) -> getString ( ) ; else if ( Arg . hasName ( ) ) Name = Arg . getName ( ) ; StringRef TypeName ; Node = Func -> getMetadata ( <STR_LIT> ) ; if ( Node && ArgNo < Node -> getNumOperands ( ) ) TypeName = cast < MDString > ( Node -> getOperand ( ArgNo ) ) -> getString ( ) ; StringRef BaseTypeName ; Node = Func -> getMetadata ( <STR_LIT> ) ; if ( Node && ArgNo < Node -> getNumOperands ( ) ) BaseTypeName = cast < MDString > ( Node -> getOperand ( ArgNo ) ) -> getString ( ) ; StringRef AccQual ; if ( Arg . getType ( ) -> isPointerTy ( ) && Arg . onlyReadsMemory ( ) && Arg . hasNoAliasAttr ( ) ) { AccQual = <STR_LIT> ; } else { Node = Func -> getMetadata ( <STR_LIT> ) ; if ( Node && ArgNo < Node -> getNumOperands ( ) ) AccQual = cast < MDString > ( Node -> getOperand ( ArgNo ) ) -> getString ( ) ; } StringRef TypeQual ; Node = Func -> getMetadata ( <STR_LIT> ) ; if ( Node && ArgNo < Node -> getNumOperands ( ) ) TypeQual = cast < MDString > ( Node -> getOperand ( ArgNo ) ) -> getString ( ) ; Type * Ty = Arg . getType ( ) ; const DataLayout & DL = Func -> getParent ( ) -> getDataLayout ( ) ; unsigned PointeeAlign = <NUM_LIT> ; if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) { if ( PtrTy -> getAddressSpace (

) == AMDGPUA<ISA_LIT> . LOCAL_ADDRESS ) {


<s> if ( ! Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) return ; auto & DL = Func . getParent ( ) -> getDataLayout ( ) ; auto Int64Ty = Type :: getInt64Ty ( Func . getContext ( ) ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetX ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetY ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetZ ) ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , AMDGPUA<ISA_LIT> . GLOBAL_ADDRESS ) ; if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenPrintfBuffer ) ; else emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenNone ) ; if ( Func . hasFnAttribute (


<s> auto Int64Ty = Type :: getInt64Ty ( Func . getContext ( ) ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetX ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetY ) ; emitKernelArg ( DL , Int64Ty , ValueKind :: HiddenGlobalOffsetZ ) ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , AMDGPUA<ISA_LIT> . GLOBAL_ADDRESS ) ; if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg

( DL , Int8PtrTy , ValueKind :: HiddenPrintfBuffer ) ;


<s> void MetadataStreamerV3 :: begin ( const Module & Mod ) { emitVersion ( ) ; emitPrintf ( Mod ) ; getRootMetadata ( <STR_LIT> ) . reset ( new msgpack :: ArrayNode ( )


<s> if ( PointeeAlign ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( PointeeAlign ) ; if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) if ( auto Qualifier = getAddressSpaceQualifier ( PtrTy -> getAddressSpace ( ) ) ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( * Qualifier ) ; if ( auto AQ = getAccessQualifier ( AccQual ) ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( * AQ ) ; SmallVector < StringRef , <NUM_LIT> > SplitTypeQuals ; TypeQual . split ( SplitTypeQuals , <STR_LIT> , - <NUM_LIT> , false ) ; for ( StringRef Key : SplitTypeQuals ) { if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared


<s> Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( ValueKind ) ; Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( getValueType ( Ty , BaseTypeName ) ) ; if ( PointeeAlign ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( PointeeAlign ) ; if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) if ( auto Qualifier = getAddressSpaceQualifier ( PtrTy -> getAddressSpace ( ) ) ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( * Qualifier ) ; if ( auto AQ = getAccessQualifier ( AccQual ) ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( * AQ ) ; SmallVector < StringRef , <NUM_LIT> > SplitTypeQuals ; TypeQual . split ( SplitTypeQuals , <STR_LIT> , - <NUM_LIT> , false ) ; for ( StringRef Key : SplitTypeQuals ) { if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( true ) ; } Args . push_back ( std :: move (


<s> void MetadataStreamerV3 :: emitKernelAttrs ( const Function & Func , msgpack :: MapNode & Kern ) { if ( auto Node = Func . getMetadata ( <STR_LIT> ) ) Kern [ <STR_LIT> ] = getWorkGroupDimensions ( Node ) ; if ( auto Node = Func . getMetadata ( <STR_LIT> ) ) Kern [ <STR_LIT> ] = getWorkGroupDimensions ( Node ) ; if ( auto Node = Func . getMetadata ( <STR_LIT> ) ) { Kern [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( getTypeName ( cast < ValueAsMetadata > ( Node -> getOperand ( <NUM_LIT> ) ) -> getType ( ) , mdconst

:: extract < ConstantInt > ( Node -> getOperand ( <NUM_LIT> ) ) -> getZExtValue ( ) ) ) ;


<s> for ( auto Op : Node -> operands ( ) ) if ( Op -> getNumOperands ( ) ) Printf -> push_back ( std :: make_shared < msgpack :: ScalarNode > ( cast < MDString > ( Op -> getOperand ( <NUM_LIT> ) ) -> getString ( ) ) ) ; getRootMetadata ( <STR_LIT> ) = std :: move (


<s> Version -> push_back ( std :: make_shared < msgpack :: ScalarNode > ( V3 :: VersionMinor ) ) ; getRootMetadata ( <STR_LIT> ) = std :: move


<s> std :: string HSAMetadataString ; raw_string_ostream StrOS ( HSAMetadataString ) ; yaml :: Output YOut ( StrOS ) ; YOut <<


<s> HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = ProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = ProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ; HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ; HSACodeProps . mIsXNACKEnabled = STM . isXNACKEnabled ( ) ; HSACodeProps . mNumSpilledSGPRs = MFI . getNumSpilledSGPRs ( ) ; HSACodeProps . mNumSpilledVGPRs = MFI . getNumSpilledVGPRs ( ) ; return


<s> const GCNSubtarget & STM = MF . getSubtarget < GCNSubtarget > ( ) ; const <ISA_LIT>MachineFunctionInfo & MFI = * MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; HSAMD :: Kernel :: CodeProps :: Metadata HSACodeProps ; const Function & F = MF . getFunction ( ) ; assert ( F . getCallingConv ( ) == CallingConv :: <ISA_LIT>_KERNEL || F . getCallingConv ( ) == CallingConv :: SPIR_KERNEL ) ; unsigned MaxKernArgAlign ; HSACodeProps . mKernargSegmentSize = STM . getKernArgSegmentSize ( F , MaxKernArgAlign ) ; HSACodeProps . mGroupSegmentFixedSize = ProgramInfo . LDSSize ; HSACodeProps . mPrivateSegmentFixedSize = ProgramInfo . ScratchSize ; HSACodeProps . mKernargSegmentAlign = std :: max ( MaxKernArgAlign , <NUM_LIT> ) ; HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = ProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = ProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ; HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ; HSACodeProps . mIsXNACKEnabled = STM


<s> std :: shared_ptr < msgpack :: MapNode > MetadataStreamerV3 :: getHSAKernelProps ( const MachineFunction & MF , const <ISA_LIT>ProgramInfo & ProgramInfo ) const { const GCNSubtarget & STM = MF . getSubtarget < GCNSubtarget > ( ) ; const <ISA_LIT>MachineFunctionInfo & MFI = * MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const Function & F = MF . getFunction ( ) ; auto HSAKernelProps = std :: make_shared < msgpack :: MapNode > ( ) ; auto & Kern = * HSAKernelProps ; unsigned MaxKernArgAlign ; Kern [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( STM . getKernArgSegmentSize ( F , MaxKernArgAlign ) ) ; Kern [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( ProgramInfo . LDSSize ) ; Kern [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( ProgramInfo . ScratchSize ) ; Kern [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode > ( std :: max ( uint32_t ( <NUM_LIT> ) , MaxKernArgAlign ) ) ; Kern [ <STR_LIT> ] = std :: make_shared < msgpack :: ScalarNode >


<s> std :: shared_ptr < msgpack :: ArrayNode > MetadataStreamerV3 :: getWorkGroupDimensions ( MDNode * Node ) const { auto Dims = std :: make_shared < msgpack :: ArrayNode > ( ) ; if ( Node -> getNumOperands ( ) != <NUM_LIT> ) return


<s> std :: shared_ptr < msgpack :: Node > FromHSAMetadataString = std :: make_shared < msgpack :: MapNode > ( ) ; yaml :: Input YIn ( HSAMetadataString ) ; YIn >> FromHSAMetadataString ; if ( YIn . error ( ) ) { errs ( ) << <STR_LIT> ; return ; } std :: string ToHSAMetadataString ; raw_string_ostream StrOS ( ToHSAMetadataString ) ; yaml :: Output YOut ( StrOS ) ; YOut <<


<s> emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; Offset += <NUM_LIT> ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( M -> getNamedMetadata ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; if ( M -> getModuleFlag ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; if ( Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; Offset += <NUM_LIT> ; if ( ST . getGeneration ( ) == <ISA_LIT>Subtarget :: VOLCANIC_ISLANDS ) { emitKernelArg ( DL , Int32Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int32Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; const <ISA_LIT>MachineFunctionInfo & MFI = * MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; if ( MFI . hasQueuePtr ( ) ) emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT>


<s> emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int16Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( M -> getNamedMetadata ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; if ( M -> getModuleFlag ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset += <NUM_LIT> ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; Offset += <NUM_LIT> ; if ( Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else Offset +=


<s> const <ISA_LIT>MachineFunctionInfo & MFI = * MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; const Function & F = MF . getFunction ( ) ; auto Kern = HSAMetadataDoc -> getMapNode ( ) ; unsigned MaxKernArgAlign ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( STM . getKernArgSegmentSize ( F , MaxKernArgAlign ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . LDSSize ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . ScratchSize ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( std :: max ( uint32_t ( <NUM_LIT> ) , MaxKernArgAlign ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( STM . getWavefrontSize ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumSGPR ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumVGPR ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getMaxFlatWorkGroupSize ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getNumSpilledSGPRs ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getNumSpilledVGPRs ( ) ) ; return Kern


<s> if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; else emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; if ( Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; } else { emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int8PtrTy , <STR_LIT> , Offset , Args ) ; } } Kern [ <STR_LIT> ]


<s> emitVersion ( ) ; emitPrintf ( Mod )


<s> auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . getParent ( ) -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenPrintfBuffer ) ; else emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenNone ) ; } if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , ValueKind :: HiddenDefaultQueue ) ; emitKernelArg ( DL , Int8PtrTy ,


<s> auto DebugProps = getHSADebugProps ( MF , ProgramInfo ) ; HSAMetadata . mKernels . push_back ( Kernel :: Metadata ( ) ) ; auto & Kernel = HSAMetadata . mKernels . back ( ) ; Kernel . mName = Func . getName ( ) ; Kernel . mSymbolName = ( Twine ( Func . getName ( ) ) + Twine ( <STR_LIT> ) ) . str ( ) ; emitKernelLanguage ( Func ) ; emitKernelAttrs ( Func ) ; emitKernelArgs ( Func


<s> Arg . mAlign = DL . getABITypeAlignment ( Ty ) ; Arg . mValueKind = ValueKind ; Arg . mValueType = getValueType ( Ty , BaseTypeName ) ; Arg . mPointeeAlign = PointeeAlign ; if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) Arg . mAddrSpaceQual = getAddressSpaceQualifer ( PtrTy -> getAddressSpace ( ) ) ; Arg . mAccQual = getAccessQualifier ( AccQual ) ; SmallVector < StringRef , <NUM_LIT> > SplitTypeQuals ; TypeQual . split ( SplitTypeQuals , <STR_LIT> , - <NUM_LIT> ,


<s> auto & Printf = HSAMetadata . mPrintf ; auto Node = Mod . getNamedMetadata ( <STR_LIT> ) ; if ( ! Node ) return ; for ( auto Op : Node -> operands ( ) ) if ( Op -> getNumOperands ( ) ) Printf . push_back ( cast < MDString > ( Op ->

getOperand ( <NUM_LIT> ) ) -> getString ( ) ) ;


<s> auto & Version = HSAMetadata . mVersion ; Version . push_back ( VersionMajor ) ; Version . push_back ( VersionMinor )


<s> Version . push_back ( VersionMajor ) ; Version . push_back ( VersionMinor


<s> void MetadataStreamer :: end ( ) { std :: string HSAMetadataString ; if ( toString ( HSAMetadata , HSAMetadataString ) ) return ; if ( DumpHSAMetadata ) dump ( HSAMetadataString ) ; if ( VerifyHSAMetadata ) verify (


<s> if ( AddressSpace == <ISA_LIT>AS :: GLOBAL_ADDRESS ) return AddressSpaceQualifier :: Global ; if ( AddressSpace == <ISA_LIT>AS :: CONSTANT_ADDRESS ) return AddressSpaceQualifier :: Constant ; if ( AddressSpace == <ISA_LIT>AS :: LOCAL_ADDRESS ) return AddressSpaceQualifier :: Local ; if ( AddressSpace == <ISA_LIT>AS :: FLAT_ADDRESS ) return AddressSpaceQualifier :: Generic ; if ( AddressSpace == <ISA_LIT>AS :: REGION_ADDRESS ) return AddressSpaceQualifier


<s> HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = ProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = ProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ; HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ; HSACodeProps . mIsXNACKEnabled = STM . isXNACKEnabled ( ) ; HSACodeProps . mNumSpilledSGPRs = MFI . getNumSpilledSGPRs ( ) ; HSACodeProps . mNumSpilledVGPRs = MFI . getNumSpilledVGPRs ( ) ; return HSACodeProps


<s> ValueKind MetadataStreamer :: getValueKind ( Type * Ty , StringRef TypeQual , StringRef BaseTypeName ) const { if ( TypeQual . find ( <STR_LIT> ) != StringRef :: npos ) return ValueKind :: Pipe ; return StringSwitch < ValueKind > ( BaseTypeName ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Image ) . Case ( <STR_LIT> , ValueKind :: Sampler ) . Case ( <STR_LIT> , ValueKind :: Queue ) . Default ( isa < PointerType > ( Ty

) ? ( Ty -> getPointerAddressSpace ( ) == <ISA_LIT>AS :: LOCAL_ADDRESS ? ValueKind :: DynamicSharedPointer :


<s> errs ( ) << <STR_LIT> ; return ; } errs ( ) << ( HSAMetadataString == ToHSAMetadataString ? <STR_LIT> : <STR_LIT> ) << '\n' ; if ( HSAMetadataString != ToHSAMetadataString ) { errs ( ) << <STR_LIT> << HSAMetadataString << '\n' << <STR_LIT> <<


<s> switch ( AddressSpace ) { case <ISA_LIT>AS :: PRIVATE_ADDRESS : return AddressSpaceQualifier :: Private ; case <ISA_LIT>AS :: GLOBAL_ADDRESS : return AddressSpaceQualifier :: Global ; case <ISA_LIT>AS :: CONSTANT_ADDRESS : return AddressSpaceQualifier :: Constant ; case <ISA_LIT>AS :: LOCAL_ADDRESS : return AddressSpaceQualifier :: Local ; case <ISA_LIT>AS :: FLAT_ADDRESS : return AddressSpaceQualifier :: Generic ; case <ISA_LIT>AS :: REGION_ADDRESS


<s> else if ( M -> getModuleFlag ( <STR_LIT> ) ) { assert ( ! M -> getNamedMetadata ( <STR_LIT> ) ) ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( Func . hasFnAttribute ( <STR_LIT> ) ) { emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else


<s> auto Int64Ty = Type :: getInt64Ty ( Func . getContext ( ) ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) emitKernelArg ( DL , Int64Ty , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; auto Int8PtrTy = Type :: getInt8PtrTy ( Func . getContext ( ) , <ISA_LIT>AS :: GLOBAL_ADDRESS ) ; if ( HiddenArgNumBytes >= <NUM_LIT> ) { if ( M -> getNamedMetadata ( <STR_LIT> ) ) emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; else if ( M -> getModuleFlag ( <STR_LIT> ) ) { assert ( ! M -> getNamedMetadata ( <STR_LIT> ) ) ; emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } else emitKernelArg ( DL , Int8PtrTy , Align ( <NUM_LIT> ) , <STR_LIT> , Offset , Args ) ; } if ( HiddenArgNumBytes >= <NUM_LIT>


<s> auto & Func = MF . getFunction ( ) ; auto Kern = getHSAKernelProps ( MF , ProgramInfo ) ; const GCNSubtarget & ST = MF . getSubtarget < GCNSubtarget > ( ) ; assert ( Func . getCallingConv ( ) == CallingConv :: <ISA_LIT>_KERNEL || Func . getCallingConv ( ) == CallingConv :: SPIR_KERNEL ) ; auto Kernels = getRootMetadata ( <STR_LIT> ) . getArray ( true ) ; { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( Func . getName ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ( Twine ( Func . getName ( ) ) + Twine ( <STR_LIT> ) ) .


<s> auto Args = HSAMetadataDoc -> getArrayNode ( ) ; for ( auto & Arg : Func . args ( ) ) emitKernelArg ( Arg , Offset , Args ) ; emitHiddenKernelArgs ( Func , ST , Offset , Args ) ; Kern [ <STR_LIT> ]


<s> if ( Node && ArgNo < Node -> getNumOperands ( ) ) AccQual = cast < MDString > ( Node -> getOperand ( ArgNo ) ) -> getString ( ) ; } StringRef TypeQual ; Node = Func -> getMetadata ( <STR_LIT> ) ; if ( Node && ArgNo < Node -> getNumOperands ( ) ) TypeQual = cast < MDString > ( Node -> getOperand ( ArgNo ) ) -> getString ( ) ; emitKernelArg ( Func -> getParent ( ) -> getDataLayout ( ) , Arg . getType ( ) , getValueKind ( Arg . getType ( ) , TypeQual , BaseTypeName ) , Name , TypeName , BaseTypeName


<s> void MetadataStreamerV3 :: emitKernelArg ( const DataLayout & DL , Type * Ty , StringRef ValueKind , unsigned & Offset , msgpack :: ArrayDocNode Args , MaybeAlign PointeeAlign , StringRef Name , StringRef TypeName , StringRef BaseTypeName , StringRef AccQual , StringRef TypeQual ) { auto Arg = Args . getDocument ( ) -> getMapNode ( ) ; if ( ! Name . empty ( ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( Name , true ) ; if ( ! TypeName . empty ( ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( TypeName , true ) ; auto Size = DL . getTypeAllocSize ( Ty ) ; Align Alignment = DL . getABITypeAlign ( Ty ) ; Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( Size ) ; Offset = alignTo ( Offset , Alignment ) ; Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( Offset ) ; Offset += Size ; Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( ValueKind , true ) ; if ( PointeeAlign ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( PointeeAlign -> value ( ) ) ; if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) if ( auto Qualifier = getAddressSpaceQualifier ( PtrTy -> getAddressSpace ( ) ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( * Qualifier , true ) ; if ( auto AQ = getAccessQualifier ( AccQual ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( * AQ , true ) ; SmallVector < StringRef ,


<s> void MetadataStreamerV3 :: dump ( StringRef HSAMetadataString ) const { errs ( ) << <STR_LIT> << HSAMetadataString


<s> auto Kern = getHSAKernelProps ( MF , ProgramInfo ) ; assert ( Func . getCallingConv ( ) == CallingConv :: <ISA_LIT>_KERNEL || Func . getCallingConv ( ) == CallingConv :: SPIR_KERNEL ) ; auto Kernels = getRootMetadata ( <STR_LIT> ) . getArray ( true ) ; { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( Func . getName ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ( Twine ( Func . getName ( ) ) + Twine ( <STR_LIT> ) ) . str ( ) , true ) ; emitKernelLanguage ( Func , Kern ) ; emitKernelAttrs ( Func


<s> auto & Func = MF . getFunction ( ) ; auto Kern = getHSAKernelProps ( MF , ProgramInfo ) ; assert ( Func . getCallingConv ( ) == CallingConv :: <ISA_LIT>_KERNEL || Func . getCallingConv ( ) == CallingConv :: SPIR_KERNEL ) ; auto Kernels = getRootMetadata ( <STR_LIT> ) . getArray ( true ) ; { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( Func . getName ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ( Twine ( Func . getName ( ) ) + Twine ( <STR_LIT> ) ) . str ( ) , true ) ; emitKernelLanguage ( Func , Kern ) ; emitKernelAttrs ( Func , Kern ) ; emitKernelArgs ( Func ,


<s> if ( PointeeAlign ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( PointeeAlign -> value ( ) ) ; if ( auto PtrTy = dyn_cast < PointerType > ( Ty ) ) if ( auto Qualifier = getAddressSpaceQualifier ( PtrTy -> getAddressSpace ( ) ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( * Qualifier , true ) ; if ( auto AQ = getAccessQualifier ( AccQual ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( * AQ , true ) ; SmallVector < StringRef , <NUM_LIT> > SplitTypeQuals ; TypeQual . split ( SplitTypeQuals , <STR_LIT> , - <NUM_LIT> , false ) ; for ( StringRef Key : SplitTypeQuals ) { if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( true ) ; else if ( Key == <STR_LIT> ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode (


<s> if ( ! Name . empty ( ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( Name , true ) ; if ( ! TypeName . empty ( ) ) Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( TypeName , true ) ; auto Size = DL . getTypeAllocSize ( Ty ) ; Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( Size ) ; Offset = alignTo ( Offset , Alignment ) ; Arg [ <STR_LIT> ] = Arg . getDocument ( ) -> getNode ( Offset ) ; Offset += Size ; Arg [ <STR_LIT> ] = Arg . getDocument ( )


<s> void MetadataStreamerV3 :: emitKernelArgs ( const Function & Func , msgpack :: MapDocNode Kern ) { unsigned Offset = <NUM_LIT>


<s> void MetadataStreamerV3 :: emitKernelArgs ( const Function & Func , msgpack :: MapDocNode Kern ) { unsigned Offset = <NUM_LIT> ; auto Args = HSAMetadataDoc -> getArrayNode ( ) ; for ( auto & Arg : Func . args ( ) ) emitKernelArg ( Arg , Offset , Args ) ; emitHiddenKernelArgs ( Func , Offset , Args ) ; Kern [ <STR_LIT> ]


<s> if ( auto Node = Func . getMetadata ( <STR_LIT> ) ) { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( getTypeName ( cast < ValueAsMetadata > ( Node -> getOperand ( <NUM_LIT> ) ) -> getType ( ) , mdconst :: extract < ConstantInt > ( Node -> getOperand ( <NUM_LIT> ) ) -> getZExtValue ( ) ) , true ) ; } if ( Func . hasFnAttribute ( <STR_LIT> ) ) { Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( Func . getFnAttribute ( <STR_LIT> ) . getValueAsString ( ) . str ( ) , true ) ; } if ( Func . hasFnAttribute ( <STR_LIT> ) ) Kern [ <STR_LIT> ] = Kern . getDocument


<s> if ( Op0 -> getNumOperands ( ) <= <NUM_LIT> ) return ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( <STR_LIT> ) ; auto LanguageVersion = Kern . getDocument ( ) -> getArrayNode ( ) ; LanguageVersion . push_back ( Kern . getDocument ( ) -> getNode ( mdconst :: extract < ConstantInt > ( Op0 -> getOperand ( <NUM_LIT> )


<s> Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( <STR_LIT> ) ; auto LanguageVersion = Kern . getDocument ( ) -> getArrayNode ( ) ; LanguageVersion . push_back ( Kern . getDocument ( ) -> getNode ( mdconst :: extract < ConstantInt > ( Op0 -> getOperand ( <NUM_LIT> ) ) -> getZExtValue ( ) ) ) ; LanguageVersion . push_back ( Kern . getDocument ( ) -> getNode ( mdconst :: extract < ConstantInt > ( Op0 -> getOperand ( <NUM_LIT> ) ) -> getZExtValue ( ) ) ) ; Kern [ <STR_LIT> ] =


<s> for ( auto Op : Node -> operands ( ) ) if ( Op -> getNumOperands ( ) ) Printf . push_back ( Printf . getDocument ( ) -> getNode (

cast < MDString > ( Op -> getOperand ( <NUM_LIT> ) ) -> getString ( ) , true ) ) ;


<s> void MetadataStreamerV4 :: emitTargetID ( const IsaInfo :: <ISA_LIT>TargetID &


<s> auto Version = HSAMetadataDoc -> getArrayNode ( ) ; Version . push_back ( Version . getDocument ( ) -> getNode (


<s> Optional < StringRef > MetadataStreamerV3 :: getAddressSpaceQualifier ( unsigned AddressSpace ) const { switch ( AddressSpace ) { case <ISA_LIT>AS :: PRIVATE_ADDRESS : return StringRef ( <STR_LIT> ) ; case <ISA_LIT>AS :: GLOBAL_ADDRESS : return StringRef ( <STR_LIT> ) ; case <ISA_LIT>AS :: CONSTANT_ADDRESS : return StringRef ( <STR_LIT> ) ; case <ISA_LIT>AS :: LOCAL_ADDRESS : return StringRef ( <STR_LIT> ) ; case <ISA_LIT>AS :: FLAT_ADDRESS : return StringRef ( <STR_LIT> ) ; case <ISA_LIT>AS ::


<s> HSAMD :: Kernel :: CodeProps :: Metadata HSACodeProps ; const Function & F = MF . getFunction ( ) ; assert ( F . getCallingConv ( ) == CallingConv :: <ISA_LIT>_KERNEL || F . getCallingConv ( ) == CallingConv :: SPIR_KERNEL ) ; Align MaxKernArgAlign ; HSACodeProps . mKernargSegmentSize = STM . getKernArgSegmentSize ( F , MaxKernArgAlign ) ; HSACodeProps . mGroupSegmentFixedSize = ProgramInfo . LDSSize ; HSACodeProps . mPrivateSegmentFixedSize = ProgramInfo . ScratchSize ; HSACodeProps . mKernargSegmentAlign = std :: max ( MaxKernArgAlign , Align ( <NUM_LIT> ) ) . value ( ) ; HSACodeProps . mWavefrontSize = STM . getWavefrontSize ( ) ; HSACodeProps . mNumSGPRs = ProgramInfo . NumSGPR ; HSACodeProps . mNumVGPRs = ProgramInfo . NumVGPR ; HSACodeProps . mMaxFlatWorkGroupSize = MFI . getMaxFlatWorkGroupSize ( ) ; HSACodeProps . mIsDynamicCallStack = ProgramInfo . DynamicCallStack ; HSACodeProps . mIsXNACKEnabled = STM . isXNACKEnabled ( ) ; HSACodeProps . mNumSpilledSGPRs = MFI . getNumSpilledSGPRs ( ) ; HSACodeProps . mNumSpilledVGPRs = MFI . getNumSpilledVGPRs ( ) ; return HSACodeProps


<s> return HSAMD :: Kernel :: DebugProps ::


<s> Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . LDSSize ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . ScratchSize ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( std :: max ( Align ( <NUM_LIT> ) , MaxKernArgAlign ) . value ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( STM . getWavefrontSize ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumSGPR ) ; Kern [ <STR_LIT> ] = Kern . getDocument (

) -> getNode ( ProgramInfo . NumVGPR ) ;


<s> Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumSGPR ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( ProgramInfo . NumVGPR ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getMaxFlatWorkGroupSize ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getNumSpilledSGPRs ( ) ) ; Kern [ <STR_LIT> ] = Kern . getDocument ( ) -> getNode ( MFI . getNumSpilledVGPRs ( ) ) ; return


<s> msgpack :: DocNode & getRootMetadata ( StringRef


<s> msgpack :: DocNode & getRootMetadata ( StringRef Key ) { return HSAMetadataDoc -> getRoot ( ) . getMap ( true ) [


<s> case Type :: IntegerTyID : { if ( ! Signed ) return ( Twine ( 'u' ) + getTypeName ( Ty , true ) ) . str ( ) ; auto BitWidth = Ty -> getIntegerBitWidth ( ) ; switch ( BitWidth ) { case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return


<s> auto Dims = HSAMetadataDoc -> getArrayNode ( ) ; if ( Node -> getNumOperands ( ) != <NUM_LIT> ) return Dims ; for ( auto & Op : Node -> operands ( ) ) Dims . push_back ( Dims . getDocument ( ) -> getNode ( uint64_t ( mdconst :: extract < ConstantInt


<s> raw_string_ostream StrOS ( ToHSAMetadataString ) ; FromHSAMetadataString . toYAML ( StrOS ) ; errs ( ) << ( HSAMetadataString == StrOS . str ( ) ? <STR_LIT>


<s> TargetLoweringObjectFileELF :: Initialize ( Ctx , TM ) ; InitializeELF ( TM . Options . UseInitArray


<s> MCSection * <ISA_LIT>HSATargetObjectFile :: SelectSectionForGlobal ( const GlobalValue * GV , SectionKind Kind , Mangler & Mang , const TargetMachine & TM ) const { if ( Kind . isText ( ) && ! GV -> hasComdat ( ) ) return getTextSection ( ) ; return TargetLoweringObjectFileELF :: SelectSectionForGlobal ( GV , Kind , Mang ,


<s> if ( CS . isNoInline ( ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; TargetTransformInfo & TTI = TTIWP -> getTTI ( * Callee ) ; if ( ! TTI . areInlineCompatible ( Caller , Callee ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( CS . hasFnAttr ( Attribute :: AlwaysInline ) ) { auto IsViable = isInlineViable ( * Callee ) ; if ( IsViable . isSuccess ( ) ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; return llvm :: InlineCost :: getNever ( IsViable . getFailureReason ( ) ) ; } if ( isWrapperOnlyCall ( CS ) ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; InlineParams LocalParams = Params ; LocalParams . DefaultThreshold = ( int ) getInlineThreshold ( CS ) ; bool RemarksEnabled = false ; const auto & BBs = Caller ->


<s> bool RemarksEnabled = false ; const auto & BBs = Caller -> getBasicBlockList ( ) ; if ( ! BBs . empty ( ) ) { auto DI = OptimizationRemark ( DEBUG_TYPE , <STR_LIT> , DebugLoc ( ) , & BBs . front ( ) ) ; if ( DI . isEnabled ( ) ) RemarksEnabled = true ; } OptimizationRemarkEmitter ORE ( Caller ) ; std :: function < AssumptionCache & ( Function & ) > GetAssumptionCache = [ this ] ( Function & F ) -> AssumptionCache & { return ACT -> getAssumptionCache ( F ) ; } ; auto IC = llvm :: getInlineCost ( CB , Callee , LocalParams , TTI , GetAssumptionCache , None , GetTLI , P<ISA_LIT> , RemarksEnabled ? & ORE : nullptr ) ; if ( IC && ! IC . isAlways ( ) && ! Callee -> hasFnAttribute ( Attribute :: InlineHint ) ) { size_t Size = Caller -> size ( ) + Callee -> size ( ) - <NUM_LIT> ; if ( MaxBB && Size > MaxBB ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; } return IC


<s> Function * Caller = CB . getCaller ( ) ; Function * Callee = CB . getCalledFunction ( ) ; bool InlineHint = Callee && ! Callee -> isDeclaration ( ) && Callee -> hasFnAttribute ( Attribute :: InlineHint ) ; if ( InlineHint && Params . HintThreshold && Params . HintThreshold > Thres && ! Caller -> hasFnAttribute ( Attribute :: MinSize ) ) Thres = Params . HintThreshold . getValue ( ) * TTIWP -> getTTI ( * Callee ) . getInliningThresholdMultiplier ( ) ; const DataLayout & DL = Caller -> getParent ( ) -> getDataLayout ( ) ; if ( ! Callee ) return ( unsigned ) Thres ; uint64_t AllocaSize = <NUM_LIT> ; SmallPtrSet < const AllocaInst * , <NUM_LIT> > AIVisited ; for ( Value * PtrArg : CB . args ( ) ) { PointerType * Ty = dyn_cast < PointerType > ( PtrArg -> getType ( ) ) ; if ( ! Ty || ( Ty -> getAddressSpace ( ) != <ISA_LIT>AS :: PRIVATE_ADDRESS && Ty -> getAddressSpace ( ) != <ISA_LIT>AS


<s> Function * Callee = CB . getCalledFunction ( ) ; if ( ! Callee || Callee -> size ( ) != <NUM_LIT> ) return false ; const BasicBlock & BB = Callee


<s> Function * Callee = CB . getCalledFunction ( ) ; if ( ! Callee || Callee -> size ( ) != <NUM_LIT> ) return false ; const BasicBlock & BB = Callee -> getEntryBlock ( ) ; if ( const Instruction * I = BB . getFirstNonPHI ( ) ) { if ( ! isa < CallInst > (


<s> Function * Callee = CS . getCalledFunction ( ) ; Function * Caller = CS . getCaller ( ) ; TargetTransformInfo & TTI = TTIWP -> getTTI ( * Callee ) ; if ( ! Callee || Callee -> isDeclaration ( ) || CS . isNoInline ( ) || ! TTI . areInlineCompatible ( Caller , Callee ) ) return llvm :: InlineCost :: getNever ( ) ; if ( CS . hasFnAttr ( Attribute :: AlwaysInline ) ) { if ( isInlineViable ( * Callee ) ) return llvm :: InlineCost :: getAlways ( ) ; return llvm :: InlineCost :: getNever ( ) ; } if ( isWrapperOnlyCall ( CS ) ) return llvm :: InlineCost :: getAlways ( ) ; InlineParams LocalParams = Params ; LocalParams . DefaultThreshold = ( int ) getInlineThreshold ( CS ) ; bool RemarksEnabled = false ; const auto & BBs = Caller -> getBasicBlockList ( ) ; if ( ! BBs . empty ( ) ) { auto DI = OptimizationRemark ( DEBUG_TYPE , <STR_LIT> , DebugLoc ( ) , & BBs . front ( ) ) ; if ( DI . isEnabled ( ) ) RemarksEnabled = true ; } OptimizationRemarkEmitter ORE ( Caller )


<s> Function * Caller = CS . getCaller ( ) ; Function * Callee = CS . getCalledFunction ( ) ; bool InlineHint = Callee && ! Callee -> isDeclaration ( ) && Callee -> hasFnAttribute ( Attribute :: InlineHint ) ; if ( InlineHint && Params . HintThreshold && Params . HintThreshold > Thres && ! Caller -> hasFnAttribute ( Attribute :: MinSize ) ) Thres = Params . HintThreshold . getValue ( ) ; const DataLayout & DL = Caller -> getParent ( ) -> getDataLayout ( ) ; if ( ! Callee ) return ( unsigned ) Thres ; const <ISA_LIT>AS AS = <STR_LIT> ( * Caller -> getParent


<s> Function * Callee = CS . getCalledFunction ( ) ; Function * Caller = CS . getCaller ( ) ; if ( ! Callee || Callee -> isDeclaration ( ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( CS . isNoInline ( ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; TargetTransformInfo & TTI = TTIWP -> getTTI ( * Callee ) ; if ( ! TTI . areInlineCompatible ( Caller , Callee ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( CS . hasFnAttr ( Attribute :: AlwaysInline ) ) { auto IsViable = isInlineViable ( * Callee ) ; if ( IsViable ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; return llvm :: InlineCost :: getNever ( IsViable . message ) ; } if ( isWrapperOnlyCall ( CS ) ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; InlineParams LocalParams = Params ; LocalParams . DefaultThreshold = ( int ) getInlineThreshold ( CS ) ; bool RemarksEnabled = false ; const auto & BBs = Caller -> getBasicBlockList ( ) ; if ( ! BBs .


<s> Function * Caller = CS . getCaller ( ) ; if ( ! Callee || Callee -> isDeclaration ( ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( CS . isNoInline ( ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; TargetTransformInfo & TTI = TTIWP -> getTTI ( * Callee ) ; if ( ! TTI . areInlineCompatible ( Caller , Callee ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( CS . hasFnAttr ( Attribute :: AlwaysInline ) ) { auto IsViable = isInlineViable ( * Callee ) ; if ( IsViable . isSuccess ( ) ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; return llvm :: InlineCost :: getNever ( IsViable . getFailureReason ( ) ) ; } if ( isWrapperOnlyCall ( CS ) ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; InlineParams LocalParams = Params


<s> InlineParams LocalParams = Params ; LocalParams . DefaultThreshold = ( int ) getInlineThreshold ( CB ) ; bool RemarksEnabled = false ; const auto & BBs = Caller -> getBasicBlockList ( ) ; if ( ! BBs . empty ( ) ) { auto DI = OptimizationRemark ( DEBUG_TYPE , <STR_LIT> , DebugLoc ( ) , & BBs . front ( ) ) ; if ( DI . isEnabled ( ) ) RemarksEnabled = true ; } OptimizationRemarkEmitter ORE ( Caller ) ; auto GetAssumptionCache = [ this ] ( Function & F ) -> AssumptionCache & { return ACT -> getAssumptionCache ( F ) ; } ; auto IC = llvm :: getInlineCost ( CB , Callee , LocalParams , TTI , GetAssumptionCache , GetTLI , nullptr , P<ISA_LIT> , RemarksEnabled ? & ORE : nullptr ) ; if ( IC && ! IC . isAlways ( ) && ! Callee -> hasFnAttribute ( Attribute :: InlineHint ) ) { size_t Size = Caller -> size ( ) + Callee -> size ( ) - <NUM_LIT> ; if ( MaxBB && Size > MaxBB ) return llvm :: InlineCost


<s> return llvm :: InlineCost :: getNever ( IsViable . getFailureReason ( ) ) ; } if ( isWrapperOnlyCall ( CB ) ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; InlineParams LocalParams = Params ; LocalParams . DefaultThreshold = ( int ) getInlineThreshold ( CB ) ; bool RemarksEnabled = false ; const auto & BBs = Caller -> getBasicBlockList ( ) ; if ( ! BBs . empty ( ) ) { auto DI = OptimizationRemark ( DEBUG_TYPE , <STR_LIT> , DebugLoc ( ) , & BBs . front ( ) ) ; if ( DI . isEnabled ( ) ) RemarksEnabled = true ; } OptimizationRemarkEmitter ORE ( Caller ) ; auto GetAssumptionCache = [ this ] ( Function & F ) -> AssumptionCache & { return ACT -> getAssumptionCache ( F ) ; } ; auto IC = llvm :: getInlineCost ( CB , Callee , LocalParams , TTI , GetAssumptionCache , GetTLI , nullptr , P<ISA_LIT> , RemarksEnabled ? & ORE : nullptr ) ; if ( IC && ! IC . isAlways ( ) && ! Callee -> hasFnAttribute ( Attribute :: InlineHint ) ) { size_t Size = Caller -> size ( ) + Callee -> size ( )


<s> if ( ! Callee ) return ( unsigned ) Thres ; uint64_t AllocaSize = <NUM_LIT> ; SmallPtrSet < const AllocaInst * , <NUM_LIT> > AIVisited ; for ( Value * PtrArg : CB . args ( ) ) { PointerType * Ty = dyn_cast < PointerType > ( PtrArg -> getType ( ) ) ; if ( ! Ty || ( Ty -> getAddressSpace ( ) != <ISA_LIT>AS :: PRIVATE_ADDRESS && Ty -> getAddressSpace ( ) != <ISA_LIT>AS :: FLAT_ADDRESS ) ) continue ; PtrArg = getUnderlyingObject ( PtrArg ) ; if ( const AllocaInst * AI = dyn_cast < AllocaInst > ( PtrArg ) ) { if ( ! AI -> isStaticAlloca ( ) || ! AIVisited . insert ( AI ) . second ) continue ; AllocaSize += DL . getTypeAllocSize ( AI -> getAllocatedType ( ) ) ; if ( AllocaSize > ArgAllocaCutoff ) { AllocaSize =


<s> if ( ! Callee || Callee -> isDeclaration ( ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( CS . isNoInline ( ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( ! TTI . areInlineCompatible ( Caller , Callee ) ) return llvm :: InlineCost :: getNever ( <STR_LIT> ) ; if ( CS . hasFnAttr ( Attribute :: AlwaysInline ) ) { auto IsViable = isInlineViable ( * Callee ) ; if ( IsViable ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; return llvm :: InlineCost :: getNever ( IsViable . message ) ; } if ( isWrapperOnlyCall ( CS ) ) return llvm :: InlineCost :: getAlways ( <STR_LIT> ) ; InlineParams LocalParams = Params ; LocalParams . DefaultThreshold = ( int ) getInlineThreshold ( CS ) ; bool RemarksEnabled = false ; const auto & BBs = Caller -> getBasicBlockList ( ) ; if ( ! BBs . empty (


<s> initialize<ISA_LIT>InlinerPass ( * PassRegistry :: getPassRegistry ( ) ) ; Params = getInlineParams (


<s> Pass * llvm :: create<ISA_LIT>FunctionInliningPass


<s> void <ISA_LIT>Inliner :: getAnalysisUsage ( AnalysisUsage & AU ) const { AU . addRequired < TargetTransformInfoWrapperPass > ( ) ; LegacyInlinerBase :: getAnalysisUsage (


<s> const DataLayout & DL = Caller -> getParent ( ) -> getDataLayout ( ) ; if ( ! Callee ) return ( unsigned ) Thres ; uint64_t AllocaSize = <NUM_LIT> ; SmallPtrSet < const AllocaInst * , <NUM_LIT> > AIVisited ; for ( Value * PtrArg : CS . args ( ) ) { Type * Ty = PtrArg -> getType ( ) ; if ( ! Ty -> isPointerTy ( ) || Ty -> getPointerAddressSpace ( ) != <ISA_LIT>AS :: PRIVATE_ADDRESS ) continue ; PtrArg = GetUnderlyingObject ( PtrArg ,


<s> } } else { if ( ConstantInt * ConstInt = dyn_cast < ConstantInt > ( & V ) ) { APInt IntValue ( ConstInt -> getValue ( ) ) ; return IntValue . getActiveBits ( ) <= <NUM_LIT> ; } } Value * CastSrc ; bool IsExt = IsFloat ? match ( & V , m_FPExt ( PatternMatch :: m_Value ( CastSrc ) ) ) : match ( & V , m_ZExt ( PatternMatch :: m_Value ( CastSrc ) ) ) ; if ( IsExt ) { Type * CastSrcTy = CastSrc


<s> return true ; } auto * TLI = & IC . getTargetLibraryInfo ( ) ; if ( isKnownNeverInfinity ( Op0 , TLI ) && isKnownNeverNaN ( Op0 , TLI ) && isKnownNeverInfinity ( Op1 , TLI ) && isKnownNeverNaN ( Op1 , TLI ) ) { return true ; } return


<s> auto * TLI = & IC . getTargetLibraryInfo ( ) ; if ( isKnownNeverInfinity ( Op0 , TLI ) && isKnownNeverNaN ( Op0 , TLI ) && isKnownNeverInfinity ( Op1 , TLI ) && isKnownNeverNaN ( Op1 , TLI ) ) { return true


<s> if ( VTy -> isIntegerTy ( ) ) return Builder . CreateIntCast ( & V , Type :: getInt16Ty ( V . getContext ( ) ) , false ) ; if ( VTy -> isFloatingPointTy ( ) ) return Builder . CreateFPCast ( & V , Type :: getHalfTy ( V . getContext ( ) ) ) ; llvm_unreachable (


<s> if ( Cmp0 == APFloat :: cmpEqual ) return maxnum ( Src1 , Src2 ) ; APFloat :: cmpResult Cmp1 = Max3 . compare ( Src1 ) ; assert ( Cmp1 != APFloat :: cmpUnordered && <STR_LIT> ) ; if ( Cmp1 == APFloat :: cmpEqual ) return maxnum ( Src0 , Src2 ) ; return maxnum ( Src0 ,


<s> SmallVector < Value * , <NUM_LIT> > Args ( OldIntr . args ( ) ) ; Func ( Args , ArgTys ) ; Function * I = <STR_LIT> ( OldIntr . getModule ( ) , NewIntr , ArgTys ) ; CallInst * NewCall = IC . Builder . CreateCall ( I , Args ) ; NewCall -> takeName ( & OldIntr ) ; NewCall -> copyMetadata ( OldIntr ) ; if ( isa < FPMathOperator > ( NewCall ) ) NewCall


<s> break ; default : OffsetIdx = InvalidOffsetIdx ; break ; } if ( OffsetIdx != InvalidOffsetIdx ) { DemandedElts &= ~ ( ( <NUM_LIT> << UnusedComponentsAtFront ) - <NUM_LIT> ) ; auto * Offset = II . getArgOperand ( OffsetIdx ) ; unsigned SingleComponentSizeInBits = IC . getDataLayout ( ) . getTypeSizeInBits ( II . getType ( ) -> getScalarType ( ) ) ; unsigned OffsetAdd = UnusedComponentsAtFront * SingleComponentSizeInBits / <NUM_LIT> ; auto * OffsetAddVal = ConstantInt :: get ( Offset -> getType ( ) , OffsetAdd ) ; Args [ OffsetIdx ] = IC . Builder . CreateAdd ( Offset , OffsetAddVal ) ; } } } else { ConstantInt * DMask = cast < ConstantInt > ( II . getArgOperand ( DMaskIdx ) ) ; unsigned DMaskVal = DMask -> getZExtValue ( ) & <NUM_LIT> ; DemandedElts &= ( <NUM_LIT> << countPopulation ( DMaskVal ) ) - <NUM_LIT> ; unsigned NewDMaskVal = <NUM_LIT> ; unsigned OrigLoadIdx = <NUM_LIT> ; for ( unsigned SrcIdx = <NUM_LIT> ; SrcIdx < <NUM_LIT> ; ++ SrcIdx ) { const unsigned Bit = <NUM_LIT> << SrcIdx ; if ( ! ! ( DMaskVal & Bit ) ) { if ( ! ! DemandedElts [ OrigLoadIdx ] ) NewDMaskVal |= Bit ; OrigLoadIdx ++ ; } } if ( DMaskVal != NewDMaskVal ) Args [ DMaskIdx ] = ConstantInt :: get ( DMask -> getType ( ) , NewDMaskVal ) ; } unsigned NewNumElts = DemandedElts . countPopulation ( ) ; if ( ! NewNumElts ) return UndefValue :: get ( II . getType ( ) ) ; if ( NewNumElts >= VWidth && DemandedElts . isMask ( ) ) { if ( DMaskIdx >= <NUM_LIT> ) II . setArgOperand (


<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 simplifyAMDGCNMemoryIntrinsicDemanded ( IC , II , DemandedElts ) ; default : { if ( get<ISA_LIT>ImageDMaskIntrinsic ( II . getIntrinsicID (


<s> static Optional < Instruction * > simplifyAMDGCNImageIntrinsic ( const GCNSubtarget * ST , const <STR_LIT> * ImageDimIntr , IntrinsicInst & II , InstCombiner & IC ) { if ( ! ST -> hasA16 ( ) && ! ST -> hasG16 ( ) ) return None ; bool FloatCoord = false ; bool OnlyDerivatives = false ; for ( unsigned OperandIndex = ImageDimIntr -> GradientStart ; OperandIndex < ImageDimIntr -> VAddrEnd ; OperandIndex ++ ) { Value * Coord = II . getOperand ( OperandIndex ) ; if ( ! canSafelyConvertTo16Bit ( * Coord ) ) { if ( OperandIndex < ImageDimIntr -> CoordStart || ImageDimIntr -> GradientStart == ImageDimIntr -> CoordStart ) { return None ; } OnlyDerivatives = true ; break ; } assert ( OperandIndex == ImageDimIntr -> GradientStart || FloatCoord == Coord -> getType ( ) -> isFloatingPointTy ( ) ) ; FloatCoord = Coord -> getType ( ) -> isFloatingPointTy ( ) ; } if ( OnlyDerivatives ) { if ( ! ST -> hasG16 ( ) ) return None ; }


<s> Function * I = <STR_LIT> ( II . getModule ( ) , NewIntr , ArgTys ) ; CallInst * NewCall = IC . Builder . CreateCall ( I , Args ) ; NewCall -> takeName ( & II ) ; NewCall -> copyMetadata ( II ) ; if ( isa < FPMathOperator > ( NewCall ) ) NewCall -> copyFastMathFlags ( & II ) ; if ( ! II . getType ( ) -> isVoidTy ( ) ) IC . replaceInstUsesWith ( II , NewCall ) ; return IC . eraseInstFromFunction ( II )


<s> break ; } if ( OffsetIdx != InvalidOffsetIdx ) { DemandedElts &= ~ ( ( <NUM_LIT> << UnusedComponentsAtFront ) - <NUM_LIT> ) ; auto * Offset = II . getArgOperand ( OffsetIdx ) ; unsigned SingleComponentSizeInBits = IC . getDataLayout ( ) . getTypeSizeInBits ( II . getType ( ) -> getScalarType ( ) ) ; unsigned OffsetAdd = UnusedComponentsAtFront * SingleComponentSizeInBits / <NUM_LIT> ; auto * OffsetAddVal = ConstantInt :: get ( Offset -> getType ( ) , OffsetAdd ) ; Args [ OffsetIdx ] = IC . Builder . CreateAdd ( Offset , OffsetAddVal ) ; } } } else { ConstantInt * DMask = cast < ConstantInt > ( II . getArgOperand ( DMaskIdx ) ) ; unsigned DMaskVal = DMask -> getZExtValue ( ) & <NUM_LIT> ; DemandedElts &= ( <NUM_LIT> << countPopulation ( DMaskVal ) ) - <NUM_LIT> ; unsigned NewDMaskVal = <NUM_LIT> ; unsigned OrigLoadIdx = <NUM_LIT> ; for ( unsigned SrcIdx = <NUM_LIT> ; SrcIdx < <NUM_LIT> ; ++ SrcIdx ) { const unsigned Bit = <NUM_LIT> << SrcIdx ; if ( ! ! ( DMaskVal & Bit ) ) { if ( ! ! DemandedElts [ OrigLoadIdx ] ) NewDMaskVal |= Bit ; OrigLoadIdx ++ ; } } if ( DMaskVal != NewDMaskVal ) Args [ DMaskIdx ] = ConstantInt :: get ( DMask -> getType ( ) , NewDMaskVal ) ; } unsigned NewNumElts = DemandedElts . countPopulation ( ) ; if ( ! NewNumElts ) return UndefValue :: get ( II . getType ( ) ) ; if ( NewNumElts >= VWidth && DemandedElts . isMask ( ) ) { if ( DMaskIdx >= <NUM_LIT> ) II . setArgOperand ( DMaskIdx , Args [ DMaskIdx ] ) ; return nullptr ; } SmallVector < Type * , <NUM_LIT> > OverloadTys ; if ( ! <STR_LIT> ( II . getCalledFunction ( )


<s> unsigned NewDMaskVal = <NUM_LIT> ; unsigned OrigLoadIdx = <NUM_LIT> ; for ( unsigned SrcIdx = <NUM_LIT> ; SrcIdx < <NUM_LIT> ; ++ SrcIdx ) { const unsigned Bit = <NUM_LIT> << SrcIdx ; if ( ! ! ( DMaskVal & Bit ) ) { if ( ! ! DemandedElts [ OrigLoadIdx ] ) NewDMaskVal |= Bit ; OrigLoadIdx ++ ; } } if ( DMaskVal != NewDMaskVal ) Args [ DMaskIdx ] = ConstantInt :: get ( DMask -> getType ( ) , NewDMaskVal ) ; } unsigned NewNumElts = DemandedElts . countPopulation ( ) ; if ( ! NewNumElts ) return UndefValue :: get ( II . getType ( ) ) ; if ( II . getType ( ) -> getScalarSizeInBits ( ) == <NUM_LIT> && NewNumElts == <NUM_LIT> ) return nullptr ; if ( NewNumElts >= VWidth && DemandedElts . isMask ( ) ) { if ( DMaskIdx >= <NUM_LIT> ) II . setArgOperand ( DMaskIdx , Args [ DMaskIdx ] ) ; return nullptr ; } SmallVector < Type * , <NUM_LIT> > OverloadTys ; if ( ! <STR_LIT> ( II . getCalledFunction ( ) , OverloadTys ) ) return nullptr ; Module * M = II . getParent ( ) -> getParent ( ) -> getParent ( ) ; Type * EltTy = IIVTy -> getElementType ( ) ; Type * NewTy = ( NewNumElts == <NUM_LIT> ) ? EltTy : FixedVectorType :: get ( EltTy , NewNumElts ) ; OverloadTys [ <NUM_LIT> ] = NewTy ; Function * NewIntrin = <STR_LIT> ( M , II . getIntrinsicID ( ) , OverloadTys


<s> OffsetIdx = <NUM_LIT> ; break ; case <STR_LIT> : if ( ActiveBits == <NUM_LIT> && UnusedComponentsAtFront == <NUM_LIT> ) OffsetIdx = InvalidOffsetIdx ; else OffsetIdx = <NUM_LIT> ; break ; case <STR_LIT> : OffsetIdx = <NUM_LIT> ; break ; default : OffsetIdx = InvalidOffsetIdx ; break ; } if ( OffsetIdx != InvalidOffsetIdx ) { DemandedElts &= ~ ( ( <NUM_LIT> << UnusedComponentsAtFront ) - <NUM_LIT> ) ; auto * Offset = II . getArgOperand ( OffsetIdx ) ; unsigned SingleComponentSizeInBits = IC . getDataLayout ( ) . getTypeSizeInBits ( II . getType ( ) -> getScalarType ( ) ) ; unsigned OffsetAdd = UnusedComponentsAtFront * SingleComponentSizeInBits / <NUM_LIT> ; auto * OffsetAddVal = ConstantInt :: get ( Offset -> getType ( ) , OffsetAdd ) ; Args [ OffsetIdx ] = IC . Builder . CreateAdd ( Offset , OffsetAddVal ) ; } } } else { ConstantInt * DMask = cast < ConstantInt > ( II . getArgOperand ( DMaskIdx ) ) ; unsigned DMaskVal = DMask -> getZExtValue ( ) & <NUM_LIT> ; DemandedElts &= ( <NUM_LIT> << countPopulation ( DMaskVal ) ) - <NUM_LIT> ; unsigned NewDMaskVal = <NUM_LIT> ; unsigned OrigLoadIdx = <NUM_LIT> ; for ( unsigned SrcIdx = <NUM_LIT> ; SrcIdx < <NUM_LIT> ; ++ SrcIdx ) { const unsigned Bit = <NUM_LIT> << SrcIdx ; if ( ! ! ( DMaskVal & Bit ) ) { if ( ! ! DemandedElts [ OrigLoadIdx ] ) NewDMaskVal |= Bit ; OrigLoadIdx ++ ; } } if ( DMaskVal != NewDMaskVal ) Args [ DMaskIdx ] = ConstantInt :: get ( DMask -> getType ( ) , NewDMaskVal ) ; } unsigned NewNumElts = DemandedElts . countPopulation ( ) ; if ( ! NewNumElts ) return UndefValue :: get ( II . getType ( ) ) ; if ( II . getType ( ) -> getScalarSizeInBits ( ) == <NUM_LIT> && NewNumElts == <NUM_LIT> ) return nullptr ; if ( NewNumElts >= VWidth && DemandedElts . isMask ( ) ) { if ( DMaskIdx >= <NUM_LIT> ) II . setArgOperand ( DMaskIdx , Args [ DMaskIdx ] ) ; return nullptr ; } SmallVector < Type * ,


<s> Value * convertTo16Bit ( Value & V , InstCombiner :: BuilderTy & Builder ) { Type * VTy = V . getType ( ) ; if ( isa < FPExtInst > ( & V ) || isa < SExtInst > ( & V ) || isa < ZExtInst > ( & V ) ) return cast < Instruction > ( & V ) -> getOperand ( <NUM_LIT> ) ; if ( VTy -> isIntegerTy ( ) ) return Builder . CreateIntCast ( & V , Type :: getInt16Ty ( V . getContext ( ) ) , false ) ; if ( VTy -> isFloatingPointTy ( ) ) return Builder . CreateFPCast ( & V

, Type :: getHalfTy ( V . getContext ( ) ) ) ;


<s> if ( VTy -> isIntegerTy ( ) ) return Builder . CreateIntCast ( & V , Type :: getInt16Ty ( V . getContext ( ) ) , false ) ; if ( VTy -> isFloatingPointTy ( ) ) return Builder . CreateFPCast ( & V , Type :: getHalfTy


<s> } if ( OnlyDerivatives ) { if ( ! ST -> hasG16 ( ) ) return None ; } else { if ( ! ST -> hasA16 ( ) ) OnlyDerivatives = true ; } Type * CoordType = FloatCoord ? Type :: getHalfTy ( II . getContext ( ) ) : Type :: getInt16Ty ( II . getContext ( ) ) ; SmallVector < Type * , <NUM_LIT> > ArgTys ; if ( ! <STR_LIT> ( II . getCalledFunction ( ) , ArgTys ) ) return None ; ArgTys [ ImageDimIntr -> GradientTyArg ] = CoordType ; if ( ! OnlyDerivatives ) ArgTys [ ImageDimIntr -> CoordTyArg ] = CoordType ; Function * I = <STR_LIT> ( II . getModule ( ) , II . getIntrinsicID ( ) , ArgTys ) ; SmallVector < Value * , <NUM_LIT> > Args


<s> void <ISA_LIT>InstPrinter :: printDA ( const MCInst * MI , unsigned OpNo ,


<s> } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( Imm == <NUM_LIT> ) { O <<


<s> } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT>


<s> printNamedBit ( MI , OpNo , O , <STR_LIT>


<s> void <ISA_LIT>InstPrinter :: printGDS ( const MCInst * MI , unsigned


<s> void <ISA_LIT>InstPrinter :: printGLC ( const MCInst * MI , unsigned OpNo , raw_ostream & O ) { printNamedBit ( MI , OpNo , O ,


<s> int64_t <ISA_LIT>mm = static_cast < int64_t > ( Imm ) ; if ( <ISA_LIT>mm >= - <NUM_LIT> && <ISA_LIT>mm <= <NUM_LIT> ) { O << <ISA_LIT>mm ; return ; } if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else { assert ( isUInt < <NUM_LIT> > ( Imm


<s> void <ISA_LIT>InstPrinter :: printLWE ( const MCInst * MI , unsigned OpNo


<s> if ( MI -> getOperand ( OpNo ) . getImm ( ) ) { O << <STR_LIT> << BitName


<s> O << <STR_LIT> ; printU4ImmOperand ( MI , OpNo ,


<s> if ( MII . get ( MI -> getOpcode ( ) ) . TSFlags & <STR_LIT> ) O << <STR_LIT> ; else if ( MII . get ( MI -> getOpcode (


<s> void <ISA_LIT>InstPrinter :: printVOPDst ( const MCInst * MI , unsigned OpNo , raw_ostream & O ) { if ( MII . get ( MI -> getOpcode ( ) ) . TSFlags & <STR_LIT> ) O << <STR_LIT> ; else if ( MII . get ( MI -> getOpcode ( ) ) . TSFlags & <STR_LIT> ) O << <STR_LIT> ; else O <<


<s> void <ISA_LIT>InstPrinter :: printAbs ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { static_cast < <ISA_LIT>InstPrinter * > ( this ) ->


<s> static_cast < <ISA_LIT>InstPrinter * > ( this ) ->


<s> void <ISA_LIT>InstPrinter :: printCT ( const MCInst * MI , unsigned OpNo

, const MCSubtargetInfo & STI , raw_ostream & O ) {


<s> void <ISA_LIT>InstPrinter :: printDFMT ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { if ( MI -> getOperand ( OpNo


<s> void <ISA_LIT>InstPrinter :: printDFMT ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI


<s> unsigned Imm = MI -> getOperand ( OpNo ) . getImm ( ) ; if ( Imm <= <NUM_LIT> ) { O << <STR_LIT> ; O << formatDec ( Imm & <NUM_LIT> ) << ',' ; O << formatDec ( ( Imm & <NUM_LIT> ) >> <NUM_LIT> ) << ',' ; O << formatDec ( ( Imm & <NUM_LIT> ) >> <NUM_LIT> ) << ',' ; O << formatDec ( ( Imm & <NUM_LIT> ) >> <NUM_LIT> ) << ']' ; } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT> ; } else if ( Imm == <NUM_LIT> ) { O << <STR_LIT>


<s> void <ISA_LIT>InstPrinter :: printImmediate64 ( uint64_t Imm , const MCSubtargetInfo & STI , raw_ostream & O ) { int64_t <ISA_LIT>mm = static_cast < int64_t > ( Imm ) ; if ( <ISA_LIT>mm >= - <NUM_LIT> && <ISA_LIT>mm <= <NUM_LIT> ) { O << <ISA_LIT>mm ; return ; } if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> )


<s> O << <ISA_LIT>mm ; return ; } if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( <NUM_LIT> ) ) O << <STR_LIT> ; else if ( Imm == DoubleToBits ( - <NUM_LIT> ) ) O


<s> static_cast < <ISA_LIT>InstPrinter * > ( this ) -> printKCache ( MI , OpNo ,


<s> static_cast < <ISA_LIT>InstPrinter * > ( this ) -> printLast ( MI , OpNo ,


<s> void <ISA_LIT>InstPrinter :: printLiteral ( const MCInst * MI , unsigned OpNo


<s> return ; } printOperand ( MI , OpNo , STI , O ) ; O << <STR_LIT> ; printOperand ( MI , OpNo + <NUM_LIT> , STI ,


<s> void <ISA_LIT>InstPrinter :: printNeg ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { static_cast < <ISA_LIT>InstPrinter * > ( this ) -> printNeg


<s> void <ISA_LIT>InstPrinter :: printNFMT ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { if ( MI -> getOperand ( OpNo ) . getImm ( ) ) { O << <STR_LIT> ; printU8ImmDecOperand ( MI , OpNo


<s> void <ISA_LIT>InstPrinter :: printOMOD ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { static_cast < <ISA_LIT>InstPrinter * > ( this ) -> printOMOD ( MI ,


<s> } else if ( Op . isImm ( ) ) { O << Op . getImm ( ) ; } else if ( Op . isFPImm ( ) ) { if ( Op . getFPImm ( ) == <NUM_LIT> ) O << <STR_LIT> ; else { O << Op . getFPImm ( ) ; } } else if ( Op . isExpr ( ) ) { const MCExpr * Exp = Op . getExpr ( ) ; Exp -> print ( O , & MAI


<s> void <ISA_LIT>InstPrinter :: printR128 ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { printNamedBit ( MI , OpNo , O ,


<s> void <ISA_LIT>InstPrinter :: printR128 ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { printNamedBit ( MI , OpNo ,


<s> static_cast < <ISA_LIT>InstPrinter * > ( this ) ->


<s> void <ISA_LIT>InstPrinter :: printRel ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { static_cast < <ISA_LIT>InstPrinter * > ( this ) -> printRel (


<s> void <ISA_LIT>InstPrinter :: printRSel ( const MCInst * MI , unsigned OpNo


<s> void <ISA_LIT>InstPrinter :: printUpdateExecMask ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo


<s> void <ISA_LIT>InstPrinter :: printUpdateExecMask ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI


<s> static_cast < <ISA_LIT>InstPrinter * > ( this ) -> printUpdatePred ( MI , OpNo ,


<s>
<STR_LIT>
::
IsaVersion
ISA
=
<STR_LIT>
::
getIsaVersion
(
STI
.
getFeatureBits
(
)
)
;
unsigned
<ISA_LIT>mm16
=
MI
->
getOperand
(
OpNo
)
.
getImm
(
)
;
unsigned
Vmcnt
,
Expcnt
,
Lgkmcnt
;
decodeWaitcnt
(
ISA
,
<ISA_LIT>mm16
,
Vmcnt
,
Expcnt
,
Lgkmcnt
)
;
bool
NeedSpace
=
false
;
if
(
Vmcnt
!=
getVmcntBitMask
(
ISA
)
)
{
O
<<
<STR_LIT>
<<
Vmcnt
<<
')'
;
NeedSpace
=
true
;
}
if
(
Expcnt
!=
getExpcntBitMask
(
ISA
)
)
{
if
(
NeedSpace
)
O
<<
' '
;
O
<<
<STR_LIT>
<<
Expcnt
<<
')'
;
NeedSpace
=
true


<s> unsigned <ISA_LIT>mm16 = MI -> getOperand ( OpNo ) . getImm ( ) ; unsigned Vmcnt , Expcnt , Lgkmcnt ; decodeWaitcnt ( ISA , <ISA_LIT>mm16 , Vmcnt , Expcnt , Lgkmcnt ) ; bool NeedSpace = false ; if ( Vmcnt != getVmcntBitMask ( ISA ) ) { O << <STR_LIT> << Vmcnt << ')' ; NeedSpace = true ; } if ( Expcnt != getExpcntBitMask ( ISA )


<s> void <ISA_LIT>InstPrinter :: printWrite ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { static_cast < <ISA_LIT>InstPrinter * > ( this ) -> printWrite ( MI , OpNo


<s> void <ISA_LIT>InstPrinter :: printABID ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { unsigned Imm = MI -> getOperand ( OpNo ) . getImm (


<s> unsigned Imm = MI -> getOperand ( OpNo ) . getImm ( ) ; if ( ! Imm ) return ; O << <STR_LIT> <<


<s> unsigned Imm = MI -> getOperand ( OpNo ) . getImm ( ) ; if ( ! Imm ) return ; O << <STR_LIT> << Imm


<s> void <ISA_LIT>InstPrinter :: printCBSZ ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { unsigned Imm = MI -> getOperand ( OpNo ) . getImm ( ) ; if ( ! Imm


<s> void <ISA_LIT>InstPrinter :: printDim ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { unsigned Dim = MI -> getOperand ( OpNo ) . getImm ( ) ; O <<


<s> void <ISA_LIT>InstPrinter :: printDLC ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { if ( <STR_LIT> ( STI ) ) printNamedBit ( MI


<s> unsigned Imm = MI -> getOperand ( OpNo ) . getImm ( ) ; O << <STR_LIT> << formatDec ( Imm & <NUM_LIT> ) ; for ( size_t i = <NUM_LIT> ; i < <NUM_LIT> ; ++


<s> O << <STR_LIT> ; O << formatDec ( Imm & <NUM_LIT> ) << ',' ; O << formatDec ( ( Imm & <NUM_LIT> ) >> <NUM_LIT> ) << ',' ; O << formatDec ( ( Imm & <NUM_LIT> ) >> <NUM_LIT> ) << ',' ; O << formatDec ( ( Imm & <NUM_LIT> ) >> <NUM_LIT> ) << ']' ; } else if ( ( Imm >= DppCtrl :: ROW_SHL_FIRST ) && ( Imm <= DppCtrl :: ROW_SHL_LAST ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= DppCtrl :: ROW_SHR_FIRST ) && ( Imm <= DppCtrl :: ROW_SHR_LAST ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( ( Imm >= DppCtrl :: ROW_ROR_FIRST ) && ( Imm <= DppCtrl :: ROW_ROR_LAST ) ) { O << <STR_LIT> ; printU4ImmDecOperand ( MI , OpNo , O ) ; } else if ( Imm == DppCtrl :: WAVE_SHL1 ) { if ( ! <STR_LIT> ( STI ) && ! <STR_LIT> ( STI ) ) { O << <STR_LIT> ; return ; } O << <STR_LIT> ; } else if ( Imm == DppCtrl :: WAVE_ROL1 ) { if ( ! <STR_LIT> ( STI ) && ! <STR_LIT> ( STI ) ) { O << <STR_LIT> ; return ; } O << <STR_LIT> ; } else if ( Imm == DppCtrl :: WAVE_SHR1 ) { if ( ! <STR_LIT> ( STI ) && ! <STR_LIT> ( STI ) ) { O << <STR_LIT> ; return ; } O << <STR_LIT> ; } else if ( Imm == DppCtrl :: WAVE_ROR1 ) { if ( ! <STR_LIT> ( STI ) && ! <STR_LIT> ( STI ) ) { O << <STR_LIT> ; return ; } O << <STR_LIT> ; } else if ( Imm == DppCtrl :: ROW_MIRROR ) { O << <STR_LIT> ; } else if ( Imm == DppCtrl :: ROW_HALF_MIRROR ) { O << <STR_LIT> ; } else if ( Imm == DppCtrl :: BCAST15 ) { if ( ! <STR_LIT> ( STI ) && ! <STR_LIT> ( STI )


<s> void <ISA_LIT>InstPrinter :: printFI ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { using namespace llvm :: <STR_LIT> ; unsigned Imm = MI -> getOperand ( OpNo


<s> O << <STR_LIT> ; if ( ! HwRegName . empty ( ) ) { O << HwRegName ; } else { O << Id ; } if ( Width != WIDTH_DEFAULT_ || Offset != OFFSET_DEFAULT_ ) { O << <STR_LIT> << Offset << <STR_LIT> <<


<s> void <ISA_LIT>InstPrinter :: printInst ( const MCInst * MI , uint64_t Address , StringRef Annot , const MCSubtargetInfo & STI , raw_ostream &


<s> } const MCOperand & Op = MI -> getOperand ( OpNo ) ; if ( Op . isReg ( ) ) { printRegOperand ( Op . getReg ( ) , O , MRI ) ; } else if ( Op . isImm ( ) ) { switch ( Desc . OpInfo [ OpNo ] . OperandType ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case MCOI :: OPERAND_IMMEDIATE : printImmediate32 ( Op . getImm ( ) , STI , O ) ; break ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : printImmediate64 ( Op . getImm ( ) , STI , O ) ; break ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : printImmediate16 ( Op . getImm ( ) , STI , O ) ; break ; case <STR_LIT> : case <STR_LIT> : if ( ! isUInt < <NUM_LIT> > ( Op . getImm ( ) ) && STI . getFeatureBits ( ) [ <STR_LIT> ] ) { printImmediate32 ( Op . getImm ( ) , STI , O ) ; break ; } LLVM_FALLTHROUGH ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : printImmediateV216 ( Op . getImm ( ) , STI , O ) ; break ; case MCOI :: OPERAND_UNKNOWN : case MCOI :: OPERAND_PCREL : O << formatDec ( Op . getImm ( ) ) ; break ; case MCOI :: OPERAND_REGISTER : O << <STR_LIT> ; break ; default : llvm_unreachable ( <STR_LIT> ) ; } } else if ( Op . isFPImm ( ) ) { if ( Op . getFPImm ( ) == <NUM_LIT> ) O << <STR_LIT> ; else { const MCInstrDesc & Desc = MII . get ( MI -> getOpcode ( ) ) ; int RCID = Desc . OpInfo [ OpNo ] . RegClass ; unsigned RCBits = <STR_LIT> ( MRI . getRegClass ( RCID ) ) ; if ( RCBits == <NUM_LIT> ) printImmediate32 ( FloatToBits ( Op . getFPImm ( ) ) , STI , O ) ; else if ( RCBits == <NUM_LIT> ) printImmediate64 ( DoubleToBits ( Op . getFPImm ( ) ) , STI , O ) ; else llvm_unreachable ( <STR_LIT> ) ; } } else if ( Op . isExpr ( ) ) { const MCExpr * Exp = Op . getExpr ( ) ; Exp -> print ( O , & MAI ) ; } else { O << <STR_LIT> ; } switch ( MI -> getOpcode ( ) ) { default :


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : printImmediate64 ( Op . getImm ( ) , STI , O ) ; break ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : printImmediate16 ( Op . getImm ( ) , STI , O ) ; break ; case <STR_LIT> : case <STR_LIT> : if ( ! isUInt < <NUM_LIT> > ( Op . getImm ( ) ) && STI . getFeatureBits ( ) [ <STR_LIT> ] ) { printImmediate32 ( Op . getImm ( ) , STI , O ) ; break ; } LLVM_FALLTHROUGH ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : printImmediateV216 ( Op . getImm ( ) , STI , O ) ; break ; case MCOI :: OPERAND_UNKNOWN : case MCOI :: OPERAND_PCREL : O << formatDec ( Op . getImm ( ) ) ; break ; case MCOI :: OPERAND_REGISTER : O << <STR_LIT> ; break ; default : llvm_unreachable ( <STR_LIT> ) ; } } else if ( Op . isFPImm ( ) ) { if ( Op . getFPImm ( ) == <NUM_LIT> ) O << <STR_LIT> ; else { const MCInstrDesc & Desc = MII . get ( MI -> getOpcode ( ) ) ; int RCID = Desc . OpInfo [ OpNo ] . RegClass ; unsigned RCBits = <STR_LIT> ( MRI . getRegClass ( RCID ) ) ; if ( RCBits == <NUM_LIT> ) printImmediate32 ( FloatToBits ( Op . getFPImm ( ) ) , STI , O ) ; else if ( RCBits == <NUM_LIT> ) printImmediate64 ( DoubleToBits ( Op . getFPImm ( ) ) , STI , O ) ; else llvm_unreachable ( <STR_LIT> ) ; } } else if ( Op . isExpr ( ) ) { const MCExpr * Exp = Op . getExpr ( ) ; Exp -> print ( O , & MAI ) ; } else { O << <STR_LIT> ; } switch ( MI -> getOpcode ( ) ) { default : break ; case


<s> llvm_unreachable ( <STR_LIT> ) ; case <STR_LIT> : llvm_unreachable ( <STR_LIT> ) ; default : break ; } O << getRegisterName ( RegNo


<s> if ( isValidMsgId ( MsgId , STI ) && isValidMsgOp ( MsgId , OpId ) && isValidMsgStream ( MsgId , OpId , StreamId ) ) { O << <STR_LIT> << getMsgName ( MsgId ) ; if ( msgRequiresOp ( MsgId ) ) { O << <STR_LIT> << getMsgOpName ( MsgId , OpId ) ; if ( msgSupportsStream ( MsgId , OpId ) ) { O << <STR_LIT> << StreamId ; } } O << ')' ; } else if ( encodeMsg ( MsgId , OpId , StreamId ) ==


<s> using namespace llvm :: <STR_LIT> ; uint16_t Imm = MI -> getOperand ( OpNo ) . getImm ( ) ; if ( Imm == <NUM_LIT> ) { return ; } O << <STR_LIT> ; if ( ( Imm & QUAD_PERM_ENC_MASK ) == QUAD_PERM_ENC ) { O << <STR_LIT> << IdSymbolic [ ID_QUAD_PERM ] ; for ( unsigned I = <NUM_LIT> ; I < LANE_NUM ; ++ I ) { O << <STR_LIT> ; O << formatDec ( Imm & LANE_MASK ) ; Imm >>= LANE_SHIFT ; } O << <STR_LIT> ; } else if ( ( Imm & BITMASK_PERM_ENC_MASK ) == BITMASK_PERM_ENC ) { uint16_t AndMask = ( Imm >> BITMASK_AND_SHIFT ) & BITMASK_MASK ; uint16_t OrMask = ( Imm >> BITMASK_OR_SHIFT ) & BITMASK_MASK ; uint16_t XorMask = ( Imm >> BITMASK_XOR_SHIFT ) & BITMASK_MASK ; if ( AndMask == BITMASK_MAX && OrMask == <NUM_LIT> && countPopulation ( XorMask ) == <NUM_LIT> ) { O << <STR_LIT> << IdSymbolic [ ID_SWAP ] ; O << <STR_LIT> ; O << formatDec ( XorMask ) ; O << <STR_LIT> ; } else if ( AndMask == BITMASK_MAX && OrMask == <NUM_LIT> && XorMask > <NUM_LIT> && isPowerOf2_64 ( XorMask + <NUM_LIT> ) ) { O << <STR_LIT> << IdSymbolic [ ID_REVERSE ] ; O << <STR_LIT> ; O << formatDec ( XorMask + <NUM_LIT> ) ; O << <STR_LIT> ; } else { uint16_t GroupSize = BITMASK_MAX - AndMask + <NUM_LIT> ; if ( GroupSize > <NUM_LIT> && isPowerOf2_64 ( GroupSize ) && OrMask < GroupSize && XorMask == <NUM_LIT> ) { O << <STR_LIT> << IdSymbolic [ ID_BROADCAST ] ; O << <STR_LIT> ; O << formatDec ( GroupSize ) ; O << <STR_LIT> ; O << formatDec ( OrMask


<s> if ( ( Val & ~ ENABLE_MASK ) != <NUM_LIT> ) { O << <STR_LIT> << formatHex ( static_cast < uint64_t > ( Val ) ) ; } else { O << <STR_LIT> ; bool NeedComma = false ; for ( unsigned ModeId = ID_MIN ; ModeId <= ID_MAX ; ++ ModeId ) { if ( Val & ( <NUM_LIT> << ModeId ) ) { if ( NeedComma ) O


<s> else if ( MII . get ( MI -> getOpcode ( ) ) . TSFlags & <STR_LIT> ) O << <STR_LIT> ; else if ( MII . get ( MI -> getOpcode ( ) ) . TSFlags & <STR_LIT> ) O << <STR_LIT> ; else O << <STR_LIT> ; } printOperand ( MI , OpNo , STI , O ) ; switch ( MI -> getOpcode ( ) ) { default : break ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT>


<s> if ( ! ! ( Ops [ I ] & Mod ) != DefaultValue ) return false ; } return


<s> void <ISA_LIT>InstPrinter :: printAbs ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { printIfSet ( MI , OpNo ,


<s> void <ISA_LIT>InstPrinter :: printAbs ( const MCInst * MI , unsigned OpNo , const MCSubtargetInfo & STI , raw_ostream & O ) { printIfSet ( MI , OpNo , O ,