OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / except.h
1 /* Exception Handling interface routines.
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3    2007  Free Software Foundation, Inc.
4    Contributed by Mike Stump <mrs@cygnus.com>.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22
23 struct function;
24
25 /* Per-function EH data.  Used only in except.c, but GC and others
26    manipulate pointers to the opaque type.  */
27 struct eh_status;
28
29 /* Internal structure describing a region.  */
30 struct eh_region;
31
32 /* Test: is exception handling turned on?  */
33 extern int doing_eh (int);
34
35 /* Note that the current EH region (if any) may contain a throw, or a
36    call to a function which itself may contain a throw.  */
37 extern void note_eh_region_may_contain_throw (struct eh_region *);
38
39 /* Invokes CALLBACK for every exception handler label.  Only used by old
40    loop hackery; should not be used by new code.  */
41 extern void for_each_eh_label (void (*) (rtx));
42
43 /* Invokes CALLBACK for every exception region in the current function.  */
44 extern void for_each_eh_region (void (*) (struct eh_region *));
45
46 /* Determine if the given INSN can throw an exception.  */
47 extern bool can_throw_internal_1 (int, bool);
48 extern bool can_throw_internal (const_rtx);
49 extern bool can_throw_external_1 (int, bool);
50 extern bool can_throw_external (const_rtx);
51
52 /* Set TREE_NOTHROW and cfun->all_throwers_are_sibcalls.  */
53 extern unsigned int set_nothrow_function_flags (void);
54
55 /* After initial rtl generation, call back to finish generating
56    exception support code.  */
57 extern void finish_eh_generation (void);
58
59 extern void init_eh (void);
60 extern void init_eh_for_function (void);
61
62 extern rtx reachable_handlers (rtx);
63 extern void maybe_remove_eh_handler (rtx);
64
65 extern void convert_from_eh_region_ranges (void);
66 extern unsigned int convert_to_eh_region_ranges (void);
67 extern void find_exception_handler_labels (void);
68 extern bool current_function_has_exception_handlers (void);
69 extern void output_function_exception_table (const char *);
70
71 extern void expand_builtin_unwind_init (void);
72 extern rtx expand_builtin_eh_return_data_regno (tree);
73 extern rtx expand_builtin_extract_return_addr (tree);
74 extern void expand_builtin_init_dwarf_reg_sizes (tree);
75 extern rtx expand_builtin_frob_return_addr (tree);
76 extern rtx expand_builtin_dwarf_sp_column (void);
77 extern void expand_builtin_eh_return (tree, tree);
78 extern void expand_eh_return (void);
79 extern rtx expand_builtin_extend_pointer (tree);
80 extern rtx get_exception_pointer (void);
81 extern rtx get_exception_filter (void);
82 typedef tree (*duplicate_eh_regions_map) (tree, void *);
83 extern int duplicate_eh_regions (struct function *, duplicate_eh_regions_map,
84                                  void *, int, int);
85
86 extern void sjlj_emit_function_exit_after (rtx);
87 extern void default_init_unwind_resume_libfunc (void);
88
89 extern struct eh_region *gen_eh_region_cleanup (struct eh_region *,
90                                                 struct eh_region *);
91 extern struct eh_region *gen_eh_region_try (struct eh_region *);
92 extern struct eh_region *gen_eh_region_catch (struct eh_region *, tree);
93 extern struct eh_region *gen_eh_region_allowed (struct eh_region *, tree);
94 extern struct eh_region *gen_eh_region_must_not_throw (struct eh_region *);
95 extern int get_eh_region_number (struct eh_region *);
96 extern bool get_eh_region_may_contain_throw (struct eh_region *);
97 extern tree get_eh_region_tree_label (struct eh_region *);
98 extern void set_eh_region_tree_label (struct eh_region *, tree);
99
100 extern void foreach_reachable_handler (int, bool,
101                                        void (*) (struct eh_region *, void *),
102                                        void *);
103
104 extern void collect_eh_region_array (void);
105 extern void expand_resx_expr (tree);
106 extern void verify_eh_tree (struct function *);
107 extern void dump_eh_tree (FILE *, struct function *);
108 extern bool eh_region_outer_p (struct function *, int, int);
109 extern int eh_region_outermost (struct function *, int, int);
110
111 /* tree-eh.c */
112 extern void add_stmt_to_eh_region_fn (struct function *, tree, int);
113 extern bool remove_stmt_from_eh_region_fn (struct function *, tree);
114 extern int lookup_stmt_eh_region_fn (struct function *, const_tree);
115 extern int lookup_stmt_eh_region (const_tree);
116 extern bool verify_eh_edges (tree);
117
118 /* If non-NULL, this is a function that returns an expression to be
119    executed if an unhandled exception is propagated out of a cleanup
120    region.  For example, in C++, an exception thrown by a destructor
121    during stack unwinding is required to result in a call to
122    `std::terminate', so the C++ version of this function returns a
123    CALL_EXPR for `std::terminate'.  */
124 extern tree (*lang_protect_cleanup_actions) (void);
125
126 /* Return true if type A catches type B.  */
127 extern int (*lang_eh_type_covers) (tree a, tree b);
128
129 /* Map a type to a runtime object to match type.  */
130 extern tree (*lang_eh_runtime_type) (tree);
131
132
133 /* Just because the user configured --with-sjlj-exceptions=no doesn't
134    mean that we can use call frame exceptions.  Detect that the target
135    has appropriate support.  */
136
137 #ifndef MUST_USE_SJLJ_EXCEPTIONS
138 # if !(defined (EH_RETURN_DATA_REGNO)                   \
139        && (defined (TARGET_UNWIND_INFO)                 \
140            || (DWARF2_UNWIND_INFO                       \
141                && (defined (EH_RETURN_HANDLER_RTX)      \
142                    || defined (HAVE_eh_return)))))
143 #  define MUST_USE_SJLJ_EXCEPTIONS      1
144 # else
145 #  define MUST_USE_SJLJ_EXCEPTIONS      0
146 # endif
147 #endif
148
149 #ifdef CONFIG_SJLJ_EXCEPTIONS
150 # if CONFIG_SJLJ_EXCEPTIONS == 1
151 #  define USING_SJLJ_EXCEPTIONS         1
152 # endif
153 # if CONFIG_SJLJ_EXCEPTIONS == 0
154 #  define USING_SJLJ_EXCEPTIONS         0
155 #  ifndef EH_RETURN_DATA_REGNO
156     #error "EH_RETURN_DATA_REGNO required"
157 #  endif
158 #  if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return)
159     #error "EH_RETURN_HANDLER_RTX or eh_return required"
160 #  endif
161 #  if !defined(DWARF2_UNWIND_INFO) && !defined(TARGET_UNWIND_INFO)
162     #error "{DWARF2,TARGET}_UNWIND_INFO required"
163 #  endif
164 # endif
165 #else
166 # define USING_SJLJ_EXCEPTIONS          MUST_USE_SJLJ_EXCEPTIONS
167 #endif
168
169 struct throw_stmt_node GTY(())
170 {
171   tree stmt;
172   int region_nr;
173 };
174
175 extern struct htab *get_eh_throw_stmt_table (struct function *);
176 extern void set_eh_throw_stmt_table (struct function *, struct htab *);