forked from OSchip/llvm-project
simplify code by using the variadic StructType::get method.
llvm-svn: 48535
This commit is contained in:
parent
3e593cdb98
commit
554221e9fb
|
@ -50,8 +50,8 @@ llvm::Value *CGObjCGNU::generateMessageSend(llvm::LLVMFoldingBuilder &Builder,
|
|||
// Get the selector Type.
|
||||
const llvm::Type *PtrToInt8Ty =
|
||||
llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
|
||||
std::vector<const llvm::Type*> Str2(2, PtrToInt8Ty);
|
||||
const llvm::Type *SelStructTy = llvm::StructType::get(Str2);
|
||||
const llvm::Type *SelStructTy =
|
||||
llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, NULL);
|
||||
const llvm::Type *SelTy = llvm::PointerType::getUnqual(SelStructTy);
|
||||
|
||||
// Look up the selector.
|
||||
|
|
|
@ -81,38 +81,36 @@ void CodeGenModule::EmitGlobalCtors() {
|
|||
VoidArgs,
|
||||
false);
|
||||
// i32, function type pair
|
||||
CtorFields.push_back(llvm::PointerType::getUnqual(CtorFuncTy));
|
||||
llvm::StructType* CtorStructTy = llvm::StructType::get(CtorFields, false);
|
||||
const llvm::Type *FPType = llvm::PointerType::getUnqual(CtorFuncTy);
|
||||
llvm::StructType* CtorStructTy =
|
||||
llvm::StructType::get(llvm::Type::Int32Ty, FPType, NULL);
|
||||
// Array of fields
|
||||
llvm::ArrayType* GlobalCtorsTy = llvm::ArrayType::get(CtorStructTy,
|
||||
GlobalCtors.size());
|
||||
llvm::ArrayType* GlobalCtorsTy =
|
||||
llvm::ArrayType::get(CtorStructTy, GlobalCtors.size());
|
||||
|
||||
const std::string GlobalCtorsVar = std::string("llvm.global_ctors");
|
||||
// Define the global variable
|
||||
llvm::GlobalVariable *GlobalCtorsVal = new llvm::GlobalVariable(
|
||||
GlobalCtorsTy,
|
||||
false,
|
||||
llvm::GlobalValue::AppendingLinkage,
|
||||
(llvm::Constant*)0,
|
||||
GlobalCtorsVar,
|
||||
&TheModule);
|
||||
llvm::GlobalVariable *GlobalCtorsVal =
|
||||
new llvm::GlobalVariable(GlobalCtorsTy, false,
|
||||
llvm::GlobalValue::AppendingLinkage,
|
||||
(llvm::Constant*)0, "llvm.global_ctors",
|
||||
&TheModule);
|
||||
|
||||
// Populate the array
|
||||
std::vector<llvm::Constant*> CtorValues;
|
||||
llvm::Constant *MagicNumber = llvm::ConstantInt::get(llvm::IntegerType::Int32Ty,
|
||||
65535,
|
||||
false);
|
||||
llvm::Constant *MagicNumber =
|
||||
llvm::ConstantInt::get(llvm::Type::Int32Ty, 65535, false);
|
||||
std::vector<llvm::Constant*> StructValues;
|
||||
for (std::vector<llvm::Constant*>::iterator I = GlobalCtors.begin(),
|
||||
E = GlobalCtors.end(); I != E; ++I) {
|
||||
std::vector<llvm::Constant*> StructValues;
|
||||
E = GlobalCtors.end(); I != E; ++I) {
|
||||
StructValues.clear();
|
||||
StructValues.push_back(MagicNumber);
|
||||
StructValues.push_back(*I);
|
||||
|
||||
llvm::Constant* CtorEntry = llvm::ConstantStruct::get(CtorStructTy, StructValues);
|
||||
CtorValues.push_back(CtorEntry);
|
||||
CtorValues.push_back(llvm::ConstantStruct::get(CtorStructTy, StructValues));
|
||||
}
|
||||
llvm::Constant* CtorArray = llvm::ConstantArray::get(GlobalCtorsTy, CtorValues);
|
||||
GlobalCtorsVal->setInitializer(CtorArray);
|
||||
|
||||
GlobalCtorsVal->setInitializer(llvm::ConstantArray::get(GlobalCtorsTy,
|
||||
CtorValues));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -189,10 +189,9 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
|
|||
break;
|
||||
}
|
||||
case Type::Complex: {
|
||||
std::vector<const llvm::Type*> Elts;
|
||||
Elts.push_back(ConvertType(cast<ComplexType>(Ty).getElementType()));
|
||||
Elts.push_back(Elts[0]);
|
||||
return llvm::StructType::get(Elts);
|
||||
const llvm::Type *EltTy =
|
||||
ConvertType(cast<ComplexType>(Ty).getElementType());
|
||||
return llvm::StructType::get(EltTy, EltTy, NULL);
|
||||
}
|
||||
case Type::Pointer: {
|
||||
const PointerType &P = cast<PointerType>(Ty);
|
||||
|
|
Loading…
Reference in New Issue