rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95k stars 12.25k forks source link

Tracking Issue for asm_goto #119364

Open nbdd0121 opened 6 months ago

nbdd0121 commented 6 months ago

The feature gate for the issue is #![feature(asm_goto)].

Summary

This feature adds a label<block> operand type to asm!.

Example:


unsafe {
    asm!(
        "jmp {}",
        label {
            println!("Jumped from asm!");
        }
    );
}

The block must have unit type.

Steps

Unresolved Questions

@rustbot labels: +A-inline-assembly +F-asm

Nilstrieb commented 6 months ago

Where is this coming from? Is there a lang MCP or anything like that?

nbdd0121 commented 6 months ago

This is outlined as a future possibility in RFC2873 which I am implementing in #119365.

tgross35 commented 1 month ago

Could we support a named label rather than being only positional? Maybe

unsafe { asm!(
    "jmp {foo}",
    label foo {
        println!("Jumped from asm!");
    }
);}

(I mean that foo would be the alias for use in the format string, not that the label in assembly would wind up as foo:)

bjorn3 commented 1 month ago
unsafe { asm!(
    "jmp {foo}",
    foo = label {
        println!("Jumped from asm!");
    }
);}

is closer to the syntax used by other operands.

tgross35 commented 1 month ago

oh, that does actually work already. Awesome