-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix the inline assembly examples #24842
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
Conversation
They now use the currently working syntax.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
@bors: r+ rollup |
📌 Commit a70b2ed has been approved by |
Thank you! |
⌛ Testing commit a70b2ed with merge c13dd9d... |
@@ -100,6 +100,21 @@ fn main() { | |||
} | |||
``` | |||
|
|||
If you would like to use real operands in this position, however, | |||
you are required to put curly braces `{}` around the register that | |||
you want, and you are required to put the specific size of the |
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 don't believe this is true, e.g. #24799 (comment) .
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.
It is, I have tried it both ways.
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.
Hm, well it's definitely not always required. E.g. to add to the example above, this also works (the not
indicates that the correct register size is being used and it's not just, say, defaulting to eax
in some way: the output is fffffffffffffffd
):
#![feature(asm)]
fn main() {
let mut test: u64;
unsafe {
asm!("mov $$2, %rax
not %rax"
: "={ax}"(test));
}
println!("{:x}", test);
}
What's the other way in your example? (al
-> ax
?)
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.
Oh, or maybe just {a}
? It seems that {ax}
always works (I see no difference in the asm between al
and ax
), but just a
presumably means something different to LLVM.
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.
That must be it. Just {a}
doesn't work right now.
💔 Test failed - auto-linux-64-nopt-t |
They now use the currently working syntax. Also, I added two examples.
They now use the currently working syntax.
Also, I added two examples.