Commit graph

195715 commits

Author SHA1 Message Date
Jakub Jelinek
e564021e4c aarch64: Fix C++ ICEs with _Float16 and __fp16 [PR107080]
On Fri, Sep 30, 2022 at 09:54:49AM -0400, Jason Merrill wrote:
> > Note, there is one further problem on aarch64/arm, types with HFmode
> > (_Float16 and __fp16) are there mangled as Dh (which is standard
> > Itanium mangling:
> >                   ::= Dh # IEEE 754r half-precision floating point (16 bits)
> >                   ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
> > so in theory is also ok, but DF16_ is more specific.  Should we just
> > change Dh to DF16_ in those backends, or should __fp16 there be distinct
> > type from _Float16 where __fp16 would mangle Dh and _Float16 DF16_ ?
>
> You argued for keeping __float128 separate from _Float128, does the same
> argument not apply to this case?

Actually, they already were distinct types that just mangled the same.
So the same issue that had to be solved on i?86, ia64 and rs6000 for
_Float64x vs. long double is a problem on arm and aarch64 with _Float16
vs. __fp16.
The following patch fixes it so far for aarch64.

2022-09-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/107080
	* config/aarch64/aarch64.cc (aarch64_mangle_type): Mangle just __fp16
	as Dh and _Float16 as DF16_.

	* g++.target/aarch64/pr107080.C: New test.
2022-09-30 19:52:49 +02:00
Jakub Jelinek
a6d8c61a49 i386, rs6000, ia64, s390: Fix C++ ICEs with _Float64x or _Float128 [PR107080]
The following testcase ICEs on x86 as well as ppc64le (the latter
with -mabi=ieeelongdouble), because _Float64x there isn't mangled as
DF64x but e or u9__ieee128 instead.
Those are the mangling that should be used for the non-standard
types with the same mode or for long double, but not for _Float64x.
All the 4 mangle_type targhook implementations start with
type = TYPE_MAIN_VARIANT (type);
so I think it is cleanest to handle it the same in all and return NULL
before the switches on mode or whatever other tests.
s390 doesn't actually have a bug, but while I was there, having
type = TYPE_MAIN_VARIANT (type);
if (TYPE_MAIN_VARIANT (type) == long_double_type_node)
looked useless to me.

Note, there is one further problem on aarch64/arm, types with HFmode
(_Float16 and __fp16) are there mangled as Dh (which is standard
Itanium mangling:
                 ::= Dh # IEEE 754r half-precision floating point (16 bits)
                 ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
so in theory is also ok, but DF16_ is more specific.  Should we just
change Dh to DF16_ in those backends, or should __fp16 there be distinct
type from _Float16 where __fp16 would mangle Dh and _Float16 DF16_ ?
And there is csky, which mangles __fp16 (but only if type's name is __fp16,
not _Float16) as __fp16, that looks clearly invalid to me as it isn't
valid in the mangling grammar.  So perhaps just nuke csky's mangle_type
and have it mangled as DF16_ by the generic code?

2022-09-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/107080
	* config/i386/i386.cc (ix86_mangle_type): Always return NULL
	for float128_type_node or float64x_type_node, don't check
	float128t_type_node later on.
	* config/ia64/ia64.cc (ia64_mangle_type): Always return NULL
	for float128_type_node or float64x_type_node.
	* config/rs6000/rs6000.cc (rs6000_mangle_type): Likewise.
	Don't check float128_type_node later on.
	* config/s390/s390.cc (s390_mangle_type): Don't use
	TYPE_MAIN_VARIANT on type which was set to TYPE_MAIN_VARIANT
	a few lines earlier.

	* g++.dg/cpp23/ext-floating11.C: New test.
2022-09-30 18:41:15 +02:00
Torbjörn SVENSSON
fe8264bb9b testsuite: Windows paths use \ and not /
libstdc++-v3/ChangeLog:

	* testsuite/20_util/bind/ref_neg.cc: Prune Windows paths too.

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 18:33:06 +02:00
Torbjörn SVENSSON
5fb71366da testsuite: Only run test on target if VMA == LMA
Checking that the triplet matches arm*-*-eabi (or msp430-*-*) is not
enough to know if the execution will enter an endless loop, or if it
will give a meaningful result. As the execution test only work when
VMA and LMA are equal, make sure that this condition is met.

gcc/ChangeLog:

	* doc/sourcebuild.texi: Document new vma_equals_lma effective
	target check.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp (check_effective_target_vma_equals_lma): New.
	* c-c++-common/torture/attr-noinit-1.c: Requre VMA == LMA to run.
	* c-c++-common/torture/attr-noinit-2.c: Likewise.
	* c-c++-common/torture/attr-noinit-3.c: Likewise.
	* c-c++-common/torture/attr-persistent-1.c: Likewise.
	* c-c++-common/torture/attr-persistent-3.c: Likewise.

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 18:28:46 +02:00
Torbjörn SVENSSON
86291da005 testsuite: Do not prefix linker script with "-Wl,"
The linker script should not be prefixed with "-Wl," - it's not an
input file and does not interfere with the new dump output filename
strategy.

gcc/testsuite/ChangeLog:

	* lib/gcc-defs.exp: Do not prefix linker script with "-Wl,".

Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 18:24:46 +02:00
Jiawei
32f86f2b54 RISC-V: Add '-m[no]-csr-check' option in gcc.
Add -m[no]-csr-check option in gcc part, when enable -mcsr-check option,
it will add csr-check in .option section and pass this to assembler.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_file_start): New .option.
	* config/riscv/riscv.opt: New options.
	* doc/invoke.texi: New definations.
2022-09-30 23:09:16 +08:00
Patrick Palka
1e2c124d71 c++: streamline built-in trait addition process
Adding a new built-in trait currently involves manual boilerplate
consisting of defining an rid enumerator for the identifier as well as a
corresponding cp_trait_kind enumerator and handling them in various switch
statements, the exact set of which depends on whether the proposed trait
yields (and thus is recognized as) a type or an expression.

To streamline the process, this patch adds a central cp-trait.def file
that tabulates the essential details about each built-in trait (whether
it yields a type or an expression, its code, its spelling and its arity)
and uses this file to automate away the manual boilerplate.  It also
migrates all the existing C++-specific built-in traits to use this
approach.

After this change, adding a new built-in trait just entails declaring
it in cp-trait.def and defining its behavior in finish_trait_expr/type
(and handling it in diagnose_trait_expr, if it's an expression-yielding
trait).

gcc/c-family/ChangeLog:

	* c-common.cc (c_common_reswords): Use cp/cp-trait.def to handle
	C++ traits.
	* c-common.h (enum rid): Likewise.

gcc/cp/ChangeLog:

	* constraint.cc (diagnose_trait_expr): Likewise.
	* cp-objcp-common.cc (names_builtin_p): Likewise.
	* cp-tree.h (enum cp_trait_kind): Likewise.
	* cxx-pretty-print.cc (pp_cxx_trait): Likewise.
	* parser.cc (cp_keyword_starts_decl_specifier_p): Likewise.
	(cp_parser_primary_expression): Likewise.
	(cp_parser_trait): Likewise.
	(cp_parser_simple_type_specifier): Likewise.
	* cp-trait.def: New file.
2022-09-30 11:06:54 -04:00
Torbjörn SVENSSON
3bb2d70d38 testsuite: Colon is reserved on Windows
The ':' is reserved in filenames on Windows.

Without this patch, the test case failes with:
.../ben-1_a.C:4:8: error: failed to write compiled module: Invalid argument
.../ben-1_a.C:4:8: note: compiled module file is 'partitions/module:import.mod'

gcc/testsuite:

	* g++.dg/modules/ben-1.map: Replace the colon with dash.
	* g++.dg/modules/ben-1_a.C: Likewise

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 15:54:50 +02:00
Arsen Arsenović
57707f38f2 libstdc++: Add missing <bits/stl_algobase.h> include to <bitset>
libstdc++-v3/ChangeLog:

	* include/std/bitset: Include <bits/stl_algobase.h>.
2022-09-30 14:43:19 +01:00
Kewen Lin
c23b5006d3 rs6000: Rework ELFv2 support for -fpatchable-function-entry* [PR99888]
As PR99888 and its related show, the current support for
-fpatchable-function-entry on powerpc ELFv2 doesn't work
well with global entry existence.  For example, with one
command line option -fpatchable-function-entry=3,2, it got
below w/o this patch:

  .LPFE1:
	  nop
	  nop
	  .type   foo, @function
  foo:
	  nop
  .LFB0:
	  .cfi_startproc
  .LCF0:
  0:      addis 2,12,.TOC.-.LCF0@ha
	  addi 2,2,.TOC.-.LCF0@l
	  .localentry     foo,.-foo

, the assembly is unexpected since the patched nops have
no effects when being entered from local entry.

This patch is to update the nops patched before and after
local entry, it looks like:

	  .type   foo, @function
  foo:
  .LFB0:
	  .cfi_startproc
  .LCF0:
  0:      addis 2,12,.TOC.-.LCF0@ha
	  addi 2,2,.TOC.-.LCF0@l
	  nop
	  nop
	  .localentry     foo,.-foo
	  nop

	PR target/99888
	PR target/105649

gcc/ChangeLog:

	* doc/invoke.texi (option -fpatchable-function-entry): Adjust the
	documentation for PowerPC ELFv2 ABI dual entry points.
	* config/rs6000/rs6000-internal.h
	(rs6000_print_patchable_function_entry): New function declaration.
	* config/rs6000/rs6000-logue.cc (rs6000_output_function_prologue):
	Support patchable-function-entry by emitting nops before and after
	local entry for the function that needs global entry.
	* config/rs6000/rs6000.cc (rs6000_print_patchable_function_entry): Skip
	the function that needs global entry till global entry has been
	emitted.
	* config/rs6000/rs6000.h (struct machine_function): New bool member
	global_entry_emitted.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr99888-1.c: New test.
	* gcc.target/powerpc/pr99888-2.c: New test.
	* gcc.target/powerpc/pr99888-3.c: New test.
	* gcc.target/powerpc/pr99888-4.c: New test.
	* gcc.target/powerpc/pr99888-5.c: New test.
	* gcc.target/powerpc/pr99888-6.c: New test.
	* c-c++-common/patchable_function_entry-default.c: Adjust for
	powerpc_elfv2 to avoid compilation error.
2022-09-30 07:16:49 -05:00
Kewen Lin
c28957176d rs6000/test: Adjust pr104992.c with vect_int_mod [PR106516]
As PR106516 shows, we can get unexpected gimple outputs for
function thud on some target which supports modulus operation
for vector int.  This patch introduces one effective target
vect_int_mod for it, then adjusts the test case with it.

	PR testsuite/106516

gcc/testsuite/ChangeLog:

	* gcc.dg/pr104992.c: Adjust with vect_int_mod.
	* lib/target-supports.exp (check_effective_target_vect_int_mod): New
	effective target.
2022-09-30 07:16:36 -05:00
Christophe Lyon
c09663eabf testsuite: [arm] Relax expected register names in MVE tests
These two tests have hardcoded q0 as destination/source of load/store
instructions, but this register is actually used only under
-mfloat-abi=hard. When using -mfloat-abi=softfp, other registers
(eg. q3) can be used to transfer function arguments from core
registers to MVE registers, making the expected regexp fail.

This small patch replaces q0 with q[0-7] to accept any 'q' register.
In several places where we had q[0-9]+, replace it with q[0-7] as MVE
only has q0-q7 registers.

OK for trunk?

gcc/testsuite/ChangeLog:

	* gcc.target/arm/mve/mve_load_memory_modes.c: Update expected
	registers.
	* gcc.target/arm/mve/mve_store_memory_modes.c: Likewise.
2022-09-30 13:55:50 +02:00
Richard Biener
44510e44e7 tree-optimization/107095 - fix typo in .MASK_STORE DSE handling
We were using the size of the mask argument rather than the data
argument for the ao_ref.

	PR tree-optimization/107095
	* tree-ssa-dse.cc (initialize_ao_ref_for_dse): Use data arg
	for .MASK_STORE size.
2022-09-30 13:42:58 +02:00
Tobias Burnus
10a1161049 Fortran: Update use_device_ptr for OpenMP 5.1 [PR105318]
OpenMP 5.1 added has_device_addr and relaxed the restrictions for
use_device_ptr, including processing non-type(c_ptr) arguments as
if has_device_addr was used. (There is a semantic difference.)

For completeness, the likewise change was done for 'use_device_ptr',
where non-type(c_ptr) arguments now use use_device_addr.

Finally, a warning for 'device(omp_{initial,invalid}_device)' was
silenced on the way as affecting the new testcase.

	PR fortran/105318

gcc/fortran/ChangeLog:
	* openmp.cc (resolve_omp_clauses): Update is_device_ptr restrictions
	for OpenMP 5.1 and map to has_device_addr where applicable; map
	use_device_ptr to use_device_addr where applicable.
	Silence integer-range warning for device(omp_{initial,invalid}_device).

libgomp/ChangeLog:
	* testsuite/libgomp.fortran/is_device_ptr-2.f90: New test.

gcc/testsuite/ChangeLog:
	* gfortran.dg/gomp/is_device_ptr-1.f90: Remove dg-error.
	* gfortran.dg/gomp/is_device_ptr-2.f90: Likewise.
	* gfortran.dg/gomp/is_device_ptr-3.f90: Update tree-scan-dump.
2022-09-30 13:37:18 +02:00
Olivier Hainque
9b8ffbb8a0 Arrange to --disable-shared by default for VxWorks
This change makes sure that shared libraries for VxWorks are
only built on explicit request, when configured with --enable-shared.

As the support to build shared libs gets in very incrementally,
this provides us with a robust way to guard the relevant pieces
and reduce the risks of accidentally breaking a platform not yet
ready for it.

2022-09-30  Olivier Hainque  <hainque@adacore.com>

	* configure.ac (*vxworks*): If enable_shared is not
	set, set to "no" and add --disable-shared to target and
	host_configargs.
	* configure: Regenerate.
2022-09-30 10:43:13 +00:00
Jason Merrill
43faf3e544 c++: reduce redundant TARGET_EXPR
An experiment led me to notice that in some cases we were ending up with
TARGET_EXPR initialized by TARGET_EXPR, which isn't useful.

The target_expr_needs_replace change won't make a difference in most cases,
since cp_genericize_init will have already expanded VEC_INIT_EXPR by the
time we consider it, but it is correct.

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_fold_r) [TARGET_EXPR]: Collapse
	TARGET_EXPR within TARGET_EXPR.
	* constexpr.cc (cxx_eval_outermost_constant_expr): Avoid
	adding redundant TARGET_EXPR.
	* cp-tree.h (target_expr_needs_replace): VEC_INIT_EXPR doesn't.
2022-09-29 21:27:02 -04:00
GCC Administrator
bbdcdf5cc7 Daily bump. 2022-09-30 00:17:47 +00:00
Joseph Myers
3a3516bc4a c: C2x noreturn attribute
C2x adds a standard [[noreturn]] attribute (which can also be spelt
[[_Noreturn]] for use with <stdnoreturn.h>), so allowing non-returning
functions to be declared in a manner compatible with C++; the
_Noreturn function specifier remains available but is marked
obsolescent.

Implement this attribute.  It's more restricted than GNU
__attribute__ ((noreturn)) - that allows function pointers but using
the standard attribute on a function pointer is a constraint
violation.  Thus, the attribute gets its own handler that checks for a
FUNCTION_DECL before calling the handler for the GNU attribute.  Tests
for the attribute are based on those for C11 _Noreturn and for other
C2x attributes.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c-family/
	* c-lex.cc (c_common_has_attribute): Handle noreturn attribute for
	C.

gcc/c/
	* c-decl.cc (handle_std_noreturn_attribute): New function.
	(std_attribute_table): Add _Noreturn and noreturn.

gcc/testsuite/
	* gcc.dg/c2x-attr-noreturn-1.c, gcc.dg/c2x-attr-noreturn-2.c,
	gcc.dg/c2x-attr-noreturn-3.c: New tests.
	* gcc.dg/c2x-has-c-attribute-2.c: Also test __has_c_attribute for
	noreturn attribute.
2022-09-29 22:59:22 +00:00
Andrew MacLeod
7ea258a13a Process unsigned overflow relations for plus and minus is range-ops.
If a relation is available, calculate overflow and normal ranges. Then
apply as appropriate.

	gcc/
	* range-op.cc (plus_minus_ranges): New.
	(adjust_op1_for_overflow): New.
	(operator_plus::op1_range): Use new adjustment.
	(operator_plus::op2_range): Ditto.
	(operator_minus::op1_range): Ditto.
	* value-relation.h (relation_lt_le_gt_ge_p): New.

	gcc/testsuite/
	* gcc.dg/tree-ssa/pr79095.c: Test evrp pass rather than vrp1.
2022-09-29 18:34:18 -04:00
Andrew MacLeod
67166c9ec3 Refine ranges using relations in GORI.
This allows GORI to recognize when a relation passed in applies to the
2 operands of the current statement.  Check to see if further range
refinement is possible before proceeding.

	* gimple-range-gori.cc (gori_compute::refine_using_relation): New.
	(gori_compute::compute_operand1_range): Invoke
	refine_using_relation when applicable.
	(gori_compute::compute_operand2_range): Ditto.
	* gimple-range-gori.h (class gori_compute): Adjust prototypes.
2022-09-29 18:34:18 -04:00
Andrew MacLeod
431cdfbea1 Track value_relations in GORI.
This allows GORI to recognize and pass relations along the calculation chain.
This will allow relations between the LHS and the operand being calculated
to be utilized in op1_range and op2_range.

	* gimple-range-gori.cc (ori_compute::compute_operand_range):
	Create a relation record and pass it along when possible.
	(gori_compute::compute_operand1_range): Pass relation along.
	(gori_compute::compute_operand2_range): Ditto.
	(gori_compute::compute_operand1_and_operand2_range): Ditto.
	* gimple-range-gori.h (class gori_compute): Adjust prototypes.
	* gimple-range-op.cc (gimple_range_op_handler::calc_op1): Pass
	relation to op1_range call.
	(gimple_range_op_handler::calc_op2): Pass relation to op2_range call.
	* gimple-range-op.h (class gimple_range_op_handler): Adjust
	prototypes.
2022-09-29 18:34:18 -04:00
Andrew MacLeod
cfa7434c4b Move class value_relation the header file.
* value-relation.cc (class value_relation): Move to .h file.
	(value_relation::set_relation): Ditto.
	(value_relation::value_relation): ditto.
	* value-relation.h (class value_relation): Move from .cc file.
	(value_relation::set_relation): Ditto
	(value_relation::value_relation): Ditto.
2022-09-29 18:34:18 -04:00
Andrew MacLeod
ef9bc3626c Audit op1_range and op2_range for undefined LHS.
If the LHS is undefined, GORI should cease looking. There are numerous
places where this happens, and a few potential traps.

	* range-op.cc (operator_minus::op2_range): Check for undefined.
	(operator_mult::op1_range): Ditto.
	(operator_exact_divide::op1_range): Ditto.
	(operator_lshift::op1_range): Ditto.
	(operator_rshift::op1_range): Ditto.
	(operator_cast::op1_range): Ditto.
	(operator_bitwise_and::op1_range): Ditto.
	(operator_bitwise_or::op1_range): Ditto.
	(operator_trunc_mod::op1_range): Ditto.
	(operator_trunc_mod::op2_range): Ditto.
	(operator_bitwise_not::op1_range): Ditto.
	(pointer_or_operator::op1_range): Ditto.
	(range_op_handler::op1_range): Ditto.
	(range_op_handler::op2_range): Ditto.
2022-09-29 18:34:18 -04:00
Andrew MacLeod
845ee38e9b Remove undefined behaviour from testscase.
There was a patch posted to remove the undefined behaviour from this
testcase, but it appear to never have been applied.

	gcc/teststuite/
	PR tree-optimization/102892
	* gcc.dg/pr102892-1.c: Remove undefined behaviour.
2022-09-29 18:34:09 -04:00
Patrick Palka
c2ee70f20d c++: implicit lookup of std::initializer_list [PR102576]
Here the lookup for the implicit use of std::initializer_list fails
because we do it using get_namespace_binding, which isn't import aware.
Fix this by using lookup_qualified_name instead.

	PR c++/102576

gcc/cp/ChangeLog:

	* pt.cc (listify): Use lookup_qualified_name instead of
	get_namespace_binding.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr102576_a.H: New test.
	* g++.dg/modules/pr102576_b.C: New test.
2022-09-29 16:27:30 -04:00
Jason Merrill
04d54b70fe c++: fix triviality of class with unsatisfied op=
cxx20_pair is trivially copyable because it has a trivial copy constructor
and only a deleted copy assignment operator; the non-triviality of the
unsatisfied copy assignment overload is not considered.

gcc/cp/ChangeLog:

	* class.cc (check_methods): Call constraints_satisfied_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/cond-triv3.C: New test.
2022-09-29 15:11:44 -04:00
François Dumont
13337ea9a1 libstdc++: [_GLIBCXX_INLINE_VERSION] Add gdb pretty print for _GLIBCXX_DEBUG
In _GLIBCXX_DEBUG mode containers are in std::__debug namespace but not template
parameters. In _GLIBCXX_INLINE_VERSION mode most types are in std::__8 namespace but
not std::__debug containers. We need to register specific type printers for this
combination.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (add_one_template_type_printer): Register
	printer for types in std::__debug namespace with template parameters in std::__8
	namespace.
2022-09-29 20:41:37 +02:00
Olivier Hainque
61762797ba Improve comments and INITFINI macro use in vxcrtsutff.c
This change augments the comment attached to the use of auto-host.h
in vxcrtstuff.c to better describe the reason for including it and
for the associated series of #undef directives.

It also augments the comment on dso_handle and removes a redundant
guard on HAVE_INITFINI_ARRAY_SUPPORT for the shared version of the
objects, nested within a section guarded on USE_INITFINI_ARRAY.

2022-09-29  Olivier Hainque  <hainque@adacore.com>

libgcc/
	* config/vxcrtstuff.c: Improve the comment attached to the use
	of auto-host.h and of __dso_handle.  Remove redundant guard on
	HAVE_INITFINI_ARRAY_SUPPORT within a USE_INITFINI_ARRAY section.
2022-09-29 18:02:21 +00:00
Jason Merrill
73d9b0e594 c++: check DECL_INITIAL for constexpr
We were overlooking non-potentially-constant bits in variable initializer
because we didn't walk into DECL_INITIAL.

gcc/cp/ChangeLog:

	* constexpr.cc (potential_constant_expression_1): Look into
	DECL_INITIAL.  Use location wrappers.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/constexpr-local4.C: Expect error sooner.
	* g++.dg/cpp2a/consteval24.C: Likewise.
	* g++.dg/cpp2a/consteval7.C: Likewise.
	* g++.dg/cpp2a/inline-asm3.C: Likewise.
2022-09-29 13:50:54 -04:00
Jason Merrill
bbdb5612f6 c++: fix class-valued ?: extension
When the gimplifier encounters the same TARGET_EXPR twice, it evaluates
TARGET_EXPR_INITIAL the first time and clears it so that the later
evaluation is just the temporary.  With this testcase, using the extension
to treat an omitted middle operand as repeating the first operand, that led
to doing a bitwise copy of the S(1) temporary on return rather than properly
calling the copy constructor.

We can't use S(1) to initialize the return value here anyway, because we
need to materialize it into a temporary so we can convert it to bool and
determine which arm we're evaluating.  So let's just treat the middle
operand as an xvalue.

	PR c++/93046

gcc/cp/ChangeLog:

	* call.cc (build_conditional_expr): For a?:c extension, treat
	a reused class prvalue as an xvalue.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/cond4.C: Add runtime test.
2022-09-29 13:50:03 -04:00
Jason Merrill
32b2eb59fb c++: reduce temporaries in ?:
When the sides of ?: are class prvalues, we wrap the COND_EXPR in a
TARGET_EXPR so that both sides will initialize the same temporary.  But in
this case we were stripping the outer TARGET_EXPR and conditionally creating
different temporaries, unnecessarily using extra stack.  The
recently added TARGET_EXPR_NO_ELIDE flag avoids this.

gcc/cp/ChangeLog:

	* call.cc (build_conditional_expr): Set TARGET_EXPR_NO_ELIDE on the
	outer TARGET_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/cond-temp1.C: New test.
2022-09-29 13:48:20 -04:00
Andrew Stubbs
af9034827e amdgcn: remove unused variable
This was left over from a previous version of the SIMD clone patch.

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_simd_clone_compute_vecsize_and_simdlen):
	Remove unused elt_bits variable.
2022-09-29 17:26:07 +01:00
Olivier Hainque
cc09a9cf4d Comment about HAVE_INITFINI_ARRAY_SUPPORT in vxworks.h
Explain that we rely on compiler .c files
to include auto-host.h before target configuration headers.

2022-09-29  Olivier Hainque  <hainque@adacore.com>

gcc/
	* config/vxworks.h: Add comment on our use of
	HAVE_INITFINI_ARRAY_SUPPORT.
2022-09-29 15:10:57 +00:00
Olivier Hainque
64d6440ee7 Add an mcmodel=large multilib for aarch64-vxworks
This makes good sense in general anyway, and in particular
with forthcoming support for shared shared libraries, which will
work for mrtp alone but not yet for mrtp+mcmodel=large.

2022-09-29  Olivier Hainque  <hainque@adacore.com>

gcc/
	* config/aarch64/t-aarch64-vxworks: Request multilib
	variants for mcmodel=large.
2022-09-29 14:58:58 +00:00
Olivier Hainque
77ce3fbfc8 Remove TARGET_FLOAT128_ENABLE_TYPE setting for VxWorks
We have, in vxworks.h:

 /* linux64.h enables this, not supported in vxWorks.  */
 #undef TARGET_FLOAT128_ENABLE_TYPE
 #define TARGET_FLOAT128_ENABLE_TYPE 0

We inherit linux64.h for a few reasons, but don't really support
float128 for vxworks, so the setting made sense.

Many tests rely on the linux default (1) though, so resetting is
causing lots of failures on compilation tests that would pass otherwise.

Not resetting lets users write code declaring floa128
objects but linking will typically fail at some point, so
there's no real adverse effect.

Bottom line is we don't have any particular incentive to alter
the default, whatever the default, so better leave the parameter
alone.

2022-09-29  Olivier Hainque  <hainque@adacore.com>

gcc/
	* config/rs6000/vxworks.h (TARGET_FLOAT128_ENABLE_TYPE): Remove
	resetting to 0.
2022-09-29 14:58:46 +00:00
Olivier Hainque
2813f529ab Robustify DWARF2_UNWIND_INFO handling in vx-common.h
This adjusts vx-common.h to #define DWARF2_UNWIND_INFO to 0
when ARM_UNWIND_INFO is set, preventing defaults.h from
possibly setting DWARF2_UNWIND_INFO to 1 (as well) on its own
afterwards if the macro isn't defined.

2022-09-29  Olivier Hainque  <hainque@adacore.com>

gcc/
	* config/vx-common.h (DWARF2_UNWIND_INFO): #define to 0
	when ARM_UNWIND_INFO is set.
2022-09-29 14:39:10 +00:00
Julian Brown
8ace67ddb9 OpenACC: whole struct vs. component mappings (PR107028)
This patch fixes an ICE when both a complete struct variable and
components of that struct are mapped on the same directive for OpenACC,
using a modified version of the scheme used for OpenMP in the following
patch:

  https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601558.html

A new function has been added to make sure that the mapping kinds of
the whole struct and the member access are compatible -- conservatively,
so as not to copy more to/from the device than the user expects.

This version of the patch uses a different method to detect duplicate
clauses for OpenACC in oacc_resolve_clause_dependencies, and removes
the now-redundant check in omp_accumulate_sibling_lists.  (The latter
check would no longer trigger when we map the whole struct on the same
directive because the component-mapping clauses are now deleted before
the check is executed.)

2022-09-28  Julian Brown  <julian@codesourcery.com>

gcc/
	PR middle-end/107028
	* gimplify.cc (omp_check_mapping_compatibility,
	oacc_resolve_clause_dependencies): New functions.
	(omp_accumulate_sibling_list): Remove redundant duplicate clause
	detection for OpenACC.
	(build_struct_sibling_lists): Skip deleted groups.  Don't build sibling
	list for struct variables that are fully mapped on the same directive
	for OpenACC.
	(gimplify_scan_omp_clauses): Call oacc_resolve_clause_dependencies.

gcc/testsuite/
	PR middle-end/107028
	* c-c++-common/goacc/struct-component-kind-1.c: New test.
	* g++.dg/goacc/pr107028-1.C: New test.
	* g++.dg/goacc/pr107028-2.C: New test.
	* gfortran.dg/goacc/mapping-tests-5.f90: New test.
2022-09-29 13:53:27 +00:00
Patrick Palka
9ca1471540 c++: implement __remove_cv, __remove_reference and __remove_cvref
This implements builtins for std::remove_cv, std::remove_reference and
std::remove_cvref using TRAIT_TYPE from the previous patch.

gcc/c-family/ChangeLog:

	* c-common.cc (c_common_reswords): Add __remove_cv,
	__remove_reference and __remove_cvref.
	* c-common.h (enum rid): Add RID_REMOVE_CV, RID_REMOVE_REFERENCE
	and RID_REMOVE_CVREF.

gcc/cp/ChangeLog:

	* constraint.cc (diagnose_trait_expr): Handle CPTK_REMOVE_CV,
	CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF.
	* cp-objcp-common.cc (names_builtin_p): Likewise.
	* cp-tree.h (enum cp_trait_kind): Add CPTK_REMOVE_CV,
	CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF.
	* cxx-pretty-print.cc (pp_cxx_trait): Handle CPTK_REMOVE_CV,
	CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF.
	* parser.cc (cp_keyword_starts_decl_specifier_p): Return true
	for RID_REMOVE_CV, RID_REMOVE_REFERENCE and RID_REMOVE_CVREF.
	(cp_parser_trait): Handle RID_REMOVE_CV, RID_REMOVE_REFERENCE
	and RID_REMOVE_CVREF.
	(cp_parser_simple_type_specifier): Likewise.
	* semantics.cc (finish_trait_type): Likewise.

libstdc++-v3/ChangeLog:

	* include/bits/unique_ptr.h (unique_ptr<_Tp[], _Dp>): Remove
	__remove_cv and use __remove_cv_t instead.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/has-builtin-1.C: Test existence of __remove_cv,
	__remove_reference and __remove_cvref.
	* g++.dg/ext/remove_cv.C: New test.
	* g++.dg/ext/remove_reference.C: New test.
	* g++.dg/ext/remove_cvref.C: New test.
2022-09-29 09:18:40 -04:00
Patrick Palka
817e878a31 c++: introduce TRAIT_TYPE alongside TRAIT_EXPR
We already have generic support for predicate-like traits that yield a
boolean value via TRAIT_EXPR, but we lack the same support for traits
that yield a type instead of a value.  Such support would streamline
implementing efficient builtins for the standard library type traits.

To that end this patch implements a generic TRAIT_TYPE type alongside
TRAIT_EXPR, and reimplements the existing UNDERLYING_TYPE builtin trait
using this new TRAIT_TYPE.

gcc/cp/ChangeLog:

	* cp-objcp-common.cc (cp_common_init_ts): Replace
	UNDERLYING_TYPE with TRAIT_TYPE.
	* cp-tree.def (TRAIT_TYPE): Define.
	(UNDERLYING_TYPE): Remove.
	* cp-tree.h (TRAIT_TYPE_KIND_RAW): Define.
	(TRAIT_TYPE_KIND): Define.
	(TRAIT_TYPE_TYPE1): Define.
	(TRAIT_TYPE_TYPE2): Define.
	(WILDCARD_TYPE_P): Return true for TRAIT_TYPE.
	(finish_trait_type): Declare.
	* cxx-pretty-print.cc (cxx_pretty_printer::primary_expression):
	Adjust after renaming pp_cxx_trait_expression.
	(cxx_pretty_printer::simple_type_specifier) <case TRAIT_TYPE>:
	New.
	(cxx_pretty_printer::type_id): Replace UNDERLYING_TYPE with
	TRAIT_TYPE.
	(pp_cxx_trait_expression): Rename to ...
	(pp_cxx_trait): ... this.  Handle TRAIT_TYPE as well.  Correct
	pretty printing of the trailing arguments.
	* cxx-pretty-print.h (pp_cxx_trait_expression): Rename to ...
	(pp_cxx_trait_type): ... this.
	* error.cc (dump_type) <case UNDERLYING_TYPE>: Remove.
	<case TRAIT_TYPE>: New.
	(dump_type_prefix): Replace UNDERLYING_WITH with TRAIT_TYPE.
	(dump_type_suffix): Likewise.
	* mangle.cc (write_type) <case UNDERLYING_TYPE>: Remove.
	<case TRAIT_TYPE>: New.
	* module.cc (trees_out::type_node) <case UNDERLYING_TYPE>:
	Remove.
	<case TRAIT_TYPE>: New.
	(trees_in::tree_node): Likewise.
	* parser.cc (cp_parser_primary_expression): Adjust after
	renaming cp_parser_trait_expr.
	(cp_parser_trait_expr): Rename to ...
	(cp_parser_trait): ... this.  Call finish_trait_type for traits
	that yield a type.
	(cp_parser_simple_type_specifier): Adjust after renaming
	cp_parser_trait_expr.
	* pt.cc (for_each_template_parm_r) <case UNDERLYING_TYPE>:
	Remove.
	<case TRAIT_TYPE>: New.
	(tsubst): Likewise.
	(unify): Replace UNDERLYING_TYPE with TRAIT_TYPE.
	(dependent_type_p_r): Likewise.
	* semantics.cc (finish_underlying_type): Don't return
	UNDERLYING_TYPE anymore when processing_template_decl.
	(finish_trait_type): Define.
	* tree.cc (strip_typedefs) <case UNDERLYING_TYPE>: Remove.
	<case TRAIT_TYPE>: New.
	(cp_walk_subtrees): Likewise.
	* typeck.cc (structural_comptypes): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-59.C: Adjust expected error message.
	* g++.dg/ext/underlying_type7.C: Likewise.
	* g++.dg/ext/underlying_type13.C: New test.
	* g++.dg/ext/underlying_type14.C: New test.
2022-09-29 09:18:11 -04:00
Jonathan Wakely
df7f273650 libstdc++: Guard use of new built-in with __has_builtin
I forgot that non-GCC compilers don't have this built-in yet.

For Clang we could do something like the check below (as described in
P2255), but for now I'm just fixing the regression.

 #if __has_builtin((__reference_binds_to_temporary)
  bool _Dangle = __reference_binds_to_temporary(_Tp, _Res_t)
                 && __and_<is_reference<_Tp>,
                           __not_<is_reference<_Res_t>>,
                           is_convertible<__remove_cvref_t<_Res_t>*,
                                          __remove_cvref_t<_Tp>*>>::value
 #endif

libstdc++-v3/ChangeLog:

	* include/std/type_traits (__is_invocable_impl): Check
	__has_builtin(__reference_converts_from_temporary) before using
	built-in.
2022-09-29 12:47:37 +01:00
Nathan Sidwell
a1f7f9541c c++: import/export NTTP objects
This adds smarts to the module machinery to handle NTTP object
VAR_DECLs.  Like typeinfo objects, these must be ignored in the symbol
table, streamed specially and recreated on stream in.

	gcc/cp/
	PR c++/100616
	* module.cc (enum tree_tag): Add tt_nttp_var.
	(trees_out::decl_node): Handle NTTP objects.
	(trees_in::tree_node): Handle tt_nttp_var.
	(depset:#️⃣:add_binding_entry): Skip NTTP objects.

	gcc/testsuite/
	PR c++/100616
	* g++.dg/modules/100616_a.H: New.
	* g++.dg/modules/100616_b.C: New.
	* g++.dg/modules/100616_c.C: New.
	* g++.dg/modules/100616_d.C: New.
2022-09-29 04:41:59 -07:00
Jose E. Marchesi
a0aafbc324 place `const volatile' objects in read-only sections
It is common for C BPF programs to use variables that are implicitly
set by the BPF loader and run-time.  It is also necessary for these
variables to be stored in read-only storage so the BPF verifier
recognizes them as such.  This leads to declarations using both
`const' and `volatile' qualifiers, like this:

  const volatile unsigned char is_allow_list = 0;

Where `volatile' is used to avoid the compiler to optimize out the
variable, or turn it into a constant, and `const' to make sure it is
placed in .rodata.

Now, it happens that:

- GCC places `const volatile' objects in the .data section, under the
  assumption that `volatile' somehow voids the `const'.

- LLVM places `const volatile' objects in .rodata, under the
  assumption that `volatile' is orthogonal to `const'.

So there is a divergence, that has practical consequences: it makes
BPF programs compiled with GCC to not work properly.

When looking into this, I found this bugzilla:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25521
  "change semantics of const volatile variables"

which was filed back in 2005, long ago.  This report was already
asking to put `const volatile' objects in .rodata, questioning the
current behavior.

While discussing this in the #gcc IRC channel I was pointed out to the
following excerpt from the C18 spec:

   6.7.3 Type qualifiers / 5 The properties associated with qualified
         types are meaningful only for expressions that are
         lval-values [note 135]

   135) The implementation may place a const object that is not
        volatile in a read-only region of storage. Moreover, the
        implementation need not allocate storage for such an object if
        its $ address is never used.

This footnote may be interpreted as if const objects that are volatile
shouldn't be put in read-only storage.  Even if I personally was not
very convinced of that interpretation (see my earlier comment in BZ
25521) I filed the following issue in the LLVM tracker in order to
discuss the matter:

  https://github.com/llvm/llvm-project/issues/56468

As you can see, Aaron Ballman, one of the LLVM hackers, asked the WG14
reflectors about this.  He reported that the reflectors don't think
footnote 135 has any normative value.

So, not having a normative mandate on either direction, there are two
options:

a) To change GCC to place `const volatile' objects in .rodata instead
   of .data.

b) To change LLVM to place `const volatile' objects in .data instead
   of .rodata.

Considering that:

- One target (bpf-unknown-none) breaks with the current GCC behavior.

- No target/platform relies on the GCC behavior, that we know.

- Changing the LLVM behavior at this point would be very severely
  traumatic for the BPF people and their users.

I think the right thing to do at this point is a).
Therefore this patch.

Regtested in x86_64-linux-gnu and bpf-unknown-none.
No regressions observed.

gcc/ChangeLog:

	PR middle-end/25521
	* varasm.cc (categorize_decl_for_section): Place `const volatile'
	objects in read-only sections.
	(default_select_section): Likewise.

gcc/testsuite/ChangeLog:

	PR middle-end/25521
	* lib/target-supports.exp (check_effective_target_elf): Define.
	* gcc.dg/pr25521.c: New test.
2022-09-29 12:39:04 +02:00
Richard Sandiford
2f52c8caa3 data-ref: Fix ranges_maybe_overlap_p test
dr_may_alias_p rightly used poly_int_tree_p to guard a use of
ranges_maybe_overlap_p, but used the non-poly extractors.
This caused a few failures in the SVE ACLE asm tests.

gcc/
	* tree-data-ref.cc (dr_may_alias_p): Use to_poly_widest instead
	of to_widest.
2022-09-29 11:32:57 +01:00
Richard Sandiford
a31641840a aarch64: Remove redundant TARGET_* checks
After previous patches, it's possible to remove TARGET_*
options that are redundant due to (IMO) obvious dependencies.

gcc/
	* config/aarch64/aarch64.h (TARGET_CRYPTO, TARGET_SHA3, TARGET_SM4)
	(TARGET_DOTPROD): Don't depend on TARGET_SIMD.
	(TARGET_AES, TARGET_SHA2): Likewise.  Remove TARGET_CRYPTO test.
	(TARGET_FP_F16INST): Don't depend on TARGET_FLOAT.
	(TARGET_SVE2, TARGET_SVE_F32MM, TARGET_SVE_F64MM): Don't depend
	on TARGET_SVE.
	(TARGET_SVE2_AES, TARGET_SVE2_BITPERM, TARGET_SVE2_SHA3)
	(TARGET_SVE2_SM4): Don't depend on TARGET_SVE2.
	(TARGET_F32MM, TARGET_F64MM): Delete.
	* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Guard
	float macros with just TARGET_FLOAT rather than TARGET_FLOAT
	|| TARGET_SIMD.
	* config/aarch64/aarch64-simd.md (copysign<mode>3): Depend
	only on TARGET_SIMD, rather than TARGET_FLOAT && TARGET_SIMD.
	(aarch64_crypto_aes<aes_op>v16qi): Depend only on TARGET_AES,
	rather than TARGET_SIMD && TARGET_AES.
	(aarch64_crypto_aes<aesmc_op>v16qi): Likewise.
	(*aarch64_crypto_aese_fused): Likewise.
	(*aarch64_crypto_aesd_fused): Likewise.
	(aarch64_crypto_pmulldi): Likewise.
	(aarch64_crypto_pmullv2di): Likewise.
	(aarch64_crypto_sha1hsi): Likewise TARGET_SHA2.
	(aarch64_crypto_sha1hv4si): Likewise.
	(aarch64_be_crypto_sha1hv4si): Likewise.
	(aarch64_crypto_sha1su1v4si): Likewise.
	(aarch64_crypto_sha1<sha1_op>v4si): Likewise.
	(aarch64_crypto_sha1su0v4si): Likewise.
	(aarch64_crypto_sha256h<sha256_op>v4si): Likewise.
	(aarch64_crypto_sha256su0v4si): Likewise.
	(aarch64_crypto_sha256su1v4si): Likewise.
	(aarch64_crypto_sha512h<sha512_op>qv2di): Likewise TARGET_SHA3.
	(aarch64_crypto_sha512su0qv2di): Likewise.
	(aarch64_crypto_sha512su1qv2di, eor3q<mode>4): Likewise.
	(aarch64_rax1qv2di, aarch64_xarqv2di, bcaxq<mode>4): Likewise.
	(aarch64_sm3ss1qv4si): Likewise TARGET_SM4.
	(aarch64_sm3tt<sm3tt_op>qv4si): Likewise.
	(aarch64_sm3partw<sm3part_op>qv4si): Likewise.
	(aarch64_sm4eqv4si, aarch64_sm4ekeyqv4si): Likewise.
	* config/aarch64/aarch64.md (<FLOATUORS:optab>dihf2)
	(copysign<GPF:mode>3, copysign<GPF:mode>3_insn)
	(xorsign<mode>3): Remove redundant TARGET_FLOAT condition.
2022-09-29 11:32:57 +01:00
Richard Sandiford
2a269bda9e aarch64: Tweak handling of -mgeneral-regs-only
-mgeneral-regs-only is effectively "+nofp for the compiler without
changing the assembler's ISA flags".  Currently that's implemented
by making TARGET_FLOAT, TARGET_SIMD and TARGET_SVE depend on
!TARGET_GENERAL_REGS_ONLY and then making any feature that needs FP
registers depend (directly or indirectly) on one of those three TARGET
macros.  The problem is that it's easy to forgot to do the last bit.

This patch instead represents the distinction between "assemnbler
ISA flags" and "compiler ISA flags" more directly, funnelling
all updates through a new function that sets both sets of flags
together.

gcc/
	* config/aarch64/aarch64.opt (aarch64_asm_isa_flags): New variable.
	* config/aarch64/aarch64.h (aarch64_asm_isa_flags)
	(aarch64_isa_flags): Redefine as read-only macros.
	(TARGET_SIMD, TARGET_FLOAT, TARGET_SVE): Don't depend on
	!TARGET_GENERAL_REGS_ONLY.
	* common/config/aarch64/aarch64-common.cc
	(aarch64_set_asm_isa_flags): New function.
	(aarch64_handle_option): Call it when updating -mgeneral-regs.
	* config/aarch64/aarch64-protos.h (aarch64_simd_switcher): Replace
	m_old_isa_flags with m_old_asm_isa_flags.
	(aarch64_set_asm_isa_flags): Declare.
	* config/aarch64/aarch64-builtins.cc
	(aarch64_simd_switcher::aarch64_simd_switcher)
	(aarch64_simd_switcher::~aarch64_simd_switcher): Save and restore
	aarch64_asm_isa_flags instead of aarch64_isa_flags.
	* config/aarch64/aarch64-sve-builtins.cc
	(check_required_extensions): Use aarch64_asm_isa_flags instead
	of aarch64_isa_flags.
	* config/aarch64/aarch64.cc (aarch64_set_asm_isa_flags): New function.
	(aarch64_override_options, aarch64_handle_attr_arch)
	(aarch64_handle_attr_cpu, aarch64_handle_attr_isa_flags): Use
	aarch64_set_asm_isa_flags to set the ISA flags.
	(aarch64_option_print, aarch64_declare_function_name)
	(aarch64_start_file): Use aarch64_asm_isa_flags instead
	of aarch64_isa_flags.
	(aarch64_can_inline_p): Check aarch64_asm_isa_flags as well as
	aarch64_isa_flags.
2022-09-29 11:32:57 +01:00
Richard Sandiford
bb7f43b62a aarch64: Tweak contents of flags_on/off fields
After previous changes, it's more convenient if the flags_on and
flags_off fields of all_extensions include the feature flag itself.

gcc/
	* common/config/aarch64/aarch64-common.cc (all_extensions):
	Include the feature flag in flags_on and flags_off.
	(aarch64_parse_extension): Update accordingly.
	(aarch64_get_extension_string_for_isa_flags): Likewise.
2022-09-29 11:32:56 +01:00
Richard Sandiford
fed55a60e5 aarch64: Make more use of aarch64_feature_flags
A previous patch added a aarch64_feature_flags typedef, to abstract
the representation of the feature flags.  This patch makes existing
code use the typedef too.  Hope I've caught them all!

gcc/
	* common/config/aarch64/aarch64-common.cc: Use aarch64_feature_flags
	for feature flags throughout.
	* config/aarch64/aarch64-protos.h: Likewise.
	* config/aarch64/aarch64-sve-builtins.h: Likewise.
	* config/aarch64/aarch64-sve-builtins.cc: Likewise.
	* config/aarch64/aarch64.cc: Likewise.
	* config/aarch64/aarch64.opt: Likewise.
	* config/aarch64/driver-aarch64.cc: Likewise.
2022-09-29 11:32:56 +01:00
Richard Sandiford
60dee638c8 aarch64: Tweak constness of option-related data
Some of the option structures have all-const member variables.
That doesn't seem necessary: we can just use const on the objects
that are supposed to be read-only.

Also, with the new, more C++-heavy option handling, it seems
better to use constexpr for the static data, to make sure that
we're not adding unexpected overhead.

gcc/
	* common/config/aarch64/aarch64-common.cc (aarch64_option_extension)
	(processor_name_to_arch, arch_to_arch_name): Remove const from
	member variables.
	(all_extensions, all_cores, all_architectures): Make a constexpr.
	* config/aarch64/aarch64.cc (processor): Remove const from
	member variables.
	(all_architectures): Make a constexpr.
	* config/aarch64/driver-aarch64.cc (aarch64_core_data)
	(aarch64_arch_driver_info): Remove const from member variables.
	(aarch64_cpu_data, aarch64_arches): Make a constexpr.
	(get_arch_from_id): Return a pointer to const.
	(host_detect_local_cpu): Update accordingly.
2022-09-29 11:32:55 +01:00
Richard Sandiford
13af9e9fda aarch64: Avoid std::string in static data
Just a minor patch to avoid having to construct std::strings
in static data.

gcc/
	* common/config/aarch64/aarch64-common.cc (processor_name_to_arch)
	(arch_to_arch_name): Use const char * instead of std::string.
2022-09-29 11:32:55 +01:00
Richard Sandiford
4ebf56f283 aarch64: Simplify generation of .arch strings
aarch64-common.cc has two arrays, one maintaining the original
definition order and one sorted by population count.  Sorting
by population count was a way of ensuring topological ordering,
taking advantage of the fact that the entries are partially
ordered by the subset relation.  However, the sorting is not
needed now that the .def file is forced to have topological
order from the outset.

Other changes are:

(1) The population count used:

      uint64_t total_flags_a = opt_a->flag_canonical & opt_a->flags_on;
      uint64_t total_flags_b = opt_b->flag_canonical & opt_b->flags_on;
      int popcnt_a = popcount_hwi ((HOST_WIDE_INT)total_flags_a);
      int popcnt_b = popcount_hwi ((HOST_WIDE_INT)total_flags_b);

    where I think the & was supposed to be |.  This meant that the
    counts would always be 1 in practice, since flag_canonical is
    a single bit.  This led us to printing +nofp+nosimd even though
    GCC "knows" (and GAS agrees) that +nofp disables simd.

(2) The .arch output code converts +aes+sha2 to +crypto.  I think
    the main reason for doing this is to support assemblers that
    predate the individual per-feature crypto flags.  It therefore
    seems more natural to treat it as a special case, rather than
    as an instance of a general pattern.  Hopefully we won't do
    something similar in future!

    (There is already special handling of CRC, for different reasons.)

(3) Previously, if the /proc/cpuinfo code saw a feature like sve,
    it would assume the presence of all the features that sve
    depends on.  It would be possible to keep that behaviour
    if necessary, but it was simpler to assume the presence of
    fp16 (say) only when fphp is present.  There's an argument
    that that's more conservatively correct too.

gcc/
	* common/config/aarch64/aarch64-common.cc
	(TARGET_OPTION_INIT_STRUCT): Delete.
	(aarch64_option_extension): Remove is_synthetic_flag.
	(all_extensions): Update accordingly.
	(all_extensions_by_on, opt_ext, opt_ext_cmp): Delete.
	(aarch64_option_init_struct, aarch64_contains_opt): Delete.
	(aarch64_get_extension_string_for_isa_flags): Rewrite to use
	all_extensions instead of all_extensions_on.

gcc/testsuite/
	* gcc.target/aarch64/cpunative/info_8: Add all dependencies of sve.
	* gcc.target/aarch64/cpunative/info_9: Likewise svesm4.
	* gcc.target/aarch64/cpunative/info_15: Likewise.
	* gcc.target/aarch64/cpunative/info_16: Likewise sve2.
	* gcc.target/aarch64/cpunative/info_17: Likewise.
	* gcc.target/aarch64/cpunative/native_cpu_2.c: Expect just +nofp
	rather than +nofp+nosimd.
	* gcc.target/aarch64/cpunative/native_cpu_10.c: Likewise.
	* gcc.target/aarch64/target_attr_15.c: Likewise.
2022-09-29 11:32:55 +01:00