本文整理汇总了C++中codegen::CodeGenModule类的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenModule类的具体用法?C++ CodeGenModule怎么用?C++ CodeGenModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CodeGenModule类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LookupFieldBitOffset
static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM,
const ObjCInterfaceDecl *OID,
const ObjCImplementationDecl *ID,
const ObjCIvarDecl *Ivar) {
const ObjCInterfaceDecl *Container = Ivar->getContainingInterface();
// FIXME: We should eliminate the need to have ObjCImplementationDecl passed
// in here; it should never be necessary because that should be the lexical
// decl context for the ivar.
// If we know have an implementation (and the ivar is in it) then
// look up in the implementation layout.
const ASTRecordLayout *RL;
if (ID && ID->getClassInterface() == Container)
RL = &CGM.getContext().getASTObjCImplementationLayout(ID);
else
RL = &CGM.getContext().getASTObjCInterfaceLayout(Container);
// Compute field index.
//
// FIXME: The index here is closely tied to how ASTContext::getObjCLayout is
// implemented. This should be fixed to get the information from the layout
// directly.
unsigned Index = 0;
for (const ObjCIvarDecl *IVD = Container->all_declared_ivar_begin();
IVD; IVD = IVD->getNextIvar()) {
if (Ivar == IVD)
break;
++Index;
}
assert(Index < RL->getFieldCount() && "Ivar is not inside record layout!");
return RL->getFieldOffset(Index);
}
开发者ID:asdlei00,项目名称:freebsd,代码行数:35,代码来源:CGObjCRuntime.cpp
示例2: ComputeIvarBaseOffset
uint64_t CGObjCRuntime::ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM,
const ObjCImplementationDecl *OID,
const ObjCIvarDecl *Ivar) {
return LookupFieldBitOffset(CGM, OID->getClassInterface(), OID, Ivar) /
CGM.getContext().getCharWidth();
}
开发者ID:asdlei00,项目名称:freebsd,代码行数:6,代码来源:CGObjCRuntime.cpp
示例3: CGObjCRuntime
CGObjCJit::CGObjCJit(CodeGen::CodeGenModule &cgm)
: CGObjCRuntime(cgm),
isUsable(false),
CGM(cgm),
VMContext(cgm.getLLVMContext()),
ObjCTypes(cgm),
JitInitFunction(0) {
//puts("Constructing CGObjCJit (host runtime proxy)");
llvm::PointerType *PtrToInt8Ty =
llvm::Type::getInt8Ty(VMContext)->getPointerTo();
NULLPtr = llvm::ConstantPointerNull::get(PtrToInt8Ty);
// TODO: For now, just searching for pre-loaded objc runtime
LOAD_FN(_objc_getClass, "objc_getClass");
// Don't bother to try the rest if the first one wasn't available
if (_objc_getClass) {
isUsable = true;
LOAD_FN(_objc_allocateClassPair, "objc_allocateClassPair");
LOAD_FN(_objc_registerClassPair, "objc_registerClassPair");
LOAD_FN(_objc_getProtocol, "objc_getProtocol");
LOAD_FN(_object_getClass, "object_getClass");
LOAD_FN(_sel_registerName, "sel_registerName");
LOAD_FN(_class_getClassVariable, "class_getClassVariable");
LOAD_FN(_class_addIvar, "class_addIvar");
LOAD_FN(_class_addProtocol, "class_addProtocol");
LOAD_FN(_class_getMethodImplementation, "class_getMethodImplementation");
LOAD_FN(_ivar_getOffset, "ivar_getOffset");
LOAD_FN(_NSGetSizeAndAlignment, "NSGetSizeAndAlignment");
//puts("Creating .objc_jit_init()");
llvm::FunctionType *initFuncType =
llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), false);
JitInitFunction =
cast<llvm::Function>(CGM.getModule().getOrInsertFunction(
llvm::StringRef(".objc_jit_init"),
initFuncType));
JitInitFunction->setLinkage(llvm::Function::PrivateLinkage);
JitInitFunction->setCallingConv(llvm::CallingConv::C);
JitInitBlock =
llvm::BasicBlock::Create(VMContext, "entry", JitInitFunction);
// Define VM objc_getClass function
fn_objc_getClass.init(&CGM, "objc_getClass",
ObjCTypes.ClassPtrTy,
ObjCTypes.Int8PtrTy,
NULL);
fn_objc_getMetaClass.init(&CGM, "objc_getMetaClass",
ObjCTypes.ClassPtrTy,
ObjCTypes.Int8PtrTy,
NULL);
fn_objc_getProtocol.init(&CGM, "objc_getProtocol",
ObjCTypes.ProtocolPtrTy,
ObjCTypes.Int8PtrTy,
NULL);
fn_object_getClass.init(&CGM, "object_getClass",
ObjCTypes.ClassPtrTy,
ObjCTypes.ObjectPtrTy,
NULL);
// Define VM class_addMethod and class_replaceMethod function calls for
// the init function
llvm::Type *ImpParams[] = {ObjCTypes.ObjectPtrTy, ObjCTypes.SelectorPtrTy};
ImpPtrTy = llvm::FunctionType::get(ObjCTypes.ObjectPtrTy,
ImpParams,
false)->getPointerTo();
fn_class_addMethod.init(&CGM, "class_addMethod",
llvm::Type::getInt8Ty(VMContext),
ObjCTypes.ClassPtrTy,
ObjCTypes.SelectorPtrTy,
ImpPtrTy,
ObjCTypes.Int8PtrTy,
NULL);
fn_class_replaceMethod.init(&CGM, "class_replaceMethod",
llvm::Type::getInt8Ty(VMContext),
ObjCTypes.ClassTy,
ObjCTypes.SelectorPtrTy,
ImpPtrTy,
ObjCTypes.Int8PtrTy,
NULL);
fn_class_getMethodImplementation.init(&CGM, "class_getMethodImplementation",
ImpPtrTy,
ObjCTypes.ClassPtrTy,
ObjCTypes.SelectorPtrTy,
NULL);
// Unfortunately, even though class_getMethodImplementation is provided by
//.........这里部分代码省略.........
开发者ID:eerolanguage,项目名称:clang-interpreter-runtime,代码行数:101,代码来源:CGObjCJit.cpp
示例4: ComputeIvarBaseOffset
uint64_t CGObjCRuntime::ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM,
const ObjCInterfaceDecl *OID,
const ObjCIvarDecl *Ivar) {
return LookupFieldBitOffset(CGM, OID, nullptr, Ivar) /
CGM.getContext().getCharWidth();
}
开发者ID:hsorby,项目名称:opencor,代码行数:6,代码来源:CGObjCRuntime.cpp
注:本文中的codegen::CodeGenModule类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论