OSDN Git Service

* varasm.c (assemble_variable): Fix format specifier thinko.
[pf3gnuchains/gcc-fork.git] / gcc / config / bfin / predicates.md
1 ;; Predicate definitions for the Blackfin.
2 ;;
3 ;; This file is part of GCC.
4 ;;
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)
8 ;; any later version.
9 ;;
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.
14 ;;
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.
19
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")))
24
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")))
29
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))")))
37
38 ;; Return nonzero if OP is suitable as a right-hand side operand for an
39 ;; andsi3 operation.
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"))))
44
45 ;; Return nonzero if OP is a register or a constant with exactly one bit
46 ;; set.
47 (define_predicate "regorlog2_operand"
48   (ior (match_operand 0 "register_operand")
49        (and (match_code "const_int")
50             (match_test "log2constp (INTVAL (op))"))))
51
52 ;; Like register_operand, but make sure that hard regs have a valid mode.
53 (define_predicate "valid_reg_operand"
54   (match_operand 0 "register_operand")
55 {
56   if (GET_CODE (op) == SUBREG)
57     op = SUBREG_REG (op);
58   if (REGNO (op) < FIRST_PSEUDO_REGISTER)
59     return HARD_REGNO_MODE_OK (REGNO (op), mode);
60   return 1;
61 })
62
63 ;; Return nonzero if OP is the CC register.
64 (define_predicate "cc_operand"
65   (and (match_code "reg")
66        (match_test "REGNO (op) == REG_CC && GET_MODE (op) == BImode")))
67
68 ;; Return nonzero if OP is a register or a 7 bit signed constant.
69 (define_predicate "reg_or_7bit_operand"
70   (ior (match_operand 0 "register_operand")
71        (and (match_code "const_int")
72             (match_test "CONST_7BIT_IMM_P (INTVAL (op))"))))
73
74 ;; Used for secondary reloads, this function returns 1 if OP is of the
75 ;; form (plus (fp) (const_int)).
76 (define_predicate "fp_plus_const_operand"
77   (match_code "plus")
78 {
79   rtx op1, op2;
80
81   op1 = XEXP (op, 0);
82   op2 = XEXP (op, 1);
83   return (REG_P (op1)
84           && (REGNO (op1) == FRAME_POINTER_REGNUM
85               || REGNO (op1) == STACK_POINTER_REGNUM)
86           && GET_CODE (op2) == CONST_INT);
87 })
88
89 ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
90 ;; possibly with an offset.
91 (define_predicate "symbolic_operand"
92   (ior (match_code "symbol_ref,label_ref")
93        (and (match_code "const")
94             (match_test "GET_CODE (XEXP (op,0)) == PLUS
95                          && (GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
96                              || GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF)
97                          && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT"))))
98
99 ;; Returns 1 if OP is a plain constant or matched by symbolic_operand.
100 (define_predicate "symbolic_or_const_operand"
101   (ior (match_code "const_int,const_double")
102        (match_operand 0 "symbolic_operand")))
103
104 ;; True for any non-virtual or eliminable register.  Used in places where
105 ;; instantiation of such a register may cause the pattern to not be recognized.
106 (define_predicate "register_no_elim_operand"
107   (match_operand 0 "register_operand")
108 {
109   if (GET_CODE (op) == SUBREG)
110     op = SUBREG_REG (op);
111   return !(op == arg_pointer_rtx
112            || op == frame_pointer_rtx
113            || (REGNO (op) >= FIRST_PSEUDO_REGISTER
114                && REGNO (op) <= LAST_VIRTUAL_REGISTER));
115 })
116
117 ;; Test for a valid operand for a call instruction.  Don't allow the
118 ;; arg pointer register or virtual regs since they may decay into
119 ;; reg + const, which the patterns can't handle.
120 ;; We only allow SYMBOL_REF if !flag_pic.
121 (define_predicate "call_insn_operand"
122   (ior (and (match_test "!flag_pic && !TARGET_LONG_CALLS") (match_code "symbol_ref"))
123        (match_operand 0 "register_no_elim_operand")))
124
125 ;; Test for an operator valid in a conditional branch
126 (define_predicate "bfin_cbranch_operator"
127   (match_code "eq,ne"))