本文整理汇总了C++中IRGenModule::getLLVMContext方法的典型用法代码示例。如果您正苦于以下问题:C++ IRGenModule::getLLVMContext方法的具体用法?C++ IRGenModule::getLLVMContext怎么用?C++ IRGenModule::getLLVMContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRGenModule
的用法示例。
在下文中一共展示了IRGenModule::getLLVMContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromBitPattern
EnumPayload EnumPayload::fromBitPattern(IRGenModule &IGM,
APInt bitPattern,
EnumPayloadSchema schema) {
EnumPayload result;
schema.forEachType(IGM, [&](llvm::Type *type) {
unsigned bitSize = IGM.DataLayout.getTypeSizeInBits(type);
llvm::IntegerType *intTy
= llvm::IntegerType::get(IGM.getLLVMContext(), bitSize);
// Take some bits off of the bottom of the pattern.
auto bits = bitPattern.zextOrTrunc(bitSize);
auto val = llvm::ConstantInt::get(intTy, bits);
if (val->getType() != type) {
if (type->isPointerTy())
val = llvm::ConstantExpr::getIntToPtr(val, type);
else
val = llvm::ConstantExpr::getBitCast(val, type);
}
result.PayloadValues.push_back(val);
// Shift the remaining bits down.
bitPattern = bitPattern.lshr(bitSize);
});
return result;
}
示例2: IGM
IRGenFunction::IRGenFunction(IRGenModule &IGM,
llvm::Function *Fn,
const SILDebugScope *DbgScope,
Optional<SILLocation> DbgLoc)
: IGM(IGM), Builder(IGM.getLLVMContext()),
CurFn(Fn), DbgScope(DbgScope)
{
// Make sure the instructions in this function are attached its debug scope.
if (IGM.DebugInfo) {
// Functions, especially artificial thunks and closures, are often
// generated on-the-fly while we are in the middle of another
// function. Be nice and preserve the current debug location until
// after we're done with this function.
IGM.DebugInfo->pushLoc();
}
// Apply sanitizer attributes to the function.
// TODO: Check if the function is ASan black listed either in the external
// file or via annotations.
if (IGM.IRGen.Opts.Sanitize == SanitizerKind::Address)
Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
if (IGM.IRGen.Opts.Sanitize == SanitizerKind::Thread)
Fn->addFnAttr(llvm::Attribute::SanitizeThread);
emitPrologue();
}
示例3: IGM
IRGenFunction::IRGenFunction(IRGenModule &IGM, llvm::Function *Fn,
const SILDebugScope *DbgScope,
Optional<SILLocation> DbgLoc)
: IGM(IGM), Builder(IGM.getLLVMContext(),
IGM.DebugInfo && !IGM.Context.LangOpts.DebuggerSupport),
CurFn(Fn), DbgScope(DbgScope) {
// Make sure the instructions in this function are attached its debug scope.
if (IGM.DebugInfo) {
// Functions, especially artificial thunks and closures, are often
// generated on-the-fly while we are in the middle of another
// function. Be nice and preserve the current debug location until
// after we're done with this function.
IGM.DebugInfo->pushLoc();
}
emitPrologue();
}