This is the mail archive of the binutils@sources.redhat.com 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 jalx 32-bit insn


Hi All,

As of 2002-07-09, generation of 32-bit jalx instructions is broken by
http://sources.redhat.com/ml/binutils/2002-06/msg00379.html , it is
now regarded as invalid opcode. The idea behind this was to disallow
the assembly of jalx for non MIPS16 capable processors.

The problem is that gas has currently no notion of MIPS16 capability but
only one of actual MIPS16 code generation. I fixed this by using
file_ase_mips16 as an indicator of MIPS16 capability.

This changes gas' behaviour:
With this patch, -mips16 is now also required to create normal code
which can call MIPS16 functions, as long as gas isn't invoked (or
configured) for a known to be MIPS16 capable CPU (currently only
mips16-* targets). Of course, ".set nomips16" needs to be used for
the relevant portions of the file, otherwise pure MIPS16 code would
be generated.

I don't believe this is a problem, because MIPS16 is used to conserve
memory, and normal MIPS code will only be used for relatively small
performance critical parts.


Thiemo


2002-09-17  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/gas/ChangeLog
	* config/tc-mips.c (macro_build): Check for MIPS16 capability, not
	for actual MIPS16 code generation.
	(mips_ip): Likewise.

	/gas/testsuite/ChangeLog
	* gas/mips/mips-jalx.d: New file, check jalx assembly.
	* gas/mips/mips-jalx.s: Likewise.
	* gas/mips/mips-no-jalx.l: Likewise.
	* gas/mips/mips-no-jalx.s: Likewise.
	* gas/mips/mips16-jalx.d: Likewise.
	* gas/mips/mips16-jalx.s: Likewise.
	* gas/mips/mips.exp: Add new tests.

	/opcodes/ChangeLog:
	* mips-dis.c (print_insn_mips): Always allow disassembly of
	32-bit jalx opcode.

diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/config/tc-mips.c source/gas/config/tc-mips.c
--- source-orig/gas/config/tc-mips.c	Sun Sep 15 03:30:51 2002
+++ source/gas/config/tc-mips.c	Mon Sep 16 09:44:39 2002
@@ -2698,7 +2714,7 @@ macro_build (place, counter, ep, name, f
 	  && insn.insn_mo->pinfo != INSN_MACRO
   	  && OPCODE_IS_MEMBER (insn.insn_mo,
   			       (mips_opts.isa
-	      		        | (mips_opts.mips16 ? INSN_MIPS16 : 0)),
+	      		        | (file_ase_mips16 ? INSN_MIPS16 : 0)),
 			       mips_arch)
 	  && (mips_arch != CPU_R4650 || (insn.insn_mo->pinfo & FP_D) == 0))
 	break;
@@ -7738,7 +7827,7 @@ mips_ip (str, ip)
 
       if (OPCODE_IS_MEMBER (insn,
 			    (mips_opts.isa
-			     | (mips_opts.mips16 ? INSN_MIPS16 : 0)
+			     | (file_ase_mips16 ? INSN_MIPS16 : 0)
 	      		     | (mips_opts.ase_mdmx ? INSN_MDMX : 0)
 			     | (mips_opts.ase_mips3d ? INSN_MIPS3D : 0)),
 			    mips_arch))
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/opcodes/mips-dis.c source/opcodes/mips-dis.c
--- source-orig/opcodes/mips-dis.c	Wed Sep  4 23:04:11 2002
+++ source/opcodes/mips-dis.c	Sat Sep 14 15:08:15 2002
@@ -526,7 +526,9 @@ print_insn_mips (memaddr, word, info)
 	    {
 	      register const char *d;
 
-	      if (! OPCODE_IS_MEMBER (op, mips_isa, target_processor))
+	      /* We always allow to disassemble the jalx instruction.  */
+	      if (! OPCODE_IS_MEMBER (op, mips_isa, target_processor)
+		  && strcmp (op->name, "jalx"))
 		continue;
 
 	      /* Figure out instruction type and branch delay information.  */
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/mips-jalx.d source/gas/testsuite/gas/mips/mips-jalx.d
--- source-orig/gas/testsuite/gas/mips/mips-jalx.d	Thu Jan  1 01:00:00 1970
+++ source/gas/testsuite/gas/mips/mips-jalx.d	Sat Sep 14 15:13:54 2002
@@ -0,0 +1,9 @@
+#objdump: -dr -mmips:4000
+#as: -mips3 -mtune=r4000 -mips16
+#name: mips jalx
+.*:     file format .*
+Disassembly of section .text:
+00000000 <.text>:
+   0:	74000000 	jalx	0x0
+			0: R_MIPS_26	external_label
+   4:	00000000 	nop
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/mips-jalx.s source/gas/testsuite/gas/mips/mips-jalx.s
--- source-orig/gas/testsuite/gas/mips/mips-jalx.s	Thu Jan  1 01:00:00 1970
+++ source/gas/testsuite/gas/mips/mips-jalx.s	Sat Sep 14 12:36:07 2002
@@ -0,0 +1,3 @@
+# Test the generation of jalx opcodes
+	.set nomips16
+	jalx	external_label
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/mips-no-jalx.l source/gas/testsuite/gas/mips/mips-no-jalx.l
--- source-orig/gas/testsuite/gas/mips/mips-no-jalx.l	Thu Jan  1 01:00:00 1970
+++ source/gas/testsuite/gas/mips/mips-no-jalx.l	Tue Sep 17 05:09:49 2002
@@ -0,0 +1,2 @@
+.*: Assembler messages:
+.*:3: Error: opcode not supported at this ISA level \(mips.*\) `jalx external_label'
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/mips-no-jalx.s source/gas/testsuite/gas/mips/mips-no-jalx.s
--- source-orig/gas/testsuite/gas/mips/mips-no-jalx.s	Thu Jan  1 01:00:00 1970
+++ source/gas/testsuite/gas/mips/mips-no-jalx.s	Tue Sep 17 04:21:58 2002
@@ -0,0 +1,3 @@
+# Test the generation of jalx opcodes
+	.set nomips16
+	jalx	external_label
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/mips.exp source/gas/testsuite/gas/mips/mips.exp
--- source-orig/gas/testsuite/gas/mips/mips.exp	Wed Sep  4 23:01:59 2002
+++ source/gas/testsuite/gas/mips/mips.exp	Tue Sep 17 04:24:25 2002
@@ -138,7 +139,13 @@ if { [istarget mips*-*-*] } then {
     }
     # The mips16 test can only be run on ELF, because only ELF
     # supports the necessary mips16 reloc.
-    if { $elf && !$no_mips16 } { run_dump_test "mips16" }
+    if { $elf && !$no_mips16 } {
+	run_dump_test "mips16"
+	# Check jalx handling
+	run_dump_test "mips16-jalx"
+	run_dump_test "mips-jalx"
+    }
+    run_list_test "mips-no-jalx" ""
     run_dump_test "delay"
     run_dump_test "nodelay"
     run_dump_test "mips4010"
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/mips16-jalx.d source/gas/testsuite/gas/mips/mips16-jalx.d
--- source-orig/gas/testsuite/gas/mips/mips16-jalx.d	Thu Jan  1 01:00:00 1970
+++ source/gas/testsuite/gas/mips/mips16-jalx.d	Sat Sep 14 12:45:41 2002
@@ -0,0 +1,10 @@
+#objdump: -dr -mmips:4000 -mmips:16
+#as: -mips3 -mtune=r4000 -mips16
+#name: mips16 jalx
+.*:     file format .*
+Disassembly of section .text:
+00000000 <.text>:
+   0:	1c00 0000 	jalx	0x0
+			0: R_MIPS16_26	external_label
+   4:	6500      	nop
+   6:	6500      	nop
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/mips16-jalx.s source/gas/testsuite/gas/mips/mips16-jalx.s
--- source-orig/gas/testsuite/gas/mips/mips16-jalx.s	Thu Jan  1 01:00:00 1970
+++ source/gas/testsuite/gas/mips/mips16-jalx.s	Sat Sep 14 15:14:02 2002
@@ -0,0 +1,2 @@
+# Test the generation of jalx opcodes
+	jalx	external_label


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