From ebc47d00a101ab8c3773a9440111fe695ad0be74 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 17 Jun 2015 14:07:51 +0300 Subject: [PATCH] remove several redundant #if - clauses --- builtins.cpp | 35 +++++++---------- cbackend.cpp | 98 +++++++++++++++++++++++----------------------- ctx.cpp | 52 ++++++++++++------------- ctx.h | 14 +++---- expr.cpp | 2 +- func.cpp | 16 ++++---- ispc.cpp | 18 ++++----- ispc.h | 6 +-- ispc_version.h | 4 ++ llvmutil.h | 4 +- main.cpp | 5 +-- module.cpp | 92 +++++++++++++++++++++---------------------- module.h | 4 +- opt.cpp | 60 ++++++++++++++-------------- parse.yy | 2 +- stmt.cpp | 6 +-- type.cpp | 104 ++++++++++++++++++++++++------------------------- type.h | 24 ++++++------ util.cpp | 2 +- 19 files changed, 273 insertions(+), 275 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index 9cc36fc0..a29bee0e 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -47,10 +47,8 @@ #include #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include -#endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #include #include #include @@ -784,7 +782,7 @@ void AddBitcodeToModule(const unsigned char *bitcode, int length, llvm::Module *module, SymbolTable *symbolTable, bool warn) { llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); #else // LLVM 3.6+ llvm::MemoryBufferRef bcBuf = llvm::MemoryBuffer::getMemBuffer(sb)->getMemBufferRef(); @@ -880,7 +878,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, std::string(linkError); if (llvm::Linker::LinkModules(module, bcModule -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 , llvm::Linker::DestroySource, &linkError)) Error(SourcePos(), "Error linking stdlib bitcode: %s", linkError.c_str()); @@ -917,7 +915,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module, symbolTable->AddVariable(sym); if (m->diBuilder != NULL) { -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIFile file; llvm::DIType diType = sym->type->GetDIType(file); Assert(diType.Verify()); @@ -932,7 +930,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module, // have the DW_AT_artifical attribute. It's not clear if this // matters for anything though. -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( name, file, @@ -940,7 +938,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module, diType, true /* static */, sym->storagePtr); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* i.e., 3.6 */ +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // LLVM 3.6 llvm::Constant *sym_const_storagePtr = llvm::dyn_cast(sym->storagePtr); Assert(sym_const_storagePtr); llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( @@ -965,7 +963,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module, true /* static */, sym_const_storagePtr); #endif -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 Assert(var.Verify()); #else // LLVM 3.7+ //coming soon @@ -984,7 +982,7 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module, llvm::Function *func = module->getFunction(name); Assert(func != NULL); // it should be declared already... -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 func->addFnAttr(llvm::Attributes::AlwaysInline); #else // LLVM 3.3+ func->addFnAttr(llvm::Attribute::AlwaysInline); @@ -1019,7 +1017,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) { symbolTable->AddVariable(sym); if (m->diBuilder != NULL) { -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIFile file; llvm::DIType diType = sym->type->GetDIType(file); Assert(diType.Verify()); @@ -1030,13 +1028,10 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) { llvm::DIType *diType = sym->type->GetDIType(file); // Assert(diType.Verify()); #endif -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // LLVM 3.6 llvm::Constant *sym_const_storagePtr = llvm::dyn_cast(sym->storagePtr); Assert(sym_const_storagePtr); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 - llvm::DIGlobalVariable var = -#endif - m->diBuilder->createGlobalVariable( + llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( file, sym->name.c_str(), sym->name.c_str(), @@ -1045,7 +1040,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) { diType, false /* static */, sym_const_storagePtr); -#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 /* && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 */ +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( sym->name.c_str(), file, @@ -1053,7 +1048,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) { diType, false /* static */, sym->storagePtr); -#else +#else // LLVM 3.7+ llvm::Constant *sym_const_storagePtr = llvm::dyn_cast(sym->storagePtr); Assert(sym_const_storagePtr); m->diBuilder->createGlobalVariable( @@ -1065,8 +1060,8 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) { diType, false /* static */, sym_const_storagePtr); -#endif -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#endif +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 Assert(var.Verify()); #else // LLVM 3.7+ //coming soon diff --git a/cbackend.cpp b/cbackend.cpp index aa2385eb..41614f26 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -41,7 +41,7 @@ #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" #include "llvm/InlineAsm.h" -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/CallingConv.h" @@ -52,25 +52,25 @@ #include "llvm/IR/InlineAsm.h" #endif #include "llvm/Pass.h" -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* <= 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6 #include "llvm/PassManager.h" -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ #include "llvm/IR/LegacyPassManager.h" #endif #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include "llvm/TypeFinder.h" -#else /* LLVM_3_3+ */ +#else // LLVM_3_3+ #include "llvm/IR/TypeFinder.h" #endif #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4 #include "llvm/Support/InstIterator.h" -#else /* 3.5+ */ +#else // 3.5+ #include "llvm/IR/InstIterator.h" #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 #include "llvm/Analysis/FindUsedTypes.h" #endif #include "llvm/Analysis/LoopInfo.h" @@ -100,18 +100,18 @@ #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSymbol.h" -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2 #include "llvm/DataLayout.h" -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ #include "llvm/IR/DataLayout.h" #endif #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2 #include "llvm/Support/InstVisitor.h" -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.3, 3.4 */ +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.3, 3.4 #include "llvm/InstVisitor.h" -#else /* LLVM 3.5+ */ +#else // LLVM 3.5+ #include "llvm/IR/InstVisitor.h" #endif #include "llvm/Support/MathExtras.h" @@ -119,7 +119,7 @@ #include "llvm/Support/Host.h" #include "llvm/Target/TargetMachine.h" -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4 #include "llvm/Config/config.h" #endif @@ -312,7 +312,7 @@ namespace { /// walked in other ways. GlobalValues, basic blocks, instructions, and /// inst operands are all explicitly enumerated. void incorporateValue(const llvm::Value *V) { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5 if (const llvm::MDNode *M = llvm::dyn_cast(V)) { incorporateMDNode(M); return; @@ -339,7 +339,7 @@ namespace { incorporateValue(*I); } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5 void incorporateMDNode(const llvm::MDNode *V) { // Already visited? @@ -351,7 +351,7 @@ namespace { if (llvm::Value *Op = V->getOperand(i)) incorporateValue(Op); } -#else /* LLVM 3.6+ */ +#else // LLVM 3.6+ void incorporateMDNode(const llvm::Metadata *M) { // Already visited? @@ -397,7 +397,7 @@ namespace { public: CBEMCAsmInfo() { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4 GlobalPrefix = ""; #endif PrivateGlobalPrefix = ""; @@ -449,9 +449,9 @@ namespace { OpaqueCounter(0), NextAnonValueNumber(0), includeName(incname ? incname : "generic_defs.h"), vectorWidth(vecwidth) { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6 initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry()); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ initializeLoopInfoWrapperPassPass(*llvm::PassRegistry::getPassRegistry()); #endif FPCounter = 0; @@ -461,9 +461,9 @@ namespace { virtual const char *getPassName() const { return "C backend"; } void getAnalysisUsage(llvm::AnalysisUsage &AU) const { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6 AU.addRequired(); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ AU.addRequired(); #endif AU.setPreservesAll(); @@ -477,9 +477,9 @@ namespace { if (F.hasAvailableExternallyLinkage()) return false; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6 LI = &getAnalysis(); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ LI = &getAnalysis().getLoopInfo(); #endif @@ -521,7 +521,7 @@ namespace { bool IgnoreName = false, #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 const llvm::AttrListPtr &PAL = llvm::AttrListPtr() -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ const llvm::AttributeSet &PAL = llvm::AttributeSet() #endif ); @@ -532,7 +532,7 @@ namespace { void printStructReturnPointerFunctionType(llvm::raw_ostream &Out, #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 const llvm::AttrListPtr &PAL, -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ const llvm::AttributeSet &PAL, #endif llvm::PointerType *Ty); @@ -778,7 +778,7 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) { void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 const llvm::AttrListPtr &PAL, -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ const llvm::AttributeSet &PAL, #endif llvm::PointerType *TheTy) { @@ -797,7 +797,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, llvm::Type *ArgTy = *I; #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { #endif assert(ArgTy->isPointerTy()); @@ -806,7 +806,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, printType(FunctionInnards, ArgTy, #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), #endif ""); @@ -823,7 +823,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, printType(Out, RetTy, #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), #endif FunctionInnards.str()); @@ -2391,7 +2391,7 @@ bool CWriter::doInitialization(llvm::Module &M) { #endif TAsm = new CBEMCAsmInfo(); MRI = new llvm::MCRegisterInfo(); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 /* LLVM 3.4+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+ TCtx = new llvm::MCContext(TAsm, MRI, NULL); #else TCtx = new llvm::MCContext(*TAsm, *MRI, NULL); @@ -2515,7 +2515,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() || I->hasCommonLinkage()) Out << "extern "; -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ else if (I->hasDLLImportStorageClass()) #else else if (I->hasDLLImportLinkage()) @@ -2692,7 +2692,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasLocalLinkage()) Out << "static "; -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -3041,7 +3041,7 @@ void CWriter::printContainedStructs(llvm::Type *Ty, if (llvm::StructType *ST = llvm::dyn_cast(Ty)) { // Check to see if we have already printed this struct. -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* LLVM 3.6+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+ if (!Printed.insert(Ty).second) return; #else if (!Printed.insert(Ty)) return; @@ -3052,7 +3052,7 @@ void CWriter::printContainedStructs(llvm::Type *Ty, Out << ";\n\n"; } if (llvm::ArrayType *AT = llvm::dyn_cast(Ty)) { -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* LLVM 3.6+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+ if (!Printed.insert(Ty).second) return; #else if (!Printed.insert(Ty)) return; @@ -3066,7 +3066,7 @@ void CWriter::printContainedStructs(llvm::Type *Ty, void CWriter::printContainedArrays(llvm::ArrayType *ATy, llvm::SmallPtrSet &Printed) { -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* LLVM 3.6+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+ if (!Printed.insert(ATy).second) return; #else @@ -3087,7 +3087,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { bool isStructReturn = F->hasStructRetAttr(); if (F->hasLocalLinkage()) Out << "static "; -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -3413,7 +3413,7 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) { printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ if (llvm::Function::iterator(Succ) == std::next(llvm::Function::iterator(SI.getParent()))) #else if (llvm::Function::iterator(Succ) == llvm::next(llvm::Function::iterator(SI.getParent()))) @@ -3438,7 +3438,7 @@ bool CWriter::isGotoCodeNecessary(llvm::BasicBlock *From, llvm::BasicBlock *To) /// FIXME: This should be reenabled, but loop reordering safe!! return true; -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ if (std::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) #else if (llvm::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) @@ -4093,7 +4093,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) { // All other intrinsic calls we must lower. llvm::Instruction *Before = 0; if (CI != &BB->front()) -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ Before = std::prev(llvm::BasicBlock::iterator(CI)); #else Before = prior(llvm::BasicBlock::iterator(CI)); @@ -4818,7 +4818,7 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) { void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) { Out << "("; -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ printType(Out, ACXI.getType(), false); Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly #endif @@ -4829,7 +4829,7 @@ void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) { Out << ", "; writeOperand(ACXI.getNewValOperand()); Out << ")"; -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ Out << ", true /* There is no way to learn the value of this bit inside ISPC, so making it constant */)"; #endif Out << ")"; @@ -5315,9 +5315,9 @@ bool WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, const char *includeName) { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // 3.2, 3.3, 3.4, 3.5, 3.6 llvm::PassManager pm; -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ llvm::legacy::PassManager pm; #endif #if 0 @@ -5327,23 +5327,23 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, pm.add(new llvm::TargetData(module)); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // 3.2, 3.3 int flags = 0; -#else /* LLVM 3.4+ */ +#else // LLVM 3.4+ llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None; #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5 std::string error; -#else /* LLVM 3.6+ */ +#else // LLVM 3.6+ std::error_code error; #endif llvm::tool_output_file *of = new llvm::tool_output_file(fn, error, flags); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5 if (error.size()) { -#else /* LLVM 3.6+ */ +#else // LLVM 3.6+ if (error) { #endif fprintf(stderr, "Error opening output file \"%s\".\n", fn); diff --git a/ctx.cpp b/ctx.cpp index fdf80c56..e4a20f64 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -337,22 +337,22 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, /* If debugging is enabled, tell the debug information emission code about this new function */ -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ diFile = funcStartPos.GetDIFile(); AssertPos(currentPos, diFile.Verify()); #else /* LLVM 3.7+ */ diFile = funcStartPos.GetDIFile(); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 /* 3.2, 3.3 */ llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU()); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.4, 3.5, 3.6 */ +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.4, 3.5, 3.6 */ llvm::DIScope scope = llvm::DIScope(m->diCompileUnit); #else /* LLVM 3.7+ */ llvm::DIScope *scope = m->diCompileUnit; //llvm::MDScope *scope = m->diCompileUnit; #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::DIType diSubprogramType; AssertPos(currentPos, scope.Verify()); #else /* LLVM 3.7+ */ @@ -365,17 +365,17 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, AssertPos(currentPos, m->errorCount > 0); else { diSubprogramType = functionType->GetDIType(scope); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ AssertPos(currentPos, diSubprogramType.Verify()); #else /* LLVM 3.7+ */ //comming soon #endif } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 /* 3.2, 3.3 */ llvm::DIType diSubprogramType_n = diSubprogramType; int flags = llvm::DIDescriptor::FlagPrototyped; -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.4, 3.5, 3.6 */ +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.4, 3.5, 3.6 */ Assert(diSubprogramType.isCompositeType()); llvm::DICompositeType diSubprogramType_n = static_cast(diSubprogramType); @@ -395,7 +395,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, bool isOptimized = (g->opt.level > 0); int firstLine = funcStartPos.first_line; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ diSubprogram = m->diBuilder->createFunction(diFile /* scope */, funSym->name, mangledName, diFile, @@ -1613,7 +1613,7 @@ lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) { sConstant, var_name.c_str()); llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) }; llvm::ArrayRef arrayRef(&indices[0], &indices[2]); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ return llvm::GetElementPtrInst::Create(sPtr, arrayRef, "sptr", bblock); #else /* LLVM 3.7+ */ return llvm::GetElementPtrInst::Create(PTYPE(sPtr), @@ -1657,7 +1657,7 @@ FunctionEmitContext::GetDebugPos() const { void FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos, -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::DIScope *scope) { #else /* LLVM 3.7+ */ llvm::DIScope *scope) { @@ -1672,7 +1672,7 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos, // for those functions inst->setDebugLoc(llvm::DebugLoc::get(p.first_line, p.first_column, scope ? -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ *scope #else /* LLVM 3.7+ */ scope @@ -1685,7 +1685,7 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos, void FunctionEmitContext::StartScope() { if (m->diBuilder != NULL) { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::DIScope parentScope; llvm::DILexicalBlock lexicalBlock; #else /* LLVM 3.7+ */ @@ -1712,7 +1712,7 @@ FunctionEmitContext::StartScope() { // as the last argument currentPos.first_column); #endif // LLVM 3.2, 3.3, 3.4 and 3.6+ -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ AssertPos(currentPos, lexicalBlock.Verify()); debugScopes.push_back(lexicalBlock); #else /* LLVM 3.7+ */ @@ -1732,7 +1732,7 @@ FunctionEmitContext::EndScope() { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::DIScope #else /* LLVM 3.7+ */ llvm::DIScope* @@ -1749,7 +1749,7 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) { if (m->diBuilder == NULL) return; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::DIScope scope = GetDIScope(); llvm::DIType diType = sym->type->GetDIType(scope); AssertPos(currentPos, diType.Verify()); @@ -1769,7 +1769,7 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) { sym->pos.first_line, diType, true /* preserve through opts */); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ AssertPos(currentPos, var.Verify()); llvm::Instruction *declareInst = m->diBuilder->insertDeclare(sym->storagePtr, var, @@ -1796,7 +1796,7 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) { return; int flags = 0; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::DIScope scope = diSubprogram; llvm::DIType diType = sym->type->GetDIType(scope); AssertPos(currentPos, diType.Verify()); @@ -1818,7 +1818,7 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) { true /* preserve through opts */, flags, argNum + 1); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ AssertPos(currentPos, var.Verify()); llvm::Instruction *declareInst = m->diBuilder->insertDeclare(sym->storagePtr, var, @@ -2444,7 +2444,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index, // uniform, so just emit the regular LLVM GEP instruction llvm::Value *ind[1] = { index }; llvm::ArrayRef arrayRef(&ind[0], &ind[1]); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::Instruction *inst = llvm::GetElementPtrInst::Create(basePtr, arrayRef, name ? name : "gep", bblock); @@ -2511,7 +2511,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0 // uniform, so just emit the regular LLVM GEP instruction llvm::Value *indices[2] = { index0, index1 }; llvm::ArrayRef arrayRef(&indices[0], &indices[2]); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ llvm::Instruction *inst = llvm::GetElementPtrInst::Create(basePtr, arrayRef, name ? name : "gep", bblock); @@ -2612,7 +2612,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum, // If the pointer is uniform, we can use the regular LLVM GEP. llvm::Value *offsets[2] = { LLVMInt32(0), LLVMInt32(elementNum) }; llvm::ArrayRef arrayRef(&offsets[0], &offsets[2]); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ resultPtr = llvm::GetElementPtrInst::Create(basePtr, arrayRef, name ? name : "struct_offset", bblock); @@ -2923,7 +2923,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) { llvm::Instruction *inst = llvm::dyn_cast(v); if (inst == NULL) return; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */ llvm::Value *str = llvm::MDString::get(*g->ctx, pos.name); #else /* LLVN 3.6+ */ llvm::MDString *str = llvm::MDString::get(*g->ctx, pos.name); @@ -2931,7 +2931,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) { llvm::MDNode *md = llvm::MDNode::get(*g->ctx, str); inst->setMetadata("filename", md); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */ llvm::Value *first_line = LLVMInt32(pos.first_line); #else /* LLVN 3.6+ */ llvm::Metadata *first_line = llvm::ConstantAsMetadata::get(LLVMInt32(pos.first_line)); @@ -2939,7 +2939,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) { md = llvm::MDNode::get(*g->ctx, first_line); inst->setMetadata("first_line", md); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */ llvm::Value *first_column = LLVMInt32(pos.first_column); #else /* LLVN 3.6+ */ llvm::Metadata *first_column = llvm::ConstantAsMetadata::get(LLVMInt32(pos.first_column)); @@ -2947,7 +2947,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) { md = llvm::MDNode::get(*g->ctx, first_column); inst->setMetadata("first_column", md); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */ llvm::Value *last_line = LLVMInt32(pos.last_line); #else /* LLVN 3.6+ */ llvm::Metadata *last_line = llvm::ConstantAsMetadata::get(LLVMInt32(pos.last_line)); @@ -2955,7 +2955,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) { md = llvm::MDNode::get(*g->ctx, last_line); inst->setMetadata("last_line", md); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */ llvm::Value *last_column = LLVMInt32(pos.last_column); #else /* LLVN 3.6+ */ llvm::Metadata *last_column = llvm::ConstantAsMetadata::get(LLVMInt32(pos.last_column)); diff --git a/ctx.h b/ctx.h index 7b2184ca..3f52cdc4 100644 --- a/ctx.h +++ b/ctx.h @@ -40,17 +40,17 @@ #include "ispc.h" #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include #include -#else /* >= 3.3 */ +#else // 3.3+ #include #include #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 #include #include -#else /* >= 3.5 */ +#else // 3.5+ #include #include #endif @@ -352,7 +352,7 @@ public: Instructions stored using Value pointers; the code here returns silently if it's not actually given an instruction. */ void AddDebugPos(llvm::Value *instruction, const SourcePos *pos = NULL, -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIScope *scope = NULL); #else /* LLVM 3.7+ */ llvm::DIScope *scope = NULL); @@ -369,7 +369,7 @@ public: /** Returns the llvm::DIScope corresponding to the current program scope. */ -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIScope GetDIScope() const; #else // LLVM 3.7++ llvm::DIScope *GetDIScope() const; @@ -684,7 +684,7 @@ private: emitted. */ std::vector controlFlowInfo; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /** DIFile object corresponding to the source file where the current function was defined (used for debugging info). */ llvm::DIFile diFile; diff --git a/expr.cpp b/expr.cpp index 411628ab..54862c1d 100644 --- a/expr.cpp +++ b/expr.cpp @@ -74,7 +74,7 @@ #include #endif #include -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ #include #else #include diff --git a/func.cpp b/func.cpp index 9be935f4..6529cddb 100644 --- a/func.cpp +++ b/func.cpp @@ -46,7 +46,7 @@ #include "util.h" #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2 #ifdef ISPC_NVPTX_ENABLED #include #endif /* ISPC_NVPTX_ENABLED */ @@ -67,9 +67,9 @@ #include #include #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 #include "llvm/PassManager.h" -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ #include "llvm/IR/LegacyPassManager.h" #endif #include @@ -78,7 +78,7 @@ #include #include #include -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+ #include #include #include @@ -360,7 +360,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, { llvm::NamedMDNode* annotations = m->module->getOrInsertNamedMetadata("nvvm.annotations"); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* 3.6+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+ llvm::SmallVector av; av.push_back(llvm::ValueAsMetadata::get(function)); av.push_back(llvm::MDString::get(*g->ctx, "kernel")); @@ -392,9 +392,9 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, // isn't worth the code bloat / overhead. bool checkMask = (type->isTask == true) || ( -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2 (function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false) -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ (function->getAttributes().getFnAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::AlwaysInline) == false) #endif && @@ -577,7 +577,7 @@ Function::GenerateIR() { { llvm::NamedMDNode* annotations = m->module->getOrInsertNamedMetadata("nvvm.annotations"); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* 3.6+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+ llvm::SmallVector av; av.push_back(llvm::ValueAsMetadata::get(function)); diff --git a/ispc.cpp b/ispc.cpp index 6d5ff527..3b92fa05 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -338,7 +338,7 @@ public: #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 // LLVM 3.2 or 3.3 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // LLVM 3.2 or 3.3 #define CPU_Silvermont CPU_Nehalem #else /* LLVM 3.4+ */ compat[CPU_Silvermont] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn, @@ -353,7 +353,7 @@ public: CPU_Haswell, CPU_Broadwell, CPU_None); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // LLVM 3.2, 3.3, 3.4 or 3.5 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // LLVM 3.2, 3.3, 3.4 or 3.5 #define CPU_Broadwell CPU_Haswell #else /* LLVM 3.6+ */ compat[CPU_Broadwell] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn, @@ -446,7 +446,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo m_is32Bit(true), m_cpu(""), m_attributes(""), -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 /* ! 3.2 */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 m_tf_attributes(NULL), #endif m_nativeVectorWidth(-1), @@ -1020,7 +1020,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo #endif if (g->opt.disableFMA == false) options.AllowFPOpFusion = llvm::FPOpFusion::Fast; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 #ifdef ISPC_IS_WINDOWS if (strcmp("x86", arch) == 0) { // Workaround for issue #503 (LLVM issue 14646). @@ -1034,7 +1034,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo relocModel); Assert(m_targetMachine != NULL); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 m_targetMachine->setAsmVerbosityDefault(true); #else /* LLVM 3.7+ */ m_targetMachine->Options.MCOptions.AsmVerbose = true; @@ -1324,7 +1324,7 @@ Target::SizeOf(llvm::Type *type, llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); llvm::ArrayRef arrayRef(&index[0], &index[1]); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::Instruction *gep = llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep", insertAtEnd); @@ -1362,7 +1362,7 @@ Target::StructOffset(llvm::Type *type, int element, llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); llvm::ArrayRef arrayRef(&indices[0], &indices[2]); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::Instruction *gep = llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep", insertAtEnd); @@ -1483,7 +1483,7 @@ SourcePos::SourcePos(const char *n, int fl, int fc, int ll, int lc) { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIFile #else /* LLVM 3.7+ */ llvm::DIFile* @@ -1492,7 +1492,7 @@ llvm::DIFile* SourcePos::GetDIFile() const { std::string directory, filename; GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIFile ret = m->diBuilder->createFile(filename, directory); Assert(ret.Verify()); #else /* LLVM 3.7+ */ diff --git a/ispc.h b/ispc.h index 31c0bd9d..eaead10b 100644 --- a/ispc.h +++ b/ispc.h @@ -86,11 +86,11 @@ namespace llvm { class TargetMachine; class Type; class Value; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 class DIFile; class DIType; class DIDescriptor; -#else // LLVM 3.7++ +#else // LLVM 3.7+ class DIFile; class DIType; class DIScope; @@ -144,7 +144,7 @@ struct SourcePos { /** Prints the filename and line/column range to standard output. */ void Print() const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /** Returns a LLVM DIFile object that represents the SourcePos's file */ llvm::DIFile GetDIFile() const; #else diff --git a/ispc_version.h b/ispc_version.h index fe438e76..17e12f38 100644 --- a/ispc_version.h +++ b/ispc_version.h @@ -61,4 +61,8 @@ #define ISPC_LLVM_VERSION_STRING __ispc__xstr(LLVM_VERSION_MAJOR) "." __ispc__xstr(LLVM_VERSION_MINOR) +#if ISPC_LLVM_VERSION < OLDEST_SUPPORTED_LLVM || ISPC_LLVM_VERSION > LATEST_SUPPORTED_LLVM +#error "Unhandled LLVM version" +#endif + #endif // ISPC_VERSION_H diff --git a/llvmutil.h b/llvmutil.h index f65bf638..3d4de774 100644 --- a/llvmutil.h +++ b/llvmutil.h @@ -39,12 +39,12 @@ #define ISPC_LLVMUTIL_H 1 #include "ispc_version.h" -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include #include #include #include -#else /* >= 3.3 */ +#else // 3.3+ #include #include #include diff --git a/main.cpp b/main.cpp index 7937dfcb..b52e713d 100644 --- a/main.cpp +++ b/main.cpp @@ -158,8 +158,7 @@ devUsage(int ret) { printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n"); printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n"); printf(" [--debug-phase=]\t\tSet optimization phases to dump. --debug-phase=first,210:220,300,305,310:last\n"); - -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.4, 3.5 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_4 || ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // 3.4, 3.5 printf(" [--debug-ir=]\t\tSet optimization phase to generate debugIR after it\n"); #endif printf(" [--off-phase=]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n"); @@ -556,7 +555,7 @@ int main(int Argc, char *Argv[]) { g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase=")); } -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.4, 3.5 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_4 || ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // 3.4, 3.5 else if (strncmp(argv[i], "--debug-ir=", 11) == 0) { g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir=")); } diff --git a/module.cpp b/module.cpp index a0412edf..84a0d140 100644 --- a/module.cpp +++ b/module.cpp @@ -91,9 +91,9 @@ #endif #endif /* ISPC_NVPTX_ENABLED */ #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 #include "llvm/PassManager.h" -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ #include "llvm/IR/LegacyPassManager.h" #endif #include @@ -169,9 +169,9 @@ static void lStripUnusedDebugInfo(llvm::Module *module) { if (g->generateDebuggingSymbols == false) return; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* <= 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // <= 3.5 std::set SPall; -#else /* LLVM 3.6+ */ +#else // LLVM 3.6+ std::set SPall; #endif // OK, now we are to determine which functions actually survived the @@ -190,7 +190,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { while (node) { // get the scope of the current instruction`s location // node becomes NULL if this was the original location -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* <= 3.6 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6 llvm::DILocation dloc(node); llvm::DIScope scope = dloc.getScope(); node = dloc.getOrigLocation(); @@ -205,7 +205,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { else break; } if (scope.isSubprogram()) { -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ llvm::DILocation *dloc = llvm::cast(node); llvm::DIScope *scope = dloc->getScope(); //llvm::MDLocation *dloc = llvm::cast(node); @@ -233,7 +233,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) { for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) { llvm::MDNode *cuNode = cuNodes->getOperand(i); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DICompileUnit cu(cuNode); llvm::DIArray subprograms = cu.getSubprograms(); if (subprograms.getNumElements() == 0) { @@ -246,7 +246,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { #endif continue; } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 std::set SPset; std::vector usedSubprograms; #else /* LLVM 3.6+ */ @@ -255,16 +255,16 @@ lStripUnusedDebugInfo(llvm::Module *module) { #endif // determine what functions of those extracted belong to the unit -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 for (unsigned j = 0, je = subprograms.getNumElements(); j != je; ++j) #else /* LLVM 3.7+ */ for (unsigned j = 0, je = subprograms.size(); j != je; ++j) #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 SPset.insert(subprograms->getOperand(j)); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 SPset.insert(subprograms.getElement(j)); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ SPset.insert(subprograms [j]); #endif @@ -274,7 +274,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { Debug(SourcePos(), "%d / %d functions left in module with debug " "info.", (int)usedSubprograms.size(), -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 (int)subprograms.getNumElements()); #else /* LLVM 3.7+ */ (int)subprograms.size()); @@ -299,7 +299,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 ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2 llvm::MDNode *nodeSPMD = llvm::dyn_cast(cuNode->getOperand(12)); Assert(nodeSPMD != NULL); @@ -317,7 +317,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { llvm::MDNode *replNode = llvm::MDNode::get(*g->ctx, llvm::ArrayRef(usedSubprogramsArray)); cuNode->replaceOperandWith(12, replNode); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.3, 3.4, 3.5 */ +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.3, 3.4, 3.5 llvm::MDNode *nodeSPMDArray = llvm::dyn_cast(cuNode->getOperand(9)); Assert(nodeSPMDArray != NULL); @@ -331,7 +331,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { llvm::MDNode *replNode = m->diBuilder->getOrCreateArray(llvm::ArrayRef(usedSubprograms)); cuNode->replaceOperandWith(9, replNode); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.6 */ +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // 3.6 llvm::DIArray nodeSPs = cu.getSubprograms(); Assert(nodeSPs.getNumElements() == subprograms.getNumElements()); for (int i = 0; i < (int)nodeSPs.getNumElements(); ++i) @@ -342,7 +342,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { llvm::MDNode *replNode = llvm::MDNode::get(module->getContext(), llvm::ArrayRef(usedSubprograms)); cu.replaceSubprograms(llvm::DIArray(replNode)); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ llvm::DISubprogramArray nodeSPs = cu->getSubprograms(); //llvm::MDSubprogramArray nodeSPs = cu->getSubprograms(); Assert(nodeSPs.size() == subprograms.size()); @@ -420,7 +420,7 @@ Module::Module(const char *fn) { sprintf(producerString, "ispc version %s (built on %s)", ISPC_VERSION, __DATE__); #endif -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 /* 3.4+ */ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+ diCompileUnit = #endif // LLVM_3_4+ diBuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99, /* lang */ @@ -700,7 +700,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE } if (diBuilder) { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5 llvm::DIFile file = pos.GetDIFile(); llvm::DIGlobalVariable var = diBuilder->createGlobalVariable( name, @@ -709,7 +709,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE sym->type->GetDIType(file), (sym->storageClass == SC_STATIC), sym->storagePtr); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.6 */ +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // 3.6 llvm::DIFile file = pos.GetDIFile(); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast(sym->storagePtr); Assert(sym_const_storagePtr); @@ -722,7 +722,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE sym->type->GetDIType(file), (sym->storageClass == SC_STATIC), sym_const_storagePtr); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ llvm::DIFile *file = pos.GetDIFile(); //llvm::MDFile *file = pos.GetDIFile(); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast(sym->storagePtr); @@ -737,9 +737,9 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE (sym->storageClass == SC_STATIC), sym_const_storagePtr); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 Assert(var.Verify()); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ //comming soon #endif } @@ -1445,28 +1445,28 @@ 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 ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // 3.2, 3.3 unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0; -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.4 */ +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_4 // 3.4 llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary : llvm::sys::fs::F_None; -#else /* 3.5+ */ +#else // LLVM 3.5+ llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text; #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 std::string error; -#else /* LLVM 3.6+ */ +#else // LLVM 3.6+ std::error_code error; #endif llvm::tool_output_file *of = new llvm::tool_output_file(outFileName, error, flags); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 if (error.size()) { -#else /* LLVM 3.6+ */ +#else // LLVM 3.6+ if (error) { #endif @@ -1474,25 +1474,25 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, return false; } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::PassManager pm; -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ llvm::legacy::PassManager pm; #endif -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4 pm.add(new llvm::DataLayout(*g->target->getDataLayout())); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.5 */ +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // 3.5 pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.6 */ +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // 3.6 llvm::DataLayoutPass *dlp= new llvm::DataLayoutPass(); dlp->doInitialization(*module); pm.add(dlp); #endif // LLVM 3.7+ doesn't have DataLayoutPass anymore. { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::formatted_raw_ostream fos(of->os()); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ llvm::raw_fd_ostream &fos(of->os()); #endif if (targetMachine->addPassesToEmitFile(pm, fos, fileType)) { @@ -2434,9 +2434,9 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre inst.setDiagnostics(diagEngine); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4 clang::TargetOptions &options = inst.getTargetOpts(); -#else /* LLVM 3.5+ */ +#else // LLVM 3.5+ const std::shared_ptr< clang::TargetOptions > &options = std::make_shared< clang::TargetOptions >(inst.getTargetOpts()); #endif @@ -2446,19 +2446,19 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre triple.setTriple(llvm::sys::getDefaultTargetTriple()); } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4 options.Triple = triple.getTriple(); -#else /* LLVM 3.5+ */ +#else // LLVM 3.5+ options->Triple = triple.getTriple(); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2 clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.3, 3.4 */ +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.3, 3.4 clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options); -#else /* LLVM 3.5+ */ +#else // LLVM 3.5+ clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); #endif @@ -2908,9 +2908,9 @@ static void lEmitDispatchModule(llvm::Module *module, // Do some rudimentary cleanup of the final result and make sure that // the module is all ok. -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::PassManager optPM; -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ llvm::legacy::PassManager optPM; #endif optPM.add(llvm::createGlobalDCEPass()); diff --git a/module.h b/module.h index f6a82646..3785abf2 100644 --- a/module.h +++ b/module.h @@ -41,7 +41,7 @@ #include "ispc.h" #include "ast.h" -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_4 #include #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 #include @@ -160,7 +160,7 @@ public: /** The diBuilder manages generating debugging information */ llvm::DIBuilder *diBuilder; -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DICompileUnit diCompileUnit; #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 llvm::DICompileUnit* diCompileUnit; diff --git a/opt.cpp b/opt.cpp index 47918c78..781835d1 100644 --- a/opt.cpp +++ b/opt.cpp @@ -48,7 +48,7 @@ #include #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include #include #include @@ -58,7 +58,7 @@ #ifdef ISPC_NVPTX_ENABLED #include #endif /* ISPC_NVPTX_ENABLED */ -#else /* >= 3.3 */ +#else // LLVM 3.3+ #include #include #include @@ -72,9 +72,9 @@ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+ #include #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 #include "llvm/PassManager.h" -#else /* >= 3.7 */ +#else // LLVM 3.7+ #include "llvm/IR/LegacyPassManager.h" #endif #include @@ -83,16 +83,16 @@ #include #include #include -#else /* < 3.5 */ +#else // < 3.5 #include #include #include #include #endif #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 #include -#else /* >= 3.7 */ +#else // LLVM 3.7+ #include #endif #include @@ -101,9 +101,9 @@ #include #include #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include -#else /* LLVM 3.3+ */ +#else // LLVM 3.3+ #include #include #endif @@ -238,7 +238,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) { llvm::MDString *str = llvm::dyn_cast(filename->getOperand(0)); Assert(str); llvm::ConstantInt *first_lnum = -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::dyn_cast(first_line->getOperand(0)); #else /* LLVN 3.6+ */ llvm::mdconst::extract(first_line->getOperand(0)); @@ -246,7 +246,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) { Assert(first_lnum); llvm::ConstantInt *first_colnum = -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::dyn_cast(first_column->getOperand(0)); #else /* LLVN 3.6+ */ llvm::mdconst::extract(first_column->getOperand(0)); @@ -254,7 +254,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) { Assert(first_column); llvm::ConstantInt *last_lnum = -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::dyn_cast(last_line->getOperand(0)); #else /* LLVN 3.6+ */ llvm::mdconst::extract(last_line->getOperand(0)); @@ -262,7 +262,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) { Assert(last_lnum); llvm::ConstantInt *last_colnum = -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::dyn_cast(last_column->getOperand(0)); #else /* LLVN 3.6+ */ llvm::mdconst::extract(last_column->getOperand(0)); @@ -330,10 +330,10 @@ lGEPInst(llvm::Value *ptr, llvm::Value *offset, const char *name, llvm::Instruction *insertBefore) { llvm::Value *index[1] = { offset }; llvm::ArrayRef arrayRef(&index[0], &index[1]); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 return llvm::GetElementPtrInst::Create(ptr, arrayRef, name, insertBefore); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ return llvm::GetElementPtrInst::Create(PTYPE(ptr), ptr, arrayRef, name, insertBefore); #endif @@ -466,13 +466,13 @@ public: DebugPassManager():number(0){} void add(llvm::Pass * P, int stage); bool run(llvm::Module& M) {return PM.run(M);} -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::PassManager& getPM() {return PM;} #else /* LLVM 3.7+ */ llvm::legacy::PassManager& getPM() {return PM;} #endif private: -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::PassManager PM; #else /* LLVM 3.7+ */ llvm::legacy::PassManager PM; @@ -500,7 +500,7 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) { PM.add(CreateDebugPass(buf)); } -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // only 3.4 and 3.5 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_4 || ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // only 3.4 and 3.5 if (g->debugIR == number) { // adding generating of LLVM IR debug after optimization char buf[100]; @@ -521,19 +521,19 @@ Optimize(llvm::Module *module, int optLevel) { DebugPassManager optPM; optPM.add(llvm::createVerifierPass(),0); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::TargetLibraryInfo *targetLibraryInfo = new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); optPM.add(targetLibraryInfo); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ optPM.add(new llvm::TargetLibraryInfoWrapperPass(llvm::Triple(module->getTargetTriple()))); #endif -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_5 optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 llvm::DataLayoutPass *dlp= new llvm::DataLayoutPass(); dlp->doInitialization(*module); optPM.add(dlp); @@ -541,12 +541,12 @@ Optimize(llvm::Module *module, int optLevel) { llvm::TargetMachine *targetMachine = g->target->GetTargetMachine(); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(), targetMachine->getVectorTargetTransformInfo())); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 targetMachine->addAnalysisPasses(optPM.getPM()); -#else /* LLVM 3.7+ */ +#else // LLVM 3.7+ optPM.getPM().add(createTargetTransformInfoWrapperPass(targetMachine->getTargetIRAnalysis())); #endif @@ -660,7 +660,7 @@ Optimize(llvm::Module *module, int optLevel) { optPM.add(llvm::createCFGSimplificationPass()); optPM.add(llvm::createArgumentPromotionPass()); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // Starting from 3.4 this functionality was moved to // InstructionCombiningPass. See r184459 for details. optPM.add(llvm::createSimplifyLibCallsPass(), 240); @@ -810,7 +810,7 @@ Optimize(llvm::Module *module, int optLevel) { optPM.add(llvm::createCFGSimplificationPass()); optPM.add(llvm::createArgumentPromotionPass()); -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // Starting from 3.4 this functionality was moved to // InstructionCombiningPass. See r184459 for details. optPM.add(llvm::createSimplifyLibCallsPass()); @@ -4924,7 +4924,7 @@ PeepholePass::PeepholePass() : BasicBlockPass(ID) { } -#if ISPC_LLVM_VERSION > ISPC_LLVM_3_2 +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 using namespace llvm::PatternMatch; @@ -5258,7 +5258,7 @@ PeepholePass::runOnBasicBlock(llvm::BasicBlock &bb) { llvm::Instruction *inst = &*iter; llvm::Instruction *builtinCall = NULL; -#if ISPC_LLVM_VERSION > ISPC_LLVM_3_2 +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 if (!builtinCall) builtinCall = lMatchAvgUpUInt8(inst); if (!builtinCall) diff --git a/parse.yy b/parse.yy index 703e12d1..5484ceed 100644 --- a/parse.yy +++ b/parse.yy @@ -83,7 +83,7 @@ struct ForeachDimension; #include "util.h" #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include #else #include diff --git a/stmt.cpp b/stmt.cpp index 3b70c364..67553a8d 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -48,7 +48,7 @@ #include #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include #include #include @@ -190,7 +190,7 @@ static llvm::Value* lConvertToGenericPtr(FunctionEmitContext *ctx, llvm::Value * llvm::Function *func_warp_index = m->module->getFunction("__warp_index"); llvm::Value *warpId = ctx->CallInst(func_warp_index, NULL, std::vector(), "gep2gen_warp_index"); llvm::Value *offset = ctx->BinaryOperator(llvm::Instruction::Mul, warpId, LLVMInt32(numEl), "gep2gen_offset"); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 value = llvm::GetElementPtrInst::Create(value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock()); #else value = llvm::GetElementPtrInst::Create(NULL, value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock()); @@ -1539,7 +1539,7 @@ lUpdateVaryingCounter(int dim, int nDims, FunctionEmitContext *ctx, ptr_arrayidx_indices.push_back(LLVMInt32(0)); ptr_arrayidx_indices.push_back(laneIdx); #if 1 -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::Instruction* ptr_arrayidx = llvm::GetElementPtrInst::Create(globalDelta, ptr_arrayidx_indices, "arrayidx", ctx->GetCurrentBasicBlock()); #else llvm::Instruction* ptr_arrayidx = llvm::GetElementPtrInst::Create(NULL, globalDelta, ptr_arrayidx_indices, "arrayidx", ctx->GetCurrentBasicBlock()); diff --git a/type.cpp b/type.cpp index 6d48bca4..9785d532 100644 --- a/type.cpp +++ b/type.cpp @@ -79,7 +79,7 @@ lShouldPrintName(const std::string &name) { /** Utility routine to create a llvm array type of the given number of the given element type. */ -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 static llvm::DIType lCreateDIArray(llvm::DIType eltType, int count) { #else // LLVM 3.7++ static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) { @@ -95,11 +95,11 @@ static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) { } llvm::Value *sub = m->diBuilder->getOrCreateSubrange(lowerBound, upperBound); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, count); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 std::vector subs; #else // LLVM 3.6++ llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, count); @@ -107,7 +107,7 @@ static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) { #endif subs.push_back(sub); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIArray subArray = m->diBuilder->getOrCreateArray(subs); uint64_t size = eltType.getSizeInBits() * count; uint64_t align = eltType.getAlignInBits(); @@ -526,7 +526,7 @@ AtomicType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType AtomicType::GetDIType(llvm::DIDescriptor scope) const { #else //LLVM 3.7++ llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const { @@ -536,7 +536,7 @@ llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const { if (variability.type == Variability::Uniform) { switch (basicType) { case TYPE_VOID: -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 return llvm::DIType(); #else //LLVM 3.7++ return NULL; @@ -587,27 +587,27 @@ llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const { break; default: FATAL("unhandled basic type in AtomicType::GetDIType()"); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 return llvm::DIType(); -#else //LLVM 3.7++ +#else //LLVM 3.7+ return NULL; #endif } } else if (variability == Variability::Varying) { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1); -#elif ISPC_LLVM_VERSION >= ISPC_VERSION_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#elif ISPC_LLVM_VERSION > ISPC_VERSION_3_2 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); -#else // LLVM 3.6++ +#else // LLVM 3.6+ llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); #endif -#if ISPC_LLVM_VERSION >= ISPC_VERSION_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION > ISPC_VERSION_3_2 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub); llvm::DIType unifType = GetAsUniformType()->GetDIType(scope); uint64_t size = unifType.getSizeInBits() * g->target->getVectorWidth(); uint64_t align = unifType.getAlignInBits() * g->target->getVectorWidth(); -#elif ISPC_LLVM_VERSION >= ISPC_VERSION_3_7 // LLVM 3.7+ +#else // LLVM 3.7+ llvm::DINodeArray subArray = m->diBuilder->getOrCreateArray(sub); llvm::DIType *unifType = GetAsUniformType()->GetDIType(scope); //llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub); @@ -847,15 +847,15 @@ EnumType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType EnumType::GetDIType(llvm::DIDescriptor scope) const { -#else // LLVM 3.7++ +#else // LLVM 3.7+ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const { #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 std::vector enumeratorDescriptors; -#else // LLVM 3.6++ +#else // LLVM 3.6+ std::vector enumeratorDescriptors; #endif for (unsigned int i = 0; i < enumerators.size(); ++i) { @@ -863,15 +863,15 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const { Assert(enumerators[i]->constValue != NULL); int count = enumerators[i]->constValue->GetValues(&enumeratorValue); Assert(count == 1); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::Value *descriptor = -#else // LLVM 3.6++ +#else // LLVM 3.6+ llvm::Metadata *descriptor = #endif m->diBuilder->createEnumerator(enumerators[i]->name, enumeratorValue); enumeratorDescriptors.push_back(descriptor); } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIArray elementArray = m->diBuilder->getOrCreateArray(enumeratorDescriptors); llvm::DIFile diFile = pos.GetDIFile(); @@ -880,7 +880,7 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const { 32 /* size in bits */, 32 /* align in bits */, elementArray, llvm::DIType()); -#else // LLVM 3.7++ +#else // LLVM 3.7+ llvm::DINodeArray elementArray = m->diBuilder->getOrCreateArray(enumeratorDescriptors); llvm::DIFile *diFile = pos.GetDIFile(); @@ -894,18 +894,18 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const { case Variability::Uniform: return diType; case Variability::Varying: { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); #else // LLVM 3.6++ llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub); uint64_t size = diType.getSizeInBits() * g->target->getVectorWidth(); uint64_t align = diType.getAlignInBits() * g->target->getVectorWidth(); -#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++ +#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+ llvm::DINodeArray subArray = m->diBuilder->getOrCreateArray(sub); //llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub); uint64_t size = diType->getSizeInBits() * g->target->getVectorWidth(); @@ -918,7 +918,7 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const { } default: FATAL("Unexpected variability in EnumType::GetDIType()"); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 return llvm::DIType(); #else //LLVM 3.7++ return NULL; @@ -1256,7 +1256,7 @@ PointerType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType PointerType::GetDIType(llvm::DIDescriptor scope) const { if (baseType == NULL) { Assert(m->errorCount > 0); @@ -1279,7 +1279,7 @@ llvm::DIType *PointerType::GetDIType(llvm::DIScope *scope) const { ptrAlignBits); case Variability::Varying: { // emit them as an array of pointers -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType eltType = #else //LLVM 3.7++ llvm::DIDerivedType *eltType = @@ -1293,7 +1293,7 @@ llvm::DIType *PointerType::GetDIType(llvm::DIScope *scope) const { } default: FATAL("Unexpected variability in PointerType::GetDIType()"); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 return llvm::DIType(); #else //LLVM 3.7++ return NULL; @@ -1571,7 +1571,7 @@ ArrayType::TotalElementCount() const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType ArrayType::GetDIType(llvm::DIDescriptor scope) const { if (child == NULL) { Assert(m->errorCount > 0); @@ -1820,16 +1820,16 @@ VectorType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType VectorType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType eltType = base->GetDIType(scope); #else //LLVM 3.7++ llvm::DIType *VectorType::GetDIType(llvm::DIScope *scope) const { llvm::DIType *eltType = base->GetDIType(scope); #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements); #else // LLVM 3.6++ llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, numElements); @@ -1838,7 +1838,7 @@ llvm::DIType *VectorType::GetDIType(llvm::DIScope *scope) const { // vectors of varying types are already naturally aligned to the // machine's vector width, but arrays of uniform types need to be // explicitly aligned to the machines natural vector alignment. -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub); uint64_t sizeBits = eltType.getSizeInBits() * numElements; uint64_t align = eltType.getAlignInBits(); @@ -1859,7 +1859,7 @@ llvm::DIType *VectorType::GetDIType(llvm::DIScope *scope) const { } else { FATAL("Unexpected variability in VectorType::GetDIType()"); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 return llvm::DIType(); #else // LLVM 3.7++ return NULL; @@ -2263,13 +2263,13 @@ StructType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType StructType::GetDIType(llvm::DIDescriptor scope) const { #else //LLVM 3.7++ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const { #endif uint64_t currentSize = 0, align = 0; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 std::vector elementLLVMTypes; #else // LLVM 3.6++ std::vector elementLLVMTypes; @@ -2278,7 +2278,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const { // alignment and size, using that to figure out its offset w.r.t. the // start of the structure. for (unsigned int i = 0; i < elementTypes.size(); ++i) { -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType eltType = GetElementType(i)->GetDIType(scope); uint64_t eltAlign = eltType.getAlignInBits(); uint64_t eltSize = eltType.getSizeInBits(); @@ -2300,7 +2300,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const { Assert((currentSize == 0) || (currentSize % eltAlign) == 0); int line = elementPositions[i].first_line; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIFile diFile = elementPositions[i].GetDIFile(); llvm::DIType fieldType = #else // LLVM 3.7++ @@ -2320,7 +2320,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const { if (currentSize > 0 && (currentSize % align)) currentSize += align - (currentSize % align); -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes); llvm::DIFile diFile = pos.GetDIFile(); #else // LLVM 3.7++ @@ -2335,7 +2335,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const { currentSize, // Size in bits align, // Alignment in bits 0, // Flags -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType(), // DerivedFrom #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++ NULL, @@ -2568,7 +2568,7 @@ UndefinedStructType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIFile diFile = pos.GetDIFile(); llvm::DIArray elements; @@ -2585,9 +2585,9 @@ llvm::DIType *UndefinedStructType::GetDIType(llvm::DIScope *scope) const { 0, // Size 0, // Align 0, // Flags -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType(), // DerivedFrom -#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++ +#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+ NULL, #endif elements); @@ -2842,7 +2842,7 @@ ReferenceType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType ReferenceType::GetDIType(llvm::DIDescriptor scope) const { if (targetType == NULL) { Assert(m->errorCount > 0); @@ -3121,13 +3121,13 @@ FunctionType::LLVMType(llvm::LLVMContext *ctx) const { } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType FunctionType::GetDIType(llvm::DIDescriptor scope) const { #else //LLVM 3.7++ llvm::DIType *FunctionType::GetDIType(llvm::DIScope *scope) const { #endif -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 std::vector retArgTypes; #else // LLVM 3.6++ std::vector retArgTypes; @@ -3137,28 +3137,28 @@ llvm::DIType *FunctionType::GetDIType(llvm::DIScope *scope) const { const Type *t = GetParameterType(i); if (t == NULL) -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 return llvm::DIType(); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 return llvm::DICompositeType(); #else // LLVM 3.7++ return NULL; #endif retArgTypes.push_back(t->GetDIType(scope)); } -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 llvm::DIArray retArgTypesArray = m->diBuilder->getOrCreateArray(llvm::ArrayRef(retArgTypes)); llvm::DIType diType = // FIXME: DIFile m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray); -#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 llvm::DITypeArray retArgTypesArray = m->diBuilder->getOrCreateTypeArray(retArgTypes); llvm::DIType diType = // FIXME: DIFile m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray); -#else // LLVM 3.7++ +#else // LLVM 3.7+ llvm::DITypeRefArray retArgTypesArray = m->diBuilder->getOrCreateTypeArray(retArgTypes); llvm::DIType *diType = diff --git a/type.h b/type.h index a8c70512..d8e9be86 100644 --- a/type.h +++ b/type.h @@ -40,10 +40,10 @@ #include "ispc.h" #include "util.h" -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include #include -#else /* >= 3.3 */ +#else // >= 3.3 #include #include #endif @@ -222,7 +222,7 @@ public: /** Returns the LLVM type corresponding to this ispc type */ virtual llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /** Returns the DIType (LLVM's debugging information structure), corresponding to this type. */ virtual llvm::DIType GetDIType(llvm::DIDescriptor scope) const = 0; @@ -317,7 +317,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -400,7 +400,7 @@ public: const std::string &GetEnumName() const { return name; } llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -485,7 +485,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -591,7 +591,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -663,7 +663,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -718,7 +718,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -810,7 +810,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -857,7 +857,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; @@ -915,7 +915,7 @@ public: std::string GetCDeclarationForDispatch(const std::string &fname) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 llvm::DIType GetDIType(llvm::DIDescriptor scope) const; #else // LLVM 3.7++ llvm::DIType *GetDIType(llvm::DIScope *scope) const; diff --git a/util.cpp b/util.cpp index fd076ade..3c9fbf3c 100644 --- a/util.cpp +++ b/util.cpp @@ -65,7 +65,7 @@ #include #include -#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 +#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #include #else // LLVM 3.3+ #include