arc: Detect usage of illegal double register pairs
authorClaudiu Zissulescu <claziss@gmail.com>
Tue, 14 Jul 2020 11:51:15 +0000 (14:51 +0300)
committerClaudiu Zissulescu <claziss@gmail.com>
Tue, 14 Jul 2020 11:51:15 +0000 (14:51 +0300)
ARC can use odd-even double register pairs in some selected
instructions. Although the GNU assembler doesn't allow even-odd
registers to be used, there may be cases when the disassembler is
presented with such situation.  This patch add a test and detects such
cases.

opcodes/
2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>

* arc-dis.c (print_insn_arc): Detect and emit a warning when a
faulty double register pair is detected.

binutils/
2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>

* testsuite/binutils-all/arc/double_regs.s: New test.
* testsuite/binutils-all/arc/objdump.exp: Add the above test.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
binutils/ChangeLog
binutils/testsuite/binutils-all/arc/double_regs.s [new file with mode: 0644]
binutils/testsuite/binutils-all/arc/objdump.exp
opcodes/ChangeLog
opcodes/arc-dis.c

index 7219f85b49b951d3b07b531c73891cd28fde70d3..708be22cfd7f2944d21f2811ee98bf8072a82d68 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>
+
+       * testsuite/binutils-all/arc/double_regs.s: New test.
+       * testsuite/binutils-all/arc/objdump.exp: Add the above test.
+
 2020-07-13  Nick Clifton  <nickc@redhat.com>
 
        * po/fr.po: Updated French translation.
diff --git a/binutils/testsuite/binutils-all/arc/double_regs.s b/binutils/testsuite/binutils-all/arc/double_regs.s
new file mode 100644 (file)
index 0000000..5d3aa86
--- /dev/null
@@ -0,0 +1,3 @@
+       .cpu HS
+       .text
+       .byte 0x9e,0x2f,0x20,0x75
index 18f0bb74a18829b2e3cef000e300d36de737a376..542a33676977a831878c935249ab689d2a6aec10 100644 (file)
@@ -72,6 +72,9 @@ proc check_assembly { testname objfile expected { disas_flags "" } } {
 # disassembler has had to guess as the instruction class in use).
 set want "Warning: disassembly.*vmac2hnfr\[ \t\]*r0,r2,r4.*dmulh12.f\[ \t\]*r0,r2,r4.*dmulh11.f"
 check_assembly "Warning test" [do_objfile dsp.s] $want
+set warn_double_reg "Warning: illegal use of double register pair."
+check_assembly "Warning faulty double regs" [do_objfile double_regs.s] \
+    $warn_double_reg
 
 set double_store_hs_expected {std\s*r0r1,\[r3\]}
 set objfile [do_objfile double_store.s]
index 3a38bb2853fb1333d90ca94c788cfcf543251b2f..f57188494e29cbc474d109207c9f7a5a7210a209 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>
+
+       * arc-dis.c (print_insn_arc): Detect and emit a warning when a
+       faulty double register pair is detected.
+
 2020-07-14  Jan Beulich  <jbeulich@suse.com>
 
        * i386-dis.c (OP_D): Print dr<N> instead of db<N> in Intel mode.
index bf3194071c920427db4b2f23fa363d8ec2bffed0..27852e8f03bca2f9a18f6d53ed57e64557816e49 100644 (file)
@@ -1269,11 +1269,19 @@ print_insn_arc (bfd_vma memaddr,
          if (!rname)
            rname = regnames[value];
          (*info->fprintf_func) (info->stream, "%s", rname);
+
+         /* Check if we have a double register to print.  */
          if (operand->flags & ARC_OPERAND_TRUNCATE)
            {
-             rname = arcExtMap_coreRegName (value + 1);
-             if (!rname)
-               rname = regnames[value + 1];
+             if ((value & 0x01) == 0)
+               {
+                 rname = arcExtMap_coreRegName (value + 1);
+                 if (!rname)
+                   rname = regnames[value + 1];
+               }
+             else
+               rname = _("\nWarning: illegal use of double register "
+                         "pair.\n");
              (*info->fprintf_func) (info->stream, "%s", rname);
            }
          if (value == 63)