Skip to content

asm!: options should work multiple times, to simplify macros #73193

Closed
@joshtriplett

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);
}

Metadata

Assignees

Labels

A-inline-assemblyArea: Inline assembly (`asm!(…)`)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.F-asm`#![feature(asm)]` (not `llvm_asm`)T-langRelevant to the language team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions