]>
Commit | Line | Data |
---|---|---|
8eb1bc5c | 1 | ;; Predicate definitions for Xtensa. |
99dee823 | 2 | ;; Copyright (C) 2005-2021 Free Software Foundation, Inc. |
8eb1bc5c BW |
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 | |
2f83c7d6 | 8 | ;; the Free Software Foundation; either version 3, or (at your option) |
8eb1bc5c BW |
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 | |
2f83c7d6 NC |
17 | ;; along with GCC; see the file COPYING3. If not see |
18 | ;; <http://www.gnu.org/licenses/>. | |
8eb1bc5c BW |
19 | |
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"))) | |
25 | ||
036a2b7a BW |
26 | (define_predicate "addsubx_operand" |
27 | (and (match_code "const_int") | |
06ff8708 MF |
28 | (match_test "INTVAL (op) >= 1 |
29 | && INTVAL (op) <= 3"))) | |
036a2b7a | 30 | |
8eb1bc5c BW |
31 | (define_predicate "arith_operand" |
32 | (ior (and (match_code "const_int") | |
33 | (match_test "xtensa_simm8 (INTVAL (op))")) | |
34 | (match_operand 0 "register_operand"))) | |
35 | ||
36 | ;; Non-immediate operand excluding the constant pool. | |
37 | (define_predicate "nonimmed_operand" | |
38 | (ior (and (match_operand 0 "memory_operand") | |
37fbe8a3 | 39 | (match_test "!constantpool_mem_p (op)")) |
8eb1bc5c BW |
40 | (match_operand 0 "register_operand"))) |
41 | ||
42 | ;; Memory operand excluding the constant pool. | |
43 | (define_predicate "mem_operand" | |
44 | (and (match_operand 0 "memory_operand") | |
37fbe8a3 BW |
45 | (match_test "!constantpool_mem_p (op)"))) |
46 | ||
47 | ;; Memory operand in the constant pool. | |
48 | (define_predicate "constantpool_operand" | |
49 | (match_test "constantpool_mem_p (op)")) | |
8eb1bc5c BW |
50 | |
51 | (define_predicate "mask_operand" | |
52 | (ior (and (match_code "const_int") | |
53 | (match_test "xtensa_mask_immediate (INTVAL (op))")) | |
54 | (match_operand 0 "register_operand"))) | |
55 | ||
56 | (define_predicate "extui_fldsz_operand" | |
57 | (and (match_code "const_int") | |
58 | (match_test "xtensa_mask_immediate ((1 << INTVAL (op)) - 1)"))) | |
59 | ||
60 | (define_predicate "sext_operand" | |
61 | (if_then_else (match_test "TARGET_SEXT") | |
62 | (match_operand 0 "nonimmed_operand") | |
63 | (match_operand 0 "mem_operand"))) | |
64 | ||
65 | (define_predicate "sext_fldsz_operand" | |
66 | (and (match_code "const_int") | |
67 | (match_test "INTVAL (op) >= 8 && INTVAL (op) <= 23"))) | |
68 | ||
69 | (define_predicate "lsbitnum_operand" | |
70 | (and (match_code "const_int") | |
71 | (match_test "BITS_BIG_ENDIAN | |
72 | ? (INTVAL (op) == BITS_PER_WORD - 1) | |
73 | : (INTVAL (op) == 0)"))) | |
74 | ||
75 | (define_predicate "branch_operand" | |
76 | (ior (and (match_code "const_int") | |
77 | (match_test "xtensa_b4const_or_zero (INTVAL (op))")) | |
78 | (match_operand 0 "register_operand"))) | |
79 | ||
80 | (define_predicate "ubranch_operand" | |
81 | (ior (and (match_code "const_int") | |
82 | (match_test "xtensa_b4constu (INTVAL (op))")) | |
83 | (match_operand 0 "register_operand"))) | |
84 | ||
85 | (define_predicate "call_insn_operand" | |
86 | (match_code "const_int,const,symbol_ref,reg") | |
87 | { | |
88 | if ((GET_CODE (op) == REG) | |
89 | && (op != arg_pointer_rtx) | |
90 | && ((REGNO (op) < FRAME_POINTER_REGNUM) | |
91 | || (REGNO (op) > LAST_VIRTUAL_REGISTER))) | |
92 | return true; | |
93 | ||
94 | if (CONSTANT_ADDRESS_P (op)) | |
95 | { | |
96 | /* Direct calls only allowed to static functions with PIC. */ | |
97 | if (flag_pic) | |
98 | { | |
0218574f JH |
99 | tree callee; |
100 | const char * callee_sec, * caller_sec; | |
8eb1bc5c BW |
101 | |
102 | if (GET_CODE (op) != SYMBOL_REF | |
103 | || !SYMBOL_REF_LOCAL_P (op) || SYMBOL_REF_EXTERNAL_P (op)) | |
104 | return false; | |
105 | ||
106 | /* Don't attempt a direct call if the callee is known to be in | |
107 | a different section, since there's a good chance it will be | |
108 | out of range. */ | |
109 | ||
110 | if (flag_function_sections | |
111 | || DECL_ONE_ONLY (current_function_decl)) | |
112 | return false; | |
113 | caller_sec = DECL_SECTION_NAME (current_function_decl); | |
114 | callee = SYMBOL_REF_DECL (op); | |
115 | if (callee) | |
116 | { | |
117 | if (DECL_ONE_ONLY (callee)) | |
118 | return false; | |
119 | callee_sec = DECL_SECTION_NAME (callee); | |
0218574f JH |
120 | if (((caller_sec == NULL) ^ (callee_sec == NULL)) |
121 | || (caller_sec != NULL | |
122 | && caller_sec != callee_sec)) | |
8eb1bc5c BW |
123 | return false; |
124 | } | |
0218574f | 125 | else if (caller_sec) |
8eb1bc5c BW |
126 | return false; |
127 | } | |
128 | return true; | |
129 | } | |
130 | ||
131 | return false; | |
132 | }) | |
133 | ||
134 | (define_predicate "move_operand" | |
135 | (ior | |
136 | (ior (match_operand 0 "register_operand") | |
37fbe8a3 BW |
137 | (and (match_operand 0 "memory_operand") |
138 | (match_test "!constantpool_mem_p (op) | |
139 | || GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0"))) | |
8eb1bc5c BW |
140 | (ior (and (match_code "const_int") |
141 | (match_test "GET_MODE_CLASS (mode) == MODE_INT | |
142 | && xtensa_simm12b (INTVAL (op))")) | |
143 | (and (match_code "const_int,const_double,const,symbol_ref,label_ref") | |
a024f514 MF |
144 | (match_test "(TARGET_CONST16 || TARGET_AUTO_LITPOOLS) |
145 | && CONSTANT_P (op) | |
8eb1bc5c BW |
146 | && GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0"))))) |
147 | ||
148 | ;; Accept the floating point constant 1 in the appropriate mode. | |
149 | (define_predicate "const_float_1_operand" | |
150 | (match_code "const_double") | |
151 | { | |
34a72c33 | 152 | return real_equal (CONST_DOUBLE_REAL_VALUE (op), &dconst1); |
8eb1bc5c BW |
153 | }) |
154 | ||
155 | (define_predicate "fpmem_offset_operand" | |
156 | (and (match_code "const_int") | |
157 | (match_test "xtensa_mem_offset (INTVAL (op), SFmode)"))) | |
158 | ||
159 | (define_predicate "branch_operator" | |
160 | (match_code "eq,ne,lt,ge")) | |
161 | ||
162 | (define_predicate "ubranch_operator" | |
163 | (match_code "ltu,geu")) | |
164 | ||
165 | (define_predicate "boolean_operator" | |
166 | (match_code "eq,ne")) | |
6a7a462c | 167 | |
f90b7a5a PB |
168 | (define_predicate "xtensa_cstoresi_operator" |
169 | (match_code "eq,ne,gt,ge,lt,le")) | |
170 | ||
6a7a462c BW |
171 | (define_predicate "tls_symbol_operand" |
172 | (and (match_code "symbol_ref") | |
173 | (match_test "SYMBOL_REF_TLS_MODEL (op) != 0"))) |