Skip to content

Feature Request: Option to show "hand-written style" assembly output #412

@alloc33

Description

@alloc33

Currently cargo asm shows optimized assembly with compiler-generated symbols and linker optimizations, which can be hard to understand when learning.

Example:

#[no_mangle]
pub fn multiply_tuple(x: i32, y: i32, z: i32, t: i32) -> (i32, i32, i32, i32) {
    (x * 2, y * 3, z * 4, t * 5)
}

Current ARM64 output:

_multiply_tuple:
    ldr q0, [x0]
    adrp x9, lCPI8_0@PAGE
    ldr q1, [x9, lCPI8_0@PAGEOFF]  // What are the actual values?
    mul.4s v0, v0, v1
    str q0, [x8]
    ret

Would love to see something like:

_multiply_tuple:
    ldr q0, [x0]
    ldr q1, =constants     // or show actual values: [2, 3, 4, 5]
    mul.4s v0, v0, v1
    str q0, [x8]
    ret

constants: .word 2, 3, 4, 5

Question: Is there a flag or could we add one that:

  • Expands constant pool references to show actual values
  • Uses simpler, more readable symbols
  • Shows assembly closer to what you'd write by hand

This would be incredibly helpful for learning how Rust maps to assembly instructions.

Tried: --include-constants, --simplify, --reduce-labels but still get cryptic linker symbols.

Note: --dev mode does show readable code but adds extensive overflow checking that obscures the core algorithm, making it impractical for learning the actual instruction mapping.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions