except.h revision 117395
11541Srgrimes/* Exception Handling interface routines. 21541Srgrimes Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 31541Srgrimes Free Software Foundation, Inc. 41541Srgrimes Contributed by Mike Stump <mrs@cygnus.com>. 528400Speter 61541SrgrimesThis file is part of GCC. 71541Srgrimes 81541SrgrimesGCC is free software; you can redistribute it and/or modify it under 91541Srgrimesthe terms of the GNU General Public License as published by the Free 101541SrgrimesSoftware Foundation; either version 2, or (at your option) any later 111541Srgrimesversion. 121541Srgrimes 131541SrgrimesGCC is distributed in the hope that it will be useful, but WITHOUT ANY 141541SrgrimesWARRANTY; without even the implied warranty of MERCHANTABILITY or 151541SrgrimesFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 161541Srgrimesfor more details. 171541Srgrimes 181541SrgrimesYou should have received a copy of the GNU General Public License 191541Srgrimesalong with GCC; see the file COPYING. If not, write to the Free 201541SrgrimesSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 211541Srgrimes02111-1307, USA. */ 221541Srgrimes 231541Srgrimes 241541Srgrimes#ifndef GCC_VARRAY_H 251541Srgrimesstruct varray_head_tag; 261541Srgrimes#define varray_type struct varray_head_tag * 271541Srgrimes#endif 281541Srgrimes 291541Srgrimesstruct function; 301541Srgrimes 311541Srgrimesstruct inline_remap; 321541Srgrimes 331541Srgrimes/* Per-function EH data. Used only in except.c, but GC and others 341541Srgrimes manipulate pointers to the opaque type. */ 351541Srgrimesstruct eh_status; 361541Srgrimes 371541Srgrimes/* Internal structure describing a region. */ 381541Srgrimesstruct eh_region; 391541Srgrimes 401541Srgrimes/* Test: is exception handling turned on? */ 411541Srgrimesextern int doing_eh PARAMS ((int)); 421541Srgrimes 431541Srgrimes/* Start an exception handling region. All instructions emitted after 441541Srgrimes this point are considered to be part of the region until an 451541Srgrimes expand_eh_region_end variant is invoked. */ 461541Srgrimesextern void expand_eh_region_start PARAMS ((void)); 471541Srgrimes 481541Srgrimes/* End an exception handling region for a cleanup. HANDLER is an 491541Srgrimes expression to expand for the cleanup. */ 501541Srgrimesextern void expand_eh_region_end_cleanup PARAMS ((tree)); 511541Srgrimes 521541Srgrimes/* End an exception handling region for a try block, and prepares 531541Srgrimes for subsequent calls to expand_start_catch. */ 541541Srgrimesextern void expand_start_all_catch PARAMS ((void)); 551541Srgrimes 561541Srgrimes/* Begin a catch clause. TYPE is an object to be matched by the 571541Srgrimes runtime, or a list of such objects, or null if this is a catch-all 581541Srgrimes clause. */ 591541Srgrimesextern void expand_start_catch PARAMS ((tree)); 601541Srgrimes 611541Srgrimes/* End a catch clause. Control will resume after the try/catch block. */ 621541Srgrimesextern void expand_end_catch PARAMS ((void)); 631541Srgrimes 641541Srgrimes/* End a sequence of catch handlers for a try block. */ 651541Srgrimesextern void expand_end_all_catch PARAMS ((void)); 661541Srgrimes 671541Srgrimes/* End an exception region for an exception type filter. ALLOWED is a 681541Srgrimes TREE_LIST of TREE_VALUE objects to be matched by the runtime. 691541Srgrimes FAILURE is a function to invoke if a mismatch occurs. */ 701541Srgrimesextern void expand_eh_region_end_allowed PARAMS ((tree, tree)); 711541Srgrimes 721541Srgrimes/* End an exception region for a must-not-throw filter. FAILURE is a 731541Srgrimes function to invoke if an uncaught exception propagates this far. */ 741541Srgrimesextern void expand_eh_region_end_must_not_throw PARAMS ((tree)); 751541Srgrimes 761541Srgrimes/* End an exception region for a throw. No handling goes on here, 771541Srgrimes but it's the easiest way for the front-end to indicate what type 781541Srgrimes is being thrown. */ 791541Srgrimesextern void expand_eh_region_end_throw PARAMS ((tree)); 801541Srgrimes 811541Srgrimes/* End a fixup region. Within this region the cleanups for the immediately 821541Srgrimes enclosing region are _not_ run. This is used for goto cleanup to avoid 831541Srgrimes destroying an object twice. */ 841541Srgrimesextern void expand_eh_region_end_fixup PARAMS ((tree)); 851541Srgrimes 861541Srgrimes/* Note that the current EH region (if any) may contain a throw, or a 871541Srgrimes call to a function which itself may contain a throw. */ 881541Srgrimesextern void note_eh_region_may_contain_throw PARAMS ((void)); 891541Srgrimes 901541Srgrimes/* Invokes CALLBACK for every exception handler label. Only used by old 911541Srgrimes loop hackery; should not be used by new code. */ 921541Srgrimesextern void for_each_eh_label PARAMS ((void (*) (rtx))); 931541Srgrimes 941541Srgrimes/* Determine if the given INSN can throw an exception. */ 951541Srgrimesextern bool can_throw_internal PARAMS ((rtx)); 961541Srgrimesextern bool can_throw_external PARAMS ((rtx)); 971541Srgrimes 981541Srgrimes/* Set current_function_nothrow and cfun->all_throwers_are_sibcalls. */ 991541Srgrimesextern void set_nothrow_function_flags PARAMS ((void)); 1001541Srgrimes 1011541Srgrimes/* After initial rtl generation, call back to finish generating 1021541Srgrimes exception support code. */ 1031541Srgrimesextern void finish_eh_generation PARAMS ((void)); 1041541Srgrimes 1051541Srgrimesextern void init_eh PARAMS ((void)); 1061541Srgrimesextern void init_eh_for_function PARAMS ((void)); 1071541Srgrimes 1081541Srgrimesextern rtx reachable_handlers PARAMS ((rtx)); 1091541Srgrimesextern void maybe_remove_eh_handler PARAMS ((rtx)); 1101541Srgrimes 1111541Srgrimesextern void convert_from_eh_region_ranges PARAMS ((void)); 1121541Srgrimesextern void convert_to_eh_region_ranges PARAMS ((void)); 1131541Srgrimesextern void find_exception_handler_labels PARAMS ((void)); 1141541Srgrimesextern bool current_function_has_exception_handlers PARAMS ((void)); 1151541Srgrimesextern void output_function_exception_table PARAMS ((void)); 1161541Srgrimes 1171541Srgrimesextern void expand_builtin_unwind_init PARAMS ((void)); 1181541Srgrimesextern rtx expand_builtin_eh_return_data_regno PARAMS ((tree)); 1191541Srgrimesextern rtx expand_builtin_extract_return_addr PARAMS ((tree)); 1201541Srgrimesextern void expand_builtin_init_dwarf_reg_sizes PARAMS ((tree)); 1211541Srgrimesextern rtx expand_builtin_frob_return_addr PARAMS ((tree)); 1221541Srgrimesextern rtx expand_builtin_dwarf_sp_column PARAMS ((void)); 1231541Srgrimesextern void expand_builtin_eh_return PARAMS ((tree, tree)); 1241541Srgrimesextern void expand_eh_return PARAMS ((void)); 1251541Srgrimesextern rtx get_exception_pointer PARAMS ((struct function *)); 1261541Srgrimesextern int duplicate_eh_regions PARAMS ((struct function *, 1271541Srgrimes struct inline_remap *)); 12814220Speter 1291541Srgrimesextern void sjlj_emit_function_exit_after PARAMS ((rtx)); 1301541Srgrimes 1311541Srgrimes 1321541Srgrimes/* If non-NULL, this is a function that returns an expression to be 1331541Srgrimes executed if an unhandled exception is propagated out of a cleanup 1341541Srgrimes region. For example, in C++, an exception thrown by a destructor 1358019Sache during stack unwinding is required to result in a call to 1368019Sache `std::terminate', so the C++ version of this function returns a 1371541Srgrimes CALL_EXPR for `std::terminate'. */ 1381541Srgrimesextern tree (*lang_protect_cleanup_actions) PARAMS ((void)); 1391541Srgrimes 1401541Srgrimes/* Return true if type A catches type B. */ 1411541Srgrimesextern int (*lang_eh_type_covers) PARAMS ((tree a, tree b)); 1421541Srgrimes 1431541Srgrimes/* Map a type to a runtime object to match type. */ 1441541Srgrimesextern tree (*lang_eh_runtime_type) PARAMS ((tree)); 1451541Srgrimes 1461541Srgrimes#ifndef GCC_VARRAY_H 1471541Srgrimes#undef varray_type 1481541Srgrimes#endif 1491541Srgrimes 1501541Srgrimes 1511541Srgrimes/* Just because the user configured --with-sjlj-exceptions=no doesn't 1521541Srgrimes mean that we can use call frame exceptions. Detect that the target 1531541Srgrimes has appropriate support. */ 1541541Srgrimes 1551541Srgrimes#if ! (defined (EH_RETURN_DATA_REGNO) \ 1561541Srgrimes && (defined (IA64_UNWIND_INFO) \ 1571541Srgrimes || (DWARF2_UNWIND_INFO \ 1581541Srgrimes && (defined (EH_RETURN_HANDLER_RTX) \ 1591541Srgrimes || defined (HAVE_eh_return))))) 16014220Speter#define MUST_USE_SJLJ_EXCEPTIONS 1 16114220Speter#else 16214220Speter#define MUST_USE_SJLJ_EXCEPTIONS 0 1631541Srgrimes#endif 1641541Srgrimes 1651541Srgrimes#ifdef CONFIG_SJLJ_EXCEPTIONS 1661541Srgrimes# if CONFIG_SJLJ_EXCEPTIONS == 1 1671541Srgrimes# define USING_SJLJ_EXCEPTIONS 1 1681541Srgrimes# endif 1691541Srgrimes# if CONFIG_SJLJ_EXCEPTIONS == 0 1701541Srgrimes# define USING_SJLJ_EXCEPTIONS 0 1711541Srgrimes# ifndef EH_RETURN_DATA_REGNO 1721541Srgrimes #error "EH_RETURN_DATA_REGNO required" 1731541Srgrimes# endif 17413416Sphk# if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return) 1751541Srgrimes #error "EH_RETURN_HANDLER_RTX or eh_return required" 1761541Srgrimes# endif 1771541Srgrimes# if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO) 1781541Srgrimes #error "{DWARF2,IA64}_UNWIND_INFO required" 1791549Srgrimes# endif 1801549Srgrimes# endif 1811549Srgrimes#else 1821549Srgrimes# define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS 1832442Sdg#endif 1841541Srgrimes