constraints.md revision 1.1 1 1.1 mrg ;; Constraint definitions for ARM and Thumb
2 1.1 mrg ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
3 1.1 mrg ;; Contributed by ARM Ltd.
4 1.1 mrg
5 1.1 mrg ;; This file is part of GCC.
6 1.1 mrg
7 1.1 mrg ;; GCC is free software; you can redistribute it and/or modify it
8 1.1 mrg ;; under the terms of the GNU General Public License as published
9 1.1 mrg ;; by the Free Software Foundation; either version 3, or (at your
10 1.1 mrg ;; option) any later version.
11 1.1 mrg
12 1.1 mrg ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 1.1 mrg ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 1.1 mrg ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 1.1 mrg ;; License for more details.
16 1.1 mrg
17 1.1 mrg ;; You should have received a copy of the GNU General Public License
18 1.1 mrg ;; along with GCC; see the file COPYING3. If not see
19 1.1 mrg ;; <http://www.gnu.org/licenses/>.
20 1.1 mrg
21 1.1 mrg ;; The following register constraints have been used:
22 1.1 mrg ;; - in ARM/Thumb-2 state: f, t, v, w, x, y, z
23 1.1 mrg ;; - in Thumb state: h, b
24 1.1 mrg ;; - in both states: l, c, k
25 1.1 mrg ;; In ARM state, 'l' is an alias for 'r'
26 1.1 mrg
27 1.1 mrg ;; The following normal constraints have been used:
28 1.1 mrg ;; in ARM/Thumb-2 state: G, H, I, j, J, K, L, M
29 1.1 mrg ;; in Thumb-1 state: I, J, K, L, M, N, O
30 1.1 mrg
31 1.1 mrg ;; The following multi-letter normal constraints have been used:
32 1.1 mrg ;; in ARM/Thumb-2 state: Da, Db, Dc, Dn, Dl, DL, Dv, Dy
33 1.1 mrg ;; in Thumb-1 state: Pa, Pb
34 1.1 mrg ;; in Thumb-2 state: Ps, Pt
35 1.1 mrg
36 1.1 mrg ;; The following memory constraints have been used:
37 1.1 mrg ;; in ARM/Thumb-2 state: Q, Ut, Uv, Uy, Un, Um, Us
38 1.1 mrg ;; in ARM state: Uq
39 1.1 mrg
40 1.1 mrg
41 1.1 mrg (define_register_constraint "f" "TARGET_ARM ? FPA_REGS : NO_REGS"
42 1.1 mrg "Legacy FPA registers @code{f0}-@code{f7}.")
43 1.1 mrg
44 1.1 mrg (define_register_constraint "t" "TARGET_32BIT ? VFP_LO_REGS : NO_REGS"
45 1.1 mrg "The VFP registers @code{s0}-@code{s31}.")
46 1.1 mrg
47 1.1 mrg (define_register_constraint "v" "TARGET_ARM ? CIRRUS_REGS : NO_REGS"
48 1.1 mrg "The Cirrus Maverick co-processor registers.")
49 1.1 mrg
50 1.1 mrg (define_register_constraint "w"
51 1.1 mrg "TARGET_32BIT ? (TARGET_VFPD32 ? VFP_REGS : VFP_LO_REGS) : NO_REGS"
52 1.1 mrg "The VFP registers @code{d0}-@code{d15}, or @code{d0}-@code{d31} for VFPv3.")
53 1.1 mrg
54 1.1 mrg (define_register_constraint "x" "TARGET_32BIT ? VFP_D0_D7_REGS : NO_REGS"
55 1.1 mrg "The VFP registers @code{d0}-@code{d7}.")
56 1.1 mrg
57 1.1 mrg (define_register_constraint "y" "TARGET_REALLY_IWMMXT ? IWMMXT_REGS : NO_REGS"
58 1.1 mrg "The Intel iWMMX co-processor registers.")
59 1.1 mrg
60 1.1 mrg (define_register_constraint "z"
61 1.1 mrg "TARGET_REALLY_IWMMXT ? IWMMXT_GR_REGS : NO_REGS"
62 1.1 mrg "The Intel iWMMX GR registers.")
63 1.1 mrg
64 1.1 mrg (define_register_constraint "l" "TARGET_THUMB ? LO_REGS : GENERAL_REGS"
65 1.1 mrg "In Thumb state the core registers @code{r0}-@code{r7}.")
66 1.1 mrg
67 1.1 mrg (define_register_constraint "h" "TARGET_THUMB ? HI_REGS : NO_REGS"
68 1.1 mrg "In Thumb state the core registers @code{r8}-@code{r15}.")
69 1.1 mrg
70 1.1 mrg (define_constraint "j"
71 1.1 mrg "A constant suitable for a MOVW instruction. (ARM/Thumb-2)"
72 1.1 mrg (and (match_test "TARGET_32BIT && arm_arch_thumb2")
73 1.1 mrg (ior (match_code "high")
74 1.1 mrg (and (match_code "const_int")
75 1.1 mrg (match_test "(ival & 0xffff0000) == 0")))))
76 1.1 mrg
77 1.1 mrg (define_register_constraint "k" "STACK_REG"
78 1.1 mrg "@internal The stack register.")
79 1.1 mrg
80 1.1 mrg (define_register_constraint "b" "TARGET_THUMB ? BASE_REGS : NO_REGS"
81 1.1 mrg "@internal
82 1.1 mrg Thumb only. The union of the low registers and the stack register.")
83 1.1 mrg
84 1.1 mrg (define_register_constraint "c" "CC_REG"
85 1.1 mrg "@internal The condition code register.")
86 1.1 mrg
87 1.1 mrg (define_constraint "I"
88 1.1 mrg "In ARM/Thumb-2 state a constant that can be used as an immediate value in a
89 1.1 mrg Data Processing instruction. In Thumb-1 state a constant in the range
90 1.1 mrg 0-255."
91 1.1 mrg (and (match_code "const_int")
92 1.1 mrg (match_test "TARGET_32BIT ? const_ok_for_arm (ival)
93 1.1 mrg : ival >= 0 && ival <= 255")))
94 1.1 mrg
95 1.1 mrg (define_constraint "J"
96 1.1 mrg "In ARM/Thumb-2 state a constant in the range @minus{}4095-4095. In Thumb-1
97 1.1 mrg state a constant in the range @minus{}255-@minus{}1."
98 1.1 mrg (and (match_code "const_int")
99 1.1 mrg (match_test "TARGET_32BIT ? (ival >= -4095 && ival <= 4095)
100 1.1 mrg : (ival >= -255 && ival <= -1)")))
101 1.1 mrg
102 1.1 mrg (define_constraint "K"
103 1.1 mrg "In ARM/Thumb-2 state a constant that satisfies the @code{I} constraint if
104 1.1 mrg inverted. In Thumb-1 state a constant that satisfies the @code{I}
105 1.1 mrg constraint multiplied by any power of 2."
106 1.1 mrg (and (match_code "const_int")
107 1.1 mrg (match_test "TARGET_32BIT ? const_ok_for_arm (~ival)
108 1.1 mrg : thumb_shiftable_const (ival)")))
109 1.1 mrg
110 1.1 mrg (define_constraint "L"
111 1.1 mrg "In ARM/Thumb-2 state a constant that satisfies the @code{I} constraint if
112 1.1 mrg negated. In Thumb-1 state a constant in the range @minus{}7-7."
113 1.1 mrg (and (match_code "const_int")
114 1.1 mrg (match_test "TARGET_32BIT ? const_ok_for_arm (-ival)
115 1.1 mrg : (ival >= -7 && ival <= 7)")))
116 1.1 mrg
117 1.1 mrg ;; The ARM state version is internal...
118 1.1 mrg ;; @internal In ARM/Thumb-2 state a constant in the range 0-32 or any
119 1.1 mrg ;; power of 2.
120 1.1 mrg (define_constraint "M"
121 1.1 mrg "In Thumb-1 state a constant that is a multiple of 4 in the range 0-1020."
122 1.1 mrg (and (match_code "const_int")
123 1.1 mrg (match_test "TARGET_32BIT ? ((ival >= 0 && ival <= 32)
124 1.1 mrg || ((ival & (ival - 1)) == 0))
125 1.1 mrg : ((ival >= 0 && ival <= 1020) && ((ival & 3) == 0))")))
126 1.1 mrg
127 1.1 mrg (define_constraint "N"
128 1.1 mrg "Thumb-1 state a constant in the range 0-31."
129 1.1 mrg (and (match_code "const_int")
130 1.1 mrg (match_test "!TARGET_32BIT && (ival >= 0 && ival <= 31)")))
131 1.1 mrg
132 1.1 mrg (define_constraint "O"
133 1.1 mrg "In Thumb-1 state a constant that is a multiple of 4 in the range
134 1.1 mrg @minus{}508-508."
135 1.1 mrg (and (match_code "const_int")
136 1.1 mrg (match_test "TARGET_THUMB1 && ival >= -508 && ival <= 508
137 1.1 mrg && ((ival & 3) == 0)")))
138 1.1 mrg
139 1.1 mrg (define_constraint "Pa"
140 1.1 mrg "@internal In Thumb-1 state a constant in the range -510 to +510"
141 1.1 mrg (and (match_code "const_int")
142 1.1 mrg (match_test "TARGET_THUMB1 && ival >= -510 && ival <= 510
143 1.1 mrg && (ival > 255 || ival < -255)")))
144 1.1 mrg
145 1.1 mrg (define_constraint "Pb"
146 1.1 mrg "@internal In Thumb-1 state a constant in the range -262 to +262"
147 1.1 mrg (and (match_code "const_int")
148 1.1 mrg (match_test "TARGET_THUMB1 && ival >= -262 && ival <= 262
149 1.1 mrg && (ival > 255 || ival < -255)")))
150 1.1 mrg
151 1.1 mrg (define_constraint "Ps"
152 1.1 mrg "@internal In Thumb-2 state a constant in the range -255 to +255"
153 1.1 mrg (and (match_code "const_int")
154 1.1 mrg (match_test "TARGET_THUMB2 && ival >= -255 && ival <= 255")))
155 1.1 mrg
156 1.1 mrg (define_constraint "Pt"
157 1.1 mrg "@internal In Thumb-2 state a constant in the range -7 to +7"
158 1.1 mrg (and (match_code "const_int")
159 1.1 mrg (match_test "TARGET_THUMB2 && ival >= -7 && ival <= 7")))
160 1.1 mrg
161 1.1 mrg (define_constraint "G"
162 1.1 mrg "In ARM/Thumb-2 state a valid FPA immediate constant."
163 1.1 mrg (and (match_code "const_double")
164 1.1 mrg (match_test "TARGET_32BIT && arm_const_double_rtx (op)")))
165 1.1 mrg
166 1.1 mrg (define_constraint "H"
167 1.1 mrg "In ARM/Thumb-2 state a valid FPA immediate constant when negated."
168 1.1 mrg (and (match_code "const_double")
169 1.1 mrg (match_test "TARGET_32BIT && neg_const_double_rtx_ok_for_fpa (op)")))
170 1.1 mrg
171 1.1 mrg (define_constraint "Da"
172 1.1 mrg "@internal
173 1.1 mrg In ARM/Thumb-2 state a const_int, const_double or const_vector that can
174 1.1 mrg be generated with two Data Processing insns."
175 1.1 mrg (and (match_code "const_double,const_int,const_vector")
176 1.1 mrg (match_test "TARGET_32BIT && arm_const_double_inline_cost (op) == 2")))
177 1.1 mrg
178 1.1 mrg (define_constraint "Db"
179 1.1 mrg "@internal
180 1.1 mrg In ARM/Thumb-2 state a const_int, const_double or const_vector that can
181 1.1 mrg be generated with three Data Processing insns."
182 1.1 mrg (and (match_code "const_double,const_int,const_vector")
183 1.1 mrg (match_test "TARGET_32BIT && arm_const_double_inline_cost (op) == 3")))
184 1.1 mrg
185 1.1 mrg (define_constraint "Dc"
186 1.1 mrg "@internal
187 1.1 mrg In ARM/Thumb-2 state a const_int, const_double or const_vector that can
188 1.1 mrg be generated with four Data Processing insns. This pattern is disabled
189 1.1 mrg if optimizing for space or when we have load-delay slots to fill."
190 1.1 mrg (and (match_code "const_double,const_int,const_vector")
191 1.1 mrg (match_test "TARGET_32BIT && arm_const_double_inline_cost (op) == 4
192 1.1 mrg && !(optimize_size || arm_ld_sched)")))
193 1.1 mrg
194 1.1 mrg (define_constraint "Dn"
195 1.1 mrg "@internal
196 1.1 mrg In ARM/Thumb-2 state a const_vector which can be loaded with a Neon vmov
197 1.1 mrg immediate instruction."
198 1.1 mrg (and (match_code "const_vector")
199 1.1 mrg (match_test "TARGET_32BIT
200 1.1 mrg && imm_for_neon_mov_operand (op, GET_MODE (op))")))
201 1.1 mrg
202 1.1 mrg (define_constraint "Dl"
203 1.1 mrg "@internal
204 1.1 mrg In ARM/Thumb-2 state a const_vector which can be used with a Neon vorr or
205 1.1 mrg vbic instruction."
206 1.1 mrg (and (match_code "const_vector")
207 1.1 mrg (match_test "TARGET_32BIT
208 1.1 mrg && imm_for_neon_logic_operand (op, GET_MODE (op))")))
209 1.1 mrg
210 1.1 mrg (define_constraint "DL"
211 1.1 mrg "@internal
212 1.1 mrg In ARM/Thumb-2 state a const_vector which can be used with a Neon vorn or
213 1.1 mrg vand instruction."
214 1.1 mrg (and (match_code "const_vector")
215 1.1 mrg (match_test "TARGET_32BIT
216 1.1 mrg && imm_for_neon_inv_logic_operand (op, GET_MODE (op))")))
217 1.1 mrg
218 1.1 mrg (define_constraint "Dv"
219 1.1 mrg "@internal
220 1.1 mrg In ARM/Thumb-2 state a const_double which can be used with a VFP fconsts
221 1.1 mrg instruction."
222 1.1 mrg (and (match_code "const_double")
223 1.1 mrg (match_test "TARGET_32BIT && vfp3_const_double_rtx (op)")))
224 1.1 mrg
225 1.1 mrg (define_constraint "Dy"
226 1.1 mrg "@internal
227 1.1 mrg In ARM/Thumb-2 state a const_double which can be used with a VFP fconstd
228 1.1 mrg instruction."
229 1.1 mrg (and (match_code "const_double")
230 1.1 mrg (match_test "TARGET_32BIT && TARGET_VFP_DOUBLE && vfp3_const_double_rtx (op)")))
231 1.1 mrg
232 1.1 mrg (define_memory_constraint "Ut"
233 1.1 mrg "@internal
234 1.1 mrg In ARM/Thumb-2 state an address valid for loading/storing opaque structure
235 1.1 mrg types wider than TImode."
236 1.1 mrg (and (match_code "mem")
237 1.1 mrg (match_test "TARGET_32BIT && neon_struct_mem_operand (op)")))
238 1.1 mrg
239 1.1 mrg (define_memory_constraint "Uv"
240 1.1 mrg "@internal
241 1.1 mrg In ARM/Thumb-2 state a valid VFP load/store address."
242 1.1 mrg (and (match_code "mem")
243 1.1 mrg (match_test "TARGET_32BIT && arm_coproc_mem_operand (op, FALSE)")))
244 1.1 mrg
245 1.1 mrg (define_memory_constraint "Uy"
246 1.1 mrg "@internal
247 1.1 mrg In ARM/Thumb-2 state a valid iWMMX load/store address."
248 1.1 mrg (and (match_code "mem")
249 1.1 mrg (match_test "TARGET_32BIT && arm_coproc_mem_operand (op, TRUE)")))
250 1.1 mrg
251 1.1 mrg (define_memory_constraint "Un"
252 1.1 mrg "@internal
253 1.1 mrg In ARM/Thumb-2 state a valid address for Neon doubleword vector
254 1.1 mrg load/store instructions."
255 1.1 mrg (and (match_code "mem")
256 1.1 mrg (match_test "TARGET_32BIT && neon_vector_mem_operand (op, 0)")))
257 1.1 mrg
258 1.1 mrg (define_memory_constraint "Um"
259 1.1 mrg "@internal
260 1.1 mrg In ARM/Thumb-2 state a valid address for Neon element and structure
261 1.1 mrg load/store instructions."
262 1.1 mrg (and (match_code "mem")
263 1.1 mrg (match_test "TARGET_32BIT && neon_vector_mem_operand (op, 2)")))
264 1.1 mrg
265 1.1 mrg (define_memory_constraint "Us"
266 1.1 mrg "@internal
267 1.1 mrg In ARM/Thumb-2 state a valid address for non-offset loads/stores of
268 1.1 mrg quad-word values in four ARM registers."
269 1.1 mrg (and (match_code "mem")
270 1.1 mrg (match_test "TARGET_32BIT && neon_vector_mem_operand (op, 1)")))
271 1.1 mrg
272 1.1 mrg (define_memory_constraint "Uq"
273 1.1 mrg "@internal
274 1.1 mrg In ARM state an address valid in ldrsb instructions."
275 1.1 mrg (and (match_code "mem")
276 1.1 mrg (match_test "TARGET_ARM
277 1.1 mrg && arm_legitimate_address_outer_p (GET_MODE (op), XEXP (op, 0),
278 1.1 mrg SIGN_EXTEND, 0)")))
279 1.1 mrg
280 1.1 mrg (define_memory_constraint "Q"
281 1.1 mrg "@internal
282 1.1 mrg In ARM/Thumb-2 state an address that is a single base register."
283 1.1 mrg (and (match_code "mem")
284 1.1 mrg (match_test "REG_P (XEXP (op, 0))")))
285 1.1 mrg
286 1.1 mrg ;; We used to have constraint letters for S and R in ARM state, but
287 1.1 mrg ;; all uses of these now appear to have been removed.
288 1.1 mrg
289 1.1 mrg ;; Additionally, we used to have a Q constraint in Thumb state, but
290 1.1 mrg ;; this wasn't really a valid memory constraint. Again, all uses of
291 1.1 mrg ;; this now seem to have been removed.
292