1 ;; Predicate definitions for Xtensa.
2 ;; Copyright (C) 2005, 2006, 2007 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 3, 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 COPYING3. If not see
18 ;; <http://www.gnu.org/licenses/>.
20 (define_predicate "add_operand"
21 (ior (and (match_code "const_int")
22 (match_test "xtensa_simm8 (INTVAL (op))
23 || xtensa_simm8x256 (INTVAL (op))"))
24 (match_operand 0 "register_operand")))
26 (define_predicate "addsubx_operand"
27 (and (match_code "const_int")
28 (match_test "INTVAL (op) == 2
30 || INTVAL (op) == 8")))
32 (define_predicate "arith_operand"
33 (ior (and (match_code "const_int")
34 (match_test "xtensa_simm8 (INTVAL (op))"))
35 (match_operand 0 "register_operand")))
37 ;; Non-immediate operand excluding the constant pool.
38 (define_predicate "nonimmed_operand"
39 (ior (and (match_operand 0 "memory_operand")
40 (match_test "!constantpool_address_p (XEXP (op, 0))"))
41 (match_operand 0 "register_operand")))
43 ;; Memory operand excluding the constant pool.
44 (define_predicate "mem_operand"
45 (and (match_operand 0 "memory_operand")
46 (match_test "!constantpool_address_p (XEXP (op, 0))")))
48 (define_predicate "mask_operand"
49 (ior (and (match_code "const_int")
50 (match_test "xtensa_mask_immediate (INTVAL (op))"))
51 (match_operand 0 "register_operand")))
53 (define_predicate "extui_fldsz_operand"
54 (and (match_code "const_int")
55 (match_test "xtensa_mask_immediate ((1 << INTVAL (op)) - 1)")))
57 (define_predicate "sext_operand"
58 (if_then_else (match_test "TARGET_SEXT")
59 (match_operand 0 "nonimmed_operand")
60 (match_operand 0 "mem_operand")))
62 (define_predicate "sext_fldsz_operand"
63 (and (match_code "const_int")
64 (match_test "INTVAL (op) >= 8 && INTVAL (op) <= 23")))
66 (define_predicate "lsbitnum_operand"
67 (and (match_code "const_int")
68 (match_test "BITS_BIG_ENDIAN
69 ? (INTVAL (op) == BITS_PER_WORD - 1)
70 : (INTVAL (op) == 0)")))
72 (define_predicate "branch_operand"
73 (ior (and (match_code "const_int")
74 (match_test "xtensa_b4const_or_zero (INTVAL (op))"))
75 (match_operand 0 "register_operand")))
77 (define_predicate "ubranch_operand"
78 (ior (and (match_code "const_int")
79 (match_test "xtensa_b4constu (INTVAL (op))"))
80 (match_operand 0 "register_operand")))
82 (define_predicate "call_insn_operand"
83 (match_code "const_int,const,symbol_ref,reg")
85 if ((GET_CODE (op) == REG)
86 && (op != arg_pointer_rtx)
87 && ((REGNO (op) < FRAME_POINTER_REGNUM)
88 || (REGNO (op) > LAST_VIRTUAL_REGISTER)))
91 if (CONSTANT_ADDRESS_P (op))
93 /* Direct calls only allowed to static functions with PIC. */
96 tree callee, callee_sec, caller_sec;
98 if (GET_CODE (op) != SYMBOL_REF
99 || !SYMBOL_REF_LOCAL_P (op) || SYMBOL_REF_EXTERNAL_P (op))
102 /* Don't attempt a direct call if the callee is known to be in
103 a different section, since there's a good chance it will be
106 if (flag_function_sections
107 || DECL_ONE_ONLY (current_function_decl))
109 caller_sec = DECL_SECTION_NAME (current_function_decl);
110 callee = SYMBOL_REF_DECL (op);
113 if (DECL_ONE_ONLY (callee))
115 callee_sec = DECL_SECTION_NAME (callee);
116 if (((caller_sec == NULL_TREE) ^ (callee_sec == NULL_TREE))
117 || (caller_sec != NULL_TREE
118 && strcmp (TREE_STRING_POINTER (caller_sec),
119 TREE_STRING_POINTER (callee_sec)) != 0))
122 else if (caller_sec != NULL_TREE)
131 (define_predicate "move_operand"
133 (ior (match_operand 0 "register_operand")
134 (match_operand 0 "memory_operand"))
135 (ior (and (match_code "const_int")
136 (match_test "GET_MODE_CLASS (mode) == MODE_INT
137 && xtensa_simm12b (INTVAL (op))"))
138 (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
139 (match_test "TARGET_CONST16 && CONSTANT_P (op)
140 && GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0")))))
142 ;; Accept the floating point constant 1 in the appropriate mode.
143 (define_predicate "const_float_1_operand"
144 (match_code "const_double")
147 REAL_VALUE_FROM_CONST_DOUBLE (d, op);
148 return REAL_VALUES_EQUAL (d, dconst1);
151 (define_predicate "fpmem_offset_operand"
152 (and (match_code "const_int")
153 (match_test "xtensa_mem_offset (INTVAL (op), SFmode)")))
155 (define_predicate "branch_operator"
156 (match_code "eq,ne,lt,ge"))
158 (define_predicate "ubranch_operator"
159 (match_code "ltu,geu"))
161 (define_predicate "boolean_operator"
162 (match_code "eq,ne"))