This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix MIPS jalr(.hb) register checking


Hi,

  The register checking for jalr uses $0 as the default
lastregno.  This leads to the rejection of valid instructions
as follows.
Ex:
# cat jalr31.s
test:
        jalr    $0
        jalr    $0, $31

# as-new jalr31.s -o jalr31.o
jalr31.s: Assembler messages:
jalr31.s:2: Error: source and destinationations must be different `jalr'
jalr31.s:3: Error: a destination register must be supplied `jalr'

  So, this patch sets lastregno to 0xffffffff, fixes a typo
of "destinationations", and uses "strncmp" to match "jalr.hb" as well.
The gas test is updated.

  Is this patch ok?  Thanks!

Regards,
Chao-ying

gas/ChangeLog
2008-12-22  Chao-ying Fu  <fu@mips.com>

	* config/tc-mips.c (mips_ip): Set lastregno to 0xffffffff.
	Use strncmp to match jalr and jalr.hb
	Fix a typo.

2008-12-22  Chao-ying Fu  <fu@mips.com>

	* gas/mips/jalr.s, gas/mips/jalr.l: Add more tests for jalr
	and jalr.hb.
	
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.399
diff -u -p -r1.399 tc-mips.c
--- gas/config/tc-mips.c	28 Nov 2008 18:02:17 -0000	1.399
+++ gas/config/tc-mips.c	22 Dec 2008 18:56:13 -0000
@@ -8656,6 +8656,7 @@ mips_ip (char *str, struct mips_cl_insn 
       create_insn (ip, insn);
       insn_error = NULL;
       argnum = 1;
+      lastregno = 0xffffffff;
       for (args = insn->args;; ++args)
 	{
 	  int is_mdmx;
@@ -9397,14 +9398,14 @@ do_msbd:
 		  if (c == 'z' && regno != 0)
 		    break;
 
-		  if (c == 's' && !strcmp (ip->insn_mo->name, "jalr"))
+		  if (c == 's' && !strncmp (ip->insn_mo->name, "jalr", 4))
 		    {
 		      if (regno == lastregno)
 		        {
-			  insn_error = _("source and destinationations must be different");
+			  insn_error = _("source and destination must be different");
 			  continue;
 		        }
-		      if (regno == 31 && lastregno == 0)
+		      if (regno == 31 && lastregno == 0xffffffff)
 		        {
 			  insn_error = _("a destination register must be supplied");
 			  continue;
Index: gas/testsuite/gas/mips/jalr.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/jalr.s,v
retrieving revision 1.1
diff -u -p -r1.1 jalr.s
--- gas/testsuite/gas/mips/jalr.s	2 Jan 2008 20:59:46 -0000	1.1
+++ gas/testsuite/gas/mips/jalr.s	22 Dec 2008 18:56:13 -0000
@@ -2,3 +2,15 @@
 	jalr	$31
 	jalr	$7, $7
 	jalr	$31, $2
+	jalr	$0
+	jalr	$0, $31
+	jalr	$31, $0
+
+	.set	mips32
+	jalr.hb	$32
+	jalr.hb	$31
+	jalr.hb	$7, $7
+	jalr.hb	$31, $2
+	jalr.hb	$0
+	jalr.hb	$0, $31
+	jalr.hb	$31, $0
Index: gas/testsuite/gas/mips/jalr.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/jalr.l,v
retrieving revision 1.1
diff -u -p -r1.1 jalr.l
--- gas/testsuite/gas/mips/jalr.l	2 Jan 2008 20:59:46 -0000	1.1
+++ gas/testsuite/gas/mips/jalr.l	22 Dec 2008 18:56:13 -0000
@@ -1,5 +1,8 @@
 .*: Assembler messages:
 .*:1: Error: illegal operands.*
 .*:2: Error: a destination register must be supplied.*
-.*:3: Error: source and destinationations must be different.*
+.*:3: Error: source and destination must be different.*
+.*:10: Error: illegal operands.*
+.*:11: Error: a destination register must be supplied.*
+.*:12: Error: source and destination must be different.*
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]