-
Notifications
You must be signed in to change notification settings - Fork 173
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
Conversation
gcc/rust/backend/rust-mangle.cc
Outdated
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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.
f425f31
to
fd9d37c
Compare
bors r+ |
nit: we are now in 2021, not 2020 :)
|
@dkm oh, right. We should update all of the copyright headers throughout the project |
Build succeeded: |
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 <[email protected]>
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.