xref: /openbsd-src/gnu/gcc/gcc/config/arm/constraints.md (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert;; Constraint definitions for ARM and Thumb
2*404b540aSrobert;; Copyright (C) 2006 Free Software Foundation, Inc.
3*404b540aSrobert;; Contributed by ARM Ltd.
4*404b540aSrobert
5*404b540aSrobert;; This file is part of GCC.
6*404b540aSrobert
7*404b540aSrobert;; GCC is free software; you can redistribute it and/or modify it
8*404b540aSrobert;; under the terms of the GNU General Public License as published
9*404b540aSrobert;; by the Free Software Foundation; either version 2, or (at your
10*404b540aSrobert;; option) any later version.
11*404b540aSrobert
12*404b540aSrobert;; GCC is distributed in the hope that it will be useful, but WITHOUT
13*404b540aSrobert;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14*404b540aSrobert;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15*404b540aSrobert;; License for more details.
16*404b540aSrobert
17*404b540aSrobert;; You should have received a copy of the GNU General Public License
18*404b540aSrobert;; along with GCC; see the file COPYING.  If not, write to
19*404b540aSrobert;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20*404b540aSrobert;; Boston, MA 02110-1301, USA.
21*404b540aSrobert
22*404b540aSrobert;; The following register constraints have been used:
23*404b540aSrobert;; - in ARM state: f, v, w, y, z
24*404b540aSrobert;; - in Thumb state: h, k, b
25*404b540aSrobert;; - in both states: l, c
26*404b540aSrobert;; In ARM state, 'l' is an alias for 'r'
27*404b540aSrobert
28*404b540aSrobert;; The following normal constraints have been used:
29*404b540aSrobert;; in ARM state: G, H, I, J, K, L, M
30*404b540aSrobert;; in Thumb state: I, J, K, L, M, N, O
31*404b540aSrobert
32*404b540aSrobert;; The following multi-letter normal constraints have been used:
33*404b540aSrobert;; in ARM state: Da, Db, Dc
34*404b540aSrobert
35*404b540aSrobert;; The following memory constraints have been used:
36*404b540aSrobert;; in ARM state: Q, Uq, Uv, Uy
37*404b540aSrobert
38*404b540aSrobert
39*404b540aSrobert(define_register_constraint "f" "TARGET_ARM ? FPA_REGS : NO_REGS"
40*404b540aSrobert "Legacy FPA registers @code{f0}-@code{f7}.")
41*404b540aSrobert
42*404b540aSrobert(define_register_constraint "v" "TARGET_ARM ? CIRRUS_REGS : NO_REGS"
43*404b540aSrobert "The Cirrus Maverick co-processor registers.")
44*404b540aSrobert
45*404b540aSrobert(define_register_constraint "w" "TARGET_ARM ? VFP_REGS : NO_REGS"
46*404b540aSrobert "The VFP registers @code{s0}-@code{s31}.")
47*404b540aSrobert
48*404b540aSrobert(define_register_constraint "y" "TARGET_REALLY_IWMMXT ? IWMMXT_REGS : NO_REGS"
49*404b540aSrobert "The Intel iWMMX co-processor registers.")
50*404b540aSrobert
51*404b540aSrobert(define_register_constraint "z"
52*404b540aSrobert "TARGET_REALLY_IWMMXT ? IWMMXT_GR_REGS : NO_REGS"
53*404b540aSrobert "The Intel iWMMX GR registers.")
54*404b540aSrobert
55*404b540aSrobert(define_register_constraint "l" "TARGET_THUMB ? LO_REGS : GENERAL_REGS"
56*404b540aSrobert "In Thumb state the core registers @code{r0}-@code{r7}.")
57*404b540aSrobert
58*404b540aSrobert(define_register_constraint "h" "TARGET_THUMB ? HI_REGS : NO_REGS"
59*404b540aSrobert "In Thumb state the core registers @code{r8}-@code{r15}.")
60*404b540aSrobert
61*404b540aSrobert(define_register_constraint "k" "TARGET_THUMB ? STACK_REG : NO_REGS"
62*404b540aSrobert "@internal
63*404b540aSrobert  Thumb only.  The stack register.")
64*404b540aSrobert
65*404b540aSrobert(define_register_constraint "b" "TARGET_THUMB ? BASE_REGS : NO_REGS"
66*404b540aSrobert "@internal
67*404b540aSrobert  Thumb only.  The union of the low registers and the stack register.")
68*404b540aSrobert
69*404b540aSrobert(define_register_constraint "c" "CC_REG"
70*404b540aSrobert "@internal The condition code register.")
71*404b540aSrobert
72*404b540aSrobert(define_constraint "I"
73*404b540aSrobert "In ARM state a constant that can be used as an immediate value in a Data
74*404b540aSrobert  Processing instruction.  In Thumb state a constant in the range 0-255."
75*404b540aSrobert (and (match_code "const_int")
76*404b540aSrobert      (match_test "TARGET_ARM ? const_ok_for_arm (ival)
77*404b540aSrobert		   : ival >= 0 && ival <= 255")))
78*404b540aSrobert
79*404b540aSrobert(define_constraint "J"
80*404b540aSrobert "In ARM state a constant in the range @minus{}4095-4095.  In Thumb state
81*404b540aSrobert  a constant in the range @minus{}255-@minus{}1."
82*404b540aSrobert (and (match_code "const_int")
83*404b540aSrobert      (match_test "TARGET_ARM ? (ival >= -4095 && ival <= 4095)
84*404b540aSrobert		   : (ival >= -255 && ival <= -1)")))
85*404b540aSrobert
86*404b540aSrobert(define_constraint "K"
87*404b540aSrobert "In ARM state a constant that satisfies the @code{I} constraint if inverted.
88*404b540aSrobert  In Thumb state a constant that satisfies the @code{I} constraint multiplied
89*404b540aSrobert  by any power of 2."
90*404b540aSrobert (and (match_code "const_int")
91*404b540aSrobert      (match_test "TARGET_ARM ? const_ok_for_arm (~ival)
92*404b540aSrobert		   : thumb_shiftable_const (ival)")))
93*404b540aSrobert
94*404b540aSrobert(define_constraint "L"
95*404b540aSrobert "In ARM state a constant that satisfies the @code{I} constraint if negated.
96*404b540aSrobert  In Thumb state a constant in the range @minus{}7-7."
97*404b540aSrobert (and (match_code "const_int")
98*404b540aSrobert      (match_test "TARGET_ARM ? const_ok_for_arm (-ival)
99*404b540aSrobert		   : (ival >= -7 && ival <= 7)")))
100*404b540aSrobert
101*404b540aSrobert;; The ARM state version is internal...
102*404b540aSrobert;; @internal In ARM state a constant in the range 0-32 or any power of 2.
103*404b540aSrobert(define_constraint "M"
104*404b540aSrobert "In Thumb state a constant that is a multiple of 4 in the range 0-1020."
105*404b540aSrobert (and (match_code "const_int")
106*404b540aSrobert      (match_test "TARGET_ARM ? ((ival >= 0 && ival <= 32)
107*404b540aSrobert				 || ((ival & (ival - 1)) == 0))
108*404b540aSrobert		   : ((ival >= 0 && ival <= 1020) && ((ival & 3) == 0))")))
109*404b540aSrobert
110*404b540aSrobert(define_constraint "N"
111*404b540aSrobert "In Thumb state a constant in the range 0-31."
112*404b540aSrobert (and (match_code "const_int")
113*404b540aSrobert      (match_test "TARGET_THUMB && ival >= 0 && ival <= 31")))
114*404b540aSrobert
115*404b540aSrobert(define_constraint "O"
116*404b540aSrobert "In Thumb state a constant that is a multiple of 4 in the range
117*404b540aSrobert  @minus{}508-508."
118*404b540aSrobert (and (match_code "const_int")
119*404b540aSrobert      (match_test "TARGET_THUMB && ival >= -508 && ival <= 508
120*404b540aSrobert		   && ((ival & 3) == 0)")))
121*404b540aSrobert
122*404b540aSrobert(define_constraint "G"
123*404b540aSrobert "In ARM state a valid FPA immediate constant."
124*404b540aSrobert (and (match_code "const_double")
125*404b540aSrobert      (match_test "TARGET_ARM && arm_const_double_rtx (op)")))
126*404b540aSrobert
127*404b540aSrobert(define_constraint "H"
128*404b540aSrobert "In ARM state a valid FPA immediate constant when negated."
129*404b540aSrobert (and (match_code "const_double")
130*404b540aSrobert      (match_test "TARGET_ARM && neg_const_double_rtx_ok_for_fpa (op)")))
131*404b540aSrobert
132*404b540aSrobert(define_constraint "Da"
133*404b540aSrobert "@internal
134*404b540aSrobert  In ARM state a const_int, const_double or const_vector that can
135*404b540aSrobert  be generated with two Data Processing insns."
136*404b540aSrobert (and (match_code "const_double,const_int,const_vector")
137*404b540aSrobert      (match_test "TARGET_ARM && arm_const_double_inline_cost (op) == 2")))
138*404b540aSrobert
139*404b540aSrobert(define_constraint "Db"
140*404b540aSrobert "@internal
141*404b540aSrobert  In ARM state a const_int, const_double or const_vector that can
142*404b540aSrobert  be generated with three Data Processing insns."
143*404b540aSrobert (and (match_code "const_double,const_int,const_vector")
144*404b540aSrobert      (match_test "TARGET_ARM && arm_const_double_inline_cost (op) == 3")))
145*404b540aSrobert
146*404b540aSrobert(define_constraint "Dc"
147*404b540aSrobert "@internal
148*404b540aSrobert  In ARM state a const_int, const_double or const_vector that can
149*404b540aSrobert  be generated with four Data Processing insns.  This pattern is disabled
150*404b540aSrobert  if optimizing for space or when we have load-delay slots to fill."
151*404b540aSrobert (and (match_code "const_double,const_int,const_vector")
152*404b540aSrobert      (match_test "TARGET_ARM && arm_const_double_inline_cost (op) == 4
153*404b540aSrobert		   && !(optimize_size || arm_ld_sched)")))
154*404b540aSrobert
155*404b540aSrobert(define_memory_constraint "Uv"
156*404b540aSrobert "@internal
157*404b540aSrobert  In ARM state a valid VFP load/store address."
158*404b540aSrobert (and (match_code "mem")
159*404b540aSrobert      (match_test "TARGET_ARM && arm_coproc_mem_operand (op, FALSE)")))
160*404b540aSrobert
161*404b540aSrobert(define_memory_constraint "Uy"
162*404b540aSrobert "@internal
163*404b540aSrobert  In ARM state a valid iWMMX load/store address."
164*404b540aSrobert (and (match_code "mem")
165*404b540aSrobert      (match_test "TARGET_ARM && arm_coproc_mem_operand (op, TRUE)")))
166*404b540aSrobert
167*404b540aSrobert(define_memory_constraint "Uq"
168*404b540aSrobert "@internal
169*404b540aSrobert  In ARM state an address valid in ldrsb instructions."
170*404b540aSrobert (and (match_code "mem")
171*404b540aSrobert      (match_test "TARGET_ARM
172*404b540aSrobert		   && arm_legitimate_address_p (GET_MODE (op), XEXP (op, 0),
173*404b540aSrobert						SIGN_EXTEND, 0)")))
174*404b540aSrobert
175*404b540aSrobert(define_memory_constraint "Q"
176*404b540aSrobert "@internal
177*404b540aSrobert  In ARM state an address that is a single base register."
178*404b540aSrobert (and (match_code "mem")
179*404b540aSrobert      (match_test "REG_P (XEXP (op, 0))")))
180*404b540aSrobert
181*404b540aSrobert;; We used to have constraint letters for S and R in ARM state, but
182*404b540aSrobert;; all uses of these now appear to have been removed.
183*404b540aSrobert
184*404b540aSrobert;; Additionally, we used to have a Q constraint in Thumb state, but
185*404b540aSrobert;; this wasn't really a valid memory constraint.  Again, all uses of
186*404b540aSrobert;; this now seem to have been removed.
187