Lines Matching refs:M

41 IntegerType *getSizeTTy(Module &M) {  in getSizeTTy()  argument
42 LLVMContext &C = M.getContext(); in getSizeTTy()
43 switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) { in getSizeTTy()
59 StructType *getEntryTy(Module &M) { in getEntryTy() argument
60 LLVMContext &C = M.getContext(); in getEntryTy()
64 Type::getInt8PtrTy(C), getSizeTTy(M), in getEntryTy()
69 PointerType *getEntryPtrTy(Module &M) { in getEntryPtrTy() argument
70 return PointerType::getUnqual(getEntryTy(M)); in getEntryPtrTy()
79 StructType *getDeviceImageTy(Module &M) { in getDeviceImageTy() argument
80 LLVMContext &C = M.getContext(); in getDeviceImageTy()
84 Type::getInt8PtrTy(C), getEntryPtrTy(M), in getDeviceImageTy()
85 getEntryPtrTy(M)); in getDeviceImageTy()
89 PointerType *getDeviceImagePtrTy(Module &M) { in getDeviceImagePtrTy() argument
90 return PointerType::getUnqual(getDeviceImageTy(M)); in getDeviceImagePtrTy()
99 StructType *getBinDescTy(Module &M) { in getBinDescTy() argument
100 LLVMContext &C = M.getContext(); in getBinDescTy()
104 getDeviceImagePtrTy(M), getEntryPtrTy(M), in getBinDescTy()
105 getEntryPtrTy(M)); in getBinDescTy()
109 PointerType *getBinDescPtrTy(Module &M) { in getBinDescPtrTy() argument
110 return PointerType::getUnqual(getBinDescTy(M)); in getBinDescPtrTy()
151 GlobalVariable *createBinDesc(Module &M, ArrayRef<ArrayRef<char>> Bufs) { in createBinDesc() argument
152 LLVMContext &C = M.getContext(); in createBinDesc()
155 M, getEntryTy(M), /*isConstant*/ true, GlobalValue::ExternalLinkage, in createBinDesc()
159 M, getEntryTy(M), /*isConstant*/ true, GlobalValue::ExternalLinkage, in createBinDesc()
169 ConstantAggregateZero::get(ArrayType::get(getEntryTy(M), 0u)); in createBinDesc()
171 M, DummyInit->getType(), true, GlobalVariable::ExternalLinkage, DummyInit, in createBinDesc()
176 auto *Zero = ConstantInt::get(getSizeTTy(M), 0u); in createBinDesc()
184 auto *Image = new GlobalVariable(M, Data->getType(), /*isConstant*/ true, in createBinDesc()
191 auto *Size = ConstantInt::get(getSizeTTy(M), Buf.size()); in createBinDesc()
199 ImagesInits.push_back(ConstantStruct::get(getDeviceImageTy(M), ImageB, in createBinDesc()
205 ArrayType::get(getDeviceImageTy(M), ImagesInits.size()), ImagesInits); in createBinDesc()
208 new GlobalVariable(M, ImagesData->getType(), /*isConstant*/ true, in createBinDesc()
218 getBinDescTy(M), in createBinDesc()
222 return new GlobalVariable(M, DescInit->getType(), /*isConstant*/ true, in createBinDesc()
227 void createRegisterFunction(Module &M, GlobalVariable *BinDesc) { in createRegisterFunction() argument
228 LLVMContext &C = M.getContext(); in createRegisterFunction()
231 ".omp_offloading.descriptor_reg", &M); in createRegisterFunction()
235 auto *RegFuncTy = FunctionType::get(Type::getVoidTy(C), getBinDescPtrTy(M), in createRegisterFunction()
238 M.getOrInsertFunction("__tgt_register_lib", RegFuncTy); in createRegisterFunction()
251 appendToGlobalCtors(M, Func, /*Priority*/ 1); in createRegisterFunction()
254 void createUnregisterFunction(Module &M, GlobalVariable *BinDesc) { in createUnregisterFunction() argument
255 LLVMContext &C = M.getContext(); in createUnregisterFunction()
258 ".omp_offloading.descriptor_unreg", &M); in createUnregisterFunction()
262 auto *UnRegFuncTy = FunctionType::get(Type::getVoidTy(C), getBinDescPtrTy(M), in createUnregisterFunction()
265 M.getOrInsertFunction("__tgt_unregister_lib", UnRegFuncTy); in createUnregisterFunction()
274 appendToGlobalDtors(M, Func, /*Priority*/ 1); in createUnregisterFunction()
283 StructType *getFatbinWrapperTy(Module &M) { in getFatbinWrapperTy() argument
284 LLVMContext &C = M.getContext(); in getFatbinWrapperTy()
295 GlobalVariable *createFatbinDesc(Module &M, ArrayRef<char> Image, bool IsHIP) { in createFatbinDesc() argument
296 LLVMContext &C = M.getContext(); in createFatbinDesc()
298 llvm::Triple Triple = llvm::Triple(M.getTargetTriple()); in createFatbinDesc()
305 auto *Fatbin = new GlobalVariable(M, Data->getType(), /*isConstant*/ true, in createFatbinDesc()
321 ConstantStruct::get(getFatbinWrapperTy(M), FatbinWrapper); in createFatbinDesc()
324 new GlobalVariable(M, getFatbinWrapperTy(M), in createFatbinDesc()
334 ConstantAggregateZero::get(ArrayType::get(getEntryTy(M), 0u)); in createFatbinDesc()
336 M, DummyInit->getType(), true, GlobalVariable::ExternalLinkage, DummyInit, in createFatbinDesc()
368 Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) { in createRegisterGlobalsFunction() argument
369 LLVMContext &C = M.getContext(); in createRegisterGlobalsFunction()
378 FunctionCallee RegFunc = M.getOrInsertFunction( in createRegisterGlobalsFunction()
386 getSizeTTy(M), Type::getInt32Ty(C), Type::getInt32Ty(C)}, in createRegisterGlobalsFunction()
388 FunctionCallee RegVar = M.getOrInsertFunction( in createRegisterGlobalsFunction()
393 new GlobalVariable(M, ArrayType::get(getEntryTy(M), 0), in createRegisterGlobalsFunction()
400 new GlobalVariable(M, ArrayType::get(getEntryTy(M), 0), in createRegisterGlobalsFunction()
412 IsHIP ? ".hip.globals_reg" : ".cuda.globals_reg", &M); in createRegisterGlobalsFunction()
430 auto *Entry = Builder.CreatePHI(getEntryPtrTy(M), 2, "entry"); in createRegisterGlobalsFunction()
432 Builder.CreateInBoundsGEP(getEntryTy(M), Entry, in createRegisterGlobalsFunction()
433 {ConstantInt::get(getSizeTTy(M), 0), in createRegisterGlobalsFunction()
437 Builder.CreateInBoundsGEP(getEntryTy(M), Entry, in createRegisterGlobalsFunction()
438 {ConstantInt::get(getSizeTTy(M), 0), in createRegisterGlobalsFunction()
442 Builder.CreateInBoundsGEP(getEntryTy(M), Entry, in createRegisterGlobalsFunction()
443 {ConstantInt::get(getSizeTTy(M), 0), in createRegisterGlobalsFunction()
445 auto *Size = Builder.CreateLoad(getSizeTTy(M), SizePtr, "size"); in createRegisterGlobalsFunction()
447 Builder.CreateInBoundsGEP(getEntryTy(M), Entry, in createRegisterGlobalsFunction()
448 {ConstantInt::get(getSizeTTy(M), 0), in createRegisterGlobalsFunction()
452 Builder.CreateICmpEQ(Size, ConstantInt::getNullValue(getSizeTTy(M))); in createRegisterGlobalsFunction()
495 getEntryTy(M), Entry, ConstantInt::get(getSizeTTy(M), 1)); in createRegisterGlobalsFunction()
499 ArrayType::get(getEntryTy(M), 0), EntriesE, in createRegisterGlobalsFunction()
500 ArrayRef<Constant *>({ConstantInt::get(getSizeTTy(M), 0), in createRegisterGlobalsFunction()
501 ConstantInt::get(getSizeTTy(M), 0)}))); in createRegisterGlobalsFunction()
504 ArrayType::get(getEntryTy(M), 0), EntriesB, in createRegisterGlobalsFunction()
505 ArrayRef<Constant *>({ConstantInt::get(getSizeTTy(M), 0), in createRegisterGlobalsFunction()
506 ConstantInt::get(getSizeTTy(M), 0)})), in createRegisterGlobalsFunction()
518 void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc, in createRegisterFatbinFunction() argument
520 LLVMContext &C = M.getContext(); in createRegisterFatbinFunction()
524 IsHIP ? ".hip.fatbin_reg" : ".cuda.fatbin_reg", &M); in createRegisterFatbinFunction()
530 IsHIP ? ".hip.fatbin_unreg" : ".cuda.fatbin_unreg", &M); in createRegisterFatbinFunction()
537 FunctionCallee RegFatbin = M.getOrInsertFunction( in createRegisterFatbinFunction()
544 M.getOrInsertFunction("__cudaRegisterFatBinaryEnd", RegFatEndTy); in createRegisterFatbinFunction()
549 FunctionCallee UnregFatbin = M.getOrInsertFunction( in createRegisterFatbinFunction()
556 FunctionCallee AtExit = M.getOrInsertFunction("atexit", AtExitTy); in createRegisterFatbinFunction()
559 M, Type::getInt8PtrTy(C)->getPointerTo(), false, in createRegisterFatbinFunction()
571 Align(M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C)))); in createRegisterFatbinFunction()
572 CtorBuilder.CreateCall(createRegisterGlobalsFunction(M, IsHIP), Handle); in createRegisterFatbinFunction()
584 Align(M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C)))); in createRegisterFatbinFunction()
589 appendToGlobalCtors(M, CtorFunc, /*Priority*/ 1); in createRegisterFatbinFunction()
594 Error wrapOpenMPBinaries(Module &M, ArrayRef<ArrayRef<char>> Images) { in wrapOpenMPBinaries() argument
595 GlobalVariable *Desc = createBinDesc(M, Images); in wrapOpenMPBinaries()
599 createRegisterFunction(M, Desc); in wrapOpenMPBinaries()
600 createUnregisterFunction(M, Desc); in wrapOpenMPBinaries()
604 Error wrapCudaBinary(Module &M, ArrayRef<char> Image) { in wrapCudaBinary() argument
605 GlobalVariable *Desc = createFatbinDesc(M, Image, /* IsHIP */ false); in wrapCudaBinary()
610 createRegisterFatbinFunction(M, Desc, /* IsHIP */ false); in wrapCudaBinary()
614 Error wrapHIPBinary(Module &M, ArrayRef<char> Image) { in wrapHIPBinary() argument
615 GlobalVariable *Desc = createFatbinDesc(M, Image, /* IsHIP */ true); in wrapHIPBinary()
620 createRegisterFatbinFunction(M, Desc, /* IsHIP */ true); in wrapHIPBinary()