[cfe-commits] r48535 - in /cfe/trunk/lib/CodeGen: CGObjCGNU.cpp CodeGenModule.cpp CodeGenTypes.cpp
Chris Lattner
sabre at nondot.org
Tue Mar 18 22:24:56 PDT 2008
Author: lattner
Date: Wed Mar 19 00:24:56 2008
New Revision: 48535
URL: http://llvm.org/viewvc/llvm-project?rev=48535&view=rev
Log:
simplify code by using the variadic StructType::get method.
Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=48535&r1=48534&r2=48535&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Mar 19 00:24:56 2008
@@ -50,8 +50,8 @@
// 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.
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=48535&r1=48534&r2=48535&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Mar 19 00:24:56 2008
@@ -81,38 +81,36 @@
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));
}
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=48535&r1=48534&r2=48535&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Wed Mar 19 00:24:56 2008
@@ -189,10 +189,9 @@
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);
More information about the cfe-commits
mailing list