🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42597

Re: GCC with multiple delay slots

#42597
From: Thomas Lundqvist
Date: Tue, 14 Nov 1995 00:00
109 lines
3926 bytes
In article <199511082228.QAA08290@long-eared.owlnet.rice.edu>,
Frederick Earl Gray <fgray@owlnet.rice.edu> wrote:
>As part of a research project, we're modifying GCC to support an architecture
>with multiple delay slots after each branch instruction.  Aside from the 
>delay slots, our hypothetical machine is identical to the SPARC.  
>
>We have tried both four and two delay slots, with the following RTL code
>in sparc.md:

>GCC compiles successfully, but while running it with optimization (-O) on 
>just about anything it aborts.  Here is the trace ('where' output in gdb):

>Is anyone actively using GCC with multiple delay slots?  Are we the first
>to try to make use of the code to support this?  Does anyone have any good
>ideas?


We have also discovered this problem while doing a port to a machine
with 2 delay slots. A few minutes ago I sent the following bug-report
to bug-gcc@prep.ai.mit.edu. It might help you.

Good luck,

Thomas Lundqvist

===========================================================================
A bug exists in reorg.c (2.7.0) when using multiple delay slots.

Symptom: GCC aborts when filling multiple delay slots.

Cause:   The function 'emit_insn_before' aborts because 'update_block'
         tries to use it to insert an instruction before a previous
         deleted one.

Fix:     The bug probably exists because of a faulty use of
         'update_data', but we have enhanced 'update_data'
         instead, hiding the problem from the above layers
         (a bad solution maybe but it's working for us).

================================================== Original version:
static void
update_block (insn, where)
     rtx insn;
     rtx where;
{
  int b;

  /* Ignore if this was in a delay slot and it came from the target of 
     a branch.  */
  if (INSN_FROM_TARGET_P (insn))
    return;

  emit_insn_before (gen_rtx (USE, VOIDmode, insn), where);

  /* INSN might be making a value live in a block where it didn't use to
     be.  So recompute liveness information for this block.  */

  b = find_basic_block (insn);
  if (b != -1)
    bb_ticks[b]++;
}

================================================== Fixed version:
static void
update_block (insn, where)
     rtx insn;
     rtx where;
{
  int b;

  /* Ignore if this was in a delay slot and it came from the target of 
     a branch.  */
  if (INSN_FROM_TARGET_P (insn))
    return;

  /* Change made to work on Thor. When using two delay-slots
     'where' can point to a deleted insn. Then emit_insn_before will
     abort. */
  if (! INSN_DELETED_P (where))
    emit_insn_before (gen_rtx (USE, VOIDmode, insn), where);
  else
    emit_insn_after (gen_rtx (USE, VOIDmode, insn), PREV_INSN (where));

  /* INSN might be making a value live in a block where it didn't use to
     be.  So recompute liveness information for this block.  */

  b = find_basic_block (insn);
  if (b != -1)
    bb_ticks[b]++;
}



Regards,

Thomas Lundqvist, d0thomas@dtek.chalmers.se
Harry Gunnarson, d1harry@dtek.chalmers.se


(The bug was found when doing a port to Thor, a microprocessor
designed at Saab Ericsson Space AB, which have a stack-based
instruction set and 2 delay slots. For more information send
e-mail to thor@space.se)

--


Thomas Lundqvist           | Student, Chalmers University of
d0thomas@dtek.chalmers.se  | Technology, Gothenburg, SWEDEN
Technical Details
Message-ID: <48a08f$958@nyheter.chalmers.se>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <199511082228.QAA08290@long-eared.owlnet.rice.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,b9e7379e155d60f5
X-Google-Attributes: gid11318c,public
From: d0thomas@dtek.chalmers.se (Thomas Lundqvist)
Subject: Re: GCC with multiple delay slots
Date: 1995/11/14
Message-ID: <48a08f$958@nyheter.chalmers.se>
X-Deja-AN: 119374933
distribution: gnu
references: <199511082228.QAA08290@long-eared.owlnet.rice.edu>
organization: Chalmers University of Technology
newsgroups: gnu.gcc.help