]> gcc.gnu.org Git - gcc.git/commitdiff
acconfig.h (HAVE_GAS_MAX_SKIP_P2ALIGN): New tag.
authorJohn Wehle <john@feith.com>
Thu, 21 May 1998 19:12:20 +0000 (19:12 +0000)
committerJeff Law <law@gcc.gnu.org>
Thu, 21 May 1998 19:12:20 +0000 (13:12 -0600)
* acconfig.h (HAVE_GAS_MAX_SKIP_P2ALIGN): New tag.
* configure.in: Check for it.
* i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Use it.
* final.c (uid_align, uid_shuid, label_align): Make static.
(label_align): Change type to struct label_alignment pointer.
(LABEL_TO_ALIGNMENT, shorten_branches): Update due to type change.
(LABEL_TO_MAX_SKIP): Define.
(LABEL_ALIGN_MAX_SKIP, LOOP_ALIGN_MAX_SKIP,
LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Provide defaults.
(shorten_branches): Record the maximum bytes to skip when
aligning a label.
(final_scan_insn): Use the maximum bytes to skip when aligning a label
if ASM_OUTPUT_MAX_SKIP_ALIGN is available.
* i386.h (LOOP_ALIGN_MAX_SKIP,
LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Define.
* i386.c (override_options): i386_align_jumps and i386_align_loops
default to 4 if ASM_OUTPUT_MAX_SKIP_ALIGN is available.
* invoke.texi: Document new i386 align-loops and align-jumps behavior.

From-SVN: r19933

gcc/ChangeLog
gcc/acconfig.h
gcc/config.in
gcc/config/i386/gas.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/configure
gcc/configure.in
gcc/final.c
gcc/invoke.texi

index dd1456afafeb0ad31109588e2a8cb2e8836820f8..ba56e08602c5c9868f61f37c1d39d0cced195701 100644 (file)
@@ -1,3 +1,24 @@
+Wed May 20 23:44:28 EDT 1998  John Wehle  (john@feith.com)
+
+       * acconfig.h (HAVE_GAS_MAX_SKIP_P2ALIGN): New tag.
+       * configure.in: Check for it.
+       * i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Use it.
+       * final.c (uid_align, uid_shuid, label_align): Make static.
+       (label_align): Change type to struct label_alignment pointer.
+       (LABEL_TO_ALIGNMENT, shorten_branches): Update due to type change.
+       (LABEL_TO_MAX_SKIP): Define.
+       (LABEL_ALIGN_MAX_SKIP, LOOP_ALIGN_MAX_SKIP,
+       LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Provide defaults.
+       (shorten_branches): Record the maximum bytes to skip when
+       aligning a label.
+       (final_scan_insn): Use the maximum bytes to skip when aligning a label
+       if ASM_OUTPUT_MAX_SKIP_ALIGN is available.
+       * i386.h (LOOP_ALIGN_MAX_SKIP,
+       LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Define.
+       * i386.c (override_options): i386_align_jumps and i386_align_loops
+       default to 4 if ASM_OUTPUT_MAX_SKIP_ALIGN is available.
+       * invoke.texi: Document new i386 align-loops and align-jumps behavior.
+
 1998-05-21  Mark Mitchell  <mmitchell@usa.net>
 
        * cplus-dem.c (do_type): Handle volatile qualification.
index 914fd43b5cf35ff44310212c6b068e83d66418ab..904b7e44750f9d7dc138f82f5224bfbe4e09b597 100644 (file)
 /* Define if your compiler understands volatile.  */
 #undef HAVE_VOLATILE
 
+/* Define if your assembler supports specifying the maximum number
+   of bytes to skip when using the GAS .p2align command. */
+#undef HAVE_GAS_MAX_SKIP_P2ALIGN
+
 /* Define if you have a working <inttypes.h> header file.  */
 #undef HAVE_INTTYPES_H
 
index 9283e71e3c2bfa5f1e2a684eee48267789a89692..38cc36db108994b330be6d27eb2bd37446fa1ed8 100644 (file)
 /* Define if your compiler understands volatile.  */
 #undef HAVE_VOLATILE
 
+/* Define if your assembler supports specifying the maximum number
+   of bytes to skip when using the GAS .p2align command. */
+#undef HAVE_GAS_MAX_SKIP_P2ALIGN
+
 /* Define if you have a working <inttypes.h> header file.  */
 #undef HAVE_INTTYPES_H
 
index 50976cf8bec5cdb04b3c792cda6ae04f4cbd2453..2da338a6518fe4baeb7ceafb0868e27441014081 100644 (file)
@@ -85,6 +85,19 @@ Boston, MA 02111-1307, USA.  */
 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
   if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
 #endif
+
+/* A C statement to output to the stdio stream FILE an assembler
+   command to advance the location counter to a multiple of 1<<LOG
+   bytes if it is within MAX_SKIP bytes.
+
+   This is used to align code labels according to Intel recommendations.  */
+
+#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
+#  define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
+     if ((LOG)!=0) \
+       if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
+       else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
+#endif
 \f
 /* A C statement or statements which output an assembler instruction
    opcode to the stdio stream STREAM.  The macro-operand PTR is a
index 0e332a59c0a8d9d74fbc39620406f2612883113a..da08da1ff8af765e03370c98602fd91e1e29f6ef 100644 (file)
@@ -332,7 +332,11 @@ override_options ()
               i386_align_loops, MAX_CODE_ALIGN);
     }
   else
+#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
+    i386_align_loops = 4;
+#else
     i386_align_loops = 2;
+#endif
 
   /* Validate -malign-jumps= value, or provide default.  */
   if (i386_align_jumps_string)
@@ -343,7 +347,11 @@ override_options ()
               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. */
   if (i386_align_funcs_string)
index b55ffccb986e2a2a3ad2d3e3ed54ba8a4adbb78a..759e5c12a56b0a8cd71c4ab3c8f01fe2a129d7d3 100644 (file)
@@ -506,11 +506,13 @@ extern int ix86_arch;
 
 /* Align loop starts for optimal branching.  */
 #define LOOP_ALIGN(LABEL) (i386_align_loops)
+#define LOOP_ALIGN_MAX_SKIP (i386_align_loops_string ? 0 : 7)
 
 /* This is how to align an instruction for optimal branching.
    On i486 we'll get better performance by aligning on a
    cache line (i.e. 16 byte) boundary.  */
 #define LABEL_ALIGN_AFTER_BARRIER(LABEL) (i386_align_jumps)
+#define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP (i386_align_jumps_string ? 0 : 7)
 
 \f
 /* Standard register usage.  */
index e6eb22fbee5aeab1580c57f7065278c8e9e96575..23757416b8e470dc1405c392103e346b7d8cbda9 100755 (executable)
@@ -5070,6 +5070,53 @@ if [ -f ../ld/Makefile ]; then
 #      fi
 fi
 
+# Figure out what assembler alignment features are present.
+echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6
+echo "configure:5076: checking assembler alignment features" >&5
+gcc_cv_as=
+gcc_cv_as_alignment_features=
+if [ -x as$host_exeext ]; then
+       # Build using assembler in the current directory.
+       gcc_cv_as=./as$host_exeext
+elif [ -f $srcdir/../gas/configure.in ]; then
+       # Single tree build which includes gas.
+       for f in $srcdir/../gas/configure.in $srcdir/../gas/Makefile.in
+       do
+               gcc_cv_gas_version=`grep '^VERSION=[0-9]*\.[0-9]*' $f`
+               if [ x$gcc_cv_gas_version != x ]; then
+                       break
+               fi
+       done
+       gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([0-9]*\)"`
+       gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
+       # Gas version 2.8 and later support specifying the maximum
+       # bytes to skip when using .p2align.
+       if [ "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 8 -o "$gcc_cv_gas_major_version" -gt 2 ]; then
+               gcc_cv_as_alignment_features=".p2align including maximum skip"
+               cat >> confdefs.h <<\EOF
+#define HAVE_GAS_MAX_SKIP_P2ALIGN 1
+EOF
+
+       fi
+elif [ x$host = x$target ]; then
+       # Native build.
+       gcc_cv_as=as$host_exeext
+fi
+if [ x$gcc_cv_as != x ]; then
+       # Check if specifying the maximum bytes to skip when
+       # using .p2align is supported.
+       echo ".p2align 4,,7" > conftest.s
+       if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+               gcc_cv_as_alignment_features=".p2align including maximum skip"
+               cat >> confdefs.h <<\EOF
+#define HAVE_GAS_MAX_SKIP_P2ALIGN 1
+EOF
+
+       fi
+       rm -f conftest.s conftest.o
+fi
+echo "$ac_t""$gcc_cv_as_alignment_features" 1>&6
+
 # Figure out what language subdirectories are present.
 subdirs=
 for lang in ${srcdir}/*/config-lang.in ..
index 5728efca104c67fa4c10e3808de37fe7634939cd..bb6b46c773e14d243808d39b6be3f7ae72164afe 100644 (file)
@@ -3226,6 +3226,46 @@ if [[ -f ../ld/Makefile ]]; then
 #      fi
 fi
 
+# Figure out what assembler alignment features are present.
+AC_MSG_CHECKING(assembler alignment features)
+gcc_cv_as=
+gcc_cv_as_alignment_features=
+if [[ -x as$host_exeext ]]; then
+       # Build using assembler in the current directory.
+       gcc_cv_as=./as$host_exeext
+elif [[ -f $srcdir/../gas/configure.in ]]; then
+       # Single tree build which includes gas.
+       for f in $srcdir/../gas/configure.in $srcdir/../gas/Makefile.in
+       do
+               gcc_cv_gas_version=`grep '^VERSION=[[0-9]]*\.[[0-9]]*' $f`
+               if [[ x$gcc_cv_gas_version != x ]]; then
+                       break
+               fi
+       done
+       gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([[0-9]]*\)"`
+       gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.\([[0-9]]*\)"`
+       # Gas version 2.8 and later support specifying the maximum
+       # bytes to skip when using .p2align.
+       if [[ "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 8 -o "$gcc_cv_gas_major_version" -gt 2 ]]; then
+               gcc_cv_as_alignment_features=".p2align including maximum skip"
+               AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN)
+       fi
+elif [[ x$host = x$target ]]; then
+       # Native build.
+       gcc_cv_as=as$host_exeext
+fi
+if [[ x$gcc_cv_as != x ]]; then
+       # Check if specifying the maximum bytes to skip when
+       # using .p2align is supported.
+       echo ".p2align 4,,7" > conftest.s
+       if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+               gcc_cv_as_alignment_features=".p2align including maximum skip"
+               AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN)
+       fi
+       rm -f conftest.s conftest.o
+fi
+AC_MSG_RESULT($gcc_cv_as_alignment_features)
+
 # Figure out what language subdirectories are present.
 subdirs=
 for lang in ${srcdir}/*/config-lang.in ..
index 9dac1376851ee1fae5e17ff3096d9c449f007eaa..f6f6670f17456fcf473e47a54715f1789b2167b0 100644 (file)
@@ -649,9 +649,14 @@ int insn_current_align;
    for each insn we'll call the alignment chain of this insn in the following
    comments.  */
 
-rtx *uid_align;
-int *uid_shuid;
-short *label_align;
+struct label_alignment {
+  short alignment;
+  short max_skip;
+};
+
+static rtx *uid_align;
+static int *uid_shuid;
+static struct label_alignment *label_align;
 
 /* Indicate that branch shortening hasn't yet been done.  */
 
@@ -794,14 +799,26 @@ get_attr_length (insn)
 #define LABEL_ALIGN(LABEL) 0
 #endif
 
+#ifndef LABEL_ALIGN_MAX_SKIP
+#define LABEL_ALIGN_MAX_SKIP 0
+#endif
+
 #ifndef LOOP_ALIGN
 #define LOOP_ALIGN(LABEL) 0
 #endif
 
+#ifndef LOOP_ALIGN_MAX_SKIP
+#define LOOP_ALIGN_MAX_SKIP 0
+#endif
+
 #ifndef LABEL_ALIGN_AFTER_BARRIER
 #define LABEL_ALIGN_AFTER_BARRIER(LABEL) 0
 #endif
 
+#ifndef LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
+#define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP 0
+#endif
+
 #ifndef ADDR_VEC_ALIGN
 int
 final_addr_vec_align (addr_vec)
@@ -826,7 +843,10 @@ final_addr_vec_align (addr_vec)
 static int min_labelno, max_labelno;
 
 #define LABEL_TO_ALIGNMENT(LABEL) \
-  (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno])
+  (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].alignment)
+
+#define LABEL_TO_MAX_SKIP(LABEL) \
+  (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].max_skip)
 
 /* For the benefit of port specific code do this also as a function.  */
 int
@@ -962,6 +982,7 @@ shorten_branches (first)
   int max_uid;
   int i;
   int max_log;
+  int max_skip;
 #ifdef HAVE_ATTR_length
 #define MAX_CODE_ALIGN 16
   rtx seq;
@@ -1001,10 +1022,10 @@ shorten_branches (first)
 
   max_labelno = max_label_num ();
   min_labelno = get_first_label_num ();
-  label_align
-    = (short*) xmalloc ((max_labelno - min_labelno + 1) * sizeof (short));
-  bzero ((char *) label_align,
-        (max_labelno - min_labelno + 1) * sizeof (short));
+  label_align = (struct label_alignment *) xmalloc (
+    (max_labelno - min_labelno + 1) * sizeof (struct label_alignment));
+  bzero (label_align,
+    (max_labelno - min_labelno + 1) * sizeof (struct label_alignment));
 
   uid_shuid = (int *) xmalloc (max_uid * sizeof *uid_shuid);
 
@@ -1014,7 +1035,10 @@ shorten_branches (first)
      impose on the next CODE_LABEL (or the current one if we are processing
      the CODE_LABEL itself).  */
      
-  for (max_log = 0, insn = get_insns (), i = 1; insn; insn = NEXT_INSN (insn))
+  max_log = 0;
+  max_skip = 0;
+
+  for (insn = get_insns (), i = 1; insn; insn = NEXT_INSN (insn))
     {
       int log;
 
@@ -1033,7 +1057,10 @@ shorten_branches (first)
 
          log = LABEL_ALIGN (insn);
          if (max_log < log)
-           max_log = log;
+           {
+             max_log = log;
+             max_skip = LABEL_ALIGN_MAX_SKIP;
+           }
          next = NEXT_INSN (insn);
 /* ADDR_VECs only take room if read-only data goes into the text section.  */
 #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
@@ -1045,12 +1072,17 @@ shorten_branches (first)
                {
                  log = ADDR_VEC_ALIGN (next);
                  if (max_log < log)
-                   max_log = log;
+                   {
+                     max_log = log;
+                     max_skip = LABEL_ALIGN_MAX_SKIP;
+                   }
                }
            }
 #endif
          LABEL_TO_ALIGNMENT (insn) = max_log;
+         LABEL_TO_MAX_SKIP (insn) = max_skip;
          max_log = 0;
+         max_skip = 0;
        }
       else if (GET_CODE (insn) == BARRIER)
        {
@@ -1062,7 +1094,10 @@ shorten_branches (first)
              {
                log = LABEL_ALIGN_AFTER_BARRIER (insn);
                if (max_log < log)
-                 max_log = log;
+                 {
+                   max_log = log;
+                   max_skip = LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP;
+                 }
                break;
              }
        }
@@ -1078,7 +1113,10 @@ shorten_branches (first)
              {
                log = LOOP_ALIGN (insn);
                if (max_log < log)
-                 max_log = log;
+                 {
+                   max_log = log;
+                   max_skip = LOOP_ALIGN_MAX_SKIP;
+                 }
                break;
              }
        }
@@ -2222,9 +2260,14 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
       if (CODE_LABEL_NUMBER (insn) <= max_labelno)
        {
          int align = LABEL_TO_ALIGNMENT (insn);
+         int max_skip = LABEL_TO_MAX_SKIP (insn);
 
          if (align && NEXT_INSN (insn))
+#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
+           ASM_OUTPUT_MAX_SKIP_ALIGN (file, align, max_skip);
+#else
            ASM_OUTPUT_ALIGN (file, align);
+#endif
        }
       CC_STATUS_INIT;
       if (prescan > 0)
index 2289f3c543d6a8de45fae87bf9cfb411405979c1..4d1a413717d61ad395990ba688039f3bf69ba32e 100644 (file)
@@ -4905,12 +4905,18 @@ startup modules.
 
 @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.
+@samp{-malign-loops} is not specified, the default is 2 unless
+gas 2.8 (or later) is being used in which case the default is
+to align the loop on a 16 byte boundary if it is less than 8
+bytes away.
 
 @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 if optimizing for a 386, and 4 if optimizing for a 486.
+2 if optimizing for a 386, and 4 if optimizing for a 486 unless
+gas 2.8 (or later) is being used in which case the default is
+to align the instruction on a 16 byte boundary if it is less
+than 8 bytes away.
 
 @item -malign-functions=@var{num}
 Align the start of functions to a 2 raised to @var{num} byte boundary.
This page took 0.093284 seconds and 5 git commands to generate.