Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base v0 mangling grammar #747

Merged
merged 3 commits into from
Oct 18, 2021
Merged

Conversation

CohenArthur
Copy link
Member

This PR adds base functions to deal with the v0 mangling grammar, found here.

I have a few questions regarding this implementation:
1/ Is there any existing implementation for the base62 algorithm used here? This is directly adapted from rustc's base_n module which I'm assuming is relatively standard and might already exist in the compiler. I haven't been able to find it however.
2/ gccrs cannot yet deal with unicode identifiers, as pointed out by @bjorn3 in #418. This means that a big chunk of the v0_add_identifier implementation is missing. Should it be added in this PR too?
3/ As mentionned in zulip, it would be great to be able to create unit tests for this piece of code. It would be quite easy to generate a bunch of base62 strings and ensure that the algorithm here matches with them.

@@ -154,6 +155,85 @@ v0_simple_type_prefix (const TyTy::BaseType *ty)
gcc_unreachable ();
}

// FIXME: Is this present somewhere in libbiberty already?
static std::string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think generic things like this base62 implementation method should really belong to its own file over in https://github.com/Rust-GCC/gccrs/tree/master/gcc/rust/util

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the file in f425f31. I think this implementation is used throughout rustc and with more bases, so I'm assuming the function might grow bigger. I also don't really know if this implementation is rustc-specific so for now I'm assuming it is and calling it rust-base62.h :D

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM I really like your approach to lots of these small PR's keep up the good work.

gcc/rust/util/rust-base62.cc Show resolved Hide resolved
gcc/rust/util/rust-base62.h Show resolved Hide resolved
@philberty
Copy link
Member

bors r+

@dkm
Copy link
Member

dkm commented Oct 18, 2021 via email

@CohenArthur
Copy link
Member Author

CohenArthur commented Oct 18, 2021

@dkm oh, right. We should update all of the copyright headers throughout the project

@bors
Copy link
Contributor

bors bot commented Oct 18, 2021

Build succeeded:

@bors bors bot merged commit 649e3e0 into Rust-GCC:master Oct 18, 2021
@CohenArthur CohenArthur deleted the base-v0-mangling-grammar branch October 18, 2021 09:54
bors bot added a commit that referenced this pull request Oct 22, 2021
764: Update GCC/Rust files per 'contrib/update-copyright.py --this-year' r=philberty a=tschwinge

As noted by `@dkm/@CohenArthur` in <https://github.com/Rust-GCC/gccrs/pull/747#issuecomment-945581716>/<https://github.com/Rust-GCC/gccrs/issues/747#issuecomment-945585735>.


Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants