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 @@ -150,12 +150,22 @@ Group, DocFlatten; def pedantic_Group : OptionGroup<"">, Group, DocFlatten; + +def offload_Group : OptionGroup<"">, Group, + DocName<"Common Offloading options">; + def opencl_Group : OptionGroup<"">, Group, DocName<"OpenCL options">; def sycl_Group : OptionGroup<"">, Group, DocName<"SYCL options">; +def cuda_Group : OptionGroup<"">, Group, + DocName<"CUDA options">; + +def hip_Group : OptionGroup<"">, Group, + DocName<"HIP options">; + def m_Group : OptionGroup<"">, Group, DocName<"Target-dependent compilation options">; @@ -987,32 +997,108 @@ NegFlag, PosFlag>; +// Common offloading options +let Group = offload_Group in { +def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>, + HelpText<"Specify an offloading device architecture for CUDA, HIP, or OpenMP. (e.g. sm_35). " + "If 'native' is used the compiler will detect locally installed architectures. " + "For HIP offloading, the device architecture can be followed by target ID features " + "delimited by a colon (e.g. gfx908:xnack+:sramecc-). May be specified more than once.">; +def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, Flags<[NoXarchOption]>, + HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, gfx906) from the list of devices to compile for. " + "'all' resets the list to its default value.">; + +def offload_new_driver : Flag<["--"], "offload-new-driver">, Flags<[CC1Option]>, Group, + 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">, Flags<[FlangOption]>, + HelpText<"Only compile for the offloading device.">; +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">, Flags<[FlangOption]>, + HelpText<"Compile for both the offloading host and device (default).">; + def gpu_use_aux_triple_only : Flag<["--"], "gpu-use-aux-triple-only">, InternalDriverOpt, HelpText<"Prepare '-aux-triple' only without populating " "'-aux-target-cpu' and '-aux-target-feature'.">; +def amdgpu_arch_tool_EQ : Joined<["--"], "amdgpu-arch-tool=">, + HelpText<"Tool used for detecting AMD GPU arch in the system.">; +def nvptx_arch_tool_EQ : Joined<["--"], "nvptx-arch-tool=">, + HelpText<"Tool used for detecting NVIDIA GPU arch in the system.">; + +defm gpu_rdc : BoolFOption<"gpu-rdc", + LangOpts<"GPURelocatableDeviceCode">, DefaultFalse, + PosFlag, + NegFlag>; + +def fgpu_default_stream_EQ : Joined<["-"], "fgpu-default-stream=">, + HelpText<"Specify default stream. The default value is 'legacy'. (CUDA/HIP only)">, + Flags<[CC1Option]>, + Values<"legacy,per-thread">, + NormalizedValuesScope<"LangOptions::GPUDefaultStreamKind">, + NormalizedValues<["Legacy", "PerThread"]>, + MarshallingInfoEnum, "Legacy">; + +def fgpu_flush_denormals_to_zero : Flag<["-"], "fgpu-flush-denormals-to-zero">, + HelpText<"Flush denormal floating point values to zero in CUDA/HIP device mode.">; +def fno_gpu_flush_denormals_to_zero : Flag<["-"], "fno-gpu-flush-denormals-to-zero">; + +defm gpu_defer_diag : BoolFOption<"gpu-defer-diag", + LangOpts<"GPUDeferDiag">, DefaultFalse, + PosFlag, NegFlag, + BothFlags<[], " host/device related diagnostic messages for CUDA/HIP">>; + +defm gpu_exclude_wrong_side_overloads : BoolFOption<"gpu-exclude-wrong-side-overloads", + LangOpts<"GPUExcludeWrongSideOverloads">, DefaultFalse, + PosFlag, + NegFlag, + BothFlags<[HelpHidden], " in overloading resolution for CUDA/HIP">>; + +def cuid_EQ : Joined<["-"], "cuid=">, Flags<[CC1Option]>, + HelpText<"An ID for compilation unit, which should be the same for the same " + "compilation unit but different for different compilation units. " + "It is used to externalize device-side static variables for single " + "source offloading languages CUDA and HIP so that they can be " + "accessed by the host code of the same compilation unit.">, + MarshallingInfoString>; +def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">, + HelpText<"Method to generate ID's for compilation units for single source " + "offloading languages CUDA and HIP: 'hash' (ID's generated by hashing " + "file path and command line options) | 'random' (ID's generated as " + "random numbers) | 'none' (disabled). Default is 'hash'. This option " + "will be overridden by option '-cuid=[ID]' if it is specified." >; + +def fgpu_inline_threshold_EQ : Joined<["-"], "fgpu-inline-threshold=">, + Flags<[HelpHidden]>, + HelpText<"Inline threshold for device compilation for CUDA/HIP">; + +def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">, Group, + HelpText<"Enable sanitizer for supported offloading devices">; +def fno_gpu_sanitize : Flag<["-"], "fno-gpu-sanitize">, Group; +} + +// CUDA options +let Group = cuda_Group in { def cuda_include_ptx_EQ : Joined<["--"], "cuda-include-ptx=">, Flags<[NoXarchOption]>, HelpText<"Include PTX for the following GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">; def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, Flags<[NoXarchOption]>, HelpText<"Do not include PTX for the following GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">; -def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>, - HelpText<"Specify an offloading device architecture for CUDA, HIP, or OpenMP. (e.g. sm_35). " - "If 'native' is used the compiler will detect locally installed architectures. " - "For HIP offloading, the device architecture can be followed by target ID features " - "delimited by a colon (e.g. gfx908:xnack+:sramecc-). May be specified more than once.">; def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[NoXarchOption]>, Alias; def cuda_feature_EQ : Joined<["--"], "cuda-feature=">, HelpText<"Manually specify the CUDA feature to use">; -def hip_link : Flag<["--"], "hip-link">, - HelpText<"Link clang-offload-bundler bundles for HIP">; -def no_hip_rt: Flag<["-"], "no-hip-rt">, - HelpText<"Do not link against HIP runtime libraries">; -def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, Flags<[NoXarchOption]>, - HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, gfx906) from the list of devices to compile for. " - "'all' resets the list to its default value.">; -def emit_static_lib : Flag<["--"], "emit-static-lib">, - HelpText<"Enable linker job to emit a static library.">; def no_cuda_gpu_arch_EQ : Joined<["--"], "no-cuda-gpu-arch=">, Flags<[NoXarchOption]>, Alias; + +def cuda_device_only : Flag<["--"], "cuda-device-only">, Alias, + HelpText<"Compile CUDA code for device only">; +def cuda_host_only : Flag<["--"], "cuda-host-only">, Alias, + HelpText<"Compile CUDA code for host only. Has no effect on non-CUDA compilations.">; +def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">, Alias, + HelpText<"Compile CUDA code for both host and device (default). Has no " + "effect on non-CUDA compilations.">; + def cuda_noopt_device_debug : Flag<["--"], "cuda-noopt-device-debug">, HelpText<"Enable device-side debug info generation. Disables ptxas optimizations.">; def no_cuda_version_check : Flag<["--"], "no-cuda-version-check">, @@ -1025,23 +1111,21 @@ HelpText<"Ignore environment variables to detect CUDA installation">; def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group, HelpText<"Path to ptxas (used for compiling CUDA code)">; -def fgpu_flush_denormals_to_zero : Flag<["-"], "fgpu-flush-denormals-to-zero">, - HelpText<"Flush denormal floating point values to zero in CUDA/HIP device mode.">; -def fno_gpu_flush_denormals_to_zero : Flag<["-"], "fno-gpu-flush-denormals-to-zero">; def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">, Alias; def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">, Alias; -defm gpu_rdc : BoolFOption<"gpu-rdc", - LangOpts<"GPURelocatableDeviceCode">, DefaultFalse, - PosFlag, - NegFlag>; def : Flag<["-"], "fcuda-rdc">, Alias; def : Flag<["-"], "fno-cuda-rdc">, Alias; defm cuda_short_ptr : BoolFOption<"cuda-short-ptr", TargetOpts<"NVPTXUseShortPointers">, DefaultFalse, PosFlag, NegFlag>; +} + +def emit_static_lib : Flag<["--"], "emit-static-lib">, + HelpText<"Enable linker job to emit a static library.">; + def mprintf_kind_EQ : Joined<["-"], "mprintf-kind=">, Group, HelpText<"Specify the printf lowering scheme (AMDGPU only), allowed values are " "\"hostcall\"(printing happens during kernel execution, this scheme " @@ -1053,30 +1137,26 @@ NormalizedValuesScope<"TargetOptions::AMDGPUPrintfKind">, NormalizedValues<["Hostcall", "Buffered"]>, MarshallingInfoEnum, "Hostcall">; -def fgpu_default_stream_EQ : Joined<["-"], "fgpu-default-stream=">, - HelpText<"Specify default stream. The default value is 'legacy'. (HIP only)">, - Flags<[CC1Option]>, - Values<"legacy,per-thread">, - NormalizedValuesScope<"LangOptions::GPUDefaultStreamKind">, - NormalizedValues<["Legacy", "PerThread"]>, - MarshallingInfoEnum, "Legacy">; -def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group, + +// HIP options +let Group = hip_Group in { +def hip_link : Flag<["--"], "hip-link">, Group, + HelpText<"Link clang-offload-bundler bundles for HIP">; +def no_hip_rt: Flag<["-"], "no-hip-rt">, Group, + HelpText<"Do not link against HIP runtime libraries">; +def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group, HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">; -def hip_path_EQ : Joined<["--"], "hip-path=">, Group, +def hip_path_EQ : Joined<["--"], "hip-path=">, Group, HelpText<"HIP runtime installation path, used for finding HIP version and adding HIP include path.">; -def amdgpu_arch_tool_EQ : Joined<["--"], "amdgpu-arch-tool=">, Group, - HelpText<"Tool used for detecting AMD GPU arch in the system.">; -def nvptx_arch_tool_EQ : Joined<["--"], "nvptx-arch-tool=">, Group, - HelpText<"Tool used for detecting NVIDIA GPU arch in the system.">; -def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group, +def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group, HelpText<"ROCm device library path. Alternative to rocm-path.">; def : Joined<["--"], "hip-device-lib-path=">, Alias; -def hip_device_lib_EQ : Joined<["--"], "hip-device-lib=">, Group, +def hip_device_lib_EQ : Joined<["--"], "hip-device-lib=">, Group, HelpText<"HIP device library">; -def hip_version_EQ : Joined<["--"], "hip-version=">, +def hip_version_EQ : Joined<["--"], "hip-version=">, Group, HelpText<"HIP version in the format of major.minor.patch">; def fhip_dump_offload_linker_script : Flag<["-"], "fhip-dump-offload-linker-script">, - Group, Flags<[NoArgumentUnused, HelpHidden]>; + Group, Flags<[NoArgumentUnused, HelpHidden]>; defm hip_new_launch_api : BoolFOption<"hip-new-launch-api", LangOpts<"HIPUseNewLaunchAPI">, DefaultFalse, PosFlag, NegFlag, @@ -1102,50 +1182,24 @@ PosFlag, NegFlag, BothFlags<[], " device side init function in HIP (experimental)">>, ShouldParseIf; -defm gpu_defer_diag : BoolFOption<"gpu-defer-diag", - LangOpts<"GPUDeferDiag">, DefaultFalse, - PosFlag, NegFlag, - BothFlags<[], " host/device related diagnostic messages for CUDA/HIP">>; -defm gpu_exclude_wrong_side_overloads : BoolFOption<"gpu-exclude-wrong-side-overloads", - LangOpts<"GPUExcludeWrongSideOverloads">, DefaultFalse, - PosFlag, - NegFlag, - BothFlags<[HelpHidden], " in overloading resolution for CUDA/HIP">>; def gpu_max_threads_per_block_EQ : Joined<["--"], "gpu-max-threads-per-block=">, Flags<[CC1Option]>, HelpText<"Default max threads per block for kernel launch bounds for HIP">, MarshallingInfoInt, "1024">, ShouldParseIf; -def fgpu_inline_threshold_EQ : Joined<["-"], "fgpu-inline-threshold=">, - Flags<[HelpHidden]>, - HelpText<"Inline threshold for device compilation for CUDA/HIP">; def gpu_instrument_lib_EQ : Joined<["--"], "gpu-instrument-lib=">, HelpText<"Instrument device library for HIP, which is a LLVM bitcode containing " "__cyg_profile_func_enter and __cyg_profile_func_exit">; -def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">, Group, - HelpText<"Enable sanitizer for AMDGPU target">; -def fno_gpu_sanitize : Flag<["-"], "fno-gpu-sanitize">, Group; def gpu_bundle_output : Flag<["--"], "gpu-bundle-output">, - Group, HelpText<"Bundle output files of HIP device compilation">; + HelpText<"Bundle output files of HIP device compilation">; def no_gpu_bundle_output : Flag<["--"], "no-gpu-bundle-output">, - Group, HelpText<"Do not bundle output files of HIP device compilation">; -def fhip_emit_relocatable : Flag<["-"], "fhip-emit-relocatable">, Group, + Group, HelpText<"Do not bundle output files of HIP device compilation">; +def fhip_emit_relocatable : Flag<["-"], "fhip-emit-relocatable">, HelpText<"Compile HIP source to relocatable">; -def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">, Group, +def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">, HelpText<"Do not override toolchain to compile HIP source to relocatable">; -def cuid_EQ : Joined<["-"], "cuid=">, Flags<[CC1Option]>, - HelpText<"An ID for compilation unit, which should be the same for the same " - "compilation unit but different for different compilation units. " - "It is used to externalize device-side static variables for single " - "source offloading languages CUDA and HIP so that they can be " - "accessed by the host code of the same compilation unit.">, - MarshallingInfoString>; -def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">, - HelpText<"Method to generate ID's for compilation units for single source " - "offloading languages CUDA and HIP: 'hash' (ID's generated by hashing " - "file path and command line options) | 'random' (ID's generated as " - "random numbers) | 'none' (disabled). Default is 'hash'. This option " - "will be overridden by option '-cuid=[ID]' if it is specified." >; +} + def libomptarget_amdgpu_bc_path_EQ : Joined<["--"], "libomptarget-amdgpu-bc-path=">, Group, HelpText<"Path to libomptarget-amdgcn bitcode library">; def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], "libomptarget-amdgcn-bc-path=">, Group, @@ -2866,23 +2920,6 @@ PosFlag, NegFlag, BothFlags<[NoArgumentUnused, HelpHidden]>>; def static_openmp: Flag<["-"], "static-openmp">, HelpText<"Use the static host OpenMP runtime while linking.">; -def offload_new_driver : Flag<["--"], "offload-new-driver">, Flags<[CC1Option]>, Group, - 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">, Flags<[FlangOption]>, - HelpText<"Only compile for the offloading device.">; -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">, Flags<[FlangOption]>, - HelpText<"Compile for both the offloading host and device (default).">; -def cuda_device_only : Flag<["--"], "cuda-device-only">, Alias, - HelpText<"Compile CUDA code for device only">; -def cuda_host_only : Flag<["--"], "cuda-host-only">, Alias, - HelpText<"Compile CUDA code for host only. Has no effect on non-CUDA compilations.">; -def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">, Alias, - HelpText<"Compile CUDA code for both host and device (default). Has no " - "effect on non-CUDA compilations.">; def fopenmp_new_driver : Flag<["-"], "fopenmp-new-driver">, Flags<[HelpHidden]>, HelpText<"Use the new driver for OpenMP offloading.">; def fno_openmp_new_driver : Flag<["-"], "fno-openmp-new-driver">, Flags<[HelpHidden]>,