expr.h 11.7 KB
Newer Older
Richard Kenner committed
1
/* Definitions for code generation pass of GNU compiler.
2
   Copyright (C) 1987-2017 Free Software Foundation, Inc.
Richard Kenner committed
3

4
This file is part of GCC.
Richard Kenner committed
5

6 7
GCC is free software; you can redistribute it and/or modify it under
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.
Richard Kenner committed
10

11 12 13 14
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
Richard Kenner committed
15 16

You should have received a copy of the GNU General Public License
17 18
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
Richard Kenner committed
19

20 21 22
#ifndef GCC_EXPR_H
#define GCC_EXPR_H

Richard Kenner committed
23
/* This is the 4th arg to `expand_expr'.
24
   EXPAND_STACK_PARM means we are possibly expanding a call param onto
25
   the stack.
Richard Kenner committed
26 27 28
   EXPAND_SUM means it is ok to return a PLUS rtx or MULT rtx.
   EXPAND_INITIALIZER is similar but also record any labels on forced_labels.
   EXPAND_CONST_ADDRESS means it is ok to return a MEM whose address
29
    is a constant that is not a legitimate address.
30 31
   EXPAND_WRITE means we are only going to write to the resulting rtx.
   EXPAND_MEMORY means we are interested in a memory result, even if
32 33
    the memory is constant and we could have propagated a constant value,
    or the memory is unaligned on a STRICT_ALIGNMENT target.  */
34
enum expand_modifier {EXPAND_NORMAL = 0, EXPAND_STACK_PARM, EXPAND_SUM,
35 36
		      EXPAND_CONST_ADDRESS, EXPAND_INITIALIZER, EXPAND_WRITE,
		      EXPAND_MEMORY};
Richard Kenner committed
37

38 39 40 41 42 43 44
/* Prevent the compiler from deferring stack pops.  See
   inhibit_defer_pop for more information.  */
#define NO_DEFER_POP (inhibit_defer_pop += 1)

/* Allow the compiler to defer stack pops.  See inhibit_defer_pop for
   more information.  */
#define OK_DEFER_POP (inhibit_defer_pop -= 1)
Richard Kenner committed
45

46 47 48 49 50 51
/* This structure is used to pass around information about exploded
   unary, binary and trinary expressions between expand_expr_real_1 and
   friends.  */
typedef struct separate_ops
{
  enum tree_code code;
52
  location_t location;
53 54 55 56
  tree type;
  tree op0, op1, op2;
} *sepops;

H.J. Lu committed
57
/* This is run during target initialization to set up which modes can be
58 59
   used directly in memory and to initialize the block move optab.  */
extern void init_expr_target (void);
60 61

/* This is run at the start of compiling a function.  */
62
extern void init_expr (void);
63

Richard Kenner committed
64 65
/* Emit some rtl insns to move data between rtx's, converting machine modes.
   Both modes must be floating or both fixed.  */
66
extern void convert_move (rtx, rtx, int);
Richard Kenner committed
67 68

/* Convert an rtx to specified machine mode and return the result.  */
69
extern rtx convert_to_mode (machine_mode, rtx, int);
Richard Kenner committed
70

71
/* Convert an rtx to MODE from OLDMODE and return the result.  */
72
extern rtx convert_modes (machine_mode, machine_mode, rtx, int);
73

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
/* Expand a call to memcpy or memmove or memcmp, and return the result.  */
extern rtx emit_block_op_via_libcall (enum built_in_function, rtx, rtx, rtx,
				      bool);

static inline rtx
emit_block_copy_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
{
  return emit_block_op_via_libcall (BUILT_IN_MEMCPY, dst, src, size, tailcall);
}

static inline rtx
emit_block_move_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
{
  return emit_block_op_via_libcall (BUILT_IN_MEMMOVE, dst, src, size, tailcall);
}

static inline rtx
emit_block_comp_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
{
  return emit_block_op_via_libcall (BUILT_IN_MEMCMP, dst, src, size, tailcall);
}
95

96
/* Emit code to move a block Y to a block X.  */
97 98 99
enum block_op_methods
{
  BLOCK_OP_NORMAL,
100
  BLOCK_OP_NO_LIBCALL,
101 102 103
  BLOCK_OP_CALL_PARM,
  /* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized.  */
  BLOCK_OP_TAILCALL
104 105
};

106 107
typedef rtx (*by_pieces_constfn) (void *, HOST_WIDE_INT, machine_mode);

108
extern rtx emit_block_move (rtx, rtx, rtx, enum block_op_methods);
109
extern rtx emit_block_move_hints (rtx, rtx, rtx, enum block_op_methods,
110 111
			          unsigned int, HOST_WIDE_INT,
				  unsigned HOST_WIDE_INT,
112
				  unsigned HOST_WIDE_INT,
113
				  unsigned HOST_WIDE_INT);
114 115
extern rtx emit_block_cmp_hints (rtx, rtx, rtx, tree, rtx, bool,
				 by_pieces_constfn, void *);
116
extern bool emit_storent_insn (rtx to, rtx from);
117 118 119

/* Copy all or part of a value X into registers starting at REGNO.
   The number of registers to be filled is NREGS.  */
120
extern void move_block_to_reg (int, rtx, int, machine_mode);
121 122 123

/* Copy all or part of a BLKmode value X out of registers starting at REGNO.
   The number of registers to be filled is NREGS.  */
124
extern void move_block_from_reg (int, rtx, int);
125

126
/* Generate a non-consecutive group of registers represented by a PARALLEL.  */
127
extern rtx gen_group_rtx (rtx);
128

129 130
/* Load a BLKmode value into non-consecutive registers represented by a
   PARALLEL.  */
131
extern void emit_group_load (rtx, rtx, tree, int);
132

133 134 135
/* Similarly, but load into new temporaries.  */
extern rtx emit_group_load_into_temps (rtx, rtx, tree, int);

136 137
/* Move a non-consecutive group of registers represented by a PARALLEL into
   a non-consecutive group of registers represented by a PARALLEL.  */
138
extern void emit_group_move (rtx, rtx);
139

140 141 142
/* Move a group of registers represented by a PARALLEL into pseudos.  */
extern rtx emit_group_move_into_temps (rtx);

143 144
/* Store a BLKmode value from non-consecutive registers represented by a
   PARALLEL.  */
145
extern void emit_group_store (rtx, rtx, tree, int);
146

147 148
extern rtx maybe_emit_group_store (rtx, tree);

149 150
/* Mark REG as holding a parameter for the next CALL_INSN.
   Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode.  */
151 152
extern void use_reg_mode (rtx *, rtx, machine_mode);
extern void clobber_reg_mode (rtx *, rtx, machine_mode);
153

154
extern rtx copy_blkmode_to_reg (machine_mode, tree);
155

156
/* Mark REG as holding a parameter for the next CALL_INSN.  */
157 158 159 160 161
static inline void
use_reg (rtx *fusage, rtx reg)
{
  use_reg_mode (fusage, reg, VOIDmode);
}
162

Tom de Vries committed
163 164 165 166 167 168 169
/* Mark REG as clobbered by the call with FUSAGE as CALL_INSN_FUNCTION_USAGE.  */
static inline void
clobber_reg (rtx *fusage, rtx reg)
{
  clobber_reg_mode (fusage, reg, VOIDmode);
}

170 171
/* Mark NREGS consecutive regs, starting at REGNO, as holding parameters
   for the next CALL_INSN.  */
172
extern void use_regs (rtx *, int, int);
173

174
/* Mark a PARALLEL as holding a parameter for the next CALL_INSN.  */
175
extern void use_group_regs (rtx *, rtx);
176

177 178 179 180 181
#ifdef GCC_INSN_CODES_H
extern rtx expand_cmpstrn_or_cmpmem (insn_code, rtx, rtx, rtx, tree, rtx,
				     HOST_WIDE_INT);
#endif

182
/* Write zeros through the storage of OBJECT.
183
   If OBJECT has BLKmode, SIZE is its length in bytes.  */
184
extern rtx clear_storage (rtx, rtx, enum block_op_methods);
185
extern rtx clear_storage_hints (rtx, rtx, enum block_op_methods,
186 187
			        unsigned int, HOST_WIDE_INT,
				unsigned HOST_WIDE_INT,
188
				unsigned HOST_WIDE_INT,
189
				unsigned HOST_WIDE_INT);
190
/* The same, but always output an library call.  */
191
extern rtx set_storage_via_libcall (rtx, rtx, rtx, bool = false);
192

193
/* Expand a setmem pattern; return true if successful.  */
H.J. Lu committed
194
extern bool set_storage_via_setmem (rtx, rtx, rtx, unsigned int,
195 196
				    unsigned int, HOST_WIDE_INT,
				    unsigned HOST_WIDE_INT,
197
				    unsigned HOST_WIDE_INT,
198
				    unsigned HOST_WIDE_INT);
199

200
/* Return nonzero if it is desirable to store LEN bytes generated by
201 202 203
   CONSTFUN with several move instructions by store_by_pieces
   function.  CONSTFUNDATA is a pointer which will be passed as argument
   in every CONSTFUN call.
204 205 206
   ALIGN is maximum alignment we can assume.
   MEMSETP is true if this is a real memset/bzero, not a copy
   of a const string.  */
207
extern int can_store_by_pieces (unsigned HOST_WIDE_INT,
208
				by_pieces_constfn,
209
				void *, unsigned int, bool);
210 211 212 213

/* Generate several move instructions to store LEN bytes generated by
   CONSTFUN to block TO.  (A MEM rtx with BLKmode).  CONSTFUNDATA is a
   pointer which will be passed as argument in every CONSTFUN call.
214
   ALIGN is maximum alignment we can assume.
215
   MEMSETP is true if this is a real memset/bzero, not a copy.
216
   Returns TO + LEN.  */
217
extern rtx store_by_pieces (rtx, unsigned HOST_WIDE_INT, by_pieces_constfn,
218
			    void *, unsigned int, bool, int);
219

220
/* Emit insns to set X from Y.  */
221
extern rtx_insn *emit_move_insn (rtx, rtx);
222
extern rtx_insn *gen_move_insn (rtx, rtx);
223 224

/* Emit insns to set X from Y, with no frills.  */
225
extern rtx_insn *emit_move_insn_1 (rtx, rtx);
226

227
extern rtx_insn *emit_move_complex_push (machine_mode, rtx, rtx);
228
extern rtx_insn *emit_move_complex_parts (rtx, rtx);
229
extern rtx read_complex_part (rtx, bool);
230
extern void write_complex_part (rtx, rtx, bool);
231
extern rtx read_complex_part (rtx, bool);
232
extern rtx emit_move_resolve_push (machine_mode, rtx);
233

234 235
/* Push a block of length SIZE (perhaps variable)
   and return an rtx to address the beginning of the block.  */
236
extern rtx push_block (rtx, int, int);
237 238

/* Generate code to push something onto the stack, given its mode and type.  */
239 240
extern bool emit_push_insn (rtx, machine_mode, tree, rtx, unsigned int,
			    int, rtx, int, rtx, rtx, int, rtx, bool);
241

242 243 244 245
/* Extract the accessible bit-range from a COMPONENT_REF.  */
extern void get_bit_range (unsigned HOST_WIDE_INT *, unsigned HOST_WIDE_INT *,
			   tree, HOST_WIDE_INT *, tree *);

246
/* Expand an assignment that stores the value of FROM into TO.  */
247
extern void expand_assignment (tree, tree, bool);
248 249 250 251 252

/* Generate code for computing expression EXP,
   and storing the value into TARGET.
   If SUGGEST_REG is nonzero, copy the value through a register
   and return that register, if that is possible.  */
253 254
extern rtx store_expr_with_bounds (tree, rtx, int, bool, bool, tree);
extern rtx store_expr (tree, rtx, int, bool, bool);
Richard Kenner committed
255 256 257 258

/* Given an rtx that may include add and multiply operations,
   generate them as insns and return a pseudo-reg containing the value.
   Useful after calling expand_expr with 1 as sum_ok.  */
259
extern rtx force_operand (rtx, rtx);
Richard Kenner committed
260

261
/* Work horses for expand_expr.  */
262
extern rtx expand_expr_real (tree, rtx, machine_mode,
263
			     enum expand_modifier, rtx *, bool);
264
extern rtx expand_expr_real_1 (tree, rtx, machine_mode,
265
			       enum expand_modifier, rtx *, bool);
266
extern rtx expand_expr_real_2 (sepops, rtx, machine_mode,
267
			       enum expand_modifier);
268

269 270 271
/* Generate code for computing expression EXP.
   An rtx for the computed value is returned.  The value is never null.
   In the case of a void EXP, const0_rtx is returned.  */
272
static inline rtx
273
expand_expr (tree exp, rtx target, machine_mode mode,
274 275
	     enum expand_modifier modifier)
{
276
  return expand_expr_real (exp, target, mode, modifier, NULL, false);
277
}
278

279 280 281
static inline rtx
expand_normal (tree exp)
{
282
  return expand_expr_real (exp, NULL_RTX, VOIDmode, EXPAND_NORMAL, NULL, false);
283 284
}

285

286 287
/* Return the tree node and offset if a given argument corresponds to
   a string constant.  */
288
extern tree string_constant (tree, tree *);
289

290
/* Two different ways of generating switch statements.  */
Easwaran Raman committed
291 292
extern int try_casesi (tree, tree, tree, tree, rtx, rtx, rtx, int);
extern int try_tablejump (tree, tree, tree, tree, rtx, rtx, int);
293

294
extern int safe_from_p (const_rtx, tree, int);
295

296 297 298
/* Get the personality libfunc for a function decl.  */
rtx get_personality_function (tree);

299 300 301
/* Determine whether the LEN bytes can be moved by using several move
   instructions.  Return nonzero if a call to move_by_pieces should
   succeed.  */
302
extern bool can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int);
303 304 305 306 307 308

extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree);

extern bool categorize_ctor_elements (const_tree, HOST_WIDE_INT *,
				      HOST_WIDE_INT *, bool *);

309 310
extern void expand_operands (tree, tree, rtx, rtx*, rtx*,
			     enum expand_modifier);
311 312 313 314 315

/* rtl.h and tree.h were included.  */
/* Return an rtx for the size in bytes of the value of an expr.  */
extern rtx expr_size (tree);

316
#endif /* GCC_EXPR_H */