[PATCH] D98520: [OpenCL] Remove spurious atomic_fetch tablegen builtins
Sven van Haastregt via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 18 05:17:36 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5c4a88a8400: [OpenCL] Remove spurious atomic_fetch tablegen builtins (authored by svenvh).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98520/new/
https://reviews.llvm.org/D98520
Files:
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===================================================================
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -39,6 +39,9 @@
typedef unsigned long ulong;
typedef unsigned short ushort;
typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __INTPTR_TYPE__ intptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
typedef char char2 __attribute__((ext_vector_type(2)));
typedef char char4 __attribute__((ext_vector_type(4)));
typedef uchar uchar4 __attribute__((ext_vector_type(4)));
@@ -98,6 +101,24 @@
size_t ws[2] = {2, 8};
ndrange_t r = ndrange_2D(ws);
}
+
+// Check that atomic_fetch_ functions can be called with (u)intptr_t arguments,
+// despite OpenCLBuiltins.td not providing explicit overloads for those types.
+void test_atomic_fetch(volatile __generic atomic_int *a_int,
+ volatile __generic atomic_intptr_t *a_intptr,
+ volatile __generic atomic_uintptr_t *a_uintptr) {
+ int i;
+ intptr_t ip;
+ uintptr_t uip;
+ ptrdiff_t ptrdiff;
+
+ i = atomic_fetch_add(a_int, i);
+ ip = atomic_fetch_add(a_intptr, ptrdiff);
+ uip = atomic_fetch_add(a_uintptr, ptrdiff);
+
+ ip = atomic_fetch_or(a_intptr, ip);
+ uip = atomic_fetch_or(a_uintptr, uip);
+}
#endif
kernel void basic_conversion() {
Index: clang/lib/Sema/OpenCLBuiltins.td
===================================================================
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -1100,7 +1100,6 @@
foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
[AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
- [AtomicIntPtr, IntPtr, PtrDiff],
[AtomicUIntPtr, UIntPtr, PtrDiff]] in {
foreach ModOp = ["add", "sub"] in {
def : Builtin<"atomic_fetch_" # ModOp,
@@ -1112,9 +1111,7 @@
}
}
foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
- [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
- [AtomicIntPtr, IntPtr, IntPtr],
- [AtomicUIntPtr, UIntPtr, UIntPtr]] in {
+ [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] in {
foreach ModOp = ["or", "xor", "and", "min", "max"] in {
def : Builtin<"atomic_fetch_" # ModOp,
[TypePair[1], PointerType<VolatileType<TypePair[0]>, GenericAS>, TypePair[2]]>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98520.331525.patch
Type: text/x-patch
Size: 2547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210318/9bcf1459/attachment.bin>
More information about the cfe-commits
mailing list