From 2e4ddf6218d1a7360a3d3836f80056703f149e85 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Fri, 10 Jul 2009 18:10:10 +0000 Subject: [PATCH] Push LLVMContext through the TypeBuilder API. There are no users for this in-tree, so I can't really test it. If you're using this, and it's broken, please send patches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75257 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/TypeBuilder.h | 202 +++++++++++++++++++------------------ 1 file changed, 106 insertions(+), 96 deletions(-) diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h index b0ae516b815..22698e96f57 100644 --- a/include/llvm/Support/TypeBuilder.h +++ b/include/llvm/Support/TypeBuilder.h @@ -104,9 +104,9 @@ template class TypeBuilder // Pointers template class TypeBuilder { public: - static const PointerType *get() { + static const PointerType *get(LLVMContext &Context) { static const PointerType *const result = - PointerType::getUnqual(TypeBuilder::get()); + Context.getPointerTypeUnqual(TypeBuilder::get(Context)); return result; } }; @@ -117,18 +117,18 @@ template class TypeBuilder {}; // Arrays template class TypeBuilder { public: - static const ArrayType *get() { + static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - ArrayType::get(TypeBuilder::get(), N); + Context.getArrayType(TypeBuilder::get(Context), N); return result; } }; /// LLVM uses an array of length 0 to represent an unknown-length array. template class TypeBuilder { public: - static const ArrayType *get() { + static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - ArrayType::get(TypeBuilder::get(), 0); + Context.getArrayType(TypeBuilder::get(Context), 0); return result; } }; @@ -158,9 +158,9 @@ public: #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ template<> class TypeBuilder { \ public: \ - static const IntegerType *get() { \ + static const IntegerType *get(LLVMContext &Context) { \ static const IntegerType *const result = \ - IntegerType::get(sizeof(T) * CHAR_BIT); \ + Context.getIntegerType(sizeof(T) * CHAR_BIT); \ return result; \ } \ }; \ @@ -189,15 +189,15 @@ DEFINE_INTEGRAL_TYPEBUILDER(unsigned long long); template class TypeBuilder, cross> { public: - static const IntegerType *get() { - static const IntegerType *const result = IntegerType::get(num_bits); + static const IntegerType *get(LLVMContext &Context) { + static const IntegerType *const result = Context.getIntegerType(num_bits); return result; } }; template<> class TypeBuilder { public: - static const Type *get() { + static const Type *get(LLVMContext&) { return Type::FloatTy; } }; @@ -205,7 +205,7 @@ template<> class TypeBuilder {}; template<> class TypeBuilder { public: - static const Type *get() { + static const Type *get(LLVMContext&) { return Type::DoubleTy; } }; @@ -213,28 +213,28 @@ template<> class TypeBuilder {}; template class TypeBuilder { public: - static const Type *get() { return Type::FloatTy; } + static const Type *get(LLVMContext&) { return Type::FloatTy; } }; template class TypeBuilder { public: - static const Type *get() { return Type::DoubleTy; } + static const Type *get(LLVMContext&) { return Type::DoubleTy; } }; template class TypeBuilder { public: - static const Type *get() { return Type::X86_FP80Ty; } + static const Type *get(LLVMContext&) { return Type::X86_FP80Ty; } }; template class TypeBuilder { public: - static const Type *get() { return Type::FP128Ty; } + static const Type *get(LLVMContext&) { return Type::FP128Ty; } }; template class TypeBuilder { public: - static const Type *get() { return Type::PPC_FP128Ty; } + static const Type *get(LLVMContext&) { return Type::PPC_FP128Ty; } }; template class TypeBuilder { public: - static const Type *get() { + static const Type *get(LLVMContxt&) { return Type::VoidTy; } }; @@ -246,64 +246,67 @@ template<> class TypeBuilder template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { - return FunctionType::get(TypeBuilder::get(), false); + static const FunctionType *create(LLVMContext &Context) { + return Context.getFunctionType(TypeBuilder::get(Context), false); } }; template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(1); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, false); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, false); } }; template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(2); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, false); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, false); } }; template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(3); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, false); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, false); } }; @@ -311,20 +314,21 @@ template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(4); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, false); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, false); } }; @@ -332,85 +336,89 @@ template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(5); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, false); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, false); } }; template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { - return FunctionType::get(TypeBuilder::get(), true); + static const FunctionType *create(LLVMContext &Context) { + return Context.getFunctionType(TypeBuilder::get(Context), true); } }; template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(1); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, true); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, true); } }; template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(2); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, true); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, true); } }; template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(3); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, true); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, true); } }; @@ -418,20 +426,21 @@ template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(4); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, true); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, true); } }; @@ -439,21 +448,22 @@ template class TypeBuilder { public: - static const FunctionType *get() { - static const FunctionType *const result = create(); + static const FunctionType *get(LLVMContext &Context) { + static const FunctionType *const result = create(Context); return result; } private: - static const FunctionType *create() { + static const FunctionType *create(LLVMContext &Context) { std::vector params; params.reserve(5); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - params.push_back(TypeBuilder::get()); - return FunctionType::get(TypeBuilder::get(), params, true); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + params.push_back(TypeBuilder::get(Context)); + return Context.getFunctionType(TypeBuilder::get(Context), + params, true); } }; -- 2.11.0