This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Patch: Mips -- Let gas report an error message if jalr operands are not unique
- From: Catherine Moore <clm at codesourcery dot com>
- To: binutils at sourceware dot org
- Cc: Catherine Moore <clm at codesourcery dot com>
- Date: Thu, 27 Dec 2007 14:38:44 -0500
- Subject: Patch: Mips -- Let gas report an error message if jalr operands are not unique
From the mips isa for jalr:
> Register specifiers rs and rd must not be equal, because
> such an instruction does not have the same effect when reexecuted.
> The result of executing such an instruction is undefined.
> This restriction permits an exception handler to
> resume execution by reexecuting the branch when an
> exception occurs in the branch delay slot.
I've modified gas to report an error if rs and rd are equal for the jalr instruction.
OK to commit?
Thanks,
Catherine
ChangeLog for gas:
* config/tc-mips.c (mips_ip): Check operands on jalr instruction.
ChangeLog for gas/testsuite:
* gas/mips/jalr.s: New test.
* gas/mips/jalr.l: New test output.
* gas/mips/mips.exp: Run new test.
Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.380
diff -p -r1.380 tc-mips.c
*** config/tc-mips.c 10 Dec 2007 10:36:00 -0000 1.380
--- config/tc-mips.c 27 Dec 2007 19:19:24 -0000
*************** do_msbd:
*** 9133,9138 ****
--- 9133,9151 ----
if (c == 'z' && regno != 0)
break;
+ if (c == 's' && !strcmp (ip->insn_mo->name, "jalr"))
+ {
+ if (regno == lastregno)
+ {
+ insn_error = _("source and destinationations must be different");
+ continue;
+ }
+ if (regno == 31 && lastregno == 0)
+ {
+ insn_error = _("a destination register must be supplied");
+ continue;
+ }
+ }
/* Now that we have assembled one operand, we use the args string
* to figure out where it goes in the instruction. */
switch (c)
Index: testsuite/gas/mips/jalr.l
===================================================================
RCS file: testsuite/gas/mips/jalr.l
diff -N testsuite/gas/mips/jalr.l
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/mips/jalr.l 27 Dec 2007 19:19:24 -0000
***************
*** 0 ****
--- 1,5 ----
+ .*: Assembler messages:
+ .*:1: Error: illegal operands.*
+ .*:2: Error: a destination register must be supplied.*
+ .*:3: Error: source and destinationations must be different.*
+
Index: testsuite/gas/mips/jalr.s
===================================================================
RCS file: testsuite/gas/mips/jalr.s
diff -N testsuite/gas/mips/jalr.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/mips/jalr.s 27 Dec 2007 19:19:24 -0000
***************
*** 0 ****
--- 1,4 ----
+ jalr $32
+ jalr $31
+ jalr $7, $7
+ jalr $31, $2
Index: testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.134
diff -p -r1.134 mips.exp
*** testsuite/gas/mips/mips.exp 10 Dec 2007 10:36:00 -0000 1.134
--- testsuite/gas/mips/mips.exp 27 Dec 2007 19:19:24 -0000
*************** if { [istarget mips*-*-vxworks*] } {
*** 573,578 ****
--- 573,579 ----
run_list_test "illegal" "-32"
run_list_test "baddata1" "-32"
+ run_list_test "jalr" ""
# LOSE: As of 2002-02-08, the next 4 tests fail for target mips-ecoff.
# It's unknown whether they _should_ pass as-is, or whether different