constraints.md revision 1.1.1.7 1 ;; Machine Description for Renesas RL78 processors
2 ;; Copyright (C) 2011-2020 Free Software Foundation, Inc.
3 ;; Contributed by Red Hat.
4
5 ;; This file is part of GCC.
6
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
10 ;; any later version.
11
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
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/>.
20
22 ; Constraints in use:
23
24 ; core:
25 ; V X g i m n o p r s < >
26 ; 0..9
27 ; I..Q - integers
28 ; Int8 = 0..255
29 ; Int3 = 1..7
30 ; J = -255..0
31 ; K = 1
32 ; L = -1
33 ; M = 0
34 ; N = 2
35 ; O = -2
36 ; P = 1..15
37
38 ; E..H - float constants
39
40 ; RL78-specific
41 ; a x b c d e h l w - 8-bit regs
42 ; A B D T S - 16-bit regs
43 ; R = all regular registers (A-L)
44 ; Y - any valid memory
45 ; Wxx - various memory addressing modes
46 ; Qxx - conditionals
47 ; U = usual memory references mov-able to/from AX
48 ; v = virtual registers
49 ; Zxx = specific virtual registers
50
51 (define_constraint "Int8"
52 "Integer constant in the range 0 @dots{} 255."
53 (and (match_code "const_int")
54 (match_test "IN_RANGE (ival, 0, 255)")))
55
56 (define_constraint "Int3"
57 "Integer constant in the range 1 @dots{} 7."
58 (and (match_code "const_int")
59 (match_test "IN_RANGE (ival, 1, 7)")))
60
61 (define_constraint "Iv08"
62 "@internal
63 Integer constant equal to 8."
64 (and (match_code "const_int")
65 (match_test "IN_RANGE (ival, 8, 8)")))
66
67 (define_constraint "Iv16"
68 "@internal
69 Integer constant equal to 16."
70 (and (match_code "const_int")
71 (match_test "IN_RANGE (ival, 16, 16)")))
72
73 (define_constraint "Iv24"
74 "@internal
75 Integer constant equal to 24."
76 (and (match_code "const_int")
77 (match_test "IN_RANGE (ival, 24, 24)")))
78
79 (define_constraint "Is09"
80 "@internal
81 Integer constant in the range 9 @dots{} 15 (for shifts)."
82 (and (match_code "const_int")
83 (match_test "IN_RANGE (ival, 9, 15)")))
84
85 (define_constraint "Is17"
86 "@internal
87 Integer constant in the range 17 @dots{} 23 (for shifts)."
88 (and (match_code "const_int")
89 (match_test "IN_RANGE (ival, 17, 23)")))
90
91 (define_constraint "Is25"
92 "@internal
93 Integer constant in the range 25 @dots{} 31 (for shifts)."
94 (and (match_code "const_int")
95 (match_test "IN_RANGE (ival, 25, 31)")))
96
97 (define_constraint "ISsi"
98 "@internal
99 Integer constant with bit 31 set."
100 (and (match_code "const_int")
101 (match_test "(ival & 0x80000000) != 0")))
102
103 (define_constraint "IShi"
104 "@internal
105 Integer constant with bit 15 set."
106 (and (match_code "const_int")
107 (match_test "(ival & 0x8000) != 0")))
108
109 (define_constraint "ISqi"
110 "@internal
111 Integer constant with bit 7 set."
112 (and (match_code "const_int")
113 (match_test "(ival & 0x80) != 0")))
114
115 (define_constraint "Ibqi"
116 "@internal
117 Integer constant with one bit in 0..7 set."
118 (and (match_code "const_int")
119 (match_test "(ival & 0xff) && (exact_log2 (ival & 0xff) >= 0)")))
120 (define_constraint "IBqi"
121 "@internal
122 Integer constant with one bit in 0..7 clear."
123 (and (match_code "const_int")
124 (match_test "(~ival & 0xff) && (exact_log2 (~ival & 0xff) >= 0)")))
125
126 (define_constraint "J"
127 "Integer constant in the range -255 @dots{} 0"
128 (and (match_code "const_int")
129 (match_test "IN_RANGE (ival, -255, 0)")))
130
131 (define_constraint "K"
132 "Integer constant 1."
133 (and (match_code "const_int")
134 (match_test "IN_RANGE (ival, 1, 1)")))
135
136 (define_constraint "L"
137 "Integer constant -1."
138 (and (match_code "const_int")
139 (match_test "IN_RANGE (ival, -1, -1)")))
140
141 (define_constraint "M"
142 "Integer constant 0."
143 (and (match_code "const_int")
144 (match_test "IN_RANGE (ival, 0, 0)")))
145
146 (define_constraint "N"
147 "Integer constant 2."
148 (and (match_code "const_int")
149 (match_test "IN_RANGE (ival, 2, 2)")))
150
151 (define_constraint "O"
152 "Integer constant -2."
153 (and (match_code "const_int")
154 (match_test "IN_RANGE (ival, -2, -2)")))
155
156 (define_constraint "P"
157 "Integer constant 1..15"
158 (and (match_code "const_int")
159 (match_test "IN_RANGE (ival, 1, 15)")))
160
161 (define_register_constraint "R" "QI_REGS"
162 "@code{A} through @code{L} registers.")
163
164 (define_register_constraint "a" "AREG"
165 "The @code{A} register.")
166
167 (define_register_constraint "x" "XREG"
168 "The @code{X} register.")
169
170 (define_register_constraint "b" "BREG"
171 "The @code{B} register.")
172
173 (define_register_constraint "c" "CREG"
174 "The @code{C} register.")
175
176 (define_register_constraint "d" "DREG"
177 "The @code{D} register.")
178
179 (define_register_constraint "e" "EREG"
180 "The @code{E} register.")
181
182 (define_register_constraint "h" "HREG"
183 "The @code{H} register.")
184
185 (define_register_constraint "l" "LREG"
186 "The @code{L} register.")
187
188 (define_register_constraint "w" "PSWREG"
189 "The @code{PSW} register.")
190
191 (define_register_constraint "A" "AXREG"
192 "The @code{AX} register.")
193
194 (define_register_constraint "B" "BCREG"
195 "The @code{BC} register.")
196
197 (define_register_constraint "D" "DEREG"
198 "The @code{DE} register.")
199
200 ; because H + L = T, assuming A=1.
201 (define_register_constraint "T" "HLREG"
202 "The @code{HL} register.")
203
204 (define_register_constraint "S" "SPREG"
205 "The @code{SP} register.")
206
207 (define_register_constraint "v" "V_REGS"
208 "The virtual registers.")
209
210 (define_register_constraint "Z08W" "R8W_REGS"
211 "The R8 register, HImode.")
212
213 (define_register_constraint "Z10W" "R10W_REGS"
214 "The R10 register, HImode.")
215
216 (define_register_constraint "Zint" "INT_REGS"
217 "The interrupt registers.")
218
219 ; All the memory addressing schemes the RL78 supports
220 ; of the form W {register} {bytes of offset}
221 ; or W {register} {register}
222 ; Additionally, the Cxx forms are the same as the Wxx forms, but without
223 ; the ES: override.
224
225 ; absolute address
226 (define_memory_constraint "Cab"
227 "[addr]"
228 (and (match_code "mem")
229 (ior (match_test "CONSTANT_P (XEXP (op, 0))")
230 (match_test "GET_CODE (XEXP (op, 0)) == PLUS && GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF"))
231 )
232 )
233 (define_memory_constraint "Wab"
234 "es:[addr]"
235 (match_test "(rl78_es_addr (op) && satisfies_constraint_Cab (rl78_es_base (op)))
236 || satisfies_constraint_Cab (op)")
237 )
238
239 (define_memory_constraint "Cbc"
240 "word16[BC]"
241 (and (match_code "mem")
242 (ior
243 (and (match_code "reg" "0")
244 (match_test "REGNO (XEXP (op, 0)) == BC_REG"))
245 (and (match_code "plus" "0")
246 (and (and (match_code "reg" "00")
247 (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == BC_REG"))
248 (match_test "uword_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
249 )
250 )
251 (define_memory_constraint "Wbc"
252 "es:word16[BC]"
253 (match_test "(rl78_es_addr (op) && satisfies_constraint_Cbc (rl78_es_base (op)))
254 || satisfies_constraint_Cbc (op)")
255 )
256
257 (define_memory_constraint "Cde"
258 "[DE]"
259 (and (match_code "mem")
260 (and (match_code "reg" "0")
261 (match_test "REGNO (XEXP (op, 0)) == DE_REG")))
262 )
263 (define_memory_constraint "Wde"
264 "es:[DE]"
265 (match_test "(rl78_es_addr (op) && satisfies_constraint_Cde (rl78_es_base (op)))
266 || satisfies_constraint_Cde (op)")
267 )
268
269 (define_memory_constraint "Cca"
270 "[AX..HL] for calls"
271 (and (match_code "mem")
272 (and (match_code "reg" "0")
273 (match_test "REGNO (XEXP (op, 0)) <= HL_REG")))
274 )
275 (define_memory_constraint "Wca"
276 "es:[AX..HL] for calls"
277 (match_test "(rl78_es_addr (op) && satisfies_constraint_Cca (rl78_es_base (op)))
278 || satisfies_constraint_Cca (op)")
279 )
280
281 (define_memory_constraint "Ccv"
282 "[AX..HL,r8-r31] for calls"
283 (and (match_code "mem")
284 (and (match_code "reg" "0")
285 (match_test "REGNO (XEXP (op, 0)) < 32")))
286 )
287 (define_memory_constraint "Wcv"
288 "es:[AX..HL,r8-r31] for calls"
289 (match_test "(rl78_es_addr (op) && satisfies_constraint_Ccv (rl78_es_base (op)))
290 || satisfies_constraint_Ccv (op)")
291 )
292
293 (define_memory_constraint "Cd2"
294 "word16[DE]"
295 (and (match_code "mem")
296 (ior
297 (and (match_code "reg" "0")
298 (match_test "REGNO (XEXP (op, 0)) == DE_REG"))
299 (and (match_code "plus" "0")
300 (and (and (match_code "reg" "00")
301 (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == DE_REG"))
302 (match_test "uword_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
303 )
304 )
305 (define_memory_constraint "Wd2"
306 "es:word16[DE]"
307 (match_test "(rl78_es_addr (op) && satisfies_constraint_Cd2 (rl78_es_base (op)))
308 || satisfies_constraint_Cd2 (op)")
309 )
310
311 (define_memory_constraint "Chl"
312 "[HL]"
313 (and (match_code "mem")
314 (and (match_code "reg" "0")
315 (match_test "REGNO (XEXP (op, 0)) == HL_REG")))
316 )
317 (define_memory_constraint "Whl"
318 "es:[HL]"
319 (match_test "(rl78_es_addr (op) && satisfies_constraint_Chl (rl78_es_base (op)))
320 || satisfies_constraint_Chl (op)")
321 )
322
323 (define_memory_constraint "Ch1"
324 "byte8[HL]"
325 (and (match_code "mem")
326 (and (match_code "plus" "0")
327 (and (and (match_code "reg" "00")
328 (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == HL_REG"))
329 (match_test "ubyte_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
330 )
331 (define_memory_constraint "Wh1"
332 "es:byte8[HL]"
333 (match_test "(rl78_es_addr (op) && satisfies_constraint_Ch1 (rl78_es_base (op)))
334 || satisfies_constraint_Ch1 (op)")
335 )
336
337 (define_memory_constraint "Chb"
338 "[HL+B]"
339 (and (match_code "mem")
340 (match_test "rl78_hl_b_c_addr_p (XEXP (op, 0))"))
341 )
342 (define_memory_constraint "Whb"
343 "es:[HL+B]"
344 (match_test "(rl78_es_addr (op) && satisfies_constraint_Chb (rl78_es_base (op)))
345 || satisfies_constraint_Chb (op)")
346 )
347
348 (define_memory_constraint "Cs1"
349 "word8[SP]"
350 (and (match_code "mem")
351 (ior
352 (and (match_code "reg" "0")
353 (match_test "REGNO (XEXP (op, 0)) == SP_REG"))
354 (and (match_code "plus" "0")
355 (and (and (match_code "reg" "00")
356 (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == SP_REG"))
357 (and (match_code "const_int" "01")
358 (match_test "IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), 0, 256 - GET_MODE_SIZE (GET_MODE (op)))")))))
359 )
360 )
361
362 (define_memory_constraint "Ws1"
363 "es:word8[SP]"
364 (match_test "(rl78_es_addr (op) && satisfies_constraint_Cs1 (rl78_es_base (op)))
365 || satisfies_constraint_Cs1 (op)")
366 )
367
368 (define_constraint "Wfr"
369 "ES/CS far pointer"
370 (and (match_code "mem")
371 (match_test "rl78_far_p (op)"))
372 )
373
374 (define_memory_constraint "Wsa"
375 "any SADDR memory access"
376 (and (match_code "mem")
377 (match_test "rl78_saddr_p (op)"))
378 )
379
380 (define_memory_constraint "Wsf"
381 "any SFR memory access"
382 (and (match_code "mem")
383 (match_test "rl78_sfr_p (op)"))
384 )
385
386 (define_memory_constraint "Y"
387 "any near legitimate memory access"
388 (and (match_code "mem")
389 (match_test "!rl78_far_p (op) && rl78_as_legitimate_address (VOIDmode, XEXP (op, 0), true, ADDR_SPACE_GENERIC)"))
390 )
391
392 (define_memory_constraint "U"
393 "memory references valid with mov to/from a/ax"
394 (and (match_code "mem")
395 (match_test "rl78_virt_insns_ok ()
396 || satisfies_constraint_Wab (op)
397 || satisfies_constraint_Wbc (op)
398 || satisfies_constraint_Wde (op)
399 || satisfies_constraint_Wd2 (op)
400 || satisfies_constraint_Whl (op)
401 || satisfies_constraint_Wh1 (op)
402 || satisfies_constraint_Whb (op)
403 || satisfies_constraint_Ws1 (op)
404 || satisfies_constraint_Wfr (op) ")))
405
406 (define_memory_constraint "Qbi"
407 "built-in compare types"
408 (match_code "eq,ne,gtu,ltu,geu,leu"))
409
410 (define_memory_constraint "Qsc"
411 "synthetic compares"
412 (match_code "gt,lt,ge,le"))
413
414 (define_constraint "Qs8"
415 "Integer constant computed from (SUBREG (SYMREF))."
416 (and (match_code "subreg")
417 (match_test "GET_CODE (XEXP (op, 0)) == SYMBOL_REF"))
418 )
419