OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [gcc/] [stack-ptr-mod.c] - Diff between revs 684 and 783

Only display areas with differences | Details | Blame | View Log

Rev 684 Rev 783
/* Discover if the stack pointer is modified in a function.
/* Discover if the stack pointer is modified in a function.
   Copyright (C) 2007, 2008, 2009
   Copyright (C) 2007, 2008, 2009
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
Software Foundation; either version 3, or (at your option) any later
version.
version.
 
 
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
#include "tree.h"
#include "tree.h"
#include "rtl.h"
#include "rtl.h"
#include "regs.h"
#include "regs.h"
#include "expr.h"
#include "expr.h"
#include "tree-pass.h"
#include "tree-pass.h"
#include "basic-block.h"
#include "basic-block.h"
#include "flags.h"
#include "flags.h"
#include "output.h"
#include "output.h"
#include "df.h"
#include "df.h"
 
 
/* Determine if the stack pointer is constant over the life of the function.
/* Determine if the stack pointer is constant over the life of the function.
   Only useful before prologues have been emitted.  */
   Only useful before prologues have been emitted.  */
 
 
static void
static void
notice_stack_pointer_modification_1 (rtx x, const_rtx pat ATTRIBUTE_UNUSED,
notice_stack_pointer_modification_1 (rtx x, const_rtx pat ATTRIBUTE_UNUSED,
                                     void *data ATTRIBUTE_UNUSED)
                                     void *data ATTRIBUTE_UNUSED)
{
{
  if (x == stack_pointer_rtx
  if (x == stack_pointer_rtx
      /* The stack pointer is only modified indirectly as the result
      /* The stack pointer is only modified indirectly as the result
         of a push until later.  See the comments in rtl.texi
         of a push until later.  See the comments in rtl.texi
         regarding Embedded Side-Effects on Addresses.  */
         regarding Embedded Side-Effects on Addresses.  */
      || (MEM_P (x)
      || (MEM_P (x)
          && GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == RTX_AUTOINC
          && GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == RTX_AUTOINC
          && XEXP (XEXP (x, 0), 0) == stack_pointer_rtx))
          && XEXP (XEXP (x, 0), 0) == stack_pointer_rtx))
    current_function_sp_is_unchanging = 0;
    current_function_sp_is_unchanging = 0;
}
}
 
 
static void
static void
notice_stack_pointer_modification (void)
notice_stack_pointer_modification (void)
{
{
  basic_block bb;
  basic_block bb;
  rtx insn;
  rtx insn;
 
 
  /* Assume that the stack pointer is unchanging if alloca hasn't
  /* Assume that the stack pointer is unchanging if alloca hasn't
     been used.  */
     been used.  */
  current_function_sp_is_unchanging = !cfun->calls_alloca;
  current_function_sp_is_unchanging = !cfun->calls_alloca;
  if (current_function_sp_is_unchanging)
  if (current_function_sp_is_unchanging)
    FOR_EACH_BB (bb)
    FOR_EACH_BB (bb)
      FOR_BB_INSNS (bb, insn)
      FOR_BB_INSNS (bb, insn)
        {
        {
          if (INSN_P (insn))
          if (INSN_P (insn))
            {
            {
              /* Check if insn modifies the stack pointer.  */
              /* Check if insn modifies the stack pointer.  */
              note_stores (PATTERN (insn),
              note_stores (PATTERN (insn),
                           notice_stack_pointer_modification_1,
                           notice_stack_pointer_modification_1,
                           NULL);
                           NULL);
              if (! current_function_sp_is_unchanging)
              if (! current_function_sp_is_unchanging)
                return;
                return;
            }
            }
        }
        }
 
 
  /* The value coming into this pass was 0, and the exit block uses
  /* The value coming into this pass was 0, and the exit block uses
     are based on this.  If the value is now 1, we need to redo the
     are based on this.  If the value is now 1, we need to redo the
     exit block uses.  */
     exit block uses.  */
  if (df && current_function_sp_is_unchanging)
  if (df && current_function_sp_is_unchanging)
    df_update_exit_block_uses ();
    df_update_exit_block_uses ();
}
}
 
 
  /* Some targets can emit simpler epilogues if they know that sp was
  /* Some targets can emit simpler epilogues if they know that sp was
     not ever modified during the function.  After reload, of course,
     not ever modified during the function.  After reload, of course,
     we've already emitted the epilogue so there's no sense searching.  */
     we've already emitted the epilogue so there's no sense searching.  */
 
 
static unsigned int
static unsigned int
rest_of_handle_stack_ptr_mod (void)
rest_of_handle_stack_ptr_mod (void)
{
{
  notice_stack_pointer_modification ();
  notice_stack_pointer_modification ();
  return 0;
  return 0;
}
}
 
 
struct rtl_opt_pass pass_stack_ptr_mod =
struct rtl_opt_pass pass_stack_ptr_mod =
{
{
 {
 {
  RTL_PASS,
  RTL_PASS,
  "*stack_ptr_mod",                     /* name */
  "*stack_ptr_mod",                     /* name */
  NULL,                                 /* gate */
  NULL,                                 /* gate */
  rest_of_handle_stack_ptr_mod,         /* execute */
  rest_of_handle_stack_ptr_mod,         /* execute */
  NULL,                                 /* sub */
  NULL,                                 /* sub */
  NULL,                                 /* next */
  NULL,                                 /* next */
  0,                                    /* static_pass_number */
  0,                                    /* static_pass_number */
  TV_NONE,                              /* tv_id */
  TV_NONE,                              /* tv_id */
  0,                                    /* properties_required */
  0,                                    /* properties_required */
  0,                                    /* properties_provided */
  0,                                    /* properties_provided */
  0,                                    /* properties_destroyed */
  0,                                    /* properties_destroyed */
  0,                                    /* todo_flags_start */
  0,                                    /* todo_flags_start */
  0                                     /* todo_flags_finish */
  0                                     /* todo_flags_finish */
 }
 }
};
};
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.