reversed macros LLVM_3_6 to LLVM_3_5+ in .cpp and .h files

This commit is contained in:
Anton Mitrokhin
2014-08-01 15:40:48 +04:00
parent d0c9b7c9b5
commit 60fa76ccc1
11 changed files with 33 additions and 24 deletions

View File

@@ -66,7 +66,7 @@
#include <llvm/IR/Intrinsics.h> #include <llvm/IR/Intrinsics.h>
#include <llvm/IR/DerivedTypes.h> #include <llvm/IR/DerivedTypes.h>
#endif #endif
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/Linker/Linker.h> #include <llvm/Linker/Linker.h>
#else #else
#include <llvm/Linker.h> #include <llvm/Linker.h>
@@ -705,7 +705,8 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
llvm::Module *module, SymbolTable *symbolTable) { llvm::Module *module, SymbolTable *symbolTable) {
llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); llvm::StringRef sb = llvm::StringRef((char *)bitcode, length);
llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb);
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
llvm::ErrorOr<llvm::Module *> ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); llvm::ErrorOr<llvm::Module *> ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx);
if (std::error_code EC = ModuleOrErr.getError()) if (std::error_code EC = ModuleOrErr.getError())
Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str()); Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str());
@@ -762,7 +763,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
// architecture and investigate what happened. // architecture and investigate what happened.
// Generally we allow library DataLayout to be subset of module // Generally we allow library DataLayout to be subset of module
// DataLayout or library DataLayout to be empty. // DataLayout or library DataLayout to be empty.
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(), if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(),
bcModule->getDataLayoutStr())) { bcModule->getDataLayoutStr())) {
Warning(SourcePos(), "Module DataLayout is incompatible with " Warning(SourcePos(), "Module DataLayout is incompatible with "

View File

@@ -1546,7 +1546,7 @@ FunctionEmitContext::StartScope() {
llvm::DILexicalBlock lexicalBlock = llvm::DILexicalBlock lexicalBlock =
m->diBuilder->createLexicalBlock(parentScope, diFile, m->diBuilder->createLexicalBlock(parentScope, diFile,
currentPos.first_line, currentPos.first_line,
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
// Revision 202736 in LLVM adds support of DWARF discriminator // Revision 202736 in LLVM adds support of DWARF discriminator
// to the last argument and revision 202737 in clang adds 0 // to the last argument and revision 202737 in clang adds 0
// for the last argument by default. // for the last argument by default.

2
ctx.h
View File

@@ -47,7 +47,7 @@
#include <llvm/IR/InstrTypes.h> #include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h> #include <llvm/IR/Instructions.h>
#endif #endif
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/DebugInfo.h> #include <llvm/IR/DebugInfo.h>
#include <llvm/IR/DIBuilder.h> #include <llvm/IR/DIBuilder.h>
#else #else

View File

@@ -74,7 +74,7 @@
#include <llvm/IR/CallingConv.h> #include <llvm/IR/CallingConv.h>
#endif #endif
#include <llvm/ExecutionEngine/GenericValue.h> #include <llvm/ExecutionEngine/GenericValue.h>
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/InstIterator.h> #include <llvm/IR/InstIterator.h>
#else #else
#include <llvm/Support/InstIterator.h> #include <llvm/Support/InstIterator.h>

View File

@@ -69,7 +69,7 @@
#include <llvm/Target/TargetMachine.h> #include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h> #include <llvm/Target/TargetOptions.h>
#include <llvm/PassManager.h> #include <llvm/PassManager.h>
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/Verifier.h> #include <llvm/IR/Verifier.h>
#include <llvm/IR/IRPrintingPasses.h> #include <llvm/IR/IRPrintingPasses.h>
#include <llvm/IR/CFG.h> #include <llvm/IR/CFG.h>
@@ -476,7 +476,8 @@ Function::GenerateIR() {
} }
if (m->errorCount == 0) { if (m->errorCount == 0) {
#if defined (LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
if (llvm::verifyFunction(*function) == true) { if (llvm::verifyFunction(*function) == true) {
#else #else
if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) { if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) {
@@ -523,7 +524,8 @@ Function::GenerateIR() {
emitCode(&ec, appFunction, firstStmtPos); emitCode(&ec, appFunction, firstStmtPos);
if (m->errorCount == 0) { if (m->errorCount == 0) {
sym->exportedFunction = appFunction; sym->exportedFunction = appFunction;
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
if (llvm::verifyFunction(*appFunction) == true) { if (llvm::verifyFunction(*appFunction) == true) {
#else #else
if (llvm::verifyFunction(*appFunction, if (llvm::verifyFunction(*appFunction,

View File

@@ -57,7 +57,7 @@
#include <llvm/IR/Module.h> #include <llvm/IR/Module.h>
#include <llvm/IR/Instructions.h> #include <llvm/IR/Instructions.h>
#endif #endif
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/DebugInfo.h> #include <llvm/IR/DebugInfo.h>
#include <llvm/IR/DIBuilder.h> #include <llvm/IR/DIBuilder.h>
#else #else

View File

@@ -166,7 +166,8 @@ devUsage(int ret) {
printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n"); printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n");
printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n"); printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n");
printf(" [--debug-phase=<value>]\t\tSet optimization phases to dump. --debug-phase=first,210:220,300,305,310:last\n"); printf(" [--debug-phase=<value>]\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) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
printf(" [--debug-ir=<value>]\t\tSet optimization phase to generate debugIR after it\n"); printf(" [--debug-ir=<value>]\t\tSet optimization phase to generate debugIR after it\n");
#endif #endif
printf(" [--off-phase=<value>]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n"); printf(" [--off-phase=<value>]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n");
@@ -549,7 +550,8 @@ int main(int Argc, char *Argv[]) {
"away or introduce the new ones.\n"); "away or introduce the new ones.\n");
g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase=")); g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase="));
} }
#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
else if (strncmp(argv[i], "--debug-ir=", 11) == 0) { else if (strncmp(argv[i], "--debug-ir=", 11) == 0) {
g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir=")); g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir="));
} }

View File

@@ -93,7 +93,7 @@
#include <llvm/IR/DataLayout.h> #include <llvm/IR/DataLayout.h>
#include <llvm/Analysis/TargetTransformInfo.h> #include <llvm/Analysis/TargetTransformInfo.h>
#endif #endif
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/Verifier.h> #include <llvm/IR/Verifier.h>
#include <llvm/IR/IRPrintingPasses.h> #include <llvm/IR/IRPrintingPasses.h>
#include <llvm/IR/CFG.h> #include <llvm/IR/CFG.h>
@@ -939,7 +939,7 @@ Module::writeOutput(OutputType outputType, const char *outFileName,
lStripUnusedDebugInfo(module); lStripUnusedDebugInfo(module);
} }
#if defined (LLVM_3_4) || defined (LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
// In LLVM_3_4 after r195494 and r195504 revisions we should pass // In LLVM_3_4 after r195494 and r195504 revisions we should pass
// "Debug Info Version" constant to the module. LLVM will ignore // "Debug Info Version" constant to the module. LLVM will ignore
// our Debug Info metadata without it. // our Debug Info metadata without it.
@@ -1096,7 +1096,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
} }
llvm::PassManager pm; llvm::PassManager pm;
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
#else #else
pm.add(new llvm::DataLayout(*g->target->getDataLayout())); pm.add(new llvm::DataLayout(*g->target->getDataLayout()));
@@ -2093,7 +2093,8 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
} }
inst.getLangOpts().LineComment = 1; inst.getLangOpts().LineComment = 1;
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
inst.createPreprocessor(clang::TU_Complete); inst.createPreprocessor(clang::TU_Complete);
#else #else
inst.createPreprocessor(); inst.createPreprocessor();

View File

@@ -44,7 +44,7 @@
#if defined(LLVM_3_4) #if defined(LLVM_3_4)
#include <llvm/DebugInfo.h> #include <llvm/DebugInfo.h>
#endif #endif
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/DebugInfo.h> #include <llvm/IR/DebugInfo.h>
#endif #endif

View File

@@ -63,12 +63,12 @@
#include <llvm/IR/BasicBlock.h> #include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Constants.h> #include <llvm/IR/Constants.h>
#endif #endif
#if defined (LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
#include <llvm/Transforms/Instrumentation.h> #include <llvm/Transforms/Instrumentation.h>
#endif #endif
#include <llvm/PassManager.h> #include <llvm/PassManager.h>
#include <llvm/PassRegistry.h> #include <llvm/PassRegistry.h>
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/Verifier.h> #include <llvm/IR/Verifier.h>
#include <llvm/IR/IRPrintingPasses.h> #include <llvm/IR/IRPrintingPasses.h>
#include <llvm/IR/PatternMatch.h> #include <llvm/IR/PatternMatch.h>
@@ -444,7 +444,8 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) {
number, P->getPassName()); number, P->getPassName());
PM.add(CreateDebugPass(buf)); PM.add(CreateDebugPass(buf));
} }
#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
if (g->debugIR == number) { if (g->debugIR == number) {
// adding generating of LLVM IR debug after optimization // adding generating of LLVM IR debug after optimization
char buf[100]; char buf[100];
@@ -469,7 +470,7 @@ Optimize(llvm::Module *module, int optLevel) {
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
optPM.add(targetLibraryInfo); optPM.add(targetLibraryInfo);
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
#else #else
optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); optPM.add(new llvm::DataLayout(*g->target->getDataLayout()));

View File

@@ -50,7 +50,7 @@
#include <llvm/IR/Value.h> #include <llvm/IR/Value.h>
#include <llvm/IR/Module.h> #include <llvm/IR/Module.h>
#endif #endif
#if defined(LLVM_3_5) || defined(LLVM_3_6) #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
#include <llvm/IR/DebugInfo.h> #include <llvm/IR/DebugInfo.h>
#include <llvm/IR/DIBuilder.h> #include <llvm/IR/DIBuilder.h>
#else #else
@@ -2981,14 +2981,16 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const {
for (int i = 0; i < GetNumParameters(); ++i) { for (int i = 0; i < GetNumParameters(); ++i) {
const Type *t = GetParameterType(i); const Type *t = GetParameterType(i);
if (t == NULL) if (t == NULL)
#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)// LLVM 3.4+
return llvm::DICompositeType(); return llvm::DICompositeType();
#else #else
return llvm::DIType(); return llvm::DIType();
#endif #endif
retArgTypes.push_back(t->GetDIType(scope)); retArgTypes.push_back(t->GetDIType(scope));
} }
#if defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+
llvm::DITypeArray retArgTypesArray = llvm::DITypeArray retArgTypesArray =
m->diBuilder->getOrCreateTypeArray(llvm::ArrayRef<llvm::Value *>(retArgTypes)); m->diBuilder->getOrCreateTypeArray(llvm::ArrayRef<llvm::Value *>(retArgTypes));
#else #else