Fixups after merge
[official-gcc.git] / gcc / config / rl78 / constraints.md
blob3f5e490850279ba7a2cc333f101a608e2e977ab2
1 ;;  Machine Description for Renesas RL78 processors
2 ;;  Copyright (C) 2011-2014 Free Software Foundation, Inc.
3 ;;  Contributed by Red Hat.
5 ;; This file is part of GCC.
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.
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.
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 ; Constraints in use:
23 ; core:
24 ; V X g i m n o p r s < >
25 ; 0..9
26 ; I..Q - integers
27 ;   Int8 = 0..255
28 ;   Int3 = 1..7
29 ;   J = -255..0
30 ;   K = 1
31 ;   L = -1
32 ;   M = 0
33 ;   N = 2
34 ;   O = -2
35 ;   P = 1..15
37 ; E..H - float constants
39 ; RL78-specific
40 ; a x b c d e h l w - 8-bit regs
41 ; A B D T S - 16-bit regs
42 ; R = all regular registers (A-L)
43 ; Y - any valid memory
44 ; Wxx - various memory addressing modes
45 ; Qxx - conditionals
46 ; U = usual memory references mov-able to/from AX
47 ; v = virtual registers
48 ; Zxx = specific virtual registers
50 (define_constraint "Int8"
51   "Integer constant in the range 0 @dots{} 255."
52   (and (match_code "const_int")
53        (match_test "IN_RANGE (ival, 0, 255)")))
55 (define_constraint "Int3"
56   "Integer constant in the range 1 @dots{} 7."
57   (and (match_code "const_int")
58        (match_test "IN_RANGE (ival, 1, 7)")))
60 (define_constraint "Iv08"
61   "@internal
62    Integer constant equal to 8."
63   (and (match_code "const_int")
64        (match_test "IN_RANGE (ival, 8, 8)")))
66 (define_constraint "Iv16"
67   "@internal
68    Integer constant equal to 16."
69   (and (match_code "const_int")
70        (match_test "IN_RANGE (ival, 16, 16)")))
72 (define_constraint "Iv24"
73   "@internal
74    Integer constant equal to 24."
75   (and (match_code "const_int")
76        (match_test "IN_RANGE (ival, 24, 24)")))
78 (define_constraint "Is09"
79   "@internal
80    Integer constant in the range 9 @dots{} 15 (for shifts)."
81   (and (match_code "const_int")
82        (match_test "IN_RANGE (ival, 9, 15)")))
84 (define_constraint "Is17"
85   "@internal
86    Integer constant in the range 17 @dots{} 23 (for shifts)."
87   (and (match_code "const_int")
88        (match_test "IN_RANGE (ival, 17, 23)")))
90 (define_constraint "Is25"
91   "@internal
92    Integer constant in the range 25 @dots{} 31 (for shifts)."
93   (and (match_code "const_int")
94        (match_test "IN_RANGE (ival, 25, 31)")))
96 (define_constraint "ISsi"
97   "@internal
98    Integer constant with bit 31 set."
99   (and (match_code "const_int")
100        (match_test "(ival & 0x80000000) != 0")))
102 (define_constraint "IShi"
103   "@internal
104    Integer constant with bit 15 set."
105   (and (match_code "const_int")
106        (match_test "(ival & 0x8000) != 0")))
108 (define_constraint "ISqi"
109   "@internal
110    Integer constant with bit 7 set."
111   (and (match_code "const_int")
112        (match_test "(ival & 0x80) != 0")))
114 (define_constraint "J"
115   "Integer constant in the range -255 @dots{} 0"
116   (and (match_code "const_int")
117        (match_test "IN_RANGE (ival, -255, 0)")))
119 (define_constraint "K"
120   "Integer constant 1."
121   (and (match_code "const_int")
122        (match_test "IN_RANGE (ival, 1, 1)")))
124 (define_constraint "L"
125   "Integer constant -1."
126   (and (match_code "const_int")
127        (match_test "IN_RANGE (ival, -1, -1)")))
129 (define_constraint "M"
130   "Integer constant 0."
131   (and (match_code "const_int")
132        (match_test "IN_RANGE (ival, 0, 0)")))
134 (define_constraint "N"
135   "Integer constant 2."
136   (and (match_code "const_int")
137        (match_test "IN_RANGE (ival, 2, 2)")))
139 (define_constraint "O"
140   "Integer constant -2."
141   (and (match_code "const_int")
142        (match_test "IN_RANGE (ival, -2, -2)")))
144 (define_constraint "P"
145   "Integer constant 1..15"
146   (and (match_code "const_int")
147        (match_test "IN_RANGE (ival, 1, 15)")))
149 (define_register_constraint "R" "QI_REGS"
150  "@code{A} through @code{L} registers.")
152 (define_register_constraint "a" "AREG"
153  "The @code{A} register.")
155 (define_register_constraint "x" "XREG"
156  "The @code{X} register.")
158 (define_register_constraint "b" "BREG"
159  "The @code{B} register.")
161 (define_register_constraint "c" "CREG"
162  "The @code{C} register.")
164 (define_register_constraint "d" "DREG"
165  "The @code{D} register.")
167 (define_register_constraint "e" "EREG"
168  "The @code{E} register.")
170 (define_register_constraint "h" "HREG"
171  "The @code{H} register.")
173 (define_register_constraint "l" "LREG"
174  "The @code{L} register.")
176 (define_register_constraint "w" "PSWREG"
177  "The @code{PSW} register.")
179 (define_register_constraint "A" "AXREG"
180  "The @code{AX} register.")
182 (define_register_constraint "B" "BCREG"
183  "The @code{BC} register.")
185 (define_register_constraint "D" "DEREG"
186  "The @code{DE} register.")
188 ; because H + L = T, assuming A=1.
189 (define_register_constraint "T" "HLREG"
190  "The @code{HL} register.")
192 (define_register_constraint "S" "SPREG"
193  "The @code{SP} register.")
195 (define_register_constraint "v" "V_REGS"
196  "The virtual registers.")
198 (define_register_constraint "Z08W" "R8W_REGS"
199  "The R8 register, HImode.")
201 (define_register_constraint "Z10W" "R10W_REGS"
202  "The R10 register, HImode.")
204 (define_register_constraint "Zint" "INT_REGS"
205  "The interrupt registers.")
207 ; All the memory addressing schemes the RL78 supports
208 ; of the form W {register} {bytes of offset}
209 ;          or W {register} {register}
210 ; Additionally, the Cxx forms are the same as the Wxx forms, but without
211 ; the ES: override.
213 ; absolute address
214 (define_memory_constraint "Cab"
215   "[addr]"
216   (and (match_code "mem")
217        (ior (match_test "CONSTANT_P (XEXP (op, 0))")
218             (match_test "GET_CODE (XEXP (op, 0)) == PLUS && GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF"))
219             )
220   )
221 (define_memory_constraint "Wab"
222   "es:[addr]"
223   (match_test "(rl78_es_addr (op) && satisfies_constraint_Cab (rl78_es_base (op)))
224                || satisfies_constraint_Cab (op)")
225   )
227 (define_memory_constraint "Cbc"
228   "word16[BC]"
229   (and (match_code "mem")
230        (ior
231         (and (match_code "reg" "0")
232              (match_test "REGNO (XEXP (op, 0)) == BC_REG"))
233         (and (match_code "plus" "0")
234              (and (and (match_code "reg" "00")
235                        (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == BC_REG"))
236                        (match_test "uword_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
237        )
238   )
239 (define_memory_constraint "Wbc"
240   "es:word16[BC]"
241   (match_test "(rl78_es_addr (op) && satisfies_constraint_Cbc (rl78_es_base (op)))
242                || satisfies_constraint_Cbc (op)")
243   )
245 (define_memory_constraint "Cde"
246   "[DE]"
247   (and (match_code "mem")
248        (and (match_code "reg" "0")
249             (match_test "REGNO (XEXP (op, 0)) == DE_REG")))
250   )
251 (define_memory_constraint "Wde"
252   "es:[DE]"
253   (match_test "(rl78_es_addr (op) && satisfies_constraint_Cde (rl78_es_base (op)))
254                || satisfies_constraint_Cde (op)")
255   )
257 (define_memory_constraint "Cca"
258   "[AX..HL] for calls"
259   (and (match_code "mem")
260        (and (match_code "reg" "0")
261             (match_test "REGNO (XEXP (op, 0)) <= HL_REG")))
262   )
263 (define_memory_constraint "Wca"
264   "es:[AX..HL] for calls"
265   (match_test "(rl78_es_addr (op) && satisfies_constraint_Cca (rl78_es_base (op)))
266                || satisfies_constraint_Cca (op)")
267   )
269 (define_memory_constraint "Ccv"
270   "[AX..HL,r8-r31] for calls"
271   (and (match_code "mem")
272        (and (match_code "reg" "0")
273             (match_test "REGNO (XEXP (op, 0)) < 32")))
274   )
275 (define_memory_constraint "Wcv"
276   "es:[AX..HL,r8-r31] for calls"
277   (match_test "(rl78_es_addr (op) && satisfies_constraint_Ccv (rl78_es_base (op)))
278                || satisfies_constraint_Ccv (op)")
279   )
281 (define_memory_constraint "Cd2"
282   "word16[DE]"
283   (and (match_code "mem")
284        (ior
285         (and (match_code "reg" "0")
286              (match_test "REGNO (XEXP (op, 0)) == DE_REG"))
287         (and (match_code "plus" "0")
288              (and (and (match_code "reg" "00")
289                        (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == DE_REG"))
290                        (match_test "uword_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
291        )
292   )
293 (define_memory_constraint "Wd2"
294   "es:word16[DE]"
295   (match_test "(rl78_es_addr (op) && satisfies_constraint_Cd2 (rl78_es_base (op)))
296                || satisfies_constraint_Cd2 (op)")
297   )
299 (define_memory_constraint "Chl"
300   "[HL]"
301   (and (match_code "mem")
302        (and (match_code "reg" "0")
303             (match_test "REGNO (XEXP (op, 0)) == HL_REG")))
304   )
305 (define_memory_constraint "Whl"
306   "es:[HL]"
307   (match_test "(rl78_es_addr (op) && satisfies_constraint_Chl (rl78_es_base (op)))
308                || satisfies_constraint_Chl (op)")
309   )
311 (define_memory_constraint "Ch1"
312   "byte8[HL]"
313   (and (match_code "mem")
314        (and (match_code "plus" "0")
315             (and (and (match_code "reg" "00")
316                       (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == HL_REG"))
317                       (match_test "ubyte_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
318   )
319 (define_memory_constraint "Wh1"
320   "es:byte8[HL]"
321   (match_test "(rl78_es_addr (op) && satisfies_constraint_Ch1 (rl78_es_base (op)))
322                || satisfies_constraint_Ch1 (op)")
323   )
325 (define_memory_constraint "Chb"
326   "[HL+B]"
327   (and (match_code "mem")
328        (match_test "rl78_hl_b_c_addr_p (XEXP (op, 0))"))
329   )
330 (define_memory_constraint "Whb"
331   "es:[HL+B]"
332   (match_test "(rl78_es_addr (op) && satisfies_constraint_Chb (rl78_es_base (op)))
333                || satisfies_constraint_Chb (op)")
334   )
336 (define_memory_constraint "Cs1"
337   "word8[SP]"
338   (and (match_code "mem")
339        (ior
340         (and (match_code "reg" "0")
341              (match_test "REGNO (XEXP (op, 0)) == SP_REG"))
342         (and (match_code "plus" "0")
343              (and (and (match_code "reg" "00")
344                        (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == SP_REG"))
345                        (match_test "ubyte_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
346        )
347   )
348 (define_memory_constraint "Ws1"
349   "es:word8[SP]"
350   (match_test "(rl78_es_addr (op) && satisfies_constraint_Cs1 (rl78_es_base (op)))
351                || satisfies_constraint_Cs1 (op)")
352   )
354 (define_memory_constraint "Wfr"
355   "ES/CS far pointer"
356   (and (match_code "mem")
357        (match_test "rl78_far_p (op)"))
358   )
360 (define_memory_constraint "Y"
361   "any near legitimate memory access"
362   (and (match_code "mem")
363        (match_test "!rl78_far_p (op) && rl78_as_legitimate_address (VOIDmode, XEXP (op, 0), true, ADDR_SPACE_GENERIC)"))
366 (define_memory_constraint "U"
367   "memory references valid with mov to/from a/ax"
368   (and (match_code "mem")
369        (match_test "rl78_virt_insns_ok ()
370 || satisfies_constraint_Wab (op)
371 || satisfies_constraint_Wbc (op)
372 || satisfies_constraint_Wde (op)
373 || satisfies_constraint_Wd2 (op)
374 || satisfies_constraint_Whl (op)
375 || satisfies_constraint_Wh1 (op)
376 || satisfies_constraint_Whb (op)
377 || satisfies_constraint_Ws1 (op)
378 || satisfies_constraint_Wfr (op) ")))
380 (define_memory_constraint "Qbi"
381   "built-in compare types"
382   (match_code "eq,ne,gtu,ltu,geu,leu"))
384 (define_memory_constraint "Qsc"
385   "synthetic compares"
386   (match_code "gt,lt,ge,le"))