From d3c567503bf64ec9066c09cb8959c31d4aa1be0e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 31 Jul 2013 06:46:45 -0700 Subject: [PATCH] Remove support for building with LLVM 3.1 --- builtins.cpp | 2 - builtins/target-avx11-x2.ll | 4 +- builtins/target-avx11.ll | 4 +- builtins/target-avx2-x2.ll | 25 +------- builtins/target-avx2.ll | 25 +------- cbackend.cpp | 115 +++++++++--------------------------- ctx.cpp | 4 +- ctx.h | 11 +--- expr.cpp | 2 +- func.cpp | 10 +--- ispc.cpp | 68 ++++----------------- ispc.h | 18 +----- llvmutil.cpp | 2 +- llvmutil.h | 2 +- main.cpp | 4 +- module.cpp | 47 +++------------ opt.cpp | 22 ++----- stmt.cpp | 2 +- type.cpp | 26 +++----- type.h | 2 +- util.cpp | 9 +-- 21 files changed, 84 insertions(+), 320 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index b2896388..17582d68 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -49,8 +49,6 @@ #include #if defined(LLVM_3_2) #include -#endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) #include #include #include diff --git a/builtins/target-avx11-x2.ll b/builtins/target-avx11-x2.ll index 1aa6345c..2aee1e1c 100644 --- a/builtins/target-avx11-x2.ll +++ b/builtins/target-avx11-x2.ll @@ -31,9 +31,7 @@ include(`target-avx-x2.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max diff --git a/builtins/target-avx11.ll b/builtins/target-avx11.ll index fea0a7c2..44593113 100644 --- a/builtins/target-avx11.ll +++ b/builtins/target-avx11.ll @@ -31,9 +31,7 @@ include(`target-avx.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max diff --git a/builtins/target-avx2-x2.ll b/builtins/target-avx2-x2.ll index 053fd078..19f1845d 100644 --- a/builtins/target-avx2-x2.ll +++ b/builtins/target-avx2-x2.ll @@ -29,15 +29,11 @@ ;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -ifelse(LLVM_VERSION, `LLVM_3_0', `', - LLVM_VERSION, `LLVM_3_1', `', - `define(`HAVE_GATHER', `1')') +define(`HAVE_GATHER', `1') include(`target-avx-x2.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -176,21 +172,6 @@ define(`assemble_4s', ` assemble_8s($1, $2, $2_1, $2_2) ') -ifelse(LLVM_VERSION, `LLVM_3_0', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', -LLVM_VERSION, `LLVM_3_1', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', ` - gen_gather(i8) gen_gather(i16) @@ -557,5 +538,3 @@ define <16 x double> @__gather64_double(<16 x i64> %ptrs, ret <16 x double> %v } - -') diff --git a/builtins/target-avx2.ll b/builtins/target-avx2.ll index f4a0ee07..d3410011 100644 --- a/builtins/target-avx2.ll +++ b/builtins/target-avx2.ll @@ -29,15 +29,11 @@ ;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -ifelse(LLVM_VERSION, `LLVM_3_0', `', - LLVM_VERSION, `LLVM_3_1', `', - `define(`HAVE_GATHER', `1')') +define(`HAVE_GATHER', `1') include(`target-avx.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -123,21 +119,6 @@ define(`extract_4s', ` %$2_2 = shufflevector <8 x $1> %$2, <8 x $1> undef, <4 x i32> ') -ifelse(LLVM_VERSION, `LLVM_3_0', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', -LLVM_VERSION, `LLVM_3_1', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', ` - gen_gather(i8) gen_gather(i16) @@ -429,5 +410,3 @@ define <8 x double> @__gather64_double(<8 x i64> %ptrs, ret <8 x double> %v } - -') diff --git a/cbackend.cpp b/cbackend.cpp index d23bcc20..d54f48fb 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -29,7 +29,7 @@ #include "llvmutil.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/CallingConv.h" @@ -38,6 +38,7 @@ #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" #include "llvm/InlineAsm.h" + #include "llvm/TypeFinder.h" #else #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" @@ -47,16 +48,10 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/InlineAsm.h" + #include "llvm/IR/TypeFinder.h" #endif #include "llvm/Pass.h" #include "llvm/PassManager.h" -#if !defined(LLVM_3_1) - #if defined(LLVM_3_2) - #include "llvm/TypeFinder.h" - #else // LLVM_3_3 + - #include "llvm/IR/TypeFinder.h" - #endif -#endif // LLVM_3_2 + #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" @@ -76,9 +71,7 @@ #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSymbol.h" -#if defined(LLVM_3_1) - #include "llvm/Target/TargetData.h" -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/DataLayout.h" #else // LLVM 3.3+ #include "llvm/IR/DataLayout.h" @@ -88,7 +81,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/GetElementPtrTypeIterator.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Support/InstVisitor.h" #else // LLVM 3.3+ #include "llvm/InstVisitor.h" @@ -258,14 +251,10 @@ namespace { const llvm::MCRegisterInfo *MRI; const llvm::MCObjectFileInfo *MOFI; llvm::MCContext *TCtx; -#if defined(LLVM_3_1) - const llvm::TargetData* TD; -#else // FIXME: it's ugly to have the name be "TD" here, but it saves us // lots of ifdefs in the below since the new DataLayout and the old // TargetData have generally similar interfaces... const llvm::DataLayout* TD; -#endif std::map FPConstantMap; std::map VectorConstantMap; @@ -352,7 +341,7 @@ namespace { bool isSigned = false, const std::string &VariableName = "", bool IgnoreName = false, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL = llvm::AttrListPtr() #else const llvm::AttributeSet &PAL = llvm::AttributeSet() @@ -363,7 +352,7 @@ namespace { const std::string &NameSoFar = ""); void printStructReturnPointerFunctionType(llvm::raw_ostream &Out, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL, #else const llvm::AttributeSet &PAL, @@ -586,7 +575,7 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) { /// return type, except, instead of printing the type as void (*)(Struct*, ...) /// print it as "Struct (*)(...)", for struct return functions. void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL, #else const llvm::AttributeSet &PAL, @@ -605,20 +594,16 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, if (PrintedType) FunctionInnards << ", "; llvm::Type *ArgTy = *I; -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else - if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { + if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { #endif assert(ArgTy->isPointerTy()); ArgTy = llvm::cast(ArgTy)->getElementType(); } printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), @@ -635,9 +620,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, } FunctionInnards << ')'; printType(Out, RetTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), @@ -737,7 +720,7 @@ CWriter::printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned, llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned, const std::string &NameSoFar, bool IgnoreName, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL #else const llvm::AttributeSet &PAL @@ -759,9 +742,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, for (llvm::FunctionType::param_iterator I = FTy->param_begin(), E = FTy->param_end(); I != E; ++I) { llvm::Type *ArgTy = *I; -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { @@ -772,9 +753,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, if (I != FTy->param_begin()) FunctionInnards << ", "; printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), @@ -791,9 +770,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, } FunctionInnards << ')'; printType(Out, FTy->getReturnType(), -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), @@ -1972,11 +1949,7 @@ void CWriter::writeOperandWithCast(llvm::Value* Operand, const llvm::ICmpInst &C // directives to cater to specific compilers as need be. // static void generateCompilerSpecificCode(llvm::formatted_raw_ostream& Out, -#if defined(LLVM_3_1) - const llvm::TargetData *TD) { -#else const llvm::DataLayout *TD) { -#endif // We output GCC specific attributes to preserve 'linkonce'ness on globals. // If we aren't being compiled with GCC, just drop these attributes. Out << "#ifndef __GNUC__ /* Can only support \"linkonce\" vars with GCC */\n" @@ -2169,11 +2142,7 @@ bool CWriter::doInitialization(llvm::Module &M) { // Initialize TheModule = &M; -#if defined(LLVM_3_1) - TD = new llvm::TargetData(&M); -#else TD = new llvm::DataLayout(&M); -#endif IL = new llvm::IntrinsicLowering(*TD); IL->AddPrototypes(M); @@ -2656,15 +2625,11 @@ void CWriter::printModuleTypes() { // Get all of the struct types used in the module. std::vector StructTypes; -#if defined(LLVM_3_1) - TheModule->findUsedStructTypes(StructTypes); -#else llvm::TypeFinder typeFinder; typeFinder.run(*TheModule, false); for (llvm::TypeFinder::iterator iter = typeFinder.begin(); iter != typeFinder.end(); ++iter) StructTypes.push_back(*iter); -#endif // Get all of the array types used in the module std::vector ArrayTypes; @@ -2785,7 +2750,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { // Loop over the arguments, printing them... llvm::FunctionType *FT = llvm::cast(F->getFunctionType()); -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL = F->getAttributes(); #else const llvm::AttributeSet &PAL = F->getAttributes(); @@ -2819,20 +2784,16 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { else ArgName = ""; llvm::Type *ArgTy = I->getType(); -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else - if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { + if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { #endif ArgTy = llvm::cast(ArgTy)->getElementType(); ByValParams.insert(I); } printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), @@ -2858,9 +2819,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { for (; I != E; ++I) { if (PrintedArg) FunctionInnards << ", "; llvm::Type *ArgTy = *I; -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { @@ -2869,9 +2828,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { ArgTy = llvm::cast(ArgTy)->getElementType(); } printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt) -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt) #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt) @@ -2908,9 +2865,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { // Print out the return type and the signature built above. printType(Out, RetTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), @@ -3712,7 +3667,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) { const char *BuiltinName = ""; #define GET_GCC_BUILTIN_NAME #define Intrinsic llvm::Intrinsic -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Intrinsics.gen" #else #include "llvm/IR/Intrinsics.gen" @@ -3777,7 +3732,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) { // If this is a call to a struct-return function, assign to the first // parameter instead of passing it to the call. -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL = I.getAttributes(); #else const llvm::AttributeSet &PAL = I.getAttributes(); @@ -3865,9 +3820,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) { (*AI)->getType() != FTy->getParamType(ArgNo)) { Out << '('; printType(Out, FTy->getParamType(ArgNo), -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt) -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt) #else PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt) @@ -3905,7 +3858,7 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID, const char *BuiltinName = ""; #define GET_GCC_BUILTIN_NAME #define Intrinsic llvm::Intrinsic -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Intrinsics.gen" #else #include "llvm/IR/Intrinsics.gen" @@ -4555,13 +4508,8 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) { smearType, NULL); smearFunc = llvm::dyn_cast(sf); assert(smearFunc != NULL); -#if defined(LLVM_3_1) - smearFunc->setDoesNotThrow(true); - smearFunc->setDoesNotAccessMemory(true); -#else smearFunc->setDoesNotThrow(); smearFunc->setDoesNotAccessMemory(); -#endif } assert(smearFunc != NULL); @@ -4703,13 +4651,8 @@ AndCmpCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) { LLVMTypes::MaskType, NULL); andCmpFunc = llvm::dyn_cast(acf); Assert(andCmpFunc != NULL); -#if defined(LLVM_3_1) - andCmpFunc->setDoesNotThrow(true); - andCmpFunc->setDoesNotAccessMemory(true); -#else andCmpFunc->setDoesNotThrow(); andCmpFunc->setDoesNotAccessMemory(); -#endif } // Set up the function call to the *_and_mask function; the @@ -4914,7 +4857,7 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, pm.add(new llvm::TargetData(module)); #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) +#if defined(LLVM_3_2) || defined(LLVM_3_3) int flags = 0; #else llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None; @@ -4939,7 +4882,7 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, pm.add(llvm::createDeadCodeEliminationPass()); // clean up after smear pass //CO pm.add(llvm::createPrintModulePass(&fos)); pm.add(new CWriter(fos, includeName, vectorWidth)); -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) // This interface is depricated for 3.3+ pm.add(llvm::createGCInfoDeleter()); #endif diff --git a/ctx.cpp b/ctx.cpp index c50d22f9..32ba0ad9 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -46,7 +46,7 @@ #include "sym.h" #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -3312,7 +3312,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType, // alias analysis. // TODO: what other attributes needs to be copied? // TODO: do the same for varing path. -#if !defined (LLVM_3_1) && !defined (LLVM_3_2) // LLVM 3.3+ +#if !defined (LLVM_3_2) // LLVM 3.3+ llvm::CallInst *cc = llvm::dyn_cast(ci); if (cc && cc->getCalledFunction() && diff --git a/ctx.h b/ctx.h index 58f9aae3..4b27e6e5 100644 --- a/ctx.h +++ b/ctx.h @@ -40,20 +40,15 @@ #include "ispc.h" #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else #include #include #endif -#if defined(LLVM_3_1) - #include - #include -#else - #include - #include -#endif +#include +#include struct CFInfo; diff --git a/expr.cpp b/expr.cpp index 856d363c..eb8c0951 100644 --- a/expr.cpp +++ b/expr.cpp @@ -56,7 +56,7 @@ #include #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include diff --git a/func.cpp b/func.cpp index b975049b..3097f86d 100644 --- a/func.cpp +++ b/func.cpp @@ -46,7 +46,7 @@ #include "util.h" #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -310,9 +310,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, // isn't worth the code bloat / overhead. bool checkMask = (type->isTask == true) || ( -#if defined(LLVM_3_1) - (function->hasFnAttr(llvm::Attribute::AlwaysInline) == false) -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) (function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false) #else // LLVM 3.3+ (function->getAttributes().getFnAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::AlwaysInline) == false) @@ -453,11 +451,7 @@ Function::GenerateIR() { functionName += std::string("_") + g->target->GetISAString(); llvm::Function *appFunction = llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module); -#if defined(LLVM_3_1) - appFunction->setDoesNotThrow(true); -#else appFunction->setDoesNotThrow(); -#endif g->target->markFuncWithTargetAttr(appFunction); diff --git a/ispc.cpp b/ispc.cpp index de8fba4d..b25527c4 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -48,7 +48,7 @@ #include #include #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -57,19 +57,12 @@ #include #include #endif -#if defined(LLVM_3_1) - #include - #include -#else - #include - #include -#endif +#include +#include #include #include #include -#if defined(LLVM_3_1) - #include -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #else // LLVM 3.3+ #include @@ -145,27 +138,20 @@ static const char *supportedCPUs[] = { // cortex-a9 and a15. We should be able to handle any of them that also // have NEON support. "cortex-a9", "cortex-a15", - "atom", "penryn", "core2", "corei7", "corei7-avx" -#if !defined(LLVM_3_1) - , "core-avx-i", "core-avx2" -#endif // LLVM 3.2+ + "atom", "penryn", "core2", "corei7", "corei7-avx", "core-avx-i", "core-avx2" }; Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : m_target(NULL), m_targetMachine(NULL), -#if defined(LLVM_3_1) - m_targetData(NULL), -#else m_dataLayout(NULL), -#endif m_valid(false), m_isa(SSE2), m_arch(""), m_is32Bit(true), m_cpu(""), m_attributes(""), -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) m_tf_attributes(NULL), #endif m_nativeVectorWidth(-1), @@ -407,10 +393,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : this->m_maskingIsFree = false; this->m_maskBitCount = 32; this->m_hasHalf = true; -#if !defined(LLVM_3_1) - // LLVM 3.2+ only this->m_hasRand = true; -#endif } else if (!strcasecmp(isa, "avx1.1-x2")) { this->m_isa = Target::AVX11; @@ -420,46 +403,29 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : this->m_maskingIsFree = false; this->m_maskBitCount = 32; this->m_hasHalf = true; -#if !defined(LLVM_3_1) - // LLVM 3.2+ only this->m_hasRand = true; -#endif } else if (!strcasecmp(isa, "avx2")) { this->m_isa = Target::AVX2; this->m_nativeVectorWidth = 8; this->m_vectorWidth = 8; - this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand" -#ifndef LLVM_3_1 - ",+fma" -#endif // !LLVM_3_1 - ; + this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand,+fma"; this->m_maskingIsFree = false; this->m_maskBitCount = 32; this->m_hasHalf = true; -#if !defined(LLVM_3_1) - // LLVM 3.2+ only this->m_hasRand = true; this->m_hasGather = true; -#endif } else if (!strcasecmp(isa, "avx2-x2")) { this->m_isa = Target::AVX2; this->m_nativeVectorWidth = 16; this->m_vectorWidth = 16; - this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand" -#ifndef LLVM_3_1 - ",+fma" -#endif // !LLVM_3_1 - ; + this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand,+fma"; this->m_maskingIsFree = false; this->m_maskBitCount = 32; this->m_hasHalf = true; -#if !defined(LLVM_3_1) - // LLVM 3.2+ only this->m_hasRand = true; this->m_hasGather = true; -#endif } else if (!strcasecmp(isa, "neon-8")) { this->m_isa = Target::NEON8; @@ -505,10 +471,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : if (m_isa == Target::NEON8 || m_isa == Target::NEON16 || m_isa == Target::NEON32) options.FloatABIType = llvm::FloatABI::Hard; -#if !defined(LLVM_3_1) if (g->opt.disableFMA == false) options.AllowFPOpFusion = llvm::FPOpFusion::Fast; -#endif // !LLVM_3_1 #ifdef ISPC_IS_WINDOWS if (strcmp("x86", arch) == 0) { @@ -526,12 +490,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : // Initialize TargetData/DataLayout in 3 steps. // 1. Get default data layout first - std::string dl_string; -#if defined(LLVM_3_1) - dl_string = m_targetMachine->getTargetData()->getStringRepresentation(); -#else - dl_string = m_targetMachine->getDataLayout()->getStringRepresentation(); -#endif + std::string dl_string = + m_targetMachine->getDataLayout()->getStringRepresentation(); // 2. Adjust for generic if (m_isa == Target::GENERIC) { @@ -546,11 +506,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : } // 3. Finally set member data -#if defined(LLVM_3_1) - m_targetData = new llvm::TargetData(dl_string); -#else m_dataLayout = new llvm::DataLayout(dl_string); -#endif // Set is32Bit // This indicates if we are compiling for 32 bit platform @@ -558,7 +514,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : // FIXME: all generic targets are handled as 64 bit, which is incorrect. this->m_is32Bit = (getDataLayout()->getPointerSize() == 4); -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) // This is LLVM 3.3+ feature. // Initialize target-specific "target-feature" attribute. if (!m_attributes.empty()) { @@ -772,7 +728,7 @@ Target::StructOffset(llvm::Type *type, int element, } void Target::markFuncWithTargetAttr(llvm::Function* func) { -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) if (m_tf_attributes) { func->addAttributes(llvm::AttributeSet::FunctionIndex, *m_tf_attributes); } diff --git a/ispc.h b/ispc.h index bf6d2642..d68f9034 100644 --- a/ispc.h +++ b/ispc.h @@ -40,8 +40,8 @@ #define ISPC_VERSION "1.4.5dev" -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) -#error "Only LLVM 3.1, 3.2, 3.3 and the 3.4 development branch are supported" +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) +#error "Only LLVM 3.2, 3.3 and the 3.4 development branch are supported" #endif #if defined(_WIN32) || defined(_WIN64) @@ -72,11 +72,7 @@ namespace llvm { class BasicBlock; class Constant; class ConstantValue; -#if defined(LLVM_3_1) - class TargetData; -#else class DataLayout; -#endif class DIBuilder; class DIDescriptor; class DIFile; @@ -226,11 +222,7 @@ public: // Note the same name of method for 3.1 and 3.2+, this allows // to reduce number ifdefs on client side. -#if defined(LLVM_3_1) - llvm::TargetData *getDataLayout() const {return m_targetData;} -#else llvm::DataLayout *getDataLayout() const {return m_dataLayout;} -#endif /** Reports if Target object has valid state. */ bool isValid() const {return m_valid;} @@ -278,11 +270,7 @@ private: */ llvm::TargetMachine *m_targetMachine; -#if defined(LLVM_3_1) - llvm::TargetData *m_targetData; -#else llvm::DataLayout *m_dataLayout; -#endif /** flag to report invalid state after construction (due to bad parameters passed to constructor). */ @@ -303,7 +291,7 @@ private: /** Target-specific attribute string to pass along to the LLVM backend */ std::string m_attributes; -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) /** Target-specific LLVM attribute, which has to be attached to every function to ensure that it is generated for correct target architecture. This is requirement was introduced in LLVM 3.3 */ diff --git a/llvmutil.cpp b/llvmutil.cpp index 180c8676..2f54a2fe 100644 --- a/llvmutil.cpp +++ b/llvmutil.cpp @@ -38,7 +38,7 @@ #include "llvmutil.h" #include "ispc.h" #include "type.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else diff --git a/llvmutil.h b/llvmutil.h index d6c5ede0..d1803f32 100644 --- a/llvmutil.h +++ b/llvmutil.h @@ -38,7 +38,7 @@ #ifndef ISPC_LLVMUTIL_H #define ISPC_LLVMUTIL_H 1 -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include diff --git a/main.cpp b/main.cpp index de2bb620..4c4b4575 100644 --- a/main.cpp +++ b/main.cpp @@ -62,9 +62,7 @@ static void lPrintVersion() { printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n", ISPC_VERSION, BUILD_VERSION, BUILD_DATE, -#if defined(LLVM_3_1) - "3.1" -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) "3.2" #elif defined(LLVM_3_3) "3.3" diff --git a/module.cpp b/module.cpp index 755a5dc4..eba5eb3b 100644 --- a/module.cpp +++ b/module.cpp @@ -64,7 +64,7 @@ #define strcasecmp stricmp #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -86,9 +86,7 @@ #include #include #include -#if defined(LLVM_3_1) - #include -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else // LLVM 3.3+ @@ -202,7 +200,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { // stuff and remove it later on. Removing it is useful, as it // reduces size of the binary significantly (manyfold for small // programs). -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) llvm::MDNode *nodeSPMD = llvm::dyn_cast(cuNode->getOperand(12)); Assert(nodeSPMD != NULL); @@ -797,11 +795,7 @@ Module::AddFunctionDeclaration(const std::string &name, #endif if (functionType->isTask) // This also applies transitively to members I think? -#if defined(LLVM_3_1) - function->setDoesNotAlias(1, true); -#else // LLVM 3.2+ function->setDoesNotAlias(1); -#endif g->target->markFuncWithTargetAttr(function); @@ -850,12 +844,7 @@ Module::AddFunctionDeclaration(const std::string &name, // NOTE: LLVM indexes function parameters starting from 1. // This is unintuitive. -#if defined(LLVM_3_1) - function->setDoesNotAlias(i+1, true); -#else function->setDoesNotAlias(i+1); -#endif - #if 0 int align = 4 * RoundUpPow2(g->target->nativeVectorWidth); function->addAttribute(i+1, llvm::Attribute::constructAlignmentFromInt(align)); @@ -1067,7 +1056,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, llvm::TargetMachine::CodeGenFileType fileType = (outputType == Object) ? llvm::TargetMachine::CGFT_ObjectFile : llvm::TargetMachine::CGFT_AssemblyFile; bool binary = (fileType == llvm::TargetMachine::CGFT_ObjectFile); -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) +#if defined(LLVM_3_2) || defined(LLVM_3_3) unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0; #else llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary : @@ -1082,11 +1071,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, } llvm::PassManager pm; -#if defined(LLVM_3_1) - pm.add(new llvm::TargetData(*g->target->getDataLayout())); -#else pm.add(new llvm::DataLayout(*g->target->getDataLayout())); -#endif llvm::formatted_raw_ostream fos(of->os()); @@ -1800,22 +1785,12 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre llvm::raw_fd_ostream stderrRaw(2, false); -#if defined(LLVM_3_1) - clang::TextDiagnosticPrinter *diagPrinter = - new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions()); -#else clang::DiagnosticOptions *diagOptions = new clang::DiagnosticOptions(); clang::TextDiagnosticPrinter *diagPrinter = new clang::TextDiagnosticPrinter(stderrRaw, diagOptions); -#endif llvm::IntrusiveRefCntPtr diagIDs(new clang::DiagnosticIDs); -#if defined(LLVM_3_1) - clang::DiagnosticsEngine *diagEngine = - new clang::DiagnosticsEngine(diagIDs, diagPrinter); -#else clang::DiagnosticsEngine *diagEngine = new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter); -#endif inst.setDiagnostics(diagEngine); clang::TargetOptions &options = inst.getTargetOpts(); @@ -1825,7 +1800,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre } options.Triple = triple.getTriple(); -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); #else // LLVM 3.3+ @@ -1835,18 +1810,14 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre inst.setTarget(target); inst.createSourceManager(inst.getFileManager()); -#if defined(LLVM_3_1) - inst.InitializeSourceManager(infilename); -#else clang::FrontendInputFile inputFile(infilename, clang::IK_None); inst.InitializeSourceManager(inputFile); -#endif // Don't remove comments in the preprocessor, so that we can accurately // track the source file position by handling them ourselves. inst.getPreprocessorOutputOpts().ShowComments = 1; -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) // LLVM 3.3+ +#if !defined(LLVM_3_2) // LLVM 3.3+ inst.getPreprocessorOutputOpts().ShowCPP = 1; #endif @@ -1858,7 +1829,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre headerOpts.Verbose = 1; for (int i = 0; i < (int)g->includePath.size(); ++i) { headerOpts.AddPath(g->includePath[i], clang::frontend::Angled, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) true /* is user supplied */, #endif false /* not a framework */, @@ -1913,11 +1884,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre } } -#if defined(LLVM_3_1) - inst.getLangOpts().BCPLComment = 1; -#else inst.getLangOpts().LineComment = 1; -#endif inst.createPreprocessor(); diagPrinter->BeginSourceFile(inst.getLangOpts(), &inst.getPreprocessor()); diff --git a/opt.cpp b/opt.cpp index 8efdbc67..8c86368e 100644 --- a/opt.cpp +++ b/opt.cpp @@ -48,7 +48,7 @@ #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -73,9 +73,7 @@ #include #include #include -#if defined(LLVM_3_1) - #include -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #else // LLVM 3.3+ #include @@ -85,11 +83,7 @@ #include #include #include -#if defined(LLVM_3_1) - #include -#else - #include -#endif +#include #include #ifdef ISPC_IS_LINUX #include @@ -415,18 +409,14 @@ Optimize(llvm::Module *module, int optLevel) { optPM.add(targetLibraryInfo); -#if defined(LLVM_3_1) - optPM.add(new llvm::TargetData(*g->target->getDataLayout())); -#else optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); llvm::TargetMachine *targetMachine = g->target->GetTargetMachine(); - #ifdef LLVM_3_2 +#ifdef LLVM_3_2 optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(), targetMachine->getVectorTargetTransformInfo())); - #else // LLVM 3.3+ +#else // LLVM 3.3+ targetMachine->addAnalysisPasses(optPM); - #endif #endif optPM.add(llvm::createIndVarSimplifyPass()); @@ -505,7 +495,7 @@ Optimize(llvm::Module *module, int optLevel) { optPM.add(llvm::createCFGSimplificationPass()); optPM.add(llvm::createArgumentPromotionPass()); -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) +#if defined(LLVM_3_2) || defined(LLVM_3_3) // Starting from 3.4 this functionality was moved to // InstructionCombiningPass. See r184459 for details. optPM.add(llvm::createSimplifyLibCallsPass()); diff --git a/stmt.cpp b/stmt.cpp index 4ec63d35..412b0dd9 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -48,7 +48,7 @@ #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include diff --git a/type.cpp b/type.cpp index 5fa1845b..11a165f5 100644 --- a/type.cpp +++ b/type.cpp @@ -43,20 +43,15 @@ #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else #include #include #endif -#if defined(LLVM_3_1) - #include - #include -#else - #include - #include -#endif +#include +#include #include @@ -819,11 +814,8 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const { m->diBuilder->createEnumerationType(scope, name, diFile, pos.first_line, 32 /* size in bits */, 32 /* align in bits */, - elementArray -#if !defined(LLVM_3_1) - , llvm::DIType() -#endif - ); + elementArray, + llvm::DIType()); switch (variability.type) { @@ -2139,7 +2131,7 @@ StructType::GetDIType(llvm::DIDescriptor scope) const { currentSize, // Size in bits align, // Alignment in bits 0, // Flags -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) llvm::DIType(), // DerivedFrom #endif elements); @@ -2382,7 +2374,7 @@ UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const { 0, // Size 0, // Align 0, // Flags -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) llvm::DIType(), // DerivedFrom #endif elements); @@ -2645,12 +2637,8 @@ ReferenceType::GetDIType(llvm::DIDescriptor scope) const { } llvm::DIType diTargetType = targetType->GetDIType(scope); -#if defined(LLVM_3_1) - return m->diBuilder->createReferenceType(diTargetType); -#else return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type, diTargetType); -#endif } diff --git a/type.h b/type.h index 880f8574..a6a52e10 100644 --- a/type.h +++ b/type.h @@ -40,7 +40,7 @@ #include "ispc.h" #include "util.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else diff --git a/util.cpp b/util.cpp index dbea9517..4be863bf 100644 --- a/util.cpp +++ b/util.cpp @@ -65,9 +65,7 @@ #include #include -#if defined(LLVM_3_1) - #include -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #else // LLVM 3.3+ #include @@ -616,13 +614,8 @@ VerifyDataLayoutCompatibility(const std::string &module_dl, // which contradic: f80:128:128 followed by f80:32:32. This is a bug, but // correct thing to do is to interpret this exactly how LLVM would treat it, // so we create a DataLayout class and take its string representation. -#if defined(LLVM_3_1) - llvm::TargetData d1(module_dl); - llvm::TargetData d2(lib_dl); -#else // LLVM 3.2+ llvm::DataLayout d1(module_dl); llvm::DataLayout d2(lib_dl); -#endif std::string module_dl_canonic = d1.getStringRepresentation(); std::string lib_dl_canonic = d2.getStringRepresentation();