diff --git a/builtins.cpp b/builtins.cpp index 6df7e6c6..f0dedabf 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -47,15 +47,25 @@ #include #include -#include -#if !defined(LLVM_3_0) && !defined(LLVM_3_1) +#if defined(LLVM_3_2) #include #endif -#include -#include -#include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include + #include +#endif #include #include #include @@ -700,10 +710,10 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module, llvm::Function *func = module->getFunction(name); Assert(func != NULL); // it should be declared already... -#if defined(LLVM_3_0) || defined(LLVM_3_1) - func->addFnAttr(llvm::Attribute::AlwaysInline); -#else +#if defined(LLVM_3_2) func->addFnAttr(llvm::Attributes::AlwaysInline); +#else + func->addFnAttr(llvm::Attribute::AlwaysInline); #endif llvm::BasicBlock *bblock = llvm::BasicBlock::Create(*g->ctx, "entry", func, 0); llvm::ReturnInst::Create(*g->ctx, LLVMInt32(val), bblock); diff --git a/cbackend.cpp b/cbackend.cpp index f5fa85c7..057ba5b4 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -29,16 +29,27 @@ #include "llvmutil.h" -#include "llvm/CallingConv.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Module.h" -#include "llvm/Instructions.h" +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include "llvm/Constants.h" + #include "llvm/DerivedTypes.h" + #include "llvm/CallingConv.h" + #include "llvm/Module.h" + #include "llvm/Instructions.h" + #include "llvm/Intrinsics.h" + #include "llvm/IntrinsicInst.h" + #include "llvm/InlineAsm.h" +#else + #include "llvm/IR/Constants.h" + #include "llvm/IR/DerivedTypes.h" + #include "llvm/IR/CallingConv.h" + #include "llvm/IR/Module.h" + #include "llvm/IR/Instructions.h" + #include "llvm/IR/Intrinsics.h" + #include "llvm/IR/IntrinsicInst.h" + #include "llvm/IR/InlineAsm.h" +#endif #include "llvm/Pass.h" #include "llvm/PassManager.h" -#include "llvm/Intrinsics.h" -#include "llvm/IntrinsicInst.h" -#include "llvm/InlineAsm.h" #if !defined(LLVM_3_0) && !defined(LLVM_3_1) #include "llvm/TypeFinder.h" #endif // LLVM_3_2 + @@ -63,8 +74,10 @@ #include "llvm/MC/MCSymbol.h" #if defined(LLVM_3_0) || defined(LLVM_3_1) #include "llvm/Target/TargetData.h" -#else +#elif defined(LLVM_3_2) #include "llvm/DataLayout.h" +#else // LLVM 3.3+ + #include "llvm/IR/DataLayout.h" #endif #include "llvm/Support/CallSite.h" #include "llvm/Support/CFG.h" @@ -335,13 +348,22 @@ namespace { bool isSigned = false, const std::string &VariableName = "", bool IgnoreName = false, - const llvm::AttrListPtr &PAL = llvm::AttrListPtr()); +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + const llvm::AttrListPtr &PAL = llvm::AttrListPtr() +#else + const llvm::AttributeSet &PAL = llvm::AttributeSet() +#endif + ); llvm::raw_ostream &printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned, const std::string &NameSoFar = ""); void printStructReturnPointerFunctionType(llvm::raw_ostream &Out, +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) const llvm::AttrListPtr &PAL, +#else + const llvm::AttributeSet &PAL, +#endif llvm::PointerType *Ty); std::string getStructName(llvm::StructType *ST); @@ -567,7 +589,11 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2) const llvm::AttrListPtr &PAL, +#else + const llvm::AttributeSet &PAL, +#endif llvm::PointerType *TheTy) { llvm::FunctionType *FTy = llvm::cast(TheTy->getElementType()); std::string tstr; @@ -584,8 +610,10 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, llvm::Type *ArgTy = *I; #if defined(LLVM_3_0) || defined(LLVM_3_1) if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#else +#elif defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { +#else + if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) { #endif assert(ArgTy->isPointerTy()); ArgTy = llvm::cast(ArgTy)->getElementType(); @@ -593,8 +621,10 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, printType(FunctionInnards, ArgTy, #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), +#else + PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt), #endif ""); PrintedType = true; @@ -610,8 +640,10 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, printType(Out, RetTy, #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), +#else + PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt), #endif FunctionInnards.str()); } @@ -707,7 +739,14 @@ 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, const llvm::AttrListPtr &PAL) { + bool IgnoreName, +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + const llvm::AttrListPtr &PAL +#else + const llvm::AttributeSet &PAL +#endif + ) { + if (Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) { printSimpleType(Out, Ty, isSigned, NameSoFar); return Out; @@ -725,8 +764,10 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, llvm::Type *ArgTy = *I; #if defined(LLVM_3_0) || defined(LLVM_3_1) if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#else +#elif defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { +#else + if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) { #endif assert(ArgTy->isPointerTy()); ArgTy = llvm::cast(ArgTy)->getElementType(); @@ -736,8 +777,10 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, printType(FunctionInnards, ArgTy, #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), +#else + PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt), #endif ""); ++Idx; @@ -753,8 +796,10 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, printType(Out, FTy->getReturnType(), #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), +#else + PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt), #endif FunctionInnards.str()); return Out; @@ -2796,7 +2841,11 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2) const llvm::AttrListPtr &PAL = F->getAttributes(); +#else + const llvm::AttributeSet &PAL = F->getAttributes(); +#endif std::string tstr; llvm::raw_string_ostream FunctionInnards(tstr); @@ -2828,8 +2877,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { llvm::Type *ArgTy = I->getType(); #if defined(LLVM_3_0) || defined(LLVM_3_1) if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#else +#elif defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { +#else + if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) { #endif ArgTy = llvm::cast(ArgTy)->getElementType(); ByValParams.insert(I); @@ -2837,8 +2888,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { printType(FunctionInnards, ArgTy, #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), +#else + PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt), #endif ArgName); PrintedArg = true; @@ -2863,8 +2916,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { llvm::Type *ArgTy = *I; #if defined(LLVM_3_0) || defined(LLVM_3_1) if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#else +#elif defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { +#else + if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) { #endif assert(ArgTy->isPointerTy()); ArgTy = llvm::cast(ArgTy)->getElementType(); @@ -2872,9 +2927,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { printType(FunctionInnards, ArgTy, #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt) -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt) - +#else + PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt) #endif ); PrintedArg = true; @@ -2910,8 +2966,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { printType(Out, RetTy, #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), +#else + PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt), #endif FunctionInnards.str()); } @@ -3718,7 +3776,11 @@ void CWriter::lowerIntrinsics(llvm::Function &F) { const char *BuiltinName = ""; #define GET_GCC_BUILTIN_NAME #define Intrinsic llvm::Intrinsic -#include "llvm/Intrinsics.gen" +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include "llvm/Intrinsics.gen" +#else + #include "llvm/IR/Intrinsics.gen" +#endif #undef Intrinsic #undef GET_GCC_BUILTIN_NAME // If we handle it, don't lower it. @@ -3779,7 +3841,11 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2) const llvm::AttrListPtr &PAL = I.getAttributes(); +#else + const llvm::AttributeSet &PAL = I.getAttributes(); +#endif bool hasByVal = I.hasByValArgument(); bool isStructRet = I.hasStructRetAttr(); if (isStructRet) { @@ -3858,18 +3924,20 @@ void CWriter::visitCallInst(llvm::CallInst &I) { printType(Out, FTy->getParamType(ArgNo), #if defined(LLVM_3_0) || defined(LLVM_3_1) /*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt) -#else +#elif defined(LLVM_3_2) PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt) +#else + PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attribute::SExt) #endif ); Out << ')'; } // Check if the argument is expected to be passed by value. if (I.paramHasAttr(ArgNo+1, -#if defined(LLVM_3_0) || defined(LLVM_3_1) - llvm::Attribute::ByVal -#else +#if defined(LLVM_3_2) llvm::Attributes::ByVal +#else + llvm::Attribute::ByVal #endif )) writeOperandDeref(*AI); @@ -3895,7 +3963,11 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID, #endif // LLVM_3_0 #define GET_GCC_BUILTIN_NAME #define Intrinsic llvm::Intrinsic -#include "llvm/Intrinsics.gen" +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include "llvm/Intrinsics.gen" +#else + #include "llvm/IR/Intrinsics.gen" +#endif #undef Intrinsic #undef GET_GCC_BUILTIN_NAME assert(BuiltinName[0] && "Unknown LLVM intrinsic!"); @@ -4677,35 +4749,35 @@ public: notFunc = llvm::dyn_cast(m->getOrInsertFunction("__not", mt, mt, NULL)); assert(notFunc != NULL); -#if defined(LLVM_3_0) || defined(LLVM_3_1) - notFunc->addFnAttr(llvm::Attribute::NoUnwind); - notFunc->addFnAttr(llvm::Attribute::ReadNone); -#else +#if defined(LLVM_3_2) notFunc->addFnAttr(llvm::Attributes::NoUnwind); notFunc->addFnAttr(llvm::Attributes::ReadNone); +#else + notFunc->addFnAttr(llvm::Attribute::NoUnwind); + notFunc->addFnAttr(llvm::Attribute::ReadNone); #endif andNotFuncs[0] = llvm::dyn_cast(m->getOrInsertFunction("__and_not1", mt, mt, mt, NULL)); assert(andNotFuncs[0] != NULL); -#if defined(LLVM_3_0) || defined(LLVM_3_1) - andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind); - andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone); -#else +#if defined(LLVM_3_2) andNotFuncs[0]->addFnAttr(llvm::Attributes::NoUnwind); andNotFuncs[0]->addFnAttr(llvm::Attributes::ReadNone); +#else + andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind); + andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone); #endif andNotFuncs[1] = llvm::dyn_cast(m->getOrInsertFunction("__and_not2", mt, mt, mt, NULL)); assert(andNotFuncs[1] != NULL); -#if defined(LLVM_3_0) || defined(LLVM_3_1) - andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind); - andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone); -#else +#if defined(LLVM_3_2) andNotFuncs[1]->addFnAttr(llvm::Attributes::NoUnwind); andNotFuncs[1]->addFnAttr(llvm::Attributes::ReadNone); +#else + andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind); + andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone); #endif } diff --git a/ctx.cpp b/ctx.cpp index a066679b..8e6571e6 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -45,11 +45,18 @@ #include "module.h" #include "sym.h" #include -#include -#include #include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include +#else + #include + #include + #include + #include +#endif /** This is a small utility structure that records information related to one level of nested control flow. It's mostly used in correctly restoring diff --git a/ctx.h b/ctx.h index 9f1f2788..1cd4cc8e 100644 --- a/ctx.h +++ b/ctx.h @@ -40,8 +40,13 @@ #include "ispc.h" #include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include +#else + #include + #include +#endif #if defined(LLVM_3_0) || defined(LLVM_3_1) #include #include diff --git a/expr.cpp b/expr.cpp index ce4704e9..56eaaa57 100644 --- a/expr.cpp +++ b/expr.cpp @@ -56,13 +56,23 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include + #include +#endif #include #include diff --git a/func.cpp b/func.cpp index 7f3eee21..2f9f903f 100644 --- a/func.cpp +++ b/func.cpp @@ -46,12 +46,21 @@ #include "util.h" #include -#include -#include -#include -#include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include +#endif #include #include #include @@ -303,8 +312,10 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, ( #if defined(LLVM_3_0) || defined(LLVM_3_1) (function->hasFnAttr(llvm::Attribute::AlwaysInline) == false) -#else +#elif defined(LLVM_3_2) (function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false) +#else // LLVM 3.3+ + (function->getAttributes().getFnAttributes().hasAttribute(llvm::Attribute::AlwaysInline) == false) #endif && costEstimate > CHECK_MASK_AT_FUNCTION_START_COST); diff --git a/ispc.cpp b/ispc.cpp index af066063..6ac9e6ce 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -48,8 +48,15 @@ #include #include #endif -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include +#else + #include + #include + #include +#endif #if defined(LLVM_3_0) || defined(LLVM_3_1) #include #include @@ -58,13 +65,14 @@ #include #endif #include -#include #include #include #if defined(LLVM_3_0) || defined(LLVM_3_1) #include -#else +#elif defined(LLVM_3_2) #include +#else // LLVM 3.3+ + #include #endif #include #include diff --git a/llvmutil.cpp b/llvmutil.cpp index d0c694ff..4e310fb8 100644 --- a/llvmutil.cpp +++ b/llvmutil.cpp @@ -38,8 +38,13 @@ #include "llvmutil.h" #include "ispc.h" #include "type.h" -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include +#else + #include + #include +#endif #include #include diff --git a/llvmutil.h b/llvmutil.h index ba8bc16d..192d89a3 100644 --- a/llvmutil.h +++ b/llvmutil.h @@ -38,10 +38,17 @@ #ifndef ISPC_LLVMUTIL_H #define ISPC_LLVMUTIL_H 1 -#include -#include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include +#else + #include + #include + #include + #include +#endif namespace llvm { class PHINode; diff --git a/module.cpp b/module.cpp index c8f328ba..b6ca98b3 100644 --- a/module.cpp +++ b/module.cpp @@ -64,12 +64,21 @@ #define strcasecmp stricmp #endif -#include -#include -#include -#include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include +#endif #include #include #include @@ -80,7 +89,11 @@ #if defined(LLVM_3_0) || defined(LLVM_3_1) #include #else - #include + #if defined(LLVM_3_2) + #include + #else // LLVM 3.3+ + #include + #endif #include #endif #include @@ -760,10 +773,10 @@ Module::AddFunctionDeclaration(const std::string &name, if (storageClass != SC_EXTERN_C && !g->generateDebuggingSymbols && isInline) -#if defined(LLVM_3_0) || defined(LLVM_3_1) - function->addFnAttr(llvm::Attribute::AlwaysInline); -#else +#ifdef LLVM_3_2 function->addFnAttr(llvm::Attributes::AlwaysInline); +#else + function->addFnAttr(llvm::Attribute::AlwaysInline); #endif if (functionType->isTask) // This also applies transitively to members I think? @@ -1799,8 +1812,13 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre } options.Triple = triple.getTriple(); +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); +#else // LLVM 3.3+ + clang::TargetInfo *target = + clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options); +#endif inst.setTarget(target); inst.createSourceManager(inst.getFileManager()); diff --git a/opt.cpp b/opt.cpp index 8c6f7b06..5f5ec67a 100644 --- a/opt.cpp +++ b/opt.cpp @@ -48,15 +48,24 @@ #include #include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include +#endif #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -66,8 +75,11 @@ #include #if defined(LLVM_3_0) || defined(LLVM_3_1) #include -#else +#elif defined(LLVM_3_2) #include +#else // LLVM 3.3+ + #include + #include #endif #include #include @@ -416,8 +428,13 @@ Optimize(llvm::Module *module, int optLevel) { optPM.add(new llvm::DataLayout(*dl)); else optPM.add(new llvm::DataLayout(module)); + #ifdef LLVM_3_2 optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(), targetMachine->getVectorTargetTransformInfo())); + #else // LLVM 3.3+ + optPM.add(llvm::createNoTTIPass(targetMachine->getScalarTargetTransformInfo(), + targetMachine->getVectorTargetTransformInfo())); + #endif #endif optPM.add(llvm::createIndVarSimplifyPass()); diff --git a/parse.yy b/parse.yy index cb81a5a9..bdabe50a 100644 --- a/parse.yy +++ b/parse.yy @@ -83,7 +83,11 @@ struct ForeachDimension; #include "util.h" #include -#include +#if !defined(LLVM_3_0) && !defined(LLVM_3_1) && !defined(LLVM_3_2) + #include +#else + #include +#endif #define UNIMPLEMENTED \ Error(yylloc, "Unimplemented parser functionality %s:%d", \ diff --git a/stmt.cpp b/stmt.cpp index 830754d5..665389fc 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -48,14 +48,25 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include + #include + #include +#endif #include /////////////////////////////////////////////////////////////////////////// diff --git a/type.cpp b/type.cpp index ffc84252..a53222ce 100644 --- a/type.cpp +++ b/type.cpp @@ -43,8 +43,13 @@ #include #include -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include +#else + #include + #include +#endif #if defined(LLVM_3_0) || defined(LLVM_3_1) #include #include diff --git a/type.h b/type.h index c5df6dd0..2c6834ef 100644 --- a/type.h +++ b/type.h @@ -40,8 +40,13 @@ #include "ispc.h" #include "util.h" -#include -#include +#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2) + #include + #include +#else + #include + #include +#endif #include class ConstExpr;