Mercurial > hg > CbC > CbC_gcc
comparison gcc/rtl.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
1 /* RTL utility routines. | 1 /* RTL utility routines. |
2 Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002, | 2 Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002, |
3 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. | 3 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
8 the terms of the GNU General Public License as published by the Free | 8 the terms of the GNU General Public License as published by the Free |
162 #endif | 162 #endif |
163 | 163 |
164 return rt; | 164 return rt; |
165 } | 165 } |
166 | 166 |
167 /* Create a bitwise copy of VEC. */ | |
168 | |
169 rtvec | |
170 shallow_copy_rtvec (rtvec vec) | |
171 { | |
172 rtvec newvec; | |
173 int n; | |
174 | |
175 n = GET_NUM_ELEM (vec); | |
176 newvec = rtvec_alloc (n); | |
177 memcpy (&newvec->elem[0], &vec->elem[0], sizeof (rtx) * n); | |
178 return newvec; | |
179 } | |
180 | |
167 /* Return the number of bytes occupied by rtx value X. */ | 181 /* Return the number of bytes occupied by rtx value X. */ |
168 | 182 |
169 unsigned int | 183 unsigned int |
170 rtx_size (const_rtx x) | 184 rtx_size (const_rtx x) |
171 { | 185 { |
204 | 218 |
205 bool | 219 bool |
206 shared_const_p (const_rtx orig) | 220 shared_const_p (const_rtx orig) |
207 { | 221 { |
208 gcc_assert (GET_CODE (orig) == CONST); | 222 gcc_assert (GET_CODE (orig) == CONST); |
209 | 223 |
210 /* CONST can be shared if it contains a SYMBOL_REF. If it contains | 224 /* CONST can be shared if it contains a SYMBOL_REF. If it contains |
211 a LABEL_REF, it isn't sharable. */ | 225 a LABEL_REF, it isn't sharable. */ |
212 return (GET_CODE (XEXP (orig, 0)) == PLUS | 226 return (GET_CODE (XEXP (orig, 0)) == PLUS |
213 && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF | 227 && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF |
214 && GET_CODE (XEXP (XEXP (orig, 0), 1)) == CONST_INT); | 228 && CONST_INT_P(XEXP (XEXP (orig, 0), 1))); |
215 } | 229 } |
216 | 230 |
217 | 231 |
218 /* Create a new copy of an rtx. | 232 /* Create a new copy of an rtx. |
219 Recursively copies the operands of the rtx, | 233 Recursively copies the operands of the rtx, |
230 code = GET_CODE (orig); | 244 code = GET_CODE (orig); |
231 | 245 |
232 switch (code) | 246 switch (code) |
233 { | 247 { |
234 case REG: | 248 case REG: |
249 case DEBUG_EXPR: | |
250 case VALUE: | |
235 case CONST_INT: | 251 case CONST_INT: |
236 case CONST_DOUBLE: | 252 case CONST_DOUBLE: |
237 case CONST_FIXED: | 253 case CONST_FIXED: |
238 case CONST_VECTOR: | 254 case CONST_VECTOR: |
239 case SYMBOL_REF: | 255 case SYMBOL_REF: |
332 /* Nonzero when we are expanding trees to RTL. */ | 348 /* Nonzero when we are expanding trees to RTL. */ |
333 int currently_expanding_to_rtl; | 349 int currently_expanding_to_rtl; |
334 | 350 |
335 | 351 |
336 | 352 |
337 /* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL. | 353 /* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL. |
338 When the callback returns true, we continue with the new pair. */ | 354 When the callback returns true, we continue with the new pair. |
355 Whenever changing this function check if rtx_equal_p below doesn't need | |
356 changing as well. */ | |
339 | 357 |
340 int | 358 int |
341 rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) | 359 rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) |
342 { | 360 { |
343 int i; | 361 int i; |
365 (REG:SI x) and (REG:HI x) are NOT equivalent. */ | 383 (REG:SI x) and (REG:HI x) are NOT equivalent. */ |
366 | 384 |
367 if (GET_MODE (x) != GET_MODE (y)) | 385 if (GET_MODE (x) != GET_MODE (y)) |
368 return 0; | 386 return 0; |
369 | 387 |
388 /* MEMs refering to different address space are not equivalent. */ | |
389 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y)) | |
390 return 0; | |
391 | |
370 /* Some RTL can be compared nonrecursively. */ | 392 /* Some RTL can be compared nonrecursively. */ |
371 switch (code) | 393 switch (code) |
372 { | 394 { |
373 case REG: | 395 case REG: |
374 return (REGNO (x) == REGNO (y)); | 396 return (REGNO (x) == REGNO (y)); |
377 return XEXP (x, 0) == XEXP (y, 0); | 399 return XEXP (x, 0) == XEXP (y, 0); |
378 | 400 |
379 case SYMBOL_REF: | 401 case SYMBOL_REF: |
380 return XSTR (x, 0) == XSTR (y, 0); | 402 return XSTR (x, 0) == XSTR (y, 0); |
381 | 403 |
404 case DEBUG_EXPR: | |
405 case VALUE: | |
382 case SCRATCH: | 406 case SCRATCH: |
383 case CONST_DOUBLE: | 407 case CONST_DOUBLE: |
384 case CONST_INT: | 408 case CONST_INT: |
385 case CONST_FIXED: | 409 case CONST_FIXED: |
386 return 0; | 410 return 0; |
414 if (XVECLEN (x, i) != XVECLEN (y, i)) | 438 if (XVECLEN (x, i) != XVECLEN (y, i)) |
415 return 0; | 439 return 0; |
416 | 440 |
417 /* And the corresponding elements must match. */ | 441 /* And the corresponding elements must match. */ |
418 for (j = 0; j < XVECLEN (x, i); j++) | 442 for (j = 0; j < XVECLEN (x, i); j++) |
419 if (rtx_equal_p_cb (XVECEXP (x, i, j), | 443 if (rtx_equal_p_cb (XVECEXP (x, i, j), |
420 XVECEXP (y, i, j), cb) == 0) | 444 XVECEXP (y, i, j), cb) == 0) |
421 return 0; | 445 return 0; |
422 break; | 446 break; |
423 | 447 |
424 case 'e': | 448 case 'e': |
451 } | 475 } |
452 return 1; | 476 return 1; |
453 } | 477 } |
454 | 478 |
455 /* Return 1 if X and Y are identical-looking rtx's. | 479 /* Return 1 if X and Y are identical-looking rtx's. |
456 This is the Lisp function EQUAL for rtx arguments. */ | 480 This is the Lisp function EQUAL for rtx arguments. |
481 Whenever changing this function check if rtx_equal_p_cb above doesn't need | |
482 changing as well. */ | |
457 | 483 |
458 int | 484 int |
459 rtx_equal_p (const_rtx x, const_rtx y) | 485 rtx_equal_p (const_rtx x, const_rtx y) |
460 { | 486 { |
461 return rtx_equal_p_cb (x, y, NULL); | 487 int i; |
488 int j; | |
489 enum rtx_code code; | |
490 const char *fmt; | |
491 | |
492 if (x == y) | |
493 return 1; | |
494 if (x == 0 || y == 0) | |
495 return 0; | |
496 | |
497 code = GET_CODE (x); | |
498 /* Rtx's of different codes cannot be equal. */ | |
499 if (code != GET_CODE (y)) | |
500 return 0; | |
501 | |
502 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent. | |
503 (REG:SI x) and (REG:HI x) are NOT equivalent. */ | |
504 | |
505 if (GET_MODE (x) != GET_MODE (y)) | |
506 return 0; | |
507 | |
508 /* MEMs refering to different address space are not equivalent. */ | |
509 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y)) | |
510 return 0; | |
511 | |
512 /* Some RTL can be compared nonrecursively. */ | |
513 switch (code) | |
514 { | |
515 case REG: | |
516 return (REGNO (x) == REGNO (y)); | |
517 | |
518 case LABEL_REF: | |
519 return XEXP (x, 0) == XEXP (y, 0); | |
520 | |
521 case SYMBOL_REF: | |
522 return XSTR (x, 0) == XSTR (y, 0); | |
523 | |
524 case DEBUG_EXPR: | |
525 case VALUE: | |
526 case SCRATCH: | |
527 case CONST_DOUBLE: | |
528 case CONST_INT: | |
529 case CONST_FIXED: | |
530 return 0; | |
531 | |
532 default: | |
533 break; | |
534 } | |
535 | |
536 /* Compare the elements. If any pair of corresponding elements | |
537 fail to match, return 0 for the whole thing. */ | |
538 | |
539 fmt = GET_RTX_FORMAT (code); | |
540 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
541 { | |
542 switch (fmt[i]) | |
543 { | |
544 case 'w': | |
545 if (XWINT (x, i) != XWINT (y, i)) | |
546 return 0; | |
547 break; | |
548 | |
549 case 'n': | |
550 case 'i': | |
551 if (XINT (x, i) != XINT (y, i)) | |
552 return 0; | |
553 break; | |
554 | |
555 case 'V': | |
556 case 'E': | |
557 /* Two vectors must have the same length. */ | |
558 if (XVECLEN (x, i) != XVECLEN (y, i)) | |
559 return 0; | |
560 | |
561 /* And the corresponding elements must match. */ | |
562 for (j = 0; j < XVECLEN (x, i); j++) | |
563 if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0) | |
564 return 0; | |
565 break; | |
566 | |
567 case 'e': | |
568 if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0) | |
569 return 0; | |
570 break; | |
571 | |
572 case 'S': | |
573 case 's': | |
574 if ((XSTR (x, i) || XSTR (y, i)) | |
575 && (! XSTR (x, i) || ! XSTR (y, i) | |
576 || strcmp (XSTR (x, i), XSTR (y, i)))) | |
577 return 0; | |
578 break; | |
579 | |
580 case 'u': | |
581 /* These are just backpointers, so they don't matter. */ | |
582 break; | |
583 | |
584 case '0': | |
585 case 't': | |
586 break; | |
587 | |
588 /* It is believed that rtx's at this level will never | |
589 contain anything but integers and other rtx's, | |
590 except for within LABEL_REFs and SYMBOL_REFs. */ | |
591 default: | |
592 gcc_unreachable (); | |
593 } | |
594 } | |
595 return 1; | |
462 } | 596 } |
463 | 597 |
464 void | 598 void |
465 dump_rtx_statistics (void) | 599 dump_rtx_statistics (void) |
466 { | 600 { |
487 } | 621 } |
488 fprintf (stderr, "---------------------------------------\n"); | 622 fprintf (stderr, "---------------------------------------\n"); |
489 fprintf (stderr, "%-20s %7d %10d\n", | 623 fprintf (stderr, "%-20s %7d %10d\n", |
490 "Total", total_counts, total_sizes); | 624 "Total", total_counts, total_sizes); |
491 fprintf (stderr, "---------------------------------------\n"); | 625 fprintf (stderr, "---------------------------------------\n"); |
492 #endif | 626 #endif |
493 } | 627 } |
494 | 628 |
495 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) | 629 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) |
496 void | 630 void |
497 rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line, | 631 rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line, |