public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Supporting FP cmp lib routines
@ 2009-09-14 13:59 Mohamed Shafi
  2009-09-14 14:49 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Mohamed Shafi @ 2009-09-14 13:59 UTC (permalink / raw)
  To: GCC

Hi all,

I am doing a GCC port for a 32bit target in GCC 4.4.0. The target uses
hand coded floating point compare routines. Generally the function
returns the values in the general purpose registers. But these fp cmp
routines return the result in the Status Register itself.  So there is
no need to have compare instruction after the function call for FP
compare. Is there a way to let GCC know that the result for FP compare
are stored in the Status Register so that GCC generates directly a
jump operation? How can i implement this?

Regards,
Shafi

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

* Re: Supporting FP cmp lib routines
  2009-09-14 13:59 Supporting FP cmp lib routines Mohamed Shafi
@ 2009-09-14 14:49 ` Richard Henderson
  2009-09-14 16:03   ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2009-09-14 14:49 UTC (permalink / raw)
  To: Mohamed Shafi; +Cc: GCC

On 09/14/2009 06:59 AM, Mohamed Shafi wrote:
> Is there a way to let GCC know that the result for FP compare
> are stored in the Status Register so that GCC generates directly a
> jump operation? How can i implement this?

There is no way to do this via the standard libcall sequence.

In order to implement this, you'll want to build the function
calls yourself, directly from the cbranch expanders.  Have a
look at alpha_emit_xfloating_libcall for ideas.

You'll want to make sure that that your status register is set
up as the return value of the call pattern, i.e.

   (set (reg:CC status-reg)
        (call:CC (mem (symbol_ref "fp-compare-routine"))))


That should be about all you need to get things working.


r~

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

* Re: Supporting FP cmp lib routines
  2009-09-14 14:49 ` Richard Henderson
@ 2009-09-14 16:03   ` Richard Henderson
  2009-10-23 14:32     ` Mohamed Shafi
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2009-09-14 16:03 UTC (permalink / raw)
  To: Mohamed Shafi; +Cc: GCC

Another thing to look at, since you have hand-written routines and may 
be able to specify that e.g. only a subset of the normal call clobbered 
registers are actually modified, is to leave the call as a "compare" 
insn.  Something like

(define_insn "*cmpsf"
   [(set (reg:CC status-reg)
         (compare:CC
           (match_operand:SF 0 "register_operand" "R0")
           (match_operand:SF 1 "register_operand" "R1")))
    (clobber (reg:SI r2))
    (clobber (reg:SI r3))]
   ""
   "call __compareSF"
   [(set_attr "type" "call")])

Where the R0 and R1 constraints resolve to the input registers for the 
routine.  Depending on your ISA and ABI, you may not even need to split 
this pattern post-reload.


r~

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

* Re: Supporting FP cmp lib routines
  2009-09-14 16:03   ` Richard Henderson
@ 2009-10-23 14:32     ` Mohamed Shafi
  2009-10-23 14:40       ` Joern Rennecke
  0 siblings, 1 reply; 5+ messages in thread
From: Mohamed Shafi @ 2009-10-23 14:32 UTC (permalink / raw)
  To: Richard Henderson; +Cc: GCC

2009/9/14 Richard Henderson <rth@redhat.com>:
> Another thing to look at, since you have hand-written routines and may be
> able to specify that e.g. only a subset of the normal call clobbered
> registers are actually modified, is to leave the call as a "compare" insn.
>  Something like
>
> (define_insn "*cmpsf"
>  [(set (reg:CC status-reg)
>        (compare:CC
>          (match_operand:SF 0 "register_operand" "R0")
>          (match_operand:SF 1 "register_operand" "R1")))
>   (clobber (reg:SI r2))
>   (clobber (reg:SI r3))]
>  ""
>  "call __compareSF"
>  [(set_attr "type" "call")])
>
> Where the R0 and R1 constraints resolve to the input registers for the
> routine.  Depending on your ISA and ABI, you may not even need to split this
> pattern post-reload.
>

I have implemented the above solution and it works. I have to support
the same for DF also. But with DF i have a problem with the
constraints. My target generates code for both big and little endian.
The ABI specifies that when a 64bit value is passed as an argument
they are passed in R6 and R7, R6 containing the most significant  long
word and R7 containing the least significant long word, regardless of
the  endianess mode. How can i do this in the DF compare pattern?

Regards,
Shafi

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

* Re: Supporting FP cmp lib routines
  2009-10-23 14:32     ` Mohamed Shafi
@ 2009-10-23 14:40       ` Joern Rennecke
  0 siblings, 0 replies; 5+ messages in thread
From: Joern Rennecke @ 2009-10-23 14:40 UTC (permalink / raw)
  To: Mohamed Shafi; +Cc: Richard Henderson, GCC

Quoting Mohamed Shafi <shafitvm@gmail.com>:
> I have implemented the above solution and it works. I have to support
> the same for DF also. But with DF i have a problem with the
> constraints. My target generates code for both big and little endian.
> The ABI specifies that when a 64bit value is passed as an argument
> they are passed in R6 and R7, R6 containing the most significant  long
> word and R7 containing the least significant long word, regardless of
> the  endianess mode. How can i do this in the DF compare pattern?

If 64 bit values are generally held in registers this way - or if it's OK
for the compiler to make it so - just change the nominal register numbers
in GCC so that endianness works as expected - register names and the nominal
numbers in gcc do not need to match.

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

end of thread, other threads:[~2009-10-23 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-14 13:59 Supporting FP cmp lib routines Mohamed Shafi
2009-09-14 14:49 ` Richard Henderson
2009-09-14 16:03   ` Richard Henderson
2009-10-23 14:32     ` Mohamed Shafi
2009-10-23 14:40       ` Joern Rennecke

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