]> gcc.gnu.org Git - gcc.git/log
gcc.git
9 months agogccrs: Add AltPattern HIR node
Owen Avery [Mon, 20 Feb 2023 19:46:03 +0000 (14:46 -0500)]
gccrs: Add AltPattern HIR node

Example:
match x {
    0 | 1 => true,
    _ => false
}

gcc/rust/ChangeLog:

* backend/rust-compile-fnparam.h:
(CompileFnParam::visit): Add AltPattern visitor.
* backend/rust-compile-pattern.h:
(CompilePatternCaseLabelExpr::visit): Add AltPattern visitor.
(CompilePatternBindings::visit): Add AltPattern visitor.
(CompilePatternLet::visit): Add AltPattern visitor.
* backend/rust-compile-resolve-path.h:
(ResolvePathRef::visit): Add AltPattern visitor.
* backend/rust-compile-var-decl.h:
(CompileVarDecl::visit): Add AltPattern visitor.
* checks/errors/rust-const-checker.cc
(ConstChecker::visit): Add AltPattern visitor.
* checks/errors/rust-const-checker.h:
(ConstChecker::visit): Add AltPattern visitor.
* checks/errors/rust-unsafe-checker.cc
(UnsafeChecker::visit): Add AltPattern visitor.
* checks/errors/rust-unsafe-checker.h:
(UnsafeChecker::visit): Add AltPattern visitor.
* hir/rust-hir-dump.cc
(Dump::visit): Add AltPattern visitor.
* hir/rust-hir-dump.h:
(Dump::visit): Add AltPattern visitor.
* hir/tree/rust-hir-full-decls.h
(class AltPattern): Add forward declaration.
* hir/tree/rust-hir-pattern.h
(class AltPattern): New class.
* hir/tree/rust-hir-visitor.h:
(HIRFullVisitor::visit): Add AltPattern visitor.
(HIRFullVisitorBase::visit): Add AltPattern visitor.
(HIRPatternVisitor::visit): Add AltPattern visitor.
* hir/tree/rust-hir.h:
(Pattern::PatternType::ALT): New enumerator.
* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): Add AltPattern visitor.
* typecheck/rust-hir-type-check-pattern.h:
(TypeCheckPattern::visit): Add AltPattern visitor.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
9 months agogccrs: expand: Add stringify macro
Pierre-Emmanuel Patry [Mon, 6 Mar 2023 08:58:02 +0000 (09:58 +0100)]
gccrs: expand: Add stringify macro

Add the stringify macro expansion as well as some tests.

gcc/rust/ChangeLog:

* ast/rust-macro.cc (builtin_macro_from_string): Add identifier
identification.
* ast/rust-macro.h (enum class): Add Stringify builtin macro
type.
* expand/rust-macro-builtins.cc (make_macro_path_str): Add path
for builtin stringify macro.
(MacroBuiltin::stringify_handler): Add handler for builtin
stringify macro.
* expand/rust-macro-builtins.h: Add stringify handler's
prototype.
* util/rust-hir-map.cc (Mappings::insert_macro_def): Add
stringify handler to builtin hir map.

gcc/testsuite/ChangeLog:

* rust/compile/stringify.rs: Add a basic test with some text.
* rust/execute/torture/builtin_macro_stringify.rs: Verify the
text is left as is without any other macro expansion.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: Add length checking for tuple patterns
Nikos Alexandris [Fri, 3 Mar 2023 21:55:59 +0000 (23:55 +0200)]
gccrs: Add length checking for tuple patterns

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
Add length checking for tuple patterns.
(TypeCheckPattern::emit_pattern_size_error): New function.
* typecheck/rust-hir-type-check-pattern.h: New function
emit_pattern_size_error.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nikos Alexandris <nikos-alexandris@protonmail.com>
9 months agogccrs: parser: Fix handling of multiple left angles in null denotation
goar5670 [Sat, 4 Mar 2023 19:13:18 +0000 (22:13 +0300)]
gccrs: parser: Fix handling of multiple left angles in null denotation

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_expr):
split LEFT_SHIFT before null_denotation.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
9 months agogccrs: Cleanup and Assertion
Parthib [Mon, 6 Mar 2023 02:04:43 +0000 (07:34 +0530)]
gccrs: Cleanup and Assertion

gcc/rust/ChangLog:

* rust-object-export.cc: Modified
* hir/rust-ast-lower-type.cc (rust_fatal_error): Removed
(rust_assert): Added

Signed-off-by: Parthib <parthibdutta02@gmail.com>
9 months agogccrs: Resolve closure parameters without given type
Owen Avery [Sat, 4 Mar 2023 01:05:59 +0000 (20:05 -0500)]
gccrs: Resolve closure parameters without given type

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit):
Check for closure parameter without given type.

gcc/testsuite/ChangeLog:

* rust/compile/closure_no_type_anno.rs: Extend test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
9 months agogccrs: make predicate bounds overwrite-able
Philip Herron [Fri, 3 Mar 2023 18:17:50 +0000 (18:17 +0000)]
gccrs: make predicate bounds overwrite-able

When compiling types especially when using queries it needs to be
permissive and allow them to be overwritten and a predicate might have one
set of details in one senario and a new one with the same id later on but
with different types.

Fixes #1524

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_resolved_predicate): remove

gcc/testsuite/ChangeLog:

* rust/compile/issue-1524.rs: New test.

9 months agogccrs: Fix name-resolution to be permissive and carry on
Philip Herron [Fri, 3 Mar 2023 18:01:01 +0000 (18:01 +0000)]
gccrs: Fix name-resolution to be permissive and carry on

There are a few edge cases when resolving TypePaths that we cannot fully
resolve to an explicit node_id and this is expected. So for example

  <A as B>::foo

A and B are simple Type paths and thats 100% but the segment foo cannot be
100% resolved to an explicit node id as this requires type-resolution to
find the correct path. So when we have complex paths such as:

  <<A as B>::foo as C>

The ::foo part will return UNKNOWN_NODEId and we return early and think its
a failure case but its not necessarily a failure but we need to make sure
to name resolve C so when we do type-resolution we can resolve C properly.

Addresses #1524

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-type.cc (ResolveRelativeQualTypePath::resolve_qual_seg): fix

gcc/testsuite/ChangeLog:

* rust/compile/parse_associated_type_as_generic_arg3.rs: remove -fsyntax-only

9 months agogccrs: Add missing node_id copys in the copy constructors
Philip Herron [Fri, 3 Mar 2023 17:59:00 +0000 (17:59 +0000)]
gccrs: Add missing node_id copys in the copy constructors

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* ast/rust-path.h: add missing copy for node_id

9 months agogccrs: cleanup headers
Philip Herron [Fri, 3 Mar 2023 16:44:43 +0000 (16:44 +0000)]
gccrs: cleanup headers

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* rust-gcc.h: remove unused headers

9 months agogccrs: Fix missing move and copy constructors missing the associated-path
Philip Herron [Wed, 1 Mar 2023 22:09:47 +0000 (22:09 +0000)]
gccrs: Fix missing move and copy constructors missing the associated-path

Addresses #1524

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* ast/rust-ast.cc (QualifiedPathInType::as_string): add missing to string
* ast/rust-path.h: add missing copy+move constructors and assignment overloads
* hir/tree/rust-hir-path.h: likewise
* hir/tree/rust-hir.cc (QualifiedPathInType::as_string): add missing to string

gcc/testsuite/ChangeLog:

* rust/compile/parse_associated_type_as_generic_arg.rs: it now works without -fsyntax-only
* rust/compile/parse_associated_type_as_generic_arg2.rs: likewise

9 months agogccrs: destructure parameter names.
Philip Herron [Fri, 3 Mar 2023 16:12:46 +0000 (16:12 +0000)]
gccrs: destructure parameter names.

When we have complex generic code you can end up with situations where we
compile types:

  Maybe<<S as Foo>::A>

Into

  Maybe<<placeholder:<Projection=::()>>>

This calls destructure to cleanup the naming here and avoid making non
canonical TREE_TYPES hitting the verify_gimple code triggering non-trival
constructors.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (ParamType::get_name): call destructure

9 months agogccrs: Take advantage of our new unify_and to inject inference
Philip Herron [Fri, 3 Mar 2023 18:42:21 +0000 (18:42 +0000)]
gccrs: Take advantage of our new unify_and to inject inference

Wen computing higher ranked trait bounds where there are multiple type
params and ones which are not bound entirely on the impl-type we need
to inject inference variables as required to compute the types. The
inference variables we inject are missing the callbacks that we can compute
the bounds properly so this is the first part of the fix.

Addresses #1893

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc: use unify_and infer

9 months agogccrs: parser: Fix parsing closure parameter
goar5670 [Thu, 2 Mar 2023 18:34:44 +0000 (21:34 +0300)]
gccrs: parser: Fix parsing closure parameter

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_closure_param):
Replace parse_pattern with parse_pattern_no_alt.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
9 months agogccrs: parser: Fix while let expr parsing
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 16:45:51 +0000 (17:45 +0100)]
gccrs: parser: Fix while let expr parsing

While let expr return unit but are valid construct in rust, they should
therefore be included in the parsing code. Also add a new test to check
parsing of while let expressions.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_while_let_loop_expr):
Prevent hard error on token skip.
(Parser::null_denotation): Fix parser for while let expressions.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: add uninit intrinsic
Philip Herron [Wed, 1 Mar 2023 12:43:56 +0000 (12:43 +0000)]
gccrs: add uninit intrinsic

Following an investigation from rustc and discussions on zulip the
recommendation was that for uninit we memset to 0x01 which is less likely
to be a null ptr but still an invalid reference.

Fixes #1899

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* backend/rust-builtins.cc (BuiltinsContext::setup): add memset builtin to the map
* backend/rust-compile-intrinsic.cc (uninit_handler): implement uninit intrinsic

gcc/testsuite/ChangeLog:

* rust/compile/torture/uninit-intrinsic-1.rs: New test.

9 months agogccrs: parser: Add 0 sized slice pattern parsing
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 17:46:33 +0000 (18:46 +0100)]
gccrs: parser: Add 0 sized slice pattern parsing

Check for a closing square bracket before attempting to parse any
pattern within a slice. Also add a new test to verify zero sized
slice parsing.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_slice_pattern): Add
closing square bracket check.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: fixup: parser: Fix bootstrap compile error
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 09:04:04 +0000 (10:04 +0100)]
gccrs: fixup: parser: Fix bootstrap compile error

The recent changes in the parser bringing the parsing of extern type
items also brought a compilation error when boostrapping the compiler.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_external_type_item):
Fix compilation error due to unnecessary move.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: added support for printing HIR dump of functions, statements, arithematic...
Abdul Rafey [Mon, 27 Feb 2023 12:01:31 +0000 (17:31 +0530)]
gccrs: added support for printing HIR dump of functions, statements, arithematic/logical expressions and literals.

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::go): support inner attrs, crate items and node mappings
(Dump::visit): support functions, arith/logical exprs, let stmts and literals

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
9 months agogccrs: Add location info when opening a file fails in include_str and include_bytes...
Nikos Alexandris [Thu, 2 Mar 2023 01:14:46 +0000 (03:14 +0200)]
gccrs: Add location info when opening a file fails in include_str and include_bytes. Resolves issue #1872

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (load_file_bytes): Add location parameter.
(MacroBuiltin::include_bytes_handler): Pass location to load_file_bytes.
(MacroBuiltin::include_str_handler): Pass location to load_file_bytes.

gcc/testsuite/ChangeLog:

* rust/compile/builtin_macro_include_bytes_location_info.rs: New test.
* rust/compile/builtin_macro_include_str_location_info.rs: New test.

Signed-off-by: Nikos Alexandris <nikos-alexandris@protonmail.com>
9 months agogccrs: testsuite: Add a test for .. in slice patterns
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 10:36:42 +0000 (11:36 +0100)]
gccrs: testsuite: Add a test for .. in slice patterns

Add a test to check wether the syntax of a RestPattern in a SlicePattern
parse correctly.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: parser: Add RestPattern parsing
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 10:00:29 +0000 (11:00 +0100)]
gccrs: parser: Add RestPattern parsing

Add simple RestPattern parsing to the pattern parsing function.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_pattern_no_alt): Handle
RestPattern correctly.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: ast: Add NodeId and clone to RestPattern
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 09:54:29 +0000 (10:54 +0100)]
gccrs: ast: Add NodeId and clone to RestPattern

The RestPattern AST node did not have any NodeId to identify it and
could therefore not be instanciated.

gcc/rust/ChangeLog:

* ast/rust-pattern.h (class RestPattern): Add NodeId as well as
the clone_impl function.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: testsuite: Add a test for if let syntax
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 13:20:23 +0000 (14:20 +0100)]
gccrs: testsuite: Add a test for if let syntax

Add a new test to check the if let expression syntax parsing.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: parser: Fix if let parsing
Pierre-Emmanuel Patry [Wed, 1 Mar 2023 13:13:01 +0000 (14:13 +0100)]
gccrs: parser: Fix if let parsing

Fix if let parsing in null_notation function. This problem was due to
the current token already being passed in the function parameters and
already out of the buffered queue. Hence why the peeked token was let
and not if.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::null_denotation): Fix if let
parsing.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: add {add,sub,mul}_with_overflow intrinsics
Philip Herron [Wed, 1 Mar 2023 11:42:36 +0000 (11:42 +0000)]
gccrs: add {add,sub,mul}_with_overflow intrinsics

Fixes #1898

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* backend/rust-compile-intrinsic.cc (op_with_overflow_inner): wraps op_with_overflow
(std::function<tree): likewise
(op_with_overflow): generate the intrinsic based on the tree_code op

gcc/testsuite/ChangeLog:

* rust/compile/torture/intrinsics-8.rs: New test.

9 months agogccrs: hir: Refactor ASTLoweringStmt to source file.
Arthur Cohen [Wed, 1 Mar 2023 10:03:24 +0000 (11:03 +0100)]
gccrs: hir: Refactor ASTLoweringStmt to source file.

gcc/rust/ChangeLog:

* Make-lang.in: Add rust-ast-lower-stmt.o
* hir/rust-ast-lower-stmt.h: Move definitions to...
* hir/rust-ast-lower-stmt.cc: ...here.

9 months agogccrs: Add feature gate definition for `extern_types`.
mxlol233 [Wed, 1 Mar 2023 11:31:19 +0000 (19:31 +0800)]
gccrs: Add feature gate definition for `extern_types`.

This commit add a basic implementation to gating `ExternalTypeItem` AST node.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc: Add definition
for `extern_types`.
* checks/errors/rust-feature-gate.h: Likewise.
* checks/errors/rust-feature.cc: Likewise.
* checks/errors/rust-feature.h: Likewise.

gcc/testsuite/ChangeLog:
* rust/compile/feature_extern_types.rs:New file.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
9 months agogccrs: Fix assignment operator overloads for AST and HIR patterns
Owen Avery [Mon, 27 Feb 2023 16:18:56 +0000 (11:18 -0500)]
gccrs: Fix assignment operator overloads for AST and HIR patterns

gcc/rust/ChangeLog:

* ast/rust-pattern.h
(StructPatternElements::operator=): Clear vector before inserting.
(TupleStructItemsNoRange::operator=): Clear vector before inserting.
(TupleStructItemsRange::operator=): Clear vectors before inserting.
(TuplePatternItemsMultiple::operator=): Clear vector before inserting.
(TuplePatternItemsRanged::operator=): Clear vectors before inserting.
(SlicePattern::operator=): Clear vector before inserting.
(AltPattern::operator=): Clear vector before inserting.
* hir/tree/rust-hir-pattern.h
(StructPatternElements::operator=): Clear vector before inserting.
(TupleStructItemsNoRange::operator=): Clear vector before inserting.
(TupleStructItemsRange::operator=): Clear vectors before inserting.
(TuplePatternItemsMultiple::operator=): Clear vector before inserting.
(TuplePatternItemsRanged::operator=): Clear vectors before inserting.
(SlicePattern::operator=): Clear vector before inserting.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
9 months agogccrs: typecheck: Fix casting error behind generics
bl7awy [Tue, 28 Feb 2023 17:53:01 +0000 (20:53 +0300)]
gccrs: typecheck: Fix casting error behind generics

gcc/rust/ChangeLog:
* typecheck/rust-casts.cc (TypeCastRules::cast_rules): Perform destructure on `from` type.

gcc/testsuite/ChangeLog:
* rust/compile/cast_generics.rs: New test.

Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
9 months agogccrs: Change struct StructPatternElements into class
Owen Avery [Mon, 27 Feb 2023 16:02:02 +0000 (11:02 -0500)]
gccrs: Change struct StructPatternElements into class

gcc/rust/ChangeLog:

* ast/rust-pattern.h
(struct StructPatternElements): Change to class.
(class StructPatternElements): Change from struct.
* hir/tree/rust-hir-pattern.h
(struct StructPatternElements): Change to class.
(class StructPatternElements): Change from struct.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
9 months agogccrs: Replace gcc_unreachable with rust_sorry_at
Owen Avery [Mon, 27 Feb 2023 15:23:19 +0000 (10:23 -0500)]
gccrs: Replace gcc_unreachable with rust_sorry_at

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): Improve error messages.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
9 months agogccrs: Fix formatting
Owen Avery [Mon, 20 Feb 2023 21:05:41 +0000 (16:05 -0500)]
gccrs: Fix formatting

gcc/rust/ChangeLog:

* hir/tree/rust-hir-pattern.h
(class TupleStructItemsNoRange): Fix formatting.
(class TupleStructItemsRange): Fix formatting.
(class TuplePatternItemsMultiple): Fix formatting.
(class TuplePatternItemsRanged): Fix formatting.
(class SlicePattern): Fix formatting.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
9 months agogccrs: ast: Add RestPattern AST node
Pierre-Emmanuel Patry [Tue, 28 Feb 2023 16:34:31 +0000 (17:34 +0100)]
gccrs: ast: Add RestPattern AST node

Add the RestPattern AST node representing ".." code in some rust
context. This commit also provides the different visitors for this node.

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add visitor.
* ast/rust-ast-dump.h: Add visitor prototype.
* ast/rust-ast-full-decls.h (class RestPattern): Add forward
declaration for class RestPattern.
* ast/rust-ast-visitor.h: Add visitor prototype.
* ast/rust-ast.cc (RestPattern::accept_vis): Add function to
accept a foreign visitor.
* ast/rust-pattern.h (class RestPattern): Add class RestPattern.
* checks/errors/rust-feature-gate.h: Add visitor prototype.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Add
visitor implementation.
* expand/rust-attribute-visitor.h: Add visitor prototype.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add
visitor implementation.
* hir/rust-ast-lower-base.h: Add visitor prototype.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add
visitor implementation.
* resolve/rust-ast-resolve-base.h: Add visitor prototype.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Add visitor implementation.
* resolve/rust-early-name-resolver.h: Add visitor prototype.
* util/rust-attributes.cc (AttributeChecker::visit): Add visitor
implementation.
* util/rust-attributes.h: Add visitor prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: Remove cmp_autoderef_mode hack from old autoderef
Philip Herron [Tue, 28 Feb 2023 19:07:11 +0000 (19:07 +0000)]
gccrs: Remove cmp_autoderef_mode hack from old autoderef

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-tyty-cmp.h: remove
* typecheck/rust-tyty.cc (set_cmp_autoderef_mode): likewise
(reset_cmp_autoderef_mode): likewise
* typecheck/rust-tyty.h (set_cmp_autoderef_mode): likewise
(reset_cmp_autoderef_mode): likewise

9 months agogccrs: Fix method resolution to use TryCoerce
Philip Herron [Mon, 27 Feb 2023 19:16:00 +0000 (19:16 +0000)]
gccrs: Fix method resolution to use TryCoerce

Rust allows us to call generic pointer methods on pointers so in non
generic contexts the old code using the bad can_eq interface couldn't
handle this case. So taking advantage of our new unify_and interface to try
and infer when required we can start using our TryCoerce interface to reuse
existing code to assemble possible candidates more acurately using the
existing coercion rules.

Fixes #1901 #878

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-coercion.cc (TypeCoercionRules::Coerce): Add new try_flag
(TypeCoercionRules::TypeCoercionRules): set new try flag
(TypeCoercionRules::do_coercion): default to a final unify_and in the else case
(TypeCoercionRules::coerce_unsafe_ptr): cannot coerce to a ptr from ref during autoderef
(TypeCoercionRules::coerce_borrowed_pointer): respect coerceable mutability
* typecheck/rust-coercion.h: update header
* typecheck/rust-hir-dot-operator.cc (MethodResolver::select): use new TryCoerce interface
(MethodResolver::append_adjustments): ensure we maintain adjustment mappings
* typecheck/rust-hir-dot-operator.h: add new method append_adjustments
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): extra logging

gcc/testsuite/ChangeLog:

* rust/compile/issue-1901.rs: New test.

9 months agogccrs: bug-fix implicit inference checks
Philip Herron [Mon, 27 Feb 2023 17:39:09 +0000 (17:39 +0000)]
gccrs: bug-fix implicit inference checks

When generating implicit inference variables we can miss cases where the
other side might be another inference variable too but it runs the risk of
generating unending inference cycles needing more info but if they other
side is a non general inference variables like <integer> or <float> this
is safe to do so and allows us to infer mroe cases.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::go): fix inference check

9 months agogccrs: autoderef unconstify so we can use in non const contexts
Philip Herron [Mon, 27 Feb 2023 17:05:13 +0000 (17:05 +0000)]
gccrs: autoderef unconstify so we can use in non const contexts

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* backend/rust-compile-base.h: unconsify
* backend/rust-compile.cc (HIRCompileBase::coercion_site): likewise
(HIRCompileBase::coercion_site1): likewise
* typecheck/rust-autoderef.cc (Adjuster::try_deref_type): likewise
(Adjuster::try_raw_deref_type): likewise
(Adjuster::try_unsize_type): likewise
(AutoderefCycle::cycle): likewise
(AutoderefCycle::try_autoderefed): likewise
* typecheck/rust-autoderef.h: likewise
* typecheck/rust-coercion.cc (TypeCoercionRules::select): likewise
* typecheck/rust-coercion.h: likewise
* typecheck/rust-hir-dot-operator.cc (MethodResolver::Probe): likewise
(MethodResolver::select): likewise
* typecheck/rust-hir-dot-operator.h: likewise

9 months agogccrs: Only emit errors during type-bounds checking when required
Philip Herron [Mon, 27 Feb 2023 16:38:41 +0000 (16:38 +0000)]
gccrs: Only emit errors during type-bounds checking when required

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::go): respect the emit_errors flag

9 months agogccrs: Make coercion sites autoderef cycle optional
Philip Herron [Mon, 27 Feb 2023 14:16:29 +0000 (14:16 +0000)]
gccrs: Make coercion sites autoderef cycle optional

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-casts.cc (TypeCastRules::check): update to new interface
* typecheck/rust-coercion.cc (TypeCoercionRules::Coerce): likewise
(TypeCoercionRules::TryCoerce): likewise
(TypeCoercionRules::TypeCoercionRules): likewise
* typecheck/rust-coercion.h: likewise
* typecheck/rust-type-util.cc (coercion_site): likewise

9 months agogccrs: Allow infer vars on the lhs too
Philip Herron [Mon, 27 Feb 2023 13:34:30 +0000 (13:34 +0000)]
gccrs: Allow infer vars on the lhs too

We should allow implicit inference on the expected side too not just the
receiver.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::go): allow lhs infer vars

9 months agogccrs: Generic pointers are coerceable
Philip Herron [Sun, 26 Feb 2023 22:08:26 +0000 (22:08 +0000)]
gccrs: Generic pointers are coerceable

This is a complex type-system change where it begins out journey to get
rid of our can_eq interface. Rust allows:

  let x:*mut T
  let y = x as *mut u8;

Which requires us to consider find a way to infer what T should be so as
to keep unify happy. This means we need to introduce a new unify_and
interface where we can optionally inject inference variables as well as
only commit the inference variable joins when they are sucsessful.

So for this case we can then inject an implicit inference variables for T
that can unify against u8 to make this a valid type-resolution.

Fixes #1930

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::resolve_method_address): update to new inteface
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsafe_ptr): likewise
(TypeCoercionRules::coerce_borrowed_pointer): likewise
* typecheck/rust-hir-type-check.h: likewise
* typecheck/rust-type-util.cc (unify_site_and): new interface to allow for infer and commit
* typecheck/rust-type-util.h (unify_site_and): likewise
* typecheck/rust-typecheck-context.cc (TypeCheckContext::clear_type): new interface
* typecheck/rust-unify.cc (UnifyRules::UnifyRules): update
(UnifyRules::Resolve): new optional flags for commit and infer
(UnifyRules::go): likewise
(UnifyRules::expect_adt): refactor to use new interface
(UnifyRules::expect_reference): likewise
(UnifyRules::expect_pointer): likewise
(UnifyRules::expect_array): likewise
(UnifyRules::expect_slice): likewise
(UnifyRules::expect_fndef): likewise
(UnifyRules::expect_fnptr): likewise
(UnifyRules::expect_tuple): likewise
(UnifyRules::expect_closure): likewise
* typecheck/rust-unify.h: refactor interface

gcc/testsuite/ChangeLog:

* rust/compile/issue-1930.rs: New test.

9 months agogccrs: refactor unify commit as a static function from unify code
Philip Herron [Sun, 26 Feb 2023 18:30:49 +0000 (18:30 +0000)]
gccrs: refactor unify commit as a static function from unify code

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::Resolve): refactor
(UnifyRules::commit): refactor
* typecheck/rust-unify.h: likewise

9 months agogccrs: Fix ICE in ADTType::is_concrete
Philip Herron [Sun, 26 Feb 2023 22:36:20 +0000 (22:36 +0000)]
gccrs: Fix ICE in ADTType::is_concrete

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (ADTType::is_concrete):  need to consider if is a num_variant
* typecheck/rust-tyty.h: refactor to cc file

9 months agogccrs: testsuite: Add test with missing semicolon
Pierre-Emmanuel Patry [Mon, 27 Feb 2023 13:08:10 +0000 (14:08 +0100)]
gccrs: testsuite: Add test with missing semicolon

Add a test to the testsuite in order to verify the presence of a
semicolon at the end of an external type item declaration.

gcc/testsuite/ChangeLog:

* rust/compile/extern_type_item_missing_semi.rs: New failing
test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: testsuite: Add extern type item test
Pierre-Emmanuel Patry [Mon, 27 Feb 2023 13:07:00 +0000 (14:07 +0100)]
gccrs: testsuite: Add extern type item test

Add a test for extern type item declaration.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: parser: Parse external type item
Pierre-Emmanuel Patry [Mon, 27 Feb 2023 09:10:51 +0000 (10:10 +0100)]
gccrs: parser: Parse external type item

Add the code to parse type item declaration within an extern block.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_external_type_item):
Add function to parser an external type item.
(Parser::parse_external_item):
Add identification and parsing for external type items.
* parse/rust-parse.h:
Add parser_external_type_item prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: Implement and test include_str eager expansion
omkar-mohanty [Thu, 16 Feb 2023 04:40:24 +0000 (10:10 +0530)]
gccrs: Implement and test include_str eager expansion

builtins: Implement eager expansion for include_str!()

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): eager expansion
(make_macro_path_str): macto to string
(parse_single_string_literal): check for eager invocation
(MacroBuiltin::assert_handler): eager expansion
(MacroBuiltin::include_bytes_handler): eager expansion
(MacroBuiltin::include_str_handler): eager expansion
(MacroBuiltin::compile_error_handler): eager expansion
(MacroBuiltin::include_handler): eager expansion

gcc/testsuite/ChangeLog:

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

Signed-off-by: omkar-mohanty <franzohouser@gmail.com>
9 months agogccrs: parser: Parse `default` impl Functions and Methods
Arthur Cohen [Thu, 23 Feb 2023 14:11:04 +0000 (15:11 +0100)]
gccrs: parser: Parse `default` impl Functions and Methods

gcc/rust/ChangeLog:

* ast/rust-item.h (class Method): Add `is_default` field.
(class Function): Likewise.
* parse/rust-parse-impl.h (Parser::parse_item): Add nice error when
parsing `default` outside of an `impl` block
(Parser::parse_trait_impl_item): Allow parsing functions
or methods when seeing `default`.

gcc/testsuite/ChangeLog:

* rust/compile/parse_invalid_specialization.rs: New test.
* rust/compile/parse_specialization.rs: New test.
* rust/compile/default_not_a_kw.rs: New test.

9 months agogccrs: typecheck: Refactor cast_site
Pierre-Emmanuel Patry [Thu, 23 Feb 2023 18:00:07 +0000 (19:00 +0100)]
gccrs: typecheck: Refactor cast_site

Refactor cast_site to be a simple function in rust-type-util.h.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::cast_site):
Remove cast_site.
* typecheck/rust-hir-type-check-base.h: Remove cast_site
prototype.
* typecheck/rust-type-util.cc (cast_site): Add cast_site.
* typecheck/rust-type-util.h (cast_site): Add cast_site
prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: ast: Add proper visitors for ExternalTypeItem
Arthur Cohen [Thu, 23 Feb 2023 15:59:20 +0000 (16:59 +0100)]
gccrs: ast: Add proper visitors for ExternalTypeItem

gcc/rust/ChangeLog:

* ast/rust-item.h: Add non-const `get_visibility` to ExternalTypeItem.
* ast/rust-ast-dump.cc (Dump::visit): Add implementation for ExternalTypeItem.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Likewise.

9 months agogccrs: ast: Add ExternalTypeItem node
Arthur Cohen [Thu, 23 Feb 2023 15:50:39 +0000 (16:50 +0100)]
gccrs: ast: Add ExternalTypeItem node

gcc/rust/ChangeLog:

* ast/rust-item.h (class ExternalTypeItem): New class.
* ast/rust-ast.cc (ExternalTypeItem::as_string): New function.
(ExternalTypeItem::accept_vis): Likewise.
* ast/rust-ast-full-decls.h (class ExternalTypeItem): Declare class.
* ast/rust-ast-dump.cc (Dump::visit): Add base visitor for ExternalTypeItem.
* ast/rust-ast-dump.h: Likewise.
* ast/rust-ast-visitor.h: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Likewise.
* expand/rust-attribute-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise.
* resolve/rust-early-name-resolver.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h: Likewise.

9 months agogccrs: macro_invoc_lexer: Add `split_current_token` implementation
Arthur Cohen [Tue, 21 Feb 2023 12:51:54 +0000 (13:51 +0100)]
gccrs: macro_invoc_lexer: Add `split_current_token` implementation

gcc/rust/ChangeLog:

* expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::split_current_token):
Add proper implementation.

gcc/testsuite/ChangeLog:

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

9 months agogccrs: parser: Add parsing of auto traits
Arthur Cohen [Wed, 15 Feb 2023 15:53:41 +0000 (16:53 +0100)]
gccrs: parser: Add parsing of auto traits

This adds enough handling to start parsing `auto` traits but not handle
them in the AST, lowering phase or HIR yet.

The feature is named `optin_builtin_traits` in Rust 1.49 but changes to
`auto_traits` later down the line. So we'll need to take care of this later
on.

Finally, this also changes the way the lexer detects if a string is a
keyword or not. We relied on a call to `std::lower_bound` to figure
out if a string was contained in an array or not, and this ended up
causing issues when adding new keywords. We can instead switch to a
simple hashmap and search for the key. The code *might* be less
optimized (unsure) but it is definitely simpler and easier to read.

Fixes #1814

gcc/rust/ChangeLog:

* ast/rust-item.h (class Trait): Add `has_auto` field.
* checks/errors/rust-feature.cc: Add handling for `feature(optin_builtin_traits)`
* checks/errors/rust-feature.h: Likewise.
* lex/rust-lex.cc: Fix keyword classification using hashmap.
* lex/rust-token.h: Add `auto` keyword token.
* parse/rust-parse-impl.h (Parser::parse_vis_item): Parse auto traits
on `auto` keyword.

gcc/testsuite/ChangeLog:

* rust/compile/auto_trait_invalid.rs: New test.
* rust/compile/auto_trait_valid.rs: New test.

9 months agogccrs: typecheck: Refactor coercion_site
Pierre-Emmanuel Patry [Wed, 22 Feb 2023 09:44:16 +0000 (10:44 +0100)]
gccrs: typecheck: Refactor coercion_site

Refactor coercion_site to be a simple function in rust-type-util.h
instead of a static function in TypeCheckBase.
gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item):
Remove TypeCheckBase namespace qualifier.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::coercion_site):
Remove coercion_site function.
* typecheck/rust-hir-type-check-base.h: Remove coercion_site
prototype.
* typecheck/rust-type-util.cc (coercion_site): Add coercion_site
function.
* typecheck/rust-type-util.h (coercion_site): Add coercion_site
prototype.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
Remove TypeCheckBase namespace qualifier.
(TypeCheckMethodCallExpr::check): Remove TypeCheckBase namespace
qualifier.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: typecheck: Refactor unify_site
Pierre-Emmanuel Patry [Tue, 21 Feb 2023 16:29:53 +0000 (17:29 +0100)]
gccrs: typecheck: Refactor unify_site

Refactor unify_site to be a simple function in rust-type-util.h.

gcc/rust/ChangeLog:

* typecheck/rust-autoderef.cc: Remove TypeCheckBase qualifier.
* typecheck/rust-hir-trait-resolve.cc: Remove TypeCheckBase
qualifier.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::unify_site):
Remove unify_site.
* typecheck/rust-hir-type-check-base.h: Remove unify_site
header.
* typecheck/rust-hir-type-check.cc (TypeResolution::Resolve):
Remove TypeCheckBase qualifier.
* typecheck/rust-type-util.cc (unify_site): Add unify_site
function.
* typecheck/rust-type-util.h (unify_site): Add unify_site
prototype.
* typecheck/rust-tyty-call.cc (TypeCheckMethodCallExpr::check):
Remove TypeCheckBase qualifier.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: parser: Allow `LEFT_SHIFT` to start `parse_type`
Arthur Cohen [Fri, 17 Feb 2023 13:24:07 +0000 (14:24 +0100)]
gccrs: parser: Allow `LEFT_SHIFT` to start `parse_type`

Similarly to the last commit, we need to allow `LEFT_SHIFT` tokens to
start a qualified path type and split them into two `LEFT_ANGLE` tokens.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_type): Allow LEFT_SHIFT to
start a type and then split it in `parse_qualified_path_type`

gcc/testsuite/ChangeLog:

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

9 months agogccrs: parser: Allow parsing of qualified type path as nested generic argument
Arthur Cohen [Thu, 16 Feb 2023 12:53:22 +0000 (13:53 +0100)]
gccrs: parser: Allow parsing of qualified type path as nested generic argument

Let's take the example of lexing `Option<<T as Iterator>::Item>` and look
at the first few tokens. Originally, `Option<<T` was lexed as 3 tokens:

* IDENTIFIER(Option)
* LEFT_SHIFT
* IDENTIFIER(T)

The parser did not allow a list of generic arguments to start with a left
shift, and rejected the above type. We are now splitting the left shift
into two left angles, as this allows complex generic arguments and overall
makes sense parsing wise. Thus, the above list becomes:

* IDENTIFIER(Option)
* LEFT_ANGLE
* LEFT_ANGLE
* IDENTIFIER(T)

and `<T as Iterator>` is properly parsed as a qualified path.

Fixes #1815
Fixed #1809

Addresses #1524

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_path_generic_args): Split leading
`LEFT_SHIFT` token into two `LEFT_ANGLE` tokens when parsing generic arguments.
(Parser::parse_type_path_segment): Allow `LEFT_ANGLE` as starting token for
parsing generic arguments.

gcc/testsuite/ChangeLog:

* rust/compile/parse_associated_type_as_generic_arg.rs: New test.
* rust/compile/parse_associated_type_as_generic_arg2.rs: New test.
* rust/compile/path_as_generic_arg.rs: New test.
* rust/compile/nested_generic.rs: New test.

9 months agogccrs: Add feature gate for "rustc_attri".
mxlol233 [Thu, 16 Feb 2023 11:38:42 +0000 (19:38 +0800)]
gccrs: Add feature gate for "rustc_attri".

This commit implemented a basic feature gate to check some attributes
for `rustc_attri`.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc: Add implementations
for `rustc_attri`.
* checks/errors/rust-feature-gate.h: Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/builtin_macro_compile_error.rs: Add
crate feature `rustc_attri`.
* rust/compile/builtin_macro_concat.rs: Likewise.
* rust/compile/builtin_macro_eager1.rs: Likewise.
* rust/compile/builtin_macro_eager2.rs: Likewise.
* rust/compile/builtin_macro_env.rs: Likewise.
* rust/compile/builtin_macro_include_bytes.rs:
Likewise.
* rust/compile/builtin_macro_include_str.rs:
Likewise.
* rust/compile/builtin_macro_not_found.rs:
Likewise.
* rust/compile/builtin_macro_recurse2.rs:
Likewise.
* rust/compile/feature_rust_attri0.rs:New file.
* rust/compile/feature_rust_attri1.rs:New file.
* rust/compile/include_empty.rs:Add crate feature
`rustc_attri`.
* rust/compile/issue-1830_bytes.rs:Likewise.
* rust/compile/issue-1830_str.rs:Likewise.
* rust/compile/macro42.rs:Likewise.
* rust/execute/torture/builtin_macro_cfg.rs:
Likewise.
* rust/execute/torture/builtin_macro_concat.rs:
Likewise.
* rust/execute/torture/builtin_macro_env.rs:
Likewise.
* rust/execute/torture/builtin_macro_include_bytes.rs:
Likewise.
* rust/execute/torture/builtin_macro_include_str.rs:
Likewise.
* rust/execute/torture/builtin_macro_line.rs:
Likewise.
* rust/execute/torture/builtin_macros1.rs:
Likewise.
* rust/execute/torture/builtin_macros3.rs:
Likewise.
* rust/execute/torture/macros29.rs:Likewise.
* rust/execute/torture/macros30.rs:Likewise.
* rust/execute/torture/macros31.rs:Likewise.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
9 months agoAArch64: Reassociate CONST in address expressions
Wilco Dijkstra [Tue, 16 Jan 2024 16:27:02 +0000 (16:27 +0000)]
AArch64: Reassociate CONST in address expressions

GCC tends to optimistically create CONST of globals with an immediate offset.
However it is almost always better to CSE addresses of globals and add immediate
offsets separately (the offset could be merged later in single-use cases).
Splitting CONST expressions with an index in aarch64_legitimize_address fixes
part of PR112573.

gcc/ChangeLog:
PR target/112573
* config/aarch64/aarch64.cc (aarch64_legitimize_address): Reassociate
badly formed CONST expressions.

gcc/testsuite/ChangeLog:
PR target/112573
* gcc.target/aarch64/pr112573.c: Add new test.

9 months agogccrs: Parse AltPattern
Owen Avery [Tue, 14 Feb 2023 23:42:39 +0000 (18:42 -0500)]
gccrs: Parse AltPattern

Renamed Parser::parse_pattern to Parser::parse_pattern_no_alt and created
new method Parser::parse_pattern to handle alternate patterns.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h
(Parser::parse_pattern): Add.
(Parser::parse_pattern_no_alt): Rename.
* parse/rust-parse.h:
(Parser::parse_pattern): Add.
(Parser::parse_pattern_no_alt): Rename.

gcc/testsuite/ChangeLog:

* rust/compile/pattern-or.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
9 months agogccrs: Fix missing build dependency
Pierre-Emmanuel Patry [Mon, 12 Jun 2023 08:51:49 +0000 (10:51 +0200)]
gccrs: Fix missing build dependency

Fix the missing dependency between the gcc and libgrust.

ChangeLog:

* Makefile.def: Add a dependency to libgrust for all-gcc.
* Makefile.in: Regenerate the file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agogccrs: Fix bootstrap build
Pierre-Emmanuel Patry [Wed, 3 May 2023 16:43:10 +0000 (18:43 +0200)]
gccrs: Fix bootstrap build

This commit fixes bootstrapping for future additions to libgrust/

ChangeLog:

* Makefile.def: Add libgrust target to bootstrap.
* Makefile.in: Regenerate.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
9 months agosparc: Char arrays are 64-bit aligned on SPARC
Daniel Cederman [Fri, 8 Dec 2023 08:49:12 +0000 (09:49 +0100)]
sparc: Char arrays are 64-bit aligned on SPARC

pr88077 fails on SPARC since char HeaderStr[1] in pr88077_1.c and
long HeaderStr in pr88077_0.c differs in alignment.

Warning printed by Binutils ld:
warning: alignment 4 of normal symbol `HeaderStr' in c_lto_pr88077_0.o is
smaller than 8 used by the common definition in c_lto_pr88077_1.o

gcc/testsuite/ChangeLog:

* gcc.dg/lto/pr88077_0.c: Change type to match alignment for SPARC

9 months agotestsuite: Skip ifcvt-4.c for SPARC V8
Daniel Cederman [Mon, 8 Jan 2024 08:08:43 +0000 (09:08 +0100)]
testsuite: Skip ifcvt-4.c for SPARC V8

Conditional moves are not available in SPARC V8.

gcc/testsuite/ChangeLog:

* gcc.dg/ifcvt-4.c: Skip for SPARC V8

9 months agosparc: Treat instructions with length 0 as empty
Daniel Cederman [Tue, 5 Dec 2023 14:26:27 +0000 (15:26 +0100)]
sparc: Treat instructions with length 0 as empty

This is to handle the membar_empty instruction that can be generated
when compiling for UT699.

gcc/ChangeLog:

* config/sparc/sparc.cc (next_active_non_empty_insn): Length 0 treated as empty

9 months agosparc: Add errata workaround to membar patterns
Daniel Cederman [Thu, 4 Jan 2024 13:56:06 +0000 (14:56 +0100)]
sparc: Add errata workaround to membar patterns

LEON now uses the standard V8 membar patterns that contains an ldstub
instruction. This instruction needs to be aligned properly when the
GR712RC errata workaround is enabled.

gcc/ChangeLog:

* config/sparc/sparc.cc (atomic_insn_for_leon3_p): Treat membar_storeload as atomic
* config/sparc/sync.md (membar_storeload): Turn into named insn
and add GR712RC errata workaround.
(membar_v8): Add GR712RC errata workaround.

9 months agosparc: Revert membar optimization that is not suitable for LEON5
Andreas Larsson [Mon, 16 Jan 2023 14:43:24 +0000 (15:43 +0100)]
sparc: Revert membar optimization that is not suitable for LEON5

LEON5 has a deeper write-buffer and hence stb is not enough to flush a
write out. For compatibility, use the default V8 approach for both
LEON3 and LEON5.

This reverts commit 49cc765db35a5a21cab2aece27a44983fa70b94b,
"sync.md (*membar_storeload_leon3): New insn."

gcc/ChangeLog:

* config/sparc/sync.md (*membar_storeload_leon3): Remove
(*membar_storeload): Enable for LEON

9 months agoFix crash of -fdump-ada-spec in a pathological case
Eric Botcazou [Tue, 16 Jan 2024 11:15:31 +0000 (12:15 +0100)]
Fix crash of -fdump-ada-spec in a pathological case

gcc/c-family/
PR ada/113397
* c-ada-spec.cc (check_type_name_conflict): Add guard for the
presence of DECL_NAME on a TYPE_DECL.

9 months agocfgexpand: Workaround CSE of ADDR_EXPRs in VAR_DECL partitioning [PR113372]
Jakub Jelinek [Tue, 16 Jan 2024 10:49:34 +0000 (11:49 +0100)]
cfgexpand: Workaround CSE of ADDR_EXPRs in VAR_DECL partitioning [PR113372]

The following patch adds a quick workaround to bugs in VAR_DECL
partitioning.
The problem is that there is no dependency between ADDR_EXPRs of local
decls and CLOBBERs of those vars, so VN can CSE uses of ADDR_EXPRs
(including ivopts integral variants thereof), which can break
add_scope_conflicts discovery of what variables are actually used
in certain region.
E.g. we can have
  ivtmp.40_3 = (unsigned long) &MEM <unsigned long[100]> [(void *)&bitint.6 + 8B];
...
  uses of ivtmp.40_3
...
  bitint.6 ={v} {CLOBBER(eos)};
...
  ivtmp.28_43 = (unsigned long) &MEM <unsigned long[100]> [(void *)&bitint.6 + 8B];
...
  uses of ivtmp.28_43
before VN (such as dom3), which the add_scope_conflicts code identifies as 2
independent uses of bitint.6 variable (which is correct), but then VN
determines ivtmp.28_43 is the same as ivtmp.40_3 and just uses ivtmp.40_3
even in the second region; at that point add_scope_conflict thinks the
bitint.6 variable is not used in that region anymore.

The following patch does a simple single def-stmt check for such ADDR_EXPRs
(rather than say trying to do a full propagation of what SSA_NAMEs can
contain ADDR_EXPRs of local variables), which seems to workaround all 4 PRs.

In addition to this patch I've used the attached one to gather statistics
on the total size of all variable partitions in a function and seems besides
the new testcases nothing is really affected compared to no patch (I've
actually just modified the patch to == OMP_SCAN instead of == ADDR_EXPR, so
it looks the same except that it never triggers).  The comparison wasn't
perfect because I've only gathered BITS_PER_WORD, main_input_filename (did
some replacement of build directories and /tmp/ccXXXXXX names of LTO to make
it more similar between the two bootstraps/regtests), current_function_name
and the total size of all variable partitions if any, because I didn't
record e.g. the optimization options and so e.g. torture tests which iterate
over options could have different partition sizes even in one compiler when
BITS_PER_WORD, main_input_filename and current_function_name are all equal.
So had to write an awk script to check if the first triple in the second
build appeared in the first one and the quadruple in the second build
appeared in the first one too, otherwise print result and that only
triggered in the new tests.
Also, the cc1plus binary according to objdump -dr is identical between the
two builds except for the ADDR_EXPR vs. OMP_SCAN constant in the two spots.

2024-01-16  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/113372
PR middle-end/90348
PR middle-end/110115
PR middle-end/111422
* cfgexpand.cc (add_scope_conflicts_2): New function.
(add_scope_conflicts_1): Use it.

* gcc.dg/torture/bitint-49.c: New test.
* gcc.c-torture/execute/pr90348.c: New test.
* gcc.c-torture/execute/pr110115.c: New test.
* gcc.c-torture/execute/pr111422.c: New test.

9 months agoAVR: Add AVR16EB, AVR16EA and AVR32EA devices.
Georg-Johann Lay [Tue, 16 Jan 2024 10:38:06 +0000 (11:38 +0100)]
AVR: Add AVR16EB, AVR16EA and AVR32EA devices.

gcc/
* config/avr/avr-mcus.def (avr16eb14, avr16eb20, avr16eb28, avr16eb32)
(avr16ea28, avr16ea32, avr16ea48, avr32ea28, avr32ea32, avr32ea48): Add.
* doc/avr-mmcu.texi: Regenerate.

9 months agoDo not count unused scalar use when marking STMT_VINFO_LIVE_P [PR113091]
Feng Xue [Thu, 28 Dec 2023 08:55:39 +0000 (16:55 +0800)]
Do not count unused scalar use when marking STMT_VINFO_LIVE_P [PR113091]

When pattern recognition is involved, a statement whose definition is
consumed in some pattern, may not be included in the final replacement
pattern statements, and would be skipped when building SLP graph.

 * Original
  char a_c = *(char *) a;
  char b_c = *(char *) b;
  unsigned short a_s = (unsigned short) a_c;
  int a_i = (int) a_s;
  int b_i = (int) b_c;
  int r_i = a_i - b_i;

 * After pattern replacement
  a_s = (unsigned short) a_c;
  a_i = (int) a_s;

  patt_b_s = (unsigned short) b_c;    // b_i = (int) b_c
  patt_b_i = (int) patt_b_s;          // b_i = (int) b_c

  patt_r_s = widen_minus(a_c, b_c);   // r_i = a_i - b_i
  patt_r_i = (int) patt_r_s;          // r_i = a_i - b_i

The definitions of a_i(original statement) and b_i(pattern statement)
are related to, but actually not part of widen_minus pattern.
Vectorizing the pattern does not cause these definition statements to
be marked as PURE_SLP.  For this case, we need to recursively check
whether their uses are all absorbed into vectorized code.  But there
is an exception that some use may participate in an vectorized
operation via an external SLP node containing that use as an element.

gcc/ChangeLog:

PR tree-optimization/113091
* tree-vect-slp.cc (vect_slp_has_scalar_use): New function.
(vect_bb_slp_mark_live_stmts): New parameter scalar_use_map, check
scalar use with new function.
(vect_bb_slp_mark_live_stmts): New function as entry to existing
overriden functions with same name.
(vect_slp_analyze_operations): Call new entry function to mark
live statements.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/bb-slp-pr113091.c: New test.

9 months agoRISC-V: Report Sorry when users enable RVV in big-endian mode [PR113404]
Juzhe-Zhong [Tue, 16 Jan 2024 03:04:49 +0000 (11:04 +0800)]
RISC-V: Report Sorry when users enable RVV in big-endian mode [PR113404]

As PR113404 mentioned: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113404

We have ICE when we enable RVV in big-endian mode:

during RTL pass: expand
a-float-point-dynamic-frm-66.i:2:14: internal compiler error: in to_constant, at poly-int.h:588
0xab4c2c poly_int<2u, unsigned short>::to_constant() const
        /repo/gcc-trunk/gcc/poly-int.h:588
0xab4de1 poly_int<2u, unsigned short>::to_constant() const
        /repo/gcc-trunk/gcc/tree.h:4055
0xab4de1 default_function_arg_padding(machine_mode, tree_node const*)
        /repo/gcc-trunk/gcc/targhooks.cc:844
0x12e2327 locate_and_pad_parm(machine_mode, tree_node*, int, int, int, tree_node*, args_size*, locate_and_pad_arg_data*)
        /repo/gcc-trunk/gcc/function.cc:4061
0x12e2aca assign_parm_find_entry_rtl
        /repo/gcc-trunk/gcc/function.cc:2614
0x12e2c89 assign_parms
        /repo/gcc-trunk/gcc/function.cc:3693
0x12e59df expand_function_start(tree_node*)
        /repo/gcc-trunk/gcc/function.cc:5152
0x112fafb execute
        /repo/gcc-trunk/gcc/cfgexpand.cc:6739

Report users that we don't support RVV in big-endian mode for the following reasons:
1. big-endian in RISC-V is pretty rare case.
2. We didn't test RVV in big-endian and we don't have enough time to test it since it's stage 4 now.

Naive disallow RVV in big-endian.

Tested no regression, ok for trunk ?

gcc/ChangeLog:

PR target/113404
* config/riscv/riscv.cc (riscv_override_options_internal): Report sorry
for RVV in big-endian mode.

gcc/testsuite/ChangeLog:

PR target/113404
* gcc.target/riscv/rvv/base/big_endian-1.c: New test.
* gcc.target/riscv/rvv/base/big_endian-2.c: New test.

9 months agotestsuite: Fix vect_long_mult on Power [PR109705]
Kewen Lin [Tue, 16 Jan 2024 02:55:40 +0000 (20:55 -0600)]
testsuite: Fix vect_long_mult on Power [PR109705]

As pointed out by the discussion in PR109705, the current
vect_long_mult effective target check on Power is broken.
This patch is to fix it accordingly.

With additional change by adding a guard vect_long_mult
in gcc.dg/vect/pr25413a.c, it's tested well on Power{8,9}
LE & BE (also on Power10 LE as before).

PR testsuite/109705

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_vect_long_mult):
Fix powerpc*-*-* checks.

9 months agoRISC-V: delete vector abi checking in all relevant tests.
Yanzhang Wang [Mon, 15 Jan 2024 06:00:31 +0000 (14:00 +0800)]
RISC-V: delete vector abi checking in all relevant tests.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/abi-call-args-1-run.c: Delete the
-Wno-psabi.
* gcc.target/riscv/rvv/base/abi-call-args-1.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-args-2-run.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-args-2.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-args-3-run.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-args-3.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-args-4-run.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-args-4.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-error-1.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-return-run.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-return.c: Ditto.
* gcc.target/riscv/rvv/base/abi-call-variant_cc.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-1-fixed-1.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-1-fixed-2.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-1-save-restore.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-1-zcmp.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-1.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-2-save-restore.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-2-zcmp.c: Ditto.
* gcc.target/riscv/rvv/base/abi-callee-saved-2.c: Ditto.
* gcc.target/riscv/rvv/base/fixed-point-vxrm-error.c: Ditto.
* gcc.target/riscv/rvv/base/fixed-point-vxrm.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-cvt-f.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-cvt-x.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-cvt-xu.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-1.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-10.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-11.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-12.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-13.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-14.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-15.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-16.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-17.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-18.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-19.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-2.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-20.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-21.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-22.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-23.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-24.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-25.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-26.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-27.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-28.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-29.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-3.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-30.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-31.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-32.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-33.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-34.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-35.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-36.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-37.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-38.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-39.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-4.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-40.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-41.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-42.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-43.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-44.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-45.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-46.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-47.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-48.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-49.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-5.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-50.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-51.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-52.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-53.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-54.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-55.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-56.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-57.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-58.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-59.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-6.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-60.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-61.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-62.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-63.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-64.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-65.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-66.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-67.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-68.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-69.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-7.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-70.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-71.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-72.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-73.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-74.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-75.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-76.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-77.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-8.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-9.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-autovec-1.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-autovec-2.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-autovec-3.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-autovec-4.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-error.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-1.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-10.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-2.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-3.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-4.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-5.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-7.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-8.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-insert-9.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-run-1.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-run-2.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-run-3.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-run-4.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-run-5.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-fwmacc.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-macc.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-madd.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-msac.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-msub.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-ncvt-f.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-ncvt-x.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-ncvt-xu.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-nmacc.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-nmadd.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-nmsac.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-nmsub.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-rec7.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-redosum.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-redusum.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-single-div.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-single-mul.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-single-rdiv.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-single-rsub.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-single-sub.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-sqrt.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-wcvt-x.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-wcvt-xu.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-widening-add.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-widening-mul.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-widening-sub.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-wmsac.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-wnmacc.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-wnmsac.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-wredosum.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-wredusum.c: Ditto.
* gcc.target/riscv/rvv/base/intrisinc-vrgatherei16.c: Ditto.
* gcc.target/riscv/rvv/base/no-honor-frm-1.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv32_vadd.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv32_vfadd.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv32_vget_vset.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv32_vloxseg2ei16.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv32_vmv.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv32_vreinterpret.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv64_vadd.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv64_vfadd.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv64_vget_vset.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv64_vloxseg2ei16.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv64_vmv.c: Ditto.
* gcc.target/riscv/rvv/base/overloaded_rv64_vreinterpret.c: Ditto.
* gcc.target/riscv/rvv/base/pr110119-1.c: Ditto.
* gcc.target/riscv/rvv/base/pr110119-2.c: Ditto.
* gcc.target/riscv/rvv/base/pr110265-1.c: Ditto.
* gcc.target/riscv/rvv/base/pr110265-2.c: Ditto.
* gcc.target/riscv/rvv/base/pr110265-3.c: Ditto.
* gcc.target/riscv/rvv/base/pr110277-1.c: Ditto.
* gcc.target/riscv/rvv/base/pr110277-2.c: Ditto.
* gcc.target/riscv/rvv/base/pr110299-1.c: Ditto.
* gcc.target/riscv/rvv/base/pr110299-2.c: Ditto.
* gcc.target/riscv/rvv/base/pr110299-3.c: Ditto.
* gcc.target/riscv/rvv/base/pr110299-4.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-0.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-1.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-10.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-2.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-3.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-4.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-5.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-6.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-7.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-8.c: Ditto.
* gcc.target/riscv/rvv/base/pr111720-9.c: Ditto.
* gcc.target/riscv/rvv/base/pr111935.c: Ditto.
* gcc.target/riscv/rvv/base/scalar-move-merged-run-1.c: Ditto.
* gcc.target/riscv/rvv/base/simplify-vdiv.c: Ditto.
* gcc.target/riscv/rvv/base/simplify-vrsub.c: Ditto.
* gcc.target/riscv/rvv/base/tuple-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/tuple_vundefined.c: Ditto.
* gcc.target/riscv/rvv/base/vcreate.c: Ditto.
* gcc.target/riscv/rvv/base/vlmul_ext-2.c: Ditto.
* gcc.target/riscv/rvv/base/vslide1down-1.c: Ditto.
* gcc.target/riscv/rvv/base/vslide1down-2.c: Ditto.
* gcc.target/riscv/rvv/base/vslide1down-3.c: Ditto.
* gcc.target/riscv/rvv/base/vslide1up-1.c: Ditto.
* gcc.target/riscv/rvv/base/vslide1up-2.c: Ditto.
* gcc.target/riscv/rvv/base/vslide1up-3.c: Ditto.
* gcc.target/riscv/rvv/base/zvbb-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvbb_vandn_vx_constraint.c: Ditto.
* gcc.target/riscv/rvv/base/zvbc-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvbc_vx_constraint-1.c: Ditto.
* gcc.target/riscv/rvv/base/zvbc_vx_constraint-2.c: Ditto.
* gcc.target/riscv/rvv/base/zvfhmin-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvkg-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvkned-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvknha-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvknhb-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvksed-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvksh-intrinsic.c: Ditto.

Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com>
9 months agoRISC-V: delete all the vector psabi checking.
Yanzhang Wang [Mon, 15 Jan 2024 06:00:30 +0000 (14:00 +0800)]
RISC-V: delete all the vector psabi checking.

Thanks the
https://hub.fgit.cf/riscv-non-isa/riscv-elf-psabi-doc/pull/389, we
need not to maintain the psabi checking any more.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_arg_has_vector): Delete.
(riscv_pass_in_vector_p): Delete.
(riscv_init_cumulative_args): Delete the checking.
(riscv_get_arg_info): Delete the checking.
(riscv_function_value): Delete the checking.
* config/riscv/riscv.h: Delete the member for checking.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/binop_vx_constraint-120.c: Delete the -Wno-psabi.
* gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c: Ditto.
* gcc.target/riscv/rvv/base/mask_insn_shortcut.c: Ditto.
* gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c: Ditto.
* gcc.target/riscv/rvv/base/pr110109-2.c: Ditto.
* gcc.target/riscv/rvv/base/scalar_move-9.c: Ditto.
* gcc.target/riscv/rvv/base/spill-10.c: Ditto.
* gcc.target/riscv/rvv/base/spill-11.c: Ditto.
* gcc.target/riscv/rvv/base/spill-9.c: Ditto.
* gcc.target/riscv/rvv/base/vlmul_ext-1.c: Ditto.
* gcc.target/riscv/rvv/base/zero_base_load_store_optimization.c: Ditto.
* gcc.target/riscv/rvv/base/zvfh-intrinsic.c: Ditto.
* gcc.target/riscv/rvv/base/zvfh-over-zvfhmin.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-1.c: Ditto.
* gcc.target/riscv/rvv/base/vector-abi-1.c: Removed.
* gcc.target/riscv/rvv/base/vector-abi-2.c: Removed.
* gcc.target/riscv/rvv/base/vector-abi-3.c: Removed.
* gcc.target/riscv/rvv/base/vector-abi-4.c: Removed.
* gcc.target/riscv/rvv/base/vector-abi-5.c: Removed.
* gcc.target/riscv/rvv/base/vector-abi-6.c: Removed.
* gcc.target/riscv/rvv/base/vector-abi-7.c: Removed.
* gcc.target/riscv/rvv/base/vector-abi-8.c: Removed.

Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com>
Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com>
Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com>
Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com<mailto:yanzhang.wang@intel.com>>
9 months agoDaily bump.
GCC Administrator [Tue, 16 Jan 2024 00:18:46 +0000 (00:18 +0000)]
Daily bump.

9 months agoanalyzer: fix false +ves from -Wanalyzer-tainted-array-index with unsigned char index...
David Malcolm [Tue, 16 Jan 2024 00:01:21 +0000 (19:01 -0500)]
analyzer: fix false +ves from -Wanalyzer-tainted-array-index with unsigned char index [PR106229]

gcc/analyzer/ChangeLog:
PR analyzer/106229
* analyzer.h (compare_constants): New decl.
* constraint-manager.cc (compare_constants): Make non-static.
* sm-taint.cc: Add include "fold-const.h".
(class concrete_range): New.
(get_possible_range): New.
(index_can_be_out_of_bounds_p): New.
(region_model::check_region_for_taint): Reject
-Wanalyzer-tainted-array-index if the type of the value makes it
impossible for it to be out-of-bounds of the array.

gcc/testsuite/ChangeLog:
PR analyzer/106229
* c-c++-common/analyzer/taint-index-pr106229.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agoanalyzer: casting all zeroes should give all zeroes [PR113333]
David Malcolm [Tue, 16 Jan 2024 00:01:16 +0000 (19:01 -0500)]
analyzer: casting all zeroes should give all zeroes [PR113333]

In particular, accessing the result of *calloc (1, SZ) (if non-NULL)
should be known to be all zeroes.

gcc/analyzer/ChangeLog:
PR analyzer/113333
* region-model-manager.cc
(region_model_manager::maybe_fold_unaryop): Casting all zeroes
should give all zeroes.

gcc/testsuite/ChangeLog:
PR analyzer/113333
* c-c++-common/analyzer/calloc-1.c: Add tests.
* c-c++-common/analyzer/pr96639.c: Update expected results.
* gcc.dg/analyzer/data-model-9.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agoc++: ICE with auto in template arg [PR110065]
Marek Polacek [Mon, 15 Jan 2024 14:15:59 +0000 (09:15 -0500)]
c++: ICE with auto in template arg [PR110065]

Here we started crashing with r14-1659 because that removed the
auto checking in cp_parser_template_type_arg which seemed like
dead code.  But the attached test shows that the code can still
be reached because cp_parser_type_id_1 checks auto only when
auto_is_implicit_function_template_parm_p is on.

Then I noticed that we're still crashing in C++20, and that ICE
started with r12-4772.  So I changed the reemerged check to use
flag_concepts_ts rather than flag_concepts on the basis that
check_auto_in_tmpl_args also checks flag_concepts_ts.

PR c++/110065

gcc/cp/ChangeLog:

* parser.cc (cp_parser_template_type_arg): Add auto checking.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/auto8.C: New test.
* g++.dg/concepts/auto8a.C: New test.

9 months agoAdd myself to the DCO section
Andrew Pinski [Mon, 15 Jan 2024 22:15:15 +0000 (14:15 -0800)]
Add myself to the DCO section

It is time to add myself to DCO section for my quicinc email account.

ChangeLog:

* MAINTAINERS (DCO): Add myself.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
9 months agoc++: access of class-scope partial spec
Patrick Palka [Mon, 15 Jan 2024 22:01:33 +0000 (17:01 -0500)]
c++: access of class-scope partial spec

Since partial specializations can't be named directly, their access
when declared at class scope is irrelevant, so we shouldn't have to set
their TREE_PRIVATE / TREE_PROTECTED in maybe_new_partial_specialization
(which is used only for constrained partial specializations anyway).

This code was added by r10-4833-gcce3c9db9e6ffa for PR92078, but it
seems better to just disable the access consistency check for partial
specializations, which lets us accept the below testcase.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_check_access_in_redeclaration): Don't
check access for a partial or explicit specialization.
* pt.cc (maybe_new_partial_specialization): Don't set TREE_PRIVATE
or TREE_PROTECTED on the newly created partial specialization.

gcc/testsuite/ChangeLog:

* g++.dg/template/partial-specialization14.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
9 months agoc++: explicit inst w/ similar constrained partial specs [PR104634]
Patrick Palka [Mon, 15 Jan 2024 21:53:28 +0000 (16:53 -0500)]
c++: explicit inst w/ similar constrained partial specs [PR104634]

Here we neglect to emit the definitions of A<double>::f2 and A<double*>::f4
despite the explicit instantiations ultimately because TREE_PUBLIC isn't
set on the corresponding partial specializations, whose declarations are
created from maybe_new_partial_specialization which is responsible for
disambiguating them from the first and third partial specializations (which
have the same class-head but different constraints).  This makes grokfndecl
in turn clear TREE_PUBLIC for f2 and f4 as if they have internal linkage.

This patch fixes this by setting TREE_PUBLIC appropriately for such partial
specializations.

PR c++/104634

gcc/cp/ChangeLog:

* pt.cc (maybe_new_partial_specialization): Propagate TREE_PUBLIC
to the newly created partial specialization.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-explicit-inst6.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
9 months agoc++: non-dep array list-init w/ non-triv dtor [PR109899]
Patrick Palka [Mon, 15 Jan 2024 21:49:19 +0000 (16:49 -0500)]
c++: non-dep array list-init w/ non-triv dtor [PR109899]

The get_target_expr call added in r12-7069-g119cea98f66476 causes us
for the below testcase to call build_vec_delete in a template context,
which builds a templated destructor call and checks expr_noexcept_p for
it, which ICEs because the call has templated form.

Much of the work of build_vec_delete however is code generation and thus
will just get discarded in a template context, and that includes the
code guarded by expr_noexcept_p.  So this patch narrowly fixes this ICE
by eliding the expr_noexcept_p call when in a template context.

PR c++/109899

gcc/cp/ChangeLog:

* init.cc (build_vec_delete_1): Assume expr_noexcept_p returns
false in a template context.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-array21.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
9 months agolibstdc++: Reduce std::variant template instantiation depth
Patrick Palka [Mon, 15 Jan 2024 21:41:42 +0000 (16:41 -0500)]
libstdc++: Reduce std::variant template instantiation depth

The recursively defined constraints on _Variadic_union's user-defined
destructor (used for maintaining trivial destructibility of the variant
iff all of its alternatives are) turn out to require a template
instantiation depth of 3x the number of variants in C++20 mode, with the
instantiation stack looking like

  ...
  _Variadic_union<B, C, ...>
  std::is_trivially_destructible_v<_Variadic_union<B, C, ...>>
  _Variadic_union<A, B, C, ...>::~_Variadic_union()
  _Variadic_union<A, B, C, ...>
  ...

Ideally the template depth should be ~equal to the number of variants
(plus a constant).  Luckily it seems we don't need to compute trivial
destructibility of the alternatives at all from _Variadic_union, since
its only user _Variant_storage already has that information.  To that
end this patch removes these recursive constraints and instead passes
this information down from _Variant_storage.  After this patch, the
template instantiation depth for 87619.cc in C++20 mode is ~270 instead
of ~780.

libstdc++-v3/ChangeLog:

* include/std/variant (__detail::__variant::_Variadic_union):
Add bool __trivially_destructible template parameter.
(__detail::__variant::_Variadic_union::~_Variadic_union):
Use __trivially_destructible in constraints instead.
(__detail::__variant::_Variant_storage): Pass
__trivially_destructible value to _Variadic_union.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
9 months agolibstdc++: Implement P2836R1 changes to const_iterator
Patrick Palka [Mon, 15 Jan 2024 20:13:53 +0000 (15:13 -0500)]
libstdc++: Implement P2836R1 changes to const_iterator

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (const_iterator): Define conversion
operators as per P2836R1.
* include/bits/version.def (ranges_as_const): Update value.
* include/bits/version.h: Regenerate.
* testsuite/24_iterators/const_iterator/1.cc (test04): New test.
* testsuite/std/ranges/adaptors/as_const/1.cc: Adjust expected
value of __cpp_lib_ranges_as_const.
* testsuite/std/ranges/version_c++23.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
9 months agoRemove --save-temps from some compile tests
H.J. Lu [Mon, 15 Jan 2024 19:18:41 +0000 (11:18 -0800)]
Remove --save-temps from some compile tests

--save-temps is needed to scan assembly outputs for assemble, link and
run tests.  Not all compile tests need --save-temps unless they used to
trigger GCC bugs.  Run --save-temps from compile tests if not needed.

PR testsuite/113369
* g++.dg/abi/ref-temp1.C: Remove --save-temps.
* g++.target/i386/bfloat_cpp_typecheck.C: Likewise.
* gcc.dg/debug/dwarf2/pr111080.c: Likewise.
* gcc.dg/debug/dwarf2/pr47939-1.c: Likewise.
* gcc.dg/debug/dwarf2/pr47939-2.c: Likewise.
* gcc.dg/debug/dwarf2/pr47939-3.c: Likewise.
* gcc.dg/debug/dwarf2/pr47939-4.c: Likewise.

9 months agolibstdc++: Fix redefinition error in std::tuple [PR108822]
Jonathan Wakely [Mon, 15 Jan 2024 16:51:39 +0000 (16:51 +0000)]
libstdc++: Fix redefinition error in std::tuple [PR108822]

When using a compiler that doesn't define __cpp_conditional_explicit
there's a redefinition error for tuple::__nothrow_assignable. This is
because it's defined in different places for the pre-C++20 and C++20
implementations, which are controled by different preprocessor
conditions. For certain combinations of C++20 feature test macros it's
possible for both __nothrow_assignable definitions to be in scope.

Move the pre-C++20 __assignable and __nothrow_assignable definitions adjacent to
their use, so that only one set of definitions is visible for any given
set of feature test macros.

libstdc++-v3/ChangeLog:

PR libstdc++/108822
* include/std/tuple (__assignable, __is_nothrow_assignable):
Move pre-C++20 definitions adjacent to their use.

9 months agolibstdc++: Use variable template to fix -fconcepts-ts error [PR113366]
Jonathan Wakely [Sat, 13 Jan 2024 12:13:33 +0000 (12:13 +0000)]
libstdc++: Use variable template to fix -fconcepts-ts error [PR113366]

There's an error for -fconcepts-ts due to using a concept where a bool
NTTP is required, which is fixed by using the vraiable template that
already exists in the class scope.

This doesn't fix the problem with -fconcepts-ts as changes to the
placement of attributes is also needed.

libstdc++-v3/ChangeLog:

PR testsuite/113366
* include/std/format (basic_format_arg): Use __formattable
variable template instead of __format::__formattable_with
concept.

9 months agolibstdc++: Update tzdata to 2023d
Jonathan Wakely [Fri, 12 Jan 2024 16:57:41 +0000 (16:57 +0000)]
libstdc++: Update tzdata to 2023d

Import the new 2023d tzdata.zi file. The leapseconds file was also
updated to have a new expiry (no new leap seconds were added).

libstdc++-v3/ChangeLog:

* src/c++20/tzdata.zi: Import new file from 2023d release.
* src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds)
Update expiry date for leap seconds list.

9 months agotestsuite: Add testcase for already fixed PR [PR113048]
Jakub Jelinek [Mon, 15 Jan 2024 16:35:04 +0000 (17:35 +0100)]
testsuite: Add testcase for already fixed PR [PR113048]

The ICE on this testcase was fixed by r14-7141.

2024-01-15  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/113048
* gcc.target/i386/pr113048.c: New test.

9 months agoAVR: Document option -mskip-bug.
Georg-Johann Lay [Mon, 15 Jan 2024 16:06:58 +0000 (17:06 +0100)]
AVR: Document option -mskip-bug.

gcc/
* doc/invoke.texi (AVR Options) [-mskip-bug]: Add documentation.

9 months agoRISC-V: Add C intrinsic for Scalar Bitmanip Extension
Liao Shihua [Mon, 15 Jan 2024 08:31:35 +0000 (16:31 +0800)]
RISC-V: Add C intrinsic for Scalar Bitmanip Extension

This patch adds C intrinsics for Bitmanip Extension.
RISCV_BUILTIN_NO_PREFIX is a new riscv_builtin_description like RISCV_BUILTIN.
But it uses CODE_FOR_##INSN rather than CODE_FOR_riscv_##INSN.
Changed orcb, clmul, brev8 pattern's mode form X to GPR because orcbsi, clmul_si,
brev8_si are both included in rv32 and rv64. Test them in scalar_bitmanip_intrinsic-64-emulated.c.

gcc/ChangeLog:

* config.gcc: Include riscv_bitmanip.h.
* config/riscv/bitmanip.md: Changed mode form X to GPR in orcb and clmul pattern.
* config/riscv/crypto.md: Changed mode form X to GPR in brev8 pattern.
* config/riscv/riscv-builtins.cc (AVAIL): Adding new bitmanip builtins.
(RISCV_BUILTIN_NO_PREFIX): New helper macro.
* config/riscv/riscv-cmo.def (RISCV_BUILTIN): Add '_32'/'_64' postfix to builtins.
* config/riscv/riscv-ftypes.def (2): New ftypes.
* config/riscv/riscv-scalar-crypto.def (RISCV_BUILTIN): New builtins.
(RISCV_BUILTIN_NO_PREFIX): Likewise.
* config/riscv/riscv_bitmanip.h: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/scalar_bitmanip_intrinsic-32.c: New test.
* gcc.target/riscv/scalar_bitmanip_intrinsic-64-emulated.c: New test.
* gcc.target/riscv/scalar_bitmanip_intrinsic-64.c: New test.

9 months agoRISC-V: Add C intrinsic for Scalar Crypto Extension
Liao Shihua [Mon, 15 Jan 2024 08:31:34 +0000 (16:31 +0800)]
RISC-V: Add C intrinsic for Scalar Crypto Extension

This patch adds C intrinsics for Scalar Crypto Extension.

gcc/ChangeLog:

* config.gcc: Include riscv_crypto.h.
* config/riscv/riscv_crypto.h: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/scalar_crypto_intrinsic-32.c: New test.
* gcc.target/riscv/scalar_crypto_intrinsic-64.c: New test.

9 months agoRISC-V: Remove the Scalar Bitmanip and Crypto Built-In function testsuites
Liao Shihua [Mon, 15 Jan 2024 08:31:33 +0000 (16:31 +0800)]
RISC-V: Remove the Scalar Bitmanip and Crypto Built-In function testsuites

The serials patch provides a mapping from the RV intrinsics to the builtin names.
There are some duplicates testsuites between intrinsic and built-in function.
Remove the Scalar Bitmanip and Scalar Crypto Built-In function testsuites
that will be included in the intrinsic functions.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zbb_32_bswap-2.c: Moved to...
* gcc.target/riscv/zbb_bswap16.c: ...here.
* gcc.target/riscv/zbkb32.c: Remove __builtin_riscv_(un)zip and
zip,__builtin_riscv_brev8.
* gcc.target/riscv/zbkb64.c: Remove __builtin_riscv_brev8.
* gcc.target/riscv/zbb_32_bswap-1.c: Removed.
* gcc.target/riscv/zbb_bswap-1.c: Removed.
* gcc.target/riscv/zbb_bswap-2.c: Removed.
* gcc.target/riscv/zbbw.c: Removed.
* gcc.target/riscv/zbc32.c: Removed.
* gcc.target/riscv/zbc64.c: Removed.
* gcc.target/riscv/zbkc32.c: Removed.
* gcc.target/riscv/zbkc64.c: Removed.
* gcc.target/riscv/zbkx32.c: Removed.
* gcc.target/riscv/zbkx64.c: Removed.
* gcc.target/riscv/zknd32-2.c: Removed.
* gcc.target/riscv/zknd64-2.c: Removed.
* gcc.target/riscv/zkne32-2.c: Removed.
* gcc.target/riscv/zkne64-2.c: Removed.
* gcc.target/riscv/zknh-sha256-32.c: Removed.
* gcc.target/riscv/zknh-sha256-64.c: Removed.
* gcc.target/riscv/zknh-sha512-32.c: Removed.
* gcc.target/riscv/zknh-sha512-64.c: Removed.
* gcc.target/riscv/zksed32-2.c: Removed.
* gcc.target/riscv/zksed64-2.c: Removed.
* gcc.target/riscv/zksh32.c: Removed.
* gcc.target/riscv/zksh64.c: Removed.

9 months ago[PR113354][LRA]: Fixing LRA failure on building MIPS GCC
Vladimir N. Makarov [Mon, 15 Jan 2024 15:19:39 +0000 (10:19 -0500)]
[PR113354][LRA]: Fixing LRA failure on building MIPS GCC

My recent patch for PR112918 triggered a hidden bug in LRA on MIPS.  A
pseudo is matched to a register constraint and assigned to a hard
registers at the first constraint sub-pass but later it is matched to
X constraint.  Keeping this pseudo in the register (MD0) prevents to
use the same register for another pseudo in the insn and this results
in LRA failure.  The patch fixes this by spilling the pseudo at the
constraint subpass when the chosen alternative constraint not require
hard register anymore.

gcc/ChangeLog:

PR middle-end/113354
* lra-constraints.cc (curr_insn_transform): Spill pseudo only used
in the insn if the corresponding operand does not require hard
register anymore.

9 months agoAVR: target/107201: Make -nodevicelib work for all devices.
Georg-Johann Lay [Mon, 15 Jan 2024 12:25:59 +0000 (13:25 +0100)]
AVR: target/107201: Make -nodevicelib work for all devices.

driver-avr.cc contains a spec that discriminates bwtween cores
and devices by means of a mmcu=avr* spec pattern.  This does not
work for new devices like AVR128* which also start with mmcu=avr
like all cores do.  The patch uses a new spec function in order to
tell apart cores from devices.

gcc/
PR target/107201
* config/avr/avr.h (EXTRA_SPEC_FUNCTIONS): Add no-devlib, avr_no_devlib.
* config/avr/driver-avr.cc (avr_no_devlib): New function.
(avr_devicespecs_file): Use it to remove -nodevicelib from the
options for cores only.
* config/avr/avr-arch.h (avr_get_parch): New prototype.
* config/avr/avr-devices.cc (avr_get_parch): New function.

9 months agolibgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD
Lipeng Zhu [Fri, 5 Jan 2024 01:43:26 +0000 (20:43 -0500)]
libgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD

This patch try to fix the bug when HAVE_ATOMIC_FETCH_ADD is
not defined in dec_waiting_unlocked function. As io.h does
not include async.h, the WRLOCK and RWUNLOCK macros are
undefined.

libgfortran/ChangeLog:

* io/io.h (dec_waiting_unlocked): Use
__gthread_rwlock_wrlock/__gthread_rwlock_unlock or
__gthread_mutex_lock/__gthread_mutex_unlock functions
to replace WRLOCK and RWUNLOCK macros.

Signed-off-by: Lipeng Zhu <lipeng.zhu@intel.com>
9 months agoRISC-V: Fix regression (GCC-14 compare with GCC-13.2) of SHA256 from coremark-pro
Juzhe-Zhong [Mon, 15 Jan 2024 12:00:14 +0000 (20:00 +0800)]
RISC-V: Fix regression (GCC-14 compare with GCC-13.2) of SHA256 from coremark-pro

This patch fixes -70% performance drop from GCC-13.2 to GCC-14 with -march=rv64gcv in real hardware.

The root cause is incorrect cost model cause inefficient vectorization which makes us performance drop significantly.

So this patch does:

1. Adjust vector to scalar cost by introducing v to scalar reg move.
2. Adjust vec_construct cost since we does spend NUNITS instructions to construct the vector.

Tested on both RV32/RV64 no regression, Rebase to the trunk and commit it as it is approved by Robin.

PR target/113247

gcc/ChangeLog:

* config/riscv/riscv-protos.h (struct regmove_vector_cost): Add vector to scalar regmove.
* config/riscv/riscv-vector-costs.cc (adjust_stmt_cost): Ditto.
* config/riscv/riscv.cc (riscv_builtin_vectorization_cost): Adjust vec_construct cost.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/reduc-19.c: Adapt test.
* gcc.target/riscv/rvv/autovec/vls/reduc-20.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/reduc-21.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/pr113247-1.c: New test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113247-2.c: New test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113247-3.c: New test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113247-4.c: New test.

9 months agoRISC-V: Adjust loop len by costing 1 when NITER < VF
Juzhe-Zhong [Mon, 15 Jan 2024 01:22:40 +0000 (09:22 +0800)]
RISC-V: Adjust loop len by costing 1 when NITER < VF

Rebase in v3: Rebase to the trunk and commit it as it's approved by Robin.
Update in v2: Add dynmaic lmul test.

This patch fixes the regression between GCC 13.2.0 and trunk GCC (GCC-14)

GCC 13.2.0:

lui a5,%hi(a)
li a4,19
sb a4,%lo(a)(a5)
li a0,0
ret

Trunk GCC:

        vsetvli a5,zero,e8,mf2,ta,ma
        li      a4,-32768
        vid.v   v1
        vsetvli zero,zero,e16,m1,ta,ma
        addiw   a4,a4,104
        vmv.v.i v3,15
        lui     a1,%hi(a)
        li      a0,19
        vsetvli zero,zero,e8,mf2,ta,ma
        vadd.vi v1,v1,1
        sb      a0,%lo(a)(a1)
        vsetvli zero,zero,e16,m1,ta,ma
        vzext.vf2       v2,v1
        vmv.v.x v1,a4
        vminu.vv        v2,v2,v3
        vsrl.vv v1,v1,v2
        vslidedown.vi   v1,v1,17
        vmv.x.s a0,v1
        snez    a0,a0
        ret

The root cause we are vectorizing the codes inefficiently since we doesn't cost len when NITERS < VF.
Leverage loop control of mask targets or rs6000 fixes the regression.

Tested no regression. Ok for trunk ?

PR target/113281

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (costs::adjust_vect_cost_per_loop): New function.
(costs::finish_cost): Adjust cost for LOOP LEN with NITERS < VF.
* config/riscv/riscv-vector-costs.h: New function.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/riscv/rvv/pr113281-3.c: New test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113281-4.c: New test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113281-5.c: New test.

This page took 0.123153 seconds and 5 git commands to generate.