public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 03/10] aarch64: Provide line info for unclosed sequences
@ 2021-11-30 13:18 Richard Sandiford
  2021-12-02 12:39 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2021-11-30 13:18 UTC (permalink / raw)
  To: binutils; +Cc: rearnsha

We warn about MOVPRFX instructions that have no following
instruction.  This patch adds a line number to the message,
which is useful if the assembly code has multiple text sections.

The new code is unconditional since OBJ_ELF is always defined
for aarch64.

Tested on aarch64-linux-gnu.  OK to install?

Richard


gas/
	* config/tc-aarch64.h (aarch64_segment_info_type): Add last_file
	and last_line.
	* config/tc-aarch64.c (now_instr_sequence): Delete.
	(force_automatic_sequence_close): Provide a line number when
	reporting unclosed sequences.
	(md_assemble): Record the location of the instruction in
	tc_segment_info.
	* testsuite/gas/aarch64/sve-movprfx_4.l: Add line number to error
	message.
	* testsuite/gas/aarch64/sve-movprfx_7.l: Likewise.
	* testsuite/gas/aarch64/sve-movprfx_8.l: Likewise.
---
 gas/config/tc-aarch64.c                   | 24 +++++++++++------------
 gas/config/tc-aarch64.h                   |  2 ++
 gas/testsuite/gas/aarch64/sve-movprfx_4.l |  2 +-
 gas/testsuite/gas/aarch64/sve-movprfx_7.l |  2 +-
 gas/testsuite/gas/aarch64/sve-movprfx_8.l |  2 +-
 5 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index b6ed80e6d3a..497c126ea83 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -160,13 +160,6 @@ static aarch64_instruction inst;
 static bool parse_operands (char *, const aarch64_opcode *);
 static bool programmer_friendly_fixup (aarch64_instruction *);
 
-#ifdef OBJ_ELF
-#  define now_instr_sequence seg_info \
-		(now_seg)->tc_segment_info_data.insn_sequence
-#else
-static struct aarch64_instr_sequence now_instr_sequence;
-#endif
-
 /* Diagnostics inline function utilities.
 
    These are lightweight utilities which should only be called by parse_operands
@@ -7801,11 +7794,15 @@ warn_unpredictable_ldst (aarch64_instruction *instr, char *str)
 static void
 force_automatic_sequence_close (void)
 {
-  if (now_instr_sequence.instr)
+  struct aarch64_segment_info_type *tc_seg_info;
+
+  tc_seg_info = &seg_info (now_seg)->tc_segment_info_data;
+  if (tc_seg_info->insn_sequence.instr)
     {
-      as_warn (_("previous `%s' sequence has not been closed"),
-	       now_instr_sequence.instr->opcode->name);
-      init_insn_sequence (NULL, &now_instr_sequence);
+      as_warn_where (tc_seg_info->last_file, tc_seg_info->last_line,
+		     _("previous `%s' sequence has not been closed"),
+		     tc_seg_info->insn_sequence.instr->opcode->name);
+      init_insn_sequence (NULL, &tc_seg_info->insn_sequence);
     }
 }
 
@@ -7855,6 +7852,7 @@ md_assemble (char *str)
 {
   templates *template;
   const aarch64_opcode *opcode;
+  struct aarch64_segment_info_type *tc_seg_info;
   aarch64_inst *inst_base;
   unsigned saved_cond;
 
@@ -7867,7 +7865,9 @@ md_assemble (char *str)
     }
 
   /* Update the current insn_sequence from the segment.  */
-  insn_sequence = &seg_info (now_seg)->tc_segment_info_data.insn_sequence;
+  tc_seg_info = &seg_info (now_seg)->tc_segment_info_data;
+  insn_sequence = &tc_seg_info->insn_sequence;
+  tc_seg_info->last_file = as_where (&tc_seg_info->last_line);
 
   inst.reloc.type = BFD_RELOC_UNUSED;
 
diff --git a/gas/config/tc-aarch64.h b/gas/config/tc-aarch64.h
index 658b6935cd3..78bff0a1b56 100644
--- a/gas/config/tc-aarch64.h
+++ b/gas/config/tc-aarch64.h
@@ -225,6 +225,8 @@ void mapping_state (enum mstate);
 
 struct aarch64_segment_info_type
 {
+  const char *last_file;
+  unsigned last_line;
   enum mstate mapstate;
   unsigned int marked_pr_dependency;
   aarch64_instr_sequence insn_sequence;
diff --git a/gas/testsuite/gas/aarch64/sve-movprfx_4.l b/gas/testsuite/gas/aarch64/sve-movprfx_4.l
index 277a6d969f1..6ea4551b4d5 100644
--- a/gas/testsuite/gas/aarch64/sve-movprfx_4.l
+++ b/gas/testsuite/gas/aarch64/sve-movprfx_4.l
@@ -1,2 +1,2 @@
 [^:]*: Assembler messages:
-.*: Warning: previous `movprfx' sequence has not been closed
+.*:8: Warning: previous `movprfx' sequence has not been closed
diff --git a/gas/testsuite/gas/aarch64/sve-movprfx_7.l b/gas/testsuite/gas/aarch64/sve-movprfx_7.l
index 277a6d969f1..e5776c73595 100644
--- a/gas/testsuite/gas/aarch64/sve-movprfx_7.l
+++ b/gas/testsuite/gas/aarch64/sve-movprfx_7.l
@@ -1,2 +1,2 @@
 [^:]*: Assembler messages:
-.*: Warning: previous `movprfx' sequence has not been closed
+.*:7: Warning: previous `movprfx' sequence has not been closed
diff --git a/gas/testsuite/gas/aarch64/sve-movprfx_8.l b/gas/testsuite/gas/aarch64/sve-movprfx_8.l
index 277a6d969f1..e5776c73595 100644
--- a/gas/testsuite/gas/aarch64/sve-movprfx_8.l
+++ b/gas/testsuite/gas/aarch64/sve-movprfx_8.l
@@ -1,2 +1,2 @@
 [^:]*: Assembler messages:
-.*: Warning: previous `movprfx' sequence has not been closed
+.*:7: Warning: previous `movprfx' sequence has not been closed
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 03/10] aarch64: Provide line info for unclosed sequences
  2021-11-30 13:18 [PATCH 03/10] aarch64: Provide line info for unclosed sequences Richard Sandiford
@ 2021-12-02 12:39 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2021-12-02 12:39 UTC (permalink / raw)
  To: binutils, rearnsha, richard.sandiford

Hi Richard,

> gas/
> 	* config/tc-aarch64.h (aarch64_segment_info_type): Add last_file
> 	and last_line.
> 	* config/tc-aarch64.c (now_instr_sequence): Delete.
> 	(force_automatic_sequence_close): Provide a line number when
> 	reporting unclosed sequences.
> 	(md_assemble): Record the location of the instruction in
> 	tc_segment_info.
> 	* testsuite/gas/aarch64/sve-movprfx_4.l: Add line number to error
> 	message.
> 	* testsuite/gas/aarch64/sve-movprfx_7.l: Likewise.
> 	* testsuite/gas/aarch64/sve-movprfx_8.l: Likewise.


Approved - please apply.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-02 12:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 13:18 [PATCH 03/10] aarch64: Provide line info for unclosed sequences Richard Sandiford
2021-12-02 12:39 ` Nick Clifton

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).