Home | History | Annotate | Line # | Download | only in gcc
optabs.h revision 1.8
      1  1.1  mrg /* Definitions for code generation pass of GNU compiler.
      2  1.8  mrg    Copyright (C) 2001-2017 Free Software Foundation, Inc.
      3  1.1  mrg 
      4  1.1  mrg This file is part of GCC.
      5  1.1  mrg 
      6  1.1  mrg GCC is free software; you can redistribute it and/or modify
      7  1.1  mrg it under the terms of the GNU General Public License as published by
      8  1.1  mrg the Free Software Foundation; either version 3, or (at your option)
      9  1.1  mrg any later version.
     10  1.1  mrg 
     11  1.1  mrg GCC is distributed in the hope that it will be useful,
     12  1.1  mrg but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  1.1  mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  1.1  mrg GNU General Public License for more details.
     15  1.1  mrg 
     16  1.1  mrg You should have received a copy of the GNU General Public License
     17  1.1  mrg along with GCC; see the file COPYING3.  If not see
     18  1.1  mrg <http://www.gnu.org/licenses/>.  */
     19  1.1  mrg 
     20  1.1  mrg #ifndef GCC_OPTABS_H
     21  1.1  mrg #define GCC_OPTABS_H
     22  1.1  mrg 
     23  1.6  mrg #include "optabs-query.h"
     24  1.6  mrg #include "optabs-libfuncs.h"
     25  1.1  mrg 
     26  1.3  mrg /* Generate code for a widening multiply.  */
     27  1.5  mrg extern rtx expand_widening_mult (machine_mode, rtx, rtx, rtx, int, optab);
     28  1.3  mrg 
     29  1.3  mrg /* Describes the type of an expand_operand.  Each value is associated
     30  1.3  mrg    with a create_*_operand function; see the comments above those
     31  1.3  mrg    functions for details.  */
     32  1.3  mrg enum expand_operand_type {
     33  1.3  mrg   EXPAND_FIXED,
     34  1.3  mrg   EXPAND_OUTPUT,
     35  1.3  mrg   EXPAND_INPUT,
     36  1.3  mrg   EXPAND_CONVERT_TO,
     37  1.3  mrg   EXPAND_CONVERT_FROM,
     38  1.3  mrg   EXPAND_ADDRESS,
     39  1.3  mrg   EXPAND_INTEGER
     40  1.3  mrg };
     41  1.3  mrg 
     42  1.3  mrg /* Information about an operand for instruction expansion.  */
     43  1.3  mrg struct expand_operand {
     44  1.3  mrg   /* The type of operand.  */
     45  1.3  mrg   ENUM_BITFIELD (expand_operand_type) type : 8;
     46  1.3  mrg 
     47  1.3  mrg   /* True if any conversion should treat VALUE as being unsigned
     48  1.3  mrg      rather than signed.  Only meaningful for certain types.  */
     49  1.3  mrg   unsigned int unsigned_p : 1;
     50  1.3  mrg 
     51  1.3  mrg   /* Unused; available for future use.  */
     52  1.3  mrg   unsigned int unused : 7;
     53  1.3  mrg 
     54  1.3  mrg   /* The mode passed to the convert_*_operand function.  It has a
     55  1.3  mrg      type-dependent meaning.  */
     56  1.3  mrg   ENUM_BITFIELD (machine_mode) mode : 16;
     57  1.3  mrg 
     58  1.3  mrg   /* The value of the operand.  */
     59  1.3  mrg   rtx value;
     60  1.3  mrg };
     61  1.3  mrg 
     62  1.3  mrg /* Initialize OP with the given fields.  Initialise the other fields
     63  1.3  mrg    to their default values.  */
     64  1.3  mrg 
     65  1.3  mrg static inline void
     66  1.3  mrg create_expand_operand (struct expand_operand *op,
     67  1.3  mrg 		       enum expand_operand_type type,
     68  1.5  mrg 		       rtx value, machine_mode mode,
     69  1.3  mrg 		       bool unsigned_p)
     70  1.3  mrg {
     71  1.3  mrg   op->type = type;
     72  1.3  mrg   op->unsigned_p = unsigned_p;
     73  1.3  mrg   op->unused = 0;
     74  1.3  mrg   op->mode = mode;
     75  1.3  mrg   op->value = value;
     76  1.3  mrg }
     77  1.3  mrg 
     78  1.3  mrg /* Make OP describe an operand that must use rtx X, even if X is volatile.  */
     79  1.3  mrg 
     80  1.3  mrg static inline void
     81  1.3  mrg create_fixed_operand (struct expand_operand *op, rtx x)
     82  1.3  mrg {
     83  1.3  mrg   create_expand_operand (op, EXPAND_FIXED, x, VOIDmode, false);
     84  1.3  mrg }
     85  1.3  mrg 
     86  1.3  mrg /* Make OP describe an output operand that must have mode MODE.
     87  1.3  mrg    X, if nonnull, is a suggestion for where the output should be stored.
     88  1.3  mrg    It is OK for VALUE to be inconsistent with MODE, although it will just
     89  1.3  mrg    be ignored in that case.  */
     90  1.3  mrg 
     91  1.3  mrg static inline void
     92  1.3  mrg create_output_operand (struct expand_operand *op, rtx x,
     93  1.5  mrg 		       machine_mode mode)
     94  1.3  mrg {
     95  1.3  mrg   create_expand_operand (op, EXPAND_OUTPUT, x, mode, false);
     96  1.3  mrg }
     97  1.3  mrg 
     98  1.3  mrg /* Make OP describe an input operand that must have mode MODE and
     99  1.3  mrg    value VALUE; MODE cannot be VOIDmode.  The backend may request that
    100  1.3  mrg    VALUE be copied into a different kind of rtx before being passed
    101  1.3  mrg    as an operand.  */
    102  1.3  mrg 
    103  1.3  mrg static inline void
    104  1.3  mrg create_input_operand (struct expand_operand *op, rtx value,
    105  1.5  mrg 		      machine_mode mode)
    106  1.3  mrg {
    107  1.3  mrg   create_expand_operand (op, EXPAND_INPUT, value, mode, false);
    108  1.3  mrg }
    109  1.3  mrg 
    110  1.3  mrg /* Like create_input_operand, except that VALUE must first be converted
    111  1.3  mrg    to mode MODE.  UNSIGNED_P says whether VALUE is unsigned.  */
    112  1.3  mrg 
    113  1.3  mrg static inline void
    114  1.3  mrg create_convert_operand_to (struct expand_operand *op, rtx value,
    115  1.5  mrg 			   machine_mode mode, bool unsigned_p)
    116  1.3  mrg {
    117  1.3  mrg   create_expand_operand (op, EXPAND_CONVERT_TO, value, mode, unsigned_p);
    118  1.3  mrg }
    119  1.3  mrg 
    120  1.3  mrg /* Make OP describe an input operand that should have the same value
    121  1.3  mrg    as VALUE, after any mode conversion that the backend might request.
    122  1.3  mrg    If VALUE is a CONST_INT, it should be treated as having mode MODE.
    123  1.3  mrg    UNSIGNED_P says whether VALUE is unsigned.  */
    124  1.3  mrg 
    125  1.3  mrg static inline void
    126  1.3  mrg create_convert_operand_from (struct expand_operand *op, rtx value,
    127  1.5  mrg 			     machine_mode mode, bool unsigned_p)
    128  1.3  mrg {
    129  1.3  mrg   create_expand_operand (op, EXPAND_CONVERT_FROM, value, mode, unsigned_p);
    130  1.3  mrg }
    131  1.3  mrg 
    132  1.3  mrg 
    133  1.3  mrg /* Make OP describe an input Pmode address operand.  VALUE is the value
    134  1.3  mrg    of the address, but it may need to be converted to Pmode first.  */
    135  1.3  mrg 
    136  1.3  mrg static inline void
    137  1.3  mrg create_address_operand (struct expand_operand *op, rtx value)
    138  1.3  mrg {
    139  1.3  mrg   create_expand_operand (op, EXPAND_ADDRESS, value, Pmode, false);
    140  1.3  mrg }
    141  1.3  mrg 
    142  1.3  mrg /* Make OP describe an input operand that has value INTVAL and that has
    143  1.3  mrg    no inherent mode.  This function should only be used for operands that
    144  1.3  mrg    are always expand-time constants.  The backend may request that INTVAL
    145  1.3  mrg    be copied into a different kind of rtx, but it must specify the mode
    146  1.3  mrg    of that rtx if so.  */
    147  1.3  mrg 
    148  1.3  mrg static inline void
    149  1.3  mrg create_integer_operand (struct expand_operand *op, HOST_WIDE_INT intval)
    150  1.3  mrg {
    151  1.3  mrg   create_expand_operand (op, EXPAND_INTEGER, GEN_INT (intval), VOIDmode, false);
    152  1.3  mrg }
    153  1.3  mrg 
    154  1.3  mrg 
    155  1.5  mrg /* Passed to expand_simple_binop and expand_binop to say which options
    156  1.5  mrg    to try to use if the requested operation can't be open-coded on the
    157  1.5  mrg    requisite mode.  Either OPTAB_LIB or OPTAB_LIB_WIDEN says try using
    158  1.5  mrg    a library call.  Either OPTAB_WIDEN or OPTAB_LIB_WIDEN says try
    159  1.5  mrg    using a wider mode.  OPTAB_MUST_WIDEN says try widening and don't
    160  1.5  mrg    try anything else.  */
    161  1.5  mrg 
    162  1.5  mrg enum optab_methods
    163  1.5  mrg {
    164  1.5  mrg   OPTAB_DIRECT,
    165  1.5  mrg   OPTAB_LIB,
    166  1.5  mrg   OPTAB_WIDEN,
    167  1.5  mrg   OPTAB_LIB_WIDEN,
    168  1.5  mrg   OPTAB_MUST_WIDEN
    169  1.5  mrg };
    170  1.5  mrg 
    171  1.5  mrg extern rtx expand_widen_pattern_expr (struct separate_ops *, rtx , rtx , rtx,
    172  1.5  mrg                                       rtx, int);
    173  1.5  mrg extern rtx expand_ternary_op (machine_mode mode, optab ternary_optab,
    174  1.5  mrg 			      rtx op0, rtx op1, rtx op2, rtx target,
    175  1.5  mrg 			      int unsignedp);
    176  1.5  mrg extern rtx simplify_expand_binop (machine_mode mode, optab binoptab,
    177  1.5  mrg 				  rtx op0, rtx op1, rtx target, int unsignedp,
    178  1.5  mrg 				  enum optab_methods methods);
    179  1.5  mrg extern bool force_expand_binop (machine_mode, optab, rtx, rtx, rtx, int,
    180  1.5  mrg 				enum optab_methods);
    181  1.5  mrg 
    182  1.5  mrg /* Generate code for a simple binary or unary operation.  "Simple" in
    183  1.5  mrg    this case means "can be unambiguously described by a (mode, code)
    184  1.5  mrg    pair and mapped to a single optab."  */
    185  1.5  mrg extern rtx expand_simple_binop (machine_mode, enum rtx_code, rtx,
    186  1.5  mrg 				rtx, rtx, int, enum optab_methods);
    187  1.5  mrg 
    188  1.5  mrg /* Expand a binary operation given optab and rtx operands.  */
    189  1.5  mrg extern rtx expand_binop (machine_mode, optab, rtx, rtx, rtx, int,
    190  1.5  mrg 			 enum optab_methods);
    191  1.5  mrg 
    192  1.5  mrg /* Expand a binary operation with both signed and unsigned forms.  */
    193  1.5  mrg extern rtx sign_expand_binop (machine_mode, optab, optab, rtx, rtx,
    194  1.5  mrg 			      rtx, int, enum optab_methods);
    195  1.5  mrg 
    196  1.5  mrg /* Generate code to perform an operation on one operand with two results.  */
    197  1.5  mrg extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
    198  1.5  mrg 
    199  1.5  mrg /* Generate code to perform an operation on two operands with two results.  */
    200  1.5  mrg extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
    201  1.5  mrg 
    202  1.5  mrg /* Generate code to perform an operation on two operands with two
    203  1.5  mrg    results, using a library function.  */
    204  1.5  mrg extern bool expand_twoval_binop_libfunc (optab, rtx, rtx, rtx, rtx,
    205  1.5  mrg 					 enum rtx_code);
    206  1.5  mrg extern rtx expand_simple_unop (machine_mode, enum rtx_code, rtx, rtx,
    207  1.5  mrg 			       int);
    208  1.5  mrg 
    209  1.5  mrg /* Expand a unary arithmetic operation given optab rtx operand.  */
    210  1.5  mrg extern rtx expand_unop (machine_mode, optab, rtx, rtx, int);
    211  1.5  mrg 
    212  1.5  mrg /* Expand the absolute value operation.  */
    213  1.5  mrg extern rtx expand_abs_nojump (machine_mode, rtx, rtx, int);
    214  1.5  mrg extern rtx expand_abs (machine_mode, rtx, rtx, int, int);
    215  1.5  mrg 
    216  1.5  mrg /* Expand the one's complement absolute value operation.  */
    217  1.5  mrg extern rtx expand_one_cmpl_abs_nojump (machine_mode, rtx, rtx);
    218  1.5  mrg 
    219  1.5  mrg /* Expand the copysign operation.  */
    220  1.5  mrg extern rtx expand_copysign (rtx, rtx, rtx);
    221  1.5  mrg /* Generate an instruction with a given INSN_CODE with an output and
    222  1.5  mrg    an input.  */
    223  1.5  mrg extern bool maybe_emit_unop_insn (enum insn_code, rtx, rtx, enum rtx_code);
    224  1.5  mrg extern void emit_unop_insn (enum insn_code, rtx, rtx, enum rtx_code);
    225  1.5  mrg 
    226  1.5  mrg /* Emit code to make a call to a constant function or a library call.  */
    227  1.8  mrg extern void emit_libcall_block (rtx_insn *, rtx, rtx, rtx);
    228  1.5  mrg 
    229  1.5  mrg /* The various uses that a comparison can have; used by can_compare_p:
    230  1.5  mrg    jumps, conditional moves, store flag operations.  */
    231  1.5  mrg enum can_compare_purpose
    232  1.5  mrg {
    233  1.5  mrg   ccp_jump,
    234  1.5  mrg   ccp_cmov,
    235  1.5  mrg   ccp_store_flag
    236  1.5  mrg };
    237  1.5  mrg 
    238  1.5  mrg /* Nonzero if a compare of mode MODE can be done straightforwardly
    239  1.5  mrg    (without splitting it into pieces).  */
    240  1.5  mrg extern int can_compare_p (enum rtx_code, machine_mode,
    241  1.5  mrg 			  enum can_compare_purpose);
    242  1.5  mrg extern rtx prepare_operand (enum insn_code, rtx, int, machine_mode,
    243  1.5  mrg 			    machine_mode, int);
    244  1.5  mrg /* Emit a pair of rtl insns to compare two rtx's and to jump
    245  1.5  mrg    to a label if the comparison is true.  */
    246  1.5  mrg extern void emit_cmp_and_jump_insns (rtx, rtx, enum rtx_code, rtx,
    247  1.5  mrg 				     machine_mode, int, rtx, int prob=-1);
    248  1.5  mrg 
    249  1.5  mrg /* Generate code to indirectly jump to a location given in the rtx LOC.  */
    250  1.5  mrg extern void emit_indirect_jump (rtx);
    251  1.5  mrg 
    252  1.5  mrg #include "insn-config.h"
    253  1.5  mrg 
    254  1.5  mrg #ifndef GCC_INSN_CONFIG_H
    255  1.5  mrg #error "insn-config.h must be included before optabs.h"
    256  1.5  mrg #endif
    257  1.5  mrg 
    258  1.5  mrg /* Emit a conditional move operation.  */
    259  1.5  mrg rtx emit_conditional_move (rtx, enum rtx_code, rtx, rtx, machine_mode,
    260  1.5  mrg 			   rtx, rtx, machine_mode, int);
    261  1.5  mrg 
    262  1.6  mrg /* Emit a conditional negate or bitwise complement operation.  */
    263  1.6  mrg rtx emit_conditional_neg_or_complement (rtx, rtx_code, machine_mode, rtx,
    264  1.6  mrg 					 rtx, rtx);
    265  1.5  mrg 
    266  1.5  mrg rtx emit_conditional_add (rtx, enum rtx_code, rtx, rtx, machine_mode,
    267  1.5  mrg 			  rtx, rtx, machine_mode, int);
    268  1.5  mrg 
    269  1.5  mrg /* Create but don't emit one rtl instruction to perform certain operations.
    270  1.5  mrg    Modes must match; operands must meet the operation's predicates.
    271  1.5  mrg    Likewise for subtraction and for just copying.  */
    272  1.6  mrg extern rtx_insn *gen_add2_insn (rtx, rtx);
    273  1.6  mrg extern rtx_insn *gen_add3_insn (rtx, rtx, rtx);
    274  1.5  mrg extern int have_add2_insn (rtx, rtx);
    275  1.6  mrg extern rtx_insn *gen_addptr3_insn (rtx, rtx, rtx);
    276  1.5  mrg extern int have_addptr3_insn (rtx, rtx, rtx);
    277  1.6  mrg extern rtx_insn *gen_sub2_insn (rtx, rtx);
    278  1.6  mrg extern rtx_insn *gen_sub3_insn (rtx, rtx, rtx);
    279  1.5  mrg extern int have_sub2_insn (rtx, rtx);
    280  1.5  mrg 
    281  1.5  mrg /* Generate the body of an insn to extend Y (with mode MFROM)
    282  1.5  mrg    into X (with mode MTO).  Do zero-extension if UNSIGNEDP is nonzero.  */
    283  1.6  mrg extern rtx_insn *gen_extend_insn (rtx, rtx, machine_mode, machine_mode, int);
    284  1.5  mrg 
    285  1.5  mrg /* Generate code for a FLOAT_EXPR.  */
    286  1.5  mrg extern void expand_float (rtx, rtx, int);
    287  1.5  mrg 
    288  1.5  mrg /* Generate code for a FIX_EXPR.  */
    289  1.5  mrg extern void expand_fix (rtx, rtx, int);
    290  1.5  mrg 
    291  1.5  mrg /* Generate code for a FIXED_CONVERT_EXPR.  */
    292  1.5  mrg extern void expand_fixed_convert (rtx, rtx, int, int);
    293  1.3  mrg 
    294  1.5  mrg /* Generate code for float to integral conversion.  */
    295  1.5  mrg extern bool expand_sfix_optab (rtx, rtx, convert_optab);
    296  1.3  mrg 
    297  1.5  mrg /* Report whether the machine description contains an insn which can
    298  1.5  mrg    perform the operation described by CODE and MODE.  */
    299  1.5  mrg extern int have_insn_for (enum rtx_code, machine_mode);
    300  1.5  mrg 
    301  1.5  mrg /* Generate a conditional trap instruction.  */
    302  1.6  mrg extern rtx_insn *gen_cond_trap (enum rtx_code, rtx, rtx, rtx);
    303  1.5  mrg 
    304  1.5  mrg /* Generate code for VEC_PERM_EXPR.  */
    305  1.5  mrg extern rtx expand_vec_perm (machine_mode, rtx, rtx, rtx, rtx);
    306  1.5  mrg 
    307  1.6  mrg /* Generate code for vector comparison.  */
    308  1.6  mrg extern rtx expand_vec_cmp_expr (tree, tree, rtx);
    309  1.5  mrg 
    310  1.5  mrg /* Generate code for VEC_COND_EXPR.  */
    311  1.5  mrg extern rtx expand_vec_cond_expr (tree, tree, tree, tree, rtx);
    312  1.5  mrg 
    313  1.5  mrg /* Generate code for MULT_HIGHPART_EXPR.  */
    314  1.5  mrg extern rtx expand_mult_highpart (machine_mode, rtx, rtx, rtx, bool);
    315  1.5  mrg 
    316  1.5  mrg extern rtx expand_sync_lock_test_and_set (rtx, rtx, rtx);
    317  1.5  mrg extern rtx expand_atomic_test_and_set (rtx, rtx, enum memmodel);
    318  1.5  mrg extern rtx expand_atomic_exchange (rtx, rtx, rtx, enum memmodel);
    319  1.5  mrg extern bool expand_atomic_compare_and_swap (rtx *, rtx *, rtx, rtx, rtx, bool,
    320  1.5  mrg 					    enum memmodel, enum memmodel);
    321  1.5  mrg /* Generate memory barriers.  */
    322  1.5  mrg extern void expand_mem_thread_fence (enum memmodel);
    323  1.5  mrg extern void expand_mem_signal_fence (enum memmodel);
    324  1.5  mrg 
    325  1.5  mrg rtx expand_atomic_load (rtx, rtx, enum memmodel);
    326  1.5  mrg rtx expand_atomic_store (rtx, rtx, enum memmodel, bool);
    327  1.5  mrg rtx expand_atomic_fetch_op (rtx, rtx, rtx, enum rtx_code, enum memmodel,
    328  1.5  mrg 			      bool);
    329  1.5  mrg 
    330  1.5  mrg extern bool insn_operand_matches (enum insn_code icode, unsigned int opno,
    331  1.5  mrg 				  rtx operand);
    332  1.5  mrg extern bool valid_multiword_target_p (rtx);
    333  1.5  mrg extern void create_convert_operand_from_type (struct expand_operand *op,
    334  1.5  mrg 					      rtx value, tree type);
    335  1.5  mrg extern bool maybe_legitimize_operands (enum insn_code icode,
    336  1.5  mrg 				       unsigned int opno, unsigned int nops,
    337  1.5  mrg 				       struct expand_operand *ops);
    338  1.6  mrg extern rtx_insn *maybe_gen_insn (enum insn_code icode, unsigned int nops,
    339  1.6  mrg 				 struct expand_operand *ops);
    340  1.5  mrg extern bool maybe_expand_insn (enum insn_code icode, unsigned int nops,
    341  1.5  mrg 			       struct expand_operand *ops);
    342  1.5  mrg extern bool maybe_expand_jump_insn (enum insn_code icode, unsigned int nops,
    343  1.5  mrg 				    struct expand_operand *ops);
    344  1.5  mrg extern void expand_insn (enum insn_code icode, unsigned int nops,
    345  1.5  mrg 			 struct expand_operand *ops);
    346  1.5  mrg extern void expand_jump_insn (enum insn_code icode, unsigned int nops,
    347  1.5  mrg 			      struct expand_operand *ops);
    348  1.5  mrg 
    349  1.5  mrg extern enum rtx_code get_rtx_code (enum tree_code tcode, bool unsignedp);
    350  1.3  mrg 
    351  1.1  mrg #endif /* GCC_OPTABS_H */
    352