mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
23411ce166
Extract the inline asm operand reorder/remap logic into a dedicated helper so `print_inline_asm` stays focused on assembling the printed argument list. This keeps the reordered-template logic local to the AST pretty printer while making the main printing path easier to read. Also extend the pretty regression test with a `const` operand case. That checks that non-register operands other than `in(reg)` are also moved ahead of explicit register operands and that the remapped template indices still match the new operand order. Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
15 lines
381 B
Rust
15 lines
381 B
Rust
//@ pretty-mode:expanded
|
|
//@ pp-exact:asm-operand-order.pp
|
|
//@ only-x86_64
|
|
|
|
use std::arch::asm;
|
|
|
|
pub fn main() {
|
|
unsafe {
|
|
asm!("{val}", out("rax") _, val = in(reg) 4);
|
|
asm!("{val}", out("rax") _, val = in(reg) 4, options(nostack));
|
|
asm!("{a} {b}", out("rax") _, a = in(reg) 4, b = in(reg) 5);
|
|
asm!("{val}", out("rax") _, val = const 5);
|
|
}
|
|
}
|