1;; Constraints for C-SKY.
2;; Copyright (C) 2018-2020 Free Software Foundation, Inc.
3;; Contributed by C-SKY Microsystems and Mentor Graphics.
4;;
5;; This file is part of GCC.
6;;
7;; GCC is free software; you can redistribute it and/or modify it
8;; 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, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15;; 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
21;; Register constraints.
22
23(define_register_constraint "a" "MINI_REGS" "r0 - r7")
24(define_register_constraint "b" "LOW_REGS"  "r0 - r15")
25(define_register_constraint "c" "C_REGS" "C register")
26(define_register_constraint "y" "HILO_REGS" "HI and LO registers")
27(define_register_constraint "l" "LO_REGS" "LO register")
28(define_register_constraint "h" "HI_REGS" "HI register")
29(define_register_constraint "v" "V_REGS" "vector registers")
30(define_register_constraint "z" "SP_REGS" "SP register")
31
32
33;; Memory and misc constraints.
34
35(define_memory_constraint "Q"
36  "Memory operands with base register, index register and short displacement for FPUV2"
37  (match_test "csky_valid_fpuv2_mem_operand (op)"))
38
39(define_constraint "R"
40  "Memory operands whose address is a label_ref"
41  (and (match_code "mem")
42       (match_test "GET_CODE (XEXP (op, 0)) == LABEL_REF")))
43
44(define_constraint "S"
45  "Symbol reference with optional offset"
46  (match_test "csky_symbolic_address_p (op)"))
47
48
49;; Constant integer constraints.
50
51(define_constraint "I"
52  "Constant in range [0, 65535]"
53  (and (match_code "const_int")
54       (match_test "CSKY_CONST_OK_FOR_I (ival)")))
55
56(define_constraint "J"
57  "Constant in range [1, 32]"
58  (and (match_code "const_int")
59       (match_test "CSKY_CONST_OK_FOR_J (ival)")))
60
61(define_constraint "K"
62  "Constant in range [0, 31]"
63  (and (match_code "const_int")
64       (match_test "CSKY_CONST_OK_FOR_K (ival)")))
65
66(define_constraint "L"
67  "Constant in range [1, 8]"
68  (and (match_code "const_int")
69       (match_test "CSKY_CONST_OK_FOR_L (ival)")))
70
71(define_constraint "M"
72  "Constant in range [1, 4096]"
73  (and (match_code "const_int")
74       (match_test "CSKY_CONST_OK_FOR_M (ival)")))
75
76(define_constraint "N"
77  "Constant in range [1, 256]"
78  (and (match_code "const_int")
79       (match_test "CSKY_CONST_OK_FOR_N (ival)")))
80
81(define_constraint "O"
82  "Constant in range [0, 4095]"
83  (and (match_code "const_int")
84       (match_test "CSKY_CONST_OK_FOR_O (ival)")))
85
86(define_constraint "P"
87  "Constant in range [4, 508] that is divisible by 4"
88  (and (match_code "const_int")
89       (match_test "CSKY_CONST_OK_FOR_P (ival)")))
90
91(define_constraint "T"
92  "Constant in range [-256, -1]"
93  (and (match_code "const_int")
94       (match_test "CSKY_CONST_OK_FOR_T (ival)")))
95
96(define_constraint "Ua"
97  "Constant 0"
98  (and (match_code "const_int")
99       (match_test "ival == 0")))
100
101(define_constraint "Ub"
102  "Unsigned int that is an exact power of 2"
103  (and (match_code "const_int")
104       (match_test "CSKY_CONST_OK_FOR_Ub (ival)")))
105
106(define_constraint "Uc"
107  "Unsigned int X such that X+1 is an exact power of 2"
108  (and (match_code "const_int")
109       (match_test "CSKY_CONST_OK_FOR_Uc (ival)")))
110
111(define_constraint "Ud"
112  "64-bit int whose high/low words separately satisfy I, Ub, or Uc"
113  (and (match_code "const_int")
114       (match_test "CSKY_CONST_OK_FOR_Ud (ival)")))
115
116(define_constraint "Ug"
117  "Constant in range [-508, -4] that is divisible by 4"
118  (and (match_code "const_int")
119       (match_test "CSKY_CONST_OK_FOR_Ug (ival)")))
120
121(define_constraint "Uh"
122  "Constant in range [-31, 0]"
123  (and (match_code "const_int")
124       (match_test "CSKY_CONST_OK_FOR_Uh (ival)")))
125
126(define_constraint "Uj"
127  "Constant in range [4, 1024] that is divisible by 4"
128  (and (match_code "const_int")
129       (match_test "CSKY_CONST_OK_FOR_Uj (ival)")))
130
131(define_constraint "Uk"
132  "Constant in range [1, 65536]"
133  (and (match_code "const_int")
134       (match_test "CSKY_CONST_OK_FOR_Uk (ival)")))
135
136(define_constraint "Ul"
137  "Constant in range [-1024, -4] that is divisible by 4"
138  (and (match_code "const_int")
139       (match_test "CSKY_CONST_OK_FOR_Ul (ival)")))
140
141(define_constraint "Um"
142  "Constant in range [-4096, -1]"
143  (and (match_code "const_int")
144       (match_test "CSKY_CONST_OK_FOR_Um (ival)")))
145
146(define_constraint "Un"
147  "Constant whose low 16 bits are all zeros"
148  (and (match_code "const_int")
149       (match_test "CSKY_CONST_OK_FOR_MOVIH (ival)")))
150
151(define_constraint "Uo"
152  "Constant that can be synthesized with an extra instruction"
153  (and (match_code "const_int")
154       (match_test "csky_inlinable_constant (ival)")))
155
156(define_constraint "Up"
157  "Constant in range [0, 255]"
158  (and (match_code "const_int")
159       (match_test "CSKY_CONST_OK_FOR_N (ival + 1)")))
160
161(define_constraint "Uq"
162  "Constant in range [0, 1020] that is divisible by 4"
163  (and (match_code "const_int")
164       (match_test "CSKY_CONST_OK_FOR_Uj (ival + 4)")))
165
166(define_constraint "Ur"
167  "Constant in range [-1020, -4] that is divisible by 4"
168  (and (match_code "const_int")
169       (match_test "CSKY_CONST_OK_FOR_Uj (-ival + 4)")))
170
171(define_constraint "Us"
172  "Constant in range [-8, -1]"
173  (and (match_code "const_int")
174       (match_test "CSKY_CONST_OK_FOR_US (ival)")))
175