Use CONSTEXPR in machmode.h

Jeff Law law@redhat.com
Fri Oct 4 15:53:00 GMT 2019


On 10/4/19 9:01 AM, Richard Sandiford wrote:
> I'd like to use CONSTEXPR to get static initialisation of some
> aarch64-specific variables.  This obviously means that cross toolchains
> built with old compilers won't benefit, but I hope toolchains built with
> newer compilers are faster for other reasons too. :-)
> 
> The variables in question have scalar_int_mode fields, so I first
> needed to make the machine_mode stuff more constexpr-friendly.
> This patch therefore 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.
> 
> Tested on aarch64-linux-gnu, with and without the follow-on changes.
> OK to install?
> 
> Richard
> 
> 
> 2019-10-04  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.
Given that we've got the necessary magic in ansidecl.h and have already
started using constexpr elsewhere (bitmap, vec) I think this has to be
considered OK regardless of any policies we have WRT C++11 features.

So OK as would be the introduction of CONSTEXPR elsewhere.

Jeff



More information about the Gcc-patches mailing list