From 725be222acda6cb8f23c392bba04c9b9eac068b9 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 30 Jul 2014 11:50:15 +0400 Subject: [PATCH] added LLVM_3_6 var --- Makefile | 7 +++++++ builtins.cpp | 6 +++--- builtins/util.m4 | 7 ++++++- cbackend.cpp | 26 +++++++++++++------------- ctx.cpp | 4 ++-- ctx.h | 2 +- expr.cpp | 2 +- func.cpp | 6 +++--- ispc.cpp | 2 +- ispc.h | 4 ++-- main.cpp | 6 ++++-- module.cpp | 8 ++++---- module.h | 2 +- opt.cpp | 8 ++++---- type.cpp | 4 ++-- 15 files changed, 54 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 29b5875e..fb93e324 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,10 @@ ifeq ($(LLVM_VERSION),LLVM_3_5) ISPC_LIBS += -lcurses -lz endif +ifeq ($(LLVM_VERSION),LLVM_3_6) + ISPC_LIBS += -lcurses -lz +endif + ifeq ($(ARCH_OS),Linux) ISPC_LIBS += -ldl endif @@ -153,6 +157,9 @@ CXXFLAGS=$(OPT) $(LLVM_CXXFLAGS) -I. -Iobjs/ -I$(CLANG_INCLUDE) \ ifeq ($(LLVM_VERSION),LLVM_3_5) CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register endif +ifeq ($(LLVM_VERSION),LLVM_3_6) + CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register +endif ifneq ($(ARM_ENABLED), 0) CXXFLAGS+=-DISPC_ARM_ENABLED endif diff --git a/builtins.cpp b/builtins.cpp index 472c2ce8..377f4f50 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -66,7 +66,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #else #include @@ -705,7 +705,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, llvm::Module *module, SymbolTable *symbolTable) { llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) llvm::ErrorOr ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); if (std::error_code EC = ModuleOrErr.getError()) Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str()); @@ -762,7 +762,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, // architecture and investigate what happened. // Generally we allow library DataLayout to be subset of module // DataLayout or library DataLayout to be empty. -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(), bcModule->getDataLayoutStr())) { Warning(SourcePos(), "Module DataLayout is incompatible with " diff --git a/builtins/util.m4 b/builtins/util.m4 index b014645e..52c642b4 100644 --- a/builtins/util.m4 +++ b/builtins/util.m4 @@ -1500,10 +1500,12 @@ define <$1 x $2> @__atomic_compare_exchange_$3_global($2* %ptr, <$1 x $2> %cmp, ifelse(LLVM_VERSION,LLVM_3_5,` %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 + ',LLVM_VERSION,LLVM_3_6,` + %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst + %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 ',` %r_LANE_ID = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst ') - %rp_LANE_ID = getelementptr $2 * %rptr32, i32 LANE store $2 %r_LANE_ID, $2 * %rp_LANE_ID') @@ -1516,6 +1518,9 @@ define $2 @__atomic_compare_exchange_uniform_$3_global($2* %ptr, $2 %cmp, ifelse(LLVM_VERSION,LLVM_3_5,` %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r = extractvalue { $2, i1 } %r_t, 0 + ',LLVM_VERSION,LLVM_3_6,` + %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst + %r = extractvalue { $2, i1 } %r_t, 0 ',` %r = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst ') diff --git a/cbackend.cpp b/cbackend.cpp index 3d515a60..aa7a9aca 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -63,7 +63,7 @@ #include "llvm/Analysis/ConstantsScanner.h" #include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/LoopInfo.h" -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include "llvm/IR/Verifier.h" #include #include "llvm/IR/CallSite.h" @@ -250,7 +250,7 @@ namespace { class CBEMCAsmInfo : public llvm::MCAsmInfo { public: CBEMCAsmInfo() { -#if !defined(LLVM_3_5) +#if !defined(LLVM_3_5) && !defined(LLVM_3_6) GlobalPrefix = ""; #endif PrivateGlobalPrefix = ""; @@ -465,7 +465,7 @@ namespace { // Must not be used in inline asm, extractelement, or shufflevector. if (I.hasOneUse()) { -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) const llvm::Instruction &User = llvm::cast(*I.user_back()); #else const llvm::Instruction &User = llvm::cast(*I.use_back()); @@ -477,7 +477,7 @@ namespace { } // Only inline instruction it if it's use is in the same BB as the inst. -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) return I.getParent() == llvm::cast(I.user_back())->getParent(); #else return I.getParent() == llvm::cast(I.use_back())->getParent(); @@ -1770,7 +1770,7 @@ std::string CWriter::GetValueName(const llvm::Value *Operand) { // Resolve potential alias. if (const llvm::GlobalAlias *GA = llvm::dyn_cast(Operand)) { -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (const llvm::Value *V = GA->getAliasee()) #else if (const llvm::Value *V = GA->resolveAliasedGlobal(false)) @@ -2163,7 +2163,7 @@ static SpecialGlobalClass getGlobalVariableClass(const llvm::GlobalVariable *GV) // Otherwise, if it is other metadata, don't print it. This catches things // like debug information. -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) // Here we compare char * if (!strcmp(GV->getSection(), "llvm.metadata")) #else @@ -2225,7 +2225,7 @@ bool CWriter::doInitialization(llvm::Module &M) { #endif TAsm = new CBEMCAsmInfo(); MRI = new llvm::MCRegisterInfo(); -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) TCtx = new llvm::MCContext(TAsm, MRI, NULL); #else TCtx = new llvm::MCContext(*TAsm, *MRI, NULL); @@ -2349,7 +2349,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() || I->hasCommonLinkage()) Out << "extern "; -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) else if (I->hasDLLImportStorageClass()) #else else if (I->hasDLLImportLinkage()) @@ -2525,7 +2525,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasLocalLinkage()) Out << "static "; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -2810,7 +2810,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { bool isStructReturn = F->hasStructRetAttr(); if (F->hasLocalLinkage()) Out << "static "; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -3145,7 +3145,7 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) { Out << ":\n"; printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2); -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) 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()))) @@ -3170,7 +3170,7 @@ bool CWriter::isGotoCodeNecessary(llvm::BasicBlock *From, llvm::BasicBlock *To) /// FIXME: This should be reenabled, but loop reordering safe!! return true; -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) if (std::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) #else if (llvm::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) @@ -3788,7 +3788,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) { // All other intrinsic calls we must lower. llvm::Instruction *Before = 0; if (CI != &BB->front()) -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) Before = std::prev(llvm::BasicBlock::iterator(CI)); #else Before = prior(llvm::BasicBlock::iterator(CI)); diff --git a/ctx.cpp b/ctx.cpp index 57cbe7ae..8026c10a 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -352,7 +352,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, AssertPos(currentPos, diSubprogramType.Verify()); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) Assert(diSubprogramType.isCompositeType()); llvm::DICompositeType diSubprogramType_n = static_cast(diSubprogramType); @@ -1546,7 +1546,7 @@ FunctionEmitContext::StartScope() { llvm::DILexicalBlock lexicalBlock = m->diBuilder->createLexicalBlock(parentScope, diFile, currentPos.first_line, -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) // Revision 202736 in LLVM adds support of DWARF discriminator // to the last argument and revision 202737 in clang adds 0 // for the last argument by default. diff --git a/ctx.h b/ctx.h index f47777ff..3b9ce86a 100644 --- a/ctx.h +++ b/ctx.h @@ -47,7 +47,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #else diff --git a/expr.cpp b/expr.cpp index 8fa64f91..aeb8b670 100644 --- a/expr.cpp +++ b/expr.cpp @@ -74,7 +74,7 @@ #include #endif #include -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #else #include diff --git a/func.cpp b/func.cpp index 82df6b27..1c92d112 100644 --- a/func.cpp +++ b/func.cpp @@ -69,7 +69,7 @@ #include #include #include -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #include @@ -478,7 +478,7 @@ Function::GenerateIR() { } if (m->errorCount == 0) { -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) if (llvm::verifyFunction(*function) == true) { #else if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) { @@ -528,7 +528,7 @@ Function::GenerateIR() { emitCode(&ec, appFunction, firstStmtPos); if (m->errorCount == 0) { sym->exportedFunction = appFunction; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (llvm::verifyFunction(*appFunction) == true) { #else if (llvm::verifyFunction(*appFunction, diff --git a/ispc.cpp b/ispc.cpp index 8e029502..913a2d99 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -57,7 +57,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #else diff --git a/ispc.h b/ispc.h index 86be754c..29925e46 100644 --- a/ispc.h +++ b/ispc.h @@ -40,8 +40,8 @@ #define ISPC_VERSION "1.7.1dev" -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) -#error "Only LLVM 3.1, 3.2, 3.3, 3.4 and the 3.5 development branch are supported" +#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) +#error "Only LLVM 3.1, 3.2, 3.3, 3.4, 3.5 and the 3.6 development branch are supported" #endif #if defined(_WIN32) || defined(_WIN64) diff --git a/main.cpp b/main.cpp index 99497af5..97dec095 100644 --- a/main.cpp +++ b/main.cpp @@ -72,6 +72,8 @@ lPrintVersion() { "3.4" #elif defined(LLVM_3_5) "3.5" +#elif defined(LLVM_3_6) + "3.6" #else #error "Unhandled LLVM version" #endif @@ -166,7 +168,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 defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) 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"); @@ -549,7 +551,7 @@ int main(int Argc, char *Argv[]) { "away or introduce the new ones.\n"); g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase=")); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) 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 b5fd860c..ce7e6bde 100644 --- a/module.cpp +++ b/module.cpp @@ -93,7 +93,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #include @@ -948,7 +948,7 @@ Module::writeOutput(OutputType outputType, const char *outFileName, lStripUnusedDebugInfo(module); } -#if defined (LLVM_3_4) || defined (LLVM_3_5) +#if defined (LLVM_3_4) || defined (LLVM_3_5) || defined(LLVM_3_6) // In LLVM_3_4 after r195494 and r195504 revisions we should pass // "Debug Info Version" constant to the module. LLVM will ignore // our Debug Info metadata without it. @@ -1105,7 +1105,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, } llvm::PassManager pm; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else pm.add(new llvm::DataLayout(*g->target->getDataLayout())); @@ -2114,7 +2114,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre } inst.getLangOpts().LineComment = 1; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) inst.createPreprocessor(clang::TU_Complete); #else inst.createPreprocessor(); diff --git a/module.h b/module.h index c1350063..7575457f 100644 --- a/module.h +++ b/module.h @@ -44,7 +44,7 @@ #if defined(LLVM_3_4) #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #endif diff --git a/opt.cpp b/opt.cpp index 7b955a2c..a42a2268 100644 --- a/opt.cpp +++ b/opt.cpp @@ -63,12 +63,12 @@ #include #include #endif -#if defined (LLVM_3_4) || defined(LLVM_3_5) +#if defined (LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) #include #endif #include #include -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #include @@ -444,7 +444,7 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) { number, P->getPassName()); PM.add(CreateDebugPass(buf)); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) if (g->debugIR == number) { // adding generating of LLVM IR debug after optimization char buf[100]; @@ -469,7 +469,7 @@ Optimize(llvm::Module *module, int optLevel) { new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); optPM.add(targetLibraryInfo); -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); diff --git a/type.cpp b/type.cpp index 9e8ef131..57d448d8 100644 --- a/type.cpp +++ b/type.cpp @@ -50,7 +50,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #else @@ -2987,7 +2987,7 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const { for (int i = 0; i < GetNumParameters(); ++i) { const Type *t = GetParameterType(i); if (t == NULL) -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) return llvm::DICompositeType(); #else return llvm::DIType();