summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorJan Vesely <[email protected]>2016-06-22 20:52:26 -0400
committerFrancisco Jerez <[email protected]>2016-06-27 23:12:37 -0700
commit87787e907929fe65d6b65d467ad05ea94279bb5a (patch)
treea5a41eea605d74d544095579da9bdd773cc1f0e2 /src/gallium/state_trackers
parenta8a966ddb5ad805421bb9548b150055d14fb5c63 (diff)
clover: Fix kernel metadata retrieval after clang r273425
Signed-off-by: Jan Vesely <[email protected]> Acked-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/clover/llvm/invocation.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 384b1a1dee3..44c7e1eb2c9 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -281,7 +281,16 @@ namespace {
}
std::vector<llvm::Function *>
- find_kernels(const llvm::Module *mod) {
+ find_kernels(llvm::Module *mod) {
+ std::vector<llvm::Function *> kernels;
+#if HAVE_LLVM >= 0x0309
+ auto &list = mod->getFunctionList();
+ for_each(list.begin(), list.end(), [&](llvm::Function &f){
+ if (f.getMetadata("kernel_arg_type"))
+ kernels.push_back(&f);
+ });
+ return kernels;
+#endif
const llvm::NamedMDNode *kernel_node =
mod->getNamedMetadata("opencl.kernels");
// This means there are no kernels in the program. The spec does not
@@ -291,7 +300,6 @@ namespace {
return std::vector<llvm::Function *>();
}
- std::vector<llvm::Function *> kernels;
kernels.reserve(kernel_node->getNumOperands());
for (unsigned i = 0; i < kernel_node->getNumOperands(); ++i) {
#if HAVE_LLVM >= 0x0306
@@ -377,8 +385,27 @@ namespace {
kernel_arg_md(llvm::StringRef type_name_, llvm::StringRef access_qual_):
type_name(type_name_), access_qual(access_qual_) {}
};
+#if HAVE_LLVM >= 0x0309
+ std::vector<kernel_arg_md>
+ get_kernel_arg_md(const llvm::Function *kernel_func) {
-#if HAVE_LLVM >= 0x0306
+ size_t num_args = kernel_func->getArgumentList().size();
+
+ auto aq = kernel_func->getMetadata("kernel_arg_access_qual");
+ auto ty = kernel_func->getMetadata("kernel_arg_type");
+
+ std::vector<kernel_arg_md> res;
+ res.reserve(num_args);
+ for (size_t i = 0; i < num_args; ++i) {
+ res.push_back(kernel_arg_md(
+ llvm::cast<llvm::MDString>(ty->getOperand(i))->getString(),
+ llvm::cast<llvm::MDString>(aq->getOperand(i))->getString()));
+ }
+
+ return res;
+ }
+
+#elif HAVE_LLVM >= 0x0306
const llvm::MDNode *
get_kernel_metadata(const llvm::Function *kernel_func) {
@@ -776,7 +803,7 @@ namespace {
module
build_module_native(std::vector<char> &code,
- const llvm::Module *mod,
+ llvm::Module *mod,
const clang::LangAS::Map &address_spaces,
std::string &r_log) {