From: rsandifo Date: Mon, 7 Oct 2019 08:38:49 +0000 (+0000) Subject: Use CONSTEXPR in machmode.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92402274cf432bd079988ed0bf5fb6c7e07bd068;p=thirdparty%2Fgcc.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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276649 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ef8731fb3a0d..ce9158595924 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 005ec80e89d2..64ac213fbac1 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);