PATCH: Add -n option to i386 assembler

H. J. Lu hjl@lucon.org
Tue Jun 10 06:17:00 GMT 2003


On Tue, Jun 10, 2003 at 11:06:05AM +0930, Alan Modra wrote:
> On Mon, Jun 09, 2003 at 10:09:59AM -0700, H. J. Lu wrote:
> > +* A new command line option for the i386 assembler, -n,  will turn off
> > +  code alignment optimization.
> 
> "turn off code alignment optimization" doesn't really say what this
> switch does.  I suggest:
> 
> * Added -n switch for x86 assembler.  By default, x86 GAS replaces
>   multiple nop instructions used for alignment within code sections with
>   multi-byte nop instructions such as leal 0(%esi,1),%esi.  This switch
>   disables the optimization.
> 
> > +extern int optimize_align_code;
> > +
> >  #define md_do_align(n, fill, len, max, around)				\
> >  if ((n) && !need_pass_2							\
> > -    && (!(fill) || ((char)*(fill) == (char)0x90 && (len) == 1))		\
> > +    && (!(fill)								\
> > +	|| (optimize_align_code						\
> > +	    && (char)*(fill) == (char)0x90				\
> > +	    && (len) == 1))						\
> >      && subseg_text_p (now_seg))						\
> >    {									\
> >      frag_align_code ((n), (max));					\
> 
> Looks wrong to me.  Surely optimize_align_code should affect the
> !(fill) case too?  You should also fix the formatting.
> 
> > --- gas/doc/c-i386.texi.nop	2001-03-09 11:17:14.000000000 -0800
> > +++ gas/doc/c-i386.texi	2003-06-09 09:55:10.000000000 -0700
> > @@ -61,6 +61,10 @@ These options are only available with th
> >  require that the necessary BFD support has been included (on a 32-bit
> >  platform you have to add --enable-64-bit-bfd to configure enable 64-bit
> >  usage and use x86-64 as target platform).
> > +
> > +@item -n
> > +When this option is used, code alignment optimization will be turned
> > +off.
> >  @end table
> >  
> >  @node i386-Syntax
> 
> Use the expanded description here too.
> 

Here is the new one.

Thanks.


H.J.
-------------- next part --------------
2003-06-09  H.J. Lu <hongjiu.lu@intel.com>

	* NEWS: Updated for the new -n option for the i386 assembler.

	* config/tc-i386.c (optimize_align_code): New.
	(md_shortopts): Add 'n'.
	(md_parse_option): Handle 'n'.
	(md_show_usage): Add '-n'.

	* config/tc-i386.h (optimize_align_code): Declared.
	(md_do_align): Optimize code alignment only if optimize_align_code
	is not 0.

	* doc/as.texinfo: Add the new -n option.

	* doc/c-i386.texi: Document the new -n option.

	* doc/as.1: Regenerated.

--- gas/NEWS.nop	2003-04-28 07:48:50.000000000 -0700
+++ gas/NEWS	2003-06-09 23:05:10.000000000 -0700
@@ -1,5 +1,10 @@
 -*- text -*-
 
+* Added -n switch for x86 assembler.  By default, x86 GAS replaces
+  multiple nop instructions used for alignment within code sections
+  with multi-byte nop instructions such as leal 0(%esi,1),%esi.  This
+  switch disables the optimization.
+
 * Added support for MIPS32 Release 2.
 
 * Added support for Xtensa architecture.
--- gas/config/tc-i386.c.nop	2003-06-08 17:42:05.000000000 -0700
+++ gas/config/tc-i386.c	2003-06-09 09:46:45.000000000 -0700
@@ -303,6 +303,9 @@ static int allow_naked_reg = 0;
    frame as in 32 bit mode.  */
 static char stackop_size = '\0';
 
+/* Non-zero to optimize code alignment.  */
+int optimize_align_code = 1;
+
 /* Non-zero to quieten some warnings.  */
 static int quiet_warnings = 0;
 
@@ -4904,9 +4907,9 @@ parse_register (reg_string, end_op)
 }
 
 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-const char *md_shortopts = "kVQ:sq";
+const char *md_shortopts = "kVQ:sqn";
 #else
-const char *md_shortopts = "q";
+const char *md_shortopts = "qn";
 #endif
 
 struct option md_longopts[] = {
@@ -4927,6 +4930,10 @@ md_parse_option (c, arg)
 {
   switch (c)
     {
+    case 'n':
+      optimize_align_code = 0;
+      break;
+
     case 'q':
       quiet_warnings = 1;
       break;
@@ -4988,10 +4995,12 @@ md_show_usage (stream)
   -Q                      ignored\n\
   -V                      print assembler version number\n\
   -k                      ignored\n\
+  -n                      Do not optimize code alignment\n\
   -q                      quieten some warnings\n\
   -s                      ignored\n"));
 #else
   fprintf (stream, _("\
+  -n                      Do not optimize code alignment\n\
   -q                      quieten some warnings\n"));
 #endif
 }
--- gas/config/tc-i386.h.nop	2003-06-08 17:42:05.000000000 -0700
+++ gas/config/tc-i386.h	2003-06-09 23:15:30.000000000 -0700
@@ -517,8 +517,12 @@ extern int tc_i386_fix_adjustable PARAMS
 extern const struct relax_type md_relax_table[];
 #define TC_GENERIC_RELAX_TABLE md_relax_table
 
+extern int optimize_align_code;
+
 #define md_do_align(n, fill, len, max, around)				\
-if ((n) && !need_pass_2							\
+if ((n)									\
+    && !need_pass_2							\
+    && optimize_align_code						\
     && (!(fill) || ((char)*(fill) == (char)0x90 && (len) == 1))		\
     && subseg_text_p (now_seg))						\
   {									\
--- gas/doc/as.texinfo.nop	2003-06-08 17:41:37.000000000 -0700
+++ gas/doc/as.texinfo	2003-06-09 10:00:20.000000000 -0700
@@ -332,7 +332,7 @@ gcc(1), ld(1), and the Info entries for 
 @ifset I80386
 
 @emph{Target i386 options:}
-   [@b{--32}|@b{--64}]
+   [@b{--32}|@b{--64}] [@b{-n}]
 @end ifset
 @ifset I960
 
--- gas/doc/c-i386.texi.nop	2001-03-09 11:17:14.000000000 -0800
+++ gas/doc/c-i386.texi	2003-06-09 23:07:16.000000000 -0700
@@ -61,6 +61,11 @@ These options are only available with th
 require that the necessary BFD support has been included (on a 32-bit
 platform you have to add --enable-64-bit-bfd to configure enable 64-bit
 usage and use x86-64 as target platform).
+
+@item -n
+By default, x86 GAS replaces multiple nop instructions used for
+alignment within code sections with multi-byte nop instructions such
+as leal 0(%esi,1),%esi.  This switch disables the optimization.
 @end table
 
 @node i386-Syntax


More information about the Binutils mailing list