annotate gcc/config/nds32/nds32-predicates.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Predicate functions of Andes NDS32 cpu for GNU compiler
kono
parents:
diff changeset
2 Copyright (C) 2012-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3 Contributed by Andes Technology Corporation.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
8 under the terms of the GNU General Public License as published
kono
parents:
diff changeset
9 by the Free Software Foundation; either version 3, or (at your
kono
parents:
diff changeset
10 option) any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT
kono
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
kono
parents:
diff changeset
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
kono
parents:
diff changeset
15 License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 /* ------------------------------------------------------------------------ */
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 #include "config.h"
kono
parents:
diff changeset
24 #include "system.h"
kono
parents:
diff changeset
25 #include "coretypes.h"
kono
parents:
diff changeset
26 #include "backend.h"
kono
parents:
diff changeset
27 #include "target.h"
kono
parents:
diff changeset
28 #include "rtl.h"
kono
parents:
diff changeset
29 #include "tree.h"
kono
parents:
diff changeset
30 #include "memmodel.h"
kono
parents:
diff changeset
31 #include "tm_p.h"
kono
parents:
diff changeset
32 #include "optabs.h" /* For GEN_FCN. */
kono
parents:
diff changeset
33 #include "emit-rtl.h"
kono
parents:
diff changeset
34 #include "recog.h"
kono
parents:
diff changeset
35 #include "tm-constrs.h"
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 /* ------------------------------------------------------------------------ */
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 /* A subroutine that checks multiple load and store
kono
parents:
diff changeset
40 using consecutive registers.
kono
parents:
diff changeset
41 OP is a parallel rtx we would like to check.
kono
parents:
diff changeset
42 LOAD_P indicates whether we are checking load operation.
kono
parents:
diff changeset
43 PAR_INDEX is starting element of parallel rtx.
kono
parents:
diff changeset
44 FIRST_ELT_REGNO is used to tell starting register number.
kono
parents:
diff changeset
45 COUNT helps us to check consecutive register numbers. */
kono
parents:
diff changeset
46 static bool
kono
parents:
diff changeset
47 nds32_consecutive_registers_load_store_p (rtx op,
kono
parents:
diff changeset
48 bool load_p,
kono
parents:
diff changeset
49 int par_index,
kono
parents:
diff changeset
50 int first_elt_regno,
kono
parents:
diff changeset
51 int count)
kono
parents:
diff changeset
52 {
kono
parents:
diff changeset
53 int i;
kono
parents:
diff changeset
54 int check_regno;
kono
parents:
diff changeset
55 rtx elt;
kono
parents:
diff changeset
56 rtx elt_reg;
kono
parents:
diff changeset
57 rtx elt_mem;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 for (i = 0; i < count; i++)
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 /* Pick up each element from parallel rtx. */
kono
parents:
diff changeset
62 elt = XVECEXP (op, 0, i + par_index);
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 /* If this element is not a 'set' rtx, return false immediately. */
kono
parents:
diff changeset
65 if (GET_CODE (elt) != SET)
kono
parents:
diff changeset
66 return false;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 /* Pick up reg and mem of this element. */
kono
parents:
diff changeset
69 elt_reg = load_p ? SET_DEST (elt) : SET_SRC (elt);
kono
parents:
diff changeset
70 elt_mem = load_p ? SET_SRC (elt) : SET_DEST (elt);
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* If elt_reg is not a expected reg rtx, return false. */
kono
parents:
diff changeset
73 if (GET_CODE (elt_reg) != REG || GET_MODE (elt_reg) != SImode)
kono
parents:
diff changeset
74 return false;
kono
parents:
diff changeset
75 /* If elt_mem is not a expected mem rtx, return false. */
kono
parents:
diff changeset
76 if (GET_CODE (elt_mem) != MEM || GET_MODE (elt_mem) != SImode)
kono
parents:
diff changeset
77 return false;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* The consecutive registers should be in (Rb,Rb+1...Re) order. */
kono
parents:
diff changeset
80 check_regno = first_elt_regno + i;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 /* If the register number is not continuous, return false. */
kono
parents:
diff changeset
83 if (REGNO (elt_reg) != (unsigned int) check_regno)
kono
parents:
diff changeset
84 return false;
kono
parents:
diff changeset
85 }
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 return true;
kono
parents:
diff changeset
88 }
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 /* Function to check whether the OP is a valid load/store operation.
kono
parents:
diff changeset
91 This is a helper function for the predicates:
kono
parents:
diff changeset
92 'nds32_load_multiple_operation' and 'nds32_store_multiple_operation'
kono
parents:
diff changeset
93 in predicates.md file.
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 The OP is supposed to be a parallel rtx.
kono
parents:
diff changeset
96 For each element within this parallel rtx:
kono
parents:
diff changeset
97 (set (reg) (mem addr)) is the form for load operation.
kono
parents:
diff changeset
98 (set (mem addr) (reg)) is the form for store operation.
kono
parents:
diff changeset
99 We have to extract reg and mem of every element and
kono
parents:
diff changeset
100 check if the information is valid for multiple load/store operation. */
kono
parents:
diff changeset
101 bool
kono
parents:
diff changeset
102 nds32_valid_multiple_load_store (rtx op, bool load_p)
kono
parents:
diff changeset
103 {
kono
parents:
diff changeset
104 int count;
kono
parents:
diff changeset
105 int first_elt_regno;
kono
parents:
diff changeset
106 rtx elt;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 /* Get the counts of elements in the parallel rtx. */
kono
parents:
diff changeset
109 count = XVECLEN (op, 0);
kono
parents:
diff changeset
110 /* Pick up the first element. */
kono
parents:
diff changeset
111 elt = XVECEXP (op, 0, 0);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 /* Perform some quick check for the first element in the parallel rtx. */
kono
parents:
diff changeset
114 if (GET_CODE (elt) != SET
kono
parents:
diff changeset
115 || count <= 1
kono
parents:
diff changeset
116 || count > 8)
kono
parents:
diff changeset
117 return false;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 /* Pick up regno of first element for further detail checking.
kono
parents:
diff changeset
120 Note that the form is different between load and store operation. */
kono
parents:
diff changeset
121 if (load_p)
kono
parents:
diff changeset
122 {
kono
parents:
diff changeset
123 if (GET_CODE (SET_DEST (elt)) != REG
kono
parents:
diff changeset
124 || GET_CODE (SET_SRC (elt)) != MEM)
kono
parents:
diff changeset
125 return false;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 first_elt_regno = REGNO (SET_DEST (elt));
kono
parents:
diff changeset
128 }
kono
parents:
diff changeset
129 else
kono
parents:
diff changeset
130 {
kono
parents:
diff changeset
131 if (GET_CODE (SET_SRC (elt)) != REG
kono
parents:
diff changeset
132 || GET_CODE (SET_DEST (elt)) != MEM)
kono
parents:
diff changeset
133 return false;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 first_elt_regno = REGNO (SET_SRC (elt));
kono
parents:
diff changeset
136 }
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 /* Perform detail check for each element.
kono
parents:
diff changeset
139 Refer to nds32-multiple.md for more information
kono
parents:
diff changeset
140 about following checking.
kono
parents:
diff changeset
141 The starting element of parallel rtx is index 0. */
kono
parents:
diff changeset
142 if (!nds32_consecutive_registers_load_store_p (op, load_p, 0,
kono
parents:
diff changeset
143 first_elt_regno,
kono
parents:
diff changeset
144 count))
kono
parents:
diff changeset
145 return false;
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 /* Pass all test, this is a valid rtx. */
kono
parents:
diff changeset
148 return true;
kono
parents:
diff changeset
149 }
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 /* Function to check whether the OP is a valid stack push/pop operation.
kono
parents:
diff changeset
152 For a valid stack operation, it must satisfy following conditions:
kono
parents:
diff changeset
153 1. Consecutive registers push/pop operations.
kono
parents:
diff changeset
154 2. Valid $fp/$gp/$lp push/pop operations.
kono
parents:
diff changeset
155 3. The last element must be stack adjustment rtx.
kono
parents:
diff changeset
156 See the prologue/epilogue implementation for details. */
kono
parents:
diff changeset
157 bool
kono
parents:
diff changeset
158 nds32_valid_stack_push_pop_p (rtx op, bool push_p)
kono
parents:
diff changeset
159 {
kono
parents:
diff changeset
160 int index;
kono
parents:
diff changeset
161 int total_count;
kono
parents:
diff changeset
162 int rest_count;
kono
parents:
diff changeset
163 int first_regno;
kono
parents:
diff changeset
164 int save_fp, save_gp, save_lp;
kono
parents:
diff changeset
165 rtx elt;
kono
parents:
diff changeset
166 rtx elt_reg;
kono
parents:
diff changeset
167 rtx elt_mem;
kono
parents:
diff changeset
168 rtx elt_plus;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 /* Get the counts of elements in the parallel rtx. */
kono
parents:
diff changeset
171 total_count = XVECLEN (op, 0);
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 /* Perform some quick check for that every element should be 'set'. */
kono
parents:
diff changeset
174 for (index = 0; index < total_count; index++)
kono
parents:
diff changeset
175 {
kono
parents:
diff changeset
176 elt = XVECEXP (op, 0, index);
kono
parents:
diff changeset
177 if (GET_CODE (elt) != SET)
kono
parents:
diff changeset
178 return false;
kono
parents:
diff changeset
179 }
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 /* For push operation, the parallel rtx looks like:
kono
parents:
diff changeset
182 (parallel [(set (mem (plus (reg:SI SP_REGNUM) (const_int -32)))
kono
parents:
diff changeset
183 (reg:SI Rb))
kono
parents:
diff changeset
184 (set (mem (plus (reg:SI SP_REGNUM) (const_int -28)))
kono
parents:
diff changeset
185 (reg:SI Rb+1))
kono
parents:
diff changeset
186 ...
kono
parents:
diff changeset
187 (set (mem (plus (reg:SI SP_REGNUM) (const_int -16)))
kono
parents:
diff changeset
188 (reg:SI Re))
kono
parents:
diff changeset
189 (set (mem (plus (reg:SI SP_REGNUM) (const_int -12)))
kono
parents:
diff changeset
190 (reg:SI FP_REGNUM))
kono
parents:
diff changeset
191 (set (mem (plus (reg:SI SP_REGNUM) (const_int -8)))
kono
parents:
diff changeset
192 (reg:SI GP_REGNUM))
kono
parents:
diff changeset
193 (set (mem (plus (reg:SI SP_REGNUM) (const_int -4)))
kono
parents:
diff changeset
194 (reg:SI LP_REGNUM))
kono
parents:
diff changeset
195 (set (reg:SI SP_REGNUM)
kono
parents:
diff changeset
196 (plus (reg:SI SP_REGNUM) (const_int -32)))])
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 For pop operation, the parallel rtx looks like:
kono
parents:
diff changeset
199 (parallel [(set (reg:SI Rb)
kono
parents:
diff changeset
200 (mem (reg:SI SP_REGNUM)))
kono
parents:
diff changeset
201 (set (reg:SI Rb+1)
kono
parents:
diff changeset
202 (mem (plus (reg:SI SP_REGNUM) (const_int 4))))
kono
parents:
diff changeset
203 ...
kono
parents:
diff changeset
204 (set (reg:SI Re)
kono
parents:
diff changeset
205 (mem (plus (reg:SI SP_REGNUM) (const_int 16))))
kono
parents:
diff changeset
206 (set (reg:SI FP_REGNUM)
kono
parents:
diff changeset
207 (mem (plus (reg:SI SP_REGNUM) (const_int 20))))
kono
parents:
diff changeset
208 (set (reg:SI GP_REGNUM)
kono
parents:
diff changeset
209 (mem (plus (reg:SI SP_REGNUM) (const_int 24))))
kono
parents:
diff changeset
210 (set (reg:SI LP_REGNUM)
kono
parents:
diff changeset
211 (mem (plus (reg:SI SP_REGNUM) (const_int 28))))
kono
parents:
diff changeset
212 (set (reg:SI SP_REGNUM)
kono
parents:
diff changeset
213 (plus (reg:SI SP_REGNUM) (const_int 32)))]) */
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 /* 1. Consecutive registers push/pop operations.
kono
parents:
diff changeset
216 We need to calculate how many registers should be consecutive.
kono
parents:
diff changeset
217 The $sp adjustment rtx, $fp push rtx, $gp push rtx,
kono
parents:
diff changeset
218 and $lp push rtx are excluded. */
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 /* Detect whether we have $fp, $gp, or $lp in the parallel rtx. */
kono
parents:
diff changeset
221 save_fp = reg_mentioned_p (gen_rtx_REG (SImode, FP_REGNUM), op);
kono
parents:
diff changeset
222 save_gp = reg_mentioned_p (gen_rtx_REG (SImode, GP_REGNUM), op);
kono
parents:
diff changeset
223 save_lp = reg_mentioned_p (gen_rtx_REG (SImode, LP_REGNUM), op);
kono
parents:
diff changeset
224 /* Exclude last $sp adjustment rtx. */
kono
parents:
diff changeset
225 rest_count = total_count - 1;
kono
parents:
diff changeset
226 /* Exclude $fp, $gp, and $lp if they are in the parallel rtx. */
kono
parents:
diff changeset
227 if (save_fp)
kono
parents:
diff changeset
228 rest_count--;
kono
parents:
diff changeset
229 if (save_gp)
kono
parents:
diff changeset
230 rest_count--;
kono
parents:
diff changeset
231 if (save_lp)
kono
parents:
diff changeset
232 rest_count--;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 if (rest_count > 0)
kono
parents:
diff changeset
235 {
kono
parents:
diff changeset
236 elt = XVECEXP (op, 0, 0);
kono
parents:
diff changeset
237 /* Pick up register element. */
kono
parents:
diff changeset
238 elt_reg = push_p ? SET_SRC (elt) : SET_DEST (elt);
kono
parents:
diff changeset
239 first_regno = REGNO (elt_reg);
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 /* The 'push' operation is a kind of store operation.
kono
parents:
diff changeset
242 The 'pop' operation is a kind of load operation.
kono
parents:
diff changeset
243 Pass corresponding false/true as second argument (bool load_p).
kono
parents:
diff changeset
244 The par_index is supposed to start with index 0. */
kono
parents:
diff changeset
245 if (!nds32_consecutive_registers_load_store_p (op,
kono
parents:
diff changeset
246 !push_p ? true : false,
kono
parents:
diff changeset
247 0,
kono
parents:
diff changeset
248 first_regno,
kono
parents:
diff changeset
249 rest_count))
kono
parents:
diff changeset
250 return false;
kono
parents:
diff changeset
251 }
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 /* 2. Valid $fp/$gp/$lp push/pop operations.
kono
parents:
diff changeset
254 Remember to set start index for checking them. */
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 /* The rest_count is the start index for checking $fp/$gp/$lp. */
kono
parents:
diff changeset
257 index = rest_count;
kono
parents:
diff changeset
258 /* If index < 0, this parallel rtx is definitely
kono
parents:
diff changeset
259 not a valid stack push/pop operation. */
kono
parents:
diff changeset
260 if (index < 0)
kono
parents:
diff changeset
261 return false;
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 /* Check $fp/$gp/$lp one by one.
kono
parents:
diff changeset
264 We use 'push_p' to pick up reg rtx and mem rtx. */
kono
parents:
diff changeset
265 if (save_fp)
kono
parents:
diff changeset
266 {
kono
parents:
diff changeset
267 elt = XVECEXP (op, 0, index);
kono
parents:
diff changeset
268 elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt);
kono
parents:
diff changeset
269 elt_reg = push_p ? SET_SRC (elt) : SET_DEST (elt);
kono
parents:
diff changeset
270 index++;
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 if (GET_CODE (elt_mem) != MEM
kono
parents:
diff changeset
273 || GET_CODE (elt_reg) != REG
kono
parents:
diff changeset
274 || REGNO (elt_reg) != FP_REGNUM)
kono
parents:
diff changeset
275 return false;
kono
parents:
diff changeset
276 }
kono
parents:
diff changeset
277 if (save_gp)
kono
parents:
diff changeset
278 {
kono
parents:
diff changeset
279 elt = XVECEXP (op, 0, index);
kono
parents:
diff changeset
280 elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt);
kono
parents:
diff changeset
281 elt_reg = push_p ? SET_SRC (elt) : SET_DEST (elt);
kono
parents:
diff changeset
282 index++;
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 if (GET_CODE (elt_mem) != MEM
kono
parents:
diff changeset
285 || GET_CODE (elt_reg) != REG
kono
parents:
diff changeset
286 || REGNO (elt_reg) != GP_REGNUM)
kono
parents:
diff changeset
287 return false;
kono
parents:
diff changeset
288 }
kono
parents:
diff changeset
289 if (save_lp)
kono
parents:
diff changeset
290 {
kono
parents:
diff changeset
291 elt = XVECEXP (op, 0, index);
kono
parents:
diff changeset
292 elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt);
kono
parents:
diff changeset
293 elt_reg = push_p ? SET_SRC (elt) : SET_DEST (elt);
kono
parents:
diff changeset
294 index++;
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 if (GET_CODE (elt_mem) != MEM
kono
parents:
diff changeset
297 || GET_CODE (elt_reg) != REG
kono
parents:
diff changeset
298 || REGNO (elt_reg) != LP_REGNUM)
kono
parents:
diff changeset
299 return false;
kono
parents:
diff changeset
300 }
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 /* 3. The last element must be stack adjustment rtx.
kono
parents:
diff changeset
303 Its form of rtx should be:
kono
parents:
diff changeset
304 (set (reg:SI SP_REGNUM)
kono
parents:
diff changeset
305 (plus (reg:SI SP_REGNUM) (const_int X)))
kono
parents:
diff changeset
306 The X could be positive or negative value. */
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 /* Pick up the last element. */
kono
parents:
diff changeset
309 elt = XVECEXP (op, 0, total_count - 1);
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 /* Extract its destination and source rtx. */
kono
parents:
diff changeset
312 elt_reg = SET_DEST (elt);
kono
parents:
diff changeset
313 elt_plus = SET_SRC (elt);
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 /* Check this is (set (stack_reg) (plus stack_reg const)) pattern. */
kono
parents:
diff changeset
316 if (GET_CODE (elt_reg) != REG
kono
parents:
diff changeset
317 || GET_CODE (elt_plus) != PLUS
kono
parents:
diff changeset
318 || REGNO (elt_reg) != SP_REGNUM)
kono
parents:
diff changeset
319 return false;
kono
parents:
diff changeset
320
kono
parents:
diff changeset
321 /* Pass all test, this is a valid rtx. */
kono
parents:
diff changeset
322 return true;
kono
parents:
diff changeset
323 }
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 /* Function to check if 'bclr' instruction can be used with IVAL. */
kono
parents:
diff changeset
326 int
kono
parents:
diff changeset
327 nds32_can_use_bclr_p (int ival)
kono
parents:
diff changeset
328 {
kono
parents:
diff changeset
329 int one_bit_count;
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 /* Calculate the number of 1-bit of (~ival), if there is only one 1-bit,
kono
parents:
diff changeset
332 it means the original ival has only one 0-bit,
kono
parents:
diff changeset
333 So it is ok to perform 'bclr' operation. */
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 one_bit_count = popcount_hwi ((unsigned HOST_WIDE_INT) (~ival));
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 /* 'bclr' is a performance extension instruction. */
kono
parents:
diff changeset
338 return (TARGET_PERF_EXT && (one_bit_count == 1));
kono
parents:
diff changeset
339 }
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 /* Function to check if 'bset' instruction can be used with IVAL. */
kono
parents:
diff changeset
342 int
kono
parents:
diff changeset
343 nds32_can_use_bset_p (int ival)
kono
parents:
diff changeset
344 {
kono
parents:
diff changeset
345 int one_bit_count;
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 /* Caculate the number of 1-bit of ival, if there is only one 1-bit,
kono
parents:
diff changeset
348 it is ok to perform 'bset' operation. */
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 one_bit_count = popcount_hwi ((unsigned HOST_WIDE_INT) (ival));
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 /* 'bset' is a performance extension instruction. */
kono
parents:
diff changeset
353 return (TARGET_PERF_EXT && (one_bit_count == 1));
kono
parents:
diff changeset
354 }
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 /* Function to check if 'btgl' instruction can be used with IVAL. */
kono
parents:
diff changeset
357 int
kono
parents:
diff changeset
358 nds32_can_use_btgl_p (int ival)
kono
parents:
diff changeset
359 {
kono
parents:
diff changeset
360 int one_bit_count;
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 /* Caculate the number of 1-bit of ival, if there is only one 1-bit,
kono
parents:
diff changeset
363 it is ok to perform 'btgl' operation. */
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 one_bit_count = popcount_hwi ((unsigned HOST_WIDE_INT) (ival));
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 /* 'btgl' is a performance extension instruction. */
kono
parents:
diff changeset
368 return (TARGET_PERF_EXT && (one_bit_count == 1));
kono
parents:
diff changeset
369 }
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 /* Function to check if 'bitci' instruction can be used with IVAL. */
kono
parents:
diff changeset
372 int
kono
parents:
diff changeset
373 nds32_can_use_bitci_p (int ival)
kono
parents:
diff changeset
374 {
kono
parents:
diff changeset
375 /* If we are using V3 ISA, we have 'bitci' instruction.
kono
parents:
diff changeset
376 Try to see if we can present 'andi' semantic with
kono
parents:
diff changeset
377 such 'bit-clear-immediate' operation.
kono
parents:
diff changeset
378 For example, 'andi $r0,$r0,0xfffffffc' can be
kono
parents:
diff changeset
379 presented with 'bitci $r0,$r0,3'. */
kono
parents:
diff changeset
380 return (TARGET_ISA_V3
kono
parents:
diff changeset
381 && (ival < 0)
kono
parents:
diff changeset
382 && satisfies_constraint_Iu15 (gen_int_mode (~ival, SImode)));
kono
parents:
diff changeset
383 }
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 /* ------------------------------------------------------------------------ */