This is the mail archive of the binutils-cvs@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]

[binutils-gdb] Fix the AVR assembler so that it will correctly issue warnings about skipped instructions even if su


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=95e42ad4425f0ab0ebfb90035a891be576f9fca4

commit 95e42ad4425f0ab0ebfb90035a891be576f9fca4
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Oct 19 16:21:51 2017 +0100

    Fix the AVR assembler so that it will correctly issue warnings about skipped instructions even if subsections are used.
    
    	PR 21621
    	* config/tc-avr.h (struct avr_frag_data): Add prev_opcode field.
    	(TC_FRAG_INIT): Define.
    	(avr_frag_init): Add prototype.
    	* config/tc-avr.c (avr_frag_init): New function.
    	(avr_operands): Replace static local 'prev' variable with
    	prev_opcode field in current frag.
    	* testsuite/gas/avr/pr21621.s: New test source file.
    	* testsuite/gas/avr/pr21621.d: New test driver file.
    	* testsuite/gas/avr/pr21621.s: New test error output file.

Diff:
---
 gas/ChangeLog                   | 13 +++++++++++++
 gas/config/tc-avr.c             | 14 +++++++++++---
 gas/config/tc-avr.h             |  5 ++++-
 gas/testsuite/gas/avr/pr21621.d |  4 ++++
 gas/testsuite/gas/avr/pr21621.l |  2 ++
 gas/testsuite/gas/avr/pr21621.s | 15 +++++++++++++++
 6 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 23b2faa..3e41860 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,16 @@
+2017-10-19  Nick Clifton  <nickc@redhat.com>
+
+	PR 21621
+	* config/tc-avr.h (struct avr_frag_data): Add prev_opcode field.
+	(TC_FRAG_INIT): Define.
+	(avr_frag_init): Add prototype.
+	* config/tc-avr.c (avr_frag_init): New function.
+	(avr_operands): Replace static local 'prev' variable with
+	prev_opcode field in current frag.
+	* testsuite/gas/avr/pr21621.s: New test source file.
+	* testsuite/gas/avr/pr21621.d: New test driver file.
+	* testsuite/gas/avr/pr21621.s: New test error output file.
+
 2017-10-19  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
 	* testsuite/gas/all/fill-1.s: Use normal labels.  Change .text to
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 067657b..51f1b93 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -1326,6 +1326,15 @@ avr_operand (struct avr_opcodes_s *opcode,
   return op_mask;
 }
 
+/* TC_FRAG_INIT hook */
+
+void
+avr_frag_init (fragS *frag)
+{
+  memset (& frag->tc_frag_data, 0, sizeof frag->tc_frag_data);
+}
+
+
 /* Parse instruction operands.
    Return binary opcode.  */
 
@@ -1337,7 +1346,6 @@ avr_operands (struct avr_opcodes_s *opcode, char **line)
   char *frag = frag_more (opcode->insn_size * 2);
   char *str = *line;
   int where = frag - frag_now->fr_literal;
-  static unsigned int prev = 0;  /* Previous opcode.  */
   int regno1 = -2;
   int regno2 = -2;
 
@@ -1403,7 +1411,7 @@ avr_operands (struct avr_opcodes_s *opcode, char **line)
          (AVR core bug, fixed in the newer devices).  */
       if (!(avr_opt.no_skip_bug ||
             (avr_mcu->isa & (AVR_ISA_MUL | AVR_ISA_MOVW)))
-	  && AVR_SKIP_P (prev))
+	  && AVR_SKIP_P (frag_now->tc_frag_data.prev_opcode))
 	as_warn (_("skipping two-word instruction"));
 
       bfd_putl32 ((bfd_vma) bin, frag);
@@ -1411,7 +1419,7 @@ avr_operands (struct avr_opcodes_s *opcode, char **line)
   else
     bfd_putl16 ((bfd_vma) bin, frag);
 
-  prev = bin;
+  frag_now->tc_frag_data.prev_opcode = bin;
   *line = str;
   return bin;
 }
diff --git a/gas/config/tc-avr.h b/gas/config/tc-avr.h
index 0cfe9ff..96f6890 100644
--- a/gas/config/tc-avr.h
+++ b/gas/config/tc-avr.h
@@ -230,7 +230,7 @@ extern symbolS* avr_undefined_symbol (char*);
 extern void avr_post_relax_hook (void);
 
 #define HANDLE_ALIGN(fragP) avr_handle_align (fragP)
-extern void avr_handle_align (fragS *fragP);
+extern void avr_handle_align (fragS *);
 
 struct avr_frag_data
 {
@@ -240,5 +240,8 @@ struct avr_frag_data
 
   char fill;
   offsetT alignment;
+  unsigned int prev_opcode;
 };
 #define TC_FRAG_TYPE			struct avr_frag_data
+#define TC_FRAG_INIT(frag)		avr_frag_init (frag)
+extern void avr_frag_init (fragS *);
diff --git a/gas/testsuite/gas/avr/pr21621.d b/gas/testsuite/gas/avr/pr21621.d
new file mode 100644
index 0000000..6354c85
--- /dev/null
+++ b/gas/testsuite/gas/avr/pr21621.d
@@ -0,0 +1,4 @@
+#name: PR 21621 (correct generation of skip warnings)
+#as: 
+#target: avr-*-*
+#error-output: pr21621.l
diff --git a/gas/testsuite/gas/avr/pr21621.l b/gas/testsuite/gas/avr/pr21621.l
new file mode 100644
index 0000000..a356bc7
--- /dev/null
+++ b/gas/testsuite/gas/avr/pr21621.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:15: Warning: skipping two-word instruction
diff --git a/gas/testsuite/gas/avr/pr21621.s b/gas/testsuite/gas/avr/pr21621.s
new file mode 100644
index 0000000..6ada2ca
--- /dev/null
+++ b/gas/testsuite/gas/avr/pr21621.s
@@ -0,0 +1,15 @@
+
+.text
+    cpse 0,0
+.subsection 1
+    lds 0,0
+.previous
+    clc
+
+
+.text
+    cpse 1,1
+.subsection 1
+    sec
+.previous
+    lds 1,1


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