1// REQUIRES: clang-driver
2// REQUIRES: x86-registered-target
3// REQUIRES: amdgpu-registered-target
4
5// RUN: %clang -### -target x86_64-linux-gnu \
6// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
7// RUN:   --emit-static-lib -nogpulib \
8// RUN:   -fuse-ld=lld -fgpu-rdc -nogpuinc \
9// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
10// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
11// RUN: 2>&1 | FileCheck %s
12
13// emit objects for host side path
14// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
15// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
16// CHECK-SAME: "-emit-obj"
17// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
18// CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
19// CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
20
21// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
22// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
23// CHECK-SAME: "-emit-obj"
24// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
25// CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
26// CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
27
28// generate image for device side path on gfx803
29// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
30// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
31// CHECK-SAME: "-emit-llvm-bc"
32// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
33// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
34// CHECK-SAME: "-target-cpu" "gfx803"
35// CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
36// CHECK-SAME: {{.*}} [[A_SRC]]
37
38// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
39// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
40// CHECK-SAME: "-emit-llvm-bc"
41// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
42// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
43// CHECK-SAME: "-target-cpu" "gfx803"
44// CHECK-SAME: {{.*}} "-o" [[B_BC1:".*bc"]] "-x" "hip"
45// CHECK-SAME: {{.*}} [[B_SRC]]
46
47// CHECK-NOT: "*.llvm-link"
48// CHECK-NOT: ".*opt"
49// CHECK-NOT: ".*llc"
50// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
51// CHECK-SAME: "-plugin-opt=mcpu=gfx803"
52// CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
53
54// generate image for device side path on gfx900
55// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
56// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
57// CHECK-SAME: "-emit-llvm-bc"
58// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
59// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
60// CHECK-SAME: "-target-cpu" "gfx900"
61// CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
62// CHECK-SAME: {{.*}} [[A_SRC]]
63
64// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
65// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
66// CHECK-SAME: "-emit-llvm-bc"
67// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
68// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
69// CHECK-SAME: "-target-cpu" "gfx900"
70// CHECK-SAME: {{.*}} "-o" [[B_BC2:".*bc"]] "-x" "hip"
71// CHECK-SAME: {{.*}} [[B_SRC]]
72
73// CHECK-NOT: "*.llvm-link"
74// CHECK-NOT: ".*opt"
75// CHECK-NOT: ".*llc"
76// CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
77// CHECK-SAME: "-plugin-opt=mcpu=gfx900"
78// CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
79
80// combine images generated into hip fat binary object
81// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
82// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
83// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
84
85// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
86
87// CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
88