summaryrefslogtreecommitdiff
path: root/backend/src/llvm/llvm_unroll.cpp
diff options
context:
space:
mode:
authorYang Rong <rong.r.yang@intel.com>2015-02-12 16:29:40 +0800
committerZhigang Gong <zhigang.gong@intel.com>2015-02-12 18:59:47 +0800
commitdd6b8896deb8c799f1155b7c87343b5e6d1a9d86 (patch)
tree569a83c474cca03aafc49ca6bea1e98a0a674c71 /backend/src/llvm/llvm_unroll.cpp
parent7c21daf4d04c6ad3fbca040b1165c08f7b40d179 (diff)
Add llvm3.6 build support.
There are some changes from llvm3.5: 1. Some functions return std::unique_ptr instead of pointer. 2. MetaNode to Value and Value to MetaNode. V2: Fix llvm3.5 build error. V3: Print link and function materialize message. Signed-off-by: Yang Rong <rong.r.yang@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'backend/src/llvm/llvm_unroll.cpp')
-rw-r--r--backend/src/llvm/llvm_unroll.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp
index 172e724c..5d3fad88 100644
--- a/backend/src/llvm/llvm_unroll.cpp
+++ b/backend/src/llvm/llvm_unroll.cpp
@@ -95,7 +95,11 @@ namespace gbe {
if (Name.equals(S->getString())) {
assert(MD->getNumOperands() == 2 &&
"Unroll hint metadata should have two operands.");
+#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+ return mdconst::extract<ConstantInt>(MD->getOperand(1));
+#else
return cast<ConstantInt>(MD->getOperand(1));
+#endif
}
}
return nullptr;
@@ -105,6 +109,15 @@ namespace gbe {
if (!enable && disabledLoops.find(L) != disabledLoops.end())
return;
LLVMContext &Context = L->getHeader()->getContext();
+#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6
+ SmallVector<Metadata *, 2> forceUnroll;
+ forceUnroll.push_back(MDString::get(Context, "llvm.loop.unroll.enable"));
+ forceUnroll.push_back(ConstantAsMetadata::get(ConstantInt::get(Type::getInt1Ty(Context), enable)));
+ MDNode *forceUnrollNode = MDNode::get(Context, forceUnroll);
+ SmallVector<Metadata *, 4> Vals;
+ Vals.push_back(NULL);
+ Vals.push_back(forceUnrollNode);
+#else
SmallVector<Value *, 2> forceUnroll;
forceUnroll.push_back(MDString::get(Context, "llvm.loop.unroll.enable"));
forceUnroll.push_back(ConstantInt::get(Type::getInt1Ty(Context), enable));
@@ -112,6 +125,7 @@ namespace gbe {
SmallVector<Value *, 4> Vals;
Vals.push_back(NULL);
Vals.push_back(forceUnrollNode);
+#endif
MDNode *NewLoopID = MDNode::get(Context, Vals);
// Set operand 0 to refer to the loop id itself.
NewLoopID->replaceOperandWith(0, NewLoopID);