Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.48 KB | None | 0 0
  1. diff --git a/gcc/config/or1k/or1k-protos.h b/gcc/config/or1k/or1k-protos.h
  2. index d4a2533..68a2954 100644
  3. --- a/gcc/config/or1k/or1k-protos.h
  4. +++ b/gcc/config/or1k/or1k-protos.h
  5. @@ -26,6 +26,7 @@ extern int         or1k_trampoline_code_size (void);
  6.  
  7.  /* The following are only needed when handling the machine definition. */
  8.  #ifdef RTX_CODE
  9. +extern void        or1k_init_expanders (void);
  10.  extern void        or1k_expand_prologue (void);
  11.  extern void        or1k_expand_epilogue (void);
  12.  extern bool        or1k_expand_move (enum machine_mode mode, rtx operands[]);
  13. diff --git a/gcc/config/or1k/or1k.c b/gcc/config/or1k/or1k.c
  14. index 88e0e07..646eae0 100644
  15. --- a/gcc/config/or1k/or1k.c
  16. +++ b/gcc/config/or1k/or1k.c
  17. @@ -134,7 +134,8 @@ or1k_save_reg_p (int regno)
  18.    /* We need to save the incoming return address if it is ever clobbered
  19.       within the function.  */
  20.    if (regno == LINK_REGNUM
  21. -      && (df_regs_ever_live_p(regno) || crtl->uses_pic_offset_table))
  22. +      && (df_regs_ever_live_p(regno) || crtl->uses_pic_offset_table
  23. +          || cfun->machine->force_lr_save))
  24.      return true;
  25.  
  26.    if(crtl->calls_eh_return)
  27. @@ -2123,15 +2124,14 @@ or1k_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED)
  28.    if (count != 0)
  29.      return const0_rtx;
  30.  
  31. -  or1k_compute_frame_size (get_frame_size ());
  32. +  /* We don't know if LR is going to be saved or if we're going to
  33. +   * be clobbering it with the GOT instruction.
  34. +   * Therefore the safest bet is to force a save of LR and use that.
  35. +   * Assume it's going to be first in the stack. */
  36.  
  37. -  /* If we clobber the LR register, we should have saved it.
  38. -   * If we didn't save it - assume it's still in LR */
  39. -  if (frame_info.save_lr_p)
  40. -    return gen_rtx_MEM (Pmode, plus_constant (Pmode, arg_pointer_rtx,
  41. -                                              frame_info.lr_save_offset));
  42. -  else
  43. -    return get_hard_reg_initial_val (Pmode, LINK_REGNUM);
  44. +  cfun->machine->force_lr_save = true;
  45. +  return gen_rtx_MEM (Pmode, plus_constant (Pmode, arg_pointer_rtx,
  46. +                                            -UNITS_PER_WORD));
  47.  }
  48.  
  49.  /* Implement TARGET_FRAME_POINTER_REQUIRED.
  50. @@ -2142,6 +2142,26 @@ or1k_frame_pointer_required (void)
  51.    return crtl->calls_eh_return || cfun->calls_alloca;
  52.  }
  53.  
  54. +/* Functions to save and restore machine-specific function data.  */
  55. +static struct machine_function *
  56. +or1k_init_machine_status (void)
  57. +{
  58. +    return ggc_alloc_cleared_machine_function ();
  59. +}
  60. +
  61. +void
  62. +or1k_init_expanders (void)
  63. +{
  64. +  /* Arrange to initialize and mark the machine per-function
  65. +   * status.  */
  66. +  init_machine_status = or1k_init_machine_status;
  67. +
  68. +  if (cfun && cfun->machine)
  69. +    {
  70. +      cfun->machine->force_lr_save = false;
  71. +    }
  72. +}
  73. +
  74.  #undef  TARGET_FRAME_POINTER_REQUIRED
  75.  #define TARGET_FRAME_POINTER_REQUIRED or1k_frame_pointer_required
  76.  
  77. diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
  78. index 50db43e..3b538fb 100644
  79. --- a/gcc/config/or1k/or1k.h
  80. +++ b/gcc/config/or1k/or1k.h
  81. @@ -1189,4 +1189,14 @@ enum reg_class
  82.  #define EH_RETURN_STACKADJ_RTX  gen_rtx_REG (Pmode, EH_RETURN_REGNUM)
  83.  #define EH_RETURN_HANDLER_RTX   or1k_eh_return_handler_rtx ()
  84.  
  85. +#define INIT_EXPANDERS or1k_init_expanders ()
  86. +
  87. +/* A C structure for machine-specific, per-function data.  This is
  88. + *    added to the cfun structure.  */
  89. +typedef struct GTY(()) machine_function
  90. +{
  91. +  /* Force stack save of LR. Used in RETURN_ADDR_RTX. */
  92. +  int force_lr_save;
  93. +} machine_function;
  94. +
  95.  #endif /* _OR1K_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement