[RFC PATCH] Implement dummy x87/MMX FPU mode switching

Uros Bizjak uros@kss-loka.si
Fri Jun 17 17:38:00 GMT 2005


Richard Henderson wrote:

>>+	  if (mmx && x87)
>>+	    error ("Mixing x87 and MMX registers in function call "
>>+		   "is not allowed.");
>>    
>>
>
>This error ought to be caught earilier so that proper line number
>information can be emitted.
>  
>
OK. I'll change this into gcc_abort(). However, could you suggest me a 
place in the sources, where this check should be most appropriate?  GCC 
should report an error when %mm and %st registers are used at the same 
time, not when someone declares

double func (__m64 a, float x)

This definition is still valid, because x can be passed thru memory, as 
it is the case with current gcc. However, with (not yet submited) 
fpregparm patch, the same definition with fpregparm attribute would be 
wrong: As fpregparm patch changes function_arg to include x87_nregs, 
perhaps we can check there?

>You can change function_arg to encode whether mmx registers are
>needed (without scanning CALL_INSN_FUNCTION_USAGE), here:
>
>  /* Handle a hidden AL argument containing number of registers for varargs
>     x86-64 functions.  For i386 ABI just return constm1_rtx to avoid
>     any AL settings.  */
>  if (mode == VOIDmode)
>    {
>      if (TARGET_64BIT)
>        return GEN_INT (cum->maybe_vaarg
>                        ? (cum->sse_nregs < 0
>                           ? SSE_REGPARM_MAX
>                           : cum->sse_regno)
>                        : -1);
>      else
>        return constm1_rtx;
>    }
>  
>
I have made some experiments using current_function_args_info as you 
suggested in some previous e-mail:

  MODE_ENTRY = (current_function_args_info.maybe_vaarg
		|| current_function_args_info.mmx_nregs == MMX_REGPARM_MAX
		? I387 : MMX)

However, I have encountered some (variable argument) functions that set 
both maybe_vaarg and mmx_nregs. Considering the name of the variable, I 
was under impression that scanning DECL_ARGUMENTS is more reliable way 
of checking for argument passing registers.

>>+	  return TARGET_80387
>>+	    ? FPU_MODE_X87 : FPU_MODE_MMX;
>>    
>>
>
>I don't see the value in this.  I think it just makes the code 
>more complex for no reason.  I think default_mode should equal
>x87 mode all the time.
>
>  
>
  Suppose you have a function that uses neither x87, neither MMX 
registers to pass its input arguments and neither x87 reg and mmx reg is 
used as function return register. In this case, MODE_ENTRY of function 
is set to default mode - x87 mode. If some MMX instructions are used in 
function body, an emms insn would be emitted before function exit bb, 
because function exits in default mode, that is FPU_X87.
  Another example is the case, where mmx instructions are emitted 
between a couple  of "default mode" functions. A couple of transitions 
from x87 -> mmx and mmx -> x87 (with emms) will be needed. There is no 
point in that, as user explicitly specified that x87 unit is disabled.
  Perhaps some kind of  I386_FPU_DEFAULT_MODE macro should be used there?

Uros.



More information about the Gcc-patches mailing list