]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* flags.h: New flag (optimize_size).
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jan 1998 23:00:04 +0000 (23:00 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jan 1998 23:00:04 +0000 (23:00 +0000)
        * toplev.c (main): Parse -Os option and set optimize_space
        accordingly.
        * gcc.c (default_compilers), cp/lang-specs.h, f/lang-specs.h: Define
        __OPTIMIZE_SIZE__ when compiling with -Os.
        * config/dsp16xx/dsp16xx.h, config/i386/i386.h,
        config/i386/dgux.h, config/i960/i960.h, config/pdp11/pdp11.h,
        config/v850/v850.h (OPTIMIZATION_OPTIONS): New SIZE argument
        to macro.
        * config/i386/i386.c (optimization_options): Accept new SIZE argument.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@17497 138bc75d-0d04-0410-961f-82ee72b054a4

15 files changed:
gcc/ChangeLog
gcc/config/dsp16xx/dsp16xx.h
gcc/config/i386/dgux.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/i960/i960.h
gcc/config/pdp11/pdp11.h
gcc/config/v850/v850.h
gcc/cp/lang-specs.h
gcc/f/lang-specs.h
gcc/flags.h
gcc/gcc.c
gcc/invoke.texi
gcc/tm.texi
gcc/toplev.c

index 3ec5d67effec2cb9e9c211ecd7ccc375baaf776b..518c8e56772d01af767625c46dd69e51e25786b1 100644 (file)
@@ -1,3 +1,16 @@
+Tue Jan 20 16:01:03 1998  Anthony Green  <green@cygnus.com>
+
+       * flags.h: New flag (optimize_size).
+       * toplev.c (main): Parse -Os option and set optimize_space
+       accordingly.
+       * gcc.c (default_compilers), cp/lang-specs.h, f/lang-specs.h: Define 
+       __OPTIMIZE_SIZE__ when compiling with -Os.
+       * config/dsp16xx/dsp16xx.h, config/i386/i386.h,
+       config/i386/dgux.h, config/i960/i960.h, config/pdp11/pdp11.h,
+       config/v850/v850.h (OPTIMIZATION_OPTIONS): New SIZE argument
+       to macro.
+       * config/i386/i386.c (optimization_options): Accept new SIZE argument.
+
 Mon Jan 26 23:57:39 1998  Manfred Hollstein  <manfred@s-direktnet.de>
 
        * libgcc2.c (__clear_insn_cache): On sysV68 enable the memctl
index e128b48a787f0b2ccc5867351fd674ade100343d..138696530db586f690ef5bc5cc76ab9213e8eff2 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler.  AT&T DSP1600.
-   Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    Contributed by Michael Collison (collison@world.std.com).
 
 This file is part of GNU CC.
@@ -286,7 +286,7 @@ extern int target_flags;
 
 #define OVERRIDE_OPTIONS override_options ()
 
-#define OPTIMIZATION_OPTIONS(LEVEL)                   \
+#define OPTIMIZATION_OPTIONS(LEVEL,SIZE)              \
 {                                                     \
     flag_gnu_linker             = FALSE;              \
                                                       \
@@ -298,14 +298,15 @@ extern int target_flags;
                                                       \
     if (LEVEL >= 2)                                   \
     {                                                 \
-       flag_strength_reduce         = TRUE;          \
+        if (! SIZE)                                   \
+         flag_strength_reduce       = TRUE;          \
        flag_cse_follow_jumps        = TRUE;          \
        flag_cse_skip_blocks         = TRUE;          \
        flag_expensive_optimizations = TRUE;          \
        flag_rerun_cse_after_loop    = TRUE;          \
     }                                                 \
                                                       \
-    if (LEVEL >= 3)                                   \
+    if ((LEVEL >= 3) && ! SIZE)                       \
     {                                                 \
        flag_inline_functions = 1;                     \
     }                                                 \
index 4a923fca67985b01db410eeba2bd31fb3145f2d2..692fb7dbc6b31621b6283fc5ca025495c877eb0d 100644 (file)
@@ -1,5 +1,5 @@
 /* Target definitions for GNU compiler for Intel 80x86 running DG/ux
-   Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    Currently maintained by gcc@dg-rtp.dg.com.
 
 This file is part of GNU CC.
@@ -25,7 +25,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "i386/sysv4.h"
 
 #ifndef VERSION_INFO2
-#define VERSION_INFO2   "$Revision: 1.1 $"
+#define VERSION_INFO2   "$Revision: 1.6 $"
 #endif
 
 #ifndef VERSION_STRING
@@ -119,12 +119,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 */
 
 #undef OPTIMIZATION_OPTIONS
-#define OPTIMIZATION_OPTIONS(LEVEL)                    \
+#define OPTIMIZATION_OPTIONS(LEVEL,SIZE)               \
   do {                                                 \
     extern int flag_signed_bitfields;                  \
     flag_signed_bitfields = 0;                         \
     abort_helper ();                                   \
-    optimization_options (LEVEL);                      \
+    optimization_options (LEVEL,SIZE);                 \
   } while (0)
 
 
@@ -170,7 +170,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Linker and library spec's.
    -static, -shared, -symbolic, -h* and -z* access AT&T V.4 link options.
    -svr4 instructs gcc to place /usr/lib/values-X[cat].o on link the line.
-   The absense of -msvr4 indicates linking done in a COFF environment and
+   The absence of -msvr4 indicates linking done in a COFF environment and
    adds the link script to the link line.  In all environments, the first
    and last objects are crtbegin.o and crtend.o.
    When the -G link option is used (-shared and -symbolic) a final link is
@@ -260,24 +260,6 @@ char insn; int insn_; char * file_; int line_;
     warning ("argument is a structure"),0 : 0), \
     (function_arg (&CUM, MODE, TYPE, NAMED)))
 
-/* This is how to output an assembler line
-   that says to advance the location counter
-   to a multiple of 2**LOG bytes.  */
-
-#undef ASM_OUTPUT_ALIGN
-#define ASM_OUTPUT_ALIGN(FILE,LOG)     \
-     if (LOG <= 2)                     \
-        fprintf ((FILE), "\t.align %d\n", 1<<(LOG));\
-     else if ((LOG)!=0)                \
-        {                              \
-        char buf[256];                 \
-        if (!backalign_labelno) fprintf ((FILE), "\t.align %d\n", 1); \
-        ASM_GENERATE_INTERNAL_LABEL (buf, "LBA", backalign_labelno++); \
-        fprintf ((FILE), "%s:", &buf[1]); \
-        fprintf ((FILE), "\t.backalign %s,%d,%d\n", &buf[1], 1<<(LOG), \
-                 ((TARGET_PENTIUMPRO || TARGET_486) && LOG==4) ? 6 : 2);\
-        }
-
-/* add .align 1 to avoid .backalign bug in assembler */
+/* Add .align 1 to avoid .backalign bug in assembler */
 #undef CONST_SECTION_ASM_OP
 #define CONST_SECTION_ASM_OP    ".section\t.rodata\n\t.align 1"
index a4ec3b6a3f2945969a67960f333d12945a3bfd7a..4e616287d43fa6a8457f932427add2184c6573c2 100644 (file)
@@ -1,5 +1,5 @@
 /* Subroutines for insn-output.c for Intel X86.
-   Copyright (C) 1988, 92, 94, 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1988, 92, 94-97, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -410,8 +410,9 @@ order_regs_for_local_alloc ()
 }
 \f
 void
-optimization_options (level)
+optimization_options (level, size)
      int level;
+     int size;
 {
   /* For -O2 and beyond, turn off -fschedule-insns by default.  It tends to
      make the problem with not enough registers even worse.  */
index d2bc5e2d15661d9fa88e3cb6f601f68b25af3592..8e485252bde5d56007164ce7e301eb68ec17d04d 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler for Intel X86
    (386, 486, Pentium).
-   Copyright (C) 1988, 92, 94, 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1988, 92, 94-97, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -287,7 +287,7 @@ extern int ix86_arch;
 #define SUBTARGET_OPTIONS
 
 /* Define this to change the optimizations performed by default.  */
-#define OPTIMIZATION_OPTIONS(LEVEL) optimization_options(LEVEL)
+#define OPTIMIZATION_OPTIONS(LEVEL,SIZE) optimization_options(LEVEL,SIZE)
 
 /* Specs for the compiler proper */
 
index d9cddb99d57b9bbb502fdd65c39a490a17dfb237..1ef3ba7291260f7ae2bde498b4987c724f4d0e7e 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for Intel 80960
-   Copyright (C) 1992, 1993, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1993, 1995, 1996, 1998 Free Software Foundation, Inc.
    Contributed by Steven McGeady, Intel Corp.
    Additional Work by Glenn Colon-Bonet, Jonathan Shapiro, Andy Wilson
    Converted to GCC 2.0 by Jim Wilson and Michael Tiemann, Cygnus Support.
@@ -94,7 +94,7 @@ Boston, MA 02111-1307, USA.  */
 #define CAN_DEBUG_WITHOUT_FP
 
 /* Do leaf procedure and tail call optimizations for -O2 and higher.  */
-#define OPTIMIZATION_OPTIONS(LEVEL)            \
+#define OPTIMIZATION_OPTIONS(LEVEL,SIZE)       \
 {                                              \
   if ((LEVEL) >= 2)                            \
     {                                          \
index 9a37528f536a1505e5b31d32e60688c31ecc7952..87c4954fda130a7faedf0aa25095e285725684bc 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for the pdp-11
-   Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
    Contributed by Michael K. Gschwind (mike@vlsivie.tuwien.ac.at).
 
 This file is part of GNU CC.
@@ -1295,11 +1295,12 @@ JMP     FUNCTION        0x0058  0x0000 <- FUNCTION
    LEVEL is the optimization level specified; 2 if -O2 is
    specified, 1 if -O is specified, and 0 if neither is specified.  */
 
-#define OPTIMIZATION_OPTIONS(LEVEL)                                    \
+#define OPTIMIZATION_OPTIONS(LEVEL,SIZE)                               \
 {                                                                      \
   if (LEVEL >= 3)                                                      \
     {                                                                  \
-      flag_inline_functions            = 1;                            \
+      if (! SIZE)                                                      \
+        flag_inline_functions          = 1;                            \
       flag_omit_frame_pointer          = 1;                            \
       /* flag_unroll_loops                     = 1; */                 \
     }                                                                  \
index b09a475ac43589e2e7265f2510e263c199a5ba4a..59ad91d2de7cccb0918e63fc7f94694e2733e8c8 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler. NEC V850 series
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    Contributed by Jeff Law (law@cygnus.com).
 
 This file is part of GNU CC.
@@ -208,6 +208,8 @@ extern struct small_memory_info small_memory[(int)SMALL_MEMORY_max];
    LEVEL is the optimization level specified; 2 if `-O2' is
    specified, 1 if `-O' is specified, and 0 if neither is specified.
 
+   SIZE is non-zero if `-Os' is specified, 0 otherwise.  
+
    You should not use this macro to change options that are not
    machine-specific.  These should uniformly selected by the same
    optimization level on all supported machines.  Use this macro to
@@ -216,7 +218,7 @@ extern struct small_memory_info small_memory[(int)SMALL_MEMORY_max];
    *Do not examine `write_symbols' in this macro!* The debugging
    options are not supposed to alter the generated code. */
 
-#define OPTIMIZATION_OPTIONS(LEVEL)                                    \
+#define OPTIMIZATION_OPTIONS(LEVEL,SIZE)                               \
 {                                                                      \
   if (LEVEL)                                                           \
     target_flags |= (MASK_EP | MASK_PROLOG_FUNCTION);                  \
index 381bec56ecb13c5ee6d7a3d20dd64867818d5024..78a6956dfbf2c6aa208ec0430a80a91d6d829528 100644 (file)
@@ -34,7 +34,7 @@ Boston, MA 02111-1307, USA.  */
        -undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\
        %{ansi:-trigraphs -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
        %{!fno-exceptions:-D__EXCEPTIONS}\
-        %c %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
+        %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
    "%{!M:%{!MM:%{!E:cc1plus %{!pipe:%g.ii} %1 %2\
index 016f59ce197d90d8a26308f7b765216110f4bd8d..a51e2a6ba9af9a93c5901d93e7a3e29ab6038458 100644 (file)
@@ -49,7 +49,7 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
        -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
        %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
        %{!undef:%P} -D_LANGUAGE_FORTRAN %{trigraphs} \
-       %c %{O*:%{!O0:-D__OPTIMIZE__}} -traditional\
+       %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} -traditional\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
        %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
    "%{!M:%{!MM:%{!E:f771 %{!pipe:%g.i} -fset-g77-defaults %(f771) \
index 616726e06d64123ff3c96bbe49e5e9c29f504114..f5d1255e9b3de111c818f0742e42a837878e76fa 100644 (file)
@@ -1,5 +1,5 @@
 /* Compilation switch flag definitions for GNU CC.
-   Copyright (C) 1987, 88, 94, 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1987, 88, 94-97, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -53,6 +53,10 @@ extern int use_gnu_debug_info_extensions;
 
 extern int optimize;
 
+/* Nonzero means optimize for size.  -Os.  */
+
+extern int optimize_size;
+
 /* Nonzero means do stupid register allocation.  -noreg.
    Currently, this is 1 if `optimize' is 0.  */
 
index 52a23bb82d51cf4ae334374966af6773177c9355..05e741f64ea5624db62a93cc5d32472d4902121d 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1,5 +1,5 @@
 /* Compiler driver program that can handle many languages.
-   Copyright (C) 1987, 89, 92-96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1987, 89, 92-97, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -601,7 +601,8 @@ static struct compiler default_compilers[] =
         -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
        %{ansi:-trigraphs -D__STRICT_ANSI__}\
        %{!undef:%{!ansi:%p} %P} %{trigraphs} \
-        %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+        %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
+        %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
@@ -622,7 +623,8 @@ static struct compiler default_compilers[] =
         -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
        %{ansi:-trigraphs -D__STRICT_ANSI__}\
        %{!undef:%{!ansi:%p} %P} %{trigraphs}\
-        %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+        %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
+        %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %W{o*}}\
@@ -635,7 +637,8 @@ static struct compiler default_compilers[] =
         -undef -D__OBJC__ -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
         %{ansi:-trigraphs -D__STRICT_ANSI__}\
        %{!undef:%{!ansi:%p} %P} %{trigraphs}\
-        %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+        %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
+        %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
@@ -659,7 +662,8 @@ static struct compiler default_compilers[] =
         -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
         %{ansi:-trigraphs -D__STRICT_ANSI__}\
        %{!undef:%{!ansi:%p} %P} %{trigraphs}\
-        %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+        %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
+        %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %W{o*}"},
@@ -685,7 +689,8 @@ static struct compiler default_compilers[] =
        %{C:%{!E:%eGNU C does not support -C without using -E}}\
        %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{trigraphs}\
         -undef -$ %{!undef:%p %P} -D__ASSEMBLER__ \
-        %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+        %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
+        %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %{!M:%{!MM:%{!E:%{!pipe:%g.s}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
index ef833830261e1b1c7c2fec37200eb0cec4e492c6..562eb77e6f1ab458e0f2dd3a12c3312bd5dddb8f 100644 (file)
@@ -1,4 +1,4 @@
-@c Copyright (C) 1988,89,92,93,94,95,96,1997 Free Software Foundation, Inc.
+@c Copyright (C) 1988,89,92-97,1998 Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
 
@@ -155,7 +155,7 @@ in the following sections.
 -fschedule-insns2  -fstrength-reduce  -fthread-jumps
 -funroll-all-loops  -funroll-loops
 -fmove-all-movables  -freduce-all-givs
--O  -O0  -O1  -O2  -O3
+-O  -O0  -O1  -O2  -O3 -Os
 @end smallexample
 
 @item Preprocessor Options
@@ -2078,6 +2078,11 @@ Optimize yet more.  @samp{-O3} turns on all optimizations specified by
 @item -O0
 Do not optimize.
 
+@item -Os
+Optimize for size.  @samp{-Os} enables all @samp{-O2} optimizations that
+do not typically increase code size.  It also performs further
+optimizations designed to reduce code size.
+
 If you use multiple @samp{-O} options, with or without level numbers,
 the last such option is the one that is effective.
 @end table
index a8c2f03cb1cd96489a864c2cb594ef7938ed3ce2..981d0f91a1a8799cf78ddd83cedc405709ba4bb3 100644 (file)
@@ -1,4 +1,4 @@
-@c Copyright (C) 1988,89,92,93,94,96,1997 Free Software Foundation, Inc.
+@c Copyright (C) 1988,89,92-97,1998 Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
 
@@ -591,7 +591,7 @@ Don't use this macro to turn on various extra optimizations for
 @samp{-O}.  That is what @code{OPTIMIZATION_OPTIONS} is for.
 
 @findex OPTIMIZATION_OPTIONS
-@item OPTIMIZATION_OPTIONS (@var{level})
+@item OPTIMIZATION_OPTIONS (@var{level}, @var{size})
 Some machines may desire to change what optimizations are performed for
 various optimization levels.   This macro, if defined, is executed once
 just after the optimization level is determined and before the remainder
@@ -601,6 +601,8 @@ used as the default values for the other command line options.
 @var{level} is the optimization level specified; 2 if @samp{-O2} is
 specified, 1 if @samp{-O} is specified, and 0 if neither is specified.
 
+@var{size} is non-zero if @samp{-Os} is specified and zero otherwise.
+
 You should not use this macro to change options that are not
 machine-specific.  These should uniformly selected by the same
 optimization level on all supported machines.  Use this macro to enable
index 7c9ca603527f9f1612be55c10a4a38b6412e4f9b..5d19787ea4a92541963fdba294ffdea0c84dab65 100644 (file)
@@ -1,5 +1,5 @@
 /* Top level of GNU C compiler
-   Copyright (C) 1987, 88, 89, 92-6, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1987, 88, 89, 92-7, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -306,6 +306,13 @@ int use_gnu_debug_info_extensions = 0;
 
 int optimize = 0;
 
+/* Nonzero means optimize for size.  -Os.
+   The only valid values are zero and non-zero. When optimize_size is
+   non-zero, optimize defaults to 2, but certain individual code
+   bloating optimizations are disabled.  */
+
+int optimize_size = 0;
+
 /* Number of error messages and warning messages so far.  */
 
 int errorcount = 0;
@@ -3719,18 +3726,27 @@ main (argc, argv, envp)
        }
       else if (argv[i][0] == '-' && argv[i][1] == 'O')
        {
-         /* Handle -O2, -O3, -O69, ...  */
+         /* Handle -Os, -O2, -O3, -O69, ...  */
          char *p = &argv[i][2];
          int c;
-
-         while (c = *p++)
-           if (! (c >= '0' && c <= '9'))
-             break;
-         if (c == 0)
-           optimize = atoi (&argv[i][2]);
+         
+         if ((p[0] == 's') && (p[1] == 0))
+           optimize_size = 1;
+         else
+           {       
+             while (c = *p++)
+               if (! (c >= '0' && c <= '9'))
+                 break;
+             if (c == 0)
+               optimize = atoi (&argv[i][2]);
+           }
        }
     }
 
+  /* Optimizing for size forces optimize to be no less than 2. */
+  if (optimize_size && (optimize < 2))
+    optimize = 2;
+    
   obey_regdecls = (optimize == 0);
 
   if (optimize >= 1)
@@ -3767,6 +3783,12 @@ main (argc, argv, envp)
       flag_inline_functions = 1;
     }
 
+  /* Disable code bloating optimizations if optimizing for size. */
+  if (optimize_size)
+    {
+      flag_inline_functions = 0;
+    }
+
   /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
      modify it.  */
   target_flags = 0;
@@ -3774,7 +3796,7 @@ main (argc, argv, envp)
 
 #ifdef OPTIMIZATION_OPTIONS
   /* Allow default optimizations to be specified on a per-machine basis.  */
-  OPTIMIZATION_OPTIONS (optimize);
+  OPTIMIZATION_OPTIONS (optimize, optimize_size);
 #endif
 
   /* Initialize register usage now so switches may override.  */
@@ -3966,8 +3988,11 @@ main (argc, argv, envp)
          else if (str[0] == 'O')
            {
              register char *p = str+1;
-             while (*p && *p >= '0' && *p <= '9')
+             if (*p == 's')
                p++;
+             else
+               while (*p && *p >= '0' && *p <= '9')
+                 p++;
              if (*p == '\0')
                ;
              else