Commit 5e46b0c6 by Ian Lance Taylor Committed by Ian Lance Taylor

common.opt (fcx-limited-range): Add SetByCombined flag.

	* common.opt (fcx-limited-range): Add SetByCombined flag.
	(ffinite-math-only, fmath-errno, frounding-math): Likewise.
	(fsignaling-nans, fsigned-zeros, ftrapping-math): Likewise.
	(fassociative-math, freciprocal-math): Likewise.
	(funsafe-math-optimizations): Likewise.
	* opth-gen.awk: Handle SetByCombined.
	* optc-gen.awk: Likewise.
	* opts.c (set_fast_math_flags): Don't override flag if set by
	frontend.
	(set_unsafe_math_optimizations_flags): Likewise.
	* doc/options.texi (Option properties): Document SetByCombined.

From-SVN: r169930
parent 32243d46
2011-02-08 Ian Lance Taylor <iant@google.com>
* common.opt (fcx-limited-range): Add SetByCombined flag.
(ffinite-math-only, fmath-errno, frounding-math): Likewise.
(fsignaling-nans, fsigned-zeros, ftrapping-math): Likewise.
(fassociative-math, freciprocal-math): Likewise.
(funsafe-math-optimizations): Likewise.
* opth-gen.awk: Handle SetByCombined.
* optc-gen.awk: Likewise.
* opts.c (set_fast_math_flags): Don't override flag if set by
frontend.
(set_unsafe_math_optimizations_flags): Likewise.
* doc/options.texi (Option properties): Document SetByCombined.
2011-02-08 Joseph Myers <joseph@codesourcery.com> 2011-02-08 Joseph Myers <joseph@codesourcery.com>
* config.gcc (arc-*, alpha*-*-gnu*, arm*-*-netbsd*, arm-*-pe*, * config.gcc (arc-*, alpha*-*-gnu*, arm*-*-netbsd*, arm-*-pe*,
......
; Options for the language- and target-independent parts of the compiler. ; Options for the language- and target-independent parts of the compiler.
; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 ; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
; Free Software Foundation, Inc. ; Free Software Foundation, Inc.
; ;
; This file is part of GCC. ; This file is part of GCC.
...@@ -878,7 +878,7 @@ Common Ignore ...@@ -878,7 +878,7 @@ Common Ignore
Does nothing. Preserved for backward compatibility. Does nothing. Preserved for backward compatibility.
fcx-limited-range fcx-limited-range
Common Report Var(flag_cx_limited_range) Optimization Common Report Var(flag_cx_limited_range) Optimization SetByCombined
Omit range reduction step when performing complex division Omit range reduction step when performing complex division
fcx-fortran-rules fcx-fortran-rules
...@@ -1024,7 +1024,7 @@ ffast-math ...@@ -1024,7 +1024,7 @@ ffast-math
Common Common
ffinite-math-only ffinite-math-only
Common Report Var(flag_finite_math_only) Optimization Common Report Var(flag_finite_math_only) Optimization SetByCombined
Assume no NaNs or infinities are generated Assume no NaNs or infinities are generated
ffixed- ffixed-
...@@ -1340,7 +1340,7 @@ Common Report Var(flag_lto_report) Init(0) Optimization ...@@ -1340,7 +1340,7 @@ Common Report Var(flag_lto_report) Init(0) Optimization
Report various link-time optimization statistics Report various link-time optimization statistics
fmath-errno fmath-errno
Common Report Var(flag_errno_math) Init(1) Optimization Common Report Var(flag_errno_math) Init(1) Optimization SetByCombined
Set errno after built-in math functions Set errno after built-in math functions
fmax-errors= fmax-errors=
...@@ -1577,7 +1577,7 @@ Common Ignore ...@@ -1577,7 +1577,7 @@ Common Ignore
Does nothing. Preserved for backward compatibility. Does nothing. Preserved for backward compatibility.
frounding-math frounding-math
Common Report Var(flag_rounding_math) Optimization Common Report Var(flag_rounding_math) Optimization SetByCombined
Disable optimizations that assume default FP rounding behavior Disable optimizations that assume default FP rounding behavior
fsched-interblock fsched-interblock
...@@ -1706,11 +1706,11 @@ Common Report Var(flag_show_column) Init(1) ...@@ -1706,11 +1706,11 @@ Common Report Var(flag_show_column) Init(1)
Show column numbers in diagnostics, when available. Default on Show column numbers in diagnostics, when available. Default on
fsignaling-nans fsignaling-nans
Common Report Var(flag_signaling_nans) Optimization Common Report Var(flag_signaling_nans) Optimization SetByCombined
Disable optimizations observable by IEEE signaling NaNs Disable optimizations observable by IEEE signaling NaNs
fsigned-zeros fsigned-zeros
Common Report Var(flag_signed_zeros) Init(1) Optimization Common Report Var(flag_signed_zeros) Init(1) Optimization SetByCombined
Disable floating point optimizations that ignore the IEEE signedness of zero Disable floating point optimizations that ignore the IEEE signedness of zero
fsingle-precision-constant fsingle-precision-constant
...@@ -1827,7 +1827,7 @@ Perform superblock formation via tail duplication ...@@ -1827,7 +1827,7 @@ Perform superblock formation via tail duplication
; (user-visible) trap. This is the case, for example, in nonstop ; (user-visible) trap. This is the case, for example, in nonstop
; IEEE 754 arithmetic. ; IEEE 754 arithmetic.
ftrapping-math ftrapping-math
Common Report Var(flag_trapping_math) Init(1) Optimization Common Report Var(flag_trapping_math) Init(1) Optimization SetByCombined
Assume floating-point operations can trap Assume floating-point operations can trap
ftrapv ftrapv
...@@ -1978,12 +1978,12 @@ Common Report Var(flag_unsafe_loop_optimizations) Optimization ...@@ -1978,12 +1978,12 @@ Common Report Var(flag_unsafe_loop_optimizations) Optimization
Allow loop optimizations to assume that the loops behave in normal way Allow loop optimizations to assume that the loops behave in normal way
fassociative-math fassociative-math
Common Report Var(flag_associative_math) Common Report Var(flag_associative_math) SetByCombined
Allow optimization for floating-point arithmetic which may change the Allow optimization for floating-point arithmetic which may change the
result of the operation due to rounding. result of the operation due to rounding.
freciprocal-math freciprocal-math
Common Report Var(flag_reciprocal_math) Common Report Var(flag_reciprocal_math) SetByCombined
Same as -fassociative-math for expressions which include division. Same as -fassociative-math for expressions which include division.
; Nonzero means that unsafe floating-point math optimizations are allowed ; Nonzero means that unsafe floating-point math optimizations are allowed
...@@ -1991,7 +1991,7 @@ Same as -fassociative-math for expressions which include division. ...@@ -1991,7 +1991,7 @@ Same as -fassociative-math for expressions which include division.
; are allowed to assume that their arguments and results are "normal" ; are allowed to assume that their arguments and results are "normal"
; (e.g., nonnegative for SQRT). ; (e.g., nonnegative for SQRT).
funsafe-math-optimizations funsafe-math-optimizations
Common Report Var(flag_unsafe_math_optimizations) Optimization Common Report Var(flag_unsafe_math_optimizations) Optimization SetByCombined
Allow math optimizations that may violate IEEE or ISO standards Allow math optimizations that may violate IEEE or ISO standards
funswitch-loops funswitch-loops
......
@c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 @c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
@c Free Software Foundation, Inc. @c Free Software Foundation, Inc.
@c This is part of the GCC manual. @c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi. @c For copying conditions, see the file gcc.texi.
...@@ -436,4 +436,17 @@ the @option{--help} output. ...@@ -436,4 +436,17 @@ the @option{--help} output.
Build the @code{cl_target_option} structure to hold a copy of the Build the @code{cl_target_option} structure to hold a copy of the
option, add the functions @code{cl_target_option_save} and option, add the functions @code{cl_target_option_save} and
@code{cl_target_option_restore} to save and restore the options. @code{cl_target_option_restore} to save and restore the options.
@item SetByCombined
The option may also be set by a combined option such as
@option{-ffast-math}. This causes the @code{gcc_options} struct to
have a field @code{frontend_set_@var{name}}, where @code{@var{name}}
is the name of the field holding the value of this option (without the
leading @code{x_}). This gives the front end a way to indicate that
the value has been set explicitly and should not be changed by the
combined option. For example, some front ends use this to prevent
@option{-ffast-math} and @option{-fno-fast-math} from changing the
value of @option{-fmath-errno} for languages that do not use
@code{errno}.
@end table @end table
# Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010 # Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
# Free Software Foundation, Inc. # Free Software Foundation, Inc.
# Contributed by Kelley Cook, June 2004. # Contributed by Kelley Cook, June 2004.
# Original code from Neil Booth, May 2003. # Original code from Neil Booth, May 2003.
...@@ -250,6 +250,10 @@ for (i = 0; i < n_opts; i++) { ...@@ -250,6 +250,10 @@ for (i = 0; i < n_opts; i++) {
print "#undef x_" name print "#undef x_" name
} }
} }
for (i = 0; i < n_opts; i++) {
if (flag_set_p("SetByCombined", flags[i]))
print " false, /* frontend_set_" var_name(flags[i]) " */"
}
print "};" print "};"
print "" print ""
print "struct gcc_options global_options;" print "struct gcc_options global_options;"
......
# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010 # Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011
# Free Software Foundation, Inc. # Free Software Foundation, Inc.
# Contributed by Kelley Cook, June 2004. # Contributed by Kelley Cook, June 2004.
# Original code from Neil Booth, May 2003. # Original code from Neil Booth, May 2003.
...@@ -193,6 +193,13 @@ for (i = 0; i < n_opts; i++) { ...@@ -193,6 +193,13 @@ for (i = 0; i < n_opts; i++) {
print "#endif" print "#endif"
} }
} }
for (i = 0; i < n_opts; i++) {
if (flag_set_p("SetByCombined", flags[i])) {
print "#ifndef GENERATOR_FILE"
print " bool frontend_set_" var_name(flags[i]) ";"
print "#endif"
}
}
print "#ifndef GENERATOR_FILE" print "#ifndef GENERATOR_FILE"
print "};" print "};"
print "extern struct gcc_options global_options;" print "extern struct gcc_options global_options;"
......
/* Command line option handling. /* Command line option handling.
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Neil Booth. Contributed by Neil Booth.
...@@ -1757,15 +1757,23 @@ set_Wstrict_aliasing (struct gcc_options *opts, int onoff) ...@@ -1757,15 +1757,23 @@ set_Wstrict_aliasing (struct gcc_options *opts, int onoff)
static void static void
set_fast_math_flags (struct gcc_options *opts, int set) set_fast_math_flags (struct gcc_options *opts, int set)
{ {
opts->x_flag_unsafe_math_optimizations = set; if (!opts->frontend_set_flag_unsafe_math_optimizations)
set_unsafe_math_optimizations_flags (opts, set); {
opts->x_flag_finite_math_only = set; opts->x_flag_unsafe_math_optimizations = set;
opts->x_flag_errno_math = !set; set_unsafe_math_optimizations_flags (opts, set);
}
if (!opts->frontend_set_flag_finite_math_only)
opts->x_flag_finite_math_only = set;
if (!opts->frontend_set_flag_errno_math)
opts->x_flag_errno_math = !set;
if (set) if (set)
{ {
opts->x_flag_signaling_nans = 0; if (!opts->frontend_set_flag_signaling_nans)
opts->x_flag_rounding_math = 0; opts->x_flag_signaling_nans = 0;
opts->x_flag_cx_limited_range = 1; if (!opts->frontend_set_flag_rounding_math)
opts->x_flag_rounding_math = 0;
if (!opts->frontend_set_flag_cx_limited_range)
opts->x_flag_cx_limited_range = 1;
} }
} }
...@@ -1774,10 +1782,14 @@ set_fast_math_flags (struct gcc_options *opts, int set) ...@@ -1774,10 +1782,14 @@ set_fast_math_flags (struct gcc_options *opts, int set)
static void static void
set_unsafe_math_optimizations_flags (struct gcc_options *opts, int set) set_unsafe_math_optimizations_flags (struct gcc_options *opts, int set)
{ {
opts->x_flag_trapping_math = !set; if (!opts->frontend_set_flag_trapping_math)
opts->x_flag_signed_zeros = !set; opts->x_flag_trapping_math = !set;
opts->x_flag_associative_math = set; if (!opts->frontend_set_flag_signed_zeros)
opts->x_flag_reciprocal_math = set; opts->x_flag_signed_zeros = !set;
if (!opts->frontend_set_flag_associative_math)
opts->x_flag_associative_math = set;
if (!opts->frontend_set_flag_reciprocal_math)
opts->x_flag_reciprocal_math = set;
} }
/* Return true iff flags in OPTS are set as if -ffast-math. */ /* Return true iff flags in OPTS are set as if -ffast-math. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment