except.h revision 96263
11558Srgrimes/* Exception Handling interface routines. 21558Srgrimes Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 31558Srgrimes Free Software Foundation, Inc. 41558Srgrimes Contributed by Mike Stump <mrs@cygnus.com>. 51558Srgrimes 61558SrgrimesThis file is part of GCC. 71558Srgrimes 81558SrgrimesGCC is free software; you can redistribute it and/or modify it under 91558Srgrimesthe terms of the GNU General Public License as published by the Free 101558SrgrimesSoftware Foundation; either version 2, or (at your option) any later 111558Srgrimesversion. 121558Srgrimes 131558SrgrimesGCC is distributed in the hope that it will be useful, but WITHOUT ANY 141558SrgrimesWARRANTY; without even the implied warranty of MERCHANTABILITY or 151558SrgrimesFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 161558Srgrimesfor more details. 171558Srgrimes 181558SrgrimesYou should have received a copy of the GNU General Public License 191558Srgrimesalong with GCC; see the file COPYING. If not, write to the Free 201558SrgrimesSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 211558Srgrimes02111-1307, USA. */ 221558Srgrimes 231558Srgrimes 241558Srgrimes#ifndef GCC_VARRAY_H 251558Srgrimesstruct varray_head_tag; 261558Srgrimes#define varray_type struct varray_head_tag * 271558Srgrimes#endif 2823678Speter 2950476Speterstruct function; 301558Srgrimes 31176370Syarstruct inline_remap; 321558Srgrimes 3379530Sru/* Per-function EH data. Used only in except.c, but GC and others 341558Srgrimes manipulate pointers to the opaque type. */ 351558Srgrimesstruct eh_status; 361558Srgrimes 371558Srgrimes/* Internal structure describing a region. */ 3884471Srustruct eh_region; 391558Srgrimes 40152769Sru/* Test: is exception handling turned on? */ 41152769Sruextern int doing_eh PARAMS ((int)); 42152769Sru 43152769Sru/* Start an exception handling region. All instructions emitted after 441558Srgrimes this point are considered to be part of the region until an 451558Srgrimes expand_eh_region_end variant is invoked. */ 4668960Sruextern void expand_eh_region_start PARAMS ((void)); 471558Srgrimes 481558Srgrimes/* End an exception handling region for a cleanup. HANDLER is an 491558Srgrimes expression to expand for the cleanup. */ 501558Srgrimesextern void expand_eh_region_end_cleanup PARAMS ((tree)); 511558Srgrimes 5276022Sru/* End an exception handling region for a try block, and prepares 531558Srgrimes for subsequent calls to expand_start_catch. */ 541558Srgrimesextern void expand_start_all_catch PARAMS ((void)); 5576022Sru 561558Srgrimes/* Begin a catch clause. TYPE is an object to be matched by the 574065Swollman runtime, or a list of such objects, or null if this is a catch-all 5876022Sru clause. */ 594065Swollmanextern void expand_start_catch PARAMS ((tree)); 6076022Sru 614065Swollman/* End a catch clause. Control will resume after the try/catch block. */ 6276022Sruextern void expand_end_catch PARAMS ((void)); 634065Swollman 641558Srgrimes/* End a sequence of catch handlers for a try block. */ 6523678Speterextern void expand_end_all_catch PARAMS ((void)); 6668960Sru 671558Srgrimes/* End an exception region for an exception type filter. ALLOWED is a 6876022Sru TREE_LIST of TREE_VALUE objects to be matched by the runtime. 691558Srgrimes FAILURE is a function to invoke if a mismatch occurs. */ 701558Srgrimesextern void expand_eh_region_end_allowed PARAMS ((tree, tree)); 711558Srgrimes 721558Srgrimes/* End an exception region for a must-not-throw filter. FAILURE is a 73241581Seadler function to invoke if an uncaught exception propagates this far. */ 74241581Seadlerextern void expand_eh_region_end_must_not_throw PARAMS ((tree)); 754065Swollman 761558Srgrimes/* End an exception region for a throw. No handling goes on here, 771558Srgrimes but it's the easiest way for the front-end to indicate what type 781558Srgrimes is being thrown. */ 791558Srgrimesextern void expand_eh_region_end_throw PARAMS ((tree)); 801558Srgrimes 8176022Sru/* End a fixup region. Within this region the cleanups for the immediately 821558Srgrimes enclosing region are _not_ run. This is used for goto cleanup to avoid 831558Srgrimes destroying an object twice. */ 8476022Sruextern void expand_eh_region_end_fixup PARAMS ((tree)); 8576022Sru 861558Srgrimes/* Begin a region that will contain entries created with 8768960Sru add_partial_entry. */ 881558Srgrimesextern void begin_protect_partials PARAMS ((void)); 891558Srgrimes 901558Srgrimes/* Create a new exception region and add the handler for the region 9176022Sru onto a list. These regions will be ended (and their handlers emitted) 921558Srgrimes when end_protect_partials is invoked. */ 931558Srgrimesextern void add_partial_entry PARAMS ((tree)); 941558Srgrimes 951558Srgrimes/* End all of the pending exception regions that have handlers added with 961558Srgrimes add_partial_entry. */ 9776022Sruextern void end_protect_partials PARAMS ((void)); 981558Srgrimes 9976022Sru/* Invokes CALLBACK for every exception handler label. Only used by old 1001558Srgrimes loop hackery; should not be used by new code. */ 1011558Srgrimesextern void for_each_eh_label PARAMS ((void (*) (rtx))); 1021558Srgrimes 1031558Srgrimes/* Determine if the given INSN can throw an exception. */ 1041558Srgrimesextern bool can_throw_internal PARAMS ((rtx)); 10576022Sruextern bool can_throw_external PARAMS ((rtx)); 1061558Srgrimes 10776022Sru/* Return nonzero if nothing in this function can throw. */ 1081558Srgrimesextern bool nothrow_function_p PARAMS ((void)); 10976022Sru 1104065Swollman/* After initial rtl generation, call back to finish generating 11176022Sru exception support code. */ 1124065Swollmanextern void finish_eh_generation PARAMS ((void)); 11376022Sru 1141558Srgrimesextern void init_eh PARAMS ((void)); 1151558Srgrimesextern void init_eh_for_function PARAMS ((void)); 1161558Srgrimes 1171558Srgrimesextern rtx reachable_handlers PARAMS ((rtx)); 1181558Srgrimesextern void maybe_remove_eh_handler PARAMS ((rtx)); 1191558Srgrimes 1201558Srgrimesextern void convert_from_eh_region_ranges PARAMS ((void)); 12176022Sruextern void convert_to_eh_region_ranges PARAMS ((void)); 1221558Srgrimesextern void find_exception_handler_labels PARAMS ((void)); 1231558Srgrimesextern bool current_function_has_exception_handlers PARAMS ((void)); 1241558Srgrimesextern void output_function_exception_table PARAMS ((void)); 1251558Srgrimes 1261558Srgrimesextern void expand_builtin_unwind_init PARAMS ((void)); 1271558Srgrimesextern rtx expand_builtin_eh_return_data_regno PARAMS ((tree)); 1281558Srgrimesextern rtx expand_builtin_extract_return_addr PARAMS ((tree)); 1291558Srgrimesextern void expand_builtin_init_dwarf_reg_sizes PARAMS ((tree)); 1301558Srgrimesextern rtx expand_builtin_frob_return_addr PARAMS ((tree)); 1311558Srgrimesextern rtx expand_builtin_dwarf_fp_regnum PARAMS ((void)); 1321558Srgrimesextern void expand_builtin_eh_return PARAMS ((tree, tree)); 1331558Srgrimesextern void expand_eh_return PARAMS ((void)); 1341558Srgrimesextern rtx get_exception_pointer PARAMS ((struct function *)); 1351558Srgrimesextern int duplicate_eh_regions PARAMS ((struct function *, 1361558Srgrimes struct inline_remap *)); 13776022Sru 13876022Sruextern void sjlj_emit_function_exit_after PARAMS ((rtx)); 1391558Srgrimes 1401558Srgrimes 1411558Srgrimes/* If non-NULL, this is a function that returns an expression to be 142102231Strhodes executed if an unhandled exception is propagated out of a cleanup 1431558Srgrimes region. For example, in C++, an exception thrown by a destructor 1441558Srgrimes during stack unwinding is required to result in a call to 1451558Srgrimes `std::terminate', so the C++ version of this function returns a 1461558Srgrimes CALL_EXPR for `std::terminate'. */ 1471558Srgrimesextern tree (*lang_protect_cleanup_actions) PARAMS ((void)); 1481558Srgrimes 1491558Srgrimes/* Return true if type A catches type B. */ 1501558Srgrimesextern int (*lang_eh_type_covers) PARAMS ((tree a, tree b)); 1511558Srgrimes 1521558Srgrimes/* Map a type to a runtime object to match type. */ 1531558Srgrimesextern tree (*lang_eh_runtime_type) PARAMS ((tree)); 1541558Srgrimes 1551558Srgrimes#ifndef GCC_VARRAY_H 1561558Srgrimes#undef varray_type 1571558Srgrimes#endif 15823678Speter 1591558Srgrimes 16023678Speter/* Just because the user configured --with-sjlj-exceptions=no doesn't 1611558Srgrimes mean that we can use call frame exceptions. Detect that the target 1621558Srgrimes has appropriate support. */ 1631558Srgrimes 16423678Speter#if ! (defined (EH_RETURN_DATA_REGNO) \ 16576022Sru && (defined (IA64_UNWIND_INFO) \ 166176370Syar || (DWARF2_UNWIND_INFO \ 16768960Sru && defined (EH_RETURN_STACKADJ_RTX) \ 1681558Srgrimes && (defined (EH_RETURN_HANDLER_RTX) \ 1691558Srgrimes || defined (HAVE_eh_return))))) 170176370Syar#define MUST_USE_SJLJ_EXCEPTIONS 1 17123678Speter#else 17276022Sru#define MUST_USE_SJLJ_EXCEPTIONS 0 17323678Speter#endif 1741558Srgrimes 1751558Srgrimes#ifdef CONFIG_SJLJ_EXCEPTIONS 1761558Srgrimes# if CONFIG_SJLJ_EXCEPTIONS == 1 1771558Srgrimes# define USING_SJLJ_EXCEPTIONS 1 1781558Srgrimes# endif 1791558Srgrimes# if CONFIG_SJLJ_EXCEPTIONS == 0 18076022Sru# define USING_SJLJ_EXCEPTIONS 0 1811558Srgrimes# ifndef EH_RETURN_DATA_REGNO 182 #error "EH_RETURN_DATA_REGNO required" 183# endif 184# ifndef EH_RETURN_STACKADJ_RTX 185 #error "EH_RETURN_STACKADJ_RTX required" 186# endif 187# if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return) 188 #error "EH_RETURN_HANDLER_RTX or eh_return required" 189# endif 190# if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO) 191 #error "{DWARF2,IA64}_UNWIND_INFO required" 192# endif 193# endif 194#else 195# define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS 196#endif 197