1 /* Exception Handling interface routines.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000 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)
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. */
25 #define tree union tree_node *
30 #define rtx struct rtx_def *
34 struct varray_head_tag
;
35 #define varray_type struct varray_head_tag *
39 /* Per-function EH data. Used only in except.c, but GC and others
40 manipulate pointers to the opaque type. */
43 /* Internal structure describing a region. */
46 /* Test: is exception handling turned on? */
47 extern int doing_eh
PARAMS ((int));
49 /* Start an exception handling region. All instructions emitted after
50 this point are considered to be part of the region until an
51 expand_eh_region_end variant is invoked. */
52 extern void expand_eh_region_start
PARAMS ((void));
54 /* End an exception handling region for a cleanup. HANDLER is an
55 expression to expand for the cleanup. */
56 extern void expand_eh_region_end_cleanup
PARAMS ((tree
));
58 /* End an exception handling region for a try block, and prepares
59 for subsequent calls to expand_start_catch. */
60 extern void expand_start_all_catch
PARAMS ((void));
62 /* Begin a catch clause. TYPE is an object to be matched by the
63 runtime, or null if this is a catch-all clause. */
64 extern void expand_start_catch
PARAMS ((tree
));
66 /* End a catch clause. Control will resume after the try/catch block. */
67 extern void expand_end_catch
PARAMS ((void));
69 /* End a sequence of catch handlers for a try block. */
70 extern void expand_end_all_catch
PARAMS ((void));
72 /* End an exception region for an exception type filter. ALLOWED is a
73 TREE_LIST of TREE_VALUE objects to be matched by the runtime.
74 FAILURE is a function to invoke if a mismatch ocurrs. */
75 extern void expand_eh_region_end_allowed
PARAMS ((tree
, tree
));
77 /* End an exception region for a must-not-throw filter. FAILURE is a
78 function to invoke if an uncaught exception propagates this far. */
79 extern void expand_eh_region_end_must_not_throw
PARAMS ((tree
));
81 /* End an exception region for a throw. No handling goes on here,
82 but it's the easiest way for the front-end to indicate what type
84 extern void expand_eh_region_end_throw
PARAMS ((tree
));
86 /* End a fixup region. Within this region the cleanups for the immediately
87 enclosing region are _not_ run. This is used for goto cleanup to avoid
88 destroying an object twice. */
89 extern void expand_eh_region_end_fixup
PARAMS ((tree
));
91 /* Begin a region that will contain entries created with
93 extern void begin_protect_partials
PARAMS ((void));
95 /* Create a new exception region and add the handler for the region
96 onto a list. These regions will be ended (and their handlers emitted)
97 when end_protect_partials is invoked. */
98 extern void add_partial_entry
PARAMS ((tree
));
100 /* End all of the pending exception regions that have handlers added with
101 add_partial_entry. */
102 extern void end_protect_partials
PARAMS ((void));
105 /* A list of labels used for exception handlers. */
106 extern rtx exception_handler_labels
;
108 /* Determine if the given INSN can throw an exception. */
109 extern bool can_throw_internal
PARAMS ((rtx
));
110 extern bool can_throw_external
PARAMS ((rtx
));
112 /* Return nonzero if nothing in this function can throw. */
113 extern bool nothrow_function_p
PARAMS ((void));
115 /* After initial rtl generation, call back to finish generating
116 exception support code. */
117 extern void finish_eh_generation
PARAMS ((void));
119 extern void init_eh
PARAMS ((void));
120 extern void init_eh_for_function
PARAMS ((void));
122 extern rtx reachable_handlers
PARAMS ((rtx
));
123 extern void maybe_remove_eh_handler
PARAMS ((rtx
));
125 extern void convert_from_eh_region_ranges
PARAMS ((void));
126 extern void convert_to_eh_region_ranges
PARAMS ((void));
127 extern void find_exception_handler_labels
PARAMS ((void));
128 extern void output_function_exception_table
PARAMS ((void));
130 extern void expand_builtin_unwind_init
PARAMS ((void));
131 extern rtx expand_builtin_eh_return_data_regno
PARAMS ((tree
));
132 extern rtx expand_builtin_extract_return_addr
PARAMS ((tree
));
133 extern rtx expand_builtin_frob_return_addr
PARAMS ((tree
));
134 extern rtx expand_builtin_dwarf_fp_regnum
PARAMS ((void));
135 extern void expand_builtin_eh_return
PARAMS ((tree
, tree
));
136 extern void expand_eh_return
PARAMS ((void));
138 extern rtx get_exception_pointer
PARAMS ((void));
142 extern int duplicate_eh_regions
PARAMS ((struct function
*,
143 struct inline_remap
*));
145 extern void sjlj_emit_function_exit_after
PARAMS ((rtx
));
148 /* Nonzero to protect cleanup actions with must-not-throw regions. */
149 extern tree protect_cleanup_actions
;
151 /* Return true if type A catches type B. */
152 extern int (*lang_eh_type_covers
) PARAMS ((tree a
, tree b
));
154 /* Map a type to a runtime object to match type. */
155 extern tree (*lang_eh_runtime_type
) PARAMS ((tree
));
170 /* Just because the user configured --with-sjlj-exceptions=no doesn't
171 mean that we can use call frame exceptions. Detect that the target
172 has appropriate support. */
174 #if !defined (EH_RETURN_DATA_REGNO) \
175 || !defined(EH_RETURN_STACKADJ_RTX) \
176 || ! (defined(EH_RETURN_HANDLER_RTX) \
177 || defined(HAVE_eh_return)) \
178 || ! (defined(DWARF2_UNWIND_INFO) \
179 || defined(IA64_UNWIND_INFO))
180 #define MUST_USE_SJLJ_EXCEPTIONS 1
182 #define MUST_USE_SJLJ_EXCEPTIONS 0
185 #ifdef CONFIG_SJLJ_EXCEPTIONS
186 # if CONFIG_SJLJ_EXCEPTIONS == 1
187 # define USING_SJLJ_EXCEPTIONS 1
189 # if CONFIG_SJLJ_EXCEPTIONS == 0
190 # define USING_SJLJ_EXCEPTIONS 0
191 # ifndef EH_RETURN_DATA_REGNO
192 #error "EH_RETURN_DATA_REGNO required"
194 # ifndef EH_RETURN_STACKADJ_RTX
195 #error "EH_RETURN_STACKADJ_RTX required"
197 # if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return)
198 #error "EH_RETURN_HANDLER_RTX or eh_return required"
200 # if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO)
201 #error "{DWARF2,IA64}_UNWIND_INFO required"
205 # define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS