2015-05-22 Ed Schonberg <schonberg@adacore.com>
[official-gcc.git] / gcc / emit-rtl.h
blob7dce7ebef11809ddd7e310d4abd3ecce2e6db78b
1 /* Exported functions from emit-rtl.c
2 Copyright (C) 2004-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
20 #ifndef GCC_EMIT_RTL_H
21 #define GCC_EMIT_RTL_H
23 /* Return whether two MEM_ATTRs are equal. */
24 bool mem_attrs_eq_p (const struct mem_attrs *, const struct mem_attrs *);
26 /* Set the alias set of MEM to SET. */
27 extern void set_mem_alias_set (rtx, alias_set_type);
29 /* Set the alignment of MEM to ALIGN bits. */
30 extern void set_mem_align (rtx, unsigned int);
32 /* Set the address space of MEM to ADDRSPACE. */
33 extern void set_mem_addr_space (rtx, addr_space_t);
35 /* Set the expr for MEM to EXPR. */
36 extern void set_mem_expr (rtx, tree);
38 /* Set the offset for MEM to OFFSET. */
39 extern void set_mem_offset (rtx, HOST_WIDE_INT);
41 /* Clear the offset recorded for MEM. */
42 extern void clear_mem_offset (rtx);
44 /* Set the size for MEM to SIZE. */
45 extern void set_mem_size (rtx, HOST_WIDE_INT);
47 /* Clear the size recorded for MEM. */
48 extern void clear_mem_size (rtx);
50 /* Set the attributes for MEM appropriate for a spill slot. */
51 extern void set_mem_attrs_for_spill (rtx);
52 extern tree get_spill_slot_decl (bool);
54 /* Return a memory reference like MEMREF, but with its address changed to
55 ADDR. The caller is asserting that the actual piece of memory pointed
56 to is the same, just the form of the address is being changed, such as
57 by putting something into a register. */
58 extern rtx replace_equiv_address (rtx, rtx, bool = false);
60 /* Likewise, but the reference is not required to be valid. */
61 extern rtx replace_equiv_address_nv (rtx, rtx, bool = false);
63 extern rtx gen_blockage (void);
64 extern rtvec gen_rtvec (int, ...);
65 extern rtx copy_insn_1 (rtx);
66 extern rtx copy_insn (rtx);
67 extern rtx_insn *copy_delay_slot_insn (rtx_insn *);
68 extern rtx gen_int_mode (HOST_WIDE_INT, machine_mode);
69 extern rtx_insn *emit_copy_of_insn_after (rtx_insn *, rtx_insn *);
70 extern void set_reg_attrs_from_value (rtx, rtx);
71 extern void set_reg_attrs_for_parm (rtx, rtx);
72 extern void set_reg_attrs_for_decl_rtl (tree t, rtx x);
73 extern void adjust_reg_mode (rtx, machine_mode);
74 extern int mem_expr_equal_p (const_tree, const_tree);
76 extern bool need_atomic_barrier_p (enum memmodel, bool);
78 /* Return the current sequence. */
80 static inline struct sequence_stack *
81 get_current_sequence (void)
83 return &crtl->emit.seq;
86 /* Return the outermost sequence. */
88 static inline struct sequence_stack *
89 get_topmost_sequence (void)
91 struct sequence_stack *seq, *top;
93 seq = get_current_sequence ();
96 top = seq;
97 seq = seq->next;
98 } while (seq);
99 return top;
102 /* Return the first insn of the current sequence or current function. */
104 static inline rtx_insn *
105 get_insns (void)
107 return get_current_sequence ()->first;
110 /* Specify a new insn as the first in the chain. */
112 static inline void
113 set_first_insn (rtx_insn *insn)
115 gcc_checking_assert (!insn || !PREV_INSN (insn));
116 get_current_sequence ()->first = insn;
119 /* Return the last insn emitted in current sequence or current function. */
121 static inline rtx_insn *
122 get_last_insn (void)
124 return get_current_sequence ()->last;
127 /* Specify a new insn as the last in the chain. */
129 static inline void
130 set_last_insn (rtx_insn *insn)
132 gcc_checking_assert (!insn || !NEXT_INSN (insn));
133 get_current_sequence ()->last = insn;
136 /* Return a number larger than any instruction's uid in this function. */
138 static inline int
139 get_max_uid (void)
141 return crtl->emit.x_cur_insn_uid;
144 extern void set_decl_incoming_rtl (tree, rtx, bool);
146 /* Return a memory reference like MEMREF, but with its mode changed
147 to MODE and its address changed to ADDR.
148 (VOIDmode means don't change the mode.
149 NULL for ADDR means don't change the address.) */
150 extern rtx change_address (rtx, machine_mode, rtx);
152 /* Return a memory reference like MEMREF, but with its mode changed
153 to MODE and its address offset by OFFSET bytes. */
154 #define adjust_address(MEMREF, MODE, OFFSET) \
155 adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 0, 0)
157 /* Likewise, but the reference is not required to be valid. */
158 #define adjust_address_nv(MEMREF, MODE, OFFSET) \
159 adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 0, 0)
161 /* Return a memory reference like MEMREF, but with its mode changed
162 to MODE and its address offset by OFFSET bytes. Assume that it's
163 for a bitfield and conservatively drop the underlying object if we
164 cannot be sure to stay within its bounds. */
165 #define adjust_bitfield_address(MEMREF, MODE, OFFSET) \
166 adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, 0)
168 /* As for adjust_bitfield_address, but specify that the width of
169 BLKmode accesses is SIZE bytes. */
170 #define adjust_bitfield_address_size(MEMREF, MODE, OFFSET, SIZE) \
171 adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, SIZE)
173 /* Likewise, but the reference is not required to be valid. */
174 #define adjust_bitfield_address_nv(MEMREF, MODE, OFFSET) \
175 adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 1, 0)
177 /* Return a memory reference like MEMREF, but with its mode changed
178 to MODE and its address changed to ADDR, which is assumed to be
179 increased by OFFSET bytes from MEMREF. */
180 #define adjust_automodify_address(MEMREF, MODE, ADDR, OFFSET) \
181 adjust_automodify_address_1 (MEMREF, MODE, ADDR, OFFSET, 1)
183 /* Likewise, but the reference is not required to be valid. */
184 #define adjust_automodify_address_nv(MEMREF, MODE, ADDR, OFFSET) \
185 adjust_automodify_address_1 (MEMREF, MODE, ADDR, OFFSET, 0)
187 extern rtx adjust_address_1 (rtx, machine_mode, HOST_WIDE_INT, int, int,
188 int, HOST_WIDE_INT);
189 extern rtx adjust_automodify_address_1 (rtx, machine_mode, rtx,
190 HOST_WIDE_INT, int);
192 /* Return a memory reference like MEMREF, but whose address is changed by
193 adding OFFSET, an RTX, to it. POW2 is the highest power of two factor
194 known to be in OFFSET (possibly 1). */
195 extern rtx offset_address (rtx, rtx, unsigned HOST_WIDE_INT);
197 /* Given REF, a MEM, and T, either the type of X or the expression
198 corresponding to REF, set the memory attributes. OBJECTP is nonzero
199 if we are making a new object of this type. */
200 extern void set_mem_attributes (rtx, tree, int);
202 /* Similar, except that BITPOS has not yet been applied to REF, so if
203 we alter MEM_OFFSET according to T then we should subtract BITPOS
204 expecting that it'll be added back in later. */
205 extern void set_mem_attributes_minus_bitpos (rtx, tree, int, HOST_WIDE_INT);
207 /* Return OFFSET if XEXP (MEM, 0) - OFFSET is known to be ALIGN
208 bits aligned for 0 <= OFFSET < ALIGN / BITS_PER_UNIT, or
209 -1 if not known. */
210 extern int get_mem_align_offset (rtx, unsigned int);
212 /* Return a memory reference like MEMREF, but with its mode widened to
213 MODE and adjusted by OFFSET. */
214 extern rtx widen_memory_access (rtx, machine_mode, HOST_WIDE_INT);
216 #endif /* GCC_EMIT_RTL_H */