1 ;; Predicate definitions for MIPS.
2 ;; Copyright (C) 2004 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
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)
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.
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, 51 Franklin Street, Fifth Floor,
19 ;; Boston, MA 02110-1301, USA.
21 (define_predicate "const_uns_arith_operand"
22 (and (match_code "const_int")
23 (match_test "SMALL_OPERAND_UNSIGNED (INTVAL (op))")))
25 (define_predicate "uns_arith_operand"
26 (ior (match_operand 0 "const_uns_arith_operand")
27 (match_operand 0 "register_operand")))
29 (define_predicate "const_arith_operand"
30 (and (match_code "const_int")
31 (match_test "SMALL_OPERAND (INTVAL (op))")))
33 (define_predicate "arith_operand"
34 (ior (match_operand 0 "const_arith_operand")
35 (match_operand 0 "register_operand")))
37 (define_predicate "const_uimm6_operand"
38 (and (match_code "const_int")
39 (match_test "UIMM6_OPERAND (INTVAL (op))")))
41 (define_predicate "const_imm10_operand"
42 (and (match_code "const_int")
43 (match_test "IMM10_OPERAND (INTVAL (op))")))
45 (define_predicate "reg_imm10_operand"
46 (ior (match_operand 0 "const_imm10_operand")
47 (match_operand 0 "register_operand")))
49 (define_predicate "sle_operand"
50 (and (match_code "const_int")
51 (match_test "SMALL_OPERAND (INTVAL (op) + 1)")))
53 (define_predicate "sleu_operand"
54 (and (match_operand 0 "sle_operand")
55 (match_test "INTVAL (op) + 1 != 0")))
57 (define_predicate "const_0_operand"
58 (and (match_code "const_int,const_double,const_vector")
59 (match_test "op == CONST0_RTX (GET_MODE (op))")))
61 (define_predicate "reg_or_0_operand"
62 (ior (and (match_operand 0 "const_0_operand")
63 (match_test "!TARGET_MIPS16"))
64 (match_operand 0 "register_operand")))
66 (define_predicate "const_1_operand"
67 (and (match_code "const_int,const_double,const_vector")
68 (match_test "op == CONST1_RTX (GET_MODE (op))")))
70 (define_predicate "reg_or_1_operand"
71 (ior (match_operand 0 "const_1_operand")
72 (match_operand 0 "register_operand")))
74 ;; This is used for indexing into vectors, and hence only accepts const_int.
75 (define_predicate "const_0_or_1_operand"
76 (and (match_code "const_int")
77 (ior (match_test "op == CONST0_RTX (GET_MODE (op))")
78 (match_test "op == CONST1_RTX (GET_MODE (op))"))))
80 (define_predicate "fpr_operand"
81 (and (match_code "reg")
82 (match_test "FP_REG_P (REGNO (op))")))
84 (define_predicate "lo_operand"
85 (and (match_code "reg")
86 (match_test "REGNO (op) == LO_REGNUM")))
88 (define_predicate "fcc_reload_operand"
89 (and (match_code "reg,subreg")
90 (match_test "ST_REG_P (true_regnum (op))")))
92 (define_special_predicate "pc_or_label_operand"
93 (match_code "pc,label_ref"))
95 (define_predicate "const_call_insn_operand"
96 (match_code "const,symbol_ref,label_ref")
98 enum mips_symbol_type symbol_type;
100 if (!mips_symbolic_constant_p (op, &symbol_type))
106 /* If -mlong-calls, force all calls to use register addressing. Also,
107 if this function has the long_call attribute, we must use register
109 return !TARGET_LONG_CALLS && !SYMBOL_REF_LONG_CALL_P (op);
111 case SYMBOL_GOT_GLOBAL:
112 /* Without explicit relocs, there is no special syntax for
113 loading the address of a call destination into a register.
114 Using "la $25,foo; jal $25" would prevent the lazy binding
115 of "foo", so keep the address of global symbols with the
117 return !TARGET_EXPLICIT_RELOCS;
124 (define_predicate "call_insn_operand"
125 (ior (match_operand 0 "const_call_insn_operand")
126 (match_operand 0 "register_operand")))
128 (define_predicate "move_operand"
129 (match_operand 0 "general_operand")
131 switch (GET_CODE (op))
134 /* When generating mips16 code, LEGITIMATE_CONSTANT_P rejects
135 CONST_INTs that can't be loaded using simple insns. */
139 /* When generating 32-bit code, allow DImode move_operands to
140 match arbitrary constants. We split them after reload. */
141 if (!TARGET_64BIT && mode == DImode)
144 /* Otherwise check whether the constant can be loaded in a single
146 return LUI_INT (op) || SMALL_INT (op) || SMALL_INT_UNSIGNED (op);
151 return CONST_GP_P (op) || mips_atomic_symbolic_constant_p (op);
158 (define_predicate "consttable_operand"
159 (match_test "CONSTANT_P (op)"))
161 (define_predicate "symbolic_operand"
162 (match_code "const,symbol_ref,label_ref")
164 enum mips_symbol_type type;
165 return mips_symbolic_constant_p (op, &type);
168 (define_predicate "general_symbolic_operand"
169 (match_code "const,symbol_ref,label_ref")
171 enum mips_symbol_type type;
172 return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GENERAL;
175 (define_predicate "global_got_operand"
176 (match_code "const,symbol_ref,label_ref")
178 enum mips_symbol_type type;
179 return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GOT_GLOBAL;
182 (define_predicate "local_got_operand"
183 (match_code "const,symbol_ref,label_ref")
185 enum mips_symbol_type type;
186 return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GOT_LOCAL;
189 (define_predicate "stack_operand"
190 (and (match_code "mem")
191 (match_test "mips_stack_address_p (XEXP (op, 0), GET_MODE (op))")))
193 (define_predicate "macc_msac_operand"
194 (ior (and (match_code "plus") (match_test "ISA_HAS_MACC"))
195 (and (match_code "minus") (match_test "ISA_HAS_MSAC")))
197 rtx mult = XEXP (op, GET_CODE (op) == PLUS ? 0 : 1);
198 rtx accum = XEXP (op, GET_CODE (op) == PLUS ? 1 : 0);
199 return (GET_CODE (mult) == MULT
200 && REG_P (XEXP (mult, 0))
201 && REG_P (XEXP (mult, 1))
206 (define_predicate "equality_operator"
207 (match_code "eq,ne"))
209 (define_predicate "extend_operator"
210 (match_code "zero_extend,sign_extend"))
212 (define_predicate "trap_comparison_operator"
213 (match_code "eq,ne,lt,ltu,ge,geu"))
216 (define_predicate "small_data_pattern"
217 (and (match_code "set,parallel,unspec,unspec_volatile,prefetch")
218 (match_test "mips_small_data_pattern_p (op)")))