当前位置: 首页>>代码示例>>C++>>正文


C++ CodeGenModule::getLLVMContext方法代码示例

本文整理汇总了C++中codegen::CodeGenModule::getLLVMContext方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenModule::getLLVMContext方法的具体用法?C++ CodeGenModule::getLLVMContext怎么用?C++ CodeGenModule::getLLVMContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在codegen::CodeGenModule的用法示例。


在下文中一共展示了CodeGenModule::getLLVMContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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


注:本文中的codegen::CodeGenModule::getLLVMContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。