summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-08 17:41:00 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-08 17:41:00 +0000
commitecee1b296d7a3e1bf2a7613eac325a9d761e8a1c (patch)
tree8fc008788b764f0ba0d67864e8566ca53db122f5
parenta735976018759ccf5c634e13480d676dbd33304d (diff)
downloadgcc-ecee1b296d7a3e1bf2a7613eac325a9d761e8a1c.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169930 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/common.opt22
-rw-r--r--gcc/doc/options.texi15
-rw-r--r--gcc/optc-gen.awk6
-rw-r--r--gcc/opth-gen.awk9
-rw-r--r--gcc/opts.c36
6 files changed, 76 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 81cac7d1a7c..e27a71fe59f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+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>
* config.gcc (arc-*, alpha*-*-gnu*, arm*-*-netbsd*, arm-*-pe*,
diff --git a/gcc/common.opt b/gcc/common.opt
index aed8dd1a512..5485da92840 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1,6 +1,6 @@
; 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.
;
; This file is part of GCC.
@@ -878,7 +878,7 @@ Common Ignore
Does nothing. Preserved for backward compatibility.
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
fcx-fortran-rules
@@ -1024,7 +1024,7 @@ ffast-math
Common
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
ffixed-
@@ -1340,7 +1340,7 @@ Common Report Var(flag_lto_report) Init(0) Optimization
Report various link-time optimization statistics
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
fmax-errors=
@@ -1577,7 +1577,7 @@ Common Ignore
Does nothing. Preserved for backward compatibility.
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
fsched-interblock
@@ -1706,11 +1706,11 @@ Common Report Var(flag_show_column) Init(1)
Show column numbers in diagnostics, when available. Default on
fsignaling-nans
-Common Report Var(flag_signaling_nans) Optimization
+Common Report Var(flag_signaling_nans) Optimization SetByCombined
Disable optimizations observable by IEEE signaling NaNs
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
fsingle-precision-constant
@@ -1827,7 +1827,7 @@ Perform superblock formation via tail duplication
; (user-visible) trap. This is the case, for example, in nonstop
; IEEE 754 arithmetic.
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
ftrapv
@@ -1978,12 +1978,12 @@ Common Report Var(flag_unsafe_loop_optimizations) Optimization
Allow loop optimizations to assume that the loops behave in normal way
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
result of the operation due to rounding.
freciprocal-math
-Common Report Var(flag_reciprocal_math)
+Common Report Var(flag_reciprocal_math) SetByCombined
Same as -fassociative-math for expressions which include division.
; Nonzero means that unsafe floating-point math optimizations are allowed
@@ -1991,7 +1991,7 @@ Same as -fassociative-math for expressions which include division.
; are allowed to assume that their arguments and results are "normal"
; (e.g., nonnegative for SQRT).
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
funswitch-loops
diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 1c8f5d9f134..e39d79e1c8f 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -1,4 +1,4 @@
-@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 This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@@ -436,4 +436,17 @@ the @option{--help} output.
Build the @code{cl_target_option} structure to hold a copy of the
option, add the functions @code{cl_target_option_save} and
@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
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 4aaa2a6041a..502b23bf6e0 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -1,4 +1,4 @@
-# Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010
+# Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
# Free Software Foundation, Inc.
# Contributed by Kelley Cook, June 2004.
# Original code from Neil Booth, May 2003.
@@ -250,6 +250,10 @@ for (i = 0; i < n_opts; i++) {
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 "struct gcc_options global_options;"
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index db32121f914..c3f6c04ebfb 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -1,4 +1,4 @@
-# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010
+# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011
# Free Software Foundation, Inc.
# Contributed by Kelley Cook, June 2004.
# Original code from Neil Booth, May 2003.
@@ -193,6 +193,13 @@ for (i = 0; i < n_opts; i++) {
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 "};"
print "extern struct gcc_options global_options;"
diff --git a/gcc/opts.c b/gcc/opts.c
index 9a3fb133a31..8ca9c67bb8e 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1,5 +1,5 @@
/* 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.
Contributed by Neil Booth.
@@ -1757,15 +1757,23 @@ set_Wstrict_aliasing (struct gcc_options *opts, int onoff)
static void
set_fast_math_flags (struct gcc_options *opts, int set)
{
- opts->x_flag_unsafe_math_optimizations = set;
- set_unsafe_math_optimizations_flags (opts, set);
- opts->x_flag_finite_math_only = set;
- opts->x_flag_errno_math = !set;
+ if (!opts->frontend_set_flag_unsafe_math_optimizations)
+ {
+ opts->x_flag_unsafe_math_optimizations = 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)
{
- opts->x_flag_signaling_nans = 0;
- opts->x_flag_rounding_math = 0;
- opts->x_flag_cx_limited_range = 1;
+ if (!opts->frontend_set_flag_signaling_nans)
+ opts->x_flag_signaling_nans = 0;
+ 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)
static void
set_unsafe_math_optimizations_flags (struct gcc_options *opts, int set)
{
- opts->x_flag_trapping_math = !set;
- opts->x_flag_signed_zeros = !set;
- opts->x_flag_associative_math = set;
- opts->x_flag_reciprocal_math = set;
+ if (!opts->frontend_set_flag_trapping_math)
+ opts->x_flag_trapping_math = !set;
+ if (!opts->frontend_set_flag_signed_zeros)
+ 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. */