Index: include/llvm/Support/LLVMBuilder.h =================================================================== --- include/llvm/Support/LLVMBuilder.h (revision 48490) +++ include/llvm/Support/LLVMBuilder.h (working copy) @@ -226,6 +226,16 @@ GetElementPtrInst *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") { return Insert(new GetElementPtrInst(Ptr, Idx, Name)); } + GetElementPtrInst *CreateStructGEP(Value *Ptr, int Idx, const char *Name = "") { + llvm::Value *Idxs[] = { + ConstantInt::get(llvm::Type::Int32Ty, 0), + ConstantInt::get(llvm::Type::Int32Ty, Idx) + }; + return Insert(new GetElementPtrInst(Ptr, + Idxs, + Idxs+2, + Name)); + } //===--------------------------------------------------------------------===// // Instruction creation methods: Cast/Conversion Operators Index: include/llvm/DerivedTypes.h =================================================================== --- include/llvm/DerivedTypes.h (revision 48490) +++ include/llvm/DerivedTypes.h (working copy) @@ -219,6 +219,9 @@ /// static StructType *get(const std::vector &Params, bool isPacked=false); + /// StructType::get - This static method is a convenience method for + /// creating structure types by specifying the elements as arguments. + static StructType *get(const Type *type, ...); // Iterator access to the elements typedef Type::subtype_iterator element_iterator; Index: lib/VMCore/Type.cpp =================================================================== --- lib/VMCore/Type.cpp (revision 48490) +++ lib/VMCore/Type.cpp (working copy) @@ -22,6 +22,8 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Debug.h" #include +#include + using namespace llvm; // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are @@ -1247,8 +1249,18 @@ return ST; } +StructType *StructType::get(const Type *type, ...) { + va_list ap; + std::vector StructFields; + va_start(ap, type); + do { + StructFields.push_back(type); + } while (type = va_arg(ap, llvm::Type*)); + return llvm::StructType::get(StructFields); +} + //===----------------------------------------------------------------------===// // Pointer Type Factory... //