PR c++/11645
[official-gcc.git] / gcc / integrate.h
blob94bf2e738d4791b1f50f91240a9a0affbf98135a
1 /* Function integration definitions for GCC
2 Copyright (C) 1990, 1995, 1998, 1999, 2000, 2001, 2003
3 Free Software Foundation, Inc.
5 This file is part of GCC.
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 2, or (at your option) any later
10 version.
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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 #include "varray.h"
24 /* This structure is used to remap objects in the function being inlined to
25 those belonging to the calling function. It is passed by
26 expand_inline_function to its children.
28 This structure is also used when unrolling loops and otherwise
29 replicating code, although not all fields are needed in this case;
30 only those fields needed by copy_rtx_and_substitute() and its children
31 are used.
33 This structure is used instead of static variables because
34 expand_inline_function may be called recursively via expand_expr. */
36 struct inline_remap
38 /* True if we are doing function integration, false otherwise.
39 Used to control whether RTX_UNCHANGING bits are copied by
40 copy_rtx_and_substitute. */
41 int integrating;
42 /* Definition of function be inlined. */
43 tree fndecl;
44 /* Place to put insns needed at start of function. */
45 rtx insns_at_start;
46 /* Mapping from old BLOCKs to new BLOCKs. */
47 varray_type block_map;
48 /* Mapping from old registers to new registers.
49 It is allocated and deallocated in `expand_inline_function' */
50 rtx *reg_map;
51 #if defined (LEAF_REGISTERS) && defined (LEAF_REG_REMAP)
52 /* Mapping from old leaf registers to new leaf registers. */
53 rtx leaf_reg_map[FIRST_PSEUDO_REGISTER][NUM_MACHINE_MODES];
54 #endif
55 /* Mapping from old code-labels to new code-labels.
56 The first element of this map is label_map[min_labelno]. */
57 rtx *label_map;
58 /* Mapping from old insn uid's to copied insns. The first element
59 of this map is insn_map[min_insnno]; the last element is
60 insn_map[max_insnno]. We keep the bounds here for when the map
61 only covers a partial range of insns (such as loop unrolling or
62 code replication). */
63 rtx *insn_map;
64 int min_insnno, max_insnno;
66 /* Map pseudo reg number in calling function to equivalent constant. We
67 cannot in general substitute constants into parameter pseudo registers,
68 since some machine descriptions (many RISCs) won't always handle
69 the resulting insns. So if an incoming parameter has a constant
70 equivalent, we record it here, and if the resulting insn is
71 recognizable, we go with it.
73 We also use this mechanism to convert references to incoming arguments
74 and stacked variables. copy_rtx_and_substitute will replace the virtual
75 incoming argument and virtual stacked variables registers with new
76 pseudos that contain pointers into the replacement area allocated for
77 this inline instance. These pseudos are then marked as being equivalent
78 to the appropriate address and substituted if valid. */
79 varray_type const_equiv_varray;
80 /* This is incremented for each new basic block.
81 It is used to store in the age field to record the domain of validity
82 of each entry in const_equiv_varray.
83 A value of -1 indicates an entry for a reg which is a parm.
84 All other values are "positive". */
85 #define CONST_AGE_PARM (-1)
86 unsigned int const_age;
88 /* Target of the inline function being expanded, or NULL if none. */
89 rtx inline_target;
90 /* When an insn is being copied by copy_rtx_and_substitute,
91 this is nonzero if we have copied an ASM_OPERANDS.
92 In that case, it is the original input-operand vector. */
93 rtvec orig_asm_operands_vector;
94 /* When an insn is being copied by copy_rtx_and_substitute,
95 this is nonzero if we have copied an ASM_OPERANDS.
96 In that case, it is the copied input-operand vector. */
97 rtvec copy_asm_operands_vector;
98 /* Likewise, this is the copied constraints vector. */
99 rtvec copy_asm_constraints_vector;
101 /* Target of a return insn, if needed and inlining. */
102 rtx local_return_label;
104 /* Indications for regs being pointers and their alignment. */
105 unsigned char *regno_pointer_align;
106 rtx *x_regno_reg_rtx;
108 /* The next few fields are used for subst_constants to record the SETs
109 that it saw. */
110 int num_sets;
111 struct equiv_table
113 rtx dest;
114 rtx equiv;
115 } equiv_sets[MAX_RECOG_OPERANDS];
116 /* Record the last thing assigned to pc. This is used for folded
117 conditional branch insns. */
118 rtx last_pc_value;
119 #ifdef HAVE_cc0
120 /* Record the last thing assigned to cc0. */
121 rtx last_cc0_value;
122 #endif
123 /* Note mode of COMPARE if the mode would be otherwise lost (comparing of
124 two VOIDmode constants. */
125 rtx compare_src;
126 enum machine_mode compare_mode;
129 /* Return a copy of an rtx (as needed), substituting pseudo-register,
130 labels, and frame-pointer offsets as necessary. */
131 extern rtx copy_rtx_and_substitute (rtx, struct inline_remap *, int);
133 /* Return a pseudo that corresponds to the value in the specified hard
134 reg as of the start of the function (for inlined functions, the
135 value at the start of the parent function). */
136 extern rtx get_hard_reg_initial_val (enum machine_mode, int);
137 /* Likewise, but for a different than the current function, or
138 arbitrary expression. */
139 extern rtx get_func_hard_reg_initial_val (struct function *, rtx);
140 /* Likewise, but iff someone else has caused it to become allocated. */
141 extern rtx has_func_hard_reg_initial_val (struct function *, rtx);
142 /* Likewise, but for common cases. */
143 extern rtx has_hard_reg_initial_val (enum machine_mode, int);
144 /* If a pseudo represents an initial hard reg (or expression), return
145 it, else return NULL_RTX. */
146 extern rtx get_hard_reg_initial_reg (struct function *, rtx);
147 /* Called from rest_of_compilation. */
148 extern void emit_initial_value_sets (void);
149 extern void allocate_initial_values (rtx *);
151 /* Copy a declaration when one function is substituted inline into
152 another. */
153 extern tree copy_decl_for_inlining (tree, tree, tree);
155 /* Check whether there's any attribute in a function declaration that
156 makes the function uninlinable. Returns false if it finds any,
157 true otherwise. */
158 extern bool function_attribute_inlinable_p (tree);
160 extern void try_constants (rtx, struct inline_remap *);
162 /* Return the label indicated. */
163 extern rtx get_label_from_map (struct inline_remap *, int);
165 /* Set the label indicated. */
166 #define set_label_in_map(MAP, I, X) ((MAP)->label_map[I] = (X))
168 /* Unfortunately, we need a global copy of const_equiv varray for
169 communication with a function called from note_stores. Be *very*
170 careful that this is used properly in the presence of recursion. */
172 extern varray_type global_const_equiv_varray;
174 #define MAYBE_EXTEND_CONST_EQUIV_VARRAY(MAP,MAX) \
176 if ((size_t)(MAX) >= VARRAY_SIZE ((MAP)->const_equiv_varray)) \
178 int is_global = (global_const_equiv_varray \
179 == (MAP)->const_equiv_varray); \
180 VARRAY_GROW ((MAP)->const_equiv_varray, (MAX)+1); \
181 if (is_global) \
182 global_const_equiv_varray = (MAP)->const_equiv_varray; \
186 #define SET_CONST_EQUIV_DATA(MAP,REG,RTX,AGE) \
188 struct const_equiv_data *p; \
189 MAYBE_EXTEND_CONST_EQUIV_VARRAY ((MAP), REGNO (REG)); \
190 p = &VARRAY_CONST_EQUIV ((MAP)->const_equiv_varray, REGNO (REG)); \
191 p->rtx = (RTX); \
192 p->age = (AGE); \