[Mesa-dev] [PATCH] clover: Fix compilation after clang r315871
Jan Vesely
jano.vesely at gmail.com
Sun Oct 22 22:16:16 UTC 2017
From: Jan Vesely <jan.vesely at rutgers.edu>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103388
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
Hi,
this is an alternative to Vedran's approach. it hides the logic behind a compat function.
Jan
src/gallium/state_trackers/clover/llvm/codegen/common.cpp | 3 +--
src/gallium/state_trackers/clover/llvm/compat.hpp | 11 +++++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
index 075183400a..a4d22e53c3 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
@@ -128,8 +128,7 @@ namespace {
const unsigned address_space =
cast< ::llvm::PointerType>(actual_type)->getAddressSpace();
- if (address_space == address_spaces[clang::LangAS::opencl_local
- - compat::lang_as_offset]) {
+ if (compat::address_space_is_local(address_space, address_spaces)) {
args.emplace_back(module::argument::local, arg_api_size,
target_size, target_align,
module::argument::zero_ext);
diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp b/src/gallium/state_trackers/clover/llvm/compat.hpp
index f8b56516d5..66a82d3013 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -69,11 +69,18 @@ namespace clover {
typedef ::llvm::TargetLibraryInfo target_library_info;
#endif
+ template<typename AS>
+ bool address_space_is_local(unsigned address_space, const AS& map) {
+#if HAVE_LLVM >= 0x0500
+ return address_space == map[static_cast<unsigned>(clang::LangAS::opencl_local)];
+#else
+ return address_space == map[clang::LangAS::opencl_local - clang::LangAS::Offset];
+#endif
+ }
+
#if HAVE_LLVM >= 0x0500
- const auto lang_as_offset = 0;
const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
#else
- const auto lang_as_offset = clang::LangAS::Offset;
const clang::InputKind ik_opencl = clang::IK_OpenCL;
#endif
--
2.13.6
More information about the mesa-dev
mailing list