Commit graph

208497 commits

Author SHA1 Message Date
Owen Avery
b71668068b gccrs: Create base class for TupleStructItems and TuplePatternItems
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-pattern.h
	(class TupleItems): New.
	(class TupleStructItems): Inherit from TupleItems.
	(class TuplePatternItems): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-30 12:36:46 +01:00
Arthur Cohen
8fa748692c gccrs: toplevel: Resolve use declarations
gcc/rust/ChangeLog:

	* resolve/rust-toplevel-name-resolver-2.0.cc
	(TopLevel::insert_or_error_out): New functions.
	(TopLevel::handle_use_dec): New function.
	(flatten_rebind): Likewise.
	(flatten_list): Likewise.
	(flatten_glob): Likewise.
	(flatten): Likewise.
	(TopLevel::visit): Visit various `use` declaration nodes.
	* resolve/rust-toplevel-name-resolver-2.0.h: Declare functions and
	visitors.
2024-01-30 12:36:46 +01:00
Arthur Cohen
17da301e2a gccrs: early: Move use declaration resolving to TopLevel
gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc
	(Early::visit): Remove visitors.
	* resolve/rust-early-name-resolver-2.0.h: Likewise.
2024-01-30 12:36:46 +01:00
Arthur Cohen
1133c1c671 gccrs: ast: Add NodeId to UseTree base class
gcc/rust/ChangeLog:

	* ast/rust-item.h (class UseTree): Add `node_id` member.
2024-01-30 12:36:46 +01:00
Arthur Cohen
0a5cc7a4cb gccrs: toplevel: Add comment about running the collector twice
gcc/rust/ChangeLog:

	* resolve/rust-toplevel-name-resolver-2.0.cc
	(TopLevel::insert_or_error_out): Add documentation comment.
	(TopLevel::go): Likewise.
2024-01-30 12:36:46 +01:00
Arthur Cohen
53d979f361 gccrs: early: Resolve paths properly
gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc
	(Early::insert_once): New function.
	(Early::visit): Likewise.
	* resolve/rust-early-name-resolver-2.0.h: Likewise.
2024-01-30 12:36:46 +01:00
Arthur Cohen
0f0ec052b4 gccrs: late: Start storing mappings properly in the resolver
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Store mappings
	after having resolved them.
	* resolve/rust-late-name-resolver-2.0.h: Add `TypePath` visitor.
2024-01-30 12:36:46 +01:00
Arthur Cohen
df6eadda5e gccrs: late: Start setting up builtin types
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc
	(Late::setup_builtin_types): New function.
	(Late::go): Setup builtin types.
	* resolve/rust-late-name-resolver-2.0.h:
	* resolve/rust-name-resolution-context.cc
	(NameResolutionContext::map_usage): New function.
	* resolve/rust-name-resolution-context.h: Likewise.
2024-01-30 12:36:45 +01:00
Arthur Cohen
cb3a12f3ee gccrs: nr2.0: Store mappings in NameResolutionContext
gcc/rust/ChangeLog:

	* resolve/rust-name-resolution-context.h: Store a reference to the
	mappings.
	* resolve/rust-name-resolution-context.cc
	(NameResolutionContext::NameResolutionContext): Likewise.
2024-01-30 12:36:45 +01:00
Arthur Cohen
1ee01fd157 gccrs: toplevel: Use DefaultResolver for Function
gcc/rust/ChangeLog:

	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Use
	the DefaultResolver in the toplevel visitor.
2024-01-30 12:36:45 +01:00
Arthur Cohen
f726875f97 gccrs: nr2.0: Add base for late name resolution
gcc/rust/ChangeLog:

	* Make-lang.in: Compile late name resolver.
	* resolve/rust-late-name-resolver-2.0.cc: New file.
	* resolve/rust-late-name-resolver-2.0.h: New file.
2024-01-30 12:36:45 +01:00
Arthur Cohen
d9b7a3d0f4 gccrs: ctx: Add Labels ForeverStack to the resolver.
Not sure if dealing with "labels" is the proper way of doing so, so we
might eventually change this to use `resolver.values` later on.

gcc/rust/ChangeLog:

	* resolve/rust-name-resolution-context.h: Add a Labels stack.
2024-01-30 12:36:45 +01:00
M V V S Manoj Kumar
d5c582396c gccrs: Added support to Parse ASYNC function
Fixes issue #2650
The parser now parses ASYNC functions. Added ASYNC case to parse_item
Added a new function parse_async_item which is called in
parse_vis_item to handle the ASYNC case. Parse_async_item
also checks the current Rust edition and generates an error if the
edition is 2015

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_item): Likewise.
	(Parser::parse_vis_item): Likewise.
	(Parser::parse_async_item): Likewise.
	* parse/rust-parse.h: Made declaration for parse_async_item.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2650-1.rs: New test.(edition=2018)
	* rust/compile/issue-2650-2.rs: New test.(edition=2015)

Signed-off-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
2024-01-30 12:36:45 +01:00
Pierre-Emmanuel Patry
2c843a047d gccrs: Introduce a proper keyword list
The old "keyword" list was used for the lexer, and could therefore not
be used with keyword spanning over multiple tokens as those tokens should
remain lexed as is. Hence the introduction of a new list macro for
keyword exclusive tasks. This also means we can no longer match a token
id for each keyword. The token id map has been renamed to keep it's
properties.

gcc/rust/ChangeLog:

	* lex/rust-lex.cc (Lexer::classify_keyword): Update keyword map name.
	* lex/rust-token.h (enum PrimitiveCoreType): Remove some deprecated
	comments.
	* util/rust-keyword-values.cc (get_keywords): Update the keyword map
	name.
	(RS_TOKEN): Define as empty
	(RS_TOKEN_KEYWORD_2015): Add the emission value.
	(RS_TOKEN_KEYWORD_2018): Likewise.
	* util/rust-keyword-values.h (RS_KEYWORD_LIST): Introduce the keyword
	list.
	(RS_TOKEN_KEYWORD_2018): Define multiple new keywords.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:45 +01:00
Pierre-Emmanuel Patry
28652f21e5 gccrs: Replace some weak keyword raw value with constexpr
Raw values may have typos or contain error, replacing those will
improve the codebase.

gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Replace raw value.
	* parse/rust-parse-impl.h (Parser::is_macro_rules_def): Likewise.
	(Parser::parse_item): Likewise.
	(Parser::parse_vis_item): Likewise.
	(Parser::parse_macro_rules_def): Likewise.
	(Parser::parse_union): Likewise.
	(Parser::parse_trait_impl_item): Likewise.
	(Parser::parse_stmt): Likewise.
	(Parser::parse_stmt_or_expr): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:45 +01:00
Pierre-Emmanuel Patry
2fe5baf3dc gccrs: Add a list of weak keyword
Retrieving a weak keyword value is done using raw values. Introducing a
list of weak keywords means this could change.

gcc/rust/ChangeLog:

	* util/rust-keyword-values.h (class WeakKeywords): Add new class with
	weak keyword constexpr.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:45 +01:00
Pierre-Emmanuel Patry
f1c7ce7e18 gccrs: Replace some keyword raw values
Raw values cannot be understood easily by most tools. This commit replace
some raw values with their variable counterpart.

gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Replace raw value
	with keyword call.
	* ast/rust-ast.h: Likewise.
	* parse/rust-parse-impl.h (Parser::parse_path_ident_segment): Likewise.
	(Parser::parse_macro_match_fragment): Likewise.
	(Parser::parse_extern_crate): Likewise.
	(Parser::parse_use_tree): Likewise.
	(Parser::parse_const_item): Likewise.
	(Parser::parse_literal_expr): Likewise.
	(Parser::parse_maybe_named_param): Likewise.
	(Parser::parse_pattern_no_alt): Likewise.
	(Parser::left_denotation): Likewise.
	(Parser::parse_path_in_expression_pratt): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
ad2ff326cc gccrs: Add await keyword
The 2018 edition await keyword was missing from the keyword list.

gcc/rust/ChangeLog:

	* lex/rust-token.h (enum PrimitiveCoreType): Add await keyword
	definition.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
3b853501e7 gccrs: Treat underscore as a keyword
Make the underscore token a 2015 keyword.

gcc/rust/ChangeLog:

	* lex/rust-token.h (enum PrimitiveCoreType): Change macro for
	underscore in token list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
c23db3e0c2 gccrs: Add edition separation for keywords
It might be required in the future to get only the keywords from a
specific edition. To do so we need a mean to differentiate keywords based
on their edition. This commit changes the existing keyword macro to
allow such behavior.

gcc/rust/ChangeLog:

	* lex/rust-token.h (enum PrimitiveCoreType): Change enum macro calls.
	(RS_TOKEN_KEYWORD): Remove generic token keyword macro.
	(RS_TOKEN_KEYWORD_2015): Introduce keywords for edition 2015.
	(RS_TOKEN_KEYWORD_2018): Likewise with edition 2018.
	* lex/rust-token.cc (RS_TOKEN_KEYWORD): Remove old macro definition.
	(RS_TOKEN_KEYWORD_2015): Replace with 2015 definition...
	(RS_TOKEN_KEYWORD_2018): ... and 2018 definition.
	* util/rust-keyword-values.cc (RS_TOKEN_KEYWORD):  Likewise.
	(RS_TOKEN_KEYWORD_2015): Likewise.
	(RS_TOKEN_KEYWORD_2018): Likewise.
	* util/rust-keyword-values.h (RS_TOKEN_KEYWORD): Likewise.
	(RS_TOKEN_KEYWORD_2015): Likewise.
	(RS_TOKEN_KEYWORD_2018): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
7f6319671e gccrs: Replace TOK suffix with KW
TOK suffix was chosen to disambiguate some identifiers with c++ reserved
keyword. Even though this list lies within the rust-token header, this
macro is used in many context sometimes unrelated with the lexer and
tokens. This TOK suffix may appear surprising in such context.

gcc/rust/ChangeLog:

	* lex/rust-token.h (enum PrimitiveCoreType): Change keyword suffix from
	tok to kw.
	* ast/rust-ast-collector.cc (TokenCollector::visit): Update suffix to
	match the new declaration.
	* lex/rust-lex.cc (Lexer::parse_raw_identifier): Likewise.
	* parse/rust-parse-impl.h (can_tok_start_type): Likewise.
	(Parser::parse_item): Likewise.
	(Parser::parse_vis_item): Likewise.
	(Parser::parse_extern_crate): Likewise.
	(Parser::parse_function): Likewise.
	(Parser::parse_function_qualifiers): Likewise.
	(Parser::parse_struct): Likewise.
	(Parser::parse_enum): Likewise.
	(Parser::parse_static_item): Likewise.
	(Parser::parse_trait_item): Likewise.
	(Parser::parse_inherent_impl_item): Likewise.
	(Parser::parse_trait_impl_item): Likewise.
	(Parser::parse_extern_block): Likewise.
	(Parser::parse_external_item): Likewise.
	(Parser::parse_stmt): Likewise.
	(Parser::parse_return_expr): Likewise.
	(Parser::parse_match_expr): Likewise.
	(Parser::parse_type): Likewise.
	(Parser::parse_for_prefixed_type): Likewise.
	(Parser::parse_type_no_bounds): Likewise.
	(Parser::parse_stmt_or_expr): Likewise.
	* parse/rust-parse.cc (peculiar_fragment_match_compatible): Likewie.
	* util/rust-token-converter.cc (convert): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
72792563e6 gccrs: Add ast validation check on union variant number
Unions with zero fields are forbidden. Add regression test for empty
unions.

gcc/rust/ChangeLog:

	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
	zero field check during ast validation pass.
	* checks/errors/rust-ast-validation.h: Add union visit function
	prototype.

gcc/testsuite/ChangeLog:

	* rust/compile/const_generics_8.rs: Fill the union with dummy values.
	* rust/compile/empty_union.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
4f45c715b8 gccrs: Add a test regular variadic functions errors
Add a new regression test for the error message in regular function
variadic errors during ast validation pass.

gcc/testsuite/ChangeLog:

	* rust/compile/non_foreign_variadic_function.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
162137fd26 gccrs: Emit an error on variadic non extern functions
Variadic regular functions were recently added in the parser as they
should be rejected in the ast validation pass. This commit add the ast
validation pass rejecting this kind of variadic arguments.

gcc/rust/ChangeLog:

	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
	ast validation pass to reject variadic arguments on regular functions.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
685491f232 gccrs: Add check for associated items on auto traits
Reject rust code with associated items on auto traits.

gcc/rust/ChangeLog:

	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add auto
	trait associated item check in AST validation pass.
	* parse/rust-parse-impl.h: Remove old error emission done during
	parsing pass.

gcc/testsuite/ChangeLog:

	* rust/compile/auto_trait_invalid.rs: Update old test with updated
	error message.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
84e06bb631 gccrs: Add a regression test for super trait on auto trait
Add a new regression test to highlight the error behavior with a super
trait on an auto trait.

gcc/testsuite/ChangeLog:

	* rust/compile/auto_trait_super_trait.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:44 +01:00
Pierre-Emmanuel Patry
d8c1a756c4 gccrs: Reject auto traits with super trait
Reject auto traits containing a super trait bound during AST validation
pass.

gcc/rust/ChangeLog:

	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Reject
	auto traits with super traits.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:43 +01:00
Pierre-Emmanuel Patry
3e0e74f3e9 gccrs: Add regression test for generic auto traits
Generics are forbidden on auto traits and an error should be emitted.
This commit highlight this behavior.

gcc/testsuite/ChangeLog:

	* rust/compile/generic_auto_trait.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:43 +01:00
Pierre-Emmanuel Patry
b1b744fc46 gccrs: Reject auto traits with generic parameters
Generic parameters are not allowed on auto traits, the compiler should
emit an error.

gcc/rust/ChangeLog:

	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
	check for generics on auto traits.
	* checks/errors/rust-ast-validation.h: Add visit function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:43 +01:00
Arthur Cohen
478ac287e7 gccrs: forever stack: Remove development debug info
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.hxx: Remove debug log.
2024-01-30 12:36:43 +01:00
Arthur Cohen
cbd0a9ce03 gccrs: resolve: Format if properly
gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Format.
2024-01-30 12:36:43 +01:00
Arthur Cohen
232f94af30 gccrs: foreverstack: Add to_rib method
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.h: New method.
	* resolve/rust-forever-stack.hxx: Likewise.
2024-01-30 12:36:43 +01:00
Arthur Cohen
12b2dcb088 gccrs: foreverstack: Add to_canonical_path method
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.h: New method.
	* resolve/rust-forever-stack.hxx: Likewise.
2024-01-30 12:36:43 +01:00
Arthur Cohen
66e8a1614e gccrs: forever stack: Improve resolve_path implementation
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.hxx: Do not copy segment when
	dereferencing iterator in `find_starting_point`.
2024-01-30 12:36:43 +01:00
Arthur Cohen
5fd3de1150 gccrs: forever stack: Fix resolve_path signature
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.h: Fix `ForeverStack::resolve_path`
	signature.
	* resolve/rust-forever-stack.hxx: Likewise.
	* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Use new API.
	(Early::visit_attributes): Likewise.
2024-01-30 12:36:43 +01:00
Arthur Cohen
eec00ae275 gccrs: foreverstack: Specialize get for Namespace::Labels
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.hxx: Add specific behavior for
	`ForeverStack::get` when dealing with labels.
2024-01-30 12:36:42 +01:00
Arthur Cohen
446ab9b265 gccrs: forever-stack: Fix basic get logic
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.h: Improve resolve_path API.
	* resolve/rust-forever-stack.hxx: Likewise and fix implementation.
2024-01-30 12:36:42 +01:00
Arthur Cohen
f7d8356a6e gccrs: rib: Add Namespace enum
gcc/rust/ChangeLog:

	* resolve/rust-rib.h: Add Namespace enum.
2024-01-30 12:36:42 +01:00
Arthur Cohen
c5925f3492 gccrs: ast: Change *Path nodes API
gcc/rust/ChangeLog:

	* ast/rust-ast.h: Change Path API to be more consistent.
	* ast/rust-path.h: Likewise.
	* ast/rust-ast-collector.cc (TokenCollector::visit): Use new API.
	* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Likewise.
	* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise.
	* resolve/rust-forever-stack.hxx: Likewise.
2024-01-30 12:36:42 +01:00
Pierre-Emmanuel Patry
08999fb035 gccrs: Add new test for parsing errors on self pointers
Add new tests to highlight the behavior of errors thrown when meeting a
self pointer.

gcc/testsuite/ChangeLog:

	* rust/compile/self_const_ptr.rs: New test.
	* rust/compile/self_mut_ptr.rs: New test.
	* rust/compile/self_ptr.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:42 +01:00
Pierre-Emmanuel Patry
3e450ae1bb gccrs: Report self parameter parsing error kind
Self parameter parsing errors may come from different situations, which
should not be handled in the same way. It is now possible to
differentiate a missing self parameter from a self pointer or a parsing
error.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_function): Early return on
	unrecoverable errors.
	(Parser::parse_trait_item): Likewise.
	(Parser::parse_self_param): Update return type.
	* parse/rust-parse.h (enum ParseSelfError): Add enumeration to describe
	different self parameter parsing errors.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:42 +01:00
Pierre-Emmanuel Patry
ca16a3ee23 gccrs: Fix error emission for self pointers
Self pointer checking loop condition was inverted, the latter was
therefore never executed.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_self_param): Fix the loop
	exit condition.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:42 +01:00
Pierre-Emmanuel Patry
bf47346052 gccrs: Add a test to highlight public trait type parsing
This new test highlight the parser's behavior around public trait types.

gcc/testsuite/ChangeLog:

	* rust/compile/trait_pub_type.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:42 +01:00
Pierre-Emmanuel Patry
ceed844b52 gccrs: Add visibility to trait item
The compiler shall parse visibility modifiers on trait items and reject
those at a later stage (ast validation).

gcc/rust/ChangeLog:

	* ast/rust-item.h (struct Visibility): Move Visibility from here...
	* ast/rust-ast.h (struct Visibility): ...to here.
	* parse/rust-parse-impl.h (Parser::parse_trait_item): Parse visibility
	before giving it back to the item parsing function.
	(Parser::parse_trait_type): Add visibility modifier.
	* parse/rust-parse.h (RUST_PARSE_H): Change function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30 12:36:42 +01:00
Richard Biener
4c2169d2f4 tree-optimization/113659 - early exit vectorization and missing VUSE
The following handles the case of the main exit going to a path without
virtual use and handles it similar to the alternate exit handling.

	PR tree-optimization/113659
	* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
	Handle main exit without virtual use.

	* gcc.dg/pr113659.c: New testcase.
2024-01-30 11:53:37 +01:00
Christoph Müllner
87ed338808 riscv: Move UNSPEC_XTHEAD* from unspecv to unspec
The UNSPEC_XTHEAD* macros ended up in the unspecv enum,
which broke gcc/testsuite/gcc.target/riscv/xtheadfmv-fmv.c.
The INSNs expect these unspecs to be not volatile.
Further, there is not reason to have them defined volatile.
So let's simply move the macros into the unspec enum.

With this patch we have again 0 fails in riscv.exp.

gcc/ChangeLog:

	* config/riscv/riscv.md: Move UNSPEC_XTHEADFMV* to unspec enum.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-01-30 10:55:12 +01:00
Iain Sandoe
d1d144d80f testsuite, GDC: Update link flags [PR112861].
The regressions here are because we do not generate a runpath for
the uninstalled libstdc++.  This patch updates the link flags handling
to simplify it.

We need to add options to locate both libgphobos and libstdc++
Usually '-L' options are added to point to the relevant directories for
the uninstalled libraries.

In cases where libraries are available as both shared and convenience
some additional checks are made.

For some targets -static-xxxx options are handled by specs substitution
and need a '-B' option rather than '-L'.  For Darwin, when embedded
runpaths are in use (the default for all versions after macOS 10.11),
'-B' is also needed to provide the runpath.

When '-B' is used, this results in a '-L' for each path that exists (so
that appending a '-L' as well is a needless duplicate).  There are also
cases where tools warn for duplicates, leading to spurious fails.
Therefore the objective is to add a single -B/-L option for each needed
path.

	PR target/112861

gcc/testsuite/ChangeLog:

	* lib/gdc.exp: Decide on whether to present -B or -L to reference
	the paths to uninstalled libphobos and libstdc++ and use that to
	generate the link flags.
2024-01-30 09:33:38 +00:00
Iain Sandoe
506e74f53a libgcc: Make heap trampoline support dynamic [PR113403].
In order to handle system security constraints during GCC build
and test and that most platform versions cannot link to libgcc_eh
since the unwinder there is incompatible with the system one.

1. We make the support functions weak definitions.
2. We include them as a CRT for platform conditions that do not
   allow libgcc_eh.
3. We ensure that the weak symbols are exported from DSOs (which
   includes exes on Darwin) so that the dynamic linker will
   pick one instance (which avoids duplication of trampoline
   caches).

	PR libgcc/113403

gcc/ChangeLog:

	* config/darwin.h (DARWIN_SHARED_WEAK_ADDS, DARWIN_WEAK_CRTS): New.
	(REAL_LIBGCC_SPEC): Move weak CRT handling to separate spec.
	* config/i386/darwin.h (DARWIN_HEAP_T_LIB): New.
	* config/i386/darwin32-biarch.h (DARWIN_HEAP_T_LIB): New.
	* config/i386/darwin64-biarch.h (DARWIN_HEAP_T_LIB): New.
	* config/rs6000/darwin.h (DARWIN_HEAP_T_LIB): New.

libgcc/ChangeLog:

	* config.host: Build libheap_t.a for i686/x86_64 Darwin.
	* config/aarch64/heap-trampoline.c (HEAP_T_ATTR): New.
	(allocate_tramp_ctrl): Allow a target to build this as a weak def.
	(__gcc_nested_func_ptr_created): Likewise.
	* config/i386/heap-trampoline.c (HEAP_T_ATTR): New.
	(allocate_tramp_ctrl): Allow a target to build this as a weak def.
	(__gcc_nested_func_ptr_created): Likewise.
	* config/t-darwin: Build libheap_t.a (a CRT with heap trampoline
	support).
2024-01-30 09:33:09 +00:00
Iain Sandoe
7b3b3788c5 libgcc: Make heap trampoline support dynamic [PR113403].
This removes the heap trampoline support functions from libgcc.a and
adds them to libgcc_eh.a.  They are also present in libgcc_s.

	PR libgcc/113403

libgcc/ChangeLog:

	* config/aarch64/t-heap-trampoline: Move the heap trampoline
	support functions from libgcc.a to libgcc_eh.a.
	* config/i386/t-heap-trampoline: Likewise.
2024-01-30 09:32:48 +00:00
Richard Sandiford
fa2739ac1b aarch64: Avoid allocating FPRs to address registers [PR113623]
For something like:

void
foo (void)
{
  int *ptr;
  asm volatile ("%0" : "=w" (ptr));
  asm volatile ("%0" :: "m" (*ptr));
}

early-ra would allocate ptr to an FPR for the first asm, thus
leaving an FPR address in the second asm.  The address was then
reloaded by LRA to make it valid.

But early-ra shouldn't be allocating at all in that kind of
situation.  Doing so caused the ICE in the PR (with LDP fusion).

Fixed by making sure that we record address references as
GPR references.

gcc/
	PR target/113623
	* config/aarch64/aarch64-early-ra.cc (early_ra::preprocess_insns):
	Mark all registers that occur in addresses as needing a GPR.

gcc/testsuite/
	PR target/113623
	* gcc.c-torture/compile/pr113623.c: New test.
2024-01-30 09:30:35 +00:00