+2018-09-04 Daniel Cederman <cederman@gaisler.com>
+
+ * config/tc-sparc.c (md_assemble): Allow non-fpop2 instructions
+ before floating point branches for Sparc V8 and earlier.
+ * testsuite/gas/sparc/sparc.exp: Execute the new test.
+ * testsuite/gas/sparc/v8branch.d: New test.
+ * testsuite/gas/sparc/v8branch.s: New test.
+
2018-09-03 Nick Clifton <nickc@redhat.com>
PR gas/23570
as_warn (_("FP branch in delay slot"));
}
- /* SPARC before v9 requires a nop instruction between a floating
- point instruction and a floating point branch. We insert one
- automatically, with a warning. */
+ /* SPARC before v9 does not allow a floating point compare
+ directly before a floating point branch. Insert a nop
+ instruction if needed, with a warning. */
if (max_architecture < SPARC_OPCODE_ARCH_V9
&& last_insn != NULL
&& (insn->flags & F_FBR) != 0
- && (last_insn->flags & F_FLOAT) != 0)
+ && (last_insn->flags & F_FLOAT) != 0
+ && (last_insn->match & OP3 (0x35)) == OP3 (0x35))
{
struct sparc_it nop_insn;
nop_insn.opcode = NOP_INSN;
nop_insn.reloc = BFD_RELOC_NONE;
output_insn (insn, &nop_insn);
- as_warn (_("FP branch preceded by FP instruction; NOP inserted"));
+ as_warn (_("FP branch preceded by FP compare; NOP inserted"));
}
switch (special_case)
run_dump_test "v8-movwr-imm"
run_dump_test "save-args"
run_dump_test "leon"
+ run_dump_test "v8branch"
set_tests_arch "v9c"
run_dump_test "ldtxa"
--- /dev/null
+#as: -Av8
+#objdump: -dr -m sparc
+#warning: Warning: FP branch preceded by FP compare; NOP inserted
+#name: v8 branch instructions
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <no_fpop2_before_fcmp>:
+ 0: 81 a0 08 20 fadds %f0, %f0, %f0
+ 4: 13 80 00 06 fbe 1c <no_fpop2_before_fcmp\+0x1c>
+ 8: 01 00 00 00 nop
+ c: 81 a8 0a 20 fcmps %f0, %f0
+ 10: 01 00 00 00 nop
+ 14: 13 80 00 02 fbe 1c <no_fpop2_before_fcmp\+0x1c>
+ 18: 01 00 00 00 nop
+ 1c: 01 00 00 00 nop
--- /dev/null
+ .text
+ # Check that a nop instruction is inserted to prevent a floating
+ # point compare directly followed by a floating point branch.
+no_fpop2_before_fcmp:
+ fadds %f0, %f0, %f0
+ fbe 1f
+ nop
+ fcmps %f0, %f0
+ fbe 1f
+ nop
+1: nop