OSDN Git Service

84bbe0706c31f6593ebac6ea91418a0c007c49fd
[pf3gnuchains/gcc-fork.git] / gcc / except.h
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>.
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 TREE_CODE
24 union tree_node;
25 #define tree union tree_node *
26 #endif
27
28 #ifndef RTX_CODE
29 struct rtx_def;
30 #define rtx struct rtx_def *
31 #endif
32
33 #ifndef _VARRAY_H_
34 struct varray_head_tag;
35 #define varray_type struct varray_head_tag *
36 #endif
37
38
39 /* Per-function EH data.  Used only in except.c, but GC and others
40    manipulate pointers to the opaque type.  */
41 struct eh_status;
42
43 /* Internal structure describing a region.  */
44 struct eh_region;
45
46 /* Test: is exception handling turned on?  */
47 extern int doing_eh                             PARAMS ((int));
48
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));
53
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));
57
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));
61
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));
65
66 /* End a catch clause.  Control will resume after the try/catch block.  */
67 extern void expand_end_catch                    PARAMS ((void));
68
69 /* End a sequence of catch handlers for a try block.  */
70 extern void expand_end_all_catch                PARAMS ((void));
71
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));
76
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));
80
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
83    is being thrown.  */
84 extern void expand_eh_region_end_throw          PARAMS ((tree));
85
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));
90
91 /* Begin a region that will contain entries created with
92    add_partial_entry.  */
93 extern void begin_protect_partials              PARAMS ((void));
94
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));
99
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));
103
104
105 /* A list of labels used for exception handlers.  */
106 extern rtx exception_handler_labels;
107
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));
111
112 /* Return nonzero if nothing in this function can throw.  */
113 extern bool nothrow_function_p                  PARAMS ((void));
114
115 /* After initial rtl generation, call back to finish generating
116    exception support code.  */
117 extern void finish_eh_generation                PARAMS ((void));
118
119 extern void init_eh                             PARAMS ((void));
120 extern void init_eh_for_function                PARAMS ((void));
121
122 extern rtx reachable_handlers                   PARAMS ((rtx));
123 extern void maybe_remove_eh_handler             PARAMS ((rtx));
124
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));
129
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));
137
138 extern rtx get_exception_pointer                PARAMS ((void));
139
140 struct function;
141 struct inline_remap;
142 extern int duplicate_eh_regions         PARAMS ((struct function *,
143                                                  struct inline_remap *));
144
145 extern void sjlj_emit_function_exit_after       PARAMS ((rtx));
146
147
148 /* Nonzero to protect cleanup actions with must-not-throw regions.  */
149 extern tree protect_cleanup_actions;
150
151 /* Return true if type A catches type B.  */
152 int (*lang_eh_type_covers) PARAMS ((tree a, tree b));
153
154 /* Map a type to a runtime object to match type.  */
155 tree (*lang_eh_runtime_type) PARAMS ((tree));
156
157 #ifndef TREE_CODE
158 #undef tree
159 #endif
160
161 #ifndef RTX_CODE
162 #undef rtx
163 #endif
164
165 #ifndef _VARRAY_H_
166 #undef varray_type
167 #endif
168
169
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.  */
173
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
181 #else
182 #define MUST_USE_SJLJ_EXCEPTIONS        0
183 #endif
184
185 #ifdef CONFIG_SJLJ_EXCEPTIONS
186 # if CONFIG_SJLJ_EXCEPTIONS == 1
187 #  define USING_SJLJ_EXCEPTIONS         1
188 # endif
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"
193 #  endif
194 #  ifndef EH_RETURN_STACKADJ_RTX
195     #error "EH_RETURN_STACKADJ_RTX required"
196 #  endif
197 #  if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return)
198     #error "EH_RETURN_HANDLER_RTX or eh_return required"
199 #  endif
200 #  if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO)
201     #error "{DWARF2,IA64}_UNWIND_INFO required"
202 #  endif
203 # endif
204 #else
205 # define USING_SJLJ_EXCEPTIONS          MUST_USE_SJLJ_EXCEPTIONS
206 #endif