<s> llvm_unreachable ( <STR_LIT> ) ; case MachineOperand :: MO_FPImmediate : { const APFloat & FloatValue = MO . getFPImm ( ) -> getValueAPF ( ) ; if ( & FloatValue . getSemantics ( ) == & APFloat :: IEEEsingle ) MCOp = MCOperand :: createFPImm ( FloatValue . convertToFloat ( ) ) ; else if ( & FloatValue . getSemantics ( ) == & APFloat :: IEEEdouble ) MCOp = MCOperand :: createFPImm ( FloatValue . convertToDouble ( ) ) ; else llvm_unreachable ( <STR_LIT> ) ; break ; } case MachineOperand :: MO_Immediate : MCOp = MCOperand :: createImm ( MO . getImm ( ) ) ; break ; case MachineOperand :: MO_Register : MCOp = MCOperand :: createReg ( MO . getReg ( ) ) ; break ; case MachineOperand :: MO_MachineBasicBlock : MCOp = MCOperand :: createExpr ( MCSymbolRefExpr :: create ( MO . getMBB ( ) -> getSymbol ( ) , Ctx ) ) ; break ; case MachineOperand :: MO_GlobalAddress : { const GlobalValue * GV = MO . getGlobal ( ) ; SmallString < <NUM_LIT> > Name ; AP . get<ISA_LIT>MangledName ( Name , GV ) ; MCSymbol * Sym = Ctx . getOrCreateSymbol ( Name ) ; MCOp = MCOperand :: createExpr ( MCSymbolRefExpr :: create ( Sym , Ctx ) ) ; break ; } case MachineOperand :: MO_ExternalSymbol : { MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( '%' ) + MO . getSymbolName ( ) ) ; MCOp = MCOperand :: createExpr ( MCSymbolRefExpr :: create ( Sym , Ctx ) ) ; break ; } case MachineOperand :: MO_MCSymbol : { MCSymbol * Sym = MO . getMCSymbol ( ) ; MCOp = MCOperand :: createExpr ( MCSymbolRefExpr :: create ( Sym , Ctx ) ) ; break ; } case MachineOperand :: MO_TargetIndex : { llvm_unreachable ( <STR_LIT> ) ; break ; } } OutMI . addOperand ( MCOp ) ;


<s> return createBRIGDwarfStreamer ( Ctx , TAB , * RVOS , Emitter , RelaxAll ) ;


<s> RawVectorOstream * RVOS = new RawVectorOstream ( & OS ) ; return createBRIGDwarfStreamer ( Ctx , TAB , * RVOS , Emitter , RelaxAll ) ;


<s> MCCodeGenInfo * X = new MCCodeGenInfo ( ) ;

X -> initMCCodeGenInfo ( RM , CM , OL ) ;


<s> static MCInstPrinter * create<ISA_LIT>MCInstPrinter ( const Triple & TT , unsigned SyntaxVariant , const MCAsmInfo & MAI , const MCInstrInfo & MII , const MCRegisterInfo & MRI ) { return new <ISA_LIT>InstPrinter ( MAI , MII , MRI ) ;


<s> MCRegisterInfo * X = new MCRegisterInfo ( ) ;

Init<ISA_LIT>MCRegisterInfo ( X , <NUM_LIT> ) ;


<s> static MCRegisterInfo * create<ISA_LIT>MCRegisterInfo ( const Triple & TT ) {

MCRegisterInfo * X = new MCRegisterInfo ( ) ;


<s> static MCSubtargetInfo * create<ISA_LIT>MCSubtargetInfo ( const Triple & TT , StringRef CPU , StringRef FS ) { return create<ISA_LIT>MCSubtargetInfoImpl ( TT , CPU , FS ) ;


<s> MCTargetStreamer * create<ISA_LIT>ObjectTargetStreamer ( MCStreamer & S , const MCSubtargetInfo & STI ) { return new <ISA_LIT>TargetStreamer ( S ) ;


<s> void LLVMInitialize<ISA_LIT>TargetMC ( ) { for ( Target * T : { & The<ISA_LIT>_32Target , & The<ISA_LIT>_64Target } ) { RegisterMCAsmInfo < <ISA_LIT>MCAsmInfo > X ( * T ) ; TargetRegistry :: RegisterMCCodeGenInfo ( * T , create<ISA_LIT>MCCodeGenInfo ) ; TargetRegistry :: RegisterMCInstrInfo ( * T , create<ISA_LIT>MCInstrInfo ) ; TargetRegistry :: RegisterMCRegInfo ( * T , create<ISA_LIT>MCRegisterInfo ) ; TargetRegistry :: RegisterMCSubtargetInfo ( * T , create<ISA_LIT>MCSubtargetInfo ) ;

TargetRegistry :: RegisterMCInstPrinter ( * T , create<ISA_LIT>MCInstPrinter ) ;


<s> const <ISA_LIT>ConstPtr * curConst = getConstPtr ( krnl , Arg ) ; if ( ! curConst ) { return <NUM_LIT> ; }


<s> if ( mFuncNames . find ( func ) == mFuncNames . end ( ) ) { id = mFuncNames . size ( ) + RESERVED_FUNCS + mFuncPtrNames . size ( ) ; mFuncNames [ func ] = id ; } else {


<s> uint32_t get_printf_offset ( ) { return mPrintfOffset ;


<s> <ISA_LIT>ModuleInfo :: <ISA_LIT>ModuleInfo ( const MachineModuleInfo & MMI ) { mMMI = & MMI ;


<s> mMMI = & MMI ; mOffset = <NUM_LIT> ; mReservedBuffs = <NUM_LIT> ; symTab = nullptr ; mCurrentCPOffset = <NUM_LIT> ; mPrintfOffset = <NUM_LIT> ; mProcessed = false ;


<s> bool <ISA_LIT>ModuleInfo :: isReadOnlyImage ( StringRef name , uint32_t iID ) const { const StringMap < <ISA_LIT>Kernel * > :: const_iterator kiter = mKernels . find ( name ) ; if ( kiter == mKernels . end ( ) ) { return false ; }

return kiter -> second -> readOnly . count ( iID ) ;


<s> bool <ISA_LIT>ModuleInfo :: isWriteOnlyImage ( StringRef name , uint32_t iID ) const { const StringMap < <ISA_LIT>Kernel * > :: const_iterator kiter = mKernels . find ( name ) ; if ( kiter == mKernels . end ( ) ) { return false ;


<s> mSTM = mTM -> getSubtargetImpl ( ) ;


<s> void <ISA_LIT>ModuleInfo :: processModule ( const Module * M , const <ISA_LIT>TargetMachine * mTM ) {


<s> bool <ISA_LIT>ModuleInfo :: usesHWConstant ( const <ISA_LIT>Kernel * krnl , StringRef arg ) {

const <ISA_LIT>ConstPtr * curConst = getConstPtr ( krnl , arg ) ;


<s> kb != ke ; ++ kb ) { <ISA_LIT>Kernel * ptr = kb -> getValue ( ) ;


<s> return StringSwitch < OpaqueType > ( ST -> getName ( ) ) . Cases ( <STR_LIT> , <STR_LIT> , I1D ) . Cases ( <STR_LIT> , <STR_LIT> , I1DA ) . Cases ( <STR_LIT> , <STR_LIT> , I1DB ) . Cases ( <STR_LIT> , <STR_LIT> , I2D ) . Cases ( <STR_LIT> , <STR_LIT> , I2DA ) . Cases ( <STR_LIT> , <STR_LIT> , I3D ) . Cases ( <STR_LIT> , <STR_LIT> , I2DDepth ) . Cases ( <STR_LIT> , <STR_LIT> , I2DADepth ) . Case ( <STR_LIT> , Sampler ) . Cases ( <STR_LIT> , <STR_LIT> , Event ) . Case ( <STR_LIT> , C32 ) . Case ( <STR_LIT> , C64 ) . Case ( <STR_LIT> , Sema ) . Case ( <STR_LIT> , ReserveId ) . Case ( <STR_LIT> , CLKEventT ) . Case ( <STR_LIT> , QueueT ) . Default ( UnknownOpaque ) ;


<s> inline bool IsSampler ( const Type * T ) { return GetOpaqueType ( T ) == Sampler ;


<s> unsigned <ISA_LIT>ParamManager :: addArgumentParam ( unsigned AS , const Argument & Arg , const StringRef ParamName ) { unsigned Param = addParam ( ( AS == <STR_LIT> ) ? <ISA_LIT>_PARAM_TYPE_ARGUMENT : <ISA_LIT>_PARAM_TYPE_KERNARG , Arg . getType ( ) , ParamName ) ;

AllParams . find ( Param ) -> second . Arg = & Arg ;


<s> unsigned <ISA_LIT>ParamManager :: addCallArgParam ( Type * Ty , const StringRef ParamName ) {

return addParam ( <ISA_LIT>_PARAM_TYPE_CALL_PARAM , Ty , ParamName ) ;


<s> unsigned <ISA_LIT>ParamManager :: addCallRetParam ( Type * Ty , const StringRef ParamName ) { return addParam ( <ISA_LIT>_PARAM_TYPE_CALL_RET , Ty , ParamName ) ;


<s> case <ISA_LIT>_PARAM_TYPE_CALL_PARAM : ParamList = & CallArgParams ; DefName = <STR_LIT> ; break ; case <ISA_LIT>_PARAM_TYPE_CALL_RET : ParamList = & CallRetParams ; DefName = <STR_LIT> ; break ; } if ( ParamName . empty ( ) ) { Name = DefName ; Name += utostr ( ParamList -> size ( ) ) ; } else { Name = ParamName ; } unsigned prev_offset = <NUM_LIT> ; unsigned prev_size = <NUM_LIT> ; if ( ParamList -> size ( ) > <NUM_LIT> ) { unsigned prev_param = ( * ParamList ) [ ParamList -> size ( ) - <NUM_LIT> ] ; prev_offset = getParamOffset ( prev_param ) ; prev_size = getParamSize ( prev_param ) ; } if ( prev_offset == UINT_MAX || GetOpaqueType ( Ty ) ) { Param . Offset = UINT_MAX ; } else { unsigned alignment = DL -> getABITypeAlignment ( Ty ) ; if ( ParamType == <ISA_LIT>_PARAM_TYPE_KERNARG && Ty -> isVectorTy ( ) ) alignment = DL -> getABITypeAlignment ( Ty -> getVectorElementType ( ) ) ; assert ( alignment != <NUM_LIT> ) ; Param . Offset = ( prev_offset + prev_size + alignment - <NUM_LIT> ) & ~ ( alignment - <NUM_LIT> ) ; } unsigned Index = AllParams . size ( ) ;


<s> break ; } if ( ParamName . empty ( ) ) { Name = DefName ; Name += utostr ( ParamList -> size ( ) ) ; } else { Name = ParamName ; } unsigned prev_offset = <NUM_LIT> ; unsigned prev_size = <NUM_LIT> ; if ( ParamList -> size ( ) > <NUM_LIT> ) { unsigned prev_param = ( * ParamList ) [ ParamList -> size ( ) - <NUM_LIT> ] ; prev_offset = getParamOffset ( prev_param ) ; prev_size = getParamSize ( prev_param ) ; } if ( prev_offset == UINT_MAX || GetOpaqueType ( Ty ) ) { Param . Offset = UINT_MAX ; } else { unsigned alignment = DL -> getABITypeAlignment ( Ty ) ; if ( ParamType == <ISA_LIT>_PARAM_TYPE_KERNARG && Ty -> isVectorTy ( ) ) alignment = DL -> getABITypeAlignment ( Ty -> getVectorElementType ( ) ) ; assert ( alignment != <NUM_LIT> ) ; Param . Offset = ( prev_offset + prev_size + alignment - <NUM_LIT> ) & ~ ( alignment - <NUM_LIT> ) ;


<s> void <ISA_LIT>ParamManager :: addParamName ( std :: string Name , unsigned Index ) {

char * name = ( char * ) malloc ( Name . length ( ) + <NUM_LIT> ) ;


<s> void <ISA_LIT>ParamManager :: addParamType ( Type * pTy , unsigned Index ) { ParamTypes [ Index ] = pTy ;


<s> return addParam ( <ISA_LIT>_PARAM_TYPE_RETURN , Ty , ParamName ) ;


<s> param_iterator arg_begin ( ) const {


<s> param_iterator call_ret_end ( ) const {


<s> return AllParams . find ( Param ) -> second . Arg ;


<s> const Argument * getParamArg ( unsigned Param ) const { assert ( AllParams . count ( Param ) == <NUM_LIT> && <STR_LIT> ) ;

return AllParams . find ( Param ) -> second . Arg ;


<s> unsigned getParamByOffset ( int64_t & Offset ) const { if ( Offset >= UINT_MAX || Offset < <NUM_LIT> ) return UINT_MAX ; unsigned o = ( unsigned ) Offset ; unsigned r = getParamByOffset ( o ) ; Offset = o ;


<s> const char * getParamName ( unsigned Param ) const {

assert ( AllParams . count ( Param ) == <NUM_LIT> && <STR_LIT> ) ;


<s> return ParamNames . find ( Param ) -> second ;


<s> unsigned getParamSize ( unsigned Param ) const {

return DL -> getTypeStoreSize ( getParamType ( Param ) ) ;


<s> assert ( AllParams . count ( Param ) == <NUM_LIT> && <STR_LIT> ) ; return ParamTypes . find ( Param ) -> second ;


<s> Type * getParamType ( unsigned Param ) const {


<s> Mang -> getNameWithPrefix ( NameStr , ArgName , DL ) ; } return std :: move ( NameStrStorage ) ;


<s> param_iterator ret_begin ( ) const { return ReturnParams . begin ( ) ;


<s> param_iterator ret_end ( ) const { return ReturnParams . end ( ) ;


<s> unsigned Opcode = MI . getOpcode ( ) ; MachineFunction * MF = MI . getParent ( ) -> getParent ( ) ; const MachineFrameInfo * MFI = MF -> getFrameInfo ( ) ; MCContext & Ctx = MF -> getContext ( ) ; assert ( <STR_LIT> ( Opcode , <STR_LIT> :: address ) == static_cast < int > ( FIOperandNum ) && <STR_LIT> ) ; MachineOperand & Base = MI . getOperand ( FIOperandNum ) ; int FrameIndex = Base . getIndex ( ) ; if ( Opcode == <STR_LIT> ) lowerSpillB1 ( II , FrameIndex ) ; else if ( Opcode == <STR_LIT> ) lowerRestoreB1 ( II , FrameIndex ) ; StringRef SymName = MFI -> isSpillSlotObjectIndex ( FrameIndex ) ? <STR_LIT> : <STR_LIT> ;

MCSymbol * Sym = Ctx . getOrCreateSymbol ( SymName ) ;


<s> unsigned Opcode = MI . getOpcode ( ) ; MachineFunction * MF = MI . getParent ( ) -> getParent ( ) ; const MachineFrameInfo * MFI = MF -> getFrameInfo ( ) ; MCContext & Ctx = MF -> getContext ( ) ; assert ( <STR_LIT> ( Opcode , <STR_LIT> :: address ) == static_cast < int > ( FIOperandNum ) && <STR_LIT> ) ;

MachineOperand & Base = MI . getOperand ( FIOperandNum ) ;


<s> static const uint16_t CalleeSavedRegs [ ] = { <NUM_LIT> } ;


<s> static const uint16_t CalleeSavedRegs [ ] = { <NUM_LIT> } ; return CalleeSavedRegs ;


<s> for ( const TargetRegisterClass * BaseClass : BaseClasses ) { if ( BaseClass -> contains ( Reg ) ) return BaseClass ;


<s> for ( const TargetRegisterClass * BaseClass : BaseClasses ) { if ( BaseClass -> contains ( Reg ) ) return BaseClass ; }


<s> if ( RC == & <STR_LIT> ) { return <ISA_LIT>Reg32PressureLimit ; } if ( RC == & <STR_LIT> ) { return <ISA_LIT>Reg64PressureLimit ;


<s> return <ISA_LIT>Reg32PressureLimit ; } if ( RC == & <STR_LIT> ) { return <ISA_LIT>Reg64PressureLimit ; } return <NUM_LIT> ;


<s> <ISA_LIT>MachineFunctionInfo * MFI = const_cast < <ISA_LIT>MachineFunctionInfo * > ( MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ) ; unsigned NumSlotsTotal = <STR_LIT> . getNumRegs ( ) ; unsigned RegSlots = NumSlotsTotal / <NUM_LIT> ; if ( MFI -> getRegisterPartitioning ( ) == <NUM_LIT> ) { const MachineRegisterInfo & RI = MF . getRegInfo ( ) ; unsigned rc32 = <NUM_LIT> , rc64 = <NUM_LIT> ; for ( unsigned i = <NUM_LIT> , e = RI . getNumVirtRegs ( ) ; i != e ; ++ i ) { switch ( RI . getRegClass ( index2VirtReg ( i ) ) -> getSize ( ) ) { case <NUM_LIT> : rc32 ++ ; break ; case <NUM_LIT> : rc64 ++ ; break ; } } if ( <ISA_LIT>RegSlots > <NUM_LIT> ) { RegSlots = <ISA_LIT>RegSlots ; } else { if ( rc64 < ( NumSlotsTotal - RegSlots ) && rc32 > ( RegSlots * <NUM_LIT> ) ) { RegSlots = NumSlotsTotal - rc64 ; } else if ( rc32 < ( RegSlots * <NUM_LIT> ) && rc64 > ( NumSlotsTotal - RegSlots ) ) { RegSlots = ( rc32 + <NUM_LIT> ) / <NUM_LIT> ; } } if ( RegSlots < <NUM_LIT> ) RegSlots = <NUM_LIT> ;

else if ( RegSlots > ( NumSlotsTotal - <NUM_LIT> ) ) RegSlots = NumSlotsTotal - <NUM_LIT> ;


<s> <ISA_LIT>RegisterInfo :: <ISA_LIT>RegisterInfo ( <ISA_LIT>Subtarget & st ) : <ISA_LIT>GenRegisterInfo ( <NUM_LIT> , <NUM_LIT> ) , ST ( st ) {


<s> unsigned DestReg = MI . getOperand ( <NUM_LIT> ) . getReg ( ) ; const <ISA_LIT>InstrInfo * TII = ST . getInstrInfo ( ) ; MachineRegisterInfo & MRI = MBB -> getParent ( ) -> getRegInfo ( ) ; unsigned TempGPR32 = MRI . createVirtualRegister ( & <STR_LIT> ) ; BuildMI ( * MBB , ++ II , DL , TII -> get ( <STR_LIT> ) , DestReg ) . addImm ( <NUM_LIT> ) . addImm ( <NUM_LIT> ) . addImm ( BRIG_TYPE_B1 ) . addImm ( BRIG_TYPE_U32 ) . addReg ( TempGPR32 , RegState :: Kill ) ; MI . setDesc ( TII -> get ( <STR_LIT> ) ) ; MI . getOperand ( <NUM_LIT> ) . setReg ( TempGPR32 ) ; MI . getOperand ( <NUM_LIT> ) . setIsDef ( ) ;

MachineOperand * TypeOp = TII -> getNamedOperand ( MI , <STR_LIT> :: TypeLength ) ;


<s> unsigned TempGPR32 = MRI . createVirtualRegister ( & <STR_LIT> ) ; DebugLoc DL = MI . getDebugLoc ( ) ; BuildMI ( * MBB , II , DL , TII -> get ( <STR_LIT> ) , TempGPR32 ) . addImm ( <NUM_LIT> ) . addImm ( <NUM_LIT> ) . addImm ( BRIG_TYPE_U32 ) . addImm ( BRIG_TYPE_B1 ) . addOperand ( MI . getOperand ( <NUM_LIT> ) ) ; MI . setDesc ( TII -> get ( <STR_LIT> ) ) ; MI . getOperand ( <NUM_LIT> ) . setReg ( TempGPR32 ) ; MI . getOperand ( <NUM_LIT> ) . setIsKill ( ) ; MachineOperand * TypeOp = TII -> getNamedOperand ( MI , <STR_LIT> :: TypeLength ) ;


<s> bool <ISA_LIT>RegisterInfo :: requiresFrameIndexScavenging ( const MachineFunction & MF ) const { const <ISA_LIT>MachineFunctionInfo * Info = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; return Info -> hasSpilledCRs ( ) ;


<s> const <ISA_LIT>MachineFunctionInfo * Info = MF . getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ;


<s> bool <ISA_LIT>RegisterInfo :: requiresRegisterScavenging ( const MachineFunction & MF ) const {


<s> bool <ISA_LIT>RegisterInfo :: saveScavengerRegister ( MachineBasicBlock & MBB , MachineBasicBlock :: iterator I , MachineBasicBlock :: iterator & UseMI , const TargetRegisterClass * RC , unsigned Reg ) const { MachineFunction * MF = MBB . getParent ( ) ; <ISA_LIT>MachineFunctionInfo * Info = MF -> getInfo < <ISA_LIT>MachineFunctionInfo > ( ) ; MCContext & Ctx = MF -> getContext ( ) ; const <ISA_LIT>InstrInfo * TII = ST . getInstrInfo ( ) ;

assert ( RC == & <STR_LIT> && <STR_LIT> ) ;


<s> bool <ISA_LIT>RegisterInfo :: trackLivenessAfterRegAlloc ( const MachineFunction & MF ) const {


return dataSizeInBytes ( ) / InitEltSize ;


<s> switch ( InitEltSize ) { case <NUM_LIT> : { uint32_t Tmp ; std :: memcpy ( & Tmp , Ptr , <NUM_LIT> ) ; if ( IsFPElt ) printFloat ( Tmp , O ) ; else O << Tmp ; break ; } case <NUM_LIT> : { uint64_t Tmp ; std :: memcpy ( & Tmp , Ptr , <NUM_LIT> ) ; if ( IsFPElt ) printDouble ( Tmp , O ) ; else O << Tmp ; break ; } case <NUM_LIT> : { uint16_t Tmp ;


<s> if ( I != <NUM_LIT> ) O << <STR_LIT> ; O << ( static_cast < int > ( Str [ I ] ) & <NUM_LIT> ) ; } return ; } for ( unsigned I = <NUM_LIT> , E = Str . size ( ) ; I != E ; I += InitEltSize ) { if ( I != <NUM_LIT> ) O << <STR_LIT> ; const char * Ptr = & Str . data ( ) [ I ] ; switch ( InitEltSize ) { case <NUM_LIT> : { uint32_t Tmp ; std :: memcpy ( & Tmp , Ptr , <NUM_LIT> ) ; if ( IsFPElt ) printFloat ( Tmp , O ) ; else O << Tmp ; break ; } case <NUM_LIT> : { uint64_t Tmp ; std :: memcpy ( & Tmp , Ptr , <NUM_LIT> ) ; if ( IsFPElt ) printDouble ( Tmp , O ) ; else O << Tmp ; break ; } case <NUM_LIT> : { uint16_t Tmp ; std :: memcpy ( & Tmp , Ptr , <NUM_LIT> ) ; assert ( ! IsFPElt && <STR_LIT> ) ; O << Tmp ; break ; } default : llvm_unreachable ( <STR_LIT> ) ; } }


<s> O << format ( <STR_LIT> PRIx64 , Val ) ;


<s> void StoreInitializer :: printFloat ( uint32_t Val , raw_ostream & O ) {

O << format ( <STR_LIT> PRIx32 , Val ) ;


<s> StoreInitializer :: StoreInitializer ( Type * EltTy , AsmPrinter & AP ) : DL ( AP . getDataLayout ( ) ) , AP ( AP ) , InitEltSize ( DL . getTypeAllocSize ( EltTy ) ) , IsFPElt ( EltTy -> isFloatingPointTy ( ) ) , m_data ( ) , OS ( m_data ) , LE ( OS ) {


<s> StringRef str ( ) { return OS . str ( ) ;


<s> return makeArrayRef ( VarInitAddresses ) ;


<s> VarInitOffset ( uint64_t Offset , const MCExpr * E ) : BaseOffset ( Offset ) , Expr ( E ) {


<s> for ( unsigned i = <NUM_LIT> ; i < <ISA_LIT>Samplers . size ( ) ; i ++ ) { if ( getSamplerSymbol ( i ) . empty ( ) ) { sprintf ( buf , <STR_LIT> , <STR_LIT> , index ) ; <ISA_LIT>Samplers [ i ] -> setSym ( buf ) ; index ++ ; }


<s> for ( unsigned i = <NUM_LIT> ; i < <ISA_LIT>ImageArgs . size ( ) ; i ++ ) { if ( <ISA_LIT>ImageArgs [ i ] == symStr ) { return i ; }


<s> const <ISA_LIT>FrameLowering * getFrameLowering ( ) const override {


<s> assert ( index < <ISA_LIT>ImageArgs . size ( ) && <STR_LIT> ) ;


<s> const <ISA_LIT>InstrInfo * getInstrInfo ( ) const override {


<s> const <ISA_LIT>RegisterInfo * getRegisterInfo ( ) const override { return & getInstrInfo ( ) -> getRegisterInfo ( ) ;


<s> SmallVector < <ISA_LIT>SamplerHandle * , <NUM_LIT> > getSamplerHandles ( ) { return <ISA_LIT>Samplers ;


<s> assert ( index < <ISA_LIT>Samplers . size ( ) && <STR_LIT> ) ; return <ISA_LIT>Samplers [ index ] -> getSym ( ) ;


<s> assert ( index < <ISA_LIT>Samplers . size ( ) && <STR_LIT> ) ;

return <ISA_LIT>Samplers [ index ] -> getVal ( ) ;


<s> inline std :: string getSym ( ) { return mSym ;


<s> <ISA_LIT>ImageHandles ( ) { index = <NUM_LIT> ;


<s> <ISA_LIT>SamplerHandle ( unsigned int u ) { mVal = u ; mIsRO = false ;


<s> <ISA_LIT>SamplerHandle ( unsigned int u ) {


<s> ParseSubtargetFeatures ( GPU , FS ) ; return * this ;


<s> inline bool isEmitted ( ) { return mEmitted ;


<s> inline bool isRO ( ) { return mIsRO ;


<s> bool <ISA_LIT>ImageHandles :: isSamplerSym ( std :: string sym ) { for ( unsigned i = <NUM_LIT> ; i < <ISA_LIT>Samplers . size ( ) ; i ++ ) { if ( getSamplerSymbol ( i ) == sym ) { return true ; } } return false ;


<s> inline void setEmitted ( ) { mEmitted = true ;


<s> inline void setSym ( std :: string str ) {


<s> void LLVMInitialize<ISA_LIT>TargetInfo ( ) { RegisterTarget < Triple :: hsail , false > Target32 ( The<ISA_LIT>_32Target , <STR_LIT> , <STR_LIT> ) ;

RegisterTarget < Triple :: hsail64 , false > Target64 ( The<ISA_LIT>_64Target , <STR_LIT> , <STR_LIT> ) ;


<s> addPass ( create<ISA_LIT>ISelDag ( HSATM ) ) ; addPass ( & DeadMachineInstructionElimID ) ; if ( EnableUniformOps ) { addPass ( create<ISA_LIT>UniformOperations ( HSATM ) ) ; } return false ;


<s> void <ISA_LIT>PassConfig :: addIRPasses ( ) { addPass ( create<ISA_LIT>AlwaysInlinePass ( ) ) ;

addPass ( createAlwaysInlinerPass ( ) ) ;


<s> addPass ( create<ISA_LIT>AlwaysInlinePass ( ) ) ; addPass ( createAlwaysInlinerPass ( ) ) ;


<s> return LLVMTargetMachine :: addPassesToEmitFile ( PM , Out , FT , DisableVerify , StartAfter , StopAfter , MFInitializer ) ;


<s> void <ISA_LIT>PassConfig :: addPostRegAlloc ( ) {


<s> void <ISA_LIT>PassConfig :: addPreEmitPass ( ) {


<s> addPass ( createLCSSAPass ( ) ) ; return true ;


<s> bool <ISA_LIT>PassConfig :: addPreISel ( ) {


<s> void <ISA_LIT>PassConfig :: addPreRegAlloc ( ) {


<s> static StringRef computeDataLayout ( const Triple & T ) { if ( T . getArch ( ) == Triple :: hsail64 ) { return <STR_LIT> <STR_LIT> <STR_LIT> <STR_LIT> <STR_LIT> ; }


<s> return new <ISA_LIT>PassConfig ( this , PM ) ;


<s> const <ISA_LIT>Subtarget * getSubtargetImpl ( const Function & ) const override { return & Subtarget ;


<s> const <ISA_LIT>Subtarget * getSubtargetImpl ( const Function & ) const override {


<s> if ( TT . getOS ( ) != Triple :: UnknownOS ) TT . setOS ( Triple :: UnknownOS ) ; return TT ;


<s> <ISA_LIT>PassConfig ( <ISA_LIT>TargetMachine * TM , PassManagerBase & PM ) : TargetPassConfig ( TM , PM ) {


<s> <ISA_LIT>_32TargetMachine :: <ISA_LIT>_32TargetMachine ( const Target & T , const Triple & TT , StringRef CPU , StringRef FS , const TargetOptions & Options , Reloc :: Model RM , CodeModel :: Model CM , CodeGenOpt :: Level OL ) : <ISA_LIT>TargetMachine ( T , TT , CPU , FS , Options , RM , CM , OL ) {

if ( TT . getArch ( ) == Triple :: hsail64 ) {


<s> <ISA_LIT>_32TargetMachine :: <ISA_LIT>_32TargetMachine ( const Target & T , const Triple & TT , StringRef CPU , StringRef FS , const TargetOptions & Options , Reloc :: Model RM , CodeModel :: Model CM , CodeGenOpt :: Level OL ) : <ISA_LIT>TargetMachine ( T , TT , CPU , FS , Options , RM , CM , OL ) { if ( TT . getArch ( ) == Triple :: hsail64 ) { errs ( ) << <STR_LIT> << TT . str ( ) << <STR_LIT> ; }


<s> RegisterTargetMachine < <ISA_LIT>_32TargetMachine > X ( The<ISA_LIT>_32Target ) ; RegisterTargetMachine < <ISA_LIT>_64TargetMachine > Y ( The<ISA_LIT>_64Target ) ;


<s> MCSection * getExplicitSectionGlobal ( const GlobalValue * GV , SectionKind Kind , Mangler & Mang , const TargetMachine & TM ) const override { return DataSection ;


<s> MCSection * getSectionForConstant ( const DataLayout & DL , SectionKind Kind , const Constant * C ) const override {


<s> <ISA_LIT>TargetObjectFile :: <ISA_LIT>TargetObjectFile ( ) { TextSection = nullptr ; DataSection = nullptr ; BSSSection = nullptr ; ReadOnlySection = nullptr ; StaticCtorSection = nullptr ; StaticDtorSection = nullptr ; LSDASection = nullptr ; EHFrameSection = nullptr ; DwarfAbbrevSection = nullptr ; DwarfInfoSection = nullptr ; DwarfLineSection = nullptr ; DwarfFrameSection = nullptr ; DwarfPubTypesSection = nullptr ; DwarfDebugInlineSection = nullptr ; DwarfStrSection = nullptr ; DwarfLocSection = nullptr ; DwarfARangesSection = nullptr ;


<s> DwarfFrameSection = new <ISA_LIT>Section ( MCSection :: SV_ELF , SectionKind :: getMetadata ( ) ) ; DwarfPubTypesSection = new <ISA_LIT>Section ( MCSection :: SV_ELF , SectionKind :: getMetadata ( ) ) ; DwarfDebugInlineSection = new <ISA_LIT>Section ( MCSection :: SV_ELF , SectionKind :: getMetadata ( ) ) ; DwarfStrSection = new <ISA_LIT>Section ( MCSection :: SV_ELF , SectionKind :: getMetadata ( ) ) ; DwarfLocSection = new <ISA_LIT>Section ( MCSection :: SV_ELF , SectionKind :: getMetadata ( ) ) ; DwarfARangesSection = new <ISA_LIT>Section ( MCSection :: SV_ELF , SectionKind :: getMetadata ( ) ) ; DwarfRangesSection = new <ISA_LIT>Section ( MCSection :: SV_ELF , SectionKind :: getMetadata ( ) ) ;


<s> BRIG32_DwarfTargetObjectFile :: ~ BRIG32_DwarfTargetObjectFile ( ) {


<s> BRIG64_DwarfTargetObjectFile :: ~ BRIG64_DwarfTargetObjectFile ( ) {


<s> <ISA_LIT>TargetAsmStreamer :: <ISA_LIT>TargetAsmStreamer ( MCStreamer & S ) : <ISA_LIT>TargetStreamer ( S ) {


<s> <ISA_LIT>TargetStreamer :: <ISA_LIT>TargetStreamer ( MCStreamer & S ) : MCTargetStreamer ( S ) {


<s> EltTy = AT -> getElementType ( ) ; AT = dyn_cast < ArrayType > ( EltTy ) ; } unsigned EltElts = ~ <NUM_LIT> ; Type * Tmp = analyzeType ( EltTy , EltElts , DL ) ; if ( EltElts != <NUM_LIT> ) NElts *= EltElts ; return Tmp ; } if ( VectorType * VT = dyn_cast < VectorType > ( Ty ) ) { Type * EltTy = VT -> getElementType ( ) ; NElts = DL . getTypeAllocSize ( Ty ) / DL . getTypeAllocSize ( EltTy ) ; assert ( NElts >= VT -> getNumElements ( ) ) ; if ( EltTy -> isIntegerTy ( <NUM_LIT> ) ) report_fatal_error ( <STR_LIT> ) ; return EltTy ; } if ( isa < StructType > ( Ty ) ) { NElts = DL . getTypeAllocSize ( Ty ) ; return Type :: getInt8Ty ( Ty -> getContext ( ) ) ; } assert ( ! Ty -> isAggregateType ( ) ) ; NElts = <NUM_LIT> ; if ( Ty -> isIntegerTy ( <NUM_LIT> ) ) return Type :: getInt8Ty ( Ty -> getContext ( ) ) ;


<s> Type * Tmp = analyzeType ( EltTy , EltElts , DL ) ; if ( EltElts != <NUM_LIT> ) NElts *= EltElts ; return Tmp ; } if ( VectorType * VT = dyn_cast < VectorType > ( Ty ) ) { Type * EltTy = VT -> getElementType ( ) ; NElts = DL . getTypeAllocSize ( Ty ) / DL . getTypeAllocSize ( EltTy ) ; assert ( NElts >= VT -> getNumElements ( ) ) ; if ( EltTy -> isIntegerTy ( <NUM_LIT> ) ) report_fatal_error ( <STR_LIT> ) ;


<s> if ( ArrayType * ATy = dyn_cast < ArrayType > ( ty ) ) ty = ATy -> getElementType ( ) ;

if ( IsImage ( ty ) || IsSampler ( ty ) ) return <NUM_LIT> ;


<s> return BRIG_TYPE_NONE ; case Type :: FloatTyID : return BRIG_TYPE_F32 ; case Type :: DoubleTyID : return BRIG_TYPE_F64 ; case Type :: IntegerTyID : if ( type -> isIntegerTy ( <NUM_LIT> ) ) { return Signed ? BRIG_TYPE_S8 : BRIG_TYPE_U8 ; } else if ( type -> isIntegerTy ( <NUM_LIT> ) ) { return Signed ? BRIG_TYPE_S16 : BRIG_TYPE_U16 ; } else if ( type -> isIntegerTy ( <NUM_LIT> ) ) { return Signed ? BRIG_TYPE_S32 : BRIG_TYPE_U32 ; } else if ( type -> isIntegerTy ( <NUM_LIT> ) ) { return Signed ? BRIG_TYPE_S64 : BRIG_TYPE_U64 ; } else if ( type -> isIntegerTy ( <NUM_LIT> ) ) { return BRIG_TYPE_B1 ; } else llvm_unreachable ( <STR_LIT> ) ; break ; case Type :: PointerTyID : { if ( OpaqueType OT = GetOpaqueType ( type ) ) { if ( IsImage ( OT ) ) return BRIG_TYPE_RWIMG ; if ( OT == Sampler ) return BRIG_TYPE_SAMP ; } unsigned AS = cast < PointerType > ( type ) -> getAddressSpace ( ) ; return DL . getPointerSize ( AS ) == <NUM_LIT> ? BRIG_TYPE_U64 : BRIG_TYPE_U32 ; } case Type :: StructTyID : return BRIG_TYPE_U8_ARRAY ; case Type :: VectorTyID : return static_cast < BrigType > ( getBrigType ( type -> getScalarType ( ) , DL , Signed ) | BRIG_TYPE_ARRAY ) ; case Type :: ArrayTyID : return static_cast < BrigType > ( getBrigType ( cast < ArrayType > ( type ) -> getElementType ( ) , DL , Signed ) | BRIG_TYPE_ARRAY ) ; default : type -> dump ( ) ; llvm_unreachable ( <STR_LIT> ) ; }


<s> break ; case Type :: PointerTyID : { if ( OpaqueType OT = GetOpaqueType ( type ) ) { if ( IsImage ( OT ) ) return BRIG_TYPE_RWIMG ; if ( OT == Sampler ) return BRIG_TYPE_SAMP ; } unsigned AS = cast < PointerType > ( type ) -> getAddressSpace ( ) ; return DL . getPointerSize ( AS ) == <NUM_LIT> ? BRIG_TYPE_U64 : BRIG_TYPE_U32 ; } case Type :: StructTyID : return BRIG_TYPE_U8_ARRAY ; case Type :: VectorTyID : return static_cast < BrigType > ( getBrigType ( type -> getScalarType ( ) , DL , Signed ) | BRIG_TYPE_ARRAY ) ; case Type :: ArrayTyID : return static_cast < BrigType > ( getBrigType ( cast < ArrayType > ( type ) -> getElementType ( ) , DL , Signed ) | BRIG_TYPE_ARRAY ) ; default : type -> dump ( ) ; llvm_unreachable ( <STR_LIT> ) ;


<s> static inline bool isConv ( const MachineInstr * MI ) {

return MI -> getDesc ( ) . TSFlags & <STR_LIT> ;


<s> return MI -> getDesc ( ) . TSFlags & <STR_LIT> ;


<s> StringRef GVname = GV -> getName ( ) ;

return GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) || GVname . startswith ( <STR_LIT> ) ;


<s> static inline bool isImageInst ( const MachineInstr * MI ) {


<s> if ( CallingConv :: SPIR_KERNEL == F -> getCallingConv ( ) ) return true ;

return isKernelFunc ( F -> getName ( ) ) ;


<s> bool isSPIRModule ( const Module & M ) {

return M . getNamedMetadata ( <STR_LIT> ) ;


<s> bool notUsedInKernel ( const GlobalVariable * GV ) { SmallVector < const User * , <NUM_LIT> > worklist ; worklist . append ( GV -> user_begin ( ) , GV -> user_end ( ) ) ; while ( ! worklist . empty ( ) ) { const User * user = worklist . pop_back_val ( ) ;

if ( const GlobalValue * GUser = dyn_cast < GlobalValue > ( user ) ) {


<s> SmallVector < const User * , <NUM_LIT> > worklist ; worklist . append ( GV -> user_begin ( ) , GV -> user_end ( ) ) ; while ( ! worklist . empty ( ) ) { const User * user = worklist . pop_back_val ( ) ;


<s> Name = Name . drop_front ( <NUM_LIT> ) ; } size_t p = <NUM_LIT> ; size_t q = <NUM_LIT> ; while ( q != StringRef :: npos ) { q = Name . find_first_not_of ( Syntax , p ) ; if ( q != p ) { NewName += Name . slice ( p , q ) ; } if ( q == StringRef :: npos ) break ;


<s> NewName += '_' ; Name = Name . drop_front ( <NUM_LIT> ) ; } size_t p = <NUM_LIT> ; size_t q = <NUM_LIT> ; while ( q != StringRef :: npos ) { q = Name . find_first_not_of ( Syntax , p ) ; if ( q != p ) { NewName += Name . slice ( p , q ) ; } if ( q == StringRef :: npos ) break ; NewName += '_' ; p = q + <NUM_LIT> ; } if ( Name . empty ( ) || Digits . find ( Name [ <NUM_LIT> ] ) != StringRef :: npos || ! Name . equals ( NewName ) ) { Out . append ( NewName . begin ( ) , NewName . end ( ) ) ;


<s> bool sanitizeGlobalValueName ( GlobalValue * GV ) { SmallString < <NUM_LIT> > NewName ; if ( sanitizedGlobalValueName ( GV -> getName ( ) , NewName ) ) { GV -> setName ( Twine ( <STR_LIT> ) + Twine ( NewName ) ) ; return true ; } return false ;


<s> if ( sanitizedGlobalValueName ( GV -> getName ( ) , NewName ) ) { GV -> setName ( Twine ( <STR_LIT> ) + Twine ( NewName ) ) ; return true ; } return false ;


<s> uint64_t RawVectorOstream :: current_pos ( ) const {

return static_cast < uint64_t > ( Position ) ;


<s> return StringRef ( Data . data ( ) , Data . size ( ) ) ;


<s> void RawVectorOstream :: pwrite_impl ( const char * Ptr , size_t Size , uint64_t Offset ) { flush ( ) ; memcpy ( Data . data ( ) + Offset , Ptr , Size ) ; if ( Other ) Other -> pwrite ( Ptr , Size , Offset ) ;


<s> RawVectorOstream :: RawVectorOstream ( raw_pwrite_stream * other ) : Data ( AllocationChunk ) , Position ( <NUM_LIT> ) , Other ( other ) {


<s> void RawVectorOstream :: releaseStream ( ) { if ( Other ) {


<s> } std :: copy ( Ptr , Ptr + Size , Data . begin ( ) + Position ) ; Position += Size ; if ( Other ) {