1;; Operand and operator predicates for the GCC CRIS port. 2;; Copyright (C) 2005-2018 Free Software Foundation, Inc. 3 4;; This file is part of GCC. 5;; 6;; GCC is free software; you can redistribute it and/or modify 7;; it under the terms of the GNU General Public License as published by 8;; the Free Software Foundation; either version 3, or (at your option) 9;; any later version. 10;; 11;; GCC is distributed in the hope that it will be useful, 12;; but WITHOUT ANY WARRANTY; without even the implied warranty of 13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14;; GNU General Public License for more details. 15;; 16;; You should have received a copy of the GNU General Public License 17;; along with GCC; see the file COPYING3. If not see 18;; <http://www.gnu.org/licenses/>. 19 20 21;; Operator predicates. 22 23(define_predicate "cris_orthogonal_operator" 24 (match_code "plus, minus, ior, and, umin")) 25 26(define_predicate "cris_commutative_orth_op" 27 (match_code "plus, ior, and, umin")) 28 29;; By the name, you might think we should include MULT. We don't because 30;; it doesn't accept the same addressing modes as the others (only 31;; registers) and there's also the problem of handling TARGET_MUL_BUG. 32 33(define_predicate "cris_operand_extend_operator" 34 (match_code "plus, minus, umin")) 35 36(define_predicate "cris_additive_operand_extend_operator" 37 (match_code "plus, minus")) 38 39(define_predicate "cris_extend_operator" 40 (match_code "zero_extend, sign_extend")) 41 42(define_predicate "cris_plus_or_bound_operator" 43 (match_code "plus, umin")) 44 45;; Used as an operator to get a handle on a already-known-valid MEM rtx:es 46;; (no need to validate the address), where some address expression parts 47;; have their own match_operand. 48 49(define_predicate "cris_mem_op" 50 (match_code "mem")) 51 52(define_predicate "cris_load_multiple_op" 53 (and (match_code "parallel") 54 (match_test "cris_movem_load_rest_p (op, 0)"))) 55 56(define_predicate "cris_store_multiple_op" 57 (and (match_code "parallel") 58 (match_test "cris_store_multiple_op_p (op)"))) 59 60 61;; Operand helper predicates. 62 63(define_predicate "cris_bdap_const_operand" 64 (and (match_code "label_ref, symbol_ref, const_int, const_double, const") 65 (ior (not (match_test "flag_pic")) 66 (match_test "cris_valid_pic_const (op, true)")))) 67 68(define_predicate "cris_simple_address_operand" 69 (ior (match_operand:SI 0 "register_operand") 70 (and (match_code "post_inc") 71 (match_test "register_operand (XEXP (op, 0), Pmode)")))) 72 73(define_predicate "cris_simple_operand" 74 (ior (match_operand 0 "register_operand") 75 (and (match_code "mem") 76 (match_test "cris_simple_address_operand (XEXP (op, 0), 77 Pmode)")))) 78 79(define_predicate "cris_nonsp_register_operand" 80 (and (match_operand 0 "register_operand") 81 (match_test "op != stack_pointer_rtx"))) 82 83;; The caller needs to use :SI. 84(define_predicate "cris_bdap_sign_extend_operand" 85; Disabled until <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01376.html> 86; or <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00940.html> is committed. 87 (match_test "0")) 88; (and (match_code "sign_extend") 89; (and (match_test "MEM_P (XEXP (op, 0))") 90; (match_test "cris_simple_address_operand (XEXP (XEXP (op, 0), 0), 91; Pmode)")))) 92 93;; FIXME: Should not have to test for 1. 94(define_predicate "cris_scale_int_operand" 95 (and (match_code "const_int") 96 (ior (ior (match_test "op == GEN_INT (4)") 97 (match_test "op == const2_rtx")) 98 (match_test "op == const1_rtx")))) 99 100;; FIXME: Should be able to assume (reg int). 101(define_predicate "cris_biap_mult_operand" 102 (and (match_code "mult") 103 (ior (and (match_test "register_operand (XEXP (op, 0), Pmode)") 104 (match_test "cris_scale_int_operand (XEXP (op, 1), Pmode)")) 105 (and (match_test "cris_scale_int_operand (XEXP (op, 0), Pmode)") 106 (match_test "register_operand (XEXP (op, 1), Pmode)"))))) 107 108 109;; Operand predicates. 110 111;; This checks a part of an address, the one that is not a plain register 112;; for an addressing mode using BDAP. 113;; Allowed operands are either: 114;; a) a register 115;; b) a CONST operand (but not a symbol when generating PIC) 116;; c) a [r] or [r+] in SImode, or sign-extend from HI or QI. 117 118(define_predicate "cris_bdap_operand" 119 (ior (match_operand 0 "cris_bdap_const_operand") 120 (ior (match_operand:SI 0 "cris_simple_operand") 121 (match_operand:SI 0 "cris_bdap_sign_extend_operand")))) 122 123;; This is similar to cris_bdap_operand: 124;; It checks a part of an address, the one that is not a plain register 125;; for an addressing mode using BDAP or BIAP. 126;; Allowed operands are either: 127;; a) a register 128;; b) a CONST operand (but not a symbol when generating PIC) 129;; c) a mult of (1, 2 or 4) and a register 130;; d) a [r] or [r+] in SImode, or sign-extend from HI or QI. */ 131 132(define_predicate "cris_bdap_biap_operand" 133 (ior (match_operand 0 "cris_bdap_operand") 134 (match_operand 0 "cris_biap_mult_operand"))) 135 136;; Since with -fPIC, not all symbols are valid PIC symbols or indeed 137;; general_operands, we have to have a predicate that matches it for the 138;; "movsi" expander. 139;; FIXME: Can s/special_// when PR 20413 is fixed. 140 141(define_special_predicate "cris_general_operand_or_symbol" 142 (ior (match_operand 0 "general_operand") 143 (and (match_code "const, symbol_ref, label_ref") 144 ; The following test is actually just an assertion. 145 (match_test "cris_symbol_type_of (op) != cris_no_symbol")))) 146 147;; A predicate for the anon movsi expansion, one that fits a PCREL 148;; operand as well as general_operand. 149 150(define_special_predicate "cris_general_operand_or_pic_source" 151 (ior (match_operand 0 "general_operand") 152 (and (match_test "flag_pic") 153 (match_test "cris_valid_pic_const (op, false)")))) 154 155;; Since a PLT symbol is not a general_operand, we have to have a 156;; predicate that matches it when we need it. We use this in the expanded 157;; "call" and "call_value" anonymous patterns. 158 159(define_predicate "cris_nonmemory_operand_or_callable_symbol" 160 (ior (match_operand 0 "nonmemory_operand") 161 (and (match_code "const") 162 (and 163 (match_test "GET_CODE (XEXP (op, 0)) == UNSPEC") 164 (ior 165 (match_test "XINT (XEXP (op, 0), 1) == CRIS_UNSPEC_PLT_PCREL") 166 (match_test "XINT (XEXP (op, 0), 1) == CRIS_UNSPEC_PCREL")))))) 167 168;; This matches a (MEM (general_operand)) or 169;; (MEM (cris_general_operand_or_symbol)). The second one isn't a valid 170;; memory_operand, so we need this predicate to recognize call 171;; destinations before we change them to a PLT operand (by wrapping in 172;; UNSPEC CRIS_UNSPEC_PLT). 173 174(define_predicate "cris_mem_call_operand" 175 (and (match_code "mem") 176 (ior (match_operand 0 "memory_operand") 177 (match_test "cris_general_operand_or_symbol (XEXP (op, 0), 178 Pmode)")))) 179 180;; A marker for the call-insn: (const_int 0) for a call to a 181;; hidden or static function and non-pic and 182;; pic_offset_table_rtx for a call that *might* go through the 183;; PLT. 184 185(define_predicate "cris_call_type_marker" 186 (ior (and (match_operand 0 "const_int_operand") 187 (match_test "op == const0_rtx")) 188 (and (and (match_operand 0 "register_operand") 189 (match_test "op == pic_offset_table_rtx")) 190 (match_test "flag_pic != 0")))) 191