diff --git a/buildbot/configure.py b/buildbot/configure.py index 4874c0a44557a..6798bfa7356ad 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -200,6 +200,16 @@ def do_configure(args, passthrough_args): "-DBUG_REPORT_URL=https://github.com/intel/llvm/issues", ] + llvm_spirv64_runtimes = "libc" + runtime_targets += ";spirv64-unknown-unknown" + cmake_cmd.extend( + [ + "-DRUNTIMES_spirv64-unknown-unknown_LLVM_ENABLE_RUNTIMES={}".format( + llvm_spirv64_runtimes + ), + ] + ) + if llvm_enable_runtimes: cmake_cmd.extend( [ @@ -225,19 +235,18 @@ def do_configure(args, passthrough_args): if libclc_enabled: for target in runtime_targets.split(";"): - if target == "default": + if target == "default" or target == "spirv64-unknown-unknown": continue cmake_cmd.extend( [ f"-DRUNTIMES_{target}_LLVM_ENABLE_RUNTIMES=libclc", ] ) - cmake_cmd.extend( - [ - "-DLLVM_RUNTIME_TARGETS={}".format(runtime_targets), - ] - ) - + cmake_cmd.extend( + [ + "-DLLVM_RUNTIME_TARGETS={}".format(runtime_targets), + ] + ) if args.l0_headers and args.l0_loader: cmake_cmd.extend( [ diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e8df893277adb..c59f7beaa6c0e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -5852,6 +5852,15 @@ class OffloadingActionBuilder final { SmallVector, 4> LibLocCandidates; SYCLInstallation.getSYCLDeviceLibPath(LibLocCandidates); + if (TC->getTriple().isSPIROrSPIRV()) { + SmallVector, 4> OriginalLibLocs(LibLocCandidates); + for (auto LibLoc : OriginalLibLocs) { + SmallString<128> SPIRVLibLoc(LibLoc); + llvm::sys::path::append(SPIRVLibLoc, "spirv64-unknown-unknown"); + if (llvm::sys::fs::exists(SPIRVLibLoc)) + LibLocCandidates.emplace_back(SPIRVLibLoc); + } + } const toolchains::SYCLToolChain &SYCLTC = static_cast(*TC); SmallVector DeviceLibraries; diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 70c72596d0900..9a591a741c7a0 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -604,7 +604,7 @@ SYCLToolChain::getDeviceLibNames(const Driver &D, #if defined(_WIN32) "libsycl-msvc-math", #endif - "libsycl-imf"}; + "libsycl-imf", "libm"}; auto addLibraries = [&](const SYCLDeviceLibsList &LibsList) { for (const StringRef &Lib : LibsList) addLibToList(Args.MakeArgString(Lib + ".bc")); @@ -821,6 +821,9 @@ const char *SYCL::Linker::constructLLVMLinkCommand( InputFilename.contains("libspirv") || InputFilename.contains("libdevice"))) return true; + if ((InputFilename.compare("libm.bc") == 0) && + (FileName.find("spirv64-unknown-unknown") != std::string::npos)) + return true; StringRef LibSyclPrefix("libsycl-"); if (!InputFilename.starts_with(LibSyclPrefix) || !InputFilename.ends_with(LibPostfix)) @@ -1908,6 +1911,15 @@ SYCLToolChain::getDeviceLibs( SmallVector, 4> LibraryPaths; SYCLInstallation.getSYCLDeviceLibPath(LibraryPaths); + if (getTriple().isSPIROrSPIRV()) { + SmallVector, 4> OriginalLibraryPaths(LibraryPaths); + for (auto LP : OriginalLibraryPaths) { + SmallString<128> SPIRVLibraryPath(LP); + llvm::sys::path::append(SPIRVLibraryPath, "spirv64-unknown-unknown"); + if (llvm::sys::fs::exists(SPIRVLibraryPath)) + LibraryPaths.emplace_back(SPIRVLibraryPath); + } + } // Formulate all of the device libraries needed for this compilation. SmallVector DeviceLibs = getDeviceLibNames(getDriver(), DriverArgs, getTriple()); diff --git a/clang/test/Driver/Inputs/SYCL/lib/spirv64-unknown-unknown/libm.bc b/clang/test/Driver/Inputs/SYCL/lib/spirv64-unknown-unknown/libm.bc new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/clang-linker-wrapper.cpp b/clang/test/Driver/clang-linker-wrapper.cpp index d0abae0a22cda..8453beb4e072c 100644 --- a/clang/test/Driver/clang-linker-wrapper.cpp +++ b/clang/test/Driver/clang-linker-wrapper.cpp @@ -3,9 +3,9 @@ // ------- // Generate .o file as linker wrapper input. // -// RUN: %clang %s -fsycl -fsycl-targets=spir64-unknown-unknown -c --offload-new-driver -o %t.o -// RUN: %clang %s -fsycl -fsycl-targets=intel_gpu_pvc -c --offload-new-driver -o %t_aot_gpu.o -// RUN: %clang %s -fsycl -fsycl-targets=spir64_x86_64 -c --offload-new-driver -o %t_aot_cpu.o +// RUN: %clang %s -fsycl -fsycl-targets=spir64-unknown-unknown -c --offload-new-driver --no-offloadlib -o %t.o +// RUN: %clang %s -fsycl -fsycl-targets=intel_gpu_pvc -c --offload-new-driver --no-offloadlib -o %t_aot_gpu.o +// RUN: %clang %s -fsycl -fsycl-targets=spir64_x86_64 -c --offload-new-driver --no-offloadlib -o %t_aot_cpu.o // RUN: %clang %s -fsycl -fsycl-targets=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_50 -nocudalib -fno-sycl-libspirv -c --offload-new-driver -o %t_nvptx.o // RUN: %clang %s -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx803 -fgpu-rdc -nogpulib -fno-sycl-libspirv -c --offload-new-driver -o %t_amdgcn.o // RUN: %clang %s -fsycl -fsycl-targets=native_cpu -fno-sycl-libspirv -c --offload-new-driver -o %t_native_cpu.o @@ -105,7 +105,7 @@ // ------- // Generate .o file as linker wrapper input. // -// RUN: %clang %s -fsycl -fsycl-targets=intel_gpu_pvc -c --offload-new-driver -o %t1.o +// RUN: %clang %s -fsycl -fsycl-targets=intel_gpu_pvc -c --offload-new-driver --no-offloadlib -o %t1.o // // Generate .bc file as SYCL device library file. // @@ -136,7 +136,7 @@ // ------- // Generate .o file as linker wrapper input. // -// RUN: %clang %s -fsycl -fsycl-targets=spir64_x86_64 -c --offload-new-driver -o %t2.o +// RUN: %clang %s -fsycl -fsycl-targets=spir64_x86_64 -c --offload-new-driver --no-offloadlib -o %t2.o // // Generate .bc file as SYCL device library file. // @@ -251,7 +251,7 @@ // ------- // Generate .o file as linker wrapper input. // -// RUN: %clang %s -fsycl -fsycl-targets=spir64-unknown-unknown -c --offload-new-driver -o %t5.o +// RUN: %clang %s -fsycl -fsycl-targets=spir64-unknown-unknown -c --offload-new-driver --no-offloadlib -o %t5.o // // RUN: clang-linker-wrapper -sycl-post-link-options="SYCL_POST_LINK_OPTIONS" -llvm-spirv-options="LLVM_SPIRV_OPTIONS" "--host-triple=x86_64-unknown-linux-gnu" "--linker-path=/usr/bin/ld" "--" HOST_LINKER_FLAGS "-dynamic-linker" HOST_DYN_LIB "-o" "a.out" HOST_LIB_PATH HOST_STAT_LIB %t5.o --bitcode-library=spir64-unknown-unknown=%S/Inputs/SYCL/lib/libsycl-crt.bc -sycl-device-library-location=%S/Inputs/SYCL/lib --dry-run 2>&1 | FileCheck -check-prefix=CHK-CMDS-DEVICE-LIB-DIR %s // CHK-CMDS-DEVICE-LIB-DIR: spirv-to-ir-wrapper{{.*}} --llvm-spirv-opts --spirv-preserve-auxdata --spirv-target-env=SPV-IR --spirv-builtin-format=global diff --git a/clang/test/Driver/sycl-device-traits-macros.cpp b/clang/test/Driver/sycl-device-traits-macros.cpp index 1dda50b94c383..03da9088bb3cc 100644 --- a/clang/test/Driver/sycl-device-traits-macros.cpp +++ b/clang/test/Driver/sycl-device-traits-macros.cpp @@ -8,7 +8,7 @@ /// In this case, where no specific sycl targets are passed, the sycl /// targets are spir64 and the host target (e.g. x86_64). We expect two /// occurrences of the macro definition, one for host and one for device. -// RUN: %clang -fsycl --no-offload-new-driver -### %s 2>&1 \ +// RUN: %clang -fsycl --no-offload-new-driver --no-offloadlib -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ENABLED %s // RUN: %clang -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ENABLED %s @@ -18,7 +18,7 @@ /// In this case the sycl targets are spir64, spir64_gen and the host /// target (e.g. x86_64). We expect three occurrences of the macro /// definition, one for host and one for each of the two devices. -// RUN: %clang -fsycl --no-offload-new-driver -fsycl-targets=spir64,spir64_gen -### %s 2>&1 \ +// RUN: %clang -fsycl --no-offload-new-driver --no-offloadlib -fsycl-targets=spir64,spir64_gen -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SYCL-TARGETS %s // RUN: %clang -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -fsycl-targets=spir64,spir64_gen -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SYCL-TARGETS %s @@ -35,11 +35,11 @@ /// Check device traits macros are defined if sycl is enabled: /// Verify that when compiling for multiple targets and maySupportOtherAspects -/// is false for all of the targets, the driver will never add the +/// is false for all of the targets, the driver --no-offloadlib will never add the /// __SYCL_ANY_DEVICE_HAS_ANY_ASPECT__ macro to the compilation arguments. /// NOTE: Both intel_gpu_pvc and amd_gpu_gfx906 have non-empty aspects lists and /// set maySupportOtherAspects to false, hence why they are used for this test. -// RUN: %clangxx -fsycl --no-offload-new-driver -nogpulib -fsycl-targets=intel_gpu_pvc,amd_gpu_gfx906 \ +// RUN: %clangxx -fsycl --no-offload-new-driver --no-offloadlib -nogpulib -fsycl-targets=intel_gpu_pvc,amd_gpu_gfx906 \ // RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/libspirv.bc -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SYCL-TARGETS-NO-MAY-SUPPORT-OTHER-ASPECTS %s // RUN: %clangxx -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -nogpulib -fsycl-targets=intel_gpu_pvc,amd_gpu_gfx906 \ diff --git a/clang/test/Driver/sycl-esimd-force-stateless-mem.cpp b/clang/test/Driver/sycl-esimd-force-stateless-mem.cpp index 65f2cac97ad81..7972479afeee4 100644 --- a/clang/test/Driver/sycl-esimd-force-stateless-mem.cpp +++ b/clang/test/Driver/sycl-esimd-force-stateless-mem.cpp @@ -1,5 +1,5 @@ -/// Verify that the driver option is translated to corresponding options +/// Verify that the driver --no-offloadlib option is translated to corresponding options /// to host/device compilation and sycl-post-link. // Case1: Check that the enforcing is turned on by default. diff --git a/clang/test/Driver/sycl-fsyclbin.cpp b/clang/test/Driver/sycl-fsyclbin.cpp index 36a9dcaf75bd1..7cfc3da4013f2 100644 --- a/clang/test/Driver/sycl-fsyclbin.cpp +++ b/clang/test/Driver/sycl-fsyclbin.cpp @@ -1,7 +1,7 @@ /// Tests behaviors of -fsyclbin /// -fsyclbin is only used with the new offloading model. -// RUN: %clangxx -fsycl -fsyclbin --no-offload-new-driver %s -### 2>&1 \ +// RUN: %clangxx -fsycl -fsyclbin --no-offload-new-driver --no-offloadlib %s -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=UNUSED // UNUSED: warning: argument unused during compilation: '-fsyclbin' diff --git a/clang/test/Driver/sycl-no-rdc-fat-archive-old-model.cpp b/clang/test/Driver/sycl-no-rdc-fat-archive-old-model.cpp index c81bf19e2f61e..02057ff538157 100644 --- a/clang/test/Driver/sycl-no-rdc-fat-archive-old-model.cpp +++ b/clang/test/Driver/sycl-no-rdc-fat-archive-old-model.cpp @@ -13,18 +13,18 @@ // CHECK: 2: clang-offload-unbundler, {1}, tempfilelist // CHECK: 3: spirv-to-ir-wrapper, {2}, tempfilelist, (device-sycl) // CHECK: 4: input, "{{.*}}libsycl-crt.bc", ir, (device-sycl) -// CHECK: 10: linker, {4, {{.*}}}, ir, (device-sycl) -// CHECK: 11: linker, {3, 10}, ir, (device-sycl) -// CHECK: 12: foreach, {3, 11}, ir, (device-sycl) -// CHECK: 13: file-table-tform, {3, 12}, tempfilelist, (device-sycl) -// CHECK: 14: sycl-post-link, {13}, tempfiletable, (device-sycl) -// CHECK: 15: foreach, {13, 14}, tempfiletable, (device-sycl) -// CHECK: 16: file-table-tform, {15}, tempfilelist, (device-sycl) -// CHECK: 17: file-table-tform, {15}, tempfilelist, (device-sycl) -// CHECK: 18: foreach, {13, 17}, tempfilelist, (device-sycl) -// CHECK: 19: file-table-tform, {18}, tempfilelist, (device-sycl) -// CHECK: 20: llvm-spirv, {19}, tempfilelist, (device-sycl) -// CHECK: 21: file-table-tform, {16, 20}, tempfiletable, (device-sycl) -// CHECK: 22: clang-offload-wrapper, {21}, object, (device-sycl) -// CHECK: 23: offload, "device-sycl (spir64-unknown-unknown)" {22}, object -// CHECK: 24: linker, {0, 23}, image, (host-sycl) +// CHECK: 11: linker, {4, {{.*}}}, ir, (device-sycl) +// CHECK: 12: linker, {3, 11}, ir, (device-sycl) +// CHECK: 13: foreach, {3, 12}, ir, (device-sycl) +// CHECK: 14: file-table-tform, {3, 13}, tempfilelist, (device-sycl) +// CHECK: 15: sycl-post-link, {14}, tempfiletable, (device-sycl) +// CHECK: 16: foreach, {14, 15}, tempfiletable, (device-sycl) +// CHECK: 17: file-table-tform, {16}, tempfilelist, (device-sycl) +// CHECK: 18: file-table-tform, {16}, tempfilelist, (device-sycl) +// CHECK: 19: foreach, {14, 18}, tempfilelist, (device-sycl) +// CHECK: 20: file-table-tform, {19}, tempfilelist, (device-sycl) +// CHECK: 21: llvm-spirv, {20}, tempfilelist, (device-sycl) +// CHECK: 22: file-table-tform, {17, 21}, tempfiletable, (device-sycl) +// CHECK: 23: clang-offload-wrapper, {22}, object, (device-sycl) +// CHECK: 24: offload, "device-sycl (spir64-unknown-unknown)" {23}, object +// CHECK: 25: linker, {0, 24}, image, (host-sycl) diff --git a/clang/test/Driver/sycl-no-rdc-old-model.cpp b/clang/test/Driver/sycl-no-rdc-old-model.cpp index 52d770582cba5..d791eb06048a5 100644 --- a/clang/test/Driver/sycl-no-rdc-old-model.cpp +++ b/clang/test/Driver/sycl-no-rdc-old-model.cpp @@ -12,19 +12,19 @@ // CHECK: 12: preprocessor, {11}, c++-cpp-output, (device-sycl) // CHECK: 13: compiler, {12}, ir, (device-sycl) // CHECK: 18: input, "{{.*}}libsycl-crt.bc", ir, (device-sycl) -// CHECK: 24: linker, {18, {{.*}}}, ir, (device-sycl) -// CHECK: 25: linker, {4, 24}, ir, (device-sycl) -// CHECK: 26: sycl-post-link, {25}, tempfiletable, (device-sycl) -// CHECK: 27: file-table-tform, {26}, tempfilelist, (device-sycl) -// CHECK: 28: llvm-spirv, {27}, tempfilelist, (device-sycl) -// CHECK: 29: file-table-tform, {26, 28}, tempfiletable, (device-sycl) -// CHECK: 30: clang-offload-wrapper, {29}, object, (device-sycl) -// CHECK: 31: offload, "device-sycl (spir64-unknown-unknown)" {30}, object -// CHECK: 32: linker, {13, 24}, ir, (device-sycl) -// CHECK: 33: sycl-post-link, {32}, tempfiletable, (device-sycl) -// CHECK: 34: file-table-tform, {33}, tempfilelist, (device-sycl) -// CHECK: 35: llvm-spirv, {34}, tempfilelist, (device-sycl) -// CHECK: 36: file-table-tform, {33, 35}, tempfiletable, (device-sycl) -// CHECK: 37: clang-offload-wrapper, {36}, object, (device-sycl) -// CHECK: 38: offload, "device-sycl (spir64-unknown-unknown)" {37}, object -// CHECK: 39: linker, {8, 17, 31, 38}, image, (host-sycl) +// CHECK: 25: linker, {18, {{.*}}}, ir, (device-sycl) +// CHECK: 26: linker, {4, 25}, ir, (device-sycl) +// CHECK: 27: sycl-post-link, {26}, tempfiletable, (device-sycl) +// CHECK: 28: file-table-tform, {27}, tempfilelist, (device-sycl) +// CHECK: 29: llvm-spirv, {28}, tempfilelist, (device-sycl) +// CHECK: 30: file-table-tform, {27, 29}, tempfiletable, (device-sycl) +// CHECK: 31: clang-offload-wrapper, {30}, object, (device-sycl) +// CHECK: 32: offload, "device-sycl (spir64-unknown-unknown)" {31}, object +// CHECK: 33: linker, {13, 25}, ir, (device-sycl) +// CHECK: 34: sycl-post-link, {33}, tempfiletable, (device-sycl) +// CHECK: 35: file-table-tform, {34}, tempfilelist, (device-sycl) +// CHECK: 36: llvm-spirv, {35}, tempfilelist, (device-sycl) +// CHECK: 37: file-table-tform, {34, 36}, tempfiletable, (device-sycl) +// CHECK: 38: clang-offload-wrapper, {37}, object, (device-sycl) +// CHECK: 39: offload, "device-sycl (spir64-unknown-unknown)" {38}, object +// CHECK: 40: linker, {8, 17, 32, 39}, image, (host-sycl) diff --git a/clang/test/Driver/sycl-offload-arch-intel-cpu.cpp b/clang/test/Driver/sycl-offload-arch-intel-cpu.cpp index fdf50e430d058..095f8a3bf8bda 100644 --- a/clang/test/Driver/sycl-offload-arch-intel-cpu.cpp +++ b/clang/test/Driver/sycl-offload-arch-intel-cpu.cpp @@ -1,4 +1,4 @@ -/// Tests the behaviors of using -fsycl --offload-new-driver +/// Tests the behaviors of using -fsycl --offload-new-driver --no-offloadlib // --offload-arch=. // SYCL AOT compilation to Intel CPUs using --offload-arch diff --git a/clang/test/Driver/sycl-offload-arch-intel-gpu.cpp b/clang/test/Driver/sycl-offload-arch-intel-gpu.cpp index b7c9c82705e54..e0913732f2057 100644 --- a/clang/test/Driver/sycl-offload-arch-intel-gpu.cpp +++ b/clang/test/Driver/sycl-offload-arch-intel-gpu.cpp @@ -1,4 +1,4 @@ -/// Tests the behaviors of using -fsycl --offload-new-driver +/// Tests the behaviors of using -fsycl --offload-new-driver --no-offloadlib // --offload-arch=. // SYCL AOT compilation to Intel GPUs using --offload-arch diff --git a/clang/test/Driver/sycl-offload-jit.cpp b/clang/test/Driver/sycl-offload-jit.cpp index 89f064acc4a04..de5a022fad6d7 100644 --- a/clang/test/Driver/sycl-offload-jit.cpp +++ b/clang/test/Driver/sycl-offload-jit.cpp @@ -1,4 +1,4 @@ -/// Perform several driver tests for SYCL offloading for JIT +/// Perform several driver --no-offloadlib tests for SYCL offloading for JIT /// Check the phases graph with -fsycl. Use of -fsycl enables offload // RUN: %clang --offload-new-driver --sysroot=%S/Inputs/SYCL -ccc-print-phases --target=x86_64-unknown-linux-gnu -fsycl %s 2>&1 \ @@ -57,6 +57,6 @@ /// Check for option incompatibility with -fsycl // RUN: not %clang -### -fsycl -ffreestanding %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-ffreestanding -// RUN: not %clang -### -fsycl --offload-new-driver -static-libstdc++ %s 2>&1 \ +// RUN: not %clang -### -fsycl --offload-new-driver --no-offloadlib -static-libstdc++ %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s -DINCOMPATOPT=-static-libstdc++ // CHK-INCOMPATIBILITY: error: invalid argument '[[INCOMPATOPT]]' not allowed with '-fsycl' diff --git a/clang/test/Driver/sycl-offload-new-driver.cpp b/clang/test/Driver/sycl-offload-new-driver.cpp index 6aa189703809a..7bec2623f2e60 100644 --- a/clang/test/Driver/sycl-offload-new-driver.cpp +++ b/clang/test/Driver/sycl-offload-new-driver.cpp @@ -30,10 +30,10 @@ // CHK-FLOW-NEXT: clang-linker-wrapper{{.*}} "--host-triple=x86_64-unknown-linux-gnu"{{.*}} "--linker-path={{.*}}/ld" {{.*}} "[[CC1FINALOUT]]" /// Verify phases used to generate SPIR-V instead of LLVM-IR -// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-device-obj=spirv -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix SPIRV_OBJ %s -// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-device-only -fsycl-device-obj=spirv \ // RUN: -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix SPIRV_OBJ %s @@ -113,7 +113,7 @@ /// Check phases with multiple intel_gpu settings // RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl \ // RUN: -fsycl-targets=intel_gpu_dg1,intel_gpu_pvc \ -// RUN: --offload-new-driver -ccc-print-phases %s 2>&1 \ +// RUN: --offload-new-driver --no-offloadlib -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix=MULT_TARG_PHASES %s // MULT_TARG_PHASES: 0: input, "[[INPUT:.+\.cpp]]", c++, (host-sycl) // MULT_TARG_PHASES: 1: preprocessor, {0}, c++-cpp-output, (host-sycl) diff --git a/clang/test/Driver/sycl-offload.cpp b/clang/test/Driver/sycl-offload.cpp index 44cf684999acc..ec8df82dfe2f4 100644 --- a/clang/test/Driver/sycl-offload.cpp +++ b/clang/test/Driver/sycl-offload.cpp @@ -1,5 +1,5 @@ /// -/// Perform several driver tests for SYCL offloading +/// Perform several driver --no-offloadlib tests for SYCL offloading /// // REQUIRES: x86-registered-target @@ -33,7 +33,7 @@ /// ########################################################################### -/// Check error for no -fsycl --offload-new-driver option +/// Check error for no -fsycl --offload-new-driver --no-offloadlib option // RUN: not %clang -### -fsycl-targets=spir64-unknown-unknown %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-NO-FSYCL %s // RUN: not %clang_cl -### -fsycl-targets=spir64-unknown-unknown %s 2>&1 \ @@ -479,14 +479,14 @@ /// passing of a library should not trigger the unbundler // RUN: touch %t.a // RUN: touch %t.lib -// RUN: %clang -ccc-print-phases -fsycl --offload-new-driver -fno-sycl-instrument-device-code --no-offloadlib %t.a %s 2>&1 \ +// RUN: %clang -ccc-print-phases -fsycl --offload-new-driver --no-offloadlib -fno-sycl-instrument-device-code --no-offloadlib %t.a %s 2>&1 \ // RUN: | FileCheck -check-prefix=LIB-UNBUNDLE-CHECK %s -// RUN: %clang_cl -ccc-print-phases -fsycl --offload-new-driver -fno-sycl-instrument-device-code --no-offloadlib %t.lib %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl --offload-new-driver --no-offloadlib -fno-sycl-instrument-device-code --no-offloadlib %t.lib %s 2>&1 \ // RUN: | FileCheck -check-prefix=LIB-UNBUNDLE-CHECK %s // LIB-UNBUNDLE-CHECK-NOT: clang-offload-unbundler /// passing of only a library should not create a device link -// RUN: %clang -ccc-print-phases -fsycl --offload-new-driver -lsomelib 2>&1 \ +// RUN: %clang -ccc-print-phases -fsycl --offload-new-driver --no-offloadlib -lsomelib 2>&1 \ // RUN: | FileCheck -check-prefix=LIB-NODEVICE %s // LIB-NODEVICE: 0: input, "somelib", object, (host-sycl) // LIB-NODEVICE: 1: clang-linker-wrapper, {0}, image, (host-sycl) @@ -612,7 +612,7 @@ /// ########################################################################### -/// Check that the needed -fsycl --offload-new-driver -fsycl-is-device and -fsycl-is-host options +/// Check that the needed -fsycl --offload-new-driver --no-offloadlib -fsycl-is-device and -fsycl-is-host options /// are passed to all of the needed compilation steps regardless of final /// phase. // RUN: %clang -### -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -c %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s diff --git a/clang/test/Driver/sycl-post-link-options.cpp b/clang/test/Driver/sycl-post-link-options.cpp index 98db4fcefb5c9..3bcb38143d065 100644 --- a/clang/test/Driver/sycl-post-link-options.cpp +++ b/clang/test/Driver/sycl-post-link-options.cpp @@ -2,13 +2,13 @@ // REQUIRES: libdevice // RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl -### \ -// RUN: --no-offload-new-driver -Xdevice-post-link -O0 %s --sysroot=%S/Inputs/SYCL 2>&1 \ +// RUN: --no-offload-new-driver --no-offloadlib -Xdevice-post-link -O0 %s --sysroot=%S/Inputs/SYCL 2>&1 \ // RUN: | FileCheck -check-prefix OPTIONS_POSTLINK_JIT_OLD %s // OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "--device-lib-dir={{.*}}" "-properties" "-spec-const=native" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0" // // Generate .o file as linker wrapper input. // -// RUN: %clang %s -fsycl -fsycl-targets=spir64-unknown-unknown -c --offload-new-driver -o %t.o +// RUN: %clang %s -fsycl -fsycl-targets=spir64-unknown-unknown -c --offload-new-driver --no-offloadlib -o %t.o // // Generate .bc file as SYCL device library file. // @@ -30,26 +30,26 @@ // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck --check-prefix OPTIONS_POSTLINK_JIT_NEW_SYCLBIN %s // OPTIONS_POSTLINK_JIT_NEW_SYCLBIN: sycl-post-link{{.*}} -spec-const=native -properties -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-kernel-names -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0 // -// Ensure driver forwards these triple based options to clang-linker-wrapper. +// Ensure driver --no-offloadlib forwards these triple based options to clang-linker-wrapper. // -// RUN: %clangxx %s -### -fsycl --offload-new-driver \ +// RUN: %clangxx %s -### -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-remove-unused-external-funcs \ // RUN: -fsycl-device-code-split-esimd \ // RUN: -fsycl-add-default-spec-consts-image \ // RUN: 2>&1 | FileCheck --check-prefix=OPTIONS_FORWARD %s -// RUN: %clang_cl %s -### -fsycl --offload-new-driver \ +// RUN: %clang_cl %s -### -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-remove-unused-external-funcs \ // RUN: -fsycl-device-code-split-esimd \ // RUN: -fsycl-add-default-spec-consts-image \ // RUN: 2>&1 | FileCheck --check-prefix=OPTIONS_FORWARD %s // OPTIONS_FORWARD: clang-linker-wrapper{{.*}} "-sycl-remove-unused-external-funcs" "-sycl-device-code-split-esimd" "-sycl-add-default-spec-consts-image" // -// RUN: %clangxx %s -### -fsycl --offload-new-driver \ +// RUN: %clangxx %s -### -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fno-sycl-remove-unused-external-funcs \ // RUN: -fno-sycl-device-code-split-esimd \ // RUN: -fno-sycl-add-default-spec-consts-image \ // RUN: 2>&1 | FileCheck --check-prefix=OPTIONS_FORWARD_NO %s -// RUN: %clang_cl %s -### -fsycl --offload-new-driver \ +// RUN: %clang_cl %s -### -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fno-sycl-remove-unused-external-funcs \ // RUN: -fno-sycl-device-code-split-esimd \ // RUN: -fno-sycl-add-default-spec-consts-image \ @@ -74,7 +74,7 @@ // // Generate AOT .o file as linker wrapper input. // -// RUN: %clang %s -fsycl -fsycl-targets=spir64_gen-unknown-unknown -c --offload-new-driver -o %t_aot.o +// RUN: %clang %s -fsycl -fsycl-targets=spir64_gen-unknown-unknown -c --offload-new-driver --no-offloadlib -o %t_aot.o // // Generate AOT .bc file as SYCL device library file. // diff --git a/clang/test/Driver/sycl-preprocess.cpp b/clang/test/Driver/sycl-preprocess.cpp index 89eb0e999b148..c311e08720084 100644 --- a/clang/test/Driver/sycl-preprocess.cpp +++ b/clang/test/Driver/sycl-preprocess.cpp @@ -3,23 +3,23 @@ /// Creating a preprocessed file is expected to do an integration header /// creation step. -// RUN: %clangxx -fsycl --offload-new-driver -E -o %t_output.ii %s -### 2>&1 \ +// RUN: %clangxx -fsycl --offload-new-driver --no-offloadlib -E -o %t_output.ii %s -### 2>&1 \ // RUN: | FileCheck -check-prefix PREPROC_ONLY %s -// RUN: %clang_cl -fsycl --offload-new-driver -P %s -### 2>&1 \ +// RUN: %clang_cl -fsycl --offload-new-driver --no-offloadlib -P %s -### 2>&1 \ // RUN: | FileCheck -check-prefix PREPROC_ONLY %s // PREPROC_ONLY: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\.h]]"{{.*}} "-E" // PREPROC_ONLY: clang{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-include-internal-footer" "[[INTFOOTER]]"{{.*}} "-o" "[[HOST_OUT:.+\.ii]]" /// When compiling from preprocessed file, no integration header is expected // RUN: touch %t.ii -// RUN: %clangxx -fsycl --offload-new-driver %t.ii -### 2>&1 | FileCheck -check-prefix PREPROC_IN %s +// RUN: %clangxx -fsycl --offload-new-driver --no-offloadlib %t.ii -### 2>&1 | FileCheck -check-prefix PREPROC_IN %s // PREPROC_IN-NOT: "-fsycl-int-header={{.*}}" // PREPROC_IN: clang{{.*}} "-fsycl-is-host" /// When generating preprocessed files, verify the compilation phases. -// RUN: %clangxx --target=x86_64-unknown-linux-gnu --offload-new-driver -fsycl -E %s -o %t.ii -ccc-print-phases 2>&1 \ +// RUN: %clangxx --target=x86_64-unknown-linux-gnu --offload-new-driver --no-offloadlib -fsycl -E %s -o %t.ii -ccc-print-phases 2>&1 \ // RUN: | FileCheck %s -check-prefix PREPROC_PHASES -DTARGET=x86_64-unknown-linux-gnu -// RUN: %clang_cl --target=x86_64-pc-windows-msvc --offload-new-driver -fsycl -P %s -Fi%t.ii -ccc-print-phases 2>&1 \ +// RUN: %clang_cl --target=x86_64-pc-windows-msvc --offload-new-driver --no-offloadlib -fsycl -P %s -Fi%t.ii -ccc-print-phases 2>&1 \ // RUN: | FileCheck %s -check-prefix PREPROC_PHASES -DTARGET=x86_64-pc-windows-msvc // PREPROC_PHASES: 0: input, "[[INPUT:.+\.cpp]]", c++, (host-sycl) // PREPROC_PHASES: 1: preprocessor, {0}, c++-cpp-output, (host-sycl) @@ -32,11 +32,11 @@ /// When generating preprocessed files, verify the tools called and the expected /// output file name. -// RUN: %clangxx --offload-new-driver -fsycl -E %s -o sycl-preprocess.ii -### 2>&1 \ +// RUN: %clangxx --offload-new-driver --no-offloadlib -fsycl -E %s -o sycl-preprocess.ii -### 2>&1 \ // RUN: | FileCheck %s -check-prefix PREPROC_TOOLS -// RUN: %clang_cl --offload-new-driver -fsycl -P %s -Fisycl-preprocess.ii -### 2>&1 \ +// RUN: %clang_cl --offload-new-driver --no-offloadlib -fsycl -P %s -Fisycl-preprocess.ii -### 2>&1 \ // RUN: | FileCheck %s -check-prefix PREPROC_TOOLS -// RUN: %clang_cl --offload-new-driver -fsycl -E %s -o sycl-preprocess.ii -### 2>&1 \ +// RUN: %clang_cl --offload-new-driver --no-offloadlib -fsycl -E %s -o sycl-preprocess.ii -### 2>&1 \ // RUN: | FileCheck %s -check-prefix PREPROC_TOOLS // PREPROC_TOOLS: clang{{.*}} "-fsycl-is-device" // PREPROC_TOOLS-SAME: "-o" "[[DEVICE_PP_FILE:.+\.ii]] diff --git a/clang/test/Driver/sycl-rtc-mode.cpp b/clang/test/Driver/sycl-rtc-mode.cpp index 132d136d953e6..588027c1f6fe2 100644 --- a/clang/test/Driver/sycl-rtc-mode.cpp +++ b/clang/test/Driver/sycl-rtc-mode.cpp @@ -1,11 +1,11 @@ /// -/// Perform driver test for SYCL RTC mode. +/// Perform driver --no-offloadlib test for SYCL RTC mode. /// /// Check that the '-fsycl-rtc-mode' is correctly forwarded to the device /// compilation and only to the device compilation. -// RUN: %clangxx -fsycl -fsycl-rtc-mode --no-offload-new-driver %s -### 2>&1 \ +// RUN: %clangxx -fsycl -fsycl-rtc-mode --no-offload-new-driver --no-offloadlib %s -### 2>&1 \ // RUN: | FileCheck %s // RUN: %clangxx -fsycl -fsycl-rtc-mode --offload-new-driver --sysroot=%S/Inputs/SYCL %s -### 2>&1 \ @@ -20,7 +20,7 @@ /// Check that the '-fno-sycl-rtc-mode' is correctly forwarded to the device /// compilation and only to the device compilation. -// RUN: %clangxx -fsycl -fno-sycl-rtc-mode --no-offload-new-driver %s -### 2>&1 \ +// RUN: %clangxx -fsycl -fno-sycl-rtc-mode --no-offload-new-driver --no-offloadlib %s -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=NEGATIVE // RUN: %clangxx -fsycl -fno-sycl-rtc-mode --offload-new-driver --sysroot=%S/Inputs/SYCL %s -### 2>&1 \ diff --git a/clang/test/Driver/sycl-spirv-default-options.cpp b/clang/test/Driver/sycl-spirv-default-options.cpp index 32f9eb6711669..9e9711c0ecba1 100644 --- a/clang/test/Driver/sycl-spirv-default-options.cpp +++ b/clang/test/Driver/sycl-spirv-default-options.cpp @@ -5,7 +5,7 @@ // Test for default llvm-spirv options -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-targets=spir64-unknown-unknown -c %s -o %t.o // RUN: clang-linker-wrapper --bitcode-library=spir64-unknown-unknown=%t.devicelib.bc \ // RUN: "--host-triple=x86_64-unknown-linux-gnu" "--linker-path=/usr/bin/ld" \ diff --git a/clang/test/Driver/sycl-spirv-ext.cpp b/clang/test/Driver/sycl-spirv-ext.cpp index 20e7949108b47..ba0d80adac377 100644 --- a/clang/test/Driver/sycl-spirv-ext.cpp +++ b/clang/test/Driver/sycl-spirv-ext.cpp @@ -7,19 +7,19 @@ /// Check llvm-spirv extensions that are set -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-targets=spir64-unknown-unknown -c %s -o %t_1.o // RUN: clang-linker-wrapper --bitcode-library=spir64-unknown-unknown=%t_1.devicelib.bc \ // RUN: "--host-triple=x86_64-unknown-linux-gnu" "--linker-path=/usr/bin/ld" \ // RUN: "--" "-o" "a.out" %t_1.o --dry-run 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-DEFAULT %s -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-targets=spir64_gen-unknown-unknown -c %s -o %t_2.o // RUN: clang-linker-wrapper --bitcode-library=spir64_gen-unknown-unknown=%t_2.devicelib.bc \ // RUN: "--host-triple=x86_64-unknown-linux-gnu" "--linker-path=/usr/bin/ld" \ // RUN: "--" "-o" "a.out" %t_2.o --dry-run 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-DEFAULT %s -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -fsycl-targets=spir64_x86_64-unknown-unknown -c %s -o %t_3.o // RUN: clang-linker-wrapper --bitcode-library=spir64_x86_64-unknown-unknown=%t_3.devicelib.bc \ // RUN: "--host-triple=x86_64-unknown-linux-gnu" "--linker-path=/usr/bin/ld" \ diff --git a/clang/test/Driver/sycl-time-trace-actual.cpp b/clang/test/Driver/sycl-time-trace-actual.cpp index a3d06ec31129c..c04957ffc213d 100644 --- a/clang/test/Driver/sycl-time-trace-actual.cpp +++ b/clang/test/Driver/sycl-time-trace-actual.cpp @@ -9,7 +9,7 @@ // RUN: cp %s %t/src/test.cpp // Test 1: Compile-only mode with explicit trace directory -// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -c -ftime-trace=%t/traces -ftime-trace-granularity=0 \ // RUN: -ftime-trace-verbose %t/src/test.cpp -o %t/test.o @@ -26,7 +26,7 @@ // Test 2: Verify trace file naming with -o option // When using -c with -o, trace files should be named based on the -o output // RUN: rm -rf %t/traces2 && mkdir -p %t/traces2 -// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -c -ftime-trace=%t/traces2 %t/src/test.cpp -o %t/different_name.o // Should be named after the -o output (different_name), not the source (test.cpp) @@ -37,7 +37,7 @@ // Test 3: Compile and link mode // In compile+link mode, trace files are named based on source file // RUN: rm -rf %t/traces3 && mkdir -p %t/traces3 -// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -ftime-trace=%t/traces3 %t/src/test.cpp -o %t/myapp // Frontend traces should still be generated (named after source file) @@ -49,7 +49,7 @@ // RUN: rm -rf %t/traces4 && mkdir -p %t/traces4 %t/src2 // RUN: cp %s %t/src2/file1.cpp // RUN: cp %s %t/src2/file2.cpp -// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -c -ftime-trace=%t/traces4 %t/src2/file1.cpp %t/src2/file2.cpp // Should have clean trace file names since basenames are unique @@ -64,7 +64,7 @@ // RUN: rm -rf %t/traces5 && mkdir -p %t/traces5 %t/dir1 %t/dir2 // RUN: cp %s %t/dir1/test.cpp // RUN: cp %s %t/dir2/test.cpp -// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ +// RUN: %clang --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --no-offloadlib \ // RUN: -c -ftime-trace=%t/traces5 %t/dir1/test.cpp %t/dir2/test.cpp // Should have 4 trace files (2 sources × 2 traces each) diff --git a/clang/test/Driver/sycl-time-trace.cpp b/clang/test/Driver/sycl-time-trace.cpp index 16c99ccddeeaa..f813ff1654cbe 100644 --- a/clang/test/Driver/sycl-time-trace.cpp +++ b/clang/test/Driver/sycl-time-trace.cpp @@ -1,6 +1,6 @@ // Enable time tracing capability in SYCL applications. -// This test verifies that Clang driver correctly propagates time-trace related options +// This test verifies that Clang driver --no-offloadlib correctly propagates time-trace related options // during a compile-only invocation and enables JSON time-trace output. // REQUIRES: system-linux @@ -10,40 +10,40 @@ // SYCL-DEVICE-COMPILE: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=e{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // SYCL-HOST-COMPILE: -cc1{{.*}} "-fsycl-is-host"{{.*}} "-ftime-trace=e{{/|\\\\}}a-host-x86_64-unknown-linux-gnu.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" -// Verify that the Clang driver generates JSON time-trace output for compile-only +// Verify that the Clang driver --no-offloadlib generates JSON time-trace output for compile-only // invocation and propagates the time-trace options, respecting the specified dump directory. // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -dumpdir f/ 2>&1 | FileCheck %s --check-prefixes=SYCL-DEVICE-DUMPDIR,SYCL-HOST-DUMPDIR // SYCL-DEVICE-DUMPDIR: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=f{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // SYCL-HOST-DUMPDIR: -cc1{{.*}} "-fsycl-is-host"{{.*}} "-ftime-trace=f{{/|\\\\}}a-host-x86_64-unknown-linux-gnu.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" -// This test verifies that Clang driver correctly propagates time-trace related options +// This test verifies that Clang driver --no-offloadlib correctly propagates time-trace related options // during a compile-and-link invocation and enables JSON time-trace output. // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -ftime-trace=e -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -o f/x -dumpdir f/ 2>&1 | FileCheck %s --check-prefixes=LINK-DEVICE,LINK-HOST // LINK-DEVICE: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=e{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // LINK-HOST: -cc1{{.*}} "-fsycl-is-host"{{.*}} "-ftime-trace=e{{/|\\\\}}a-host-x86_64-unknown-linux-gnu.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // Verify time tracing works for SYCL offload in the old model -// This test verifies that Clang driver correctly propagates time-trace related options +// This test verifies that Clang driver --no-offloadlib correctly propagates time-trace related options // during a compile-only invocation and enables JSON time-trace output. // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -o e/a.o 2>&1 | FileCheck %s --check-prefixes=SYCL-DEVICE-COMPILE-OLD-MODEL,SYCL-HOST-COMPILE-OLD-MODEL // SYCL-DEVICE-COMPILE-OLD-MODEL: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=e{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // SYCL-HOST-COMPILE-OLD-MODEL: -cc1{{.*}} "-fsycl-is-host"{{.*}} "-ftime-trace=e{{/|\\\\}}a-host-x86_64-unknown-linux-gnu.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" -// Verify that the Clang driver generates JSON time-trace output for compile-only +// Verify that the Clang driver --no-offloadlib generates JSON time-trace output for compile-only // invocation and propagates the time-trace options, respecting the specified dump directory. // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -dumpdir f/ 2>&1 | FileCheck %s --check-prefixes=SYCL-DEVICE-DUMPDIR-OLD-MODEL,SYCL-HOST-DUMPDIR-OLD-MODEL // SYCL-DEVICE-DUMPDIR-OLD-MODEL: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=f{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // SYCL-HOST-DUMPDIR-OLD-MODEL: -cc1{{.*}} "-fsycl-is-host"{{.*}} "-ftime-trace=f{{/|\\\\}}a-host-x86_64-unknown-linux-gnu.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" -// This test verifies that Clang driver correctly propagates time-trace related options +// This test verifies that Clang driver --no-offloadlib correctly propagates time-trace related options // during a compile-and-link invocation and enables JSON time-trace output. // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -ftime-trace=e -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -o f/x -dumpdir f/ 2>&1 | FileCheck %s --check-prefixes=LINK-DEVICE-OLD-MODEL,LINK-HOST-OLD-MODEL // LINK-DEVICE-OLD-MODEL: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=e{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // LINK-HOST-OLD-MODEL: -cc1{{.*}} "-fsycl-is-host"{{.*}} "-ftime-trace=e{{/|\\\\}}a-host-x86_64-unknown-linux-gnu.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" -// Verify time tracing works with -fsycl-device-only (new driver model) +// Verify time tracing works with -fsycl-device-only (new driver --no-offloadlib model) // This test verifies device-only compilation generates the correct time-trace file // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -fsycl-device-only -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -o e/a.o 2>&1 | FileCheck %s --check-prefixes=DEVICE-ONLY-COMPILE // DEVICE-ONLY-COMPILE: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=e{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" @@ -54,12 +54,12 @@ // DEVICE-ONLY-DUMPDIR: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=f{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // DEVICE-ONLY-DUMPDIR-NOT: "-fsycl-is-host" -// Verify time tracing works with -fsycl-device-only (old driver model) +// Verify time tracing works with -fsycl-device-only (old driver --no-offloadlib model) // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -fsycl-device-only -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -o e/a.o 2>&1 | FileCheck %s --check-prefixes=DEVICE-ONLY-COMPILE-OLD // DEVICE-ONLY-COMPILE-OLD: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=e{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // DEVICE-ONLY-COMPILE-OLD-NOT: "-fsycl-is-host" -// Verify device-only compilation with -dumpdir (old driver model) +// Verify device-only compilation with -dumpdir (old driver --no-offloadlib model) // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -fsycl-device-only -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp -dumpdir f/ 2>&1 | FileCheck %s --check-prefixes=DEVICE-ONLY-DUMPDIR-OLD // DEVICE-ONLY-DUMPDIR-OLD: -cc1{{.*}} "-fsycl-is-device"{{.*}} "-ftime-trace=f{{/|\\\\}}a-sycl-spir64-unknown-unknown.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose" // DEVICE-ONLY-DUMPDIR-OLD-NOT: "-fsycl-is-host" diff --git a/clang/test/Driver/sycl-xarch.cpp b/clang/test/Driver/sycl-xarch.cpp index cf40d63d67e0a..76cd59d64b35e 100644 --- a/clang/test/Driver/sycl-xarch.cpp +++ b/clang/test/Driver/sycl-xarch.cpp @@ -1,5 +1,5 @@ /// -/// Perform several driver tests for SYCL -Xarch_device/host on Linux +/// Perform several driver --no-offloadlib tests for SYCL -Xarch_device/host on Linux /// // UNSUPPORTED: system-windows diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index e796598e48924..0cec9c9d67ec7 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -269,6 +269,13 @@ else() set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}) endif() +if (LIBC_TARGET_ARCHITECTURE_IS_SPIRV AND WIN32) + set(LIBC_INCLUDE_DIR ${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}) +endif() + if(LIBC_TARGET_OS_IS_GPU) include(prepare_libc_gpu_build) set(LIBC_ENABLE_UNITTESTS OFF) @@ -412,7 +419,7 @@ add_subdirectory(hdr) add_subdirectory(src) add_subdirectory(utils) -if(LLVM_LIBC_FULL_BUILD) +if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_ARCHITECTURE_IS_SPIRV) # The startup system can potentially depend on the library components so add # it after the library implementation directories. add_subdirectory(startup) diff --git a/libc/cmake/modules/LLVMLibCLibraryRules.cmake b/libc/cmake/modules/LLVMLibCLibraryRules.cmake index 9f8c6c0db8c6f..2dc346fc15330 100644 --- a/libc/cmake/modules/LLVMLibCLibraryRules.cmake +++ b/libc/cmake/modules/LLVMLibCLibraryRules.cmake @@ -116,8 +116,54 @@ function(add_bitcode_entrypoint_library target_name base_target_name) target_link_options(${target_name} PRIVATE "${LIBC_COMPILE_OPTIONS_DEFAULT}" "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm") endif() + add_dependencies(${base_target_name} ${target_name}) endfunction(add_bitcode_entrypoint_library) +# A rule to build a library from a collection of entrypoint objects and bundle +# it in a single LLVM-IR bitcode file with llvm-link +# Usage: +# link_bitcode_library( +# DEPENDS +# ) +function(link_bitcode_library target_name base_target_name output_name) + cmake_parse_arguments( + "ENTRYPOINT_LIBRARY" + "" # No optional arguments + "" # No single value arguments + "DEPENDS" # Multi-value arguments + ${ARGN} + ) + if(NOT ENTRYPOINT_LIBRARY_DEPENDS) + message(FATAL_ERROR "'link_bitcode_library' target requires a DEPENDS list " + "of 'add_entrypoint_object' targets.") + endif() + + get_fq_deps_list(fq_deps_list ${ENTRYPOINT_LIBRARY_DEPENDS}) + get_all_object_file_deps(all_deps "${fq_deps_list}") + + set(objects "") + foreach(dep IN LISTS all_deps) + set(object $<$,${dep}>:$>) + list(APPEND objects ${object}) + endforeach() + + find_program(LLVM_LINK_EXE + NAMES llvm-link + PATHS ${LLVM_TOOLS_BINARY_DIR} + NO_DEFAULT_PATH) + string(REPLACE ";" "\n" rsp_contents "${objects}") + file(GENERATE + OUTPUT ${CMAKE_BINARY_DIR}/${target_name}.rsp + CONTENT "${rsp_contents}") + if(LLVM_LINK_EXE) + set(bc_file ${CMAKE_BINARY_DIR}/libc/lib/${output_name}) + add_custom_target(${target_name} + COMMAND ${LLVM_LINK_EXE} -o ${bc_file} @${CMAKE_BINARY_DIR}/${target_name}.rsp + DEPENDS ${objects}) + add_dependencies(${base_target_name} ${target_name}) + endif() +endfunction(link_bitcode_library) + # A rule to build a library from a collection of entrypoint objects. # Usage: # add_entrypoint_library( diff --git a/libc/config/gpu/spirv/entrypoints.txt b/libc/config/gpu/spirv/entrypoints.txt index 11edc358339b7..52cedb54a338e 100644 --- a/libc/config/gpu/spirv/entrypoints.txt +++ b/libc/config/gpu/spirv/entrypoints.txt @@ -31,6 +31,9 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.ctype.toupper libc.src.ctype.toupper_l + # errno.h entrypoints + libc.src.errno.errno + # string.h entrypoints libc.src.string.memccpy libc.src.string.memchr @@ -85,6 +88,88 @@ set(TARGET_LIBC_ENTRYPOINTS ) set(TARGET_LIBM_ENTRYPOINTS + # math.h entrypoints + libc.src.math.acos + libc.src.math.acosf + libc.src.math.asin + libc.src.math.asinf + libc.src.math.atan2 + libc.src.math.atan2f + libc.src.math.atan + libc.src.math.atanf + libc.src.math.cbrt + libc.src.math.ceil + libc.src.math.ceilf + libc.src.math.copysign + libc.src.math.copysignf + libc.src.math.cos + libc.src.math.cosf + libc.src.math.coshf + libc.src.math.cospif + libc.src.math.exp10 + libc.src.math.exp10f + libc.src.math.exp2 + libc.src.math.exp2f + libc.src.math.exp + libc.src.math.expf + libc.src.math.fabs + libc.src.math.fabsf + libc.src.math.fdim + libc.src.math.fdimf + libc.src.math.floor + libc.src.math.floorf + libc.src.math.fma + libc.src.math.fmaf + libc.src.math.fmax + libc.src.math.fmaxf + libc.src.math.fmin + libc.src.math.fminf + libc.src.math.fmod + libc.src.math.frexp + libc.src.math.frexpf + libc.src.math.ilogb + libc.src.math.ilogbf + libc.src.math.ldexp + libc.src.math.ldexpf + libc.src.math.log + libc.src.math.logf + libc.src.math.log10 + libc.src.math.log10f + libc.src.math.log2 + libc.src.math.log2f + libc.src.math.logb + libc.src.math.logbf + libc.src.math.modf + libc.src.math.modff + libc.src.math.nextafter + libc.src.math.nextafterf + libc.src.math.pow + libc.src.math.powf + libc.src.math.remainder + libc.src.math.remainderf + libc.src.math.remquo + libc.src.math.remquof + libc.src.math.rint + libc.src.math.rintf + libc.src.math.round + libc.src.math.roundf + libc.src.math.rsqrtf + libc.src.math.scalbln + libc.src.math.scalblnf + libc.src.math.scalbn + libc.src.math.scalbnf + libc.src.math.sin + libc.src.math.sinf + libc.src.math.sinhf + libc.src.math.sinpif + libc.src.math.sqrt + libc.src.math.sqrtf + libc.src.math.tan + libc.src.math.tanf + libc.src.math.tanh + libc.src.math.tanhf + libc.src.math.trunc + libc.src.math.truncf ) if(LIBC_TYPES_HAS_FLOAT16) diff --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt index 19751a9cc0736..50b0f95c3cf2c 100644 --- a/libc/lib/CMakeLists.txt +++ b/libc/lib/CMakeLists.txt @@ -40,17 +40,37 @@ foreach(archive IN ZIP_LISTS # Add the offloading version of the library for offloading languages. These # are installed in the standard search path separate from the other libraries. if(LIBC_TARGET_OS_IS_GPU) - add_bitcode_entrypoint_library( - ${archive_1}bitcode - ${archive_1} - DEPENDS - ${${archive_2}} - ) - set_target_properties( - ${archive_1}bitcode - PROPERTIES - OUTPUT_NAME ${archive_1}.bc - ) + if (NOT WIN32) + add_bitcode_entrypoint_library( + ${archive_1}bitcode + ${archive_1} + DEPENDS + ${${archive_2}} + ) + set_target_properties( + ${archive_1}bitcode + PROPERTIES + OUTPUT_NAME ${archive_1}.bc + ) + else() + link_bitcode_library( + ${archive_1}bitcode + ${archive_1} + ${archive_1}.bc + DEPENDS + ${${archive_2}} + ) + set_target_properties( + ${archive_1}bitcode + PROPERTIES + LINK_OUTPUT_NAME ${CMAKE_BINARY_DIR}/libc/lib/${archive_1}.bc + ) + set_target_properties( + ${archive_1}bitcode + PROPERTIES + OUTPUT_NAME ${archive_1}.bc + ) + endif() list(APPEND added_bitcode_targets ${archive_1}bitcode) endif() endforeach() @@ -61,13 +81,23 @@ install( COMPONENT libc ) -foreach(file ${added_bitcode_targets}) - install(FILES $ - DESTINATION ${LIBC_INSTALL_LIBRARY_DIR} - RENAME $ - COMPONENT libc - ) -endforeach() +if(WIN32) + foreach(file ${added_bitcode_targets}) + install(FILES $ + DESTINATION ${LIBC_INSTALL_LIBRARY_DIR} + RENAME $ + COMPONENT libc + ) + endforeach() +else() + foreach(file ${added_bitcode_targets}) + install(FILES $ + DESTINATION ${LIBC_INSTALL_LIBRARY_DIR} + RENAME $ + COMPONENT libc + ) + endforeach() +endif() if(NOT LIBC_TARGET_OS_IS_BAREMETAL) # For now we will disable libc-startup installation for baremetal. The @@ -80,19 +110,17 @@ if(LLVM_LIBC_FULL_BUILD) set(header_install_target install-libc-headers) endif() +set(install-libc-depends ${added_archive_targets} ${added_bitcode_targets} ${header_install_target}) +if (NOT LIBC_TARGET_ARCHITECTURE_IS_SPIRV) + list(APPEND install-libc-depends ${startup_target}) +endif() add_custom_target(install-libc - DEPENDS ${added_archive_targets} - ${added_bitcode_targets} - ${startup_target} - ${header_install_target} + DEPENDS ${install-libc-depends} COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=libc -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") add_custom_target(install-libc-stripped - DEPENDS ${added_archive_targets} - ${added_bitcode_targets} - ${startup_target} - ${header_install_target} + DEPENDS ${install-libc-depends} COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=libc -DCMAKE_INSTALL_DO_STRIP=1 diff --git a/libc/src/math/spirv/CMakeLists.txt b/libc/src/math/spirv/CMakeLists.txt new file mode 100644 index 0000000000000..1eaffc547da9c --- /dev/null +++ b/libc/src/math/spirv/CMakeLists.txt @@ -0,0 +1,495 @@ +add_entrypoint_object( + acos + SRCS + acos.cpp + HDRS + ../acos.h +) + +add_entrypoint_object( + acosf + SRCS + acosf.cpp + HDRS + ../acosf.h +) + +add_entrypoint_object( + asin + SRCS + asin.cpp + HDRS + ../asin.h +) + +add_entrypoint_object( + asinf + SRCS + asinf.cpp + HDRS + ../asinf.h +) + +add_entrypoint_object( + atan2 + SRCS + atan2.cpp + HDRS + ../atan2.h +) + +add_entrypoint_object( + atan2f + SRCS + atan2f.cpp + HDRS + ../atan2f.h +) + +add_entrypoint_object( + atan + SRCS + atan.cpp + HDRS + ../atan.h +) + +add_entrypoint_object( + atanf + SRCS + atanf.cpp + HDRS + ../atanf.h +) + +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( + cos + SRCS + cos.cpp + HDRS + ../cos.h +) + +add_entrypoint_object( + cosf + SRCS + cosf.cpp + HDRS + ../cosf.h +) + +add_entrypoint_object( + coshf + SRCS + coshf.cpp + HDRS + ../coshf.h +) + +add_entrypoint_object( + exp10 + SRCS + exp10.cpp + HDRS + ../exp10.h +) + +add_entrypoint_object( + exp10f + SRCS + exp10f.cpp + HDRS + ../exp10f.h +) + +add_entrypoint_object( + exp2 + SRCS + exp2.cpp + HDRS + ../exp2.h +) + +add_entrypoint_object( + exp2f + SRCS + exp2f.cpp + HDRS + ../exp2f.h +) + +add_entrypoint_object( + exp + SRCS + exp.cpp + HDRS + ../exp.h +) + +add_entrypoint_object( + expf + SRCS + expf.cpp + HDRS + ../expf.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( + frexp + SRCS + frexp.cpp + HDRS + ../frexp.h +) + +add_entrypoint_object( + frexpf + SRCS + frexpf.cpp + HDRS + ../frexpf.h +) + +add_entrypoint_object( + ldexp + SRCS + ldexp.cpp + HDRS + ../ldexp.h +) + +add_entrypoint_object( + ldexpf + SRCS + ldexpf.cpp + HDRS + ../ldexpf.h +) + +add_entrypoint_object( + log10 + SRCS + log10.cpp + HDRS + ../log10.h +) + +add_entrypoint_object( + log10f + SRCS + log10f.cpp + HDRS + ../log10f.h +) + +add_entrypoint_object( + log2 + SRCS + log2.cpp + HDRS + ../log2.h +) + +add_entrypoint_object( + log2f + SRCS + log2f.cpp + HDRS + ../log2f.h +) + +add_entrypoint_object( + log + SRCS + log.cpp + HDRS + ../log.h +) + +add_entrypoint_object( + logf + SRCS + logf.cpp + HDRS + ../logf.h +) + +add_entrypoint_object( + pow + SRCS + pow.cpp + HDRS + ../pow.h +) + +add_entrypoint_object( + powf + SRCS + powf.cpp + HDRS + ../powf.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( + roundf + SRCS + roundf.cpp + HDRS + ../roundf.h +) + +add_entrypoint_object( + scalbln + SRCS + scalbln.cpp + HDRS + ../scalbln.h +) + +add_entrypoint_object( + scalblnf + SRCS + scalblnf.cpp + HDRS + ../scalblnf.h +) + +add_entrypoint_object( + scalbn + SRCS + scalbn.cpp + HDRS + ../scalbn.h +) + +add_entrypoint_object( + scalbnf + SRCS + scalbnf.cpp + HDRS + ../scalbnf.h +) + +add_entrypoint_object( + sin + SRCS + sin.cpp + HDRS + ../sin.h +) + +add_entrypoint_object( + sinf + SRCS + sinf.cpp + HDRS + ../sinf.h +) + +add_entrypoint_object( + sinhf + SRCS + sinhf.cpp + HDRS + ../sinhf.h +) + +add_entrypoint_object( + sqrt + SRCS + sqrt.cpp + HDRS + ../sqrt.h +) + +add_entrypoint_object( + sqrtf + SRCS + sqrtf.cpp + HDRS + ../sqrtf.h +) + +add_entrypoint_object( + tan + SRCS + tan.cpp + HDRS + ../tan.h +) + +add_entrypoint_object( + tanf + SRCS + tanf.cpp + HDRS + ../tanf.h +) + +add_entrypoint_object( + tanh + SRCS + tanh.cpp + HDRS + ../tanh.h +) + +add_entrypoint_object( + tanhf + SRCS + tanhf.cpp + HDRS + ../tanhf.h +) + +add_entrypoint_object( + trunc + SRCS + trunc.cpp + HDRS + ../trunc.h +) + +add_entrypoint_object( + truncf + SRCS + truncf.cpp + HDRS + ../truncf.h +) diff --git a/libc/src/math/spirv/acos.cpp b/libc/src/math/spirv/acos.cpp new file mode 100644 index 0000000000000..2c5cdd1428319 --- /dev/null +++ b/libc/src/math/spirv/acos.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU acos 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/acos.h" +#include "src/__support/math/acos.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, acos, (double x)) { return __builtin_acos(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/acosf.cpp b/libc/src/math/spirv/acosf.cpp new file mode 100644 index 0000000000000..de34130101c17 --- /dev/null +++ b/libc/src/math/spirv/acosf.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU acosf 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/acosf.h" +#include "src/__support/math/acosf.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, acosf, (float x)) { return __builtin_acosf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/asin.cpp b/libc/src/math/spirv/asin.cpp new file mode 100644 index 0000000000000..7e533b81a4681 --- /dev/null +++ b/libc/src/math/spirv/asin.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU asin 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/asin.h" +#include "src/__support/math/asin.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, asin, (double x)) { return __builtin_asin(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/asinf.cpp b/libc/src/math/spirv/asinf.cpp new file mode 100644 index 0000000000000..8e5d4396107aa --- /dev/null +++ b/libc/src/math/spirv/asinf.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU asinf 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/asinf.h" +#include "src/__support/math/asinf.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, asinf, (float x)) { return __builtin_asinf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/atan.cpp b/libc/src/math/spirv/atan.cpp new file mode 100644 index 0000000000000..c01c89c7d0e0b --- /dev/null +++ b/libc/src/math/spirv/atan.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU atan 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/atan.h" +#include "src/__support/math/atan.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, atan, (double x)) { return __builtin_atan(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/atan2.cpp b/libc/src/math/spirv/atan2.cpp new file mode 100644 index 0000000000000..e8620f9f8f438 --- /dev/null +++ b/libc/src/math/spirv/atan2.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU atan2 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/atan2.h" +#include "src/__support/math/atan2.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, atan2, (double y, double x)) { + return __builtin_atan2(y, x); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/atan2f.cpp b/libc/src/math/spirv/atan2f.cpp new file mode 100644 index 0000000000000..ff4183c5eb05a --- /dev/null +++ b/libc/src/math/spirv/atan2f.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU atan2f 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/atan2f.h" +#include "src/__support/math/atan2f.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, atan2f, (float y, float x)) { + return __builtin_atan2f(y, x); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/atanf.cpp b/libc/src/math/spirv/atanf.cpp new file mode 100644 index 0000000000000..e16dc05e4ca2a --- /dev/null +++ b/libc/src/math/spirv/atanf.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU atanf 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/atanf.h" +#include "src/__support/math/atanf.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, atanf, (float x)) { return __builtin_atanf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/ceil.cpp b/libc/src/math/spirv/ceil.cpp new file mode 100644 index 0000000000000..8834c7b560a1b --- /dev/null +++ b/libc/src/math/spirv/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/spirv/ceilf.cpp b/libc/src/math/spirv/ceilf.cpp new file mode 100644 index 0000000000000..5d26a30c849cd --- /dev/null +++ b/libc/src/math/spirv/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/spirv/copysign.cpp b/libc/src/math/spirv/copysign.cpp new file mode 100644 index 0000000000000..06ef36fb3595f --- /dev/null +++ b/libc/src/math/spirv/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/spirv/copysignf.cpp b/libc/src/math/spirv/copysignf.cpp new file mode 100644 index 0000000000000..aea94f3577d8f --- /dev/null +++ b/libc/src/math/spirv/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/spirv/cos.cpp b/libc/src/math/spirv/cos.cpp new file mode 100644 index 0000000000000..46e68cdc2d953 --- /dev/null +++ b/libc/src/math/spirv/cos.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU cos 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/cos.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, cos, (double x)) { return __builtin_cos(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/cosf.cpp b/libc/src/math/spirv/cosf.cpp new file mode 100644 index 0000000000000..56d8ddd138a6c --- /dev/null +++ b/libc/src/math/spirv/cosf.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU cosf 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/cosf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, cosf, (float x)) { return __builtin_cosf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/coshf.cpp b/libc/src/math/spirv/coshf.cpp new file mode 100644 index 0000000000000..5e881c2f59d54 --- /dev/null +++ b/libc/src/math/spirv/coshf.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU coshf 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/coshf.h" +#include "src/__support/math/coshf.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, coshf, (float x)) { return __builtin_coshf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/exp.cpp b/libc/src/math/spirv/exp.cpp new file mode 100644 index 0000000000000..cc3a6906fe980 --- /dev/null +++ b/libc/src/math/spirv/exp.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU exp 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/exp.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, exp, (double x)) { return __builtin_exp(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/exp10.cpp b/libc/src/math/spirv/exp10.cpp new file mode 100644 index 0000000000000..57455f15a36cc --- /dev/null +++ b/libc/src/math/spirv/exp10.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU exp10 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/exp10.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, exp10, (double x)) { return __builtin_exp10(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/exp10f.cpp b/libc/src/math/spirv/exp10f.cpp new file mode 100644 index 0000000000000..9aabd49ff77ab --- /dev/null +++ b/libc/src/math/spirv/exp10f.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU exp10f 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/exp10f.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, exp10f, (float x)) { return __builtin_exp10f(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/exp2.cpp b/libc/src/math/spirv/exp2.cpp new file mode 100644 index 0000000000000..c2b6f677e7c19 --- /dev/null +++ b/libc/src/math/spirv/exp2.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU exp2 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/exp2.h" +#include "src/__support/common.h" // for LLVM_LIBC_FUNCTION +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, exp2, (double x)) { return __builtin_exp2(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/exp2f.cpp b/libc/src/math/spirv/exp2f.cpp new file mode 100644 index 0000000000000..eb90ca19999ab --- /dev/null +++ b/libc/src/math/spirv/exp2f.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU exp2f 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/exp2f.h" +#include "src/__support/common.h" // for LLVM_LIBC_FUNCTION +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, exp2f, (float x)) { return __builtin_exp2f(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/expf.cpp b/libc/src/math/spirv/expf.cpp new file mode 100644 index 0000000000000..ed608407640a4 --- /dev/null +++ b/libc/src/math/spirv/expf.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU expf 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/expf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, expf, (float x)) { return __builtin_expf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/fabs.cpp b/libc/src/math/spirv/fabs.cpp new file mode 100644 index 0000000000000..bb37596b9d563 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/fabsf.cpp b/libc/src/math/spirv/fabsf.cpp new file mode 100644 index 0000000000000..2698618f3f1e1 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/floor.cpp b/libc/src/math/spirv/floor.cpp new file mode 100644 index 0000000000000..564efa9a7da38 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/floorf.cpp b/libc/src/math/spirv/floorf.cpp new file mode 100644 index 0000000000000..6717c8f60c992 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/fma.cpp b/libc/src/math/spirv/fma.cpp new file mode 100644 index 0000000000000..c4a117e42a3aa --- /dev/null +++ b/libc/src/math/spirv/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/spirv/fmaf.cpp b/libc/src/math/spirv/fmaf.cpp new file mode 100644 index 0000000000000..c088bd5b30fea --- /dev/null +++ b/libc/src/math/spirv/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/spirv/fmax.cpp b/libc/src/math/spirv/fmax.cpp new file mode 100644 index 0000000000000..a2496fecb01c4 --- /dev/null +++ b/libc/src/math/spirv/fmax.cpp @@ -0,0 +1,20 @@ +//===-- 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/common.h" +#include "src/__support/macros/config.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 new file mode 100644 index 0000000000000..59ee8259c025a --- /dev/null +++ b/libc/src/math/spirv/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/spirv/fmin.cpp b/libc/src/math/spirv/fmin.cpp new file mode 100644 index 0000000000000..694eb664b599b --- /dev/null +++ b/libc/src/math/spirv/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/spirv/fminf.cpp b/libc/src/math/spirv/fminf.cpp new file mode 100644 index 0000000000000..2060b71b0841f --- /dev/null +++ b/libc/src/math/spirv/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/spirv/frexp.cpp b/libc/src/math/spirv/frexp.cpp new file mode 100644 index 0000000000000..4ae2b00198ec3 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/frexpf.cpp b/libc/src/math/spirv/frexpf.cpp new file mode 100644 index 0000000000000..fd53f65701f59 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/ldexp.cpp b/libc/src/math/spirv/ldexp.cpp new file mode 100644 index 0000000000000..5b786a9b21e70 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/ldexpf.cpp b/libc/src/math/spirv/ldexpf.cpp new file mode 100644 index 0000000000000..d3aa77fe592cb --- /dev/null +++ b/libc/src/math/spirv/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/spirv/log.cpp b/libc/src/math/spirv/log.cpp new file mode 100644 index 0000000000000..cb69349c3a796 --- /dev/null +++ b/libc/src/math/spirv/log.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU log 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/log.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, log, (double x)) { return __builtin_log(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/log10.cpp b/libc/src/math/spirv/log10.cpp new file mode 100644 index 0000000000000..5a1c52de93ac1 --- /dev/null +++ b/libc/src/math/spirv/log10.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU log10 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/log10.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, log10, (double x)) { return __builtin_log10(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/log10f.cpp b/libc/src/math/spirv/log10f.cpp new file mode 100644 index 0000000000000..15a7a8c605c8e --- /dev/null +++ b/libc/src/math/spirv/log10f.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU log10f 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/log10f.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return __builtin_log10f(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/log2.cpp b/libc/src/math/spirv/log2.cpp new file mode 100644 index 0000000000000..0888f590bfb7f --- /dev/null +++ b/libc/src/math/spirv/log2.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU log2 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/log2.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, log2, (double x)) { return __builtin_log2(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/log2f.cpp b/libc/src/math/spirv/log2f.cpp new file mode 100644 index 0000000000000..08c8ee28ceea5 --- /dev/null +++ b/libc/src/math/spirv/log2f.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU log2f 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/log2f.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return __builtin_log2f(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/logf.cpp b/libc/src/math/spirv/logf.cpp new file mode 100644 index 0000000000000..6068e2fc839d8 --- /dev/null +++ b/libc/src/math/spirv/logf.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU logf 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/logf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, logf, (float x)) { return __builtin_logf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/pow.cpp b/libc/src/math/spirv/pow.cpp new file mode 100644 index 0000000000000..d9655290d83c9 --- /dev/null +++ b/libc/src/math/spirv/pow.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU pow 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/pow.h" +#include "src/__support/math/pow.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, pow, (double x, double y)) { + return __builtin_pow(x, y); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/powf.cpp b/libc/src/math/spirv/powf.cpp new file mode 100644 index 0000000000000..5e314cba7d486 --- /dev/null +++ b/libc/src/math/spirv/powf.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU powf 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/powf.h" +#include "src/__support/math/powf.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) { + return __builtin_powf(x, y); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/rint.cpp b/libc/src/math/spirv/rint.cpp new file mode 100644 index 0000000000000..ac6837a4abc37 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/rintf.cpp b/libc/src/math/spirv/rintf.cpp new file mode 100644 index 0000000000000..94093471a8d92 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/round.cpp b/libc/src/math/spirv/round.cpp new file mode 100644 index 0000000000000..0d2765f2e959f --- /dev/null +++ b/libc/src/math/spirv/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/spirv/roundf.cpp b/libc/src/math/spirv/roundf.cpp new file mode 100644 index 0000000000000..86e8ba3ac83d6 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/scalbln.cpp b/libc/src/math/spirv/scalbln.cpp new file mode 100644 index 0000000000000..91f06286d4c7b --- /dev/null +++ b/libc/src/math/spirv/scalbln.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of scalbln 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/scalbln.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, scalbln, (double x, long n)) { + return __builtin_ldexp(x, static_cast(n)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/scalblnf.cpp b/libc/src/math/spirv/scalblnf.cpp new file mode 100644 index 0000000000000..ad358ff3f60dd --- /dev/null +++ b/libc/src/math/spirv/scalblnf.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of scalblnf 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/scalblnf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, scalblnf, (float x, long n)) { + return __builtin_ldexpf(x, static_cast(n)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/scalbn.cpp b/libc/src/math/spirv/scalbn.cpp new file mode 100644 index 0000000000000..fd3d0435369d6 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/scalbnf.cpp b/libc/src/math/spirv/scalbnf.cpp new file mode 100644 index 0000000000000..b5cb06f7bda0a --- /dev/null +++ b/libc/src/math/spirv/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/spirv/sin.cpp b/libc/src/math/spirv/sin.cpp new file mode 100644 index 0000000000000..133f206300145 --- /dev/null +++ b/libc/src/math/spirv/sin.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU sin 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/sin.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, sin, (double x)) { return __builtin_sin(x); } +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/sinf.cpp b/libc/src/math/spirv/sinf.cpp new file mode 100644 index 0000000000000..79113e18e5cdb --- /dev/null +++ b/libc/src/math/spirv/sinf.cpp @@ -0,0 +1,16 @@ +//===-- Implementation of the GPU sinf 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/sinf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, sinf, (float x)) { return __builtin_sinf(x); } +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/sinhf.cpp b/libc/src/math/spirv/sinhf.cpp new file mode 100644 index 0000000000000..d1b17e09db216 --- /dev/null +++ b/libc/src/math/spirv/sinhf.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU sinhf 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/sinhf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, sinhf, (float x)) { return __builtin_sinhf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/sqrt.cpp b/libc/src/math/spirv/sqrt.cpp new file mode 100644 index 0000000000000..ed83b6e5c6cae --- /dev/null +++ b/libc/src/math/spirv/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/spirv/sqrtf.cpp b/libc/src/math/spirv/sqrtf.cpp new file mode 100644 index 0000000000000..851922c316452 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/tan.cpp b/libc/src/math/spirv/tan.cpp new file mode 100644 index 0000000000000..aee67b23a94d6 --- /dev/null +++ b/libc/src/math/spirv/tan.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU tan 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/tan.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, tan, (double x)) { return __builtin_tan(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/tanf.cpp b/libc/src/math/spirv/tanf.cpp new file mode 100644 index 0000000000000..4c7250f43dae2 --- /dev/null +++ b/libc/src/math/spirv/tanf.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU tanf 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/tanf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, tanf, (float x)) { return __builtin_tanf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/tanh.cpp b/libc/src/math/spirv/tanh.cpp new file mode 100644 index 0000000000000..08a91c73af235 --- /dev/null +++ b/libc/src/math/spirv/tanh.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU tanh 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/tanh.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(double, tanh, (double x)) { return __builtin_tanh(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/tanhf.cpp b/libc/src/math/spirv/tanhf.cpp new file mode 100644 index 0000000000000..8ca99c7131736 --- /dev/null +++ b/libc/src/math/spirv/tanhf.cpp @@ -0,0 +1,17 @@ +//===-- Implementation of the GPU tanhf 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/tanhf.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, tanhf, (float x)) { return __builtin_tanhf(x); } + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/spirv/trunc.cpp b/libc/src/math/spirv/trunc.cpp new file mode 100644 index 0000000000000..f60caa2a71d78 --- /dev/null +++ b/libc/src/math/spirv/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/spirv/truncf.cpp b/libc/src/math/spirv/truncf.cpp new file mode 100644 index 0000000000000..a6c9b8f188f02 --- /dev/null +++ b/libc/src/math/spirv/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/libdevice/cmake/modules/SYCLLibdevice.cmake b/libdevice/cmake/modules/SYCLLibdevice.cmake index 643dd0ef06d89..8b4af69f61d16 100644 --- a/libdevice/cmake/modules/SYCLLibdevice.cmake +++ b/libdevice/cmake/modules/SYCLLibdevice.cmake @@ -316,9 +316,8 @@ set(sycl-compiler_deps ${file-table-tform_target} ${llvm-foreach_target} ${llvm-spirv_target} ${sycl-post-link_target}) set(crt_obj_deps wrapper.h device.h spirv_vars.h fallback-cstring.hpp ${sycl-compiler_deps}) -set(cmath_obj_deps - device_math.h device.h fallback-cmath.hpp fallback-cmath-fp64.hpp - device_complex.h fallback-complex.hpp fallback-complex-fp64.hpp complex_wrapper.hpp ${sycl-compiler_deps}) +set(cmath_obj_deps device_math.h device.h device_complex.h fallback-complex.hpp + fallback-complex-fp64.hpp complex_wrapper.hpp ${sycl-compiler_deps}) set(imf_obj_deps device_imf.hpp imf_half.hpp imf_bf16.hpp imf_rounding_op.hpp imf_impl_utils.hpp device.h ${sycl-compiler_deps}) set(itt_obj_deps device_itt.h spirv_vars.h device.h ${sycl-compiler_deps}) set(bfloat16_obj_deps sycl-headers ${sycl-compiler_deps}) diff --git a/libdevice/cmath_wrapper.cpp b/libdevice/cmath_wrapper.cpp index cfb9892f69b01..5e05745dc370c 100644 --- a/libdevice/cmath_wrapper.cpp +++ b/libdevice/cmath_wrapper.cpp @@ -8,334 +8,87 @@ #include "complex_wrapper.hpp" #include "device.h" -#include "fallback-cmath-fp64.hpp" -#include "fallback-cmath.hpp" #if defined(__SPIR__) || defined(__SPIRV__) DEVICE_EXTERN_C_INLINE -float fabsf(float x) { return __devicelib_fabsf(x); } +float acoshf(float x) { return __spirv_ocl_acosh(x); } DEVICE_EXTERN_C_INLINE -float ceilf(float x) { return __devicelib_ceilf(x); } +float asinhf(float x) { return __spirv_ocl_asinh(x); } DEVICE_EXTERN_C_INLINE -float copysignf(float x, float y) { return __devicelib_copysignf(x, y); } +float atanhf(float x) { return __spirv_ocl_atanh(x); } DEVICE_EXTERN_C_INLINE -float cospif(float x) { return __devicelib_cospif(x); } +float cbrtf(float x) { return __spirv_ocl_cbrt(x); } DEVICE_EXTERN_C_INLINE -float fmaxf(float x, float y) { return __devicelib_fmaxf(x, y); } +float erfcf(float x) { return __spirv_ocl_erfc(x); } DEVICE_EXTERN_C_INLINE -float fminf(float x, float y) { return __devicelib_fminf(x, y); } +float erff(float x) { return __spirv_ocl_erf(x); } DEVICE_EXTERN_C_INLINE -float truncf(float x) { return __devicelib_truncf(x); } +float expm1f(float x) { return __spirv_ocl_expm1(x); } DEVICE_EXTERN_C_INLINE -float sinpif(float x) { return __devicelib_sinpif(x); } +float fmodf(float x, float y) { return __spirv_ocl_fmod(x, y); } DEVICE_EXTERN_C_INLINE -float rsqrtf(float x) { return __devicelib_rsqrtf(x); } +float hypotf(float x, float y) { return __spirv_ocl_hypot(x, y); } DEVICE_EXTERN_C_INLINE -float exp10f(float x) { return __devicelib_exp10f(x); } +float log1pf(float x) { return __spirv_ocl_log1p(x); } DEVICE_EXTERN_C_INLINE -float roundf(float x) { return __devicelib_roundf(x); } +float tgammaf(float x) { return __spirv_ocl_tgamma(x); } DEVICE_EXTERN_C_INLINE -float floorf(float x) { return __devicelib_floorf(x); } +float lgammaf(float x) { return __spirv_ocl_lgamma(x); } DEVICE_EXTERN_C_INLINE -float scalbnf(float x, int n) { return __devicelib_scalbnf(x, n); } +double cospi(double x) { return __spirv_ocl_cospi(x); } DEVICE_EXTERN_C_INLINE -float scalblnf(float x, long int n) { return __devicelib_scalblnf(x, n); } +double expm1(double x) { return __spirv_ocl_expm1(x); } DEVICE_EXTERN_C_INLINE -float logf(float x) { return __devicelib_logf(x); } +double sinpi(double x) { return __spirv_ocl_sinpi(x); } DEVICE_EXTERN_C_INLINE -float expf(float x) { return __devicelib_expf(x); } +double rsqrt(double x) { return __spirv_ocl_rsqrt(x); } DEVICE_EXTERN_C_INLINE -float frexpf(float x, int *exp) { return __devicelib_frexpf(x, exp); } +double erf(double x) { return __spirv_ocl_erf(x); } DEVICE_EXTERN_C_INLINE -float ldexpf(float x, int exp) { return __devicelib_ldexpf(x, exp); } +double erfc(double x) { return __spirv_ocl_erfc(x); } DEVICE_EXTERN_C_INLINE -float log10f(float x) { return __devicelib_log10f(x); } +double log1p(double x) { return __spirv_ocl_log1p(x); } DEVICE_EXTERN_C_INLINE -float modff(float x, float *intpart) { return __devicelib_modff(x, intpart); } +double tgamma(double x) { return __spirv_ocl_tgamma(x); } DEVICE_EXTERN_C_INLINE -float exp2f(float x) { return __devicelib_exp2f(x); } +double lgamma(double x) { return __spirv_ocl_lgamma(x); } DEVICE_EXTERN_C_INLINE -float expm1f(float x) { return __devicelib_expm1f(x); } +double cosh(double x) { return __spirv_ocl_cosh(x); } DEVICE_EXTERN_C_INLINE -int ilogbf(float x) { return __devicelib_ilogbf(x); } +double sinh(double x) { return __spirv_ocl_sinh(x); } DEVICE_EXTERN_C_INLINE -float log1pf(float x) { return __devicelib_log1pf(x); } +double acosh(double x) { return __spirv_ocl_acosh(x); } DEVICE_EXTERN_C_INLINE -float log2f(float x) { return __devicelib_log2f(x); } +double asinh(double x) { return __spirv_ocl_asinh(x); } DEVICE_EXTERN_C_INLINE -float logbf(float x) { return __devicelib_logbf(x); } +double atanh(double x) { return __spirv_ocl_atanh(x); } DEVICE_EXTERN_C_INLINE -float sqrtf(float x) { return __devicelib_sqrtf(x); } - -DEVICE_EXTERN_C_INLINE -float cbrtf(float x) { return __devicelib_cbrtf(x); } - -DEVICE_EXTERN_C_INLINE -float hypotf(float x, float y) { return __devicelib_hypotf(x, y); } - -DEVICE_EXTERN_C_INLINE -float erff(float x) { return __devicelib_erff(x); } - -DEVICE_EXTERN_C_INLINE -float erfcf(float x) { return __devicelib_erfcf(x); } - -DEVICE_EXTERN_C_INLINE -float tgammaf(float x) { return __devicelib_tgammaf(x); } - -DEVICE_EXTERN_C_INLINE -float lgammaf(float x) { return __devicelib_lgammaf(x); } - -DEVICE_EXTERN_C_INLINE -float fmodf(float x, float y) { return __devicelib_fmodf(x, y); } - -DEVICE_EXTERN_C_INLINE -float remainderf(float x, float y) { return __devicelib_remainderf(x, y); } - -DEVICE_EXTERN_C_INLINE -float remquof(float x, float y, int *q) { return __devicelib_remquof(x, y, q); } - -DEVICE_EXTERN_C_INLINE -float nextafterf(float x, float y) { return __devicelib_nextafterf(x, y); } - -DEVICE_EXTERN_C_INLINE -float fdimf(float x, float y) { return __devicelib_fdimf(x, y); } - -DEVICE_EXTERN_C_INLINE -float fmaf(float x, float y, float z) { return __devicelib_fmaf(x, y, z); } - -DEVICE_EXTERN_C_INLINE -float sinf(float x) { return __devicelib_sinf(x); } - -DEVICE_EXTERN_C_INLINE -float cosf(float x) { return __devicelib_cosf(x); } - -DEVICE_EXTERN_C_INLINE -float tanf(float x) { return __devicelib_tanf(x); } - -DEVICE_EXTERN_C_INLINE -float powf(float x, float y) { return __devicelib_powf(x, y); } - -DEVICE_EXTERN_C_INLINE -float acosf(float x) { return __devicelib_acosf(x); } - -DEVICE_EXTERN_C_INLINE -float asinf(float x) { return __devicelib_asinf(x); } - -DEVICE_EXTERN_C_INLINE -float atanf(float x) { return __devicelib_atanf(x); } - -DEVICE_EXTERN_C_INLINE -float atan2f(float x, float y) { return __devicelib_atan2f(x, y); } - -DEVICE_EXTERN_C_INLINE -float coshf(float x) { return __devicelib_coshf(x); } - -DEVICE_EXTERN_C_INLINE -float sinhf(float x) { return __devicelib_sinhf(x); } - -DEVICE_EXTERN_C_INLINE -float tanhf(float x) { return __devicelib_tanhf(x); } - -DEVICE_EXTERN_C_INLINE -float acoshf(float x) { return __devicelib_acoshf(x); } - -DEVICE_EXTERN_C_INLINE -float asinhf(float x) { return __devicelib_asinhf(x); } - -DEVICE_EXTERN_C_INLINE -float atanhf(float x) { return __devicelib_atanhf(x); } - -DEVICE_EXTERN_C_INLINE -float rintf(float x) { return __spirv_ocl_rint(x); } - -DEVICE_EXTERN_C_INLINE -double fabs(double x) { return __devicelib_fabs(x); } - -DEVICE_EXTERN_C_INLINE -double ceil(double x) { return __devicelib_ceil(x); } - -DEVICE_EXTERN_C_INLINE -double copysign(double x, double y) { return __devicelib_copysign(x, y); } - -DEVICE_EXTERN_C_INLINE -double scalbln(double x, long y) { return __devicelib_scalbln(x, y); } - -DEVICE_EXTERN_C_INLINE -double cospi(double x) { return __devicelib_cospi(x); } - -DEVICE_EXTERN_C_INLINE -double fmax(double x, double y) { return __devicelib_fmax(x, y); } - -DEVICE_EXTERN_C_INLINE -double fmin(double x, double y) { return __devicelib_fmin(x, y); } - -DEVICE_EXTERN_C_INLINE -double trunc(double x) { return __devicelib_trunc(x); } - -DEVICE_EXTERN_C_INLINE -double sinpi(double x) { return __devicelib_sinpi(x); } - -DEVICE_EXTERN_C_INLINE -double rsqrt(double x) { return __devicelib_rsqrt(x); } - -DEVICE_EXTERN_C_INLINE -double exp10(double x) { return __devicelib_exp10(x); } - -DEVICE_EXTERN_C_INLINE -double log(double x) { return __devicelib_log(x); } - -DEVICE_EXTERN_C_INLINE -double round(double x) { return __devicelib_round(x); } - -DEVICE_EXTERN_C_INLINE -double floor(double x) { return __devicelib_floor(x); } - -DEVICE_EXTERN_C_INLINE -double exp(double x) { return __devicelib_exp(x); } - -DEVICE_EXTERN_C_INLINE -double frexp(double x, int *exp) { return __devicelib_frexp(x, exp); } - -DEVICE_EXTERN_C_INLINE -double ldexp(double x, int exp) { return __devicelib_ldexp(x, exp); } - -DEVICE_EXTERN_C_INLINE -double log10(double x) { return __devicelib_log10(x); } - -DEVICE_EXTERN_C_INLINE -double modf(double x, double *intpart) { return __devicelib_modf(x, intpart); } - -DEVICE_EXTERN_C_INLINE -double exp2(double x) { return __devicelib_exp2(x); } - -DEVICE_EXTERN_C_INLINE -double expm1(double x) { return __devicelib_expm1(x); } - -DEVICE_EXTERN_C_INLINE -int ilogb(double x) { return __devicelib_ilogb(x); } - -DEVICE_EXTERN_C_INLINE -double log1p(double x) { return __devicelib_log1p(x); } - -DEVICE_EXTERN_C_INLINE -double log2(double x) { return __devicelib_log2(x); } - -DEVICE_EXTERN_C_INLINE -double logb(double x) { return __devicelib_logb(x); } - -DEVICE_EXTERN_C_INLINE -double sqrt(double x) { return __devicelib_sqrt(x); } - -DEVICE_EXTERN_C_INLINE -double cbrt(double x) { return __devicelib_cbrt(x); } - -DEVICE_EXTERN_C_INLINE -double hypot(double x, double y) { return __devicelib_hypot(x, y); } - -DEVICE_EXTERN_C_INLINE -double erf(double x) { return __devicelib_erf(x); } - -DEVICE_EXTERN_C_INLINE -double erfc(double x) { return __devicelib_erfc(x); } - -DEVICE_EXTERN_C_INLINE -double tgamma(double x) { return __devicelib_tgamma(x); } - -DEVICE_EXTERN_C_INLINE -double lgamma(double x) { return __devicelib_lgamma(x); } - -DEVICE_EXTERN_C_INLINE -double fmod(double x, double y) { return __devicelib_fmod(x, y); } - -DEVICE_EXTERN_C_INLINE -double remainder(double x, double y) { return __devicelib_remainder(x, y); } - -DEVICE_EXTERN_C_INLINE -double remquo(double x, double y, int *q) { - return __devicelib_remquo(x, y, q); -} - -DEVICE_EXTERN_C_INLINE -double nextafter(double x, double y) { return __devicelib_nextafter(x, y); } - -DEVICE_EXTERN_C_INLINE -double fdim(double x, double y) { return __devicelib_fdim(x, y); } - -DEVICE_EXTERN_C_INLINE -double fma(double x, double y, double z) { return __devicelib_fma(x, y, z); } - -DEVICE_EXTERN_C_INLINE -double sin(double x) { return __devicelib_sin(x); } - -DEVICE_EXTERN_C_INLINE -double cos(double x) { return __devicelib_cos(x); } - -DEVICE_EXTERN_C_INLINE -double tan(double x) { return __devicelib_tan(x); } - -DEVICE_EXTERN_C_INLINE -double pow(double x, double y) { return __devicelib_pow(x, y); } - -DEVICE_EXTERN_C_INLINE -double acos(double x) { return __devicelib_acos(x); } - -DEVICE_EXTERN_C_INLINE -double asin(double x) { return __devicelib_asin(x); } - -DEVICE_EXTERN_C_INLINE -double atan(double x) { return __devicelib_atan(x); } - -DEVICE_EXTERN_C_INLINE -double atan2(double x, double y) { return __devicelib_atan2(x, y); } - -DEVICE_EXTERN_C_INLINE -double cosh(double x) { return __devicelib_cosh(x); } - -DEVICE_EXTERN_C_INLINE -double sinh(double x) { return __devicelib_sinh(x); } - -DEVICE_EXTERN_C_INLINE -double tanh(double x) { return __devicelib_tanh(x); } - -DEVICE_EXTERN_C_INLINE -double acosh(double x) { return __devicelib_acosh(x); } - -DEVICE_EXTERN_C_INLINE -double asinh(double x) { return __devicelib_asinh(x); } - -DEVICE_EXTERN_C_INLINE -double atanh(double x) { return __devicelib_atanh(x); } - -DEVICE_EXTERN_C_INLINE -double scalbn(double x, int exp) { return __devicelib_scalbn(x, exp); } - -DEVICE_EXTERN_C_INLINE -double rint(double x) { return __spirv_ocl_rint(x); } +double hypot(double x, double y) { return __spirv_ocl_hypot(x, y); } #endif // __SPIR__ || __SPIRV__ diff --git a/libdevice/fallback-cmath-fp64.hpp b/libdevice/fallback-cmath-fp64.hpp deleted file mode 100644 index 320604bd63007..0000000000000 --- a/libdevice/fallback-cmath-fp64.hpp +++ /dev/null @@ -1,183 +0,0 @@ -//==--- fallback-cmath-fp64.cpp - fallback implementation of double precision -// math functions -----==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#pragma once -#include "device.h" -#ifdef __LIBDEVICE_TARGET_SUPPORT - -static inline double __devicelib_fabs(double x) { return x < 0 ? -x : x; } - -static inline double __devicelib_ceil(double x) { return __spirv_ocl_ceil(x); } - -static inline double __devicelib_copysign(double x, double y) { - return __spirv_ocl_copysign(x, y); -} - -static inline double __devicelib_cospi(double x) { - return __spirv_ocl_cospi(x); -} - -static inline double __devicelib_scalbln(double x, long int y) { - return __spirv_ocl_ldexp(x, (int)y); -} - -static inline double __devicelib_fmax(double x, double y) { - return __spirv_ocl_fmax(x, y); -} - -static inline double __devicelib_fmin(double x, double y) { - return __spirv_ocl_fmin(x, y); -} - -static inline double __devicelib_trunc(double x) { - return __spirv_ocl_trunc(x); -} - -static inline double __devicelib_sinpi(double x) { - return __spirv_ocl_sinpi(x); -} - -static inline double __devicelib_rsqrt(double x) { - return __spirv_ocl_rsqrt(x); -} - -static inline double __devicelib_exp10(double x) { - return __spirv_ocl_exp10(x); -} - -static inline double __devicelib_log(double x) { return __spirv_ocl_log(x); } - -static inline double __devicelib_exp(double x) { return __spirv_ocl_exp(x); } - -static inline double __devicelib_frexp(double x, int *exp) { - return __spirv_ocl_frexp(x, exp); -} - -static inline double __devicelib_ldexp(double x, int exp) { - return __spirv_ocl_ldexp(x, exp); -} - -static inline double __devicelib_log10(double x) { - return __spirv_ocl_log10(x); -} - -static inline double __devicelib_modf(double x, double *intpart) { - return __spirv_ocl_modf(x, intpart); -} - -static inline double __devicelib_round(double x) { - return __spirv_ocl_round(x); -} - -static inline double __devicelib_floor(double x) { - return __spirv_ocl_floor(x); -} - -static inline double __devicelib_exp2(double x) { return __spirv_ocl_exp2(x); } - -static inline double __devicelib_expm1(double x) { - return __spirv_ocl_expm1(x); -} - -static inline int __devicelib_ilogb(double x) { return __spirv_ocl_ilogb(x); } - -static inline double __devicelib_log1p(double x) { - return __spirv_ocl_log1p(x); -} - -static inline double __devicelib_log2(double x) { return __spirv_ocl_log2(x); } - -static inline double __devicelib_logb(double x) { return __spirv_ocl_logb(x); } - -static inline double __devicelib_sqrt(double x) { return __spirv_ocl_sqrt(x); } - -static inline double __devicelib_cbrt(double x) { return __spirv_ocl_cbrt(x); } - -static inline double __devicelib_hypot(double x, double y) { - return __spirv_ocl_hypot(x, y); -} - -static inline double __devicelib_erf(double x) { return __spirv_ocl_erf(x); } - -static inline double __devicelib_erfc(double x) { return __spirv_ocl_erfc(x); } - -static inline double __devicelib_tgamma(double x) { - return __spirv_ocl_tgamma(x); -} - -static inline double __devicelib_lgamma(double x) { - return __spirv_ocl_lgamma(x); -} - -static inline double __devicelib_fmod(double x, double y) { - return __spirv_ocl_fmod(x, y); -} - -static inline double __devicelib_remainder(double x, double y) { - return __spirv_ocl_remainder(x, y); -} - -static inline double __devicelib_remquo(double x, double y, int *q) { - return __spirv_ocl_remquo(x, y, q); -} - -static inline double __devicelib_nextafter(double x, double y) { - return __spirv_ocl_nextafter(x, y); -} - -static inline double __devicelib_fdim(double x, double y) { - return __spirv_ocl_fdim(x, y); -} - -static inline double __devicelib_fma(double x, double y, double z) { - return __spirv_ocl_fma(x, y, z); -} - -static inline double __devicelib_sin(double x) { return __spirv_ocl_sin(x); } - -static inline double __devicelib_cos(double x) { return __spirv_ocl_cos(x); } - -static inline double __devicelib_tan(double x) { return __spirv_ocl_tan(x); } - -static inline double __devicelib_pow(double x, double y) { - return __spirv_ocl_pow(x, y); -} - -static inline double __devicelib_acos(double x) { return __spirv_ocl_acos(x); } - -static inline double __devicelib_asin(double x) { return __spirv_ocl_asin(x); } - -static inline double __devicelib_atan(double x) { return __spirv_ocl_atan(x); } - -static inline double __devicelib_atan2(double x, double y) { - return __spirv_ocl_atan2(x, y); -} - -static inline double __devicelib_cosh(double x) { return __spirv_ocl_cosh(x); } - -static inline double __devicelib_sinh(double x) { return __spirv_ocl_sinh(x); } - -static inline double __devicelib_tanh(double x) { return __spirv_ocl_tanh(x); } - -static inline double __devicelib_acosh(double x) { - return __spirv_ocl_acosh(x); -} - -static inline double __devicelib_asinh(double x) { - return __spirv_ocl_asinh(x); -} - -static inline double __devicelib_atanh(double x) { - return __spirv_ocl_atanh(x); -} - -static inline double __devicelib_scalbn(double x, int exp) { - return __spirv_ocl_ldexp(x, exp); -} -#endif // __LIBDEVICE_TARGET_SUPPORT diff --git a/libdevice/fallback-cmath.hpp b/libdevice/fallback-cmath.hpp deleted file mode 100644 index e62489a8467f6..0000000000000 --- a/libdevice/fallback-cmath.hpp +++ /dev/null @@ -1,162 +0,0 @@ -//==--- fallback-cmath.cpp - fallback implementation of math functions -----==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#pragma once -#if defined(__SPIR__) || defined(__SPIRV__) - -static inline float __devicelib_fabsf(float x) { return x < 0 ? -x : x; } - -static inline float __devicelib_ceilf(float x) { return __spirv_ocl_ceil(x); } - -static inline float __devicelib_copysignf(float x, float y) { - return __spirv_ocl_copysign(x, y); -} - -static inline float __devicelib_cospif(float x) { return __spirv_ocl_cospi(x); } - -static inline float __devicelib_scalblnf(float x, long int y) { - return __spirv_ocl_ldexp(x, (int)y); -} - -static inline float __devicelib_fmaxf(float x, float y) { - return __spirv_ocl_fmax(x, y); -} - -static inline float __devicelib_fminf(float x, float y) { - return __spirv_ocl_fmin(x, y); -} - -static inline float __devicelib_truncf(float x) { return __spirv_ocl_trunc(x); } - -static inline float __devicelib_sinpif(float x) { return __spirv_ocl_sinpi(x); } - -static inline float __devicelib_rsqrtf(float x) { return __spirv_ocl_rsqrt(x); } - -static inline float __devicelib_exp10f(float x) { return __spirv_ocl_exp10(x); } - -static inline float __devicelib_scalbnf(float x, int n) { - return __spirv_ocl_ldexp(x, n); -} - -static inline float __devicelib_roundf(float x) { return __spirv_ocl_round(x); } - -static inline float __devicelib_floorf(float x) { return __spirv_ocl_floor(x); } - -static inline float __devicelib_logf(float x) { return __spirv_ocl_log(x); } - -static inline float __devicelib_expf(float x) { return __spirv_ocl_exp(x); } - -static inline float __devicelib_frexpf(float x, int *exp) { - return __spirv_ocl_frexp(x, exp); -} - -static inline float __devicelib_ldexpf(float x, int exp) { - return __spirv_ocl_ldexp(x, exp); -} - -static inline float __devicelib_log10f(float x) { return __spirv_ocl_log10(x); } - -static inline float __devicelib_modff(float x, float *intpart) { - return __spirv_ocl_modf(x, intpart); -} - -static inline float __devicelib_exp2f(float x) { return __spirv_ocl_exp2(x); } - -static inline float __devicelib_expm1f(float x) { return __spirv_ocl_expm1(x); } - -static inline int __devicelib_ilogbf(float x) { return __spirv_ocl_ilogb(x); } - -static inline float __devicelib_log1pf(float x) { return __spirv_ocl_log1p(x); } - -static inline float __devicelib_log2f(float x) { return __spirv_ocl_log2(x); } - -static inline float __devicelib_logbf(float x) { return __spirv_ocl_logb(x); } - -static inline float __devicelib_sqrtf(float x) { return __spirv_ocl_sqrt(x); } - -static inline float __devicelib_cbrtf(float x) { return __spirv_ocl_cbrt(x); } - -static inline float __devicelib_hypotf(float x, float y) { - return __spirv_ocl_hypot(x, y); -} - -static inline float __devicelib_erff(float x) { return __spirv_ocl_erf(x); } - -static inline float __devicelib_erfcf(float x) { return __spirv_ocl_erfc(x); } - -static inline float __devicelib_tgammaf(float x) { - return __spirv_ocl_tgamma(x); -} - -static inline float __devicelib_lgammaf(float x) { - return __spirv_ocl_lgamma(x); -} - -static inline float __devicelib_fmodf(float x, float y) { - return __spirv_ocl_fmod(x, y); -} - -static inline float __devicelib_remainderf(float x, float y) { - return __spirv_ocl_remainder(x, y); -} - -static inline float __devicelib_remquof(float x, float y, int *q) { - return __spirv_ocl_remquo(x, y, q); -} - -static inline float __devicelib_nextafterf(float x, float y) { - return __spirv_ocl_nextafter(x, y); -} - -static inline float __devicelib_fdimf(float x, float y) { - return __spirv_ocl_fdim(x, y); -} - -static inline float __devicelib_fmaf(float x, float y, float z) { - return __spirv_ocl_fma(x, y, z); -} - -#if defined(__SPIR__) || defined(__SPIRV__) -static inline float __devicelib_sinf(float x) { - return (x == 0.0f) ? x : __spirv_ocl_sin(x); -} -#else -static inline float __devicelib_sinf(float x) { return __spirv_ocl_sin(x); } -#endif - -static inline float __devicelib_cosf(float x) { return __spirv_ocl_cos(x); } - -static inline float __devicelib_tanf(float x) { return __spirv_ocl_tan(x); } - -static inline float __devicelib_powf(float x, float y) { - return __spirv_ocl_pow(x, y); -} - -static inline float __devicelib_acosf(float x) { return __spirv_ocl_acos(x); } - -static inline float __devicelib_asinf(float x) { return __spirv_ocl_asin(x); } - -static inline float __devicelib_atanf(float x) { return __spirv_ocl_atan(x); } - -static inline float __devicelib_atan2f(float x, float y) { - return __spirv_ocl_atan2(x, y); -} - -static inline float __devicelib_coshf(float x) { return __spirv_ocl_cosh(x); } - -static inline float __devicelib_sinhf(float x) { return __spirv_ocl_sinh(x); } - -static inline float __devicelib_tanhf(float x) { return __spirv_ocl_tanh(x); } - -static inline float __devicelib_acoshf(float x) { return __spirv_ocl_acosh(x); } - -static inline float __devicelib_asinhf(float x) { return __spirv_ocl_asinh(x); } - -static inline float __devicelib_atanhf(float x) { return __spirv_ocl_atanh(x); } - -#endif // __SPIR__ || __SPIRV__ diff --git a/sycl-jit/jit-compiler/CMakeLists.txt b/sycl-jit/jit-compiler/CMakeLists.txt index e0ac377ac4195..e6b021d7a5b1b 100644 --- a/sycl-jit/jit-compiler/CMakeLists.txt +++ b/sycl-jit/jit-compiler/CMakeLists.txt @@ -18,7 +18,8 @@ set(SYCL_JIT_RESOURCE_INSTALL_COMPONENTS sycl-headers OpenCL-Headers clang-resource-headers - libsycldevice) + libsycldevice + runtimes-spirv64-unknown-unknown) set(libclc_enabled FALSE) foreach(target IN LISTS LLVM_RUNTIME_TARGETS) @@ -53,6 +54,9 @@ foreach(component IN LISTS SYCL_JIT_RESOURCE_INSTALL_COMPONENTS) sycl_jit_add_install_command("${component}" "${CMAKE_BINARY_DIR}/runtimes/runtimes-${tgt}-bins/libclc") endif() endforeach() + elseif("${component}" STREQUAL "runtimes-spirv64-unknown-unknown") + list(APPEND SYCL_JIT_RESOURCE_DEPS runtimes-spirv64-unknown-unknown) + sycl_jit_add_install_command("libc" "${CMAKE_BINARY_DIR}/runtimes/runtimes-spirv64-unknown-unknown-bins/libc") else() list(APPEND SYCL_JIT_RESOURCE_DEPS ${component}) sycl_jit_add_install_command("${component}" "${CMAKE_BINARY_DIR}") diff --git a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp index 7c9b832acece5..393e5d7627969 100644 --- a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp +++ b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp @@ -788,7 +788,7 @@ static void getDeviceLibraries(const ArgList &Args, #if defined(_WIN32) "libsycl-msvc-math", #endif - "libsycl-imf"}; + "libsycl-imf", "libm"}; StringRef LibSuffix = ".bc"; auto AddLibraries = [&](const SYCLDeviceLibsList &LibsList) { @@ -841,10 +841,14 @@ Error jit_compiler::linkDeviceLibraries(llvm::Module &Module, std::string TripleName = (Format == BinaryFormat::PTX) ? "nvptx64-nvidia-cuda" : "amdgcn-amd-amdhsa"; - std::string LibPath = - (LibName.find("libspirv") != std::string::npos) - ? (TC.getLibclcDir() + TripleName + "/" + LibName).str() - : (TC.getPrefix() + "/lib/" + LibName).str(); + std::string LibPath; + if (LibName.find("libspirv") != std::string::npos) + LibPath = (TC.getLibclcDir() + TripleName + "/" + LibName).str(); + else if (LibName == "libm.bc") + LibPath = + (TC.getPrefix() + "/lib/spirv64-unknown-unknown/" + LibName).str(); + else + LibPath = (TC.getPrefix() + "/lib/" + LibName).str(); ModuleUPtr LibModule; if (auto Error = diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index dc14e9996bd15..6351e94d9d1e9 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -529,6 +529,11 @@ if("lld" IN_LIST LLVM_ENABLE_PROJECTS) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS lld) endif() +if ("libc" IN_LIST RUNTIMES_spirv64-unknown-unknown_LLVM_ENABLE_RUNTIMES) + add_dependencies(sycl-toolchain runtimes-spirv64-unknown-unknown) + list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS runtimes-spirv64-unknown-unknown) +endif() + set(libclc_enabled FALSE) foreach(target IN LISTS LLVM_RUNTIME_TARGETS) if("libclc" IN_LIST RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES) diff --git a/sycl/test/syclbin/simple_kernel.cpp b/sycl/test/syclbin/simple_kernel.cpp index 827acc093bcbc..0991e866154a7 100644 --- a/sycl/test/syclbin/simple_kernel.cpp +++ b/sycl/test/syclbin/simple_kernel.cpp @@ -1,7 +1,7 @@ -// RUN: %clangxx --offload-new-driver -fsyclbin=input -o %t.input.syclbin %s -// RUN: %clangxx --offload-new-driver -fsyclbin=object -o %t.object.syclbin %s -// RUN: %clangxx --offload-new-driver -fsyclbin=executable -o %t.executable.syclbin %s -// RUN: %clangxx --offload-new-driver -fsyclbin -o %t.default.syclbin %s +// RUN: %clangxx --offload-new-driver -fsyclbin=input -o %t.input.syclbin %s --no-offloadlib +// RUN: %clangxx --offload-new-driver -fsyclbin=object -o %t.object.syclbin %s --no-offloadlib +// RUN: %clangxx --offload-new-driver -fsyclbin=executable -o %t.executable.syclbin %s --no-offloadlib +// RUN: %clangxx --offload-new-driver -fsyclbin -o %t.default.syclbin %s --no-offloadlib // RUN: syclbin-dump %t.input.syclbin | FileCheck %s --check-prefix CHECK-INPUT // RUN: syclbin-dump %t.object.syclbin | FileCheck %s --check-prefix CHECK-OBJECT // RUN: syclbin-dump %t.executable.syclbin | FileCheck %s --check-prefix CHECK-EXECUTABLE