Lines Matching defs:M

31 IntegerType *getSizeTTy(Module &M) {
32 return M.getDataLayout().getIntPtrType(M.getContext());
41 StructType *getDeviceImageTy(Module &M) {
42 LLVMContext &C = M.getContext();
52 PointerType *getDeviceImagePtrTy(Module &M) {
53 return PointerType::getUnqual(getDeviceImageTy(M));
62 StructType *getBinDescTy(Module &M) {
63 LLVMContext &C = M.getContext();
67 "__tgt_bin_desc", Type::getInt32Ty(C), getDeviceImagePtrTy(M),
72 PointerType *getBinDescPtrTy(Module &M) {
73 return PointerType::getUnqual(getBinDescTy(M));
114 GlobalVariable *createBinDesc(Module &M, ArrayRef<ArrayRef<char>> Bufs,
117 LLVMContext &C = M.getContext();
120 auto *Zero = ConstantInt::get(getSizeTTy(M), 0u);
129 auto *Image = new GlobalVariable(M, Data->getType(), /*isConstant=*/true,
150 auto *Begin = ConstantInt::get(getSizeTTy(M), Entry->ImageOffset);
152 ConstantInt::get(getSizeTTy(M), Entry->ImageOffset + Entry->ImageSize);
161 ImagesInits.push_back(ConstantStruct::get(getDeviceImageTy(M), ImageB,
167 ArrayType::get(getDeviceImageTy(M), ImagesInits.size()), ImagesInits);
170 new GlobalVariable(M, ImagesData->getType(), /*isConstant*/ true,
180 getBinDescTy(M),
184 return new GlobalVariable(M, DescInit->getType(), /*isConstant*/ true,
189 Function *createUnregisterFunction(Module &M, GlobalVariable *BinDesc,
191 LLVMContext &C = M.getContext();
195 ".omp_offloading.descriptor_unreg" + Suffix, &M);
199 auto *UnRegFuncTy = FunctionType::get(Type::getVoidTy(C), getBinDescPtrTy(M),
202 M.getOrInsertFunction("__tgt_unregister_lib", UnRegFuncTy);
212 void createRegisterFunction(Module &M, GlobalVariable *BinDesc,
214 LLVMContext &C = M.getContext();
217 ".omp_offloading.descriptor_reg" + Suffix, &M);
221 auto *RegFuncTy = FunctionType::get(Type::getVoidTy(C), getBinDescPtrTy(M),
224 M.getOrInsertFunction("__tgt_register_lib", RegFuncTy);
228 FunctionCallee AtExit = M.getOrInsertFunction("atexit", AtExitTy);
230 Function *UnregFunc = createUnregisterFunction(M, BinDesc, Suffix);
245 appendToGlobalCtors(M, Func, /*Priority=*/101);
254 StructType *getFatbinWrapperTy(Module &M) {
255 LLVMContext &C = M.getContext();
264 /// Embed the image \p Image into the module \p M so it can be found by the
266 GlobalVariable *createFatbinDesc(Module &M, ArrayRef<char> Image, bool IsHIP,
268 LLVMContext &C = M.getContext();
270 llvm::Triple Triple = llvm::Triple(M.getTargetTriple());
277 auto *Fatbin = new GlobalVariable(M, Data->getType(), /*isConstant*/ true,
293 ConstantStruct::get(getFatbinWrapperTy(M), FatbinWrapper);
296 new GlobalVariable(M, getFatbinWrapperTy(M),
328 Function *createRegisterGlobalsFunction(Module &M, bool IsHIP,
332 LLVMContext &C = M.getContext();
344 FunctionCallee RegFunc = M.getOrInsertFunction(
351 getSizeTTy(M), Type::getInt32Ty(C), Type::getInt32Ty(C)},
353 FunctionCallee RegVar = M.getOrInsertFunction(
362 FunctionCallee RegSurface = M.getOrInsertFunction(
371 FunctionCallee RegTexture = M.getOrInsertFunction(
378 IsHIP ? ".hip.globals_reg" : ".cuda.globals_reg", &M);
398 Builder.CreateInBoundsGEP(offloading::getEntryTy(M), Entry,
399 {ConstantInt::get(getSizeTTy(M), 0),
403 Builder.CreateInBoundsGEP(offloading::getEntryTy(M), Entry,
404 {ConstantInt::get(getSizeTTy(M), 0),
408 Builder.CreateInBoundsGEP(offloading::getEntryTy(M), Entry,
409 {ConstantInt::get(getSizeTTy(M), 0),
411 auto *Size = Builder.CreateLoad(getSizeTTy(M), SizePtr, "size");
413 Builder.CreateInBoundsGEP(offloading::getEntryTy(M), Entry,
414 {ConstantInt::get(getSizeTTy(M), 0),
418 Builder.CreateInBoundsGEP(offloading::getEntryTy(M), Entry,
419 {ConstantInt::get(getSizeTTy(M), 0),
442 Builder.CreateICmpEQ(Size, ConstantInt::getNullValue(getSizeTTy(M)));
492 offloading::getEntryTy(M), Entry, ConstantInt::get(getSizeTTy(M), 1));
496 ArrayType::get(offloading::getEntryTy(M), 0), EntriesE,
497 ArrayRef<Constant *>({ConstantInt::get(getSizeTTy(M), 0),
498 ConstantInt::get(getSizeTTy(M), 0)})));
501 ArrayType::get(offloading::getEntryTy(M), 0), EntriesB,
502 ArrayRef<Constant *>({ConstantInt::get(getSizeTTy(M), 0),
503 ConstantInt::get(getSizeTTy(M), 0)})),
515 void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
519 LLVMContext &C = M.getContext();
523 (IsHIP ? ".hip.fatbin_reg" : ".cuda.fatbin_reg") + Suffix, &M);
529 (IsHIP ? ".hip.fatbin_unreg" : ".cuda.fatbin_unreg") + Suffix, &M);
536 FunctionCallee RegFatbin = M.getOrInsertFunction(
542 M.getOrInsertFunction("__cudaRegisterFatBinaryEnd", RegFatEndTy);
546 FunctionCallee UnregFatbin = M.getOrInsertFunction(
552 FunctionCallee AtExit = M.getOrInsertFunction("atexit", AtExitTy);
555 M, PtrTy, false, llvm::GlobalValue::InternalLinkage,
566 Align(M.getDataLayout().getPointerTypeSize(PtrTy)));
567 CtorBuilder.CreateCall(createRegisterGlobalsFunction(M, IsHIP, EntryArray,
582 Align(M.getDataLayout().getPointerTypeSize(PtrTy)));
587 appendToGlobalCtors(M, CtorFunc, /*Priority=*/101);
591 Error offloading::wrapOpenMPBinaries(Module &M, ArrayRef<ArrayRef<char>> Images,
595 createBinDesc(M, Images, EntryArray, Suffix, Relocatable);
599 createRegisterFunction(M, Desc, Suffix);
603 Error offloading::wrapCudaBinary(Module &M, ArrayRef<char> Image,
607 GlobalVariable *Desc = createFatbinDesc(M, Image, /*IsHip=*/false, Suffix);
612 createRegisterFatbinFunction(M, Desc, /*IsHip=*/false, EntryArray, Suffix,
617 Error offloading::wrapHIPBinary(Module &M, ArrayRef<char> Image,
620 GlobalVariable *Desc = createFatbinDesc(M, Image, /*IsHip=*/true, Suffix);
625 createRegisterFatbinFunction(M, Desc, /*IsHip=*/true, EntryArray, Suffix,