diff options
author | Jan Hubicka <hubicka@freesoft.cz> | 1999-04-17 23:13:53 +0200 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 1999-04-17 14:13:53 -0700 |
commit | 3af4bd89433b88aa8b04e0b9cb4868a0f41db962 (patch) | |
tree | a48f5a498c066f4f4f4b2006a1f5fa3a2e2981ae | |
parent | 73fe76e49623a713bdf92a7c009cbf6e5227871e (diff) | |
download | gcc-3af4bd89433b88aa8b04e0b9cb4868a0f41db962.zip gcc-3af4bd89433b88aa8b04e0b9cb4868a0f41db962.tar.gz gcc-3af4bd89433b88aa8b04e0b9cb4868a0f41db962.tar.bz2 |
i386.c (i386_preferred_stack_boundary_string): New global variable.
* i386.c (i386_preferred_stack_boundary_string): New global variable.
(i386_preferred_stack_boundary): New global variable.
(override_functions): Set it. Tidy option setting code.
* i386.h (TARGET_OPTIONS): New command line option.
(i386_preferred_stack_boundary_string): Declare it.
(i386_preferred_stack_boundary): Likewise.
(PREFERRED_STACK_BOUNDARY): Use i386_preferred_stack_boundary.
From-SVN: r26527
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 66 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 20 | ||||
-rw-r--r-- | gcc/invoke.texi | 28 |
4 files changed, 87 insertions, 37 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0201f21..ae4dd94 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +Sat Apr 17 21:10:10 1999 Jan Hubicka <hubicka@freesoft.cz> + + * i386.c (i386_preferred_stack_boundary_string): New global variable. + (i386_preferred_stack_boundary): New global variable. + (override_functions): Set it. Tidy option setting code. + * i386.h (TARGET_OPTIONS): New command line option. + (i386_preferred_stack_boundary_string): Declare it. + (i386_preferred_stack_boundary): Likewise. + (PREFERRED_STACK_BOUNDARY): Use i386_preferred_stack_boundary. + Sat Apr 17 19:22:38 1999 Jan Hubicka <hubicka@freesoft.cz> * i386.c (k6_cost): Take into account the decoding time. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b5173d6..dab0300 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -203,6 +203,12 @@ char *i386_align_loops_string; /* Power of two alignment for non-loop jumps. */ char *i386_align_jumps_string; +/* Power of two alignment for stack boundary in bytes. */ +char *i386_preferred_stack_boundary_string; + +/* Preferred alignment for stack boundary in bits. */ +int i386_preferred_stack_boundary; + /* Values 1-5: see jump.c */ int i386_branch_cost; char *i386_branch_cost_string; @@ -239,16 +245,16 @@ override_options () struct processor_costs *cost; /* Processor costs */ int target_enable; /* Target flags to enable. */ int target_disable; /* Target flags to disable. */ - } processor_target_table[] - = {{PROCESSOR_I386_STRING, PROCESSOR_I386, &i386_cost, 0, 0}, - {PROCESSOR_I486_STRING, PROCESSOR_I486, &i486_cost, 0, 0}, - {PROCESSOR_I586_STRING, PROCESSOR_PENTIUM, &pentium_cost, 0, 0}, - {PROCESSOR_PENTIUM_STRING, PROCESSOR_PENTIUM, &pentium_cost, 0, 0}, - {PROCESSOR_I686_STRING, PROCESSOR_PENTIUMPRO, &pentiumpro_cost, - 0, 0}, - {PROCESSOR_PENTIUMPRO_STRING, PROCESSOR_PENTIUMPRO, - &pentiumpro_cost, 0, 0}, - {PROCESSOR_K6_STRING, PROCESSOR_K6, &k6_cost, 0, 0}}; + } processor_target_table[] = { + {PROCESSOR_I386_STRING, PROCESSOR_I386, &i386_cost, 0, 0}, + {PROCESSOR_I486_STRING, PROCESSOR_I486, &i486_cost, 0, 0}, + {PROCESSOR_I586_STRING, PROCESSOR_PENTIUM, &pentium_cost, 0, 0}, + {PROCESSOR_PENTIUM_STRING, PROCESSOR_PENTIUM, &pentium_cost, 0, 0}, + {PROCESSOR_I686_STRING, PROCESSOR_PENTIUMPRO, &pentiumpro_cost, 0, 0}, + {PROCESSOR_PENTIUMPRO_STRING, PROCESSOR_PENTIUMPRO, + &pentiumpro_cost, 0, 0}, + {PROCESSOR_K6_STRING, PROCESSOR_K6, &k6_cost, 0, 0} + }; int ptt_size = sizeof (processor_target_table) / sizeof (struct ptt); @@ -346,6 +352,11 @@ override_options () def_align = (TARGET_486) ? 4 : 2; /* Validate -malign-loops= value, or provide default. */ +#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN + i386_align_loops = 4; +#else + i386_align_loops = 2; +#endif if (i386_align_loops_string) { i386_align_loops = atoi (i386_align_loops_string); @@ -353,14 +364,13 @@ override_options () fatal ("-malign-loops=%d is not between 0 and %d", i386_align_loops, MAX_CODE_ALIGN); } - else + + /* Validate -malign-jumps= value, or provide default. */ #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN - i386_align_loops = 4; + i386_align_jumps = 4; #else - i386_align_loops = 2; + i386_align_jumps = def_align; #endif - - /* Validate -malign-jumps= value, or provide default. */ if (i386_align_jumps_string) { i386_align_jumps = atoi (i386_align_jumps_string); @@ -368,14 +378,9 @@ override_options () fatal ("-malign-jumps=%d is not between 0 and %d", i386_align_jumps, MAX_CODE_ALIGN); } - else -#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN - i386_align_jumps = 4; -#else - i386_align_jumps = def_align; -#endif /* Validate -malign-functions= value, or provide default. */ + i386_align_funcs = def_align; if (i386_align_funcs_string) { i386_align_funcs = atoi (i386_align_funcs_string); @@ -383,19 +388,26 @@ override_options () fatal ("-malign-functions=%d is not between 0 and %d", i386_align_funcs, MAX_CODE_ALIGN); } - else - i386_align_funcs = def_align; + + /* Validate -mpreferred_stack_boundary= value, or provide default. + The default of 128 bits is for Pentium III's SSE __m128. */ + i386_preferred_stack_boundary = 128; + if (i386_preferred_stack_boundary_string) + { + i = atoi (i386_preferred_stack_boundary_string); + if (i < 2 || i > 31) + fatal ("-mpreferred_stack_boundary=%d is not between 2 and 31", i); + i386_preferred_stack_boundary = (1 << i) * BITS_PER_UNIT; + } /* Validate -mbranch-cost= value, or provide default. */ + i386_branch_cost = 1; if (i386_branch_cost_string) { i386_branch_cost = atoi (i386_branch_cost_string); if (i386_branch_cost < 0 || i386_branch_cost > 5) - fatal ("-mbranch-cost=%d is not between 0 and 5", - i386_branch_cost); + fatal ("-mbranch-cost=%d is not between 0 and 5", i386_branch_cost); } - else - i386_branch_cost = 1; /* Keep nonleaf frame pointers. */ if (TARGET_OMIT_LEAF_FRAME_POINTER) diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index b485471..6b00459 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -182,10 +182,10 @@ extern const int x86_double_with_add; { "hard-float", MASK_80387, "Use hardware fp" }, \ { "soft-float", -MASK_80387, "Do not use hardware fp" },\ { "no-soft-float", MASK_80387, "Use hardware fp" }, \ - { "386", 0, "Optimize for i80386" }, \ - { "486", 0, "Optimize for i80486" }, \ - { "pentium", 0, "Optimize for Pentium" }, \ - { "pentiumpro", 0, "Optimize for Pentium Pro, Pentium II" },\ + { "386", 0, "Same as -mcpu=i386" }, \ + { "486", 0, "Same as -mcpu=i486" }, \ + { "pentium", 0, "Same as -mcpu=pentium" }, \ + { "pentiumpro", 0, "Same as -mcpu=pentiumpro" }, \ { "rtd", MASK_RTD, "Alternate calling convention" },\ { "no-rtd", -MASK_RTD, "Use normal calling convention" },\ { "align-double", MASK_ALIGN_DOUBLE, "Align some doubles on dword boundary" },\ @@ -265,6 +265,7 @@ extern int ix86_arch; { "align-loops=", &i386_align_loops_string, "Loop code aligned to this power of 2" }, \ { "align-jumps=", &i386_align_jumps_string, "Jump targets are aligned to this power of 2" }, \ { "align-functions=", &i386_align_funcs_string, "Function starts are aligned to this power of 2" }, \ + { "preferred-stack-boundary=", &i386_preferred_stack_boundary_string, "Attempt to keep stack aligned to this power of 2" }, \ { "branch-cost=", &i386_branch_cost_string, "Branches are this expensive (1-5, arbitrary units)" }, \ SUBTARGET_OPTIONS \ } @@ -407,13 +408,12 @@ extern int ix86_arch; /* Allocation boundary (in *bits*) for storing arguments in argument list. */ #define PARM_BOUNDARY 32 -/* Boundary (in *bits*) on which stack pointer should be aligned. */ +/* Boundary (in *bits*) on which the stack pointer must be aligned. */ #define STACK_BOUNDARY 32 -/* We want to keep the stack aligned to 128 bits when possible, for the - benefit of doubles and SSE __m128. But the compiler can not rely on - the stack having this alignment.*/ -#define PREFERRED_STACK_BOUNDARY 128 +/* Boundary (in *bits*) on which the stack pointer preferrs to be + aligned; the compiler cannot rely on having this alignment. */ +#define PREFERRED_STACK_BOUNDARY i386_preferred_stack_boundary /* Allocation boundary (in *bits*) for the code of a function. For i486, we get better performance by aligning to a cache @@ -2781,11 +2781,13 @@ extern char *i386_regparm_string; /* # registers to use to pass args */ extern char *i386_align_loops_string; /* power of two alignment for loops */ extern char *i386_align_jumps_string; /* power of two alignment for non-loop jumps */ extern char *i386_align_funcs_string; /* power of two alignment for functions */ +extern char *i386_preferred_stack_boundary_string;/* power of two alignment for stack boundary */ extern char *i386_branch_cost_string; /* values 1-5: see jump.c */ extern int i386_regparm; /* i386_regparm_string as a number */ extern int i386_align_loops; /* power of two alignment for loops */ extern int i386_align_jumps; /* power of two alignment for non-loop jumps */ extern int i386_align_funcs; /* power of two alignment for functions */ +extern int i386_preferred_stack_boundary; /* preferred stack boundary alignment in bits */ extern int i386_branch_cost; /* values 1-5: see jump.c */ extern char *hi_reg_name[]; /* names for 16 bit regs */ extern char *qi_reg_name[]; /* names for 8 bit regs (low) */ diff --git a/gcc/invoke.texi b/gcc/invoke.texi index a8eb923..9a7ebb1 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -342,7 +342,7 @@ in the following sections. -mno-wide-multiply -mrtd -malign-double -mreg-alloc=@var{list} -mregparm=@var{num} -malign-jumps=@var{num} -malign-loops=@var{num} --malign-functions=@var{num} +-malign-functions=@var{num} -mpreferred_stack_boundary=@var{num} @emph{HPPA Options} -mbig-switch -mdisable-fpregs -mdisable-indexing @@ -5172,6 +5172,32 @@ If @samp{-malign-functions} is not specified, the default is 2 if optimizing for a 386, and 4 if optimizing for a 486. @end table +@item -mpreferred-stack-boundary=@var{num} +Attempt to keep the stack boundary aligned to a 2 raised to @var{num} +byte boundary. If @samp{-mpreferred-stack-boundary} is not specified, +the default is 4 (16 bytes or 128 bits). + +The stack is required to be aligned on a 4 byte boundary. On Pentium +and PentiumPro, @code{double} and @code{long double} values should be +aligned to an 8 byte boundary (see @samp{-malign-double}) or suffer +significant run time performance penalties. On Pentium III, the +Streaming SIMD Extention (SSE) data type @code{__m128} suffers similar +penalties if it is not 16 byte aligned. + +To ensure proper alignment of this values on the stack, the stack boundary +must be as aligned as that required by any value stored on the stack. +Further, every function must be generated such that it keeps the stack +aligned. Thus calling a function compiled with a higher preferred +stack boundary from a function compiled with a lower preferred stack +boundary will most likely misalign the stack. It is recommended that +libraries that use callbacks always use the default setting. + +This extra alignment does consume extra stack space. Code that is sensitive +to stack space usage, such as embedded systems and operating system kernels, +may want to reduce the preferred alignment to +@samp{-mpreferred-stack-boundary=2}. +@end table + @node HPPA Options @subsection HPPA Options @cindex HPPA Options |