1 ;; Predicate definitions for Xtensa.
2 ;; Copyright (C) 2005, 2006 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 "add_operand"
22 (ior (and (match_code "const_int")
23 (match_test "xtensa_simm8 (INTVAL (op))
24 || xtensa_simm8x256 (INTVAL (op))"))
25 (match_operand 0 "register_operand")))
27 (define_predicate "addsubx_operand"
28 (and (match_code "const_int")
29 (match_test "INTVAL (op) == 2
31 || INTVAL (op) == 8")))
33 (define_predicate "arith_operand"
34 (ior (and (match_code "const_int")
35 (match_test "xtensa_simm8 (INTVAL (op))"))
36 (match_operand 0 "register_operand")))
38 ;; Non-immediate operand excluding the constant pool.
39 (define_predicate "nonimmed_operand"
40 (ior (and (match_operand 0 "memory_operand")
41 (match_test "!constantpool_address_p (XEXP (op, 0))"))
42 (match_operand 0 "register_operand")))
44 ;; Memory operand excluding the constant pool.
45 (define_predicate "mem_operand"
46 (and (match_operand 0 "memory_operand")
47 (match_test "!constantpool_address_p (XEXP (op, 0))")))
49 (define_predicate "mask_operand"
50 (ior (and (match_code "const_int")
51 (match_test "xtensa_mask_immediate (INTVAL (op))"))
52 (match_operand 0 "register_operand")))
54 (define_predicate "extui_fldsz_operand"
55 (and (match_code "const_int")
56 (match_test "xtensa_mask_immediate ((1 << INTVAL (op)) - 1)")))
58 (define_predicate "sext_operand"
59 (if_then_else (match_test "TARGET_SEXT")
60 (match_operand 0 "nonimmed_operand")
61 (match_operand 0 "mem_operand")))
63 (define_predicate "sext_fldsz_operand"
64 (and (match_code "const_int")
65 (match_test "INTVAL (op) >= 8 && INTVAL (op) <= 23")))
67 (define_predicate "lsbitnum_operand"
68 (and (match_code "const_int")
69 (match_test "BITS_BIG_ENDIAN
70 ? (INTVAL (op) == BITS_PER_WORD - 1)
71 : (INTVAL (op) == 0)")))
73 (define_predicate "branch_operand"
74 (ior (and (match_code "const_int")
75 (match_test "xtensa_b4const_or_zero (INTVAL (op))"))
76 (match_operand 0 "register_operand")))
78 (define_predicate "ubranch_operand"
79 (ior (and (match_code "const_int")
80 (match_test "xtensa_b4constu (INTVAL (op))"))
81 (match_operand 0 "register_operand")))
83 (define_predicate "call_insn_operand"
84 (match_code "const_int,const,symbol_ref,reg")
86 if ((GET_CODE (op) == REG)
87 && (op != arg_pointer_rtx)
88 && ((REGNO (op) < FRAME_POINTER_REGNUM)
89 || (REGNO (op) > LAST_VIRTUAL_REGISTER)))
92 if (CONSTANT_ADDRESS_P (op))
94 /* Direct calls only allowed to static functions with PIC. */
97 tree callee, callee_sec, caller_sec;
99 if (GET_CODE (op) != SYMBOL_REF
100 || !SYMBOL_REF_LOCAL_P (op) || SYMBOL_REF_EXTERNAL_P (op))
103 /* Don't attempt a direct call if the callee is known to be in
104 a different section, since there's a good chance it will be
107 if (flag_function_sections
108 || DECL_ONE_ONLY (current_function_decl))
110 caller_sec = DECL_SECTION_NAME (current_function_decl);
111 callee = SYMBOL_REF_DECL (op);
114 if (DECL_ONE_ONLY (callee))
116 callee_sec = DECL_SECTION_NAME (callee);
117 if (((caller_sec == NULL_TREE) ^ (callee_sec == NULL_TREE))
118 || (caller_sec != NULL_TREE
119 && strcmp (TREE_STRING_POINTER (caller_sec),
120 TREE_STRING_POINTER (callee_sec)) != 0))
123 else if (caller_sec != NULL_TREE)
132 (define_predicate "move_operand"
134 (ior (match_operand 0 "register_operand")
135 (match_operand 0 "memory_operand"))
136 (ior (and (match_code "const_int")
137 (match_test "GET_MODE_CLASS (mode) == MODE_INT
138 && xtensa_simm12b (INTVAL (op))"))
139 (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
140 (match_test "TARGET_CONST16 && CONSTANT_P (op)
141 && GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0")))))
143 ;; Accept the floating point constant 1 in the appropriate mode.
144 (define_predicate "const_float_1_operand"
145 (match_code "const_double")
148 REAL_VALUE_FROM_CONST_DOUBLE (d, op);
149 return REAL_VALUES_EQUAL (d, dconst1);
152 (define_predicate "fpmem_offset_operand"
153 (and (match_code "const_int")
154 (match_test "xtensa_mem_offset (INTVAL (op), SFmode)")))
156 (define_predicate "branch_operator"
157 (match_code "eq,ne,lt,ge"))
159 (define_predicate "ubranch_operator"
160 (match_code "ltu,geu"))
162 (define_predicate "boolean_operator"
163 (match_code "eq,ne"))