]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/mips/predicates.md
7000.md (rm7_impy_si_mult): Just match imul and imadd.
[thirdparty/gcc.git] / gcc / config / mips / predicates.md
1 ;; Predicate definitions for MIPS.
2 ;; Copyright (C) 2004 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 2, 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 COPYING. If not, write to
18 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
20
21 (define_predicate "const_uns_arith_operand"
22 (and (match_code "const_int")
23 (match_test "SMALL_OPERAND_UNSIGNED (INTVAL (op))")))
24
25 (define_predicate "uns_arith_operand"
26 (ior (match_operand 0 "const_uns_arith_operand")
27 (match_operand 0 "register_operand")))
28
29 (define_predicate "const_arith_operand"
30 (and (match_code "const_int")
31 (match_test "SMALL_OPERAND (INTVAL (op))")))
32
33 (define_predicate "arith_operand"
34 (ior (match_operand 0 "const_arith_operand")
35 (match_operand 0 "register_operand")))
36
37 (define_predicate "sle_operand"
38 (and (match_code "const_int")
39 (match_test "SMALL_OPERAND (INTVAL (op) + 1)")))
40
41 (define_predicate "sleu_operand"
42 (and (match_operand 0 "sle_operand")
43 (match_test "INTVAL (op) + 1 != 0")))
44
45 (define_predicate "const_0_operand"
46 (and (match_code "const_int,const_double,const_vector")
47 (match_test "op == CONST0_RTX (GET_MODE (op))")))
48
49 (define_predicate "reg_or_0_operand"
50 (ior (and (match_operand 0 "const_0_operand")
51 (match_test "!TARGET_MIPS16"))
52 (match_operand 0 "register_operand")))
53
54 (define_predicate "const_1_operand"
55 (and (match_code "const_int,const_double,const_vector")
56 (match_test "op == CONST1_RTX (GET_MODE (op))")))
57
58 (define_predicate "reg_or_1_operand"
59 (ior (match_operand 0 "const_1_operand")
60 (match_operand 0 "register_operand")))
61
62 ;; This is used for indexing into vectors, and hence only accepts const_int.
63 (define_predicate "const_0_or_1_operand"
64 (and (match_code "const_int")
65 (ior (match_test "op == CONST0_RTX (GET_MODE (op))")
66 (match_test "op == CONST1_RTX (GET_MODE (op))"))))
67
68 (define_predicate "fpr_operand"
69 (and (match_code "reg")
70 (match_test "FP_REG_P (REGNO (op))")))
71
72 (define_predicate "lo_operand"
73 (and (match_code "reg")
74 (match_test "REGNO (op) == LO_REGNUM")))
75
76 (define_predicate "fcc_reload_operand"
77 (and (match_code "reg,subreg")
78 (match_test "ST_REG_P (true_regnum (op))")))
79
80 (define_special_predicate "pc_or_label_operand"
81 (match_code "pc,label_ref"))
82
83 (define_predicate "const_call_insn_operand"
84 (match_code "const,symbol_ref,label_ref")
85 {
86 enum mips_symbol_type symbol_type;
87
88 if (!mips_symbolic_constant_p (op, &symbol_type))
89 return false;
90
91 switch (symbol_type)
92 {
93 case SYMBOL_GENERAL:
94 /* If -mlong-calls, force all calls to use register addressing. */
95 return !TARGET_LONG_CALLS;
96
97 case SYMBOL_GOT_GLOBAL:
98 /* Without explicit relocs, there is no special syntax for
99 loading the address of a call destination into a register.
100 Using "la $25,foo; jal $25" would prevent the lazy binding
101 of "foo", so keep the address of global symbols with the
102 jal macro. */
103 return !TARGET_EXPLICIT_RELOCS;
104
105 default:
106 return false;
107 }
108 })
109
110 (define_predicate "call_insn_operand"
111 (ior (match_operand 0 "const_call_insn_operand")
112 (match_operand 0 "register_operand")))
113
114 (define_predicate "move_operand"
115 (match_operand 0 "general_operand")
116 {
117 switch (GET_CODE (op))
118 {
119 case CONST_INT:
120 /* When generating mips16 code, LEGITIMATE_CONSTANT_P rejects
121 CONST_INTs that can't be loaded using simple insns. */
122 if (TARGET_MIPS16)
123 return true;
124
125 /* When generating 32-bit code, allow DImode move_operands to
126 match arbitrary constants. We split them after reload. */
127 if (!TARGET_64BIT && mode == DImode)
128 return true;
129
130 /* Otherwise check whether the constant can be loaded in a single
131 instruction. */
132 return LUI_INT (op) || SMALL_INT (op) || SMALL_INT_UNSIGNED (op);
133
134 case CONST:
135 case SYMBOL_REF:
136 case LABEL_REF:
137 return CONST_GP_P (op) || mips_atomic_symbolic_constant_p (op);
138
139 default:
140 return true;
141 }
142 })
143
144 (define_predicate "consttable_operand"
145 (match_test "CONSTANT_P (op)"))
146
147 (define_predicate "symbolic_operand"
148 (match_code "const,symbol_ref,label_ref")
149 {
150 enum mips_symbol_type type;
151 return mips_symbolic_constant_p (op, &type);
152 })
153
154 (define_predicate "general_symbolic_operand"
155 (match_code "const,symbol_ref,label_ref")
156 {
157 enum mips_symbol_type type;
158 return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GENERAL;
159 })
160
161 (define_predicate "global_got_operand"
162 (match_code "const,symbol_ref,label_ref")
163 {
164 enum mips_symbol_type type;
165 return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GOT_GLOBAL;
166 })
167
168 (define_predicate "local_got_operand"
169 (match_code "const,symbol_ref,label_ref")
170 {
171 enum mips_symbol_type type;
172 return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GOT_LOCAL;
173 })
174
175 (define_predicate "stack_operand"
176 (and (match_code "mem")
177 (match_test "mips_stack_address_p (XEXP (op, 0), GET_MODE (op))")))
178
179 (define_predicate "macc_msac_operand"
180 (ior (and (match_code "plus") (match_test "ISA_HAS_MACC"))
181 (and (match_code "minus") (match_test "ISA_HAS_MSAC")))
182 {
183 rtx mult = XEXP (op, GET_CODE (op) == PLUS ? 0 : 1);
184 rtx accum = XEXP (op, GET_CODE (op) == PLUS ? 1 : 0);
185 return (GET_CODE (mult) == MULT
186 && REG_P (XEXP (mult, 0))
187 && REG_P (XEXP (mult, 1))
188 && REG_P (accum));
189 })
190
191
192 (define_predicate "equality_operator"
193 (match_code "eq,ne"))
194
195 (define_predicate "extend_operator"
196 (match_code "zero_extend,sign_extend"))
197
198 (define_predicate "trap_comparison_operator"
199 (match_code "eq,ne,lt,ltu,ge,geu"))
200
201
202 (define_predicate "small_data_pattern"
203 (and (match_code "set,parallel,unspec,unspec_volatile,prefetch")
204 (match_test "mips_small_data_pattern_p (op)")))