00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* Exception Handling interface routines. 00006 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 00007 Free Software Foundation, Inc. 00008 Contributed by Mike Stump <mrs@cygnus.com>. 00009 00010 This file is part of GCC. 00011 00012 GCC is free software; you can redistribute it and/or modify it under 00013 the terms of the GNU General Public License as published by the Free 00014 Software Foundation; either version 2, or (at your option) any later 00015 version. 00016 00017 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00018 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00019 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00020 for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with GCC; see the file COPYING. If not, write to the Free 00024 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00025 02111-1307, USA. */ 00026 00027 #ifdef SGI_MONGOOSE 00028 // To get typdef tree 00029 #include "rtl.h" 00030 #endif /* SGI_MONGOOSE */ 00031 00032 #ifndef GCC_VARRAY_H 00033 struct varray_head_tag; 00034 #define varray_type struct varray_head_tag * 00035 #endif 00036 00037 struct function; 00038 00039 struct inline_remap; 00040 00041 /* Per-function EH data. Used only in except.c, but GC and others 00042 manipulate pointers to the opaque type. */ 00043 struct eh_status; 00044 00045 /* Internal structure describing a region. */ 00046 struct eh_region; 00047 00048 /* Test: is exception handling turned on? */ 00049 extern int doing_eh PARAMS ((int)); 00050 00051 /* Start an exception handling region. All instructions emitted after 00052 this point are considered to be part of the region until an 00053 expand_eh_region_end variant is invoked. */ 00054 extern void expand_eh_region_start PARAMS ((void)); 00055 00056 /* End an exception handling region for a cleanup. HANDLER is an 00057 expression to expand for the cleanup. */ 00058 extern void expand_eh_region_end_cleanup PARAMS ((tree)); 00059 00060 /* End an exception handling region for a try block, and prepares 00061 for subsequent calls to expand_start_catch. */ 00062 extern void expand_start_all_catch PARAMS ((void)); 00063 00064 /* Begin a catch clause. TYPE is an object to be matched by the 00065 runtime, or a list of such objects, or null if this is a catch-all 00066 clause. */ 00067 extern void expand_start_catch PARAMS ((tree)); 00068 00069 /* End a catch clause. Control will resume after the try/catch block. */ 00070 extern void expand_end_catch PARAMS ((void)); 00071 00072 /* End a sequence of catch handlers for a try block. */ 00073 extern void expand_end_all_catch PARAMS ((void)); 00074 00075 /* End an exception region for an exception type filter. ALLOWED is a 00076 TREE_LIST of TREE_VALUE objects to be matched by the runtime. 00077 FAILURE is a function to invoke if a mismatch occurs. */ 00078 extern void expand_eh_region_end_allowed PARAMS ((tree, tree)); 00079 00080 /* End an exception region for a must-not-throw filter. FAILURE is a 00081 function to invoke if an uncaught exception propagates this far. */ 00082 extern void expand_eh_region_end_must_not_throw PARAMS ((tree)); 00083 00084 /* End an exception region for a throw. No handling goes on here, 00085 but it's the easiest way for the front-end to indicate what type 00086 is being thrown. */ 00087 extern void expand_eh_region_end_throw PARAMS ((tree)); 00088 00089 /* End a fixup region. Within this region the cleanups for the immediately 00090 enclosing region are _not_ run. This is used for goto cleanup to avoid 00091 destroying an object twice. */ 00092 extern void expand_eh_region_end_fixup PARAMS ((tree)); 00093 00094 /* Note that the current EH region (if any) may contain a throw, or a 00095 call to a function which itself may contain a throw. */ 00096 extern void note_eh_region_may_contain_throw PARAMS ((void)); 00097 00098 /* Invokes CALLBACK for every exception handler label. Only used by old 00099 loop hackery; should not be used by new code. */ 00100 extern void for_each_eh_label PARAMS ((void (*) (rtx))); 00101 00102 /* Determine if the given INSN can throw an exception. */ 00103 extern bool can_throw_internal PARAMS ((rtx)); 00104 extern bool can_throw_external PARAMS ((rtx)); 00105 00106 /* Set current_function_nothrow and cfun->all_throwers_are_sibcalls. */ 00107 extern void set_nothrow_function_flags PARAMS ((void)); 00108 00109 /* After initial rtl generation, call back to finish generating 00110 exception support code. */ 00111 extern void finish_eh_generation PARAMS ((void)); 00112 00113 extern void init_eh PARAMS ((void)); 00114 extern void init_eh_for_function PARAMS ((void)); 00115 00116 extern rtx reachable_handlers PARAMS ((rtx)); 00117 extern void maybe_remove_eh_handler PARAMS ((rtx)); 00118 00119 extern void convert_from_eh_region_ranges PARAMS ((void)); 00120 extern void convert_to_eh_region_ranges PARAMS ((void)); 00121 extern void find_exception_handler_labels PARAMS ((void)); 00122 extern bool current_function_has_exception_handlers PARAMS ((void)); 00123 extern void output_function_exception_table PARAMS ((void)); 00124 00125 extern void expand_builtin_unwind_init PARAMS ((void)); 00126 extern rtx expand_builtin_eh_return_data_regno PARAMS ((tree)); 00127 extern rtx expand_builtin_extract_return_addr PARAMS ((tree)); 00128 extern void expand_builtin_init_dwarf_reg_sizes PARAMS ((tree)); 00129 extern rtx expand_builtin_frob_return_addr PARAMS ((tree)); 00130 extern rtx expand_builtin_dwarf_sp_column PARAMS ((void)); 00131 extern void expand_builtin_eh_return PARAMS ((tree, tree)); 00132 extern void expand_eh_return PARAMS ((void)); 00133 /* from gcc patch */ 00134 extern rtx expand_builtin_extend_pointer PARAMS ((tree)); 00135 extern rtx get_exception_pointer PARAMS ((struct function *)); 00136 extern int duplicate_eh_regions PARAMS ((struct function *, 00137 struct inline_remap *)); 00138 00139 extern void sjlj_emit_function_exit_after PARAMS ((rtx)); 00140 00141 00142 /* If non-NULL, this is a function that returns an expression to be 00143 executed if an unhandled exception is propagated out of a cleanup 00144 region. For example, in C++, an exception thrown by a destructor 00145 during stack unwinding is required to result in a call to 00146 `std::terminate', so the C++ version of this function returns a 00147 CALL_EXPR for `std::terminate'. */ 00148 extern tree (*lang_protect_cleanup_actions) PARAMS ((void)); 00149 00150 /* Return true if type A catches type B. */ 00151 extern int (*lang_eh_type_covers) PARAMS ((tree a, tree b)); 00152 00153 /* Map a type to a runtime object to match type. */ 00154 extern tree (*lang_eh_runtime_type) PARAMS ((tree)); 00155 00156 #ifndef GCC_VARRAY_H 00157 #undef varray_type 00158 #endif 00159 00160 00161 /* Just because the user configured --with-sjlj-exceptions=no doesn't 00162 mean that we can use call frame exceptions. Detect that the target 00163 has appropriate support. */ 00164 00165 #if ! (defined (EH_RETURN_DATA_REGNO) \ 00166 && (defined (IA64_UNWIND_INFO) \ 00167 || (DWARF2_UNWIND_INFO \ 00168 && (defined (EH_RETURN_HANDLER_RTX) \ 00169 || defined (HAVE_eh_return))))) 00170 #define MUST_USE_SJLJ_EXCEPTIONS 1 00171 #else 00172 #define MUST_USE_SJLJ_EXCEPTIONS 0 00173 #endif 00174 00175 #ifdef CONFIG_SJLJ_EXCEPTIONS 00176 # if CONFIG_SJLJ_EXCEPTIONS == 1 00177 # define USING_SJLJ_EXCEPTIONS 1 00178 # endif 00179 # if CONFIG_SJLJ_EXCEPTIONS == 0 00180 # define USING_SJLJ_EXCEPTIONS 0 00181 # ifndef EH_RETURN_DATA_REGNO 00182 #error "EH_RETURN_DATA_REGNO required" 00183 # endif 00184 # if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return) 00185 #error "EH_RETURN_HANDLER_RTX or eh_return required" 00186 # endif 00187 # if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO) 00188 #error "{DWARF2,IA64}_UNWIND_INFO required" 00189 # endif 00190 # endif 00191 #else 00192 # define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS 00193 #endif 00194 00195 #ifdef KEY 00196 #undef USING_SJLJ_EXCEPTIONS 00197 #define USING_SJLJ_EXCEPTIONS 0 00198 #endif
1.5.6