]>
Commit | Line | Data |
---|---|---|
ceaaaeab | 1 | ;; Constraint definitions for Renesas H8/300. |
8d9254fc | 2 | ;; Copyright (C) 2011-2020 Free Software Foundation, Inc. |
ceaaaeab NF |
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 "a" "MAC_REGS" | |
22 | "@internal") | |
23 | ||
24 | (define_register_constraint "c" "COUNTER_REGS" | |
25 | "@internal") | |
26 | ||
27 | ;; Some patterns need to use er6 as a scratch register. This is | |
28 | ;; difficult to arrange since er6 is the frame pointer and usually can't | |
29 | ;; be spilled. | |
30 | ||
31 | ;; Such patterns should define two alternatives, one which allows only | |
32 | ;; er6 and one which allows any general register. The former | |
33 | ;; alternative should have a 'd' constraint while the latter should be | |
34 | ;; disparaged and use 'D'. | |
35 | ||
36 | ;; Normally, 'd' maps to DESTINATION_REGS and 'D' maps to GENERAL_REGS. | |
37 | ;; However, there are cases where they should be NO_REGS: | |
38 | ||
39 | ;; - 'd' should be NO_REGS when reloading a function that uses the | |
40 | ;; frame pointer. In this case, DESTINATION_REGS won't contain any | |
41 | ;; spillable registers, so the first alternative can't be used. | |
42 | ||
43 | ;; - -fno-omit-frame-pointer means that the frame pointer will | |
44 | ;; always be in use. It's therefore better to map 'd' to NO_REGS | |
45 | ;; before reload so that register allocator will pick the second | |
46 | ;; alternative. | |
47 | ||
026c3cfd | 48 | ;; - we would like 'D' to be NO_REGS when the frame pointer isn't |
ceaaaeab NF |
49 | ;; live, but we the frame pointer may turn out to be needed after |
50 | ;; we start reload, and then we may have already decided we don't | |
51 | ;; have a choice, so we can't do that. Forcing the register | |
52 | ;; allocator to use er6 if possible might produce better code for | |
53 | ;; small functions: it's more efficient to save and restore er6 in | |
54 | ;; the prologue & epilogue than to do it in a define_split. | |
55 | ;; Hopefully disparaging 'D' will have a similar effect, without | |
56 | ;; forcing a reload failure if the frame pointer is found to be | |
57 | ;; needed too late. | |
58 | ||
59 | (define_register_constraint "d" | |
60 | "(!flag_omit_frame_pointer && !reload_completed | |
61 | ? NO_REGS | |
62 | : (frame_pointer_needed && reload_in_progress | |
63 | ? NO_REGS | |
64 | : DESTINATION_REGS))" | |
65 | "@internal") | |
66 | ||
67 | (define_register_constraint "D" "GENERAL_REGS" | |
68 | "@internal") | |
69 | ||
70 | (define_register_constraint "f" "SOURCE_REGS" | |
71 | "@internal") | |
72 | ||
73 | ;; Integer constraints. | |
74 | (define_constraint "I" | |
75 | "Integer zero." | |
76 | (and (match_code "const_int") | |
77 | (match_test "ival == 0"))) | |
78 | ||
79 | (define_constraint "J" | |
80 | "An integer with its low byte clear." | |
81 | (and (match_code "const_int") | |
82 | (match_test "(ival & 0xff) == 0"))) | |
83 | ||
84 | (define_constraint "L" | |
85 | "1, 2 or 4 on the H8300H or S; 1 or 2 otherwise." | |
86 | (and (match_code "const_int") | |
87 | (if_then_else (match_test "TARGET_H8300H || TARGET_H8300S") | |
88 | (match_test "ival == 1 || ival == 2 || ival == 4") | |
89 | (match_test "ival == 1 || ival == 2")))) | |
90 | ||
91 | (define_constraint "M" | |
92 | "Integer 1 or 2." | |
93 | (and (match_code "const_int") | |
94 | (match_test "ival == 1 || ival == 2"))) | |
95 | ||
96 | (define_constraint "N" | |
97 | "-1, -2, or -4 on the H8300H or S; -1 or -2 otherwise." | |
98 | (and (match_code "const_int") | |
99 | (if_then_else (match_test "TARGET_H8300H || TARGET_H8300S") | |
100 | (match_test "ival == -1 || ival == -2 || ival == -4") | |
101 | (match_test "ival == -1 || ival == -2")))) | |
102 | ||
103 | (define_constraint "O" | |
104 | "Integer -1 or -2." | |
105 | (and (match_code "const_int") | |
106 | (match_test "ival == -1 || ival == -2"))) | |
107 | ||
108 | (define_constraint "P1>X" | |
109 | "A positive, non-zero integer that fits in 1 bits." | |
110 | (and (match_code "const_int") | |
111 | (match_test "TARGET_H8300SX") | |
112 | (match_test "IN_RANGE (ival, 1, (1 << 1) - 1)"))) | |
113 | ||
114 | (define_constraint "P3>X" | |
115 | "A positive, non-zero integer that fits in 3 bits." | |
116 | (and (match_code "const_int") | |
117 | (match_test "TARGET_H8300SX") | |
118 | (match_test "IN_RANGE (ival, 1, (1 << 3) - 1)"))) | |
119 | ||
120 | (define_constraint "P4>X" | |
121 | "A positive, non-zero integer that fits in 4 bits." | |
122 | (and (match_code "const_int") | |
123 | (match_test "TARGET_H8300SX") | |
124 | (match_test "IN_RANGE (ival, 1, (1 << 4) - 1)"))) | |
125 | ||
126 | (define_constraint "P5>X" | |
127 | "A positive, non-zero integer that fits in 5 bits." | |
128 | (and (match_code "const_int") | |
129 | (match_test "TARGET_H8300SX") | |
130 | (match_test "IN_RANGE (ival, 1, (1 << 5) - 1)"))) | |
131 | ||
132 | (define_constraint "P8>X" | |
133 | "A positive, non-zero integer that fits in 8 bits." | |
134 | (and (match_code "const_int") | |
135 | (match_test "TARGET_H8300SX") | |
136 | (match_test "IN_RANGE (ival, 1, (1 << 8) - 1)"))) | |
137 | ||
138 | (define_constraint "P3<X" | |
139 | "A negative, non-zero integer that fits in 3 bits." | |
140 | (and (match_code "const_int") | |
141 | (match_test "TARGET_H8300SX") | |
142 | (match_test "IN_RANGE (ival, (-(1 << 3)) + 1, -1)"))) | |
143 | ||
144 | ;; Floating-point constraints. | |
145 | (define_constraint "G" | |
146 | "Single-float zero." | |
147 | (and (match_code "const_double") | |
148 | (match_test "op == CONST0_RTX (SFmode)"))) | |
149 | ||
150 | ;; Extra constraints. | |
151 | (define_constraint "Q" | |
152 | "@internal" | |
153 | (and (match_test "TARGET_H8300SX") | |
154 | (match_operand 0 "memory_operand"))) | |
155 | ||
156 | (define_constraint "R" | |
157 | "@internal" | |
158 | (and (match_code "const_int") | |
159 | (match_test "!h8300_shift_needs_scratch_p (ival, QImode)"))) | |
160 | ||
735352d2 JL |
161 | (define_constraint "C" |
162 | "@internal" | |
163 | (match_code "symbol_ref")) | |
164 | ||
ceaaaeab NF |
165 | (define_constraint "S" |
166 | "@internal" | |
167 | (and (match_code "const_int") | |
168 | (match_test "!h8300_shift_needs_scratch_p (ival, HImode)"))) | |
169 | ||
170 | (define_constraint "T" | |
171 | "@internal" | |
172 | (and (match_code "const_int") | |
173 | (match_test "!h8300_shift_needs_scratch_p (ival, SImode)"))) | |
174 | ||
175 | (define_constraint "U" | |
176 | "An operand valid for a bset destination." | |
177 | (ior (and (match_code "reg") | |
b291a202 JL |
178 | (match_test "(reload_in_progress || reload_completed) |
179 | ? REG_OK_FOR_BASE_STRICT_P (op) | |
180 | : REG_OK_FOR_BASE_P (op)")) | |
ceaaaeab NF |
181 | (and (match_code "mem") |
182 | (match_code "reg" "0") | |
b291a202 JL |
183 | (match_test "(reload_in_progress || reload_completed) |
184 | ? REG_OK_FOR_BASE_STRICT_P (XEXP (op, 0)) | |
185 | : REG_OK_FOR_BASE_P (XEXP (op, 0))")) | |
ceaaaeab NF |
186 | (and (match_code "mem") |
187 | (match_code "symbol_ref" "0") | |
188 | (match_test "TARGET_H8300S")) | |
189 | (and (match_code "mem") | |
190 | (match_code "const" "0") | |
191 | (match_code "plus" "00") | |
192 | (match_code "symbol_ref" "000") | |
193 | (match_code "const_int" "001") | |
194 | (ior (match_test "TARGET_H8300S") | |
9f9ab303 | 195 | (match_test "(SYMBOL_REF_FLAGS (XEXP (XEXP (XEXP (op, 0), 0), 0)) & SYMBOL_FLAG_EIGHTBIT_DATA) != 0"))) |
ceaaaeab NF |
196 | (and (match_code "mem") |
197 | (match_test "h8300_eightbit_constant_address_p (XEXP (op, 0))")) | |
198 | (and (match_code "mem") | |
199 | (ior (match_test "TARGET_H8300S") | |
200 | (match_test "TARGET_H8300SX")) | |
201 | (match_code "const_int" "0")))) | |
202 | ||
203 | (define_memory_constraint "WU" | |
204 | "@internal" | |
205 | (and (match_code "mem") | |
206 | (match_test "satisfies_constraint_U (op)"))) | |
207 | ||
208 | (define_constraint "Y0" | |
209 | "@internal" | |
210 | (and (match_code "const_int") | |
211 | (match_test "exact_log2 (~ival & 0xff) != -1"))) | |
212 | ||
213 | (define_constraint "Y2" | |
214 | "@internal" | |
215 | (and (match_code "const_int") | |
216 | (match_test "exact_log2 (ival & 0xff) != -1"))) | |
217 | ||
218 | (define_constraint "Z" | |
219 | "@internal" | |
220 | (and (match_test "TARGET_H8300SX") | |
221 | (match_code "mem") | |
222 | (match_test "CONSTANT_P (XEXP (op, 0))"))) |