Lines Matching refs:CGM
46 static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM,
51 static llvm::Constant *buildCopyHelper(CodeGenModule &CGM, in buildCopyHelper() argument
53 return CodeGenFunction(CGM).GenerateCopyHelperFunction(blockInfo); in buildCopyHelper()
57 static llvm::Constant *buildDisposeHelper(CodeGenModule &CGM, in buildDisposeHelper() argument
59 return CodeGenFunction(CGM).GenerateDestroyHelperFunction(blockInfo); in buildDisposeHelper()
76 static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM, in buildBlockDescriptor() argument
78 ASTContext &C = CGM.getContext(); in buildBlockDescriptor()
80 llvm::Type *ulong = CGM.getTypes().ConvertType(C.UnsignedLongTy); in buildBlockDescriptor()
82 if (CGM.getLangOpts().OpenCL) in buildBlockDescriptor()
85 CGM.getLLVMContext(), C.getTargetAddressSpace(LangAS::opencl_constant)); in buildBlockDescriptor()
87 i8p = CGM.getTypes().ConvertType(C.VoidPtrTy); in buildBlockDescriptor()
104 elements.push_back(buildCopyHelper(CGM, blockInfo)); in buildBlockDescriptor()
107 elements.push_back(buildDisposeHelper(CGM, blockInfo)); in buildBlockDescriptor()
112 CGM.getContext().getObjCEncodingForBlock(blockInfo.getBlockExpr()); in buildBlockDescriptor()
114 CGM.GetAddrOfConstantCString(typeAtEncoding).getPointer(), i8p)); in buildBlockDescriptor()
118 if (CGM.getLangOpts().getGC() != LangOptions::NonGC) in buildBlockDescriptor()
119 elements.push_back(CGM.getObjCRuntime().BuildGCBlockLayout(CGM, blockInfo)); in buildBlockDescriptor()
121 elements.push_back(CGM.getObjCRuntime().BuildRCBlockLayout(CGM, blockInfo)); in buildBlockDescriptor()
129 new llvm::GlobalVariable(CGM.getModule(), init->getType(), true, in buildBlockDescriptor()
133 return llvm::ConstantExpr::getBitCast(global, CGM.getBlockDescriptorType()); in buildBlockDescriptor()
262 static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM, in tryCaptureAsConstant() argument
280 if (CGM.getLangOpts().CPlusPlus && !isSafeForCXXConstantCapture(type)) in tryCaptureAsConstant()
289 return CGM.EmitConstantInit(*var, CGF); in tryCaptureAsConstant()
298 static void initializeForBlockHeader(CodeGenModule &CGM, CGBlockInfo &info, in initializeForBlockHeader() argument
302 assert(CGM.getIntSize() <= CGM.getPointerSize()); in initializeForBlockHeader()
303 assert(CGM.getIntAlign() <= CGM.getPointerAlign()); in initializeForBlockHeader()
304 assert((2 * CGM.getIntSize()).isMultipleOf(CGM.getPointerAlign())); in initializeForBlockHeader()
306 info.BlockAlign = CGM.getPointerAlign(); in initializeForBlockHeader()
307 info.BlockSize = 3 * CGM.getPointerSize() + 2 * CGM.getIntSize(); in initializeForBlockHeader()
310 elementTypes.push_back(CGM.VoidPtrTy); in initializeForBlockHeader()
311 elementTypes.push_back(CGM.IntTy); in initializeForBlockHeader()
312 elementTypes.push_back(CGM.IntTy); in initializeForBlockHeader()
313 elementTypes.push_back(CGM.VoidPtrTy); in initializeForBlockHeader()
314 elementTypes.push_back(CGM.getBlockDescriptorType()); in initializeForBlockHeader()
321 static void computeBlockInfo(CodeGenModule &CGM, CodeGenFunction *CGF, in computeBlockInfo() argument
323 ASTContext &C = CGM.getContext(); in computeBlockInfo()
327 initializeForBlockHeader(CGM, info, elementTypes); in computeBlockInfo()
331 llvm::StructType::get(CGM.getLLVMContext(), elementTypes, true); in computeBlockInfo()
336 CGM.getLangOpts().getGC() == LangOptions::NonGC) in computeBlockInfo()
354 llvm::Type *llvmType = CGM.getTypes().ConvertType(thisType); in computeBlockInfo()
356 = CGM.getContext().getTypeInfoInChars(thisType); in computeBlockInfo()
373 CharUnits align = CGM.getPointerAlign(); in computeBlockInfo()
376 layout.push_back(BlockLayoutChunk(align, CGM.getPointerSize(), in computeBlockInfo()
378 CGM.VoidPtrTy)); in computeBlockInfo()
384 if (llvm::Constant *constant = tryCaptureAsConstant(CGM, CGF, variable)) { in computeBlockInfo()
423 } else if (CGM.getLangOpts().CPlusPlus) { in computeBlockInfo()
440 CGM.getTypes().ConvertTypeForMem(VT); in computeBlockInfo()
448 llvm::StructType::get(CGM.getLLVMContext(), elementTypes, true); in computeBlockInfo()
525 elementTypes.push_back(llvm::ArrayType::get(CGM.Int8Ty, in computeBlockInfo()
543 elementTypes.push_back(llvm::ArrayType::get(CGM.Int8Ty, in computeBlockInfo()
556 llvm::StructType::get(CGM.getLLVMContext(), elementTypes, true); in computeBlockInfo()
573 computeBlockInfo(CGF.CGM, &CGF, blockInfo); in enterBlockScope()
679 computeBlockInfo(CGM, this, blockInfo); in EmitBlockLiteral()
697 = CodeGenFunction(CGM, true).GenerateBlockFunction(CurGD, blockInfo, in EmitBlockLiteral()
704 return buildGlobalBlock(CGM, blockInfo, blockFn); in EmitBlockLiteral()
708 llvm::Constant *isa = CGM.getNSConcreteStackBlock(); in EmitBlockLiteral()
712 llvm::Constant *descriptor = buildBlockDescriptor(CGM, blockInfo); in EmitBlockLiteral()
964 llvm::PointerType::getUnqual(CGM.getGenericBlockLiteralType()); in EmitBlockCallExpr()
972 Builder.CreateStructGEP(CGM.getGenericBlockLiteralType(), BlockLiteral, 3); in EmitBlockCallExpr()
990 CGM.getTypes().arrangeBlockFunctionCall(Args, FuncTy); in EmitBlockCallExpr()
993 llvm::Type *BlockFTy = CGM.getTypes().GetFunctionType(FnInfo); in EmitBlockCallExpr()
1058 static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM, in buildGlobalBlock() argument
1067 fields[0] = CGM.getNSConcreteGlobalBlock(); in buildGlobalBlock()
1073 fields[1] = llvm::ConstantInt::get(CGM.IntTy, flags.getBitMask()); in buildGlobalBlock()
1076 fields[2] = llvm::Constant::getNullValue(CGM.IntTy); in buildGlobalBlock()
1082 fields[4] = buildBlockDescriptor(CGM, blockInfo); in buildGlobalBlock()
1087 new llvm::GlobalVariable(CGM.getModule(), in buildGlobalBlock()
1097 CGM.getTypes().ConvertType(blockInfo.getBlockExpr()->getType()); in buildGlobalBlock()
1107 if (CGM.getCodeGenOpts().OptimizationLevel == 0) { in setBlockContextParameter()
1115 if (CGM.getCodeGenOpts().getDebugInfo() >= in setBlockContextParameter()
1169 IdentifierInfo *II = &CGM.getContext().Idents.get(".block_descriptor"); in GenerateBlockFunction()
1181 CGM.getTypes().arrangeBlockFunctionDeclaration(fnType, args); in GenerateBlockFunction()
1182 if (CGM.ReturnSlotInterferesWithArgs(fnInfo)) in GenerateBlockFunction()
1185 llvm::FunctionType *fnLLVMType = CGM.getTypes().GetFunctionType(fnInfo); in GenerateBlockFunction()
1187 StringRef name = CGM.getBlockMangledName(GD, blockDecl); in GenerateBlockFunction()
1189 fnLLVMType, llvm::GlobalValue::InternalLinkage, name, &CGM.getModule()); in GenerateBlockFunction()
1190 CGM.SetInternalFunctionAttributes(blockDecl, fn, fnInfo); in GenerateBlockFunction()
1202 if (CGM.getCodeGenOpts().OptimizationLevel == 0) { in GenerateBlockFunction()
1265 if (CGM.getCodeGenOpts().getDebugInfo() >= in GenerateBlockFunction()
1335 CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args); in GenerateCopyHelperFunction()
1339 llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); in GenerateCopyHelperFunction()
1343 "__copy_helper_block_", &CGM.getModule()); in GenerateCopyHelperFunction()
1346 = &CGM.getContext().Idents.get("__copy_helper_block_"); in GenerateCopyHelperFunction()
1356 CGM.SetInternalFunctionAttributes(nullptr, Fn, FI); in GenerateCopyHelperFunction()
1447 if (CGM.getCodeGenOpts().OptimizationLevel == 0) { in GenerateCopyHelperFunction()
1474 CGM.getContext().getBlockVarCopyInits(variable); in GenerateCopyHelperFunction()
1481 EmitRuntimeCallOrInvoke(CGM.getBlockObjectAssign(), args); in GenerateCopyHelperFunction()
1483 EmitNounwindRuntimeCall(CGM.getBlockObjectAssign(), args); in GenerateCopyHelperFunction()
1511 CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args); in GenerateDestroyHelperFunction()
1515 llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); in GenerateDestroyHelperFunction()
1519 "__destroy_helper_block_", &CGM.getModule()); in GenerateDestroyHelperFunction()
1522 = &CGM.getContext().Idents.get("__destroy_helper_block_"); in GenerateDestroyHelperFunction()
1530 CGM.SetInternalFunctionAttributes(nullptr, Fn, FI); in GenerateDestroyHelperFunction()
1649 llvm::Value *fn = CGF.CGM.getBlockObjectAssign(); in emitCopy()
1703 if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) { in emitCopy()
1797 CGF.CGM.getTypes().arrangeBuiltinFunctionDeclaration(R, args); in generateByrefCopyHelper()
1799 llvm::FunctionType *LTy = CGF.CGM.getTypes().GetFunctionType(FI); in generateByrefCopyHelper()
1805 "__Block_byref_object_copy_", &CGF.CGM.getModule()); in generateByrefCopyHelper()
1817 CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI); in generateByrefCopyHelper()
1849 static llvm::Constant *buildByrefCopyHelper(CodeGenModule &CGM, in buildByrefCopyHelper() argument
1852 CodeGenFunction CGF(CGM); in buildByrefCopyHelper()
1870 CGF.CGM.getTypes().arrangeBuiltinFunctionDeclaration(R, args); in generateByrefDisposeHelper()
1872 llvm::FunctionType *LTy = CGF.CGM.getTypes().GetFunctionType(FI); in generateByrefDisposeHelper()
1879 &CGF.CGM.getModule()); in generateByrefDisposeHelper()
1891 CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI); in generateByrefDisposeHelper()
1911 static llvm::Constant *buildByrefDisposeHelper(CodeGenModule &CGM, in buildByrefDisposeHelper() argument
1914 CodeGenFunction CGF(CGM); in buildByrefDisposeHelper()
1921 static T *buildByrefHelpers(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, in buildByrefHelpers() argument
1928 = CGM.ByrefHelpersCache.FindNodeOrInsertPos(id, insertPos); in buildByrefHelpers()
1931 generator.CopyHelper = buildByrefCopyHelper(CGM, byrefInfo, generator); in buildByrefHelpers()
1932 generator.DisposeHelper = buildByrefDisposeHelper(CGM, byrefInfo, generator); in buildByrefHelpers()
1934 T *copy = new (CGM.getContext()) T(std::move(generator)); in buildByrefHelpers()
1935 CGM.ByrefHelpersCache.InsertNode(copy, insertPos); in buildByrefHelpers()
1956 const Expr *copyExpr = CGM.getContext().getBlockVarCopyInits(&var); in buildByrefHelpers()
1960 CGM, byrefInfo, CXXByrefHelpers(valueAlignment, type, copyExpr)); in buildByrefHelpers()
1982 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
1990 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
1996 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
2006 } else if (CGM.getContext().isObjCNSObjectType(type) || in buildByrefHelpers()
2016 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
2124 } else if (CGM.getDataLayout().getABITypeAlignment(varTy) in getBlockByrefInfo()
2212 if (CGM.getLangOpts().ObjCGCBitmapPrint) { in emitByrefStructureInit()
2235 CharUnits byrefSize = CGM.GetTargetTypeStoreSize(byrefType); in emitByrefStructureInit()
2247 auto layoutInfo = CGM.getObjCRuntime().BuildByrefLayout(CGM, type); in emitByrefStructureInit()
2253 llvm::Value *F = CGM.getBlockObjectDispose(); in BuildBlockRelease()
2280 if (CGM.getLangOpts().getGC() == LangOptions::GCOnly) in enterByrefCleanup()
2288 static void configureBlocksRuntimeObject(CodeGenModule &CGM, in configureBlocksRuntimeObject() argument
2292 if (CGM.getTarget().getTriple().isOSBinFormatCOFF()) { in configureBlocksRuntimeObject()
2293 IdentifierInfo &II = CGM.getContext().Idents.get(C->getName()); in configureBlocksRuntimeObject()
2294 TranslationUnitDecl *TUDecl = CGM.getContext().getTranslationUnitDecl(); in configureBlocksRuntimeObject()
2317 if (!CGM.getLangOpts().BlocksRuntimeOptional) in configureBlocksRuntimeObject()