constraints.md revision 1.10 1 1.1 mrg ;; Constraint definitions for Renesas H8/300.
2 1.10 mrg ;; Copyright (C) 2011-2022 Free Software Foundation, Inc.
3 1.1 mrg ;;
4 1.1 mrg ;; This file is part of GCC.
5 1.1 mrg ;;
6 1.1 mrg ;; GCC is free software; you can redistribute it and/or modify
7 1.1 mrg ;; it under the terms of the GNU General Public License as published by
8 1.1 mrg ;; the Free Software Foundation; either version 3, or (at your option)
9 1.1 mrg ;; any later version.
10 1.1 mrg ;;
11 1.1 mrg ;; GCC is distributed in the hope that it will be useful,
12 1.1 mrg ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 1.1 mrg ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 1.1 mrg ;; GNU General Public License for more details.
15 1.1 mrg ;;
16 1.1 mrg ;; You should have received a copy of the GNU General Public License
17 1.1 mrg ;; along with GCC; see the file COPYING3. If not see
18 1.1 mrg ;; <http://www.gnu.org/licenses/>.
19 1.1 mrg
20 1.1 mrg ;; Register constraints.
21 1.1 mrg (define_register_constraint "a" "MAC_REGS"
22 1.1 mrg "@internal")
23 1.1 mrg
24 1.1 mrg (define_register_constraint "c" "COUNTER_REGS"
25 1.1 mrg "@internal")
26 1.1 mrg
27 1.1 mrg ;; Some patterns need to use er6 as a scratch register. This is
28 1.1 mrg ;; difficult to arrange since er6 is the frame pointer and usually can't
29 1.1 mrg ;; be spilled.
30 1.1 mrg
31 1.1 mrg ;; Such patterns should define two alternatives, one which allows only
32 1.1 mrg ;; er6 and one which allows any general register. The former
33 1.1 mrg ;; alternative should have a 'd' constraint while the latter should be
34 1.1 mrg ;; disparaged and use 'D'.
35 1.1 mrg
36 1.1 mrg ;; Normally, 'd' maps to DESTINATION_REGS and 'D' maps to GENERAL_REGS.
37 1.1 mrg ;; However, there are cases where they should be NO_REGS:
38 1.1 mrg
39 1.1 mrg ;; - 'd' should be NO_REGS when reloading a function that uses the
40 1.1 mrg ;; frame pointer. In this case, DESTINATION_REGS won't contain any
41 1.1 mrg ;; spillable registers, so the first alternative can't be used.
42 1.1 mrg
43 1.1 mrg ;; - -fno-omit-frame-pointer means that the frame pointer will
44 1.1 mrg ;; always be in use. It's therefore better to map 'd' to NO_REGS
45 1.1 mrg ;; before reload so that register allocator will pick the second
46 1.1 mrg ;; alternative.
47 1.1 mrg
48 1.4 mrg ;; - we would like 'D' to be NO_REGS when the frame pointer isn't
49 1.1 mrg ;; live, but we the frame pointer may turn out to be needed after
50 1.1 mrg ;; we start reload, and then we may have already decided we don't
51 1.1 mrg ;; have a choice, so we can't do that. Forcing the register
52 1.1 mrg ;; allocator to use er6 if possible might produce better code for
53 1.1 mrg ;; small functions: it's more efficient to save and restore er6 in
54 1.1 mrg ;; the prologue & epilogue than to do it in a define_split.
55 1.1 mrg ;; Hopefully disparaging 'D' will have a similar effect, without
56 1.1 mrg ;; forcing a reload failure if the frame pointer is found to be
57 1.1 mrg ;; needed too late.
58 1.1 mrg
59 1.1 mrg (define_register_constraint "d"
60 1.1 mrg "(!flag_omit_frame_pointer && !reload_completed
61 1.1 mrg ? NO_REGS
62 1.1 mrg : (frame_pointer_needed && reload_in_progress
63 1.1 mrg ? NO_REGS
64 1.1 mrg : DESTINATION_REGS))"
65 1.1 mrg "@internal")
66 1.1 mrg
67 1.1 mrg (define_register_constraint "D" "GENERAL_REGS"
68 1.1 mrg "@internal")
69 1.1 mrg
70 1.1 mrg (define_register_constraint "f" "SOURCE_REGS"
71 1.1 mrg "@internal")
72 1.1 mrg
73 1.1 mrg ;; Integer constraints.
74 1.1 mrg (define_constraint "I"
75 1.1 mrg "Integer zero."
76 1.1 mrg (and (match_code "const_int")
77 1.1 mrg (match_test "ival == 0")))
78 1.1 mrg
79 1.1 mrg (define_constraint "J"
80 1.1 mrg "An integer with its low byte clear."
81 1.1 mrg (and (match_code "const_int")
82 1.1 mrg (match_test "(ival & 0xff) == 0")))
83 1.1 mrg
84 1.1 mrg (define_constraint "L"
85 1.10 mrg "Integer 1, 2 or 4"
86 1.1 mrg (and (match_code "const_int")
87 1.10 mrg (match_test "ival == 1 || ival == 2 || ival == 4")))
88 1.1 mrg
89 1.1 mrg (define_constraint "M"
90 1.1 mrg "Integer 1 or 2."
91 1.1 mrg (and (match_code "const_int")
92 1.1 mrg (match_test "ival == 1 || ival == 2")))
93 1.1 mrg
94 1.1 mrg (define_constraint "N"
95 1.10 mrg "Integer -1, -2 or -4"
96 1.1 mrg (and (match_code "const_int")
97 1.10 mrg (match_test "ival == -1 || ival == -2 || ival == -4")))
98 1.1 mrg
99 1.1 mrg (define_constraint "O"
100 1.1 mrg "Integer -1 or -2."
101 1.1 mrg (and (match_code "const_int")
102 1.1 mrg (match_test "ival == -1 || ival == -2")))
103 1.1 mrg
104 1.1 mrg (define_constraint "P1>X"
105 1.1 mrg "A positive, non-zero integer that fits in 1 bits."
106 1.1 mrg (and (match_code "const_int")
107 1.1 mrg (match_test "TARGET_H8300SX")
108 1.1 mrg (match_test "IN_RANGE (ival, 1, (1 << 1) - 1)")))
109 1.1 mrg
110 1.1 mrg (define_constraint "P3>X"
111 1.1 mrg "A positive, non-zero integer that fits in 3 bits."
112 1.1 mrg (and (match_code "const_int")
113 1.1 mrg (match_test "TARGET_H8300SX")
114 1.1 mrg (match_test "IN_RANGE (ival, 1, (1 << 3) - 1)")))
115 1.1 mrg
116 1.1 mrg (define_constraint "P4>X"
117 1.1 mrg "A positive, non-zero integer that fits in 4 bits."
118 1.1 mrg (and (match_code "const_int")
119 1.1 mrg (match_test "TARGET_H8300SX")
120 1.1 mrg (match_test "IN_RANGE (ival, 1, (1 << 4) - 1)")))
121 1.1 mrg
122 1.1 mrg (define_constraint "P5>X"
123 1.1 mrg "A positive, non-zero integer that fits in 5 bits."
124 1.1 mrg (and (match_code "const_int")
125 1.1 mrg (match_test "TARGET_H8300SX")
126 1.1 mrg (match_test "IN_RANGE (ival, 1, (1 << 5) - 1)")))
127 1.1 mrg
128 1.1 mrg (define_constraint "P8>X"
129 1.1 mrg "A positive, non-zero integer that fits in 8 bits."
130 1.1 mrg (and (match_code "const_int")
131 1.1 mrg (match_test "TARGET_H8300SX")
132 1.1 mrg (match_test "IN_RANGE (ival, 1, (1 << 8) - 1)")))
133 1.1 mrg
134 1.1 mrg (define_constraint "P3<X"
135 1.1 mrg "A negative, non-zero integer that fits in 3 bits."
136 1.1 mrg (and (match_code "const_int")
137 1.1 mrg (match_test "TARGET_H8300SX")
138 1.1 mrg (match_test "IN_RANGE (ival, (-(1 << 3)) + 1, -1)")))
139 1.1 mrg
140 1.1 mrg ;; Floating-point constraints.
141 1.1 mrg (define_constraint "G"
142 1.1 mrg "Single-float zero."
143 1.1 mrg (and (match_code "const_double")
144 1.1 mrg (match_test "op == CONST0_RTX (SFmode)")))
145 1.1 mrg
146 1.1 mrg ;; Extra constraints.
147 1.1 mrg (define_constraint "Q"
148 1.1 mrg "@internal"
149 1.1 mrg (and (match_test "TARGET_H8300SX")
150 1.1 mrg (match_operand 0 "memory_operand")))
151 1.1 mrg
152 1.1 mrg (define_constraint "R"
153 1.1 mrg "@internal"
154 1.1 mrg (and (match_code "const_int")
155 1.10 mrg (match_test "!h8300_shift_needs_scratch_p (ival, QImode, CLOBBER)")))
156 1.1 mrg
157 1.8 mrg (define_constraint "C"
158 1.8 mrg "@internal"
159 1.8 mrg (match_code "symbol_ref"))
160 1.8 mrg
161 1.1 mrg (define_constraint "S"
162 1.1 mrg "@internal"
163 1.1 mrg (and (match_code "const_int")
164 1.10 mrg (match_test "!h8300_shift_needs_scratch_p (ival, HImode, CLOBBER)")))
165 1.1 mrg
166 1.1 mrg (define_constraint "T"
167 1.1 mrg "@internal"
168 1.1 mrg (and (match_code "const_int")
169 1.10 mrg (match_test "!h8300_shift_needs_scratch_p (ival, SImode, CLOBBER)")))
170 1.1 mrg
171 1.1 mrg (define_constraint "U"
172 1.1 mrg "An operand valid for a bset destination."
173 1.1 mrg (ior (and (match_code "reg")
174 1.3 mrg (match_test "(reload_in_progress || reload_completed)
175 1.3 mrg ? REG_OK_FOR_BASE_STRICT_P (op)
176 1.3 mrg : REG_OK_FOR_BASE_P (op)"))
177 1.1 mrg (and (match_code "mem")
178 1.1 mrg (match_code "reg" "0")
179 1.3 mrg (match_test "(reload_in_progress || reload_completed)
180 1.3 mrg ? REG_OK_FOR_BASE_STRICT_P (XEXP (op, 0))
181 1.3 mrg : REG_OK_FOR_BASE_P (XEXP (op, 0))"))
182 1.1 mrg (and (match_code "mem")
183 1.1 mrg (match_code "symbol_ref" "0")
184 1.1 mrg (match_test "TARGET_H8300S"))
185 1.1 mrg (and (match_code "mem")
186 1.1 mrg (match_code "const" "0")
187 1.1 mrg (match_code "plus" "00")
188 1.1 mrg (match_code "symbol_ref" "000")
189 1.1 mrg (match_code "const_int" "001")
190 1.1 mrg (ior (match_test "TARGET_H8300S")
191 1.3 mrg (match_test "(SYMBOL_REF_FLAGS (XEXP (XEXP (XEXP (op, 0), 0), 0)) & SYMBOL_FLAG_EIGHTBIT_DATA) != 0")))
192 1.1 mrg (and (match_code "mem")
193 1.1 mrg (match_test "h8300_eightbit_constant_address_p (XEXP (op, 0))"))
194 1.1 mrg (and (match_code "mem")
195 1.1 mrg (ior (match_test "TARGET_H8300S")
196 1.1 mrg (match_test "TARGET_H8300SX"))
197 1.1 mrg (match_code "const_int" "0"))))
198 1.1 mrg
199 1.1 mrg (define_memory_constraint "WU"
200 1.1 mrg "@internal"
201 1.1 mrg (and (match_code "mem")
202 1.1 mrg (match_test "satisfies_constraint_U (op)")))
203 1.1 mrg
204 1.1 mrg (define_constraint "Y0"
205 1.1 mrg "@internal"
206 1.1 mrg (and (match_code "const_int")
207 1.1 mrg (match_test "exact_log2 (~ival & 0xff) != -1")))
208 1.1 mrg
209 1.1 mrg (define_constraint "Y2"
210 1.1 mrg "@internal"
211 1.1 mrg (and (match_code "const_int")
212 1.1 mrg (match_test "exact_log2 (ival & 0xff) != -1")))
213 1.1 mrg
214 1.1 mrg (define_constraint "Z"
215 1.1 mrg "@internal"
216 1.1 mrg (and (match_test "TARGET_H8300SX")
217 1.1 mrg (match_code "mem")
218 1.1 mrg (match_test "CONSTANT_P (XEXP (op, 0))")))
219