2017-10-24 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / gcc / config / cris / constraints.md
blobdcf9a137db344f899ab7b85027003385f88a7630
1 ;; Constraint definitions for CRIS.
2 ;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
9 ;; any later version.
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3.  If not see
18 ;; <http://www.gnu.org/licenses/>.
20 ;; Register constraints.
21 (define_register_constraint "a" "ACR_REGS"
22   "@internal")
24 (define_register_constraint "b" "GENNONACR_REGS"
25   "@internal")
27 (define_register_constraint "h" "MOF_REGS"
28   "@internal")
30 (define_register_constraint "x" "SPECIAL_REGS"
31   "@internal")
33 (define_register_constraint "c" "CC0_REGS"
34   "@internal")
36 ;; Integer constraints.
37 (define_constraint "I"
38   "MOVEQ, CMPQ, ANDQ, ORQ."
39   (and (match_code "const_int")
40        (match_test "IN_RANGE (ival, -32, 31)")))
42 (define_constraint "J"
43   "ADDQ, SUBQ."
44   (and (match_code "const_int")
45        (match_test "IN_RANGE (ival, 0, 63)")))
47 (define_constraint "Kc"
48   "ASRQ, BTSTQ, LSRQ, LSLQ."
49   (and (match_code "const_int")
50        (match_test "IN_RANGE (ival, 0, 31)")))
52 (define_constraint "Kp"
53   "A power of two."
54   (and (match_code "const_int")
55        (match_test "exact_log2 (ival) >= 0")))
57 (define_constraint "L"
58   "A 16-bit signed number."
59   (and (match_code "const_int")
60        (match_test "IN_RANGE (ival, -32768, 32767)")))
62 (define_constraint "M"
63   "The constant 0 for CLEAR."
64   (and (match_code "const_int")
65        (match_test "ival == 0")))
67 (define_constraint "N"
68   "A negative ADDQ or SUBQ."
69   (and (match_code "const_int")
70        (match_test "IN_RANGE (ival, -63, -1)")))
72 (define_constraint "O"
73   "Quickened ints, QI and HI."
74   (and (match_code "const_int")
75        (ior (match_test "IN_RANGE (ival, (65535 - 31), 65535)")
76             (match_test "IN_RANGE (ival, (255 - 31), 255)"))))
78 (define_constraint "P"
79   "A 16-bit number signed *or* unsigned."
80   (and (match_code "const_int")
81        (match_test "IN_RANGE (ival, -32768, 65535)")))
83 ;; Floating-point constant constraints.
84 (define_constraint "G"
85   "The floating point zero constant"
86   (and (match_code "const_double")
87        (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT")
88        (match_test "op == CONST0_RTX (mode)")))
90 ;; Memory constraints.
92 ;; Just an indirect register (happens to also be "all" slottable
93 ;; memory addressing modes not covered by other constraints, i.e. '>').
94 (define_memory_constraint "Q"
95   "@internal"
96   (and (match_code "mem")
97        (match_test "cris_base_p (XEXP (op, 0), reload_in_progress
98                                                || reload_completed)")))
100 ;; Extra constraints.
101 (define_constraint "R"
102   "An operand to BDAP or BIAP."
103        ;; A BIAP; r.S?
104   (ior (match_test "cris_biap_index_p (op, reload_in_progress
105                                            || reload_completed)")
106        ;; A [reg] or (int) [reg], maybe with post-increment.
107        (match_test "cris_bdap_index_p (op, reload_in_progress
108                                            || reload_completed)")
109        (match_test "cris_constant_index_p (op)")))
111 (define_constraint "T"
112   "Memory three-address operand."
113   ;; All are indirect-memory:
114   (and (match_code "mem")
115             ;; Double indirect: [[reg]] or [[reg+]]?
116        (ior (and (match_code "mem" "0")
117                  (match_test "cris_base_or_autoincr_p (XEXP (XEXP (op, 0), 0),
118                                                        reload_in_progress
119                                                        || reload_completed)"))
120             ;; Just an explicit indirect reference: [const]?
121             (match_test "CRIS_CONSTANT_P (XEXP (op, 0))")
122             ;; Something that is indexed; [...+...]?
123             (and (match_code "plus" "0")
124                       ;; A BDAP constant: [reg+(8|16|32)bit offset]?
125                  (ior (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
126                                                      reload_in_progress
127                                                      || reload_completed)")
128                            (match_test "cris_constant_index_p (XEXP (XEXP (op, 0), 1))"))
129                       ;; A BDAP register: [reg+[reg(+)].S]?
130                       (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
131                                                      reload_in_progress
132                                                      || reload_completed)")
133                            (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 1),
134                                                            reload_in_progress
135                                                            || reload_completed)"))
136                       ;; Same, but with swapped arguments (no canonical
137                       ;; ordering between e.g. REG and MEM as of LAST_UPDATED
138                       ;; "Thu May 12 03:59:11 UTC 2005").
139                       (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
140                                                      reload_in_progress
141                                                      || reload_completed)")
142                            (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 0),
143                                                            reload_in_progress
144                                                            || reload_completed)"))
145                       ;; A BIAP: [reg+reg.S] (MULT comes first).
146                       (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
147                                                      reload_in_progress
148                                                      || reload_completed)")
149                            (match_test "cris_biap_index_p (XEXP (XEXP (op, 0), 0),
150                                                            reload_in_progress
151                                                            || reload_completed)")))))))
153 (define_constraint "S"
154   "PIC-constructs for symbols."
155   (and (match_test "flag_pic")
156        (match_code "const")
157        (match_test "cris_valid_pic_const (op, false)")))
159 (define_constraint "U"
160   "@internal"
161   (and (match_test "flag_pic")
162        ;; We're just interested in the ..._or_callable_symbol part.
163        ;; (Using CRIS_CONSTANT_P would exclude that too.)
164        (match_test "CONSTANT_P (op)")
165        (match_operand 0 "cris_nonmemory_operand_or_callable_symbol")))