[Flang] remove whole-archive option for AIX linker (#76039)
[llvm-project.git] / clang / lib / Headers / openmp_wrappers / __clang_openmp_device_functions.h
blobd5b6846b034885964e007cd1acfd5a61ee89c747
1 /*===- __clang_openmp_device_functions.h - OpenMP device function declares -===
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
7 *===-----------------------------------------------------------------------===
8 */
10 #ifndef __CLANG_OPENMP_DEVICE_FUNCTIONS_H__
11 #define __CLANG_OPENMP_DEVICE_FUNCTIONS_H__
13 #ifndef _OPENMP
14 #error "This file is for OpenMP compilation only."
15 #endif
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
21 #pragma omp begin declare variant match( \
22 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
24 #define __CUDA__
25 #define __OPENMP_NVPTX__
27 /// Include declarations for libdevice functions.
28 #include <__clang_cuda_libdevice_declares.h>
30 /// Provide definitions for these functions.
31 #include <__clang_cuda_device_functions.h>
33 #undef __OPENMP_NVPTX__
34 #undef __CUDA__
36 #pragma omp end declare variant
38 #ifdef __AMDGCN__
39 #pragma omp begin declare variant match(device = {arch(amdgcn)})
41 // Import types which will be used by __clang_hip_libdevice_declares.h
42 #ifndef __cplusplus
43 #include <stdint.h>
44 #endif
46 #define __OPENMP_AMDGCN__
47 #pragma push_macro("__device__")
48 #define __device__
50 /// Include declarations for libdevice functions.
51 #include <__clang_hip_libdevice_declares.h>
53 #pragma pop_macro("__device__")
54 #undef __OPENMP_AMDGCN__
56 #pragma omp end declare variant
57 #endif
59 #ifdef __cplusplus
60 } // extern "C"
61 #endif
63 // Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the
64 // need to `include <new>` in C++ mode.
65 #ifdef __cplusplus
67 // We require malloc/free.
68 #include <cstdlib>
70 #pragma push_macro("OPENMP_NOEXCEPT")
71 #if __cplusplus >= 201103L
72 #define OPENMP_NOEXCEPT noexcept
73 #else
74 #define OPENMP_NOEXCEPT
75 #endif
77 // Device overrides for non-placement new and delete.
78 inline void *operator new(__SIZE_TYPE__ size) {
79 if (size == 0)
80 size = 1;
81 return ::malloc(size);
84 inline void *operator new[](__SIZE_TYPE__ size) { return ::operator new(size); }
86 inline void operator delete(void *ptr)OPENMP_NOEXCEPT { ::free(ptr); }
88 inline void operator delete[](void *ptr) OPENMP_NOEXCEPT {
89 ::operator delete(ptr);
92 // Sized delete, C++14 only.
93 #if __cplusplus >= 201402L
94 inline void operator delete(void *ptr, __SIZE_TYPE__ size)OPENMP_NOEXCEPT {
95 ::operator delete(ptr);
97 inline void operator delete[](void *ptr, __SIZE_TYPE__ size) OPENMP_NOEXCEPT {
98 ::operator delete(ptr);
100 #endif
102 #pragma pop_macro("OPENMP_NOEXCEPT")
103 #endif
105 #endif