diff --git a/sycl/include/sycl/pointers.hpp b/sycl/include/sycl/pointers.hpp index c74a8e104ab82..cd082b9f79904 100644 --- a/sycl/include/sycl/pointers.hpp +++ b/sycl/include/sycl/pointers.hpp @@ -47,6 +47,11 @@ using private_ptr = // The interface exposes non-decorated pointer while keeping the // address space information internally. +template +using raw_generic_ptr = + multi_ptr; + template using raw_global_ptr = multi_ptr +using decorated_generic_ptr = + multi_ptr; + template using decorated_global_ptr = multi_ptr -using decorated_generic_ptr = - multi_ptr; - namespace static_as_cast { // CHECK-LABEL: define dso_local spir_func void @_ZN14static_as_cast19to_global_decoratedEN4sycl3_V19multi_ptrIiLNS1_6access13address_spaceE6ELNS3_9decoratedE1EEE( // CHECK-SAME: ptr addrspace(4) dead_on_unwind noalias nocapture writable writeonly sret(%"class.sycl::_V1::multi_ptr") align 8 [[AGG_RESULT:%.*]], ptr nocapture noundef readonly byval(%"class.sycl::_V1::multi_ptr.0") align 8 [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] !srcloc [[META6:![0-9]+]] !sycl_fixed_targets [[META7:![0-9]+]] { diff --git a/sycl/test/multi_ptr/aliases.cpp b/sycl/test/multi_ptr/aliases.cpp new file mode 100644 index 0000000000000..1911602e74386 --- /dev/null +++ b/sycl/test/multi_ptr/aliases.cpp @@ -0,0 +1,87 @@ +//==--------------- aliases.cpp - SYCL multi_ptr aliases test --------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning + +// expected-no-diagnostics + +#include + +#include + +template +void test_address_space_aliases() { + static_assert(std::is_same_v< + sycl::generic_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::global_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::local_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::private_ptr, + sycl::multi_ptr>); +} + +template void test_aliases() { + // Template specialization aliases for different pointer address spaces + test_address_space_aliases(); + test_address_space_aliases(); + test_address_space_aliases(); + + // Template specialization aliases for different pointer address spaces. + // The interface exposes non-decorated pointer while keeping the + // address space information internally. + static_assert(std::is_same_v< + sycl::raw_generic_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::raw_global_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::raw_local_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::raw_private_ptr, + sycl::multi_ptr>); + + // Template specialization aliases for different pointer address spaces. + // The interface exposes decorated pointer. + static_assert(std::is_same_v< + sycl::decorated_generic_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::decorated_global_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::decorated_local_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::decorated_private_ptr, + sycl::multi_ptr>); +} + +// Test "minimal set of types" in the CTS. As we are just testing aliases are +// present in this test, this should work for any type. + +template void test_aliases(); +template void test_aliases();