public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH] gas: re-arrange listing output for .irp and alike
Date: Mon, 19 Dec 2022 11:53:19 +0100	[thread overview]
Message-ID: <fdbff837-ebd9-7726-351c-1c43c619b4cb@suse.com> (raw)

It is kind of odd to have the expansions of such constructs ahead of
their definition in listings with macro expansion enabled. Adjust this
by pulling ahead the output of the definition lines, taking care to
avoid producing a listing line for (non-existing) line 0 when the source
is stdin.
---
According to my testing, with respective debugging code in place, the
conditional operator then isn't needed anymore in the invocation of
print_lines() that is being moved: As long as list->file->linenum is
non-zero, it and list->line are now always equal. I didn't make that
simplification right away though, as I fear I may be overlooking some
corner case. Unless I hear otherwise I intend to commit with that
adjustment.

The x86 testsuite adjustment goes on top of "x86: rework noavx512-1
testcase" [1]. If the change here is to go in first, the adjustment done
here would need folding into there (serving as a test of the new
behavior at the same time).

[1] https://sourceware.org/pipermail/binutils/2022-December/125209.html

--- a/gas/listing.c
+++ b/gas/listing.c
@@ -1247,18 +1247,7 @@ listing_listing (char *name ATTRIBUTE_UN
 	  if (current_hll_file && list->hll_line && (listing & LISTING_HLL))
 	    print_source (current_hll_file, list, width);
 
-	  if (list->line_contents)
-	    {
-	      if (!((listing & LISTING_NODEBUG)
-		    && debugging_pseudo (list, list->line_contents)))
-		print_lines (list,
-			     list->file->linenum == 0 ? list->line : list->file->linenum,
-			     list->line_contents, calc_hex (list));
-
-	      free (list->line_contents);
-	      list->line_contents = NULL;
-	    }
-	  else
+	  if (!list->line_contents || list->file->linenum)
 	    {
 	      while (list->file->linenum < list_line
 		     && !list->file->at_end)
@@ -1278,6 +1267,18 @@ listing_listing (char *name ATTRIBUTE_UN
 		}
 	    }
 
+	  if (list->line_contents)
+	    {
+	      if (!((listing & LISTING_NODEBUG)
+		    && debugging_pseudo (list, list->line_contents)))
+		print_lines (list,
+			     list->file->linenum == 0 ? list->line : list->file->linenum,
+			     list->line_contents, calc_hex (list));
+
+	      free (list->line_contents);
+	      list->line_contents = NULL;
+	    }
+
 	  if (list->edict == EDICT_EJECT)
 	    eject = 1;
 	}
--- a/gas/testsuite/gas/i386/noavx512-1.l
+++ b/gas/testsuite/gas/i386/noavx512-1.l
@@ -45,6 +45,8 @@
 [ 	]*[0-9]+[ 	]*
 [ 	]*[0-9]+[ 	]+\.irp isa, default, .*
 #...
+[ 	]*[0-9]+[ 	]+\.endr
+#...
 [ 	]*[0-9]+[ 	]+>  \.arch default
 [ 	]*[0-9]+[ 	]+>  \.arch default
 [ 	]*[0-9]+[ 	]+\?\?\?\? 62F27D4F 	>  vpabsb %zmm5,%zmm6\{%k7\}
@@ -399,8 +401,6 @@
 [ 	]*[0-9]+[ 	]+>  vpermb %xmm4,%xmm5,%xmm6\{%k7\}
 [ 	]*[0-9]+[ 	]+>  vpermb %ymm4,%ymm5,%ymm6\{%k7\}
 #...
-[ 	]*[0-9]+[ 	]+\.endr
-[ 	]*[0-9]+[ 	]*
 [ 	]*[0-9]+[ 	]+\?\?\?\? C4E2791C 		vpabsb %xmm5, %xmm6
 [ 	]*[0-9]+[ 	]+F5
 [ 	]*[0-9]+[ 	]+\?\?\?\? C4E27D1C 		vpabsb %ymm5, %ymm6

                 reply	other threads:[~2022-12-19 10:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fdbff837-ebd9-7726-351c-1c43c619b4cb@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).