1 ;; Predicate definitions for the Blackfin.
3 ;; This file is part of GCC.
5 ;; GCC is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; GCC is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with GCC; see the file COPYING. If not, write to
17 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
18 ;; Boston, MA 02110-1301, USA.
20 ;; Return nonzero iff OP is one of the integer constants 1 or 2.
21 (define_predicate "pos_scale_operand"
22 (and (match_code "const_int")
23 (match_test "INTVAL (op) == 1 || INTVAL (op) == 2")))
25 ;; Return nonzero iff OP is one of the integer constants 2 or 4.
26 (define_predicate "scale_by_operand"
27 (and (match_code "const_int")
28 (match_test "INTVAL (op) == 2 || INTVAL (op) == 4")))
30 ;; Return nonzero if OP is a constant that consists of two parts; lower
31 ;; bits all zero and upper bits all ones. In this case, we can perform
32 ;; an AND operation with a sequence of two shifts. Don't return nonzero
33 ;; if the constant would be cheap to load.
34 (define_predicate "highbits_operand"
35 (and (match_code "const_int")
36 (match_test "log2constp (-INTVAL (op)) && !CONST_7BIT_IMM_P (INTVAL (op))")))
38 ;; Return nonzero if OP is suitable as a right-hand side operand for an
40 (define_predicate "rhs_andsi3_operand"
41 (ior (match_operand 0 "register_operand")
42 (and (match_code "const_int")
43 (match_test "log2constp (~INTVAL (op)) || INTVAL (op) == 255 || INTVAL (op) == 65535"))))
45 ;; Return nonzero if OP is a register or a constant with exactly one bit
47 (define_predicate "regorlog2_operand"
48 (ior (match_operand 0 "register_operand")
49 (and (match_code "const_int")
50 (match_test "log2constp (INTVAL (op))"))))
52 ;; Return nonzero if OP is a register or an integer constant.
53 (define_predicate "reg_or_const_int_operand"
54 (ior (match_operand 0 "register_operand")
55 (match_code "const_int")))
57 ;; Like register_operand, but make sure that hard regs have a valid mode.
58 (define_predicate "valid_reg_operand"
59 (match_operand 0 "register_operand")
61 if (GET_CODE (op) == SUBREG)
63 if (REGNO (op) < FIRST_PSEUDO_REGISTER)
64 return HARD_REGNO_MODE_OK (REGNO (op), mode);
68 ;; Return nonzero if OP is the CC register.
69 (define_predicate "cc_operand"
70 (and (match_code "reg")
71 (match_test "REGNO (op) == REG_CC && GET_MODE (op) == BImode")))
73 ;; Return nonzero if OP is a register or a 7 bit signed constant.
74 (define_predicate "reg_or_7bit_operand"
75 (ior (match_operand 0 "register_operand")
76 (and (match_code "const_int")
77 (match_test "CONST_7BIT_IMM_P (INTVAL (op))"))))
79 ;; Used for secondary reloads, this function returns 1 if OP is of the
80 ;; form (plus (fp) (const_int)).
81 (define_predicate "fp_plus_const_operand"
89 && (REGNO (op1) == FRAME_POINTER_REGNUM
90 || REGNO (op1) == STACK_POINTER_REGNUM)
91 && GET_CODE (op2) == CONST_INT);
94 ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
95 ;; possibly with an offset.
96 (define_predicate "symbolic_operand"
97 (ior (match_code "symbol_ref,label_ref")
98 (and (match_code "const")
99 (match_test "GET_CODE (XEXP (op,0)) == PLUS
100 && (GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
101 || GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF)
102 && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT"))))
104 ;; Returns 1 if OP is a plain constant or matched by symbolic_operand.
105 (define_predicate "symbolic_or_const_operand"
106 (ior (match_code "const_int,const_double")
107 (match_operand 0 "symbolic_operand")))
109 ;; Returns 1 if OP is a SYMBOL_REF.
110 (define_predicate "symbol_ref_operand"
111 (match_code "symbol_ref"))
113 ;; True for any non-virtual or eliminable register. Used in places where
114 ;; instantiation of such a register may cause the pattern to not be recognized.
115 (define_predicate "register_no_elim_operand"
116 (match_operand 0 "register_operand")
118 if (GET_CODE (op) == SUBREG)
119 op = SUBREG_REG (op);
120 return !(op == arg_pointer_rtx
121 || op == frame_pointer_rtx
122 || (REGNO (op) >= FIRST_PSEUDO_REGISTER
123 && REGNO (op) <= LAST_VIRTUAL_REGISTER));
126 ;; Test for an operator valid in a conditional branch
127 (define_predicate "bfin_cbranch_operator"
128 (match_code "eq,ne"))