Skip to content

Specification of inline assembly #422

Open
@chorman0773

Description

@chorman0773

What are the operational semantics of the following program:

fn main(){
     asm!("mov [0], eax");
}

Specifically, how do we guarantee (and can we even guarantee) the following properties from the reference:

  1. The compiler cannot assume that the instructions in the asm are the ones that will actually end up executed.
  2. It is possible to correctly evaluate (including by causing some kind of error/ub/termination) asm in a "pure AM" implementation, such as miri.
  3. The assembler (which IMO, should be regarded as a part of the compiler) is permitted to make decisions about syntax beyond the guaranteed common subset, semantics of non-guaranteed directives, and the bytes to generate from a particular assembly statement
  4. Machine differences are permitted to change the behaviour of assembly (either from a trap to non-trap behaviour, or betwen different non-trapping behaviour)
  5. General optimizations of the assembly expressions (via it's interface) and surrounding unrelated rust code, remain possible.

@rustbot label +S-pending-design

Note: This should get an A-label, but no label suitable for inline-assembly curently exists. Could someone with maintain access add such a label and then apply it to this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-asmTopic: Related to inline assembyS-pending-designStatus: Resolving this issue requires addressing some open design questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions