1 ;; Machine description for AArch64 architecture.
2 ;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 ;; Contributed by ARM Ltd.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; GCC is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
21 (define_special_predicate "cc_register"
22 (and (match_code "reg")
23 (and (match_test "REGNO (op) == CC_REGNUM")
24 (ior (match_test "mode == GET_MODE (op)")
25 (match_test "mode == VOIDmode
26 && GET_MODE_CLASS (GET_MODE (op)) == MODE_CC"))))
29 (define_predicate "aarch64_reg_or_zero"
30 (and (match_code "reg,subreg,const_int")
31 (ior (match_operand 0 "register_operand")
32 (match_test "op == const0_rtx"))))
34 (define_predicate "aarch64_reg_or_fp_zero"
35 (and (match_code "reg,subreg,const_double")
36 (ior (match_operand 0 "register_operand")
37 (match_test "aarch64_float_const_zero_rtx_p (op)"))))
39 (define_predicate "aarch64_reg_zero_or_m1_or_1"
40 (and (match_code "reg,subreg,const_int")
41 (ior (match_operand 0 "register_operand")
42 (ior (match_test "op == const0_rtx")
43 (ior (match_test "op == constm1_rtx")
44 (match_test "op == const1_rtx"))))))
46 (define_predicate "aarch64_fp_compare_operand"
47 (ior (match_operand 0 "register_operand")
48 (and (match_code "const_double")
49 (match_test "aarch64_float_const_zero_rtx_p (op)"))))
51 (define_predicate "aarch64_plus_immediate"
52 (and (match_code "const_int")
53 (ior (match_test "aarch64_uimm12_shift (INTVAL (op))")
54 (match_test "aarch64_uimm12_shift (-INTVAL (op))"))))
56 (define_predicate "aarch64_plus_operand"
57 (ior (match_operand 0 "register_operand")
58 (match_operand 0 "aarch64_plus_immediate")))
60 (define_predicate "aarch64_pluslong_immediate"
61 (and (match_code "const_int")
62 (match_test "(INTVAL (op) < 0xffffff && INTVAL (op) > -0xffffff)")))
64 (define_predicate "aarch64_pluslong_operand"
65 (ior (match_operand 0 "register_operand")
66 (match_operand 0 "aarch64_pluslong_immediate")))
68 (define_predicate "aarch64_logical_immediate"
69 (and (match_code "const_int")
70 (match_test "aarch64_bitmask_imm (INTVAL (op), mode)")))
72 (define_predicate "aarch64_logical_operand"
73 (ior (match_operand 0 "register_operand")
74 (match_operand 0 "aarch64_logical_immediate")))
76 (define_predicate "aarch64_shift_imm_si"
77 (and (match_code "const_int")
78 (match_test "(unsigned HOST_WIDE_INT) INTVAL (op) < 32")))
80 (define_predicate "aarch64_shift_imm_di"
81 (and (match_code "const_int")
82 (match_test "(unsigned HOST_WIDE_INT) INTVAL (op) < 64")))
84 (define_predicate "aarch64_reg_or_shift_imm_si"
85 (ior (match_operand 0 "register_operand")
86 (match_operand 0 "aarch64_shift_imm_si")))
88 (define_predicate "aarch64_reg_or_shift_imm_di"
89 (ior (match_operand 0 "register_operand")
90 (match_operand 0 "aarch64_shift_imm_di")))
92 ;; The imm3 field is a 3-bit field that only accepts immediates in the
94 (define_predicate "aarch64_imm3"
95 (and (match_code "const_int")
96 (match_test "(unsigned HOST_WIDE_INT) INTVAL (op) <= 4")))
98 (define_predicate "aarch64_pwr_imm3"
99 (and (match_code "const_int")
100 (match_test "INTVAL (op) != 0
101 && (unsigned) exact_log2 (INTVAL (op)) <= 4")))
103 (define_predicate "aarch64_pwr_2_si"
104 (and (match_code "const_int")
105 (match_test "INTVAL (op) != 0
106 && (unsigned) exact_log2 (INTVAL (op)) < 32")))
108 (define_predicate "aarch64_pwr_2_di"
109 (and (match_code "const_int")
110 (match_test "INTVAL (op) != 0
111 && (unsigned) exact_log2 (INTVAL (op)) < 64")))
113 (define_predicate "aarch64_mem_pair_operand"
114 (and (match_code "mem")
115 (match_test "aarch64_legitimate_address_p (mode, XEXP (op, 0), PARALLEL,
118 (define_predicate "aarch64_valid_symref"
119 (match_code "const, symbol_ref, label_ref")
121 enum aarch64_symbol_type symbol_type;
122 return (aarch64_symbolic_constant_p (op, SYMBOL_CONTEXT_ADR, &symbol_type)
123 && symbol_type != SYMBOL_FORCE_TO_MEM);
126 (define_predicate "aarch64_tls_ie_symref"
127 (match_code "const, symbol_ref, label_ref")
129 switch (GET_CODE (op))
133 if (GET_CODE (op) != PLUS
134 || GET_CODE (XEXP (op, 0)) != SYMBOL_REF
135 || GET_CODE (XEXP (op, 1)) != CONST_INT)
140 return SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC;
147 (define_predicate "aarch64_tls_le_symref"
148 (match_code "const, symbol_ref, label_ref")
150 switch (GET_CODE (op))
154 if (GET_CODE (op) != PLUS
155 || GET_CODE (XEXP (op, 0)) != SYMBOL_REF
156 || GET_CODE (XEXP (op, 1)) != CONST_INT)
161 return SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC;
168 (define_predicate "aarch64_mov_operand"
169 (and (match_code "reg,subreg,mem,const,const_int,symbol_ref,label_ref,high")
170 (ior (match_operand 0 "register_operand")
171 (ior (match_operand 0 "memory_operand")
172 (match_test "aarch64_mov_operand_p (op, SYMBOL_CONTEXT_ADR, mode)")))))
174 (define_predicate "aarch64_movti_operand"
175 (and (match_code "reg,subreg,mem,const_int")
176 (ior (match_operand 0 "register_operand")
177 (ior (match_operand 0 "memory_operand")
178 (match_operand 0 "const_int_operand")))))
180 (define_predicate "aarch64_reg_or_imm"
181 (and (match_code "reg,subreg,const_int")
182 (ior (match_operand 0 "register_operand")
183 (match_operand 0 "const_int_operand"))))
185 ;; True for integer comparisons and for FP comparisons other than LTGT or UNEQ.
186 (define_special_predicate "aarch64_comparison_operator"
187 (match_code "eq,ne,le,lt,ge,gt,geu,gtu,leu,ltu,unordered,ordered,unlt,unle,unge,ungt"))
189 ;; True if the operand is memory reference suitable for a load/store exclusive.
190 (define_predicate "aarch64_sync_memory_operand"
191 (and (match_operand 0 "memory_operand")
192 (match_code "reg" "0")))
194 ;; Predicates for parallel expanders based on mode.
195 (define_special_predicate "vect_par_cnst_hi_half"
196 (match_code "parallel")
198 HOST_WIDE_INT count = XVECLEN (op, 0);
199 int nunits = GET_MODE_NUNITS (mode);
203 || count != nunits / 2)
206 if (!VECTOR_MODE_P (mode))
209 for (i = 0; i < count; i++)
211 rtx elt = XVECEXP (op, 0, i);
214 if (GET_CODE (elt) != CONST_INT)
218 if (val != (nunits / 2) + i)
224 (define_special_predicate "vect_par_cnst_lo_half"
225 (match_code "parallel")
227 HOST_WIDE_INT count = XVECLEN (op, 0);
228 int nunits = GET_MODE_NUNITS (mode);
232 || count != nunits / 2)
235 if (!VECTOR_MODE_P (mode))
238 for (i = 0; i < count; i++)
240 rtx elt = XVECEXP (op, 0, i);
243 if (GET_CODE (elt) != CONST_INT)
254 (define_special_predicate "aarch64_simd_lshift_imm"
255 (match_code "const_vector")
257 return aarch64_simd_shift_imm_p (op, mode, true);
260 (define_special_predicate "aarch64_simd_rshift_imm"
261 (match_code "const_vector")
263 return aarch64_simd_shift_imm_p (op, mode, false);
266 (define_predicate "aarch64_simd_reg_or_zero"
267 (and (match_code "reg,subreg,const_int,const_vector")
268 (ior (match_operand 0 "register_operand")
269 (ior (match_test "op == const0_rtx")
270 (match_test "aarch64_simd_imm_zero_p (op, mode)")))))
272 (define_predicate "aarch64_simd_struct_operand"
273 (and (match_code "mem")
274 (match_test "TARGET_SIMD && aarch64_simd_mem_operand_p (op)")))
276 ;; Like general_operand but allow only valid SIMD addressing modes.
277 (define_predicate "aarch64_simd_general_operand"
278 (and (match_operand 0 "general_operand")
279 (match_test "!MEM_P (op)
280 || GET_CODE (XEXP (op, 0)) == POST_INC
281 || GET_CODE (XEXP (op, 0)) == REG")))
283 ;; Like nonimmediate_operand but allow only valid SIMD addressing modes.
284 (define_predicate "aarch64_simd_nonimmediate_operand"
285 (and (match_operand 0 "nonimmediate_operand")
286 (match_test "!MEM_P (op)
287 || GET_CODE (XEXP (op, 0)) == POST_INC
288 || GET_CODE (XEXP (op, 0)) == REG")))
290 (define_special_predicate "aarch64_simd_imm_zero"
291 (match_code "const_vector")
293 return aarch64_simd_imm_zero_p (op, mode);