Hello!

A sse function that gets its parameters via xmm regs and returns its result in
xmm reg is defined as:

__m128
func_sse (__m128 x, __m128 y)
{
  __m128 xmm;

  xmm = _mm_add_ss (x, y);
  return xmm;
}

The RTL code that is used to call this function is produced as:

(call_insn/u:HI 30 29 31 0 (set (reg:V4SF 21 xmm0)
        (call (mem:QI (symbol_ref:SI ("func_sse") [flags 0x3] <function_decl
0x403cd948 func_sse>) [0 S1 A8])
            (const_int 0 [0x0]))) 529 {*call_value_0} (insn_list:REG_DEP_TRUE 28
(insn_list:REG_DEP_TRUE 29 (nil)))
    (insn_list:REG_RETVAL 28 (expr_list:REG_DEAD (reg:V4SF 22 xmm1 [ xmm1 ])
            (expr_list:REG_EH_REGION (const_int -1 [0xffffffff])
                (nil))))
    (expr_list:REG_DEP_TRUE (use (reg:V4SF 21 xmm0 [ xmm0 ]))
        (expr_list:REG_DEP_TRUE (use (reg:V4SF 22 xmm1 [ xmm1 ]))
            (nil))))

To implement a LCM pass to switch FPU between MMX and x87 mode (the example
above is a call to SSE function, currently the call to MMX function is wrong,
see PR21981), the type of registers, used to pass parameters is needed for
MODE_NEEDED macro to insert correct mode for the call - that is FPU_MODE_MMX if
there are MMX registers used and FPU_MODE_X87 otherwise:

  if (entity == I387_FPU_MODE)
    {
      if (CALL_P (insn))
        {
          if ("mmx registers are used")    <<< here we should check for MMX regs
            return FPU_MODE_MMX;
          else
            return FPU_MODE_X87;
        }

      mode = get_attr_unit (insn);

      return (mode == UNIT_I387)
        ? FPU_MODE_X87 : (mode == UNIT_MMX)
        ? FPU_MODE_MMX : FPU_MODE_ANY;
    }


Secondly, if return value is placed in MMX regsister, MODE_AFTER after call insn
should set mode state to FPU_MODE_MMX, otherwise to FPU_MODE_X87.

To properly implement this switching scheme, I would like to ask, what is the
proper way to check if MMX register is used as a parameter passing register in
the call, and how to check if MMX register is used to hold return value. This
information is needed to properly calculate MODE_NEEDED and MODE_AFTER values
for function call in LCM pass.

In the function itself, we can handle entry and exit mode using
MODE_ENTRY and MODE_EXIT macros. Entry mode would be set to FPU_MODE_MMX if MMX
registers are used for parameter passing and exit mode would be set to
FPU_MODE_MMX if MMX reg is used to hold return value. Otherwise, they would both
be set to FPU_MODE_X87.

I would like to obtain the same information in function itself to
properly set MODE_ENTRY and MODE_EXIT in LCM pass. Is there an recommended
approach on how to get this information?

Thanks in advance,

Uros.

Reply via email to