aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-06-22Require moves in Token constructorsTom Tromey2-31/+34
This avoids some string copies by changing the Token constructors to require any std::string argument to be transferred via std::move.
2021-06-21Use unique_ptr in TokenTom Tromey1-3/+3
Token currently uses a "std::string *". There's a comment proposing that perhaps this should be changed; but meanwhile, it's slightly cleaner to use unique_ptr rather than have Token manage the string's lifetime manually.
2021-06-21Merge #514bors[bot]2-2/+17
514: Rename tuple field names r=philberty a=tromey Tuples currently use plain integer field names in the DWARF. However, rustc prefixes these with "__", and GDB understands this convention. This patch changes gccrs to match, and adds an explanatory comment. Co-authored-by: Tom Tromey <tom@tromey.com>
2021-06-21Merge #512bors[bot]20-42/+48
512: Fix various Wformat-diag diagnostics r=philberty a=dkm Fix warnings mainly coming from ` being used instead of %< and %>. Also fixing occurences of : ``` ../../gcc/rust/lex/rust-token.cc:126:40: warning: unquoted sequence of 2 consecutive punctuation characters ‘',’ in format [-Wformat-diag] 126 | "attempted to get string for '%s', which has no string. " | ^~ ../../gcc/rust/lex/rust-token.cc:127:39: warning: spurious trailing punctuation sequence ‘.’ in format [-Wformat-diag] 127 | "returning empty string instead.", | ^ ../../gcc/rust/lex/rust-token.cc:126:37: warning: unterminated quote character ‘'’ in format [-Wformat-diag] 126 | "attempted to get string for '%s', which has no string. " | ^ ``` and various occurences of : ``` ../../gcc/rust/lex/rust-lex.cc:1326:11: warning: unquoted keyword ‘char’ in format [-Wformat-diag] 1326 | "byte char %<%c%> out of range", byte_char); | ^~~~ ``` Also using full word for arguments, integer, character, declaration, variable, floting-point instead of args, int, char, decl, var, float when applicable. Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
2021-06-21Rename tuple field namesTom Tromey2-2/+17
Tuples currently use plain integer field names in the DWARF. However, rustc prefixes these with "__", and GDB understands this convention. This patch changes gccrs to match, and adds an explanatory comment.
2021-06-21Fix various Wformat-diag diagnosticsMarc Poulhiès20-42/+48
Fix warnings mainly coming from ` being used instead of %< and %>. Also fixing occurences of : ../../gcc/rust/lex/rust-token.cc:126:40: warning: unquoted sequence of 2 consecutive punctuation characters ‘',’ in format [-Wformat-diag] 126 | "attempted to get string for '%s', which has no string. " | ^~ ../../gcc/rust/lex/rust-token.cc:127:39: warning: spurious trailing punctuation sequence ‘.’ in format [-Wformat-diag] 127 | "returning empty string instead.", | ^ ../../gcc/rust/lex/rust-token.cc:126:37: warning: unterminated quote character ‘'’ in format [-Wformat-diag] 126 | "attempted to get string for '%s', which has no string. " | ^ and various occurences of : ../../gcc/rust/lex/rust-lex.cc:1326:11: warning: unquoted keyword ‘char’ in format [-Wformat-diag] 1326 | "byte char %<%c%> out of range", byte_char); | ^~~~ Also using full word for arguments, integer, character, declaration, variable, floting-point instead of args, int, char, decl, var, float when applicable.
2021-06-21Merge #513bors[bot]4-5/+5
513: Fix up test suite buglets r=philberty a=tromey Mark Wielaard pointed out that the i8u8.rs test that I recently introduced has a bug: it checks the DW_AT_language attribute, not DW_AT_encoding. Sorry about this. This patch fixes this problem. I've verified that this notices the failure after temporarily backing out the corresponding GCC change. This patch also fixes another problem that he found, namely that it's possible for these tests to find the wrong answer, because the hex value that is checked for might be a prefix of some longer value. This patch also adds a whitespace check to avoid this potential problem. Co-authored-by: Tom Tromey <tom@tromey.com>
2021-06-20Fix up test suite bugletsTom Tromey4-5/+5
Mark Wielaard pointed out that the i8u8.rs test that I recently introduced has a bug: it checks the DW_AT_language attribute, not DW_AT_encoding. Sorry about this. This patch fixes this problem. I've verified that this notices the failure after temporarily backing out the corresponding GCC change. This patch also fixes another problem that he found, namely that it's possible for these tests to find the wrong answer, because the hex value that is checked for might be a prefix of some longer value. This patch also adds a whitespace check to avoid this potential problem.
2021-06-19Update PULL_REQUEST_TEMPLATE.mdMarc Poulhiès1-2/+1
Reverting previous change. Github is smart enough to filter out this block, but bors is not and pastes it in its commit message.
2021-06-19Merge #506 #507 #508bors[bot]4-12/+17
506: Fix: do not use object after it has been moved r=philberty a=dkm After std::move(mapping), mapping is unspecified <!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT Thank you for making Rust GCC better! If your PR fixes an issue, you can add "Fixes #issue_number" into this PR description and the git commit message. This way the issue will be automatically closed when your PR is merged. If your change addresses an issue but does not fully fix it please mark it as "Addresses #issue_number" in the git commit message. Here is a checklist to help you with your PR. - \[ ] GCC code require copyright assignment: https://gcc.gnu.org/contribute.html - \[ ] Read contributing guidlines - \[ ] `make check-rust` passes locally - \[ ] Run `clang-format` - \[ ] Added any relevant test cases to `gcc/testsuite/rust/` Note that you can skip the above if you are just opening a WIP PR in order to get feedback. --- --> 507: Add more info in HIR dump for struct r=philberty a=dkm Make struct fields more visible in dumps and add the mapping in the dump string. <!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT Thank you for making Rust GCC better! If your PR fixes an issue, you can add "Fixes #issue_number" into this PR description and the git commit message. This way the issue will be automatically closed when your PR is merged. If your change addresses an issue but does not fully fix it please mark it as "Addresses #issue_number" in the git commit message. Here is a checklist to help you with your PR. - \[ ] GCC code require copyright assignment: https://gcc.gnu.org/contribute.html - \[ ] Read contributing guidlines - \[ ] `make check-rust` passes locally - \[ ] Run `clang-format` - \[ ] Added any relevant test cases to `gcc/testsuite/rust/` Note that you can skip the above if you are just opening a WIP PR in order to get feedback. --- --> 508: Make 3 error messages slightly more informational r=philberty a=dkm Add more context to some internal error messages (ie. not intended for user) <!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT Thank you for making Rust GCC better! If your PR fixes an issue, you can add "Fixes #issue_number" into this PR description and the git commit message. This way the issue will be automatically closed when your PR is merged. If your change addresses an issue but does not fully fix it please mark it as "Addresses #issue_number" in the git commit message. Here is a checklist to help you with your PR. - \[ ] GCC code require copyright assignment: https://gcc.gnu.org/contribute.html - \[ ] Read contributing guidlines - \[ ] `make check-rust` passes locally - \[ ] Run `clang-format` - \[ ] Added any relevant test cases to `gcc/testsuite/rust/` Note that you can skip the above if you are just opening a WIP PR in order to get feedback. --- --> Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
2021-06-19Merge #505bors[bot]4-10/+40
505: DWARF for Rust primitive types r=philberty a=tromey I found a couple of small bugs in the DWARF that is emitted for primitive types. These two patches fix these. Co-authored-by: Tom Tromey <tom@tromey.com>
2021-06-19Add more info in HIR dump for structMarc Poulhiès1-2/+3
Make struct fields more visible in dumps and add the mapping in the dump string.
2021-06-19Make 3 error messages slightly more informationalMarc Poulhiès2-6/+10
Add more context to some internal error messages (ie. not intended for user)
2021-06-19Fix: do not use object after it has been movedMarc Poulhiès1-4/+4
After std::move(mapping), mapping is unspecified
2021-06-18Use DW_ATE_UTF for the Rust 'char' typeTom Tromey3-5/+27
The Rust 'char' type should use the DWARF DW_ATE_UTF encoding.
2021-06-18Use correct DWARF encoding for i8 and u8 typesTom Tromey2-5/+13
Currently, the i8 and u8 types use the DWARF character encoding, like: <1><113>: Abbrev Number: 3 (DW_TAG_base_type) <114> DW_AT_byte_size : 1 <115> DW_AT_encoding : 8 (unsigned char) <116> DW_AT_name : u8 This happens because gccrs uses signed_char_type_node and unsigned_char_type_node for i8 and u8, respectively. This patch fixes this problem by arranging to use a custom integer type instead. Another option is to clear TYPE_STRING_FLAG on these types, but it was unclear to me whether this would impact other parts of GCC.
2021-06-18Merge #504bors[bot]1-4/+2
504: Update PULL_REQUEST_TEMPLATE.md r=philberty a=dkm Make template content invisible. Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
2021-06-18Merge #503bors[bot]4-0/+52
503: Use DW_LANG_Rust in DWARF r=philberty a=tromey This changes the GCC DWARF emitterto use DW_LANG_Rust or DW_LANG_Rust_old as appropriate. Co-authored-by: Tom Tromey <tom@tromey.com>
2021-06-18Update PULL_REQUEST_TEMPLATE.mdMarc Poulhiès1-4/+2
Make template content invisible.
2021-06-18Use DW_LANG_Rust in DWARFTom Tromey4-0/+52
This changes the GCC DWARF emitterto use DW_LANG_Rust or DW_LANG_Rust_old as appropriate.
2021-06-18Merge #501bors[bot]1-0/+15
501: Update README.md for building steps on MacOS. r=philberty a=thomasyonug The path of header dir and sysroot should be specified when you configure the project. Fixed #500 Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
2021-06-18Update README.md for building steps on MacOS.Thomas Young1-0/+15
2021-06-17Merge #499bors[bot]3-10/+6
499: Cleanup warnings r=philberty a=philberty This adds the missing override specifier to as_string on identifier patterns and ensures rust_debug gains printf specifier checks. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2021-06-17Ensure rust_debug has printf specifier checksPhilip Herron2-9/+5
This adds a macro wrapper over rust_debug_loc to inject a default location so calls can maintain printf specifier checks.
2021-06-17Mark function as override to squash warningPhilip Herron1-1/+1
2021-06-17Merge #498bors[bot]13-358/+108
498: Remove HIR::TraitItemMethod, this can be represented by TraitItemFunction r=philberty a=philberty Canonicalizing the paths of the compiler to treat functions and methods the same way will ensure we avoid duplication. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2021-06-17Remove HIR::TraitItemMethod this can be represented by TraitItemFunctionPhilip Herron13-358/+108
Methods are simply functions with a self param, this simplifies the paths in HIR to avoid duplication as much as possible.
2021-06-17Merge #497bors[bot]4-13/+12
497: Avoid abort macro override the abort of std r=philberty a=thomasyonug Fixing the build issue in macos by avoiding abort macro override the abort call of std. Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
2021-06-17avoid abort macro override the abort of stdThomas Young4-13/+12
2021-06-16Merge #496bors[bot]3-2/+29
496: TraitImpl blocks have a different CanonicalPath to normal impl blocks r=philberty a=philberty TraitImpls have a canonical path which is a trait projection such as ```rust pub trait Trait { // ::a::Trait fn f(&self); // ::a::Trait::f } impl Trait for Struct { fn f(&self) {} // <::a::Struct as ::a::Trait>::f } ``` Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2021-06-16Merge #495bors[bot]28-696/+263
495: HIR cleanup r=philberty a=philberty The HIR implementation has been bootstrapped from the AST, this has lead to a lot of missed desugaring. This PR removes TraitImpls and refactors the InerhentImpls to be an ImplBlock. The class hierarchy has been simplified in tandem here such that all impl items are of the same base class. More cleanup is required but this is an isolated change that can go in now. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2021-06-16TraitImpl blocks have a different CanonicalPath to normal impl blocksPhilip Herron3-2/+29
TraitImpls have a canonical path which is a trait projection such as ```rust pub trait Trait { // ::a::Trait fn f(&self); // ::a::Trait::f } impl Trait for Struct { fn f(&self) {} // <::a::Struct as ::a::Trait>::f } ```
2021-06-16Impl blocks can have a trait referencePhilip Herron4-78/+113
This refactors Type HIR lowering to extract TypePath AST -> HIR lowering function, as Trait References are simply TypePaths.
2021-06-16Refactor HIR::InherentImpl to become HIR::ImplBlockPhilip Herron26-226/+157
This folds the abstract Impl class directly into HIR::ImplBlock since the TraitImplBlock is removed. It also refactors InherentImplItem to become simply ImplItem.
2021-06-16Cleanup HIR to canonicalize TraitImpl to be treated as an impl blockPhilip Herron17-431/+32
HIR should desugar the AST as best it can. Trait impl blocks are just impl blocks. The HIR impl block can just have an optional<TraitRef> in order to represent a trait impl block.
2021-06-15Merge #494bors[bot]6-33/+32
494: replace analysis dir with lint dir and rename liveness to marklive r=philberty a=thomasyonug replace analysis dir with lint dir and rename liveness to marklive Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
2021-06-15replace analysis dir with lint dir and rename liveness to markliveThomas Young6-33/+32
2021-06-14Merge #492 #493bors[bot]12-1038/+187
492: HIR should not contain any macros r=philberty a=philberty This removes the macros tree's from HIR. HIR should be an expanded and simplifed representation of the compilation unit. Fixes #70 493: Path resolution fixes r=philberty a=philberty In order to support Modules, we need to do path resolution properly. The old code assumed a basic A::B but this is not generic enough in order to support modules. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2021-06-14Add comment about modules and pathsPhilip Herron1-1/+22
In order to support modules the path expression will fail here since a module is not a value and does not have a TyTy type, so this is ok to continue the rest of resolution so long as there are more segments. Addresses: #432
2021-06-14Fix PathExpression type resolutionPhilip Herron1-56/+103
There are cases where the name resolver can fully resolve a path such as: ```rust struct Foo(i32); impl Foo{ fn new() { ... } } fn main() { let a; a = Foo::new(); } ``` This case does not require a PathProbe. This enhances the Path resolution to iterate each segment untill we are unable to resolve the root segment at that point we can fall back to a PathProbe and lookup any impl item that might satisfy the path instead. Addresses #432
2021-06-14Name resolver should try to resolve each segment in turnPhilip Herron1-54/+58
Name resolution tried to greedily resolve the entire CanonicalPath in one lookup which was ok for simple paths like A::B. This changes the name resolver to resolve each segment which allows the type resolution to determine the root path to be up until the segment is unresolved which will then require a PathProbe or its a failure. This will be required to support modules which extend the resolution to be much more generic than is assumed here. Addresses: #432
2021-06-11HIR should not contain any macrosPhilip Herron10-928/+5
This removes the macros tree's from HIR. HIR should be an expanded and simplifed representation of the compilation unit. Fixes #70
2021-06-07Merge #488bors[bot]1-5/+1
488: Build fixes for 32-bit ARM r=philberty a=glaubitz Fixes #483 Co-authored-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2021-06-07arm: rust: Remove unsupported baselines arm_arch8_5 and arm_arch8_6John Paul Adrian Glaubitz1-4/+0
2021-06-07arm: rust: Fix typo: hasBaseLine8MPreReqs => hasBaseline8MPreReqsJohn Paul Adrian Glaubitz1-1/+1
2021-06-05Merge #484 #485 #486bors[bot]22-84/+916
484: Trait impls and initial start of traits work r=philberty a=philberty This does not start enforcing anything to do with traits. in order to implement the traits milestone we need to be able to implement a trait first. This makes the Trait impls follow a normal impl block. As the starting point. Fixes #395 #472 485: All toplevel items must respect the prefix for their path r=philberty a=philberty The commit message has a more detailed explanation as to why. But some toplevel items were not respecting their prefix which is important for module support. 486: Use PRIx64 to print 64bit hex values in legacy_hash r=philberty a=philberty * gcc/rust/backend/rust-compile.cc (legacy_hash): lo and hi are uint64_t use PRIx64 to print them as hex values instead of %lx which is target specific. Co-authored-by: Philip Herron <philip.herron@embecosm.com> Co-authored-by: Mark Wielaard <mark@klomp.org>
2021-06-05Use PRIx64 to print 64bit hex values in legacy_hashMark Wielaard1-1/+1
* gcc/rust/backend/rust-compile.cc (legacy_hash): lo and hi are uint64_t use PRIx64 to print them as hex values instead of %lx which is target specific.
2021-06-05Merge #455bors[bot]1-1/+4
455: Update CONTRIBUTING.md r=philberty a=philberty We have been accepting patches via mail from developers following the normal GCC processes. Let's update our guidelines to reflect this. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2021-06-05Update CONTRIBUTING.mdPhilip Herron1-1/+4
We have been accepting patches via mail from developers following the normal GCC processes. Let's update our guidelines to reflect this. Co-authored-by: CohenArthur <arthur.cohen@epita.fr> Co-authored-by: Thomas Schwinge <thomas@codesourcery.com> Co-authored-by: Miguel Ojeda <ojeda@users.noreply.github.com>
2021-06-05All toplevel items must respect the prefix for their pathPhilip Herron1-8/+8
Name resolution is split into two parts, one for the toplevel canonical paths and then a second to actually drill down into new scopes for blocks for example. Consider a rust program: ```rust fn foo() -> bar { ... } struct bar(..); ``` In that example the function foo references bar which is declared later on. The compiler is partly query based in that we use ids to get away from looking up things via strings as quickly as possible. The toplevel scan follows the rust documentation over on: This assigns canonical names for all toplevel items but ignore the details like return types, or body. So the name resolver ends up with: ::foo ::bar Then we can drill down into foo and check the return type and see that ::bar is already defined. The prefix is important for the case of modules for example. This should be a toplevel scan within the same scope. Addresses: #432