Repository navigation
Tracking Issue for inline assembly (asm!) #72016
Copy link
Copy link
Closed
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-asm`#![feature(asm)]` (not `llvm_asm`)`#![feature(asm)]` (not `llvm_asm`)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamWG-embeddedWorking group: Embedded systemsWorking group: Embedded systemsdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
This is a tracking issue for the RFC 2873 (rust-lang/rfcs#2873).
The feature gate for the issue is #![feature(asm)].
Stabilization
Blockers: Tracking Issue for inline assembly (asm!) #72016 (comment)Blockers: Tracking Issue for inline assembly (asm!) #72016 (comment)- Stabilization report: Tracking Issue for inline assembly (
asm!) #72016 (comment)
Steps
- Implement the RFC (Implement new asm! syntax from RFC 2850 #69171)
- LLVM version check (Implement new asm! syntax from RFC 2850 #69171 (comment), min-LLVM: Can only use x86 asm ATT syntax for LLVM < 10 in new
asm!#76738) - Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
Implementation history
- Implement new asm! syntax from RFC 2850 #69171 Initial implementation
November stabilization report for FCP
November FCP checklist
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-asm`#![feature(asm)]` (not `llvm_asm`)`#![feature(asm)]` (not `llvm_asm`)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamWG-embeddedWorking group: Embedded systemsWorking group: Embedded systemsdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Type
Projects
- StatusShow more project fieldsStabilized
Activity
[-]Tracking Issue for inline assembly[/-][+]Tracking Issue for inline assembly (`asm!`)[/+]joshtriplett commentedon May 25, 2020
Note: if you'd like to report an issue in inline assembly, please report it as a separate github issue, and just link to this one. Please don't report issues in inline assembly as comments on this tracking issue.
BartMassey commentedon May 25, 2020
Definitely want the explicit import. This would also make it a bit clearer what's going on when somebody tries to compile an old-style
asm!with a newer compiler, which is going to happen a lot: you'd get an unresolved symbol rather than mysterious syntax errors.joshtriplett commentedon May 26, 2020
fix bugs involving move closures exposed by latest nightly, asm --> l…
petrochenkov commentedon Jun 8, 2020
Minor compatibility concern:
asm!supports some LLVM-isms like C style comments/* comment */(#73056 (comment)).Other backends using external assemblers may need to do some pre-processing before passing the asm text to them.
programmerjake commentedon Jun 9, 2020
GNU Assembler (IIRC defined as the official assembly dialect by the RFC), and by extension GCC, supports C-style comments too, so they are definitely not LLVM-specific.
newpavlov commentedon Jun 9, 2020
I am also in favor of explicit imports from arch modules. I would suggest going even further and introduce separate macros for each supported target (e.g.
asm_x86!,asm_arm!, etc.).joshtriplett commentedon Jun 9, 2020
Some feedback from various places in response to the blog post. (I'm skipping general expressions of awesomeness, though there have been many; I'm quoting those that have specific feedback.)
@amluto (Andy Lutomirski, prominent Linux kernel developer who works on a lot of low-level x86) at https://news.ycombinator.com/item?id=23467108 :
Several people on HN were a little confused about the backward-compatibility story here; in the future, when we talk about features that have only existed on nightly, we need to be more clear in the future about messaging around our stability policy.
Several people wondered why this used a string constant; it'd be good to explain that in documentation. And this doesn't mean the assembly isn't parsed, it means it isn't parsed by rustc (it's parsed by LLVM in the backend).
We really should have mentioned, in the blog post, that AT&T syntax was supported with
options(att_syntax), so that people didn't think they have to translate all their assembly. I've prepared an update to the blog post mentioning that.Someone mentioned preferring an "explicit clobber" syntax (like
clobber("ax")) rather than having to writeout("ax") _. I can understand that.Closely related, I think we should definitely have both "clobber all function-clobbered registers" and "clobber all general-purpose registers" options.
amluto commentedon Jun 9, 2020
I’ll add one more comment: please document what happens if you try to use not-quite-general-purpose registers as operands (clobber or otherwise). The most important case is the PIC register. GCC does not appreciate inline asm that clobbers the PIC register. IMO it should be allowed, especially for things like CPUID on x86_32.
This also includes thinks like EBP/RBP. If I’m building with frame pointers on or I do something that forces a frame pointer, is RBP available? RSP is another example — presumably it’s not available.
245 remaining items
Auto merge of rust-lang#91728 - Amanieu:stable_asm, r=joshtriplett
Merge #127
bstrie commentedon Jan 25, 2022
I see that there are some new feature flags in nightly for tracking the long tail of
asm!stabilization:asm_const,asm_experimental_arch,asm_sym, andasm_unwind. Should we make dedicated tracking issues for these?Amanieu commentedon Jan 26, 2022
I created separate tracking issues for each sub-feature:
This tracking issue can be closed now that
asm!is stable.Rollup merge of rust-lang#93337 - Amanieu:asm_tracking, r=tmiasko
Merge RoaringBitmap#127
mert-kurttutan commentedon Nov 1, 2023
Hi @nagisa ,
I am still experiencing the same issue that @marysaka mentioned (in 1.73 stable and nightly) on x86 hardware, here .
I am trying out a Rust port of some C code. The C code uses inline assembly with memory inputs which has the syntax
[x] "m" (x)where x is a variable defined in the current scope, and it is able to use variables from stack memory (instead of registers).So, it is able to use less number of registers by loading multiple variables (from stack) to the same register in different parts of the code.
In the reference for inline assembly for Rust, only input operand type is that of register operand. Do we have similar method use variable as input from memory rather than register ?
nagisa commentedon Nov 1, 2023
Next time please open a new issue, or even better, ask on Zulip, rather than commenting on one that has been closed for more than a year at this point.
As far as I know, no, memory operands are considered a future possibility by the RFC that implemented inline assembly and would require some design & implementation work.
Your next best bet is to pass in an address to the variable in a register.