This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Commit: RX: Disassemble NOP instructions
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Mon, 02 Nov 2015 14:35:42 +0000
- Subject: Commit: RX: Disassemble NOP instructions
- Authentication-results: sourceware.org; auth=none
Hi Guys,
The RX assembler uses several different encodings for a NOP
instruction, depending upon the number of bytes that the instruction
needs to occupy. Unfortunately the RX disassembler did not
disassemble these instructions as NOPs. The attached patch fixes
that.
Tested with no regressions on an rx-elf toolchain.
Cheers
Nick
include/opcode/ChangeLog
2015-11-02 Nick Clifton <nickc@redhat.com>
* rx.h (enum RX_Opcode_ID): Add more NOP opcodes.
opcodes/ChangeLog
2015-11-02 Nick Clifton <nickc@redhat.com>
* rx-decode.opc (rx_decode_opcode): Decode extra NOP
instructions.
* rx-decode.c: Regenerate.
gas/testsuite/ChangeLog
2015-11-02 Nick Clifton <nickc@redhat.com>
* gas/rx/max.d: Update expecetd disassembly.
* gas/rx/nod.d: Likewise.
* gas/rx/nop.sm: Add tests of more NOP instructions.
Index: gas/testsuite/gas/rx/max.d
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gas/testsuite/gas/rx/max.d,v
retrieving revision 1.2
diff -u -3 -p -r1.2 max.d
--- gas/testsuite/gas/rx/max.d 18 Apr 2012 12:55:07 -0000 1.2
+++ gas/testsuite/gas/rx/max.d 9 Sep 2015 11:00:17 -0000
@@ -3,9 +3,9 @@
dump\.o: file format .*
-Disassembly of section \.text:
+Disassembly of section \..*:
-00000000 <\.text>:
+00000000 <\..*>:
0: fd 74 40 80 max #-128, r0
4: fd 74 4f 80 max #-128, r15
8: fd 74 40 7f max #127, r0
@@ -18,7 +18,7 @@ Disassembly of section \.text:
2c: fd 7c 4f 00 00 80 max #0xff800000, r15
32: fd 7c 40 ff ff 7f max #0x7fffff, r0
38: fd 7c 4f ff ff 7f max #0x7fffff, r15
- 3e: fd 70 40 00 00 00 80 max #0x80000000, r0
+ 3e: fd 70 40 00 00 00 80 nop ; max #0x80000000, r0
45: fd 70 4f 00 00 00 80 max #0x80000000, r15
4c: fd 70 40 ff ff ff 7f max #0x7fffffff, r0
53: fd 70 4f ff ff ff 7f max #0x7fffffff, r15
Index: gas/testsuite/gas/rx/nop.d
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gas/testsuite/gas/rx/nop.d,v
retrieving revision 1.1
diff -u -3 -p -r1.1 nop.d
--- gas/testsuite/gas/rx/nop.d 26 Apr 2010 18:58:00 -0000 1.1
+++ gas/testsuite/gas/rx/nop.d 9 Sep 2015 11:00:17 -0000
@@ -3,7 +3,14 @@
dump\.o: file format .*
-Disassembly of section \.text:
+Disassembly of section \..*:
-00000000 <\.text>:
+00000000 <\..*>:
0: 03 nop
+ 1: ef 00 nop ; mov.l r0, r0
+ 3: 63 10 nop ; mul #1, r0
+ 5: fc 13 00 nop ; max r0, r0
+ 8: 76 10 01 00 nop ; mul #1, r0
+ c: 77 10 01 00 00 nop ; mul #1, r0
+ 11: 74 10 01 00 00 00 nop ; mul #1, r0
+ 17: fd 70 40 00 00 00 80 nop ; max #0x80000000, r0
Index: gas/testsuite/gas/rx/nop.sm
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gas/testsuite/gas/rx/nop.sm,v
retrieving revision 1.1
diff -u -3 -p -r1.1 nop.sm
--- gas/testsuite/gas/rx/nop.sm 26 Apr 2010 18:58:00 -0000 1.1
+++ gas/testsuite/gas/rx/nop.sm 9 Sep 2015 11:00:17 -0000
@@ -1 +1,8 @@
nop
+ mov.l r0,r0
+ mul #1,r0
+ max r0,r0
+ .byte 0x76, 0x10, 0x01, 0x00
+ .byte 0x77, 0x10, 0x01, 0x00, 0x00
+ .byte 0x74, 0x10, 0x01, 0x00, 0x00, 0x00
+ max #0x80000000,r0
Index: opcodes/rx-decode.c
===================================================================
RCS file: /cvs/cvsfiles/gnupro/opcodes/rx-decode.c,v
retrieving revision 1.8
diff -u -3 -p -r1.8 rx-decode.c
--- opcodes/rx-decode.c 19 Mar 2014 09:46:33 -0000 1.8
+++ opcodes/rx-decode.c 9 Sep 2015 11:00:17 -0000
@@ -4256,8 +4256,16 @@ rx_decode_opcode (unsigned long pc AU,
}
SYNTAX("mul #%1, %0");
#line 602 "rx-decode.opc"
- ID(mul); DR(rdst); SC(immm); F_____;
-
+ if (immm == 1 && rdst == 0)
+ {
+ ID(nop2);
+ SYNTAX ("nop\t; mul\t#1, r0");
+ }
+ else
+ {
+ ID(mul);
+ }
+ DR(rdst); SC(immm); F_____;
}
break;
}
@@ -4624,6 +4632,7 @@ rx_decode_opcode (unsigned long pc AU,
int im AU = op[0] & 0x03;
#line 605 "rx-decode.opc"
int rdst AU = op[1] & 0x0f;
+ int val = IMMex(im);
if (trace)
{
printf ("\033[33m%s\033[0m %02x %02x\n",
@@ -4634,7 +4643,25 @@ rx_decode_opcode (unsigned long pc AU,
}
SYNTAX("mul #%1, %0");
#line 605 "rx-decode.opc"
- ID(mul); DR(rdst); SC(IMMex(im)); F_____;
+ if (val == 1 && rdst == 0)
+ {
+ SYNTAX("nop\t; mul\t#1, r0");
+ switch (im)
+ {
+ case 2: ID(nop4); break;
+ case 3: ID(nop5); break;
+ case 0: ID(nop6); break;
+ default:
+ ID(mul);
+ SYNTAX("mul #%1, %0");
+ break;
+ }
+ }
+ else
+ {
+ ID(mul);
+ }
+ DR(rdst); SC(val); F_____;
}
break;
@@ -6346,19 +6373,19 @@ rx_decode_opcode (unsigned long pc AU,
if (sd == 3 && ss == 3 && sz == 2 && rsrc == 0 && rdst == 0)
{
ID(nop2);
- rx->syntax = "nop";
+ SYNTAX ("nop\t; mov.l\tr0, r0");
}
else
{
ID(mov); sBWL(sz); F_____;
if ((ss == 3) && (sd != 3))
- {
- SD(ss, rdst, sz); DD(sd, rsrc, sz);
- }
+ {
+ SD(ss, rdst, sz); DD(sd, rsrc, sz);
+ }
else
- {
- SD(ss, rsrc, sz); DD(sd, rdst, sz);
- }
+ {
+ SD(ss, rsrc, sz); DD(sd, rdst, sz);
+ }
}
}
@@ -7204,7 +7231,7 @@ rx_decode_opcode (unsigned long pc AU,
if (ss == 3 && rsrc == 0 && rdst == 0)
{
ID(nop3);
- rx->syntax = "nop";
+ SYNTAX ("nop\t; max\tr0, r0");
}
else
{
@@ -10331,6 +10358,7 @@ rx_decode_opcode (unsigned long pc AU,
int im AU = (op[1] >> 2) & 0x03;
#line 570 "rx-decode.opc"
int rdst AU = op[2] & 0x0f;
+ int val = IMMex (im);
if (trace)
{
printf ("\033[33m%s\033[0m %02x %02x %02x\n",
@@ -10341,8 +10369,16 @@ rx_decode_opcode (unsigned long pc AU,
}
SYNTAX("max #%1, %0");
#line 570 "rx-decode.opc"
- ID(max); DR(rdst); SC(IMMex(im));
-
+ if (im == 0 && (unsigned) val == 0x80000000 && rdst == 0)
+ {
+ ID(nop7);
+ SYNTAX ("nop\t; max\t#0x80000000, r0");
+ }
+ else
+ {
+ ID(max);
+ }
+ DR(rdst); SC(val);
}
break;
case 0x50:
Index: opcodes/rx-decode.opc
===================================================================
RCS file: /cvs/cvsfiles/gnupro/opcodes/rx-decode.opc,v
retrieving revision 1.8
diff -u -3 -p -r1.8 rx-decode.opc
--- opcodes/rx-decode.opc 19 Mar 2014 09:46:33 -0000 1.8
+++ opcodes/rx-decode.opc 9 Sep 2015 11:00:18 -0000
@@ -310,7 +310,7 @@ rx_decode_opcode (unsigned long pc AU,
if (sd == 3 && ss == 3 && sz == 2 && rsrc == 0 && rdst == 0)
{
ID(nop2);
- rx->syntax = "nop";
+ SYNTAX ("nop\t; mov.l\tr0, r0");
}
else
{
@@ -567,13 +567,23 @@ rx_decode_opcode (unsigned long pc AU,
/* MAX */
/** 1111 1101 0111 im00 0100rdst max #%1, %0 */
- ID(max); DR(rdst); SC(IMMex(im));
+ int val = IMMex (im);
+ if (im == 0 && (unsigned) val == 0x80000000 && rdst == 0)
+ {
+ ID (nop7);
+ SYNTAX("nop\t; max\t#0x80000000, r0");
+ }
+ else
+ {
+ ID(max);
+ }
+ DR(rdst); SC(val);
/** 1111 1100 0001 00ss rsrc rdst max %1%S1, %0 */
if (ss == 3 && rsrc == 0 && rdst == 0)
{
ID(nop3);
- rx->syntax = "nop";
+ SYNTAX("nop\t; max\tr0, r0");
}
else
{
@@ -599,10 +609,38 @@ rx_decode_opcode (unsigned long pc AU,
/* MUL */
/** 0110 0011 immm rdst mul #%1, %0 */
- ID(mul); DR(rdst); SC(immm); F_____;
+ if (immm == 1 && rdst == 0)
+ {
+ ID(nop2);
+ SYNTAX ("nop\t; mul\t#1, r0");
+ }
+ else
+ {
+ ID(mul);
+ }
+ DR(rdst); SC(immm); F_____;
/** 0111 01im 0001rdst mul #%1, %0 */
- ID(mul); DR(rdst); SC(IMMex(im)); F_____;
+ int val = IMMex(im);
+ if (val == 1 && rdst == 0)
+ {
+ SYNTAX("nop\t; mul\t#1, r0");
+ switch (im)
+ {
+ case 2: ID(nop4); break;
+ case 3: ID(nop5); break;
+ case 0: ID(nop6); break;
+ default:
+ ID(mul);
+ SYNTAX("mul #%1, %0");
+ break;
+ }
+ }
+ else
+ {
+ ID(mul);
+ }
+ DR(rdst); SC(val); F_____;
/** 0100 11ss rsrc rdst mul %1%S1, %0 */
ID(mul); SP(ss, rsrc); DR(rdst); F_____;
Index: include/opcode/rx.h
===================================================================
RCS file: /cvs/cvsfiles/gnupro/include/opcode/rx.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 rx.h
--- include/opcode/rx.h 24 Sep 2010 21:39:58 -0000 1.3
+++ include/opcode/rx.h 9 Sep 2015 11:00:18 -0000
@@ -98,6 +99,10 @@ typedef enum
RXO_nop,
RXO_nop2,
RXO_nop3,
+ RXO_nop4,
+ RXO_nop5,
+ RXO_nop6,
+ RXO_nop7,
RXO_scmpu,
RXO_smovu,