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/GAS: Fix register use annotation of ALNV.PS


Hi,

 The ALNV.PS instruction lacks register use annotation for its general 
register argument.  As a result it can be reordered into a branch delay 
slot even if it reads a register that the branch writes.  Here's a fix.

 Regression-tested with the mips-sde-elf and mips-gnu-linux targets.  OK 
to apply?

2011-02-25  Maciej W. Rozycki  <macro@codesourcery.com>

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Correct register use 
	annotation of "alnv.ps".

	gas/testsuite/
	* gas/mips/alnv_ps-swap.d: New test for ALNV.PS instruction
	branch swapping.
	* gas/mips/alnv_ps-swap.s: Source for the new test.
	* gas/mips/mips.exp: Run the new test.

  Maciej

binutils-mips-opcode-alnv.diff
Index: binutils-fsf-trunk-quilt/opcodes/mips-opc.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/opcodes/mips-opc.c	2011-02-24 23:46:08.000000000 +0000
+++ binutils-fsf-trunk-quilt/opcodes/mips-opc.c	2011-02-24 23:46:09.000000000 +0000
@@ -297,7 +297,7 @@ const struct mips_opcode mips_builtin_op
 {"alni.ob", "X,Y,Z,O",	0x78000018, 0xff00003f,	WR_D|RD_S|RD_T|FP_D,	0,		MX|SB1	},
 {"alni.ob", "D,S,T,%",	0x48000018, 0xff00003f,	WR_D|RD_S|RD_T, 	0,		N54	},
 {"alni.qh", "X,Y,Z,O",	0x7800001a, 0xff00003f,	WR_D|RD_S|RD_T|FP_D,	0,		MX	},
-{"alnv.ps", "D,V,T,s",	0x4c00001e, 0xfc00003f,	WR_D|RD_S|RD_T|FP_D,	0,		I5_33	},
+{"alnv.ps", "D,V,T,s",	0x4c00001e, 0xfc00003f,	WR_D|RD_S|RD_T|RD_s|FP_D, 0,		I5_33	},
 {"alnv.ob", "X,Y,Z,s",	0x78000019, 0xfc00003f,	WR_D|RD_S|RD_T|RD_s|FP_D, 0,		MX|SB1	},
 {"alnv.qh", "X,Y,Z,s",	0x7800001b, 0xfc00003f,	WR_D|RD_S|RD_T|RD_s|FP_D, 0,		MX	},
 {"and",     "d,v,t",	0x00000024, 0xfc0007ff,	WR_d|RD_s|RD_t,		0,		I1	},
Index: binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/alnv_ps-swap.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/alnv_ps-swap.d	2011-02-24 23:46:09.000000000 +0000
@@ -0,0 +1,39 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS ALNV.PS instruction branch swapping
+#as: -32
+
+# Check that a register dependency between ALNV.PS and the following
+# branch prevents from branch swapping.
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 1000ffff 	b	0+0000 <foo>
+[0-9a-f]+ <[^>]*> 4c60111e 	alnv\.ps	\$f4,\$f2,\$f0,v1
+[0-9a-f]+ <[^>]*> 0411fffd 	bal	0+0000 <foo>
+[0-9a-f]+ <[^>]*> 4c60111e 	alnv\.ps	\$f4,\$f2,\$f0,v1
+[0-9a-f]+ <[^>]*> 0470fffb 	bltzal	v1,0+0000 <foo>
+[0-9a-f]+ <[^>]*> 4c60111e 	alnv\.ps	\$f4,\$f2,\$f0,v1
+[0-9a-f]+ <[^>]*> 0060f809 	jalr	v1
+[0-9a-f]+ <[^>]*> 4c60111e 	alnv\.ps	\$f4,\$f2,\$f0,v1
+[0-9a-f]+ <[^>]*> 00602009 	jalr	a0,v1
+[0-9a-f]+ <[^>]*> 4c60111e 	alnv\.ps	\$f4,\$f2,\$f0,v1
+[0-9a-f]+ <[^>]*> 4c60111e 	alnv\.ps	\$f4,\$f2,\$f0,v1
+[0-9a-f]+ <[^>]*> 03e01809 	jalr	v1,ra
+[0-9a-f]+ <[^>]*> 00000000 	nop
+[0-9a-f]+ <[^>]*> 1000fff2 	b	0+0000 <foo>
+[0-9a-f]+ <[^>]*> 4fe0111e 	alnv\.ps	\$f4,\$f2,\$f0,ra
+[0-9a-f]+ <[^>]*> 4fe0111e 	alnv\.ps	\$f4,\$f2,\$f0,ra
+[0-9a-f]+ <[^>]*> 0411ffef 	bal	0+0000 <foo>
+[0-9a-f]+ <[^>]*> 00000000 	nop
+[0-9a-f]+ <[^>]*> 4fe0111e 	alnv\.ps	\$f4,\$f2,\$f0,ra
+[0-9a-f]+ <[^>]*> 0470ffec 	bltzal	v1,0+0000 <foo>
+[0-9a-f]+ <[^>]*> 00000000 	nop
+[0-9a-f]+ <[^>]*> 4fe0111e 	alnv\.ps	\$f4,\$f2,\$f0,ra
+[0-9a-f]+ <[^>]*> 0060f809 	jalr	v1
+[0-9a-f]+ <[^>]*> 00000000 	nop
+[0-9a-f]+ <[^>]*> 00602009 	jalr	a0,v1
+[0-9a-f]+ <[^>]*> 4fe0111e 	alnv\.ps	\$f4,\$f2,\$f0,ra
+[0-9a-f]+ <[^>]*> 03e01809 	jalr	v1,ra
+[0-9a-f]+ <[^>]*> 4fe0111e 	alnv\.ps	\$f4,\$f2,\$f0,ra
+	\.\.\.
Index: binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/alnv_ps-swap.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/alnv_ps-swap.s	2011-02-24 23:46:09.000000000 +0000
@@ -0,0 +1,33 @@
+# Source file to test branch swapping with the ALNV.PS instruction.
+
+	.text
+foo:
+	alnv.ps	$f4, $f2, $f0, $3
+	b	foo
+	alnv.ps	$f4, $f2, $f0, $3
+	bal	foo
+	alnv.ps	$f4, $f2, $f0, $3
+	bltzal	$3, foo
+	alnv.ps	$f4, $f2, $f0, $3
+	jalr	$3
+	alnv.ps	$f4, $f2, $f0, $3
+	jalr	$4, $3
+	alnv.ps	$f4, $f2, $f0, $3
+	jalr	$3, $31
+
+	alnv.ps	$f4, $f2, $f0, $31
+	b	foo
+	alnv.ps	$f4, $f2, $f0, $31
+	bal	foo
+	alnv.ps	$f4, $f2, $f0, $31
+	bltzal	$3, foo
+	alnv.ps	$f4, $f2, $f0, $31
+	jalr	$3
+	alnv.ps	$f4, $f2, $f0, $31
+	jalr	$4, $3
+	alnv.ps	$f4, $f2, $f0, $31
+	jalr	$3, $31
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	2
+	.space	8
Index: binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils-fsf-trunk-quilt.orig/gas/testsuite/gas/mips/mips.exp	2011-02-24 23:46:09.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/mips.exp	2011-02-24 23:46:09.000000000 +0000
@@ -983,6 +983,9 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "mips32-sync"
     run_dump_test_arches "mips32r2-sync" \
 					[mips_arch_list_matching mips32r2]
+    run_dump_test_arches "alnv_ps-swap" [lsort -dictionary -unique [concat \
+					[mips_arch_list_matching mips5] \
+					[mips_arch_list_matching mips32r2] ] ]
 
     if $has_newabi { run_dump_test "cfi-n64-1" }
 }


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