[committed] MIPS/opcodes: Exclude $0 from "-x" R6 operand type

Maciej W. Rozycki macro@redhat.com
Fri Jul 19 10:44:08 GMT 2024


The "-x" operand type is used for the reverse encoding of the BOVC and 
BNVC instructions, where 'rs' and 'rt' have been supplied as the second 
and the first operand respectively rather than the order the instruction 
expects.

In this case we require the register associated with the "-x" operand to 
have a higher number than the register associated with the preceding "t" 
operand, which precludes the use of $0.  The case where 'rs' and 'rt' 
both refer to the same register is handled by the straight encoding of 
the BOVC and BNVC instructions, which come in the opcode table ahead of 
the corresponding reverse encoding.

Therefore clear the ZERO_OK flag for the "-x" operand.  No need for an 
extra test case as the encodings involved are already covered by "r6" 
and its associated GAS tests.
---
 opcodes/mips-opc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

binutils-mips-opcodes-prev-check-zero.diff
Index: binutils-gdb/opcodes/mips-opc.c
===================================================================
--- binutils-gdb.orig/opcodes/mips-opc.c
+++ binutils-gdb/opcodes/mips-opc.c
@@ -52,7 +52,7 @@ decode_mips_operand (const char *p)
 	case 'u': PREV_CHECK (5, 16, true, false, false, false);
 	case 'v': PREV_CHECK (5, 16, true, true, false, false);
 	case 'w': PREV_CHECK (5, 16, false, true, true, true);
-	case 'x': PREV_CHECK (5, 21, true, false, false, true);
+	case 'x': PREV_CHECK (5, 21, true, false, false, false);
 	case 'y': PREV_CHECK (5, 21, false, true, false, false);
 	case 'A': PCREL (19, 0, true, 2, 2, false, false);
 	case 'B': PCREL (18, 0, true, 3, 3, false, false);



More information about the Binutils mailing list