1*38fd1498Szrj /* Definitions for code generation pass of GNU compiler. 2*38fd1498Szrj Copyright (C) 1987-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_EXPR_H 21*38fd1498Szrj #define GCC_EXPR_H 22*38fd1498Szrj 23*38fd1498Szrj /* This is the 4th arg to `expand_expr'. 24*38fd1498Szrj EXPAND_STACK_PARM means we are possibly expanding a call param onto 25*38fd1498Szrj the stack. 26*38fd1498Szrj EXPAND_SUM means it is ok to return a PLUS rtx or MULT rtx. 27*38fd1498Szrj EXPAND_INITIALIZER is similar but also record any labels on forced_labels. 28*38fd1498Szrj EXPAND_CONST_ADDRESS means it is ok to return a MEM whose address 29*38fd1498Szrj is a constant that is not a legitimate address. 30*38fd1498Szrj EXPAND_WRITE means we are only going to write to the resulting rtx. 31*38fd1498Szrj EXPAND_MEMORY means we are interested in a memory result, even if 32*38fd1498Szrj the memory is constant and we could have propagated a constant value, 33*38fd1498Szrj or the memory is unaligned on a STRICT_ALIGNMENT target. */ 34*38fd1498Szrj enum expand_modifier {EXPAND_NORMAL = 0, EXPAND_STACK_PARM, EXPAND_SUM, 35*38fd1498Szrj EXPAND_CONST_ADDRESS, EXPAND_INITIALIZER, EXPAND_WRITE, 36*38fd1498Szrj EXPAND_MEMORY}; 37*38fd1498Szrj 38*38fd1498Szrj /* Prevent the compiler from deferring stack pops. See 39*38fd1498Szrj inhibit_defer_pop for more information. */ 40*38fd1498Szrj #define NO_DEFER_POP (inhibit_defer_pop += 1) 41*38fd1498Szrj 42*38fd1498Szrj /* Allow the compiler to defer stack pops. See inhibit_defer_pop for 43*38fd1498Szrj more information. */ 44*38fd1498Szrj #define OK_DEFER_POP (inhibit_defer_pop -= 1) 45*38fd1498Szrj 46*38fd1498Szrj /* This structure is used to pass around information about exploded 47*38fd1498Szrj unary, binary and trinary expressions between expand_expr_real_1 and 48*38fd1498Szrj friends. */ 49*38fd1498Szrj typedef struct separate_ops 50*38fd1498Szrj { 51*38fd1498Szrj enum tree_code code; 52*38fd1498Szrj location_t location; 53*38fd1498Szrj tree type; 54*38fd1498Szrj tree op0, op1, op2; 55*38fd1498Szrj } *sepops; 56*38fd1498Szrj 57*38fd1498Szrj /* This is run during target initialization to set up which modes can be 58*38fd1498Szrj used directly in memory and to initialize the block move optab. */ 59*38fd1498Szrj extern void init_expr_target (void); 60*38fd1498Szrj 61*38fd1498Szrj /* This is run at the start of compiling a function. */ 62*38fd1498Szrj extern void init_expr (void); 63*38fd1498Szrj 64*38fd1498Szrj /* Emit some rtl insns to move data between rtx's, converting machine modes. 65*38fd1498Szrj Both modes must be floating or both fixed. */ 66*38fd1498Szrj extern void convert_move (rtx, rtx, int); 67*38fd1498Szrj 68*38fd1498Szrj /* Convert an rtx to specified machine mode and return the result. */ 69*38fd1498Szrj extern rtx convert_to_mode (machine_mode, rtx, int); 70*38fd1498Szrj 71*38fd1498Szrj /* Convert an rtx to MODE from OLDMODE and return the result. */ 72*38fd1498Szrj extern rtx convert_modes (machine_mode, machine_mode, rtx, int); 73*38fd1498Szrj 74*38fd1498Szrj /* Expand a call to memcpy or memmove or memcmp, and return the result. */ 75*38fd1498Szrj extern rtx emit_block_op_via_libcall (enum built_in_function, rtx, rtx, rtx, 76*38fd1498Szrj bool); 77*38fd1498Szrj 78*38fd1498Szrj static inline rtx 79*38fd1498Szrj emit_block_copy_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false) 80*38fd1498Szrj { 81*38fd1498Szrj return emit_block_op_via_libcall (BUILT_IN_MEMCPY, dst, src, size, tailcall); 82*38fd1498Szrj } 83*38fd1498Szrj 84*38fd1498Szrj static inline rtx 85*38fd1498Szrj emit_block_move_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false) 86*38fd1498Szrj { 87*38fd1498Szrj return emit_block_op_via_libcall (BUILT_IN_MEMMOVE, dst, src, size, tailcall); 88*38fd1498Szrj } 89*38fd1498Szrj 90*38fd1498Szrj static inline rtx 91*38fd1498Szrj emit_block_comp_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false) 92*38fd1498Szrj { 93*38fd1498Szrj return emit_block_op_via_libcall (BUILT_IN_MEMCMP, dst, src, size, tailcall); 94*38fd1498Szrj } 95*38fd1498Szrj 96*38fd1498Szrj /* Emit code to move a block Y to a block X. */ 97*38fd1498Szrj enum block_op_methods 98*38fd1498Szrj { 99*38fd1498Szrj BLOCK_OP_NORMAL, 100*38fd1498Szrj BLOCK_OP_NO_LIBCALL, 101*38fd1498Szrj BLOCK_OP_CALL_PARM, 102*38fd1498Szrj /* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized. */ 103*38fd1498Szrj BLOCK_OP_TAILCALL, 104*38fd1498Szrj /* Like BLOCK_OP_NO_LIBCALL, but instead of emitting a libcall return 105*38fd1498Szrj pc_rtx to indicate nothing has been emitted and let the caller handle 106*38fd1498Szrj it. */ 107*38fd1498Szrj BLOCK_OP_NO_LIBCALL_RET 108*38fd1498Szrj }; 109*38fd1498Szrj 110*38fd1498Szrj typedef rtx (*by_pieces_constfn) (void *, HOST_WIDE_INT, scalar_int_mode); 111*38fd1498Szrj 112*38fd1498Szrj extern rtx emit_block_move (rtx, rtx, rtx, enum block_op_methods); 113*38fd1498Szrj extern rtx emit_block_move_hints (rtx, rtx, rtx, enum block_op_methods, 114*38fd1498Szrj unsigned int, HOST_WIDE_INT, 115*38fd1498Szrj unsigned HOST_WIDE_INT, 116*38fd1498Szrj unsigned HOST_WIDE_INT, 117*38fd1498Szrj unsigned HOST_WIDE_INT); 118*38fd1498Szrj extern rtx emit_block_cmp_hints (rtx, rtx, rtx, tree, rtx, bool, 119*38fd1498Szrj by_pieces_constfn, void *); 120*38fd1498Szrj extern bool emit_storent_insn (rtx to, rtx from); 121*38fd1498Szrj 122*38fd1498Szrj /* Copy all or part of a value X into registers starting at REGNO. 123*38fd1498Szrj The number of registers to be filled is NREGS. */ 124*38fd1498Szrj extern void move_block_to_reg (int, rtx, int, machine_mode); 125*38fd1498Szrj 126*38fd1498Szrj /* Copy all or part of a BLKmode value X out of registers starting at REGNO. 127*38fd1498Szrj The number of registers to be filled is NREGS. */ 128*38fd1498Szrj extern void move_block_from_reg (int, rtx, int); 129*38fd1498Szrj 130*38fd1498Szrj /* Generate a non-consecutive group of registers represented by a PARALLEL. */ 131*38fd1498Szrj extern rtx gen_group_rtx (rtx); 132*38fd1498Szrj 133*38fd1498Szrj /* Load a BLKmode value into non-consecutive registers represented by a 134*38fd1498Szrj PARALLEL. */ 135*38fd1498Szrj extern void emit_group_load (rtx, rtx, tree, poly_int64); 136*38fd1498Szrj 137*38fd1498Szrj /* Similarly, but load into new temporaries. */ 138*38fd1498Szrj extern rtx emit_group_load_into_temps (rtx, rtx, tree, poly_int64); 139*38fd1498Szrj 140*38fd1498Szrj /* Move a non-consecutive group of registers represented by a PARALLEL into 141*38fd1498Szrj a non-consecutive group of registers represented by a PARALLEL. */ 142*38fd1498Szrj extern void emit_group_move (rtx, rtx); 143*38fd1498Szrj 144*38fd1498Szrj /* Move a group of registers represented by a PARALLEL into pseudos. */ 145*38fd1498Szrj extern rtx emit_group_move_into_temps (rtx); 146*38fd1498Szrj 147*38fd1498Szrj /* Store a BLKmode value from non-consecutive registers represented by a 148*38fd1498Szrj PARALLEL. */ 149*38fd1498Szrj extern void emit_group_store (rtx, rtx, tree, poly_int64); 150*38fd1498Szrj 151*38fd1498Szrj extern rtx maybe_emit_group_store (rtx, tree); 152*38fd1498Szrj 153*38fd1498Szrj /* Mark REG as holding a parameter for the next CALL_INSN. 154*38fd1498Szrj Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode. */ 155*38fd1498Szrj extern void use_reg_mode (rtx *, rtx, machine_mode); 156*38fd1498Szrj extern void clobber_reg_mode (rtx *, rtx, machine_mode); 157*38fd1498Szrj 158*38fd1498Szrj extern rtx copy_blkmode_to_reg (machine_mode, tree); 159*38fd1498Szrj 160*38fd1498Szrj /* Mark REG as holding a parameter for the next CALL_INSN. */ 161*38fd1498Szrj static inline void 162*38fd1498Szrj use_reg (rtx *fusage, rtx reg) 163*38fd1498Szrj { 164*38fd1498Szrj use_reg_mode (fusage, reg, VOIDmode); 165*38fd1498Szrj } 166*38fd1498Szrj 167*38fd1498Szrj /* Mark REG as clobbered by the call with FUSAGE as CALL_INSN_FUNCTION_USAGE. */ 168*38fd1498Szrj static inline void 169*38fd1498Szrj clobber_reg (rtx *fusage, rtx reg) 170*38fd1498Szrj { 171*38fd1498Szrj clobber_reg_mode (fusage, reg, VOIDmode); 172*38fd1498Szrj } 173*38fd1498Szrj 174*38fd1498Szrj /* Mark NREGS consecutive regs, starting at REGNO, as holding parameters 175*38fd1498Szrj for the next CALL_INSN. */ 176*38fd1498Szrj extern void use_regs (rtx *, int, int); 177*38fd1498Szrj 178*38fd1498Szrj /* Mark a PARALLEL as holding a parameter for the next CALL_INSN. */ 179*38fd1498Szrj extern void use_group_regs (rtx *, rtx); 180*38fd1498Szrj 181*38fd1498Szrj #ifdef GCC_INSN_CODES_H 182*38fd1498Szrj extern rtx expand_cmpstrn_or_cmpmem (insn_code, rtx, rtx, rtx, tree, rtx, 183*38fd1498Szrj HOST_WIDE_INT); 184*38fd1498Szrj #endif 185*38fd1498Szrj 186*38fd1498Szrj /* Write zeros through the storage of OBJECT. 187*38fd1498Szrj If OBJECT has BLKmode, SIZE is its length in bytes. */ 188*38fd1498Szrj extern rtx clear_storage (rtx, rtx, enum block_op_methods); 189*38fd1498Szrj extern rtx clear_storage_hints (rtx, rtx, enum block_op_methods, 190*38fd1498Szrj unsigned int, HOST_WIDE_INT, 191*38fd1498Szrj unsigned HOST_WIDE_INT, 192*38fd1498Szrj unsigned HOST_WIDE_INT, 193*38fd1498Szrj unsigned HOST_WIDE_INT); 194*38fd1498Szrj /* The same, but always output an library call. */ 195*38fd1498Szrj extern rtx set_storage_via_libcall (rtx, rtx, rtx, bool = false); 196*38fd1498Szrj 197*38fd1498Szrj /* Expand a setmem pattern; return true if successful. */ 198*38fd1498Szrj extern bool set_storage_via_setmem (rtx, rtx, rtx, unsigned int, 199*38fd1498Szrj unsigned int, HOST_WIDE_INT, 200*38fd1498Szrj unsigned HOST_WIDE_INT, 201*38fd1498Szrj unsigned HOST_WIDE_INT, 202*38fd1498Szrj unsigned HOST_WIDE_INT); 203*38fd1498Szrj 204*38fd1498Szrj /* Return nonzero if it is desirable to store LEN bytes generated by 205*38fd1498Szrj CONSTFUN with several move instructions by store_by_pieces 206*38fd1498Szrj function. CONSTFUNDATA is a pointer which will be passed as argument 207*38fd1498Szrj in every CONSTFUN call. 208*38fd1498Szrj ALIGN is maximum alignment we can assume. 209*38fd1498Szrj MEMSETP is true if this is a real memset/bzero, not a copy 210*38fd1498Szrj of a const string. */ 211*38fd1498Szrj extern int can_store_by_pieces (unsigned HOST_WIDE_INT, 212*38fd1498Szrj by_pieces_constfn, 213*38fd1498Szrj void *, unsigned int, bool); 214*38fd1498Szrj 215*38fd1498Szrj /* Generate several move instructions to store LEN bytes generated by 216*38fd1498Szrj CONSTFUN to block TO. (A MEM rtx with BLKmode). CONSTFUNDATA is a 217*38fd1498Szrj pointer which will be passed as argument in every CONSTFUN call. 218*38fd1498Szrj ALIGN is maximum alignment we can assume. 219*38fd1498Szrj MEMSETP is true if this is a real memset/bzero, not a copy. 220*38fd1498Szrj Returns TO + LEN. */ 221*38fd1498Szrj extern rtx store_by_pieces (rtx, unsigned HOST_WIDE_INT, by_pieces_constfn, 222*38fd1498Szrj void *, unsigned int, bool, int); 223*38fd1498Szrj 224*38fd1498Szrj /* Emit insns to set X from Y. */ 225*38fd1498Szrj extern rtx_insn *emit_move_insn (rtx, rtx); 226*38fd1498Szrj extern rtx_insn *gen_move_insn (rtx, rtx); 227*38fd1498Szrj 228*38fd1498Szrj /* Emit insns to set X from Y, with no frills. */ 229*38fd1498Szrj extern rtx_insn *emit_move_insn_1 (rtx, rtx); 230*38fd1498Szrj 231*38fd1498Szrj extern rtx_insn *emit_move_complex_push (machine_mode, rtx, rtx); 232*38fd1498Szrj extern rtx_insn *emit_move_complex_parts (rtx, rtx); 233*38fd1498Szrj extern rtx read_complex_part (rtx, bool); 234*38fd1498Szrj extern void write_complex_part (rtx, rtx, bool); 235*38fd1498Szrj extern rtx read_complex_part (rtx, bool); 236*38fd1498Szrj extern rtx emit_move_resolve_push (machine_mode, rtx); 237*38fd1498Szrj 238*38fd1498Szrj /* Push a block of length SIZE (perhaps variable) 239*38fd1498Szrj and return an rtx to address the beginning of the block. */ 240*38fd1498Szrj extern rtx push_block (rtx, poly_int64, int); 241*38fd1498Szrj 242*38fd1498Szrj /* Generate code to push something onto the stack, given its mode and type. */ 243*38fd1498Szrj extern bool emit_push_insn (rtx, machine_mode, tree, rtx, unsigned int, 244*38fd1498Szrj int, rtx, poly_int64, rtx, rtx, int, rtx, bool); 245*38fd1498Szrj 246*38fd1498Szrj /* Extract the accessible bit-range from a COMPONENT_REF. */ 247*38fd1498Szrj extern void get_bit_range (poly_uint64_pod *, poly_uint64_pod *, tree, 248*38fd1498Szrj poly_int64_pod *, tree *); 249*38fd1498Szrj 250*38fd1498Szrj /* Expand an assignment that stores the value of FROM into TO. */ 251*38fd1498Szrj extern void expand_assignment (tree, tree, bool); 252*38fd1498Szrj 253*38fd1498Szrj /* Generate code for computing expression EXP, 254*38fd1498Szrj and storing the value into TARGET. 255*38fd1498Szrj If SUGGEST_REG is nonzero, copy the value through a register 256*38fd1498Szrj and return that register, if that is possible. */ 257*38fd1498Szrj extern rtx store_expr_with_bounds (tree, rtx, int, bool, bool, tree); 258*38fd1498Szrj extern rtx store_expr (tree, rtx, int, bool, bool); 259*38fd1498Szrj 260*38fd1498Szrj /* Given an rtx that may include add and multiply operations, 261*38fd1498Szrj generate them as insns and return a pseudo-reg containing the value. 262*38fd1498Szrj Useful after calling expand_expr with 1 as sum_ok. */ 263*38fd1498Szrj extern rtx force_operand (rtx, rtx); 264*38fd1498Szrj 265*38fd1498Szrj /* Work horses for expand_expr. */ 266*38fd1498Szrj extern rtx expand_expr_real (tree, rtx, machine_mode, 267*38fd1498Szrj enum expand_modifier, rtx *, bool); 268*38fd1498Szrj extern rtx expand_expr_real_1 (tree, rtx, machine_mode, 269*38fd1498Szrj enum expand_modifier, rtx *, bool); 270*38fd1498Szrj extern rtx expand_expr_real_2 (sepops, rtx, machine_mode, 271*38fd1498Szrj enum expand_modifier); 272*38fd1498Szrj 273*38fd1498Szrj /* Generate code for computing expression EXP. 274*38fd1498Szrj An rtx for the computed value is returned. The value is never null. 275*38fd1498Szrj In the case of a void EXP, const0_rtx is returned. */ 276*38fd1498Szrj static inline rtx 277*38fd1498Szrj expand_expr (tree exp, rtx target, machine_mode mode, 278*38fd1498Szrj enum expand_modifier modifier) 279*38fd1498Szrj { 280*38fd1498Szrj return expand_expr_real (exp, target, mode, modifier, NULL, false); 281*38fd1498Szrj } 282*38fd1498Szrj 283*38fd1498Szrj static inline rtx 284*38fd1498Szrj expand_normal (tree exp) 285*38fd1498Szrj { 286*38fd1498Szrj return expand_expr_real (exp, NULL_RTX, VOIDmode, EXPAND_NORMAL, NULL, false); 287*38fd1498Szrj } 288*38fd1498Szrj 289*38fd1498Szrj 290*38fd1498Szrj /* Return the tree node and offset if a given argument corresponds to 291*38fd1498Szrj a string constant. */ 292*38fd1498Szrj extern tree string_constant (tree, tree *); 293*38fd1498Szrj 294*38fd1498Szrj /* Two different ways of generating switch statements. */ 295*38fd1498Szrj extern int try_casesi (tree, tree, tree, tree, rtx, rtx, rtx, profile_probability); 296*38fd1498Szrj extern int try_tablejump (tree, tree, tree, tree, rtx, rtx, profile_probability); 297*38fd1498Szrj 298*38fd1498Szrj extern int safe_from_p (const_rtx, tree, int); 299*38fd1498Szrj 300*38fd1498Szrj /* Get the personality libfunc for a function decl. */ 301*38fd1498Szrj rtx get_personality_function (tree); 302*38fd1498Szrj 303*38fd1498Szrj /* Determine whether the LEN bytes can be moved by using several move 304*38fd1498Szrj instructions. Return nonzero if a call to move_by_pieces should 305*38fd1498Szrj succeed. */ 306*38fd1498Szrj extern bool can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int); 307*38fd1498Szrj 308*38fd1498Szrj extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree); 309*38fd1498Szrj 310*38fd1498Szrj extern bool categorize_ctor_elements (const_tree, HOST_WIDE_INT *, 311*38fd1498Szrj HOST_WIDE_INT *, bool *); 312*38fd1498Szrj 313*38fd1498Szrj extern void expand_operands (tree, tree, rtx, rtx*, rtx*, 314*38fd1498Szrj enum expand_modifier); 315*38fd1498Szrj 316*38fd1498Szrj /* rtl.h and tree.h were included. */ 317*38fd1498Szrj /* Return an rtx for the size in bytes of the value of an expr. */ 318*38fd1498Szrj extern rtx expr_size (tree); 319*38fd1498Szrj 320*38fd1498Szrj #endif /* GCC_EXPR_H */ 321