Index: clang/lib/Frontend/FrontendOptions.cpp =================================================================== --- clang/lib/Frontend/FrontendOptions.cpp +++ clang/lib/Frontend/FrontendOptions.cpp @@ -30,6 +30,7 @@ .Case("iim", InputKind(Language::CXX).getPreprocessed()) .Case("cl", Language::OpenCL) .Case("cu", Language::CUDA) + .Case("hip", Language::HIP) .Cases("ll", "bc", Language::LLVM_IR) .Default(Language::Unknown); } Index: clang/test/CodeGenCUDA/hip-pinned-shadow.hip =================================================================== --- /dev/null +++ clang/test/CodeGenCUDA/hip-pinned-shadow.hip @@ -0,0 +1,27 @@ +// REQUIRES: amdgpu-registered-target + +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \ +// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=HIPDEV %s +// RUN: %clang_cc1 -triple x86_64 -std=c++11 \ +// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=HIPHOST %s +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \ +// RUN: -O3 -emit-llvm -o - %s | FileCheck -check-prefixes=HIPDEVUNSED %s + +struct textureReference { + int a; +}; + +template +struct texture : public textureReference { +texture() { a = 1; } +}; + +__attribute__((hip_pinned_shadow)) texture tex; +// CUDADEV-NOT: @tex +// CUDAHOST-NOT: call i32 @__hipRegisterVar{{.*}}@tex +// HIPDEV: @tex = external addrspace(1) global %struct.texture +// HIPDEV-NOT: declare{{.*}}void @_ZN7textureIfLi2ELi1EEC1Ev +// HIPHOST: define{{.*}}@_ZN7textureIfLi2ELi1EEC1Ev +// HIPHOST: call i32 @__hipRegisterVar{{.*}}@tex{{.*}}i32 0, i32 4, i32 0, i32 0) +// HIPDEVUNSED: @tex = external addrspace(1) global %struct.texture +// HIPDEVUNSED-NOT: declare{{.*}}void @_ZN7textureIfLi2ELi1EEC1Ev Index: clang/test/CodeGenCUDA/hip-pinned-shadow.cu =================================================================== --- clang/test/CodeGenCUDA/hip-pinned-shadow.cu +++ /dev/null @@ -1,27 +0,0 @@ -// REQUIRES: amdgpu-registered-target - -// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \ -// RUN: -emit-llvm -o - -x hip %s | FileCheck -check-prefixes=HIPDEV %s -// RUN: %clang_cc1 -triple x86_64 -std=c++11 \ -// RUN: -emit-llvm -o - -x hip %s | FileCheck -check-prefixes=HIPHOST %s -// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \ -// RUN: -O3 -emit-llvm -o - -x hip %s | FileCheck -check-prefixes=HIPDEVUNSED %s - -struct textureReference { - int a; -}; - -template -struct texture : public textureReference { -texture() { a = 1; } -}; - -__attribute__((hip_pinned_shadow)) texture tex; -// CUDADEV-NOT: @tex -// CUDAHOST-NOT: call i32 @__hipRegisterVar{{.*}}@tex -// HIPDEV: @tex = external addrspace(1) global %struct.texture -// HIPDEV-NOT: declare{{.*}}void @_ZN7textureIfLi2ELi1EEC1Ev -// HIPHOST: define{{.*}}@_ZN7textureIfLi2ELi1EEC1Ev -// HIPHOST: call i32 @__hipRegisterVar{{.*}}@tex{{.*}}i32 0, i32 4, i32 0, i32 0) -// HIPDEVUNSED: @tex = external addrspace(1) global %struct.texture -// HIPDEVUNSED-NOT: declare{{.*}}void @_ZN7textureIfLi2ELi1EEC1Ev Index: clang/test/Driver/hip-autolink.hip =================================================================== --- clang/test/Driver/hip-autolink.hip +++ clang/test/Driver/hip-autolink.hip @@ -3,9 +3,9 @@ // REQUIRES: amdgpu-registered-target // // RUN: %clang --target=i386-pc-windows-msvc --cuda-gpu-arch=gfx906 -nogpulib \ -// RUN: --cuda-device-only -x hip %s -### 2>&1 | FileCheck --check-prefix=DEV %s +// RUN: --cuda-device-only %s -### 2>&1 | FileCheck --check-prefix=DEV %s // RUN: %clang --target=i386-pc-windows-msvc --cuda-gpu-arch=gfx906 -nogpulib \ -// RUN: --cuda-host-only -x hip %s -### 2>&1 | FileCheck --check-prefix=HOST %s +// RUN: --cuda-host-only %s -### 2>&1 | FileCheck --check-prefix=HOST %s // DEV: "-cc1" "-triple" "amdgcn-amd-amdhsa" // DEV-SAME: "-fno-autolink" Index: clang/test/Driver/hip-default-gpu-arch.hip =================================================================== --- clang/test/Driver/hip-default-gpu-arch.hip +++ clang/test/Driver/hip-default-gpu-arch.hip @@ -2,6 +2,6 @@ // REQUIRES: x86-registered-target // REQUIRES: amdgpu-registered-target -// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s +// RUN: %clang -### -c %s 2>&1 | FileCheck %s // CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803" Index: clang/test/Driver/hip-device-libs.hip =================================================================== --- clang/test/Driver/hip-device-libs.hip +++ clang/test/Driver/hip-device-libs.hip @@ -5,7 +5,7 @@ // Test flush-denormals-to-zero enabled uses oclc_daz_opt_on // RUN: %clang -### -target x86_64-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: --hip-device-lib-path=%S/Inputs/hip_dev_lib \ // RUN: -fcuda-flush-denormals-to-zero \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ @@ -14,7 +14,7 @@ // Test flush-denormals-to-zero disabled uses oclc_daz_opt_off // RUN: %clang -### -target x86_64-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: --hip-device-lib-path=%S/Inputs/hip_dev_lib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD @@ -23,7 +23,7 @@ // RUN: env HIP_DEVICE_LIB_PATH=%S/Inputs/hip_dev_lib \ // RUN: %clang -### -target x86_64-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck %s --check-prefixes=COM Index: clang/test/Driver/hip-host-cpu-features.hip =================================================================== --- clang/test/Driver/hip-host-cpu-features.hip +++ clang/test/Driver/hip-host-cpu-features.hip @@ -2,9 +2,9 @@ // REQUIRES: x86-registered-target // REQUIRES: amdgpu-registered-target -// RUN: %clang -### -c -target x86_64-linux-gnu -march=znver2 -x hip --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=HOSTCPU -// RUN: %clang -### -c -target x86_64-linux-gnu -msse3 -x hip --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=HOSTSSE3 -// RUN: %clang -### -c -target x86_64-linux-gnu --gpu-use-aux-triple-only -march=znver2 -x hip --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=NOHOSTCPU +// RUN: %clang -### -c -target x86_64-linux-gnu -march=znver2 --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=HOSTCPU +// RUN: %clang -### -c -target x86_64-linux-gnu -msse3 --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=HOSTSSE3 +// RUN: %clang -### -c -target x86_64-linux-gnu --gpu-use-aux-triple-only -march=znver2 --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=NOHOSTCPU // HOSTCPU: "-cc1" "-triple" "amdgcn-amd-amdhsa" // HOSTCPU-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" Index: clang/test/Driver/hip-no-device-libs.hip =================================================================== --- clang/test/Driver/hip-no-device-libs.hip +++ clang/test/Driver/hip-no-device-libs.hip @@ -3,7 +3,7 @@ // REQUIRES: amdgpu-registered-target // RUN: %clang -### -nogpulib -target x86_64-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck %s Index: clang/test/Driver/hip-output-file-name.hip =================================================================== --- clang/test/Driver/hip-output-file-name.hip +++ clang/test/Driver/hip-output-file-name.hip @@ -3,7 +3,7 @@ // REQUIRES: amdgpu-registered-target // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ // RUN: 2>&1 | FileCheck %s // CHECK: {{.*}}clang-offload-bundler{{.*}}"-outputs=hip-output-file-name.o" Index: clang/test/Driver/hip-printf.hip =================================================================== --- clang/test/Driver/hip-printf.hip +++ clang/test/Driver/hip-printf.hip @@ -2,7 +2,7 @@ // REQUIRES: x86-registered-target // REQUIRES: amdgpu-registered-target -// RUN: %clang -### -target x86_64-linux-gnu -x hip --cuda-gpu-arch=gfx900 \ +// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \ // RUN: %s 2>&1 | FileCheck %s // CHECK: [[CLANG:".*clang.*"]] "-cc1" Index: clang/test/Driver/hip-save-temps.hip =================================================================== --- clang/test/Driver/hip-save-temps.hip +++ clang/test/Driver/hip-save-temps.hip @@ -4,22 +4,22 @@ // -fno-gpu-rdc without -o // RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \ -// RUN: -x hip --cuda-gpu-arch=gfx900 %s 2>&1 | \ +// RUN: --cuda-gpu-arch=gfx900 %s 2>&1 | \ // RUN: FileCheck -check-prefixes=CHECK,NORDC,NOUT %s // -fno-gpu-rdc with -o // RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \ -// RUN: -o executable -x hip --cuda-gpu-arch=gfx900 %s 2>&1 | \ +// RUN: -o executable --cuda-gpu-arch=gfx900 %s 2>&1 | \ // RUN: FileCheck -check-prefixes=CHECK,NORDC,WOUT %s // -fgpu-rdc without -o // RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \ -// RUN: -fgpu-rdc -x hip --cuda-gpu-arch=gfx900 %s 2>&1 | \ +// RUN: -fgpu-rdc --cuda-gpu-arch=gfx900 %s 2>&1 | \ // RUN: FileCheck -check-prefixes=CHECK,RDC,RDC-NOUT,NOUT %s // -fgpu-rdc with -o // RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \ -// RUN: -o executable -fgpu-rdc -x hip --cuda-gpu-arch=gfx900 %s 2>&1 | \ +// RUN: -o executable -fgpu-rdc --cuda-gpu-arch=gfx900 %s 2>&1 | \ // RUN: FileCheck -check-prefixes=CHECK,RDC,RDC-WOUT,WOUT %s // CHECK: {{.*}}clang{{.*}}"-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.cui" Index: clang/test/Driver/hip-syntax-only.hip =================================================================== --- clang/test/Driver/hip-syntax-only.hip +++ clang/test/Driver/hip-syntax-only.hip @@ -2,7 +2,7 @@ // REQUIRES: x86-registered-target // REQUIRES: amdgpu-registered-target -// RUN: %clang -### -x hip -nogpulib -target x86_64 -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: %clang -### -nogpulib -target x86_64 -fsyntax-only %s 2>&1 | FileCheck %s // Check that there are commands for both host- and device-side compilations. // Index: clang/test/Driver/hip-toolchain-features.hip =================================================================== --- clang/test/Driver/hip-toolchain-features.hip +++ clang/test/Driver/hip-toolchain-features.hip @@ -3,10 +3,10 @@ // REQUIRES: amdgpu-registered-target // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ // RUN: -mxnack 2>&1 | FileCheck %s -check-prefix=XNACK // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ // RUN: -mno-xnack 2>&1 | FileCheck %s -check-prefix=NOXNACK // XNACK: {{.*}}clang{{.*}}"-target-feature" "+xnack" @@ -14,10 +14,10 @@ // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ // RUN: -msram-ecc 2>&1 | FileCheck %s -check-prefix=SRAM // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ // RUN: -mno-sram-ecc 2>&1 | FileCheck %s -check-prefix=NOSRAM // SRAM: {{.*}}clang{{.*}}"-target-feature" "+sram-ecc" @@ -25,11 +25,11 @@ // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ // RUN: -mxnack -msram-ecc \ // RUN: 2>&1 | FileCheck %s -check-prefix=ALL3 // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \ // RUN: -mno-xnack -mno-sram-ecc \ // RUN: 2>&1 | FileCheck %s -check-prefix=NOALL3 Index: clang/test/Driver/hip-toolchain-mllvm.hip =================================================================== --- clang/test/Driver/hip-toolchain-mllvm.hip +++ clang/test/Driver/hip-toolchain-mllvm.hip @@ -3,7 +3,7 @@ // REQUIRES: amdgpu-registered-target // RUN: %clang -### -target x86_64-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \ // RUN: -mllvm -amdgpu-function-calls=0 \ // RUN: %s 2>&1 | FileCheck %s Index: clang/test/Driver/hip-toolchain-opt.hip =================================================================== --- clang/test/Driver/hip-toolchain-opt.hip +++ clang/test/Driver/hip-toolchain-opt.hip @@ -4,56 +4,56 @@ // RUN: %clang -### \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,DEFAULT %s // RUN: %clang -### -O0 \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O0 %s // RUN: %clang -### -O1 \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O1 %s // RUN: %clang -### -O2 \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O2 %s // RUN: %clang -### -O3 \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O3 %s // RUN: %clang -### -Os \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Os %s // RUN: %clang -### -Oz \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Oz %s // RUN: %clang -### -Og \ // RUN: -target x86_64-unknown-linux-gnu \ -// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: --cuda-gpu-arch=gfx900 \ // RUN: -c -nogpulib \ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Og %s