OSDN Git Service

* except.c (expand_eh_region_start_tree): Add DECL argument so we
[pf3gnuchains/gcc-fork.git] / gcc / except.h
1 /* Exception Handling interface routines.
2    Copyright (C) 1996 Free Software Foundation, Inc.
3    Contributed by Mike Stump <mrs@cygnus.com>.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22
23 #ifndef GET_CODE
24 #define rtx int *
25 #endif
26
27 #ifdef TREE_CODE
28
29 /* A stack of labels. CHAIN points to the next entry in the stack.  */
30
31 struct label_node {
32   union {
33     rtx rlabel;
34     tree tlabel;
35   } u;
36   struct label_node *chain;
37 };
38
39 /* An eh_entry is used to describe one exception handling region.
40
41    START_LABEL is the label corresponding to the start of the region.
42
43    END_LABEL is the label corresponding to the end of the region.
44
45    EXCEPTION_HANDLER_LABEL is the label corresponding to the handler
46    for this region.
47
48    FINALIZATION is the tree codes for the handler, or is NULL_TREE if
49    one hasn't been generated yet, or is integer_zero_node to mark the
50    end of a group of try blocks.  */
51
52 struct eh_entry {
53   rtx start_label;
54   rtx end_label;
55   rtx exception_handler_label;
56
57   tree finalization;
58 };
59
60 /* A list of EH_ENTRYs. ENTRY is the entry; CHAIN points to the next
61    entry in the list, or is NULL if this is the last entry.  */
62
63 struct eh_node {
64   struct eh_entry *entry;
65   struct eh_node *chain;
66 };
67
68 /* A stack of EH_ENTRYs. TOP is the topmost entry on the stack. TOP is
69    NULL if the stack is empty.  */
70
71 struct eh_stack {
72   struct eh_node *top;
73 };
74
75 /* A queue of EH_ENTRYs. HEAD is the front of the queue; TAIL is the
76    end (the latest entry). HEAD and TAIL are NULL if the queue is
77    empty.  */
78
79 struct eh_queue {
80   struct eh_node *head;
81   struct eh_node *tail;
82 };
83
84
85 /* Start an exception handling region.  All instructions emitted after
86    this point are considered to be part of the region until
87    expand_eh_region_end () is invoked.  */
88
89 extern void expand_eh_region_start              PROTO((void));
90
91 /* Just like expand_eh_region_start, except if a cleanup action is
92    entered on the cleanup chain, the TREE_PURPOSE of the element put
93    on the chain is DECL.  DECL should be the associated VAR_DECL, if
94    any, otherwise it should be NULL_TREE.  */
95
96 extern void expand_eh_region_start_for_decl     PROTO((tree));
97
98 /* Start an exception handling region for the given cleanup action.
99    All instructions emitted after this point are considered to be part
100    of the region until expand_eh_region_end () is invoked.  CLEANUP is
101    the cleanup action to perform.  The return value is true if the
102    exception region was optimized away.  If that case,
103    expand_eh_region_end does not need to be called for this cleanup,
104    nor should it be.
105
106    This routine notices one particular common case in C++ code
107    generation, and optimizes it so as to not need the exception
108    region.  */
109
110 extern int expand_eh_region_start_tree          PROTO((tree, tree));
111
112 /* End an exception handling region.  The information about the region
113    is found on the top of ehstack.
114
115    HANDLER is either the cleanup for the exception region, or if we're
116    marking the end of a try block, HANDLER is integer_zero_node.
117
118    HANDLER will be transformed to rtl when expand_leftover_cleanups ()
119    is invoked.  */
120
121 extern void expand_eh_region_end                PROTO((tree));
122
123 /* Push RLABEL or TLABEL onto LABELSTACK. Only one of RLABEL or TLABEL
124    should be set; the other must be NULL.  */
125
126 extern void push_label_entry                    PROTO((struct label_node **labelstack, rtx rlabel, tree tlabel));
127
128 /* Pop the topmost entry from LABELSTACK and return its value as an
129    rtx node. If LABELSTACK is empty, return NULL.  */
130
131 extern rtx pop_label_entry                      PROTO((struct label_node **labelstack));
132
133 /* Return the topmost entry of LABELSTACK as a tree node, or return
134    NULL_TREE if LABELSTACK is empty.  */
135
136 extern tree top_label_entry                     PROTO((struct label_node **labelstack));
137
138 /* A set of insns for the catch clauses in the current function. They
139    will be emitted at the end of the current function.  */
140
141 extern rtx catch_clauses;
142
143 #endif
144
145 struct function;
146
147 /* Toplevel initialization for EH.  */
148
149 extern void init_eh                             PROTO((void));
150
151 /* Initialization for the per-function EH data.  */
152
153 extern void init_eh_for_function                PROTO((void));
154
155 /* Saves the current per-function EH data into P.  */
156
157 extern void save_eh_status                      PROTO((struct function *p));
158
159 /* Restores the per-function EH data from P.  */
160
161 extern void restore_eh_status                   PROTO((struct function *p));
162
163 /* Adds an EH table entry for EH entry number N. Called from
164    final_scan_insn for NOTE_INSN_EH_REGION_BEG.  */
165
166 extern void add_eh_table_entry                  PROTO((int n));
167
168 /* Returns a non-zero value if we need to output an exception table.  */
169
170 extern int exception_table_p                    PROTO((void));
171
172 /* Outputs the exception table if we have one.  */
173
174 extern void output_exception_table              PROTO((void));
175
176 /* Given a return address in ADDR, determine the address we should use
177    to find the corresponding EH region.  */
178
179 extern rtx eh_outer_context                     PROTO((rtx addr));
180
181 /* Called at the start of a block of try statements for which there is
182    a supplied catch handler.  */
183
184 extern void expand_start_try_stmts              PROTO((void));
185
186 /* Called at the start of a block of catch statements. It terminates the
187    previous set of try statements.  */
188
189 extern void expand_start_all_catch              PROTO((void));
190
191 /* Called at the end of a block of catch statements.  */
192
193 extern void expand_end_all_catch                PROTO((void));
194
195 #ifdef TREE_CODE
196 /* Create a new exception region and add the handler for the region
197    onto a list. These regions will be ended (and their handlers
198    emitted) when end_protect_partials is invoked.  */
199
200 extern void add_partial_entry                   PROTO((tree handler));
201 #endif
202
203 /* End all of the pending exception regions that have handlers added with
204    push_protect_entry ().  */
205
206 extern void end_protect_partials                PROTO((void));
207
208 /* An internal throw with a direct CONTEXT we want to throw
209    from. CONTEXT must be a label.  */
210
211 extern void expand_internal_throw               PROTO((rtx context));
212
213 /* Called from expand_exception_blocks and expand_end_catch_block to
214    expand and pending handlers.  */
215
216 extern void expand_leftover_cleanups            PROTO((void));
217
218 /* If necessary, emit insns for the start of per-function unwinder for
219    the current function.  */
220
221 extern void emit_unwinder                       PROTO((void));
222
223 /* If necessary, emit insns for the end of the per-function unwinder
224    for the current function.  */
225
226 extern void end_eh_unwinder                     PROTO((void));
227
228 /* Builds a list of handler labels and puts them in the global
229    variable exception_handler_labels.  */
230
231 extern void find_exception_handler_labels       PROTO((void));
232
233 /* Performs sanity checking on the check_exception_handler_labels
234    list.  */
235
236 extern void check_exception_handler_labels      PROTO((void));
237
238 /* A stack used to keep track of the label used to resume normal program
239    flow out of the current exception handler region.  */
240
241 extern struct label_node *caught_return_label_stack;
242
243 /* A random area used for purposes elsewhere.  */
244
245 extern struct label_node *false_label_stack;
246
247 /* A list of labels used for exception handlers. It is created by
248    find_exception_handler_labels for the optimization passes.  */
249
250 extern rtx exception_handler_labels;
251
252 /* The rtx for the saved PC value.  */
253
254 extern rtx eh_saved_pc_rtx;
255
256 /* Performs optimizations for exception handling, such as removing
257    unnecessary exception regions. Invoked from jump_optimize ().  */
258
259 extern void exception_optimize                  PROTO((void));
260
261 /* Get the dynamic handler chain.  */
262 extern rtx get_dynamic_handler_chain            PROTO((void));
263
264 /* Get the dynamic cleanup chain.  */
265 extern rtx get_dynamic_cleanup_chain            PROTO((void));
266
267 /* Throw an exception.  */
268
269 extern void emit_throw                          PROTO((void));
270
271 /* One to use setjmp/longjmp method of generating code.  */
272
273 extern int exceptions_via_longjmp;
274
275 /* One to enable asynchronous exception support.  */
276
277 extern int asynchronous_exceptions;
278
279 /* One to protect cleanup actions with a handler that calls
280    __terminate, zero otherwise.  */
281
282 extern int protect_cleanup_actions_with_terminate;
283
284 #ifdef TREE_CODE
285 extern tree protect_with_terminate              PROTO((tree));
286 #endif