00001 /* Structure for saving state for a nested function. 00002 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 00003 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 00004 00005 This file is part of GCC. 00006 00007 GCC is free software; you can redistribute it and/or modify it under 00008 the terms of the GNU General Public License as published by the Free 00009 Software Foundation; either version 2, or (at your option) any later 00010 version. 00011 00012 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00013 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GCC; see the file COPYING. If not, write to the Free 00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00020 02111-1307, USA. */ 00021 00022 #ifndef GCC_FUNCTION_H 00023 #define GCC_FUNCTION_H 00024 00025 struct var_refs_queue GTY(()) 00026 { 00027 rtx modified; 00028 enum machine_mode promoted_mode; 00029 int unsignedp; 00030 struct var_refs_queue *next; 00031 }; 00032 00033 /* Stack of pending (incomplete) sequences saved by `start_sequence'. 00034 Each element describes one pending sequence. 00035 The main insn-chain is saved in the last element of the chain, 00036 unless the chain is empty. */ 00037 00038 struct sequence_stack GTY(()) 00039 { 00040 /* First and last insns in the chain of the saved sequence. */ 00041 rtx first; 00042 rtx last; 00043 struct sequence_stack *next; 00044 }; 00045 00046 extern struct sequence_stack *sequence_stack; 00047 00048 /* Stack of single obstacks. */ 00049 00050 struct simple_obstack_stack 00051 { 00052 struct obstack *obstack; 00053 struct simple_obstack_stack *next; 00054 }; 00055 00056 struct emit_status GTY(()) 00057 { 00058 /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function. 00059 After rtl generation, it is 1 plus the largest register number used. */ 00060 int x_reg_rtx_no; 00061 00062 /* Lowest label number in current function. */ 00063 int x_first_label_num; 00064 00065 /* The ends of the doubly-linked chain of rtl for the current function. 00066 Both are reset to null at the start of rtl generation for the function. 00067 00068 start_sequence saves both of these on `sequence_stack' and then starts 00069 a new, nested sequence of insns. */ 00070 rtx x_first_insn; 00071 rtx x_last_insn; 00072 00073 /* Stack of pending (incomplete) sequences saved by `start_sequence'. 00074 Each element describes one pending sequence. 00075 The main insn-chain is saved in the last element of the chain, 00076 unless the chain is empty. */ 00077 struct sequence_stack *sequence_stack; 00078 00079 /* INSN_UID for next insn emitted. 00080 Reset to 1 for each function compiled. */ 00081 int x_cur_insn_uid; 00082 00083 /* Location the last line-number NOTE emitted. 00084 This is used to avoid generating duplicates. */ 00085 location_t x_last_location; 00086 00087 /* The length of the regno_pointer_align, regno_decl, and x_regno_reg_rtx 00088 vectors. Since these vectors are needed during the expansion phase when 00089 the total number of registers in the function is not yet known, the 00090 vectors are copied and made bigger when necessary. */ 00091 int regno_pointer_align_length; 00092 00093 /* Indexed by pseudo register number, if nonzero gives the known alignment 00094 for that pseudo (if REG_POINTER is set in x_regno_reg_rtx). 00095 Allocated in parallel with x_regno_reg_rtx. */ 00096 unsigned char * GTY ((length ("%h.x_reg_rtx_no"))) 00097 regno_pointer_align; 00098 00099 /* Indexed by pseudo register number, gives the rtx for that pseudo. 00100 Allocated in parallel with regno_pointer_align. */ 00101 rtx * GTY ((length ("%h.x_reg_rtx_no"))) x_regno_reg_rtx; 00102 }; 00103 00104 /* For backward compatibility... eventually these should all go away. */ 00105 #define reg_rtx_no (cfun->emit->x_reg_rtx_no) 00106 #define regno_reg_rtx (cfun->emit->x_regno_reg_rtx) 00107 #define seq_stack (cfun->emit->sequence_stack) 00108 00109 #define REGNO_POINTER_ALIGN(REGNO) (cfun->emit->regno_pointer_align[REGNO]) 00110 00111 struct expr_status GTY(()) 00112 { 00113 /* Number of units that we should eventually pop off the stack. 00114 These are the arguments to function calls that have already returned. */ 00115 int x_pending_stack_adjust; 00116 00117 /* Under some ABIs, it is the caller's responsibility to pop arguments 00118 pushed for function calls. A naive implementation would simply pop 00119 the arguments immediately after each call. However, if several 00120 function calls are made in a row, it is typically cheaper to pop 00121 all the arguments after all of the calls are complete since a 00122 single pop instruction can be used. Therefore, GCC attempts to 00123 defer popping the arguments until absolutely necessary. (For 00124 example, at the end of a conditional, the arguments must be popped, 00125 since code outside the conditional won't know whether or not the 00126 arguments need to be popped.) 00127 00128 When INHIBIT_DEFER_POP is nonzero, however, the compiler does not 00129 attempt to defer pops. Instead, the stack is popped immediately 00130 after each call. Rather then setting this variable directly, use 00131 NO_DEFER_POP and OK_DEFER_POP. */ 00132 int x_inhibit_defer_pop; 00133 00134 /* If PREFERRED_STACK_BOUNDARY and PUSH_ROUNDING are defined, the stack 00135 boundary can be momentarily unaligned while pushing the arguments. 00136 Record the delta since last aligned boundary here in order to get 00137 stack alignment in the nested function calls working right. */ 00138 int x_stack_pointer_delta; 00139 00140 /* Nonzero means __builtin_saveregs has already been done in this function. 00141 The value is the pseudoreg containing the value __builtin_saveregs 00142 returned. */ 00143 rtx x_saveregs_value; 00144 00145 /* Similarly for __builtin_apply_args. */ 00146 rtx x_apply_args_value; 00147 00148 /* List of labels that must never be deleted. */ 00149 rtx x_forced_labels; 00150 }; 00151 00152 #define pending_stack_adjust (cfun->expr->x_pending_stack_adjust) 00153 #define inhibit_defer_pop (cfun->expr->x_inhibit_defer_pop) 00154 #define saveregs_value (cfun->expr->x_saveregs_value) 00155 #define apply_args_value (cfun->expr->x_apply_args_value) 00156 #define forced_labels (cfun->expr->x_forced_labels) 00157 #define stack_pointer_delta (cfun->expr->x_stack_pointer_delta) 00158 00159 /* This structure can save all the important global and static variables 00160 describing the status of the current function. */ 00161 00162 struct function GTY(()) 00163 { 00164 struct eh_status *eh; 00165 struct expr_status *expr; 00166 struct emit_status *emit; 00167 struct varasm_status *varasm; 00168 00169 /* For tree-optimize.c. */ 00170 00171 /* Saved tree and arguments during tree optimization. Used later for 00172 inlining */ 00173 tree saved_tree; 00174 tree saved_args; 00175 tree saved_static_chain_decl; 00176 00177 /* For function.c. */ 00178 00179 /* Points to the FUNCTION_DECL of this function. */ 00180 tree decl; 00181 00182 /* Function containing this function, if any. */ 00183 struct function *outer; 00184 00185 /* Number of bytes of args popped by function being compiled on its return. 00186 Zero if no bytes are to be popped. 00187 May affect compilation of return insn or of function epilogue. */ 00188 int pops_args; 00189 00190 /* If function's args have a fixed size, this is that size, in bytes. 00191 Otherwise, it is -1. 00192 May affect compilation of return insn or of function epilogue. */ 00193 int args_size; 00194 00195 /* # bytes the prologue should push and pretend that the caller pushed them. 00196 The prologue must do this, but only if parms can be passed in 00197 registers. */ 00198 int pretend_args_size; 00199 00200 /* # of bytes of outgoing arguments. If ACCUMULATE_OUTGOING_ARGS is 00201 defined, the needed space is pushed by the prologue. */ 00202 int outgoing_args_size; 00203 00204 /* This is the offset from the arg pointer to the place where the first 00205 anonymous arg can be found, if there is one. */ 00206 rtx arg_offset_rtx; 00207 00208 /* Quantities of various kinds of registers 00209 used for the current function's args. */ 00210 CUMULATIVE_ARGS args_info; 00211 00212 /* If nonzero, an RTL expression for the location at which the current 00213 function returns its result. If the current function returns its 00214 result in a register, current_function_return_rtx will always be 00215 the hard register containing the result. */ 00216 rtx return_rtx; 00217 00218 /* The arg pointer hard register, or the pseudo into which it was copied. */ 00219 rtx internal_arg_pointer; 00220 00221 /* Opaque pointer used by get_hard_reg_initial_val and 00222 has_hard_reg_initial_val (see integrate.[hc]). */ 00223 struct initial_value_struct *hard_reg_initial_vals; 00224 00225 /* List (chain of EXPR_LIST) of labels heading the current handlers for 00226 nonlocal gotos. */ 00227 rtx x_nonlocal_goto_handler_labels; 00228 00229 /* Label that will go on function epilogue. 00230 Jumping to this label serves as a "return" instruction 00231 on machines which require execution of the epilogue on all returns. */ 00232 rtx x_return_label; 00233 00234 /* Label that will go on the end of function epilogue. 00235 Jumping to this label serves as a "naked return" instruction 00236 on machines which require execution of the epilogue on all returns. */ 00237 rtx x_naked_return_label; 00238 00239 /* List (chain of EXPR_LISTs) of all stack slots in this function. 00240 Made for the sake of unshare_all_rtl. */ 00241 rtx x_stack_slot_list; 00242 00243 /* Place after which to insert the tail_recursion_label if we need one. */ 00244 rtx x_tail_recursion_reentry; 00245 00246 /* Location at which to save the argument pointer if it will need to be 00247 referenced. There are two cases where this is done: if nonlocal gotos 00248 exist, or if vars stored at an offset from the argument pointer will be 00249 needed by inner routines. */ 00250 rtx x_arg_pointer_save_area; 00251 00252 /* Offset to end of allocated area of stack frame. 00253 If stack grows down, this is the address of the last stack slot allocated. 00254 If stack grows up, this is the address for the next slot. */ 00255 HOST_WIDE_INT x_frame_offset; 00256 00257 /* A PARM_DECL that should contain the static chain for this function. 00258 It will be initialized at the beginning of the function. */ 00259 tree static_chain_decl; 00260 00261 /* An expression that contains the non-local goto save area. The first 00262 word is the saved frame pointer and the second is the saved stack 00263 pointer. */ 00264 tree nonlocal_goto_save_area; 00265 00266 /* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */ 00267 rtx x_parm_birth_insn; 00268 00269 /* List of all used temporaries allocated, by level. */ 00270 struct varray_head_tag * GTY((param_is (struct temp_slot))) x_used_temp_slots; 00271 00272 /* List of available temp slots. */ 00273 struct temp_slot *x_avail_temp_slots; 00274 00275 /* Current nesting level for temporaries. */ 00276 int x_temp_slot_level; 00277 00278 /* This slot is initialized as 0 and is added to 00279 during the nested function. */ 00280 struct var_refs_queue *fixup_var_refs_queue; 00281 00282 /* For integrate.c. */ 00283 int inlinable; 00284 int no_debugging_symbols; 00285 rtvec original_arg_vector; 00286 tree original_decl_initial; 00287 00288 /* Highest label number in current function. */ 00289 int inl_max_label_num; 00290 00291 /* Function sequence number for profiling, debugging, etc. */ 00292 int funcdef_no; 00293 00294 /* For flow.c. */ 00295 00296 /* Highest loop depth seen so far in loop analysis. Used in flow.c 00297 for the "failure strategy" when doing liveness analysis starting 00298 with non-empty initial sets. */ 00299 int max_loop_depth; 00300 00301 /* For md files. */ 00302 00303 /* tm.h can use this to store whatever it likes. */ 00304 struct machine_function * GTY ((maybe_undef)) machine; 00305 /* The largest alignment of slot allocated on the stack. */ 00306 unsigned int stack_alignment_needed; 00307 /* Preferred alignment of the end of stack frame. */ 00308 unsigned int preferred_stack_boundary; 00309 /* Set when the call to function itself has been emit. */ 00310 bool recursive_call_emit; 00311 /* Set when the tail call has been produced. */ 00312 bool tail_call_emit; 00313 00314 /* Language-specific code can use this to store whatever it likes. */ 00315 struct language_function * language; 00316 00317 /* For reorg. */ 00318 00319 /* If some insns can be deferred to the delay slots of the epilogue, the 00320 delay list for them is recorded here. */ 00321 rtx epilogue_delay_list; 00322 00323 /* How commonly executed the function is. Initialized during branch 00324 probabilities pass. */ 00325 enum function_frequency { 00326 /* This function most likely won't be executed at all. 00327 (set only when profile feedback is available). */ 00328 FUNCTION_FREQUENCY_UNLIKELY_EXECUTED, 00329 /* The default value. */ 00330 FUNCTION_FREQUENCY_NORMAL, 00331 /* Optimize this function hard 00332 (set only when profile feedback is available). */ 00333 FUNCTION_FREQUENCY_HOT 00334 } function_frequency; 00335 00336 /* Maximal number of entities in the single jumptable. Used to estimate 00337 final flowgraph size. */ 00338 int max_jumptable_ents; 00339 00340 /* UIDs for LABEL_DECLs. */ 00341 int last_label_uid; 00342 00343 /* Line number of the end of the function. */ 00344 location_t function_end_locus; 00345 00346 /* Array mapping insn uids to blocks. */ 00347 struct varray_head_tag *ib_boundaries_block; 00348 00349 /* The variables unexpanded so far. */ 00350 tree unexpanded_var_list; 00351 00352 /* Collected bit flags. */ 00353 00354 /* Nonzero if function being compiled needs to be given an address 00355 where the value should be stored. */ 00356 unsigned int returns_struct : 1; 00357 00358 /* Nonzero if function being compiled needs to 00359 return the address of where it has put a structure value. */ 00360 unsigned int returns_pcc_struct : 1; 00361 00362 /* Nonzero if the current function returns a pointer type. */ 00363 unsigned int returns_pointer : 1; 00364 00365 /* Nonzero if function being compiled can call setjmp. */ 00366 unsigned int calls_setjmp : 1; 00367 00368 /* Nonzero if function being compiled can call alloca, 00369 either as a subroutine or builtin. */ 00370 unsigned int calls_alloca : 1; 00371 00372 /* Nonzero if the function calls __builtin_eh_return. */ 00373 unsigned int calls_eh_return : 1; 00374 00375 /* Nonzero if function being compiled receives nonlocal gotos 00376 from nested functions. */ 00377 unsigned int has_nonlocal_label : 1; 00378 00379 /* Nonzero if function being compiled has nonlocal gotos to parent 00380 function. */ 00381 unsigned int has_nonlocal_goto : 1; 00382 00383 /* Nonzero if function being compiled contains nested functions. */ 00384 unsigned int contains_functions : 1; 00385 00386 /* Nonzero if the current function is a thunk, i.e., a lightweight 00387 function implemented by the output_mi_thunk hook) that just 00388 adjusts one of its arguments and forwards to another 00389 function. */ 00390 unsigned int is_thunk : 1; 00391 00392 /* This bit is used by the exception handling logic. It is set if all 00393 calls (if any) are sibling calls. Such functions do not have to 00394 have EH tables generated, as they cannot throw. A call to such a 00395 function, however, should be treated as throwing if any of its callees 00396 can throw. */ 00397 unsigned int all_throwers_are_sibcalls : 1; 00398 00399 /* Nonzero if instrumentation calls for function entry and exit should be 00400 generated. */ 00401 unsigned int instrument_entry_exit : 1; 00402 00403 /* Nonzero if profiling code should be generated. */ 00404 unsigned int profile : 1; 00405 00406 /* Nonzero if stack limit checking should be enabled in the current 00407 function. */ 00408 unsigned int limit_stack : 1; 00409 00410 /* Nonzero if current function uses stdarg.h or equivalent. */ 00411 unsigned int stdarg : 1; 00412 00413 /* Nonzero if the back-end should not keep track of expressions that 00414 determine the size of variable-sized objects. Normally, such 00415 expressions are saved away, and then expanded when the next 00416 function is started. For example, if a parameter has a 00417 variable-sized type, then the size of the parameter is computed 00418 when the function body is entered. However, some front-ends do 00419 not desire this behavior. */ 00420 unsigned int x_dont_save_pending_sizes_p : 1; 00421 00422 /* Nonzero if the current function uses the constant pool. */ 00423 unsigned int uses_const_pool : 1; 00424 00425 /* Nonzero if the current function uses pic_offset_table_rtx. */ 00426 unsigned int uses_pic_offset_table : 1; 00427 00428 /* Nonzero if the current function needs an lsda for exception handling. */ 00429 unsigned int uses_eh_lsda : 1; 00430 00431 /* Nonzero if code to initialize arg_pointer_save_area has been emitted. */ 00432 unsigned int arg_pointer_save_area_init : 1; 00433 }; 00434 00435 /* The function currently being compiled. */ 00436 extern GTY(()) struct function *cfun; 00437 00438 /* Pointer to chain of `struct function' for containing functions. */ 00439 extern GTY(()) struct function *outer_function_chain; 00440 00441 /* Nonzero if we've already converted virtual regs to hard regs. */ 00442 extern int virtuals_instantiated; 00443 00444 /* Nonzero if at least one trampoline has been created. */ 00445 extern int trampolines_created; 00446 00447 /* For backward compatibility... eventually these should all go away. */ 00448 #define current_function_pops_args (cfun->pops_args) 00449 #define current_function_returns_struct (cfun->returns_struct) 00450 #define current_function_returns_pcc_struct (cfun->returns_pcc_struct) 00451 #define current_function_returns_pointer (cfun->returns_pointer) 00452 #define current_function_calls_setjmp (cfun->calls_setjmp) 00453 #define current_function_calls_alloca (cfun->calls_alloca) 00454 #define current_function_calls_eh_return (cfun->calls_eh_return) 00455 #define current_function_contains_functions (cfun->contains_functions) 00456 #define current_function_is_thunk (cfun->is_thunk) 00457 #define current_function_args_info (cfun->args_info) 00458 #define current_function_args_size (cfun->args_size) 00459 #define current_function_pretend_args_size (cfun->pretend_args_size) 00460 #define current_function_outgoing_args_size (cfun->outgoing_args_size) 00461 #define current_function_arg_offset_rtx (cfun->arg_offset_rtx) 00462 #define current_function_stdarg (cfun->stdarg) 00463 #define current_function_internal_arg_pointer (cfun->internal_arg_pointer) 00464 #define current_function_return_rtx (cfun->return_rtx) 00465 #define current_function_instrument_entry_exit (cfun->instrument_entry_exit) 00466 #define current_function_profile (cfun->profile) 00467 #define current_function_funcdef_no (cfun->funcdef_no) 00468 #define current_function_limit_stack (cfun->limit_stack) 00469 #define current_function_uses_pic_offset_table (cfun->uses_pic_offset_table) 00470 #define current_function_uses_const_pool (cfun->uses_const_pool) 00471 #define current_function_epilogue_delay_list (cfun->epilogue_delay_list) 00472 #define current_function_has_nonlocal_label (cfun->has_nonlocal_label) 00473 #define current_function_has_nonlocal_goto (cfun->has_nonlocal_goto) 00474 00475 #define return_label (cfun->x_return_label) 00476 #define naked_return_label (cfun->x_naked_return_label) 00477 #define stack_slot_list (cfun->x_stack_slot_list) 00478 #define parm_birth_insn (cfun->x_parm_birth_insn) 00479 #define frame_offset (cfun->x_frame_offset) 00480 #define tail_recursion_reentry (cfun->x_tail_recursion_reentry) 00481 #define arg_pointer_save_area (cfun->x_arg_pointer_save_area) 00482 #define used_temp_slots (cfun->x_used_temp_slots) 00483 #define avail_temp_slots (cfun->x_avail_temp_slots) 00484 #define temp_slot_level (cfun->x_temp_slot_level) 00485 #define nonlocal_labels (cfun->x_nonlocal_labels) 00486 #define nonlocal_goto_handler_labels (cfun->x_nonlocal_goto_handler_labels) 00487 00488 /* Given a function decl for a containing function, 00489 return the `struct function' for it. */ 00490 struct function *find_function_data (tree); 00491 00492 /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END}, 00493 and create duplicate blocks. */ 00494 extern void reorder_blocks (void); 00495 00496 /* Set BLOCK_NUMBER for all the blocks in FN. */ 00497 extern void number_blocks (tree); 00498 00499 extern void clear_block_marks (tree); 00500 extern tree blocks_nreverse (tree); 00501 extern void reset_block_changes (void); 00502 extern void record_block_change (tree); 00503 extern void finalize_block_changes (void); 00504 extern void check_block_change (rtx, tree *); 00505 extern void free_block_changes (void); 00506 00507 /* Return size needed for stack frame based on slots so far allocated. 00508 This size counts from zero. It is not rounded to STACK_BOUNDARY; 00509 the caller may have to do that. */ 00510 extern HOST_WIDE_INT get_frame_size (void); 00511 /* Likewise, but for a different than the current function. */ 00512 extern HOST_WIDE_INT get_func_frame_size (struct function *); 00513 00514 /* A pointer to a function to create target specific, per-function 00515 data structures. */ 00516 extern struct machine_function * (*init_machine_status) (void); 00517 00518 /* Save and restore status information for a nested function. */ 00519 extern void free_after_parsing (struct function *); 00520 extern void free_after_compilation (struct function *); 00521 00522 extern void init_varasm_status (struct function *); 00523 00524 #ifdef RTX_CODE 00525 extern void diddle_return_value (void (*)(rtx, void*), void*); 00526 extern void clobber_return_register (void); 00527 extern void use_return_register (void); 00528 #endif 00529 00530 extern rtx get_arg_pointer_save_area (struct function *); 00531 00532 extern void init_virtual_regs (struct emit_status *); 00533 extern void instantiate_virtual_regs (void); 00534 00535 /* Returns the name of the current function. */ 00536 extern const char *current_function_name (void); 00537 00538 /* Called once, at initialization, to initialize function.c. */ 00539 extern void init_function_once (void); 00540 00541 extern void do_warn_unused_parameter (tree); 00542 00543 extern bool pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, 00544 tree, bool); 00545 extern bool reference_callee_copied (CUMULATIVE_ARGS *, enum machine_mode, 00546 tree, bool); 00547 00548 #endif /* GCC_FUNCTION_H */
1.5.6