comparison gcc/config/v850/predicates.md @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents a06113de4d67
children 04ced10e8804
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
1 ;; Predicate definitions for NEC V850. 1 ;; Predicate definitions for NEC V850.
2 ;; Copyright (C) 2005, 2007 Free Software Foundation, Inc. 2 ;; Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc.
3 ;; 3 ;;
4 ;; This file is part of GCC. 4 ;; This file is part of GCC.
5 ;; 5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify 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 7 ;; it under the terms of the GNU General Public License as published by
24 { 24 {
25 if (GET_CODE (op) == CONST_INT) 25 if (GET_CODE (op) == CONST_INT)
26 return INTVAL (op) == 0; 26 return INTVAL (op) == 0;
27 27
28 else if (GET_CODE (op) == CONST_DOUBLE) 28 else if (GET_CODE (op) == CONST_DOUBLE)
29 return CONST_DOUBLE_OK_FOR_G (op); 29 return satisfies_constraint_G (op);
30 30
31 else 31 else
32 return register_operand (op, mode); 32 return register_operand (op, mode);
33 }) 33 })
34 34
64 { 64 {
65 if (GET_CODE (op) == CONST_INT) 65 if (GET_CODE (op) == CONST_INT)
66 return TRUE; 66 return TRUE;
67 67
68 return register_operand (op, mode); 68 return register_operand (op, mode);
69 })
70
71 ;; Return true if OP is a even number register.
72
73 (define_predicate "even_reg_operand"
74 (match_code "reg")
75 {
76 return (GET_CODE (op) == REG
77 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
78 || ((REGNO (op) > 0) && (REGNO (op) < 32)
79 && ((REGNO (op) & 1)==0))));
69 }) 80 })
70 81
71 ;; Return true if OP is a valid call operand. 82 ;; Return true if OP is a valid call operand.
72 83
73 (define_predicate "call_address_operand" 84 (define_predicate "call_address_operand"
77 if (TARGET_LONG_CALLS) 88 if (TARGET_LONG_CALLS)
78 return GET_CODE (op) == REG; 89 return GET_CODE (op) == REG;
79 return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == REG); 90 return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == REG);
80 }) 91 })
81 92
82 ;; TODO: Add a comment here. 93 ;; Return true if OP is a valid source operand for SImode move.
83 94
84 (define_predicate "movsi_source_operand" 95 (define_predicate "movsi_source_operand"
85 (match_code "label_ref,symbol_ref,const_int,const_double,const,high,mem,reg,subreg") 96 (match_code "label_ref,symbol_ref,const_int,const_double,const,high,mem,reg,subreg")
86 { 97 {
87 /* Some constants, as well as symbolic operands 98 /* Some constants, as well as symbolic operands
95 return special_symbolref_operand (op, mode); 106 return special_symbolref_operand (op, mode);
96 else 107 else
97 return general_operand (op, mode); 108 return general_operand (op, mode);
98 }) 109 })
99 110
100 ;; TODO: Add a comment here. 111 ;; Return true if OP is a valid operand for 23 bit displacement
112 ;; operations.
113
114 (define_predicate "disp23_operand"
115 (match_code "const_int")
116 {
117 if (GET_CODE (op) == CONST_INT
118 && ((unsigned)(INTVAL (op)) >= 0x8000)
119 && ((unsigned)(INTVAL (op)) < 0x400000))
120 return 1;
121 else
122 return 0;
123 })
124
125 ;; Return true if OP is a symbol ref with 16-bit signed value.
101 126
102 (define_predicate "special_symbolref_operand" 127 (define_predicate "special_symbolref_operand"
103 (match_code "symbol_ref") 128 (match_code "symbol_ref")
104 { 129 {
105 if (GET_CODE (op) == CONST 130 if (GET_CODE (op) == CONST
106 && GET_CODE (XEXP (op, 0)) == PLUS 131 && GET_CODE (XEXP (op, 0)) == PLUS
107 && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT 132 && satisfies_constraint_K (XEXP (XEXP (op, 0), 1)))
108 && CONST_OK_FOR_K (INTVAL (XEXP (XEXP (op, 0), 1))))
109 op = XEXP (XEXP (op, 0), 0); 133 op = XEXP (XEXP (op, 0), 0);
110 134
111 if (GET_CODE (op) == SYMBOL_REF) 135 if (GET_CODE (op) == SYMBOL_REF)
112 return (SYMBOL_REF_FLAGS (op) 136 return (SYMBOL_REF_FLAGS (op)
113 & (SYMBOL_FLAG_ZDA | SYMBOL_FLAG_TDA | SYMBOL_FLAG_SDA)) != 0; 137 & (SYMBOL_FLAG_ZDA | SYMBOL_FLAG_TDA | SYMBOL_FLAG_SDA)) != 0;
114 138
115 return FALSE; 139 return FALSE;
116 }) 140 })
117 141
118 ;; TODO: Add a comment here. 142 ;; Return true if OP is a valid operand for bit related operations
143 ;; containing only single 1 in its binary representation.
119 144
120 (define_predicate "power_of_two_operand" 145 (define_predicate "power_of_two_operand"
121 (match_code "const_int") 146 (match_code "const_int")
122 { 147 {
123 if (GET_CODE (op) != CONST_INT) 148 if (GET_CODE (op) != CONST_INT)
138 int i; 163 int i;
139 rtx vector_element; 164 rtx vector_element;
140 165
141 /* If there are no registers to save then the function prologue 166 /* If there are no registers to save then the function prologue
142 is not suitable. */ 167 is not suitable. */
143 if (count <= 2) 168 if (count <= (TARGET_LONG_CALLS ? 3 : 2))
144 return 0; 169 return 0;
145 170
146 /* The pattern matching has already established that we are adjusting the 171 /* The pattern matching has already established that we are adjusting the
147 stack and pushing at least one register. We must now check that the 172 stack and pushing at least one register. We must now check that the
148 remaining entries in the vector to make sure that they are also register 173 remaining entries in the vector to make sure that they are also register
196 return 0; 221 return 0;
197 } 222 }
198 } 223 }
199 224
200 /* Make sure that the last entries in the vector are clobbers. */ 225 /* Make sure that the last entries in the vector are clobbers. */
201 for (; i < count; i++) 226 vector_element = XVECEXP (op, 0, i++);
227
228 if (GET_CODE (vector_element) != CLOBBER
229 || GET_CODE (XEXP (vector_element, 0)) != REG
230 || REGNO (XEXP (vector_element, 0)) != 10)
231 return 0;
232
233 if (TARGET_LONG_CALLS)
202 { 234 {
203 vector_element = XVECEXP (op, 0, i); 235 vector_element = XVECEXP (op, 0, i++);
204 236
205 if (GET_CODE (vector_element) != CLOBBER 237 if (GET_CODE (vector_element) != CLOBBER
206 || GET_CODE (XEXP (vector_element, 0)) != REG 238 || GET_CODE (XEXP (vector_element, 0)) != REG
207 || !(REGNO (XEXP (vector_element, 0)) == 10 239 || REGNO (XEXP (vector_element, 0)) != 11)
208 || (TARGET_LONG_CALLS ? (REGNO (XEXP (vector_element, 0)) == 11) : 0 )))
209 return 0; 240 return 0;
210 } 241 }
211 242
212 return 1; 243 return i == count;
213 }) 244 })
214 245
215 ;; Return nonzero if the given RTX is suitable for collapsing into 246 ;; Return nonzero if the given RTX is suitable for collapsing into
216 ;; jump to a function epilogue. 247 ;; jump to a function epilogue.
217 248
235 The test below performs the C equivalent of this machine description 266 The test below performs the C equivalent of this machine description
236 pattern match: 267 pattern match:
237 268
238 (set (match_operand:SI n "register_is_ok_for_epilogue" "r") 269 (set (match_operand:SI n "register_is_ok_for_epilogue" "r")
239 (mem:SI (plus:SI (reg:SI 3) (match_operand:SI n "immediate_operand" "i")))) 270 (mem:SI (plus:SI (reg:SI 3) (match_operand:SI n "immediate_operand" "i"))))
271 */
272
273 for (i = 2; i < count; i++)
274 {
275 rtx vector_element = XVECEXP (op, 0, i);
276 rtx dest;
277 rtx src;
278 rtx plus;
279
280 if (GET_CODE (vector_element) != SET)
281 return 0;
282
283 dest = SET_DEST (vector_element);
284 src = SET_SRC (vector_element);
285
286 if (GET_CODE (dest) != REG
287 || GET_MODE (dest) != SImode
288 || ! register_is_ok_for_epilogue (dest, SImode)
289 || GET_CODE (src) != MEM
290 || GET_MODE (src) != SImode)
291 return 0;
292
293 plus = XEXP (src, 0);
294
295 if (GET_CODE (plus) != PLUS
296 || GET_CODE (XEXP (plus, 0)) != REG
297 || GET_MODE (XEXP (plus, 0)) != SImode
298 || REGNO (XEXP (plus, 0)) != STACK_POINTER_REGNUM
299 || GET_CODE (XEXP (plus, 1)) != CONST_INT)
300 return 0;
301 }
302
303 return 1;
304 })
305
306 ;; Return true if the given RTX is a register which can be restored by
307 ;; a function epilogue.
308
309 (define_predicate "register_is_ok_for_epilogue"
310 (match_code "reg")
311 {
312 /* The save/restore routines can only cope with registers 20 - 31. */
313 return ((GET_CODE (op) == REG)
314 && (((REGNO (op) >= 20) && REGNO (op) <= 31)));
315 })
316
317 ;; Return nonzero if the given RTX is suitable for collapsing into a
318 ;; DISPOSE instruction.
319
320 (define_predicate "pattern_is_ok_for_dispose"
321 (match_code "parallel")
322 {
323 int count = XVECLEN (op, 0);
324 int i;
325
326 /* If there are no registers to restore then
327 the dispose instruction is not suitable. */
328 if (count <= 2)
329 return 0;
330
331 /* The pattern matching has already established that we are performing a
332 function epilogue and that we are popping at least one register. We must
333 now check the remaining entries in the vector to make sure that they are
334 also register pops. There is no good reason why there should ever be
335 anything else in this vector, but being paranoid always helps...
336
337 The test below performs the C equivalent of this machine description
338 pattern match:
339
340 (set (match_operand:SI n "register_is_ok_for_epilogue" "r")
341 (mem:SI (plus:SI (reg:SI 3)
342 (match_operand:SI n "immediate_operand" "i"))))
240 */ 343 */
241 344
242 for (i = 3; i < count; i++) 345 for (i = 3; i < count; i++)
243 { 346 {
244 rtx vector_element = XVECEXP (op, 0, i); 347 rtx vector_element = XVECEXP (op, 0, i);
248 351
249 if (GET_CODE (vector_element) != SET) 352 if (GET_CODE (vector_element) != SET)
250 return 0; 353 return 0;
251 354
252 dest = SET_DEST (vector_element); 355 dest = SET_DEST (vector_element);
253 src = SET_SRC (vector_element); 356 src = SET_SRC (vector_element);
254 357
255 if (GET_CODE (dest) != REG 358 if ( GET_CODE (dest) != REG
256 || GET_MODE (dest) != SImode 359 || GET_MODE (dest) != SImode
257 || ! register_is_ok_for_epilogue (dest, SImode) 360 || ! register_is_ok_for_epilogue (dest, SImode)
258 || GET_CODE (src) != MEM 361 || GET_CODE (src) != MEM
259 || GET_MODE (src) != SImode) 362 || GET_MODE (src) != SImode)
260 return 0; 363 return 0;
261 364
262 plus = XEXP (src, 0); 365 plus = XEXP (src, 0);
263 366
264 if (GET_CODE (plus) != PLUS 367 if ( GET_CODE (plus) != PLUS
265 || GET_CODE (XEXP (plus, 0)) != REG 368 || GET_CODE (XEXP (plus, 0)) != REG
266 || GET_MODE (XEXP (plus, 0)) != SImode 369 || GET_MODE (XEXP (plus, 0)) != SImode
267 || REGNO (XEXP (plus, 0)) != STACK_POINTER_REGNUM 370 || REGNO (XEXP (plus, 0)) != STACK_POINTER_REGNUM
268 || GET_CODE (XEXP (plus, 1)) != CONST_INT) 371 || GET_CODE (XEXP (plus, 1)) != CONST_INT)
269 return 0; 372 return 0;
270 } 373 }
271 374
272 return 1; 375 return 1;
273 }) 376 })
274 377
275 ;; Return true if the given RTX is a register which can be restored by
276 ;; a function epilogue.
277
278 (define_predicate "register_is_ok_for_epilogue"
279 (match_code "reg")
280 {
281 /* The save/restore routines can only cope with registers 20 - 31. */
282 return ((GET_CODE (op) == REG)
283 && (((REGNO (op) >= 20) && REGNO (op) <= 31)));
284 })
285
286 ;; Return nonzero if the given RTX is suitable for collapsing into a 378 ;; Return nonzero if the given RTX is suitable for collapsing into a
287 ;; DISPOSE instruction. 379 ;; PREPARE instruction.
288 380
289 (define_predicate "pattern_is_ok_for_dispose" 381 (define_predicate "pattern_is_ok_for_prepare"
290 (match_code "parallel") 382 (match_code "parallel")
291 { 383 {
292 int count = XVECLEN (op, 0); 384 int count = XVECLEN (op, 0);
293 int i; 385 int i;
294 386
295 /* If there are no registers to restore then 387 /* If there are no registers to restore then the prepare instruction
296 the dispose instruction is not suitable. */ 388 is not suitable. */
297 if (count <= 2) 389 if (count <= 1)
298 return 0; 390 return 0;
299 391
300 /* The pattern matching has already established that we are performing a 392 /* The pattern matching has already established that we are adjusting the
301 function epilogue and that we are popping at least one register. We must 393 stack and pushing at least one register. We must now check that the
302 now check the remaining entries in the vector to make sure that they are 394 remaining entries in the vector to make sure that they are also register
303 also register pops. There is no good reason why there should ever be 395 pushes.
304 anything else in this vector, but being paranoid always helps...
305 396
306 The test below performs the C equivalent of this machine description 397 The test below performs the C equivalent of this machine description
307 pattern match: 398 pattern match:
308 399
309 (set (match_operand:SI n "register_is_ok_for_epilogue" "r") 400 (set (mem:SI (plus:SI (reg:SI 3)
310 (mem:SI (plus:SI (reg:SI 3) 401 (match_operand:SI 2 "immediate_operand" "i")))
311 (match_operand:SI n "immediate_operand" "i")))) 402 (match_operand:SI 3 "register_is_ok_for_epilogue" "r"))
403
312 */ 404 */
313 405
314 for (i = 3; i < count; i++) 406 for (i = 1; i < count; i++)
315 { 407 {
316 rtx vector_element = XVECEXP (op, 0, i); 408 rtx vector_element = XVECEXP (op, 0, i);
317 rtx dest; 409 rtx dest;
318 rtx src; 410 rtx src;
319 rtx plus; 411 rtx plus;
320 412
321 if (GET_CODE (vector_element) != SET) 413 if (GET_CODE (vector_element) == CLOBBER)
322 return 0; 414 continue;
323
324 dest = SET_DEST (vector_element);
325 src = SET_SRC (vector_element);
326
327 if ( GET_CODE (dest) != REG
328 || GET_MODE (dest) != SImode
329 || ! register_is_ok_for_epilogue (dest, SImode)
330 || GET_CODE (src) != MEM
331 || GET_MODE (src) != SImode)
332 return 0;
333
334 plus = XEXP (src, 0);
335
336 if ( GET_CODE (plus) != PLUS
337 || GET_CODE (XEXP (plus, 0)) != REG
338 || GET_MODE (XEXP (plus, 0)) != SImode
339 || REGNO (XEXP (plus, 0)) != STACK_POINTER_REGNUM
340 || GET_CODE (XEXP (plus, 1)) != CONST_INT)
341 return 0;
342 }
343
344 return 1;
345 })
346
347 ;; Return nonzero if the given RTX is suitable for collapsing into a
348 ;; PREPARE instruction.
349
350 (define_predicate "pattern_is_ok_for_prepare"
351 (match_code "parallel")
352 {
353 int count = XVECLEN (op, 0);
354 int i;
355
356 /* If there are no registers to restore then the prepare instruction
357 is not suitable. */
358 if (count <= 1)
359 return 0;
360
361 /* The pattern matching has already established that we are adjusting the
362 stack and pushing at least one register. We must now check that the
363 remaining entries in the vector to make sure that they are also register
364 pushes.
365
366 The test below performs the C equivalent of this machine description
367 pattern match:
368
369 (set (mem:SI (plus:SI (reg:SI 3)
370 (match_operand:SI 2 "immediate_operand" "i")))
371 (match_operand:SI 3 "register_is_ok_for_epilogue" "r"))
372
373 */
374
375 for (i = 2; i < count; i++)
376 {
377 rtx vector_element = XVECEXP (op, 0, i);
378 rtx dest;
379 rtx src;
380 rtx plus;
381 415
382 if (GET_CODE (vector_element) != SET) 416 if (GET_CODE (vector_element) != SET)
383 return 0; 417 return 0;
384 418
385 dest = SET_DEST (vector_element); 419 dest = SET_DEST (vector_element);
404 438
405 /* If the register is being pushed somewhere other than the stack 439 /* If the register is being pushed somewhere other than the stack
406 space just acquired by the first operand then abandon this quest. 440 space just acquired by the first operand then abandon this quest.
407 Note: the test is <= because both values are negative. */ 441 Note: the test is <= because both values are negative. */
408 if (INTVAL (XEXP (plus, 1)) 442 if (INTVAL (XEXP (plus, 1))
409 <= INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1))) 443 < INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1)))
410 return 0; 444 return 0;
411 } 445 }
412 446
413 return 1; 447 return 1;
414 }) 448 })
415 449
416 ;; TODO: Add a comment here. 450 ;; Return true if OP is a valid operand for bit related operations
451 ;; containing only single 0 in its binary representation.
417 452
418 (define_predicate "not_power_of_two_operand" 453 (define_predicate "not_power_of_two_operand"
419 (match_code "const_int") 454 (match_code "const_int")
420 { 455 {
421 unsigned int mask; 456 unsigned int mask;
434 469
435 if (exact_log2 (~INTVAL (op) & mask) == -1) 470 if (exact_log2 (~INTVAL (op) & mask) == -1)
436 return 0; 471 return 0;
437 return 1; 472 return 1;
438 }) 473 })
474
475 ;; Return true if OP is a float value operand with value as 1.
476
477 (define_predicate "const_float_1_operand"
478 (match_code "const_int")
479 {
480 if (GET_CODE (op) != CONST_DOUBLE
481 || mode != GET_MODE (op)
482 || (mode != DFmode && mode != SFmode))
483 return 0;
484
485 return op == CONST1_RTX(mode);
486 })
487
488 ;; Return true if OP is a float value operand with value as 0.
489
490 (define_predicate "const_float_0_operand"
491 (match_code "const_int")
492 {
493 if (GET_CODE (op) != CONST_DOUBLE
494 || mode != GET_MODE (op)
495 || (mode != DFmode && mode != SFmode))
496 return 0;
497
498 return op == CONST0_RTX(mode);
499 })
500
501