except.h revision 117395
1234353Sdim/* Exception Handling interface routines. 2193323Sed Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 3353358Sdim Free Software Foundation, Inc. 4353358Sdim Contributed by Mike Stump <mrs@cygnus.com>. 5353358Sdim 6193323SedThis file is part of GCC. 7193323Sed 8193323SedGCC is free software; you can redistribute it and/or modify it under 9193323Sedthe terms of the GNU General Public License as published by the Free 10193323SedSoftware Foundation; either version 2, or (at your option) any later 11193323Sedversion. 12193323Sed 13193323SedGCC is distributed in the hope that it will be useful, but WITHOUT ANY 14193323SedWARRANTY; without even the implied warranty of MERCHANTABILITY or 15193323SedFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16341825Sdimfor more details. 17193323Sed 18193323SedYou should have received a copy of the GNU General Public License 19193323Sedalong with GCC; see the file COPYING. If not, write to the Free 20193323SedSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 21341825Sdim02111-1307, USA. */ 22309124Sdim 23249423Sdim 24193323Sed#ifndef GCC_VARRAY_H 25239462Sdimstruct varray_head_tag; 26193323Sed#define varray_type struct varray_head_tag * 27193323Sed#endif 28309124Sdim 29193323Sedstruct function; 30261991Sdim 31249423Sdimstruct inline_remap; 32280031Sdim 33360784Sdim/* Per-function EH data. Used only in except.c, but GC and others 34234353Sdim manipulate pointers to the opaque type. */ 35276479Sdimstruct eh_status; 36207618Srdivacky 37193323Sed/* Internal structure describing a region. */ 38202375Srdivackystruct eh_region; 39198090Srdivacky 40198090Srdivacky/* Test: is exception handling turned on? */ 41193323Sedextern int doing_eh PARAMS ((int)); 42199481Srdivacky 43276479Sdim/* Start an exception handling region. All instructions emitted after 44276479Sdim this point are considered to be part of the region until an 45276479Sdim expand_eh_region_end variant is invoked. */ 46276479Sdimextern void expand_eh_region_start PARAMS ((void)); 47261991Sdim 48224145Sdim/* End an exception handling region for a cleanup. HANDLER is an 49224145Sdim expression to expand for the cleanup. */ 50198090Srdivackyextern void expand_eh_region_end_cleanup PARAMS ((tree)); 51327952Sdim 52327952Sdim/* End an exception handling region for a try block, and prepares 53327952Sdim for subsequent calls to expand_start_catch. */ 54198090Srdivackyextern void expand_start_all_catch PARAMS ((void)); 55198090Srdivacky 56198090Srdivacky/* Begin a catch clause. TYPE is an object to be matched by the 57198090Srdivacky runtime, or a list of such objects, or null if this is a catch-all 58198090Srdivacky clause. */ 59198090Srdivackyextern void expand_start_catch PARAMS ((tree)); 60198090Srdivacky 61198090Srdivacky/* End a catch clause. Control will resume after the try/catch block. */ 62198090Srdivackyextern void expand_end_catch PARAMS ((void)); 63309124Sdim 64309124Sdim/* End a sequence of catch handlers for a try block. */ 65309124Sdimextern void expand_end_all_catch PARAMS ((void)); 66309124Sdim 67309124Sdim/* End an exception region for an exception type filter. ALLOWED is a 68309124Sdim TREE_LIST of TREE_VALUE objects to be matched by the runtime. 69309124Sdim FAILURE is a function to invoke if a mismatch occurs. */ 70309124Sdimextern void expand_eh_region_end_allowed PARAMS ((tree, tree)); 71309124Sdim 72309124Sdim/* End an exception region for a must-not-throw filter. FAILURE is a 73314564Sdim function to invoke if an uncaught exception propagates this far. */ 74193323Sedextern void expand_eh_region_end_must_not_throw PARAMS ((tree)); 75226633Sdim 76261991Sdim/* End an exception region for a throw. No handling goes on here, 77261991Sdim but it's the easiest way for the front-end to indicate what type 78261991Sdim is being thrown. */ 79276479Sdimextern void expand_eh_region_end_throw PARAMS ((tree)); 80296417Sdim 81296417Sdim/* End a fixup region. Within this region the cleanups for the immediately 82296417Sdim enclosing region are _not_ run. This is used for goto cleanup to avoid 83296417Sdim destroying an object twice. */ 84309124Sdimextern void expand_eh_region_end_fixup PARAMS ((tree)); 85309124Sdim 86288943Sdim/* Note that the current EH region (if any) may contain a throw, or a 87226633Sdim call to a function which itself may contain a throw. */ 88218893Sdimextern void note_eh_region_may_contain_throw PARAMS ((void)); 89202375Srdivacky 90202375Srdivacky/* Invokes CALLBACK for every exception handler label. Only used by old 91202375Srdivacky loop hackery; should not be used by new code. */ 92202375Srdivackyextern void for_each_eh_label PARAMS ((void (*) (rtx))); 93202375Srdivacky 94202375Srdivacky/* Determine if the given INSN can throw an exception. */ 95202375Srdivackyextern bool can_throw_internal PARAMS ((rtx)); 96202375Srdivackyextern bool can_throw_external PARAMS ((rtx)); 97202375Srdivacky 98202375Srdivacky/* Set current_function_nothrow and cfun->all_throwers_are_sibcalls. */ 99202375Srdivackyextern void set_nothrow_function_flags PARAMS ((void)); 100276479Sdim 101202375Srdivacky/* After initial rtl generation, call back to finish generating 102202375Srdivacky exception support code. */ 103202375Srdivackyextern void finish_eh_generation PARAMS ((void)); 104321369Sdim 105202375Srdivackyextern void init_eh PARAMS ((void)); 106202375Srdivackyextern void init_eh_for_function PARAMS ((void)); 107202375Srdivacky 108261991Sdimextern rtx reachable_handlers PARAMS ((rtx)); 109202375Srdivackyextern void maybe_remove_eh_handler PARAMS ((rtx)); 110202375Srdivacky 111202375Srdivackyextern void convert_from_eh_region_ranges PARAMS ((void)); 112202375Srdivackyextern void convert_to_eh_region_ranges PARAMS ((void)); 113202375Srdivackyextern void find_exception_handler_labels PARAMS ((void)); 114202375Srdivackyextern bool current_function_has_exception_handlers PARAMS ((void)); 115243830Sdimextern void output_function_exception_table PARAMS ((void)); 116202375Srdivacky 117202375Srdivackyextern void expand_builtin_unwind_init PARAMS ((void)); 118202375Srdivackyextern rtx expand_builtin_eh_return_data_regno PARAMS ((tree)); 119202375Srdivackyextern rtx expand_builtin_extract_return_addr PARAMS ((tree)); 120202375Srdivackyextern void expand_builtin_init_dwarf_reg_sizes PARAMS ((tree)); 121208599Srdivackyextern rtx expand_builtin_frob_return_addr PARAMS ((tree)); 122202375Srdivackyextern rtx expand_builtin_dwarf_sp_column PARAMS ((void)); 123202375Srdivackyextern void expand_builtin_eh_return PARAMS ((tree, tree)); 124202375Srdivackyextern void expand_eh_return PARAMS ((void)); 125202375Srdivackyextern rtx get_exception_pointer PARAMS ((struct function *)); 126208599Srdivackyextern int duplicate_eh_regions PARAMS ((struct function *, 127202375Srdivacky struct inline_remap *)); 128202375Srdivacky 129208599Srdivackyextern void sjlj_emit_function_exit_after PARAMS ((rtx)); 130202375Srdivacky 131202375Srdivacky 132202375Srdivacky/* If non-NULL, this is a function that returns an expression to be 133202375Srdivacky executed if an unhandled exception is propagated out of a cleanup 134202375Srdivacky region. For example, in C++, an exception thrown by a destructor 135202375Srdivacky during stack unwinding is required to result in a call to 136202375Srdivacky `std::terminate', so the C++ version of this function returns a 137202375Srdivacky CALL_EXPR for `std::terminate'. */ 138309124Sdimextern tree (*lang_protect_cleanup_actions) PARAMS ((void)); 139309124Sdim 140280031Sdim/* Return true if type A catches type B. */ 141280031Sdimextern int (*lang_eh_type_covers) PARAMS ((tree a, tree b)); 142321369Sdim 143280031Sdim/* Map a type to a runtime object to match type. */ 144321369Sdimextern tree (*lang_eh_runtime_type) PARAMS ((tree)); 145321369Sdim 146321369Sdim#ifndef GCC_VARRAY_H 147321369Sdim#undef varray_type 148321369Sdim#endif 149280031Sdim 150288943Sdim 151288943Sdim/* Just because the user configured --with-sjlj-exceptions=no doesn't 152280031Sdim mean that we can use call frame exceptions. Detect that the target 153280031Sdim has appropriate support. */ 154309124Sdim 155309124Sdim#if ! (defined (EH_RETURN_DATA_REGNO) \ 156280031Sdim && (defined (IA64_UNWIND_INFO) \ 157280031Sdim || (DWARF2_UNWIND_INFO \ 158280031Sdim && (defined (EH_RETURN_HANDLER_RTX) \ 159280031Sdim || defined (HAVE_eh_return))))) 160280031Sdim#define MUST_USE_SJLJ_EXCEPTIONS 1 161280031Sdim#else 162280031Sdim#define MUST_USE_SJLJ_EXCEPTIONS 0 163280031Sdim#endif 164280031Sdim 165280031Sdim#ifdef CONFIG_SJLJ_EXCEPTIONS 166280031Sdim# if CONFIG_SJLJ_EXCEPTIONS == 1 167280031Sdim# define USING_SJLJ_EXCEPTIONS 1 168280031Sdim# endif 169280031Sdim# if CONFIG_SJLJ_EXCEPTIONS == 0 170280031Sdim# define USING_SJLJ_EXCEPTIONS 0 171280031Sdim# ifndef EH_RETURN_DATA_REGNO 172280031Sdim #error "EH_RETURN_DATA_REGNO required" 173309124Sdim# endif 174288943Sdim# if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return) 175280031Sdim #error "EH_RETURN_HANDLER_RTX or eh_return required" 176280031Sdim# endif 177280031Sdim# if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO) 178280031Sdim #error "{DWARF2,IA64}_UNWIND_INFO required" 179280031Sdim# endif 180280031Sdim# endif 181280031Sdim#else 182309124Sdim# define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS 183309124Sdim#endif 184309124Sdim