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>
20 lines
458 B
Rust
20 lines
458 B
Rust
#![feature(prelude_import)]
|
|
#![no_std]
|
|
extern crate std;
|
|
#[prelude_import]
|
|
use ::std::prelude::rust_2015::*;
|
|
//@ pretty-mode:expanded
|
|
//@ pp-exact:asm-operand-order.pp
|
|
//@ only-x86_64
|
|
|
|
use std::arch::asm;
|
|
|
|
pub fn main() {
|
|
unsafe {
|
|
asm!("{0}", in(reg) 4, out("rax") _);
|
|
asm!("{0}", in(reg) 4, out("rax") _, options(nostack));
|
|
asm!("{0} {1}", in(reg) 4, in(reg) 5, out("rax") _);
|
|
asm!("{0}", const 5, out("rax") _);
|
|
}
|
|
}
|