Mercurial > hg > CbC > CbC_gcc
comparison gcc/machmode.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Machine mode definitions for GCC; included by rtl.h and tree.h. | 1 /* Machine mode definitions for GCC; included by rtl.h and tree.h. |
2 Copyright (C) 1991-2017 Free Software Foundation, Inc. | 2 Copyright (C) 1991-2018 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 it under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
20 #ifndef HAVE_MACHINE_MODES | 20 #ifndef HAVE_MACHINE_MODES |
21 #define HAVE_MACHINE_MODES | 21 #define HAVE_MACHINE_MODES |
22 | 22 |
23 typedef opt_mode<machine_mode> opt_machine_mode; | 23 typedef opt_mode<machine_mode> opt_machine_mode; |
24 | 24 |
25 extern CONST_MODE_SIZE unsigned short mode_size[NUM_MACHINE_MODES]; | 25 extern CONST_MODE_SIZE poly_uint16_pod mode_size[NUM_MACHINE_MODES]; |
26 extern const unsigned short mode_precision[NUM_MACHINE_MODES]; | 26 extern CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES]; |
27 extern const unsigned char mode_inner[NUM_MACHINE_MODES]; | 27 extern const unsigned char mode_inner[NUM_MACHINE_MODES]; |
28 extern const unsigned char mode_nunits[NUM_MACHINE_MODES]; | 28 extern CONST_MODE_NUNITS poly_uint16_pod mode_nunits[NUM_MACHINE_MODES]; |
29 extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES]; | 29 extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES]; |
30 extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES]; | 30 extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES]; |
31 extern const unsigned char mode_wider[NUM_MACHINE_MODES]; | 31 extern const unsigned char mode_wider[NUM_MACHINE_MODES]; |
32 extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; | 32 extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; |
33 | 33 |
74 { | 74 { |
75 /* machine_mode itself needs no conversion. */ | 75 /* machine_mode itself needs no conversion. */ |
76 typedef machine_mode from_int; | 76 typedef machine_mode from_int; |
77 }; | 77 }; |
78 | 78 |
79 /* Always treat machine modes as fixed-size while compiling code specific | |
80 to targets that have no variable-size modes. */ | |
81 #if defined (IN_TARGET_CODE) && NUM_POLY_INT_COEFFS == 1 | |
82 #define ONLY_FIXED_SIZE_MODES 1 | |
83 #else | |
84 #define ONLY_FIXED_SIZE_MODES 0 | |
85 #endif | |
86 | |
79 /* Get the name of mode MODE as a string. */ | 87 /* Get the name of mode MODE as a string. */ |
80 | 88 |
81 extern const char * const mode_name[NUM_MACHINE_MODES]; | 89 extern const char * const mode_name[NUM_MACHINE_MODES]; |
82 #define GET_MODE_NAME(MODE) mode_name[MODE] | 90 #define GET_MODE_NAME(MODE) mode_name[MODE] |
83 | 91 |
98 /* Nonzero if MODE is an integral mode. */ | 106 /* Nonzero if MODE is an integral mode. */ |
99 #define INTEGRAL_MODE_P(MODE) \ | 107 #define INTEGRAL_MODE_P(MODE) \ |
100 (GET_MODE_CLASS (MODE) == MODE_INT \ | 108 (GET_MODE_CLASS (MODE) == MODE_INT \ |
101 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \ | 109 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \ |
102 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ | 110 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ |
111 || GET_MODE_CLASS (MODE) == MODE_VECTOR_BOOL \ | |
103 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT) | 112 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT) |
104 | 113 |
105 /* Nonzero if MODE is a floating-point mode. */ | 114 /* Nonzero if MODE is a floating-point mode. */ |
106 #define FLOAT_MODE_P(MODE) \ | 115 #define FLOAT_MODE_P(MODE) \ |
107 (GET_MODE_CLASS (MODE) == MODE_FLOAT \ | 116 (GET_MODE_CLASS (MODE) == MODE_FLOAT \ |
113 #define COMPLEX_MODE_P(MODE) \ | 122 #define COMPLEX_MODE_P(MODE) \ |
114 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ | 123 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ |
115 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) | 124 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) |
116 | 125 |
117 /* Nonzero if MODE is a vector mode. */ | 126 /* Nonzero if MODE is a vector mode. */ |
118 #define VECTOR_MODE_P(MODE) \ | 127 #define VECTOR_MODE_P(MODE) \ |
119 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ | 128 (GET_MODE_CLASS (MODE) == MODE_VECTOR_BOOL \ |
129 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ | |
120 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \ | 130 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \ |
121 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \ | 131 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \ |
122 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \ | 132 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \ |
123 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM \ | 133 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM \ |
124 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM) | 134 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM) |
225 || CLASS == MODE_FRACT \ | 235 || CLASS == MODE_FRACT \ |
226 || CLASS == MODE_UFRACT \ | 236 || CLASS == MODE_UFRACT \ |
227 || CLASS == MODE_ACCUM \ | 237 || CLASS == MODE_ACCUM \ |
228 || CLASS == MODE_UACCUM) | 238 || CLASS == MODE_UACCUM) |
229 | 239 |
230 #define POINTER_BOUNDS_MODE_P(MODE) \ | |
231 (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS) | |
232 | |
233 /* An optional T (i.e. a T or nothing), where T is some form of mode class. */ | 240 /* An optional T (i.e. a T or nothing), where T is some form of mode class. */ |
234 template<typename T> | 241 template<typename T> |
235 class opt_mode | 242 class opt_mode |
236 { | 243 { |
237 public: | 244 public: |
311 | 318 |
312 template<typename T> | 319 template<typename T> |
313 struct pod_mode | 320 struct pod_mode |
314 { | 321 { |
315 typedef typename mode_traits<T>::from_int from_int; | 322 typedef typename mode_traits<T>::from_int from_int; |
323 typedef typename T::measurement_type measurement_type; | |
316 | 324 |
317 machine_mode m_mode; | 325 machine_mode m_mode; |
318 ALWAYS_INLINE operator machine_mode () const { return m_mode; } | 326 ALWAYS_INLINE operator machine_mode () const { return m_mode; } |
319 ALWAYS_INLINE operator T () const { return from_int (m_mode); } | 327 ALWAYS_INLINE operator T () const { return from_int (m_mode); } |
320 ALWAYS_INLINE pod_mode &operator = (const T &m) { m_mode = m; return *this; } | 328 ALWAYS_INLINE pod_mode &operator = (const T &m) { m_mode = m; return *this; } |
389 /* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */ | 397 /* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */ |
390 class scalar_int_mode | 398 class scalar_int_mode |
391 { | 399 { |
392 public: | 400 public: |
393 typedef mode_traits<scalar_int_mode>::from_int from_int; | 401 typedef mode_traits<scalar_int_mode>::from_int from_int; |
402 typedef unsigned short measurement_type; | |
394 | 403 |
395 ALWAYS_INLINE scalar_int_mode () {} | 404 ALWAYS_INLINE scalar_int_mode () {} |
396 ALWAYS_INLINE scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {} | 405 ALWAYS_INLINE scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {} |
397 ALWAYS_INLINE operator machine_mode () const { return m_mode; } | 406 ALWAYS_INLINE operator machine_mode () const { return m_mode; } |
398 | 407 |
413 /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */ | 422 /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */ |
414 class scalar_float_mode | 423 class scalar_float_mode |
415 { | 424 { |
416 public: | 425 public: |
417 typedef mode_traits<scalar_float_mode>::from_int from_int; | 426 typedef mode_traits<scalar_float_mode>::from_int from_int; |
427 typedef unsigned short measurement_type; | |
418 | 428 |
419 ALWAYS_INLINE scalar_float_mode () {} | 429 ALWAYS_INLINE scalar_float_mode () {} |
420 ALWAYS_INLINE scalar_float_mode (from_int m) : m_mode (machine_mode (m)) {} | 430 ALWAYS_INLINE scalar_float_mode (from_int m) : m_mode (machine_mode (m)) {} |
421 ALWAYS_INLINE operator machine_mode () const { return m_mode; } | 431 ALWAYS_INLINE operator machine_mode () const { return m_mode; } |
422 | 432 |
437 /* Represents a machine mode that is known to be scalar. */ | 447 /* Represents a machine mode that is known to be scalar. */ |
438 class scalar_mode | 448 class scalar_mode |
439 { | 449 { |
440 public: | 450 public: |
441 typedef mode_traits<scalar_mode>::from_int from_int; | 451 typedef mode_traits<scalar_mode>::from_int from_int; |
452 typedef unsigned short measurement_type; | |
442 | 453 |
443 ALWAYS_INLINE scalar_mode () {} | 454 ALWAYS_INLINE scalar_mode () {} |
444 ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {} | 455 ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {} |
445 ALWAYS_INLINE scalar_mode (const scalar_int_mode &m) : m_mode (m) {} | 456 ALWAYS_INLINE scalar_mode (const scalar_int_mode &m) : m_mode (m) {} |
446 ALWAYS_INLINE scalar_mode (const scalar_float_mode &m) : m_mode (m) {} | 457 ALWAYS_INLINE scalar_mode (const scalar_float_mode &m) : m_mode (m) {} |
466 case MODE_UFRACT: | 477 case MODE_UFRACT: |
467 case MODE_ACCUM: | 478 case MODE_ACCUM: |
468 case MODE_UACCUM: | 479 case MODE_UACCUM: |
469 case MODE_FLOAT: | 480 case MODE_FLOAT: |
470 case MODE_DECIMAL_FLOAT: | 481 case MODE_DECIMAL_FLOAT: |
471 case MODE_POINTER_BOUNDS: | |
472 return true; | 482 return true; |
473 default: | 483 default: |
474 return false; | 484 return false; |
475 } | 485 } |
476 } | 486 } |
478 /* Represents a machine mode that is known to be a COMPLEX_MODE_P. */ | 488 /* Represents a machine mode that is known to be a COMPLEX_MODE_P. */ |
479 class complex_mode | 489 class complex_mode |
480 { | 490 { |
481 public: | 491 public: |
482 typedef mode_traits<complex_mode>::from_int from_int; | 492 typedef mode_traits<complex_mode>::from_int from_int; |
493 typedef unsigned short measurement_type; | |
483 | 494 |
484 ALWAYS_INLINE complex_mode () {} | 495 ALWAYS_INLINE complex_mode () {} |
485 ALWAYS_INLINE complex_mode (from_int m) : m_mode (machine_mode (m)) {} | 496 ALWAYS_INLINE complex_mode (from_int m) : m_mode (machine_mode (m)) {} |
486 ALWAYS_INLINE operator machine_mode () const { return m_mode; } | 497 ALWAYS_INLINE operator machine_mode () const { return m_mode; } |
487 | 498 |
499 return COMPLEX_MODE_P (m); | 510 return COMPLEX_MODE_P (m); |
500 } | 511 } |
501 | 512 |
502 /* Return the base GET_MODE_SIZE value for MODE. */ | 513 /* Return the base GET_MODE_SIZE value for MODE. */ |
503 | 514 |
504 ALWAYS_INLINE unsigned short | 515 ALWAYS_INLINE poly_uint16 |
505 mode_to_bytes (machine_mode mode) | 516 mode_to_bytes (machine_mode mode) |
506 { | 517 { |
507 #if GCC_VERSION >= 4001 | 518 #if GCC_VERSION >= 4001 |
508 return (__builtin_constant_p (mode) | 519 return (__builtin_constant_p (mode) |
509 ? mode_size_inline (mode) : mode_size[mode]); | 520 ? mode_size_inline (mode) : mode_size[mode]); |
512 #endif | 523 #endif |
513 } | 524 } |
514 | 525 |
515 /* Return the base GET_MODE_BITSIZE value for MODE. */ | 526 /* Return the base GET_MODE_BITSIZE value for MODE. */ |
516 | 527 |
517 ALWAYS_INLINE unsigned short | 528 ALWAYS_INLINE poly_uint16 |
518 mode_to_bits (machine_mode mode) | 529 mode_to_bits (machine_mode mode) |
519 { | 530 { |
520 return mode_to_bytes (mode) * BITS_PER_UNIT; | 531 return mode_to_bytes (mode) * BITS_PER_UNIT; |
521 } | 532 } |
522 | 533 |
523 /* Return the base GET_MODE_PRECISION value for MODE. */ | 534 /* Return the base GET_MODE_PRECISION value for MODE. */ |
524 | 535 |
525 ALWAYS_INLINE unsigned short | 536 ALWAYS_INLINE poly_uint16 |
526 mode_to_precision (machine_mode mode) | 537 mode_to_precision (machine_mode mode) |
527 { | 538 { |
528 return mode_precision[mode]; | 539 return mode_precision[mode]; |
529 } | 540 } |
530 | 541 |
568 #endif | 579 #endif |
569 } | 580 } |
570 | 581 |
571 /* Return the base GET_MODE_NUNITS value for MODE. */ | 582 /* Return the base GET_MODE_NUNITS value for MODE. */ |
572 | 583 |
573 ALWAYS_INLINE unsigned short | 584 ALWAYS_INLINE poly_uint16 |
574 mode_to_nunits (machine_mode mode) | 585 mode_to_nunits (machine_mode mode) |
575 { | 586 { |
576 #if GCC_VERSION >= 4001 | 587 #if GCC_VERSION >= 4001 |
577 return (__builtin_constant_p (mode) | 588 return (__builtin_constant_p (mode) |
578 ? mode_nunits_inline (mode) : mode_nunits[mode]); | 589 ? mode_nunits_inline (mode) : mode_nunits[mode]); |
581 #endif | 592 #endif |
582 } | 593 } |
583 | 594 |
584 /* Get the size in bytes of an object of mode MODE. */ | 595 /* Get the size in bytes of an object of mode MODE. */ |
585 | 596 |
586 #define GET_MODE_SIZE(MODE) (mode_to_bytes (MODE)) | 597 #if ONLY_FIXED_SIZE_MODES |
598 #define GET_MODE_SIZE(MODE) ((unsigned short) mode_to_bytes (MODE).coeffs[0]) | |
599 #else | |
600 ALWAYS_INLINE poly_uint16 | |
601 GET_MODE_SIZE (machine_mode mode) | |
602 { | |
603 return mode_to_bytes (mode); | |
604 } | |
605 | |
606 template<typename T> | |
607 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type | |
608 GET_MODE_SIZE (const T &mode) | |
609 { | |
610 return mode_to_bytes (mode); | |
611 } | |
612 | |
613 template<typename T> | |
614 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type | |
615 GET_MODE_SIZE (const T &mode) | |
616 { | |
617 return mode_to_bytes (mode).coeffs[0]; | |
618 } | |
619 #endif | |
587 | 620 |
588 /* Get the size in bits of an object of mode MODE. */ | 621 /* Get the size in bits of an object of mode MODE. */ |
589 | 622 |
590 #define GET_MODE_BITSIZE(MODE) (mode_to_bits (MODE)) | 623 #if ONLY_FIXED_SIZE_MODES |
624 #define GET_MODE_BITSIZE(MODE) ((unsigned short) mode_to_bits (MODE).coeffs[0]) | |
625 #else | |
626 ALWAYS_INLINE poly_uint16 | |
627 GET_MODE_BITSIZE (machine_mode mode) | |
628 { | |
629 return mode_to_bits (mode); | |
630 } | |
631 | |
632 template<typename T> | |
633 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type | |
634 GET_MODE_BITSIZE (const T &mode) | |
635 { | |
636 return mode_to_bits (mode); | |
637 } | |
638 | |
639 template<typename T> | |
640 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type | |
641 GET_MODE_BITSIZE (const T &mode) | |
642 { | |
643 return mode_to_bits (mode).coeffs[0]; | |
644 } | |
645 #endif | |
591 | 646 |
592 /* Get the number of value bits of an object of mode MODE. */ | 647 /* Get the number of value bits of an object of mode MODE. */ |
593 | 648 |
594 #define GET_MODE_PRECISION(MODE) (mode_to_precision (MODE)) | 649 #if ONLY_FIXED_SIZE_MODES |
650 #define GET_MODE_PRECISION(MODE) \ | |
651 ((unsigned short) mode_to_precision (MODE).coeffs[0]) | |
652 #else | |
653 ALWAYS_INLINE poly_uint16 | |
654 GET_MODE_PRECISION (machine_mode mode) | |
655 { | |
656 return mode_to_precision (mode); | |
657 } | |
658 | |
659 template<typename T> | |
660 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type | |
661 GET_MODE_PRECISION (const T &mode) | |
662 { | |
663 return mode_to_precision (mode); | |
664 } | |
665 | |
666 template<typename T> | |
667 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type | |
668 GET_MODE_PRECISION (const T &mode) | |
669 { | |
670 return mode_to_precision (mode).coeffs[0]; | |
671 } | |
672 #endif | |
595 | 673 |
596 /* Get the number of integral bits of an object of mode MODE. */ | 674 /* Get the number of integral bits of an object of mode MODE. */ |
597 extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES]; | 675 extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES]; |
598 #define GET_MODE_IBIT(MODE) mode_ibit[MODE] | 676 #define GET_MODE_IBIT(MODE) mode_ibit[MODE] |
599 | 677 |
625 #define GET_MODE_UNIT_PRECISION(MODE) (mode_to_unit_precision (MODE)) | 703 #define GET_MODE_UNIT_PRECISION(MODE) (mode_to_unit_precision (MODE)) |
626 | 704 |
627 /* Get the number of units in an object of mode MODE. This is 2 for | 705 /* Get the number of units in an object of mode MODE. This is 2 for |
628 complex modes and the number of elements for vector modes. */ | 706 complex modes and the number of elements for vector modes. */ |
629 | 707 |
630 #define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE)) | 708 #if ONLY_FIXED_SIZE_MODES |
709 #define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE).coeffs[0]) | |
710 #else | |
711 ALWAYS_INLINE poly_uint16 | |
712 GET_MODE_NUNITS (machine_mode mode) | |
713 { | |
714 return mode_to_nunits (mode); | |
715 } | |
716 | |
717 template<typename T> | |
718 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type | |
719 GET_MODE_NUNITS (const T &mode) | |
720 { | |
721 return mode_to_nunits (mode); | |
722 } | |
723 | |
724 template<typename T> | |
725 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type | |
726 GET_MODE_NUNITS (const T &mode) | |
727 { | |
728 return mode_to_nunits (mode).coeffs[0]; | |
729 } | |
730 #endif | |
631 | 731 |
632 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ | 732 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ |
633 | 733 |
634 template<typename T> | 734 template<typename T> |
635 ALWAYS_INLINE opt_mode<T> | 735 ALWAYS_INLINE opt_mode<T> |
650 | 750 |
651 /* Get the complex mode from the component mode. */ | 751 /* Get the complex mode from the component mode. */ |
652 extern const unsigned char mode_complex[NUM_MACHINE_MODES]; | 752 extern const unsigned char mode_complex[NUM_MACHINE_MODES]; |
653 #define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE]) | 753 #define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE]) |
654 | 754 |
655 extern opt_machine_mode mode_for_size (unsigned int, enum mode_class, int); | 755 /* Represents a machine mode that must have a fixed size. The main |
756 use of this class is to represent the modes of objects that always | |
757 have static storage duration, such as constant pool entries. | |
758 (No current target supports the concept of variable-size static data.) */ | |
759 class fixed_size_mode | |
760 { | |
761 public: | |
762 typedef mode_traits<fixed_size_mode>::from_int from_int; | |
763 typedef unsigned short measurement_type; | |
764 | |
765 ALWAYS_INLINE fixed_size_mode () {} | |
766 ALWAYS_INLINE fixed_size_mode (from_int m) : m_mode (machine_mode (m)) {} | |
767 ALWAYS_INLINE fixed_size_mode (const scalar_mode &m) : m_mode (m) {} | |
768 ALWAYS_INLINE fixed_size_mode (const scalar_int_mode &m) : m_mode (m) {} | |
769 ALWAYS_INLINE fixed_size_mode (const scalar_float_mode &m) : m_mode (m) {} | |
770 ALWAYS_INLINE fixed_size_mode (const scalar_mode_pod &m) : m_mode (m) {} | |
771 ALWAYS_INLINE fixed_size_mode (const scalar_int_mode_pod &m) : m_mode (m) {} | |
772 ALWAYS_INLINE fixed_size_mode (const complex_mode &m) : m_mode (m) {} | |
773 ALWAYS_INLINE operator machine_mode () const { return m_mode; } | |
774 | |
775 static bool includes_p (machine_mode); | |
776 | |
777 protected: | |
778 machine_mode m_mode; | |
779 }; | |
780 | |
781 /* Return true if MODE has a fixed size. */ | |
782 | |
783 inline bool | |
784 fixed_size_mode::includes_p (machine_mode mode) | |
785 { | |
786 return mode_to_bytes (mode).is_constant (); | |
787 } | |
788 | |
789 /* Wrapper for mode arguments to target macros, so that if a target | |
790 doesn't need polynomial-sized modes, its header file can continue | |
791 to treat everything as fixed_size_mode. This should go away once | |
792 macros are moved to target hooks. It shouldn't be used in other | |
793 contexts. */ | |
794 #if NUM_POLY_INT_COEFFS == 1 | |
795 #define MACRO_MODE(MODE) (as_a <fixed_size_mode> (MODE)) | |
796 #else | |
797 #define MACRO_MODE(MODE) (MODE) | |
798 #endif | |
799 | |
800 extern opt_machine_mode mode_for_size (poly_uint64, enum mode_class, int); | |
656 | 801 |
657 /* Return the machine mode to use for a MODE_INT of SIZE bits, if one | 802 /* Return the machine mode to use for a MODE_INT of SIZE bits, if one |
658 exists. If LIMIT is nonzero, modes wider than MAX_FIXED_MODE_SIZE | 803 exists. If LIMIT is nonzero, modes wider than MAX_FIXED_MODE_SIZE |
659 will not be used. */ | 804 will not be used. */ |
660 | 805 |
661 inline opt_scalar_int_mode | 806 inline opt_scalar_int_mode |
662 int_mode_for_size (unsigned int size, int limit) | 807 int_mode_for_size (poly_uint64 size, int limit) |
663 { | 808 { |
664 return dyn_cast <scalar_int_mode> (mode_for_size (size, MODE_INT, limit)); | 809 return dyn_cast <scalar_int_mode> (mode_for_size (size, MODE_INT, limit)); |
665 } | 810 } |
666 | 811 |
667 /* Return the machine mode to use for a MODE_FLOAT of SIZE bits, if one | 812 /* Return the machine mode to use for a MODE_FLOAT of SIZE bits, if one |
668 exists. */ | 813 exists. */ |
669 | 814 |
670 inline opt_scalar_float_mode | 815 inline opt_scalar_float_mode |
671 float_mode_for_size (unsigned int size) | 816 float_mode_for_size (poly_uint64 size) |
672 { | 817 { |
673 return dyn_cast <scalar_float_mode> (mode_for_size (size, MODE_FLOAT, 0)); | 818 return dyn_cast <scalar_float_mode> (mode_for_size (size, MODE_FLOAT, 0)); |
674 } | 819 } |
675 | 820 |
676 /* Likewise for MODE_DECIMAL_FLOAT. */ | 821 /* Likewise for MODE_DECIMAL_FLOAT. */ |
680 { | 825 { |
681 return dyn_cast <scalar_float_mode> | 826 return dyn_cast <scalar_float_mode> |
682 (mode_for_size (size, MODE_DECIMAL_FLOAT, 0)); | 827 (mode_for_size (size, MODE_DECIMAL_FLOAT, 0)); |
683 } | 828 } |
684 | 829 |
685 extern machine_mode smallest_mode_for_size (unsigned int, enum mode_class); | 830 extern machine_mode smallest_mode_for_size (poly_uint64, enum mode_class); |
686 | 831 |
687 /* Find the narrowest integer mode that contains at least SIZE bits. | 832 /* Find the narrowest integer mode that contains at least SIZE bits. |
688 Such a mode must exist. */ | 833 Such a mode must exist. */ |
689 | 834 |
690 inline scalar_int_mode | 835 inline scalar_int_mode |
691 smallest_int_mode_for_size (unsigned int size) | 836 smallest_int_mode_for_size (poly_uint64 size) |
692 { | 837 { |
693 return as_a <scalar_int_mode> (smallest_mode_for_size (size, MODE_INT)); | 838 return as_a <scalar_int_mode> (smallest_mode_for_size (size, MODE_INT)); |
694 } | 839 } |
695 | 840 |
696 extern opt_scalar_int_mode int_mode_for_mode (machine_mode); | 841 extern opt_scalar_int_mode int_mode_for_mode (machine_mode); |
697 extern opt_machine_mode bitwise_mode_for_mode (machine_mode); | 842 extern opt_machine_mode bitwise_mode_for_mode (machine_mode); |
698 extern opt_machine_mode mode_for_vector (scalar_mode, unsigned); | 843 extern opt_machine_mode mode_for_vector (scalar_mode, poly_uint64); |
699 extern opt_machine_mode mode_for_int_vector (unsigned int, unsigned int); | 844 extern opt_machine_mode mode_for_int_vector (unsigned int, poly_uint64); |
700 | 845 |
701 /* Return the integer vector equivalent of MODE, if one exists. In other | 846 /* Return the integer vector equivalent of MODE, if one exists. In other |
702 words, return the mode for an integer vector that has the same number | 847 words, return the mode for an integer vector that has the same number |
703 of bits as MODE and the same number of elements as MODE, with the | 848 of bits as MODE and the same number of elements as MODE, with the |
704 latter being 1 if MODE is scalar. The returned mode can be either | 849 latter being 1 if MODE is scalar. The returned mode can be either |
714 /* A class for iterating through possible bitfield modes. */ | 859 /* A class for iterating through possible bitfield modes. */ |
715 class bit_field_mode_iterator | 860 class bit_field_mode_iterator |
716 { | 861 { |
717 public: | 862 public: |
718 bit_field_mode_iterator (HOST_WIDE_INT, HOST_WIDE_INT, | 863 bit_field_mode_iterator (HOST_WIDE_INT, HOST_WIDE_INT, |
719 HOST_WIDE_INT, HOST_WIDE_INT, | 864 poly_int64, poly_int64, |
720 unsigned int, bool); | 865 unsigned int, bool); |
721 bool next_mode (scalar_int_mode *); | 866 bool next_mode (scalar_int_mode *); |
722 bool prefer_smaller_modes (); | 867 bool prefer_smaller_modes (); |
723 | 868 |
724 private: | 869 private: |
725 opt_scalar_int_mode m_mode; | 870 opt_scalar_int_mode m_mode; |
726 /* We use signed values here because the bit position can be negative | 871 /* We use signed values here because the bit position can be negative |
727 for invalid input such as gcc.dg/pr48335-8.c. */ | 872 for invalid input such as gcc.dg/pr48335-8.c. */ |
728 HOST_WIDE_INT m_bitsize; | 873 HOST_WIDE_INT m_bitsize; |
729 HOST_WIDE_INT m_bitpos; | 874 HOST_WIDE_INT m_bitpos; |
730 HOST_WIDE_INT m_bitregion_start; | 875 poly_int64 m_bitregion_start; |
731 HOST_WIDE_INT m_bitregion_end; | 876 poly_int64 m_bitregion_end; |
732 unsigned int m_align; | 877 unsigned int m_align; |
733 bool m_volatilep; | 878 bool m_volatilep; |
734 int m_count; | 879 int m_count; |
735 }; | 880 }; |
736 | 881 |
737 /* Find the best mode to use to access a bit field. */ | 882 /* Find the best mode to use to access a bit field. */ |
738 | 883 |
739 extern bool get_best_mode (int, int, unsigned HOST_WIDE_INT, | 884 extern bool get_best_mode (int, int, poly_uint64, poly_uint64, unsigned int, |
740 unsigned HOST_WIDE_INT, unsigned int, | |
741 unsigned HOST_WIDE_INT, bool, scalar_int_mode *); | 885 unsigned HOST_WIDE_INT, bool, scalar_int_mode *); |
742 | 886 |
743 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */ | 887 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */ |
744 | 888 |
745 extern CONST_MODE_BASE_ALIGN unsigned short mode_base_align[NUM_MACHINE_MODES]; | 889 extern CONST_MODE_BASE_ALIGN unsigned short mode_base_align[NUM_MACHINE_MODES]; |
782 | 926 |
783 #define TRULY_NOOP_TRUNCATION_MODES_P(MODE1, MODE2) \ | 927 #define TRULY_NOOP_TRUNCATION_MODES_P(MODE1, MODE2) \ |
784 (targetm.truly_noop_truncation (GET_MODE_PRECISION (MODE1), \ | 928 (targetm.truly_noop_truncation (GET_MODE_PRECISION (MODE1), \ |
785 GET_MODE_PRECISION (MODE2))) | 929 GET_MODE_PRECISION (MODE2))) |
786 | 930 |
787 #define HWI_COMPUTABLE_MODE_P(MODE) \ | 931 /* Return true if MODE is a scalar integer mode that fits in a |
788 (SCALAR_INT_MODE_P (MODE) \ | 932 HOST_WIDE_INT. */ |
789 && GET_MODE_PRECISION (MODE) <= HOST_BITS_PER_WIDE_INT) | 933 |
934 inline bool | |
935 HWI_COMPUTABLE_MODE_P (machine_mode mode) | |
936 { | |
937 machine_mode mme = mode; | |
938 return (SCALAR_INT_MODE_P (mme) | |
939 && mode_to_precision (mme).coeffs[0] <= HOST_BITS_PER_WIDE_INT); | |
940 } | |
941 | |
942 inline bool | |
943 HWI_COMPUTABLE_MODE_P (scalar_int_mode mode) | |
944 { | |
945 return GET_MODE_PRECISION (mode) <= HOST_BITS_PER_WIDE_INT; | |
946 } | |
790 | 947 |
791 struct int_n_data_t { | 948 struct int_n_data_t { |
792 /* These parts are initailized by genmodes output */ | 949 /* These parts are initailized by genmodes output */ |
793 unsigned int bitsize; | 950 unsigned int bitsize; |
794 scalar_int_mode_pod m; | 951 scalar_int_mode_pod m; |
856 { | 1013 { |
857 *cmode = complex_mode (complex_mode::from_int (mode)); | 1014 *cmode = complex_mode (complex_mode::from_int (mode)); |
858 return true; | 1015 return true; |
859 } | 1016 } |
860 return false; | 1017 return false; |
1018 } | |
1019 | |
1020 /* Return true if MODE is a scalar integer mode with a precision | |
1021 smaller than LIMIT's precision. */ | |
1022 | |
1023 inline bool | |
1024 is_narrower_int_mode (machine_mode mode, scalar_int_mode limit) | |
1025 { | |
1026 scalar_int_mode int_mode; | |
1027 return (is_a <scalar_int_mode> (mode, &int_mode) | |
1028 && GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (limit)); | |
861 } | 1029 } |
862 | 1030 |
863 namespace mode_iterator | 1031 namespace mode_iterator |
864 { | 1032 { |
865 /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */ | 1033 /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */ |