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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [stack-ptr-mod.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 280 jeremybenn
/* Discover if the stack pointer is modified in a function.
2
   Copyright (C) 2007, 2008, 2009
3
   Free Software Foundation, Inc.
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 3, or (at your option) any later
10
version.
11
 
12
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13
WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15
for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.  */
20
 
21
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "tm.h"
25
#include "tree.h"
26
#include "rtl.h"
27
#include "regs.h"
28
#include "expr.h"
29
#include "tree-pass.h"
30
#include "basic-block.h"
31
#include "flags.h"
32
#include "output.h"
33
#include "df.h"
34
 
35
/* Determine if the stack pointer is constant over the life of the function.
36
   Only useful before prologues have been emitted.  */
37
 
38
static void
39
notice_stack_pointer_modification_1 (rtx x, const_rtx pat ATTRIBUTE_UNUSED,
40
                                     void *data ATTRIBUTE_UNUSED)
41
{
42
  if (x == stack_pointer_rtx
43
      /* The stack pointer is only modified indirectly as the result
44
         of a push until later.  See the comments in rtl.texi
45
         regarding Embedded Side-Effects on Addresses.  */
46
      || (MEM_P (x)
47
          && GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == RTX_AUTOINC
48
          && XEXP (XEXP (x, 0), 0) == stack_pointer_rtx))
49
    current_function_sp_is_unchanging = 0;
50
}
51
 
52
static void
53
notice_stack_pointer_modification (void)
54
{
55
  basic_block bb;
56
  rtx insn;
57
 
58
  /* Assume that the stack pointer is unchanging if alloca hasn't
59
     been used.  */
60
  current_function_sp_is_unchanging = !cfun->calls_alloca;
61
  if (current_function_sp_is_unchanging)
62
    FOR_EACH_BB (bb)
63
      FOR_BB_INSNS (bb, insn)
64
        {
65
          if (INSN_P (insn))
66
            {
67
              /* Check if insn modifies the stack pointer.  */
68
              note_stores (PATTERN (insn),
69
                           notice_stack_pointer_modification_1,
70
                           NULL);
71
              if (! current_function_sp_is_unchanging)
72
                return;
73
            }
74
        }
75
 
76
  /* The value coming into this pass was 0, and the exit block uses
77
     are based on this.  If the value is now 1, we need to redo the
78
     exit block uses.  */
79
  if (df && current_function_sp_is_unchanging)
80
    df_update_exit_block_uses ();
81
}
82
 
83
  /* Some targets can emit simpler epilogues if they know that sp was
84
     not ever modified during the function.  After reload, of course,
85
     we've already emitted the epilogue so there's no sense searching.  */
86
 
87
static unsigned int
88
rest_of_handle_stack_ptr_mod (void)
89
{
90
  notice_stack_pointer_modification ();
91
  return 0;
92
}
93
 
94
struct rtl_opt_pass pass_stack_ptr_mod =
95
{
96
 {
97
  RTL_PASS,
98
  "*stack_ptr_mod",                     /* name */
99
  NULL,                                 /* gate */
100
  rest_of_handle_stack_ptr_mod,         /* execute */
101
  NULL,                                 /* sub */
102
  NULL,                                 /* next */
103
  0,                                    /* static_pass_number */
104
  TV_NONE,                              /* tv_id */
105
  0,                                    /* properties_required */
106
  0,                                    /* properties_provided */
107
  0,                                    /* properties_destroyed */
108
  0,                                    /* todo_flags_start */
109
 
110
 }
111
};

powered by: WebSVN 2.1.0

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