1// REQUIRES: clang-driver
2// REQUIRES: x86-registered-target
3// REQUIRES: amdgpu-registered-target
4
5// -fno-gpu-rdc without -o with -c
6// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
7// RUN:   --cuda-gpu-arch=gfx900 -c %s 2>&1 | \
8// RUN:   FileCheck -check-prefixes=CHECK,NORDC %s
9
10// -fno-gpu-rdc without -o
11// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
12// RUN:   --cuda-gpu-arch=gfx900 %s 2>&1 | \
13// RUN:   FileCheck -check-prefixes=CHECK,NORDC,NOUT %s
14
15// -fno-gpu-rdc with -o
16// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
17// RUN:   -o executable --cuda-gpu-arch=gfx900 %s 2>&1 | \
18// RUN:   FileCheck -check-prefixes=CHECK,NORDC,WOUT %s
19
20// -fgpu-rdc without -o with -c
21// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
22// RUN:   -fgpu-rdc --cuda-gpu-arch=gfx900 -c %s 2>&1 | \
23// RUN:   FileCheck -check-prefixes=CHECK,RDC,RDCC %s
24
25// -fgpu-rdc without -o
26// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
27// RUN:   -fgpu-rdc --cuda-gpu-arch=gfx900 %s 2>&1 | \
28// RUN:   FileCheck -check-prefixes=CHECK,RDC,RDCL,NOUT %s
29
30// -fgpu-rdc with -o
31// UN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
32// UN:   -o executable -fgpu-rdc --cuda-gpu-arch=gfx900 %s 2>&1 | \
33// UN:   FileCheck -check-prefixes=CHECK,RDC,RDCL,WOUT %s
34
35// -fgpu-rdc host object path
36// RDCL: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.cui"
37// RDCL: "{{.*clang.*}}" "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.bc"
38// RDCL: "{{.*clang.*}}" "-cc1" {{.*}} "-S" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.s"
39// RDCL: "{{.*clang.*}}" "-cc1as" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.o"
40
41// device object paths
42// CHECK: {{".*clang.*"}} "-cc1" {{.*}} "-E" {{.*}} [[CPU:"-target-cpu" "gfx900"]] {{.*}}  "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.cui"
43// NORDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} "-disable-llvm-passes" {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.bc"
44// RDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} "-disable-llvm-passes" {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.tmp.bc"
45
46// NORDC: {{".*clang.*"}} "-cc1" {{.*}} "-S"
47// NORDC-SAME: "-mllvm" "-amdgpu-internalize-symbols"
48// NORDC-SAME: [[CPU]]
49// NORDC-SAME: "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.s"
50
51// RDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.bc"
52// NORDC: {{".*clang.*"}} "-cc1as" {{.*}} "-filetype" "obj" {{.*}} [[CPU]] {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.o"
53// CHECK-NOT: "{{.*}}llvm-link"
54// CHECK-NOT: "{{.*}}opt"
55// CHECK-NOT: "{{.*}}llc"
56// NORDC: {{.*lld.*}}"-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.out"
57// RDCL: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols" {{.*}}"-save-temps"
58// RDCL-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900"
59// RDCC: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.cui"
60// RDCC: "{{.*clang.*}}" "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.bc"
61// RDCC: "{{.*clang.*}}" "-cc1" {{.*}} "-S" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.s"
62// RDCC: "{{.*clang.*}}" "-cc1as" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.o"
63// RDCC: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=hip-save-temps.o"
64// RDCL: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=hip-save-temps-hip-amdgcn-amd-amdhsa.hipfb"
65// RDCL: {{.*}}llvm-mc{{.*}}"-o" "hip-save-temps-hip-amdgcn-amd-amdhsa.o" "hip-save-temps-hip-amdgcn-amd-amdhsa.mcin" "--filetype=obj"
66
67// -fno-gpu-rdc host object path
68// NORDC: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.cui"
69// NORDC: "{{.*clang.*}}" "-cc1" {{.*}} "-emit-llvm-bc" {{.*}}  "-fcuda-include-gpubinary" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.bc"
70// NORDC: "{{.*clang.*}}" "-cc1" {{.*}} "-S" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.s"
71// NORDC: "{{.*clang.*}}" "-cc1as" {{.*}} "-o" "hip-save-temps{{.*}}.o"
72
73// output to default a.out or -o specified file name
74// NOUT: {{.*}}ld{{.*}}"-o" "a.out"
75// WOUT: {{.*}}ld{{.*}}"-o" "executable"
76