xref: /openbsd/gnu/usr.bin/gcc/gcc/except.h (revision c87b03e5)
1*c87b03e5Sespie /* Exception Handling interface routines.
2*c87b03e5Sespie    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3*c87b03e5Sespie    Free Software Foundation, Inc.
4*c87b03e5Sespie    Contributed by Mike Stump <mrs@cygnus.com>.
5*c87b03e5Sespie 
6*c87b03e5Sespie This file is part of GCC.
7*c87b03e5Sespie 
8*c87b03e5Sespie GCC is free software; you can redistribute it and/or modify it under
9*c87b03e5Sespie the terms of the GNU General Public License as published by the Free
10*c87b03e5Sespie Software Foundation; either version 2, or (at your option) any later
11*c87b03e5Sespie version.
12*c87b03e5Sespie 
13*c87b03e5Sespie GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14*c87b03e5Sespie WARRANTY; without even the implied warranty of MERCHANTABILITY or
15*c87b03e5Sespie FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16*c87b03e5Sespie for more details.
17*c87b03e5Sespie 
18*c87b03e5Sespie You should have received a copy of the GNU General Public License
19*c87b03e5Sespie along with GCC; see the file COPYING.  If not, write to the Free
20*c87b03e5Sespie Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21*c87b03e5Sespie 02111-1307, USA.  */
22*c87b03e5Sespie 
23*c87b03e5Sespie 
24*c87b03e5Sespie #ifndef GCC_VARRAY_H
25*c87b03e5Sespie struct varray_head_tag;
26*c87b03e5Sespie #define varray_type struct varray_head_tag *
27*c87b03e5Sespie #endif
28*c87b03e5Sespie 
29*c87b03e5Sespie struct function;
30*c87b03e5Sespie 
31*c87b03e5Sespie struct inline_remap;
32*c87b03e5Sespie 
33*c87b03e5Sespie /* Per-function EH data.  Used only in except.c, but GC and others
34*c87b03e5Sespie    manipulate pointers to the opaque type.  */
35*c87b03e5Sespie struct eh_status;
36*c87b03e5Sespie 
37*c87b03e5Sespie /* Internal structure describing a region.  */
38*c87b03e5Sespie struct eh_region;
39*c87b03e5Sespie 
40*c87b03e5Sespie /* Test: is exception handling turned on?  */
41*c87b03e5Sespie extern int doing_eh			        PARAMS ((int));
42*c87b03e5Sespie 
43*c87b03e5Sespie /* Start an exception handling region.  All instructions emitted after
44*c87b03e5Sespie    this point are considered to be part of the region until an
45*c87b03e5Sespie    expand_eh_region_end variant is invoked.  */
46*c87b03e5Sespie extern void expand_eh_region_start		PARAMS ((void));
47*c87b03e5Sespie 
48*c87b03e5Sespie /* End an exception handling region for a cleanup.  HANDLER is an
49*c87b03e5Sespie    expression to expand for the cleanup.  */
50*c87b03e5Sespie extern void expand_eh_region_end_cleanup	PARAMS ((tree));
51*c87b03e5Sespie 
52*c87b03e5Sespie /* End an exception handling region for a try block, and prepares
53*c87b03e5Sespie    for subsequent calls to expand_start_catch.  */
54*c87b03e5Sespie extern void expand_start_all_catch		PARAMS ((void));
55*c87b03e5Sespie 
56*c87b03e5Sespie /* Begin a catch clause.  TYPE is an object to be matched by the
57*c87b03e5Sespie    runtime, or a list of such objects, or null if this is a catch-all
58*c87b03e5Sespie    clause.  */
59*c87b03e5Sespie extern void expand_start_catch			PARAMS ((tree));
60*c87b03e5Sespie 
61*c87b03e5Sespie /* End a catch clause.  Control will resume after the try/catch block.  */
62*c87b03e5Sespie extern void expand_end_catch			PARAMS ((void));
63*c87b03e5Sespie 
64*c87b03e5Sespie /* End a sequence of catch handlers for a try block.  */
65*c87b03e5Sespie extern void expand_end_all_catch		PARAMS ((void));
66*c87b03e5Sespie 
67*c87b03e5Sespie /* End an exception region for an exception type filter.  ALLOWED is a
68*c87b03e5Sespie    TREE_LIST of TREE_VALUE objects to be matched by the runtime.
69*c87b03e5Sespie    FAILURE is a function to invoke if a mismatch occurs.  */
70*c87b03e5Sespie extern void expand_eh_region_end_allowed	PARAMS ((tree, tree));
71*c87b03e5Sespie 
72*c87b03e5Sespie /* End an exception region for a must-not-throw filter.  FAILURE is a
73*c87b03e5Sespie    function to invoke if an uncaught exception propagates this far.  */
74*c87b03e5Sespie extern void expand_eh_region_end_must_not_throw	PARAMS ((tree));
75*c87b03e5Sespie 
76*c87b03e5Sespie /* End an exception region for a throw.  No handling goes on here,
77*c87b03e5Sespie    but it's the easiest way for the front-end to indicate what type
78*c87b03e5Sespie    is being thrown.  */
79*c87b03e5Sespie extern void expand_eh_region_end_throw		PARAMS ((tree));
80*c87b03e5Sespie 
81*c87b03e5Sespie /* End a fixup region.  Within this region the cleanups for the immediately
82*c87b03e5Sespie    enclosing region are _not_ run.  This is used for goto cleanup to avoid
83*c87b03e5Sespie    destroying an object twice.  */
84*c87b03e5Sespie extern void expand_eh_region_end_fixup		PARAMS ((tree));
85*c87b03e5Sespie 
86*c87b03e5Sespie /* Note that the current EH region (if any) may contain a throw, or a
87*c87b03e5Sespie    call to a function which itself may contain a throw.  */
88*c87b03e5Sespie extern void note_eh_region_may_contain_throw    PARAMS ((void));
89*c87b03e5Sespie 
90*c87b03e5Sespie /* Invokes CALLBACK for every exception handler label.  Only used by old
91*c87b03e5Sespie    loop hackery; should not be used by new code.  */
92*c87b03e5Sespie extern void for_each_eh_label			PARAMS ((void (*) (rtx)));
93*c87b03e5Sespie 
94*c87b03e5Sespie /* Determine if the given INSN can throw an exception.  */
95*c87b03e5Sespie extern bool can_throw_internal			PARAMS ((rtx));
96*c87b03e5Sespie extern bool can_throw_external			PARAMS ((rtx));
97*c87b03e5Sespie 
98*c87b03e5Sespie /* Set current_function_nothrow and cfun->all_throwers_are_sibcalls.  */
99*c87b03e5Sespie extern void set_nothrow_function_flags		PARAMS ((void));
100*c87b03e5Sespie 
101*c87b03e5Sespie /* After initial rtl generation, call back to finish generating
102*c87b03e5Sespie    exception support code.  */
103*c87b03e5Sespie extern void finish_eh_generation		PARAMS ((void));
104*c87b03e5Sespie 
105*c87b03e5Sespie extern void init_eh				PARAMS ((void));
106*c87b03e5Sespie extern void init_eh_for_function		PARAMS ((void));
107*c87b03e5Sespie 
108*c87b03e5Sespie extern rtx reachable_handlers			PARAMS ((rtx));
109*c87b03e5Sespie extern void maybe_remove_eh_handler		PARAMS ((rtx));
110*c87b03e5Sespie 
111*c87b03e5Sespie extern void convert_from_eh_region_ranges	PARAMS ((void));
112*c87b03e5Sespie extern void convert_to_eh_region_ranges		PARAMS ((void));
113*c87b03e5Sespie extern void find_exception_handler_labels	PARAMS ((void));
114*c87b03e5Sespie extern bool current_function_has_exception_handlers PARAMS ((void));
115*c87b03e5Sespie extern void output_function_exception_table	PARAMS ((void));
116*c87b03e5Sespie 
117*c87b03e5Sespie extern void expand_builtin_unwind_init		PARAMS ((void));
118*c87b03e5Sespie extern rtx expand_builtin_eh_return_data_regno	PARAMS ((tree));
119*c87b03e5Sespie extern rtx expand_builtin_extract_return_addr	PARAMS ((tree));
120*c87b03e5Sespie extern void expand_builtin_init_dwarf_reg_sizes PARAMS ((tree));
121*c87b03e5Sespie extern rtx expand_builtin_frob_return_addr	PARAMS ((tree));
122*c87b03e5Sespie extern rtx expand_builtin_dwarf_sp_column	PARAMS ((void));
123*c87b03e5Sespie extern void expand_builtin_eh_return		PARAMS ((tree, tree));
124*c87b03e5Sespie extern void expand_eh_return			PARAMS ((void));
125*c87b03e5Sespie extern rtx get_exception_pointer		PARAMS ((struct function *));
126*c87b03e5Sespie extern int duplicate_eh_regions			PARAMS ((struct function *,
127*c87b03e5Sespie 						 struct inline_remap *));
128*c87b03e5Sespie 
129*c87b03e5Sespie extern void sjlj_emit_function_exit_after	PARAMS ((rtx));
130*c87b03e5Sespie 
131*c87b03e5Sespie 
132*c87b03e5Sespie /* If non-NULL, this is a function that returns an expression to be
133*c87b03e5Sespie    executed if an unhandled exception is propagated out of a cleanup
134*c87b03e5Sespie    region.  For example, in C++, an exception thrown by a destructor
135*c87b03e5Sespie    during stack unwinding is required to result in a call to
136*c87b03e5Sespie    `std::terminate', so the C++ version of this function returns a
137*c87b03e5Sespie    CALL_EXPR for `std::terminate'.  */
138*c87b03e5Sespie extern tree (*lang_protect_cleanup_actions) PARAMS ((void));
139*c87b03e5Sespie 
140*c87b03e5Sespie /* Return true if type A catches type B.  */
141*c87b03e5Sespie extern int (*lang_eh_type_covers) PARAMS ((tree a, tree b));
142*c87b03e5Sespie 
143*c87b03e5Sespie /* Map a type to a runtime object to match type.  */
144*c87b03e5Sespie extern tree (*lang_eh_runtime_type) PARAMS ((tree));
145*c87b03e5Sespie 
146*c87b03e5Sespie #ifndef GCC_VARRAY_H
147*c87b03e5Sespie #undef varray_type
148*c87b03e5Sespie #endif
149*c87b03e5Sespie 
150*c87b03e5Sespie 
151*c87b03e5Sespie /* Just because the user configured --with-sjlj-exceptions=no doesn't
152*c87b03e5Sespie    mean that we can use call frame exceptions.  Detect that the target
153*c87b03e5Sespie    has appropriate support.  */
154*c87b03e5Sespie 
155*c87b03e5Sespie #if ! (defined (EH_RETURN_DATA_REGNO)			\
156*c87b03e5Sespie        && (defined (IA64_UNWIND_INFO)			\
157*c87b03e5Sespie 	   || (DWARF2_UNWIND_INFO			\
158*c87b03e5Sespie 	       && (defined (EH_RETURN_HANDLER_RTX)	\
159*c87b03e5Sespie 		   || defined (HAVE_eh_return)))))
160*c87b03e5Sespie #define MUST_USE_SJLJ_EXCEPTIONS	1
161*c87b03e5Sespie #else
162*c87b03e5Sespie #define MUST_USE_SJLJ_EXCEPTIONS	0
163*c87b03e5Sespie #endif
164*c87b03e5Sespie 
165*c87b03e5Sespie #ifdef CONFIG_SJLJ_EXCEPTIONS
166*c87b03e5Sespie # if CONFIG_SJLJ_EXCEPTIONS == 1
167*c87b03e5Sespie #  define USING_SJLJ_EXCEPTIONS		1
168*c87b03e5Sespie # endif
169*c87b03e5Sespie # if CONFIG_SJLJ_EXCEPTIONS == 0
170*c87b03e5Sespie #  define USING_SJLJ_EXCEPTIONS		0
171*c87b03e5Sespie #  ifndef EH_RETURN_DATA_REGNO
172*c87b03e5Sespie     #error "EH_RETURN_DATA_REGNO required"
173*c87b03e5Sespie #  endif
174*c87b03e5Sespie #  if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return)
175*c87b03e5Sespie     #error "EH_RETURN_HANDLER_RTX or eh_return required"
176*c87b03e5Sespie #  endif
177*c87b03e5Sespie #  if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO)
178*c87b03e5Sespie     #error "{DWARF2,IA64}_UNWIND_INFO required"
179*c87b03e5Sespie #  endif
180*c87b03e5Sespie # endif
181*c87b03e5Sespie #else
182*c87b03e5Sespie # define USING_SJLJ_EXCEPTIONS		MUST_USE_SJLJ_EXCEPTIONS
183*c87b03e5Sespie #endif
184