Index: include/clang/Driver/CC1Options.td =================================================================== --- include/clang/Driver/CC1Options.td +++ include/clang/Driver/CC1Options.td @@ -667,26 +667,26 @@ // OpenCL Options //===----------------------------------------------------------------------===// -def cl_opt_disable : Flag<["-"], "cl-opt-disable">, - HelpText<"OpenCL only. This option disables all optimizations. The default is optimizations are enabled.">; -def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, - HelpText<"OpenCL only. This option does nothing and is for compatibility with OpenCL 1.0">; -def cl_single_precision_constant : Flag<["-"], "cl-single-precision-constant">, - HelpText<"OpenCL only. Treat double precision floating-point constant as single precision constant.">; -def cl_finite_math_only : Flag<["-"], "cl-finite-math-only">, - HelpText<"OpenCL only. Allow floating-point optimizations that assume arguments and results are not NaNs or +-Inf.">; -def cl_kernel_arg_info : Flag<["-"], "cl-kernel-arg-info">, - HelpText<"OpenCL only. Generate kernel argument metadata.">; -def cl_unsafe_math_optimizations : Flag<["-"], "cl-unsafe-math-optimizations">, - HelpText<"OpenCL only. Allow unsafe floating-point optimizations. Also implies -cl-no-signed-zeros and -cl-mad-enable">; -def cl_fast_relaxed_math : Flag<["-"], "cl-fast-relaxed-math">, - HelpText<"OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__">; -def cl_mad_enable : Flag<["-"], "cl-mad-enable">, - HelpText<"OpenCL only. Enable less precise MAD instructions to be generated.">; -def cl_std_EQ : Joined<["-"], "cl-std=">, - HelpText<"OpenCL language standard to compile for">; -def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, - HelpText<"OpenCL only. Allow denormals to be flushed to zero">; +//def cl_opt_disable : Flag<["-"], "cl-opt-disable">, +// HelpText<"OpenCL only. This option disables all optimizations. The default is optimizations are enabled.">; +//def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, +// HelpText<"OpenCL only. This option does nothing and is for compatibility with OpenCL 1.0">; +//def cl_single_precision_constant : Flag<["-"], "cl-single-precision-constant">, +// HelpText<"OpenCL only. Treat double precision floating-point constant as single precision constant.">; +//def cl_finite_math_only : Flag<["-"], "cl-finite-math-only">, +// HelpText<"OpenCL only. Allow floating-point optimizations that assume arguments and results are not NaNs or +-Inf.">; +//def cl_kernel_arg_info : Flag<["-"], "cl-kernel-arg-info">, +// HelpText<"OpenCL only. Generate kernel argument metadata.">; +//def cl_unsafe_math_optimizations : Flag<["-"], "cl-unsafe-math-optimizations">, +// HelpText<"OpenCL only. Allow unsafe floating-point optimizations. Also implies -cl-no-signed-zeros and -cl-mad-enable">; +//def cl_fast_relaxed_math : Flag<["-"], "cl-fast-relaxed-math">, +// HelpText<"OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__">; +//def cl_mad_enable : Flag<["-"], "cl-mad-enable">, +// HelpText<"OpenCL only. Enable less precise MAD instructions to be generated.">; +//def cl_std_EQ : Joined<["-"], "cl-std=">, +// HelpText<"OpenCL language standard to compile for">; +//def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, +// HelpText<"OpenCL only. Allow denormals to be flushed to zero">; //===----------------------------------------------------------------------===// // CUDA Options Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -78,6 +78,7 @@ def i_Group : OptionGroup<"">, Group; def clang_i_Group : OptionGroup<"">, Group; def m_Group : OptionGroup<"">, Group; +def opencl_Group : OptionGroup<"">, Group; // Feature groups - these take command line options that correspond directly to // target specific features and can be translated directly from command line @@ -366,6 +367,28 @@ def bundle__loader : Separate<["-"], "bundle_loader">; def bundle : Flag<["-"], "bundle">; def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>; + +def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. This option disables all optimizations. The default is optimizations are enabled.">; +def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. This option does nothing and is for compatibility with OpenCL 1.0">; +def cl_single_precision_constant : Flag<["-"], "cl-single-precision-constant">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Treat double precision floating-point constant as single precision constant.">; +def cl_finite_math_only : Flag<["-"], "cl-finite-math-only">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Allow floating-point optimizations that assume arguments and results are not NaNs or +-Inf.">; +def cl_kernel_arg_info : Flag<["-"], "cl-kernel-arg-info">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Generate kernel argument metadata.">; +def cl_unsafe_math_optimizations : Flag<["-"], "cl-unsafe-math-optimizations">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Allow unsafe floating-point optimizations. Also implies -cl-no-signed-zeros and -cl-mad-enable">; +def cl_fast_relaxed_math : Flag<["-"], "cl-fast-relaxed-math">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__">; +def cl_mad_enable : Flag<["-"], "cl-mad-enable">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Enable less precise MAD instructions to be generated.">; +def cl_std_EQ : Joined<["-"], "cl-std=">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL language standard to compile for">; +def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Allow denormals to be flushed to zero">; + def client__name : JoinedOrSeparate<["-"], "client_name">; def combine : Flag<["-", "--"], "combine">, Flags<[DriverOption, Unsupported]>; def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">; Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -5065,6 +5065,40 @@ CmdArgs.push_back("-arm-restrict-it"); } + // Forward -cl options to -cc1 + if (Arg *A = Args.getLastArg(options::OPT_cl_opt_disable)) { + CmdArgs.push_back("-cl-opt-disable"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_strict_aliasing)) { + CmdArgs.push_back("-cl-strict-aliasing"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_single_precision_constant)) { + CmdArgs.push_back("-cl-single-precision-constant"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_finite_math_only)) { + CmdArgs.push_back("-cl-finite-math-only"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_kernel_arg_info)) { + CmdArgs.push_back("-cl-kernel-arg-info"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_unsafe_math_optimizations)) { + CmdArgs.push_back("-cl-unsafe-math-optimizations"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_fast_relaxed_math)) { + CmdArgs.push_back("-cl-fast-relaxed-math"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_mad_enable)) { + CmdArgs.push_back("-cl-mad-enable"); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_std_EQ)) { + std::string CLStdStr = "-cl-std="; + CLStdStr += A->getValue(); + CmdArgs.push_back(Args.MakeArgString(CLStdStr)); + } + if (Arg *A = Args.getLastArg(options::OPT_cl_denorms_are_zero)) { + CmdArgs.push_back("-cl-denorms-are-zero"); + } + // Forward -f options with positive and negative forms; we translate // these by hand. if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) { Index: test/Driver/opencl.cl =================================================================== --- /dev/null +++ test/Driver/opencl.cl @@ -0,0 +1,33 @@ +// RUN: %clang -S -### %s +// RUN: %clang -S -### -cl-std=CL %s | FileCheck --check-prefix=CHECK-CL %s +// RUN: %clang -S -### -cl-std=CL1.1 %s | FileCheck --check-prefix=CHECK-CL11 %s +// RUN: %clang -S -### -cl-std=CL1.2 %s | FileCheck --check-prefix=CHECK-CL12 %s +// RUN: %clang -S -### -cl-std=CL2.0 %s | FileCheck --check-prefix=CHECK-CL20 %s +// RUN: %clang -S -### -cl-opt-disable %s | FileCheck --check-prefix=CHECK-OPT-DISABLE %s +// RUN: %clang -S -### -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s +// RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s +// RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s +// RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s +// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s +// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s +// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s +// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s +// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s +// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s +// CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL' +// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid' +// CHECK-CL: .*clang.* "-cc1" .* "-cl-std=CL" +// CHECK-CL11: .*clang.* "-cc1" .* "-cl-std=CL1.1" +// CHECK-CL12: .*clang.* "-cc1" .* "-cl-std=CL1.2" +// CHECK-CL20: .*clang.* "-cc1" .* "-cl-std=CL2.0" +// CHECK-OPT-DISABLE: .*clang.* "-cc1" .* "-cl-opt-disable" +// CHECK-STRICT-ALIASING: .*clang.* "-cc1" .* "-cl-strict-aliasing" +// CHECK-SINGLE-PRECISION-CONST: .*clang.* "-cc1" .* "-cl-single-precision-constant" +// CHECK-FINITE-MATH-ONLY: .*clang.* "-cc1" .* "-cl-finite-math-only" +// CHECK-KERNEL-ARG-INFO: .*clang.* "-cc1" .* "-cl-kernel-arg-info" +// CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations" +// CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math" +// CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable" +// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero" + +kernel void func(void); \ No newline at end of file