This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] x86: Add .nop directive to assembler


On Mon, Feb 19, 2018 at 4:05 PM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Feb 19, 2018 at 03:24:17PM -0800, H.J. Lu wrote:
>> On Mon, Feb 19, 2018 at 3:19 PM, Alan Modra <amodra@gmail.com> wrote:
>> > On Mon, Feb 19, 2018 at 10:08:38PM +0000, Maciej W. Rozycki wrote:
>> >> On Mon, 19 Feb 2018, Alan Modra wrote:
>> >>
>> >> > > .nop is similar to .skip, except that it fills with NOPs.  Yes, it can be used
>> >> > > wherever .skip can be used.
>> >> >
>> >> > Given https://sourceware.org/ml/binutils/2018-02/msg00322.html I'm
>> >> > inclined to think the name of the directive should change.
>> >> > .skipnops perhaps?
>> >>
>> >>  Just `.nops' maybe?  There doesn't appear to be any matching mnemonic in
>> >> opcodes/.
>> >
>> > I'd be happy with that too.
>>
>> There is no guarantee that one of those NO_PSEUDO_DOT targets or the new
>> NO_PSEUDO_DOT target won't have an instruction called nops or skipnops in
>> the future.
>
> If a target adds an instruction like that, then the target will need
> to deal with it.  For example, as the spu target deals with "set" and
> "equ" which existed as directives before the spu defined them as
> instructions.
>
> In this case the use of "nop" as an instruction existed before you
> decided to define ".nop" as a directive, and lack of testing resulted
> in not discovering the NO_PSEUDO_DOT clash.  I suspect we wouldn't be
> having this conversation if you had run a full test suite regression,
> rather than just testing x86.  You yourself would have chosen
> something other than ".nop" as a directive!

I would have chosen .nop and handled it for NO_PSEUDO_DOT targets.

Here is a patch to rename .nop to .nops.  OK for master?

-- 
H.J.
From eb81600ebb30f513732e395c524bcc9dca4de00a Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 19 Feb 2018 16:53:28 -0800
Subject: [PATCH] Rename .nop directive to .nops

Since directives of NO_PSEUDO_DOT targets don't have the leading '.'
and "nop" can be a valid instruction, rename .nop directive to .nops
to avoid conflict.

	* NEWS: Rename .nop to .nops.
	* doc/as.texinfo: Likewise.
	* read.c (potable): Add "nops".  Remove "nop".
	(s_nop): Renamed to ...
	(s_nops): This.
	* read.h (s_nop): Renamed to ...
	(s_nops): This.
	* write.c (cvt_frag_to_fill): Rename .nop to .nops.
	(md_generate_nops): Likewise.
	(relax_segment): Likewise.
	* testsuite/gas/i386/nop-1.d: Updated.
	* testsuite/gas/i386/nop-1.s: Likewise.
	* testsuite/gas/i386/nop-2.d: Likewise.
	* testsuite/gas/i386/nop-2.s: Likewise.
	* testsuite/gas/i386/nop-3.d: Likewise.
	* testsuite/gas/i386/nop-3.s: Likewise.
	* testsuite/gas/i386/nop-4.d: Likewise.
	* testsuite/gas/i386/nop-4.s: Likewise.
	* testsuite/gas/i386/nop-5.d: Likewise.
	* testsuite/gas/i386/nop-5.s: Likewise.
	* testsuite/gas/i386/nop-6.d: Likewise.
	* testsuite/gas/i386/nop-6.s: Likewise.
	* testsuite/gas/i386/nop-bad-1.l: Likewise.
	* testsuite/gas/i386/nop-bad-1.s: Likewise.
	* testsuite/gas/i386/x86-64-nop-1.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-2.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-3.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-4.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-5.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-6.d: Likewise.
---
 gas/NEWS                              |  2 +-
 gas/doc/as.texinfo                    |  8 ++++----
 gas/read.c                            |  6 +++---
 gas/read.h                            |  2 +-
 gas/testsuite/gas/i386/nop-1.d        |  2 +-
 gas/testsuite/gas/i386/nop-1.s        | 12 ++++++------
 gas/testsuite/gas/i386/nop-2.d        |  2 +-
 gas/testsuite/gas/i386/nop-2.s        | 12 ++++++------
 gas/testsuite/gas/i386/nop-3.d        |  2 +-
 gas/testsuite/gas/i386/nop-3.s        |  2 +-
 gas/testsuite/gas/i386/nop-4.d        |  2 +-
 gas/testsuite/gas/i386/nop-4.s        |  2 +-
 gas/testsuite/gas/i386/nop-5.d        |  2 +-
 gas/testsuite/gas/i386/nop-5.s        |  2 +-
 gas/testsuite/gas/i386/nop-6.d        |  2 +-
 gas/testsuite/gas/i386/nop-6.s        |  2 +-
 gas/testsuite/gas/i386/nop-bad-1.l    |  2 +-
 gas/testsuite/gas/i386/nop-bad-1.s    |  6 +++---
 gas/testsuite/gas/i386/x86-64-nop-1.d |  2 +-
 gas/testsuite/gas/i386/x86-64-nop-2.d |  2 +-
 gas/testsuite/gas/i386/x86-64-nop-3.d |  2 +-
 gas/testsuite/gas/i386/x86-64-nop-4.d |  2 +-
 gas/testsuite/gas/i386/x86-64-nop-5.d |  2 +-
 gas/testsuite/gas/i386/x86-64-nop-6.d |  2 +-
 gas/write.c                           |  6 +++---
 25 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/gas/NEWS b/gas/NEWS
index 27ee306f2f..c5b5e1c141 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -1,6 +1,6 @@
 -*- text -*-
 
-* Add support for .nop directive.  It is currently supported only for
+* Add support for .nops directive.  It is currently supported only for
   x86 targets.
 
 Changes in 2.30:
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index 3084bcb871..5bae3fd643 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -4479,7 +4479,7 @@ Some machine configurations provide additional directives.
 * MRI::				@code{.mri @var{val}}
 * Noaltmacro::                  @code{.noaltmacro}
 * Nolist::                      @code{.nolist}
-* Nop::                         @code{.nop @var{size}[, @var{control}]}
+* Nops::                        @code{.nops @var{size}[, @var{control}]}
 * Octa::                        @code{.octa @var{bignums}}
 * Offset::			@code{.offset @var{loc}}
 * Org::                         @code{.org @var{new-lc}, @var{fill}}
@@ -6102,10 +6102,10 @@ internal counter (which is zero initially).   @code{.list} increments the
 counter, and @code{.nolist} decrements it.  Assembly listings are
 generated whenever the counter is greater than zero.
 
-@node Nop
-@section @code{.nop @var{size}[, @var{control}]}
+@node Nops
+@section @code{.nops @var{size}[, @var{control}]}
 
-@cindex @code{nop} directive
+@cindex @code{nops} directive
 @cindex filling memory with no-op instructions
 This directive emits @var{size} bytes filled with no-op instructions.
 @var{size} is absolute expression, which must be a positve value.
diff --git a/gas/read.c b/gas/read.c
index 9ab88f8962..ff78caef38 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -417,6 +417,7 @@ static const pseudo_typeS potable[] = {
   {"noformat", s_ignore, 0},
   {"nolist", listing_list, 0},	/* Turn listing off.  */
   {"nopage", listing_nopage, 0},
+  {"nops", s_nops, 0},
   {"octa", cons, 16},
   {"offset", s_struct, 0},
   {"org", s_org, 0},
@@ -442,7 +443,6 @@ static const pseudo_typeS potable[] = {
 /* size  */
   {"space", s_space, 0},
   {"skip", s_space, 0},
-  {"nop", s_nop, 0},
   {"sleb128", s_leb128, 1},
   {"spc", s_ignore, 0},
   {"stabd", s_stab, 'd'},
@@ -3510,7 +3510,7 @@ s_space (int mult)
 }
 
 void
-s_nop (int ignore ATTRIBUTE_UNUSED)
+s_nops (int ignore ATTRIBUTE_UNUSED)
 {
   expressionS exp;
   expressionS val;
@@ -3556,7 +3556,7 @@ s_nop (int ignore ATTRIBUTE_UNUSED)
 	}
     }
   else
-    as_bad (_("unsupported variable nop control in .nop directive"));
+    as_bad (_("unsupported variable nop control in .nops directive"));
 
   demand_empty_rest_of_line ();
 }
diff --git a/gas/read.h b/gas/read.h
index 3f0927bc9e..352b802d4a 100644
--- a/gas/read.h
+++ b/gas/read.h
@@ -206,7 +206,7 @@ extern void s_purgem (int);
 extern void s_rept (int);
 extern void s_set (int);
 extern void s_space (int mult);
-extern void s_nop (int);
+extern void s_nops (int);
 extern void s_stab (int what);
 extern void s_struct (int);
 extern void s_text (int);
diff --git a/gas/testsuite/gas/i386/nop-1.d b/gas/testsuite/gas/i386/nop-1.d
index 46422c88db..5a9e03ef19 100644
--- a/gas/testsuite/gas/i386/nop-1.d
+++ b/gas/testsuite/gas/i386/nop-1.d
@@ -1,5 +1,5 @@
 #objdump: -drw
-#name: i386 .nop 1
+#name: i386 .nops 1
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/nop-1.s b/gas/testsuite/gas/i386/nop-1.s
index 891783dce8..94ec28e815 100644
--- a/gas/testsuite/gas/i386/nop-1.s
+++ b/gas/testsuite/gas/i386/nop-1.s
@@ -1,21 +1,21 @@
        .text
 single:
-	.nop 0
+	.nops 0
 	nop
 
 pseudo_1:
-	.nop 1
+	.nops 1
 
 pseudo_8:
-	.nop 8
+	.nops 8
 
 pseudo_8_4:
-	.nop 8, 4
+	.nops 8, 4
 
 pseudo_20:
-	.nop 20
+	.nops 20
 
 pseudo_30:
-	.nop 30
+	.nops 30
 
 	xor %eax, %eax
diff --git a/gas/testsuite/gas/i386/nop-2.d b/gas/testsuite/gas/i386/nop-2.d
index 332b990a97..d248fd1df7 100644
--- a/gas/testsuite/gas/i386/nop-2.d
+++ b/gas/testsuite/gas/i386/nop-2.d
@@ -1,5 +1,5 @@
 #objdump: -drw -Mi8086
-#name: i386 .nop 2
+#name: i386 .nops 2
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/nop-2.s b/gas/testsuite/gas/i386/nop-2.s
index 2b71b9786d..9f7a3729c0 100644
--- a/gas/testsuite/gas/i386/nop-2.s
+++ b/gas/testsuite/gas/i386/nop-2.s
@@ -1,22 +1,22 @@
        .text
        .code16
 single:
-	.nop 0
+	.nops 0
 	nop
 
 pseudo_1:
-	.nop 1
+	.nops 1
 
 pseudo_8:
-	.nop 8
+	.nops 8
 
 pseudo_8_4:
-	.nop 8, 4
+	.nops 8, 4
 
 pseudo_20:
-	.nop 20
+	.nops 20
 
 pseudo_30:
-	.nop 30
+	.nops 30
 
 	xor %eax, %eax
diff --git a/gas/testsuite/gas/i386/nop-3.d b/gas/testsuite/gas/i386/nop-3.d
index bebd24bc08..b2b4577b55 100644
--- a/gas/testsuite/gas/i386/nop-3.d
+++ b/gas/testsuite/gas/i386/nop-3.d
@@ -1,5 +1,5 @@
 #objdump: -drw
-#name: i386 .nop 3
+#name: i386 .nops 3
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/nop-3.s b/gas/testsuite/gas/i386/nop-3.s
index 57370ff579..0a6bb58fdf 100644
--- a/gas/testsuite/gas/i386/nop-3.s
+++ b/gas/testsuite/gas/i386/nop-3.s
@@ -4,7 +4,7 @@ _start:
 140:
 	testl %eax, %eax
 141:
-	.nop -(((144f-143f)-(141b-140b)) > 0)*((144f-143f)-(141b-140b)),7
+	.nops -(((144f-143f)-(141b-140b)) > 0)*((144f-143f)-(141b-140b)),7
 142:
 	xor %eax, %eax
 	.pushsection .altinstr_replacement,"ax"
diff --git a/gas/testsuite/gas/i386/nop-4.d b/gas/testsuite/gas/i386/nop-4.d
index 99ddcd3994..b548d079a3 100644
--- a/gas/testsuite/gas/i386/nop-4.d
+++ b/gas/testsuite/gas/i386/nop-4.d
@@ -1,5 +1,5 @@
 #objdump: -drw
-#name: i386 .nop 4
+#name: i386 .nops 4
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/nop-4.s b/gas/testsuite/gas/i386/nop-4.s
index f7aa11187e..4f0bfe6dc3 100644
--- a/gas/testsuite/gas/i386/nop-4.s
+++ b/gas/testsuite/gas/i386/nop-4.s
@@ -4,7 +4,7 @@ _start:
 140:
 	testl %eax, %eax
 141:
-	.nop -(((144f-143f)-(141b-140b)) > 0)*((144f-143f)-(141b-140b))
+	.nops -(((144f-143f)-(141b-140b)) > 0)*((144f-143f)-(141b-140b))
 142:
 	xor %eax, %eax
 	.pushsection .altinstr_replacement,"ax"
diff --git a/gas/testsuite/gas/i386/nop-5.d b/gas/testsuite/gas/i386/nop-5.d
index aab4258b19..6a4791344f 100644
--- a/gas/testsuite/gas/i386/nop-5.d
+++ b/gas/testsuite/gas/i386/nop-5.d
@@ -1,5 +1,5 @@
 #objdump: -drw
-#name: i386 .nop 5
+#name: i386 .nops 5
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/nop-5.s b/gas/testsuite/gas/i386/nop-5.s
index 4f563ce82f..d91f81fb09 100644
--- a/gas/testsuite/gas/i386/nop-5.s
+++ b/gas/testsuite/gas/i386/nop-5.s
@@ -4,7 +4,7 @@ _start:
 140:
 	testl %eax, %eax
 141:
-	.nop -(((144f-143f)-(141b-140b)) > 0)*((144f-143f)-(141b-140b)),6
+	.nops -(((144f-143f)-(141b-140b)) > 0)*((144f-143f)-(141b-140b)),6
 142:
 	xor %eax, %eax
 	.pushsection .altinstr_replacement,"ax"
diff --git a/gas/testsuite/gas/i386/nop-6.d b/gas/testsuite/gas/i386/nop-6.d
index 93ee8def03..851c129c4a 100644
--- a/gas/testsuite/gas/i386/nop-6.d
+++ b/gas/testsuite/gas/i386/nop-6.d
@@ -1,5 +1,5 @@
 #objdump: -drw
-#name: i386 .nop 6
+#name: i386 .nops 6
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/nop-6.s b/gas/testsuite/gas/i386/nop-6.s
index c7b1e2cbf0..d8952c9a43 100644
--- a/gas/testsuite/gas/i386/nop-6.s
+++ b/gas/testsuite/gas/i386/nop-6.s
@@ -1,5 +1,5 @@
 .macro mknops nr_bytes
-    .nop \nr_bytes, 9
+    .nops \nr_bytes, 9
 .endm
 
 .macro ALTERNATIVE
diff --git a/gas/testsuite/gas/i386/nop-bad-1.l b/gas/testsuite/gas/i386/nop-bad-1.l
index 34be496b4b..2ae5b48453 100644
--- a/gas/testsuite/gas/i386/nop-bad-1.l
+++ b/gas/testsuite/gas/i386/nop-bad-1.l
@@ -1,4 +1,4 @@
 .*: Assembler messages:
 .*:2: Warning: negative nop control byte, ignored
-.*:4: Warning: \.space, \.nop or \.fill with negative value, ignored
+.*:4: Warning: \.space, \.nops or \.fill with negative value, ignored
 .*:3: Error: invalide single nop size: 20 \(expect within \[0, [0-9]+\]\)
diff --git a/gas/testsuite/gas/i386/nop-bad-1.s b/gas/testsuite/gas/i386/nop-bad-1.s
index 53cc7d554a..2f2bbfb9fd 100644
--- a/gas/testsuite/gas/i386/nop-bad-1.s
+++ b/gas/testsuite/gas/i386/nop-bad-1.s
@@ -1,4 +1,4 @@
 	.text
-        .nop 100, -2
-        .nop 100, 20
-        .nop -1
+        .nops 100, -2
+        .nops 100, 20
+        .nops -1
diff --git a/gas/testsuite/gas/i386/x86-64-nop-1.d b/gas/testsuite/gas/i386/x86-64-nop-1.d
index f3edc7d346..ec6263b49d 100644
--- a/gas/testsuite/gas/i386/x86-64-nop-1.d
+++ b/gas/testsuite/gas/i386/x86-64-nop-1.d
@@ -1,6 +1,6 @@
 #source: nop-1.s
 #objdump: -drw
-#name: x86-64 .nop 1
+#name: x86-64 .nops 1
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/x86-64-nop-2.d b/gas/testsuite/gas/i386/x86-64-nop-2.d
index e894d2c7bf..438e4f84f2 100644
--- a/gas/testsuite/gas/i386/x86-64-nop-2.d
+++ b/gas/testsuite/gas/i386/x86-64-nop-2.d
@@ -1,6 +1,6 @@
 #source: nop-2.s
 #objdump: -drw -Mi8086
-#name: x86-64 .nop 2
+#name: x86-64 .nops 2
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/x86-64-nop-3.d b/gas/testsuite/gas/i386/x86-64-nop-3.d
index b43239af6f..1dc9505b4f 100644
--- a/gas/testsuite/gas/i386/x86-64-nop-3.d
+++ b/gas/testsuite/gas/i386/x86-64-nop-3.d
@@ -1,6 +1,6 @@
 #source: nop-3.s
 #objdump: -drw
-#name: x86-64 .nop 3
+#name: x86-64 .nops 3
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/x86-64-nop-4.d b/gas/testsuite/gas/i386/x86-64-nop-4.d
index a910171303..25927ca222 100644
--- a/gas/testsuite/gas/i386/x86-64-nop-4.d
+++ b/gas/testsuite/gas/i386/x86-64-nop-4.d
@@ -1,6 +1,6 @@
 #source: nop-4.s
 #objdump: -drw
-#name: x86-64 .nop 4
+#name: x86-64 .nops 4
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/x86-64-nop-5.d b/gas/testsuite/gas/i386/x86-64-nop-5.d
index 57493cf6dc..a609a1254b 100644
--- a/gas/testsuite/gas/i386/x86-64-nop-5.d
+++ b/gas/testsuite/gas/i386/x86-64-nop-5.d
@@ -1,6 +1,6 @@
 #source: nop-5.s
 #objdump: -drw
-#name: x86-64 .nop 5
+#name: x86-64 .nops 5
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/x86-64-nop-6.d b/gas/testsuite/gas/i386/x86-64-nop-6.d
index 520f590945..63f3817148 100644
--- a/gas/testsuite/gas/i386/x86-64-nop-6.d
+++ b/gas/testsuite/gas/i386/x86-64-nop-6.d
@@ -1,6 +1,6 @@
 #source: nop-6.s
 #objdump: -drw
-#name: x86-64 .nop 6
+#name: x86-64 .nops 6
 
 .*: +file format .*
 
diff --git a/gas/write.c b/gas/write.c
index 9b14fda156..4c8e42b4b4 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -453,7 +453,7 @@ skip_align:
       if (fragP->fr_offset < 0)
 	{
 	  as_bad_where (fragP->fr_file, fragP->fr_line,
-			_("attempt to .org/.space/.nop backwards? (%ld)"),
+			_("attempt to .org/.space/.nops backwards? (%ld)"),
 			(long) fragP->fr_offset);
 	  fragP->fr_offset = 0;
 	}
@@ -1587,7 +1587,7 @@ md_generate_nops (fragS *f ATTRIBUTE_UNUSED,
 		  offsetT count ATTRIBUTE_UNUSED,
 		  int control ATTRIBUTE_UNUSED)
 {
-  as_bad (_("unimplemented .nop directive"));
+  as_bad (_("unimplemented .nops directive"));
 }
 #endif
 
@@ -2840,7 +2840,7 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)
 			  }
 
 			as_warn_where (fragP->fr_file, fragP->fr_line,
-				       _(".space, .nop or .fill with negative value, ignored"));
+				       _(".space, .nops or .fill with negative value, ignored"));
 			fragP->fr_symbol = 0;
 		      }
 		    else
-- 
2.14.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]