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 @@ -438,6 +438,8 @@ defvar c99 = LangOpts<"C99">; defvar lang_std = LangOpts<"LangStd">; defvar open_cl = LangOpts<"OpenCL">; +defvar render_script = LangOpts<"RenderScript">; +defvar hip = LangOpts<"HIP">; defvar gnu_mode = LangOpts<"GNUMode">; defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")"); @@ -870,8 +872,6 @@ def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">, HelpText<"Flush denormal floating point values to zero in CUDA device mode.">; def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">; -defm cuda_approx_transcendentals : OptInFFlag<"cuda-approx-transcendentals", "Use", "Don't use", - " approximate transcendental functions">; defm gpu_rdc : BoolFOption<"gpu-rdc", LangOpts<"GPURelocatableDeviceCode">, DefaultFalse, PosFlag, @@ -896,8 +896,11 @@ LangOpts<"HIPUseNewLaunchAPI">, DefaultFalse, PosFlag, NegFlag, BothFlags<[], " new kernel launching API for HIP">>; -defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init", - "Allow", "Don't allow", " device side init function in HIP">; +defm gpu_allow_device_init : BoolFOption<"gpu-allow-device-init", + LangOpts<"GPUAllowDeviceInit">, DefaultFalse, + PosFlag, NegFlag, + BothFlags<[], " device side init function in HIP">>, + ShouldParseIf; defm gpu_defer_diag : BoolFOption<"gpu-defer-diag", LangOpts<"GPUDeferDiag">, DefaultFalse, PosFlag, NegFlag, @@ -909,7 +912,9 @@ 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">; + HelpText<"Default max threads per block for kernel launch bounds for HIP">, + MarshallingInfoStringInt, "256">, + ShouldParseIf; 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">; @@ -5157,11 +5162,17 @@ HelpText<"Control vtordisp placement on win32 targets">, MarshallingInfoStringInt, "1">; def fnative_half_type: Flag<["-"], "fnative-half-type">, - HelpText<"Use the native half type for __fp16 instead of promoting to float">; + HelpText<"Use the native half type for __fp16 instead of promoting to float">, + MarshallingInfoFlag>, + ImpliedByAnyOf<[open_cl.KeyPath, render_script.KeyPath]>; def fnative_half_arguments_and_returns : Flag<["-"], "fnative-half-arguments-and-returns">, - HelpText<"Use the native __fp16 type for arguments and returns (and skip ABI-specific lowering)">; + HelpText<"Use the native __fp16 type for arguments and returns (and skip ABI-specific lowering)">, + MarshallingInfoFlag>, + ImpliedByAnyOf<[open_cl.KeyPath, render_script.KeyPath]>; def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">, - HelpText<"Allow function arguments and returns of type half">; + HelpText<"Allow function arguments and returns of type half">, + MarshallingInfoFlag>, + ImpliedByAnyOf<[fnative_half_arguments_and_returns.KeyPath]>; def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">, NormalizedValuesScope<"LangOptions">, @@ -5295,10 +5306,18 @@ //===----------------------------------------------------------------------===// def fsycl_is_device : Flag<["-"], "fsycl-is-device">, - HelpText<"Generate code for SYCL device.">; + HelpText<"Generate code for SYCL device.">, + MarshallingInfoFlag>, + ShouldParseIf; } // let Flags = [CC1Option, NoDriverOption] +defm cuda_approx_transcendentals : BoolFOption<"cuda-approx-transcendentals", + LangOpts<"CUDADeviceApproxTranscendentals">, DefaultFalse, + PosFlag, NegFlag, + BothFlags<[], " approximate transcendental functions">>, + ShouldParseIf; + //===----------------------------------------------------------------------===// // Frontend Options - cc1 + fc1 //===----------------------------------------------------------------------===// diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -444,6 +444,22 @@ Diags.Report(diag::err_drv_argument_not_allowed_with) << "-fgnu89-inline" << GetInputKindName(IK); + if (Args.hasArg(OPT_fgpu_allow_device_init) && !LangOpts.HIP) + Diags.Report(diag::warn_ignored_hip_only_option) + << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args); + + if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ) && !LangOpts.HIP) + Diags.Report(diag::warn_ignored_hip_only_option) + << Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args); + + // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0. + // This option should be deprecated for CL > 1.0 because + // this option was added for compatibility with OpenCL 1.0. + if (Args.getLastArg(OPT_cl_strict_aliasing) && LangOpts.OpenCLVersion > 100) + Diags.Report(diag::warn_option_invalid_ocl_version) + << LangOpts.getOpenCLVersionTuple().getAsString() + << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args); + if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) { auto DefaultCC = LangOpts.getDefaultCallingConv(); @@ -2008,8 +2024,6 @@ Opts.AltiVec = 0; Opts.ZVector = 0; Opts.setDefaultFPContractMode(LangOptions::FPM_On); - Opts.NativeHalfType = 1; - Opts.NativeHalfArgsAndReturns = 1; Opts.OpenCLCPlusPlus = Opts.CPlusPlus; // Include default header file for OpenCL. @@ -2041,10 +2055,6 @@ } Opts.RenderScript = IK.getLanguage() == Language::RenderScript; - if (Opts.RenderScript) { - Opts.NativeHalfType = 1; - Opts.NativeHalfArgsAndReturns = 1; - } // OpenCL and C++ both have bool, true, false keywords. Opts.Bool = Opts.OpenCL || Opts.CPlusPlus; @@ -2240,38 +2250,9 @@ } } - Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device); - - // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0. - // This option should be deprecated for CL > 1.0 because - // this option was added for compatibility with OpenCL 1.0. - if (Args.getLastArg(OPT_cl_strict_aliasing) - && Opts.OpenCLVersion > 100) { - Diags.Report(diag::warn_option_invalid_ocl_version) - << Opts.getOpenCLVersionTuple().getAsString() - << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args); - } - if (Args.hasArg(OPT_fno_operator_names)) Opts.CXXOperatorNames = 0; - if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals)) - Opts.CUDADeviceApproxTranscendentals = 1; - - if (Args.hasArg(OPT_fgpu_allow_device_init)) { - if (Opts.HIP) - Opts.GPUAllowDeviceInit = 1; - else - Diags.Report(diag::warn_ignored_hip_only_option) - << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args); - } - if (Opts.HIP) - Opts.GPUMaxThreadsPerBlock = getLastArgIntValue( - Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock); - else if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ)) - Diags.Report(diag::warn_ignored_hip_only_option) - << Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args); - if (Opts.ObjC) { if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) { StringRef value = arg->getValue(); @@ -2432,12 +2413,6 @@ Opts.setDefaultFPContractMode(LangOptions::FPM_Fast); Opts.XLPragmaPack = Args.hasArg(OPT_fxl_pragma_pack); llvm::sort(Opts.ModuleFeatures); - Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type); - Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns); - // Enable HalfArgsAndReturns if present in Args or if NativeHalfArgsAndReturns - // is enabled. - Opts.HalfArgsAndReturns = Args.hasArg(OPT_fallow_half_arguments_and_returns) - | Opts.NativeHalfArgsAndReturns; Opts.ArmSveVectorBits = getLastArgIntValue(Args, options::OPT_msve_vector_bits_EQ, 0, Diags);