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: [RFC] RTL prologue/epilogue for SPARC


> Ok, thanks for the explanation.  My problem comes from emitting the 
> prologue/epilogue later than usual (because of the register window).

I don't see why this should cause a problem (other than stressing the
cfglayout code a bit more).  You just hand on to the edge pointing to
EXIT_BLOCK_POINTER a bit longer.

> The following change solves it:
> 
> Index: cfglayout.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 cfglayout.c
> --- cfglayout.c 16 Jun 2004 16:49:22 -0000      1.62
> +++ cfglayout.c 21 Jun 2004 15:09:03 -0000
> @@ -1208,7 +1208,7 @@ cfg_layout_finalize (void)
>    rtl_register_cfg_hooks ();
>    if (reload_completed
>  #ifdef HAVE_epilogue
> -      && !HAVE_epilogue
> +      && (!HAVE_epilogue || !epilogue_completed)
>  #endif
>        )
>      fixup_fallthru_exit_predecessor ();
> 
> Does it look correct to you?

I don't think it would cause incorrect code to be generated or ICEs, but it
papers over a problem in your machine description, at the expense of giving
worse code for tagets that set late_rtl_prologue_epilogue.  (Admittedly,
that's currently only SPARC.)

> > Incidentally, your sparc patch violates the requirement that the
> > "epilogue" pattern should emit the return instruction.
> 
> I think you misread:
> 
> ! (define_expand "epilogue"
> !   [(return)]
> !   ""
> ! {
> !   sparc_expand_epilogue ();
> ! })
> 

No, it's right there:

! /* Expand the function epilogue, either normal or part of a sibcall.
!    We emit all the instructions except the return or the call.  */
! 
! void
! sparc_expand_epilogue (void)
! {
!   int leaf_function_p = current_function_uses_only_leaf_regs;
  
    if (num_gfregs)
!     emit_restore_regs ();
  
!   if (actual_fsize == 0)
!     /* do nothing.  */ ;
!   else if (leaf_function_p)
!     {
!       if (actual_fsize <= 4096)
!       emit_stack_pointer_decrement (GEN_INT (- actual_fsize));
!       else if (actual_fsize <= 8192)
        {
!         emit_stack_pointer_decrement (GEN_INT (-4096));
!         emit_stack_pointer_decrement (GEN_INT (4096 - actual_fsize));
        }
        else
        {
!         rtx reg = gen_rtx_REG (Pmode, 1);
!         emit_move_insn (reg, GEN_INT (-actual_fsize));
!         emit_stack_pointer_decrement (reg);
        }
      }
  }


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