Jan Vesely <jano.ves...@gmail.com> writes:

> From: Jan Vesely <jan.ves...@rutgers.edu>
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103388
> Signed-off-by: Jan Vesely <jan.ves...@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)) {

Looks better to me, but I think the function would be more useful if it
returned the target address space index (because that would allow you to
do things other than comparing whether it's the local address space),
and I think I'd parameterize it on the target instead of on the address
space dictionary (which you could remove from above), like:

| 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 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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to