[2/4] S12Z: GAS: Issue warning if TFR/EXG have identical source and destination.

Message ID 20190131180442.31410-2-john@darrington.wattle.id.au
State New
Headers show
Series
  • [1/4] S12Z: GAS: Disallow immediate destination operands
Related show

Commit Message

John Darrington Jan. 31, 2019, 6:04 p.m.
It is permissible for the source and destination operands of TFR and EXG to be
the same register.  However it is a pointless instruction and anyone writing it
has probably made a mistake.  This change emits a warning if such an instruction
is encountered.

gas/
	* config/tc-s12z.c (tfr): Emit warning if operands are the same.
	* testsuite/gas/s12z/exg.d: New test case.
	* testsuite/gas/s12z/exg.l: New file.
---
 gas/config/tc-s12z.c         | 2 ++
 gas/testsuite/gas/s12z/exg.d | 1 +
 gas/testsuite/gas/s12z/exg.l | 2 ++
 3 files changed, 5 insertions(+)
 create mode 100644 gas/testsuite/gas/s12z/exg.l

-- 
2.11.0

Comments

Nick Clifton Feb. 1, 2019, 10:51 a.m. | #1
Hi John,

> It is permissible for the source and destination operands of TFR and EXG to be

> the same register.  However it is a pointless instruction and anyone writing it

> has probably made a mistake. 


I don't suppose that the ISA designers intended that this sort of instruction be
treated as a NOP, with the idea that in future ISA extensions they might be given
new semantics ?

> gas/

> 	* config/tc-s12z.c (tfr): Emit warning if operands are the same.

> 	* testsuite/gas/s12z/exg.d: New test case.

> 	* testsuite/gas/s12z/exg.l: New file.


Approved - please apply.

Cheers
  Nick

Patch

diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c
index 2bd536aca3..a0131490ba 100644
--- a/gas/config/tc-s12z.c
+++ b/gas/config/tc-s12z.c
@@ -1328,6 +1328,8 @@  tfr (const struct instruction *insn)
        && (registers[reg2].bytes <= registers[reg1].bytes))
       as_warn (_("Source register for %s is no larger than the destination register"),
                insn->name);
+  else if (reg1 == reg2)
+    as_warn (_("The destination and source registers are identical"));
 
   char *f = s12z_new_insn (1 + insn->page);
   if (insn->page == 2)
diff --git a/gas/testsuite/gas/s12z/exg.d b/gas/testsuite/gas/s12z/exg.d
index 54cf268620..e9af154e82 100644
--- a/gas/testsuite/gas/s12z/exg.d
+++ b/gas/testsuite/gas/s12z/exg.d
@@ -1,6 +1,7 @@ 
 #objdump: -d
 #name:    
 #source:  exg.s
+#warning_output: exg.l
 
 
 .*:     file format elf32-s12z
diff --git a/gas/testsuite/gas/s12z/exg.l b/gas/testsuite/gas/s12z/exg.l
new file mode 100644
index 0000000000..018d8f90df
--- /dev/null
+++ b/gas/testsuite/gas/s12z/exg.l
@@ -0,0 +1,2 @@ 
+.*: Assembler messages:
+.*:2: Warning: The destination and source registers are identical