This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Further de-specification of gcc.c


This moves a few built-ins from gcc.c to c-common.c, and as
a side-effect this means they are defined more accurately in
corner-cases with conflicting command-line options.

I didn't use the new flag_fast_math to determine the settings
after option processing, because I assume that things like
  -ffast-math -ftrapping-math
are expected to be handled in-order, so that trapping-math
should be set.  If we don't want to support stuff like this
(maybe it makes no sense?) let me know, as I can clean up
a bit and stop exporting set_fast_math_flags().

Tested x86 Linux.  Bootstrapping, OK to apply on success?

Neil.

	* c-common.c (cb_register_builtins): Handle more built-ins
	here rather than in gcc.c specs.
	* flags.h (flag_fast_math): New.
	* gcc.c (cpp_unique_options): Move many built-ins to c-common.c.
	(cpp_options): Pass -O flags even when only preprocessing.
	* toplev.c (flag_fast_math): New.
	(set_fast_math_flags): New prototype, set flag_fast_math.
	(set_no_fast_math_flags): Remove.
	(decode_f_option): Update.
	* toplev.h (set_fast_math_flags): Update.
	(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	15 May 2002 06:42:44 -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 (flag_fast_math)
+    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/flags.h
--- gcc/flags.h	26 Mar 2002 15:36:34 -0000	1.83
+++ gcc/flags.h	15 May 2002 06:42:47 -0000
@@ -343,6 +343,11 @@ extern int flag_volatile_static;
 
 extern int flag_optimize_sibling_calls;
 
+/* Nonzero means -ffast-math was given.  Behaviour implied by this
+   flag is determined by other flags.  This is to help the C front
+   ends to define __FAST_MATH__ appropriately.  */
+extern int flag_fast_math;
+
 /* Nonzero means the front end generally wants `errno' maintained by math
    operations, like built-in SQRT.  */
 
============================================================
Index: gcc/gcc.c
--- gcc/gcc.c	15 May 2002 05:29:45 -0000	1.317
+++ gcc/gcc.c	15 May 2002 06:43:03 -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	13 May 2002 04:50:11 -0000	1.623
+++ gcc/toplev.c	15 May 2002 06:43:15 -0000
@@ -553,6 +553,11 @@ int flag_no_peephole = 0;
 
 int flag_optimize_sibling_calls = 0;
 
+/* Nonzero means -ffast-math was given.  Behaviour implied by this
+   flag is determined by other flags.  This is to help the C front ends
+   to define __FAST_MATH__ appropriately.  */
+int flag_fast_math;
+
 /* Nonzero means the front end generally wants `errno' maintained by math
    operations, like built-in SQRT.  */
 
@@ -1534,19 +1539,12 @@ set_Wunused (setting)
    -ffast-math and -fno-fast-math imply.  */
 
 void
-set_fast_math_flags ()
-{
-  flag_trapping_math = 0;
-  flag_unsafe_math_optimizations = 1;
-  flag_errno_math = 0;
-}
-
-void
-set_no_fast_math_flags ()
+set_fast_math_flags (int set)
 {
-  flag_trapping_math = 1;
-  flag_unsafe_math_optimizations = 0;
-  flag_errno_math = 1;
+  flag_fast_math = set;
+  flag_trapping_math = !set;
+  flag_unsafe_math_optimizations = set;
+  flag_errno_math = !set;
 }
 
 
@@ -3813,9 +3811,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	15 May 2002 06:43:16 -0000
@@ -113,11 +113,10 @@ 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.  */
-
-extern void set_fast_math_flags         PARAMS ((void));
-extern void set_no_fast_math_flags      PARAMS ((void));
+/* 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));
 
 /* 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	15 May 2002 06:43:26 -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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]