function.h (struct sequence_stack): Remove rtl_expr.
[gcc.git] / gcc / function.h
1 /* Structure for saving state for a nested function.
2 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22
23 #if !defined(NULL_TREE) && !defined(tree)
24 typedef union union_node *_function_tree;
25 #define tree _function_tree
26 #endif
27 #if !defined(NULL_RTX) && !defined(rtx)
28 typedef struct rtx_def *_function_rtx;
29 #define rtx _function_rtx
30 #endif
31
32 struct var_refs_queue
33 {
34 rtx modified;
35 enum machine_mode promoted_mode;
36 int unsignedp;
37 struct var_refs_queue *next;
38 };
39
40 /* Stack of pending (incomplete) sequences saved by `start_sequence'.
41 Each element describes one pending sequence.
42 The main insn-chain is saved in the last element of the chain,
43 unless the chain is empty. */
44
45 struct sequence_stack
46 {
47 /* First and last insns in the chain of the saved sequence. */
48 rtx first, last;
49 struct sequence_stack *next;
50 };
51
52 extern struct sequence_stack *sequence_stack;
53
54 /* Stack of single obstacks. */
55
56 struct simple_obstack_stack
57 {
58 struct obstack *obstack;
59 struct simple_obstack_stack *next;
60 };
61 \f
62 struct emit_status
63 {
64 /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
65 After rtl generation, it is 1 plus the largest register number used. */
66 int x_reg_rtx_no;
67
68 /* Lowest label number in current function. */
69 int x_first_label_num;
70
71 /* The ends of the doubly-linked chain of rtl for the current function.
72 Both are reset to null at the start of rtl generation for the function.
73
74 start_sequence saves both of these on `sequence_stack' along with
75 `sequence_rtl_expr' and then starts a new, nested sequence of insns. */
76 rtx x_first_insn;
77 rtx x_last_insn;
78
79 /* Stack of pending (incomplete) sequences saved by `start_sequence'.
80 Each element describes one pending sequence.
81 The main insn-chain is saved in the last element of the chain,
82 unless the chain is empty. */
83 struct sequence_stack *sequence_stack;
84
85 /* INSN_UID for next insn emitted.
86 Reset to 1 for each function compiled. */
87 int x_cur_insn_uid;
88
89 /* Line number and source file of the last line-number NOTE emitted.
90 This is used to avoid generating duplicates. */
91 int x_last_linenum;
92 char *x_last_filename;
93
94 /* A vector indexed by pseudo reg number. The allocated length
95 of this vector is regno_pointer_flag_length. Since this
96 vector is needed during the expansion phase when the total
97 number of registers in the function is not yet known,
98 it is copied and made bigger when necessary. */
99 char *regno_pointer_flag;
100 int regno_pointer_flag_length;
101
102 /* Indexed by pseudo register number, if nonzero gives the known alignment
103 for that pseudo (if regno_pointer_flag is set).
104 Allocated in parallel with regno_pointer_flag. */
105 char *regno_pointer_align;
106
107 /* Indexed by pseudo register number, gives the rtx for that pseudo.
108 Allocated in parallel with regno_pointer_flag. */
109 rtx *x_regno_reg_rtx;
110 };
111
112 /* For backward compatibility... eventually these should all go away. */
113 #define reg_rtx_no (cfun->emit->x_reg_rtx_no)
114 #define regno_reg_rtx (cfun->emit->x_regno_reg_rtx)
115 #define seq_stack (cfun->emit->sequence_stack)
116
117 #define REGNO_POINTER_ALIGN(REGNO) (cfun->emit->regno_pointer_align[REGNO])
118 #define REGNO_POINTER_FLAG(REGNO) (cfun->emit->regno_pointer_flag[REGNO])
119
120 struct expr_status
121 {
122 /* Number of units that we should eventually pop off the stack.
123 These are the arguments to function calls that have already returned. */
124 int x_pending_stack_adjust;
125
126 /* Number of units that we should eventually pop off the stack.
127 These are the arguments to function calls that have not happened yet. */
128 int x_arg_space_so_far;
129
130 /* Under some ABIs, it is the caller's responsibility to pop arguments
131 pushed for function calls. A naive implementation would simply pop
132 the arguments immediately after each call. However, if several
133 function calls are made in a row, it is typically cheaper to pop
134 all the arguments after all of the calls are complete since a
135 single pop instruction can be used. Therefore, GCC attempts to
136 defer popping the arguments until absolutely necessary. (For
137 example, at the end of a conditional, the arguments must be popped,
138 since code outside the conditional won't know whether or not the
139 arguments need to be popped.)
140
141 When INHIBIT_DEFER_POP is non-zero, however, the compiler does not
142 attempt to defer pops. Instead, the stack is popped immediately
143 after each call. Rather then setting this variable directly, use
144 NO_DEFER_POP and OK_DEFER_POP. */
145 int x_inhibit_defer_pop;
146
147 /* Nonzero means __builtin_saveregs has already been done in this function.
148 The value is the pseudoreg containing the value __builtin_saveregs
149 returned. */
150 rtx x_saveregs_value;
151
152 /* Similarly for __builtin_apply_args. */
153 rtx x_apply_args_value;
154
155 /* List of labels that must never be deleted. */
156 rtx x_forced_labels;
157
158 /* Postincrements that still need to be expanded. */
159 rtx x_pending_chain;
160 };
161
162 #define pending_stack_adjust (cfun->expr->x_pending_stack_adjust)
163 #define arg_space_so_far (cfun->expr->x_arg_space_so_far)
164 #define inhibit_defer_pop (cfun->expr->x_inhibit_defer_pop)
165 #define saveregs_value (cfun->expr->x_saveregs_value)
166 #define apply_args_value (cfun->expr->x_apply_args_value)
167 #define forced_labels (cfun->expr->x_forced_labels)
168 #define pending_chain (cfun->expr->x_pending_chain)
169
170 /* This structure can save all the important global and static variables
171 describing the status of the current function. */
172
173 struct function
174 {
175 struct function *next_global;
176 struct function *next;
177
178 struct eh_status *eh;
179 struct stmt_status *stmt;
180 struct expr_status *expr;
181 struct emit_status *emit;
182 struct varasm_status *varasm;
183
184 /* For function.c. */
185
186 /* Name of this function. */
187 const char *name;
188 /* Points to the FUNCTION_DECL of this function. */
189 tree decl;
190
191 /* Number of bytes of args popped by function being compiled on its return.
192 Zero if no bytes are to be popped.
193 May affect compilation of return insn or of function epilogue. */
194 int pops_args;
195
196 /* Nonzero if function being compiled needs to be given an address
197 where the value should be stored. */
198 int returns_struct;
199
200 /* Nonzero if function being compiled needs to
201 return the address of where it has put a structure value. */
202 int returns_pcc_struct;
203
204 /* Nonzero if the current function returns a pointer type. */
205 int returns_pointer;
206
207 /* Nonzero if function being compiled needs to be passed a static chain. */
208 int needs_context;
209
210 /* Nonzero if function being compiled can call setjmp. */
211 int calls_setjmp;
212
213 /* Nonzero if function being compiled can call longjmp. */
214 int calls_longjmp;
215
216 /* Nonzero if function being compiled can call alloca,
217 either as a subroutine or builtin. */
218 int calls_alloca;
219
220 /* Nonzero if function being compiled receives nonlocal gotos
221 from nested functions. */
222
223 int has_nonlocal_label;
224
225 /* Nonzero if function being compiled has nonlocal gotos to parent
226 function. */
227 int has_nonlocal_goto;
228
229 /* Nonzero if function being compiled contains nested functions. */
230 int contains_functions;
231
232 /* Nonzero if the function being compiled issues a computed jump. */
233 int has_computed_jump;
234
235 /* Nonzero if the current function is a thunk (a lightweight function that
236 just adjusts one of its arguments and forwards to another function), so
237 we should try to cut corners where we can. */
238 int is_thunk;
239
240 /* If function's args have a fixed size, this is that size, in bytes.
241 Otherwise, it is -1.
242 May affect compilation of return insn or of function epilogue. */
243 int args_size;
244
245 /* # bytes the prologue should push and pretend that the caller pushed them.
246 The prologue must do this, but only if parms can be passed in
247 registers. */
248 int pretend_args_size;
249
250 /* # of bytes of outgoing arguments. If ACCUMULATE_OUTGOING_ARGS is
251 defined, the needed space is pushed by the prologue. */
252 int outgoing_args_size;
253
254 /* This is the offset from the arg pointer to the place where the first
255 anonymous arg can be found, if there is one. */
256 rtx arg_offset_rtx;
257
258 /* Nonzero if current function uses varargs.h or equivalent.
259 Zero for functions that use stdarg.h. */
260 int varargs;
261
262 /* Nonzero if current function uses stdarg.h or equivalent.
263 Zero for functions that use varargs.h. */
264 int stdarg;
265
266 /* Quantities of various kinds of registers
267 used for the current function's args. */
268 CUMULATIVE_ARGS args_info;
269
270 /* If non-zero, an RTL expression for the location at which the current
271 function returns its result. If the current function returns its
272 result in a register, current_function_return_rtx will always be
273 the hard register containing the result. */
274 rtx return_rtx;
275
276 /* The arg pointer hard register, or the pseudo into which it was copied. */
277 rtx internal_arg_pointer;
278
279 /* Language-specific reason why the current function cannot be made
280 inline. */
281 const char *cannot_inline;
282
283 /* Nonzero if instrumentation calls for function entry and exit should be
284 generated. */
285 int instrument_entry_exit;
286
287 /* Nonzero if memory access checking be enabled in the current function. */
288 int check_memory_usage;
289
290 /* Nonzero if stack limit checking should be enabled in the current
291 function. */
292 int limit_stack;
293
294 /* Number of function calls seen so far in current function. */
295 int x_function_call_count;
296
297 /* Nonzero if this function is being processed in function-at-a-time
298 mode. In other words, if all tree structure for this function,
299 including the BLOCK tree is created, before RTL generation
300 commences. */
301 int x_whole_function_mode_p;
302
303 /* Nonzero if the back-end should not keep track of expressions that
304 determine the size of variable-sized objects. Normally, such
305 expressions are saved away, and then expanded when the next
306 function is started. For example, if a parameter has a
307 variable-sized type, then the size of the parameter is computed
308 when the function body is entered. However, some front-ends do
309 not desire this behavior. */
310 int x_dont_save_pending_sizes_p;
311
312 /* List (chain of TREE_LIST) of LABEL_DECLs for all nonlocal labels
313 (labels to which there can be nonlocal gotos from nested functions)
314 in this function. */
315 tree x_nonlocal_labels;
316
317 /* List (chain of EXPR_LIST) of stack slots that hold the current handlers
318 for nonlocal gotos. There is one for every nonlocal label in the
319 function; this list matches the one in nonlocal_labels.
320 Zero when function does not have nonlocal labels. */
321 rtx x_nonlocal_goto_handler_slots;
322
323 /* List (chain of EXPR_LIST) of labels heading the current handlers for
324 nonlocal gotos. */
325 rtx x_nonlocal_goto_handler_labels;
326
327 /* RTX for stack slot that holds the stack pointer value to restore
328 for a nonlocal goto.
329 Zero when function does not have nonlocal labels. */
330 rtx x_nonlocal_goto_stack_level;
331
332 /* Label that will go on parm cleanup code, if any.
333 Jumping to this label runs cleanup code for parameters, if
334 such code must be run. Following this code is the logical return
335 label. */
336 rtx x_cleanup_label;
337
338 /* Label that will go on function epilogue.
339 Jumping to this label serves as a "return" instruction
340 on machines which require execution of the epilogue on all returns. */
341 rtx x_return_label;
342
343 /* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
344 So we can mark them all live at the end of the function, if nonopt. */
345 rtx x_save_expr_regs;
346
347 /* List (chain of EXPR_LISTs) of all stack slots in this function.
348 Made for the sake of unshare_all_rtl. */
349 rtx x_stack_slot_list;
350
351 /* Chain of all RTL_EXPRs that have insns in them. */
352 tree x_rtl_expr_chain;
353
354 /* Label to jump back to for tail recursion, or 0 if we have
355 not yet needed one for this function. */
356 rtx x_tail_recursion_label;
357
358 /* Place after which to insert the tail_recursion_label if we need one. */
359 rtx x_tail_recursion_reentry;
360
361 /* Location at which to save the argument pointer if it will need to be
362 referenced. There are two cases where this is done: if nonlocal gotos
363 exist, or if vars stored at an offset from the argument pointer will be
364 needed by inner routines. */
365 rtx x_arg_pointer_save_area;
366
367 /* Offset to end of allocated area of stack frame.
368 If stack grows down, this is the address of the last stack slot allocated.
369 If stack grows up, this is the address for the next slot. */
370 HOST_WIDE_INT x_frame_offset;
371
372 /* List (chain of TREE_LISTs) of static chains for containing functions.
373 Each link has a FUNCTION_DECL in the TREE_PURPOSE and a reg rtx
374 in an RTL_EXPR in the TREE_VALUE. */
375 tree x_context_display;
376
377 /* List (chain of TREE_LISTs) of trampolines for nested functions.
378 The trampoline sets up the static chain and jumps to the function.
379 We supply the trampoline's address when the function's address is
380 requested.
381
382 Each link has a FUNCTION_DECL in the TREE_PURPOSE and a reg rtx
383 in an RTL_EXPR in the TREE_VALUE. */
384 tree x_trampoline_list;
385
386 /* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
387 rtx x_parm_birth_insn;
388
389 /* Last insn of those whose job was to put parms into their nominal
390 homes. */
391 rtx x_last_parm_insn;
392
393 /* 1 + last pseudo register number possibly used for loading a copy
394 of a parameter of this function. */
395 int x_max_parm_reg;
396
397 /* Vector indexed by REGNO, containing location on stack in which
398 to put the parm which is nominally in pseudo register REGNO,
399 if we discover that that parm must go in the stack. The highest
400 element in this vector is one less than MAX_PARM_REG, above. */
401 rtx *x_parm_reg_stack_loc;
402
403 /* List of all temporaries allocated, both available and in use. */
404 struct temp_slot *x_temp_slots;
405
406 /* Current nesting level for temporaries. */
407 int x_temp_slot_level;
408
409 /* Current nesting level for variables in a block. */
410 int x_var_temp_slot_level;
411
412 /* When temporaries are created by TARGET_EXPRs, they are created at
413 this level of temp_slot_level, so that they can remain allocated
414 until no longer needed. CLEANUP_POINT_EXPRs define the lifetime
415 of TARGET_EXPRs. */
416 int x_target_temp_slot_level;
417
418 /* This slot is initialized as 0 and is added to
419 during the nested function. */
420 struct var_refs_queue *fixup_var_refs_queue;
421
422 /* For tree.c. */
423 int all_types_permanent;
424 struct momentary_level *momentary_stack;
425 char *maybepermanent_firstobj;
426 char *temporary_firstobj;
427 char *momentary_firstobj;
428 char *momentary_function_firstobj;
429 struct obstack *current_obstack;
430 struct obstack *function_obstack;
431 struct obstack *function_maybepermanent_obstack;
432 struct obstack *expression_obstack;
433 struct obstack *saveable_obstack;
434 struct obstack *rtl_obstack;
435
436 /* For integrate.c. */
437 int inlinable;
438 /* This is in fact an rtvec. */
439 void *original_arg_vector;
440 tree original_decl_initial;
441 /* Last insn of those whose job was to put parms into their nominal
442 homes. */
443 rtx inl_last_parm_insn;
444 /* Highest label number in current function. */
445 int inl_max_label_num;
446
447 /* Nonzero if the current function uses the constant pool. */
448 int uses_const_pool;
449
450 /* For md files. */
451
452 /* Nonzero if the current function uses pic_offset_table_rtx. */
453 int uses_pic_offset_table;
454 /* tm.h can use this to store whatever it likes. */
455 struct machine_function *machine;
456 /* The largest alignment of slot allocated on the stack. */
457 int stack_alignment_needed;
458 /* Preferred alignment of the end of stack frame. */
459 int preferred_stack_boundary;
460
461 /* Language-specific code can use this to store whatever it likes. */
462 struct language_function *language;
463
464 /* For reorg. */
465
466 /* If some insns can be deferred to the delay slots of the epilogue, the
467 delay list for them is recorded here. */
468 rtx epilogue_delay_list;
469 };
470
471 /* The function currently being compiled. */
472 extern struct function *cfun;
473
474 /* A list of all functions we have compiled so far. */
475 extern struct function *all_functions;
476
477 /* For backward compatibility... eventually these should all go away. */
478 #define current_function_name (cfun->name)
479 #define current_function_pops_args (cfun->pops_args)
480 #define current_function_returns_struct (cfun->returns_struct)
481 #define current_function_returns_pcc_struct (cfun->returns_pcc_struct)
482 #define current_function_returns_pointer (cfun->returns_pointer)
483 #define current_function_needs_context (cfun->needs_context)
484 #define current_function_calls_setjmp (cfun->calls_setjmp)
485 #define current_function_calls_alloca (cfun->calls_alloca)
486 #define current_function_calls_longjmp (cfun->calls_longjmp)
487 #define current_function_has_computed_jump (cfun->has_computed_jump)
488 #define current_function_contains_functions (cfun->contains_functions)
489 #define current_function_is_thunk (cfun->is_thunk)
490 #define current_function_args_info (cfun->args_info)
491 #define current_function_args_size (cfun->args_size)
492 #define current_function_pretend_args_size (cfun->pretend_args_size)
493 #define current_function_outgoing_args_size (cfun->outgoing_args_size)
494 #define current_function_arg_offset_rtx (cfun->arg_offset_rtx)
495 #define current_function_varargs (cfun->varargs)
496 #define current_function_stdarg (cfun->stdarg)
497 #define current_function_internal_arg_pointer (cfun->internal_arg_pointer)
498 #define current_function_return_rtx (cfun->return_rtx)
499 #define current_function_instrument_entry_exit (cfun->instrument_entry_exit)
500 #define current_function_check_memory_usage (cfun->check_memory_usage)
501 #define current_function_limit_stack (cfun->limit_stack)
502 #define current_function_uses_pic_offset_table (cfun->uses_pic_offset_table)
503 #define current_function_uses_const_pool (cfun->uses_const_pool)
504 #define current_function_cannot_inline (cfun->cannot_inline)
505 #define current_function_epilogue_delay_list (cfun->epilogue_delay_list)
506 #define current_function_has_nonlocal_label (cfun->has_nonlocal_label)
507 #define current_function_has_nonlocal_goto (cfun->has_nonlocal_goto)
508
509 #define max_parm_reg (cfun->x_max_parm_reg)
510 #define parm_reg_stack_loc (cfun->x_parm_reg_stack_loc)
511 #define cleanup_label (cfun->x_cleanup_label)
512 #define return_label (cfun->x_return_label)
513 #define save_expr_regs (cfun->x_save_expr_regs)
514 #define stack_slot_list (cfun->x_stack_slot_list)
515 #define parm_birth_insn (cfun->x_parm_birth_insn)
516 #define frame_offset (cfun->x_frame_offset)
517 #define tail_recursion_label (cfun->x_tail_recursion_label)
518 #define tail_recursion_reentry (cfun->x_tail_recursion_reentry)
519 #define arg_pointer_save_area (cfun->x_arg_pointer_save_area)
520 #define rtl_expr_chain (cfun->x_rtl_expr_chain)
521 #define last_parm_insn (cfun->x_last_parm_insn)
522 #define context_display (cfun->x_context_display)
523 #define trampoline_list (cfun->x_trampoline_list)
524 #define function_call_count (cfun->x_function_call_count)
525 #define temp_slots (cfun->x_temp_slots)
526 #define temp_slot_level (cfun->x_temp_slot_level)
527 #define target_temp_slot_level (cfun->x_target_temp_slot_level)
528 #define var_temp_slot_level (cfun->x_var_temp_slot_level)
529 #define nonlocal_labels (cfun->x_nonlocal_labels)
530 #define nonlocal_goto_handler_slots (cfun->x_nonlocal_goto_handler_slots)
531 #define nonlocal_goto_handler_labels (cfun->x_nonlocal_goto_handler_labels)
532 #define nonlocal_goto_stack_level (cfun->x_nonlocal_goto_stack_level)
533
534 /* The FUNCTION_DECL for an inline function currently being expanded. */
535 extern tree inline_function_decl;
536
537 /* Given a function decl for a containing function,
538 return the `struct function' for it. */
539 struct function *find_function_data PARAMS ((tree));
540
541 /* Pointer to chain of `struct function' for containing functions. */
542 extern struct function *outer_function_chain;
543
544 /* Put all this function's BLOCK nodes into a vector and return it.
545 Also store in each NOTE for the beginning or end of a block
546 the index of that block in the vector. */
547 extern void identify_blocks PARAMS ((tree, rtx));
548
549 /* Set BLOCK_NUMBER for all the blocks in FN. */
550 extern void number_blocks PARAMS ((tree));
551
552 /* Return size needed for stack frame based on slots so far allocated.
553 This size counts from zero. It is not rounded to STACK_BOUNDARY;
554 the caller may have to do that. */
555 extern HOST_WIDE_INT get_frame_size PARAMS ((void));
556 /* Likewise, but for a different than the current function. */
557 extern HOST_WIDE_INT get_func_frame_size PARAMS ((struct function *));
558
559 /* These variables hold pointers to functions to
560 save and restore machine-specific data,
561 in push_function_context and pop_function_context. */
562 extern void (*init_machine_status) PARAMS ((struct function *));
563 extern void (*mark_machine_status) PARAMS ((struct function *));
564 extern void (*save_machine_status) PARAMS ((struct function *));
565 extern void (*restore_machine_status) PARAMS ((struct function *));
566 extern void (*free_machine_status) PARAMS ((struct function *));
567
568 /* Likewise, but for language-specific data. */
569 extern void (*init_lang_status) PARAMS ((struct function *));
570 extern void (*mark_lang_status) PARAMS ((struct function *));
571 extern void (*save_lang_status) PARAMS ((struct function *));
572 extern void (*restore_lang_status) PARAMS ((struct function *));
573 extern void (*free_lang_status) PARAMS ((struct function *));
574
575 /* Save and restore status information for a nested function. */
576 extern void save_tree_status PARAMS ((struct function *));
577 extern void restore_tree_status PARAMS ((struct function *));
578 extern void restore_emit_status PARAMS ((struct function *));
579 extern void free_after_parsing PARAMS ((struct function *));
580 extern void free_after_compilation PARAMS ((struct function *));
581
582 extern void init_varasm_status PARAMS ((struct function *));
583 extern void free_varasm_status PARAMS ((struct function *));
584 extern void free_emit_status PARAMS ((struct function *));
585 extern void free_stmt_status PARAMS ((struct function *));
586 extern void free_eh_status PARAMS ((struct function *));
587 extern void free_expr_status PARAMS ((struct function *));
588
589 extern rtx get_first_block_beg PARAMS ((void));
590
591 #ifdef RTX_CODE
592 extern void diddle_return_value PARAMS ((void (*)(rtx, void*), void*));
593 extern void clobber_return_register PARAMS ((void));
594 extern void use_return_register PARAMS ((void));
595 #endif
596
597 extern void init_virtual_regs PARAMS ((struct emit_status *));
598
599 /* Called once, at initialization, to initialize function.c. */
600 extern void init_function_once PARAMS ((void));
601
602 #ifdef rtx
603 #undef rtx
604 #endif
605
606 #ifdef tree
607 #undef tree
608 #endif