[Beignet] [PATCH 5/7] Backend: Refine LLVM version check macro
Xiuli Pan
xiuli.pan at intel.com
Fri Mar 17 06:16:01 UTC 2017
From: Pan Xiuli <xiuli.pan at intel.com>
LLVM 4.0 is coming, we should refine our version check to fit the
LLVM_MAJOR_VERSION bump to 4.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
backend/src/backend/gen_program.cpp | 12 ++---
backend/src/backend/program.cpp | 16 +++---
backend/src/ir/function.hpp | 2 +-
backend/src/llvm/ExpandLargeIntegers.cpp | 6 +--
backend/src/llvm/llvm_bitcode_link.cpp | 14 +++---
backend/src/llvm/llvm_device_enqueue.cpp | 10 ++--
backend/src/llvm/llvm_gen_backend.cpp | 38 +++++++-------
backend/src/llvm/llvm_gen_backend.hpp | 2 +-
backend/src/llvm/llvm_includes.hpp | 8 +--
backend/src/llvm/llvm_loadstore_optimization.cpp | 6 +--
backend/src/llvm/llvm_passes.cpp | 6 +--
backend/src/llvm/llvm_profiling.cpp | 2 +-
backend/src/llvm/llvm_sampler_fix.cpp | 2 +-
backend/src/llvm/llvm_scalarize.cpp | 2 +-
backend/src/llvm/llvm_to_gen.cpp | 64 ++++++++++++------------
backend/src/llvm/llvm_to_gen.hpp | 4 +-
backend/src/llvm/llvm_unroll.cpp | 14 +++---
17 files changed, 104 insertions(+), 104 deletions(-)
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
index 376342b..998e340 100644
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -329,13 +329,13 @@ namespace gbe {
//the first byte stands for binary_type.
binary_content.assign(binary+1, size-1);
llvm::StringRef llvm_bin_str(binary_content);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
llvm::LLVMContext& c = GBEGetLLVMContext();
#else
llvm::LLVMContext& c = llvm::getGlobalContext();
#endif
llvm::SMDiagnostic Err;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
std::unique_ptr<llvm::MemoryBuffer> memory_buffer = llvm::MemoryBuffer::getMemBuffer(llvm_bin_str, "llvm_bin_str");
acquireLLVMContextLock();
llvm::Module* module = llvm::parseIR(memory_buffer->getMemBufferRef(), Err, c).release();
@@ -482,14 +482,14 @@ namespace gbe {
using namespace gbe;
char* errMsg;
if(((GenProgram*)dst_program)->module == NULL){
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module).release();
#else
((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module);
#endif
errSize = 0;
}else{
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
// Src now will be removed automatically. So clone it.
llvm::Module* src = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module).release();
#else
@@ -497,9 +497,9 @@ namespace gbe {
#endif
llvm::Module* dst = (llvm::Module*)((GenProgram*)dst_program)->module;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
if (LLVMLinkModules2(wrap(dst), wrap(src))) {
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource_Removed, &errMsg)) {
#else
if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource, &errMsg)) {
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index a8834f2..3081ad6 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -115,7 +115,7 @@ namespace gbe {
llvm::Module * cloned_module = NULL;
bool ret = false;
if(module){
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
cloned_module = llvm::CloneModule((llvm::Module*)module).release();
#else
cloned_module = llvm::CloneModule((llvm::Module*)module);
@@ -124,7 +124,7 @@ namespace gbe {
bool strictMath = true;
if (fast_relaxed_math || !OCL_STRICT_CONFORMANCE)
strictMath = false;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
llvm::Module * linked_module = module ? llvm::CloneModule((llvm::Module*)module).release() : NULL;
// Src now will be removed automatically. So clone it.
if (llvmToGen(*unit, fileName, linked_module, optLevel, strictMath, OCL_PROFILING_LOG, error) == false) {
@@ -651,7 +651,7 @@ namespace gbe {
// The ParseCommandLineOptions used for mllvm args can not be used with multithread
// and GVN now have a 100 inst limit on block scan. Now only pass a bigger limit
// for each context only once, this can also fix multithread bug.
-#if LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
static bool ifsetllvm = false;
if(!ifsetllvm) {
args.push_back("-mllvm");
@@ -702,7 +702,7 @@ namespace gbe {
Diags);
llvm::StringRef srcString(source);
(*CI).getPreprocessorOpts().addRemappedFile("stringInput.cl",
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
llvm::MemoryBuffer::getMemBuffer(srcString)
#else
llvm::MemoryBuffer::getMemBuffer(srcString).release()
@@ -755,7 +755,7 @@ namespace gbe {
if (!retVal)
return false;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
llvm::Module *module = Act->takeModule();
#else
llvm::Module *module = Act->takeModule().release();
@@ -764,7 +764,7 @@ namespace gbe {
*out_module = module;
// Dump the LLVM if requested.
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 36
if (!dumpLLVMFileName.empty()) {
std::string err;
llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),
@@ -1121,7 +1121,7 @@ EXTEND_QUOTE:
//FIXME: if use new allocated context to link two modules there would be context mismatch
//for some functions, so we use global context now, need switch to new context later.
llvm::Module * out_module;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
llvm::LLVMContext* llvm_ctx = &GBEGetLLVMContext();
#else
llvm::LLVMContext* llvm_ctx = &llvm::getGlobalContext();
@@ -1595,7 +1595,7 @@ namespace gbe
}
~CallBackInitializer() {
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR > 3)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 34
llvm::llvm_shutdown();
#endif
}
diff --git a/backend/src/ir/function.hpp b/backend/src/ir/function.hpp
index 5fcb14a..64d9727 100644
--- a/backend/src/ir/function.hpp
+++ b/backend/src/ir/function.hpp
@@ -186,7 +186,7 @@ namespace ir {
// only llvm-3.6 or later has kernel_arg_base_type in metadata.
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR <= 5)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
bool isImage1dT() const {
return typeName.compare("image1d_t") == 0;
}
diff --git a/backend/src/llvm/ExpandLargeIntegers.cpp b/backend/src/llvm/ExpandLargeIntegers.cpp
index 60740f5..8515dc1 100644
--- a/backend/src/llvm/ExpandLargeIntegers.cpp
+++ b/backend/src/llvm/ExpandLargeIntegers.cpp
@@ -93,7 +93,7 @@
using namespace llvm;
-#if LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
#define DEBUG_TYPE "nacl-expand-ints"
#endif
@@ -766,7 +766,7 @@ static void convertInstruction(Instruction *Inst, ConversionState &State,
bool ExpandLargeIntegers::runOnFunction(Function &F) {
// Don't support changing the function arguments. Illegal function arguments
// should not be generated by clang.
-#if LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
for (const Argument &Arg : F.args())
#else
for (const Argument &Arg : F.getArgumentList())
@@ -789,7 +789,7 @@ bool ExpandLargeIntegers::runOnFunction(Function &F) {
// Only attempt to convert an instruction if its result or any of its
// operands are illegal.
bool ShouldConvert = shouldConvert(&I);
-#if LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
for (Value *Op : I.operands())
ShouldConvert |= shouldConvert(Op);
#else
diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp
index 89d5e7c..869db89 100644
--- a/backend/src/llvm/llvm_bitcode_link.cpp
+++ b/backend/src/llvm/llvm_bitcode_link.cpp
@@ -60,7 +60,7 @@ namespace gbe
return NULL;
}
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
oclLib = getLazyIRFileModule(FilePath, Err, ctx);
#else
oclLib = getLazyIRFileModule(FilePath, Err, ctx).release();
@@ -117,7 +117,7 @@ namespace gbe
std::string ErrInfo;// = "Not Materializable";
if (!fromSrc && newMF->isMaterializable()) {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
if (newMF->Materialize(&ErrInfo)) {
printf("Can not materialize the function: %s, because %s\n", fnName.c_str(), ErrInfo.c_str());
return false;
@@ -250,7 +250,7 @@ namespace gbe
}
std::string ErrInfo;// = "Not Materializable";
if (newMF->isMaterializable()) {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
if (newMF->Materialize(&ErrInfo)) {
printf("Can not materialize the function: %s, because %s\n", fnName.c_str(), ErrInfo.c_str());
delete clonedLib;
@@ -287,7 +287,7 @@ namespace gbe
* pass to extract the functions and values in Gvs from the library module.
* After extract what we need and remove what we do not need, we use
* materializeAll to mark the module as materialized. */
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
/* Get all GlobalValue from module. */
Module::GlobalListType &GVlist = clonedLib->getGlobalList();
for(Module::global_iterator GVitr = GVlist.begin();GVitr != GVlist.end();++GVitr) {
@@ -310,7 +310,7 @@ namespace gbe
/* We use beignet's bitcode as dst because it will have a lot of
lazy functions which will not be loaded. */
char* errorMsg;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
if(LLVMLinkModules2(wrap(clonedLib), wrap(mod))) {
#else
if(LLVMLinkModules(wrap(clonedLib), wrap(mod), LLVMLinkerDestroySource, &errorMsg)) {
@@ -319,13 +319,13 @@ namespace gbe
printf("Fatal Error: link the bitcode error:\n%s\n", errorMsg);
return NULL;
}
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
llvm::legacy::PassManager passes;
#else
llvm::PassManager passes;
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
auto PreserveKernel = [=](const GlobalValue &GV) {
for(size_t i = 0;i < kernels.size(); ++i)
if(strcmp(GV.getName().data(), kernels[i]))
diff --git a/backend/src/llvm/llvm_device_enqueue.cpp b/backend/src/llvm/llvm_device_enqueue.cpp
index ee236de..9a0fb46 100644
--- a/backend/src/llvm/llvm_device_enqueue.cpp
+++ b/backend/src/llvm/llvm_device_enqueue.cpp
@@ -62,7 +62,7 @@ namespace gbe {
for (Value::use_iterator iter = v->use_begin(); iter != v->use_end(); ++iter) {
// After LLVM 3.5, use_iterator points to 'Use' instead of 'User',
// which is more straightforward.
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 35
User *theUser = *iter;
#else
User *theUser = iter->getUser();
@@ -84,7 +84,7 @@ namespace gbe {
Function* setFunctionAsKernel(Module *mod, Function *Fn)
{
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR >= 9)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
LLVMContext &Context = mod->getContext();
Type *intTy = IntegerType::get(mod->getContext(), 32);
SmallVector<llvm::Metadata *, 5> kernelMDArgs;
@@ -210,7 +210,7 @@ namespace gbe {
}
for (Value::use_iterator iter = bt->use_begin(); iter != bt->use_end(); ++iter) {
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 35
User *theUser = *iter;
#else
User *theUser = iter->getUser();
@@ -298,7 +298,7 @@ namespace gbe {
if(AllocaInst *ai = dyn_cast<AllocaInst>(ld->getPointerOperand())) {
Value *v = NULL;
for (Value::use_iterator iter = ai->use_begin(); iter != ai->use_end(); ++iter) {
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 35
User *theUser = *iter;
#else
User *theUser = iter->getUser();
@@ -347,7 +347,7 @@ namespace gbe {
if(ld) {
Value *block = ld->getPointerOperand();
for (Value::use_iterator iter = block->use_begin(); iter != block->use_end(); ++iter) {
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 35
User *theUser = *iter;
#else
User *theUser = iter->getUser();
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 742c947..4621f6d 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -95,9 +95,9 @@
#define LLVM_VERSION_MINOR 0
#endif /* !defined(LLVM_VERSION_MINOR) */
-#if (LLVM_VERSION_MAJOR != 3) || (LLVM_VERSION_MINOR < 3)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 33
#error "Only LLVM 3.3 and newer are supported"
-#endif /* (LLVM_VERSION_MAJOR != 3) || (LLVM_VERSION_MINOR > 4) */
+#endif
using namespace llvm;
@@ -565,7 +565,7 @@ namespace gbe
has_errors(false),
legacyMode(true)
{
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
initializeLoopInfoWrapperPassPass(*PassRegistry::getPassRegistry());
#else
initializeLoopInfoPass(*PassRegistry::getPassRegistry());
@@ -576,7 +576,7 @@ namespace gbe
virtual const char *getPassName() const { return "Gen Back-End"; }
void getAnalysisUsage(AnalysisUsage &AU) const {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
AU.addRequired<LoopInfoWrapperPass>();
#else
AU.addRequired<LoopInfo>();
@@ -611,7 +611,7 @@ namespace gbe
if (legacyMode)
analyzePointerOrigin(F);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
#else
LI = &getAnalysis<LoopInfo>();
@@ -835,7 +835,7 @@ namespace gbe
for (Value::use_iterator iter = work->use_begin(); iter != work->use_end(); ++iter) {
// After LLVM 3.5, use_iterator points to 'Use' instead of 'User',
// which is more straightforward.
- #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+ #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 35
User *theUser = *iter;
#else
User *theUser = iter->getUser();
@@ -1089,7 +1089,7 @@ namespace gbe
if (predBB->getTerminator())
Builder2.SetInsertPoint(predBB->getTerminator());
-#if (LLVM_VERSION_MAJOR== 3 && LLVM_VERSION_MINOR < 6)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 36
// llvm 3.5 and older version don't have CreateBitOrPointerCast() define
Type *srcTy = base->getType();
Type *dstTy = ptr->getType();
@@ -1248,7 +1248,7 @@ namespace gbe
uint32_t ops = clKernels->getNumOperands();
for(uint32_t x = 0; x < ops; x++) {
MDNode* node = clKernels->getOperand(x);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
Value * op = node->getOperand(0);
#else
auto *V = cast<ValueAsMetadata>(node->getOperand(0));
@@ -1272,7 +1272,7 @@ namespace gbe
MDNode *typeNameNode = NULL;
MDNode *typeBaseNameNode = NULL;
MDNode *typeQualNode = NULL;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
typeNameNode = F.getMetadata("kernel_arg_type");
typeBaseNameNode = F.getMetadata("kernel_arg_base_type");
typeQualNode = F.getMetadata("kernel_arg_type_qual");
@@ -1298,7 +1298,7 @@ namespace gbe
ir::FunctionArgument::InfoFromLLVM llvmInfo;
for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I, argID++) {
unsigned opID = argID;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 39
opID += 1;
#endif
@@ -1340,7 +1340,7 @@ namespace gbe
for (Value::use_iterator iter = work->use_begin(); iter != work->use_end(); ++iter) {
// After LLVM 3.5, use_iterator points to 'Use' instead of 'User',
// which is more straightforward.
- #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+ #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 35
User *theUser = *iter;
#else
User *theUser = iter->getUser();
@@ -2120,7 +2120,7 @@ namespace gbe
std::string functionAttributes;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
/* LLVM 3.9 change kernel arg info as function metadata */
addrSpaceNode = F.getMetadata("kernel_arg_addr_space");
accessQualNode = F.getMetadata("kernel_arg_access_qual");
@@ -2222,7 +2222,7 @@ namespace gbe
if (attrName->getString() == "reqd_work_group_size") {
GBE_ASSERT(attrNode->getNumOperands() == 4);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
ConstantInt *x = dyn_cast<ConstantInt>(attrNode->getOperand(1));
ConstantInt *y = dyn_cast<ConstantInt>(attrNode->getOperand(2));
ConstantInt *z = dyn_cast<ConstantInt>(attrNode->getOperand(3));
@@ -2264,13 +2264,13 @@ namespace gbe
} else if (attrName->getString() == "vec_type_hint") {
GBE_ASSERT(attrNode->getNumOperands() == 3);
functionAttributes += attrName->getString();
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
Value* V = attrNode->getOperand(1);
#else
auto *Op1 = cast<ValueAsMetadata>(attrNode->getOperand(1));
Value *V = Op1 ? Op1->getValue() : NULL;
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
ConstantInt *sign = dyn_cast<ConstantInt>(attrNode->getOperand(2));
#else
ConstantInt *sign = mdconst::extract<ConstantInt>(attrNode->getOperand(2));
@@ -2299,7 +2299,7 @@ namespace gbe
functionAttributes += " ";
} else if (attrName->getString() == "work_group_size_hint") {
GBE_ASSERT(attrNode->getNumOperands() == 4);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
ConstantInt *x = dyn_cast<ConstantInt>(attrNode->getOperand(1));
ConstantInt *y = dyn_cast<ConstantInt>(attrNode->getOperand(2));
ConstantInt *z = dyn_cast<ConstantInt>(attrNode->getOperand(3));
@@ -2341,13 +2341,13 @@ namespace gbe
// Insert a new register for each function argument
for (; I != E; ++I, ++argID) {
uint32_t opID = argID;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 39
opID += 1;
#endif
const std::string &argName = I->getName().str();
Type *type = I->getType();
if(addrSpaceNode) {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
llvmInfo.addrSpace = (cast<ConstantInt>(addrSpaceNode->getOperand(opID)))->getZExtValue();
#else
llvmInfo.addrSpace = (mdconst::extract<ConstantInt>(addrSpaceNode->getOperand(opID)))->getZExtValue();
@@ -2914,7 +2914,7 @@ namespace gbe
const Instruction *insn = NULL;
for(Value::const_use_iterator iter = v->use_begin(); iter != v->use_end(); ++iter) {
// After LLVM 3.5, use_iterator points to 'Use' instead of 'User', which is more straightforward.
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR < 35
const User *theUser = *iter;
#else
const User *theUser = iter->getUser();
diff --git a/backend/src/llvm/llvm_gen_backend.hpp b/backend/src/llvm/llvm_gen_backend.hpp
index eea050b..1b7ca49 100644
--- a/backend/src/llvm/llvm_gen_backend.hpp
+++ b/backend/src/llvm/llvm_gen_backend.hpp
@@ -149,7 +149,7 @@ namespace gbe
/*! Insert the time stamp for profiling. */
llvm::FunctionPass* createProfilingInserterPass(int profilingType, ir::Unit &unit);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
/* customized loop unrolling pass. */
llvm::LoopPass *createCustomLoopUnrollPass();
#endif
diff --git a/backend/src/llvm/llvm_includes.hpp b/backend/src/llvm/llvm_includes.hpp
index 0b80979..a242fd3 100644
--- a/backend/src/llvm/llvm_includes.hpp
+++ b/backend/src/llvm/llvm_includes.hpp
@@ -91,7 +91,7 @@
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
#include "llvm/IR/Mangler.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CFG.h"
@@ -111,7 +111,7 @@
#include "llvm/Target/Mangler.h"
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/LegacyPassManager.h"
#else
@@ -122,12 +122,12 @@
#include <clang/CodeGen/CodeGenAction.h>
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
#include "llvm/Transforms/IPO/FunctionAttrs.h"
#include "llvm/Transforms/Scalar/GVN.h"
#endif
diff --git a/backend/src/llvm/llvm_loadstore_optimization.cpp b/backend/src/llvm/llvm_loadstore_optimization.cpp
index e797e98..4f4639c 100644
--- a/backend/src/llvm/llvm_loadstore_optimization.cpp
+++ b/backend/src/llvm/llvm_loadstore_optimization.cpp
@@ -35,7 +35,7 @@ namespace gbe {
GenLoadStoreOptimization() : BasicBlockPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
AU.addRequired<ScalarEvolutionWrapperPass>();
AU.addPreserved<ScalarEvolutionWrapperPass>();
#else
@@ -46,12 +46,12 @@ namespace gbe {
}
virtual bool runOnBasicBlock(BasicBlock &BB) {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
#else
SE = &getAnalysis<ScalarEvolution>();
#endif
- #if LLVM_VERSION_MINOR >= 7
+ #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
TD = &BB.getModule()->getDataLayout();
#elif LLVM_VERSION_MINOR >= 5
DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
index 8f5bcc9..f414fbb 100644
--- a/backend/src/llvm/llvm_passes.cpp
+++ b/backend/src/llvm/llvm_passes.cpp
@@ -42,7 +42,7 @@ namespace gbe
{
bool isKernelFunction(const llvm::Function &F) {
bool bKernel = false;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
bKernel = F.getMetadata("kernel_arg_name") != NULL;
#else
const Module *module = F.getParent();
@@ -53,7 +53,7 @@ namespace gbe
uint32_t ops = md.getNumOperands();
for(uint32_t x = 0; x < ops; x++) {
MDNode* node = md.getOperand(x);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR <= 35
Value * op = node->getOperand(0);
#else
Value * op = cast<ValueAsMetadata>(node->getOperand(0))->getValue();
@@ -74,7 +74,7 @@ namespace gbe
if(ops > 0) {
uint32_t major = 0, minor = 0;
MDNode* node = version->getOperand(0);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
major = mdconst::extract<ConstantInt>(node->getOperand(0))->getZExtValue();
minor = mdconst::extract<ConstantInt>(node->getOperand(1))->getZExtValue();
#else
diff --git a/backend/src/llvm/llvm_profiling.cpp b/backend/src/llvm/llvm_profiling.cpp
index 734c69d..bc16951 100644
--- a/backend/src/llvm/llvm_profiling.cpp
+++ b/backend/src/llvm/llvm_profiling.cpp
@@ -34,7 +34,7 @@
#include "llvm/Pass.h"
#include "llvm/IR/IRBuilder.h"
-#if LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CFG.h"
#else
diff --git a/backend/src/llvm/llvm_sampler_fix.cpp b/backend/src/llvm/llvm_sampler_fix.cpp
index de7ebdb..2e8bcf9 100644
--- a/backend/src/llvm/llvm_sampler_fix.cpp
+++ b/backend/src/llvm/llvm_sampler_fix.cpp
@@ -33,7 +33,7 @@ namespace gbe {
class SamplerFix : public FunctionPass {
public:
SamplerFix() : FunctionPass(ID) {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
initializeDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
#else
initializeDominatorTreePass(*PassRegistry::getPassRegistry());
diff --git a/backend/src/llvm/llvm_scalarize.cpp b/backend/src/llvm/llvm_scalarize.cpp
index 329e3a9..be3d549 100644
--- a/backend/src/llvm/llvm_scalarize.cpp
+++ b/backend/src/llvm/llvm_scalarize.cpp
@@ -96,7 +96,7 @@ namespace gbe {
Scalarize() : FunctionPass(ID)
{
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
initializeDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
#else
initializeDominatorTreePass(*PassRegistry::getPassRegistry());
diff --git a/backend/src/llvm/llvm_to_gen.cpp b/backend/src/llvm/llvm_to_gen.cpp
index bef4df1..9b3b1f4 100644
--- a/backend/src/llvm/llvm_to_gen.cpp
+++ b/backend/src/llvm/llvm_to_gen.cpp
@@ -46,14 +46,14 @@ namespace gbe
BVAR(OCL_OUTPUT_CFG_GEN_IR, false);
using namespace llvm;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
llvm::LLVMContext& GBEGetLLVMContext() {
static llvm::LLVMContext GBEContext;
return GBEContext;
}
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
#define TARGETLIBRARY TargetLibraryInfoImpl
#else
#define TARGETLIBRARY TargetLibraryInfo
@@ -61,32 +61,32 @@ namespace gbe
void runFuntionPass(Module &mod, TARGETLIBRARY *libraryInfo, const DataLayout &DL)
{
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
legacy::FunctionPassManager FPM(&mod);
#else
FunctionPassManager FPM(&mod);
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
FPM.add(new DataLayoutPass());
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 5
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR == 35
FPM.add(new DataLayoutPass(DL));
#else
FPM.add(new DataLayout(DL));
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
FPM.add(createVerifierPass(true));
#else
FPM.add(createVerifierPass());
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
FPM.add(new TargetLibraryInfoWrapperPass(*libraryInfo));
#else
FPM.add(new TargetLibraryInfo(*libraryInfo));
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
FPM.add(createTypeBasedAAWrapperPass());
FPM.add(createBasicAAWrapperPass());
#else
@@ -108,27 +108,27 @@ namespace gbe
void runModulePass(Module &mod, TARGETLIBRARY *libraryInfo, const DataLayout &DL, int optLevel, bool strictMath)
{
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
legacy::PassManager MPM;
#else
PassManager MPM;
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
MPM.add(new DataLayoutPass());
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 5
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR == 35
MPM.add(new DataLayoutPass(DL));
#else
MPM.add(new DataLayout(DL));
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
MPM.add(new TargetLibraryInfoWrapperPass(*libraryInfo));
#else
MPM.add(new TargetLibraryInfo(*libraryInfo));
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
MPM.add(createTypeBasedAAWrapperPass());
MPM.add(createBasicAAWrapperPass());
#else
@@ -149,9 +149,9 @@ namespace gbe
MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
MPM.add(createPruneEHPass()); // Remove dead EH info
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
MPM.add(createPostOrderFunctionAttrsLegacyPass());
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
MPM.add(createPostOrderFunctionAttrsPass()); // Set readonly/readnone attrs
#else
MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs
@@ -159,7 +159,7 @@ namespace gbe
//MPM.add(createScalarReplAggregatesPass(64, true, -1, -1, 64))
if(optLevel > 0)
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
MPM.add(createSROAPass());
#else
MPM.add(createSROAPass(/*RequiresDomTree*/ false));
@@ -182,14 +182,14 @@ namespace gbe
MPM.add(createLoopDeletionPass()); // Delete dead loops
MPM.add(createLoopUnrollPass(640)); //1024, 32, 1024, 512)); //Unroll loops
if(optLevel > 0) {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
MPM.add(createSROAPass());
#else
MPM.add(createSROAPass(/*RequiresDomTree*/ false));
#endif
MPM.add(createGVNPass()); // Remove redundancies
}
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
// FIXME Workaround: we find that CustomLoopUnroll may increase register pressure greatly,
// and it may even make som cl kernel cannot compile because of limited scratch memory for spill.
// As we observe this under strict math. So we disable CustomLoopUnroll if strict math is enabled.
@@ -199,7 +199,7 @@ namespace gbe
#endif
MPM.add(createLoopUnrollPass()); //1024, 32, 1024, 512)); //Unroll loops
if(optLevel > 0) {
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
MPM.add(createSROAPass());
#else
MPM.add(createSROAPass(/*RequiresDomTree*/ false));
@@ -230,7 +230,7 @@ namespace gbe
}
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
#define OUTPUT_BITCODE(STAGE, MOD) do { \
legacy::PassManager passes__; \
if (OCL_OUTPUT_LLVM_##STAGE) { \
@@ -238,7 +238,7 @@ namespace gbe
passes__.run(MOD); \
} \
}while(0)
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
#define OUTPUT_BITCODE(STAGE, MOD) do { \
PassManager passes__; \
if (OCL_OUTPUT_LLVM_##STAGE) { \
@@ -303,12 +303,12 @@ namespace gbe
if (module) {
cl_mod = reinterpret_cast<Module*>(const_cast<void*>(module));
} else if (fileName){
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
llvm::LLVMContext& c = GBEGetLLVMContext();
#else
llvm::LLVMContext& c = llvm::getGlobalContext();
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
cl_mod = parseIRFile(fileName, Err, c).release();
#else
cl_mod = ParseIRFile(fileName, Err, c);
@@ -318,7 +318,7 @@ namespace gbe
if (!cl_mod) return false;
OUTPUT_BITCODE(BEFORE_LINK, (*cl_mod));
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
legacy::PassManager passes__;
#else
PassManager passes__;
@@ -346,7 +346,7 @@ namespace gbe
gbeDiagnosticContext dc;
mod.getContext().setDiagnosticHandler(&gbeDiagnosticHandler,&dc);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
mod.setDataLayout(DL);
#endif
Triple TargetTriple(mod.getTargetTriple());
@@ -357,15 +357,15 @@ namespace gbe
runFuntionPass(mod, libraryInfo, DL);
runModulePass(mod, libraryInfo, DL, optLevel, strictMath);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
legacy::PassManager passes;
#else
PassManager passes;
#endif
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
passes.add(new DataLayoutPass());
-#elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 5
+#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR == 35
passes.add(new DataLayoutPass(DL));
#else
passes.add(new DataLayout(DL));
@@ -374,7 +374,7 @@ namespace gbe
passes.add(createIntrinsicLoweringPass());
passes.add(createStripAttributesPass()); // Strip unsupported attributes and calling conventions.
passes.add(createFunctionInliningPass(20000));
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
passes.add(createSROAPass());
#else
passes.add(createScalarReplAggregatesPass(64, true, -1, -1, 64));
diff --git a/backend/src/llvm/llvm_to_gen.hpp b/backend/src/llvm/llvm_to_gen.hpp
index d3928c6..9025852 100644
--- a/backend/src/llvm/llvm_to_gen.hpp
+++ b/backend/src/llvm/llvm_to_gen.hpp
@@ -23,7 +23,7 @@
*/
#ifndef __GBE_IR_LLVM_TO_GEN_HPP__
#define __GBE_IR_LLVM_TO_GEN_HPP__
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
#include "llvm/IR/LLVMContext.h"
#endif
@@ -37,7 +37,7 @@ namespace gbe {
optLevel 0 equal to clang -O1 and 1 equal to clang -O2*/
bool llvmToGen(ir::Unit &unit, const char *fileName, const void* module,
int optLevel, bool strictMath, int profiling, std::string &errors);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
extern llvm::LLVMContext& GBEGetLLVMContext();
#endif
diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp
index e24dc4f..bfd3bbe 100644
--- a/backend/src/llvm/llvm_unroll.cpp
+++ b/backend/src/llvm/llvm_unroll.cpp
@@ -16,7 +16,7 @@
*/
#include "llvm/Config/llvm-config.h"
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
#include <set>
#include "llvm_includes.hpp"
@@ -36,7 +36,7 @@ namespace gbe {
LoopPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const {
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR >= 7)
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
AU.addRequired<LoopInfoWrapperPass>();
AU.addPreserved<LoopInfoWrapperPass>();
#else
@@ -47,7 +47,7 @@ namespace gbe {
AU.addPreservedID(LoopSimplifyID);
AU.addRequiredID(LCSSAID);
AU.addPreservedID(LCSSAID);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
AU.addRequired<ScalarEvolutionWrapperPass>();
AU.addPreserved<ScalarEvolutionWrapperPass>();
#else
@@ -91,7 +91,7 @@ namespace gbe {
assert(MD->getNumOperands() == 2 &&
"Unroll count hint metadata should have two operands.");
unsigned Count;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
Count = mdconst::extract<ConstantInt>(MD->getOperand(1))->getZExtValue();
#else
Count = cast<ConstantInt>(MD->getOperand(1))->getZExtValue();
@@ -105,7 +105,7 @@ namespace gbe {
void setUnrollID(Loop *L, bool enable) {
assert(enable);
LLVMContext &Context = L->getHeader()->getContext();
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
SmallVector<Metadata *, 2> forceUnroll;
forceUnroll.push_back(MDString::get(Context, "llvm.loop.unroll.enable"));
MDNode *forceUnrollNode = MDNode::get(Context, forceUnroll);
@@ -169,7 +169,7 @@ namespace gbe {
// be unrolled.
bool handleParentLoops(Loop *L, LPPassManager &LPM) {
Loop *currL = L;
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
LoopInfo &loopInfo = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
#else
@@ -205,7 +205,7 @@ namespace gbe {
if (parentTripCount != 0 && currTripCount * parentTripCount > 32) {
//Don't change the unrollID if doesn't force unroll.
//setUnrollID(parentL, false);
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
+#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
loopInfo.markAsRemoved(parentL);
#else
LPM.deleteLoopFromQueue(parentL);
--
2.7.4
More information about the Beignet
mailing list