This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Prototype for SSE2 calling convention libm on ia32
Richard Henderson wrote:
> On Tue, Jun 07, 2005 at 07:21:18PM +0200, Richard Guenther wrote:
>
>>It does so by first exposing a new function attribute "fpregparm" that
>>changes calling conventions for a single function, and second, patching
>>optabs and builtin decls and honouring it at expansion time.
>
>
> I think we need a different name than fpregparm. There was another
> patch that was submitted that would pass fp arguments on the fpu stack.
> It didn't get reviewed, but...
>
> Perhaps "sseregparm".
Ok that was my first choice, too.
>
>> * calls.c (expand_call_1): New function from expand_call
>> with extra dispatch location argument.
>> (expand_call): Wrapper to expand_call_1 with NULL_RTX
>> dispatch location.
>> * builtins.c (expand_builtin_mathfn_3): Honour optabs
>> libfunc entry via expand_call_1.
>
>
> What in the world is this for?!?
Basically we need to be able to tell the middle-end to emit
a libcall for __builtin_sin to __libm_sse2_sin rather than
to sin. Using expand_call, we always get sin, using
emit_library_call_value we get a libcall to __libm_sse2_sin,
but the backend never sees the fn decl or type for changing
the ABI. So I chose to pass powi_optab->handlers[(int) mode].libfunc
as optional extra argument to expand_call (and being lazy for the
prototype I didn't want to change all callers of expand_call, so
I wrapped it).
>
>>+ if (!TARGET_SSE2)
>>+ {
>>+ error ("%qs attribute only can be used with -msse2",
>>+ IDENTIFIER_POINTER (name));
>
>
> No, all data types are supported with moves in -msse1. See commentary
> elsewhere about minimizing the number of abis.
Basically the problem is for f.i.
double foo(double) __attribute__((fpregparm));
double bar(double x) { return foo(x); }
we ICE compiling without -msse2 enabled (because some pattern does
not match its constraints). So I chose to error out for the attribute
without -msse2 and require headers to be appropriately #ifdef'ed. The
other possibility is to ignore the attribute in this case and use
fpstack calling conventions and break at runtime. My preference was
breaking at compile time.
> Perhaps you only want to enable some of the libcalls with sse2, but
> this attribute is user visible. And I'd like this attribute to go
> in separate from any libcall tweakage.
Yes, I'll split it apart.
>
>>+ /* Use SSE registers to pass SFmode and DFmode arguments if requested
>>+ by the fpregparm attribute. */
>>+ if (fntype && lookup_attribute ("fpregparm", TYPE_ATTRIBUTES (fntype)))
>>+ {
>>+ cum->sse_nregs = 8;
>>+ cum->float_in_sse = true;
>>+ }
>>+
>> /* For local functions, pass SFmode (and DFmode for SSE2) arguments
>> in SSE registers even for 32-bit mode and not just 3, but up to
>> 8 SSE arguments in registers. */
>>! else if (!TARGET_64BIT && !cum->maybe_vaarg && !cum->fastcall
>> && cum->sse_nregs == SSE_REGPARM_MAX && fndecl
>> && TARGET_SSE_MATH && flag_unit_at_a_time && !profile_flag)
>
>
> We should handle this in a separate function like ix86_function_regparm.
Ok, will do.
Thanks,
Richard.