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