]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/emit-rtl.h
make forced labels a vec
[thirdparty/gcc.git] / gcc / emit-rtl.h
CommitLineData
78528714 1/* Exported functions from emit-rtl.c
818ab71a 2 Copyright (C) 2004-2016 Free Software Foundation, Inc.
78528714
JQ
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
78528714
JQ
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
78528714
JQ
19
20#ifndef GCC_EMIT_RTL_H
21#define GCC_EMIT_RTL_H
22
2bb8cb58
AM
23struct temp_slot;
24typedef struct temp_slot *temp_slot_p;
25
16a16ec7
AM
26/* Information mainlined about RTL representation of incoming arguments. */
27struct GTY(()) incoming_args {
28 /* Number of bytes of args popped by function being compiled on its return.
29 Zero if no bytes are to be popped.
30 May affect compilation of return insn or of function epilogue. */
31 int pops_args;
32
33 /* If function's args have a fixed size, this is that size, in bytes.
34 Otherwise, it is -1.
35 May affect compilation of return insn or of function epilogue. */
36 int size;
37
38 /* # bytes the prologue should push and pretend that the caller pushed them.
39 The prologue must do this, but only if parms can be passed in
40 registers. */
41 int pretend_args_size;
42
43 /* This is the offset from the arg pointer to the place where the first
44 anonymous arg can be found, if there is one. */
45 rtx arg_offset_rtx;
46
47 /* Quantities of various kinds of registers
48 used for the current function's args. */
49 CUMULATIVE_ARGS info;
50
51 /* The arg pointer hard register, or the pseudo into which it was copied. */
52 rtx internal_arg_pointer;
53};
54
55
2bb8cb58
AM
56/* Datastructures maintained for currently processed function in RTL form. */
57struct GTY(()) rtl_data {
58 struct expr_status expr;
59 struct emit_status emit;
60 struct varasm_status varasm;
61 struct incoming_args args;
62 struct function_subsections subsections;
63 struct rtl_eh eh;
64
65 /* For function.c */
66
67 /* # of bytes of outgoing arguments. If ACCUMULATE_OUTGOING_ARGS is
68 defined, the needed space is pushed by the prologue. */
69 int outgoing_args_size;
70
71 /* If nonzero, an RTL expression for the location at which the current
72 function returns its result. If the current function returns its
73 result in a register, current_function_return_rtx will always be
74 the hard register containing the result. */
75 rtx return_rtx;
76 /* If nonxero, an RTL expression for the lcoation at which the current
77 function returns bounds for its result. */
78 rtx return_bnd;
79
80 /* Vector of initial-value pairs. Each pair consists of a pseudo
81 register of approprite mode that stores the initial value a hard
82 register REGNO, and that hard register itself. */
83 /* ??? This could be a VEC but there is currently no way to define an
84 opaque VEC type. */
85 struct initial_value_struct *hard_reg_initial_vals;
86
87 /* A variable living at the top of the frame that holds a known value.
88 Used for detecting stack clobbers. */
89 tree stack_protect_guard;
90
91 /* List (chain of INSN_LIST) of labels heading the current handlers for
92 nonlocal gotos. */
93 rtx_insn_list *x_nonlocal_goto_handler_labels;
94
95 /* Label that will go on function epilogue.
96 Jumping to this label serves as a "return" instruction
97 on machines which require execution of the epilogue on all returns. */
98 rtx_code_label *x_return_label;
99
100 /* Label that will go on the end of function epilogue.
101 Jumping to this label serves as a "naked return" instruction
102 on machines which require execution of the epilogue on all returns. */
103 rtx_code_label *x_naked_return_label;
104
105 /* List (chain of EXPR_LISTs) of all stack slots in this function.
106 Made for the sake of unshare_all_rtl. */
107 rtx_expr_list *x_stack_slot_list;
108
109 /* List of empty areas in the stack frame. */
110 struct frame_space *frame_space_list;
111
112 /* Place after which to insert the tail_recursion_label if we need one. */
113 rtx_note *x_stack_check_probe_note;
114
115 /* Location at which to save the argument pointer if it will need to be
116 referenced. There are two cases where this is done: if nonlocal gotos
117 exist, or if vars stored at an offset from the argument pointer will be
118 needed by inner routines. */
119 rtx x_arg_pointer_save_area;
120
121 /* Dynamic Realign Argument Pointer used for realigning stack. */
122 rtx drap_reg;
123
124 /* Offset to end of allocated area of stack frame.
125 If stack grows down, this is the address of the last stack slot allocated.
126 If stack grows up, this is the address for the next slot. */
127 HOST_WIDE_INT x_frame_offset;
128
129 /* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
130 rtx_insn *x_parm_birth_insn;
131
132 /* List of all used temporaries allocated, by level. */
133 vec<temp_slot_p, va_gc> *x_used_temp_slots;
134
135 /* List of available temp slots. */
136 struct temp_slot *x_avail_temp_slots;
137
138 /* Current nesting level for temporaries. */
139 int x_temp_slot_level;
140
141 /* The largest alignment needed on the stack, including requirement
142 for outgoing stack alignment. */
143 unsigned int stack_alignment_needed;
144
145 /* Preferred alignment of the end of stack frame, which is preferred
146 to call other functions. */
147 unsigned int preferred_stack_boundary;
148
149 /* The minimum alignment of parameter stack. */
150 unsigned int parm_stack_boundary;
151
152 /* The largest alignment of slot allocated on the stack. */
153 unsigned int max_used_stack_slot_alignment;
154
155 /* The stack alignment estimated before reload, with consideration of
156 following factors:
157 1. Alignment of local stack variables (max_used_stack_slot_alignment)
158 2. Alignment requirement to call other functions
159 (preferred_stack_boundary)
160 3. Alignment of non-local stack variables but might be spilled in
161 local stack. */
162 unsigned int stack_alignment_estimated;
163
164 /* For reorg. */
165
166 /* Nonzero if function being compiled called builtin_return_addr or
167 builtin_frame_address with nonzero count. */
168 bool accesses_prior_frames;
169
170 /* Nonzero if the function calls __builtin_eh_return. */
171 bool calls_eh_return;
172
173 /* Nonzero if function saves all registers, e.g. if it has a nonlocal
174 label that can reach the exit block via non-exceptional paths. */
175 bool saves_all_registers;
176
177 /* Nonzero if function being compiled has nonlocal gotos to parent
178 function. */
179 bool has_nonlocal_goto;
180
181 /* Nonzero if function being compiled has an asm statement. */
182 bool has_asm_statement;
183
184 /* This bit is used by the exception handling logic. It is set if all
185 calls (if any) are sibling calls. Such functions do not have to
186 have EH tables generated, as they cannot throw. A call to such a
187 function, however, should be treated as throwing if any of its callees
188 can throw. */
189 bool all_throwers_are_sibcalls;
190
191 /* Nonzero if stack limit checking should be enabled in the current
192 function. */
193 bool limit_stack;
194
195 /* Nonzero if profiling code should be generated. */
196 bool profile;
197
198 /* Nonzero if the current function uses the constant pool. */
199 bool uses_const_pool;
200
201 /* Nonzero if the current function uses pic_offset_table_rtx. */
202 bool uses_pic_offset_table;
203
204 /* Nonzero if the current function needs an lsda for exception handling. */
205 bool uses_eh_lsda;
206
207 /* Set when the tail call has been produced. */
208 bool tail_call_emit;
209
210 /* Nonzero if code to initialize arg_pointer_save_area has been emitted. */
211 bool arg_pointer_save_area_init;
212
213 /* Nonzero if current function must be given a frame pointer.
214 Set in reload1.c or lra-eliminations.c if anything is allocated
215 on the stack there. */
216 bool frame_pointer_needed;
217
218 /* When set, expand should optimize for speed. */
219 bool maybe_hot_insn_p;
220
221 /* Nonzero if function stack realignment is needed. This flag may be
222 set twice: before and after reload. It is set before reload wrt
223 stack alignment estimation before reload. It will be changed after
224 reload if by then criteria of stack realignment is different.
225 The value set after reload is the accurate one and is finalized. */
226 bool stack_realign_needed;
227
228 /* Nonzero if function stack realignment is tried. This flag is set
229 only once before reload. It affects register elimination. This
230 is used to generate DWARF debug info for stack variables. */
231 bool stack_realign_tried;
232
233 /* Nonzero if function being compiled needs dynamic realigned
234 argument pointer (drap) if stack needs realigning. */
235 bool need_drap;
236
237 /* Nonzero if function stack realignment estimation is done, namely
238 stack_realign_needed flag has been set before reload wrt estimated
239 stack alignment info. */
240 bool stack_realign_processed;
241
242 /* Nonzero if function stack realignment has been finalized, namely
243 stack_realign_needed flag has been set and finalized after reload. */
244 bool stack_realign_finalized;
245
246 /* True if dbr_schedule has already been called for this function. */
247 bool dbr_scheduled_p;
248
249 /* True if current function can not throw. Unlike
250 TREE_NOTHROW (current_function_decl) it is set even for overwritable
251 function where currently compiled version of it is nothrow. */
252 bool nothrow;
253
254 /* True if we performed shrink-wrapping for the current function. */
255 bool shrink_wrapped;
256
257 /* Nonzero if function being compiled doesn't modify the stack pointer
258 (ignoring the prologue and epilogue). This is only valid after
259 pass_stack_ptr_mod has run. */
260 bool sp_is_unchanging;
261
262 /* Nonzero if function being compiled doesn't contain any calls
263 (ignoring the prologue and epilogue). This is set prior to
264 local register allocation and is valid for the remaining
265 compiler passes. */
266 bool is_leaf;
267
268 /* Nonzero if the function being compiled is a leaf function which only
269 uses leaf registers. This is valid after reload (specifically after
270 sched2) and is useful only if the port defines LEAF_REGISTERS. */
271 bool uses_only_leaf_regs;
272
273 /* Nonzero if the function being compiled has undergone hot/cold partitioning
274 (under flag_reorder_blocks_and_partition) and has at least one cold
275 block. */
276 bool has_bb_partition;
277
278 /* Nonzero if the function being compiled has completed the bb reordering
279 pass. */
280 bool bb_reorder_complete;
281
282 /* Like regs_ever_live, but 1 if a reg is set or clobbered from an
283 asm. Unlike regs_ever_live, elements of this array corresponding
284 to eliminable regs (like the frame pointer) are set if an asm
285 sets them. */
286 HARD_REG_SET asm_clobbers;
287};
288
289#define return_label (crtl->x_return_label)
290#define naked_return_label (crtl->x_naked_return_label)
291#define stack_slot_list (crtl->x_stack_slot_list)
292#define parm_birth_insn (crtl->x_parm_birth_insn)
293#define frame_offset (crtl->x_frame_offset)
294#define stack_check_probe_note (crtl->x_stack_check_probe_note)
295#define arg_pointer_save_area (crtl->x_arg_pointer_save_area)
296#define used_temp_slots (crtl->x_used_temp_slots)
297#define avail_temp_slots (crtl->x_avail_temp_slots)
298#define temp_slot_level (crtl->x_temp_slot_level)
299#define nonlocal_goto_handler_labels (crtl->x_nonlocal_goto_handler_labels)
300#define frame_pointer_needed (crtl->frame_pointer_needed)
301#define stack_realign_fp (crtl->stack_realign_needed && !crtl->need_drap)
302#define stack_realign_drap (crtl->stack_realign_needed && crtl->need_drap)
303
304extern GTY(()) struct rtl_data x_rtl;
305
306/* Accessor to RTL datastructures. We keep them statically allocated now since
307 we never keep multiple functions. For threaded compiler we might however
308 want to do differently. */
309#define crtl (&x_rtl)
310
96b3c03f
RB
311/* Return whether two MEM_ATTRs are equal. */
312bool mem_attrs_eq_p (const struct mem_attrs *, const struct mem_attrs *);
313
78528714 314/* Set the alias set of MEM to SET. */
4862826d 315extern void set_mem_alias_set (rtx, alias_set_type);
78528714
JQ
316
317/* Set the alignment of MEM to ALIGN bits. */
318extern void set_mem_align (rtx, unsigned int);
319
09e881c9
BE
320/* Set the address space of MEM to ADDRSPACE. */
321extern void set_mem_addr_space (rtx, addr_space_t);
322
78528714
JQ
323/* Set the expr for MEM to EXPR. */
324extern void set_mem_expr (rtx, tree);
325
326/* Set the offset for MEM to OFFSET. */
527210c4
RS
327extern void set_mem_offset (rtx, HOST_WIDE_INT);
328
329/* Clear the offset recorded for MEM. */
330extern void clear_mem_offset (rtx);
78528714
JQ
331
332/* Set the size for MEM to SIZE. */
f5541398
RS
333extern void set_mem_size (rtx, HOST_WIDE_INT);
334
335/* Clear the size recorded for MEM. */
336extern void clear_mem_size (rtx);
78528714 337
f6129d66
RH
338/* Set the attributes for MEM appropriate for a spill slot. */
339extern void set_mem_attrs_for_spill (rtx);
3d7e23f6 340extern tree get_spill_slot_decl (bool);
f6129d66 341
78528714
JQ
342/* Return a memory reference like MEMREF, but with its address changed to
343 ADDR. The caller is asserting that the actual piece of memory pointed
344 to is the same, just the form of the address is being changed, such as
345 by putting something into a register. */
23b33725 346extern rtx replace_equiv_address (rtx, rtx, bool = false);
78528714
JQ
347
348/* Likewise, but the reference is not required to be valid. */
23b33725 349extern rtx replace_equiv_address_nv (rtx, rtx, bool = false);
78528714 350
5936d944
JH
351extern rtx gen_blockage (void);
352extern rtvec gen_rtvec (int, ...);
353extern rtx copy_insn_1 (rtx);
354extern rtx copy_insn (rtx);
f8f0516e 355extern rtx_insn *copy_delay_slot_insn (rtx_insn *);
ef4bddc2 356extern rtx gen_int_mode (HOST_WIDE_INT, machine_mode);
a1950df3 357extern rtx_insn *emit_copy_of_insn_after (rtx_insn *, rtx_insn *);
5936d944
JH
358extern void set_reg_attrs_from_value (rtx, rtx);
359extern void set_reg_attrs_for_parm (rtx, rtx);
360extern void set_reg_attrs_for_decl_rtl (tree t, rtx x);
ef4bddc2 361extern void adjust_reg_mode (rtx, machine_mode);
5936d944
JH
362extern int mem_expr_equal_p (const_tree, const_tree);
363
8930883e
MK
364extern bool need_atomic_barrier_p (enum memmodel, bool);
365
614d5bd8
AM
366/* Return the current sequence. */
367
368static inline struct sequence_stack *
369get_current_sequence (void)
370{
371 return &crtl->emit.seq;
372}
373
374/* Return the outermost sequence. */
375
376static inline struct sequence_stack *
377get_topmost_sequence (void)
378{
379 struct sequence_stack *seq, *top;
380
381 seq = get_current_sequence ();
382 do
383 {
384 top = seq;
385 seq = seq->next;
386 } while (seq);
387 return top;
388}
389
5936d944
JH
390/* Return the first insn of the current sequence or current function. */
391
981ac3c7 392static inline rtx_insn *
5936d944
JH
393get_insns (void)
394{
614d5bd8 395 return get_current_sequence ()->first;
5936d944
JH
396}
397
398/* Specify a new insn as the first in the chain. */
399
400static inline void
fee3e72c 401set_first_insn (rtx_insn *insn)
5936d944 402{
06795261 403 gcc_checking_assert (!insn || !PREV_INSN (insn));
614d5bd8 404 get_current_sequence ()->first = insn;
5936d944
JH
405}
406
407/* Return the last insn emitted in current sequence or current function. */
408
981ac3c7 409static inline rtx_insn *
5936d944
JH
410get_last_insn (void)
411{
614d5bd8 412 return get_current_sequence ()->last;
5936d944
JH
413}
414
415/* Specify a new insn as the last in the chain. */
416
417static inline void
fee3e72c 418set_last_insn (rtx_insn *insn)
5936d944 419{
06795261 420 gcc_checking_assert (!insn || !NEXT_INSN (insn));
614d5bd8 421 get_current_sequence ()->last = insn;
5936d944
JH
422}
423
424/* Return a number larger than any instruction's uid in this function. */
425
426static inline int
427get_max_uid (void)
428{
429 return crtl->emit.x_cur_insn_uid;
430}
d8a2d370
DN
431
432extern void set_decl_incoming_rtl (tree, rtx, bool);
433
36566b39
PK
434/* Return a memory reference like MEMREF, but with its mode changed
435 to MODE and its address changed to ADDR.
436 (VOIDmode means don't change the mode.
437 NULL for ADDR means don't change the address.) */
438extern rtx change_address (rtx, machine_mode, rtx);
439
440/* Return a memory reference like MEMREF, but with its mode changed
441 to MODE and its address offset by OFFSET bytes. */
442#define adjust_address(MEMREF, MODE, OFFSET) \
443 adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 0, 0)
444
445/* Likewise, but the reference is not required to be valid. */
446#define adjust_address_nv(MEMREF, MODE, OFFSET) \
447 adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 0, 0)
448
449/* Return a memory reference like MEMREF, but with its mode changed
450 to MODE and its address offset by OFFSET bytes. Assume that it's
451 for a bitfield and conservatively drop the underlying object if we
452 cannot be sure to stay within its bounds. */
453#define adjust_bitfield_address(MEMREF, MODE, OFFSET) \
454 adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, 0)
455
456/* As for adjust_bitfield_address, but specify that the width of
457 BLKmode accesses is SIZE bytes. */
458#define adjust_bitfield_address_size(MEMREF, MODE, OFFSET, SIZE) \
459 adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, SIZE)
460
461/* Likewise, but the reference is not required to be valid. */
462#define adjust_bitfield_address_nv(MEMREF, MODE, OFFSET) \
463 adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 1, 0)
464
465/* Return a memory reference like MEMREF, but with its mode changed
466 to MODE and its address changed to ADDR, which is assumed to be
467 increased by OFFSET bytes from MEMREF. */
468#define adjust_automodify_address(MEMREF, MODE, ADDR, OFFSET) \
469 adjust_automodify_address_1 (MEMREF, MODE, ADDR, OFFSET, 1)
470
471/* Likewise, but the reference is not required to be valid. */
472#define adjust_automodify_address_nv(MEMREF, MODE, ADDR, OFFSET) \
473 adjust_automodify_address_1 (MEMREF, MODE, ADDR, OFFSET, 0)
474
475extern rtx adjust_address_1 (rtx, machine_mode, HOST_WIDE_INT, int, int,
476 int, HOST_WIDE_INT);
477extern rtx adjust_automodify_address_1 (rtx, machine_mode, rtx,
478 HOST_WIDE_INT, int);
479
480/* Return a memory reference like MEMREF, but whose address is changed by
481 adding OFFSET, an RTX, to it. POW2 is the highest power of two factor
482 known to be in OFFSET (possibly 1). */
483extern rtx offset_address (rtx, rtx, unsigned HOST_WIDE_INT);
484
485/* Given REF, a MEM, and T, either the type of X or the expression
486 corresponding to REF, set the memory attributes. OBJECTP is nonzero
487 if we are making a new object of this type. */
488extern void set_mem_attributes (rtx, tree, int);
489
490/* Similar, except that BITPOS has not yet been applied to REF, so if
491 we alter MEM_OFFSET according to T then we should subtract BITPOS
492 expecting that it'll be added back in later. */
493extern void set_mem_attributes_minus_bitpos (rtx, tree, int, HOST_WIDE_INT);
494
495/* Return OFFSET if XEXP (MEM, 0) - OFFSET is known to be ALIGN
496 bits aligned for 0 <= OFFSET < ALIGN / BITS_PER_UNIT, or
497 -1 if not known. */
498extern int get_mem_align_offset (rtx, unsigned int);
499
500/* Return a memory reference like MEMREF, but with its mode widened to
501 MODE and adjusted by OFFSET. */
502extern rtx widen_memory_access (rtx, machine_mode, HOST_WIDE_INT);
503
78528714 504#endif /* GCC_EMIT_RTL_H */