1;; Predicate definitions for Tilera TILE-Gx. 2;; Copyright (C) 2011-2013 Free Software Foundation, Inc. 3;; Contributed by Walter Lee (walt@tilera.com) 4;; 5;; This file is part of GCC. 6;; 7;; GCC is free software; you can redistribute it and/or modify it 8;; under the terms of the GNU General Public License as published 9;; by the Free Software Foundation; either version 3, or (at your 10;; option) any later version. 11;; 12;; GCC is distributed in the hope that it will be useful, but WITHOUT 13;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15;; License for more details. 16;; 17;; You should have received a copy of the GNU General Public License 18;; along with GCC; see the file COPYING3. If not see 19;; <http://www.gnu.org/licenses/>. 20 21;; Return true if OP is the zero constant for MODE. 22(define_predicate "const_zero_operand" 23 (and (match_code "const_int,const_double,const_vector") 24 (match_test "op == CONST0_RTX (mode)"))) 25 26;; Returns true if OP is either the constant zero or a register. 27(define_predicate "reg_or_0_operand" 28 (and (ior (match_operand 0 "register_operand") 29 (match_operand 0 "const_zero_operand")) 30 (match_test "GET_MODE_SIZE (mode) <= UNITS_PER_WORD"))) 31 32; Return 1 if OP is a valid Pmode pointer. 33(define_predicate "pointer_operand" 34 (and (match_operand 0 "address_operand") 35 (ior (match_operand 0 "pmode_register_operand") 36 (match_operand 0 "const_zero_operand")))) 37 38; Return 1 if OP is a network register identifier. 39(define_predicate "netreg_operand" 40 (and (match_code "const_int") 41 (match_test "IN_RANGE (INTVAL (op), 0, 5)"))) 42 43; Return 1 if OP is an unsigned 6-bit constant. 44(define_predicate "u6bit_cint_operand" 45 (and (match_code "const_int") 46 (match_test "INTVAL (op) == (INTVAL (op) & 0x3F)"))) 47 48;; Return 1 if OP is an unsigned 16-bit constant. 49(define_predicate "u16bit_cint_operand" 50 (and (match_code "const_int") 51 (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 16)"))) 52 53;; Return 1 if OP is a signed 8-bit constant. 54(define_predicate "s8bit_cint_operand" 55 (and (match_code "const_int") 56 (match_test "satisfies_constraint_I (op)"))) 57 58;; Return 1 if OP is a signed 16-bit constant. 59(define_predicate "s16bit_cint_operand" 60 (and (match_code "const_int") 61 (match_test "satisfies_constraint_J (op)"))) 62 63;; Return 1 if OP is an unsigned 14-bit constant. 64(define_predicate "u14bit_cint_operand" 65 (and (match_code "const_int") 66 (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 14)"))) 67 68;; Return 1 if OP is a constant or any register. 69(define_predicate "reg_or_cint_operand" 70 (ior (match_operand 0 "register_operand") 71 (match_operand 0 "const_int_operand"))) 72 73;; Returns 1 if OP is a "last" unspec wrapper for a symbol, got, or 74;; tls reference. 75(define_predicate "const_last_symbolic_operand" 76 (and (match_code "const") 77 (match_test "GET_CODE (XEXP (op,0)) == UNSPEC") 78 (ior (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_LAST") 79 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST") 80 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2_LAST") 81 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_PCREL") 82 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2_LAST_PCREL") 83 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_LAST_GOT") 84 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_GOT") 85 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_TLS_GD") 86 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_TLS_IE") 87 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_TLS_LE") 88 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_PLT_PCREL") 89 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2_LAST_PLT_PCREL")))) 90 91;; Returns 1 if OP is an unspec wrapper for a symbol, got, or tls 92;; reference. 93(define_predicate "const_symbolic_operand" 94 (and (match_code "const") 95 (match_test "GET_CODE (XEXP (op,0)) == UNSPEC") 96 (ior (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0") 97 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1") 98 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2") 99 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW3") 100 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_PCREL") 101 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_PCREL") 102 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_GOT") 103 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_TLS_GD") 104 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_TLS_IE") 105 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_TLS_LE") 106 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_PLT_PCREL") 107 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_PLT_PCREL")))) 108 109;; Return 1 if OP is a 8-element vector constant with identical signed 110;; 8-bit elements or any register. 111(define_predicate "reg_or_v8s8bit_operand" 112 (ior (match_operand 0 "register_operand") 113 (and (match_code "const_vector") 114 (match_test "CONST_VECTOR_NUNITS (op) == 8 115 && satisfies_constraint_I (CONST_VECTOR_ELT (op, 0)) 116 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 1) 117 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 2) 118 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 3) 119 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 4) 120 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 5) 121 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 6) 122 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 7)")))) 123 124;; Return 1 if OP is a 4-element vector constant with identical signed 125;; 8-bit elements or any register. 126(define_predicate "reg_or_v4s8bit_operand" 127 (ior (match_operand 0 "register_operand") 128 (and (match_code "const_vector") 129 (match_test "CONST_VECTOR_NUNITS (op) == 4 130 && satisfies_constraint_I (CONST_VECTOR_ELT (op, 0)) 131 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 1) 132 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 2) 133 && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 3)")))) 134 135;; Return 1 if the operand is a valid second operand to an add insn. 136(define_predicate "add_operand" 137 (if_then_else (match_code "const_int") 138 (match_test "satisfies_constraint_J (op)") 139 (ior (match_operand 0 "register_operand") 140 (match_operand 0 "const_last_symbolic_operand")))) 141 142;; Return 1 if the operand is a register or signed 8-bit immediate operand. 143(define_predicate "reg_or_s8bit_operand" 144 (if_then_else (match_code "const_int") 145 (match_test "satisfies_constraint_I (op)") 146 (match_operand 0 "register_operand"))) 147 148;; Return 1 if the operand is a register or unsigned 5-bit immediate operand. 149(define_predicate "reg_or_u5bit_operand" 150 (if_then_else (match_code "const_int") 151 (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)") 152 (match_operand 0 "register_operand"))) 153 154;; Return 1 if the operand is a register or unsigned 6-bit immediate operand. 155(define_predicate "reg_or_u6bit_operand" 156 (if_then_else (match_code "const_int") 157 (match_test "INTVAL (op) == (INTVAL (op) & 0x3F)") 158 (match_operand 0 "register_operand"))) 159 160;; Return 1 for an operand suitable for ANDing with a register. 161(define_predicate "and_operand" 162 (if_then_else (match_code "const_int") 163 (match_test "satisfies_constraint_I (op) || satisfies_constraint_M (op)") 164 (match_operand 0 "register_operand"))) 165 166; Return 1 if the operand is 2, 4 or 8. 167(define_predicate "cint_248_operand" 168 (and (match_code "const_int") 169 (match_test 170 "INTVAL (op) == 2 || INTVAL (op) == 4 || INTVAL (op) == 8"))) 171 172;; Return true if OP is a TLS symbolic operand. 173(define_predicate "tls_symbolic_operand" 174 (and (match_code "symbol_ref") 175 (match_test "SYMBOL_REF_TLS_MODEL (op) != TLS_MODEL_NONE"))) 176 177;; Return true if OP is a symbolic operand for the TLS Global Dynamic model. 178(define_predicate "tls_gd_symbolic_operand" 179 (and (match_code "symbol_ref") 180 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC"))) 181 182;; Return true if OP is a symbolic operand for the TLS Local Dynamic model. 183(define_predicate "tls_ld_symbolic_operand" 184 (and (match_code "symbol_ref") 185 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC"))) 186 187;; Return true if OP is a symbolic operand that can be used for the 188;; TLS Initial Exec model. 189(define_predicate "tls_ie_symbolic_operand" 190 (and (match_code "symbol_ref") 191 (ior (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC") 192 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))) 193 194;; Return true if OP is a symbolic operand for the TLS Local Exec model. 195(define_predicate "tls_le_symbolic_operand" 196 (and (match_code "symbol_ref") 197 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))) 198 199;; Returns true if OP is any general operand except for an 200;; auto-incrementing address operand. 201(define_predicate "nonautoinc_operand" 202 (and (match_operand 0 "general_operand") 203 (not (ior (match_code "pre_dec") (match_code "pre_inc") 204 (match_code "post_dec") (match_code "post_inc") 205 (match_code "post_modify") (match_code "pre_modify"))))) 206 207;; Returns true if OP is a non-auto-incrementing memory operand. 208(define_predicate "nonautoincmem_operand" 209 (match_operand 0 "memory_operand") 210{ 211 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0))); 212}) 213 214;; Returns true if OP is a non-auto-incrementing memory, general 215;; operand. 216(define_predicate "nonautoincmem_general_operand" 217 (match_operand 0 "general_operand") 218{ 219 if (memory_operand (op, mode)) 220 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0))); 221 else 222 return true; 223}) 224 225;; Returns true if OP is a non-auto-incrementing memory, non-immediate 226;; operand. 227(define_predicate "nonautoincmem_nonimmediate_operand" 228 (match_operand 0 "nonimmediate_operand") 229{ 230 if (memory_operand (op, mode)) 231 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0))); 232 else 233 return true; 234}) 235 236;; Return true if OP is a valid operand for the source of a move insn. 237(define_predicate "move_operand" 238 (match_operand 0 "general_operand") 239{ 240 /* If both modes are non-void they must be the same. */ 241 if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op)) 242 return false; 243 244 switch (GET_CODE (op)) 245 { 246 case CONST_INT: 247 return (satisfies_constraint_J (op) 248 || satisfies_constraint_K (op) 249 || (mode == DImode && 250 (satisfies_constraint_N (op) 251 || satisfies_constraint_P (op)))); 252 253 case MEM: 254 return memory_address_p (mode, XEXP (op, 0)); 255 256 case CONST: 257 return const_last_symbolic_operand (op, mode); 258 259 default: 260 return register_operand (op, mode); 261 } 262}) 263 264;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref, 265;; possibly with an offset. 266(define_predicate "symbolic_operand" 267 (ior (match_code "symbol_ref,label_ref") 268 (and (match_code "const") 269 (match_test "GET_CODE (XEXP (op,0)) == PLUS 270 && (GET_CODE (XEXP (XEXP (op,0), 0)) == SYMBOL_REF 271 || GET_CODE (XEXP (XEXP (op,0), 0)) == LABEL_REF) 272 && CONST_INT_P (XEXP (XEXP (op,0), 1))")))) 273 274;; Return 1 for an unsigned 16 bit or a const symbolc operand. 275(define_predicate "u16bit_or_const_symbolic_operand" 276 (ior (match_operand 0 "u16bit_cint_operand") 277 (match_operand 0 "const_symbolic_operand"))) 278 279;; Return true if OP is an address suitable for a call insn. 280;; Call insn on TILE can take a PC-relative constant address 281;; or any regular memory address. 282(define_predicate "call_address_operand" 283 (ior (match_operand 0 "symbolic_operand") 284 (match_test "memory_address_p (Pmode, op)"))) 285 286;; Return true if OP is an operand suitable for a call insn. 287(define_predicate "call_operand" 288 (and (match_code "mem") 289 (match_test "call_address_operand (XEXP (op, 0), mode)"))) 290 291;; Return 1 if OP is a signed comparison operation. 292;; We can use these directly in compares against zero. 293(define_predicate "signed_comparison_operator" 294 (match_code "eq,ne,le,lt,ge,gt")) 295 296;; Return 1 if OP is a equal or not-equal operation. 297(define_predicate "eqne_operator" 298 (match_code "eq,ne")) 299