gcc/gcc/except.h

490 lines
17 KiB
C
Raw Normal View History

1996-07-23 22:20:04 +02:00
/* Exception Handling interface routines.
1999-01-06 21:44:41 +01:00
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
1996-07-23 22:20:04 +02:00
Contributed by Mike Stump <mrs@cygnus.com>.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#if !defined(NULL_RTX) && !defined(rtx)
typedef struct rtx_def *_except_rtx;
#define rtx _except_rtx
1996-07-23 22:20:04 +02:00
#endif
#ifdef TREE_CODE
/* A stack of labels. CHAIN points to the next entry in the stack. */
1996-07-23 22:20:04 +02:00
struct label_node {
union {
rtx rlabel;
tree tlabel;
} u;
struct label_node *chain;
};
/* An eh_entry is used to describe one exception handling region.
OUTER_CONTEXT is the label used for rethrowing into the outer context.
EXCEPTION_HANDLER_LABEL is the label corresponding to the handler
for this region.
LABEL_USED indicates whether a CATCH block has already used this
label or not. New ones are needed for additional catch blocks if
it has.
FALSE_LABEL is used when either setjmp/longjmp exceptions are in
use, or old style table exceptions. It contains the label for
branching to the next runtime type check as handlers are processed.
FINALIZATION is the tree codes for the handler, or is NULL_TREE if
one hasn't been generated yet, or is integer_zero_node to mark the
end of a group of try blocks. */
1996-07-23 22:20:04 +02:00
struct eh_entry {
rtx outer_context;
1996-07-23 22:20:04 +02:00
rtx exception_handler_label;
tree finalization;
int label_used;
rtx false_label;
rtx rethrow_label;
/* If non-zero, this entry is for a handler created when we left an
exception-region via goto. */
unsigned goto_entry_p : 1;
1996-07-23 22:20:04 +02:00
};
#else
struct label_node;
struct eh_entry;
#endif
1996-07-23 22:20:04 +02:00
/* A list of EH_ENTRYs. ENTRY is the entry; CHAIN points to the next
entry in the list, or is NULL if this is the last entry. */
1996-07-23 22:20:04 +02:00
struct eh_node {
struct eh_entry *entry;
struct eh_node *chain;
};
/* A stack of EH_ENTRYs. TOP is the topmost entry on the stack. TOP is
NULL if the stack is empty. */
1996-07-23 22:20:04 +02:00
struct eh_stack {
struct eh_node *top;
};
/* A queue of EH_ENTRYs. HEAD is the front of the queue; TAIL is the
end (the latest entry). HEAD and TAIL are NULL if the queue is
empty. */
1996-07-23 22:20:04 +02:00
struct eh_queue {
struct eh_node *head;
struct eh_node *tail;
};
/* Used to save exception handling status for each function. */
struct eh_status
{
/* A stack used for keeping track of the currently active exception
handling region. As each exception region is started, an entry
describing the region is pushed onto this stack. The current
region can be found by looking at the top of the stack, and as we
exit regions, the corresponding entries are popped.
Entries cannot overlap; they can be nested. So there is only one
entry at most that corresponds to the current instruction, and that
is the entry on the top of the stack. */
struct eh_stack x_ehstack;
/* This stack is used to represent what the current eh region is
for the catch blocks beings processed */
struct eh_stack x_catchstack;
/* A queue used for tracking which exception regions have closed.
As we exit a region, we enqueue a new entry. The entries are then
dequeued during expand_leftover_cleanups and
expand_start_all_catch. */
struct eh_queue x_ehqueue;
/* Insns for all of the exception handlers for the current function.
They are currently emitted by the frontend code. */
rtx x_catch_clauses;
/* A random data area for the front end's own use. */
struct label_node *x_false_label_stack;
/* Keeps track of the label to resume to should one want to resume
normal control flow out of a handler (instead of, say, returning to
the caller of the current function or exiting the program). */
struct label_node *x_caught_return_label_stack;
/* A stack (TREE_LIST) of lists of handlers. The TREE_VALUE of each
node is itself a TREE_CHAINed list of handlers for regions that
are not yet closed. The TREE_VALUE of each entry contains the
handler for the corresponding entry on the ehstack. */
union tree_node *x_protect_list;
/* The EH context. Nonzero if the function has already
fetched a pointer to the EH context for exception handling. */
rtx ehc;
/* The label generated by expand_builtin_eh_return. */
rtx x_eh_return_stub_label;
};
#define ehstack (current_function->eh->x_ehstack)
#define catchstack (current_function->eh->x_catchstack)
#define ehqueue (current_function->eh->x_ehqueue)
#define catch_clauses (current_function->eh->x_catch_clauses)
#define false_label_stack (current_function->eh->x_false_label_stack)
#define caught_return_label_stack (current_function->eh->x_caught_return_label_stack)
#define protect_list (current_function->eh->x_protect_list)
#define current_function_ehc (current_function->eh->ehc)
#define eh_return_stub_label (current_function->eh->x_eh_return_stub_label)
#ifdef TREE_CODE
/* Start an exception handling region. All instructions emitted after
this point are considered to be part of the region until
expand_eh_region_end () is invoked. */
extern void expand_eh_region_start PROTO((void));
/* Just like expand_eh_region_start, except if a cleanup action is
entered on the cleanup chain, the TREE_PURPOSE of the element put
on the chain is DECL. DECL should be the associated VAR_DECL, if
any, otherwise it should be NULL_TREE. */
extern void expand_eh_region_start_for_decl PROTO((tree));
/* Start an exception handling region for the given cleanup action.
All instructions emitted after this point are considered to be part
of the region until expand_eh_region_end () is invoked. CLEANUP is
the cleanup action to perform. The return value is true if the
exception region was optimized away. If that case,
expand_eh_region_end does not need to be called for this cleanup,
nor should it be.
This routine notices one particular common case in C++ code
generation, and optimizes it so as to not need the exception
region. */
extern int expand_eh_region_start_tree PROTO((tree, tree));
/* End an exception handling region. The information about the region
is found on the top of ehstack.
HANDLER is either the cleanup for the exception region, or if we're
marking the end of a try block, HANDLER is integer_zero_node.
HANDLER will be transformed to rtl when expand_leftover_cleanups ()
is invoked. */
extern void expand_eh_region_end PROTO((tree));
/* Push RLABEL or TLABEL onto LABELSTACK. Only one of RLABEL or TLABEL
should be set; the other must be NULL. */
1996-07-23 22:20:04 +02:00
extern void push_label_entry PROTO((struct label_node **labelstack, rtx rlabel, tree tlabel));
/* Pop the topmost entry from LABELSTACK and return its value as an
rtx node. If LABELSTACK is empty, return NULL. */
1996-07-23 22:20:04 +02:00
extern rtx pop_label_entry PROTO((struct label_node **labelstack));
/* Return the topmost entry of LABELSTACK as a tree node, or return
NULL_TREE if LABELSTACK is empty. */
1996-07-23 22:20:04 +02:00
extern tree top_label_entry PROTO((struct label_node **labelstack));
#endif
Warning fixes: * Makefile.in (c-lang.o): Depend on c-tree.h, c-lex.h and toplev.h. (c-lex.o): Depend on output.h. (c-common.o): Likewise. (stmt.o): Likewise. (calls.o): Likewise. (integrate.o): Depend on toplev.h. (regclass.o): Depend on output.h. (final.o): Depend on reload.h. * c-common.c: Include output.h. (check_format_info): Remove unused variable `integral_format'. * c-decl.c (print_lang_decl): Mark parameters `file', `node' and `indent' with ATTRIBUTE_UNUSED. (print_lang_type): Likewise. (maybe_build_cleanup): Likewise for parameter `decl'. (copy_lang_decl): Likewise for parameter `node'. * c-lang.c: Include c-tree.h, c-lex.h and toplev.h. (lang_print_xnode): Mark parameters `file', `node' and `indent' with ATTRIBUTE_UNUSED. (lookup_interface): Likewise for parameter `arg'. (is_class_name): Likewise. (maybe_objc_check_decl): Likewise for parameter `decl'. (maybe_objc_comptypes): Likewise for parameters `lhs', `rhs' and `reflexive'. (maybe_objc_method_name): Likewise for parameter `decl'. (build_objc_string): Likewise for parameters `len' and `str'. * c-lex.c: Include output.h. * c-lex.h (position_after_white_space): Correct typo in prototype. * c-tree.h (finish_file, c_expand_start_cond, c_expand_start_else, c_expand_end_cond, init_iterators): Add prototypes. * caller-save.c (set_reg_live): Mark parameters `reg' and `setter' with ATTRIBUTE_UNUSED. * calls.c: Include output.h. * cccp.c (pipe_closed): Mark parameter `signo' with ATTRIBUTE_UNUSED. * combine.c: Move inclusion of expr.h to after insn-config.h. * iris6.h (ASM_IDENTIFY_GCC, ASM_IDENTIFY_LANGUAGE): Don't define as empty, rather define as ((void)0). * sparc.c (sparc_check_64): Add braces around ambiguous `else'. Add parentheses around assignment used as truth value. * cplus-dem.c (squangle_mop_up): Change return type to void. (internal_cplus_demangle): Remove unused parameter `options'. All callers changed. (cplus_demangle_opname): Remove function wide variable `int i' and replace with `size_t i' at each location where it is used. (cplus_demangle_opname): change type of `i' from int to size_t. * cppexp.c (right_shift): Mark parameter `pfile' with ATTRIBUTE_UNUSED. * cpphash.c (cpp_lookup): Likewise. (cpp_hash_cleanup): Likewise. * cpplib.c (parse_name): Add a prototype and make it static. (null_underflow): Mark parameter `pfile' with ATTRIBUTE_UNUSED. (null_cleanup): Likewise for parameters `pbuf' and `pfile'. (macro_cleanup): Likewise for parameter `pfile'. (file_cleanup): Likewise. * cpplib.h (cpp_reader_init, cpp_options_init, cpp_start_read, cpp_read_check_assertion, skip_rest_of_line): Add prototypes. * crtstuff.c (force_to_data, __CTOR_LIST__, force_to_data, __DTOR_END__, __FRAME_END__): Mark with ATTRIBUTE_UNUSED. * cse.c (cse_check_loop_start): Mark parameter `set' with ATTRIBUTE_UNUSED. * dbxout.c (flag_minimal_debug, have_used_extensions, source_label_number): Move inside macro wrapper check against defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO). * dwarf2out.c (gen_entry_point_die): Hide prototype and definition. * except.h (doing_eh): Provide prototype. * expr.c: Move inclusion of expr.h to after insn-config.h. * final.c: Include reload.h. (shorten_branches): Cast the first argument of bzero to char *. * fix-header.c (cpp_print_containing_files): Mark parameter `pfile' with ATTRIBUTE_UNUSED. (cpp_fatal): Likewise. * flow.c (find_basic_blocks_1): Cast the first argument of bzero to char *. * genattrtab.c (make_length_attrs): Change the type of variable `i' from int to size_t. (zero_fn): Mark parameter `exp' with ATTRIBUTE_UNUSED. (one_fn): Likewise. * genextract.c (main): When generating insn-extract.c, mark variable `junk' with ATTRIBUTE_UNUSED. * gengenrtl.c (gencode): When generating genrtl.c, cast the first argument of bzero to char*. * integrate.c: Include toplev.h. * libgcc2.c: Wrap `struct exception_table' and `find_exception_handler' in macro DWARF2_UNWIND_INFO. * objc/Make-lang.in (objc-act.o): Depend on toplev.h. * objc/objc-act.c: Include toplev.h. (lang_print_xnode): Mark parameters `file', `node' and `indent' with ATTRIBUTE_UNUSED. (finish_protocol): Likewise for parameter `protocol'. * output.h (declare_weak): Add prototype. (decode_reg_name): Don't wrap with TREE_CODE macro. (assemble_alias): Add prototype. * regclass.c: Include output.h. * reload.h (reloads_conflict): Add prototype. * rtl.h (print_rtl_single, mark_elimiation, reg_class_subset_p, output_func_start_profiler): Add prototypes. * rtlanal.c (reg_set_p_1): Mark parameters `x' and `pat' with ATTRIBUTE_UNUSED. * scan-decls.c: Include scan.h. * scan.h (recognized_function, recognized_extern): Add prototypes. * stmt.c: Include output.h. * toplev.c (error_for_asm, warning_for_asm): Remove prototypes. (output_lang_identify): Hide prototype and definition. (float_signal): Mark parameter `signo' with ATTRIBUTE_UNUSED. (pipe_closed): Likewise. * toplev.h (count_error, strip_off_ending, error_for_asm, warning_for_asm): Add prototypes. From-SVN: r19712
1998-05-13 14:40:39 +02:00
/* Test: is exception handling turned on? */
extern int doing_eh PROTO ((int));
/* Toplevel initialization for EH. */
void set_exception_lang_code PROTO((int));
void set_exception_version_code PROTO((int));
/* A list of handlers asocciated with an exception region. HANDLER_LABEL
is the the label that control should be transfered to if the data
in TYPE_INFO matches an exception. a value of NULL_TREE for TYPE_INFO
means This is a cleanup, and must always be called. A value of
CATCH_ALL_TYPE works like a cleanup, but a call to the runtime matcher
is still performed to avoid being caught by a different language
exception. NEXT is a pointer to the next handler for this region.
NULL means there are no more. */
typedef struct handler_info
{
rtx handler_label;
int handler_number;
void *type_info;
struct handler_info *next;
} handler_info;
/* Add new handler information to an exception range. The first parameter
specifies the range number (returned from new_eh_entry()). The second
parameter specifies the handler. By default the handler is inserted at
the end of the list. A handler list may contain only ONE NULL_TREE
typeinfo entry. Regardless where it is positioned, a NULL_TREE entry
is always output as the LAST handler in the exception table for a region. */
void add_new_handler PROTO((int, struct handler_info *));
/* Remove a handler label. The handler label is being deleted, so all
regions which reference this handler should have it removed from their
list of possible handlers. Any region which has the final handler
removed can be deleted. */
void remove_handler PROTO((rtx));
/* Create a new handler structure initialized with the handler label and
typeinfo fields passed in. */
struct handler_info *get_new_handler PROTO((rtx, void *));
/* Make a duplicate of an exception region by copying all the handlers
for an exception region. Return the new handler index. */
int duplicate_eh_handlers PROTO((int, int, rtx (*)(rtx)));
/* map symbol refs for rethrow */
rtx rethrow_symbol_map PROTO((rtx, rtx (*)(rtx)));
/* Is the rethrow label for a region used? */
int rethrow_used PROTO((int));
except.h (eh_nesting_info): Add new structure defintion. Tue Aug 10 10:47:42 EDT 1999 Andrew MacLeod <amacleod@cygnus.com> * except.h (eh_nesting_info): Add new structure defintion. (init_eh_nesting_info, free_eh_nesting_info): Add function prototypes. (reachable_handlers, update_rethrow_references): Add function prototypes. * rtl.h (struct rtvec_def): Update comments. REG_EH_RETHROW takes a rethrow symbol instead of an integer exception region number. * flow.c (Make_edges): Use new exception nesting routines to determine which handlers are reachable from a CALL or asynchronous insn. Dont add an edge for calls with a REG_EH_REGION of -1 to non-local goto receivers. (delete_eh_regions): Update rethrow labels, and don't delete regions which are the target of a rethrow. * except.c (struct func_eh_entry): Add rethrow_ref field, now we can avoid overloading the SYMBOL_REF_USED flag. (rethrow_symbol_map): Use new rethrow_ref field. (rethrow_used): Use new rethrow_ref field. (expand_rethrow): REG_EH_RETHROW now has a SYMBOL_REF instead of an integer. Fix formatting. (output_exception_table_entry): Use new rethrow_ref field. (can_throw): Check for EH_REGION_NOTE before deciding whether a CALL can throw or not. (scan_region): Call rethrow_used() instead of accessing data structure. (update_rethrow_references): New function to make sure only regions which are still targets of a rethrow are flagged as such. (process_nestinfo): New static function to initialize a handler list for a specific region. (init_eh_nesting_info): New function to allocate and initialize the list of all EH handlers reachable from all regions. (reachable_handlers): New function to retrieve the list of handlers reachable from a specific region and insn. (free_eh_nesting_info): New function to dispose of a list of reachable handlers. From-SVN: r28647
1999-08-10 18:19:16 +02:00
/* Update the rethrow references to reflect rethrows which have been
optimized away. */
void update_rethrow_references PROTO((void));
/* Get a pointer to the first handler in an exception region's list. */
struct handler_info *get_first_handler PROTO((int));
/* Find all the runtime handlers type matches currently referenced */
int find_all_handler_type_matches PROTO((void ***));
except.h (eh_nesting_info): Add new structure defintion. Tue Aug 10 10:47:42 EDT 1999 Andrew MacLeod <amacleod@cygnus.com> * except.h (eh_nesting_info): Add new structure defintion. (init_eh_nesting_info, free_eh_nesting_info): Add function prototypes. (reachable_handlers, update_rethrow_references): Add function prototypes. * rtl.h (struct rtvec_def): Update comments. REG_EH_RETHROW takes a rethrow symbol instead of an integer exception region number. * flow.c (Make_edges): Use new exception nesting routines to determine which handlers are reachable from a CALL or asynchronous insn. Dont add an edge for calls with a REG_EH_REGION of -1 to non-local goto receivers. (delete_eh_regions): Update rethrow labels, and don't delete regions which are the target of a rethrow. * except.c (struct func_eh_entry): Add rethrow_ref field, now we can avoid overloading the SYMBOL_REF_USED flag. (rethrow_symbol_map): Use new rethrow_ref field. (rethrow_used): Use new rethrow_ref field. (expand_rethrow): REG_EH_RETHROW now has a SYMBOL_REF instead of an integer. Fix formatting. (output_exception_table_entry): Use new rethrow_ref field. (can_throw): Check for EH_REGION_NOTE before deciding whether a CALL can throw or not. (scan_region): Call rethrow_used() instead of accessing data structure. (update_rethrow_references): New function to make sure only regions which are still targets of a rethrow are flagged as such. (process_nestinfo): New static function to initialize a handler list for a specific region. (init_eh_nesting_info): New function to allocate and initialize the list of all EH handlers reachable from all regions. (reachable_handlers): New function to retrieve the list of handlers reachable from a specific region and insn. (free_eh_nesting_info): New function to dispose of a list of reachable handlers. From-SVN: r28647
1999-08-10 18:19:16 +02:00
/* The eh_nesting_info structure is used to find a list of valid handlers
for any arbitrary exception region. When init_eh_nesting_info is called,
the information is all pre-calculated and entered in this structure.
REGION_INDEX is a vector over all possible region numbers. Since the
number of regions is typically much smaller than the range of block
numbers, this is a sparse vector and the other data structures are
represented as dense vectors. Indexed with an exception region number, this
returns the index to use in the other data structures to retreive the
correct information.
HANDLERS is an array of vectors which point to handler_info structures.
when indexed, it gives the list of all possible handlers which can
be reached by a throw from this exception region.
NUM_HANDLERS is the equivilent array indicating how many handler
pointers there are in the HANDLERS vector.
OUTER_INDEX indicates which index represents the information for the
outer block. 0 indicates there is no outer context.
REGION_COUNT is the number of regions. */
typedef struct eh_nesting
{
int *region_index;
handler_info ***handlers;
int *num_handlers;
int *outer_index;
int region_count;
} eh_nesting_info;
/* Initialize the eh_nesting_info structure. */
eh_nesting_info *init_eh_nesting_info PROTO((void));
/* Get a list of handlers reachable from a an exception region/insn. */
int reachable_handlers PROTO((int, eh_nesting_info *, rtx,
handler_info ***handlers));
/* Free the eh_nesting_info structure. */
void free_eh_nesting_info PROTO((eh_nesting_info *));
1996-07-23 22:20:04 +02:00
extern void init_eh PROTO((void));
/* Initialization for the per-function EH data. */
1996-07-23 22:20:04 +02:00
extern void init_eh_for_function PROTO((void));
/* Generate an exception label. Use instead of gen_label_rtx */
extern rtx gen_exception_label PROTO((void));
/* Adds an EH table entry for EH entry number N. Called from
final_scan_insn for NOTE_INSN_EH_REGION_BEG. */
extern void add_eh_table_entry PROTO((int n));
/* Start a catch clause, triggered by runtime value paramter. */
#ifdef TREE_CODE
extern void start_catch_handler PROTO((tree));
#endif
/* End an individual catch clause. */
extern void end_catch_handler PROTO((void));
/* Returns a non-zero value if we need to output an exception table. */
1996-07-23 22:20:04 +02:00
extern int exception_table_p PROTO((void));
/* Outputs the exception table if we have one. */
1996-07-23 22:20:04 +02:00
extern void output_exception_table PROTO((void));
/* Given a return address in ADDR, determine the address we should use
to find the corresponding EH region. */
extern rtx eh_outer_context PROTO((rtx addr));
/* Called at the start of a block of try statements for which there is
a supplied catch handler. */
extern void expand_start_try_stmts PROTO((void));
/* Called at the start of a block of catch statements. It terminates the
previous set of try statements. */
extern void expand_start_all_catch PROTO((void));
/* Called at the end of a block of catch statements. */
extern void expand_end_all_catch PROTO((void));
/* Begin a region that will contain entries created with
add_partial_entry. */
extern void begin_protect_partials PROTO((void));
#ifdef TREE_CODE
/* Create a new exception region and add the handler for the region
onto a list. These regions will be ended (and their handlers
emitted) when end_protect_partials is invoked. */
extern void add_partial_entry PROTO((tree handler));
#endif
/* End all of the pending exception regions that have handlers added with
push_protect_entry (). */
extern void end_protect_partials PROTO((void));
/* An internal throw. */
extern void expand_internal_throw PROTO((void));
/* Called from expand_exception_blocks and expand_end_catch_block to
expand and pending handlers. */
extern void expand_leftover_cleanups PROTO((void));
[multiple changes] Thu Dec 11 20:42:18 1997 Teemu Torma <tot@trema.com> Thread-safe EH support for pthreads, DCE threads and Solaris threads. * integrate.c (expand_inline_function): If the inline fn uses eh context, make sure that the current fn has one. * toplev.c (rest_of_compilation): Call emit_eh_context. * except.c (use_eh_context): New fn. (get_eh_context_once): New fn. (call_get_eh_context): New fn. (emit_eh_context): New fn. (get_eh_context): Call either get_eh_context_once or call_get_eh_context, depending on what we have. (get_dynamic_handler_chain): Call get_eh_context_once. * except.h: Prototypes for fns above. * optabs.c (get_eh_context_libfunc): Removed. (init_optabs): Don't initialize it. * expr.h (get_eh_context_libfunc): Removed. * rtl.h, rtl.c: New reg_note REG_EH_CONTEXT. * config/pa/pa.h (CPP_SPEC): Support for -threads. * config/pa/pa-hpux10.h (LIB_SPEC): Ditto. * config/pa/t-pa (MULTILIB_OPTIONS, MULTILIB_DIRNAMES): New multilib for -threads. * config/sparc/t-sol2: Added multilibs for -threads and made -pthreads alias to it. * config/sparc/sol2.h (CPP_SPEC, LIB_SPEC): Added -threads and -pthreads options. * libgcc-thr.h: New file. * libgcc2.c: (__get_cpp_eh_context): Removed. (struct cpp_eh_context): Removed. (struct eh_context): Replaced cpp_eh_context with generic language specific pointer. (__get_eh_info): New function. (__throw): Check eh_context::info. (__sjthrow): Ditto. * libgcc2.c: Include libgcc-thr.h. (new_eh_context, __get_eh_context, eh_pthread_initialize, eh_context_initialize, eh_context_static, eh_context_specific, eh_context_free): New functions. (get_eh_context, eh_context_key): New variables. (__sjthrow, __sjpopnthrow, __eh_pcnthrow, __throw): Use get_eh_context to get the context. (longjmp): Move the declaration inside #ifdef DONT_USE_BUILTIN_SETJMP. * frame.c: Include libgcc-thr.h. (object_mutex): Mutex to protect the object list. (find_fde, __register_frame, __register_frame_table, __deregister_frame): Hold the lock while accessing objects. * except.h (get_eh_context): Declare. * except.c (current_function_ehc): Define. (current_function_dhc, current_function_dcc): Removed. (get_eh_context): New function. (get_dynamic_handler_chain): Use get_eh_context. (get_saved_pc_ref): Ditto. (get_dynamic_cleanup_chain): Removed references to current_function_dcc. (save_eh_status, restore_eh_status): Save and restore current_function_ehc instead. * optabs.c (get_eh_context_libfunc): New variable. (init_optabs): Initialize it. * expr.h: Declare get_eh_context_libfunc. * function.h (struct function): Replaced dhc and dcc with ehc. * except.c (get_saved_pc_ref): New functions. (eh_saved_pc_rtx, eh_saved_pc): Deleted. (expand_internal_throw_indirect): Use get_saved_pc_ref() instead of eh_saved_pc. (end_eh_unwinder): Likewise. (init_eh): Remove initialization of eh_saved_pc. * optabs.c (get_saved_pc_libfunc): New variable. (init_optabs): Initialize it. * expr.h: Declare get_saved_pc_libfunc. * except.h (eh_saved_pc_rtx): Deleted. (get_saved_pc_ref): Declared. From Scott Snyder <snyder@d0sgif.fnal.gov>: * libgcc2.c (__get_saved_pc): New. (__eh_type, __eh_pc): Deleted. (__eh_pcnthrow): Use __get_saved_pc() instead of __eh_pc. (__get_dynamic_handler_chain): Move __dynamic_handler_chain inside this fcn. cp/: Thu Dec 11 20:43:33 1997 Teemu Torma <tot@trema.com> * decl.c (ptr_ptr_type_node): Define. (init_decl_processing): Initialize it. * cp-tree.h: Declare it. * exception.cc (__cp_exception_info): Use __get_eh_info. (__cp_push_exception): Ditto. (__cp_pop_exception): Ditto. From Scott Snyder <snyder@d0sgif.fnal.gov>: * except.c (expand_builtin_throw): Use get_saved_pc_ref instead of saved_pc. (init_exception_processing): Removed saved_pc initialization. From-SVN: r17052
1997-12-12 05:53:20 +01:00
/* If necessary, emit insns to get EH context for the current
function. */
extern void emit_eh_context PROTO((void));
/* Builds a list of handler labels and puts them in the global
variable exception_handler_labels. */
extern void find_exception_handler_labels PROTO((void));
/* Determine if an arbitrary label is an exception label */
extern int is_exception_handler_label PROTO((int));
/* Performs sanity checking on the check_exception_handler_labels
list. */
extern void check_exception_handler_labels PROTO((void));
1997-12-07 01:31:01 +01:00
/* Keeps track of the label used as the context of a throw to rethrow an
exception to the outer exception region. */
extern struct label_node *outer_context_label_stack;
/* A list of labels used for exception handlers. It is created by
find_exception_handler_labels for the optimization passes. */
1996-07-23 22:20:04 +02:00
extern rtx exception_handler_labels;
/* Performs optimizations for exception handling, such as removing
unnecessary exception regions. Invoked from jump_optimize (). */
1996-07-23 22:20:04 +02:00
extern void exception_optimize PROTO((void));
/* Return EH context (and set it up once per fn). */
[multiple changes] Thu Dec 11 20:42:18 1997 Teemu Torma <tot@trema.com> Thread-safe EH support for pthreads, DCE threads and Solaris threads. * integrate.c (expand_inline_function): If the inline fn uses eh context, make sure that the current fn has one. * toplev.c (rest_of_compilation): Call emit_eh_context. * except.c (use_eh_context): New fn. (get_eh_context_once): New fn. (call_get_eh_context): New fn. (emit_eh_context): New fn. (get_eh_context): Call either get_eh_context_once or call_get_eh_context, depending on what we have. (get_dynamic_handler_chain): Call get_eh_context_once. * except.h: Prototypes for fns above. * optabs.c (get_eh_context_libfunc): Removed. (init_optabs): Don't initialize it. * expr.h (get_eh_context_libfunc): Removed. * rtl.h, rtl.c: New reg_note REG_EH_CONTEXT. * config/pa/pa.h (CPP_SPEC): Support for -threads. * config/pa/pa-hpux10.h (LIB_SPEC): Ditto. * config/pa/t-pa (MULTILIB_OPTIONS, MULTILIB_DIRNAMES): New multilib for -threads. * config/sparc/t-sol2: Added multilibs for -threads and made -pthreads alias to it. * config/sparc/sol2.h (CPP_SPEC, LIB_SPEC): Added -threads and -pthreads options. * libgcc-thr.h: New file. * libgcc2.c: (__get_cpp_eh_context): Removed. (struct cpp_eh_context): Removed. (struct eh_context): Replaced cpp_eh_context with generic language specific pointer. (__get_eh_info): New function. (__throw): Check eh_context::info. (__sjthrow): Ditto. * libgcc2.c: Include libgcc-thr.h. (new_eh_context, __get_eh_context, eh_pthread_initialize, eh_context_initialize, eh_context_static, eh_context_specific, eh_context_free): New functions. (get_eh_context, eh_context_key): New variables. (__sjthrow, __sjpopnthrow, __eh_pcnthrow, __throw): Use get_eh_context to get the context. (longjmp): Move the declaration inside #ifdef DONT_USE_BUILTIN_SETJMP. * frame.c: Include libgcc-thr.h. (object_mutex): Mutex to protect the object list. (find_fde, __register_frame, __register_frame_table, __deregister_frame): Hold the lock while accessing objects. * except.h (get_eh_context): Declare. * except.c (current_function_ehc): Define. (current_function_dhc, current_function_dcc): Removed. (get_eh_context): New function. (get_dynamic_handler_chain): Use get_eh_context. (get_saved_pc_ref): Ditto. (get_dynamic_cleanup_chain): Removed references to current_function_dcc. (save_eh_status, restore_eh_status): Save and restore current_function_ehc instead. * optabs.c (get_eh_context_libfunc): New variable. (init_optabs): Initialize it. * expr.h: Declare get_eh_context_libfunc. * function.h (struct function): Replaced dhc and dcc with ehc. * except.c (get_saved_pc_ref): New functions. (eh_saved_pc_rtx, eh_saved_pc): Deleted. (expand_internal_throw_indirect): Use get_saved_pc_ref() instead of eh_saved_pc. (end_eh_unwinder): Likewise. (init_eh): Remove initialization of eh_saved_pc. * optabs.c (get_saved_pc_libfunc): New variable. (init_optabs): Initialize it. * expr.h: Declare get_saved_pc_libfunc. * except.h (eh_saved_pc_rtx): Deleted. (get_saved_pc_ref): Declared. From Scott Snyder <snyder@d0sgif.fnal.gov>: * libgcc2.c (__get_saved_pc): New. (__eh_type, __eh_pc): Deleted. (__eh_pcnthrow): Use __get_saved_pc() instead of __eh_pc. (__get_dynamic_handler_chain): Move __dynamic_handler_chain inside this fcn. cp/: Thu Dec 11 20:43:33 1997 Teemu Torma <tot@trema.com> * decl.c (ptr_ptr_type_node): Define. (init_decl_processing): Initialize it. * cp-tree.h: Declare it. * exception.cc (__cp_exception_info): Use __get_eh_info. (__cp_push_exception): Ditto. (__cp_pop_exception): Ditto. From Scott Snyder <snyder@d0sgif.fnal.gov>: * except.c (expand_builtin_throw): Use get_saved_pc_ref instead of saved_pc. (init_exception_processing): Removed saved_pc initialization. From-SVN: r17052
1997-12-12 05:53:20 +01:00
extern rtx get_eh_context PROTO((void));
/* Get the dynamic handler chain. */
extern rtx get_dynamic_handler_chain PROTO((void));
/* Get the dynamic cleanup chain. */
extern rtx get_dynamic_cleanup_chain PROTO((void));
/* Throw an exception. */
extern void emit_throw PROTO((void));
/* One to use setjmp/longjmp method of generating code. */
extern int exceptions_via_longjmp;
/* One to enable asynchronous exception support. */
extern int asynchronous_exceptions;
/* One to protect cleanup actions with a handler that calls
__terminate, zero otherwise. */
extern int protect_cleanup_actions_with_terminate;
#ifdef TREE_CODE
extern tree protect_with_terminate PROTO((tree));
#endif
1997-09-10 20:00:28 +02:00
Warning Fixes: * Makefile.in (print-rtl.o): Depend on bitmap.h. (dbxout.o): Depend on toplev.h. ($(SCHED_PREFIX)sched.o): Likewise. ($(out_object_file)): Likewise for system.h and toplev.h. (cppmain.o): Depend on gansidecl.h. (cpplib.o): Likewise. (cpperror.o): Likewise. (cppexp.o): Likewise. (cpphash.o): Likewise. (cppalloc.o): Likewise. (fix-header.o): Depend on cpplib.h and cpphash.h. (scan-decls.o): Depend on gansidecl.h. * basic-block.h (free_regset_vector): Add prototype. * cccp.c (check_precompiled): Mark parameter `fname' with ATTRIBUTE_UNUSED. (do_assert): Likewise for `op' and `keyword'. (do_unassert): Likewise. (do_line): Likewise for `keyword'. (do_error): Likewise for `op' and `keyword'. (do_warning): Likewise. (do_ident): Likewise for `keyword'. (do_pragma): Likewise for `limit', `op' and `keyword'. (do_sccs): Likewise. (do_if): Likewise for `keyword'. (do_elif): Likewise. (do_else): Likewise. (do_endif): Likewise. * collect2.c (getenv): Remove redundant prototype. (collect_exit, collect_execute, dump_file): Likewise. (dump_list): Wrap prototype and definition in COLLECT_EXPORT_LIST. (dump_prefix_list): Hide prototype and definition. * sparc.c: Include toplev.h. (intreg_operand): Mark parameter `mode' with ATTRIBUTE_UNUSED. (symbolic_memory_operand): Likewise. (sp64_medium_pic_operand): Likewise. (data_segment_operand): Likewise. (text_segment_operand): Likewise. (splittable_symbolic_memory_operand): Likewise. (splittable_immediate_memory_operand): Likewise. (eq_or_neq): Likewise. (normal_comp_operator): Likewise. (noov_compare_op): Likewise. (v9_regcmp_op): Likewise. (v8plus_regcmp_op): Likewise. (extend_op): Likewise. (cc_arithop): Likewise. (cc_arithopn): Likewise. (small_int): Likewise. (uns_small_int): Likewise. (clobbered_register): Likewise. (legitimize_pic_address): Likewise. (delay_operand): Likewise. (sparc_builtin_saveregs): Remove unused variable `stdarg'. * sparc.h (order_regs_for_local_alloc, eligible_for_return_delay, sparc_issue_rate, v8plus_regcmp_p): Add prototypes. * sparc.md (cmpdi_v8plus): Add abort for default case in switch. * cppalloc.c: Include gansidecl.h. * cpperror.c: Include stdarg.h/varargs.h and gansidecl.h. (cpp_file_line_for_message): Mark parameter `pfile' with ATTRIBUTE_UNUSED. (v_cpp_message): New function. (cpp_message): Use it. Also convert to variable arguments. (cpp_fatal): Likewise. (cpp_pfatal_with_name): Constify parameter `name'. * cppexp.c: Move gansidecl.h before cpplib.h. * cpphash.c: Likewise. * cpphash.h (hashf, delete_macro): Add prototypes. * cpplib.c: Include stdarg.h/varargs.h and move gansidecl.h before cpplib.h. Don't include errno.h. (update_path): Add arguments to prototype. (cpp_fatal, cpp_file_line_for_message, cpp_message, delete_macro, cpp_print_containing_files): Remove redundant prototypes. (cpp_hash_cleanup, add_import, append_include_chain, make_assertion, path_include, initialize_builtins, initialize_char_syntax, finclude, validate_else, comp_def_part, lookup_import, redundant_include_p, is_system_include, read_name_map, read_filename_string, open_include_file, check_macro_name, compare_defs, compare_token_lists, eval_if_expression, change_newlines): Add prototype arguments. (hashf): Remove redundant prototype. (read_token_list, free_token_list, safe_read, xcalloc, savestring, conditional_skip, skip_if_group): Add prototype arguments. (fdopen): Remove redundant prototype. (do_define, do_line, do_include, do_undef, do_error, do_pragma, do_ident, do_if, do_xifdef, do_else, do_elif, do_endif, do_sccs, do_once, do_assert, do_unassert, do_warning): Add prototype arguments. (struct directive): Add prototype arguments to function pointer member `func'. (handle_directive): Add missing arguments to call to `do_line'. (do_include): Mark parameters `unused1' and `unused2' with ATTRIBUTE_UNUSED. (do_line): Likewise for `keyword' and new parameters `unused1' and `unused2'. (do_error): Likewise for `keyword'. (do_warning): Likewise. Also add missing argument `pfile' in call to cpp_pedwarn. (do_once): Mark parameter `keyword', `unused1' and `unused2' with ATTRIBUTE_UNUSED. (do_ident): Likewise for `keyword', `buf' and `limit'. (do_pragma): Likewise. Also add missing arguments in call to do_once. (do_sccs): Mark parameter `keyword', `buf' and `limit' with ATTRIBUTE_UNUSED. (do_if): Likewise for `keyword'. (do_elif): Likewise. (eval_if_expression): Likewise for `buf' and `length'. (do_xifdef): Likewise for `unused1' and `unused2'. (do_else): Likewise for `keyword', `buf' and `limit'. (do_endif): Likewise. (parse_name): Add missing argument `pfile' in call to cpp_pedwarn. (cpp_handle_options): Remove superfluous NULL argument in call to cpp_fatal. (cpp_handle_options): Likewise. (do_assert): Mark parameter `keyword', `buf' and `limit' with ATTRIBUTE_UNUSED. (do_unassert): Likewise. (cpp_print_file_and_line): Add missing argument `pfile' in call to cpp_file_line_for_message. (v_cpp_error): New function. (cpp_error): Use it. Also accept variable arguments. (v_cpp_warning): New function. (cpp_warning): Use it. Also accept variable arguments. (cpp_pedwarn): Accept variable arguments. (v_cpp_error_with_line): New function (cpp_error_with_line): Use it. Accept variable arguments. (v_cpp_warning_with_line): New function. (cpp_warning_with_line): Use it. Accept variable arguments. Hide definition. (cpp_pedwarn_with_line): Accept variable arguments. (cpp_pedwarn_with_file_and_line): Likewise. (cpp_error_from_errno): Constify parameter `name'. Add missing argument `pfile' in call to cpp_file_line_for_message. (cpp_perror_with_name): Constify parameter `name'. * cpplib.h: Define PARAMS() in terms of PROTO(). (fatal): Remove redundant prototype. (cpp_error, cpp_warning, cpp_pedwarn, cpp_error_with_line, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line, cpp_error_from_errno, cpp_perror_with_name, cpp_pfatal_with_name, cpp_fatal, cpp_message, cpp_pfatal_with_name, cpp_file_line_for_message, cpp_print_containing_files): Add arguments to prototypes. (scan_decls, cpp_finish): Add prototypes. * cppmain.c: Include gansidecl.h. (main): Remove unused variable `i'. * dbxout.c: Include toplev.h. * demangle.h (do_tlink, collect_execute, collect_exit, collect_wait, dump_file, file_exists): Add prototype. * dwarf2out.c (dwarf_type_encoding_name, decl_start_label): Hide prototype and definition. (gen_unspecified_parameters_die): Don't assign results of call to function new_die() to unused variable `parm_die'. (dwarf2out_line): Mark parameter `filename' with ATTRIBUTE_UNUSED. (dwarf2out_define): Likewise for `lineno' and `buffer'. * dwarfout.c (output_unsigned_leb128, output_signed_leb128): Hide prototype and definition. (output_die): Add prototype arguments to function pointer arg. (output_unspecified_parameters_die): Mark parameter `arg' with ATTRIBUTE_UNUSED. * except.c (output_exception_table_entry): Remove unused variable `eh_entry'. * except.h (expand_fixup_region_start, expand_fixup_region_end): Add prototypes. * expr.c (do_jump_by_parts_equality_rtx): Remove prototype. * expr.h (do_jump_by_parts_equality_rtx): Add prototype. * fix-header.c: Include stdarg.h/varargs.h, move gansidecl.h before cpplib.h, include cpphash.h, remove redundant prototype of cpp_fatal, don't define `const', add a prototype for `fatal'. (cpp_file_line_for_message): Add missing arguments `pfile'. (v_cpp_message): New function. (cpp_message): Use it. (v_fatal): New function. (fatal, cpp_fatal): Use it. (cpp_pfatal_with_name): Constify parameter `name'. * flow.c (free_regset_vector): Remove redundant prototype. * function.c (round_down): Wrap prototype and definition with macro ARGS_GROW_DOWNWARD. (record_insns): Wrap prototype and definition with defined (HAVE_prologue) || defined (HAVE_epilogue). * gansidecl.h (ATTRIBUTE_PRINTF_4, ATTRIBUTE_PRINTF_5): New macros. * gen-protos.c: Include gansidecl.h. (hashf): Don't make it static, constify parameter `name'. * genattrtab.c (check_attr_test): Change XEXP() to XSTR() to match specifier %s in calls to function `fatal'. * haifa-sched.c: Include toplev.h. (find_rgns): Remove unused variable `j'. * integrate.c (note_modified_parmregs): Mark parameter `x' with ATTRIBUTE_UNUSED. (mark_stores): Likewise. * jump.c (mark_modified_reg): Likewise. * output.h (insn_current_reference_address): Add prototype. (eh_frame_section): Likewise. * print-rtl.c: Include bitmap.h. * reload1.c (reload): Wrap variables `note' and `next' in macro PRESERVE_DEATH_INFO_REGNO_P. (forget_old_reloads_1): Mark parameter `ignored' with ATTRIBUTE_UNUSED. (choose_reload_regs): Remove unused variable `in'. (reload_cse_invalidate_mem): Mark parameter `ignore' with ATTRIBUTE_UNUSED. (reload_cse_check_clobber): Likewise. * rtl.h (expand_null_return, reg_classes_intersect_p): Add prototype. (mark_elimination): Fix typo in prototype. * scan-decls.c: Include gansidecl.h. * tree.h (using_eh_for_cleanups, supports_one_only): Add prototype. From-SVN: r19867
1998-05-19 10:42:48 +02:00
extern void expand_fixup_region_start PROTO((void));
#ifdef TREE_CODE
extern void expand_fixup_region_end PROTO((tree));
#endif
1997-09-10 20:00:28 +02:00
/* Various hooks for the DWARF 2 __throw routine. */
void expand_builtin_unwind_init PROTO((void));
rtx expand_builtin_dwarf_fp_regnum PROTO((void));
#ifdef TREE_CODE
rtx expand_builtin_frob_return_addr PROTO((tree));
rtx expand_builtin_extract_return_addr PROTO((tree));
void expand_builtin_init_dwarf_reg_sizes PROTO((tree));
tree.h (BUILT_IN_CALLER_RETURN_ADDRESS): Unused. * tree.h (BUILT_IN_CALLER_RETURN_ADDRESS): Unused. Kill. (BUILT_IN_FP, BUILT_IN_SP, BUILT_IN_SET_RETURN_ADDR_REG): Kill. (BUILT_IN_EH_STUB_OLD, BUILT_IN_EH_STUB, BUILT_IN_SET_EH_REGS): Kill. (BUILT_IN_EH_RETURN, BUILT_IN_DWARF_CFA): New. * c-decl.c (init_decl_processing): Update accordingly. * expr.c (expand_builtin): Likewise. * cp/decl.c (init_decl_processing): Likewise. * rtl.h (global_rtl): Add cfa entry. (virtual_cfa_rtx, VIRTUAL_CFA_REGNUM): New. (LAST_VIRTUAL_REGISTER): Update. * emit-rtl.c (global_rtl): Add cfa entry. (init_emit): Initialize it. * function.c (cfa_offset): New. (instantiate_virtual_regs): Initialize it. (instantiate_virtual_regs_1): Instantiate virtual_cfa_rtx. (expand_function_end): Call expand_eh_return. * tm.texi (ARG_POINTER_CFA_OFFSET): New. * except.c (current_function_eh_stub_label): Kill. (current_function_eh_old_stub_label): Likwise; update all references. (expand_builtin_set_return_addr_reg): Kill. (expand_builtin_eh_stub_old, expand_builtin_eh_stub): Kill. (expand_builtin_set_eh_regs): Kill. (eh_regs): Produce a third reg for the actual handler address. (eh_return_context, eh_return_stack_adjust): New. (eh_return_handler, eh_return_stub_label): New. (init_eh_for_function): Initialize them. (expand_builtin_eh_return, expand_eh_return): New. * except.h: Update prototypes. * flow.c (find_basic_blocks_1): Update references to the stub label. * function.h (struct function): Kill stub label elements. * libgcc2.c (in_reg_window): For REG_SAVED_REG, check that the register number is one that would be in the previous window. Provide a dummy definition for non-windowed targets. (get_reg_addr): New function. (get_reg, put_reg, copy_reg): Use it. (__throw): Rely on in_reg_window, not INCOMING_REGNO. Kill stub generating code and use __builtin_eh_return. Use __builtin_dwarf_cfa. * alpha.c (alpha_eh_epilogue_sp_ofs): New. (alpha_init_expanders): Initialize it. (alpha_expand_epilogue): Use it. * alpha.h: Declare it. * alpha.md (eh_epilogue): New. * m68h.h (ARG_POINTER_CFA_OFFSET): New. * sparc.h (ARG_POINTER_CFA_OFFSET): New. From-SVN: r22436
1998-09-15 21:19:12 +02:00
void expand_builtin_eh_return PROTO((tree, tree, tree));
1997-09-10 20:00:28 +02:00
#endif
tree.h (BUILT_IN_CALLER_RETURN_ADDRESS): Unused. * tree.h (BUILT_IN_CALLER_RETURN_ADDRESS): Unused. Kill. (BUILT_IN_FP, BUILT_IN_SP, BUILT_IN_SET_RETURN_ADDR_REG): Kill. (BUILT_IN_EH_STUB_OLD, BUILT_IN_EH_STUB, BUILT_IN_SET_EH_REGS): Kill. (BUILT_IN_EH_RETURN, BUILT_IN_DWARF_CFA): New. * c-decl.c (init_decl_processing): Update accordingly. * expr.c (expand_builtin): Likewise. * cp/decl.c (init_decl_processing): Likewise. * rtl.h (global_rtl): Add cfa entry. (virtual_cfa_rtx, VIRTUAL_CFA_REGNUM): New. (LAST_VIRTUAL_REGISTER): Update. * emit-rtl.c (global_rtl): Add cfa entry. (init_emit): Initialize it. * function.c (cfa_offset): New. (instantiate_virtual_regs): Initialize it. (instantiate_virtual_regs_1): Instantiate virtual_cfa_rtx. (expand_function_end): Call expand_eh_return. * tm.texi (ARG_POINTER_CFA_OFFSET): New. * except.c (current_function_eh_stub_label): Kill. (current_function_eh_old_stub_label): Likwise; update all references. (expand_builtin_set_return_addr_reg): Kill. (expand_builtin_eh_stub_old, expand_builtin_eh_stub): Kill. (expand_builtin_set_eh_regs): Kill. (eh_regs): Produce a third reg for the actual handler address. (eh_return_context, eh_return_stack_adjust): New. (eh_return_handler, eh_return_stub_label): New. (init_eh_for_function): Initialize them. (expand_builtin_eh_return, expand_eh_return): New. * except.h: Update prototypes. * flow.c (find_basic_blocks_1): Update references to the stub label. * function.h (struct function): Kill stub label elements. * libgcc2.c (in_reg_window): For REG_SAVED_REG, check that the register number is one that would be in the previous window. Provide a dummy definition for non-windowed targets. (get_reg_addr): New function. (get_reg, put_reg, copy_reg): Use it. (__throw): Rely on in_reg_window, not INCOMING_REGNO. Kill stub generating code and use __builtin_eh_return. Use __builtin_dwarf_cfa. * alpha.c (alpha_eh_epilogue_sp_ofs): New. (alpha_init_expanders): Initialize it. (alpha_expand_epilogue): Use it. * alpha.h: Declare it. * alpha.md (eh_epilogue): New. * m68h.h (ARG_POINTER_CFA_OFFSET): New. * sparc.h (ARG_POINTER_CFA_OFFSET): New. From-SVN: r22436
1998-09-15 21:19:12 +02:00
void expand_eh_return PROTO((void));
/* Checking whether 2 instructions are within the same exception region. */
int in_same_eh_region PROTO((rtx, rtx));
void free_insn_eh_region PROTO((void));
void init_insn_eh_region PROTO((rtx, int));
#ifdef rtx
#undef rtx
#endif