* fix Xtensa branch relaxation bug
@ 2004-11-11 19:06 Bob Wilson
0 siblings, 0 replies; only message in thread
From: Bob Wilson @ 2004-11-11 19:06 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
The MAX_IMMED6 macro used to determine if a short Xtensa branch is in range had
an incorrect value that caused the assembler to hit an assertion failure. I've
included a new test for this. Committed on mainline.
gas/
* config/tc-xtensa.c (MAX_IMMED6): Change value to 65.
gas/testsuite/
* gas/xtensa/short_branch_offset.s: New.
* gas/xtensa/short_branch_offset.d: New.
* gas/xtensa/all.exp: Run new test.
[-- Attachment #2: gas-max-immed6.patch --]
[-- Type: text/plain, Size: 3091 bytes --]
Index: config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.16
diff -u -r1.16 tc-xtensa.c
--- config/tc-xtensa.c 10 Nov 2004 22:20:27 -0000 1.16
+++ config/tc-xtensa.c 11 Nov 2004 19:01:30 -0000
@@ -7242,8 +7242,11 @@
use for alignment narrow branches that definitely will not expand to a
jump and a branch. These functions find and mark these cases. */
-/* the range in bytes of a bnez.n and beqz.n */
-#define MAX_IMMED6 68
+/* The range in bytes of BNEZ.N and BEQZ.N. The target operand is encoded
+ as PC + 4 + imm6, where imm6 is a 6-bit immediate ranging from 0 to 63.
+ We start counting beginning with the frag after the 2-byte branch, so the
+ maximum offset is (4 - 2) + 63 = 65. */
+#define MAX_IMMED6 65
static size_t unrelaxed_frag_max_size (fragS *);
Index: testsuite/gas/xtensa/all.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/xtensa/all.exp,v
retrieving revision 1.2
diff -u -r1.2 all.exp
--- testsuite/gas/xtensa/all.exp 8 Oct 2004 00:22:12 -0000 1.2
+++ testsuite/gas/xtensa/all.exp 11 Nov 2004 19:01:30 -0000
@@ -78,9 +78,9 @@
objdump_finish
if [all_ones $x1] then { pass $testname } else { fail $testname }
-
+ run_dump_test "short_branch_offset"
}
if [info exists errorInfo] then {
unset errorInfo
- }
+}
Index: testsuite/gas/xtensa/short_branch_offset.d
===================================================================
RCS file: testsuite/gas/xtensa/short_branch_offset.d
diff -N testsuite/gas/xtensa/short_branch_offset.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gas/xtensa/short_branch_offset.d 11 Nov 2004 19:01:30 -0000
@@ -0,0 +1,34 @@
+# as: --no-target-align
+# objdump: -d
+
+# Test that a short branch with a target just barely out of range does
+# not crash the assembler.
+
+.*: +file format elf32-xtensa-.*
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: .* bnez a2, 0x45
+ 3: .* nop
+ 6: .* nop
+ 9: .* nop
+ c: .* nop
+ f: .* nop
+ 12: .* nop
+ 15: .* nop
+ 18: .* nop
+ 1b: .* nop
+ 1e: .* nop
+ 21: .* nop
+ 24: .* nop
+ 27: .* nop
+ 2a: .* nop
+ 2d: .* nop
+ 30: .* nop
+ 33: .* nop
+ 36: .* nop
+ 39: .* nop
+ 3c: .* nop
+ 3f: .* nop
+ 42: .* nop
Index: testsuite/gas/xtensa/short_branch_offset.s
===================================================================
RCS file: testsuite/gas/xtensa/short_branch_offset.s
diff -N testsuite/gas/xtensa/short_branch_offset.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gas/xtensa/short_branch_offset.s 11 Nov 2004 19:01:30 -0000
@@ -0,0 +1,24 @@
+ bnez.n a2, .Lplus68
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+ _nop
+.Lplus68:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-11-11 19:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-11 19:06 fix Xtensa branch relaxation bug Bob Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).