• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ codegen::CodeGenModule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ colladafw::MeshPrimitive类代码示例发布时间:2022-05-31
下一篇:
C++ codedocument::Position类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap