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, MIPS] Check the source register for bltzal and others


Hi All,

  If bltzal, bltzall, bgezal, bgezall, bltzals, bgezals instructions use $31 as
the source register, the re-execution may have different results.
Thus, the assembler should issue errors for this case.
Note that the assembler already sets errors for jalr that has
same source and destination registers.

  Here is the patch.

gas/ChangeLog
2013-09-11  Chao-Ying Fu  <Chao-ying.Fu@imgtec.com>

	* config/tc-mips.c (match_insn): Set error when $31 is used for bltzal*
	and bgezal*.

gas/testsuite/ChangeLog
2013-09-11  Chao-ying Fu  <Chao-ying.Fu@imgtec.com>

        * gas/mips/bltzal.s: New file.
        * gas/mips/bltzal.l: New file.
        * gas/mips/mips.exp: Run the bltzal test.

Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.591
diff -u -p -r1.591 tc-mips.c
--- gas/config/tc-mips.c	19 Aug 2013 20:07:09 -0000	1.591
+++ gas/config/tc-mips.c	11 Sep 2013 23:12:28 -0000
@@ -7091,6 +7091,10 @@ match_insn (struct mips_cl_insn *insn, c
 		set_insn_error
 		  (0, _("a destination register must be supplied"));
 	    }
+	  else if (arg.last_regno == 31
+		   && (strncmp (insn->insn_mo->name, "bltzal", 6) == 0
+		       || strncmp (insn->insn_mo->name, "bgezal", 6) == 0))
+	    set_insn_error (0, _("a source register must not be $31"));
 	  check_completed_insn (&arg);
 	  return TRUE;
 	}
Index: gas/testsuite/gas/mips/bltzal.s
===================================================================
RCS file: gas/testsuite/gas/mips/bltzal.s
diff -N gas/testsuite/gas/mips/bltzal.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/bltzal.s	11 Sep 2013 23:12:28 -0000
@@ -0,0 +1,10 @@
+	.set	reorder
+test:
+	bltzal	$31, test
+	bgezal	$31, test
+	.set	mips2
+	bltzall	$31, test
+	bgezall	$31, test
+	.set	micromips
+	bltzals	$31, test
+	bgezals	$31, test
Index: gas/testsuite/gas/mips/bltzal.l
===================================================================
RCS file: gas/testsuite/gas/mips/bltzal.l
diff -N gas/testsuite/gas/mips/bltzal.l
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/bltzal.l	11 Sep 2013 23:12:28 -0000
@@ -0,0 +1,7 @@
+.*: Assembler messages:
+.*:3: Error: a source register must not be \$31.*
+.*:4: Error: a source register must not be \$31.*
+.*:6: Error: a source register must not be \$31.*
+.*:7: Error: a source register must not be \$31.*
+.*:9: Error: a source register must not be \$31.*
+.*:10: Error: a source register must not be \$31.*
Index: gas/testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.233
diff -u -p -r1.233 mips.exp
--- gas/testsuite/gas/mips/mips.exp	19 Aug 2013 19:26:11 -0000	1.233
+++ gas/testsuite/gas/mips/mips.exp	11 Sep 2013 23:12:28 -0000
@@ -1146,4 +1146,5 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test_arches "ulh-reloc"	[mips_arch_list_matching mips2]
 
     run_dump_test "l_d-reloc"
+    run_list_test "bltzal"
 }

  No new failures are shown on mips-sde-elf targets.  Is it ok to commit the patch?
  Thanks a lot!

Regards,
Chao-ying





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