diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-10-07 08:38:49 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-10-07 08:38:49 +0000 |
commit | ad00d6c1746fdcbfd86b2d50f2500d7ccb0d1691 (patch) | |
tree | e898c4bd4fc7177de519be6d52f7c865c52345f2 /gcc/machmode.h | |
parent | 698114484e668abf28c70d989bc93fa399dda9ac (diff) | |
download | gcc-ad00d6c1746fdcbfd86b2d50f2500d7ccb0d1691.zip gcc-ad00d6c1746fdcbfd86b2d50f2500d7ccb0d1691.tar.gz gcc-ad00d6c1746fdcbfd86b2d50f2500d7ccb0d1691.tar.bz2 |
Use CONSTEXPR in machmode.h
This patch adds CONSTEXPR to constructors and operators in machmode.h,
excluding the controversial constexpr-resistant "() {}" constructors,
which would become "= default" if we required C++11.
Some of the other routines could potentially be constexpr too,
but that can be done on an as-needed basis.
2019-10-07 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* machmode.h (opt_mode): Mark constructors with CONSTEXPR.
(pod_mode): Mark operators likewise.
(scalar_int_mode): Mark non-default constructors and
operators with CONSTEXPR.
(scalar_float_mode, scalar_mode, complex_mode): Likewise.
(fixed_size_mode): Likewise.
From-SVN: r276649
Diffstat (limited to 'gcc/machmode.h')
-rw-r--r-- | gcc/machmode.h | 87 |
1 files changed, 62 insertions, 25 deletions
diff --git a/gcc/machmode.h b/gcc/machmode.h index 005ec80..64ac213 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -244,11 +244,11 @@ class opt_mode public: enum from_int { dummy = MAX_MACHINE_MODE }; - ALWAYS_INLINE opt_mode () : m_mode (E_VOIDmode) {} - ALWAYS_INLINE opt_mode (const T &m) : m_mode (m) {} + ALWAYS_INLINE CONSTEXPR opt_mode () : m_mode (E_VOIDmode) {} + ALWAYS_INLINE CONSTEXPR opt_mode (const T &m) : m_mode (m) {} template<typename U> - ALWAYS_INLINE opt_mode (const U &m) : m_mode (T (m)) {} - ALWAYS_INLINE opt_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE CONSTEXPR opt_mode (const U &m) : m_mode (T (m)) {} + ALWAYS_INLINE CONSTEXPR opt_mode (from_int m) : m_mode (machine_mode (m)) {} machine_mode else_void () const; machine_mode else_blk () const { return else_mode (BLKmode); } @@ -324,8 +324,12 @@ struct pod_mode typedef typename T::measurement_type measurement_type; machine_mode m_mode; - ALWAYS_INLINE operator machine_mode () const { return m_mode; } - ALWAYS_INLINE operator T () const { return from_int (m_mode); } + ALWAYS_INLINE CONSTEXPR + operator machine_mode () const { return m_mode; } + + ALWAYS_INLINE CONSTEXPR + operator T () const { return from_int (m_mode); } + ALWAYS_INLINE pod_mode &operator = (const T &m) { m_mode = m; return *this; } }; @@ -403,8 +407,11 @@ public: typedef unsigned short measurement_type; ALWAYS_INLINE scalar_int_mode () {} - ALWAYS_INLINE scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {} - ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + ALWAYS_INLINE CONSTEXPR + scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {} + + ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; } static bool includes_p (machine_mode); @@ -428,8 +435,11 @@ public: typedef unsigned short measurement_type; ALWAYS_INLINE scalar_float_mode () {} - ALWAYS_INLINE scalar_float_mode (from_int m) : m_mode (machine_mode (m)) {} - ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + ALWAYS_INLINE CONSTEXPR + scalar_float_mode (from_int m) : m_mode (machine_mode (m)) {} + + ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; } static bool includes_p (machine_mode); @@ -453,11 +463,20 @@ public: typedef unsigned short measurement_type; ALWAYS_INLINE scalar_mode () {} - ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {} - ALWAYS_INLINE scalar_mode (const scalar_int_mode &m) : m_mode (m) {} - ALWAYS_INLINE scalar_mode (const scalar_float_mode &m) : m_mode (m) {} - ALWAYS_INLINE scalar_mode (const scalar_int_mode_pod &m) : m_mode (m) {} - ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + ALWAYS_INLINE CONSTEXPR + scalar_mode (from_int m) : m_mode (machine_mode (m)) {} + + ALWAYS_INLINE CONSTEXPR + scalar_mode (const scalar_int_mode &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR + scalar_mode (const scalar_float_mode &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR + scalar_mode (const scalar_int_mode_pod &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; } static bool includes_p (machine_mode); @@ -494,8 +513,11 @@ public: typedef unsigned short measurement_type; ALWAYS_INLINE complex_mode () {} - ALWAYS_INLINE complex_mode (from_int m) : m_mode (machine_mode (m)) {} - ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + ALWAYS_INLINE CONSTEXPR + complex_mode (from_int m) : m_mode (machine_mode (m)) {} + + ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; } static bool includes_p (machine_mode); @@ -764,14 +786,29 @@ public: typedef unsigned short measurement_type; ALWAYS_INLINE fixed_size_mode () {} - ALWAYS_INLINE fixed_size_mode (from_int m) : m_mode (machine_mode (m)) {} - ALWAYS_INLINE fixed_size_mode (const scalar_mode &m) : m_mode (m) {} - ALWAYS_INLINE fixed_size_mode (const scalar_int_mode &m) : m_mode (m) {} - ALWAYS_INLINE fixed_size_mode (const scalar_float_mode &m) : m_mode (m) {} - ALWAYS_INLINE fixed_size_mode (const scalar_mode_pod &m) : m_mode (m) {} - ALWAYS_INLINE fixed_size_mode (const scalar_int_mode_pod &m) : m_mode (m) {} - ALWAYS_INLINE fixed_size_mode (const complex_mode &m) : m_mode (m) {} - ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + ALWAYS_INLINE CONSTEXPR + fixed_size_mode (from_int m) : m_mode (machine_mode (m)) {} + + ALWAYS_INLINE CONSTEXPR + fixed_size_mode (const scalar_mode &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR + fixed_size_mode (const scalar_int_mode &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR + fixed_size_mode (const scalar_float_mode &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR + fixed_size_mode (const scalar_mode_pod &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR + fixed_size_mode (const scalar_int_mode_pod &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR + fixed_size_mode (const complex_mode &m) : m_mode (m) {} + + ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; } static bool includes_p (machine_mode); |