From 17e5c8b7c2f5560bfffb4faac5f88d1a8c48728e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 13 Jul 2011 09:24:02 +0100 Subject: [PATCH] Fix LLVM 2.9 build. --- builtins.cpp | 26 +++++++++++++------------- ispc.h | 7 +++++++ llvmutil.cpp | 50 +++++++++++++++++++++++++------------------------- llvmutil.h | 51 ++++++++++++++++++++++++++------------------------- type.cpp | 28 ++++++++++++++-------------- type.h | 16 ++++++++-------- 6 files changed, 93 insertions(+), 85 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index a6af518f..b7ea19a9 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -265,7 +265,7 @@ lDeclarePseudoGathers(llvm::Module *module) { noPos.name = "__stdlib"; { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerVectorType); argTypes.push_back(LLVMTypes::MaskType); @@ -285,7 +285,7 @@ lDeclarePseudoGathers(llvm::Module *module) { } { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerType); argTypes.push_back(LLVMTypes::Int32VectorType); argTypes.push_back(LLVMTypes::MaskType); @@ -331,7 +331,7 @@ lDeclarePseudoScatters(llvm::Module *module) { noPos.name = "__stdlib"; { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerVectorType); argTypes.push_back(LLVMTypes::Int32VectorType); argTypes.push_back(LLVMTypes::MaskType); @@ -344,7 +344,7 @@ lDeclarePseudoScatters(llvm::Module *module) { func->setDoesNotThrow(true); } { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerVectorType); argTypes.push_back(LLVMTypes::Int64VectorType); argTypes.push_back(LLVMTypes::MaskType); @@ -358,7 +358,7 @@ lDeclarePseudoScatters(llvm::Module *module) { } { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerType); argTypes.push_back(LLVMTypes::Int32VectorType); argTypes.push_back(LLVMTypes::Int32VectorType); @@ -372,7 +372,7 @@ lDeclarePseudoScatters(llvm::Module *module) { func->setDoesNotThrow(true); } { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerType); argTypes.push_back(LLVMTypes::Int32VectorType); argTypes.push_back(LLVMTypes::Int64VectorType); @@ -404,7 +404,7 @@ lDeclarePseudoMaskedStore(llvm::Module *module) { noPos.name = "__stdlib"; { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::Int32VectorPointerType); argTypes.push_back(LLVMTypes::Int32VectorType); argTypes.push_back(LLVMTypes::MaskType); @@ -420,7 +420,7 @@ lDeclarePseudoMaskedStore(llvm::Module *module) { } { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(LLVMTypes::Int64VectorPointerType); argTypes.push_back(LLVMTypes::Int64VectorType); argTypes.push_back(LLVMTypes::MaskType); @@ -550,7 +550,7 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod // Add a declaration of void *ISPCMalloc(int64_t size, int alignment). // The user is responsible for linking in a definition of this if it's // needed by the compiled program. - { std::vector argTypes; + { std::vector argTypes; argTypes.push_back(llvm::Type::getInt64Ty(*ctx)); argTypes.push_back(llvm::Type::getInt32Ty(*ctx)); llvm::FunctionType *ftype = llvm::FunctionType::get(LLVMTypes::VoidPointerType, @@ -564,7 +564,7 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod // Add a declaration of void ISPCFree(void *). The user is // responsible for linking in a definition of this if it's needed by // the compiled program. - { std::vector argTypes; + { std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerType); llvm::FunctionType *ftype = llvm::FunctionType::get(LLVMTypes::VoidPointerType, argTypes, false); @@ -577,7 +577,7 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod // Add a declaration of void ISPCLaunch(void *funcPtr, void *data). // The user is responsible for linking in a definition of this if it's // needed by the compiled program. - { std::vector argTypes; + { std::vector argTypes; argTypes.push_back(LLVMTypes::VoidPointerType); argTypes.push_back(LLVMTypes::VoidPointerType); llvm::FunctionType *ftype = llvm::FunctionType::get(LLVMTypes::VoidType, @@ -592,7 +592,7 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod // linking in a definition of this if it's needed by the compiled // program. { - std::vector argTypes; + std::vector argTypes; llvm::FunctionType *ftype = llvm::FunctionType::get(LLVMTypes::VoidType, argTypes, false); llvm::Function *func = @@ -605,7 +605,7 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod // The user is responsible for linking in a definition of this if it's // needed by the compiled program. { - std::vector argTypes; + std::vector argTypes; argTypes.push_back(llvm::PointerType::get(llvm::Type::getInt8Ty(*g->ctx), 0)); argTypes.push_back(llvm::PointerType::get(llvm::Type::getInt8Ty(*g->ctx), 0)); argTypes.push_back(LLVMTypes::Int32Type); diff --git a/ispc.h b/ispc.h index 2c4ec158..8a8aecfb 100644 --- a/ispc.h +++ b/ispc.h @@ -73,6 +73,13 @@ namespace llvm { class Value; } +// llvm::Type *s are no longer const in llvm 3.0 +#if defined(LLVM_3_0) || defined(LLVM_3_0svn) +#define LLVM_TYPE_CONST +#else +#define LLVM_TYPE_CONST const +#endif + class ArrayType; class AtomicType; class DeclSpecs; diff --git a/llvmutil.cpp b/llvmutil.cpp index b92b4995..d3aaf5bb 100644 --- a/llvmutil.cpp +++ b/llvmutil.cpp @@ -38,32 +38,32 @@ #include "llvmutil.h" #include "type.h" -llvm::Type *LLVMTypes::VoidType = NULL; -llvm::PointerType *LLVMTypes::VoidPointerType = NULL; -llvm::Type *LLVMTypes::BoolType = NULL; -llvm::Type *LLVMTypes::Int8Type = NULL; -llvm::Type *LLVMTypes::Int16Type = NULL; -llvm::Type *LLVMTypes::Int32Type = NULL; -llvm::Type *LLVMTypes::Int32PointerType = NULL; -llvm::Type *LLVMTypes::Int64Type = NULL; -llvm::Type *LLVMTypes::Int64PointerType = NULL; -llvm::Type *LLVMTypes::FloatType = NULL; -llvm::Type *LLVMTypes::FloatPointerType = NULL; -llvm::Type *LLVMTypes::DoubleType = NULL; -llvm::Type *LLVMTypes::DoublePointerType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::VoidType = NULL; +LLVM_TYPE_CONST llvm::PointerType *LLVMTypes::VoidPointerType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::BoolType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int8Type = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int16Type = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int32Type = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int32PointerType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int64Type = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int64PointerType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::FloatType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::FloatPointerType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::DoubleType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::DoublePointerType = NULL; -llvm::VectorType *LLVMTypes::MaskType = NULL; -llvm::VectorType *LLVMTypes::BoolVectorType = NULL; -llvm::VectorType *LLVMTypes::Int1VectorType = NULL; -llvm::VectorType *LLVMTypes::Int32VectorType = NULL; -llvm::Type *LLVMTypes::Int32VectorPointerType = NULL; -llvm::VectorType *LLVMTypes::Int64VectorType = NULL; -llvm::Type *LLVMTypes::Int64VectorPointerType = NULL; -llvm::VectorType *LLVMTypes::FloatVectorType = NULL; -llvm::Type *LLVMTypes::FloatVectorPointerType = NULL; -llvm::VectorType *LLVMTypes::DoubleVectorType = NULL; -llvm::Type *LLVMTypes::DoubleVectorPointerType = NULL; -llvm::ArrayType *LLVMTypes::VoidPointerVectorType = NULL; +LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::MaskType = NULL; +LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::BoolVectorType = NULL; +LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int1VectorType = NULL; +LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int32VectorType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int32VectorPointerType = NULL; +LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int64VectorType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int64VectorPointerType = NULL; +LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::FloatVectorType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::FloatVectorPointerType = NULL; +LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::DoubleVectorType = NULL; +LLVM_TYPE_CONST llvm::Type *LLVMTypes::DoubleVectorPointerType = NULL; +LLVM_TYPE_CONST llvm::ArrayType *LLVMTypes::VoidPointerVectorType = NULL; llvm::Constant *LLVMTrue = NULL; llvm::Constant *LLVMFalse = NULL; diff --git a/llvmutil.h b/llvmutil.h index 5473d59f..68f2f256 100644 --- a/llvmutil.h +++ b/llvmutil.h @@ -44,37 +44,38 @@ #include #include + /** This structure holds pointers to a variety of LLVM types; code elsewhere can use them from here, ratherthan needing to make more verbose LLVM API calls. */ struct LLVMTypes { - static llvm::Type *VoidType; - static llvm::PointerType *VoidPointerType; - static llvm::Type *BoolType; - static llvm::Type *Int8Type; - static llvm::Type *Int16Type; - static llvm::Type *Int32Type; - static llvm::Type *Int32PointerType; - static llvm::Type *Int64Type; - static llvm::Type *Int64PointerType; - static llvm::Type *FloatType; - static llvm::Type *FloatPointerType; - static llvm::Type *DoubleType; - static llvm::Type *DoublePointerType; + static LLVM_TYPE_CONST llvm::Type *VoidType; + static LLVM_TYPE_CONST llvm::PointerType *VoidPointerType; + static LLVM_TYPE_CONST llvm::Type *BoolType; + static LLVM_TYPE_CONST llvm::Type *Int8Type; + static LLVM_TYPE_CONST llvm::Type *Int16Type; + static LLVM_TYPE_CONST llvm::Type *Int32Type; + static LLVM_TYPE_CONST llvm::Type *Int32PointerType; + static LLVM_TYPE_CONST llvm::Type *Int64Type; + static LLVM_TYPE_CONST llvm::Type *Int64PointerType; + static LLVM_TYPE_CONST llvm::Type *FloatType; + static LLVM_TYPE_CONST llvm::Type *FloatPointerType; + static LLVM_TYPE_CONST llvm::Type *DoubleType; + static LLVM_TYPE_CONST llvm::Type *DoublePointerType; - static llvm::VectorType *MaskType; - static llvm::VectorType *BoolVectorType; - static llvm::VectorType *Int1VectorType; - static llvm::VectorType *Int32VectorType; - static llvm::Type *Int32VectorPointerType; - static llvm::VectorType *Int64VectorType; - static llvm::Type *Int64VectorPointerType; - static llvm::VectorType *FloatVectorType; - static llvm::Type *FloatVectorPointerType; - static llvm::VectorType *DoubleVectorType; - static llvm::Type *DoubleVectorPointerType; - static llvm::ArrayType *VoidPointerVectorType; + static LLVM_TYPE_CONST llvm::VectorType *MaskType; + static LLVM_TYPE_CONST llvm::VectorType *BoolVectorType; + static LLVM_TYPE_CONST llvm::VectorType *Int1VectorType; + static LLVM_TYPE_CONST llvm::VectorType *Int32VectorType; + static LLVM_TYPE_CONST llvm::Type *Int32VectorPointerType; + static LLVM_TYPE_CONST llvm::VectorType *Int64VectorType; + static LLVM_TYPE_CONST llvm::Type *Int64VectorPointerType; + static LLVM_TYPE_CONST llvm::VectorType *FloatVectorType; + static LLVM_TYPE_CONST llvm::Type *FloatVectorPointerType; + static LLVM_TYPE_CONST llvm::VectorType *DoubleVectorType; + static LLVM_TYPE_CONST llvm::Type *DoubleVectorPointerType; + static LLVM_TYPE_CONST llvm::ArrayType *VoidPointerVectorType; }; /** These variables hold the corresponding LLVM constant values as a diff --git a/type.cpp b/type.cpp index e0ad5593..6d75377b 100644 --- a/type.cpp +++ b/type.cpp @@ -326,7 +326,7 @@ AtomicType::GetCDeclaration(const std::string &name) const { } -llvm::Type * +LLVM_TYPE_CONST llvm::Type * AtomicType::LLVMType(llvm::LLVMContext *ctx) const { switch (basicType) { case TYPE_VOID: @@ -428,12 +428,12 @@ ArrayType::ArrayType(const Type *c, int a) } -llvm::ArrayType * +LLVM_TYPE_CONST llvm::ArrayType * ArrayType::LLVMType(llvm::LLVMContext *ctx) const { if (!child) return NULL; - llvm::Type *ct = child->LLVMType(ctx); + LLVM_TYPE_CONST llvm::Type *ct = child->LLVMType(ctx); if (!ct) return NULL; return llvm::ArrayType::get(ct, numElements); @@ -730,7 +730,7 @@ SOAArrayType::TotalElementCount() const { } -llvm::ArrayType * +LLVM_TYPE_CONST llvm::ArrayType * SOAArrayType::LLVMType(llvm::LLVMContext *ctx) const { if (!child) return NULL; @@ -894,9 +894,9 @@ VectorType::GetElementType() const { } -llvm::Type * +LLVM_TYPE_CONST llvm::Type * VectorType::LLVMType(llvm::LLVMContext *ctx) const { - llvm::Type *bt = base->LLVMType(ctx); + LLVM_TYPE_CONST llvm::Type *bt = base->LLVMType(ctx); if (!bt) return NULL; @@ -1130,9 +1130,9 @@ StructType::GetCDeclaration(const std::string &n) const { } -llvm::Type * +LLVM_TYPE_CONST llvm::Type * StructType::LLVMType(llvm::LLVMContext *ctx) const { - std::vector llvmTypes; + std::vector llvmTypes; for (int i = 0; i < GetElementCount(); ++i) { const Type *type = GetElementType(i); llvmTypes.push_back(type->LLVMType(ctx)); @@ -1385,11 +1385,11 @@ ReferenceType::GetCDeclaration(const std::string &name) const { } -llvm::Type * +LLVM_TYPE_CONST llvm::Type * ReferenceType::LLVMType(llvm::LLVMContext *ctx) const { if (!targetType) return NULL; - llvm::Type *t = targetType->LLVMType(ctx); + LLVM_TYPE_CONST llvm::Type *t = targetType->LLVMType(ctx); if (!t) return NULL; return llvm::PointerType::get(t, 0); @@ -1542,7 +1542,7 @@ FunctionType::GetCDeclaration(const std::string &fname) const { } -llvm::Type * +LLVM_TYPE_CONST llvm::Type * FunctionType::LLVMType(llvm::LLVMContext *ctx) const { FATAL("FunctionType::LLVMType() shouldn't be called"); return NULL; @@ -1565,12 +1565,12 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const { } // Get the LLVM Type *s for the function arguments - std::vector llvmArgTypes; + std::vector llvmArgTypes; for (unsigned int i = 0; i < argTypes.size(); ++i) { if (!argTypes[i]) return NULL; - llvm::Type *t = argTypes[i]->LLVMType(ctx); + LLVM_TYPE_CONST llvm::Type *t = argTypes[i]->LLVMType(ctx); if (!t) return NULL; llvmArgTypes.push_back(t); @@ -1580,7 +1580,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const { if (includeMask) llvmArgTypes.push_back(LLVMTypes::MaskType); - std::vector callTypes; + std::vector callTypes; if (isTask) { // Tasks take three arguments: a pointer to a struct that holds the // actual task arguments, the thread index, and the total number of diff --git a/type.h b/type.h index 148e9cce..23eaff68 100644 --- a/type.h +++ b/type.h @@ -133,7 +133,7 @@ public: virtual std::string GetCDeclaration(const std::string &name) const = 0; /** Returns the LLVM type corresponding to this ispc type */ - virtual llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0; + virtual LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0; /** Returns the DIType (LLVM's debugging information structure), corresponding to this type. */ @@ -202,7 +202,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; /** This enumerant records the basic types that AtomicTypes can be @@ -323,7 +323,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; - llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const; + LLVM_TYPE_CONST llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const; /** This method returns the total number of elements in the array, including all dimensions if this is a multidimensional array. */ @@ -392,7 +392,7 @@ public: int TotalElementCount() const; - llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const; + LLVM_TYPE_CONST llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; SOAArrayType *GetSizedArray(int size) const; @@ -441,7 +441,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; int GetElementCount() const; @@ -487,7 +487,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; /** Returns the type of the structure element with the given name (if any). @@ -559,7 +559,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; private: @@ -605,7 +605,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &fname) const; - llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; const Type *GetReturnType() const { return returnType; }