import of gcc-2.8
[official-gcc.git] / gcc / except.h
blobac46fa4478f7b11fb875e1dae0808ce7949f7204
1 /* Exception Handling interface routines.
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Mike Stump <mrs@cygnus.com>.
5 This file is part of GNU CC.
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.
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.
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. */
23 #ifndef GET_CODE
24 #define rtx int *
25 #endif
27 #ifdef TREE_CODE
29 /* A stack of labels. CHAIN points to the next entry in the stack. */
31 struct label_node {
32 union {
33 rtx rlabel;
34 tree tlabel;
35 } u;
36 struct label_node *chain;
39 /* An eh_entry is used to describe one exception handling region.
41 OUTER_CONTEXT is the label used for rethrowing into the outer context.
43 EXCEPTION_HANDLER_LABEL is the label corresponding to the handler
44 for this region.
46 FINALIZATION is the tree codes for the handler, or is NULL_TREE if
47 one hasn't been generated yet, or is integer_zero_node to mark the
48 end of a group of try blocks. */
50 struct eh_entry {
51 rtx outer_context;
52 rtx exception_handler_label;
54 tree finalization;
57 /* A list of EH_ENTRYs. ENTRY is the entry; CHAIN points to the next
58 entry in the list, or is NULL if this is the last entry. */
60 struct eh_node {
61 struct eh_entry *entry;
62 struct eh_node *chain;
65 /* A stack of EH_ENTRYs. TOP is the topmost entry on the stack. TOP is
66 NULL if the stack is empty. */
68 struct eh_stack {
69 struct eh_node *top;
72 /* A queue of EH_ENTRYs. HEAD is the front of the queue; TAIL is the
73 end (the latest entry). HEAD and TAIL are NULL if the queue is
74 empty. */
76 struct eh_queue {
77 struct eh_node *head;
78 struct eh_node *tail;
82 /* Start an exception handling region. All instructions emitted after
83 this point are considered to be part of the region until
84 expand_eh_region_end () is invoked. */
86 extern void expand_eh_region_start PROTO((void));
88 /* Just like expand_eh_region_start, except if a cleanup action is
89 entered on the cleanup chain, the TREE_PURPOSE of the element put
90 on the chain is DECL. DECL should be the associated VAR_DECL, if
91 any, otherwise it should be NULL_TREE. */
93 extern void expand_eh_region_start_for_decl PROTO((tree));
95 /* Start an exception handling region for the given cleanup action.
96 All instructions emitted after this point are considered to be part
97 of the region until expand_eh_region_end () is invoked. CLEANUP is
98 the cleanup action to perform. The return value is true if the
99 exception region was optimized away. If that case,
100 expand_eh_region_end does not need to be called for this cleanup,
101 nor should it be.
103 This routine notices one particular common case in C++ code
104 generation, and optimizes it so as to not need the exception
105 region. */
107 extern int expand_eh_region_start_tree PROTO((tree, tree));
109 /* End an exception handling region. The information about the region
110 is found on the top of ehstack.
112 HANDLER is either the cleanup for the exception region, or if we're
113 marking the end of a try block, HANDLER is integer_zero_node.
115 HANDLER will be transformed to rtl when expand_leftover_cleanups ()
116 is invoked. */
118 extern void expand_eh_region_end PROTO((tree));
120 /* Push RLABEL or TLABEL onto LABELSTACK. Only one of RLABEL or TLABEL
121 should be set; the other must be NULL. */
123 extern void push_label_entry PROTO((struct label_node **labelstack, rtx rlabel, tree tlabel));
125 /* Pop the topmost entry from LABELSTACK and return its value as an
126 rtx node. If LABELSTACK is empty, return NULL. */
128 extern rtx pop_label_entry PROTO((struct label_node **labelstack));
130 /* Return the topmost entry of LABELSTACK as a tree node, or return
131 NULL_TREE if LABELSTACK is empty. */
133 extern tree top_label_entry PROTO((struct label_node **labelstack));
135 /* A set of insns for the catch clauses in the current function. They
136 will be emitted at the end of the current function. */
138 extern rtx catch_clauses;
140 #endif
142 /* Toplevel initialization for EH. */
144 extern void init_eh PROTO((void));
146 /* Initialization for the per-function EH data. */
148 extern void init_eh_for_function PROTO((void));
150 /* Adds an EH table entry for EH entry number N. Called from
151 final_scan_insn for NOTE_INSN_EH_REGION_BEG. */
153 extern void add_eh_table_entry PROTO((int n));
155 /* Returns a non-zero value if we need to output an exception table. */
157 extern int exception_table_p PROTO((void));
159 /* Outputs the exception table if we have one. */
161 extern void output_exception_table PROTO((void));
163 /* Given a return address in ADDR, determine the address we should use
164 to find the corresponding EH region. */
166 extern rtx eh_outer_context PROTO((rtx addr));
168 /* Called at the start of a block of try statements for which there is
169 a supplied catch handler. */
171 extern void expand_start_try_stmts PROTO((void));
173 /* Called at the start of a block of catch statements. It terminates the
174 previous set of try statements. */
176 extern void expand_start_all_catch PROTO((void));
178 /* Called at the end of a block of catch statements. */
180 extern void expand_end_all_catch PROTO((void));
182 #ifdef TREE_CODE
183 /* Create a new exception region and add the handler for the region
184 onto a list. These regions will be ended (and their handlers
185 emitted) when end_protect_partials is invoked. */
187 extern void add_partial_entry PROTO((tree handler));
188 #endif
190 /* End all of the pending exception regions that have handlers added with
191 push_protect_entry (). */
193 extern void end_protect_partials PROTO((void));
195 /* An internal throw with a direct CONTEXT we want to throw
196 from. CONTEXT must be a label. */
198 extern void expand_internal_throw PROTO((rtx context));
200 /* Called from expand_exception_blocks and expand_end_catch_block to
201 expand and pending handlers. */
203 extern void expand_leftover_cleanups PROTO((void));
205 /* If necessary, emit insns for the start of per-function unwinder for
206 the current function. */
208 extern void emit_unwinder PROTO((void));
210 /* If necessary, emit insns for the end of the per-function unwinder
211 for the current function. */
213 extern void end_eh_unwinder PROTO((void));
215 /* Builds a list of handler labels and puts them in the global
216 variable exception_handler_labels. */
218 extern void find_exception_handler_labels PROTO((void));
220 /* Performs sanity checking on the check_exception_handler_labels
221 list. */
223 extern void check_exception_handler_labels PROTO((void));
225 /* A stack used to keep track of the label used to resume normal program
226 flow out of the current exception handler region. */
228 extern struct label_node *caught_return_label_stack;
230 /* Keeps track of the label used as the context of a throw to rethrow an
231 exception to the outer exception region. */
233 extern struct label_node *outer_context_label_stack;
235 /* A random area used for purposes elsewhere. */
237 extern struct label_node *false_label_stack;
239 /* A list of labels used for exception handlers. It is created by
240 find_exception_handler_labels for the optimization passes. */
242 extern rtx exception_handler_labels;
244 /* The rtx for the saved PC value. */
246 extern rtx eh_saved_pc_rtx;
248 /* Performs optimizations for exception handling, such as removing
249 unnecessary exception regions. Invoked from jump_optimize (). */
251 extern void exception_optimize PROTO((void));
253 /* Get the dynamic handler chain. */
254 extern rtx get_dynamic_handler_chain PROTO((void));
256 /* Get the dynamic cleanup chain. */
257 extern rtx get_dynamic_cleanup_chain PROTO((void));
259 /* Throw an exception. */
261 extern void emit_throw PROTO((void));
263 /* One to use setjmp/longjmp method of generating code. */
265 extern int exceptions_via_longjmp;
267 /* One to enable asynchronous exception support. */
269 extern int asynchronous_exceptions;
271 /* One to protect cleanup actions with a handler that calls
272 __terminate, zero otherwise. */
274 extern int protect_cleanup_actions_with_terminate;
276 #ifdef TREE_CODE
277 extern tree protect_with_terminate PROTO((tree));
278 #endif
280 /* Various hooks for the DWARF 2 __throw routine. */
282 void expand_builtin_unwind_init PROTO((void));
283 rtx expand_builtin_dwarf_fp_regnum PROTO((void));
284 rtx expand_builtin_eh_stub PROTO((void));
285 #ifdef TREE_CODE
286 rtx expand_builtin_frob_return_addr PROTO((tree));
287 rtx expand_builtin_extract_return_addr PROTO((tree));
288 void expand_builtin_set_return_addr_reg PROTO((tree));
289 void expand_builtin_set_eh_regs PROTO((tree, tree));
290 rtx expand_builtin_dwarf_reg_size PROTO((tree, rtx));
291 #endif