1/* Declarations for interface to insn recognizer and insn-output.c. 2 Copyright (C) 1987, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 3 Free Software Foundation, Inc. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify it under 8the terms of the GNU General Public License as published by the Free 9Software Foundation; either version 2, or (at your option) any later 10version. 11 12GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13WARRANTY; without even the implied warranty of MERCHANTABILITY or 14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15for more details. 16 17You should have received a copy of the GNU General Public License 18along with GCC; see the file COPYING. If not, write to the Free 19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 2002110-1301, USA. */ 21 22/* Random number that should be large enough for all purposes. */ 23#define MAX_RECOG_ALTERNATIVES 30 24 25/* Types of operands. */ 26enum op_type { 27 OP_IN, 28 OP_OUT, 29 OP_INOUT 30}; 31 32struct operand_alternative 33{ 34 /* Pointer to the beginning of the constraint string for this alternative, 35 for easier access by alternative number. */ 36 const char *constraint; 37 38 /* The register class valid for this alternative (possibly NO_REGS). */ 39 enum reg_class cl; 40 41 /* "Badness" of this alternative, computed from number of '?' and '!' 42 characters in the constraint string. */ 43 unsigned int reject; 44 45 /* -1 if no matching constraint was found, or an operand number. */ 46 int matches; 47 /* The same information, but reversed: -1 if this operand is not 48 matched by any other, or the operand number of the operand that 49 matches this one. */ 50 int matched; 51 52 /* Nonzero if '&' was found in the constraint string. */ 53 unsigned int earlyclobber:1; 54 /* Nonzero if 'm' was found in the constraint string. */ 55 unsigned int memory_ok:1; 56 /* Nonzero if 'o' was found in the constraint string. */ 57 unsigned int offmem_ok:1; 58 /* Nonzero if 'V' was found in the constraint string. */ 59 unsigned int nonoffmem_ok:1; 60 /* Nonzero if '<' was found in the constraint string. */ 61 unsigned int decmem_ok:1; 62 /* Nonzero if '>' was found in the constraint string. */ 63 unsigned int incmem_ok:1; 64 /* Nonzero if 'p' was found in the constraint string. */ 65 unsigned int is_address:1; 66 /* Nonzero if 'X' was found in the constraint string, or if the constraint 67 string for this alternative was empty. */ 68 unsigned int anything_ok:1; 69}; 70 71 72extern void init_recog (void); 73extern void init_recog_no_volatile (void); 74extern int check_asm_operands (rtx); 75extern int asm_operand_ok (rtx, const char *); 76extern int validate_change (rtx, rtx *, rtx, int); 77extern int insn_invalid_p (rtx); 78extern int verify_changes (int); 79extern void confirm_change_group (void); 80extern int apply_change_group (void); 81extern int num_validated_changes (void); 82extern void cancel_changes (int); 83extern int constrain_operands (int); 84extern int constrain_operands_cached (int); 85extern int memory_address_p (enum machine_mode, rtx); 86extern int strict_memory_address_p (enum machine_mode, rtx); 87extern int validate_replace_rtx (rtx, rtx, rtx); 88extern void validate_replace_rtx_group (rtx, rtx, rtx); 89extern void validate_replace_src_group (rtx, rtx, rtx); 90extern bool validate_simplify_insn (rtx insn); 91extern int num_changes_pending (void); 92#ifdef HAVE_cc0 93extern int next_insn_tests_no_inequality (rtx); 94#endif 95extern int reg_fits_class_p (rtx, enum reg_class, int, enum machine_mode); 96extern rtx *find_single_use (rtx, rtx, rtx *); 97 98extern int offsettable_memref_p (rtx); 99extern int offsettable_nonstrict_memref_p (rtx); 100extern int offsettable_address_p (int, enum machine_mode, rtx); 101extern int mode_dependent_address_p (rtx); 102 103extern int recog (rtx, rtx, int *); 104#ifndef GENERATOR_FILE 105static inline int recog_memoized (rtx insn); 106#endif 107extern void add_clobbers (rtx, int); 108extern int added_clobbers_hard_reg_p (int); 109extern void insn_extract (rtx); 110extern void extract_insn (rtx); 111extern void extract_constrain_insn_cached (rtx); 112extern void extract_insn_cached (rtx); 113extern void preprocess_constraints (void); 114extern rtx peep2_next_insn (int); 115extern int peep2_regno_dead_p (int, int); 116extern int peep2_reg_dead_p (int, rtx); 117#ifdef CLEAR_HARD_REG_SET 118extern rtx peep2_find_free_register (int, int, const char *, 119 enum machine_mode, HARD_REG_SET *); 120#endif 121extern rtx peephole2_insns (rtx, rtx, int *); 122 123extern int store_data_bypass_p (rtx, rtx); 124extern int if_test_bypass_p (rtx, rtx); 125 126#ifndef GENERATOR_FILE 127/* Try recognizing the instruction INSN, 128 and return the code number that results. 129 Remember the code so that repeated calls do not 130 need to spend the time for actual rerecognition. 131 132 This function is the normal interface to instruction recognition. 133 The automatically-generated function `recog' is normally called 134 through this one. */ 135 136static inline int 137recog_memoized (rtx insn) 138{ 139 if (INSN_CODE (insn) < 0) 140 INSN_CODE (insn) = recog (PATTERN (insn), insn, 0); 141 return INSN_CODE (insn); 142} 143#endif 144 145/* Nonzero means volatile operands are recognized. */ 146extern int volatile_ok; 147 148/* Set by constrain_operands to the number of the alternative that 149 matched. */ 150extern int which_alternative; 151 152/* The following vectors hold the results from insn_extract. */ 153 154struct recog_data 155{ 156 /* It is very tempting to make the 5 operand related arrays into a 157 structure and index on that. However, to be source compatible 158 with all of the existing md file insn constraints and output 159 templates, we need `operand' as a flat array. Without that 160 member, making an array for the rest seems pointless. */ 161 162 /* Gives value of operand N. */ 163 rtx operand[MAX_RECOG_OPERANDS]; 164 165 /* Gives location where operand N was found. */ 166 rtx *operand_loc[MAX_RECOG_OPERANDS]; 167 168 /* Gives the constraint string for operand N. */ 169 const char *constraints[MAX_RECOG_OPERANDS]; 170 171 /* Gives the mode of operand N. */ 172 enum machine_mode operand_mode[MAX_RECOG_OPERANDS]; 173 174 /* Gives the type (in, out, inout) for operand N. */ 175 enum op_type operand_type[MAX_RECOG_OPERANDS]; 176 177 /* Gives location where the Nth duplicate-appearance of an operand 178 was found. This is something that matched MATCH_DUP. */ 179 rtx *dup_loc[MAX_DUP_OPERANDS]; 180 181 /* Gives the operand number that was duplicated in the Nth 182 duplicate-appearance of an operand. */ 183 char dup_num[MAX_DUP_OPERANDS]; 184 185 /* ??? Note that these are `char' instead of `unsigned char' to (try to) 186 avoid certain lossage from K&R C, wherein `unsigned char' default 187 promotes to `unsigned int' instead of `int' as in ISO C. As of 1999, 188 the most common places to bootstrap from K&R C are SunOS and HPUX, 189 both of which have signed characters by default. The only other 190 supported natives that have both K&R C and unsigned characters are 191 ROMP and Irix 3, and neither have been seen for a while, but do 192 continue to consider unsignedness when performing arithmetic inside 193 a comparison. */ 194 195 /* The number of operands of the insn. */ 196 char n_operands; 197 198 /* The number of MATCH_DUPs in the insn. */ 199 char n_dups; 200 201 /* The number of alternatives in the constraints for the insn. */ 202 char n_alternatives; 203 204 /* In case we are caching, hold insn data was generated for. */ 205 rtx insn; 206}; 207 208extern struct recog_data recog_data; 209 210/* Contains a vector of operand_alternative structures for every operand. 211 Set up by preprocess_constraints. */ 212extern struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES]; 213 214/* A table defined in insn-output.c that give information about 215 each insn-code value. */ 216 217typedef int (*insn_operand_predicate_fn) (rtx, enum machine_mode); 218typedef const char * (*insn_output_fn) (rtx *, rtx); 219typedef rtx (*insn_gen_fn) (rtx, ...); 220 221struct insn_operand_data 222{ 223 const insn_operand_predicate_fn predicate; 224 225 const char *const constraint; 226 227 ENUM_BITFIELD(machine_mode) const mode : 16; 228 229 const char strict_low; 230 231 const char eliminable; 232}; 233 234/* Legal values for insn_data.output_format. Indicate what type of data 235 is stored in insn_data.output. */ 236#define INSN_OUTPUT_FORMAT_NONE 0 /* abort */ 237#define INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * */ 238#define INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * */ 239#define INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) */ 240 241struct insn_data 242{ 243 const char *const name; 244#if HAVE_DESIGNATED_INITIALIZERS 245 union { 246 const char *single; 247 const char *const *multi; 248 insn_output_fn function; 249 } output; 250#else 251 struct { 252 const char *single; 253 const char *const *multi; 254 insn_output_fn function; 255 } output; 256#endif 257 const insn_gen_fn genfun; 258 const struct insn_operand_data *const operand; 259 260 const char n_operands; 261 const char n_dups; 262 const char n_alternatives; 263 const char output_format; 264}; 265 266extern const struct insn_data insn_data[]; 267extern int peep2_current_count; 268