本文整理汇总了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());
}
示例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());
}
示例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);
}
}