asm!: options
should work multiple times, to simplify macros #73193
Closed
Description
To simplify the implementation of macros wrapping asm!
, I think options
should work if specified multiple times, with the semantic that no conflicting options may be provided. (We could also do "last option wins", but I think I'd slightly prefer "don't specify conflicting options" instead.)
This would, for instance, make it much easier to implement an asm_att!
macro that passes all its arguments to asm!
and adds options(att_syntax)
, without having to scan all the tokens it receives, look for an existing options
, and append to it if found.
Sample code that I think should work (printing 9
):
#![feature(asm)]
fn main() {
let mut i: u32 = 5;
unsafe {
asm!(
"add $4, %rax",
inout("rax") i,
options(att_syntax),
options(nostack),
);
}
println!("{}", i);
}