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