From: Richard Sandiford Date: Mon, 7 Oct 2019 08:38:49 +0000 (+0000) Subject: Use CONSTEXPR in machmode.h X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ad00d6c1746fdcbfd86b2d50f2500d7ccb0d1691;p=gcc.git 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 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ef8731fb3a0..ce915859592 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2019-10-07 Richard Sandiford + + * 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. + 2019-10-07 Richard Sandiford PR target/91994 diff --git a/gcc/machmode.h b/gcc/machmode.h index 005ec80e89d..64ac213fbac 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 - 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);