[libclc] [NFC][libclc] Merge atomic extension built-ins with identical name into a single file (PR #134489)
Wenju He via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 5 02:24:05 PDT 2025
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/134489
Similar to how cl_khr_fp64 and cl_khr_fp16 implementations are put in a same file for math built-ins, this PR do the same to atom_* built-ins.
The main motivation is to prevent that two files with same base name implementats different built-ins. In a follow-up PR, I'd like to relax libclc_configure_lib_source to only compare filename instead of path for overriding, since in our downstream the same category of built-ins, e.g. math, are organized in several different folders.
>From 310f537cb36fdb6cfe208860ad9c149c4a0c372a Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Sat, 5 Apr 2025 02:08:28 -0700
Subject: [PATCH] [NFC][libclc] Merge atomic extension built-ins with identical
name into a single file
Similar to how cl_khr_fp64 and cl_khr_fp16 implementations are put in a
same file for math built-ins, this PR do the same to atom_* built-ins.
The main motivation is to prevent that two files with same base name
implementats different built-ins. In a follow-up PR, I'd like to relax
libclc_configure_lib_source to only compare filename instead of path for
overriding, since in our downstream the same category of built-ins, e.g.
math, are organized in several different folders.
---
.../atom_add.h | 12 +++-
.../atom_and.h | 12 +++-
.../generic/include/clc/atomic/atom_cmpxchg.h | 36 +++++++++++
.../atom_dec.h | 15 ++++-
.../clc/{ => atomic}/atom_decl_int32.inc | 7 +-
.../clc/{ => atomic}/atom_decl_int64.inc | 7 +-
.../atom_inc.h | 15 ++++-
.../atom_max.h | 13 +++-
.../atom_min.h | 12 +++-
.../atom_or.h | 12 +++-
.../atom_sub.h | 12 +++-
.../atom_xchg.h | 12 +++-
.../atom_xor.h | 12 +++-
.../atom_cmpxchg.h | 10 ---
.../atom_dec.h | 10 ---
.../atom_inc.h | 10 ---
.../clc/cl_khr_int64_base_atomics/atom_add.h | 10 ---
.../cl_khr_int64_base_atomics/atom_cmpxchg.h | 12 ----
.../clc/cl_khr_int64_base_atomics/atom_sub.h | 10 ---
.../clc/cl_khr_int64_base_atomics/atom_xchg.h | 10 ---
.../cl_khr_int64_extended_atomics/atom_and.h | 10 ---
.../cl_khr_int64_extended_atomics/atom_max.h | 10 ---
.../cl_khr_int64_extended_atomics/atom_min.h | 10 ---
.../cl_khr_int64_extended_atomics/atom_or.h | 10 ---
.../cl_khr_int64_extended_atomics/atom_xor.h | 10 ---
.../atom_add.h | 11 ----
.../atom_cmpxchg.h | 10 ---
.../atom_dec.h | 10 ---
.../atom_inc.h | 10 ---
.../atom_sub.h | 11 ----
.../atom_xchg.h | 11 ----
.../atom_and.h | 11 ----
.../atom_max.h | 11 ----
.../atom_min.h | 11 ----
.../atom_or.h | 11 ----
.../atom_xor.h | 11 ----
libclc/generic/include/clc/clc.h | 64 +++++--------------
libclc/generic/lib/SOURCES | 46 ++++---------
.../atom_add.cl | 14 +++-
.../atom_and.cl | 14 +++-
.../atom_cmpxchg.cl | 25 +++++++-
.../atom_dec.cl | 26 +++++++-
.../atom_inc.cl | 26 +++++++-
.../lib/{ => atomic}/atom_int32_binary.inc | 9 +--
.../atom_max.cl | 14 +++-
.../atom_min.cl | 14 +++-
.../atom_or.cl | 12 +++-
.../atom_sub.cl | 14 +++-
.../atom_xchg.cl | 14 +++-
.../atom_xor.cl | 12 +++-
.../atom_add.cl | 11 ----
.../atom_cmpxchg.cl | 17 -----
.../atom_dec.cl | 17 -----
.../atom_inc.cl | 17 -----
.../atom_sub.cl | 11 ----
.../atom_xchg.cl | 11 ----
.../atom_and.cl | 11 ----
.../atom_max.cl | 11 ----
.../atom_min.cl | 11 ----
.../atom_or.cl | 11 ----
.../atom_xor.cl | 11 ----
.../atom_add.cl | 11 ----
.../atom_cmpxchg.cl | 17 -----
.../atom_dec.cl | 17 -----
.../atom_inc.cl | 17 -----
.../atom_sub.cl | 11 ----
.../atom_xchg.cl | 11 ----
.../atom_and.cl | 11 ----
.../atom_max.cl | 11 ----
.../atom_min.cl | 11 ----
.../atom_or.cl | 11 ----
.../atom_xor.cl | 11 ----
72 files changed, 361 insertions(+), 638 deletions(-)
rename libclc/generic/include/clc/{cl_khr_global_int32_base_atomics => atomic}/atom_add.h (57%)
rename libclc/generic/include/clc/{cl_khr_global_int32_extended_atomics => atomic}/atom_and.h (56%)
create mode 100644 libclc/generic/include/clc/atomic/atom_cmpxchg.h
rename libclc/generic/include/clc/{cl_khr_int64_base_atomics => atomic}/atom_dec.h (52%)
rename libclc/generic/include/clc/{ => atomic}/atom_decl_int32.inc (73%)
rename libclc/generic/include/clc/{ => atomic}/atom_decl_int64.inc (74%)
rename libclc/generic/include/clc/{cl_khr_int64_base_atomics => atomic}/atom_inc.h (52%)
rename libclc/generic/include/clc/{cl_khr_global_int32_extended_atomics => atomic}/atom_max.h (54%)
rename libclc/generic/include/clc/{cl_khr_global_int32_extended_atomics => atomic}/atom_min.h (56%)
rename libclc/generic/include/clc/{cl_khr_global_int32_extended_atomics => atomic}/atom_or.h (56%)
rename libclc/generic/include/clc/{cl_khr_global_int32_base_atomics => atomic}/atom_sub.h (57%)
rename libclc/generic/include/clc/{cl_khr_global_int32_base_atomics => atomic}/atom_xchg.h (57%)
rename libclc/generic/include/clc/{cl_khr_global_int32_extended_atomics => atomic}/atom_xor.h (56%)
delete mode 100644 libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
delete mode 100644 libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h
delete mode 100644 libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h
delete mode 100644 libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_xchg.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_and.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_max.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_min.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_or.h
delete mode 100644 libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_xor.h
rename libclc/generic/lib/{cl_khr_int64_base_atomics => atomic}/atom_add.cl (65%)
rename libclc/generic/lib/{cl_khr_int64_extended_atomics => atomic}/atom_and.cl (64%)
rename libclc/generic/lib/{cl_khr_int64_base_atomics => atomic}/atom_cmpxchg.cl (54%)
rename libclc/generic/lib/{cl_khr_int64_base_atomics => atomic}/atom_dec.cl (54%)
rename libclc/generic/lib/{cl_khr_int64_base_atomics => atomic}/atom_inc.cl (54%)
rename libclc/generic/lib/{ => atomic}/atom_int32_binary.inc (64%)
rename libclc/generic/lib/{cl_khr_int64_extended_atomics => atomic}/atom_max.cl (74%)
rename libclc/generic/lib/{cl_khr_int64_extended_atomics => atomic}/atom_min.cl (74%)
rename libclc/generic/lib/{cl_khr_int64_extended_atomics => atomic}/atom_or.cl (67%)
rename libclc/generic/lib/{cl_khr_int64_base_atomics => atomic}/atom_sub.cl (65%)
rename libclc/generic/lib/{cl_khr_int64_base_atomics => atomic}/atom_xchg.cl (64%)
rename libclc/generic/lib/{cl_khr_int64_extended_atomics => atomic}/atom_xor.cl (67%)
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl
delete mode 100644 libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl
delete mode 100644 libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h b/libclc/generic/include/clc/atomic/atom_add.h
similarity index 57%
rename from libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h
rename to libclc/generic/include/clc/atomic/atom_add.h
index db6c09f563a38..05797b6eabe2e 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h
+++ b/libclc/generic/include/clc/atomic/atom_add.h
@@ -6,6 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_base_atomics
#define __CLC_FUNCTION atom_add
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_base_atomics
+#define __CLC_FUNCTION atom_add
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_base_atomics
+#define __CLC_FUNCTION atom_add
+#include <clc/atomic/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_and.h b/libclc/generic/include/clc/atomic/atom_and.h
similarity index 56%
rename from libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_and.h
rename to libclc/generic/include/clc/atomic/atom_and.h
index 0d8c316d8f7fd..fd8435d07ef0d 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_and.h
+++ b/libclc/generic/include/clc/atomic/atom_and.h
@@ -6,6 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_extended_atomics
#define __CLC_FUNCTION atom_and
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_FUNCTION atom_and
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_extended_atomics
+#define __CLC_FUNCTION atom_and
+#include <clc/atomic/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/atomic/atom_cmpxchg.h b/libclc/generic/include/clc/atomic/atom_cmpxchg.h
new file mode 100644
index 0000000000000..e737e1858592e
--- /dev/null
+++ b/libclc/generic/include/clc/atomic/atom_cmpxchg.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <clc/clcfunc.h>
+#include <clc/clctypes.h>
+
+// cl_khr_global_int32_base_atomics
+_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile global int *p, int cmp,
+ int val);
+_CLC_OVERLOAD _CLC_DECL unsigned int
+atom_cmpxchg(volatile global unsigned int *p, unsigned int cmp,
+ unsigned int val);
+
+// cl_khr_local_int32_base_atomics
+_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile local int *p, int cmp,
+ int val);
+_CLC_OVERLOAD _CLC_DECL unsigned int
+atom_cmpxchg(volatile local unsigned int *p, unsigned int cmp,
+ unsigned int val);
+
+// cl_khr_int64_base_atomics
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile global long *p, long cmp,
+ long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long
+atom_cmpxchg(volatile global unsigned long *p, unsigned long cmp,
+ unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile local long *p, long cmp,
+ long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long
+atom_cmpxchg(volatile local unsigned long *p, unsigned long cmp,
+ unsigned long val);
diff --git a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h b/libclc/generic/include/clc/atomic/atom_dec.h
similarity index 52%
rename from libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
rename to libclc/generic/include/clc/atomic/atom_dec.h
index 4bf4e4eae5866..cc5f94e828613 100644
--- a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
+++ b/libclc/generic/include/clc/atomic/atom_dec.h
@@ -6,7 +6,20 @@
//
//===----------------------------------------------------------------------===//
+#include <clc/clcfunc.h>
+#include <clc/clctypes.h>
+
+// cl_khr_global_int32_base_atomics
+_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile global int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile global unsigned int *p);
+
+// cl_khr_local_int32_base_atomics
+_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile local int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile local unsigned int *p);
+
+// cl_khr_int64_base_atomics
_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile global long *p);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile global unsigned long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long
+atom_dec(volatile global unsigned long *p);
_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile local long *p);
_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile local unsigned long *p);
diff --git a/libclc/generic/include/clc/atom_decl_int32.inc b/libclc/generic/include/clc/atomic/atom_decl_int32.inc
similarity index 73%
rename from libclc/generic/include/clc/atom_decl_int32.inc
rename to libclc/generic/include/clc/atomic/atom_decl_int32.inc
index 6b666c58e99be..866d8903db816 100644
--- a/libclc/generic/include/clc/atom_decl_int32.inc
+++ b/libclc/generic/include/clc/atomic/atom_decl_int32.inc
@@ -6,8 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
- _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, TYPE);
+#include <clc/clcfunc.h>
+#include <clc/clctypes.h>
+
+#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
+ _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION(volatile ADDRSPACE TYPE *, TYPE);
__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, int)
__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, uint)
diff --git a/libclc/generic/include/clc/atom_decl_int64.inc b/libclc/generic/include/clc/atomic/atom_decl_int64.inc
similarity index 74%
rename from libclc/generic/include/clc/atom_decl_int64.inc
rename to libclc/generic/include/clc/atomic/atom_decl_int64.inc
index f015cda424970..146de3412fc2e 100644
--- a/libclc/generic/include/clc/atom_decl_int64.inc
+++ b/libclc/generic/include/clc/atomic/atom_decl_int64.inc
@@ -6,8 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
- _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, TYPE);
+#include <clc/clcfunc.h>
+#include <clc/clctypes.h>
+
+#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
+ _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION(volatile ADDRSPACE TYPE *, TYPE);
__CLC_DECLARE_ATOM(local, long)
__CLC_DECLARE_ATOM(local, ulong)
diff --git a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h b/libclc/generic/include/clc/atomic/atom_inc.h
similarity index 52%
rename from libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
rename to libclc/generic/include/clc/atomic/atom_inc.h
index d7a034640d420..093ae8a07d506 100644
--- a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
+++ b/libclc/generic/include/clc/atomic/atom_inc.h
@@ -6,7 +6,20 @@
//
//===----------------------------------------------------------------------===//
+#include <clc/clcfunc.h>
+#include <clc/clctypes.h>
+
+// cl_khr_global_int32_base_atomics
+_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile global int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile global unsigned int *p);
+
+// cl_khr_local_int32_base_atomics
+_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile local int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile local unsigned int *p);
+
+// cl_khr_int64_base_atomics
_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile global long *p);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile global unsigned long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long
+atom_inc(volatile global unsigned long *p);
_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile local long *p);
_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile local unsigned long *p);
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_max.h b/libclc/generic/include/clc/atomic/atom_max.h
similarity index 54%
rename from libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_max.h
rename to libclc/generic/include/clc/atomic/atom_max.h
index f3af2eabd86e3..63bc91e4cd94e 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_max.h
+++ b/libclc/generic/include/clc/atomic/atom_max.h
@@ -6,6 +6,17 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_extended_atomics
#define __CLC_FUNCTION atom_max
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_FUNCTION atom_max
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_extended_atomics
+#define __CLC_FUNCTION atom_max
+#include <clc/atomic/atom_decl_int64.inc>
+#undef __CLC_FUNCTION
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_min.h b/libclc/generic/include/clc/atomic/atom_min.h
similarity index 56%
rename from libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_min.h
rename to libclc/generic/include/clc/atomic/atom_min.h
index e8418e161abfe..df91a6376d339 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_min.h
+++ b/libclc/generic/include/clc/atomic/atom_min.h
@@ -6,6 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_extended_atomics
#define __CLC_FUNCTION atom_min
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_FUNCTION atom_min
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_extended_atomics
+#define __CLC_FUNCTION atom_min
+#include <clc/atomic/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_or.h b/libclc/generic/include/clc/atomic/atom_or.h
similarity index 56%
rename from libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_or.h
rename to libclc/generic/include/clc/atomic/atom_or.h
index 34771728779c8..ef31f51ec1bd0 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_or.h
+++ b/libclc/generic/include/clc/atomic/atom_or.h
@@ -6,6 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_extended_atomics
#define __CLC_FUNCTION atom_or
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_FUNCTION atom_or
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_extended_atomics
+#define __CLC_FUNCTION atom_or
+#include <clc/atomic/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h b/libclc/generic/include/clc/atomic/atom_sub.h
similarity index 57%
rename from libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h
rename to libclc/generic/include/clc/atomic/atom_sub.h
index 81dab4926eaf1..0cc35a423c804 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h
+++ b/libclc/generic/include/clc/atomic/atom_sub.h
@@ -6,6 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_base_atomics
#define __CLC_FUNCTION atom_sub
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_base_atomics
+#define __CLC_FUNCTION atom_sub
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_base_atomics
+#define __CLC_FUNCTION atom_sub
+#include <clc/atomic/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h b/libclc/generic/include/clc/atomic/atom_xchg.h
similarity index 57%
rename from libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h
rename to libclc/generic/include/clc/atomic/atom_xchg.h
index 8964b9c151513..302f6821d20ab 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h
+++ b/libclc/generic/include/clc/atomic/atom_xchg.h
@@ -6,6 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_base_atomics
#define __CLC_FUNCTION atom_xchg
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_base_atomics
+#define __CLC_FUNCTION atom_xchg
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_base_atomics
+#define __CLC_FUNCTION atom_xchg
+#include <clc/atomic/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_xor.h b/libclc/generic/include/clc/atomic/atom_xor.h
similarity index 56%
rename from libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_xor.h
rename to libclc/generic/include/clc/atomic/atom_xor.h
index 17ca2e9f37c64..ed7fac0de8e85 100644
--- a/libclc/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_xor.h
+++ b/libclc/generic/include/clc/atomic/atom_xor.h
@@ -6,6 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// cl_khr_global_int32_extended_atomics
#define __CLC_FUNCTION atom_xor
#define __CLC_ADDRESS_SPACE global
-#include <clc/atom_decl_int32.inc>
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_FUNCTION atom_xor
+#define __CLC_ADDRESS_SPACE local
+#include <clc/atomic/atom_decl_int32.inc>
+
+// cl_khr_int64_extended_atomics
+#define __CLC_FUNCTION atom_xor
+#include <clc/atomic/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h b/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
deleted file mode 100644
index b8b68aff758bb..0000000000000
--- a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile global int *p, int cmp, int val);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_cmpxchg(volatile global unsigned int *p, unsigned int cmp, unsigned int val);
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h b/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h
deleted file mode 100644
index f0576422f1ed6..0000000000000
--- a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile global int *p);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile global unsigned int *p);
diff --git a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h b/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h
deleted file mode 100644
index f68758fa1561d..0000000000000
--- a/libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile global int *p);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile global unsigned int *p);
diff --git a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h b/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
deleted file mode 100644
index 427006d0d57c6..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_add
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h b/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
deleted file mode 100644
index 3e5317c22b8a1..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
+++ /dev/null
@@ -1,12 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile global long *p, long cmp, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile global unsigned long *p, unsigned long cmp, unsigned long val);
-_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile local long *p, long cmp, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile local unsigned long *p, unsigned long cmp, unsigned long val);
diff --git a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h b/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
deleted file mode 100644
index 064801815dc95..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_sub
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h b/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
deleted file mode 100644
index 4d4f3e3bcb774..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_xchg
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h b/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
deleted file mode 100644
index 5077e626488b9..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_and
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h b/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h
deleted file mode 100644
index 5d338f82f7522..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_max
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h b/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h
deleted file mode 100644
index e3baeaf205266..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_min
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h b/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h
deleted file mode 100644
index 14d244ea55e3f..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_or
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h b/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h
deleted file mode 100644
index 0506fd4527e37..0000000000000
--- a/libclc/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_xor
-#include <clc/atom_decl_int64.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h b/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h
deleted file mode 100644
index f681615c02ce9..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_add
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h b/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h
deleted file mode 100644
index 3b339e4a8d85f..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile local int *p, int cmp, int val);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_cmpxchg(volatile local unsigned int *p, unsigned int cmp, unsigned int val);
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h b/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h
deleted file mode 100644
index 89a6b3528f2b3..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile local int *p);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile local unsigned int *p);
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h b/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h
deleted file mode 100644
index 1af31cea1521d..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h
+++ /dev/null
@@ -1,10 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile local int *p);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile local unsigned int *p);
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h b/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h
deleted file mode 100644
index ef74a3def7abd..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_sub
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_xchg.h b/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_xchg.h
deleted file mode 100644
index 8a7662ffc9dbf..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_base_atomics/atom_xchg.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_xchg
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_and.h b/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_and.h
deleted file mode 100644
index a6aa525df2bde..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_and.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_and
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_max.h b/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_max.h
deleted file mode 100644
index 6b0570a765b11..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_max.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_max
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_min.h b/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_min.h
deleted file mode 100644
index 4286dfb98ffc4..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_min.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_min
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_or.h b/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_or.h
deleted file mode 100644
index 7352fa9b9ef40..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_or.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_or
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_xor.h b/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_xor.h
deleted file mode 100644
index 8696e2b3752b6..0000000000000
--- a/libclc/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_xor.h
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_FUNCTION atom_xor
-#define __CLC_ADDRESS_SPACE local
-#include <clc/atom_decl_int32.inc>
diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h
index 51a4f3413e725..8223b529f09f9 100644
--- a/libclc/generic/include/clc/clc.h
+++ b/libclc/generic/include/clc/clc.h
@@ -239,54 +239,22 @@
#include <clc/atomic/atomic_xchg.h>
#include <clc/atomic/atomic_xor.h>
-/* cl_khr_global_int32_base_atomics Extension Functions */
-#include <clc/cl_khr_global_int32_base_atomics/atom_add.h>
-#include <clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h>
-#include <clc/cl_khr_global_int32_base_atomics/atom_dec.h>
-#include <clc/cl_khr_global_int32_base_atomics/atom_inc.h>
-#include <clc/cl_khr_global_int32_base_atomics/atom_sub.h>
-#include <clc/cl_khr_global_int32_base_atomics/atom_xchg.h>
-
-/* cl_khr_global_int32_extended_atomics Extension Functions */
-#include <clc/cl_khr_global_int32_extended_atomics/atom_and.h>
-#include <clc/cl_khr_global_int32_extended_atomics/atom_max.h>
-#include <clc/cl_khr_global_int32_extended_atomics/atom_min.h>
-#include <clc/cl_khr_global_int32_extended_atomics/atom_or.h>
-#include <clc/cl_khr_global_int32_extended_atomics/atom_xor.h>
-
-/* cl_khr_local_int32_base_atomics Extension Functions */
-#include <clc/cl_khr_local_int32_base_atomics/atom_add.h>
-#include <clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h>
-#include <clc/cl_khr_local_int32_base_atomics/atom_dec.h>
-#include <clc/cl_khr_local_int32_base_atomics/atom_inc.h>
-#include <clc/cl_khr_local_int32_base_atomics/atom_sub.h>
-#include <clc/cl_khr_local_int32_base_atomics/atom_xchg.h>
-
-/* cl_khr_local_int32_extended_atomics Extension Functions */
-#include <clc/cl_khr_local_int32_extended_atomics/atom_and.h>
-#include <clc/cl_khr_local_int32_extended_atomics/atom_max.h>
-#include <clc/cl_khr_local_int32_extended_atomics/atom_min.h>
-#include <clc/cl_khr_local_int32_extended_atomics/atom_or.h>
-#include <clc/cl_khr_local_int32_extended_atomics/atom_xor.h>
-
-/* cl_khr_int64_base_atomics Extension Functions */
-#ifdef cl_khr_int64_base_atomics
-#include <clc/cl_khr_int64_base_atomics/atom_add.h>
-#include <clc/cl_khr_int64_base_atomics/atom_cmpxchg.h>
-#include <clc/cl_khr_int64_base_atomics/atom_dec.h>
-#include <clc/cl_khr_int64_base_atomics/atom_inc.h>
-#include <clc/cl_khr_int64_base_atomics/atom_sub.h>
-#include <clc/cl_khr_int64_base_atomics/atom_xchg.h>
-#endif
-
-/* cl_khr_int64_extended_atomics Extension Functions */
-#ifdef cl_khr_int64_base_atomics
-#include <clc/cl_khr_int64_extended_atomics/atom_and.h>
-#include <clc/cl_khr_int64_extended_atomics/atom_max.h>
-#include <clc/cl_khr_int64_extended_atomics/atom_min.h>
-#include <clc/cl_khr_int64_extended_atomics/atom_or.h>
-#include <clc/cl_khr_int64_extended_atomics/atom_xor.h>
-#endif
+/* cl_khr_global_int32_base_atomics, cl_khr_local_int32_base_atomics and
+ * cl_khr_int64_base_atomics Extension Functions */
+#include <clc/atomic/atom_add.h>
+#include <clc/atomic/atom_cmpxchg.h>
+#include <clc/atomic/atom_dec.h>
+#include <clc/atomic/atom_inc.h>
+#include <clc/atomic/atom_sub.h>
+#include <clc/atomic/atom_xchg.h>
+
+/* cl_khr_global_int32_extended_atomics, cl_khr_local_int32_extended_atomics and
+ * cl_khr_int64_extended_atomics Extension Functions */
+#include <clc/atomic/atom_and.h>
+#include <clc/atomic/atom_max.h>
+#include <clc/atomic/atom_min.h>
+#include <clc/atomic/atom_or.h>
+#include <clc/atomic/atom_xor.h>
/* 6.12.12 Miscellaneous Vector Functions */
#include <clc/misc/shuffle.h>
diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES
index 5f473ff8b9424..1340e08453acf 100644
--- a/libclc/generic/lib/SOURCES
+++ b/libclc/generic/lib/SOURCES
@@ -4,6 +4,17 @@ async/async_work_group_copy.cl
async/async_work_group_strided_copy.cl
async/prefetch.cl
async/wait_group_events.cl
+atomic/atom_add.cl
+atomic/atom_and.cl
+atomic/atom_cmpxchg.cl
+atomic/atom_dec.cl
+atomic/atom_inc.cl
+atomic/atom_max.cl
+atomic/atom_min.cl
+atomic/atom_or.cl
+atomic/atom_sub.cl
+atomic/atom_xchg.cl
+atomic/atom_xor.cl
atomic/atomic_add.cl
atomic/atomic_and.cl
atomic/atomic_cmpxchg.cl
@@ -13,41 +24,8 @@ atomic/atomic_max.cl
atomic/atomic_min.cl
atomic/atomic_or.cl
atomic/atomic_sub.cl
-atomic/atomic_xor.cl
atomic/atomic_xchg.cl
-cl_khr_global_int32_base_atomics/atom_add.cl
-cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
-cl_khr_global_int32_base_atomics/atom_dec.cl
-cl_khr_global_int32_base_atomics/atom_inc.cl
-cl_khr_global_int32_base_atomics/atom_sub.cl
-cl_khr_global_int32_base_atomics/atom_xchg.cl
-cl_khr_global_int32_extended_atomics/atom_and.cl
-cl_khr_global_int32_extended_atomics/atom_max.cl
-cl_khr_global_int32_extended_atomics/atom_min.cl
-cl_khr_global_int32_extended_atomics/atom_or.cl
-cl_khr_global_int32_extended_atomics/atom_xor.cl
-cl_khr_local_int32_base_atomics/atom_add.cl
-cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
-cl_khr_local_int32_base_atomics/atom_dec.cl
-cl_khr_local_int32_base_atomics/atom_inc.cl
-cl_khr_local_int32_base_atomics/atom_sub.cl
-cl_khr_local_int32_base_atomics/atom_xchg.cl
-cl_khr_local_int32_extended_atomics/atom_and.cl
-cl_khr_local_int32_extended_atomics/atom_max.cl
-cl_khr_local_int32_extended_atomics/atom_min.cl
-cl_khr_local_int32_extended_atomics/atom_or.cl
-cl_khr_local_int32_extended_atomics/atom_xor.cl
-cl_khr_int64_base_atomics/atom_add.cl
-cl_khr_int64_base_atomics/atom_cmpxchg.cl
-cl_khr_int64_base_atomics/atom_dec.cl
-cl_khr_int64_base_atomics/atom_inc.cl
-cl_khr_int64_base_atomics/atom_sub.cl
-cl_khr_int64_base_atomics/atom_xchg.cl
-cl_khr_int64_extended_atomics/atom_and.cl
-cl_khr_int64_extended_atomics/atom_max.cl
-cl_khr_int64_extended_atomics/atom_min.cl
-cl_khr_int64_extended_atomics/atom_or.cl
-cl_khr_int64_extended_atomics/atom_xor.cl
+atomic/atomic_xor.cl
common/degrees.cl
common/mix.cl
common/radians.cl
diff --git a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_add.cl b/libclc/generic/lib/atomic/atom_add.cl
similarity index 65%
rename from libclc/generic/lib/cl_khr_int64_base_atomics/atom_add.cl
rename to libclc/generic/lib/atomic/atom_add.cl
index e06c21d4acb6c..89650ddf96d21 100644
--- a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_add.cl
+++ b/libclc/generic/lib/atomic/atom_add.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_add.h>
+
+// cl_khr_global_int32_base_atomics
+#define __CLC_ATOMIC_OP add
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_base_atomics
+#define __CLC_ATOMIC_OP add
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_base_atomics
@@ -21,4 +31,4 @@ IMPL(local, long)
IMPL(local, unsigned long)
#undef IMPL
-#endif
+#endif // cl_khr_int64_base_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl b/libclc/generic/lib/atomic/atom_and.cl
similarity index 64%
rename from libclc/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl
rename to libclc/generic/lib/atomic/atom_and.cl
index 4c5dff5608d2d..e683a8bf9d501 100644
--- a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl
+++ b/libclc/generic/lib/atomic/atom_and.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_and.h>
+
+// cl_khr_global_int32_extended_atomics
+#define __CLC_ATOMIC_OP and
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_ATOMIC_OP and
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_extended_atomics
@@ -21,4 +31,4 @@ IMPL(local, long)
IMPL(local, unsigned long)
#undef IMPL
-#endif
+#endif // cl_khr_local_int32_extended_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl b/libclc/generic/lib/atomic/atom_cmpxchg.cl
similarity index 54%
rename from libclc/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl
rename to libclc/generic/lib/atomic/atom_cmpxchg.cl
index 21260103a673b..3d3cff358e3ad 100644
--- a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl
+++ b/libclc/generic/lib/atomic/atom_cmpxchg.cl
@@ -6,7 +6,28 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_cmpxchg.h>
+#include <clc/atomic/atomic_cmpxchg.h>
+
+// cl_khr_global_int32_base_atomics
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile global TYPE *p, TYPE cmp, TYPE val) { \
+ return atomic_cmpxchg(p, cmp, val); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
+#undef IMPL
+
+// cl_khr_local_int32_base_atomics
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile local TYPE *p, TYPE cmp, TYPE val) { \
+ return atomic_cmpxchg(p, cmp, val); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
+#undef IMPL
#ifdef cl_khr_int64_base_atomics
@@ -21,4 +42,4 @@ IMPL(local, long)
IMPL(local, unsigned long)
#undef IMPL
-#endif
+#endif // cl_khr_int64_base_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl b/libclc/generic/lib/atomic/atom_dec.cl
similarity index 54%
rename from libclc/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl
rename to libclc/generic/lib/atomic/atom_dec.cl
index a594f570ca851..926615a9423c3 100644
--- a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl
+++ b/libclc/generic/lib/atomic/atom_dec.cl
@@ -6,7 +6,29 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_dec.h>
+#include <clc/atomic/atom_sub.h>
+#include <clc/atomic/atomic_dec.h>
+
+// cl_khr_global_int32_base_atomics
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(volatile global TYPE *p) { \
+ return atomic_dec(p); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
+#undef IMPL
+
+// cl_khr_local_int32_base_atomics
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(volatile local TYPE *p) { \
+ return atomic_dec(p); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
+#undef IMPL
#ifdef cl_khr_int64_base_atomics
@@ -21,4 +43,4 @@ IMPL(local, long)
IMPL(local, unsigned long)
#undef IMPL
-#endif
+#endif // cl_khr_int64_base_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl b/libclc/generic/lib/atomic/atom_inc.cl
similarity index 54%
rename from libclc/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl
rename to libclc/generic/lib/atomic/atom_inc.cl
index 2aa2f9d790770..d90480882ed82 100644
--- a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl
+++ b/libclc/generic/lib/atomic/atom_inc.cl
@@ -6,7 +6,29 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_inc.h>
+#include <clc/atomic/atom_add.h>
+#include <clc/atomic/atomic_inc.h>
+
+// cl_khr_global_int32_base_atomics
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(volatile global TYPE *p) { \
+ return atomic_inc(p); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
+#undef IMPL
+
+// cl_khr_local_int32_base_atomics
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(volatile local TYPE *p) { \
+ return atomic_inc(p); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
+#undef IMPL
#ifdef cl_khr_int64_base_atomics
@@ -21,4 +43,4 @@ IMPL(local, long)
IMPL(local, unsigned long)
#undef IMPL
-#endif
+#endif // cl_khr_int64_base_atomics
diff --git a/libclc/generic/lib/atom_int32_binary.inc b/libclc/generic/lib/atomic/atom_int32_binary.inc
similarity index 64%
rename from libclc/generic/lib/atom_int32_binary.inc
rename to libclc/generic/lib/atomic/atom_int32_binary.inc
index dac9d19842dcb..81e6a8ebc7c8a 100644
--- a/libclc/generic/lib/atom_int32_binary.inc
+++ b/libclc/generic/lib/atomic/atom_int32_binary.inc
@@ -9,10 +9,11 @@
#include <clc/clc.h>
#include <clc/utils.h>
-#define __CLC_ATOM_IMPL(AS, TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE __CLC_XCONCAT(atom_, __CLC_ATOMIC_OP) (volatile AS TYPE *p, TYPE val) { \
- return __CLC_XCONCAT(atomic_, __CLC_ATOMIC_OP) (p, val); \
-}
+#define __CLC_ATOM_IMPL(AS, TYPE) \
+ _CLC_OVERLOAD _CLC_DEF TYPE __CLC_XCONCAT(atom_, __CLC_ATOMIC_OP)( \
+ volatile AS TYPE * p, TYPE val) { \
+ return __CLC_XCONCAT(atomic_, __CLC_ATOMIC_OP)(p, val); \
+ }
__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, int)
__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, uint)
diff --git a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl b/libclc/generic/lib/atomic/atom_max.cl
similarity index 74%
rename from libclc/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl
rename to libclc/generic/lib/atomic/atom_max.cl
index 5440f0d89165d..c90da3e0b64c7 100644
--- a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl
+++ b/libclc/generic/lib/atomic/atom_max.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_max.h>
+
+// cl_khr_global_int32_extended_atomics
+#define __CLC_ATOMIC_OP max
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_ATOMIC_OP max
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_extended_atomics
@@ -26,4 +36,4 @@ IMPL(local, long, max)
IMPL(local, unsigned long, umax)
#undef IMPL
-#endif
+#endif // cl_khr_int64_extended_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl b/libclc/generic/lib/atomic/atom_min.cl
similarity index 74%
rename from libclc/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl
rename to libclc/generic/lib/atomic/atom_min.cl
index 27f4112b9d994..5b2ebb2408392 100644
--- a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl
+++ b/libclc/generic/lib/atomic/atom_min.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_min.h>
+
+// cl_khr_global_int32_extended_atomics
+#define __CLC_ATOMIC_OP min
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_ATOMIC_OP min
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_extended_atomics
@@ -26,4 +36,4 @@ IMPL(local, long, min)
IMPL(local, unsigned long, umin)
#undef IMPL
-#endif
+#endif // cl_khr_int64_extended_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl b/libclc/generic/lib/atomic/atom_or.cl
similarity index 67%
rename from libclc/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl
rename to libclc/generic/lib/atomic/atom_or.cl
index b822a77172802..7c3e9d2fcb632 100644
--- a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl
+++ b/libclc/generic/lib/atomic/atom_or.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_or.h>
+
+// cl_khr_global_int32_extended_atomics
+#define __CLC_ATOMIC_OP or
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_ATOMIC_OP or
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_extended_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl b/libclc/generic/lib/atomic/atom_sub.cl
similarity index 65%
rename from libclc/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl
rename to libclc/generic/lib/atomic/atom_sub.cl
index a496c42105065..0eb1b6e06a530 100644
--- a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl
+++ b/libclc/generic/lib/atomic/atom_sub.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_sub.h>
+
+// cl_khr_global_int32_base_atomics
+#define __CLC_ATOMIC_OP sub
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_base_atomics
+#define __CLC_ATOMIC_OP sub
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_base_atomics
@@ -21,4 +31,4 @@ IMPL(local, long)
IMPL(local, unsigned long)
#undef IMPL
-#endif
+#endif // cl_khr_int64_base_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl b/libclc/generic/lib/atomic/atom_xchg.cl
similarity index 64%
rename from libclc/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl
rename to libclc/generic/lib/atomic/atom_xchg.cl
index 0bacfc863f5a4..8d101754eaa7d 100644
--- a/libclc/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl
+++ b/libclc/generic/lib/atomic/atom_xchg.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_xchg.h>
+
+// cl_khr_global_int32_base_atomics
+#define __CLC_ATOMIC_OP xchg
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_base_atomics
+#define __CLC_ATOMIC_OP xchg
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_base_atomics
@@ -21,4 +31,4 @@ IMPL(local, long)
IMPL(local, unsigned long)
#undef IMPL
-#endif
+#endif // cl_khr_int64_base_atomics
diff --git a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl b/libclc/generic/lib/atomic/atom_xor.cl
similarity index 67%
rename from libclc/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl
rename to libclc/generic/lib/atomic/atom_xor.cl
index f1dd28d796d0a..162ae544fa22a 100644
--- a/libclc/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl
+++ b/libclc/generic/lib/atomic/atom_xor.cl
@@ -6,7 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clc.h>
+#include <clc/atomic/atom_xor.h>
+
+// cl_khr_global_int32_extended_atomics
+#define __CLC_ATOMIC_OP xor
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "atom_int32_binary.inc"
+
+// cl_khr_local_int32_extended_atomics
+#define __CLC_ATOMIC_OP xor
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "atom_int32_binary.inc"
#ifdef cl_khr_int64_extended_atomics
diff --git a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl b/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl
deleted file mode 100644
index 6c6c919892aa9..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP add
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl b/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
deleted file mode 100644
index eb78b878109b6..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
+++ /dev/null
@@ -1,17 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile global TYPE *p, TYPE cmp, TYPE val) { \
- return atomic_cmpxchg(p, cmp, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
diff --git a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl b/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
deleted file mode 100644
index 82b77ff31ce87..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
+++ /dev/null
@@ -1,17 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(volatile global TYPE *p) { \
- return atomic_dec(p); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
diff --git a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl b/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
deleted file mode 100644
index f2147ccaf8d65..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
+++ /dev/null
@@ -1,17 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(volatile global TYPE *p) { \
- return atomic_inc(p); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
diff --git a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl b/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl
deleted file mode 100644
index 521d3cc633b30..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP sub
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl b/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl
deleted file mode 100644
index 5e68b489171fe..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP xchg
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl b/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl
deleted file mode 100644
index fbfba0b1b698f..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP and
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl b/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl
deleted file mode 100644
index 78f98d7c19146..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP max
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl b/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl
deleted file mode 100644
index f031585cc246a..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP min
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl b/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl
deleted file mode 100644
index 95aa2c66a3276..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP or
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl b/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl
deleted file mode 100644
index 0613f08654940..0000000000000
--- a/libclc/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP xor
-#define __CLC_ATOMIC_ADDRESS_SPACE global
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl b/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
deleted file mode 100644
index c561cc3f839d9..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP add
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl b/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
deleted file mode 100644
index efa997e5b7021..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
+++ /dev/null
@@ -1,17 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile local TYPE *p, TYPE cmp, TYPE val) { \
- return atomic_cmpxchg(p, cmp, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
diff --git a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl b/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
deleted file mode 100644
index f3b30554ea9c8..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
+++ /dev/null
@@ -1,17 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(volatile local TYPE *p) { \
- return atomic_dec(p); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
diff --git a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl b/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
deleted file mode 100644
index 9660f79046b38..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
+++ /dev/null
@@ -1,17 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(volatile local TYPE *p) { \
- return atomic_inc(p); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
diff --git a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl b/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
deleted file mode 100644
index 44a8703aaa6cb..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP sub
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl b/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl
deleted file mode 100644
index ae6c82036b7a7..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP xchg
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl b/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl
deleted file mode 100644
index c3cfd460338a8..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP and
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl b/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl
deleted file mode 100644
index 80dabbb239a77..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP max
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl b/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl
deleted file mode 100644
index 895dc8a256796..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP min
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl b/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl
deleted file mode 100644
index ee02b942a3397..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP or
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
diff --git a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl b/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl
deleted file mode 100644
index d169899aa0784..0000000000000
--- a/libclc/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl
+++ /dev/null
@@ -1,11 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#define __CLC_ATOMIC_OP xor
-#define __CLC_ATOMIC_ADDRESS_SPACE local
-#include "../atom_int32_binary.inc"
More information about the cfe-commits
mailing list