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


C++ LLGlobalVariable::getType方法代码示例

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


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

示例1: LLVM_D_GetRuntimeGlobal

llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name)
{
    LLGlobalVariable* gv = target->getNamedGlobal(name);
    if (gv) {
        return gv;
    }

    if (noruntime) {
        error("No implicit runtime calls allowed with -noruntime option enabled");
        fatal();
    }

    if (!M) {
        LLVM_D_InitRuntime();
    }

    LLGlobalVariable* g = M->getNamedGlobal(name);
    if (!g) {
        error("Runtime global '%s' was not found", name);
        fatal();
        //return NULL;
    }

    LLPointerType* t = g->getType();
    return new LLGlobalVariable(*target, t->getElementType(), g->isConstant(),
                                g->getLinkage(), NULL, g->getName());
}
开发者ID:SiegeLord,项目名称:ldc,代码行数:27,代码来源:runtime.cpp

示例2: getOrCreateGlobal

llvm::GlobalVariable *getRuntimeGlobal(Loc &loc, llvm::Module &target,
                                       const char *name) {
  LLGlobalVariable *gv = target.getNamedGlobal(name);
  if (gv) {
    return gv;
  }

  checkForImplicitGCCall(loc, name);

  if (!M) {
    initRuntime();
  }

  LLGlobalVariable *g = M->getNamedGlobal(name);
  if (!g) {
    error(loc, "Runtime global '%s' was not found", name);
    fatal();
    // return NULL;
  }

  LLPointerType *t = g->getType();
  return getOrCreateGlobal(loc, target, t->getElementType(), g->isConstant(),
                           g->getLinkage(), nullptr, g->getName());
}
开发者ID:Stretto,项目名称:Calypso,代码行数:24,代码来源:runtime.cpp

示例3: genmoduleinfo


//.........这里部分代码省略.........
    }
    // has class array?
    if (!classInits.empty())
    {
        localClassesTy = llvm::ArrayType::get(classinfoTy, classInits.size());
        localClasses = LLConstantArray::get(localClassesTy, classInits);
    }

    // These must match the values in druntime/src/object_.d
    #define MIstandalone      4
    #define MItlsctor         8
    #define MItlsdtor         0x10
    #define MIctor            0x20
    #define MIdtor            0x40
    #define MIxgetMembers     0x80
    #define MIictor           0x100
    #define MIunitTest        0x200
    #define MIimportedModules 0x400
    #define MIlocalClasses    0x800
    #define MInew             0x80000000   // it's the "new" layout

    llvm::Function* fsharedctor = build_module_shared_ctor();
    llvm::Function* fshareddtor = build_module_shared_dtor();
    llvm::Function* funittest = build_module_unittest();
    llvm::Function* fctor = build_module_ctor();
    llvm::Function* fdtor = build_module_dtor();

    unsigned flags = MInew;
    if (fctor)
        flags |= MItlsctor;
    if (fdtor)
        flags |= MItlsdtor;
    if (fsharedctor)
        flags |= MIctor;
    if (fshareddtor)
        flags |= MIdtor;
#if 0
    if (fgetmembers)
        flags |= MIxgetMembers;
    if (fictor)
        flags |= MIictor;
#endif
    if (funittest)
        flags |= MIunitTest;
    if (importedModules)
        flags |= MIimportedModules;
    if (localClasses)
        flags |= MIlocalClasses;

    if (!needmoduleinfo)
        flags |= MIstandalone;

    b.push_uint(flags); // flags
    b.push_uint(0);     // index

    if (fctor)
        b.push(fctor);
    if (fdtor)
        b.push(fdtor);
    if (fsharedctor)
        b.push(fsharedctor);
    if (fshareddtor)
        b.push(fshareddtor);
#if 0
    if (fgetmembers)
        b.push(fgetmembers);
    if (fictor)
        b.push(fictor);
#endif
    if (funittest)
        b.push(funittest);
    if (importedModules) {
        b.push_size(importInits.size());
        b.push(importedModules);
    }
    if (localClasses) {
        b.push_size(classInits.size());
        b.push(localClasses);
    }

    // Put out module name as a 0-terminated string.
    const char *name = toPrettyChars();
    const size_t len = strlen(name) + 1;
    llvm::IntegerType *it = llvm::IntegerType::getInt8Ty(gIR->context());
    llvm::ArrayType *at = llvm::ArrayType::get(it, len);
    b.push(toConstantArray(it, at, name, len, false));

    // create and set initializer
    LLGlobalVariable *moduleInfoSym = moduleInfoSymbol();
    b.finalize(moduleInfoSym->getType()->getPointerElementType(), moduleInfoSym);
    moduleInfoSym->setLinkage(llvm::GlobalValue::ExternalLinkage);

    if (global.params.isLinux) {
        build_dso_registry_calls(moduleInfoSym);
    } else {
        // build the modulereference and ctor for registering it
        LLFunction* mictor = build_module_reference_and_ctor(moduleInfoSym);
        AppendFunctionToLLVMGlobalCtorsDtors(mictor, 65535, true);
    }
}
开发者ID:doniexun,项目名称:ldc,代码行数:101,代码来源:module.cpp


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