This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, spu] Fix sched_emit_insn after scheduler changes
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: bernds at codesourcery dot com, law at redhat dot com
- Date: Wed, 27 Apr 2011 15:22:44 +0200 (CEST)
- Subject: [patch, spu] Fix sched_emit_insn after scheduler changes
Hello,
since recent changes to haifa-sched.c, the SPU back-end runs into
internal errors due to its use of the sched_emit_insn routine to
emit instruction prefetch instructions during final scheduling.
Now that scheduled instructions aren't placed into the instruction
stream directly, sched_emit_insn needs to change as well. The
patch below emits the instruction before nonscheduled_insns_begin
(so that it isn't considered for future scheduling), and adds it
to scheduled_insns so that it will be placed into the output
instruction stream at the correct location.
The patch also adds calls to the add_remove_insn and begin_schedule_ready
callbacks to make sure the back-end accounting stays up to date.
This patch gets the SPU target back to build its run-time libraries
without internal errors.
Tested on spu-elf. OK for mainline?
Bye,
Ulrich
ChangeLog:
* haifa-sched.c (sched_emit_insn): Emit insn before first
non-scheduled insn. Inform back-end about new insn. Add
new insn to scheduled_insns list.
Index: gcc/haifa-sched.c
===================================================================
*** gcc/haifa-sched.c (revision 172953)
--- gcc/haifa-sched.c (working copy)
*************** sched_create_empty_bb_1 (basic_block aft
*** 5654,5662 ****
rtx
sched_emit_insn (rtx pat)
{
! rtx insn = emit_insn_after (pat, last_scheduled_insn);
! last_scheduled_insn = insn;
haifa_init_insn (insn);
return insn;
}
--- 5654,5669 ----
rtx
sched_emit_insn (rtx pat)
{
! rtx insn = emit_insn_before (pat, nonscheduled_insns_begin);
haifa_init_insn (insn);
+
+ if (current_sched_info->add_remove_insn)
+ current_sched_info->add_remove_insn (insn, 0);
+
+ (*current_sched_info->begin_schedule_ready) (insn);
+ VEC_safe_push (rtx, heap, scheduled_insns, insn);
+
+ last_scheduled_insn = insn;
return insn;
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com