1*38fd1498Szrj /* Structure for saving state for a nested function.
2*38fd1498Szrj Copyright (C) 1989-2018 Free Software Foundation, Inc.
3*38fd1498Szrj
4*38fd1498Szrj This file is part of GCC.
5*38fd1498Szrj
6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
7*38fd1498Szrj the terms of the GNU General Public License as published by the Free
8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
9*38fd1498Szrj version.
10*38fd1498Szrj
11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14*38fd1498Szrj for more details.
15*38fd1498Szrj
16*38fd1498Szrj You should have received a copy of the GNU General Public License
17*38fd1498Szrj along with GCC; see the file COPYING3. If not see
18*38fd1498Szrj <http://www.gnu.org/licenses/>. */
19*38fd1498Szrj
20*38fd1498Szrj #ifndef GCC_FUNCTION_H
21*38fd1498Szrj #define GCC_FUNCTION_H
22*38fd1498Szrj
23*38fd1498Szrj
24*38fd1498Szrj /* Stack of pending (incomplete) sequences saved by `start_sequence'.
25*38fd1498Szrj Each element describes one pending sequence.
26*38fd1498Szrj The main insn-chain is saved in the last element of the chain,
27*38fd1498Szrj unless the chain is empty. */
28*38fd1498Szrj
29*38fd1498Szrj struct GTY(()) sequence_stack {
30*38fd1498Szrj /* First and last insns in the chain of the saved sequence. */
31*38fd1498Szrj rtx_insn *first;
32*38fd1498Szrj rtx_insn *last;
33*38fd1498Szrj struct sequence_stack *next;
34*38fd1498Szrj };
35*38fd1498Szrj
36*38fd1498Szrj struct GTY(()) emit_status {
37*38fd1498Szrj void ensure_regno_capacity ();
38*38fd1498Szrj
39*38fd1498Szrj /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
40*38fd1498Szrj After rtl generation, it is 1 plus the largest register number used. */
41*38fd1498Szrj int x_reg_rtx_no;
42*38fd1498Szrj
43*38fd1498Szrj /* Lowest label number in current function. */
44*38fd1498Szrj int x_first_label_num;
45*38fd1498Szrj
46*38fd1498Szrj /* seq.first and seq.last are the ends of the doubly-linked chain of
47*38fd1498Szrj rtl for the current function. Both are reset to null at the
48*38fd1498Szrj start of rtl generation for the function.
49*38fd1498Szrj
50*38fd1498Szrj start_sequence saves both of these on seq.next and then starts
51*38fd1498Szrj a new, nested sequence of insns.
52*38fd1498Szrj
53*38fd1498Szrj seq.next is a stack of pending (incomplete) sequences saved by
54*38fd1498Szrj start_sequence. Each element describes one pending sequence.
55*38fd1498Szrj The main insn-chain is the last element of the chain. */
56*38fd1498Szrj struct sequence_stack seq;
57*38fd1498Szrj
58*38fd1498Szrj /* INSN_UID for next insn emitted.
59*38fd1498Szrj Reset to 1 for each function compiled. */
60*38fd1498Szrj int x_cur_insn_uid;
61*38fd1498Szrj
62*38fd1498Szrj /* INSN_UID for next debug insn emitted. Only used if
63*38fd1498Szrj --param min-nondebug-insn-uid=<value> is given with nonzero value. */
64*38fd1498Szrj int x_cur_debug_insn_uid;
65*38fd1498Szrj
66*38fd1498Szrj /* The length of the regno_pointer_align, regno_decl, and x_regno_reg_rtx
67*38fd1498Szrj vectors. Since these vectors are needed during the expansion phase when
68*38fd1498Szrj the total number of registers in the function is not yet known, the
69*38fd1498Szrj vectors are copied and made bigger when necessary. */
70*38fd1498Szrj int regno_pointer_align_length;
71*38fd1498Szrj
72*38fd1498Szrj /* Indexed by pseudo register number, if nonzero gives the known alignment
73*38fd1498Szrj for that pseudo (if REG_POINTER is set in x_regno_reg_rtx).
74*38fd1498Szrj Allocated in parallel with x_regno_reg_rtx. */
75*38fd1498Szrj unsigned char * GTY((skip)) regno_pointer_align;
76*38fd1498Szrj };
77*38fd1498Szrj
78*38fd1498Szrj
79*38fd1498Szrj /* Indexed by register number, gives an rtx for that register (and only
80*38fd1498Szrj that register). For pseudo registers, it is the unique rtx for
81*38fd1498Szrj that pseudo. For hard registers, it is an rtx of the mode specified
82*38fd1498Szrj by reg_raw_mode.
83*38fd1498Szrj
84*38fd1498Szrj FIXME: We could put it into emit_status struct, but gengtype is not
85*38fd1498Szrj able to deal with length attribute nested in top level structures. */
86*38fd1498Szrj
87*38fd1498Szrj extern GTY ((length ("crtl->emit.x_reg_rtx_no"))) rtx * regno_reg_rtx;
88*38fd1498Szrj
89*38fd1498Szrj /* For backward compatibility... eventually these should all go away. */
90*38fd1498Szrj #define reg_rtx_no (crtl->emit.x_reg_rtx_no)
91*38fd1498Szrj
92*38fd1498Szrj #define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO])
93*38fd1498Szrj
94*38fd1498Szrj struct GTY(()) expr_status {
95*38fd1498Szrj /* Number of units that we should eventually pop off the stack.
96*38fd1498Szrj These are the arguments to function calls that have already returned. */
97*38fd1498Szrj poly_int64_pod x_pending_stack_adjust;
98*38fd1498Szrj
99*38fd1498Szrj /* Under some ABIs, it is the caller's responsibility to pop arguments
100*38fd1498Szrj pushed for function calls. A naive implementation would simply pop
101*38fd1498Szrj the arguments immediately after each call. However, if several
102*38fd1498Szrj function calls are made in a row, it is typically cheaper to pop
103*38fd1498Szrj all the arguments after all of the calls are complete since a
104*38fd1498Szrj single pop instruction can be used. Therefore, GCC attempts to
105*38fd1498Szrj defer popping the arguments until absolutely necessary. (For
106*38fd1498Szrj example, at the end of a conditional, the arguments must be popped,
107*38fd1498Szrj since code outside the conditional won't know whether or not the
108*38fd1498Szrj arguments need to be popped.)
109*38fd1498Szrj
110*38fd1498Szrj When INHIBIT_DEFER_POP is nonzero, however, the compiler does not
111*38fd1498Szrj attempt to defer pops. Instead, the stack is popped immediately
112*38fd1498Szrj after each call. Rather then setting this variable directly, use
113*38fd1498Szrj NO_DEFER_POP and OK_DEFER_POP. */
114*38fd1498Szrj int x_inhibit_defer_pop;
115*38fd1498Szrj
116*38fd1498Szrj /* If PREFERRED_STACK_BOUNDARY and PUSH_ROUNDING are defined, the stack
117*38fd1498Szrj boundary can be momentarily unaligned while pushing the arguments.
118*38fd1498Szrj Record the delta since last aligned boundary here in order to get
119*38fd1498Szrj stack alignment in the nested function calls working right. */
120*38fd1498Szrj poly_int64_pod x_stack_pointer_delta;
121*38fd1498Szrj
122*38fd1498Szrj /* Nonzero means __builtin_saveregs has already been done in this function.
123*38fd1498Szrj The value is the pseudoreg containing the value __builtin_saveregs
124*38fd1498Szrj returned. */
125*38fd1498Szrj rtx x_saveregs_value;
126*38fd1498Szrj
127*38fd1498Szrj /* Similarly for __builtin_apply_args. */
128*38fd1498Szrj rtx x_apply_args_value;
129*38fd1498Szrj
130*38fd1498Szrj /* List of labels that must never be deleted. */
131*38fd1498Szrj vec<rtx_insn *, va_gc> *x_forced_labels;
132*38fd1498Szrj };
133*38fd1498Szrj
134*38fd1498Szrj typedef struct call_site_record_d *call_site_record;
135*38fd1498Szrj
136*38fd1498Szrj /* RTL representation of exception handling. */
137*38fd1498Szrj struct GTY(()) rtl_eh {
138*38fd1498Szrj rtx ehr_stackadj;
139*38fd1498Szrj rtx ehr_handler;
140*38fd1498Szrj rtx_code_label *ehr_label;
141*38fd1498Szrj
142*38fd1498Szrj rtx sjlj_fc;
143*38fd1498Szrj rtx_insn *sjlj_exit_after;
144*38fd1498Szrj
145*38fd1498Szrj vec<uchar, va_gc> *action_record_data;
146*38fd1498Szrj
147*38fd1498Szrj vec<call_site_record, va_gc> *call_site_record_v[2];
148*38fd1498Szrj };
149*38fd1498Szrj
150*38fd1498Szrj #define pending_stack_adjust (crtl->expr.x_pending_stack_adjust)
151*38fd1498Szrj #define inhibit_defer_pop (crtl->expr.x_inhibit_defer_pop)
152*38fd1498Szrj #define saveregs_value (crtl->expr.x_saveregs_value)
153*38fd1498Szrj #define apply_args_value (crtl->expr.x_apply_args_value)
154*38fd1498Szrj #define forced_labels (crtl->expr.x_forced_labels)
155*38fd1498Szrj #define stack_pointer_delta (crtl->expr.x_stack_pointer_delta)
156*38fd1498Szrj
157*38fd1498Szrj struct gimple_df;
158*38fd1498Szrj struct call_site_record_d;
159*38fd1498Szrj struct dw_fde_node;
160*38fd1498Szrj
161*38fd1498Szrj struct GTY(()) varasm_status {
162*38fd1498Szrj /* If we're using a per-function constant pool, this is it. */
163*38fd1498Szrj struct rtx_constant_pool *pool;
164*38fd1498Szrj
165*38fd1498Szrj /* Number of tree-constants deferred during the expansion of this
166*38fd1498Szrj function. */
167*38fd1498Szrj unsigned int deferred_constants;
168*38fd1498Szrj };
169*38fd1498Szrj
170*38fd1498Szrj
171*38fd1498Szrj /* Data for function partitioning. */
172*38fd1498Szrj struct GTY(()) function_subsections {
173*38fd1498Szrj /* Assembly labels for the hot and cold text sections, to
174*38fd1498Szrj be used by debugger functions for determining the size of text
175*38fd1498Szrj sections. */
176*38fd1498Szrj
177*38fd1498Szrj const char *hot_section_label;
178*38fd1498Szrj const char *cold_section_label;
179*38fd1498Szrj const char *hot_section_end_label;
180*38fd1498Szrj const char *cold_section_end_label;
181*38fd1498Szrj };
182*38fd1498Szrj
183*38fd1498Szrj /* Describe an empty area of space in the stack frame. These can be chained
184*38fd1498Szrj into a list; this is used to keep track of space wasted for alignment
185*38fd1498Szrj reasons. */
186*38fd1498Szrj struct GTY(()) frame_space
187*38fd1498Szrj {
188*38fd1498Szrj struct frame_space *next;
189*38fd1498Szrj
190*38fd1498Szrj poly_int64 start;
191*38fd1498Szrj poly_int64 length;
192*38fd1498Szrj };
193*38fd1498Szrj
194*38fd1498Szrj struct GTY(()) stack_usage
195*38fd1498Szrj {
196*38fd1498Szrj /* # of bytes of static stack space allocated by the function. */
197*38fd1498Szrj HOST_WIDE_INT static_stack_size;
198*38fd1498Szrj
199*38fd1498Szrj /* # of bytes of dynamic stack space allocated by the function. This is
200*38fd1498Szrj meaningful only if has_unbounded_dynamic_stack_size is zero. */
201*38fd1498Szrj HOST_WIDE_INT dynamic_stack_size;
202*38fd1498Szrj
203*38fd1498Szrj /* Upper bound on the number of bytes pushed onto the stack after the
204*38fd1498Szrj prologue. If !ACCUMULATE_OUTGOING_ARGS, it contains the outgoing
205*38fd1498Szrj arguments. */
206*38fd1498Szrj poly_int64 pushed_stack_size;
207*38fd1498Szrj
208*38fd1498Szrj /* Nonzero if the amount of stack space allocated dynamically cannot
209*38fd1498Szrj be bounded at compile-time. */
210*38fd1498Szrj unsigned int has_unbounded_dynamic_stack_size : 1;
211*38fd1498Szrj };
212*38fd1498Szrj
213*38fd1498Szrj #define current_function_static_stack_size (cfun->su->static_stack_size)
214*38fd1498Szrj #define current_function_dynamic_stack_size (cfun->su->dynamic_stack_size)
215*38fd1498Szrj #define current_function_pushed_stack_size (cfun->su->pushed_stack_size)
216*38fd1498Szrj #define current_function_has_unbounded_dynamic_stack_size \
217*38fd1498Szrj (cfun->su->has_unbounded_dynamic_stack_size)
218*38fd1498Szrj #define current_function_allocates_dynamic_stack_space \
219*38fd1498Szrj (current_function_dynamic_stack_size != 0 \
220*38fd1498Szrj || current_function_has_unbounded_dynamic_stack_size)
221*38fd1498Szrj
222*38fd1498Szrj /* This structure can save all the important global and static variables
223*38fd1498Szrj describing the status of the current function. */
224*38fd1498Szrj
225*38fd1498Szrj struct GTY(()) function {
226*38fd1498Szrj struct eh_status *eh;
227*38fd1498Szrj
228*38fd1498Szrj /* The control flow graph for this function. */
229*38fd1498Szrj struct control_flow_graph *cfg;
230*38fd1498Szrj
231*38fd1498Szrj /* GIMPLE body for this function. */
232*38fd1498Szrj gimple_seq gimple_body;
233*38fd1498Szrj
234*38fd1498Szrj /* SSA and dataflow information. */
235*38fd1498Szrj struct gimple_df *gimple_df;
236*38fd1498Szrj
237*38fd1498Szrj /* The loops in this function. */
238*38fd1498Szrj struct loops *x_current_loops;
239*38fd1498Szrj
240*38fd1498Szrj /* Filled by the GIMPLE and RTL FEs, pass to start compilation with. */
241*38fd1498Szrj char *pass_startwith;
242*38fd1498Szrj
243*38fd1498Szrj /* The stack usage of this function. */
244*38fd1498Szrj struct stack_usage *su;
245*38fd1498Szrj
246*38fd1498Szrj /* Value histograms attached to particular statements. */
247*38fd1498Szrj htab_t GTY((skip)) value_histograms;
248*38fd1498Szrj
249*38fd1498Szrj /* For function.c. */
250*38fd1498Szrj
251*38fd1498Szrj /* Points to the FUNCTION_DECL of this function. */
252*38fd1498Szrj tree decl;
253*38fd1498Szrj
254*38fd1498Szrj /* A PARM_DECL that should contain the static chain for this function.
255*38fd1498Szrj It will be initialized at the beginning of the function. */
256*38fd1498Szrj tree static_chain_decl;
257*38fd1498Szrj
258*38fd1498Szrj /* An expression that contains the non-local goto save area. The first
259*38fd1498Szrj word is the saved frame pointer and the second is the saved stack
260*38fd1498Szrj pointer. */
261*38fd1498Szrj tree nonlocal_goto_save_area;
262*38fd1498Szrj
263*38fd1498Szrj /* Vector of function local variables, functions, types and constants. */
264*38fd1498Szrj vec<tree, va_gc> *local_decls;
265*38fd1498Szrj
266*38fd1498Szrj /* For md files. */
267*38fd1498Szrj
268*38fd1498Szrj /* tm.h can use this to store whatever it likes. */
269*38fd1498Szrj struct machine_function * GTY ((maybe_undef)) machine;
270*38fd1498Szrj
271*38fd1498Szrj /* Language-specific code can use this to store whatever it likes. */
272*38fd1498Szrj struct language_function * language;
273*38fd1498Szrj
274*38fd1498Szrj /* Used types hash table. */
275*38fd1498Szrj hash_set<tree> *GTY (()) used_types_hash;
276*38fd1498Szrj
277*38fd1498Szrj /* Dwarf2 Frame Description Entry, containing the Call Frame Instructions
278*38fd1498Szrj used for unwinding. Only set when either dwarf2 unwinding or dwarf2
279*38fd1498Szrj debugging is enabled. */
280*38fd1498Szrj struct dw_fde_node *fde;
281*38fd1498Szrj
282*38fd1498Szrj /* Last statement uid. */
283*38fd1498Szrj int last_stmt_uid;
284*38fd1498Szrj
285*38fd1498Szrj /* Debug marker counter. Count begin stmt markers. We don't have
286*38fd1498Szrj to keep it exact, it's more of a rough estimate to enable us to
287*38fd1498Szrj decide whether they are too many to copy during inlining, or when
288*38fd1498Szrj expanding to RTL. */
289*38fd1498Szrj int debug_marker_count;
290*38fd1498Szrj
291*38fd1498Szrj /* Function sequence number for profiling, debugging, etc. */
292*38fd1498Szrj int funcdef_no;
293*38fd1498Szrj
294*38fd1498Szrj /* Line number of the start of the function for debugging purposes. */
295*38fd1498Szrj location_t function_start_locus;
296*38fd1498Szrj
297*38fd1498Szrj /* Line number of the end of the function. */
298*38fd1498Szrj location_t function_end_locus;
299*38fd1498Szrj
300*38fd1498Szrj /* Properties used by the pass manager. */
301*38fd1498Szrj unsigned int curr_properties;
302*38fd1498Szrj unsigned int last_verified;
303*38fd1498Szrj
304*38fd1498Szrj /* Non-null if the function does something that would prevent it from
305*38fd1498Szrj being copied; this applies to both versioning and inlining. Set to
306*38fd1498Szrj a string describing the reason for failure. */
307*38fd1498Szrj const char * GTY((skip)) cannot_be_copied_reason;
308*38fd1498Szrj
309*38fd1498Szrj /* Last assigned dependence info clique. */
310*38fd1498Szrj unsigned short last_clique;
311*38fd1498Szrj
312*38fd1498Szrj /* Collected bit flags. */
313*38fd1498Szrj
314*38fd1498Szrj /* Number of units of general registers that need saving in stdarg
315*38fd1498Szrj function. What unit is depends on the backend, either it is number
316*38fd1498Szrj of bytes, or it can be number of registers. */
317*38fd1498Szrj unsigned int va_list_gpr_size : 8;
318*38fd1498Szrj
319*38fd1498Szrj /* Number of units of floating point registers that need saving in stdarg
320*38fd1498Szrj function. */
321*38fd1498Szrj unsigned int va_list_fpr_size : 8;
322*38fd1498Szrj
323*38fd1498Szrj /* Nonzero if function being compiled can call setjmp. */
324*38fd1498Szrj unsigned int calls_setjmp : 1;
325*38fd1498Szrj
326*38fd1498Szrj /* Nonzero if function being compiled can call alloca,
327*38fd1498Szrj either as a subroutine or builtin. */
328*38fd1498Szrj unsigned int calls_alloca : 1;
329*38fd1498Szrj
330*38fd1498Szrj /* Nonzero if function being compiled receives nonlocal gotos
331*38fd1498Szrj from nested functions. */
332*38fd1498Szrj unsigned int has_nonlocal_label : 1;
333*38fd1498Szrj
334*38fd1498Szrj /* Nonzero if function being compiled has a forced label
335*38fd1498Szrj placed into static storage. */
336*38fd1498Szrj unsigned int has_forced_label_in_static : 1;
337*38fd1498Szrj
338*38fd1498Szrj /* Nonzero if we've set cannot_be_copied_reason. I.e. if
339*38fd1498Szrj (cannot_be_copied_set && !cannot_be_copied_reason), the function
340*38fd1498Szrj can in fact be copied. */
341*38fd1498Szrj unsigned int cannot_be_copied_set : 1;
342*38fd1498Szrj
343*38fd1498Szrj /* Nonzero if current function uses stdarg.h or equivalent. */
344*38fd1498Szrj unsigned int stdarg : 1;
345*38fd1498Szrj
346*38fd1498Szrj unsigned int after_inlining : 1;
347*38fd1498Szrj unsigned int always_inline_functions_inlined : 1;
348*38fd1498Szrj
349*38fd1498Szrj /* Nonzero if function being compiled can throw synchronous non-call
350*38fd1498Szrj exceptions. */
351*38fd1498Szrj unsigned int can_throw_non_call_exceptions : 1;
352*38fd1498Szrj
353*38fd1498Szrj /* Nonzero if instructions that may throw exceptions but don't otherwise
354*38fd1498Szrj contribute to the execution of the program can be deleted. */
355*38fd1498Szrj unsigned int can_delete_dead_exceptions : 1;
356*38fd1498Szrj
357*38fd1498Szrj /* Fields below this point are not set for abstract functions; see
358*38fd1498Szrj allocate_struct_function. */
359*38fd1498Szrj
360*38fd1498Szrj /* Nonzero if function being compiled needs to be given an address
361*38fd1498Szrj where the value should be stored. */
362*38fd1498Szrj unsigned int returns_struct : 1;
363*38fd1498Szrj
364*38fd1498Szrj /* Nonzero if function being compiled needs to
365*38fd1498Szrj return the address of where it has put a structure value. */
366*38fd1498Szrj unsigned int returns_pcc_struct : 1;
367*38fd1498Szrj
368*38fd1498Szrj /* Nonzero if this function has local DECL_HARD_REGISTER variables.
369*38fd1498Szrj In this case code motion has to be done more carefully. */
370*38fd1498Szrj unsigned int has_local_explicit_reg_vars : 1;
371*38fd1498Szrj
372*38fd1498Szrj /* Nonzero if the current function is a thunk, i.e., a lightweight
373*38fd1498Szrj function implemented by the output_mi_thunk hook) that just
374*38fd1498Szrj adjusts one of its arguments and forwards to another
375*38fd1498Szrj function. */
376*38fd1498Szrj unsigned int is_thunk : 1;
377*38fd1498Szrj
378*38fd1498Szrj /* Nonzero if the current function contains any loops with
379*38fd1498Szrj loop->force_vectorize set. */
380*38fd1498Szrj unsigned int has_force_vectorize_loops : 1;
381*38fd1498Szrj
382*38fd1498Szrj /* Nonzero if the current function contains any loops with
383*38fd1498Szrj nonzero value in loop->simduid. */
384*38fd1498Szrj unsigned int has_simduid_loops : 1;
385*38fd1498Szrj
386*38fd1498Szrj /* Nonzero when the tail call has been identified. */
387*38fd1498Szrj unsigned int tail_call_marked : 1;
388*38fd1498Szrj
389*38fd1498Szrj /* Nonzero if the current function contains a #pragma GCC unroll. */
390*38fd1498Szrj unsigned int has_unroll : 1;
391*38fd1498Szrj
392*38fd1498Szrj /* Set when the function was compiled with generation of debug
393*38fd1498Szrj (begin stmt, inline entry, ...) markers enabled. */
394*38fd1498Szrj unsigned int debug_nonbind_markers : 1;
395*38fd1498Szrj };
396*38fd1498Szrj
397*38fd1498Szrj /* Add the decl D to the local_decls list of FUN. */
398*38fd1498Szrj
399*38fd1498Szrj void add_local_decl (struct function *fun, tree d);
400*38fd1498Szrj
401*38fd1498Szrj #define FOR_EACH_LOCAL_DECL(FUN, I, D) \
402*38fd1498Szrj FOR_EACH_VEC_SAFE_ELT_REVERSE ((FUN)->local_decls, I, D)
403*38fd1498Szrj
404*38fd1498Szrj /* If va_list_[gf]pr_size is set to this, it means we don't know how
405*38fd1498Szrj many units need to be saved. */
406*38fd1498Szrj #define VA_LIST_MAX_GPR_SIZE 255
407*38fd1498Szrj #define VA_LIST_MAX_FPR_SIZE 255
408*38fd1498Szrj
409*38fd1498Szrj /* The function currently being compiled. */
410*38fd1498Szrj extern GTY(()) struct function *cfun;
411*38fd1498Szrj
412*38fd1498Szrj /* In order to ensure that cfun is not set directly, we redefine it so
413*38fd1498Szrj that it is not an lvalue. Rather than assign to cfun, use
414*38fd1498Szrj push_cfun or set_cfun. */
415*38fd1498Szrj #define cfun (cfun + 0)
416*38fd1498Szrj
417*38fd1498Szrj /* Nonzero if we've already converted virtual regs to hard regs. */
418*38fd1498Szrj extern int virtuals_instantiated;
419*38fd1498Szrj
420*38fd1498Szrj /* Nonzero if at least one trampoline has been created. */
421*38fd1498Szrj extern int trampolines_created;
422*38fd1498Szrj
423*38fd1498Szrj struct GTY((for_user)) types_used_by_vars_entry {
424*38fd1498Szrj tree type;
425*38fd1498Szrj tree var_decl;
426*38fd1498Szrj };
427*38fd1498Szrj
428*38fd1498Szrj struct used_type_hasher : ggc_ptr_hash<types_used_by_vars_entry>
429*38fd1498Szrj {
430*38fd1498Szrj static hashval_t hash (types_used_by_vars_entry *);
431*38fd1498Szrj static bool equal (types_used_by_vars_entry *, types_used_by_vars_entry *);
432*38fd1498Szrj };
433*38fd1498Szrj
434*38fd1498Szrj /* Hash table making the relationship between a global variable
435*38fd1498Szrj and the types it references in its initializer. The key of the
436*38fd1498Szrj entry is a referenced type, and the value is the DECL of the global
437*38fd1498Szrj variable. types_use_by_vars_do_hash and types_used_by_vars_eq below are
438*38fd1498Szrj the hash and equality functions to use for this hash table. */
439*38fd1498Szrj extern GTY(()) hash_table<used_type_hasher> *types_used_by_vars_hash;
440*38fd1498Szrj
441*38fd1498Szrj void types_used_by_var_decl_insert (tree type, tree var_decl);
442*38fd1498Szrj
443*38fd1498Szrj /* During parsing of a global variable, this vector contains the types
444*38fd1498Szrj referenced by the global variable. */
445*38fd1498Szrj extern GTY(()) vec<tree, va_gc> *types_used_by_cur_var_decl;
446*38fd1498Szrj
447*38fd1498Szrj
448*38fd1498Szrj /* Return the loop tree of FN. */
449*38fd1498Szrj
450*38fd1498Szrj inline struct loops *
loops_for_fn(struct function * fn)451*38fd1498Szrj loops_for_fn (struct function *fn)
452*38fd1498Szrj {
453*38fd1498Szrj return fn->x_current_loops;
454*38fd1498Szrj }
455*38fd1498Szrj
456*38fd1498Szrj /* Set the loop tree of FN to LOOPS. */
457*38fd1498Szrj
458*38fd1498Szrj inline void
set_loops_for_fn(struct function * fn,struct loops * loops)459*38fd1498Szrj set_loops_for_fn (struct function *fn, struct loops *loops)
460*38fd1498Szrj {
461*38fd1498Szrj gcc_checking_assert (fn->x_current_loops == NULL || loops == NULL);
462*38fd1498Szrj fn->x_current_loops = loops;
463*38fd1498Szrj }
464*38fd1498Szrj
465*38fd1498Szrj /* For backward compatibility... eventually these should all go away. */
466*38fd1498Szrj #define current_function_funcdef_no (cfun->funcdef_no)
467*38fd1498Szrj
468*38fd1498Szrj #define current_loops (cfun->x_current_loops)
469*38fd1498Szrj #define dom_computed (cfun->cfg->x_dom_computed)
470*38fd1498Szrj #define n_bbs_in_dom_tree (cfun->cfg->x_n_bbs_in_dom_tree)
471*38fd1498Szrj #define VALUE_HISTOGRAMS(fun) (fun)->value_histograms
472*38fd1498Szrj
473*38fd1498Szrj /* A pointer to a function to create target specific, per-function
474*38fd1498Szrj data structures. */
475*38fd1498Szrj extern struct machine_function * (*init_machine_status) (void);
476*38fd1498Szrj
477*38fd1498Szrj /* Structure to record the size of a sequence of arguments
478*38fd1498Szrj as the sum of a tree-expression and a constant. This structure is
479*38fd1498Szrj also used to store offsets from the stack, which might be negative,
480*38fd1498Szrj so the variable part must be ssizetype, not sizetype. */
481*38fd1498Szrj
482*38fd1498Szrj struct args_size
483*38fd1498Szrj {
484*38fd1498Szrj poly_int64_pod constant;
485*38fd1498Szrj tree var;
486*38fd1498Szrj };
487*38fd1498Szrj
488*38fd1498Szrj /* Package up various arg related fields of struct args for
489*38fd1498Szrj locate_and_pad_parm. */
490*38fd1498Szrj struct locate_and_pad_arg_data
491*38fd1498Szrj {
492*38fd1498Szrj /* Size of this argument on the stack, rounded up for any padding it
493*38fd1498Szrj gets. If REG_PARM_STACK_SPACE is defined, then register parms are
494*38fd1498Szrj counted here, otherwise they aren't. */
495*38fd1498Szrj struct args_size size;
496*38fd1498Szrj /* Offset of this argument from beginning of stack-args. */
497*38fd1498Szrj struct args_size offset;
498*38fd1498Szrj /* Offset to the start of the stack slot. Different from OFFSET
499*38fd1498Szrj if this arg pads downward. */
500*38fd1498Szrj struct args_size slot_offset;
501*38fd1498Szrj /* The amount that the stack pointer needs to be adjusted to
502*38fd1498Szrj force alignment for the next argument. */
503*38fd1498Szrj struct args_size alignment_pad;
504*38fd1498Szrj /* Which way we should pad this arg. */
505*38fd1498Szrj pad_direction where_pad;
506*38fd1498Szrj /* slot_offset is at least this aligned. */
507*38fd1498Szrj unsigned int boundary;
508*38fd1498Szrj };
509*38fd1498Szrj
510*38fd1498Szrj /* Add the value of the tree INC to the `struct args_size' TO. */
511*38fd1498Szrj
512*38fd1498Szrj #define ADD_PARM_SIZE(TO, INC) \
513*38fd1498Szrj do { \
514*38fd1498Szrj tree inc = (INC); \
515*38fd1498Szrj if (tree_fits_shwi_p (inc)) \
516*38fd1498Szrj (TO).constant += tree_to_shwi (inc); \
517*38fd1498Szrj else if ((TO).var == 0) \
518*38fd1498Szrj (TO).var = fold_convert (ssizetype, inc); \
519*38fd1498Szrj else \
520*38fd1498Szrj (TO).var = size_binop (PLUS_EXPR, (TO).var, \
521*38fd1498Szrj fold_convert (ssizetype, inc)); \
522*38fd1498Szrj } while (0)
523*38fd1498Szrj
524*38fd1498Szrj #define SUB_PARM_SIZE(TO, DEC) \
525*38fd1498Szrj do { \
526*38fd1498Szrj tree dec = (DEC); \
527*38fd1498Szrj if (tree_fits_shwi_p (dec)) \
528*38fd1498Szrj (TO).constant -= tree_to_shwi (dec); \
529*38fd1498Szrj else if ((TO).var == 0) \
530*38fd1498Szrj (TO).var = size_binop (MINUS_EXPR, ssize_int (0), \
531*38fd1498Szrj fold_convert (ssizetype, dec)); \
532*38fd1498Szrj else \
533*38fd1498Szrj (TO).var = size_binop (MINUS_EXPR, (TO).var, \
534*38fd1498Szrj fold_convert (ssizetype, dec)); \
535*38fd1498Szrj } while (0)
536*38fd1498Szrj
537*38fd1498Szrj /* Convert the implicit sum in a `struct args_size' into a tree
538*38fd1498Szrj of type ssizetype. */
539*38fd1498Szrj #define ARGS_SIZE_TREE(SIZE) \
540*38fd1498Szrj ((SIZE).var == 0 ? ssize_int ((SIZE).constant) \
541*38fd1498Szrj : size_binop (PLUS_EXPR, fold_convert (ssizetype, (SIZE).var), \
542*38fd1498Szrj ssize_int ((SIZE).constant)))
543*38fd1498Szrj
544*38fd1498Szrj /* Convert the implicit sum in a `struct args_size' into an rtx. */
545*38fd1498Szrj #define ARGS_SIZE_RTX(SIZE) \
546*38fd1498Szrj ((SIZE).var == 0 ? gen_int_mode ((SIZE).constant, Pmode) \
547*38fd1498Szrj : expand_normal (ARGS_SIZE_TREE (SIZE)))
548*38fd1498Szrj
549*38fd1498Szrj #define ASLK_REDUCE_ALIGN 1
550*38fd1498Szrj #define ASLK_RECORD_PAD 2
551*38fd1498Szrj
552*38fd1498Szrj /* If pointers to member functions use the least significant bit to
553*38fd1498Szrj indicate whether a function is virtual, ensure a pointer
554*38fd1498Szrj to this function will have that bit clear. */
555*38fd1498Szrj #define MINIMUM_METHOD_BOUNDARY \
556*38fd1498Szrj ((TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn) \
557*38fd1498Szrj ? MAX (FUNCTION_BOUNDARY, 2 * BITS_PER_UNIT) : FUNCTION_BOUNDARY)
558*38fd1498Szrj
559*38fd1498Szrj enum stack_clash_probes {
560*38fd1498Szrj NO_PROBE_NO_FRAME,
561*38fd1498Szrj NO_PROBE_SMALL_FRAME,
562*38fd1498Szrj PROBE_INLINE,
563*38fd1498Szrj PROBE_LOOP
564*38fd1498Szrj };
565*38fd1498Szrj
566*38fd1498Szrj extern void dump_stack_clash_frame_info (enum stack_clash_probes, bool);
567*38fd1498Szrj
568*38fd1498Szrj
569*38fd1498Szrj extern void push_function_context (void);
570*38fd1498Szrj extern void pop_function_context (void);
571*38fd1498Szrj
572*38fd1498Szrj /* Save and restore status information for a nested function. */
573*38fd1498Szrj extern void free_after_parsing (struct function *);
574*38fd1498Szrj extern void free_after_compilation (struct function *);
575*38fd1498Szrj
576*38fd1498Szrj /* Return size needed for stack frame based on slots so far allocated.
577*38fd1498Szrj This size counts from zero. It is not rounded to STACK_BOUNDARY;
578*38fd1498Szrj the caller may have to do that. */
579*38fd1498Szrj extern poly_int64 get_frame_size (void);
580*38fd1498Szrj
581*38fd1498Szrj /* Issue an error message and return TRUE if frame OFFSET overflows in
582*38fd1498Szrj the signed target pointer arithmetics for function FUNC. Otherwise
583*38fd1498Szrj return FALSE. */
584*38fd1498Szrj extern bool frame_offset_overflow (poly_int64, tree);
585*38fd1498Szrj
586*38fd1498Szrj extern unsigned int spill_slot_alignment (machine_mode);
587*38fd1498Szrj
588*38fd1498Szrj extern rtx assign_stack_local_1 (machine_mode, poly_int64, int, int);
589*38fd1498Szrj extern rtx assign_stack_local (machine_mode, poly_int64, int);
590*38fd1498Szrj extern rtx assign_stack_temp_for_type (machine_mode, poly_int64, tree);
591*38fd1498Szrj extern rtx assign_stack_temp (machine_mode, poly_int64);
592*38fd1498Szrj extern rtx assign_temp (tree, int, int);
593*38fd1498Szrj extern void update_temp_slot_address (rtx, rtx);
594*38fd1498Szrj extern void preserve_temp_slots (rtx);
595*38fd1498Szrj extern void free_temp_slots (void);
596*38fd1498Szrj extern void push_temp_slots (void);
597*38fd1498Szrj extern void pop_temp_slots (void);
598*38fd1498Szrj extern void init_temp_slots (void);
599*38fd1498Szrj extern rtx get_hard_reg_initial_reg (rtx);
600*38fd1498Szrj extern rtx get_hard_reg_initial_val (machine_mode, unsigned int);
601*38fd1498Szrj extern rtx has_hard_reg_initial_val (machine_mode, unsigned int);
602*38fd1498Szrj
603*38fd1498Szrj /* Called from gimple_expand_cfg. */
604*38fd1498Szrj extern unsigned int emit_initial_value_sets (void);
605*38fd1498Szrj
606*38fd1498Szrj extern bool initial_value_entry (int i, rtx *, rtx *);
607*38fd1498Szrj extern void instantiate_decl_rtl (rtx x);
608*38fd1498Szrj extern int aggregate_value_p (const_tree, const_tree);
609*38fd1498Szrj extern bool use_register_for_decl (const_tree);
610*38fd1498Szrj extern gimple_seq gimplify_parameters (gimple_seq *);
611*38fd1498Szrj extern void locate_and_pad_parm (machine_mode, tree, int, int, int,
612*38fd1498Szrj tree, struct args_size *,
613*38fd1498Szrj struct locate_and_pad_arg_data *);
614*38fd1498Szrj extern void generate_setjmp_warnings (void);
615*38fd1498Szrj
616*38fd1498Szrj /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END},
617*38fd1498Szrj and create duplicate blocks. */
618*38fd1498Szrj extern void reorder_blocks (void);
619*38fd1498Szrj extern void clear_block_marks (tree);
620*38fd1498Szrj extern tree blocks_nreverse (tree);
621*38fd1498Szrj extern tree block_chainon (tree, tree);
622*38fd1498Szrj
623*38fd1498Szrj /* Set BLOCK_NUMBER for all the blocks in FN. */
624*38fd1498Szrj extern void number_blocks (tree);
625*38fd1498Szrj
626*38fd1498Szrj /* cfun shouldn't be set directly; use one of these functions instead. */
627*38fd1498Szrj extern void set_cfun (struct function *new_cfun, bool force = false);
628*38fd1498Szrj extern void push_cfun (struct function *new_cfun);
629*38fd1498Szrj extern void pop_cfun (void);
630*38fd1498Szrj
631*38fd1498Szrj extern int get_next_funcdef_no (void);
632*38fd1498Szrj extern int get_last_funcdef_no (void);
633*38fd1498Szrj extern void allocate_struct_function (tree, bool);
634*38fd1498Szrj extern void push_struct_function (tree fndecl);
635*38fd1498Szrj extern void push_dummy_function (bool);
636*38fd1498Szrj extern void pop_dummy_function (void);
637*38fd1498Szrj extern void init_dummy_function_start (void);
638*38fd1498Szrj extern void init_function_start (tree);
639*38fd1498Szrj extern void stack_protect_epilogue (void);
640*38fd1498Szrj extern void expand_function_start (tree);
641*38fd1498Szrj extern void expand_dummy_function_end (void);
642*38fd1498Szrj
643*38fd1498Szrj extern void thread_prologue_and_epilogue_insns (void);
644*38fd1498Szrj extern void diddle_return_value (void (*)(rtx, void*), void*);
645*38fd1498Szrj extern void clobber_return_register (void);
646*38fd1498Szrj extern void expand_function_end (void);
647*38fd1498Szrj extern rtx get_arg_pointer_save_area (void);
648*38fd1498Szrj extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
649*38fd1498Szrj extern int prologue_contains (const rtx_insn *);
650*38fd1498Szrj extern int epilogue_contains (const rtx_insn *);
651*38fd1498Szrj extern int prologue_epilogue_contains (const rtx_insn *);
652*38fd1498Szrj extern void record_prologue_seq (rtx_insn *);
653*38fd1498Szrj extern void record_epilogue_seq (rtx_insn *);
654*38fd1498Szrj extern void emit_return_into_block (bool simple_p, basic_block bb);
655*38fd1498Szrj extern void set_return_jump_label (rtx_insn *);
656*38fd1498Szrj extern bool active_insn_between (rtx_insn *head, rtx_insn *tail);
657*38fd1498Szrj extern vec<edge> convert_jumps_to_returns (basic_block last_bb, bool simple_p,
658*38fd1498Szrj vec<edge> unconverted);
659*38fd1498Szrj extern basic_block emit_return_for_exit (edge exit_fallthru_edge,
660*38fd1498Szrj bool simple_p);
661*38fd1498Szrj extern void reposition_prologue_and_epilogue_notes (void);
662*38fd1498Szrj
663*38fd1498Szrj /* Returns the name of the current function. */
664*38fd1498Szrj extern const char *fndecl_name (tree);
665*38fd1498Szrj extern const char *function_name (struct function *);
666*38fd1498Szrj extern const char *current_function_name (void);
667*38fd1498Szrj
668*38fd1498Szrj extern void used_types_insert (tree);
669*38fd1498Szrj
670*38fd1498Szrj #endif /* GCC_FUNCTION_H */
671