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