diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2735,11 +2735,11 @@ MarshallingInfoFlag>, HelpText<"Use the new driver for offloading compilation.">; def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, Flags<[CC1Option]>, Group, HelpText<"Don't Use the new driver for offloading compilation.">; -def offload_device_only : Flag<["--"], "offload-device-only">, +def offload_device_only : Flag<["--"], "offload-device-only">, Flags<[FlangOption]>, HelpText<"Only compile for the offloading device.">; -def offload_host_only : Flag<["--"], "offload-host-only">, +def offload_host_only : Flag<["--"], "offload-host-only">, Flags<[FlangOption]>, HelpText<"Only compile for the offloading host.">; -def offload_host_device : Flag<["--"], "offload-host-device">, +def offload_host_device : Flag<["--"], "offload-host-device">, Flags<[FlangOption]>, HelpText<"Only compile for the offloading host.">; def cuda_device_only : Flag<["--"], "cuda-device-only">, Alias, HelpText<"Compile CUDA code for device only">; diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90 --- a/flang/test/Driver/driver-help-hidden.f90 +++ b/flang/test/Driver/driver-help-hidden.f90 @@ -69,6 +69,9 @@ ! CHECK-NEXT: -mmlir Additional arguments to forward to MLIR's option processing ! CHECK-NEXT: -module-dir Put MODULE files in ! CHECK-NEXT: -nocpp Disable predefined and command line preprocessor macros +! CHECK-NEXT: --offload-device-only Only compile for the offloading device. +! CHECK-NEXT: --offload-host-device Only compile for the offloading host. +! CHECK-NEXT: --offload-host-only Only compile for the offloading host. ! CHECK-NEXT: -o Write output to ! CHECK-NEXT: -pedantic Warn on language extensions ! CHECK-NEXT: -print-effective-triple Print the effective target triple diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90 --- a/flang/test/Driver/driver-help.f90 +++ b/flang/test/Driver/driver-help.f90 @@ -65,6 +65,9 @@ ! HELP-NEXT: -mmlir Additional arguments to forward to MLIR's option processing ! HELP-NEXT: -module-dir Put MODULE files in ! HELP-NEXT: -nocpp Disable predefined and command line preprocessor macros +! HELP-NEXT: --offload-device-only Only compile for the offloading device. +! HELP-NEXT: --offload-host-device Only compile for the offloading host. +! HELP-NEXT: --offload-host-only Only compile for the offloading host. ! HELP-NEXT: -o Write output to ! HELP-NEXT: -pedantic Warn on language extensions ! HELP-NEXT: -print-effective-triple Print the effective target triple diff --git a/flang/test/Driver/omp-frontend-forwarding.f90 b/flang/test/Driver/omp-driver-offload.f90 rename from flang/test/Driver/omp-frontend-forwarding.f90 rename to flang/test/Driver/omp-driver-offload.f90 --- a/flang/test/Driver/omp-frontend-forwarding.f90 +++ b/flang/test/Driver/omp-driver-offload.f90 @@ -7,6 +7,42 @@ ! CHECK-OPENMP: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}}.f90" ! CHECK-OPENMP-NOT: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90" +! Test regular -fopenmp with offload, and invocation filtering options +! RUN: %flang -S -### %s -o %t 2>&1 \ +! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 \ +! RUN: --target=aarch64-unknown-linux-gnu \ +! RUN: | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE + +! RUN: %flang -S -### %s -o %t 2>&1 \ +! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-host-device \ +! RUN: --target=aarch64-unknown-linux-gnu \ +! RUN: | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE + +! OFFLOAD-HOST-AND-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" +! OFFLOAD-HOST-AND-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" +! OFFLOAD-HOST-AND-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "nvptx64-nvidia-cuda" +! OFFLOAD-HOST-AND-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" + +! RUN: %flang -S -### %s -o %t 2>&1 \ +! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-host-only \ +! RUN: --target=aarch64-unknown-linux-gnu \ +! RUN: | FileCheck %s --check-prefix=OFFLOAD-HOST + +! OFFLOAD-HOST: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" +! OFFLOAD-HOST-NOT: "-triple" "amdgcn-amd-amdhsa" +! OFFLOAD-HOST-NOT: "-triple" "nvptx64-nvidia-cuda" +! OFFLOAD-HOST-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" + +! RUN: %flang -S -### %s -o %t 2>&1 \ +! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-device-only \ +! RUN: --target=aarch64-unknown-linux-gnu \ +! RUN: | FileCheck %s --check-prefix=OFFLOAD-DEVICE + +! OFFLOAD-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" +! OFFLOAD-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" +! OFFLOAD-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "nvptx64-nvidia-cuda" +! OFFLOAD-DEVICE-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" + ! Test regular -fopenmp with offload for basic fopenmp-is-device flag addition and correct fopenmp ! RUN: %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-DEVICE %s ! CHECK-OPENMP-IS-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"