I'm porting GCC 4.1.1 to a VLIW architecture.
I have to insert NOP instructions when data dependencies occurred.
So I wrote an algorithm as the following:
foreach(insn in all real insns) {
 foreach(dep_insn in LOG_LINKS(insn)) {
  if(INSN_DELETED_P(dep_insn)) continue;

  stalls = insn_latency(dep_insn, insn);
  distance = cycle_distance(dep_insn, insn);

  if(stalls > distance)
   emit proper NOP instructions before insn;
 }
}
(This algorithm is performed in the hook `TARGET_ASM_FUNCTION_PROLOGUE')

The algorithm is highly dependent on the information of LOG_LINKS(insn).
But I found that there are not any dependecy info for `reload instructions'
because the register allocation pass and reloading pass are peformed after
the first insn scheduling pass.

For example, here are two insns which have true data dependency:
@(insn 25 2343 895 (set (reg:SI 25 rd1)
@        (const_int 0 [0x0])) 15 {*movsi_const_dsp} (nil)
@    (nil))
       movilc  .m0     rd1, #0 @ 25    *movsi_const_dsp/1      [length = 4]
@(insn 895 25 33 (set (mem/c:SI (plus:SI (reg/f:SI 12 fp)
@                (const_int -1204 [0xfffffb4c])) [0 S4 A32])
@        (reg:SI 25 rd1)) 16 {*movsi_dsp} (nil)
@    (nil))
       stw     .r0     rd1, *-fp[#1204]        @ 895   *movsi_dsp/13   [length 
= 4]

The `insn 895' is inserted by global register allocation pass.
So its LOG_LINKS field is empty because the insn didn't process by first 
scheduling pass.

Should I write a violent algorithm to scan these data dependencies?
Are there any better solutions for this problem?

Thanks a lot.

Reply via email to