>> >> +/* Generate insns to zero all st/mm registers together. >> + Return true when zeroing instructions are generated. >> + Assume the number of st registers that are zeroed is num_of_st, >> + we will emit the following sequence to zero them together: >> + fldz; \ >> + fldz; \ >> + ... >> + fldz; \ >> + fstp %%st(0); \ >> + fstp %%st(0); \ >> + ... >> + fstp %%st(0); >> + i.e., num_of_st fldz followed by num_of_st fstp to clear the stack >> + mark stack slots empty. */ >> + >> +static bool >> +zero_all_st_mm_registers (HARD_REG_SET need_zeroed_hardregs) >> +{ >> + unsigned int num_of_st = 0; >> + for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) >> + if (STACK_REGNO_P (regno) >> + && TEST_HARD_REG_BIT (need_zeroed_hardregs, regno) >> + /* When the corresponding mm register also need to be cleared too. >> */ >> + && TEST_HARD_REG_BIT (need_zeroed_hardregs, >> + (regno - FIRST_STACK_REG + FIRST_MMX_REG))) >> + num_of_st++; > > I don't think the above logic is correct. It should go like this: > > - If the function is returning an MMX register,
How to check on this? Is the following correct? If (GET_CODE(crtl->return_rtx) == REG && (MMX_REG_P (REGNO (crtl->return_rtx))) The function is returning an MMX register. > then the function > exits in MMX mode, and MMX registers should be cleared in the same way > as XMM registers. When clearing XMM registers, we used V4SFmode, what’s the mode we should use to clearing mmx registers? > Otherwise the ABI specifies that the function exits > in x87 mode and x87 stack should be cleared (but see below). > > - There is no direct mapping of stack registers to hard register > numbers. If a stack register is used, we don't know where in the stack > the value remains. So, if _any_ stack register is touched, the whole > stack should be cleared (value, returning in x87 stack register should > obviously be excluded). Then, how to exclude the x87 stack register that returns the function return value when we need to Clear the whole stack? I am a little confused here? Could you explain a little more details? > > - There is no x87 argument register. 32bit targets use MMX0-3 argument > registers and return value in the XMM register. Please also note that > complex values take two stack slots in x87 stack. You mean the complex return value will be returned in two x87 registers? thanks. Qing > > Uros. > >> + >> + if (num_of_st == 0)