1;; Constraint definitions for CRIS.
2;; Copyright (C) 2011-2021 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.
10;;
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.
15;;
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/>.
19
20;; Register constraints.
21(define_register_constraint "b" "GENNONACR_REGS"
22  "@internal")
23
24(define_register_constraint "h" "MOF_REGS"
25  "@internal")
26
27(define_register_constraint "x" "SPECIAL_REGS"
28  "@internal")
29
30(define_register_constraint "c" "CC0_REGS"
31  "@internal")
32
33;; Integer constraints.
34(define_constraint "I"
35  "MOVEQ, CMPQ, ANDQ, ORQ."
36  (and (match_code "const_int")
37       (match_test "IN_RANGE (ival, -32, 31)")))
38
39(define_constraint "J"
40  "ADDQ, SUBQ."
41  (and (match_code "const_int")
42       (match_test "IN_RANGE (ival, 0, 63)")))
43
44(define_constraint "Kc"
45  "ASRQ, BTSTQ, LSRQ, LSLQ."
46  (and (match_code "const_int")
47       (match_test "IN_RANGE (ival, 0, 31)")))
48
49(define_constraint "Kp"
50  "A power of two."
51  (and (match_code "const_int")
52       (match_test "exact_log2 (ival) >= 0")))
53
54(define_constraint "L"
55  "A 16-bit signed number."
56  (and (match_code "const_int")
57       (match_test "IN_RANGE (ival, -32768, 32767)")))
58
59(define_constraint "M"
60  "The constant 0 for CLEAR."
61  (and (match_code "const_int")
62       (match_test "ival == 0")))
63
64(define_constraint "N"
65  "A negative ADDQ or SUBQ."
66  (and (match_code "const_int")
67       (match_test "IN_RANGE (ival, -63, -1)")))
68
69(define_constraint "O"
70  "Quickened ints, QI and HI."
71  (and (match_code "const_int")
72       (ior (match_test "IN_RANGE (ival, (65535 - 31), 65535)")
73	    (match_test "IN_RANGE (ival, (255 - 31), 255)"))))
74
75(define_constraint "P"
76  "A 16-bit number signed *or* unsigned."
77  (and (match_code "const_int")
78       (match_test "IN_RANGE (ival, -32768, 65535)")))
79
80;; Floating-point constant constraints.
81(define_constraint "G"
82  "The floating point zero constant"
83  (and (match_code "const_double")
84       (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT")
85       (match_test "op == CONST0_RTX (mode)")))
86
87;; Memory constraints.
88
89;; Just an indirect register (happens to also be "all" slottable
90;; memory addressing modes not covered by other constraints, i.e. '>').
91(define_memory_constraint "Q"
92  "@internal"
93  (and (match_code "mem")
94       (match_test "cris_base_p (XEXP (op, 0), reload_in_progress
95					       || reload_completed)")))
96
97;; Extra constraints.
98(define_constraint "R"
99  "An operand to BDAP or BIAP."
100       ;; A BIAP; r.S?
101  (ior (match_test "cris_biap_index_p (op, reload_in_progress
102					   || reload_completed)")
103       ;; A [reg] or (int) [reg], maybe with post-increment.
104       (match_test "cris_bdap_index_p (op, reload_in_progress
105					   || reload_completed)")
106       (match_test "CONSTANT_P (op)")))
107
108(define_constraint "T"
109  "Memory three-address operand."
110  ;; All are indirect-memory:
111  (and (match_code "mem")
112	    ;; Double indirect: [[reg]] or [[reg+]]?
113       (ior (and (match_code "mem" "0")
114		 (match_test "cris_base_or_autoincr_p (XEXP (XEXP (op, 0), 0),
115						       reload_in_progress
116						       || reload_completed)"))
117	    ;; Just an explicit indirect reference: [const]?
118	    (match_test "CONSTANT_P (XEXP (op, 0))")
119	    ;; Something that is indexed; [...+...]?
120	    (and (match_code "plus" "0")
121		      ;; A BDAP constant: [reg+(8|16|32)bit offset]?
122		 (ior (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
123						     reload_in_progress
124						     || reload_completed)")
125			   (match_test "CONSTANT_P (XEXP (XEXP (op, 0), 1))"))
126		      ;; A BDAP register: [reg+[reg(+)].S]?
127		      (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
128						     reload_in_progress
129						     || reload_completed)")
130			   (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 1),
131							   reload_in_progress
132							   || reload_completed)"))
133		      ;; Same, but with swapped arguments (no canonical
134		      ;; ordering between e.g. REG and MEM as of LAST_UPDATED
135		      ;; "Thu May 12 03:59:11 UTC 2005").
136		      (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
137						     reload_in_progress
138						     || reload_completed)")
139			   (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 0),
140							   reload_in_progress
141							   || reload_completed)"))
142		      ;; A BIAP: [reg+reg.S] (MULT comes first).
143		      (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
144						     reload_in_progress
145						     || reload_completed)")
146			   (match_test "cris_biap_index_p (XEXP (XEXP (op, 0), 0),
147							   reload_in_progress
148							   || reload_completed)")))))))
149