diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 446367f106a..a9b68cfe3ee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2002-05-16 Neil Booth + + * 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. + 2002-05-16 Zack Weinberg * c-common.c (STDC_0_IN_SYSTEM_HEADERS, REGISTER_PREFIX): diff --git a/gcc/c-common.c b/gcc/c-common.c index 81810dd7413..c799e95886d 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -4351,6 +4351,23 @@ cb_register_builtins (pfile) /* Misc. */ builtin_define_with_value ("__VERSION__", version_string, 1); + /* 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 (); diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index fc02849aef6..ff4ac02941a 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -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. */ diff --git a/gcc/gcc.c b/gcc/gcc.c index 0b8e36365e5..cad8444c471 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -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 = diff --git a/gcc/toplev.c b/gcc/toplev.c index 5f5eb462811..9fb8813191a 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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="))) { diff --git a/gcc/toplev.h b/gcc/toplev.h index b488e14938c..04477c0a014 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -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. */