[RFA] Further de-specification of gcc.c
Neil Booth
neil@daikokuya.demon.co.uk
Wed May 15 23:19:00 GMT 2002
Richard Henderson wrote:-
> I think define __FAST_MATH__ iff the individual components are
> as set_fast_math_flags would have set them. Otherwise the header
> isn't going to know which transformations are legal.
>
> Otherwise ok.
Alright, thanks. Here's the patch I'll commit if it bootstraps OK.
Neil.
* c-common.c (cb_register_builtins): Handle more built-ins
here rather than in gcc.c specs.
* gcc.c (cpp_unique_options): Move many built-ins to c-common.c.
(cpp_options): Pass -O flags even when only preprocessing.
* toplev.c (set_fast_math_flags): New prototype.
(fast_math_flags_set_p): New.
(set_no_fast_math_flags): Remove.
(decode_f_option): Update.
* toplev.h (set_fast_math_flags): Update.
(fast_math_flags_set_p): New.
(set_no_fast_math_flags): Remove.
config:
* c4x/c4x.c (c4x_override_options): Update.
============================================================
Index: gcc/c-common.c
--- gcc/c-common.c 15 May 2002 05:29:43 -0000 1.322
+++ gcc/c-common.c 16 May 2002 06:02:05 -0000
@@ -4336,6 +4336,23 @@ cb_register_builtins (pfile)
builtin_define_with_value ("__WCHAR_TYPE__", MODIFIED_WCHAR_TYPE);
builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE);
+ /* Other target-independent built-ins determined by command-line
+ options. */
+ if (optimize_size)
+ cpp_define (pfile, "__OPTIMIZE_SIZE__");
+ if (optimize)
+ cpp_define (pfile, "__OPTIMIZE__");
+
+ if (flag_hosted)
+ cpp_define (pfile, "__STDC_HOSTED__=1");
+ else
+ cpp_define (pfile, "__STDC_HOSTED__=0");
+
+ if (fast_math_flags_set_p ())
+ cpp_define (pfile, "__FAST_MATH__");
+ if (flag_no_inline)
+ cpp_define (pfile, "__NO_INLINE__");
+
/* A straightforward target hook doesn't work, because of problems
linking that hook's body when part of non-C front ends. */
TARGET_CPU_CPP_BUILTINS ();
============================================================
Index: gcc/gcc.c
--- gcc/gcc.c 15 May 2002 05:29:45 -0000 1.317
+++ gcc/gcc.c 16 May 2002 06:02:20 -0000
@@ -682,18 +682,14 @@ static const char *cpp_unique_options =
%{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
- %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
- %{fno-inline|O0|!O*:-D__NO_INLINE__} %{ffast-math:-D__FAST_MATH__}\
- %{ffreestanding:-D__STDC_HOSTED__=0} %{fno-hosted:-D__STDC_HOSTED__=0}\
- %{!ffreestanding:%{!fno-hosted:-D__STDC_HOSTED__=1}} %{remap}\
- %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
+ %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
%{E|M|MM:%W{o*}}";
/* This contains cpp options which are common with cc1_options and are passed
only when preprocessing only to avoid duplication. */
static const char *cpp_options =
"%(cpp_unique_options) %{std*} %{d*} %{W*&pedantic*} %{w} %{m*} %{f*}\
- %{undef}";
+ %{O*} %{undef}";
/* NB: This is shared amongst all front-ends. */
static const char *cc1_options =
============================================================
Index: gcc/toplev.c
--- gcc/toplev.c 15 May 2002 09:00:08 -0000 1.624
+++ gcc/toplev.c 16 May 2002 06:02:34 -0000
@@ -1540,19 +1540,20 @@ set_Wunused (setting)
-ffast-math and -fno-fast-math imply. */
void
-set_fast_math_flags ()
+set_fast_math_flags (int set)
{
- flag_trapping_math = 0;
- flag_unsafe_math_optimizations = 1;
- flag_errno_math = 0;
+ flag_trapping_math = !set;
+ flag_unsafe_math_optimizations = set;
+ flag_errno_math = !set;
}
-void
-set_no_fast_math_flags ()
+/* Return true iff flags are set as if -ffast-math. */
+bool
+fast_math_flags_set_p ()
{
- flag_trapping_math = 1;
- flag_unsafe_math_optimizations = 0;
- flag_errno_math = 1;
+ return (!flag_trapping_math
+ && flag_unsafe_math_optimizations
+ && !flag_errno_math);
}
@@ -3819,9 +3820,9 @@ decode_f_option (arg)
}
if (!strcmp (arg, "fast-math"))
- set_fast_math_flags ();
+ set_fast_math_flags (1);
else if (!strcmp (arg, "no-fast-math"))
- set_no_fast_math_flags ();
+ set_fast_math_flags (0);
else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
|| (option_value = skip_leading_substring (arg, "inline-limit=")))
{
============================================================
Index: gcc/toplev.h
--- gcc/toplev.h 25 Mar 2002 20:52:13 -0000 1.83
+++ gcc/toplev.h 16 May 2002 06:02:34 -0000
@@ -113,11 +113,13 @@ extern const char *dump_base_name;
/* The hashtable, so that the C front ends can pass it to cpplib. */
extern struct ht *ident_hash;
-/* These functions can be used by targets to set the flags originally
- implied by -ffast-math and -fno-fast-math. */
+/* This function can be used by targets to set the flags originally
+ implied by -ffast-math and -fno-fast-math. */
+
+extern void set_fast_math_flags PARAMS ((int));
-extern void set_fast_math_flags PARAMS ((void));
-extern void set_no_fast_math_flags PARAMS ((void));
+/* Return true iff flags are set as if -ffast-math. */
+extern bool fast_math_flags_set_p PARAMS ((void));
/* The following functions accept a wide integer argument. Rather
than having to cast on every function call, we use a macro instead. */
============================================================
Index: gcc/config/c4x/c4x.c
--- gcc/config/c4x/c4x.c 10 Mar 2002 01:38:54 -0000 1.102
+++ gcc/config/c4x/c4x.c 16 May 2002 06:02:40 -0000
@@ -307,7 +307,7 @@ c4x_override_options ()
target_flags &= ~C3X_FLAG;
/* Convert foo / 8.0 into foo * 0.125, etc. */
- set_fast_math_flags();
+ set_fast_math_flags (1);
/* We should phase out the following at some stage.
This provides compatibility with the old -mno-aliases option. */
More information about the Gcc-patches
mailing list