1 // Tests the driver when targeting the NVPTX architecture directly without a
2 // host toolchain to perform CUDA mappings.
4 // REQUIRES: nvptx-registered-target
7 // Test the generated phases when targeting NVPTX.
9 // RUN: %clang -target nvptx64-nvidia-cuda -ccc-print-phases %s 2>&1 \
10 // RUN: | FileCheck -check-prefix=PHASES %s
12 // PHASES: 0: input, "[[INPUT:.+]]", c
13 // PHASES-NEXT: 1: preprocessor, {0}, cpp-output
14 // PHASES-NEXT: 2: compiler, {1}, ir
15 // PHASES-NEXT: 3: backend, {2}, assembler
16 // PHASES-NEXT: 4: assembler, {3}, object
17 // PHASES-NEXT: 5: linker, {4}, image
20 // Test the generated bindings when targeting NVPTX.
22 // RUN: %clang -target nvptx64-nvidia-cuda -ccc-print-bindings %s 2>&1 \
23 // RUN: | FileCheck -check-prefix=BINDINGS %s
25 // BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[PTX:.+]].s"
26 // BINDINGS-NEXT: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX]].s"], output: "[[CUBIN:.+]].o"
27 // BINDINGS-NEXT: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: ["[[CUBIN]].o"], output: "a.out"
30 // Test the generated arguments to the CUDA binary utils when targeting NVPTX.
31 // Ensure that the '.o' files are converted to '.cubin' if produced internally.
33 // RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -### %s 2>&1 \
34 // RUN: | FileCheck -check-prefix=ARGS %s
36 // ARGS: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_61" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
37 // ARGS-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_61" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
38 // ARGS-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_61" {{.*}} "[[CUBIN]].cubin"
41 // Test the generated arguments to the CUDA binary utils when targeting NVPTX.
42 // Ensure that we emit '.o' files if compiled with '-c'
44 // RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -c -### %s 2>&1 \
45 // RUN: | FileCheck -check-prefix=OBJECT %s
46 // RUN: %clang -target nvptx64-nvidia-cuda -save-temps -march=sm_61 -c -### %s 2>&1 \
47 // RUN: | FileCheck -check-prefix=OBJECT %s
49 // OBJECT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_61" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
50 // OBJECT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_61" "--output-file" "[[OBJ:.+]].o" "[[PTX]].s" "-c"
53 // Test the generated arguments to the CUDA binary utils when targeting NVPTX.
54 // Ensure that we copy input '.o' files to '.cubin' files when linking.
57 // RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -### %t.o 2>&1 \
58 // RUN: | FileCheck -check-prefix=LINK %s
60 // LINK: nvlink{{.*}}"-o" "a.out" "-arch" "sm_61" {{.*}} "{{.*}}.cubin"
63 // Test the generated arguments default to a value with no architecture.
65 // RUN: %clang --target=nvptx64-nvidia-cuda -### --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
66 // RUN: | FileCheck -check-prefix=DEFAULT %s
68 // DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_52" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
69 // DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_52" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
70 // DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_52" {{.*}} "[[CUBIN]].cubin"
73 // Test to ensure that we enable handling global constructors in a freestanding
74 // Nvidia compilation.
76 // RUN: %clang -target nvptx64-nvidia-cuda -march=sm_70 %s -### 2>&1 \
77 // RUN: | FileCheck -check-prefix=LOWERING %s
79 // LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" "--nvptx-lower-global-ctor-dtor"