public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* a peculiar fpload problem on an inferior processor
@ 2010-05-06  9:00 Amker.Cheng
  2010-05-06 10:31 ` Dave Korn
  0 siblings, 1 reply; 6+ messages in thread
From: Amker.Cheng @ 2010-05-06  9:00 UTC (permalink / raw)
  To: gcc

Hi :
   Our processor has an errata that the direct fpu load cannot work right,
so I have to substitute instruction sequence "load_into_gpr ; move_gpr_into_fpr"
for direct fpload insn.
  Currently I thought of two potential methods as following:

method 1:
   step1 :  keep a scratch register when expanding fpload;
   step2 :  split insn fpload into "load_into_gpr ; move_gpr_into_fpr"
sequence by using the reserved scratch register;

method 2:
   generate "load_into_gpr ; move_gpr_into_fpr" when expanding directly.

I have only tried the first method, which end up with the errro "insn
does not satisfy its constraints".
after tracing cc1, found that the problematic insn was generated by
reloading, which trying to
spill float register into memory, which itself using direct fpload.

here is the question : Is it possible to replace all direct fpload
with "load_into_gpr ; move_gpr_into_fpr"
sequence. I doubt it since the reload pass might generate direct
fpload insn for spilling fpu register.

BTW, I prefer to do the replacement in gcc, rather than assembler,
since it might produce lots of pipeline stalls.

So, any advice? Thank you all.

-- 
Best Regards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: a peculiar fpload problem on an inferior processor
  2010-05-06  9:00 a peculiar fpload problem on an inferior processor Amker.Cheng
@ 2010-05-06 10:31 ` Dave Korn
  2010-05-07 11:04   ` Amker.Cheng
  0 siblings, 1 reply; 6+ messages in thread
From: Dave Korn @ 2010-05-06 10:31 UTC (permalink / raw)
  To: Amker.Cheng; +Cc: gcc

On 06/05/2010 10:00, Amker.Cheng wrote:

> here is the question : Is it possible to replace all direct fpload
> with "load_into_gpr ; move_gpr_into_fpr"
> sequence. I doubt it since the reload pass might generate direct
> fpload insn for spilling fpu register.

  It is possible.  Your expander can handle it before reload; to handle it
during and after reload, you need to implement a TARGET_SECONDARY_RELOAD hook.

http://gcc.gnu.org/onlinedocs/gccint/Register-Classes.html#index-TARGET_005fSECONDARY_005fRELOAD-3974

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: a peculiar fpload problem on an inferior processor
  2010-05-06 10:31 ` Dave Korn
@ 2010-05-07 11:04   ` Amker.Cheng
  2010-05-07 13:45     ` Dave Korn
  0 siblings, 1 reply; 6+ messages in thread
From: Amker.Cheng @ 2010-05-07 11:04 UTC (permalink / raw)
  To: Dave Korn; +Cc: gcc

>  It is possible.  Your expander can handle it before reload; to handle it
> during and after reload, you need to implement a TARGET_SECONDARY_RELOAD hook.
>
> http://gcc.gnu.org/onlinedocs/gccint/Register-Classes.html#index-TARGET_005fSECONDARY_005fRELOAD-3974
>
Thanks Dave, It works, but I found that reload is not the only pass
which might generate fpload/fpstore instructions.
I am working with GCC 4.4(mips), there is function(mips_emit_move),
which is called in many pass after register allocation
and might generate fpload/fpstore.
For example, in pass pro_and_epilogue, it generates load/store for fpu
register which saved by function prologue/epilogue.

Seems I have to track down all calling of this function and make sure
it works in my way.

Thanks.

-- 
Best Regards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: a peculiar fpload problem on an inferior processor
  2010-05-07 11:04   ` Amker.Cheng
@ 2010-05-07 13:45     ` Dave Korn
  2010-05-08  6:52       ` Amker.Cheng
  0 siblings, 1 reply; 6+ messages in thread
From: Dave Korn @ 2010-05-07 13:45 UTC (permalink / raw)
  To: Amker.Cheng; +Cc: Dave Korn, gcc

On 07/05/2010 12:04, Amker.Cheng wrote:
>>  It is possible.  Your expander can handle it before reload; to handle it
>> during and after reload, you need to implement a TARGET_SECONDARY_RELOAD hook.
>>
>> http://gcc.gnu.org/onlinedocs/gccint/Register-Classes.html#index-TARGET_005fSECONDARY_005fRELOAD-3974
>>
> Thanks Dave, It works, but I found that reload is not the only pass
> which might generate fpload/fpstore instructions.
> I am working with GCC 4.4(mips), there is function(mips_emit_move),
> which is called in many pass after register allocation
> and might generate fpload/fpstore.
> For example, in pass pro_and_epilogue, it generates load/store for fpu
> register which saved by function prologue/epilogue.
> 
> Seems I have to track down all calling of this function and make sure
> it works in my way.

  Ah, I forgot pro/epilogue generation, but I think that's the only other
thing that happens after reload.  That is a special case: it has to generate
strict rtl that directly matches the insns it wants.  You'll probably have to
arrange for it to save at least one GPR early enough in the prologue sequence
to be able to use it as a temp for your FP moves, and similar in the epilogue
sequence.

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: a peculiar fpload problem on an inferior processor
  2010-05-07 13:45     ` Dave Korn
@ 2010-05-08  6:52       ` Amker.Cheng
  2010-05-11  2:44         ` Amker.Cheng
  0 siblings, 1 reply; 6+ messages in thread
From: Amker.Cheng @ 2010-05-08  6:52 UTC (permalink / raw)
  To: Dave Korn; +Cc: gcc

>  Ah, I forgot pro/epilogue generation, but I think that's the only other
> thing that happens after reload.  That is a special case: it has to generate
> strict rtl that directly matches the insns it wants.  You'll probably have to
> arrange for it to save at least one GPR early enough in the prologue sequence
> to be able to use it as a temp for your FP moves, and similar in the epilogue
> sequence.

Yes, Thanks for your help , Dave



-- 
Best Regards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: a peculiar fpload problem on an inferior processor
  2010-05-08  6:52       ` Amker.Cheng
@ 2010-05-11  2:44         ` Amker.Cheng
  0 siblings, 0 replies; 6+ messages in thread
From: Amker.Cheng @ 2010-05-11  2:44 UTC (permalink / raw)
  To: Dave Korn; +Cc: gcc

On Sat, May 8, 2010 at 2:52 PM, Amker.Cheng <amker.cheng@gmail.com> wrote:
>>  Ah, I forgot pro/epilogue generation, but I think that's the only other
>> thing that happens after reload.  That is a special case: it has to generate
>> strict rtl that directly matches the insns it wants.  You'll probably have to
>> arrange for it to save at least one GPR early enough in the prologue sequence
>> to be able to use it as a temp for your FP moves, and similar in the epilogue
>> sequence.
>

Sorry to disturb again, concerning this problem, There is another case
have to be handled.
the reload pass also takes care of call saved registers by generating
save/restore insns,
which might generate direct fpload/fpstore instructions. (in
save_call_clobbered_regs, etc.)

I see no way to keep GPR for this case, except using the temporary
register of the ABI,
and it seems safe in this case since the temp register are only used
around calling insn.
Actually I am not very sure about this.

Any suggestion? Thanks.

-- 
Best Regards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-11  2:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-06  9:00 a peculiar fpload problem on an inferior processor Amker.Cheng
2010-05-06 10:31 ` Dave Korn
2010-05-07 11:04   ` Amker.Cheng
2010-05-07 13:45     ` Dave Korn
2010-05-08  6:52       ` Amker.Cheng
2010-05-11  2:44         ` Amker.Cheng

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).