-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add llvm_asm! and deprecate asm! #2843
Conversation
I've been advocating for this rename for years, but I think this RFC is leaving too much unspoken in its current form. In particular:
Furthermore, passages from the text such as the following:
...suggest that there already exists a tentative design document for a stable inline assembly proposal. I would expect the RFC to contain a link to that document for further reading. |
Unfortunately we can't use an
That is the current plan. Here is the current RFC draft from the inline asm project group: https://github.com/rust-lang/project-inline-asm/blob/master/rfcs/0000-inline-asm.md |
I'd question whether we'd even want new syntax (that must then be supported by all rust parsers) for assembly when its use is likely to be contained to a small proportion of crates. Being a macro is also more consistent with the formatting macros the new design tries to imitate. |
One more question that I would like to see the RFC address: is it the recommendation of the ASM working group that the hypothetical EDIT: I didn't see the above link to the |
What about invocations that don't use the operand separator? Currently |
For the specific case of asm with no operands, the behavior is almost identical. The main difference is that the new |
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.
Modulo nitpick this LGTM.
text/0000-llvm-asm.md
Outdated
Deprecate the existing `asm!` macro and provide an identical one called | ||
`llvm_asm!`. The feature gate is also renamed from `asm` to `llvm_asm`. | ||
|
||
Unlike `asm!`, `llvm_asm!` is not intended to ever become stable. |
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.
This sounds a bit too strong, e.g, if we ever add a #[cfg(codegen_backed = "...")]
macro to detect the code generation backend, then using llvm_asm!
behind a #[cfg(codegen_backend = "llvm")]
might make sense.
Unlike `asm!`, `llvm_asm!` is not intended to ever become stable. | |
Unlike `asm!`, `llvm_asm!` is currently perma unstable. |
Also, if the feature is intended to be perma-unstable, at least for the time being, it might make sense to name the feature gate: feature(rustc_llvm_asm)
.
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.
Last that I checked (which was a while ago, mind), there are more objections to stabilizing the existing asm!
macro than just its coupling to LLVM. Furthermore, if the proto-RFC for stable ASM were accepted and implemented it would be sufficiently different from the existing ASM support (both syntactically and semantically) that I feel people would be reluctant to stabilize the old version, if only for the sake of consistency.
This isn't to say anything about whether a stable llvm_asm!
might be desirable; only that if it is desirable, it would likely not be served by merely stabilizing the existing ASM macro. I would expect such a discussion to be the purview of a totally separate RFC, although if the possibility isn't completely remote then that could suggest leaving the name llvm_asm!
free for future use. I do like the idea of prepending "rustc" to things which are not intended to ever be stabilized... but really the "rustc" prefix should only be used for perma-unstable compiler implementation details, and unless rustc is using asm!
(and I don't see why it would), I'd much prefer planning to remove the original asm!
sometime after a replacement has been stabilized.
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.
My position is that the new asm!
should be designed to provide substantially all of the functionality of the old one – and eventually more, such as an equivalent of C asm goto
, which is supported by LLVM but not currently exposed in Rust.* After all... well, I don't want to downplay the complexity of implementing inline assembly in the first place. But since we are planning to do that, the question is how much additional complexity would be required to get from "basic support" to "full parity". As I see it, most of that complexity comes from two sources:
-
The large amount of functionality supported by the assembler itself (e.g. directives, preprocessor)... but we're aiming to target existing assemblers, not create our own.
-
The smorgasbord of arch-dependent constraint codes supported by GCC... but LLVM only supports a small fraction of them anyway, and we only need to match LLVM's support.
So it should be feasible to reach pretty much full parity. At that point, llvm_asm!
will be redundant, and I think it's fine to plan to remove it. That said, there would be no urgent need to remove it; it should be possible to have a long deprecation period, and there might even be a case for keeping it indefinitely for experimentation purposes... but that would have to be weighed against the compiler maintenance burden.
* For anyone who hasn't been following discussions, that doesn't mean adding goto to Rust; we just need some way to express the concept of jumping out of asm blocks, which would most likely resemble a match statement.
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.
The only thing we need to unblock progress on the new inliner assembler is to rename the asm!
macro to llvm_asm!
, although as exposed here it also makes sense to rename the feature gate.
While I mostly agree with what you said, we don't really need to make any commitments right now about the future of llvm_asm!
, so we can just punt that discussion.
Personally I find the proposed new name ( |
I don't think the choice of replacement name is too important, as it's unlikely that the renamed macro will ever see stability... but if we're going to descend into bikeshedding, then I'll suggest |
The semantics of the temporary old-style macro would boil down to "whatever LLVM does", which is why it's We could clearly put that in the docs for the macro, and hopefully no one is calling unsafe code without reading the docs of what they're calling. |
I didn't even know "LLVM assembly language" was a (the?) correct term for it until just now, since everyone always calls it LLVM IR in practice. So IMO |
We could call it I personally don't find the name |
How about |
It is closer, but would be even more confusing than just EDIT: presuming we don't want to reimplement the same gcc -> llvm translation layer that clang implements. |
WIP PR: rust-lang/rust#68404 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
FCP finished a week ago, could someone with the appropriate permissions merge the RFC? |
Huzzah! The @rust-lang/lang team has decided to accept this RFC. To track further discussion, subscribe to the tracking issue here: |
Rename asm! to llvm_asm! As per rust-lang/rfcs#2843, this PR renames `asm!` to `llvm_asm!`. It also renames the compiler's internal `InlineAsm` data structures to `LlvmInlineAsm` in preparation for the new `asm!` functionality specified in rust-lang/rfcs#2850. This PR doesn't actually deprecate `asm!` yet, it just makes it redirect to `llvm_asm!`. This is necessary because we first need to update the submodules (in particular stdarch) to use `llvm_asm!`.
223: Use llvm_asm! instead of asm! r=Amanieu a=Amanieu `asm!` will be deprecated soon in preparation for the new `asm!` macro, so switch to using `llvm_asm!` instead. cc rust-lang/rfcs#2843 Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
223: Use llvm_asm! instead of asm! r=Amanieu a=Amanieu `asm!` will be deprecated soon in preparation for the new `asm!` macro, so switch to using `llvm_asm!` instead. cc rust-lang/rfcs#2843 Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
223: Use llvm_asm! instead of asm! r=Amanieu a=Amanieu `asm!` will be deprecated soon in preparation for the new `asm!` macro, so switch to using `llvm_asm!` instead. cc rust-lang/rfcs#2843 Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
…acrum Deprecate the asm! macro in favor of llvm_asm! Since we will be changing the syntax of `asm!` soon, deprecate it and encourage people to use `llvm_asm!` instead (which preserves the old syntax). This will avoid breakage when `asm!` is changed. RFC: rust-lang/rfcs#2843
Deprecate the asm! macro in favor of llvm_asm! Since we will be changing the syntax of `asm!` soon, deprecate it and encourage people to use `llvm_asm!` instead (which preserves the old syntax). This will avoid breakage when `asm!` is changed. RFC: rust-lang/rfcs#2843
446: update msp430 test deps r=therealprof a=burrbull rust-lang/rfcs#2843 r? @therealprof Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
This is the first RFC from the inline asm project group!
Rendered