]>
Commit | Line | Data |
---|---|---|
3250221d | 1 | /* Function integration definitions for GNU C-Compiler |
e5e809f4 | 2 | Copyright (C) 1990, 1995, 1998 Free Software Foundation, Inc. |
3250221d RS |
3 | |
4 | This file is part of GNU CC. | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
a35311b0 RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
3250221d | 20 | |
c68da89c KR |
21 | #include "varray.h" |
22 | ||
3250221d RS |
23 | /* This structure is used to remap objects in the function being inlined to |
24 | those belonging to the calling function. It is passed by | |
25 | expand_inline_function to its children. | |
26 | ||
27 | This structure is also used when unrolling loops and otherwise | |
28 | replicating code, although not all fields are needed in this case; | |
29 | only those fields needed by copy_rtx_and_substitute() and its children | |
30 | are used. | |
31 | ||
32 | This structure is used instead of static variables because | |
33 | expand_inline_function may be called recursively via expand_expr. */ | |
34 | ||
35 | struct inline_remap | |
36 | { | |
11d1f673 JW |
37 | /* True if we are doing function integration, false otherwise. |
38 | Used to control whether RTX_UNCHANGING bits are copied by | |
39 | copy_rtx_and_substitute. */ | |
40 | int integrating; | |
3250221d RS |
41 | /* Definition of function be inlined. */ |
42 | union tree_node *fndecl; | |
43 | /* Place to put insns needed at start of function. */ | |
44 | rtx insns_at_start; | |
45 | /* Mapping from old registers to new registers. | |
46 | It is allocated and deallocated in `expand_inline_function' */ | |
47 | rtx *reg_map; | |
48 | /* Mapping from old code-labels to new code-labels. | |
49 | The first element of this map is label_map[min_labelno]. */ | |
50 | rtx *label_map; | |
51 | /* Mapping from old insn uid's to copied insns. The first element | |
52 | of this map is insn_map[min_insnno]; the last element is | |
53 | insn_map[max_insnno]. We keep the bounds here for when the map | |
54 | only covers a partial range of insns (such as loop unrolling or | |
55 | code replication). */ | |
56 | rtx *insn_map; | |
57 | int min_insnno, max_insnno; | |
58 | ||
59 | /* Map pseudo reg number in calling function to equivalent constant. We | |
60 | cannot in general substitute constants into parameter pseudo registers, | |
61 | since some machine descriptions (many RISCs) won't always handle | |
62 | the resulting insns. So if an incoming parameter has a constant | |
63 | equivalent, we record it here, and if the resulting insn is | |
64 | recognizable, we go with it. | |
65 | ||
66 | We also use this mechanism to convert references to incoming arguments | |
67 | and stacked variables. copy_rtx_and_substitute will replace the virtual | |
68 | incoming argument and virtual stacked variables registers with new | |
69 | pseudos that contain pointers into the replacement area allocated for | |
70 | this inline instance. These pseudos are then marked as being equivalent | |
71 | to the appropriate address and substituted if valid. */ | |
c68da89c | 72 | varray_type const_equiv_varray; |
3250221d | 73 | /* This is incremented for each new basic block. |
c68da89c KR |
74 | It is used to store in the age field to record the domain of validity |
75 | of each entry in const_equiv_varray. | |
3250221d RS |
76 | A value of -1 indicates an entry for a reg which is a parm. |
77 | All other values are "positive". */ | |
78 | #define CONST_AGE_PARM (-1) | |
79 | unsigned int const_age; | |
c68da89c | 80 | |
3250221d RS |
81 | /* Target of the inline function being expanded, or NULL if none. */ |
82 | rtx inline_target; | |
83 | /* When an insn is being copied by copy_rtx_and_substitute, | |
84 | this is nonzero if we have copied an ASM_OPERANDS. | |
85 | In that case, it is the original input-operand vector. */ | |
86 | rtvec orig_asm_operands_vector; | |
87 | /* When an insn is being copied by copy_rtx_and_substitute, | |
88 | this is nonzero if we have copied an ASM_OPERANDS. | |
89 | In that case, it is the copied input-operand vector. */ | |
90 | rtvec copy_asm_operands_vector; | |
91 | /* Likewise, this is the copied constraints vector. */ | |
92 | rtvec copy_asm_constraints_vector; | |
93 | ||
3051365e RK |
94 | /* Indications for regs being pointers and their alignment. */ |
95 | char *regno_pointer_flag; | |
96 | char *regno_pointer_align; | |
97 | ||
3250221d RS |
98 | /* The next few fields are used for subst_constants to record the SETs |
99 | that it saw. */ | |
100 | int num_sets; | |
101 | struct equiv_table | |
102 | { | |
103 | rtx dest; | |
104 | rtx equiv; | |
105 | } equiv_sets[MAX_RECOG_OPERANDS]; | |
106 | /* Record the last thing assigned to pc. This is used for folded | |
107 | conditional branch insns. */ | |
108 | rtx last_pc_value; | |
109 | #ifdef HAVE_cc0 | |
110 | /* Record the last thing assigned to cc0. */ | |
111 | rtx last_cc0_value; | |
112 | #endif | |
113 | }; | |
114 | ||
115 | /* Return a copy of an rtx (as needed), substituting pseudo-register, | |
116 | labels, and frame-pointer offsets as necessary. */ | |
521f2d6f | 117 | extern rtx copy_rtx_and_substitute PROTO((rtx, struct inline_remap *)); |
3250221d | 118 | |
521f2d6f | 119 | extern void try_constants PROTO((rtx, struct inline_remap *)); |
3250221d | 120 | |
521f2d6f | 121 | extern void mark_stores PROTO((rtx, rtx)); |
3250221d | 122 | |
1f3d3a31 JL |
123 | /* Return the label indicated. */ |
124 | extern rtx get_label_from_map PROTO((struct inline_remap *, int)); | |
125 | ||
126 | /* Set the label indicated. */ | |
e5e809f4 | 127 | #define set_label_in_map(MAP, I, X) ((MAP)->label_map[I] = (X)) |
1f3d3a31 | 128 | |
c68da89c KR |
129 | /* Unfortunately, we need a global copy of const_equiv varray for |
130 | communication with a function called from note_stores. Be *very* | |
131 | careful that this is used properly in the presence of recursion. */ | |
132 | ||
133 | extern varray_type global_const_equiv_varray; | |
134 | ||
135 | #define MAYBE_EXTEND_CONST_EQUIV_VARRAY(MAP,MAX) \ | |
136 | { \ | |
137 | if ((MAX) >= VARRAY_SIZE ((MAP)->const_equiv_varray)) \ | |
138 | { \ | |
139 | int is_global = (global_const_equiv_varray \ | |
140 | == (MAP)->const_equiv_varray); \ | |
141 | VARRAY_GROW ((MAP)->const_equiv_varray, (MAX)+1); \ | |
142 | if (is_global) \ | |
143 | global_const_equiv_varray = (MAP)->const_equiv_varray; \ | |
144 | } \ | |
145 | } | |
146 | ||
147 | #define SET_CONST_EQUIV_DATA(MAP,REG,RTX,AGE) \ | |
148 | { \ | |
149 | struct const_equiv_data *p; \ | |
150 | MAYBE_EXTEND_CONST_EQUIV_VARRAY ((MAP), REGNO (REG)); \ | |
151 | p = &VARRAY_CONST_EQUIV ((MAP)->const_equiv_varray, REGNO (REG)); \ | |
152 | p->rtx = (RTX); \ | |
153 | p->age = (AGE); \ | |
154 | } |