diff options
author | Gil Pitney <gil.pitney@linaro.org> | 2015-01-27 01:40:06 +0000 |
---|---|---|
committer | Gil Pitney <gil.pitney@linaro.org> | 2015-01-27 01:40:06 +0000 |
commit | 7a364fc46f329a51989f5c7380456178f7d992e6 (patch) | |
tree | b40925b4a219eb76147e5cb268d4ec6433eedd30 | |
parent | 1401531bf3c6c31d728e87ee10a1c2469e43942e (diff) |
LLVM 3.6: More updates due to change in MetaData for kernel.cpp
Based on patch thanks to
Author: Tom Gall <tom.gall@linaro.org>
Date: Mon Jan 26 12:54:14 2015 -0600
add added updates based on comments in
http://llvm.org/docs/doxygen/html/classllvm_1_1ConstantInt.html
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r-- | src/core/kernel.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/core/kernel.cpp b/src/core/kernel.cpp index 76c7ab8..47e52db 100644 --- a/src/core/kernel.cpp +++ b/src/core/kernel.cpp @@ -45,7 +45,6 @@ #include <cstdlib> #include <boost/tuple/tuple.hpp> -#include <llvm/Support/Casting.h> #include <llvm/IR/Module.h> #include <llvm/IR/Type.h> #include <llvm/IR/DerivedTypes.h> @@ -55,6 +54,8 @@ using namespace Coal; +using namespace llvm; + Kernel::Kernel(Program *program) : Object(Object::T_Kernel, program), p_has_locals(false), wi_alloca_size(0) { @@ -459,7 +460,9 @@ boost::tuple<uint,uint,uint> Kernel::reqdWorkGroupSize(llvm::Module *module) con /*--------------------------------------------------------------------- * Each node has only one operand : a llvm::Function *--------------------------------------------------------------------*/ - llvm::Value *value = node->getOperand(0); + // future DEBUG point, we're not sure this works. + llvm::Value *value = llvm::dyn_cast<llvm::ValueAsMetadata>(node->getOperand(0))->getValue(); + /*--------------------------------------------------------------------- * Bug somewhere, don't crash @@ -472,17 +475,20 @@ boost::tuple<uint,uint,uint> Kernel::reqdWorkGroupSize(llvm::Module *module) con if (node->getNumOperands() <= 1) return zeros; llvm::MDNode *meta = llvm::cast<llvm::MDNode>(node->getOperand(1)); + llvm::Value *value_tmp = dyn_cast<ValueAsMetadata>(meta->getOperand(0))->getValue(); if (meta->getNumOperands() == 4 && - meta->getOperand(0)->getName().str() == std::string("reqd_work_group_size")) + value_tmp->getName().str() == std::string("reqd_work_group_size")) { - uint x = llvm::cast<llvm::ConstantInt> (meta->getOperand(1))->getValue().getLimitedValue(); - uint y = llvm::cast<llvm::ConstantInt> (meta->getOperand(2))->getValue().getLimitedValue(); - uint z = llvm::cast<llvm::ConstantInt> (meta->getOperand(3))->getValue().getLimitedValue(); + // See comments in http://llvm.org/docs/doxygen/html/classllvm_1_1ConstantInt.html + auto x = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(1))->getLimitedValue(); + auto y = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(2))->getLimitedValue(); + auto z = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(3))->getLimitedValue(); return boost::tuple<uint,uint,uint> (x,y,z); } return zeros; } + return zeros; } |