comparison gcc/function.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Structure for saving state for a nested function. 1 /* Structure for saving state for a nested function.
2 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2 Copyright (C) 1989-2017 Free Software Foundation, Inc.
3 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5 3
6 This file is part of GCC. 4 This file is part of GCC.
7 5
8 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
20 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
21 19
22 #ifndef GCC_FUNCTION_H 20 #ifndef GCC_FUNCTION_H
23 #define GCC_FUNCTION_H 21 #define GCC_FUNCTION_H
24 22
25 #include "tree.h"
26 #include "hashtab.h"
27 #include "vecprim.h"
28 #include "tm.h" /* For CUMULATIVE_ARGS. */
29 #include "hard-reg-set.h"
30 23
31 /* Stack of pending (incomplete) sequences saved by `start_sequence'. 24 /* Stack of pending (incomplete) sequences saved by `start_sequence'.
32 Each element describes one pending sequence. 25 Each element describes one pending sequence.
33 The main insn-chain is saved in the last element of the chain, 26 The main insn-chain is saved in the last element of the chain,
34 unless the chain is empty. */ 27 unless the chain is empty. */
35 28
36 struct GTY(()) sequence_stack { 29 struct GTY(()) sequence_stack {
37 /* First and last insns in the chain of the saved sequence. */ 30 /* First and last insns in the chain of the saved sequence. */
38 rtx first; 31 rtx_insn *first;
39 rtx last; 32 rtx_insn *last;
40 struct sequence_stack *next; 33 struct sequence_stack *next;
41 }; 34 };
42 35
43 struct GTY(()) emit_status { 36 struct GTY(()) emit_status {
37 void ensure_regno_capacity ();
38
44 /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function. 39 /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
45 After rtl generation, it is 1 plus the largest register number used. */ 40 After rtl generation, it is 1 plus the largest register number used. */
46 int x_reg_rtx_no; 41 int x_reg_rtx_no;
47 42
48 /* Lowest label number in current function. */ 43 /* Lowest label number in current function. */
49 int x_first_label_num; 44 int x_first_label_num;
50 45
51 /* The ends of the doubly-linked chain of rtl for the current function. 46 /* seq.first and seq.last are the ends of the doubly-linked chain of
52 Both are reset to null at the start of rtl generation for the function. 47 rtl for the current function. Both are reset to null at the
53 48 start of rtl generation for the function.
54 start_sequence saves both of these on `sequence_stack' and then starts 49
55 a new, nested sequence of insns. */ 50 start_sequence saves both of these on seq.next and then starts
56 rtx x_first_insn; 51 a new, nested sequence of insns.
57 rtx x_last_insn; 52
58 53 seq.next is a stack of pending (incomplete) sequences saved by
59 /* Stack of pending (incomplete) sequences saved by `start_sequence'. 54 start_sequence. Each element describes one pending sequence.
60 Each element describes one pending sequence. 55 The main insn-chain is the last element of the chain. */
61 The main insn-chain is saved in the last element of the chain, 56 struct sequence_stack seq;
62 unless the chain is empty. */
63 struct sequence_stack *sequence_stack;
64 57
65 /* INSN_UID for next insn emitted. 58 /* INSN_UID for next insn emitted.
66 Reset to 1 for each function compiled. */ 59 Reset to 1 for each function compiled. */
67 int x_cur_insn_uid; 60 int x_cur_insn_uid;
68 61
69 /* INSN_UID for next debug insn emitted. Only used if 62 /* INSN_UID for next debug insn emitted. Only used if
70 --param min-nondebug-insn-uid=<value> is given with nonzero value. */ 63 --param min-nondebug-insn-uid=<value> is given with nonzero value. */
71 int x_cur_debug_insn_uid; 64 int x_cur_debug_insn_uid;
72
73 /* Location the last line-number NOTE emitted.
74 This is used to avoid generating duplicates. */
75 location_t x_last_location;
76 65
77 /* The length of the regno_pointer_align, regno_decl, and x_regno_reg_rtx 66 /* The length of the regno_pointer_align, regno_decl, and x_regno_reg_rtx
78 vectors. Since these vectors are needed during the expansion phase when 67 vectors. Since these vectors are needed during the expansion phase when
79 the total number of registers in the function is not yet known, the 68 the total number of registers in the function is not yet known, the
80 vectors are copied and made bigger when necessary. */ 69 vectors are copied and made bigger when necessary. */
85 Allocated in parallel with x_regno_reg_rtx. */ 74 Allocated in parallel with x_regno_reg_rtx. */
86 unsigned char * GTY((skip)) regno_pointer_align; 75 unsigned char * GTY((skip)) regno_pointer_align;
87 }; 76 };
88 77
89 78
90 /* Indexed by pseudo register number, gives the rtx for that pseudo. 79 /* Indexed by register number, gives an rtx for that register (and only
91 Allocated in parallel with regno_pointer_align. 80 that register). For pseudo registers, it is the unique rtx for
92 FIXME: We could put it into emit_status struct, but gengtype is not able to deal 81 that pseudo. For hard registers, it is an rtx of the mode specified
93 with length attribute nested in top level structures. */ 82 by reg_raw_mode.
83
84 FIXME: We could put it into emit_status struct, but gengtype is not
85 able to deal with length attribute nested in top level structures. */
94 86
95 extern GTY ((length ("crtl->emit.x_reg_rtx_no"))) rtx * regno_reg_rtx; 87 extern GTY ((length ("crtl->emit.x_reg_rtx_no"))) rtx * regno_reg_rtx;
96 88
97 /* For backward compatibility... eventually these should all go away. */ 89 /* For backward compatibility... eventually these should all go away. */
98 #define reg_rtx_no (crtl->emit.x_reg_rtx_no) 90 #define reg_rtx_no (crtl->emit.x_reg_rtx_no)
99 #define seq_stack (crtl->emit.sequence_stack)
100 91
101 #define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO]) 92 #define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO])
102 93
103 struct GTY(()) expr_status { 94 struct GTY(()) expr_status {
104 /* Number of units that we should eventually pop off the stack. 95 /* Number of units that we should eventually pop off the stack.
135 126
136 /* Similarly for __builtin_apply_args. */ 127 /* Similarly for __builtin_apply_args. */
137 rtx x_apply_args_value; 128 rtx x_apply_args_value;
138 129
139 /* List of labels that must never be deleted. */ 130 /* List of labels that must never be deleted. */
140 rtx x_forced_labels; 131 vec<rtx_insn *, va_gc> *x_forced_labels;
141 }; 132 };
142 133
143 typedef struct call_site_record_d *call_site_record; 134 typedef struct call_site_record_d *call_site_record;
144 DEF_VEC_P(call_site_record);
145 DEF_VEC_ALLOC_P(call_site_record, gc);
146 135
147 /* RTL representation of exception handling. */ 136 /* RTL representation of exception handling. */
148 struct GTY(()) rtl_eh { 137 struct GTY(()) rtl_eh {
149 rtx ehr_stackadj; 138 rtx ehr_stackadj;
150 rtx ehr_handler; 139 rtx ehr_handler;
151 rtx ehr_label; 140 rtx_code_label *ehr_label;
152 141
153 rtx sjlj_fc; 142 rtx sjlj_fc;
154 rtx sjlj_exit_after; 143 rtx_insn *sjlj_exit_after;
155 144
156 VEC(uchar,gc) *action_record_data; 145 vec<uchar, va_gc> *action_record_data;
157 146
158 VEC(call_site_record,gc) *call_site_record[2]; 147 vec<call_site_record, va_gc> *call_site_record_v[2];
159 }; 148 };
160 149
161 #define pending_stack_adjust (crtl->expr.x_pending_stack_adjust) 150 #define pending_stack_adjust (crtl->expr.x_pending_stack_adjust)
162 #define inhibit_defer_pop (crtl->expr.x_inhibit_defer_pop) 151 #define inhibit_defer_pop (crtl->expr.x_inhibit_defer_pop)
163 #define saveregs_value (crtl->expr.x_saveregs_value) 152 #define saveregs_value (crtl->expr.x_saveregs_value)
164 #define apply_args_value (crtl->expr.x_apply_args_value) 153 #define apply_args_value (crtl->expr.x_apply_args_value)
165 #define forced_labels (crtl->expr.x_forced_labels) 154 #define forced_labels (crtl->expr.x_forced_labels)
166 #define stack_pointer_delta (crtl->expr.x_stack_pointer_delta) 155 #define stack_pointer_delta (crtl->expr.x_stack_pointer_delta)
167 156
168 struct gimple_df; 157 struct gimple_df;
169 struct temp_slot;
170 typedef struct temp_slot *temp_slot_p;
171 struct call_site_record_d; 158 struct call_site_record_d;
172 159 struct dw_fde_node;
173 DEF_VEC_P(temp_slot_p);
174 DEF_VEC_ALLOC_P(temp_slot_p,gc);
175 struct ipa_opt_pass_d;
176 typedef struct ipa_opt_pass_d *ipa_opt_pass;
177
178 DEF_VEC_P(ipa_opt_pass);
179 DEF_VEC_ALLOC_P(ipa_opt_pass,heap);
180 160
181 struct GTY(()) varasm_status { 161 struct GTY(()) varasm_status {
182 /* If we're using a per-function constant pool, this is it. */ 162 /* If we're using a per-function constant pool, this is it. */
183 struct rtx_constant_pool *pool; 163 struct rtx_constant_pool *pool;
184 164
185 /* Number of tree-constants deferred during the expansion of this 165 /* Number of tree-constants deferred during the expansion of this
186 function. */ 166 function. */
187 unsigned int deferred_constants; 167 unsigned int deferred_constants;
188 }; 168 };
189 169
190 /* Information mainlined about RTL representation of incoming arguments. */
191 struct GTY(()) incoming_args {
192 /* Number of bytes of args popped by function being compiled on its return.
193 Zero if no bytes are to be popped.
194 May affect compilation of return insn or of function epilogue. */
195 int pops_args;
196
197 /* If function's args have a fixed size, this is that size, in bytes.
198 Otherwise, it is -1.
199 May affect compilation of return insn or of function epilogue. */
200 int size;
201
202 /* # bytes the prologue should push and pretend that the caller pushed them.
203 The prologue must do this, but only if parms can be passed in
204 registers. */
205 int pretend_args_size;
206
207 /* This is the offset from the arg pointer to the place where the first
208 anonymous arg can be found, if there is one. */
209 rtx arg_offset_rtx;
210
211 /* Quantities of various kinds of registers
212 used for the current function's args. */
213 CUMULATIVE_ARGS info;
214
215 /* The arg pointer hard register, or the pseudo into which it was copied. */
216 rtx internal_arg_pointer;
217 };
218 170
219 /* Data for function partitioning. */ 171 /* Data for function partitioning. */
220 struct GTY(()) function_subsections { 172 struct GTY(()) function_subsections {
221 /* Assembly labels for the hot and cold text sections, to 173 /* Assembly labels for the hot and cold text sections, to
222 be used by debugger functions for determining the size of text 174 be used by debugger functions for determining the size of text
237 189
238 HOST_WIDE_INT start; 190 HOST_WIDE_INT start;
239 HOST_WIDE_INT length; 191 HOST_WIDE_INT length;
240 }; 192 };
241 193
242 /* Datastructures maintained for currently processed function in RTL form. */
243 struct GTY(()) rtl_data {
244 struct expr_status expr;
245 struct emit_status emit;
246 struct varasm_status varasm;
247 struct incoming_args args;
248 struct function_subsections subsections;
249 struct rtl_eh eh;
250
251 /* For function.c */
252
253 /* # of bytes of outgoing arguments. If ACCUMULATE_OUTGOING_ARGS is
254 defined, the needed space is pushed by the prologue. */
255 int outgoing_args_size;
256
257 /* If nonzero, an RTL expression for the location at which the current
258 function returns its result. If the current function returns its
259 result in a register, current_function_return_rtx will always be
260 the hard register containing the result. */
261 rtx return_rtx;
262
263 /* Opaque pointer used by get_hard_reg_initial_val and
264 has_hard_reg_initial_val (see integrate.[hc]). */
265 struct initial_value_struct *hard_reg_initial_vals;
266
267 /* A variable living at the top of the frame that holds a known value.
268 Used for detecting stack clobbers. */
269 tree stack_protect_guard;
270
271 /* List (chain of EXPR_LIST) of labels heading the current handlers for
272 nonlocal gotos. */
273 rtx x_nonlocal_goto_handler_labels;
274
275 /* Label that will go on function epilogue.
276 Jumping to this label serves as a "return" instruction
277 on machines which require execution of the epilogue on all returns. */
278 rtx x_return_label;
279
280 /* Label that will go on the end of function epilogue.
281 Jumping to this label serves as a "naked return" instruction
282 on machines which require execution of the epilogue on all returns. */
283 rtx x_naked_return_label;
284
285 /* List (chain of EXPR_LISTs) of all stack slots in this function.
286 Made for the sake of unshare_all_rtl. */
287 rtx x_stack_slot_list;
288
289 /* List of empty areas in the stack frame. */
290 struct frame_space *frame_space_list;
291
292 /* Place after which to insert the tail_recursion_label if we need one. */
293 rtx x_stack_check_probe_note;
294
295 /* Location at which to save the argument pointer if it will need to be
296 referenced. There are two cases where this is done: if nonlocal gotos
297 exist, or if vars stored at an offset from the argument pointer will be
298 needed by inner routines. */
299 rtx x_arg_pointer_save_area;
300
301 /* Dynamic Realign Argument Pointer used for realigning stack. */
302 rtx drap_reg;
303
304 /* Offset to end of allocated area of stack frame.
305 If stack grows down, this is the address of the last stack slot allocated.
306 If stack grows up, this is the address for the next slot. */
307 HOST_WIDE_INT x_frame_offset;
308
309 /* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
310 rtx x_parm_birth_insn;
311
312 /* List of all used temporaries allocated, by level. */
313 VEC(temp_slot_p,gc) *x_used_temp_slots;
314
315 /* List of available temp slots. */
316 struct temp_slot *x_avail_temp_slots;
317
318 /* Current nesting level for temporaries. */
319 int x_temp_slot_level;
320
321 /* The largest alignment needed on the stack, including requirement
322 for outgoing stack alignment. */
323 unsigned int stack_alignment_needed;
324
325 /* Preferred alignment of the end of stack frame, which is preferred
326 to call other functions. */
327 unsigned int preferred_stack_boundary;
328
329 /* The minimum alignment of parameter stack. */
330 unsigned int parm_stack_boundary;
331
332 /* The largest alignment of slot allocated on the stack. */
333 unsigned int max_used_stack_slot_alignment;
334
335 /* The stack alignment estimated before reload, with consideration of
336 following factors:
337 1. Alignment of local stack variables (max_used_stack_slot_alignment)
338 2. Alignment requirement to call other functions
339 (preferred_stack_boundary)
340 3. Alignment of non-local stack variables but might be spilled in
341 local stack. */
342 unsigned int stack_alignment_estimated;
343
344 /* For reorg. */
345
346 /* If some insns can be deferred to the delay slots of the epilogue, the
347 delay list for them is recorded here. */
348 rtx epilogue_delay_list;
349
350 /* Nonzero if function being compiled called builtin_return_addr or
351 builtin_frame_address with nonzero count. */
352 bool accesses_prior_frames;
353
354 /* Nonzero if the function calls __builtin_eh_return. */
355 bool calls_eh_return;
356
357 /* Nonzero if function saves all registers, e.g. if it has a nonlocal
358 label that can reach the exit block via non-exceptional paths. */
359 bool saves_all_registers;
360
361 /* Nonzero if function being compiled has nonlocal gotos to parent
362 function. */
363 bool has_nonlocal_goto;
364
365 /* Nonzero if function being compiled has an asm statement. */
366 bool has_asm_statement;
367
368 /* This bit is used by the exception handling logic. It is set if all
369 calls (if any) are sibling calls. Such functions do not have to
370 have EH tables generated, as they cannot throw. A call to such a
371 function, however, should be treated as throwing if any of its callees
372 can throw. */
373 bool all_throwers_are_sibcalls;
374
375 /* Nonzero if stack limit checking should be enabled in the current
376 function. */
377 bool limit_stack;
378
379 /* Nonzero if profiling code should be generated. */
380 bool profile;
381
382 /* Nonzero if the current function uses the constant pool. */
383 bool uses_const_pool;
384
385 /* Nonzero if the current function uses pic_offset_table_rtx. */
386 bool uses_pic_offset_table;
387
388 /* Nonzero if the current function needs an lsda for exception handling. */
389 bool uses_eh_lsda;
390
391 /* Set when the tail call has been produced. */
392 bool tail_call_emit;
393
394 /* Nonzero if code to initialize arg_pointer_save_area has been emitted. */
395 bool arg_pointer_save_area_init;
396
397 /* Nonzero if current function must be given a frame pointer.
398 Set in global.c if anything is allocated on the stack there. */
399 bool frame_pointer_needed;
400
401 /* When set, expand should optimize for speed. */
402 bool maybe_hot_insn_p;
403
404 /* Nonzero if function stack realignment is needed. This flag may be
405 set twice: before and after reload. It is set before reload wrt
406 stack alignment estimation before reload. It will be changed after
407 reload if by then criteria of stack realignment is different.
408 The value set after reload is the accurate one and is finalized. */
409 bool stack_realign_needed;
410
411 /* Nonzero if function stack realignment is tried. This flag is set
412 only once before reload. It affects register elimination. This
413 is used to generate DWARF debug info for stack variables. */
414 bool stack_realign_tried;
415
416 /* Nonzero if function being compiled needs dynamic realigned
417 argument pointer (drap) if stack needs realigning. */
418 bool need_drap;
419
420 /* Nonzero if function stack realignment estimation is done, namely
421 stack_realign_needed flag has been set before reload wrt estimated
422 stack alignment info. */
423 bool stack_realign_processed;
424
425 /* Nonzero if function stack realignment has been finalized, namely
426 stack_realign_needed flag has been set and finalized after reload. */
427 bool stack_realign_finalized;
428
429 /* True if dbr_schedule has already been called for this function. */
430 bool dbr_scheduled_p;
431
432 /* True if current function can not throw. Unlike
433 TREE_NOTHROW (current_function_decl) it is set even for overwritable
434 function where currently compiled version of it is nothrow. */
435 bool nothrow;
436
437 /* Like regs_ever_live, but 1 if a reg is set or clobbered from an
438 asm. Unlike regs_ever_live, elements of this array corresponding
439 to eliminable regs (like the frame pointer) are set if an asm
440 sets them. */
441 HARD_REG_SET asm_clobbers;
442 };
443
444 #define return_label (crtl->x_return_label)
445 #define naked_return_label (crtl->x_naked_return_label)
446 #define stack_slot_list (crtl->x_stack_slot_list)
447 #define parm_birth_insn (crtl->x_parm_birth_insn)
448 #define frame_offset (crtl->x_frame_offset)
449 #define stack_check_probe_note (crtl->x_stack_check_probe_note)
450 #define arg_pointer_save_area (crtl->x_arg_pointer_save_area)
451 #define used_temp_slots (crtl->x_used_temp_slots)
452 #define avail_temp_slots (crtl->x_avail_temp_slots)
453 #define temp_slot_level (crtl->x_temp_slot_level)
454 #define nonlocal_goto_handler_labels (crtl->x_nonlocal_goto_handler_labels)
455 #define frame_pointer_needed (crtl->frame_pointer_needed)
456 #define stack_realign_fp (crtl->stack_realign_needed && !crtl->need_drap)
457 #define stack_realign_drap (crtl->stack_realign_needed && crtl->need_drap)
458
459 extern GTY(()) struct rtl_data x_rtl;
460
461 /* Accessor to RTL datastructures. We keep them statically allocated now since
462 we never keep multiple functions. For threaded compiler we might however
463 want to do differently. */
464 #define crtl (&x_rtl)
465
466 struct GTY(()) stack_usage 194 struct GTY(()) stack_usage
467 { 195 {
468 /* # of bytes of static stack space allocated by the function. */ 196 /* # of bytes of static stack space allocated by the function. */
469 HOST_WIDE_INT static_stack_size; 197 HOST_WIDE_INT static_stack_size;
470 198
474 202
475 /* # of bytes of space pushed onto the stack after the prologue. If 203 /* # of bytes of space pushed onto the stack after the prologue. If
476 !ACCUMULATE_OUTGOING_ARGS, it contains the outgoing arguments. */ 204 !ACCUMULATE_OUTGOING_ARGS, it contains the outgoing arguments. */
477 int pushed_stack_size; 205 int pushed_stack_size;
478 206
479 /* # of dynamic allocations in the function. */
480 unsigned int dynamic_alloc_count : 31;
481
482 /* Nonzero if the amount of stack space allocated dynamically cannot 207 /* Nonzero if the amount of stack space allocated dynamically cannot
483 be bounded at compile-time. */ 208 be bounded at compile-time. */
484 unsigned int has_unbounded_dynamic_stack_size : 1; 209 unsigned int has_unbounded_dynamic_stack_size : 1;
485 }; 210 };
486 211
487 #define current_function_static_stack_size (cfun->su->static_stack_size) 212 #define current_function_static_stack_size (cfun->su->static_stack_size)
488 #define current_function_dynamic_stack_size (cfun->su->dynamic_stack_size) 213 #define current_function_dynamic_stack_size (cfun->su->dynamic_stack_size)
489 #define current_function_pushed_stack_size (cfun->su->pushed_stack_size) 214 #define current_function_pushed_stack_size (cfun->su->pushed_stack_size)
490 #define current_function_dynamic_alloc_count (cfun->su->dynamic_alloc_count)
491 #define current_function_has_unbounded_dynamic_stack_size \ 215 #define current_function_has_unbounded_dynamic_stack_size \
492 (cfun->su->has_unbounded_dynamic_stack_size) 216 (cfun->su->has_unbounded_dynamic_stack_size)
493 #define current_function_allocates_dynamic_stack_space \ 217 #define current_function_allocates_dynamic_stack_space \
494 (current_function_dynamic_stack_size != 0 \ 218 (current_function_dynamic_stack_size != 0 \
495 || current_function_has_unbounded_dynamic_stack_size) 219 || current_function_has_unbounded_dynamic_stack_size)
502 226
503 /* The control flow graph for this function. */ 227 /* The control flow graph for this function. */
504 struct control_flow_graph *cfg; 228 struct control_flow_graph *cfg;
505 229
506 /* GIMPLE body for this function. */ 230 /* GIMPLE body for this function. */
507 struct gimple_seq_d *gimple_body; 231 gimple_seq gimple_body;
508 232
509 /* SSA and dataflow information. */ 233 /* SSA and dataflow information. */
510 struct gimple_df *gimple_df; 234 struct gimple_df *gimple_df;
511 235
512 /* The loops in this function. */ 236 /* The loops in this function. */
513 struct loops *x_current_loops; 237 struct loops *x_current_loops;
238
239 /* Filled by the GIMPLE and RTL FEs, pass to start compilation with. */
240 char *pass_startwith;
514 241
515 /* The stack usage of this function. */ 242 /* The stack usage of this function. */
516 struct stack_usage *su; 243 struct stack_usage *su;
517 244
518 /* Value histograms attached to particular statements. */ 245 /* Value histograms attached to particular statements. */
531 word is the saved frame pointer and the second is the saved stack 258 word is the saved frame pointer and the second is the saved stack
532 pointer. */ 259 pointer. */
533 tree nonlocal_goto_save_area; 260 tree nonlocal_goto_save_area;
534 261
535 /* Vector of function local variables, functions, types and constants. */ 262 /* Vector of function local variables, functions, types and constants. */
536 VEC(tree,gc) *local_decls; 263 vec<tree, va_gc> *local_decls;
264
265 /* In a Cilk function, the VAR_DECL for the frame descriptor. */
266 tree cilk_frame_decl;
537 267
538 /* For md files. */ 268 /* For md files. */
539 269
540 /* tm.h can use this to store whatever it likes. */ 270 /* tm.h can use this to store whatever it likes. */
541 struct machine_function * GTY ((maybe_undef)) machine; 271 struct machine_function * GTY ((maybe_undef)) machine;
542 272
543 /* Language-specific code can use this to store whatever it likes. */ 273 /* Language-specific code can use this to store whatever it likes. */
544 struct language_function * language; 274 struct language_function * language;
545 275
546 /* Used types hash table. */ 276 /* Used types hash table. */
547 htab_t GTY ((param_is (union tree_node))) used_types_hash; 277 hash_set<tree> *GTY (()) used_types_hash;
278
279 /* Dwarf2 Frame Description Entry, containing the Call Frame Instructions
280 used for unwinding. Only set when either dwarf2 unwinding or dwarf2
281 debugging is enabled. */
282 struct dw_fde_node *fde;
548 283
549 /* Last statement uid. */ 284 /* Last statement uid. */
550 int last_stmt_uid; 285 int last_stmt_uid;
551 286
552 /* Function sequence number for profiling, debugging, etc. */ 287 /* Function sequence number for profiling, debugging, etc. */
565 /* Non-null if the function does something that would prevent it from 300 /* Non-null if the function does something that would prevent it from
566 being copied; this applies to both versioning and inlining. Set to 301 being copied; this applies to both versioning and inlining. Set to
567 a string describing the reason for failure. */ 302 a string describing the reason for failure. */
568 const char * GTY((skip)) cannot_be_copied_reason; 303 const char * GTY((skip)) cannot_be_copied_reason;
569 304
305 /* Last assigned dependence info clique. */
306 unsigned short last_clique;
307
570 /* Collected bit flags. */ 308 /* Collected bit flags. */
571 309
572 /* Number of units of general registers that need saving in stdarg 310 /* Number of units of general registers that need saving in stdarg
573 function. What unit is depends on the backend, either it is number 311 function. What unit is depends on the backend, either it is number
574 of bytes, or it can be number of registers. */ 312 of bytes, or it can be number of registers. */
583 321
584 /* Nonzero if function being compiled can call alloca, 322 /* Nonzero if function being compiled can call alloca,
585 either as a subroutine or builtin. */ 323 either as a subroutine or builtin. */
586 unsigned int calls_alloca : 1; 324 unsigned int calls_alloca : 1;
587 325
326 /* This will indicate whether a function is a cilk function */
327 unsigned int is_cilk_function : 1;
328
329 /* Nonzero if this is a Cilk function that spawns. */
330 unsigned int calls_cilk_spawn : 1;
331
588 /* Nonzero if function being compiled receives nonlocal gotos 332 /* Nonzero if function being compiled receives nonlocal gotos
589 from nested functions. */ 333 from nested functions. */
590 unsigned int has_nonlocal_label : 1; 334 unsigned int has_nonlocal_label : 1;
335
336 /* Nonzero if function being compiled has a forced label
337 placed into static storage. */
338 unsigned int has_forced_label_in_static : 1;
591 339
592 /* Nonzero if we've set cannot_be_copied_reason. I.e. if 340 /* Nonzero if we've set cannot_be_copied_reason. I.e. if
593 (cannot_be_copied_set && !cannot_be_copied_reason), the function 341 (cannot_be_copied_set && !cannot_be_copied_reason), the function
594 can in fact be copied. */ 342 can in fact be copied. */
595 unsigned int cannot_be_copied_set : 1; 343 unsigned int cannot_be_copied_set : 1;
596 344
597 /* Nonzero if current function uses stdarg.h or equivalent. */ 345 /* Nonzero if current function uses stdarg.h or equivalent. */
598 unsigned int stdarg : 1; 346 unsigned int stdarg : 1;
599 347
600 /* Nonzero if the back-end should not keep track of expressions that
601 determine the size of variable-sized objects. Normally, such
602 expressions are saved away, and then expanded when the next
603 function is started. For example, if a parameter has a
604 variable-sized type, then the size of the parameter is computed
605 when the function body is entered. However, some front-ends do
606 not desire this behavior. */
607 unsigned int dont_save_pending_sizes_p : 1;
608
609 unsigned int after_inlining : 1; 348 unsigned int after_inlining : 1;
610 unsigned int always_inline_functions_inlined : 1; 349 unsigned int always_inline_functions_inlined : 1;
611 350
612 /* Nonzero if function being compiled can throw synchronous non-call 351 /* Nonzero if function being compiled can throw synchronous non-call
613 exceptions. */ 352 exceptions. */
614 unsigned int can_throw_non_call_exceptions : 1; 353 unsigned int can_throw_non_call_exceptions : 1;
615 354
355 /* Nonzero if instructions that may throw exceptions but don't otherwise
356 contribute to the execution of the program can be deleted. */
357 unsigned int can_delete_dead_exceptions : 1;
358
616 /* Fields below this point are not set for abstract functions; see 359 /* Fields below this point are not set for abstract functions; see
617 allocate_struct_function. */ 360 allocate_struct_function. */
618 361
619 /* Nonzero if function being compiled needs to be given an address 362 /* Nonzero if function being compiled needs to be given an address
620 where the value should be stored. */ 363 where the value should be stored. */
621 unsigned int returns_struct : 1; 364 unsigned int returns_struct : 1;
622 365
623 /* Nonzero if function being compiled needs to 366 /* Nonzero if function being compiled needs to
624 return the address of where it has put a structure value. */ 367 return the address of where it has put a structure value. */
625 unsigned int returns_pcc_struct : 1; 368 unsigned int returns_pcc_struct : 1;
626
627 /* Nonzero if pass_tree_profile was run on this function. */
628 unsigned int after_tree_profile : 1;
629 369
630 /* Nonzero if this function has local DECL_HARD_REGISTER variables. 370 /* Nonzero if this function has local DECL_HARD_REGISTER variables.
631 In this case code motion has to be done more carefully. */ 371 In this case code motion has to be done more carefully. */
632 unsigned int has_local_explicit_reg_vars : 1; 372 unsigned int has_local_explicit_reg_vars : 1;
633 373
634 /* Nonzero if the current function is a thunk, i.e., a lightweight 374 /* Nonzero if the current function is a thunk, i.e., a lightweight
635 function implemented by the output_mi_thunk hook) that just 375 function implemented by the output_mi_thunk hook) that just
636 adjusts one of its arguments and forwards to another 376 adjusts one of its arguments and forwards to another
637 function. */ 377 function. */
638 unsigned int is_thunk : 1; 378 unsigned int is_thunk : 1;
379
380 /* Nonzero if the current function contains any loops with
381 loop->force_vectorize set. */
382 unsigned int has_force_vectorize_loops : 1;
383
384 /* Nonzero if the current function contains any loops with
385 nonzero value in loop->simduid. */
386 unsigned int has_simduid_loops : 1;
387
388 /* Set when the tail call has been identified. */
389 unsigned int tail_call_marked : 1;
639 }; 390 };
640 391
641 /* Add the decl D to the local_decls list of FUN. */ 392 /* Add the decl D to the local_decls list of FUN. */
642 393
643 static inline void 394 void add_local_decl (struct function *fun, tree d);
644 add_local_decl (struct function *fun, tree d)
645 {
646 VEC_safe_push (tree, gc, fun->local_decls, d);
647 }
648 395
649 #define FOR_EACH_LOCAL_DECL(FUN, I, D) \ 396 #define FOR_EACH_LOCAL_DECL(FUN, I, D) \
650 FOR_EACH_VEC_ELT_REVERSE (tree, (FUN)->local_decls, I, D) 397 FOR_EACH_VEC_SAFE_ELT_REVERSE ((FUN)->local_decls, I, D)
651 398
652 /* If va_list_[gf]pr_size is set to this, it means we don't know how 399 /* If va_list_[gf]pr_size is set to this, it means we don't know how
653 many units need to be saved. */ 400 many units need to be saved. */
654 #define VA_LIST_MAX_GPR_SIZE 255 401 #define VA_LIST_MAX_GPR_SIZE 255
655 #define VA_LIST_MAX_FPR_SIZE 255 402 #define VA_LIST_MAX_FPR_SIZE 255
666 extern int virtuals_instantiated; 413 extern int virtuals_instantiated;
667 414
668 /* Nonzero if at least one trampoline has been created. */ 415 /* Nonzero if at least one trampoline has been created. */
669 extern int trampolines_created; 416 extern int trampolines_created;
670 417
671 struct GTY(()) types_used_by_vars_entry { 418 struct GTY((for_user)) types_used_by_vars_entry {
672 tree type; 419 tree type;
673 tree var_decl; 420 tree var_decl;
421 };
422
423 struct used_type_hasher : ggc_ptr_hash<types_used_by_vars_entry>
424 {
425 static hashval_t hash (types_used_by_vars_entry *);
426 static bool equal (types_used_by_vars_entry *, types_used_by_vars_entry *);
674 }; 427 };
675 428
676 /* Hash table making the relationship between a global variable 429 /* Hash table making the relationship between a global variable
677 and the types it references in its initializer. The key of the 430 and the types it references in its initializer. The key of the
678 entry is a referenced type, and the value is the DECL of the global 431 entry is a referenced type, and the value is the DECL of the global
679 variable. types_use_by_vars_do_hash and types_used_by_vars_eq below are 432 variable. types_use_by_vars_do_hash and types_used_by_vars_eq below are
680 the hash and equality functions to use for this hash table. */ 433 the hash and equality functions to use for this hash table. */
681 extern GTY((param_is (struct types_used_by_vars_entry))) htab_t 434 extern GTY(()) hash_table<used_type_hasher> *types_used_by_vars_hash;
682 types_used_by_vars_hash; 435
683
684 hashval_t types_used_by_vars_do_hash (const void*);
685 int types_used_by_vars_eq (const void *, const void *);
686 void types_used_by_var_decl_insert (tree type, tree var_decl); 436 void types_used_by_var_decl_insert (tree type, tree var_decl);
687 437
688 /* During parsing of a global variable, this vector contains the types 438 /* During parsing of a global variable, this vector contains the types
689 referenced by the global variable. */ 439 referenced by the global variable. */
690 extern GTY(()) VEC(tree,gc) *types_used_by_cur_var_decl; 440 extern GTY(()) vec<tree, va_gc> *types_used_by_cur_var_decl;
691 441
692 442
693 /* cfun shouldn't be set directly; use one of these functions instead. */ 443 /* Return the loop tree of FN. */
694 extern void set_cfun (struct function *new_cfun); 444
695 extern void push_cfun (struct function *new_cfun); 445 inline struct loops *
696 extern void pop_cfun (void); 446 loops_for_fn (struct function *fn)
697 extern void instantiate_decl_rtl (rtx x); 447 {
448 return fn->x_current_loops;
449 }
450
451 /* Set the loop tree of FN to LOOPS. */
452
453 inline void
454 set_loops_for_fn (struct function *fn, struct loops *loops)
455 {
456 gcc_checking_assert (fn->x_current_loops == NULL || loops == NULL);
457 fn->x_current_loops = loops;
458 }
698 459
699 /* For backward compatibility... eventually these should all go away. */ 460 /* For backward compatibility... eventually these should all go away. */
700 #define current_function_funcdef_no (cfun->funcdef_no) 461 #define current_function_funcdef_no (cfun->funcdef_no)
701 462
702 #define current_loops (cfun->x_current_loops) 463 #define current_loops (cfun->x_current_loops)
703 #define dom_computed (cfun->cfg->x_dom_computed) 464 #define dom_computed (cfun->cfg->x_dom_computed)
704 #define n_bbs_in_dom_tree (cfun->cfg->x_n_bbs_in_dom_tree) 465 #define n_bbs_in_dom_tree (cfun->cfg->x_n_bbs_in_dom_tree)
705 #define VALUE_HISTOGRAMS(fun) (fun)->value_histograms 466 #define VALUE_HISTOGRAMS(fun) (fun)->value_histograms
706 467
707 /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END}, 468 /* A pointer to a function to create target specific, per-function
708 and create duplicate blocks. */ 469 data structures. */
709 extern void reorder_blocks (void); 470 extern struct machine_function * (*init_machine_status) (void);
710 471
711 /* Set BLOCK_NUMBER for all the blocks in FN. */ 472 /* Structure to record the size of a sequence of arguments
712 extern void number_blocks (tree); 473 as the sum of a tree-expression and a constant. This structure is
713 474 also used to store offsets from the stack, which might be negative,
714 extern void clear_block_marks (tree); 475 so the variable part must be ssizetype, not sizetype. */
715 extern tree blocks_nreverse (tree); 476
477 struct args_size
478 {
479 HOST_WIDE_INT constant;
480 tree var;
481 };
482
483 /* Package up various arg related fields of struct args for
484 locate_and_pad_parm. */
485 struct locate_and_pad_arg_data
486 {
487 /* Size of this argument on the stack, rounded up for any padding it
488 gets. If REG_PARM_STACK_SPACE is defined, then register parms are
489 counted here, otherwise they aren't. */
490 struct args_size size;
491 /* Offset of this argument from beginning of stack-args. */
492 struct args_size offset;
493 /* Offset to the start of the stack slot. Different from OFFSET
494 if this arg pads downward. */
495 struct args_size slot_offset;
496 /* The amount that the stack pointer needs to be adjusted to
497 force alignment for the next argument. */
498 struct args_size alignment_pad;
499 /* Which way we should pad this arg. */
500 pad_direction where_pad;
501 /* slot_offset is at least this aligned. */
502 unsigned int boundary;
503 };
504
505 /* Add the value of the tree INC to the `struct args_size' TO. */
506
507 #define ADD_PARM_SIZE(TO, INC) \
508 do { \
509 tree inc = (INC); \
510 if (tree_fits_shwi_p (inc)) \
511 (TO).constant += tree_to_shwi (inc); \
512 else if ((TO).var == 0) \
513 (TO).var = fold_convert (ssizetype, inc); \
514 else \
515 (TO).var = size_binop (PLUS_EXPR, (TO).var, \
516 fold_convert (ssizetype, inc)); \
517 } while (0)
518
519 #define SUB_PARM_SIZE(TO, DEC) \
520 do { \
521 tree dec = (DEC); \
522 if (tree_fits_shwi_p (dec)) \
523 (TO).constant -= tree_to_shwi (dec); \
524 else if ((TO).var == 0) \
525 (TO).var = size_binop (MINUS_EXPR, ssize_int (0), \
526 fold_convert (ssizetype, dec)); \
527 else \
528 (TO).var = size_binop (MINUS_EXPR, (TO).var, \
529 fold_convert (ssizetype, dec)); \
530 } while (0)
531
532 /* Convert the implicit sum in a `struct args_size' into a tree
533 of type ssizetype. */
534 #define ARGS_SIZE_TREE(SIZE) \
535 ((SIZE).var == 0 ? ssize_int ((SIZE).constant) \
536 : size_binop (PLUS_EXPR, fold_convert (ssizetype, (SIZE).var), \
537 ssize_int ((SIZE).constant)))
538
539 /* Convert the implicit sum in a `struct args_size' into an rtx. */
540 #define ARGS_SIZE_RTX(SIZE) \
541 ((SIZE).var == 0 ? GEN_INT ((SIZE).constant) \
542 : expand_normal (ARGS_SIZE_TREE (SIZE)))
543
544 #define ASLK_REDUCE_ALIGN 1
545 #define ASLK_RECORD_PAD 2
546
547 /* If pointers to member functions use the least significant bit to
548 indicate whether a function is virtual, ensure a pointer
549 to this function will have that bit clear. */
550 #define MINIMUM_METHOD_BOUNDARY \
551 ((TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn) \
552 ? MAX (FUNCTION_BOUNDARY, 2 * BITS_PER_UNIT) : FUNCTION_BOUNDARY)
553
554 enum stack_clash_probes {
555 NO_PROBE_NO_FRAME,
556 NO_PROBE_SMALL_FRAME,
557 PROBE_INLINE,
558 PROBE_LOOP
559 };
560
561 extern void dump_stack_clash_frame_info (enum stack_clash_probes, bool);
562
563
564 extern void push_function_context (void);
565 extern void pop_function_context (void);
566
567 /* Save and restore status information for a nested function. */
568 extern void free_after_parsing (struct function *);
569 extern void free_after_compilation (struct function *);
716 570
717 /* Return size needed for stack frame based on slots so far allocated. 571 /* Return size needed for stack frame based on slots so far allocated.
718 This size counts from zero. It is not rounded to STACK_BOUNDARY; 572 This size counts from zero. It is not rounded to STACK_BOUNDARY;
719 the caller may have to do that. */ 573 the caller may have to do that. */
720 extern HOST_WIDE_INT get_frame_size (void); 574 extern HOST_WIDE_INT get_frame_size (void);
722 /* Issue an error message and return TRUE if frame OFFSET overflows in 576 /* Issue an error message and return TRUE if frame OFFSET overflows in
723 the signed target pointer arithmetics for function FUNC. Otherwise 577 the signed target pointer arithmetics for function FUNC. Otherwise
724 return FALSE. */ 578 return FALSE. */
725 extern bool frame_offset_overflow (HOST_WIDE_INT, tree); 579 extern bool frame_offset_overflow (HOST_WIDE_INT, tree);
726 580
727 /* A pointer to a function to create target specific, per-function 581 extern unsigned int spill_slot_alignment (machine_mode);
728 data structures. */ 582
729 extern struct machine_function * (*init_machine_status) (void); 583 extern rtx assign_stack_local_1 (machine_mode, HOST_WIDE_INT, int, int);
730 584 extern rtx assign_stack_local (machine_mode, HOST_WIDE_INT, int);
731 /* Save and restore status information for a nested function. */ 585 extern rtx assign_stack_temp_for_type (machine_mode, HOST_WIDE_INT, tree);
732 extern void free_after_parsing (struct function *); 586 extern rtx assign_stack_temp (machine_mode, HOST_WIDE_INT);
733 extern void free_after_compilation (struct function *); 587 extern rtx assign_temp (tree, int, int);
734 588 extern void update_temp_slot_address (rtx, rtx);
735 extern void init_varasm_status (void); 589 extern void preserve_temp_slots (rtx);
736 590 extern void free_temp_slots (void);
737 #ifdef RTX_CODE 591 extern void push_temp_slots (void);
592 extern void pop_temp_slots (void);
593 extern void init_temp_slots (void);
594 extern rtx get_hard_reg_initial_reg (rtx);
595 extern rtx get_hard_reg_initial_val (machine_mode, unsigned int);
596 extern rtx has_hard_reg_initial_val (machine_mode, unsigned int);
597
598 /* Called from gimple_expand_cfg. */
599 extern unsigned int emit_initial_value_sets (void);
600
601 extern bool initial_value_entry (int i, rtx *, rtx *);
602 extern void instantiate_decl_rtl (rtx x);
603 extern int aggregate_value_p (const_tree, const_tree);
604 extern bool use_register_for_decl (const_tree);
605 extern gimple_seq gimplify_parameters (void);
606 extern void locate_and_pad_parm (machine_mode, tree, int, int, int,
607 tree, struct args_size *,
608 struct locate_and_pad_arg_data *);
609 extern void generate_setjmp_warnings (void);
610
611 /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END},
612 and create duplicate blocks. */
613 extern void reorder_blocks (void);
614 extern void clear_block_marks (tree);
615 extern tree blocks_nreverse (tree);
616 extern tree block_chainon (tree, tree);
617
618 /* Set BLOCK_NUMBER for all the blocks in FN. */
619 extern void number_blocks (tree);
620
621 /* cfun shouldn't be set directly; use one of these functions instead. */
622 extern void set_cfun (struct function *new_cfun, bool force = false);
623 extern void push_cfun (struct function *new_cfun);
624 extern void pop_cfun (void);
625
626 extern int get_next_funcdef_no (void);
627 extern int get_last_funcdef_no (void);
628 extern void allocate_struct_function (tree, bool);
629 extern void push_struct_function (tree fndecl);
630 extern void push_dummy_function (bool);
631 extern void pop_dummy_function (void);
632 extern void init_dummy_function_start (void);
633 extern void init_function_start (tree);
634 extern void stack_protect_epilogue (void);
635 extern void expand_function_start (tree);
636 extern void expand_dummy_function_end (void);
637
638 extern void thread_prologue_and_epilogue_insns (void);
738 extern void diddle_return_value (void (*)(rtx, void*), void*); 639 extern void diddle_return_value (void (*)(rtx, void*), void*);
739 extern void clobber_return_register (void); 640 extern void clobber_return_register (void);
740 #endif 641 extern void expand_function_end (void);
741
742 extern rtx get_arg_pointer_save_area (void); 642 extern rtx get_arg_pointer_save_area (void);
643 extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
644 extern int prologue_contains (const rtx_insn *);
645 extern int epilogue_contains (const rtx_insn *);
646 extern int prologue_epilogue_contains (const rtx_insn *);
647 extern void record_prologue_seq (rtx_insn *);
648 extern void record_epilogue_seq (rtx_insn *);
649 extern void emit_return_into_block (bool simple_p, basic_block bb);
650 extern void set_return_jump_label (rtx_insn *);
651 extern bool active_insn_between (rtx_insn *head, rtx_insn *tail);
652 extern vec<edge> convert_jumps_to_returns (basic_block last_bb, bool simple_p,
653 vec<edge> unconverted);
654 extern basic_block emit_return_for_exit (edge exit_fallthru_edge,
655 bool simple_p);
656 extern void reposition_prologue_and_epilogue_notes (void);
743 657
744 /* Returns the name of the current function. */ 658 /* Returns the name of the current function. */
659 extern const char *fndecl_name (tree);
660 extern const char *function_name (struct function *);
745 extern const char *current_function_name (void); 661 extern const char *current_function_name (void);
746 662
747 extern void do_warn_unused_parameter (tree);
748
749 extern bool pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
750 tree, bool);
751 extern bool reference_callee_copied (CUMULATIVE_ARGS *, enum machine_mode,
752 tree, bool);
753
754 extern void used_types_insert (tree); 663 extern void used_types_insert (tree);
755 664
756 extern int get_next_funcdef_no (void);
757
758 /* In predict.c */
759 extern bool optimize_function_for_size_p (struct function *);
760 extern bool optimize_function_for_speed_p (struct function *);
761
762 #endif /* GCC_FUNCTION_H */ 665 #endif /* GCC_FUNCTION_H */