|
| 1 | +// Test that RISC-V host target features are correctly passed to the linker wrapper compilation |
| 2 | +// and applied to wrapper object generation. |
| 3 | +// UNSUPPORTED: system-windows |
| 4 | +// REQUIRES: riscv-registered-target |
| 5 | +// REQUIRES: nvptx-registered-target |
| 6 | + |
| 7 | +// Simple program that requires OpenMP offloading |
| 8 | +int main() { |
| 9 | +#pragma omp target |
| 10 | + { |
| 11 | + // Device code |
| 12 | + } |
| 13 | + return 0; |
| 14 | +} |
| 15 | + |
| 16 | +// Verify that the driver invokes clang-linker-wrapper with correct host features. |
| 17 | + |
| 18 | +// Test lp64d (double-float) ABI |
| 19 | +// RUN: %clang -target riscv64-linux-gnu -mabi=lp64d \ |
| 20 | +// RUN: -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_80 \ |
| 21 | +// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \ |
| 22 | +// RUN: %s -o %t.lp64d -### 2>&1 | FileCheck %s --check-prefix=LP64D-DRIVER |
| 23 | + |
| 24 | +// Check that the driver calls clang-linker-wrapper with correct host features for lp64d |
| 25 | +// LP64D-DRIVER: clang-linker-wrapper{{.*}}--host-triple=riscv64{{.*}}--host-features={{.*}}+f{{.*}}+d{{.*}} |
| 26 | + |
| 27 | +// Test lp64f (single-float) ABI |
| 28 | +// RUN: %clang -target riscv64-linux-gnu -mabi=lp64f \ |
| 29 | +// RUN: -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_80 \ |
| 30 | +// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \ |
| 31 | +// RUN: %s -o %t.lp64f -### 2>&1 | FileCheck %s --check-prefix=LP64F-DRIVER |
| 32 | + |
| 33 | +// LP64F-DRIVER: clang-linker-wrapper{{.*}}--host-triple=riscv64{{.*}}--host-features={{.*}}+f{{.*}}-d{{.*}} |
| 34 | + |
| 35 | +// Test lp64 (soft-float) ABI |
| 36 | +// RUN: %clang -target riscv64-linux-gnu -mabi=lp64 \ |
| 37 | +// RUN: -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_80 \ |
| 38 | +// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \ |
| 39 | +// RUN: %s -o %t.lp64 -### 2>&1 | FileCheck %s --check-prefix=LP64-DRIVER |
| 40 | + |
| 41 | +// LP64-DRIVER: clang-linker-wrapper{{.*}}--host-triple=riscv64{{.*}}--host-features={{.*}}-f{{.*}}-d{{.*}} |
| 42 | + |
| 43 | +// Verify that clang-linker-wrapper applies RISC-V host features correctly when creating wrapper objects. |
| 44 | +// We do this by checking the ELF ABI flags in the generated wrapper object files. |
| 45 | + |
| 46 | +// Create test objects for linker-wrapper testing |
| 47 | +// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.device.bc |
| 48 | +// RUN: llvm-offload-binary -o %t.openmp.out \ |
| 49 | +// RUN: --image=file=%t.device.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 |
| 50 | +// RUN: %clang -cc1 %s -triple riscv64-unknown-linux-gnu -emit-obj -o %t.riscv.host.o -fembed-offload-object=%t.openmp.out |
| 51 | + |
| 52 | +// Test lp64 (soft-float) ABI - should generate ELF flags 0x0 |
| 53 | +// RUN: rm -rf %t.tmpdir1 && mkdir %t.tmpdir1 |
| 54 | +// RUN: cd %t.tmpdir1 && clang-linker-wrapper --host-triple=riscv64-unknown-linux-gnu \ |
| 55 | +// RUN: --host-features=-f,-d --linker-path=/usr/bin/ld %t.riscv.host.o -o %t.lp64.out --dry-run --save-temps 2>&1 |
| 56 | +// RUN: cd %t.tmpdir1 && find . -name "*.wrapper*.o" -exec llvm-readobj --file-headers "{}" ";" \ |
| 57 | +// RUN: | FileCheck %s --check-prefix=SOFT-FLOAT-OBJ |
| 58 | + |
| 59 | +// SOFT-FLOAT-OBJ: Flags [ (0x0) |
| 60 | + |
| 61 | +// Test lp64f (single-float) ABI - should generate ELF flags 0x2 |
| 62 | +// RUN: rm -rf %t.tmpdir2 && mkdir %t.tmpdir2 |
| 63 | +// RUN: cd %t.tmpdir2 && clang-linker-wrapper --host-triple=riscv64-unknown-linux-gnu \ |
| 64 | +// RUN: --host-features=+f,-d --linker-path=/usr/bin/ld %t.riscv.host.o -o %t.lp64f.out --dry-run --save-temps 2>&1 |
| 65 | +// RUN: cd %t.tmpdir2 && find . -name "*.wrapper*.o" -exec llvm-readobj --file-headers "{}" ";" \ |
| 66 | +// RUN: | FileCheck %s --check-prefix=SINGLE-FLOAT-OBJ |
| 67 | + |
| 68 | +// SINGLE-FLOAT-OBJ: Flags [ (0x2) |
| 69 | + |
| 70 | +// Test lp64d (double-float) ABI - should generate ELF flags 0x4 |
| 71 | +// RUN: rm -rf %t.tmpdir3 && mkdir %t.tmpdir3 |
| 72 | +// RUN: cd %t.tmpdir3 && clang-linker-wrapper --host-triple=riscv64-unknown-linux-gnu \ |
| 73 | +// RUN: --host-features=+f,+d --linker-path=/usr/bin/ld %t.riscv.host.o -o %t.lp64d.out --dry-run --save-temps 2>&1 |
| 74 | +// RUN: cd %t.tmpdir3 && find . -name "*.wrapper*.o" -exec llvm-readobj --file-headers "{}" ";" \ |
| 75 | +// RUN: | FileCheck %s --check-prefix=DOUBLE-FLOAT-OBJ |
| 76 | + |
| 77 | +// DOUBLE-FLOAT-OBJ: Flags [ (0x4) |
0 commit comments