This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: Fix __builtin_apply problems with MMX registers


On 7/14/05, Uros Bizjak <uros.bizjak@kss-loka.si> wrote:
> Quoting Richard Henderson <rth@redhat.com>:
> 
> > > For __builtin_apply ()problems, I suggest that called function (for i386)
> > > should NOT use MMX registers, and that it is always called in
> > FPU_MODE_387.
> >
> > I agree.  You planning on working on this I assume?
> 
>   In this message, please find a patch that fixes __builtin_apply problems with
> MMX registers. The problem was, that regparm MMX registers were blindly passed
> to referenced function, and MMX registers were used for return value together
> with x87 return registers in function, referenced in __builtin_apply. This is
> wrong, as it confuses processor to switch FPU to MMX mode at function entry and
> to MMX mode at function exit, clobbering the result in FP registers. (this
> switching also confuses mode_exit function of MMX/x87 switching).
> 
>   The proposed solution introduces two defines, that overload
> FUNCTION_VALUE_REGNO_P and FUNCTION_ARG_REGNO_P defines in builtin_apply.c. With
> this change __builtin_apply, __builtin_apply_args and __builtin_return don't
> reference MMX registers anymore, while MMX registers can still be used as
> function regparms / return registers for other functions.
> 
>   This problem is unrelated to MMX/x87 switching patch.
> 
>   Patch ware bootstrapped on i686-pc-linux-gnu, regtested for c and c++. With
> this patch applied, MMX/x87 switching patch introduces no regressions.
> 
>   OK for mainline?
> 
> 2005-07-14  Uros Bizjak  <uros@kss-loka.si>
> 
>         * builtins.c (FUNCTION_VALUE_REGNO_P_APPLY_RESULT): Define
>         to FUNCTION_VALUE_REGNO_P if undefined.
>         (FUNCTION_ARG_REGNO_P_APPLY_ARGS): Define to
>         FUNCTION_ARG_REGNO_P if undefined.
>         (apply_args_size): Use FUNCTION_ARG_REGNO_P_APPLY_ARGS.
>         (apply_result_size): Use FUNCTION_VALUE_REGNO_P_APPLY_RESULT.
> 
>         * config/i386/i386-protos.h (ix86_function_value_regno_p):
>         Add new bool argument.
>         (ix86_function_arg_regno_p): Add new bool argument.
>         * config/i386/i386.h (FUNCTION_VALUE_REGNO_P): Add new
>         argument in call to ix86_function_value_regno_p ().
>         (FUNCTION_VALUE_REGNO_P_APPLY_RESULT): New define.
>         (FUNCTION_ARG_REGNO_P): Add new argument in call to
>         ix86_function_arg_regno_p ().
>         (FUNCTION_ARG_REGNO_P_APPLY_ARGS): New define.
>         * config/i386/i386.c (ix86_function_arg_regno_p): Add new
>         from_builtin function argument. Do not return true for MMX
>         registers when from_builtin is set.
>         (ix86_function_value_regno_p): Add new from_builtin function
>         argument. Do not return true for MMX registers when
>         from_builtin is set.

Do you have a testcase?

Thanks,
Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]