本文整理汇总了C++中LLGlobalVariable::setLinkage方法的典型用法代码示例。如果您正苦于以下问题:C++ LLGlobalVariable::setLinkage方法的具体用法?C++ LLGlobalVariable::setLinkage怎么用?C++ LLGlobalVariable::setLinkage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLGlobalVariable
的用法示例。
在下文中一共展示了LLGlobalVariable::setLinkage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DtoDeclareTypeInfo
void DtoDeclareTypeInfo(TypeInfoDeclaration* tid)
{
DtoResolveTypeInfo(tid);
if (tid->ir.declared) return;
tid->ir.declared = true;
Logger::println("DtoDeclareTypeInfo(%s)", tid->toChars());
LOG_SCOPE;
if (Logger::enabled())
{
std::string mangled(tid->mangle());
Logger::println("type = '%s'", tid->tinfo->toChars());
Logger::println("typeinfo mangle: %s", mangled.c_str());
}
IrGlobal* irg = tid->ir.irGlobal;
assert(irg->value != NULL);
// this is a declaration of a builtin __initZ var
if (tid->tinfo->builtinTypeInfo()) {
LLGlobalVariable* g = isaGlobalVar(irg->value);
g->setLinkage(llvm::GlobalValue::ExternalLinkage);
return;
}
// define custom typedef
tid->llvmDefine();
}
示例2: TypeInfoDeclaration_codegen
void TypeInfoDeclaration_codegen(TypeInfoDeclaration *decl, IRState *p) {
IF_LOG Logger::println("TypeInfoDeclaration::codegen(%s)",
decl->toPrettyChars());
LOG_SCOPE;
if (decl->ir.isDefined()) {
return;
}
decl->ir.setDefined();
std::string mangled(mangle(decl));
IF_LOG {
Logger::println("type = '%s'", decl->tinfo->toChars());
Logger::println("typeinfo mangle: %s", mangled.c_str());
}
IrGlobal *irg = getIrGlobal(decl, true);
irg->value = gIR->module.getGlobalVariable(mangled);
if (irg->value) {
irg->type = irg->value->getType()->getContainedType(0);
assert(irg->type->isStructTy());
} else {
if (builtinTypeInfo(
decl->tinfo)) { // this is a declaration of a builtin __initZ var
irg->type = Type::dtypeinfo->type->ctype->isClass()->getMemoryLLType();
} else {
irg->type = LLStructType::create(gIR->context(), decl->toPrettyChars());
}
irg->value = new llvm::GlobalVariable(gIR->module, irg->type, true,
llvm::GlobalValue::ExternalLinkage,
nullptr, mangled);
}
emitTypeMetadata(decl);
// this is a declaration of a builtin __initZ var
if (builtinTypeInfo(decl->tinfo)) {
LLGlobalVariable *g = isaGlobalVar(irg->value);
g->setLinkage(llvm::GlobalValue::ExternalLinkage);
return;
}
// define custom typedef
LLVMDefineVisitor v;
decl->accept(&v);
}
示例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);
}
}