diff options
author | Jan Vesely <[email protected]> | 2017-10-21 15:38:54 -0400 |
---|---|---|
committer | Jan Vesely <[email protected]> | 2017-10-25 18:57:42 -0400 |
commit | a6d38f476beaaf0a9677cfc168172121b5779570 (patch) | |
tree | c23e2e8a001fb3ce3b113ce1be9489a1a7addfb0 | |
parent | b85cd69415f24ff4653e39f82dcd309363f65c59 (diff) |
clover: Fix compilation after clang r315871
v2: use a more generic compat function
v3: rename and formatting cleanup
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103388
Signed-off-by: Jan Vesely <[email protected]>
Reviewed-by: Francisco Jerez <[email protected]>
CC: <[email protected]>
-rw-r--r-- | src/gallium/state_trackers/clover/llvm/codegen/common.cpp | 5 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/llvm/compat.hpp | 12 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp index 075183400ae..ddf2083f37d 100644 --- a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp +++ b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp @@ -70,7 +70,6 @@ namespace { make_kernel_args(const Module &mod, const std::string &kernel_name, const clang::CompilerInstance &c) { std::vector<module::argument> args; - const auto address_spaces = c.getTarget().getAddressSpaceMap(); const Function &f = *mod.getFunction(kernel_name); ::llvm::DataLayout dl(&mod); const auto size_type = @@ -128,8 +127,8 @@ 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 (address_space == compat::target_address_space( + c.getTarget(), clang::LangAS::opencl_local)) { 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 f8b56516d5c..6fc75fb2502 100644 --- a/src/gallium/state_trackers/clover/llvm/compat.hpp +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp @@ -69,11 +69,19 @@ namespace clover { typedef ::llvm::TargetLibraryInfo target_library_info; #endif + template<typename T, typename AS> + unsigned target_address_space(const T &target, const AS lang_as) { + const auto &map = target.getAddressSpaceMap(); +#if HAVE_LLVM >= 0x0500 + return map[static_cast<unsigned>(lang_as)]; +#else + return map[lang_as - 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 |