[clang] [libc] [llvm] [OFFLOAD] Add support to build libc for SPIRV backend (PR #181049)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 16 16:26:43 PST 2026
https://github.com/fineg74 updated https://github.com/llvm/llvm-project/pull/181049
>From 329eca02c11370d42e9167692de61e2730cad21a Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Wed, 11 Feb 2026 15:45:17 -0800
Subject: [PATCH 1/7] Add support to build libc for SPIRV backend
---
clang/lib/Headers/llvm_libc_wrappers/assert.h | 4 +-
clang/lib/Headers/llvm_libc_wrappers/ctype.h | 4 +-
.../lib/Headers/llvm_libc_wrappers/inttypes.h | 4 +-
clang/lib/Headers/llvm_libc_wrappers/stdio.h | 6 +-
clang/lib/Headers/llvm_libc_wrappers/stdlib.h | 4 +-
clang/lib/Headers/llvm_libc_wrappers/string.h | 4 +-
clang/lib/Headers/llvm_libc_wrappers/time.h | 4 +-
clang/lib/Headers/openmp_wrappers/new | 2 +-
.../cmake/modules/LLVMLibCArchitectures.cmake | 7 +-
libc/cmake/modules/LLVMLibCLibraryRules.cmake | 8 +-
libc/config/gpu/spirv64/entrypoints.txt | 693 ++++++++++++++++++
libc/config/gpu/spirv64/headers.txt | 21 +
libc/include/llvm-libc-macros/math-macros.h | 2 +-
libc/include/llvm-libc-macros/signal-macros.h | 2 +-
libc/include/llvm-libc-macros/time-macros.h | 2 +-
libc/include/llvm-libc-types/fenv_t.h | 2 +-
libc/shared/rpc_util.h | 2 +-
.../macros/properties/architectures.h | 6 +-
.../macros/properties/cpu_features.h | 4 +-
libc/src/__support/time/gpu/time_utils.cpp | 2 +-
libc/src/__support/time/gpu/time_utils.h | 2 +-
libc/src/math/spirv64/CMakeLists.txt | 303 ++++++++
libc/src/math/spirv64/ceil.cpp | 17 +
libc/src/math/spirv64/ceilf.cpp | 17 +
libc/src/math/spirv64/copysign.cpp | 19 +
libc/src/math/spirv64/copysignf.cpp | 19 +
libc/src/math/spirv64/fabs.cpp | 17 +
libc/src/math/spirv64/fabsf.cpp | 17 +
libc/src/math/spirv64/floor.cpp | 17 +
libc/src/math/spirv64/floorf.cpp | 17 +
libc/src/math/spirv64/fma.cpp | 19 +
libc/src/math/spirv64/fmaf.cpp | 19 +
libc/src/math/spirv64/fmax.cpp | 22 +
libc/src/math/spirv64/fmaxf.cpp | 20 +
libc/src/math/spirv64/fmin.cpp | 20 +
libc/src/math/spirv64/fminf.cpp | 20 +
libc/src/math/spirv64/fmod.cpp | 19 +
libc/src/math/spirv64/fmodf.cpp | 19 +
libc/src/math/spirv64/frexp.cpp | 20 +
libc/src/math/spirv64/frexpf.cpp | 20 +
libc/src/math/spirv64/ldexp.cpp | 20 +
libc/src/math/spirv64/ldexpf.cpp | 20 +
libc/src/math/spirv64/lgamma.cpp | 19 +
libc/src/math/spirv64/lgamma_r.cpp | 21 +
libc/src/math/spirv64/llrint.cpp | 20 +
libc/src/math/spirv64/llrintf.cpp | 20 +
libc/src/math/spirv64/lrint.cpp | 20 +
libc/src/math/spirv64/lrintf.cpp | 20 +
libc/src/math/spirv64/nearbyint.cpp | 19 +
libc/src/math/spirv64/nearbyintf.cpp | 19 +
libc/src/math/spirv64/remainder.cpp | 19 +
libc/src/math/spirv64/remainderf.cpp | 19 +
libc/src/math/spirv64/rint.cpp | 17 +
libc/src/math/spirv64/rintf.cpp | 17 +
libc/src/math/spirv64/round.cpp | 17 +
libc/src/math/spirv64/roundf.cpp | 17 +
libc/src/math/spirv64/scalbn.cpp | 20 +
libc/src/math/spirv64/scalbnf.cpp | 20 +
libc/src/math/spirv64/sqrt.cpp | 17 +
libc/src/math/spirv64/sqrtf.cpp | 17 +
libc/src/math/spirv64/tgamma.cpp | 21 +
libc/src/math/spirv64/tgammaf.cpp | 21 +
libc/src/math/spirv64/trunc.cpp | 17 +
libc/src/math/spirv64/truncf.cpp | 17 +
libc/startup/gpu/CMakeLists.txt | 14 +-
libc/startup/gpu/spirv64/CMakeLists.txt | 16 +
libc/startup/gpu/spirv64/start.cpp | 72 ++
llvm/CMakeLists.txt | 5 +-
68 files changed, 1954 insertions(+), 33 deletions(-)
create mode 100644 libc/config/gpu/spirv64/entrypoints.txt
create mode 100644 libc/config/gpu/spirv64/headers.txt
create mode 100644 libc/src/math/spirv64/CMakeLists.txt
create mode 100644 libc/src/math/spirv64/ceil.cpp
create mode 100644 libc/src/math/spirv64/ceilf.cpp
create mode 100644 libc/src/math/spirv64/copysign.cpp
create mode 100644 libc/src/math/spirv64/copysignf.cpp
create mode 100644 libc/src/math/spirv64/fabs.cpp
create mode 100644 libc/src/math/spirv64/fabsf.cpp
create mode 100644 libc/src/math/spirv64/floor.cpp
create mode 100644 libc/src/math/spirv64/floorf.cpp
create mode 100644 libc/src/math/spirv64/fma.cpp
create mode 100644 libc/src/math/spirv64/fmaf.cpp
create mode 100644 libc/src/math/spirv64/fmax.cpp
create mode 100644 libc/src/math/spirv64/fmaxf.cpp
create mode 100644 libc/src/math/spirv64/fmin.cpp
create mode 100644 libc/src/math/spirv64/fminf.cpp
create mode 100644 libc/src/math/spirv64/fmod.cpp
create mode 100644 libc/src/math/spirv64/fmodf.cpp
create mode 100644 libc/src/math/spirv64/frexp.cpp
create mode 100644 libc/src/math/spirv64/frexpf.cpp
create mode 100644 libc/src/math/spirv64/ldexp.cpp
create mode 100644 libc/src/math/spirv64/ldexpf.cpp
create mode 100644 libc/src/math/spirv64/lgamma.cpp
create mode 100644 libc/src/math/spirv64/lgamma_r.cpp
create mode 100644 libc/src/math/spirv64/llrint.cpp
create mode 100644 libc/src/math/spirv64/llrintf.cpp
create mode 100644 libc/src/math/spirv64/lrint.cpp
create mode 100644 libc/src/math/spirv64/lrintf.cpp
create mode 100644 libc/src/math/spirv64/nearbyint.cpp
create mode 100644 libc/src/math/spirv64/nearbyintf.cpp
create mode 100644 libc/src/math/spirv64/remainder.cpp
create mode 100644 libc/src/math/spirv64/remainderf.cpp
create mode 100644 libc/src/math/spirv64/rint.cpp
create mode 100644 libc/src/math/spirv64/rintf.cpp
create mode 100644 libc/src/math/spirv64/round.cpp
create mode 100644 libc/src/math/spirv64/roundf.cpp
create mode 100644 libc/src/math/spirv64/scalbn.cpp
create mode 100644 libc/src/math/spirv64/scalbnf.cpp
create mode 100644 libc/src/math/spirv64/sqrt.cpp
create mode 100644 libc/src/math/spirv64/sqrtf.cpp
create mode 100644 libc/src/math/spirv64/tgamma.cpp
create mode 100644 libc/src/math/spirv64/tgammaf.cpp
create mode 100644 libc/src/math/spirv64/trunc.cpp
create mode 100644 libc/src/math/spirv64/truncf.cpp
create mode 100644 libc/startup/gpu/spirv64/CMakeLists.txt
create mode 100644 libc/startup/gpu/spirv64/start.cpp
diff --git a/clang/lib/Headers/llvm_libc_wrappers/assert.h b/clang/lib/Headers/llvm_libc_wrappers/assert.h
index 7eadb2c354aab..3d61d5db59c36 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/assert.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/assert.h
@@ -9,7 +9,7 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
@@ -17,7 +17,7 @@
#if __has_include(<llvm-libc-decls/assert.h>)
-#if defined(__HIP__) || defined(__CUDA__)
+#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/ctype.h b/clang/lib/Headers/llvm_libc_wrappers/ctype.h
index 79b0c1e9be953..7879e2fb56db8 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/ctype.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/ctype.h
@@ -9,13 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <ctype.h>
-#if defined(__HIP__) || defined(__CUDA__)
+#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/inttypes.h b/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
index 22613898248f3..e99d3f556ff23 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
@@ -9,7 +9,7 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
@@ -17,7 +17,7 @@
#if __has_include(<llvm-libc-decls/inttypes.h>)
-#if defined(__HIP__) || defined(__CUDA__)
+#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
index 0c3e44823da70..b914c92dd6534 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdio.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
@@ -9,13 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) &&!defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <stdio.h>
-#if defined(__HIP__) || defined(__CUDA__)
+#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
@@ -41,7 +41,7 @@ __LIBC_ATTRS extern FILE *stdout;
#pragma omp end declare target
// Restore the original macros when compiling on the host.
-#if !defined(__NVPTX__) && !defined(__AMDGPU__)
+#if !defined(__NVPTX__) && !defined(__AMDGPU__) && !defined(__SPIRV__)
#pragma pop_macro("stderr")
#pragma pop_macro("stdin")
#pragma pop_macro("stdout")
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdlib.h b/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
index 7af5e2ebe031a..24145c64694da 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
@@ -9,13 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <stdlib.h>
-#if defined(__HIP__) || defined(__CUDA__)
+#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/string.h b/clang/lib/Headers/llvm_libc_wrappers/string.h
index 766a58f5b6db4..78abe2eace942 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/string.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -9,13 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <string.h>
-#if defined(__HIP__) || defined(__CUDA__)
+#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/time.h b/clang/lib/Headers/llvm_libc_wrappers/time.h
index d38eea327a199..9ed8ccc39e72b 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/time.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/time.h
@@ -9,13 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <time.h>
-#if defined(__HIP__) || defined(__CUDA__)
+#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/openmp_wrappers/new b/clang/lib/Headers/openmp_wrappers/new
index 8bad3f19d6251..de40cb9a210a1 100644
--- a/clang/lib/Headers/openmp_wrappers/new
+++ b/clang/lib/Headers/openmp_wrappers/new
@@ -13,7 +13,7 @@
// which do not use nothrow_t are provided without the <new> header.
#include_next <new>
-#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(_OPENMP)
+#if (defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__)) && defined(_OPENMP)
#include <cstdlib>
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 939fc1226a4e9..5f2be539e7169 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -71,10 +71,15 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
# Setting OS name for GPU architectures.
list(GET triple_comps -1 gpu_target_sys)
- if(gpu_target_sys MATCHES "^amdhsa" OR gpu_target_sys MATCHES "^cuda")
+ if(gpu_target_sys MATCHES "^amdhsa" OR gpu_target_sys MATCHES "^cuda" OR target_arch MATCHES "^spirv64")
set(target_sys "gpu")
endif()
+ if (target_arch MATCHES "^spirv64")
+ list(APPEND
+ LIBC_COMPILE_OPTIONS_DEFAULT "-emit-llvm")
+ endif()
+
set(${sys_var} ${target_sys} PARENT_SCOPE)
endfunction(get_arch_and_system_from_triple)
diff --git a/libc/cmake/modules/LLVMLibCLibraryRules.cmake b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
index 80439de6bb4b0..7352802bc9ce4 100644
--- a/libc/cmake/modules/LLVMLibCLibraryRules.cmake
+++ b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
@@ -109,8 +109,14 @@ function(add_bitcode_entrypoint_library target_name base_target_name)
endforeach()
add_executable(${target_name} ${objects})
- target_link_options(${target_name} PRIVATE "${LIBC_COMPILE_OPTIONS_DEFAULT}"
+ if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^spirv" OR
+ "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^spirv")
+ target_link_options(${target_name} PRIVATE "${LIBC_COMPILE_OPTIONS_DEFAULT}"
+ "-nostdlib" "-emit-llvm")
+ else()
+ target_link_options(${target_name} PRIVATE "${LIBC_COMPILE_OPTIONS_DEFAULT}"
"-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm")
+ endif()
endfunction(add_bitcode_entrypoint_library)
# A rule to build a library from a collection of entrypoint objects.
diff --git a/libc/config/gpu/spirv64/entrypoints.txt b/libc/config/gpu/spirv64/entrypoints.txt
new file mode 100644
index 0000000000000..0dda7d5c683ec
--- /dev/null
+++ b/libc/config/gpu/spirv64/entrypoints.txt
@@ -0,0 +1,693 @@
+set(TARGET_LIBC_ENTRYPOINTS
+ # assert.h entrypoints
+ libc.src.assert.__assert_fail
+
+ # ctype.h entrypoints
+ libc.src.ctype.isalnum
+ libc.src.ctype.isalnum_l
+ libc.src.ctype.isalpha
+ libc.src.ctype.isalpha_l
+ libc.src.ctype.isascii
+ libc.src.ctype.isblank
+ libc.src.ctype.isblank_l
+ libc.src.ctype.iscntrl
+ libc.src.ctype.iscntrl_l
+ libc.src.ctype.isdigit
+ libc.src.ctype.isdigit_l
+ libc.src.ctype.isgraph
+ libc.src.ctype.isgraph_l
+ libc.src.ctype.islower
+ libc.src.ctype.islower_l
+ libc.src.ctype.isprint
+ libc.src.ctype.isprint_l
+ libc.src.ctype.ispunct
+ libc.src.ctype.ispunct_l
+ libc.src.ctype.isspace
+ libc.src.ctype.isspace_l
+ libc.src.ctype.isupper
+ libc.src.ctype.isupper_l
+ libc.src.ctype.isxdigit
+ libc.src.ctype.isxdigit_l
+ libc.src.ctype.toascii
+ libc.src.ctype.tolower
+ libc.src.ctype.tolower_l
+ libc.src.ctype.toupper
+ libc.src.ctype.toupper_l
+
+ # string.h entrypoints
+ libc.src.string.memccpy
+ libc.src.string.memchr
+ libc.src.string.memcmp
+ libc.src.string.memcpy
+ libc.src.string.memmem
+ libc.src.string.memmove
+ libc.src.string.mempcpy
+ libc.src.string.memrchr
+ libc.src.string.memset
+ libc.src.string.stpcpy
+ libc.src.string.stpncpy
+ libc.src.string.strcasestr
+ libc.src.string.strcat
+ libc.src.string.strchr
+ libc.src.string.strchrnul
+ libc.src.string.strcmp
+ libc.src.string.strcoll
+ libc.src.string.strcoll_l
+ libc.src.string.strcpy
+ libc.src.string.strcspn
+ libc.src.string.strdup
+ libc.src.string.strerror
+ libc.src.string.strlcat
+ libc.src.string.strlcpy
+ libc.src.string.strlen
+ libc.src.string.strncat
+ libc.src.string.strncmp
+ libc.src.string.strncpy
+ libc.src.string.strndup
+ libc.src.string.strnlen
+ libc.src.string.strpbrk
+ libc.src.string.strrchr
+ libc.src.string.strsep
+ libc.src.string.strspn
+ libc.src.string.strstr
+ libc.src.string.strtok
+ libc.src.string.strtok_r
+ libc.src.string.strxfrm
+ libc.src.string.strxfrm_l
+
+ # strings.h entrypoints
+ libc.src.strings.bcmp
+ libc.src.strings.bcopy
+ libc.src.strings.bzero
+ libc.src.strings.index
+ libc.src.strings.rindex
+ libc.src.strings.strcasecmp
+ libc.src.strings.strncasecmp
+
+ # stdbit.h entrypoints
+ libc.src.stdbit.stdc_bit_ceil_uc
+ libc.src.stdbit.stdc_bit_ceil_ui
+ libc.src.stdbit.stdc_bit_ceil_ul
+ libc.src.stdbit.stdc_bit_ceil_ull
+ libc.src.stdbit.stdc_bit_ceil_us
+ libc.src.stdbit.stdc_bit_floor_uc
+ libc.src.stdbit.stdc_bit_floor_ui
+ libc.src.stdbit.stdc_bit_floor_ul
+ libc.src.stdbit.stdc_bit_floor_ull
+ libc.src.stdbit.stdc_bit_floor_us
+ libc.src.stdbit.stdc_bit_width_uc
+ libc.src.stdbit.stdc_bit_width_ui
+ libc.src.stdbit.stdc_bit_width_ul
+ libc.src.stdbit.stdc_bit_width_ull
+ libc.src.stdbit.stdc_bit_width_us
+ libc.src.stdbit.stdc_count_ones_uc
+ libc.src.stdbit.stdc_count_ones_ui
+ libc.src.stdbit.stdc_count_ones_ul
+ libc.src.stdbit.stdc_count_ones_ull
+ libc.src.stdbit.stdc_count_ones_us
+ libc.src.stdbit.stdc_count_zeros_uc
+ libc.src.stdbit.stdc_count_zeros_ui
+ libc.src.stdbit.stdc_count_zeros_ul
+ libc.src.stdbit.stdc_count_zeros_ull
+ libc.src.stdbit.stdc_count_zeros_us
+ libc.src.stdbit.stdc_first_leading_one_uc
+ libc.src.stdbit.stdc_first_leading_one_ui
+ libc.src.stdbit.stdc_first_leading_one_ul
+ libc.src.stdbit.stdc_first_leading_one_ull
+ libc.src.stdbit.stdc_first_leading_one_us
+ libc.src.stdbit.stdc_first_leading_zero_uc
+ libc.src.stdbit.stdc_first_leading_zero_ui
+ libc.src.stdbit.stdc_first_leading_zero_ul
+ libc.src.stdbit.stdc_first_leading_zero_ull
+ libc.src.stdbit.stdc_first_leading_zero_us
+ libc.src.stdbit.stdc_first_trailing_one_uc
+ libc.src.stdbit.stdc_first_trailing_one_ui
+ libc.src.stdbit.stdc_first_trailing_one_ul
+ libc.src.stdbit.stdc_first_trailing_one_ull
+ libc.src.stdbit.stdc_first_trailing_one_us
+ libc.src.stdbit.stdc_first_trailing_zero_uc
+ libc.src.stdbit.stdc_first_trailing_zero_ui
+ libc.src.stdbit.stdc_first_trailing_zero_ul
+ libc.src.stdbit.stdc_first_trailing_zero_ull
+ libc.src.stdbit.stdc_first_trailing_zero_us
+ libc.src.stdbit.stdc_has_single_bit_uc
+ libc.src.stdbit.stdc_has_single_bit_ui
+ libc.src.stdbit.stdc_has_single_bit_ul
+ libc.src.stdbit.stdc_has_single_bit_ull
+ libc.src.stdbit.stdc_has_single_bit_us
+ libc.src.stdbit.stdc_leading_ones_uc
+ libc.src.stdbit.stdc_leading_ones_ui
+ libc.src.stdbit.stdc_leading_ones_ul
+ libc.src.stdbit.stdc_leading_ones_ull
+ libc.src.stdbit.stdc_leading_ones_us
+ libc.src.stdbit.stdc_leading_zeros_uc
+ libc.src.stdbit.stdc_leading_zeros_ui
+ libc.src.stdbit.stdc_leading_zeros_ul
+ libc.src.stdbit.stdc_leading_zeros_ull
+ libc.src.stdbit.stdc_leading_zeros_us
+ libc.src.stdbit.stdc_trailing_ones_uc
+ libc.src.stdbit.stdc_trailing_ones_ui
+ libc.src.stdbit.stdc_trailing_ones_ul
+ libc.src.stdbit.stdc_trailing_ones_ull
+ libc.src.stdbit.stdc_trailing_ones_us
+ libc.src.stdbit.stdc_trailing_zeros_uc
+ libc.src.stdbit.stdc_trailing_zeros_ui
+ libc.src.stdbit.stdc_trailing_zeros_ul
+ libc.src.stdbit.stdc_trailing_zeros_ull
+ libc.src.stdbit.stdc_trailing_zeros_us
+
+ # stdlib.h entrypoints
+ libc.src.stdlib._Exit
+ libc.src.stdlib.abort
+ libc.src.stdlib.abs
+ libc.src.stdlib.atexit
+ libc.src.stdlib.atof
+ libc.src.stdlib.atoi
+ libc.src.stdlib.atol
+ libc.src.stdlib.atoll
+ libc.src.stdlib.bsearch
+ libc.src.stdlib.div
+ libc.src.stdlib.exit
+ libc.src.stdlib.labs
+ libc.src.stdlib.ldiv
+ libc.src.stdlib.llabs
+ libc.src.stdlib.lldiv
+ libc.src.stdlib.memalignment
+ libc.src.stdlib.qsort
+ libc.src.stdlib.qsort_r
+ libc.src.stdlib.rand
+ libc.src.stdlib.srand
+ libc.src.stdlib.strtod
+ libc.src.stdlib.strtod_l
+ libc.src.stdlib.strtof
+ libc.src.stdlib.strtof_l
+ libc.src.stdlib.strtol
+ libc.src.stdlib.strtol_l
+ libc.src.stdlib.strtold
+ libc.src.stdlib.strtold_l
+ libc.src.stdlib.strtoll
+ libc.src.stdlib.strtoll_l
+ libc.src.stdlib.strtoul
+ libc.src.stdlib.strtoul_l
+ libc.src.stdlib.strtoull
+ libc.src.stdlib.strtoull_l
+ libc.src.stdlib.at_quick_exit
+ libc.src.stdlib.quick_exit
+ libc.src.stdlib.getenv
+ libc.src.stdlib.system
+
+ # TODO: Implement these correctly
+ libc.src.stdlib.aligned_alloc
+ libc.src.stdlib.calloc
+ libc.src.stdlib.free
+ libc.src.stdlib.malloc
+ libc.src.stdlib.realloc
+
+ # errno.h entrypoints
+ libc.src.errno.errno
+
+ # stdio.h entrypoints
+ libc.src.stdio.clearerr
+ libc.src.stdio.fclose
+ libc.src.stdio.printf
+ libc.src.stdio.vprintf
+ libc.src.stdio.fprintf
+ libc.src.stdio.vfprintf
+ libc.src.stdio.snprintf
+ libc.src.stdio.sprintf
+ libc.src.stdio.vsnprintf
+ libc.src.stdio.vsprintf
+ libc.src.stdio.asprintf
+ libc.src.stdio.vasprintf
+ libc.src.stdio.scanf
+ libc.src.stdio.vscanf
+ libc.src.stdio.fscanf
+ libc.src.stdio.vfscanf
+ libc.src.stdio.sscanf
+ libc.src.stdio.vsscanf
+ libc.src.stdio.feof
+ libc.src.stdio.ferror
+ libc.src.stdio.fflush
+ libc.src.stdio.fgetc
+ libc.src.stdio.fgets
+ libc.src.stdio.fopen
+ libc.src.stdio.fputc
+ libc.src.stdio.fputs
+ libc.src.stdio.fread
+ libc.src.stdio.fseek
+ libc.src.stdio.ftell
+ libc.src.stdio.fwrite
+ libc.src.stdio.getc
+ libc.src.stdio.getchar
+ libc.src.stdio.putc
+ libc.src.stdio.putchar
+ libc.src.stdio.puts
+ libc.src.stdio.remove
+ libc.src.stdio.rename
+ libc.src.stdio.stderr
+ libc.src.stdio.stdin
+ libc.src.stdio.stdout
+ libc.src.stdio.ungetc
+
+ # inttypes.h entrypoints
+ libc.src.inttypes.imaxabs
+ libc.src.inttypes.imaxdiv
+ libc.src.inttypes.strtoimax
+ libc.src.inttypes.strtoumax
+
+ # time.h entrypoints
+ libc.src.time.clock
+ libc.src.time.clock_gettime
+ libc.src.time.timespec_get
+ libc.src.time.nanosleep
+ libc.src.time.strftime
+ libc.src.time.strftime_l
+ libc.src.time.mktime
+
+ # wchar.h entrypoints
+ libc.src.wchar.wcslen
+ libc.src.wchar.wctob
+
+ # locale.h entrypoints
+ libc.src.locale.localeconv
+ libc.src.locale.duplocale
+ libc.src.locale.freelocale
+ libc.src.locale.localeconv
+ libc.src.locale.newlocale
+ libc.src.locale.setlocale
+ libc.src.locale.uselocale
+)
+
+set(TARGET_LIBM_ENTRYPOINTS
+ # math.h entrypoints
+ libc.src.math.acos
+ libc.src.math.acosf
+ libc.src.math.acoshf
+ libc.src.math.asin
+ libc.src.math.asinf
+ libc.src.math.asinhf
+ libc.src.math.atan
+ libc.src.math.atan2
+ libc.src.math.atan2f
+ libc.src.math.atan2l
+ libc.src.math.atanf
+ libc.src.math.atanhf
+ libc.src.math.canonicalize
+ libc.src.math.canonicalizef
+ libc.src.math.canonicalizel
+ libc.src.math.cbrt
+ libc.src.math.cbrtf
+ libc.src.math.ceil
+ libc.src.math.ceilf
+ libc.src.math.ceill
+ libc.src.math.copysign
+ libc.src.math.copysignf
+ libc.src.math.copysignl
+ libc.src.math.cos
+ libc.src.math.cosf
+ libc.src.math.coshf
+ libc.src.math.cospif
+ libc.src.math.ddivl
+ libc.src.math.dfmal
+ libc.src.math.dmull
+ libc.src.math.dsqrtl
+ libc.src.math.erff
+ libc.src.math.exp
+ libc.src.math.exp10
+ libc.src.math.exp10f
+ libc.src.math.exp2
+ libc.src.math.exp2f
+ libc.src.math.exp2m1f
+ libc.src.math.expf
+ libc.src.math.expm1
+ libc.src.math.expm1f
+ libc.src.math.fabs
+ libc.src.math.fabsf
+ libc.src.math.fabsl
+ libc.src.math.fadd
+ libc.src.math.faddl
+ libc.src.math.fdim
+ libc.src.math.fdimf
+ libc.src.math.fdiml
+ libc.src.math.fdiv
+ libc.src.math.fdivl
+ libc.src.math.ffma
+ libc.src.math.ffmal
+ libc.src.math.floor
+ libc.src.math.floorf
+ libc.src.math.floorl
+ libc.src.math.fma
+ libc.src.math.fmaf
+ libc.src.math.fmax
+ libc.src.math.fmaxf
+ libc.src.math.fmaximum
+ libc.src.math.fmaximumf
+ libc.src.math.fmaximuml
+ libc.src.math.fmaximum_mag
+ libc.src.math.fmaximum_magf
+ libc.src.math.fmaximum_magl
+ libc.src.math.fmaximum_mag_num
+ libc.src.math.fmaximum_mag_numf
+ libc.src.math.fmaximum_mag_numl
+ libc.src.math.fmaximum_num
+ libc.src.math.fmaximum_numf
+ libc.src.math.fmaximum_numl
+ libc.src.math.fmaxl
+ libc.src.math.fmin
+ libc.src.math.fminf
+ libc.src.math.fminimum
+ libc.src.math.fminimumf
+ libc.src.math.fminimuml
+ libc.src.math.fminimum_mag
+ libc.src.math.fminimum_magf
+ libc.src.math.fminimum_magl
+ libc.src.math.fminimum_mag_num
+ libc.src.math.fminimum_mag_numf
+ libc.src.math.fminimum_mag_numl
+ libc.src.math.fminimum_num
+ libc.src.math.fminimum_numf
+ libc.src.math.fminimum_numl
+ libc.src.math.fminl
+ libc.src.math.fmod
+ libc.src.math.fmodf
+ libc.src.math.fmodl
+ libc.src.math.fmul
+ libc.src.math.fmull
+ libc.src.math.frexp
+ libc.src.math.frexpf
+ libc.src.math.frexpl
+ libc.src.math.fromfp
+ libc.src.math.fromfpf
+ libc.src.math.fromfpl
+ libc.src.math.fromfpx
+ libc.src.math.fromfpxf
+ libc.src.math.fromfpxl
+ libc.src.math.fsqrt
+ libc.src.math.fsqrtl
+ libc.src.math.fsub
+ libc.src.math.fsubl
+ libc.src.math.getpayload
+ libc.src.math.getpayloadf
+ libc.src.math.getpayloadl
+ libc.src.math.hypot
+ libc.src.math.hypotf
+ libc.src.math.ilogb
+ libc.src.math.ilogbf
+ libc.src.math.ilogbl
+ libc.src.math.isnan
+ libc.src.math.isnanf
+ libc.src.math.isnanl
+ libc.src.math.ldexp
+ libc.src.math.ldexpf
+ libc.src.math.ldexpl
+ libc.src.math.lgamma
+ libc.src.math.lgamma_r
+ libc.src.math.llogb
+ libc.src.math.llogbf
+ libc.src.math.llogbl
+ libc.src.math.llrint
+ libc.src.math.llrintf
+ libc.src.math.llrintl
+ libc.src.math.llround
+ libc.src.math.llroundf
+ libc.src.math.llroundl
+ libc.src.math.log
+ libc.src.math.log10
+ libc.src.math.log10f
+ libc.src.math.log1p
+ libc.src.math.log1pf
+ libc.src.math.log2
+ libc.src.math.log2f
+ libc.src.math.logb
+ libc.src.math.logbf
+ libc.src.math.logbl
+ libc.src.math.logf
+ libc.src.math.lrint
+ libc.src.math.lrintf
+ libc.src.math.lrintl
+ libc.src.math.lround
+ libc.src.math.lroundf
+ libc.src.math.lroundl
+ libc.src.math.modf
+ libc.src.math.modff
+ libc.src.math.modfl
+ libc.src.math.nan
+ libc.src.math.nanf
+ libc.src.math.nanl
+ libc.src.math.nearbyint
+ libc.src.math.nearbyintf
+ libc.src.math.nearbyintl
+ libc.src.math.nextafter
+ libc.src.math.nextafterf
+ libc.src.math.nextafterl
+ libc.src.math.nextdown
+ libc.src.math.nextdownf
+ libc.src.math.nextdownl
+ libc.src.math.nexttoward
+ libc.src.math.nexttowardf
+ libc.src.math.nexttowardl
+ libc.src.math.nextup
+ libc.src.math.nextupf
+ libc.src.math.nextupl
+ libc.src.math.pow
+ libc.src.math.powf
+ libc.src.math.remainder
+ libc.src.math.remainderf
+ libc.src.math.remainderl
+ libc.src.math.remquo
+ libc.src.math.remquof
+ libc.src.math.remquol
+ libc.src.math.rint
+ libc.src.math.rintf
+ libc.src.math.rintl
+ libc.src.math.roundeven
+ libc.src.math.roundevenf
+ libc.src.math.roundevenl
+ libc.src.math.round
+ libc.src.math.roundf
+ libc.src.math.roundl
+ libc.src.math.scalbln
+ libc.src.math.scalblnf
+ libc.src.math.scalblnl
+ libc.src.math.scalbn
+ libc.src.math.scalbnf
+ libc.src.math.scalbnl
+ libc.src.math.setpayload
+ libc.src.math.setpayloadf
+ libc.src.math.setpayloadl
+ libc.src.math.setpayloadsig
+ libc.src.math.setpayloadsigf
+ libc.src.math.setpayloadsigl
+ libc.src.math.sin
+ libc.src.math.sincos
+ libc.src.math.sincosf
+ libc.src.math.sinf
+ libc.src.math.sinhf
+ libc.src.math.sinpif
+ libc.src.math.sqrt
+ libc.src.math.sqrtf
+ libc.src.math.sqrtl
+ libc.src.math.tan
+ libc.src.math.tanf
+ libc.src.math.tanhf
+ libc.src.math.tanpif
+ libc.src.math.tgamma
+ libc.src.math.tgammaf
+ libc.src.math.totalorder
+ libc.src.math.totalorderf
+ libc.src.math.totalorderl
+ libc.src.math.totalordermag
+ libc.src.math.totalordermagf
+ libc.src.math.totalordermagl
+ libc.src.math.trunc
+ libc.src.math.truncf
+ libc.src.math.truncl
+ libc.src.math.ufromfp
+ libc.src.math.ufromfpf
+ libc.src.math.ufromfpl
+ libc.src.math.ufromfpx
+ libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxl
+)
+
+if(LIBC_TYPES_HAS_FLOAT16)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ # math.h C23 _Float16 entrypoints
+ libc.src.math.acosf16
+ libc.src.math.acoshf16
+ libc.src.math.acospif16
+ libc.src.math.asinf16
+ libc.src.math.asinhf16
+ libc.src.math.atanf16
+ libc.src.math.atanhf16
+ libc.src.math.canonicalizef16
+ libc.src.math.ceilf16
+ libc.src.math.copysignf16
+ libc.src.math.cosf16
+ libc.src.math.coshf16
+ libc.src.math.cospif16
+ libc.src.math.exp10f16
+ libc.src.math.exp10m1f16
+ libc.src.math.exp2f16
+ # libc.src.math.exp2m1f16
+ libc.src.math.expf16
+ libc.src.math.expm1f16
+ libc.src.math.f16add
+ libc.src.math.f16addf
+ libc.src.math.f16addl
+ libc.src.math.f16div
+ libc.src.math.f16divf
+ libc.src.math.f16divl
+ libc.src.math.f16fma
+ libc.src.math.f16fmaf
+ libc.src.math.f16fmal
+ libc.src.math.f16mul
+ libc.src.math.f16mulf
+ libc.src.math.f16mull
+ libc.src.math.f16sqrt
+ libc.src.math.f16sqrtf
+ libc.src.math.f16sqrtl
+ libc.src.math.f16sub
+ libc.src.math.f16subf
+ libc.src.math.f16subl
+ libc.src.math.fabsf16
+ libc.src.math.fdimf16
+ libc.src.math.floorf16
+ libc.src.math.fmaf16
+ libc.src.math.fmaxf16
+ libc.src.math.fmaximum_mag_numf16
+ libc.src.math.fmaximum_magf16
+ libc.src.math.fmaximum_numf16
+ libc.src.math.fmaximumf16
+ libc.src.math.fminf16
+ libc.src.math.fminimum_mag_numf16
+ libc.src.math.fminimum_magf16
+ libc.src.math.fminimum_numf16
+ libc.src.math.fminimumf16
+ libc.src.math.fmodf16
+ libc.src.math.frexpf16
+ libc.src.math.fromfpf16
+ libc.src.math.fromfpxf16
+ libc.src.math.getpayloadf16
+ libc.src.math.hypotf16
+ libc.src.math.ilogbf16
+ libc.src.math.iscanonicalf16
+ libc.src.math.issignalingf16
+ libc.src.math.ldexpf16
+ libc.src.math.llogbf16
+ libc.src.math.llrintf16
+ libc.src.math.llroundf16
+ libc.src.math.log10f16
+ libc.src.math.log2f16
+ libc.src.math.logbf16
+ libc.src.math.logf16
+ libc.src.math.lrintf16
+ libc.src.math.lroundf16
+ libc.src.math.modff16
+ libc.src.math.nanf16
+ libc.src.math.nearbyintf16
+ libc.src.math.nextafterf16
+ libc.src.math.nextdownf16
+ libc.src.math.nexttowardf16
+ libc.src.math.nextupf16
+ libc.src.math.remainderf16
+ libc.src.math.remquof16
+ libc.src.math.rintf16
+ libc.src.math.roundevenf16
+ libc.src.math.roundf16
+ libc.src.math.scalblnf16
+ libc.src.math.scalbnf16
+ libc.src.math.setpayloadf16
+ libc.src.math.setpayloadsigf16
+ libc.src.math.sinf16
+ libc.src.math.sinhf16
+ libc.src.math.sinpif16
+ libc.src.math.sqrtf16
+ libc.src.math.tanf16
+ libc.src.math.tanhf16
+ libc.src.math.tanpif16
+ libc.src.math.totalorderf16
+ libc.src.math.totalordermagf16
+ libc.src.math.truncf16
+ libc.src.math.ufromfpf16
+ libc.src.math.ufromfpxf16
+ )
+endif()
+
+list(APPEND TARGET_LIBM_ENTRYPOINTS
+ # bfloat16 entrypoints
+ libc.src.math.bf16add
+ libc.src.math.bf16addf
+ libc.src.math.bf16addl
+ libc.src.math.bf16div
+ libc.src.math.bf16divf
+ libc.src.math.bf16divl
+ libc.src.math.bf16fma
+ libc.src.math.bf16fmaf
+ libc.src.math.bf16fmal
+ libc.src.math.bf16mul
+ libc.src.math.bf16mulf
+ libc.src.math.bf16mull
+ libc.src.math.bf16sub
+ libc.src.math.bf16subf
+ libc.src.math.bf16subl
+ libc.src.math.canonicalizebf16
+ libc.src.math.ceilbf16
+ libc.src.math.copysignbf16
+ libc.src.math.fabsbf16
+ libc.src.math.fdimbf16
+ libc.src.math.floorbf16
+ libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
+ libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
+ libc.src.math.fmodbf16
+ libc.src.math.frexpbf16
+ libc.src.math.fromfpbf16
+ libc.src.math.fromfpxbf16
+ libc.src.math.getpayloadbf16
+ libc.src.math.ilogbbf16
+ libc.src.math.iscanonicalbf16
+ libc.src.math.issignalingbf16
+ libc.src.math.ldexpbf16
+ libc.src.math.llogbbf16
+ libc.src.math.llrintbf16
+ libc.src.math.llroundbf16
+ libc.src.math.log_bf16
+ libc.src.math.logbbf16
+ libc.src.math.lrintbf16
+ libc.src.math.lroundbf16
+ libc.src.math.modfbf16
+ libc.src.math.nanbf16
+ libc.src.math.nearbyintbf16
+ libc.src.math.nextafterbf16
+ libc.src.math.nextdownbf16
+ libc.src.math.nexttowardbf16
+ libc.src.math.nextupbf16
+ libc.src.math.remainderbf16
+ libc.src.math.remquobf16
+ libc.src.math.rintbf16
+ libc.src.math.roundbf16
+ libc.src.math.roundevenbf16
+ libc.src.math.scalblnbf16
+ libc.src.math.scalbnbf16
+ libc.src.math.setpayloadbf16
+ libc.src.math.setpayloadsigbf16
+ libc.src.math.sqrtbf16
+ libc.src.math.truncbf16
+ libc.src.math.totalorderbf16
+ libc.src.math.totalordermagbf16
+ libc.src.math.ufromfpbf16
+ libc.src.math.ufromfpxbf16
+)
+
+set(TARGET_LLVMLIBC_ENTRYPOINTS
+ ${TARGET_LIBC_ENTRYPOINTS}
+ ${TARGET_LIBM_ENTRYPOINTS}
+)
diff --git a/libc/config/gpu/spirv64/headers.txt b/libc/config/gpu/spirv64/headers.txt
new file mode 100644
index 0000000000000..fa8ad7c11ba8b
--- /dev/null
+++ b/libc/config/gpu/spirv64/headers.txt
@@ -0,0 +1,21 @@
+set(TARGET_PUBLIC_HEADERS
+ libc.include.assert
+ libc.include.ctype
+ libc.include.string
+ libc.include.strings
+ libc.include.signal
+ libc.include.float
+ libc.include.stdint
+ libc.include.inttypes
+ libc.include.limits
+ libc.include.math
+ libc.include.fenv
+ libc.include.time
+ libc.include.errno
+ libc.include.stdlib
+ libc.include.stdio
+ libc.include.wchar
+ libc.include.uchar
+ libc.include.features
+ libc.include.locale
+)
diff --git a/libc/include/llvm-libc-macros/math-macros.h b/libc/include/llvm-libc-macros/math-macros.h
index e1b12e3010fe9..2051e36f72e28 100644
--- a/libc/include/llvm-libc-macros/math-macros.h
+++ b/libc/include/llvm-libc-macros/math-macros.h
@@ -44,7 +44,7 @@
// Math error handling. Target support is assumed to be existent unless
// explicitly disabled.
-#if defined(__NVPTX__) || defined(__AMDGPU__) || defined(__FAST_MATH__) || \
+#if defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__) || defined(__FAST_MATH__) || \
defined(__NO_MATH_ERRNO__)
#define __LIBC_SUPPORTS_MATH_ERRNO 0
#else
diff --git a/libc/include/llvm-libc-macros/signal-macros.h b/libc/include/llvm-libc-macros/signal-macros.h
index fbe929a0fea25..163c8742593b8 100644
--- a/libc/include/llvm-libc-macros/signal-macros.h
+++ b/libc/include/llvm-libc-macros/signal-macros.h
@@ -11,7 +11,7 @@
#if defined(__linux__)
#include "linux/signal-macros.h"
-#elif defined(__NVPTX__) || defined(__AMDGPU__)
+#elif defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__)
#include "gpu/signal-macros.h"
#endif
diff --git a/libc/include/llvm-libc-macros/time-macros.h b/libc/include/llvm-libc-macros/time-macros.h
index c026df29b1e7f..d00d5e051d757 100644
--- a/libc/include/llvm-libc-macros/time-macros.h
+++ b/libc/include/llvm-libc-macros/time-macros.h
@@ -1,7 +1,7 @@
#ifndef LLVM_LIBC_MACROS_TIME_MACROS_H
#define LLVM_LIBC_MACROS_TIME_MACROS_H
-#if defined(__AMDGPU__) || defined(__NVPTX__)
+#if defined(__AMDGPU__) || defined(__NVPTX__) || defined(__SPIRV__)
#include "gpu/time-macros.h"
#elif defined(__linux__)
#include "linux/time-macros.h"
diff --git a/libc/include/llvm-libc-types/fenv_t.h b/libc/include/llvm-libc-types/fenv_t.h
index c83f23894c0c8..2cfeff7b8a9f8 100644
--- a/libc/include/llvm-libc-types/fenv_t.h
+++ b/libc/include/llvm-libc-types/fenv_t.h
@@ -25,7 +25,7 @@ typedef struct {
} fenv_t;
#elif defined(__riscv)
typedef unsigned int fenv_t;
-#elif defined(__AMDGPU__) || defined(__NVPTX__)
+#elif defined(__AMDGPU__) || defined(__NVPTX__) || defined(__SPIRV__)
typedef struct {
unsigned int __fpc;
} fenv_t;
diff --git a/libc/shared/rpc_util.h b/libc/shared/rpc_util.h
index 687814b7ff2ae..1785920ec2504 100644
--- a/libc/shared/rpc_util.h
+++ b/libc/shared/rpc_util.h
@@ -12,7 +12,7 @@
#include <stddef.h>
#include <stdint.h>
-#if (defined(__NVPTX__) || defined(__AMDGPU__)) && \
+#if (defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__)) && \
!((defined(__CUDA__) && !defined(__CUDA_ARCH__)) || \
(defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)))
#include <gpuintrin.h>
diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h
index 21e9bc4288cd7..f05fe9e18e130 100644
--- a/libc/src/__support/macros/properties/architectures.h
+++ b/libc/src/__support/macros/properties/architectures.h
@@ -13,11 +13,15 @@
#define LIBC_TARGET_ARCH_IS_AMDGPU
#endif
+#if defined(__SPIRV__)
+#define LIBC_TARGET_ARCH_IS_SPIRV
+#endif
+
#if defined(__NVPTX__)
#define LIBC_TARGET_ARCH_IS_NVPTX
#endif
-#if defined(LIBC_TARGET_ARCH_IS_NVPTX) || defined(LIBC_TARGET_ARCH_IS_AMDGPU)
+#if defined(LIBC_TARGET_ARCH_IS_NVPTX) || defined(LIBC_TARGET_ARCH_IS_AMDGPU) || defined(LIBC_TARGET_ARCH_IS_SPIRV)
#define LIBC_TARGET_ARCH_IS_GPU
#endif
diff --git a/libc/src/__support/macros/properties/cpu_features.h b/libc/src/__support/macros/properties/cpu_features.h
index 1fe20d9b23a34..00129927263d6 100644
--- a/libc/src/__support/macros/properties/cpu_features.h
+++ b/libc/src/__support/macros/properties/cpu_features.h
@@ -91,13 +91,13 @@
#endif // LIBC_TARGET_CPU_HAS_RISCV_FPU_DOUBLE
#endif // __riscv_flen
-#if defined(__NVPTX__) || defined(__AMDGPU__)
+#if defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__)
#define LIBC_TARGET_CPU_HAS_FPU_FLOAT
#define LIBC_TARGET_CPU_HAS_FPU_DOUBLE
#endif
#if defined(__ARM_FEATURE_FMA) || (defined(__AVX2__) && defined(__FMA__)) || \
- defined(__NVPTX__) || defined(__AMDGPU__) || defined(__riscv_flen)
+ defined(__NVPTX__) || defined(__AMDGPU__) || defined(__riscv_flen) || defined(__SPIRV__)
#define LIBC_TARGET_CPU_HAS_FMA
// Provide a more fine-grained control of FMA instruction for ARM targets.
#if defined(LIBC_TARGET_CPU_HAS_FPU_HALF)
diff --git a/libc/src/__support/time/gpu/time_utils.cpp b/libc/src/__support/time/gpu/time_utils.cpp
index 38e09f600f369..bfdcb856153ee 100644
--- a/libc/src/__support/time/gpu/time_utils.cpp
+++ b/libc/src/__support/time/gpu/time_utils.cpp
@@ -11,7 +11,7 @@
namespace LIBC_NAMESPACE_DECL {
-#if defined(LIBC_TARGET_ARCH_IS_AMDGPU)
+#if defined(LIBC_TARGET_ARCH_IS_AMDGPU) || defined(__SPIRV__)
// This is expected to be initialized by the runtime if the default value is
// insufficient.
// TODO: Once we have another use-case for this we should put it in a common
diff --git a/libc/src/__support/time/gpu/time_utils.h b/libc/src/__support/time/gpu/time_utils.h
index 315506c897dcf..343a3b968c1dc 100644
--- a/libc/src/__support/time/gpu/time_utils.h
+++ b/libc/src/__support/time/gpu/time_utils.h
@@ -16,7 +16,7 @@
namespace LIBC_NAMESPACE_DECL {
-#if defined(LIBC_TARGET_ARCH_IS_AMDGPU)
+#if defined(LIBC_TARGET_ARCH_IS_AMDGPU) || defined(__SPIRV__)
// AMDGPU does not have a single set frequency. Different architectures and
// cards can have different values. The actualy frequency needs to be read from
// the kernel driver and will be between 25 MHz and 100 MHz on most cards. All
diff --git a/libc/src/math/spirv64/CMakeLists.txt b/libc/src/math/spirv64/CMakeLists.txt
new file mode 100644
index 0000000000000..d05d519b74b4f
--- /dev/null
+++ b/libc/src/math/spirv64/CMakeLists.txt
@@ -0,0 +1,303 @@
+add_entrypoint_object(
+ ceil
+ SRCS
+ ceil.cpp
+ HDRS
+ ../ceil.h
+)
+
+add_entrypoint_object(
+ ceilf
+ SRCS
+ ceilf.cpp
+ HDRS
+ ../ceilf.h
+)
+
+add_entrypoint_object(
+ copysign
+ SRCS
+ copysign.cpp
+ HDRS
+ ../copysign.h
+)
+
+add_entrypoint_object(
+ copysignf
+ SRCS
+ copysignf.cpp
+ HDRS
+ ../copysignf.h
+)
+
+add_entrypoint_object(
+ fabs
+ SRCS
+ fabs.cpp
+ HDRS
+ ../fabs.h
+)
+
+add_entrypoint_object(
+ fabsf
+ SRCS
+ fabsf.cpp
+ HDRS
+ ../fabsf.h
+)
+
+add_entrypoint_object(
+ floor
+ SRCS
+ floor.cpp
+ HDRS
+ ../floor.h
+)
+
+add_entrypoint_object(
+ floorf
+ SRCS
+ floorf.cpp
+ HDRS
+ ../floorf.h
+)
+
+add_entrypoint_object(
+ fma
+ SRCS
+ fma.cpp
+ HDRS
+ ../fma.h
+)
+
+add_entrypoint_object(
+ fmaf
+ SRCS
+ fmaf.cpp
+ HDRS
+ ../fmaf.h
+)
+
+add_entrypoint_object(
+ fmax
+ SRCS
+ fmax.cpp
+ HDRS
+ ../fmax.h
+)
+
+add_entrypoint_object(
+ fmaxf
+ SRCS
+ fmaxf.cpp
+ HDRS
+ ../fmaxf.h
+)
+
+add_entrypoint_object(
+ fmin
+ SRCS
+ fmin.cpp
+ HDRS
+ ../fmin.h
+)
+
+add_entrypoint_object(
+ fminf
+ SRCS
+ fminf.cpp
+ HDRS
+ ../fminf.h
+)
+
+add_entrypoint_object(
+ fmod
+ SRCS
+ fmod.cpp
+ HDRS
+ ../fmod.h
+)
+
+add_entrypoint_object(
+ fmodf
+ SRCS
+ fmodf.cpp
+ HDRS
+ ../fmodf.h
+)
+
+add_entrypoint_object(
+ nearbyint
+ SRCS
+ nearbyint.cpp
+ HDRS
+ ../nearbyint.h
+)
+
+add_entrypoint_object(
+ nearbyintf
+ SRCS
+ nearbyintf.cpp
+ HDRS
+ ../nearbyintf.h
+)
+
+add_entrypoint_object(
+ remainder
+ SRCS
+ remainder.cpp
+ HDRS
+ ../remainder.h
+)
+
+add_entrypoint_object(
+ remainderf
+ SRCS
+ remainderf.cpp
+ HDRS
+ ../remainderf.h
+)
+
+add_entrypoint_object(
+ rint
+ SRCS
+ rint.cpp
+ HDRS
+ ../rint.h
+)
+
+add_entrypoint_object(
+ rintf
+ SRCS
+ rintf.cpp
+ HDRS
+ ../rintf.h
+)
+
+add_entrypoint_object(
+ round
+ SRCS
+ round.cpp
+ HDRS
+ ../round.h
+)
+
+add_entrypoint_object(
+ sqrt
+ SRCS
+ sqrt.cpp
+ HDRS
+ ../sqrt.h
+)
+
+add_entrypoint_object(
+ sqrtf
+ SRCS
+ sqrtf.cpp
+ HDRS
+ ../sqrtf.h
+)
+
+add_entrypoint_object(
+ trunc
+ SRCS
+ trunc.cpp
+ HDRS
+ ../trunc.h
+)
+
+add_entrypoint_object(
+ truncf
+ SRCS
+ truncf.cpp
+ HDRS
+ ../truncf.h
+)
+
+add_entrypoint_object(
+ frexp
+ SRCS
+ frexp.cpp
+ HDRS
+ ../frexp.h
+)
+
+add_entrypoint_object(
+ frexpf
+ SRCS
+ frexpf.cpp
+ HDRS
+ ../frexpf.h
+)
+
+add_entrypoint_object(
+ scalbn
+ SRCS
+ scalbn.cpp
+ HDRS
+ ../scalbn.h
+)
+
+add_entrypoint_object(
+ scalbnf
+ SRCS
+ scalbnf.cpp
+ HDRS
+ ../scalbnf.h
+)
+
+add_entrypoint_object(
+ ldexp
+ SRCS
+ ldexp.cpp
+ HDRS
+ ../ldexp.h
+)
+
+add_entrypoint_object(
+ ldexpf
+ SRCS
+ ldexpf.cpp
+ HDRS
+ ../ldexpf.h
+)
+
+add_entrypoint_object(
+ tgamma
+ SRCS
+ tgamma.cpp
+ HDRS
+ ../tgamma.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+)
+
+add_entrypoint_object(
+ tgammaf
+ SRCS
+ tgammaf.cpp
+ HDRS
+ ../tgammaf.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+)
+
+add_entrypoint_object(
+ lgamma
+ SRCS
+ lgamma.cpp
+ HDRS
+ ../lgamma.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+)
+
+add_entrypoint_object(
+ lgamma_r
+ SRCS
+ lgamma_r.cpp
+ HDRS
+ ../lgamma_r.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+)
diff --git a/libc/src/math/spirv64/ceil.cpp b/libc/src/math/spirv64/ceil.cpp
new file mode 100644
index 0000000000000..8834c7b560a1b
--- /dev/null
+++ b/libc/src/math/spirv64/ceil.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the ceil function for GPU -----------------------===//
+//
+// 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 "src/math/ceil.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, ceil, (double x)) { return __builtin_ceil(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/ceilf.cpp b/libc/src/math/spirv64/ceilf.cpp
new file mode 100644
index 0000000000000..5d26a30c849cd
--- /dev/null
+++ b/libc/src/math/spirv64/ceilf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the ceilf function for GPU ----------------------===//
+//
+// 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 "src/math/ceilf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, ceilf, (float x)) { return __builtin_ceilf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/copysign.cpp b/libc/src/math/spirv64/copysign.cpp
new file mode 100644
index 0000000000000..06ef36fb3595f
--- /dev/null
+++ b/libc/src/math/spirv64/copysign.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the copysign function for GPU -------------------===//
+//
+// 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 "src/math/copysign.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, copysign, (double x, double y)) {
+ return __builtin_copysign(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/copysignf.cpp b/libc/src/math/spirv64/copysignf.cpp
new file mode 100644
index 0000000000000..aea94f3577d8f
--- /dev/null
+++ b/libc/src/math/spirv64/copysignf.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the copysignf function for GPU ------------------===//
+//
+// 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 "src/math/copysignf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, copysignf, (float x, float y)) {
+ return __builtin_copysignf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fabs.cpp b/libc/src/math/spirv64/fabs.cpp
new file mode 100644
index 0000000000000..bb37596b9d563
--- /dev/null
+++ b/libc/src/math/spirv64/fabs.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the fabs function for GPU -----------------------===//
+//
+// 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 "src/math/fabs.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, fabs, (double x)) { return __builtin_fabs(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fabsf.cpp b/libc/src/math/spirv64/fabsf.cpp
new file mode 100644
index 0000000000000..2698618f3f1e1
--- /dev/null
+++ b/libc/src/math/spirv64/fabsf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the fabsf function for GPU ----------------------===//
+//
+// 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 "src/math/fabsf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fabsf, (float x)) { return __builtin_fabsf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/floor.cpp b/libc/src/math/spirv64/floor.cpp
new file mode 100644
index 0000000000000..564efa9a7da38
--- /dev/null
+++ b/libc/src/math/spirv64/floor.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the floor function for GPU ----------------------===//
+//
+// 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 "src/math/floor.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, floor, (double x)) { return __builtin_floor(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/floorf.cpp b/libc/src/math/spirv64/floorf.cpp
new file mode 100644
index 0000000000000..6717c8f60c992
--- /dev/null
+++ b/libc/src/math/spirv64/floorf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the floorf function for GPU ---------------------===//
+//
+// 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 "src/math/floorf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, floorf, (float x)) { return __builtin_floorf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fma.cpp b/libc/src/math/spirv64/fma.cpp
new file mode 100644
index 0000000000000..c4a117e42a3aa
--- /dev/null
+++ b/libc/src/math/spirv64/fma.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the fma function for GPU ------------------------===//
+//
+// 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 "src/math/fma.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, fma, (double x, double y, double z)) {
+ return __builtin_fma(x, y, z);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fmaf.cpp b/libc/src/math/spirv64/fmaf.cpp
new file mode 100644
index 0000000000000..c088bd5b30fea
--- /dev/null
+++ b/libc/src/math/spirv64/fmaf.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the fmaf function for GPU -----------------------===//
+//
+// 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 "src/math/fmaf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fmaf, (float x, float y, float z)) {
+ return __builtin_fmaf(x, y, z);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fmax.cpp b/libc/src/math/spirv64/fmax.cpp
new file mode 100644
index 0000000000000..474019733598f
--- /dev/null
+++ b/libc/src/math/spirv64/fmax.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of the fmax function for GPU -----------------------===//
+//
+// 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 "src/math/fmax.h"
+
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, fmax, (double x, double y)) {
+ return __builtin_fmax(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fmaxf.cpp b/libc/src/math/spirv64/fmaxf.cpp
new file mode 100644
index 0000000000000..59ee8259c025a
--- /dev/null
+++ b/libc/src/math/spirv64/fmaxf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the fmaxf function for GPU ----------------------===//
+//
+// 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 "src/math/fmaxf.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fmaxf, (float x, float y)) {
+ return __builtin_fmaxf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fmin.cpp b/libc/src/math/spirv64/fmin.cpp
new file mode 100644
index 0000000000000..694eb664b599b
--- /dev/null
+++ b/libc/src/math/spirv64/fmin.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the fmin function for GPU -----------------------===//
+//
+// 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 "src/math/fmin.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, fmin, (double x, double y)) {
+ return __builtin_fmin(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fminf.cpp b/libc/src/math/spirv64/fminf.cpp
new file mode 100644
index 0000000000000..2060b71b0841f
--- /dev/null
+++ b/libc/src/math/spirv64/fminf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the fminf function for GPU ----------------------===//
+//
+// 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 "src/math/fminf.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fminf, (float x, float y)) {
+ return __builtin_fminf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fmod.cpp b/libc/src/math/spirv64/fmod.cpp
new file mode 100644
index 0000000000000..49d19c4decb96
--- /dev/null
+++ b/libc/src/math/spirv64/fmod.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the fmod function for GPU -----------------------===//
+//
+// 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 "src/math/fmod.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, fmod, (double x, double y)) {
+ return __builtin_fmod(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/fmodf.cpp b/libc/src/math/spirv64/fmodf.cpp
new file mode 100644
index 0000000000000..8fbcb0cc2ad9e
--- /dev/null
+++ b/libc/src/math/spirv64/fmodf.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the fmodf function for GPU ----------------------===//
+//
+// 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 "src/math/fmodf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fmodf, (float x, float y)) {
+ return __builtin_fmodf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/frexp.cpp b/libc/src/math/spirv64/frexp.cpp
new file mode 100644
index 0000000000000..4ae2b00198ec3
--- /dev/null
+++ b/libc/src/math/spirv64/frexp.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the frexp function for GPU ----------------------===//
+//
+// 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 "src/math/frexp.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, frexp, (double x, int *p)) {
+ return __builtin_frexp(x, p);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/frexpf.cpp b/libc/src/math/spirv64/frexpf.cpp
new file mode 100644
index 0000000000000..fd53f65701f59
--- /dev/null
+++ b/libc/src/math/spirv64/frexpf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the frexpf function for GPU ---------------------===//
+//
+// 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 "src/math/frexpf.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, frexpf, (float x, int *p)) {
+ return __builtin_frexpf(x, p);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/ldexp.cpp b/libc/src/math/spirv64/ldexp.cpp
new file mode 100644
index 0000000000000..5b786a9b21e70
--- /dev/null
+++ b/libc/src/math/spirv64/ldexp.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the ldexp function for GPU ----------------------===//
+//
+// 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 "src/math/ldexp.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, ldexp, (double x, int y)) {
+ return __builtin_ldexp(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/ldexpf.cpp b/libc/src/math/spirv64/ldexpf.cpp
new file mode 100644
index 0000000000000..d3aa77fe592cb
--- /dev/null
+++ b/libc/src/math/spirv64/ldexpf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the ldexpf function for GPU ---------------------===//
+//
+// 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 "src/math/ldexpf.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, ldexpf, (float x, int y)) {
+ return __builtin_ldexpf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/lgamma.cpp b/libc/src/math/spirv64/lgamma.cpp
new file mode 100644
index 0000000000000..2916ed5e77a5b
--- /dev/null
+++ b/libc/src/math/spirv64/lgamma.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the lgamma function for GPU ---------------------===//
+//
+// 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 "src/math/lgamma.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+extern "C" double __attribute__((overloadable)) __spirv_ocl_lgamma(double);
+LLVM_LIBC_FUNCTION(double, lgamma, (double x)) { return __spirv_ocl_lgamma(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/lgamma_r.cpp b/libc/src/math/spirv64/lgamma_r.cpp
new file mode 100644
index 0000000000000..2b01988d2a87f
--- /dev/null
+++ b/libc/src/math/spirv64/lgamma_r.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of the lgamma_r function for GPU -------------------===//
+//
+// 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 "src/math/lgamma_r.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+extern "C" double __attribute__((overloadable)) __spirv_ocl_lgamma_r(double, int*);
+LLVM_LIBC_FUNCTION(double, lgamma_r, (double x, int *signp)) {
+ return __spirv_ocl_lgamma_r(x, signp);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/llrint.cpp b/libc/src/math/spirv64/llrint.cpp
new file mode 100644
index 0000000000000..6e0f57a5a0387
--- /dev/null
+++ b/libc/src/math/spirv64/llrint.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the llrint function for GPU ---------------------===//
+//
+// 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 "src/math/llrint.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
+ return static_cast<long long>(__builtin_rint(x));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/llrintf.cpp b/libc/src/math/spirv64/llrintf.cpp
new file mode 100644
index 0000000000000..d8de23fac3c8b
--- /dev/null
+++ b/libc/src/math/spirv64/llrintf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the llrintf function for GPU --------------------===//
+//
+// 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 "src/math/llrintf.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
+ return static_cast<long long>(__builtin_rintf(x));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/lrint.cpp b/libc/src/math/spirv64/lrint.cpp
new file mode 100644
index 0000000000000..5ba70ec890b2c
--- /dev/null
+++ b/libc/src/math/spirv64/lrint.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the lrint function for GPU ----------------------===//
+//
+// 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 "src/math/lrint.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(long, lrint, (double x)) {
+ return static_cast<long>(__builtin_rint(x));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/lrintf.cpp b/libc/src/math/spirv64/lrintf.cpp
new file mode 100644
index 0000000000000..1c985b01c2dc1
--- /dev/null
+++ b/libc/src/math/spirv64/lrintf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the lrintf function for GPU ---------------------===//
+//
+// 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 "src/math/lrintf.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(long, lrintf, (float x)) {
+ return static_cast<long>(__builtin_rintf(x));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/nearbyint.cpp b/libc/src/math/spirv64/nearbyint.cpp
new file mode 100644
index 0000000000000..7d78c7241d023
--- /dev/null
+++ b/libc/src/math/spirv64/nearbyint.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the GPU nearbyint function ----------------------===//
+//
+// 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 "src/math/nearbyint.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, nearbyint, (double x)) {
+ return __builtin_nearbyint(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/nearbyintf.cpp b/libc/src/math/spirv64/nearbyintf.cpp
new file mode 100644
index 0000000000000..4bd20dc58fb89
--- /dev/null
+++ b/libc/src/math/spirv64/nearbyintf.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the GPU nearbyintf function ---------------------===//
+//
+// 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 "src/math/nearbyintf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, nearbyintf, (float x)) {
+ return __builtin_nearbyintf(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/remainder.cpp b/libc/src/math/spirv64/remainder.cpp
new file mode 100644
index 0000000000000..9027204312e00
--- /dev/null
+++ b/libc/src/math/spirv64/remainder.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the GPU remainder function ----------------------===//
+//
+// 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 "src/math/remainder.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, remainder, (double x, double y)) {
+ return __builtin_remainder(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/remainderf.cpp b/libc/src/math/spirv64/remainderf.cpp
new file mode 100644
index 0000000000000..50df3b2ce25c1
--- /dev/null
+++ b/libc/src/math/spirv64/remainderf.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the GPU remainderf function ---------------------===//
+//
+// 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 "src/math/remainderf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, remainderf, (float x, float y)) {
+ return __builtin_remainderf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/rint.cpp b/libc/src/math/spirv64/rint.cpp
new file mode 100644
index 0000000000000..ac6837a4abc37
--- /dev/null
+++ b/libc/src/math/spirv64/rint.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU rint function ---------------------------===//
+//
+// 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 "src/math/rint.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, rint, (double x)) { return __builtin_rint(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/rintf.cpp b/libc/src/math/spirv64/rintf.cpp
new file mode 100644
index 0000000000000..94093471a8d92
--- /dev/null
+++ b/libc/src/math/spirv64/rintf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU rintf function --------------------------===//
+//
+// 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 "src/math/rintf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, rintf, (float x)) { return __builtin_rintf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/round.cpp b/libc/src/math/spirv64/round.cpp
new file mode 100644
index 0000000000000..0d2765f2e959f
--- /dev/null
+++ b/libc/src/math/spirv64/round.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU round function --------------------------===//
+//
+// 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 "src/math/round.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, round, (double x)) { return __builtin_round(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/roundf.cpp b/libc/src/math/spirv64/roundf.cpp
new file mode 100644
index 0000000000000..86e8ba3ac83d6
--- /dev/null
+++ b/libc/src/math/spirv64/roundf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU roundf function -------------------------===//
+//
+// 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 "src/math/roundf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, roundf, (float x)) { return __builtin_roundf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/scalbn.cpp b/libc/src/math/spirv64/scalbn.cpp
new file mode 100644
index 0000000000000..ade0c40d8dc84
--- /dev/null
+++ b/libc/src/math/spirv64/scalbn.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the GPU scalbn function -------------------------===//
+//
+// 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 "src/math/scalbn.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, scalbn, (double x, int y)) {
+ return __builtin_ldexp(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/scalbnf.cpp b/libc/src/math/spirv64/scalbnf.cpp
new file mode 100644
index 0000000000000..b5cb06f7bda0a
--- /dev/null
+++ b/libc/src/math/spirv64/scalbnf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the GPU scalbnf function ------------------------===//
+//
+// 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 "src/math/scalbnf.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, scalbnf, (float x, int y)) {
+ return __builtin_ldexpf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/sqrt.cpp b/libc/src/math/spirv64/sqrt.cpp
new file mode 100644
index 0000000000000..ed83b6e5c6cae
--- /dev/null
+++ b/libc/src/math/spirv64/sqrt.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU sqrt function ---------------------------===//
+//
+// 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 "src/math/sqrt.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, sqrt, (double x)) { return __builtin_sqrt(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/sqrtf.cpp b/libc/src/math/spirv64/sqrtf.cpp
new file mode 100644
index 0000000000000..851922c316452
--- /dev/null
+++ b/libc/src/math/spirv64/sqrtf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU sqrtf function --------------------------===//
+//
+// 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 "src/math/sqrtf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, sqrtf, (float x)) { return __builtin_sqrtf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/tgamma.cpp b/libc/src/math/spirv64/tgamma.cpp
new file mode 100644
index 0000000000000..49691a29b7ac7
--- /dev/null
+++ b/libc/src/math/spirv64/tgamma.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of the GPU tgamma function -------------------------===//
+//
+// 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 "src/math/tgamma.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+extern "C" double __attribute__((overloadable)) __spirv_ocl_tgamma(double);
+LLVM_LIBC_FUNCTION(double, tgamma, (double x)) {
+ return __spirv_ocl_tgamma(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/tgammaf.cpp b/libc/src/math/spirv64/tgammaf.cpp
new file mode 100644
index 0000000000000..1c9aa95a7250c
--- /dev/null
+++ b/libc/src/math/spirv64/tgammaf.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of the GPU tgammaf function ------------------------===//
+//
+// 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 "src/math/tgammaf.h"
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+extern "C" float __attribute__((overloadable)) __spirv_ocl_tgamma(float);
+LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) {
+ return __spirv_ocl_tgamma(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/trunc.cpp b/libc/src/math/spirv64/trunc.cpp
new file mode 100644
index 0000000000000..f60caa2a71d78
--- /dev/null
+++ b/libc/src/math/spirv64/trunc.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU trunc function --------------------------===//
+//
+// 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 "src/math/trunc.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, trunc, (double x)) { return __builtin_trunc(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/truncf.cpp b/libc/src/math/spirv64/truncf.cpp
new file mode 100644
index 0000000000000..a6c9b8f188f02
--- /dev/null
+++ b/libc/src/math/spirv64/truncf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU truncf function -------------------------===//
+//
+// 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 "src/math/truncf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, truncf, (float x)) { return __builtin_truncf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/startup/gpu/CMakeLists.txt b/libc/startup/gpu/CMakeLists.txt
index 63e2a6c5dee1a..f83e86819cad7 100644
--- a/libc/startup/gpu/CMakeLists.txt
+++ b/libc/startup/gpu/CMakeLists.txt
@@ -33,9 +33,17 @@ function(add_startup_object name)
set_target_properties(${fq_target_name}.exe PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${LIBC_LIBRARY_DIR}
RUNTIME_OUTPUT_NAME ${name}.o)
- target_link_options(${fq_target_name}.exe PRIVATE
- ${LIBC_COMPILE_OPTIONS_DEFAULT}
- "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm")
+
+ if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^spirv" OR
+ "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^spirv")
+ target_link_options(${fq_target_name}.exe PRIVATE
+ ${LIBC_COMPILE_OPTIONS_DEFAULT}
+ "-nostdlib" "-emit-llvm")
+ else()
+ target_link_options(${fq_target_name}.exe PRIVATE
+ ${LIBC_COMPILE_OPTIONS_DEFAULT}
+ "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm")
+ endif()
endif()
endfunction()
diff --git a/libc/startup/gpu/spirv64/CMakeLists.txt b/libc/startup/gpu/spirv64/CMakeLists.txt
new file mode 100644
index 0000000000000..f41ae8ce24a08
--- /dev/null
+++ b/libc/startup/gpu/spirv64/CMakeLists.txt
@@ -0,0 +1,16 @@
+add_startup_object(
+ crt1
+ SRC
+ start.cpp
+ DEPENDS
+ libc.config.app_h
+ libc.src.__support.RPC.rpc_client
+ libc.src.__support.GPU.utils
+ libc.src.stdlib.exit
+ libc.src.stdlib.atexit
+ COMPILE_OPTIONS
+ -ffreestanding # To avoid compiler warnings about calling the main function.
+ -fno-builtin
+ -emit-llvm
+)
+get_fq_target_name(crt1 fq_name)
diff --git a/libc/startup/gpu/spirv64/start.cpp b/libc/startup/gpu/spirv64/start.cpp
new file mode 100644
index 0000000000000..780ec68c2a08a
--- /dev/null
+++ b/libc/startup/gpu/spirv64/start.cpp
@@ -0,0 +1,72 @@
+//===-- Implementation of crt for amdgpu ----------------------------------===//
+//
+// 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 "config/gpu/app.h"
+#include "src/__support/GPU/utils.h"
+#include "src/__support/RPC/rpc_client.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/atexit.h"
+#include "src/stdlib/exit.h"
+
+extern "C" int main(int argc, char **argv, char **envp);
+extern "C" void __cxa_finalize(void *dso);
+
+namespace LIBC_NAMESPACE_DECL {
+
+// FIXME: Touch this symbol to force this to be linked in statically.
+volatile void *dummy = &LIBC_NAMESPACE::rpc::client;
+
+DataEnvironment app;
+
+extern "C" uintptr_t __init_array_start[];
+extern "C" uintptr_t __init_array_end[];
+extern "C" uintptr_t __fini_array_start[];
+extern "C" uintptr_t __fini_array_end[];
+
+using InitCallback = void(int, char **, char **);
+using FiniCallback = void(void);
+
+static void call_init_array_callbacks(int argc, char **argv, char **env) {
+ size_t init_array_size = __init_array_end - __init_array_start;
+ for (size_t i = 0; i < init_array_size; ++i)
+ reinterpret_cast<InitCallback *>(__init_array_start[i])(argc, argv, env);
+}
+
+static void call_fini_array_callbacks() {
+ size_t fini_array_size = __fini_array_end - __fini_array_start;
+ for (size_t i = fini_array_size; i > 0; --i)
+ reinterpret_cast<FiniCallback *>(__fini_array_start[i - 1])();
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
+extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void
+_begin(int argc, char **argv, char **env) {
+ __atomic_store_n(&LIBC_NAMESPACE::app.env_ptr,
+ reinterpret_cast<uintptr_t *>(env), __ATOMIC_RELAXED);
+ // We want the fini array callbacks to be run after other atexit
+ // callbacks are run. So, we register them before running the init
+ // array callbacks as they can potentially register their own atexit
+ // callbacks.
+ LIBC_NAMESPACE::atexit(&LIBC_NAMESPACE::call_fini_array_callbacks);
+ LIBC_NAMESPACE::call_init_array_callbacks(argc, argv, env);
+}
+
+extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void
+_start(int argc, char **argv, char **envp, int *ret) {
+ // Invoke the 'main' function with every active thread that the user launched
+ // the _start kernel with.
+ __atomic_fetch_or(ret, main(argc, argv, envp), __ATOMIC_RELAXED);
+}
+
+extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void
+_end() {
+ // Only a single thread should call the destructors registred with 'atexit'.
+ // The loader utility will handle the actual exit and return code cleanly.
+ __cxa_finalize(nullptr);
+}
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 2e2c269c0abbc..1f88c84f2c60c 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -225,13 +225,14 @@ endif()
foreach(_name ${LLVM_RUNTIME_TARGETS})
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
- if("${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda")
+ if("${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda" OR "${_name}" STREQUAL "spirv64-intel-unknown")
set(LLVM_LIBC_GPU_BUILD ON)
endif()
endif()
endforeach()
if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
- "${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda")
+ "${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda" OR
+ "${LIBC_TARGET_TRIPLE}" STREQUAL "spirv64-intel-unknown")
set(LLVM_LIBC_GPU_BUILD ON)
endif()
>From f6fdad797f18dc07b5b7185ca784632d83137d69 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Wed, 11 Feb 2026 17:14:18 -0800
Subject: [PATCH 2/7] Fix formatting
---
clang/lib/Headers/llvm_libc_wrappers/assert.h | 3 ++-
clang/lib/Headers/llvm_libc_wrappers/ctype.h | 3 ++-
clang/lib/Headers/llvm_libc_wrappers/inttypes.h | 3 ++-
clang/lib/Headers/llvm_libc_wrappers/stdio.h | 3 ++-
clang/lib/Headers/llvm_libc_wrappers/stdlib.h | 3 ++-
clang/lib/Headers/llvm_libc_wrappers/string.h | 3 ++-
clang/lib/Headers/llvm_libc_wrappers/time.h | 3 ++-
libc/include/llvm-libc-macros/math-macros.h | 4 ++--
libc/src/__support/macros/properties/architectures.h | 3 ++-
libc/src/__support/macros/properties/cpu_features.h | 3 ++-
libc/src/math/spirv64/lgamma_r.cpp | 3 ++-
libc/src/math/spirv64/tgamma.cpp | 4 +---
libc/src/math/spirv64/tgammaf.cpp | 4 +---
libc/startup/gpu/spirv64/start.cpp | 3 +--
14 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/clang/lib/Headers/llvm_libc_wrappers/assert.h b/clang/lib/Headers/llvm_libc_wrappers/assert.h
index 3d61d5db59c36..1b3ea6b4affa6 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/assert.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/assert.h
@@ -9,7 +9,8 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
+ !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
diff --git a/clang/lib/Headers/llvm_libc_wrappers/ctype.h b/clang/lib/Headers/llvm_libc_wrappers/ctype.h
index 7879e2fb56db8..8d7bb608d4c5b 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/ctype.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/ctype.h
@@ -9,7 +9,8 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
+ !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
diff --git a/clang/lib/Headers/llvm_libc_wrappers/inttypes.h b/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
index e99d3f556ff23..154b6cc212201 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
@@ -9,7 +9,8 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
+ !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
index b914c92dd6534..4044bb8400f44 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdio.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
@@ -9,7 +9,8 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) &&!defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
+ !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdlib.h b/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
index 24145c64694da..6d4987936b295 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
@@ -9,7 +9,8 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
+ !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
diff --git a/clang/lib/Headers/llvm_libc_wrappers/string.h b/clang/lib/Headers/llvm_libc_wrappers/string.h
index 78abe2eace942..5edb86ac9d520 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/string.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -9,7 +9,8 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
+ !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
diff --git a/clang/lib/Headers/llvm_libc_wrappers/time.h b/clang/lib/Headers/llvm_libc_wrappers/time.h
index 9ed8ccc39e72b..b798d462aa7d4 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/time.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/time.h
@@ -9,7 +9,8 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
+ !defined(__SPIRV__)
#error "This file is for GPU offloading compilation only"
#endif
diff --git a/libc/include/llvm-libc-macros/math-macros.h b/libc/include/llvm-libc-macros/math-macros.h
index 2051e36f72e28..10d15b7e0f8cd 100644
--- a/libc/include/llvm-libc-macros/math-macros.h
+++ b/libc/include/llvm-libc-macros/math-macros.h
@@ -44,8 +44,8 @@
// Math error handling. Target support is assumed to be existent unless
// explicitly disabled.
-#if defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__) || defined(__FAST_MATH__) || \
- defined(__NO_MATH_ERRNO__)
+#if defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__) || \
+ defined(__FAST_MATH__) || defined(__NO_MATH_ERRNO__)
#define __LIBC_SUPPORTS_MATH_ERRNO 0
#else
#define __LIBC_SUPPORTS_MATH_ERRNO 1
diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h
index f05fe9e18e130..f73fa7a7643ab 100644
--- a/libc/src/__support/macros/properties/architectures.h
+++ b/libc/src/__support/macros/properties/architectures.h
@@ -21,7 +21,8 @@
#define LIBC_TARGET_ARCH_IS_NVPTX
#endif
-#if defined(LIBC_TARGET_ARCH_IS_NVPTX) || defined(LIBC_TARGET_ARCH_IS_AMDGPU) || defined(LIBC_TARGET_ARCH_IS_SPIRV)
+#if defined(LIBC_TARGET_ARCH_IS_NVPTX) || \
+ defined(LIBC_TARGET_ARCH_IS_AMDGPU) || defined(LIBC_TARGET_ARCH_IS_SPIRV)
#define LIBC_TARGET_ARCH_IS_GPU
#endif
diff --git a/libc/src/__support/macros/properties/cpu_features.h b/libc/src/__support/macros/properties/cpu_features.h
index 00129927263d6..ce676d01577fb 100644
--- a/libc/src/__support/macros/properties/cpu_features.h
+++ b/libc/src/__support/macros/properties/cpu_features.h
@@ -97,7 +97,8 @@
#endif
#if defined(__ARM_FEATURE_FMA) || (defined(__AVX2__) && defined(__FMA__)) || \
- defined(__NVPTX__) || defined(__AMDGPU__) || defined(__riscv_flen) || defined(__SPIRV__)
+ defined(__NVPTX__) || defined(__AMDGPU__) || defined(__riscv_flen) || \
+ defined(__SPIRV__)
#define LIBC_TARGET_CPU_HAS_FMA
// Provide a more fine-grained control of FMA instruction for ARM targets.
#if defined(LIBC_TARGET_CPU_HAS_FPU_HALF)
diff --git a/libc/src/math/spirv64/lgamma_r.cpp b/libc/src/math/spirv64/lgamma_r.cpp
index 2b01988d2a87f..efb388e52d05c 100644
--- a/libc/src/math/spirv64/lgamma_r.cpp
+++ b/libc/src/math/spirv64/lgamma_r.cpp
@@ -13,7 +13,8 @@
namespace LIBC_NAMESPACE_DECL {
-extern "C" double __attribute__((overloadable)) __spirv_ocl_lgamma_r(double, int*);
+extern "C" double __attribute__((overloadable)) __spirv_ocl_lgamma_r(double,
+ int *);
LLVM_LIBC_FUNCTION(double, lgamma_r, (double x, int *signp)) {
return __spirv_ocl_lgamma_r(x, signp);
}
diff --git a/libc/src/math/spirv64/tgamma.cpp b/libc/src/math/spirv64/tgamma.cpp
index 49691a29b7ac7..2395e56ac25da 100644
--- a/libc/src/math/spirv64/tgamma.cpp
+++ b/libc/src/math/spirv64/tgamma.cpp
@@ -14,8 +14,6 @@
namespace LIBC_NAMESPACE_DECL {
extern "C" double __attribute__((overloadable)) __spirv_ocl_tgamma(double);
-LLVM_LIBC_FUNCTION(double, tgamma, (double x)) {
- return __spirv_ocl_tgamma(x);
-}
+LLVM_LIBC_FUNCTION(double, tgamma, (double x)) { return __spirv_ocl_tgamma(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv64/tgammaf.cpp b/libc/src/math/spirv64/tgammaf.cpp
index 1c9aa95a7250c..ae9af5e74840c 100644
--- a/libc/src/math/spirv64/tgammaf.cpp
+++ b/libc/src/math/spirv64/tgammaf.cpp
@@ -14,8 +14,6 @@
namespace LIBC_NAMESPACE_DECL {
extern "C" float __attribute__((overloadable)) __spirv_ocl_tgamma(float);
-LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) {
- return __spirv_ocl_tgamma(x);
-}
+LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) { return __spirv_ocl_tgamma(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/startup/gpu/spirv64/start.cpp b/libc/startup/gpu/spirv64/start.cpp
index 780ec68c2a08a..702f76647636b 100644
--- a/libc/startup/gpu/spirv64/start.cpp
+++ b/libc/startup/gpu/spirv64/start.cpp
@@ -64,8 +64,7 @@ _start(int argc, char **argv, char **envp, int *ret) {
__atomic_fetch_or(ret, main(argc, argv, envp), __ATOMIC_RELAXED);
}
-extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void
-_end() {
+extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void _end() {
// Only a single thread should call the destructors registred with 'atexit'.
// The loader utility will handle the actual exit and return code cleanly.
__cxa_finalize(nullptr);
>From d9c2f455a1420bface2462523866a828a66cf1d9 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Thu, 12 Feb 2026 22:23:22 -0800
Subject: [PATCH 3/7] Address PR comments
---
clang/lib/Headers/llvm_libc_wrappers/assert.h | 5 ++---
clang/lib/Headers/llvm_libc_wrappers/ctype.h | 5 ++---
clang/lib/Headers/llvm_libc_wrappers/inttypes.h | 5 ++---
clang/lib/Headers/llvm_libc_wrappers/stdio.h | 5 ++---
clang/lib/Headers/llvm_libc_wrappers/stdlib.h | 5 ++---
clang/lib/Headers/llvm_libc_wrappers/string.h | 5 ++---
clang/lib/Headers/llvm_libc_wrappers/time.h | 5 ++---
clang/lib/Headers/openmp_wrappers/new | 2 +-
libc/cmake/modules/LLVMLibCArchitectures.cmake | 10 +++++-----
libc/config/gpu/{spirv64 => spirv}/entrypoints.txt | 0
libc/config/gpu/{spirv64 => spirv}/headers.txt | 0
libc/src/math/{spirv64 => spirv}/CMakeLists.txt | 0
libc/src/math/{spirv64 => spirv}/ceil.cpp | 0
libc/src/math/{spirv64 => spirv}/ceilf.cpp | 0
libc/src/math/{spirv64 => spirv}/copysign.cpp | 0
libc/src/math/{spirv64 => spirv}/copysignf.cpp | 0
libc/src/math/{spirv64 => spirv}/fabs.cpp | 0
libc/src/math/{spirv64 => spirv}/fabsf.cpp | 0
libc/src/math/{spirv64 => spirv}/floor.cpp | 0
libc/src/math/{spirv64 => spirv}/floorf.cpp | 0
libc/src/math/{spirv64 => spirv}/fma.cpp | 0
libc/src/math/{spirv64 => spirv}/fmaf.cpp | 0
libc/src/math/{spirv64 => spirv}/fmax.cpp | 0
libc/src/math/{spirv64 => spirv}/fmaxf.cpp | 0
libc/src/math/{spirv64 => spirv}/fmin.cpp | 0
libc/src/math/{spirv64 => spirv}/fminf.cpp | 0
libc/src/math/{spirv64 => spirv}/fmod.cpp | 0
libc/src/math/{spirv64 => spirv}/fmodf.cpp | 0
libc/src/math/{spirv64 => spirv}/frexp.cpp | 0
libc/src/math/{spirv64 => spirv}/frexpf.cpp | 0
libc/src/math/{spirv64 => spirv}/ldexp.cpp | 0
libc/src/math/{spirv64 => spirv}/ldexpf.cpp | 0
libc/src/math/{spirv64 => spirv}/lgamma.cpp | 0
libc/src/math/{spirv64 => spirv}/lgamma_r.cpp | 0
libc/src/math/{spirv64 => spirv}/llrint.cpp | 0
libc/src/math/{spirv64 => spirv}/llrintf.cpp | 0
libc/src/math/{spirv64 => spirv}/lrint.cpp | 0
libc/src/math/{spirv64 => spirv}/lrintf.cpp | 0
libc/src/math/{spirv64 => spirv}/nearbyint.cpp | 0
libc/src/math/{spirv64 => spirv}/nearbyintf.cpp | 0
libc/src/math/{spirv64 => spirv}/remainder.cpp | 0
libc/src/math/{spirv64 => spirv}/remainderf.cpp | 0
libc/src/math/{spirv64 => spirv}/rint.cpp | 0
libc/src/math/{spirv64 => spirv}/rintf.cpp | 0
libc/src/math/{spirv64 => spirv}/round.cpp | 0
libc/src/math/{spirv64 => spirv}/roundf.cpp | 0
libc/src/math/{spirv64 => spirv}/scalbn.cpp | 0
libc/src/math/{spirv64 => spirv}/scalbnf.cpp | 0
libc/src/math/{spirv64 => spirv}/sqrt.cpp | 0
libc/src/math/{spirv64 => spirv}/sqrtf.cpp | 0
libc/src/math/{spirv64 => spirv}/tgamma.cpp | 0
libc/src/math/{spirv64 => spirv}/tgammaf.cpp | 0
libc/src/math/{spirv64 => spirv}/trunc.cpp | 0
libc/src/math/{spirv64 => spirv}/truncf.cpp | 0
libc/startup/gpu/{spirv64 => spirv}/CMakeLists.txt | 0
libc/startup/gpu/{spirv64 => spirv}/start.cpp | 0
56 files changed, 20 insertions(+), 27 deletions(-)
rename libc/config/gpu/{spirv64 => spirv}/entrypoints.txt (100%)
rename libc/config/gpu/{spirv64 => spirv}/headers.txt (100%)
rename libc/src/math/{spirv64 => spirv}/CMakeLists.txt (100%)
rename libc/src/math/{spirv64 => spirv}/ceil.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/ceilf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/copysign.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/copysignf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fabs.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fabsf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/floor.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/floorf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fma.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fmaf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fmax.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fmaxf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fmin.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fminf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fmod.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/fmodf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/frexp.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/frexpf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/ldexp.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/ldexpf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/lgamma.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/lgamma_r.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/llrint.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/llrintf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/lrint.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/lrintf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/nearbyint.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/nearbyintf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/remainder.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/remainderf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/rint.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/rintf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/round.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/roundf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/scalbn.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/scalbnf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/sqrt.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/sqrtf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/tgamma.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/tgammaf.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/trunc.cpp (100%)
rename libc/src/math/{spirv64 => spirv}/truncf.cpp (100%)
rename libc/startup/gpu/{spirv64 => spirv}/CMakeLists.txt (100%)
rename libc/startup/gpu/{spirv64 => spirv}/start.cpp (100%)
diff --git a/clang/lib/Headers/llvm_libc_wrappers/assert.h b/clang/lib/Headers/llvm_libc_wrappers/assert.h
index 1b3ea6b4affa6..7eadb2c354aab 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/assert.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/assert.h
@@ -9,8 +9,7 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
- !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif
@@ -18,7 +17,7 @@
#if __has_include(<llvm-libc-decls/assert.h>)
-#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
+#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/ctype.h b/clang/lib/Headers/llvm_libc_wrappers/ctype.h
index 8d7bb608d4c5b..79b0c1e9be953 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/ctype.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/ctype.h
@@ -9,14 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
- !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <ctype.h>
-#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
+#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/inttypes.h b/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
index 154b6cc212201..22613898248f3 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/inttypes.h
@@ -9,8 +9,7 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
- !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif
@@ -18,7 +17,7 @@
#if __has_include(<llvm-libc-decls/inttypes.h>)
-#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
+#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
index 4044bb8400f44..52c88bc52506a 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdio.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
@@ -9,14 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
- !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <stdio.h>
-#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
+#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdlib.h b/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
index 6d4987936b295..7af5e2ebe031a 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdlib.h
@@ -9,14 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
- !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <stdlib.h>
-#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
+#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/string.h b/clang/lib/Headers/llvm_libc_wrappers/string.h
index 5edb86ac9d520..766a58f5b6db4 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/string.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -9,14 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
- !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <string.h>
-#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
+#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/llvm_libc_wrappers/time.h b/clang/lib/Headers/llvm_libc_wrappers/time.h
index b798d462aa7d4..d38eea327a199 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/time.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/time.h
@@ -9,14 +9,13 @@
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__
-#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) && \
- !defined(__SPIRV__)
+#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif
#include_next <time.h>
-#if defined(__HIP__) || defined(__CUDA__) || defined(__SPIRV__)
+#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#else
#define __LIBC_ATTRS
diff --git a/clang/lib/Headers/openmp_wrappers/new b/clang/lib/Headers/openmp_wrappers/new
index de40cb9a210a1..8bad3f19d6251 100644
--- a/clang/lib/Headers/openmp_wrappers/new
+++ b/clang/lib/Headers/openmp_wrappers/new
@@ -13,7 +13,7 @@
// which do not use nothrow_t are provided without the <new> header.
#include_next <new>
-#if (defined(__NVPTX__) || defined(__AMDGPU__) || defined(__SPIRV__)) && defined(_OPENMP)
+#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(_OPENMP)
#include <cstdlib>
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 5f2be539e7169..2bd16d7154bc2 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -51,8 +51,8 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
set(target_arch "amdgpu")
elseif(target_arch MATCHES "^nvptx64")
set(target_arch "nvptx")
- elseif(target_arch MATCHES "^spirv64")
- set(target_arch "spirv64")
+ elseif(target_arch MATCHES "^spirv")
+ set(target_arch "spirv")
else()
return()
endif()
@@ -71,11 +71,11 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
# Setting OS name for GPU architectures.
list(GET triple_comps -1 gpu_target_sys)
- if(gpu_target_sys MATCHES "^amdhsa" OR gpu_target_sys MATCHES "^cuda" OR target_arch MATCHES "^spirv64")
+ if(gpu_target_sys MATCHES "^amdhsa" OR gpu_target_sys MATCHES "^cuda" OR target_arch MATCHES "^spirv")
set(target_sys "gpu")
endif()
- if (target_arch MATCHES "^spirv64")
+ if (target_arch MATCHES "^spirv")
list(APPEND
LIBC_COMPILE_OPTIONS_DEFAULT "-emit-llvm")
endif()
@@ -186,7 +186,7 @@ elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "amdgpu")
set(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU TRUE)
elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "nvptx")
set(LIBC_TARGET_ARCHITECTURE_IS_NVPTX TRUE)
-elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "spirv64")
+elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "spirv")
set(LIBC_TARGET_ARCHITECTURE_IS_SPIRV TRUE)
else()
message(FATAL_ERROR
diff --git a/libc/config/gpu/spirv64/entrypoints.txt b/libc/config/gpu/spirv/entrypoints.txt
similarity index 100%
rename from libc/config/gpu/spirv64/entrypoints.txt
rename to libc/config/gpu/spirv/entrypoints.txt
diff --git a/libc/config/gpu/spirv64/headers.txt b/libc/config/gpu/spirv/headers.txt
similarity index 100%
rename from libc/config/gpu/spirv64/headers.txt
rename to libc/config/gpu/spirv/headers.txt
diff --git a/libc/src/math/spirv64/CMakeLists.txt b/libc/src/math/spirv/CMakeLists.txt
similarity index 100%
rename from libc/src/math/spirv64/CMakeLists.txt
rename to libc/src/math/spirv/CMakeLists.txt
diff --git a/libc/src/math/spirv64/ceil.cpp b/libc/src/math/spirv/ceil.cpp
similarity index 100%
rename from libc/src/math/spirv64/ceil.cpp
rename to libc/src/math/spirv/ceil.cpp
diff --git a/libc/src/math/spirv64/ceilf.cpp b/libc/src/math/spirv/ceilf.cpp
similarity index 100%
rename from libc/src/math/spirv64/ceilf.cpp
rename to libc/src/math/spirv/ceilf.cpp
diff --git a/libc/src/math/spirv64/copysign.cpp b/libc/src/math/spirv/copysign.cpp
similarity index 100%
rename from libc/src/math/spirv64/copysign.cpp
rename to libc/src/math/spirv/copysign.cpp
diff --git a/libc/src/math/spirv64/copysignf.cpp b/libc/src/math/spirv/copysignf.cpp
similarity index 100%
rename from libc/src/math/spirv64/copysignf.cpp
rename to libc/src/math/spirv/copysignf.cpp
diff --git a/libc/src/math/spirv64/fabs.cpp b/libc/src/math/spirv/fabs.cpp
similarity index 100%
rename from libc/src/math/spirv64/fabs.cpp
rename to libc/src/math/spirv/fabs.cpp
diff --git a/libc/src/math/spirv64/fabsf.cpp b/libc/src/math/spirv/fabsf.cpp
similarity index 100%
rename from libc/src/math/spirv64/fabsf.cpp
rename to libc/src/math/spirv/fabsf.cpp
diff --git a/libc/src/math/spirv64/floor.cpp b/libc/src/math/spirv/floor.cpp
similarity index 100%
rename from libc/src/math/spirv64/floor.cpp
rename to libc/src/math/spirv/floor.cpp
diff --git a/libc/src/math/spirv64/floorf.cpp b/libc/src/math/spirv/floorf.cpp
similarity index 100%
rename from libc/src/math/spirv64/floorf.cpp
rename to libc/src/math/spirv/floorf.cpp
diff --git a/libc/src/math/spirv64/fma.cpp b/libc/src/math/spirv/fma.cpp
similarity index 100%
rename from libc/src/math/spirv64/fma.cpp
rename to libc/src/math/spirv/fma.cpp
diff --git a/libc/src/math/spirv64/fmaf.cpp b/libc/src/math/spirv/fmaf.cpp
similarity index 100%
rename from libc/src/math/spirv64/fmaf.cpp
rename to libc/src/math/spirv/fmaf.cpp
diff --git a/libc/src/math/spirv64/fmax.cpp b/libc/src/math/spirv/fmax.cpp
similarity index 100%
rename from libc/src/math/spirv64/fmax.cpp
rename to libc/src/math/spirv/fmax.cpp
diff --git a/libc/src/math/spirv64/fmaxf.cpp b/libc/src/math/spirv/fmaxf.cpp
similarity index 100%
rename from libc/src/math/spirv64/fmaxf.cpp
rename to libc/src/math/spirv/fmaxf.cpp
diff --git a/libc/src/math/spirv64/fmin.cpp b/libc/src/math/spirv/fmin.cpp
similarity index 100%
rename from libc/src/math/spirv64/fmin.cpp
rename to libc/src/math/spirv/fmin.cpp
diff --git a/libc/src/math/spirv64/fminf.cpp b/libc/src/math/spirv/fminf.cpp
similarity index 100%
rename from libc/src/math/spirv64/fminf.cpp
rename to libc/src/math/spirv/fminf.cpp
diff --git a/libc/src/math/spirv64/fmod.cpp b/libc/src/math/spirv/fmod.cpp
similarity index 100%
rename from libc/src/math/spirv64/fmod.cpp
rename to libc/src/math/spirv/fmod.cpp
diff --git a/libc/src/math/spirv64/fmodf.cpp b/libc/src/math/spirv/fmodf.cpp
similarity index 100%
rename from libc/src/math/spirv64/fmodf.cpp
rename to libc/src/math/spirv/fmodf.cpp
diff --git a/libc/src/math/spirv64/frexp.cpp b/libc/src/math/spirv/frexp.cpp
similarity index 100%
rename from libc/src/math/spirv64/frexp.cpp
rename to libc/src/math/spirv/frexp.cpp
diff --git a/libc/src/math/spirv64/frexpf.cpp b/libc/src/math/spirv/frexpf.cpp
similarity index 100%
rename from libc/src/math/spirv64/frexpf.cpp
rename to libc/src/math/spirv/frexpf.cpp
diff --git a/libc/src/math/spirv64/ldexp.cpp b/libc/src/math/spirv/ldexp.cpp
similarity index 100%
rename from libc/src/math/spirv64/ldexp.cpp
rename to libc/src/math/spirv/ldexp.cpp
diff --git a/libc/src/math/spirv64/ldexpf.cpp b/libc/src/math/spirv/ldexpf.cpp
similarity index 100%
rename from libc/src/math/spirv64/ldexpf.cpp
rename to libc/src/math/spirv/ldexpf.cpp
diff --git a/libc/src/math/spirv64/lgamma.cpp b/libc/src/math/spirv/lgamma.cpp
similarity index 100%
rename from libc/src/math/spirv64/lgamma.cpp
rename to libc/src/math/spirv/lgamma.cpp
diff --git a/libc/src/math/spirv64/lgamma_r.cpp b/libc/src/math/spirv/lgamma_r.cpp
similarity index 100%
rename from libc/src/math/spirv64/lgamma_r.cpp
rename to libc/src/math/spirv/lgamma_r.cpp
diff --git a/libc/src/math/spirv64/llrint.cpp b/libc/src/math/spirv/llrint.cpp
similarity index 100%
rename from libc/src/math/spirv64/llrint.cpp
rename to libc/src/math/spirv/llrint.cpp
diff --git a/libc/src/math/spirv64/llrintf.cpp b/libc/src/math/spirv/llrintf.cpp
similarity index 100%
rename from libc/src/math/spirv64/llrintf.cpp
rename to libc/src/math/spirv/llrintf.cpp
diff --git a/libc/src/math/spirv64/lrint.cpp b/libc/src/math/spirv/lrint.cpp
similarity index 100%
rename from libc/src/math/spirv64/lrint.cpp
rename to libc/src/math/spirv/lrint.cpp
diff --git a/libc/src/math/spirv64/lrintf.cpp b/libc/src/math/spirv/lrintf.cpp
similarity index 100%
rename from libc/src/math/spirv64/lrintf.cpp
rename to libc/src/math/spirv/lrintf.cpp
diff --git a/libc/src/math/spirv64/nearbyint.cpp b/libc/src/math/spirv/nearbyint.cpp
similarity index 100%
rename from libc/src/math/spirv64/nearbyint.cpp
rename to libc/src/math/spirv/nearbyint.cpp
diff --git a/libc/src/math/spirv64/nearbyintf.cpp b/libc/src/math/spirv/nearbyintf.cpp
similarity index 100%
rename from libc/src/math/spirv64/nearbyintf.cpp
rename to libc/src/math/spirv/nearbyintf.cpp
diff --git a/libc/src/math/spirv64/remainder.cpp b/libc/src/math/spirv/remainder.cpp
similarity index 100%
rename from libc/src/math/spirv64/remainder.cpp
rename to libc/src/math/spirv/remainder.cpp
diff --git a/libc/src/math/spirv64/remainderf.cpp b/libc/src/math/spirv/remainderf.cpp
similarity index 100%
rename from libc/src/math/spirv64/remainderf.cpp
rename to libc/src/math/spirv/remainderf.cpp
diff --git a/libc/src/math/spirv64/rint.cpp b/libc/src/math/spirv/rint.cpp
similarity index 100%
rename from libc/src/math/spirv64/rint.cpp
rename to libc/src/math/spirv/rint.cpp
diff --git a/libc/src/math/spirv64/rintf.cpp b/libc/src/math/spirv/rintf.cpp
similarity index 100%
rename from libc/src/math/spirv64/rintf.cpp
rename to libc/src/math/spirv/rintf.cpp
diff --git a/libc/src/math/spirv64/round.cpp b/libc/src/math/spirv/round.cpp
similarity index 100%
rename from libc/src/math/spirv64/round.cpp
rename to libc/src/math/spirv/round.cpp
diff --git a/libc/src/math/spirv64/roundf.cpp b/libc/src/math/spirv/roundf.cpp
similarity index 100%
rename from libc/src/math/spirv64/roundf.cpp
rename to libc/src/math/spirv/roundf.cpp
diff --git a/libc/src/math/spirv64/scalbn.cpp b/libc/src/math/spirv/scalbn.cpp
similarity index 100%
rename from libc/src/math/spirv64/scalbn.cpp
rename to libc/src/math/spirv/scalbn.cpp
diff --git a/libc/src/math/spirv64/scalbnf.cpp b/libc/src/math/spirv/scalbnf.cpp
similarity index 100%
rename from libc/src/math/spirv64/scalbnf.cpp
rename to libc/src/math/spirv/scalbnf.cpp
diff --git a/libc/src/math/spirv64/sqrt.cpp b/libc/src/math/spirv/sqrt.cpp
similarity index 100%
rename from libc/src/math/spirv64/sqrt.cpp
rename to libc/src/math/spirv/sqrt.cpp
diff --git a/libc/src/math/spirv64/sqrtf.cpp b/libc/src/math/spirv/sqrtf.cpp
similarity index 100%
rename from libc/src/math/spirv64/sqrtf.cpp
rename to libc/src/math/spirv/sqrtf.cpp
diff --git a/libc/src/math/spirv64/tgamma.cpp b/libc/src/math/spirv/tgamma.cpp
similarity index 100%
rename from libc/src/math/spirv64/tgamma.cpp
rename to libc/src/math/spirv/tgamma.cpp
diff --git a/libc/src/math/spirv64/tgammaf.cpp b/libc/src/math/spirv/tgammaf.cpp
similarity index 100%
rename from libc/src/math/spirv64/tgammaf.cpp
rename to libc/src/math/spirv/tgammaf.cpp
diff --git a/libc/src/math/spirv64/trunc.cpp b/libc/src/math/spirv/trunc.cpp
similarity index 100%
rename from libc/src/math/spirv64/trunc.cpp
rename to libc/src/math/spirv/trunc.cpp
diff --git a/libc/src/math/spirv64/truncf.cpp b/libc/src/math/spirv/truncf.cpp
similarity index 100%
rename from libc/src/math/spirv64/truncf.cpp
rename to libc/src/math/spirv/truncf.cpp
diff --git a/libc/startup/gpu/spirv64/CMakeLists.txt b/libc/startup/gpu/spirv/CMakeLists.txt
similarity index 100%
rename from libc/startup/gpu/spirv64/CMakeLists.txt
rename to libc/startup/gpu/spirv/CMakeLists.txt
diff --git a/libc/startup/gpu/spirv64/start.cpp b/libc/startup/gpu/spirv/start.cpp
similarity index 100%
rename from libc/startup/gpu/spirv64/start.cpp
rename to libc/startup/gpu/spirv/start.cpp
>From e64645ad98c2963d7f536c97ed0c7ddb0396820c Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Thu, 12 Feb 2026 22:25:35 -0800
Subject: [PATCH 4/7] Address PR comments
---
clang/lib/Headers/llvm_libc_wrappers/stdio.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
index 52c88bc52506a..0c3e44823da70 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdio.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
@@ -41,7 +41,7 @@ __LIBC_ATTRS extern FILE *stdout;
#pragma omp end declare target
// Restore the original macros when compiling on the host.
-#if !defined(__NVPTX__) && !defined(__AMDGPU__) && !defined(__SPIRV__)
+#if !defined(__NVPTX__) && !defined(__AMDGPU__)
#pragma pop_macro("stderr")
#pragma pop_macro("stdin")
#pragma pop_macro("stdout")
>From 5faffbc6749bd0dfba8611c92541ba140b59a52d Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Mon, 16 Feb 2026 14:04:50 -0800
Subject: [PATCH 5/7] Remove implementations to minmize the size of the PR
---
libc/config/gpu/spirv/entrypoints.txt | 675 --------------------------
libc/config/gpu/spirv/headers.txt | 19 -
libc/src/math/spirv/CMakeLists.txt | 303 ------------
libc/src/math/spirv/ceil.cpp | 17 -
libc/src/math/spirv/ceilf.cpp | 17 -
libc/src/math/spirv/copysign.cpp | 19 -
libc/src/math/spirv/copysignf.cpp | 19 -
libc/src/math/spirv/fabs.cpp | 17 -
libc/src/math/spirv/fabsf.cpp | 17 -
libc/src/math/spirv/floor.cpp | 17 -
libc/src/math/spirv/floorf.cpp | 17 -
libc/src/math/spirv/fma.cpp | 19 -
libc/src/math/spirv/fmaf.cpp | 19 -
libc/src/math/spirv/fmax.cpp | 22 -
libc/src/math/spirv/fmaxf.cpp | 20 -
libc/src/math/spirv/fmin.cpp | 20 -
libc/src/math/spirv/fminf.cpp | 20 -
libc/src/math/spirv/fmod.cpp | 19 -
libc/src/math/spirv/fmodf.cpp | 19 -
libc/src/math/spirv/frexp.cpp | 20 -
libc/src/math/spirv/frexpf.cpp | 20 -
libc/src/math/spirv/ldexp.cpp | 20 -
libc/src/math/spirv/ldexpf.cpp | 20 -
libc/src/math/spirv/lgamma.cpp | 19 -
libc/src/math/spirv/lgamma_r.cpp | 22 -
libc/src/math/spirv/llrint.cpp | 20 -
libc/src/math/spirv/llrintf.cpp | 20 -
libc/src/math/spirv/lrint.cpp | 20 -
libc/src/math/spirv/lrintf.cpp | 20 -
libc/src/math/spirv/nearbyint.cpp | 19 -
libc/src/math/spirv/nearbyintf.cpp | 19 -
libc/src/math/spirv/remainder.cpp | 19 -
libc/src/math/spirv/remainderf.cpp | 19 -
libc/src/math/spirv/rint.cpp | 17 -
libc/src/math/spirv/rintf.cpp | 17 -
libc/src/math/spirv/round.cpp | 17 -
libc/src/math/spirv/roundf.cpp | 17 -
libc/src/math/spirv/scalbn.cpp | 20 -
libc/src/math/spirv/scalbnf.cpp | 20 -
libc/src/math/spirv/sqrt.cpp | 17 -
libc/src/math/spirv/sqrtf.cpp | 17 -
libc/src/math/spirv/tgamma.cpp | 19 -
libc/src/math/spirv/tgammaf.cpp | 19 -
libc/src/math/spirv/trunc.cpp | 17 -
libc/src/math/spirv/truncf.cpp | 17 -
45 files changed, 1786 deletions(-)
delete mode 100644 libc/src/math/spirv/CMakeLists.txt
delete mode 100644 libc/src/math/spirv/ceil.cpp
delete mode 100644 libc/src/math/spirv/ceilf.cpp
delete mode 100644 libc/src/math/spirv/copysign.cpp
delete mode 100644 libc/src/math/spirv/copysignf.cpp
delete mode 100644 libc/src/math/spirv/fabs.cpp
delete mode 100644 libc/src/math/spirv/fabsf.cpp
delete mode 100644 libc/src/math/spirv/floor.cpp
delete mode 100644 libc/src/math/spirv/floorf.cpp
delete mode 100644 libc/src/math/spirv/fma.cpp
delete mode 100644 libc/src/math/spirv/fmaf.cpp
delete mode 100644 libc/src/math/spirv/fmax.cpp
delete mode 100644 libc/src/math/spirv/fmaxf.cpp
delete mode 100644 libc/src/math/spirv/fmin.cpp
delete mode 100644 libc/src/math/spirv/fminf.cpp
delete mode 100644 libc/src/math/spirv/fmod.cpp
delete mode 100644 libc/src/math/spirv/fmodf.cpp
delete mode 100644 libc/src/math/spirv/frexp.cpp
delete mode 100644 libc/src/math/spirv/frexpf.cpp
delete mode 100644 libc/src/math/spirv/ldexp.cpp
delete mode 100644 libc/src/math/spirv/ldexpf.cpp
delete mode 100644 libc/src/math/spirv/lgamma.cpp
delete mode 100644 libc/src/math/spirv/lgamma_r.cpp
delete mode 100644 libc/src/math/spirv/llrint.cpp
delete mode 100644 libc/src/math/spirv/llrintf.cpp
delete mode 100644 libc/src/math/spirv/lrint.cpp
delete mode 100644 libc/src/math/spirv/lrintf.cpp
delete mode 100644 libc/src/math/spirv/nearbyint.cpp
delete mode 100644 libc/src/math/spirv/nearbyintf.cpp
delete mode 100644 libc/src/math/spirv/remainder.cpp
delete mode 100644 libc/src/math/spirv/remainderf.cpp
delete mode 100644 libc/src/math/spirv/rint.cpp
delete mode 100644 libc/src/math/spirv/rintf.cpp
delete mode 100644 libc/src/math/spirv/round.cpp
delete mode 100644 libc/src/math/spirv/roundf.cpp
delete mode 100644 libc/src/math/spirv/scalbn.cpp
delete mode 100644 libc/src/math/spirv/scalbnf.cpp
delete mode 100644 libc/src/math/spirv/sqrt.cpp
delete mode 100644 libc/src/math/spirv/sqrtf.cpp
delete mode 100644 libc/src/math/spirv/tgamma.cpp
delete mode 100644 libc/src/math/spirv/tgammaf.cpp
delete mode 100644 libc/src/math/spirv/trunc.cpp
delete mode 100644 libc/src/math/spirv/truncf.cpp
diff --git a/libc/config/gpu/spirv/entrypoints.txt b/libc/config/gpu/spirv/entrypoints.txt
index 0dda7d5c683ec..fc4e12324c5bf 100644
--- a/libc/config/gpu/spirv/entrypoints.txt
+++ b/libc/config/gpu/spirv/entrypoints.txt
@@ -1,690 +1,15 @@
set(TARGET_LIBC_ENTRYPOINTS
- # assert.h entrypoints
- libc.src.assert.__assert_fail
-
- # ctype.h entrypoints
- libc.src.ctype.isalnum
- libc.src.ctype.isalnum_l
- libc.src.ctype.isalpha
- libc.src.ctype.isalpha_l
- libc.src.ctype.isascii
- libc.src.ctype.isblank
- libc.src.ctype.isblank_l
- libc.src.ctype.iscntrl
- libc.src.ctype.iscntrl_l
- libc.src.ctype.isdigit
- libc.src.ctype.isdigit_l
- libc.src.ctype.isgraph
- libc.src.ctype.isgraph_l
- libc.src.ctype.islower
- libc.src.ctype.islower_l
- libc.src.ctype.isprint
- libc.src.ctype.isprint_l
- libc.src.ctype.ispunct
- libc.src.ctype.ispunct_l
- libc.src.ctype.isspace
- libc.src.ctype.isspace_l
- libc.src.ctype.isupper
- libc.src.ctype.isupper_l
- libc.src.ctype.isxdigit
- libc.src.ctype.isxdigit_l
- libc.src.ctype.toascii
- libc.src.ctype.tolower
- libc.src.ctype.tolower_l
- libc.src.ctype.toupper
- libc.src.ctype.toupper_l
-
- # string.h entrypoints
- libc.src.string.memccpy
- libc.src.string.memchr
- libc.src.string.memcmp
- libc.src.string.memcpy
- libc.src.string.memmem
- libc.src.string.memmove
- libc.src.string.mempcpy
- libc.src.string.memrchr
- libc.src.string.memset
- libc.src.string.stpcpy
- libc.src.string.stpncpy
- libc.src.string.strcasestr
- libc.src.string.strcat
- libc.src.string.strchr
- libc.src.string.strchrnul
- libc.src.string.strcmp
- libc.src.string.strcoll
- libc.src.string.strcoll_l
- libc.src.string.strcpy
- libc.src.string.strcspn
- libc.src.string.strdup
- libc.src.string.strerror
- libc.src.string.strlcat
- libc.src.string.strlcpy
- libc.src.string.strlen
- libc.src.string.strncat
- libc.src.string.strncmp
- libc.src.string.strncpy
- libc.src.string.strndup
- libc.src.string.strnlen
- libc.src.string.strpbrk
- libc.src.string.strrchr
- libc.src.string.strsep
- libc.src.string.strspn
- libc.src.string.strstr
- libc.src.string.strtok
- libc.src.string.strtok_r
- libc.src.string.strxfrm
- libc.src.string.strxfrm_l
-
- # strings.h entrypoints
- libc.src.strings.bcmp
- libc.src.strings.bcopy
- libc.src.strings.bzero
- libc.src.strings.index
- libc.src.strings.rindex
- libc.src.strings.strcasecmp
- libc.src.strings.strncasecmp
-
- # stdbit.h entrypoints
- libc.src.stdbit.stdc_bit_ceil_uc
- libc.src.stdbit.stdc_bit_ceil_ui
- libc.src.stdbit.stdc_bit_ceil_ul
- libc.src.stdbit.stdc_bit_ceil_ull
- libc.src.stdbit.stdc_bit_ceil_us
- libc.src.stdbit.stdc_bit_floor_uc
- libc.src.stdbit.stdc_bit_floor_ui
- libc.src.stdbit.stdc_bit_floor_ul
- libc.src.stdbit.stdc_bit_floor_ull
- libc.src.stdbit.stdc_bit_floor_us
- libc.src.stdbit.stdc_bit_width_uc
- libc.src.stdbit.stdc_bit_width_ui
- libc.src.stdbit.stdc_bit_width_ul
- libc.src.stdbit.stdc_bit_width_ull
- libc.src.stdbit.stdc_bit_width_us
- libc.src.stdbit.stdc_count_ones_uc
- libc.src.stdbit.stdc_count_ones_ui
- libc.src.stdbit.stdc_count_ones_ul
- libc.src.stdbit.stdc_count_ones_ull
- libc.src.stdbit.stdc_count_ones_us
- libc.src.stdbit.stdc_count_zeros_uc
- libc.src.stdbit.stdc_count_zeros_ui
- libc.src.stdbit.stdc_count_zeros_ul
- libc.src.stdbit.stdc_count_zeros_ull
- libc.src.stdbit.stdc_count_zeros_us
- libc.src.stdbit.stdc_first_leading_one_uc
- libc.src.stdbit.stdc_first_leading_one_ui
- libc.src.stdbit.stdc_first_leading_one_ul
- libc.src.stdbit.stdc_first_leading_one_ull
- libc.src.stdbit.stdc_first_leading_one_us
- libc.src.stdbit.stdc_first_leading_zero_uc
- libc.src.stdbit.stdc_first_leading_zero_ui
- libc.src.stdbit.stdc_first_leading_zero_ul
- libc.src.stdbit.stdc_first_leading_zero_ull
- libc.src.stdbit.stdc_first_leading_zero_us
- libc.src.stdbit.stdc_first_trailing_one_uc
- libc.src.stdbit.stdc_first_trailing_one_ui
- libc.src.stdbit.stdc_first_trailing_one_ul
- libc.src.stdbit.stdc_first_trailing_one_ull
- libc.src.stdbit.stdc_first_trailing_one_us
- libc.src.stdbit.stdc_first_trailing_zero_uc
- libc.src.stdbit.stdc_first_trailing_zero_ui
- libc.src.stdbit.stdc_first_trailing_zero_ul
- libc.src.stdbit.stdc_first_trailing_zero_ull
- libc.src.stdbit.stdc_first_trailing_zero_us
- libc.src.stdbit.stdc_has_single_bit_uc
- libc.src.stdbit.stdc_has_single_bit_ui
- libc.src.stdbit.stdc_has_single_bit_ul
- libc.src.stdbit.stdc_has_single_bit_ull
- libc.src.stdbit.stdc_has_single_bit_us
- libc.src.stdbit.stdc_leading_ones_uc
- libc.src.stdbit.stdc_leading_ones_ui
- libc.src.stdbit.stdc_leading_ones_ul
- libc.src.stdbit.stdc_leading_ones_ull
- libc.src.stdbit.stdc_leading_ones_us
- libc.src.stdbit.stdc_leading_zeros_uc
- libc.src.stdbit.stdc_leading_zeros_ui
- libc.src.stdbit.stdc_leading_zeros_ul
- libc.src.stdbit.stdc_leading_zeros_ull
- libc.src.stdbit.stdc_leading_zeros_us
- libc.src.stdbit.stdc_trailing_ones_uc
- libc.src.stdbit.stdc_trailing_ones_ui
- libc.src.stdbit.stdc_trailing_ones_ul
- libc.src.stdbit.stdc_trailing_ones_ull
- libc.src.stdbit.stdc_trailing_ones_us
- libc.src.stdbit.stdc_trailing_zeros_uc
- libc.src.stdbit.stdc_trailing_zeros_ui
- libc.src.stdbit.stdc_trailing_zeros_ul
- libc.src.stdbit.stdc_trailing_zeros_ull
- libc.src.stdbit.stdc_trailing_zeros_us
-
- # stdlib.h entrypoints
- libc.src.stdlib._Exit
- libc.src.stdlib.abort
- libc.src.stdlib.abs
- libc.src.stdlib.atexit
- libc.src.stdlib.atof
- libc.src.stdlib.atoi
- libc.src.stdlib.atol
- libc.src.stdlib.atoll
- libc.src.stdlib.bsearch
- libc.src.stdlib.div
- libc.src.stdlib.exit
- libc.src.stdlib.labs
- libc.src.stdlib.ldiv
- libc.src.stdlib.llabs
- libc.src.stdlib.lldiv
- libc.src.stdlib.memalignment
- libc.src.stdlib.qsort
- libc.src.stdlib.qsort_r
- libc.src.stdlib.rand
- libc.src.stdlib.srand
- libc.src.stdlib.strtod
- libc.src.stdlib.strtod_l
- libc.src.stdlib.strtof
- libc.src.stdlib.strtof_l
- libc.src.stdlib.strtol
- libc.src.stdlib.strtol_l
- libc.src.stdlib.strtold
- libc.src.stdlib.strtold_l
- libc.src.stdlib.strtoll
- libc.src.stdlib.strtoll_l
- libc.src.stdlib.strtoul
- libc.src.stdlib.strtoul_l
- libc.src.stdlib.strtoull
- libc.src.stdlib.strtoull_l
- libc.src.stdlib.at_quick_exit
- libc.src.stdlib.quick_exit
- libc.src.stdlib.getenv
- libc.src.stdlib.system
-
- # TODO: Implement these correctly
- libc.src.stdlib.aligned_alloc
- libc.src.stdlib.calloc
- libc.src.stdlib.free
- libc.src.stdlib.malloc
- libc.src.stdlib.realloc
-
- # errno.h entrypoints
- libc.src.errno.errno
-
- # stdio.h entrypoints
- libc.src.stdio.clearerr
- libc.src.stdio.fclose
- libc.src.stdio.printf
- libc.src.stdio.vprintf
- libc.src.stdio.fprintf
- libc.src.stdio.vfprintf
- libc.src.stdio.snprintf
- libc.src.stdio.sprintf
- libc.src.stdio.vsnprintf
- libc.src.stdio.vsprintf
- libc.src.stdio.asprintf
- libc.src.stdio.vasprintf
- libc.src.stdio.scanf
- libc.src.stdio.vscanf
- libc.src.stdio.fscanf
- libc.src.stdio.vfscanf
- libc.src.stdio.sscanf
- libc.src.stdio.vsscanf
- libc.src.stdio.feof
- libc.src.stdio.ferror
- libc.src.stdio.fflush
- libc.src.stdio.fgetc
- libc.src.stdio.fgets
- libc.src.stdio.fopen
- libc.src.stdio.fputc
- libc.src.stdio.fputs
- libc.src.stdio.fread
- libc.src.stdio.fseek
- libc.src.stdio.ftell
- libc.src.stdio.fwrite
- libc.src.stdio.getc
- libc.src.stdio.getchar
- libc.src.stdio.putc
- libc.src.stdio.putchar
- libc.src.stdio.puts
- libc.src.stdio.remove
- libc.src.stdio.rename
- libc.src.stdio.stderr
- libc.src.stdio.stdin
- libc.src.stdio.stdout
- libc.src.stdio.ungetc
-
- # inttypes.h entrypoints
- libc.src.inttypes.imaxabs
- libc.src.inttypes.imaxdiv
- libc.src.inttypes.strtoimax
- libc.src.inttypes.strtoumax
-
- # time.h entrypoints
- libc.src.time.clock
- libc.src.time.clock_gettime
- libc.src.time.timespec_get
- libc.src.time.nanosleep
- libc.src.time.strftime
- libc.src.time.strftime_l
- libc.src.time.mktime
-
- # wchar.h entrypoints
- libc.src.wchar.wcslen
- libc.src.wchar.wctob
-
- # locale.h entrypoints
- libc.src.locale.localeconv
- libc.src.locale.duplocale
- libc.src.locale.freelocale
- libc.src.locale.localeconv
- libc.src.locale.newlocale
- libc.src.locale.setlocale
- libc.src.locale.uselocale
)
set(TARGET_LIBM_ENTRYPOINTS
- # math.h entrypoints
- libc.src.math.acos
- libc.src.math.acosf
- libc.src.math.acoshf
- libc.src.math.asin
- libc.src.math.asinf
- libc.src.math.asinhf
- libc.src.math.atan
- libc.src.math.atan2
- libc.src.math.atan2f
- libc.src.math.atan2l
- libc.src.math.atanf
- libc.src.math.atanhf
- libc.src.math.canonicalize
- libc.src.math.canonicalizef
- libc.src.math.canonicalizel
- libc.src.math.cbrt
- libc.src.math.cbrtf
- libc.src.math.ceil
- libc.src.math.ceilf
- libc.src.math.ceill
- libc.src.math.copysign
- libc.src.math.copysignf
- libc.src.math.copysignl
- libc.src.math.cos
- libc.src.math.cosf
- libc.src.math.coshf
- libc.src.math.cospif
- libc.src.math.ddivl
- libc.src.math.dfmal
- libc.src.math.dmull
- libc.src.math.dsqrtl
- libc.src.math.erff
- libc.src.math.exp
- libc.src.math.exp10
- libc.src.math.exp10f
- libc.src.math.exp2
- libc.src.math.exp2f
- libc.src.math.exp2m1f
- libc.src.math.expf
- libc.src.math.expm1
- libc.src.math.expm1f
- libc.src.math.fabs
- libc.src.math.fabsf
- libc.src.math.fabsl
- libc.src.math.fadd
- libc.src.math.faddl
- libc.src.math.fdim
- libc.src.math.fdimf
- libc.src.math.fdiml
- libc.src.math.fdiv
- libc.src.math.fdivl
- libc.src.math.ffma
- libc.src.math.ffmal
- libc.src.math.floor
- libc.src.math.floorf
- libc.src.math.floorl
- libc.src.math.fma
- libc.src.math.fmaf
- libc.src.math.fmax
- libc.src.math.fmaxf
- libc.src.math.fmaximum
- libc.src.math.fmaximumf
- libc.src.math.fmaximuml
- libc.src.math.fmaximum_mag
- libc.src.math.fmaximum_magf
- libc.src.math.fmaximum_magl
- libc.src.math.fmaximum_mag_num
- libc.src.math.fmaximum_mag_numf
- libc.src.math.fmaximum_mag_numl
- libc.src.math.fmaximum_num
- libc.src.math.fmaximum_numf
- libc.src.math.fmaximum_numl
- libc.src.math.fmaxl
- libc.src.math.fmin
- libc.src.math.fminf
- libc.src.math.fminimum
- libc.src.math.fminimumf
- libc.src.math.fminimuml
- libc.src.math.fminimum_mag
- libc.src.math.fminimum_magf
- libc.src.math.fminimum_magl
- libc.src.math.fminimum_mag_num
- libc.src.math.fminimum_mag_numf
- libc.src.math.fminimum_mag_numl
- libc.src.math.fminimum_num
- libc.src.math.fminimum_numf
- libc.src.math.fminimum_numl
- libc.src.math.fminl
- libc.src.math.fmod
- libc.src.math.fmodf
- libc.src.math.fmodl
- libc.src.math.fmul
- libc.src.math.fmull
- libc.src.math.frexp
- libc.src.math.frexpf
- libc.src.math.frexpl
- libc.src.math.fromfp
- libc.src.math.fromfpf
- libc.src.math.fromfpl
- libc.src.math.fromfpx
- libc.src.math.fromfpxf
- libc.src.math.fromfpxl
- libc.src.math.fsqrt
- libc.src.math.fsqrtl
- libc.src.math.fsub
- libc.src.math.fsubl
- libc.src.math.getpayload
- libc.src.math.getpayloadf
- libc.src.math.getpayloadl
- libc.src.math.hypot
- libc.src.math.hypotf
- libc.src.math.ilogb
- libc.src.math.ilogbf
- libc.src.math.ilogbl
- libc.src.math.isnan
- libc.src.math.isnanf
- libc.src.math.isnanl
- libc.src.math.ldexp
- libc.src.math.ldexpf
- libc.src.math.ldexpl
- libc.src.math.lgamma
- libc.src.math.lgamma_r
- libc.src.math.llogb
- libc.src.math.llogbf
- libc.src.math.llogbl
- libc.src.math.llrint
- libc.src.math.llrintf
- libc.src.math.llrintl
- libc.src.math.llround
- libc.src.math.llroundf
- libc.src.math.llroundl
- libc.src.math.log
- libc.src.math.log10
- libc.src.math.log10f
- libc.src.math.log1p
- libc.src.math.log1pf
- libc.src.math.log2
- libc.src.math.log2f
- libc.src.math.logb
- libc.src.math.logbf
- libc.src.math.logbl
- libc.src.math.logf
- libc.src.math.lrint
- libc.src.math.lrintf
- libc.src.math.lrintl
- libc.src.math.lround
- libc.src.math.lroundf
- libc.src.math.lroundl
- libc.src.math.modf
- libc.src.math.modff
- libc.src.math.modfl
- libc.src.math.nan
- libc.src.math.nanf
- libc.src.math.nanl
- libc.src.math.nearbyint
- libc.src.math.nearbyintf
- libc.src.math.nearbyintl
- libc.src.math.nextafter
- libc.src.math.nextafterf
- libc.src.math.nextafterl
- libc.src.math.nextdown
- libc.src.math.nextdownf
- libc.src.math.nextdownl
- libc.src.math.nexttoward
- libc.src.math.nexttowardf
- libc.src.math.nexttowardl
- libc.src.math.nextup
- libc.src.math.nextupf
- libc.src.math.nextupl
- libc.src.math.pow
- libc.src.math.powf
- libc.src.math.remainder
- libc.src.math.remainderf
- libc.src.math.remainderl
- libc.src.math.remquo
- libc.src.math.remquof
- libc.src.math.remquol
- libc.src.math.rint
- libc.src.math.rintf
- libc.src.math.rintl
- libc.src.math.roundeven
- libc.src.math.roundevenf
- libc.src.math.roundevenl
- libc.src.math.round
- libc.src.math.roundf
- libc.src.math.roundl
- libc.src.math.scalbln
- libc.src.math.scalblnf
- libc.src.math.scalblnl
- libc.src.math.scalbn
- libc.src.math.scalbnf
- libc.src.math.scalbnl
- libc.src.math.setpayload
- libc.src.math.setpayloadf
- libc.src.math.setpayloadl
- libc.src.math.setpayloadsig
- libc.src.math.setpayloadsigf
- libc.src.math.setpayloadsigl
- libc.src.math.sin
- libc.src.math.sincos
- libc.src.math.sincosf
- libc.src.math.sinf
- libc.src.math.sinhf
- libc.src.math.sinpif
- libc.src.math.sqrt
- libc.src.math.sqrtf
- libc.src.math.sqrtl
- libc.src.math.tan
- libc.src.math.tanf
- libc.src.math.tanhf
- libc.src.math.tanpif
- libc.src.math.tgamma
- libc.src.math.tgammaf
- libc.src.math.totalorder
- libc.src.math.totalorderf
- libc.src.math.totalorderl
- libc.src.math.totalordermag
- libc.src.math.totalordermagf
- libc.src.math.totalordermagl
- libc.src.math.trunc
- libc.src.math.truncf
- libc.src.math.truncl
- libc.src.math.ufromfp
- libc.src.math.ufromfpf
- libc.src.math.ufromfpl
- libc.src.math.ufromfpx
- libc.src.math.ufromfpxf
- libc.src.math.ufromfpxl
)
if(LIBC_TYPES_HAS_FLOAT16)
list(APPEND TARGET_LIBM_ENTRYPOINTS
- # math.h C23 _Float16 entrypoints
- libc.src.math.acosf16
- libc.src.math.acoshf16
- libc.src.math.acospif16
- libc.src.math.asinf16
- libc.src.math.asinhf16
- libc.src.math.atanf16
- libc.src.math.atanhf16
- libc.src.math.canonicalizef16
- libc.src.math.ceilf16
- libc.src.math.copysignf16
- libc.src.math.cosf16
- libc.src.math.coshf16
- libc.src.math.cospif16
- libc.src.math.exp10f16
- libc.src.math.exp10m1f16
- libc.src.math.exp2f16
- # libc.src.math.exp2m1f16
- libc.src.math.expf16
- libc.src.math.expm1f16
- libc.src.math.f16add
- libc.src.math.f16addf
- libc.src.math.f16addl
- libc.src.math.f16div
- libc.src.math.f16divf
- libc.src.math.f16divl
- libc.src.math.f16fma
- libc.src.math.f16fmaf
- libc.src.math.f16fmal
- libc.src.math.f16mul
- libc.src.math.f16mulf
- libc.src.math.f16mull
- libc.src.math.f16sqrt
- libc.src.math.f16sqrtf
- libc.src.math.f16sqrtl
- libc.src.math.f16sub
- libc.src.math.f16subf
- libc.src.math.f16subl
- libc.src.math.fabsf16
- libc.src.math.fdimf16
- libc.src.math.floorf16
- libc.src.math.fmaf16
- libc.src.math.fmaxf16
- libc.src.math.fmaximum_mag_numf16
- libc.src.math.fmaximum_magf16
- libc.src.math.fmaximum_numf16
- libc.src.math.fmaximumf16
- libc.src.math.fminf16
- libc.src.math.fminimum_mag_numf16
- libc.src.math.fminimum_magf16
- libc.src.math.fminimum_numf16
- libc.src.math.fminimumf16
- libc.src.math.fmodf16
- libc.src.math.frexpf16
- libc.src.math.fromfpf16
- libc.src.math.fromfpxf16
- libc.src.math.getpayloadf16
- libc.src.math.hypotf16
- libc.src.math.ilogbf16
- libc.src.math.iscanonicalf16
- libc.src.math.issignalingf16
- libc.src.math.ldexpf16
- libc.src.math.llogbf16
- libc.src.math.llrintf16
- libc.src.math.llroundf16
- libc.src.math.log10f16
- libc.src.math.log2f16
- libc.src.math.logbf16
- libc.src.math.logf16
- libc.src.math.lrintf16
- libc.src.math.lroundf16
- libc.src.math.modff16
- libc.src.math.nanf16
- libc.src.math.nearbyintf16
- libc.src.math.nextafterf16
- libc.src.math.nextdownf16
- libc.src.math.nexttowardf16
- libc.src.math.nextupf16
- libc.src.math.remainderf16
- libc.src.math.remquof16
- libc.src.math.rintf16
- libc.src.math.roundevenf16
- libc.src.math.roundf16
- libc.src.math.scalblnf16
- libc.src.math.scalbnf16
- libc.src.math.setpayloadf16
- libc.src.math.setpayloadsigf16
- libc.src.math.sinf16
- libc.src.math.sinhf16
- libc.src.math.sinpif16
- libc.src.math.sqrtf16
- libc.src.math.tanf16
- libc.src.math.tanhf16
- libc.src.math.tanpif16
- libc.src.math.totalorderf16
- libc.src.math.totalordermagf16
- libc.src.math.truncf16
- libc.src.math.ufromfpf16
- libc.src.math.ufromfpxf16
)
endif()
list(APPEND TARGET_LIBM_ENTRYPOINTS
- # bfloat16 entrypoints
- libc.src.math.bf16add
- libc.src.math.bf16addf
- libc.src.math.bf16addl
- libc.src.math.bf16div
- libc.src.math.bf16divf
- libc.src.math.bf16divl
- libc.src.math.bf16fma
- libc.src.math.bf16fmaf
- libc.src.math.bf16fmal
- libc.src.math.bf16mul
- libc.src.math.bf16mulf
- libc.src.math.bf16mull
- libc.src.math.bf16sub
- libc.src.math.bf16subf
- libc.src.math.bf16subl
- libc.src.math.canonicalizebf16
- libc.src.math.ceilbf16
- libc.src.math.copysignbf16
- libc.src.math.fabsbf16
- libc.src.math.fdimbf16
- libc.src.math.floorbf16
- libc.src.math.fmaxbf16
- libc.src.math.fmaximumbf16
- libc.src.math.fmaximum_magbf16
- libc.src.math.fmaximum_mag_numbf16
- libc.src.math.fmaximum_numbf16
- libc.src.math.fminbf16
- libc.src.math.fminimumbf16
- libc.src.math.fminimum_magbf16
- libc.src.math.fminimum_mag_numbf16
- libc.src.math.fminimum_numbf16
- libc.src.math.fmodbf16
- libc.src.math.frexpbf16
- libc.src.math.fromfpbf16
- libc.src.math.fromfpxbf16
- libc.src.math.getpayloadbf16
- libc.src.math.ilogbbf16
- libc.src.math.iscanonicalbf16
- libc.src.math.issignalingbf16
- libc.src.math.ldexpbf16
- libc.src.math.llogbbf16
- libc.src.math.llrintbf16
- libc.src.math.llroundbf16
- libc.src.math.log_bf16
- libc.src.math.logbbf16
- libc.src.math.lrintbf16
- libc.src.math.lroundbf16
- libc.src.math.modfbf16
- libc.src.math.nanbf16
- libc.src.math.nearbyintbf16
- libc.src.math.nextafterbf16
- libc.src.math.nextdownbf16
- libc.src.math.nexttowardbf16
- libc.src.math.nextupbf16
- libc.src.math.remainderbf16
- libc.src.math.remquobf16
- libc.src.math.rintbf16
- libc.src.math.roundbf16
- libc.src.math.roundevenbf16
- libc.src.math.scalblnbf16
- libc.src.math.scalbnbf16
- libc.src.math.setpayloadbf16
- libc.src.math.setpayloadsigbf16
- libc.src.math.sqrtbf16
- libc.src.math.truncbf16
- libc.src.math.totalorderbf16
- libc.src.math.totalordermagbf16
- libc.src.math.ufromfpbf16
- libc.src.math.ufromfpxbf16
)
set(TARGET_LLVMLIBC_ENTRYPOINTS
diff --git a/libc/config/gpu/spirv/headers.txt b/libc/config/gpu/spirv/headers.txt
index fa8ad7c11ba8b..462061ce09b3f 100644
--- a/libc/config/gpu/spirv/headers.txt
+++ b/libc/config/gpu/spirv/headers.txt
@@ -1,21 +1,2 @@
set(TARGET_PUBLIC_HEADERS
- libc.include.assert
- libc.include.ctype
- libc.include.string
- libc.include.strings
- libc.include.signal
- libc.include.float
- libc.include.stdint
- libc.include.inttypes
- libc.include.limits
- libc.include.math
- libc.include.fenv
- libc.include.time
- libc.include.errno
- libc.include.stdlib
- libc.include.stdio
- libc.include.wchar
- libc.include.uchar
- libc.include.features
- libc.include.locale
)
diff --git a/libc/src/math/spirv/CMakeLists.txt b/libc/src/math/spirv/CMakeLists.txt
deleted file mode 100644
index d05d519b74b4f..0000000000000
--- a/libc/src/math/spirv/CMakeLists.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-add_entrypoint_object(
- ceil
- SRCS
- ceil.cpp
- HDRS
- ../ceil.h
-)
-
-add_entrypoint_object(
- ceilf
- SRCS
- ceilf.cpp
- HDRS
- ../ceilf.h
-)
-
-add_entrypoint_object(
- copysign
- SRCS
- copysign.cpp
- HDRS
- ../copysign.h
-)
-
-add_entrypoint_object(
- copysignf
- SRCS
- copysignf.cpp
- HDRS
- ../copysignf.h
-)
-
-add_entrypoint_object(
- fabs
- SRCS
- fabs.cpp
- HDRS
- ../fabs.h
-)
-
-add_entrypoint_object(
- fabsf
- SRCS
- fabsf.cpp
- HDRS
- ../fabsf.h
-)
-
-add_entrypoint_object(
- floor
- SRCS
- floor.cpp
- HDRS
- ../floor.h
-)
-
-add_entrypoint_object(
- floorf
- SRCS
- floorf.cpp
- HDRS
- ../floorf.h
-)
-
-add_entrypoint_object(
- fma
- SRCS
- fma.cpp
- HDRS
- ../fma.h
-)
-
-add_entrypoint_object(
- fmaf
- SRCS
- fmaf.cpp
- HDRS
- ../fmaf.h
-)
-
-add_entrypoint_object(
- fmax
- SRCS
- fmax.cpp
- HDRS
- ../fmax.h
-)
-
-add_entrypoint_object(
- fmaxf
- SRCS
- fmaxf.cpp
- HDRS
- ../fmaxf.h
-)
-
-add_entrypoint_object(
- fmin
- SRCS
- fmin.cpp
- HDRS
- ../fmin.h
-)
-
-add_entrypoint_object(
- fminf
- SRCS
- fminf.cpp
- HDRS
- ../fminf.h
-)
-
-add_entrypoint_object(
- fmod
- SRCS
- fmod.cpp
- HDRS
- ../fmod.h
-)
-
-add_entrypoint_object(
- fmodf
- SRCS
- fmodf.cpp
- HDRS
- ../fmodf.h
-)
-
-add_entrypoint_object(
- nearbyint
- SRCS
- nearbyint.cpp
- HDRS
- ../nearbyint.h
-)
-
-add_entrypoint_object(
- nearbyintf
- SRCS
- nearbyintf.cpp
- HDRS
- ../nearbyintf.h
-)
-
-add_entrypoint_object(
- remainder
- SRCS
- remainder.cpp
- HDRS
- ../remainder.h
-)
-
-add_entrypoint_object(
- remainderf
- SRCS
- remainderf.cpp
- HDRS
- ../remainderf.h
-)
-
-add_entrypoint_object(
- rint
- SRCS
- rint.cpp
- HDRS
- ../rint.h
-)
-
-add_entrypoint_object(
- rintf
- SRCS
- rintf.cpp
- HDRS
- ../rintf.h
-)
-
-add_entrypoint_object(
- round
- SRCS
- round.cpp
- HDRS
- ../round.h
-)
-
-add_entrypoint_object(
- sqrt
- SRCS
- sqrt.cpp
- HDRS
- ../sqrt.h
-)
-
-add_entrypoint_object(
- sqrtf
- SRCS
- sqrtf.cpp
- HDRS
- ../sqrtf.h
-)
-
-add_entrypoint_object(
- trunc
- SRCS
- trunc.cpp
- HDRS
- ../trunc.h
-)
-
-add_entrypoint_object(
- truncf
- SRCS
- truncf.cpp
- HDRS
- ../truncf.h
-)
-
-add_entrypoint_object(
- frexp
- SRCS
- frexp.cpp
- HDRS
- ../frexp.h
-)
-
-add_entrypoint_object(
- frexpf
- SRCS
- frexpf.cpp
- HDRS
- ../frexpf.h
-)
-
-add_entrypoint_object(
- scalbn
- SRCS
- scalbn.cpp
- HDRS
- ../scalbn.h
-)
-
-add_entrypoint_object(
- scalbnf
- SRCS
- scalbnf.cpp
- HDRS
- ../scalbnf.h
-)
-
-add_entrypoint_object(
- ldexp
- SRCS
- ldexp.cpp
- HDRS
- ../ldexp.h
-)
-
-add_entrypoint_object(
- ldexpf
- SRCS
- ldexpf.cpp
- HDRS
- ../ldexpf.h
-)
-
-add_entrypoint_object(
- tgamma
- SRCS
- tgamma.cpp
- HDRS
- ../tgamma.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
-)
-
-add_entrypoint_object(
- tgammaf
- SRCS
- tgammaf.cpp
- HDRS
- ../tgammaf.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
-)
-
-add_entrypoint_object(
- lgamma
- SRCS
- lgamma.cpp
- HDRS
- ../lgamma.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
-)
-
-add_entrypoint_object(
- lgamma_r
- SRCS
- lgamma_r.cpp
- HDRS
- ../lgamma_r.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
-)
diff --git a/libc/src/math/spirv/ceil.cpp b/libc/src/math/spirv/ceil.cpp
deleted file mode 100644
index 8834c7b560a1b..0000000000000
--- a/libc/src/math/spirv/ceil.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the ceil function for GPU -----------------------===//
-//
-// 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 "src/math/ceil.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, ceil, (double x)) { return __builtin_ceil(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/ceilf.cpp b/libc/src/math/spirv/ceilf.cpp
deleted file mode 100644
index 5d26a30c849cd..0000000000000
--- a/libc/src/math/spirv/ceilf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the ceilf function for GPU ----------------------===//
-//
-// 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 "src/math/ceilf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, ceilf, (float x)) { return __builtin_ceilf(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/copysign.cpp b/libc/src/math/spirv/copysign.cpp
deleted file mode 100644
index 06ef36fb3595f..0000000000000
--- a/libc/src/math/spirv/copysign.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the copysign function for GPU -------------------===//
-//
-// 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 "src/math/copysign.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, copysign, (double x, double y)) {
- return __builtin_copysign(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/copysignf.cpp b/libc/src/math/spirv/copysignf.cpp
deleted file mode 100644
index aea94f3577d8f..0000000000000
--- a/libc/src/math/spirv/copysignf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the copysignf function for GPU ------------------===//
-//
-// 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 "src/math/copysignf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, copysignf, (float x, float y)) {
- return __builtin_copysignf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fabs.cpp b/libc/src/math/spirv/fabs.cpp
deleted file mode 100644
index bb37596b9d563..0000000000000
--- a/libc/src/math/spirv/fabs.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the fabs function for GPU -----------------------===//
-//
-// 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 "src/math/fabs.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, fabs, (double x)) { return __builtin_fabs(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fabsf.cpp b/libc/src/math/spirv/fabsf.cpp
deleted file mode 100644
index 2698618f3f1e1..0000000000000
--- a/libc/src/math/spirv/fabsf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the fabsf function for GPU ----------------------===//
-//
-// 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 "src/math/fabsf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, fabsf, (float x)) { return __builtin_fabsf(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/floor.cpp b/libc/src/math/spirv/floor.cpp
deleted file mode 100644
index 564efa9a7da38..0000000000000
--- a/libc/src/math/spirv/floor.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the floor function for GPU ----------------------===//
-//
-// 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 "src/math/floor.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, floor, (double x)) { return __builtin_floor(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/floorf.cpp b/libc/src/math/spirv/floorf.cpp
deleted file mode 100644
index 6717c8f60c992..0000000000000
--- a/libc/src/math/spirv/floorf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the floorf function for GPU ---------------------===//
-//
-// 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 "src/math/floorf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, floorf, (float x)) { return __builtin_floorf(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fma.cpp b/libc/src/math/spirv/fma.cpp
deleted file mode 100644
index c4a117e42a3aa..0000000000000
--- a/libc/src/math/spirv/fma.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the fma function for GPU ------------------------===//
-//
-// 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 "src/math/fma.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, fma, (double x, double y, double z)) {
- return __builtin_fma(x, y, z);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fmaf.cpp b/libc/src/math/spirv/fmaf.cpp
deleted file mode 100644
index c088bd5b30fea..0000000000000
--- a/libc/src/math/spirv/fmaf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the fmaf function for GPU -----------------------===//
-//
-// 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 "src/math/fmaf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, fmaf, (float x, float y, float z)) {
- return __builtin_fmaf(x, y, z);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fmax.cpp b/libc/src/math/spirv/fmax.cpp
deleted file mode 100644
index 474019733598f..0000000000000
--- a/libc/src/math/spirv/fmax.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of the fmax function for GPU -----------------------===//
-//
-// 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 "src/math/fmax.h"
-
-#include "src/__support/CPP/bit.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/optimization.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, fmax, (double x, double y)) {
- return __builtin_fmax(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fmaxf.cpp b/libc/src/math/spirv/fmaxf.cpp
deleted file mode 100644
index 59ee8259c025a..0000000000000
--- a/libc/src/math/spirv/fmaxf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the fmaxf function for GPU ----------------------===//
-//
-// 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 "src/math/fmaxf.h"
-
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, fmaxf, (float x, float y)) {
- return __builtin_fmaxf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fmin.cpp b/libc/src/math/spirv/fmin.cpp
deleted file mode 100644
index 694eb664b599b..0000000000000
--- a/libc/src/math/spirv/fmin.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the fmin function for GPU -----------------------===//
-//
-// 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 "src/math/fmin.h"
-
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, fmin, (double x, double y)) {
- return __builtin_fmin(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fminf.cpp b/libc/src/math/spirv/fminf.cpp
deleted file mode 100644
index 2060b71b0841f..0000000000000
--- a/libc/src/math/spirv/fminf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the fminf function for GPU ----------------------===//
-//
-// 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 "src/math/fminf.h"
-
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, fminf, (float x, float y)) {
- return __builtin_fminf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fmod.cpp b/libc/src/math/spirv/fmod.cpp
deleted file mode 100644
index 49d19c4decb96..0000000000000
--- a/libc/src/math/spirv/fmod.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the fmod function for GPU -----------------------===//
-//
-// 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 "src/math/fmod.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, fmod, (double x, double y)) {
- return __builtin_fmod(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/fmodf.cpp b/libc/src/math/spirv/fmodf.cpp
deleted file mode 100644
index 8fbcb0cc2ad9e..0000000000000
--- a/libc/src/math/spirv/fmodf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the fmodf function for GPU ----------------------===//
-//
-// 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 "src/math/fmodf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, fmodf, (float x, float y)) {
- return __builtin_fmodf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/frexp.cpp b/libc/src/math/spirv/frexp.cpp
deleted file mode 100644
index 4ae2b00198ec3..0000000000000
--- a/libc/src/math/spirv/frexp.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the frexp function for GPU ----------------------===//
-//
-// 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 "src/math/frexp.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, frexp, (double x, int *p)) {
- return __builtin_frexp(x, p);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/frexpf.cpp b/libc/src/math/spirv/frexpf.cpp
deleted file mode 100644
index fd53f65701f59..0000000000000
--- a/libc/src/math/spirv/frexpf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the frexpf function for GPU ---------------------===//
-//
-// 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 "src/math/frexpf.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, frexpf, (float x, int *p)) {
- return __builtin_frexpf(x, p);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/ldexp.cpp b/libc/src/math/spirv/ldexp.cpp
deleted file mode 100644
index 5b786a9b21e70..0000000000000
--- a/libc/src/math/spirv/ldexp.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the ldexp function for GPU ----------------------===//
-//
-// 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 "src/math/ldexp.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, ldexp, (double x, int y)) {
- return __builtin_ldexp(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/ldexpf.cpp b/libc/src/math/spirv/ldexpf.cpp
deleted file mode 100644
index d3aa77fe592cb..0000000000000
--- a/libc/src/math/spirv/ldexpf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the ldexpf function for GPU ---------------------===//
-//
-// 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 "src/math/ldexpf.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, ldexpf, (float x, int y)) {
- return __builtin_ldexpf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/lgamma.cpp b/libc/src/math/spirv/lgamma.cpp
deleted file mode 100644
index 2916ed5e77a5b..0000000000000
--- a/libc/src/math/spirv/lgamma.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the lgamma function for GPU ---------------------===//
-//
-// 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 "src/math/lgamma.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-extern "C" double __attribute__((overloadable)) __spirv_ocl_lgamma(double);
-LLVM_LIBC_FUNCTION(double, lgamma, (double x)) { return __spirv_ocl_lgamma(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/lgamma_r.cpp b/libc/src/math/spirv/lgamma_r.cpp
deleted file mode 100644
index efb388e52d05c..0000000000000
--- a/libc/src/math/spirv/lgamma_r.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of the lgamma_r function for GPU -------------------===//
-//
-// 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 "src/math/lgamma_r.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-extern "C" double __attribute__((overloadable)) __spirv_ocl_lgamma_r(double,
- int *);
-LLVM_LIBC_FUNCTION(double, lgamma_r, (double x, int *signp)) {
- return __spirv_ocl_lgamma_r(x, signp);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/llrint.cpp b/libc/src/math/spirv/llrint.cpp
deleted file mode 100644
index 6e0f57a5a0387..0000000000000
--- a/libc/src/math/spirv/llrint.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the llrint function for GPU ---------------------===//
-//
-// 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 "src/math/llrint.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
- return static_cast<long long>(__builtin_rint(x));
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/llrintf.cpp b/libc/src/math/spirv/llrintf.cpp
deleted file mode 100644
index d8de23fac3c8b..0000000000000
--- a/libc/src/math/spirv/llrintf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the llrintf function for GPU --------------------===//
-//
-// 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 "src/math/llrintf.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
- return static_cast<long long>(__builtin_rintf(x));
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/lrint.cpp b/libc/src/math/spirv/lrint.cpp
deleted file mode 100644
index 5ba70ec890b2c..0000000000000
--- a/libc/src/math/spirv/lrint.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the lrint function for GPU ----------------------===//
-//
-// 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 "src/math/lrint.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(long, lrint, (double x)) {
- return static_cast<long>(__builtin_rint(x));
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/lrintf.cpp b/libc/src/math/spirv/lrintf.cpp
deleted file mode 100644
index 1c985b01c2dc1..0000000000000
--- a/libc/src/math/spirv/lrintf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the lrintf function for GPU ---------------------===//
-//
-// 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 "src/math/lrintf.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(long, lrintf, (float x)) {
- return static_cast<long>(__builtin_rintf(x));
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/nearbyint.cpp b/libc/src/math/spirv/nearbyint.cpp
deleted file mode 100644
index 7d78c7241d023..0000000000000
--- a/libc/src/math/spirv/nearbyint.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the GPU nearbyint function ----------------------===//
-//
-// 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 "src/math/nearbyint.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, nearbyint, (double x)) {
- return __builtin_nearbyint(x);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/nearbyintf.cpp b/libc/src/math/spirv/nearbyintf.cpp
deleted file mode 100644
index 4bd20dc58fb89..0000000000000
--- a/libc/src/math/spirv/nearbyintf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the GPU nearbyintf function ---------------------===//
-//
-// 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 "src/math/nearbyintf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, nearbyintf, (float x)) {
- return __builtin_nearbyintf(x);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/remainder.cpp b/libc/src/math/spirv/remainder.cpp
deleted file mode 100644
index 9027204312e00..0000000000000
--- a/libc/src/math/spirv/remainder.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the GPU remainder function ----------------------===//
-//
-// 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 "src/math/remainder.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, remainder, (double x, double y)) {
- return __builtin_remainder(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/remainderf.cpp b/libc/src/math/spirv/remainderf.cpp
deleted file mode 100644
index 50df3b2ce25c1..0000000000000
--- a/libc/src/math/spirv/remainderf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the GPU remainderf function ---------------------===//
-//
-// 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 "src/math/remainderf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, remainderf, (float x, float y)) {
- return __builtin_remainderf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/rint.cpp b/libc/src/math/spirv/rint.cpp
deleted file mode 100644
index ac6837a4abc37..0000000000000
--- a/libc/src/math/spirv/rint.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU rint function ---------------------------===//
-//
-// 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 "src/math/rint.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, rint, (double x)) { return __builtin_rint(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/rintf.cpp b/libc/src/math/spirv/rintf.cpp
deleted file mode 100644
index 94093471a8d92..0000000000000
--- a/libc/src/math/spirv/rintf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU rintf function --------------------------===//
-//
-// 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 "src/math/rintf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, rintf, (float x)) { return __builtin_rintf(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/round.cpp b/libc/src/math/spirv/round.cpp
deleted file mode 100644
index 0d2765f2e959f..0000000000000
--- a/libc/src/math/spirv/round.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU round function --------------------------===//
-//
-// 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 "src/math/round.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, round, (double x)) { return __builtin_round(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/roundf.cpp b/libc/src/math/spirv/roundf.cpp
deleted file mode 100644
index 86e8ba3ac83d6..0000000000000
--- a/libc/src/math/spirv/roundf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU roundf function -------------------------===//
-//
-// 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 "src/math/roundf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, roundf, (float x)) { return __builtin_roundf(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/scalbn.cpp b/libc/src/math/spirv/scalbn.cpp
deleted file mode 100644
index ade0c40d8dc84..0000000000000
--- a/libc/src/math/spirv/scalbn.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the GPU scalbn function -------------------------===//
-//
-// 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 "src/math/scalbn.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, scalbn, (double x, int y)) {
- return __builtin_ldexp(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/scalbnf.cpp b/libc/src/math/spirv/scalbnf.cpp
deleted file mode 100644
index b5cb06f7bda0a..0000000000000
--- a/libc/src/math/spirv/scalbnf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of the GPU scalbnf function ------------------------===//
-//
-// 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 "src/math/scalbnf.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, scalbnf, (float x, int y)) {
- return __builtin_ldexpf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/sqrt.cpp b/libc/src/math/spirv/sqrt.cpp
deleted file mode 100644
index ed83b6e5c6cae..0000000000000
--- a/libc/src/math/spirv/sqrt.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU sqrt function ---------------------------===//
-//
-// 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 "src/math/sqrt.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, sqrt, (double x)) { return __builtin_sqrt(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/sqrtf.cpp b/libc/src/math/spirv/sqrtf.cpp
deleted file mode 100644
index 851922c316452..0000000000000
--- a/libc/src/math/spirv/sqrtf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU sqrtf function --------------------------===//
-//
-// 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 "src/math/sqrtf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, sqrtf, (float x)) { return __builtin_sqrtf(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/tgamma.cpp b/libc/src/math/spirv/tgamma.cpp
deleted file mode 100644
index 2395e56ac25da..0000000000000
--- a/libc/src/math/spirv/tgamma.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the GPU tgamma function -------------------------===//
-//
-// 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 "src/math/tgamma.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-extern "C" double __attribute__((overloadable)) __spirv_ocl_tgamma(double);
-LLVM_LIBC_FUNCTION(double, tgamma, (double x)) { return __spirv_ocl_tgamma(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/tgammaf.cpp b/libc/src/math/spirv/tgammaf.cpp
deleted file mode 100644
index ae9af5e74840c..0000000000000
--- a/libc/src/math/spirv/tgammaf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the GPU tgammaf function ------------------------===//
-//
-// 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 "src/math/tgammaf.h"
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-extern "C" float __attribute__((overloadable)) __spirv_ocl_tgamma(float);
-LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) { return __spirv_ocl_tgamma(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/trunc.cpp b/libc/src/math/spirv/trunc.cpp
deleted file mode 100644
index f60caa2a71d78..0000000000000
--- a/libc/src/math/spirv/trunc.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU trunc function --------------------------===//
-//
-// 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 "src/math/trunc.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, trunc, (double x)) { return __builtin_trunc(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/truncf.cpp b/libc/src/math/spirv/truncf.cpp
deleted file mode 100644
index a6c9b8f188f02..0000000000000
--- a/libc/src/math/spirv/truncf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation of the GPU truncf function -------------------------===//
-//
-// 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 "src/math/truncf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, truncf, (float x)) { return __builtin_truncf(x); }
-
-} // namespace LIBC_NAMESPACE_DECL
>From 04c430780c8edf76d6f23066ea56f02513c9616a Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Mon, 16 Feb 2026 14:14:21 -0800
Subject: [PATCH 6/7] Address PR comments
---
libc/cmake/modules/LLVMLibCArchitectures.cmake | 5 -----
1 file changed, 5 deletions(-)
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 2bd16d7154bc2..94c978a458a6d 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -75,11 +75,6 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
set(target_sys "gpu")
endif()
- if (target_arch MATCHES "^spirv")
- list(APPEND
- LIBC_COMPILE_OPTIONS_DEFAULT "-emit-llvm")
- endif()
-
set(${sys_var} ${target_sys} PARENT_SCOPE)
endfunction(get_arch_and_system_from_triple)
>From 3f014e1590fef6e9d427ad1960527fdee1b9ff8d Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Mon, 16 Feb 2026 16:26:30 -0800
Subject: [PATCH 7/7] Address PR comments
---
libc/cmake/modules/LLVMLibCLibraryRules.cmake | 3 +-
libc/config/gpu/spirv/entrypoints.txt | 85 +++++++++++++++++++
libc/config/gpu/spirv/headers.txt | 4 +
libc/startup/gpu/CMakeLists.txt | 14 +--
libc/startup/gpu/spirv/CMakeLists.txt | 16 ----
libc/startup/gpu/spirv/start.cpp | 71 ----------------
6 files changed, 93 insertions(+), 100 deletions(-)
delete mode 100644 libc/startup/gpu/spirv/CMakeLists.txt
delete mode 100644 libc/startup/gpu/spirv/start.cpp
diff --git a/libc/cmake/modules/LLVMLibCLibraryRules.cmake b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
index 7352802bc9ce4..9f8c6c0db8c6f 100644
--- a/libc/cmake/modules/LLVMLibCLibraryRules.cmake
+++ b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
@@ -109,8 +109,7 @@ function(add_bitcode_entrypoint_library target_name base_target_name)
endforeach()
add_executable(${target_name} ${objects})
- if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^spirv" OR
- "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^spirv")
+ if(LIBC_TARGET_ARCHITECTURE_IS_SPIRV)
target_link_options(${target_name} PRIVATE "${LIBC_COMPILE_OPTIONS_DEFAULT}"
"-nostdlib" "-emit-llvm")
else()
diff --git a/libc/config/gpu/spirv/entrypoints.txt b/libc/config/gpu/spirv/entrypoints.txt
index fc4e12324c5bf..215d92aaa7fd7 100644
--- a/libc/config/gpu/spirv/entrypoints.txt
+++ b/libc/config/gpu/spirv/entrypoints.txt
@@ -1,4 +1,89 @@
set(TARGET_LIBC_ENTRYPOINTS
+ # assert.h entrypoints
+ libc.src.assert.__assert_fail
+
+ # ctype.h entrypoints
+ libc.src.ctype.isalnum
+ libc.src.ctype.isalnum_l
+ libc.src.ctype.isalpha
+ libc.src.ctype.isalpha_l
+ libc.src.ctype.isascii
+ libc.src.ctype.isblank
+ libc.src.ctype.isblank_l
+ libc.src.ctype.iscntrl
+ libc.src.ctype.iscntrl_l
+ libc.src.ctype.isdigit
+ libc.src.ctype.isdigit_l
+ libc.src.ctype.isgraph
+ libc.src.ctype.isgraph_l
+ libc.src.ctype.islower
+ libc.src.ctype.islower_l
+ libc.src.ctype.isprint
+ libc.src.ctype.isprint_l
+ libc.src.ctype.ispunct
+ libc.src.ctype.ispunct_l
+ libc.src.ctype.isspace
+ libc.src.ctype.isspace_l
+ libc.src.ctype.isupper
+ libc.src.ctype.isupper_l
+ libc.src.ctype.isxdigit
+ libc.src.ctype.isxdigit_l
+ libc.src.ctype.toascii
+ libc.src.ctype.tolower
+ libc.src.ctype.tolower_l
+ libc.src.ctype.toupper
+ libc.src.ctype.toupper_l
+
+ # string.h entrypoints
+ libc.src.string.memccpy
+ libc.src.string.memchr
+ libc.src.string.memcmp
+ libc.src.string.memcpy
+ libc.src.string.memmem
+ libc.src.string.memmove
+ libc.src.string.mempcpy
+ libc.src.string.memrchr
+ libc.src.string.memset
+ libc.src.string.stpcpy
+ libc.src.string.stpncpy
+ libc.src.string.strcasestr
+ libc.src.string.strcat
+ libc.src.string.strchr
+ libc.src.string.strchrnul
+ libc.src.string.strcmp
+ libc.src.string.strcoll
+ libc.src.string.strcoll_l
+ libc.src.string.strcpy
+ libc.src.string.strcspn
+ libc.src.string.strdup
+ libc.src.string.strerror
+ libc.src.string.strlcat
+ libc.src.string.strlcpy
+ libc.src.string.strlen
+ libc.src.string.strncat
+ libc.src.string.strncmp
+ libc.src.string.strncpy
+ libc.src.string.strndup
+ libc.src.string.strnlen
+ libc.src.string.strpbrk
+ libc.src.string.strrchr
+ libc.src.string.strsep
+ libc.src.string.strspn
+ libc.src.string.strstr
+ libc.src.string.strtok
+ libc.src.string.strtok_r
+ libc.src.string.strxfrm
+ libc.src.string.strxfrm_l
+
+ # strings.h entrypoints
+ libc.src.strings.bcmp
+ libc.src.strings.bcopy
+ libc.src.strings.bzero
+ libc.src.strings.index
+ libc.src.strings.rindex
+ libc.src.strings.strcasecmp
+ libc.src.strings.strncasecmp
+
)
set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/config/gpu/spirv/headers.txt b/libc/config/gpu/spirv/headers.txt
index 462061ce09b3f..d13984e5f4685 100644
--- a/libc/config/gpu/spirv/headers.txt
+++ b/libc/config/gpu/spirv/headers.txt
@@ -1,2 +1,6 @@
set(TARGET_PUBLIC_HEADERS
+ libc.include.assert
+ libc.include.ctype
+ libc.include.string
+ libc.include.strings
)
diff --git a/libc/startup/gpu/CMakeLists.txt b/libc/startup/gpu/CMakeLists.txt
index f83e86819cad7..63e2a6c5dee1a 100644
--- a/libc/startup/gpu/CMakeLists.txt
+++ b/libc/startup/gpu/CMakeLists.txt
@@ -33,17 +33,9 @@ function(add_startup_object name)
set_target_properties(${fq_target_name}.exe PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${LIBC_LIBRARY_DIR}
RUNTIME_OUTPUT_NAME ${name}.o)
-
- if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^spirv" OR
- "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^spirv")
- target_link_options(${fq_target_name}.exe PRIVATE
- ${LIBC_COMPILE_OPTIONS_DEFAULT}
- "-nostdlib" "-emit-llvm")
- else()
- target_link_options(${fq_target_name}.exe PRIVATE
- ${LIBC_COMPILE_OPTIONS_DEFAULT}
- "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm")
- endif()
+ target_link_options(${fq_target_name}.exe PRIVATE
+ ${LIBC_COMPILE_OPTIONS_DEFAULT}
+ "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm")
endif()
endfunction()
diff --git a/libc/startup/gpu/spirv/CMakeLists.txt b/libc/startup/gpu/spirv/CMakeLists.txt
deleted file mode 100644
index f41ae8ce24a08..0000000000000
--- a/libc/startup/gpu/spirv/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-add_startup_object(
- crt1
- SRC
- start.cpp
- DEPENDS
- libc.config.app_h
- libc.src.__support.RPC.rpc_client
- libc.src.__support.GPU.utils
- libc.src.stdlib.exit
- libc.src.stdlib.atexit
- COMPILE_OPTIONS
- -ffreestanding # To avoid compiler warnings about calling the main function.
- -fno-builtin
- -emit-llvm
-)
-get_fq_target_name(crt1 fq_name)
diff --git a/libc/startup/gpu/spirv/start.cpp b/libc/startup/gpu/spirv/start.cpp
deleted file mode 100644
index 702f76647636b..0000000000000
--- a/libc/startup/gpu/spirv/start.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//===-- Implementation of crt for amdgpu ----------------------------------===//
-//
-// 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 "config/gpu/app.h"
-#include "src/__support/GPU/utils.h"
-#include "src/__support/RPC/rpc_client.h"
-#include "src/__support/macros/config.h"
-#include "src/stdlib/atexit.h"
-#include "src/stdlib/exit.h"
-
-extern "C" int main(int argc, char **argv, char **envp);
-extern "C" void __cxa_finalize(void *dso);
-
-namespace LIBC_NAMESPACE_DECL {
-
-// FIXME: Touch this symbol to force this to be linked in statically.
-volatile void *dummy = &LIBC_NAMESPACE::rpc::client;
-
-DataEnvironment app;
-
-extern "C" uintptr_t __init_array_start[];
-extern "C" uintptr_t __init_array_end[];
-extern "C" uintptr_t __fini_array_start[];
-extern "C" uintptr_t __fini_array_end[];
-
-using InitCallback = void(int, char **, char **);
-using FiniCallback = void(void);
-
-static void call_init_array_callbacks(int argc, char **argv, char **env) {
- size_t init_array_size = __init_array_end - __init_array_start;
- for (size_t i = 0; i < init_array_size; ++i)
- reinterpret_cast<InitCallback *>(__init_array_start[i])(argc, argv, env);
-}
-
-static void call_fini_array_callbacks() {
- size_t fini_array_size = __fini_array_end - __fini_array_start;
- for (size_t i = fini_array_size; i > 0; --i)
- reinterpret_cast<FiniCallback *>(__fini_array_start[i - 1])();
-}
-
-} // namespace LIBC_NAMESPACE_DECL
-
-extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void
-_begin(int argc, char **argv, char **env) {
- __atomic_store_n(&LIBC_NAMESPACE::app.env_ptr,
- reinterpret_cast<uintptr_t *>(env), __ATOMIC_RELAXED);
- // We want the fini array callbacks to be run after other atexit
- // callbacks are run. So, we register them before running the init
- // array callbacks as they can potentially register their own atexit
- // callbacks.
- LIBC_NAMESPACE::atexit(&LIBC_NAMESPACE::call_fini_array_callbacks);
- LIBC_NAMESPACE::call_init_array_callbacks(argc, argv, env);
-}
-
-extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void
-_start(int argc, char **argv, char **envp, int *ret) {
- // Invoke the 'main' function with every active thread that the user launched
- // the _start kernel with.
- __atomic_fetch_or(ret, main(argc, argv, envp), __ATOMIC_RELAXED);
-}
-
-extern "C" [[gnu::visibility("protected"), clang::device_kernel]] void _end() {
- // Only a single thread should call the destructors registred with 'atexit'.
- // The loader utility will handle the actual exit and return code cleanly.
- __cxa_finalize(nullptr);
-}
More information about the llvm-commits
mailing list