From 61e95947f563d2c25fb12a8dc42f91e5d6e67dd3 Mon Sep 17 00:00:00 2001 From: geoffk Date: Thu, 2 Sep 1999 05:42:06 +0000 Subject: [PATCH] * flags.h: New variables align_loops, align_loops_log, align_jumps, align_jumps_log, align_labels, align_labels_log, align_functions, align_functions_log. * toplev.c: Define them. (f_options): Handle -falign-* when they have no argument. (main): Add logic to set variables for -falign-functions, -falign-jumps, -falign-labels, -falign-loops. Make it -fsched-verbose= and -finline-limit=. (display_help): Change help to match options. * final.c (LABEL_ALIGN): Default to align_labels_log. (LABEL_ALIGN_MAX_SKIP): Default to align_labels-1. (LOOP_ALIGN): Default to align_loops_log. (LOOP_ALIGN_MAX_SKIP): Default to align_loops-1. (LABEL_ALIGN_AFTER_BARRIER): Default to align_jumps_log. (LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Default to align_jumps-1. * varasm.c (assemble_start_function): Handle align_functions. * config/sparc/sparc.h: Don't declare sparc_align_*. Don't provide LABEL_ALIGN_AFTER_BARRIER or LOOP_ALIGN. (DEFAULT_SPARC_ALIGN_FUNCS): Delete; take functionality into sparc.c. (FUNCTION_BOUNDARY): Fix incorrect use---it's not just a request, it's a promise. * config/sparc/sparc.c: Delete sparc_align_loops, sparc_align_jumps, sparc_align_funcs and the corresponding string variables. (sparc_override_options): Default align_functions on ultrasparc. Delete -malign-* handling. * config/mips/mips.c (override_options): On 64-bit targets, try to align code to 64-bit boundaries. (print_operand): New substitution, %~, which aligns labels to align_labels_log. * config/mips/mips.md (div_trap_normal): Use %~. (div_trap_mips16): Likewise. (abssi): Likewise. (absdi2): Likewise. (ffssi2): Likewise. (ffsdi2): Likewise. (ashldi3_internal): Likewise. (ashrdi3_internal): Likewise. (lshrdi3_internal): Likewise. (casesi_internal): Likewise. Plus corresponding documentation changes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29045 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 50 ++++++++++++++++++++++++++-- gcc/config/mips/mips.c | 22 ++++++++++++- gcc/config/mips/mips.md | 58 ++++++++++++++++----------------- gcc/config/sparc/sparc.c | 53 ++---------------------------- gcc/config/sparc/sparc.h | 21 +----------- gcc/final.c | 12 +++---- gcc/flags.h | 14 ++++++++ gcc/invoke.texi | 84 ++++++++++++++++++++++++++++++++++-------------- gcc/tm.texi | 32 ++++++++++++++++++ gcc/toplev.c | 62 ++++++++++++++++++++++++++++++++--- gcc/varasm.c | 13 ++++++++ 11 files changed, 284 insertions(+), 137 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c6188fb563e..457141881e6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,49 @@ +Thu Sep 2 13:52:53 1999 Geoffrey Keating + + * flags.h: New variables align_loops, align_loops_log, + align_jumps, align_jumps_log, align_labels, align_labels_log, + align_functions, align_functions_log. + * toplev.c: Define them. + (f_options): Handle -falign-* when they have no argument. + (main): Add logic to set variables for -falign-functions, + -falign-jumps, -falign-labels, -falign-loops. + Make it -fsched-verbose= and -finline-limit=. + (display_help): Change help to match options. + * final.c (LABEL_ALIGN): Default to align_labels_log. + (LABEL_ALIGN_MAX_SKIP): Default to align_labels-1. + (LOOP_ALIGN): Default to align_loops_log. + (LOOP_ALIGN_MAX_SKIP): Default to align_loops-1. + (LABEL_ALIGN_AFTER_BARRIER): Default to align_jumps_log. + (LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Default to align_jumps-1. + * varasm.c (assemble_start_function): Handle align_functions. + + * config/sparc/sparc.h: Don't declare sparc_align_*. + Don't provide LABEL_ALIGN_AFTER_BARRIER or LOOP_ALIGN. + (DEFAULT_SPARC_ALIGN_FUNCS): Delete; take functionality into + sparc.c. + (FUNCTION_BOUNDARY): Fix incorrect use---it's not just a request, + it's a promise. + * config/sparc/sparc.c: Delete sparc_align_loops, + sparc_align_jumps, sparc_align_funcs and the corresponding string + variables. + (sparc_override_options): Default align_functions on ultrasparc. + Delete -malign-* handling. + + * config/mips/mips.c (override_options): On 64-bit targets, + try to align code to 64-bit boundaries. + (print_operand): New substitution, %~, + which aligns labels to align_labels_log. + * config/mips/mips.md (div_trap_normal): Use %~. + (div_trap_mips16): Likewise. + (abssi): Likewise. + (absdi2): Likewise. + (ffssi2): Likewise. + (ffsdi2): Likewise. + (ashldi3_internal): Likewise. + (ashrdi3_internal): Likewise. + (lshrdi3_internal): Likewise. + (casesi_internal): Likewise. + Wed Sep 1 21:13:48 1999 Richard Henderson Merge new ia32 backend from the branch! @@ -2644,7 +2690,7 @@ Sat Jul 31 11:10:07 1999 Bernd Schmidt Sat Jul 31 04:10:01 1999 Jeffrey A Law (law@cygnus.com) - * pa.c (compute_frame_size): Use STARTINg_FRAME_OFFSET instea_ABI]: New function. + * pa.c (compute_frame_size): Use STARTINg_FRAME_OFFSET instea_ABI]: New function. (mvs_add_alias, mvs_need_alias): New functions. (mvs_get_alias, mvs_check_alias): New functions. (handle_pragma): New function. @@ -3558,4 +3604,4 @@ Thu Jun 17 13:28:30 1999 David O'Brien * i386/freebsd-elf.h (LINK_SPEC): Fix typo. - * i386/freebsd- + * i386/freebsd- diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 51838eab96f..0b82cd8c09a 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -4413,6 +4413,7 @@ override_options () mips_print_operand_punct['^'] = 1; mips_print_operand_punct['$'] = 1; mips_print_operand_punct['+'] = 1; + mips_print_operand_punct['~'] = 1; mips_char_to_class['d'] = TARGET_MIPS16 ? M16_REGS : GR_REGS; mips_char_to_class['e'] = M16_NA_REGS; @@ -4493,6 +4494,17 @@ override_options () /* Save GPR registers in word_mode sized hunks. word_mode hasn't been initialized yet, so we can't use that here. */ gpr_mode = TARGET_64BIT ? DImode : SImode; + + /* Provide default values for align_* for 64-bit targets. */ + if (TARGET_64BIT) + { + if (align_loops == 0) + align_loops = 8; + if (align_jumps == 0) + align_jumps = 8; + if (align_functions == 0) + align_functions = 8; + } } /* On the mips16, we want to allocate $24 (T_REG) before other @@ -4617,7 +4629,8 @@ mips_debugger_offset (addr, offset) '.' Print the name of the register with a hard-wired zero (zero or $0). '^' Print the name of the pic call-through register (t9 or $25). '$' Print the name of the stack pointer register (sp or $29). - '+' Print the name of the gp register (gp or $28). */ + '+' Print the name of the gp register (gp or $28). + '~' Output an branch alignment to LABEL_ALIGN(NULL). */ void print_operand (file, op, letter) @@ -4738,6 +4751,13 @@ print_operand (file, op, letter) break; + case '~': + { + if (align_labels_log > 0) + ASM_OUTPUT_ALIGN (file, align_labels_log); + } + break; + default: error ("PRINT_OPERAND: Unknown punctuation '%c'", letter); break; diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index c3a6ba7068c..7b860edc652 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -2418,16 +2418,16 @@ if (GENERATE_BRANCHLIKELY) { if (GET_CODE (operands[1]) == CONST_INT) - return \"%(beql\\t%0,$0,1f\\n\\tbreak\\t%2\\n1:%)\"; + return \"%(beql\\t%0,$0,1f\\n\\tbreak\\t%2\\n%~1:%)\"; else - return \"%(beql\\t%0,%1,1f\\n\\tbreak\\t%2\\n1:%)\"; + return \"%(beql\\t%0,%1,1f\\n\\tbreak\\t%2\\n%~1:%)\"; } else { if (GET_CODE (operands[1]) == CONST_INT) - return \"%(bne\\t%0,$0,1f\\n\\tnop\\n\\tbreak\\t%2\\n1:%)\"; + return \"%(bne\\t%0,$0,1f\\n\\tnop\\n\\tbreak\\t%2\\n%~1:%)\"; else - return \"%(bne\\t%0,%1,1f\\n\\tnop\\n\\tbreak\\t%2\\n1:%)\"; + return \"%(bne\\t%0,%1,1f\\n\\tnop\\n\\tbreak\\t%2\\n%~1:%)\"; } } return \"\"; @@ -2462,9 +2462,9 @@ { /* No branch delay slots on mips16. */ if (GET_CODE (operands[1]) == CONST_INT) - return \"%(bnez\\t%0,1f\\n\\tbreak\\t%2\\n1:%)\"; + return \"%(bnez\\t%0,1f\\n\\tbreak\\t%2\\n%~1:%)\"; else - return \"%(bne\\t%0,%1,1f\\n\\tbreak\\t%2\\n1:%)\"; + return \"%(bne\\t%0,%1,1f\\n\\tbreak\\t%2\\n%~1:%)\"; } return \"\"; }" @@ -2820,12 +2820,12 @@ if (REGNO (operands[0]) == REGNO (operands[1])) { if (GENERATE_BRANCHLIKELY) - return \"%(bltzl\\t%1,1f\\n\\tsubu\\t%0,%z2,%0\\n1:%)\"; + return \"%(bltzl\\t%1,1f\\n\\tsubu\\t%0,%z2,%0\\n%~1:%)\"; else - return \"bgez\\t%1,1f%#\\n\\tsubu\\t%0,%z2,%0\\n1:\"; + return \"bgez\\t%1,1f%#\\n\\tsubu\\t%0,%z2,%0\\n%~1:\"; } else - return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tsubu\\t%0,%z2,%0\\n1:%)\"; + return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tsubu\\t%0,%z2,%0\\n%~1:%)\"; }" [(set_attr "type" "multi") (set_attr "mode" "SI") @@ -2842,9 +2842,9 @@ operands[2] = const0_rtx; if (REGNO (operands[0]) == REGNO (operands[1])) - return \"%(bltzl\\t%1,1f\\n\\tdsubu\\t%0,%z2,%0\\n1:%)\"; + return \"%(bltzl\\t%1,1f\\n\\tdsubu\\t%0,%z2,%0\\n%~1:%)\"; else - return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tdsubu\\t%0,%z2,%0\\n1:%)\"; + return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tdsubu\\t%0,%z2,%0\\n%~1:%)\"; }" [(set_attr "type" "multi") (set_attr "mode" "DI") @@ -2891,21 +2891,21 @@ return \"%(\\ move\\t%0,%z4\\n\\ \\tbeq\\t%1,%z4,2f\\n\\ -1:\\tand\\t%2,%1,0x0001\\n\\ +%~1:\\tand\\t%2,%1,0x0001\\n\\ \\taddu\\t%0,%0,1\\n\\ \\tbeq\\t%2,%z4,1b\\n\\ \\tsrl\\t%1,%1,1\\n\\ -2:%)\"; +%~2:%)\"; return \"%(\\ move\\t%0,%z4\\n\\ \\tmove\\t%3,%1\\n\\ \\tbeq\\t%3,%z4,2f\\n\\ -1:\\tand\\t%2,%3,0x0001\\n\\ +%~1:\\tand\\t%2,%3,0x0001\\n\\ \\taddu\\t%0,%0,1\\n\\ \\tbeq\\t%2,%z4,1b\\n\\ \\tsrl\\t%3,%3,1\\n\\ -2:%)\"; +%~2:%)\"; }" [(set_attr "type" "multi") (set_attr "mode" "SI") @@ -2927,21 +2927,21 @@ move\\t%0,%z4\\n\\ return \"%(\\ move\\t%0,%z4\\n\\ \\tbeq\\t%1,%z4,2f\\n\\ -1:\\tand\\t%2,%1,0x0001\\n\\ +%~1:\\tand\\t%2,%1,0x0001\\n\\ \\tdaddu\\t%0,%0,1\\n\\ \\tbeq\\t%2,%z4,1b\\n\\ \\tdsrl\\t%1,%1,1\\n\\ -2:%)\"; +%~2:%)\"; return \"%(\\ move\\t%0,%z4\\n\\ \\tmove\\t%3,%1\\n\\ \\tbeq\\t%3,%z4,2f\\n\\ -1:\\tand\\t%2,%3,0x0001\\n\\ +%~1:\\tand\\t%2,%3,0x0001\\n\\ \\tdaddu\\t%0,%0,1\\n\\ \\tbeq\\t%2,%z4,1b\\n\\ \\tdsrl\\t%3,%3,1\\n\\ -2:%)\"; +%~2:%)\"; }" [(set_attr "type" "multi") (set_attr "mode" "DI") @@ -6471,16 +6471,16 @@ move\\t%0,%z4\\n\\ \\t%(b\\t3f\\n\\ \\tmove\\t%L0,%z4%)\\n\\ \\n\\ -1:\\n\\ +%~1:\\n\\ \\t%(beq\\t%3,%z4,2f\\n\\ \\tsll\\t%M0,%M1,%2%)\\n\\ \\n\\ \\tsubu\\t%3,%z4,%2\\n\\ \\tsrl\\t%3,%L1,%3\\n\\ \\tor\\t%M0,%M0,%3\\n\\ -2:\\n\\ +%~2:\\n\\ \\tsll\\t%L0,%L1,%2\\n\\ -3:\"; +%~3:\"; }" [(set_attr "type" "darith") (set_attr "mode" "SI") @@ -6829,16 +6829,16 @@ move\\t%0,%z4\\n\\ \\t%(b\\t3f\\n\\ \\tsra\\t%M0,%M1,31%)\\n\\ \\n\\ -1:\\n\\ +%~1:\\n\\ \\t%(beq\\t%3,%z4,2f\\n\\ \\tsrl\\t%L0,%L1,%2%)\\n\\ \\n\\ \\tsubu\\t%3,%z4,%2\\n\\ \\tsll\\t%3,%M1,%3\\n\\ \\tor\\t%L0,%L0,%3\\n\\ -2:\\n\\ +%~2:\\n\\ \\tsra\\t%M0,%M1,%2\\n\\ -3:\"; +%~3:\"; }" [(set_attr "type" "darith") (set_attr "mode" "DI") @@ -7210,16 +7210,16 @@ move\\t%0,%z4\\n\\ \\t%(b\\t3f\\n\\ \\tmove\\t%M0,%z4%)\\n\\ \\n\\ -1:\\n\\ +%~1:\\n\\ \\t%(beq\\t%3,%z4,2f\\n\\ \\tsrl\\t%L0,%L1,%2%)\\n\\ \\n\\ \\tsubu\\t%3,%z4,%2\\n\\ \\tsll\\t%3,%M1,%3\\n\\ \\tor\\t%L0,%L0,%3\\n\\ -2:\\n\\ +%~2:\\n\\ \\tsrl\\t%M0,%M1,%2\\n\\ -3:\"; +%~3:\"; }" [(set_attr "type" "darith") (set_attr "mode" "DI") @@ -9308,7 +9308,7 @@ move\\t%0,%z4\\n\\ "TARGET_EMBEDDED_PIC" "* { - output_asm_insn (\"%(bal\\t%S1\;sll\\t%0,2\\n%S1:\", operands); + output_asm_insn (\"%(bal\\t%S1\;sll\\t%0,2\\n%~%S1:\", operands); output_asm_insn (\"addu\\t%0,%0,$31%)\", operands); output_asm_insn (\"lw\\t%0,%1-%S1(%0)\;addu\\t%0,%0,$31\", operands); return \"j\\t%0\"; diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 23406c9722b..ad51856714d 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -132,16 +132,6 @@ const char *sparc_cmodel_string; /* Parsed value. */ enum cmodel sparc_cmodel; -/* Record alignment options as passed by user. */ -const char *sparc_align_loops_string; -const char *sparc_align_jumps_string; -const char *sparc_align_funcs_string; - -/* Parsed values, as a power of two. */ -int sparc_align_loops; -int sparc_align_jumps; -int sparc_align_funcs; - char sparc_hard_reg_printed[8]; struct sparc_cpu_select sparc_select[] = @@ -325,46 +315,9 @@ sparc_override_options () if (! TARGET_FPU) target_flags &= ~MASK_VIS; - /* Validate -malign-loops= value, or provide default. */ - if (sparc_align_loops_string) - { - sparc_align_loops = exact_log2 (atoi (sparc_align_loops_string)); - if (sparc_align_loops < 2 || sparc_align_loops > 7) - fatal ("-malign-loops=%s is not between 4 and 128 or is not a power of two", - sparc_align_loops_string); - } - else - { - /* ??? This relies on ASM_OUTPUT_ALIGN to not emit the alignment if - its 0. This sounds a bit kludgey. */ - sparc_align_loops = 0; - } - - /* Validate -malign-jumps= value, or provide default. */ - if (sparc_align_jumps_string) - { - sparc_align_jumps = exact_log2 (atoi (sparc_align_jumps_string)); - if (sparc_align_jumps < 2 || sparc_align_loops > 7) - fatal ("-malign-jumps=%s is not between 4 and 128 or is not a power of two", - sparc_align_jumps_string); - } - else - { - /* ??? This relies on ASM_OUTPUT_ALIGN to not emit the alignment if - its 0. This sounds a bit kludgey. */ - sparc_align_jumps = 0; - } - - /* Validate -malign-functions= value, or provide default. */ - if (sparc_align_funcs_string) - { - sparc_align_funcs = exact_log2 (atoi (sparc_align_funcs_string)); - if (sparc_align_funcs < 2 || sparc_align_loops > 7) - fatal ("-malign-functions=%s is not between 4 and 128 or is not a power of two", - sparc_align_funcs_string); - } - else - sparc_align_funcs = DEFAULT_SPARC_ALIGN_FUNCS; + /* Supply a default value for align_functions. */ + if (align_functions == 0 && sparc_cpu == PROCESSOR_ULTRASPARC) + align_functions = 32; /* Validate PCC_STRUCT_RETURN. */ if (flag_pcc_struct_return == DEFAULT_PCC_STRUCT_RETURN) diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index 20ba7dca730..9d78988ed48 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -663,9 +663,6 @@ extern enum processor_type sparc_cpu; { "cpu=", &sparc_select[1].string, "Use features of and schedule code for given CPU" }, \ { "tune=", &sparc_select[2].string, "Schedule code for given CPU" }, \ { "cmodel=", &sparc_cmodel_string, "Use given Sparc code model" }, \ - { "align-loops=", &sparc_align_loops_string, "Loop code aligned to this power of 2" }, \ - { "align-jumps=", &sparc_align_jumps_string, "Jump targets are aligned to this power of 2" }, \ - { "align-functions=", &sparc_align_funcs_string, "Function starts are aligned to this power of 2" }, \ SUBTARGET_OPTIONS \ } @@ -682,18 +679,6 @@ struct sparc_cpu_select }; extern struct sparc_cpu_select sparc_select[]; - -/* Variables to record values the user passes. */ -extern const char *sparc_align_loops_string; -extern const char *sparc_align_jumps_string; -extern const char *sparc_align_funcs_string; -/* Parsed values as a power of two. */ -extern int sparc_align_loops; -extern int sparc_align_jumps; -extern int sparc_align_funcs; - -#define DEFAULT_SPARC_ALIGN_FUNCS \ -(sparc_cpu == PROCESSOR_ULTRASPARC ? 5 : 2) /* target machine storage layout */ @@ -799,7 +784,7 @@ if (TARGET_ARCH64 \ (TARGET_ARCH64 ? (((LOC)+15) & ~15) : (((LOC)+7) & ~7)) /* Allocation boundary (in *bits*) for the code of a function. */ -#define FUNCTION_BOUNDARY (1 << (sparc_align_funcs + 3)) +#define FUNCTION_BOUNDARY 32 /* Alignment of field after `int : 0' in a structure. */ #define EMPTY_FIELD_BOUNDARY (TARGET_ARCH64 ? 64 : 32) @@ -3039,10 +3024,6 @@ do { \ if ((LOG) != 0) \ fprintf (FILE, "\t.align %d\n", (1<<(LOG))) -#define LABEL_ALIGN_AFTER_BARRIER(LABEL) (sparc_align_jumps) - -#define LOOP_ALIGN(LABEL) (sparc_align_loops) - #define ASM_OUTPUT_SKIP(FILE,SIZE) \ fprintf (FILE, "\t.skip %u\n", (SIZE)) diff --git a/gcc/final.c b/gcc/final.c index 4134ae3e407..1562dcb05d6 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -797,27 +797,27 @@ get_attr_length (insn) address mod X to one mod Y, which is Y - X. */ #ifndef LABEL_ALIGN -#define LABEL_ALIGN(LABEL) 0 +#define LABEL_ALIGN(LABEL) align_labels_log #endif #ifndef LABEL_ALIGN_MAX_SKIP -#define LABEL_ALIGN_MAX_SKIP 0 +#define LABEL_ALIGN_MAX_SKIP (align_labels-1) #endif #ifndef LOOP_ALIGN -#define LOOP_ALIGN(LABEL) 0 +#define LOOP_ALIGN(LABEL) align_loops_log #endif #ifndef LOOP_ALIGN_MAX_SKIP -#define LOOP_ALIGN_MAX_SKIP 0 +#define LOOP_ALIGN_MAX_SKIP (align_loops-1) #endif #ifndef LABEL_ALIGN_AFTER_BARRIER -#define LABEL_ALIGN_AFTER_BARRIER(LABEL) 0 +#define LABEL_ALIGN_AFTER_BARRIER(LABEL) align_jumps_log #endif #ifndef LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP -#define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP 0 +#define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP (align_jumps-1) #endif #ifndef ADDR_VEC_ALIGN diff --git a/gcc/flags.h b/gcc/flags.h index cbdf9cde151..52914730297 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -507,6 +507,20 @@ extern int g_switch_set; extern int inline_max_insns; +/* Values of the -falign-* flags: how much to align labels in code. + 0 means `use default', 1 means `don't align'. + For each variable, there is an _log variant which is the power + of two not less than the variable, for .align output. */ + +extern int align_loops; +extern int align_loops_log; +extern int align_jumps; +extern int align_jumps_log; +extern int align_labels; +extern int align_labels_log; +extern int align_functions; +extern int align_functions_log; + /* Nonzero if we dump in VCG format, not plain text. */ extern int dump_for_graph; diff --git a/gcc/invoke.texi b/gcc/invoke.texi index cc60c991ec6..84184977466 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -150,18 +150,20 @@ in the following sections. @item Optimization Options @xref{Optimize Options,,Options that Control Optimization}. @smallexample --fbranch-probabilities -foptimize-register-moves +-falign-functions=@var{n} -falign-labels=@var{n} -falign-loops=@var{n} +-falign-jumps=@var{n} -fbranch-probabilities -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -fdelayed-branch -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem --fdata-sections -ffunction-sections -fgcse --finline-functions -finline-limit-@var{n} -fkeep-inline-functions --fno-default-inline -fno-defer-pop -fno-function-cse --fno-inline -fno-peephole -fomit-frame-pointer -fregmove --frerun-cse-after-loop -frerun-loop-opt -fschedule-insns --fschedule-insns2 -fstrength-reduce -fthread-jumps --funroll-all-loops -funroll-loops --fmove-all-movables -freduce-all-givs -fstrict-aliasing +-fdata-sections -ffunction-sections -fgcse +-finline-functions -finline-limit=@var{n} -fkeep-inline-functions +-fmove-all-movables -fno-default-inline -fno-defer-pop +-fno-function-cse -fno-inline -fno-peephole +-fomit-frame-pointer -foptimize-register-moves -fregmove +-frerun-cse-after-loop -frerun-loop-opt -freduce-all-givs +-fschedule-insns -fschedule-insns2 -fstrength-reduce +-fstrict-aliasing -fthread-jumps -funroll-all-loops +-funroll-loops -O -O0 -O1 -O2 -O3 -Os @end smallexample @@ -223,8 +225,6 @@ in the following sections. -mcpu=@var{cpu type} -mtune=@var{cpu type} -mcmodel=@var{code model} --malign-jumps=@var{num} -malign-loops=@var{num} --malign-functions=@var{num} -m32 -m64 -mapp-regs -mbroken-saverestore -mcypress -mepilogue -mflat -mfpu -mhard-float -mhard-quad-float @@ -2336,7 +2336,7 @@ If all calls to a given function are integrated, and the function is declared @code{static}, then the function is normally not output as assembler code in its own right. -@item -finline-limit-@var{n} +@item -finline-limit=@var{n} By default, gcc limits the size of functions that can be inlined. This flag allows the control of this limit for functions that are explicitly marked as inline (ie marked with the inline keyword or defined within the class @@ -2602,6 +2602,53 @@ allowed to alias. For an example, see the C front-end function @code{c_get_alias_set}. @end ifset +@item -falign-functions +@itemx -falign-functions=@var{n} +Align the start of functions to the next power-of-two greater than +@var{n}, skipping up to @var{n} bytes. For instance, +@samp{-falign-functions=32} aligns functions to the next 32-byte +boundary, but @samp{-falign-functions=24} would align to the next +32-byte boundary only if this can be done by skipping 23 bytes or less. + +@samp{-fno-align-functions} and @samp{-falign-functions=1} are +equivalent and mean that functions will not be aligned. + +Some assemblers only support this flag when @var{n} is a power of two; +in that case, it is rounded up. + +If @var{n} is not specified, use a machine-dependent default. + +@item -falign-labels +@itemx -falign-labels=@var{n} +Align all branch targets to a power-of-two boundary, skipping up to +@var{n} bytes like @samp{-falign-functions}. This option can easily +make code slower, because it must insert dummy operations for when the +branch target is reached in the usual flow of the code. + +If @samp{-falign-loops} or @samp{-falign-jumps} are applicable and +are greater than this value, then their values are used instead. + +If @var{n} is not specified, use a machine-dependent default which is +very likely to be @samp{1}, meaning no alignment. + +@item -falign-loops +@itemx -falign-loops=@var{n} +Align loops to a power-of-two boundary, skipping up to @var{n} bytes +like @samp{-falign-functions}. The hope is that the loop will be +executed many times, which will make up for any execution of the dummy +operations. + +If @var{n} is not specified, use a machine-dependent default. + +@item -falign-jumps +@itemx -falign-jumps=@var{n} +Align branch targets to a power-of-two boundary, for branch targets +where the targets can only be reached by jumping, skipping up to @var{n} +bytes like @samp{-falign-functions}. In this case, no dummy operations +need be executed. + +If @var{n} is not specified, use a machine-dependent default. + @end table @node Preprocessor Options @@ -3894,19 +3941,6 @@ select a particular cpu implementation: @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}. -@item -malign-loops=@var{num} -Align loops to a 2 raised to a @var{num} byte boundary. If -@samp{-malign-loops} is not specified, the default is 2. - -@item -malign-jumps=@var{num} -Align instructions that are only jumped to to a 2 raised to a @var{num} -byte boundary. If @samp{-malign-jumps} is not specified, the default is 2. - -@item -malign-functions=@var{num} -Align the start of functions to a 2 raised to @var{num} byte boundary. -If @samp{-malign-functions} is not specified, the default is 2 if compiling -for 32 bit sparc, and 5 if compiling for 64 bit sparc. - @end table These @samp{-m} switches are supported in addition to the above diff --git a/gcc/tm.texi b/gcc/tm.texi index 7bb29279bef..8375908b10c 100644 --- a/gcc/tm.texi +++ b/gcc/tm.texi @@ -6474,6 +6474,18 @@ This macro need not be defined if you don't want any special alignment to be done at such a time. Most machine descriptions do not currently define the macro. +Unless it's necessary to inspect the @var{label} parameter, it is better +to set the variable @var{align_jumps} in the target's +@code{OVERRIDE_OPTIONS}. Otherwise, you should try to honour the user's +selection in @var{align_jumps} in a @code{LABEL_ALIGN_AFTER_BARRIER} +implementation. + +@findex LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP +@item LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP +The maximum number of bytes to skip when applying +@code{LABEL_ALIGN_AFTER_BARRIER}. This works only if +@code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined. + @findex LOOP_ALIGN @item LOOP_ALIGN (@var{label}) The alignment (log base 2) to put in front of @var{label}, which follows @@ -6483,12 +6495,32 @@ This macro need not be defined if you don't want any special alignment to be done at such a time. Most machine descriptions do not currently define the macro. +Unless it's necessary to inspect the @var{label} parameter, it is better +to set the variable @var{align_loops} in the target's +@code{OVERRIDE_OPTIONS}. Otherwise, you should try to honour the user's +selection in @var{align_loops} in a @code{LOOP_ALIGN} implementation. + +@findex LOOP_ALIGN_MAX_SKIP +@item LOOP_ALIGN_MAX_SKIP +The maximum number of bytes to skip when applying @code{LOOP_ALIGN}. +This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined. + @findex LABEL_ALIGN @item LABEL_ALIGN (@var{label}) The alignment (log base 2) to put in front of @var{label}. If LABEL_ALIGN_AFTER_BARRIER / LOOP_ALIGN specify a different alignment, the maximum of the specified values is used. +Unless it's necessary to inspect the @var{label} parameter, it is better +to set the variable @var{align_labels} in the target's +@code{OVERRIDE_OPTIONS}. Otherwise, you should try to honour the user's +selection in @var{align_labels} in a @code{LABEL_ALIGN} implementation. + +@findex LABEL_ALIGN_MAX_SKIP +@item LABEL_ALIGN_MAX_SKIP +The maximum number of bytes to skip when applying @code{LABEL_ALIGN}. +This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined. + @findex ASM_OUTPUT_SKIP @item ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes}) A C statement to output to the stdio stream @var{stream} an assembler diff --git a/gcc/toplev.c b/gcc/toplev.c index a3017b70d3a..ab1cf9ba0c5 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -765,6 +765,20 @@ int flag_no_ident = 0; /* This will perform a peephole pass before sched2. */ int flag_peephole2 = 0; +/* Values of the -falign-* flags: how much to align labels in code. + 0 means `use default', 1 means `don't align'. + For each variable, there is an _log variant which is the power + of two not less than the variable, for .align output. */ + +int align_loops; +int align_loops_log; +int align_jumps; +int align_jumps_log; +int align_labels; +int align_labels_log; +int align_functions; +int align_functions_log; + /* Table of supported debugging formats. */ static struct { @@ -959,6 +973,14 @@ lang_independent_options f_options[] = "Assume arguments do not alias each other or globals" }, {"strict-aliasing", &flag_strict_aliasing, 1, "Assume strict aliasing rules apply" }, + {"align-loops", &align_loops, 0, + "Align the start of loops" }, + {"align-jumps", &align_jumps, 0, + "Align labels which are only reached by jumping" }, + {"align-labels", &align_labels, 0, + "Align all labels" }, + {"align-functions", &align_functions, 0, + "Align the start of functions" }, {"check-memory-usage", &flag_check_memory_usage, 1, "Generate code to check every memory access" }, {"prefix-function-name", &flag_prefix_function_name, 1, @@ -4494,7 +4516,7 @@ display_help () printf (" -ffixed- Mark as being unavailable to the compiler\n"); printf (" -fcall-used- Mark as being corrupted by function calls\n"); printf (" -fcall-saved- Mark as being preserved across functions\n"); - printf (" -finline-limit- Limits the size of inlined functions to \n"); + printf (" -finline-limit= Limits the size of inlined functions to \n"); for (i = NUM_ELEM (f_options); i--;) { @@ -4546,7 +4568,7 @@ display_help () printf (" -d[letters] Enable dumps from specific passes of the compiler\n"); printf (" -dumpbase Base name to be used for dumps from specific passes\n"); #if defined INSN_SCHEDULING - printf (" -sched-verbose- Set the verbosity level of the scheduler\n"); + printf (" -sched-verbose= Set the verbosity level of the scheduler\n"); #endif printf (" --help Display this information\n"); @@ -4865,6 +4887,14 @@ main (argc, argv) flag_inline_functions = 1; } + if (optimize < 2 || optimize_size) + { + align_loops = 1; + align_jumps = 1; + align_labels = 1; + align_functions = 1; + } + /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can modify it. */ target_flags = 0; @@ -5074,11 +5104,12 @@ main (argc, argv) if (found) ; - else if (!strncmp (p, "inline-limit-", 13)) + else if (!strncmp (p, "inline-limit-", 13) + || !strncmp (p, "inline-limit=", 13)) inline_max_insns = read_integral_parameter (p + 13, p - 2, inline_max_insns); #ifdef INSN_SCHEDULING - else if (!strncmp (p, "sched-verbose-",14)) + else if (!strncmp (p, "sched-verbose=",14)) fix_sched_param("verbose",&p[14]); #endif else if (!strncmp (p, "fixed-", 6)) @@ -5087,6 +5118,18 @@ main (argc, argv) fix_register (&p[10], 0, 1); else if (!strncmp (p, "call-saved-", 11)) fix_register (&p[11], 0, 0); + else if (!strncmp (p, "align-loops=", 12)) + align_loops = read_integral_parameter (p + 12, p - 2, + align_loops); + else if (!strncmp (p, "align-functions=", 16)) + align_functions = read_integral_parameter (p + 16, p - 2, + align_functions); + else if (!strncmp (p, "align-jumps=", 12)) + align_jumps = read_integral_parameter (p + 12, p - 2, + align_jumps); + else if (!strncmp (p, "align-labels=", 13)) + align_labels = read_integral_parameter (p + 13, p - 2, + align_labels); else error ("Invalid option `%s'", argv[i]); } @@ -5373,6 +5416,17 @@ main (argc, argv) #endif } + /* Set up the align_*_log variables, defaulting them to 1 if they + were still unset. */ + if (align_loops <= 0) align_loops = 1; + align_loops_log = floor_log2 (align_loops*2-1); + if (align_jumps <= 0) align_jumps = 1; + align_jumps_log = floor_log2 (align_jumps*2-1); + if (align_labels <= 0) align_labels = 1; + align_labels_log = floor_log2 (align_labels*2-1); + if (align_functions <= 0) align_functions = 1; + align_functions_log = floor_log2 (align_functions*2-1); + if (profile_block_flag == 3) { warning ("`-ax' and `-a' are conflicting options. `-a' ignored."); diff --git a/gcc/varasm.c b/gcc/varasm.c index 944d1bb47f3..7110a2e6f2a 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -979,6 +979,19 @@ assemble_start_function (decl, fnname) if (align > 0) ASM_OUTPUT_ALIGN (asm_out_file, align); + /* Handle a user-specified function alignment. + Note that we still need to align to FUNCTION_BOUNDARY, as above, + because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */ + if (align_functions_log > align) + { +#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN + ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file, + align_functions_log, align_functions-1); +#else + ASM_OUTPUT_ALIGN (asm_out_file, align_functions_log); +#endif + } + #ifdef ASM_OUTPUT_FUNCTION_PREFIX ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname); #endif -- 2.11.4.GIT