本文整理汇总了C++中LLStructType::setBody方法的典型用法代码示例。如果您正苦于以下问题:C++ LLStructType::setBody方法的具体用法?C++ LLStructType::setBody怎么用?C++ LLStructType::setBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLStructType
的用法示例。
在下文中一共展示了LLStructType::setBody方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DtoType
LLStructType *DtoModuleReferenceType() {
if (gIR->moduleRefType) {
return gIR->moduleRefType;
}
// this is a recursive type so start out with a struct without body
LLStructType *st = LLStructType::create(gIR->context(), "ModuleReference");
// add members
LLType *types[] = {getPtrToType(st),
DtoType(Module::moduleinfo->type->pointerTo())};
// resolve type
st->setBody(types);
// done
gIR->moduleRefType = st;
return st;
}
示例2: finalize
void RTTIBuilder::finalize(LLType* type, LLValue* value)
{
llvm::ArrayRef<LLConstant*> inits = llvm::makeArrayRef(this->inits);
LLStructType *st = isaStruct(type);
assert(st);
// set struct body
if (st->isOpaque()) {
std::vector<LLType*> types;
for (int i = 0, n = inits.size(); i < n; ++i)
types.push_back(inits[i]->getType());
st->setBody(types);
}
// create the inititalizer
LLConstant* tiInit = LLConstantStruct::get(st, inits);
// set the initializer
isaGlobalVar(value)->setInitializer(tiInit);
}
示例3: finalize
void RTTIBuilder::finalize(LLType* type, LLValue* value)
{
llvm::ArrayRef<LLConstant*> inits = llvm::makeArrayRef(this->inits);
LLStructType *st = isaStruct(type);
assert(st);
// set struct body
if (st->isOpaque()) {
const int n = inits.size();
std::vector<LLType*> types;
types.reserve(n);
for (int i = 0; i < n; ++i)
types.push_back(inits[i]->getType());
st->setBody(types);
}
// create the inititalizer
LLConstant* tiInit = LLConstantStruct::get(st, inits);
// set the initializer
llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(value);
gvar->setInitializer(tiInit);
gvar->setLinkage(TYPEINFO_LINKAGE_TYPE);
}
示例4: DtoModuleReferenceType
LLStructType* DtoModuleReferenceType()
{
if (gIR->moduleRefType)
return gIR->moduleRefType;
// this is a recursive type so start out with a struct without body
LLStructType* st = LLStructType::create(gIR->context(), "ModuleReference");
// add members
std::vector<LLType*> types;
types.push_back(getPtrToType(st));
#if DMDV1
types.push_back(DtoType(Module::moduleinfo->type));
#else
types.push_back(DtoType(Module::moduleinfo->type->pointerTo()));
#endif
// resolve type
st->setBody(types);
// done
gIR->moduleRefType = st;
return st;
}
示例5: DtoMutexType
LLStructType* DtoMutexType()
{
if (gIR->mutexType)
return gIR->mutexType;
// The structures defined here must be the same as in druntime/src/rt/critical.c
// Windows
if (global.params.targetTriple.isOSWindows())
{
llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(gIR->context());
llvm::Type *Int32Ty = llvm::Type::getInt32Ty(gIR->context());
// Build RTL_CRITICAL_SECTION; size is 24 (32bit) or 40 (64bit)
LLType *rtl_types[] = {
VoidPtrTy, // Pointer to DebugInfo
Int32Ty, // LockCount
Int32Ty, // RecursionCount
VoidPtrTy, // Handle of OwningThread
VoidPtrTy, // Handle of LockSemaphore
VoidPtrTy // SpinCount
};
LLStructType* rtl = LLStructType::create(gIR->context(), rtl_types, "RTL_CRITICAL_SECTION");
// Build D_CRITICAL_SECTION; size is 28 (32bit) or 48 (64bit)
LLStructType *mutex = LLStructType::create(gIR->context(), "D_CRITICAL_SECTION");
LLType *types[] = { getPtrToType(mutex), rtl };
mutex->setBody(types);
// Cache type
gIR->mutexType = mutex;
return mutex;
}
// FreeBSD
else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD) {
// Just a pointer
return LLStructType::get(gIR->context(), DtoSize_t());
}
// pthread_fastlock
LLType *types2[] = {
DtoSize_t(),
LLType::getInt32Ty(gIR->context())
};
LLStructType* fastlock = LLStructType::get(gIR->context(), types2, false);
// pthread_mutex
LLType *types1[] = {
LLType::getInt32Ty(gIR->context()),
LLType::getInt32Ty(gIR->context()),
getVoidPtrType(),
LLType::getInt32Ty(gIR->context()),
fastlock
};
LLStructType* pmutex = LLStructType::get(gIR->context(), types1, false);
// D_CRITICAL_SECTION
LLStructType* mutex = LLStructType::create(gIR->context(), "D_CRITICAL_SECTION");
LLType *types[] = { getPtrToType(mutex), pmutex };
mutex->setBody(types);
// Cache type
gIR->mutexType = mutex;
return pmutex;
}
示例6: DtoMutexType
LLStructType* DtoMutexType()
{
if (gIR->mutexType)
return gIR->mutexType;
// The structures defined here must be the same as in druntime/src/rt/critical.c
// Windows
if (global.params.os == OSWindows)
{
llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(gIR->context());
llvm::Type *Int32Ty = llvm::Type::getInt32Ty(gIR->context());
// Build RTL_CRITICAL_SECTION; size is 24 (32bit) or 40 (64bit)
std::vector<LLType*> rtl_types;
rtl_types.push_back(VoidPtrTy); // Pointer to DebugInfo
rtl_types.push_back(Int32Ty); // LockCount
rtl_types.push_back(Int32Ty); // RecursionCount
rtl_types.push_back(VoidPtrTy); // Handle of OwningThread
rtl_types.push_back(VoidPtrTy); // Handle of LockSemaphore
rtl_types.push_back(VoidPtrTy); // SpinCount
LLStructType* rtl = LLStructType::create(gIR->context(), rtl_types, "RTL_CRITICAL_SECTION");
// Build D_CRITICAL_SECTION; size is 28 (32bit) or 48 (64bit)
LLStructType* mutex = LLStructType::create(gIR->context(), "D_CRITICAL_SECTION");
std::vector<LLType*> types;
types.push_back(getPtrToType(mutex));
types.push_back(rtl);
mutex->setBody(types);
// Cache type
gIR->mutexType = mutex;
return mutex;
}
// FreeBSD
else if (global.params.os == OSFreeBSD) {
// Just a pointer
return LLStructType::get(gIR->context(), DtoSize_t());
}
// pthread_fastlock
std::vector<LLType*> types2;
types2.push_back(DtoSize_t());
types2.push_back(LLType::getInt32Ty(gIR->context()));
LLStructType* fastlock = LLStructType::get(gIR->context(), types2);
// pthread_mutex
std::vector<LLType*> types1;
types1.push_back(LLType::getInt32Ty(gIR->context()));
types1.push_back(LLType::getInt32Ty(gIR->context()));
types1.push_back(getVoidPtrType());
types1.push_back(LLType::getInt32Ty(gIR->context()));
types1.push_back(fastlock);
LLStructType* pmutex = LLStructType::get(gIR->context(), types1);
// D_CRITICAL_SECTION
LLStructType* mutex = LLStructType::create(gIR->context(), "D_CRITICAL_SECTION");
std::vector<LLType*> types;
types.push_back(getPtrToType(mutex));
types.push_back(pmutex);
mutex->setBody(types);
// Cache type
gIR->mutexType = mutex;
return pmutex;
}