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.
|
// Get the selector Type.
|
||||||
const llvm::Type *PtrToInt8Ty =
|
const llvm::Type *PtrToInt8Ty =
|
||||||
llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
|
llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
|
||||||
std::vector<const llvm::Type*> Str2(2, PtrToInt8Ty);
|
const llvm::Type *SelStructTy =
|
||||||
const llvm::Type *SelStructTy = llvm::StructType::get(Str2);
|
llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, NULL);
|
||||||
const llvm::Type *SelTy = llvm::PointerType::getUnqual(SelStructTy);
|
const llvm::Type *SelTy = llvm::PointerType::getUnqual(SelStructTy);
|
||||||
|
|
||||||
// Look up the selector.
|
// Look up the selector.
|
||||||
|
|
|
@ -81,38 +81,36 @@ void CodeGenModule::EmitGlobalCtors() {
|
||||||
VoidArgs,
|
VoidArgs,
|
||||||
false);
|
false);
|
||||||
// i32, function type pair
|
// i32, function type pair
|
||||||
CtorFields.push_back(llvm::PointerType::getUnqual(CtorFuncTy));
|
const llvm::Type *FPType = llvm::PointerType::getUnqual(CtorFuncTy);
|
||||||
llvm::StructType* CtorStructTy = llvm::StructType::get(CtorFields, false);
|
llvm::StructType* CtorStructTy =
|
||||||
|
llvm::StructType::get(llvm::Type::Int32Ty, FPType, NULL);
|
||||||
// Array of fields
|
// Array of fields
|
||||||
llvm::ArrayType* GlobalCtorsTy = llvm::ArrayType::get(CtorStructTy,
|
llvm::ArrayType* GlobalCtorsTy =
|
||||||
GlobalCtors.size());
|
llvm::ArrayType::get(CtorStructTy, GlobalCtors.size());
|
||||||
|
|
||||||
const std::string GlobalCtorsVar = std::string("llvm.global_ctors");
|
|
||||||
// Define the global variable
|
// Define the global variable
|
||||||
llvm::GlobalVariable *GlobalCtorsVal = new llvm::GlobalVariable(
|
llvm::GlobalVariable *GlobalCtorsVal =
|
||||||
GlobalCtorsTy,
|
new llvm::GlobalVariable(GlobalCtorsTy, false,
|
||||||
false,
|
llvm::GlobalValue::AppendingLinkage,
|
||||||
llvm::GlobalValue::AppendingLinkage,
|
(llvm::Constant*)0, "llvm.global_ctors",
|
||||||
(llvm::Constant*)0,
|
&TheModule);
|
||||||
GlobalCtorsVar,
|
|
||||||
&TheModule);
|
|
||||||
|
|
||||||
// Populate the array
|
// Populate the array
|
||||||
std::vector<llvm::Constant*> CtorValues;
|
std::vector<llvm::Constant*> CtorValues;
|
||||||
llvm::Constant *MagicNumber = llvm::ConstantInt::get(llvm::IntegerType::Int32Ty,
|
llvm::Constant *MagicNumber =
|
||||||
65535,
|
llvm::ConstantInt::get(llvm::Type::Int32Ty, 65535, false);
|
||||||
false);
|
std::vector<llvm::Constant*> StructValues;
|
||||||
for (std::vector<llvm::Constant*>::iterator I = GlobalCtors.begin(),
|
for (std::vector<llvm::Constant*>::iterator I = GlobalCtors.begin(),
|
||||||
E = GlobalCtors.end(); I != E; ++I) {
|
E = GlobalCtors.end(); I != E; ++I) {
|
||||||
std::vector<llvm::Constant*> StructValues;
|
StructValues.clear();
|
||||||
StructValues.push_back(MagicNumber);
|
StructValues.push_back(MagicNumber);
|
||||||
StructValues.push_back(*I);
|
StructValues.push_back(*I);
|
||||||
|
|
||||||
llvm::Constant* CtorEntry = llvm::ConstantStruct::get(CtorStructTy, StructValues);
|
CtorValues.push_back(llvm::ConstantStruct::get(CtorStructTy, StructValues));
|
||||||
CtorValues.push_back(CtorEntry);
|
|
||||||
}
|
}
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
case Type::Complex: {
|
case Type::Complex: {
|
||||||
std::vector<const llvm::Type*> Elts;
|
const llvm::Type *EltTy =
|
||||||
Elts.push_back(ConvertType(cast<ComplexType>(Ty).getElementType()));
|
ConvertType(cast<ComplexType>(Ty).getElementType());
|
||||||
Elts.push_back(Elts[0]);
|
return llvm::StructType::get(EltTy, EltTy, NULL);
|
||||||
return llvm::StructType::get(Elts);
|
|
||||||
}
|
}
|
||||||
case Type::Pointer: {
|
case Type::Pointer: {
|
||||||
const PointerType &P = cast<PointerType>(Ty);
|
const PointerType &P = cast<PointerType>(Ty);
|
||||||
|
|
Loading…
Reference in New Issue