[committed 012/103] gccrs: ast: dump: add emit_generic_params helper

2023-02-21 Thread arthur . cohen
From: David Faust gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): move generic params dump ... (Dump::emit_generic_params): ... here. * ast/rust-ast-dump.h (emit_generic_params): New. --- gcc/rust/ast/rust-ast-dump.cc | 30 +-

[committed 006/103] gccrs: ast: dump assignment and compound assignment expr

2023-02-21 Thread arthur . cohen
From: David Faust gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Dump assignment and compound assignment expressions. --- gcc/rust/ast/rust-ast-dump.cc | 56 +-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git

[committed 009/103] gccrs: Track DefId on ADT variants

2023-02-21 Thread arthur . cohen
From: Philip Herron We must track the DefID on variants for algebraic data types as this will allow us to enforce unique'ness on path queries relating to this. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Adjust VariantDef ctor

[committed 011/103] gccrs: Support looking up super traits for trait items

2023-02-21 Thread arthur . cohen
From: Philip Herron When supporting calls to super traits we need to allow lookups based on the super traits as specified on the TraitReferences. Fixes #1555 gcc/rust/ChangeLog: * typecheck/rust-hir-trait-ref.h (lookup_trait_item): Add lookup in super_trait.

[committed 002/103] gccrs: visibility: Rename get_public_vis_type -> get_vis_type

2023-02-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-item.h: Rename get_public_vis_type. * hir/rust-ast-lower.cc (translate_visibility): Use new name. --- gcc/rust/ast/rust-item.h | 2 +- gcc/rust/hir/rust-ast-lower.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions

[committed 008/103] gccrs: builtins: Move implementation into source file

2023-02-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * Make-lang.in: Add `rust-builtins.o` as target * backend/rust-builtins.h: Refactor to new file. * backend/rust-builtins.cc: New file. --- gcc/rust/Make-lang.in | 1 + gcc/rust/backend/rust-builtins.cc | 143

[committed 001/103] gccrs: Fix missing dead code analysis ICE on local enum definition

2023-02-21 Thread arthur . cohen
From: Philip Herron When resolving local enum's within a Block the name resolution info is not at the top of the stack so this patch introduces a new mappings class for miscellaneous name resolutions which can be used during path analaysis. Fixes #1272 gcc/rust/ChangeLog: *

[committed 004/103] gccrs: Add catch for recusive type queries

2023-02-21 Thread arthur . cohen
From: Philip Herron When we have a type query where by generic substitution occurs we can hit the case where we need to Probe the bounds of the substited item to determine whether the the bounds are compatible this can cause us to end up querying the same type recursively. Fixes #1550

[committed 003/103] gccrs: dump: Emit visibility when dumping items

2023-02-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::emit_visibility): New function. (Dump::visit): Call into `emit_visibility`. (Dump::format_function_common): Likewise. * ast/rust-ast-dump.h: Declare `emit_visibility`. --- gcc/rust/ast/rust-ast

Rust front-end update

2023-02-21 Thread arthur . cohen
Hi everyone, This series contain the majority of gccrs commits which were present on our GitHub repository but did not have a Changelog entry yet. We have cleaned, rebased, tested and fixed all of these to contain proper Changelog entries as well as DCO signoff for big contributions. All of

Re: [PATCH] rust: Fix rust-tree.cc compilation on SPARC

2023-02-20 Thread Arthur Cohen
Thanks Rainer! Ok for trunk :) Kindly, -- Arthur On 2/20/23 11:36, Rainer Orth wrote: This patch commit 27a89f84c458ae938bc3eb92ad0d594c06fc3b42 Author: Thomas Schwinge Date: Fri Feb 17 23:36:20 2023 +0100 '#include "tm_p.h"' in 'gcc/rust/backend/rust-tree.cc' broke rust bootstrap

[COMMITTED] gccrs: rustc_attrs: Allow `rustc_inherit_overflow_checks` as a builtin..

2023-01-31 Thread Arthur Cohen
..attribute. We cannot yet handle this attribute, but we should not reject it either gcc/rust/ChangeLog: * util/rust-attributes.cc: Add `rustc_inherit_overflow_checks` to list of builtin attributes. gcc/testsuite/ChangeLog: * rust/compile/rustc_attr1.rs: New test.

[COMMITTED] gccrs: bugfix: initialize slice from array in const context

2023-01-31 Thread Arthur Cohen
From: Faisal Abbas <90.abbasfai...@gmail.com> gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Turn constant item typechecking into a coercion site instead of a unify site. gcc/testsuite/ChangeLog: * rust/compile/const6.rs: New

[COMMITTED] gccrs: Add testcase to show forward declared items work via TypeAlias

2023-01-31 Thread Arthur Cohen
From: Philip Herron Fixes #1073 gcc/testsuite/ChangeLog: * rust/compile/issue-1073.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/testsuite/rust/compile/issue-1073.rs | 4 1 file changed, 4 insertions(+) create mode 100644

[COMMITTED] gccrs: Add guards against getting data from an empty vector

2023-01-31 Thread Arthur Cohen
From: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-tyctx.cc (TypeCheckContext::pop_return_type): Add guards around `std::vector.pop_back()`. (TypeCheckContext::peek_context): Likewise for `std::vector.back()`. Tested on x86_64-pc-linux-gnu, committed on master.

[COMMITTED] gccrs: Refactor TypeResolution to be a simple query based system

2023-01-31 Thread Arthur Cohen
From: Philip Herron This patch refactors the type resolution system to introduce a new interface bool query_type (HirId, TyTy::BaseType** result) This is needed in order to properly support forward declared items. Our name resolution system has two parts: 1. Toplevel scan 2. Item

[COMMITTED] gccrs: Make constexpr constructors type-checking more permissive

2023-01-31 Thread Arthur Cohen
From: Philip Herron gcc/rust/ChangeLog: * backend/rust-constexpr.cc (eval_store_expression): Remove invalid assertion on constexpr constructors. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/backend/rust-constexpr.cc | 16 1 file changed, 8

[COMMITTED] gccrs: Desugar double borrows into two HIR:BorrowExpr's

2023-01-31 Thread Arthur Cohen
From: Philip Herron We simply hit a gcc_unreachable() on double borrows but it seems reasonable to just desugar the AST into a borrow of a borrow to foo. Instead of a borrow expression with a flag to be respected. Fixes #1506 gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.h: Lower

[COMMITTED] gccrs: testsuite/rust: add a testcase for testing ...

2023-01-31 Thread Arthur Cohen
From: liushuyu ... builtin macro and decl macro mixed expansion gcc/testsuite/ChangeLog: * rust/compile/builtin_macro_recurse.rs: New test. Signed-off-by: Zixing Liu Tested on x86_64-pc-linux-gnu, committed on master. --- .../rust/compile/builtin_macro_recurse.rs | 21

[COMMITTED] gccrs: backend: Expose Bvariable class through rust-gcc header

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * rust-gcc.cc (class Bvariable): Move class to `rust-gcc.h` header. * rust-gcc.h: New file. Tested on x86_64-pc-linux-gnu, committed on master. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/rust-gcc.cc | 30 +--

[COMMITTED] gccrs: Add testcase to show forward declared items work

2023-01-31 Thread Arthur Cohen
From: Philip Herron Fixes #1006 gcc/testsuite/ChangeLog: * rust/compile/issue-1006.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/testsuite/rust/compile/issue-1006.rs | 10 ++ 1 file changed, 10 insertions(+) create mode 100644

[COMMITTED] gccrs: Add testcase for const-eval issue from rust-blog

2023-01-31 Thread Arthur Cohen
From: Philip Herron see: https://blog.rust-lang.org/2022/09/15/const-eval-safety-rule-revision.html gcc/testsuite/ChangeLog: * rust/compile/rust-const-blog-issue.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/testsuite/rust/compile/rust-const-blog-issue.rs

[COMMITTED] gccrs: Cleanup formatting of backend expression visitor

2023-01-31 Thread Arthur Cohen
From: Philip Herron gcc/rust/ChangeLog: * backend/rust-compile-expr.h: Formatting. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/backend/rust-compile-expr.h | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git

[COMMITTED] gccrs: Static Items must be const evaluated

2023-01-31 Thread Arthur Cohen
From: Philip Herron Statics like constants need to have a singular value they are not functions to be lazy evaluated. So to evaluate a block expr we can just reuse our const code to resolve this to a singular value. gcc/rust/ChangeLog: * backend/rust-compile-item.cc

[COMMITTED] gccrs: expand: eager evaluate macros inside builtin macros

2023-01-31 Thread Arthur Cohen
From: liushuyu gcc/rust/ChangeLog: * ast/rust-ast.h (class MacroInvocData): Store expander as member of the class. (class Expr): Add `is_literal` virtual method * ast/rust-expr.h: Override `is_literal` for `LiteralExpr`s. * expand/rust-macro-builtins.cc

[COMMITTED] gccrs: module lowering: Do not append null pointers as items

2023-01-31 Thread Arthur Cohen
Some module items do not need to get lowered to HIR such as `macro_rules!` definitions. Hence, module lowering should act the same as crate lowering: Only emplace back the lowered item if it is a valid pointer gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit):

[COMMITTED] gccrs: rust: Add -frust-compile-until option

2023-01-31 Thread Arthur Cohen
This option helps ensure that we do not introduce regressions on various parts of the compilation pipeline. For example, a testcase (or testsuite from the `testing` project) might pass attribute checking, expansion and lowering, but fail during typechecking. Should a change suddenly make that

[COMMITTED] gccrs: const generics: Forbid default values in Functions, Traits and Impls

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * checks/errors/rust-const-checker.cc (ConstChecker::ctx_to_str): Allow getting an error string from a specific constant context. (ConstChecker::ctx_allows_default): New function, check if a context allows default values for Const generics.

[COMMITTED] gccrs: attributes: Add #[macro_use] as builtin

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * util/rust-attributes.cc: Add `macro_use` to list of builtin attributes. gcc/testsuite/ChangeLog: * rust/compile/macro_export_1.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/util/rust-attributes.cc | 1

[COMMITTED] gccrs: Statics are a coercion site

2023-01-31 Thread Arthur Cohen
From: Philip Herron Statics can be assigned to a block expression meaning they need to behave similarly to constant items. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-toplevel.cc (TypeCheckTopLevel::visit): Make static items behave more similarly to const items. Tested

[COMMITTED] gccrs: testsuite: add loop condition execution test

2023-01-31 Thread Arthur Cohen
From: liushuyu gcc/testsuite/ChangeLog: * rust/execute/torture/loop-condition-eval.rs: New test. Signed-off-by: Zixing Liu Tested on x86_64-pc-linux-gnu, committed on master. --- .../execute/torture/loop-condition-eval.rs| 21 +++ 1 file changed, 21

[COMMITTED] gccrs: add testcase with struct to test component_ref and constructor codes..

2023-01-31 Thread Arthur Cohen
From: Faisal Abbas <90.abbasfai...@gmail.com> ..in eval_constant_expression() gcc/testsuite/ChangeLog: * rust/compile/const8.rs: New test. Signed-off-by: Faisal Abbas <90.abbasfai...@gmail.com> Tested on x86_64-pc-linux-gnu, committed on master. ---

[COMMITTED] gccrs: const generics: Make sure const generic types are visited properly

2023-01-31 Thread Arthur Cohen
...in all contexts. gcc/testsuite/ChangeLog: * rust/compile/const_generics_7.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/testsuite/rust/compile/const_generics_7.rs | 17 + 1 file changed, 17 insertions(+) create mode 100644

[COMMITTED] gccrs: Fix duplicated function generation on higher ranked trait bounds

2023-01-31 Thread Arthur Cohen
From: Philip Herron Deuplicate function elimination can fail when we compile helpers during higher ranked trait bound monomorphization. This because the TyTy::BaseType info can be lost/reset during the compilation process. This adds a second mechanism to match based on the manged names which is

[COMMITTED] gccrs: add testcase to test component_ref and constructor codes in eval_constant_expression()

2023-01-31 Thread Arthur Cohen
From: Faisal Abbas <90.abbasfai...@gmail.com> gcc/testsuite/ChangeLog: * rust/compile/const7.rs: New test. Signed-off-by: Faisal Abbas <90.abbasfai...@gmail.com> Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/testsuite/rust/compile/const7.rs | 12 1 file

[COMMITTED] gccrs: backend: correctly formulate the exit condition ...

2023-01-31 Thread Arthur Cohen
From: liushuyu ... previously the exit condition was treated the same as the loop condition (which is the inverse condition of the exit condition). Now this is corrected. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Properly formulate exit condition

[COMMITTED] gccrs: Unit structs are not concrete when they need substitutions

2023-01-31 Thread Arthur Cohen
From: Philip Herron Fixes #1518 gcc/rust/ChangeLog: * typecheck/rust-tyty.h: Fix `is_concrete` for unit types with substitutions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/typecheck/rust-tyty.h | 5 + 1 file changed, 5 insertions(+) diff --git

[COMMITTED] gccrs: Add new check for contains_associated_types

2023-01-31 Thread Arthur Cohen
From: Philip Herron We don't need to setup associated types when a trait does not contain any associated types. gcc/rust/ChangeLog: * typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::contains_associated_types): Check if a type bound predicate contains assocated types.

[COMMITTED] gccrs: remove bad assertion

2023-01-31 Thread Arthur Cohen
From: Philip Herron gcc/rust/ChangeLog: * backend/rust-tree.cc (rs_type_quals): Comment out bad assertion Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/backend/rust-tree.cc | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git

[COMMITTED] gccrs: Remove param_use_canonical_types checks ported from c++ front-end

2023-01-31 Thread Arthur Cohen
From: Philip Herron We are not fully setting TYPE_CANONICAL yet but we don't need to be as strict as the C++ front-end yet. param_use_canonical_types is a command line option we are not using either. gcc/rust/ChangeLog: * backend/rust-tree.cc (comptypes): Remove some C++ specific

[COMMITTED] gccrs: Refactor unify to hit a unify_site

2023-01-31 Thread Arthur Cohen
From: Philip Herron This allows us to enforce better error handling on unify sites gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::unify_site): Add better unification function with debug calls. * typecheck/rust-autoderef.cc

[COMMITTED] gccrs: Add extra debugging for method call expressions

2023-01-31 Thread Arthur Cohen
From: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add more calls to `rust_debug` for development. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/typecheck/rust-hir-type-check-expr.cc | 12 1

[COMMITTED] gccrs: ast: Add better assertion on AST fragments

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-ast.h: Improve assertions within ASTFragment API. Co-authored-by: philberty Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/ast/rust-ast.h | 47 ++--- 1 file changed, 39 insertions(+), 8 deletions(-)

[COMMITTED] gccrs: transcriber: Do not infinite loop if the current parsed node is an error

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (parse_many): Return early from parsing loop if we encounter an error, and emit that error in the meantime. Co-authored-by: philberty Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/expand/rust-macro-expand.cc

[COMMITTED] gccrs: ast: Only expand expressions and types if the kind is right

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-ast.h: Add assertions and accessors for fragment nodes. * expand/rust-attribute-visitor.cc (AttrVisitor::visit): Fix expansion context typo when visiting `InherentImpl` items. (AttrVisitor::maybe_expand_expr): Use new Fragment

[COMMITTED] gccrs: Create canonical process of compiling constant items

2023-01-31 Thread Arthur Cohen
From: Philip Herron In order to compile a block expression constant, the simplest way for us was to reuse what code we have and to generate an artifical function which does not get added to the translation unit. The constant then becomes a CALL_EXPR to this artifical function which we can pass

[COMMITTED] gccrs: Add missing location info to coercions

2023-01-31 Thread Arthur Cohen
From: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::TypeCheckBase): Remove constructor. (TypeCheckBase::coercion_site): Add `Location` argument to function. * typecheck/rust-hir-type-check-base.h: Use

[COMMITTED] gccrs: lint: Do not emit unused warnings for public items

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * checks/lints/rust-lint-scan-deadcode.h: Do not report public items as dead code. gcc/testsuite/ChangeLog: * rust/compile/issue-1031.rs: Remove extraneous dead code warnings. * rust/compile/issue-1289.rs: Likewise. *

[COMMITTED] gccrs: dump: Add AST debugging using the AST::Dump class

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-ast-dump.h: Add shorthand `AST::Dump::debug` function to dump an AST node on `stderr`. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/ast/rust-ast-dump.h | 16 1 file changed, 16 insertions(+) diff --git

[COMMITTED] gccrs: macros: Handle matchers properly in repetitions

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::match_matcher): Handle fragments differently based on whether or not we are currently trying to match a matcher in a repetition context. (MacroExpander::match_n_matches): Use new `in_repetition`

[COMMITTED] gccrs: backend: Add overflow checks to every arithmetic operation

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Insert overflow checks logic. (CompileExpr::array_copied_expr): Insert overflow checks logic. * backend/rust-compile-item.cc (CompileItem::visit): Insert overflow checks logic.

[COMMITTED] gccrs: parser: Parse RangeFullExpr without erroring out

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * parse/rust-parse-impl.h: Allow parsing full range expressions without erroring out. gcc/testsuite/ChangeLog: * rust/compile/parse_range.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/parse/rust-parse-impl.h

[COMMITTED] gccrs: builtins: Add add_overflow builtin and refactor class

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * backend/rust-builtins.h: Refactor builtin context class and add overflow builtins. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/backend/rust-builtins.h | 51 ++-- 1 file changed, 36 insertions(+), 15

[COMMITTED] gccrs: session-manager: Add ast-pretty-expanded dump

2023-01-31 Thread Arthur Cohen
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Allow the dump of prettified AST (Session::dump_ast_pretty): New * rust-session-manager.h: Add new output file for pretty AST dump Tested on x86_64-pc-linux-gnu, committed on master. ---

Re: [PATCH] gccrs: avoid printing to stderr in selftest::rust_flatten_list

2023-01-05 Thread Arthur Cohen
On 1/5/23 16:36, David Malcolm wrote: On Thu, 2023-01-05 at 15:44 +0100, Arthur Cohen wrote: Hi David, On 1/4/23 20:28, David Malcolm wrote: On Mon, 2023-01-02 at 13:47 +0100, Arthur Cohen wrote: Hi David, Sorry for the delayed reply! On 12/16/22 18:01, David Malcolm wrote: Successfully

Re: [PATCH] gccrs: avoid printing to stderr in selftest::rust_flatten_list

2023-01-05 Thread Arthur Cohen
Hi David, On 1/4/23 20:28, David Malcolm wrote: On Mon, 2023-01-02 at 13:47 +0100, Arthur Cohen wrote: Hi David, Sorry for the delayed reply! On 12/16/22 18:01, David Malcolm wrote: Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. OK for trunk? gcc/rust/Chang

Re: [PATCH] gccrs: add selftest-rust-gdb and selftest-rust-valgrind "make" targets

2023-01-02 Thread Arthur Cohen
n info files that should be installed. rust.install-info: OK for trunk :) Thanks again! -- Arthur Cohen Toolchain Engineer Embecosm GmbH Geschäftsführer: Jeremy Bennett Niederlassung: Nürnberg Handelsregister: HR-B 36368 www.embecosm.de Fürther Str. 27 90429 Nürnberg Tel.: 091 - 128 707 04

Re: [PATCH] gccrs: avoid printing to stderr in selftest::rust_flatten_list

2023-01-02 Thread Arthur Cohen
(!paths.empty ()); ASSERT_EQ (paths.size (), 2); ASSERT_EQ (paths[0].get_segments ()[0].as_string (), "foo"); Looks good to me. OK for trunk :) Thanks for taking the time! All the best, -- Arthur Cohen Toolchain Engineer Embecosm GmbH Geschäftsführer: Jeremy Bennett

Re: [PATCH] testsuite: Add support for Rust and Modula-2 effective target tests

2022-12-15 Thread Arthur Cohen
Hi Jakub, On 12/15/22 13:23, Jakub Jelinek wrote: Hi! This patch allows magic comments also for Rust and Modula-2 for effective target tests etc. and fixes up the Assembly entry - it is a glob, so /* Assembly can match /whatever Assembly and not just /* Assembly. Tested on x86_64-linux with

Re: [PATCH] rust: Fix up aarch64-linux bootstrap [PR106072]

2022-12-14 Thread Arthur Cohen
upstream dev branch, so in the meantime feel free to apply your patch. When I'll get to updating master, I'm expecting these kinds of tiny conflicts and we'll deal with them. Thanks a lot for working on this and sorry that my tardiness in updating has caused a duplication of efforts. All the best

Re: Rust front-end patches v4

2022-12-13 Thread Arthur Cohen
Hi Martin, On 12/13/22 14:30, Martin Liška wrote: On 12/13/22 14:26, Arthur Cohen wrote: Thank you, and congratulations, to all the contributors. We thank you!! Congratulations. Thank you :) I have one question: do you have a list of supported architectures Rust FE can support right now

Re: Rust front-end patches v4

2022-12-13 Thread Arthur Cohen
with :) We plan on removing that flag as soon as possible, but in the meantime, we think it will help not creating divide within the Rust ecosystem, as well as not waste Rust crate maintainers' time. Thanks again, Arthur On 12/13/22 14:26, Arthur Cohen wrote: Hi everyone, I have pushed

Re: Rust front-end patches v4

2022-12-13 Thread Arthur Cohen
-cases.patch Patches 08 to 46 contain 'gcc/rust/' specific changes which will be hard to review for someone not familiar with the codebase. These changes include various transformations on our HIR, or checks specific to the Rust programming language. -- Arthur Cohen Toolchain Engineer Embecosm

[committed] MAINTAINERS: Add myself as Rust front-end maintainer

2022-12-07 Thread arthur . cohen
From: Arthur Cohen Changelog: * MAINTAINERS: Add Arthur Cohen as Rust front-end maintainer. --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 55c5ef95806..d2eea049667 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -165,6 +165,7 @@ D front

Re: Rust front-end patches v4

2022-12-06 Thread Arthur Cohen
the core library, which again, we cannot compile yet in its 1.49 version. This is very much an extremely experimental compiler and will still get a lot of changes in the coming weeks and months up until the release. Adrian -- Arthur Cohen Toolchain Engineer Embecosm GmbH Geschäftsführer

[PATCH Rust front-end v4 46/46] gccrs: Add README, CONTRIBUTING and compiler logo

2022-12-06 Thread arthur . cohen
From: Philip Herron We still need to write out a documentation section, but these READMEs will help in the meantime. --- gcc/rust/CONTRIBUTING.md | 130 +++ gcc/rust/README.md | 264 +++ gcc/rust/logo.png| Bin 0 -> 70864 bytes 3

[PATCH Rust front-end v4 45/46] gccrs: Compiler proper interface kicks off the pipeline

2022-12-06 Thread arthur . cohen
From: Philip Herron This is a wrapper to get out of C land in the rust-lang.cc and into our class hierarchy for the rust front-end. We expect that the front-end only support one source file input as the expansion pass will attempt to resolve that relative pass and parse accordingly. The main

[PATCH Rust front-end v4 44/46] gccrs: Add compiler driver

2022-12-06 Thread arthur . cohen
From: Philip Herron Our compiler driver is fairly simple so far. The key piece to enforce is that a compilation unit in Rust is the whole crate, so the process for compiling Rust means pointing the compiler at the main entry point such as src/lib.rs or src/main.rs where the expansion pass takes

[PATCH Rust front-end v4 40/46] gccrs: Add GCC Rust front-end Make-lang.in

2022-12-06 Thread arthur . cohen
From: Philip Herron This is the Makefile for our front-end. --- gcc/rust/Make-lang.in | 402 ++ 1 file changed, 402 insertions(+) create mode 100644 gcc/rust/Make-lang.in diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in new file mode 100644

[PATCH Rust front-end v4 38/46] gccrs: Add HIR to GCC GENERIC lowering entry point

2022-12-06 Thread arthur . cohen
From: Philip Herron This patch contains the entry point and utilities used for the lowering of HIR nodes to `tree`s. It also contains a constant evaluator, ported over from the C++ frontend. Co-authored-by: David Faust Co-authored-by: Faisal Abbas <90.abbasfai...@gmail.com> ---

[PATCH Rust front-end v4 43/46] gccrs: Add lang.opt

2022-12-06 Thread arthur . cohen
From: Philip Herron We have some Rust-specific language options. Note that -fwrapv is enabled by default in the code. We are trying to respect options such as -Wunused-result which we get by porting over C++'s no-discard for Rust's must-use attribute, so we have enabled these by default directly

[PATCH Rust front-end v4 42/46] gccrs: Add lang-spec.h

2022-12-06 Thread arthur . cohen
From: Philip Herron This specifies the extensions of the Rust language. --- gcc/rust/lang-specs.h | 26 ++ 1 file changed, 26 insertions(+) create mode 100644 gcc/rust/lang-specs.h diff --git a/gcc/rust/lang-specs.h b/gcc/rust/lang-specs.h new file mode 100644 index

[PATCH Rust front-end v4 28/46] gccrs: Add Rust type information

2022-12-06 Thread arthur . cohen
From: Philip Herron Contains abstractions over Rust's types, used when performing the HIR's type-resolution. --- gcc/rust/typecheck/rust-tyty.cc | 2885 +++ gcc/rust/typecheck/rust-tyty.h | 2533 +++ 2 files changed, 5418 insertions(+)

[PATCH Rust front-end v4 41/46] gccrs: Add config-lang.in

2022-12-06 Thread arthur . cohen
From: Philip Herron This was a copy/paste from gccgo front-end. We do not use any of the target_libs yet, but we will need these when we support the libpanic crate. --- gcc/rust/config-lang.in | 34 ++ 1 file changed, 34 insertions(+) create mode 100644

[PATCH Rust front-end v4 39/46] gccrs: These are wrappers ported from reusing gccgo

2022-12-06 Thread arthur . cohen
From: Philip Herron The wrappers over linemap and location will eventually disappear here but served as a useful starting point for us. We have wrappers over the diagnostics system which we might be able to get rid of as well. --- gcc/rust/rust-diagnostics.cc | 244

[PATCH Rust front-end v4 34/46] gccrs: Add unused variable scan

2022-12-06 Thread arthur . cohen
From: Philip Herron This is a simple walk_tree which acts on the monomorphized code by walking the compiled translation unit of functions. --- gcc/rust/checks/lints/rust-lint-unused-var.cc | 98 +++ gcc/rust/checks/lints/rust-lint-unused-var.h | 36 +++ 2 files changed, 134

[PATCH Rust front-end v4 33/46] gccrs: Add dead code scan on HIR

2022-12-06 Thread arthur . cohen
From: Thomas Young In order to find dead code we use a depth first search and keep liveness variables, after type resolution. In this case, if a function is unused and it calls another function the 2nd function is now unused since the caller is not used etc. The algorithm is a depth first

[PATCH Rust front-end v4 32/46] gccrs: Add privacy checks

2022-12-06 Thread arthur . cohen
From: Arthur Cohen This pass is responsible for resolving the privacy of items and verifying that access to these items is performed within the limits of that privacy. By default, items in Rust are private and only public to the current module and its submodules. However, the user can annotate

[PATCH Rust front-end v4 35/46] gccrs: Add metadata output pass

2022-12-06 Thread arthur . cohen
From: Philip Herron Extern crates statements to tell the front-end to look for another library. The mechanism here is heavily inspired from gccgo, so when we compile a library for example we invoke: gccrs -g -O2 -frust-crate=mylib -c src/lib.rs -o src/mylib.o All going well this object file

[PATCH Rust front-end v4 30/46] gccrs: Add unsafe checks for Rust

2022-12-06 Thread arthur . cohen
From: Arthur Cohen The UnsafeChecker visitor verifies that unsafe actions are only performed in unsafe contexts. Otherwise, an error should be reported to the user and the compilation pipeline should be halted. These contexts, which include unsafe blocks or unsafe functions, are allowed

[PATCH Rust front-end v4 21/46] gccrs: Add port of FNV hash used during legacy symbol mangling

2022-12-06 Thread arthur . cohen
From: Philip Herron This hash was ported from the Go runtime, as we needed a hash for the legacy symbol mangling system. All symbols in Rust contain a hash of some metadata for uniqueness on generic functions. --- gcc/rust/util/fnv-hash.h | 95 1 file

[PATCH Rust front-end v4 25/46] gccrs: Add attributes checker

2022-12-06 Thread arthur . cohen
From: Arthur Cohen The attribute checker is responsible for checking the validity of various attributes including built-in ones. It is currently unfinished and will receive some modifications, as well as become the host of some existing code in the compiler which needs to be refactored. One

[PATCH Rust front-end v4 22/46] gccrs: Add Rust ABI enum helpers

2022-12-06 Thread arthur . cohen
From: Philip Herron This is a simple helper over an enum of possible ABI options in Rust. --- gcc/rust/util/rust-abi.cc | 72 +++ gcc/rust/util/rust-abi.h | 45 2 files changed, 117 insertions(+) create mode 100644

[PATCH Rust front-end v4 31/46] gccrs: Add const checker

2022-12-06 Thread arthur . cohen
From: Arthur Cohen Similarly to the unsafe checker, constant evaluation can only be performed in a few contexts and include restrictions on the Rust language. Should the user fail to uphold those conditions, errors will be reported and the compilation pipeline interrupted. These contexts

[PATCH Rust front-end v4 18/46] gccrs: Add HIR definitions and visitor framework

2022-12-06 Thread arthur . cohen
From: Philip Herron This patch implements the classes mentioned in the previous HIR patch, as well as a set of visitor frameworks used in handling that HIR. --- gcc/rust/hir/tree/rust-hir-full-decls.h | 232 + gcc/rust/hir/tree/rust-hir-full-test.cc | 5292 +++

[PATCH Rust front-end v4 24/46] gccrs: Add implementation of Optional

2022-12-06 Thread arthur . cohen
From: Arthur Cohen This adds an Optional class to improve error handling. --- gcc/rust/util/rust-optional-test.cc | 110 +++ gcc/rust/util/rust-optional.h | 278 2 files changed, 388 insertions(+) create mode 100644 gcc/rust/util/rust-optional-test.cc

[PATCH Rust front-end v4 26/46] gccrs: Add helpers mappings canonical path and lang items

2022-12-06 Thread arthur . cohen
From: Philip Herron These are various helper classes used in the compiler pipeline. --- gcc/rust/util/rust-canonical-path.h | 195 + gcc/rust/util/rust-common.h | 53 ++ gcc/rust/util/rust-hir-map.cc | 980 ++ gcc/rust/util/rust-hir-map.h

[PATCH Rust front-end v4 20/46] gccrs: Add wrapper for make_unique

2022-12-06 Thread arthur . cohen
From: Philip Herron This is a wrapper for make_unique. We can likely get rid of this, as there are other implementations available, or simply keep using the unique_ptr constructor. --- gcc/rust/util/rust-make-unique.h | 35 1 file changed, 35 insertions(+)

[PATCH Rust front-end v4 23/46] gccrs: Add Base62 implementation

2022-12-06 Thread arthur . cohen
From: Arthur Cohen Used for V0 symbol mangling scheme which is still in development. --- gcc/rust/util/rust-base62.cc | 46 gcc/rust/util/rust-base62.h | 34 ++ 2 files changed, 80 insertions(+) create mode 100644 gcc/rust/util/rust

[PATCH Rust front-end v4 09/46] gccrs: Add definitions of Rust Items in AST data structures

2022-12-06 Thread arthur . cohen
From: The Other This adds the proper definitions of our AST Item nodes. Co-authored-by: Philip Herron --- gcc/rust/ast/rust-item.h | 4382 ++ 1 file changed, 4382 insertions(+) create mode 100644 gcc/rust/ast/rust-item.h diff --git

[PATCH Rust front-end v4 12/46] gccrs: Add Lexer for Rust front-end

2022-12-06 Thread arthur . cohen
From: The Other The lexer is referred to as a ManagedTokenSource within the parser. This lexer does not currently support Unicode, but serves as a starting point to do so. Co-authored-by: Philip Herron Co-authored-by: Arthur Cohen Co-authored-by: Mark Wielaard --- gcc/rust/lex/rust

[PATCH Rust front-end v4 11/46] gccrs: Add Rust AST visitors

2022-12-06 Thread arthur . cohen
From: The Other This patch contains the basic framework of our AST visitors, as well as one aimed at pretty-printing and exporting these AST nodes. Co-authored-by: Philip Herron Co-authored-by: Arthur Cohen --- gcc/rust/ast/rust-ast-dump.cc| 1089 ++ gcc/rust

[PATCH Rust front-end v4 06/46] gccrs: Add execution test cases

2022-12-06 Thread arthur . cohen
support the main shim, so we have a C-style main function here returning zero which is not proper Rust code. Co-authored-by: Arthur Cohen Co-authored-by: Thomas Schwinge Co-authored-by: Mark Wielaard Co-authored-by: Marc Poulhiès --- .../rust/execute/torture/block_expr1.rs | 8

[PATCH Rust front-end v4 07/46] gccrs: Add gcc-check-target check-rust

2022-12-06 Thread arthur . cohen
From: Philip Herron This allows us to invoke the rust testsuite. ChangeLog: * Makefile.def: Add Rust language. * Makefile.in: Regenerate via autogen. --- Makefile.def | 1 + Makefile.in | 8 2 files changed, 9 insertions(+) diff --git a/Makefile.def b/Makefile.def

[PATCH Rust front-end v4 04/46] gccrs: Add link cases testsuite

2022-12-06 Thread arthur . cohen
From: Philip Herron This testsuite is heavily inspired from the LTO testsuite that uses a pattern where each file is compiled to an object file and finally linked together. Since Rust does not have headers/prototypes, we rely on the ordering here so that all files numbered greater than zero get

[PATCH Rust front-end v4 02/46] gccrs: Add necessary hooks for a Rust front-end testsuite

2022-12-06 Thread arthur . cohen
From: Philip Herron This copies over code from other front-end testsuites to enable testing for the rust front-end specifically. Co-authored-by: Marc Poulhiès Co-authored-by: Thomas Schwinge --- gcc/testsuite/lib/rust-dg.exp | 49 + gcc/testsuite/lib/rust.exp| 186

[PATCH Rust front-end v4 03/46] gccrs: Add Debug info testsuite

2022-12-06 Thread arthur . cohen
From: Philip Herron This testsuite is specifically about testcases which scan the asm debug info for results. Co-authored-by: Tom Tromey Co-authored-by: Mark Wielaard Co-authored-by: Marc Poulhiès --- gcc/testsuite/rust/debug/chartype.rs | 10 ++

[PATCH Rust front-end v4 01/46] Use DW_ATE_UTF for the Rust 'char' type

2022-12-06 Thread arthur . cohen
From: Tom Tromey The Rust 'char' type should use the DWARF DW_ATE_UTF encoding. Co-authored-by: Mark Wielaard Co-authored-by: Marc Poulhiès --- gcc/dwarf2out.cc | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index

Rust front-end patches v4

2022-12-06 Thread arthur . cohen
This patchset contains the fixed version of our most recent patchset. We have fixed most of the issues noted in the previous round of reviews, and are keeping some for later as they would otherwise create too many conflicts with our updated development branch. Similarly to the previous round of

Re: [PATCH Rust front-end v3 38/46] gccrs: Add HIR to GCC GENERIC lowering entry point

2022-11-29 Thread Arthur Cohen
Hi Richard, (...) + + unsigned HOST_WIDE_INT ltype_length += wi::ext (wi::to_offset (TYPE_MAX_VALUE (ltype_domain)) +- wi::to_offset (TYPE_MIN_VALUE (ltype_domain)) + 1, TYPE_MIN_VALUE is not checked to be constant, also the correct check would be to use TREE_CODE (..)

<    1   2   3   4   5   6   >