Commit c6aded7c by Anthony Green Committed by Jeff Law

flags.h: New flag (optimize_size).

        * 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.

From-SVN: r17497
parent 3698f44e
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
......
/* 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,6 +298,7 @@ extern int target_flags;
\
if (LEVEL >= 2) \
{ \
if (! SIZE) \
flag_strength_reduce = TRUE; \
flag_cse_follow_jumps = TRUE; \
flag_cse_skip_blocks = TRUE; \
......@@ -305,7 +306,7 @@ extern int target_flags;
flag_rerun_cse_after_loop = TRUE; \
} \
\
if (LEVEL >= 3) \
if ((LEVEL >= 3) && ! SIZE) \
{ \
flag_inline_functions = 1; \
} \
......
/* 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"
/* 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 ()
}
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. */
......
/* 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 */
......
/* 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) \
{ \
......
/* 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,10 +1295,11 @@ 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) \
{ \
if (! SIZE) \
flag_inline_functions = 1; \
flag_omit_frame_pointer = 1; \
/* flag_unroll_loops = 1; */ \
......
/* 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); \
......
......@@ -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\
......
......@@ -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) \
......
/* 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. */
......
/* 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",
......
@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
......
@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
......
/* 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,10 +3726,14 @@ 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;
if ((p[0] == 's') && (p[1] == 0))
optimize_size = 1;
else
{
while (c = *p++)
if (! (c >= '0' && c <= '9'))
break;
......@@ -3730,6 +3741,11 @@ main (argc, argv, envp)
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);
......@@ -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,6 +3988,9 @@ main (argc, argv, envp)
else if (str[0] == 'O')
{
register char *p = str+1;
if (*p == 's')
p++;
else
while (*p && *p >= '0' && *p <= '9')
p++;
if (*p == '\0')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment