|
| 1 | +/*===---- spirv_builtin_vars.h - SPIR-V built-in ---------------------------=== |
| 2 | + * |
| 3 | + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | + * See https://llvm.org/LICENSE.txt for license information. |
| 5 | + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | + * |
| 7 | + *===-----------------------------------------------------------------------=== |
| 8 | + */ |
| 9 | + |
| 10 | +#ifndef __SPIRV_BUILTIN_VARS_H |
| 11 | +#define __SPIRV_BUILTIN_VARS_H |
| 12 | + |
| 13 | +#if __cplusplus >= 201103L |
| 14 | +#define __SPIRV_NOEXCEPT noexcept |
| 15 | +#else |
| 16 | +#define __SPIRV_NOEXCEPT |
| 17 | +#endif |
| 18 | + |
| 19 | +#define __SPIRV_overloadable __attribute__((overloadable)) |
| 20 | +#define __SPIRV_convergent __attribute__((convergent)) |
| 21 | +#define __SPIRV_inline __attribute__((always_inline)) |
| 22 | + |
| 23 | +#define __global __attribute__((opencl_global)) |
| 24 | +#define __local __attribute__((opencl_local)) |
| 25 | +#define __private __attribute__((opencl_private)) |
| 26 | +#define __constant __attribute__((opencl_constant)) |
| 27 | +#ifdef __SYCL_DEVICE_ONLY__ |
| 28 | +#define __generic |
| 29 | +#else |
| 30 | +#define __generic __attribute__((opencl_generic)) |
| 31 | +#endif |
| 32 | + |
| 33 | +// Check if SPIR-V builtins are supported. |
| 34 | +// As the translator doesn't use the LLVM intrinsics (which would be emitted if |
| 35 | +// we use the SPIR-V builtins) we can't rely on the SPIRV32/SPIRV64 etc macros |
| 36 | +// to establish if we can use the builtin alias. We disable builtin altogether |
| 37 | +// if we do not intent to use the backend. So instead of use target macros, rely |
| 38 | +// on a __has_builtin test. |
| 39 | +#if (__has_builtin(__builtin_spirv_generic_cast_to_ptr_explicit)) |
| 40 | +#define __SPIRV_BUILTIN_ALIAS(builtin) \ |
| 41 | + __attribute__((clang_builtin_alias(builtin))) |
| 42 | +#else |
| 43 | +#define __SPIRV_BUILTIN_ALIAS(builtin) |
| 44 | +#endif |
| 45 | + |
| 46 | +// OpGenericCastToPtrExplicit |
| 47 | + |
| 48 | +extern __SPIRV_overloadable |
| 49 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 50 | +__global void *__spirv_GenericCastToPtrExplicit_ToGlobal(__generic void *, |
| 51 | + int) __SPIRV_NOEXCEPT; |
| 52 | +extern __SPIRV_overloadable |
| 53 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 54 | +__global const void * |
| 55 | +__spirv_GenericCastToPtrExplicit_ToGlobal(__generic const void *, |
| 56 | + int) __SPIRV_NOEXCEPT; |
| 57 | +extern __SPIRV_overloadable |
| 58 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 59 | +__global volatile void * |
| 60 | +__spirv_GenericCastToPtrExplicit_ToGlobal(__generic volatile void *, |
| 61 | + int) __SPIRV_NOEXCEPT; |
| 62 | +extern __SPIRV_overloadable |
| 63 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 64 | +__global const volatile void * |
| 65 | +__spirv_GenericCastToPtrExplicit_ToGlobal(__generic const volatile void *, |
| 66 | + int) __SPIRV_NOEXCEPT; |
| 67 | +extern __SPIRV_overloadable |
| 68 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 69 | +__local void *__spirv_GenericCastToPtrExplicit_ToLocal(__generic void *, |
| 70 | + int) __SPIRV_NOEXCEPT; |
| 71 | +extern __SPIRV_overloadable |
| 72 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 73 | +__local const void * |
| 74 | +__spirv_GenericCastToPtrExplicit_ToLocal(__generic const void *, |
| 75 | + int) __SPIRV_NOEXCEPT; |
| 76 | +extern __SPIRV_overloadable |
| 77 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 78 | +__local volatile void * |
| 79 | +__spirv_GenericCastToPtrExplicit_ToLocal(__generic volatile void *, |
| 80 | + int) __SPIRV_NOEXCEPT; |
| 81 | +extern __SPIRV_overloadable |
| 82 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 83 | +__local const volatile void * |
| 84 | +__spirv_GenericCastToPtrExplicit_ToLocal(__generic const volatile void *, |
| 85 | + int) __SPIRV_NOEXCEPT; |
| 86 | +extern __SPIRV_overloadable |
| 87 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 88 | +__private void * |
| 89 | +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic void *, |
| 90 | + int) __SPIRV_NOEXCEPT; |
| 91 | +extern __SPIRV_overloadable |
| 92 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 93 | +__private const void * |
| 94 | +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic const void *, |
| 95 | + int) __SPIRV_NOEXCEPT; |
| 96 | +extern __SPIRV_overloadable |
| 97 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 98 | +__private volatile void * |
| 99 | +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic volatile void *, |
| 100 | + int) __SPIRV_NOEXCEPT; |
| 101 | +extern __SPIRV_overloadable |
| 102 | +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) |
| 103 | +__private const volatile void * |
| 104 | +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic const volatile void *, |
| 105 | + int) __SPIRV_NOEXCEPT; |
| 106 | + |
| 107 | +// OpGenericCastToPtr |
| 108 | + |
| 109 | +static __SPIRV_overloadable __SPIRV_inline __global void * |
| 110 | +__spirv_GenericCastToPtr_ToGlobal(__generic void *p, int) __SPIRV_NOEXCEPT { |
| 111 | + return (__global void *)p; |
| 112 | +} |
| 113 | +static __SPIRV_overloadable __SPIRV_inline __global const void * |
| 114 | +__spirv_GenericCastToPtr_ToGlobal(__generic const void *p, |
| 115 | + int) __SPIRV_NOEXCEPT { |
| 116 | + return (__global const void *)p; |
| 117 | +} |
| 118 | +static __SPIRV_overloadable __SPIRV_inline __global volatile void * |
| 119 | +__spirv_GenericCastToPtr_ToGlobal(__generic volatile void *p, |
| 120 | + int) __SPIRV_NOEXCEPT { |
| 121 | + return (__global volatile void *)p; |
| 122 | +} |
| 123 | +static __SPIRV_overloadable __SPIRV_inline __global const volatile void * |
| 124 | +__spirv_GenericCastToPtr_ToGlobal(__generic const volatile void *p, |
| 125 | + int) __SPIRV_NOEXCEPT { |
| 126 | + return (__global const volatile void *)p; |
| 127 | +} |
| 128 | +static __SPIRV_overloadable __SPIRV_inline __local void * |
| 129 | +__spirv_GenericCastToPtr_ToLocal(__generic void *p, int) __SPIRV_NOEXCEPT { |
| 130 | + return (__local void *)p; |
| 131 | +} |
| 132 | +static __SPIRV_overloadable __SPIRV_inline __local const void * |
| 133 | +__spirv_GenericCastToPtr_ToLocal(__generic const void *p, |
| 134 | + int) __SPIRV_NOEXCEPT { |
| 135 | + return (__local const void *)p; |
| 136 | +} |
| 137 | +static __SPIRV_overloadable __SPIRV_inline __local volatile void * |
| 138 | +__spirv_GenericCastToPtr_ToLocal(__generic volatile void *p, |
| 139 | + int) __SPIRV_NOEXCEPT { |
| 140 | + return (__local volatile void *)p; |
| 141 | +} |
| 142 | +static __SPIRV_overloadable __SPIRV_inline __local const volatile void * |
| 143 | +__spirv_GenericCastToPtr_ToLocal(__generic const volatile void *p, |
| 144 | + int) __SPIRV_NOEXCEPT { |
| 145 | + return (__local const volatile void *)p; |
| 146 | +} |
| 147 | +static __SPIRV_overloadable __SPIRV_inline __private void * |
| 148 | +__spirv_GenericCastToPtr_ToPrivate(__generic void *p, int) __SPIRV_NOEXCEPT { |
| 149 | + return (__private void *)p; |
| 150 | +} |
| 151 | +static __SPIRV_overloadable __SPIRV_inline __private const void * |
| 152 | +__spirv_GenericCastToPtr_ToPrivate(__generic const void *p, |
| 153 | + int) __SPIRV_NOEXCEPT { |
| 154 | + return (__private const void *)p; |
| 155 | +} |
| 156 | +static __SPIRV_overloadable __SPIRV_inline __private volatile void * |
| 157 | +__spirv_GenericCastToPtr_ToPrivate(__generic volatile void *p, |
| 158 | + int) __SPIRV_NOEXCEPT { |
| 159 | + return (__private volatile void *)p; |
| 160 | +} |
| 161 | +static __SPIRV_overloadable __SPIRV_inline __private const volatile void * |
| 162 | +__spirv_GenericCastToPtr_ToPrivate(__generic const volatile void *p, |
| 163 | + int) __SPIRV_NOEXCEPT { |
| 164 | + return (__private const volatile void *)p; |
| 165 | +} |
| 166 | + |
| 167 | +#undef __SPIRV_overloadable |
| 168 | +#undef __SPIRV_convergent |
| 169 | +#undef __SPIRV_inline |
| 170 | + |
| 171 | +#undef __global |
| 172 | +#undef __local |
| 173 | +#undef __constant |
| 174 | +#undef __generic |
| 175 | + |
| 176 | +#undef __SPIRV_BUILTIN_ALIAS |
| 177 | +#undef __SPIRV_NOEXCEPT |
| 178 | + |
| 179 | +#endif /* __SPIRV_BUILTIN_VARS_H */ |
0 commit comments