Skip to content

Canonicalize LinxISA llvm-objdump indentation and column formatting for B.IOS and mixed-width instructions #72

Description

@zhoubot

Summary

Define and test a deterministic LinxISA llvm-objdump presentation contract for
mixed-width instruction streams, with B.IOS aligned consistently with
B.IOT, B.IOR, B.DIM, and the bundle header.

This is a text formatting / InstPrinter integration issue, not an instruction
address-alignment defect and not a request to change any encoding or semantics.
It is narrower than #38, which owns canonical PTO operand syntax and round-trip
semantics.

Artifact evidence

Latest checked-in artifact:

Representative mixed 16/32-bit bundle, preserving the checked-in text:

   11406: 08011181     \tBSTART.TLSU\tTLOAD, FP32
   1140a: 00048043     \tB.DIM\ta7, 0, \t->lb0
   1140e: 00049043     \tB.DIM\ta7, 0, \t->lb1
   11412: a03c         \tC.B.DIMI\t128, \t->lb2
   11414: 00051813     B.IOS\tmask=0001, ->S0<64KB>
   11418: 01418013     \tB.IOR\t[a1,x0],[]

The notation above spells tabs as \t so the defect survives Markdown
rendering. In the original file:

  • 624 instruction mnemonics start at expanded visual column 24;
  • all 15 B.IOS mnemonics start at column 23;
  • normal 32-bit lines use 5 spaces + TAB after the raw word;
  • normal 16-bit lines use 9 spaces + TAB;
  • B.IOS uses only 5 spaces, so it is shifted one column left;
  • operand columns and comma/arrow spacing also vary by mnemonic;
  • bundle descriptor lines have the same leading indentation as BSTART, so the
    hierarchy is not visually expressed.

The addresses are legal. LinxISA is a variable-length 16/32/48/64-bit stream
with instruction starts on 16-bit halfword boundaries. A 32-bit instruction at
address % 4 == 2 is not a binary alignment bug. The sequence above advances
by 4, 4, 4, 2, 4, and 4 bytes and decodes continuously from a symbol boundary.

Current HEAD status

At LLVM 9fb4f7aa89ee22541bfae288e2085ada266ffd75 (23.0.0git), a pipe-only
probe already produces aligned raw-byte and mnemonic columns:

       0: 00 08        C.BSTART.STD
       2: 13 90 07 00  B.IOS  S0, mask=1111
       6: 3c 82        C.B.DIMI  8, ->lb2
       8: 13 92 10 00  B.IOS  mask=0001, ->S1<128B>
       c: 00 00        C.BSTOP

Therefore, do not assume current HEAD still has the legacy one-column defect.
The deliverable is to lock a canonical output contract with tests and define an
explicit legacy artifact regeneration/backport path if desired.

Also do not re-decode the legacy ELF with an incompatible LLVM 23 decoder and
silently treat semantic spelling changes as formatting fixes. The checked-in
.elf.diss is the authoritative text for its Clang/LLD 15.0.4 profile. For
example, its four B.FPATR words were printed as <unknown> by an incompatible
LLVM 23 decoder; that is a version mismatch, not indentation evidence.

Expected formatting contract

For LinxISA llvm-objdump -d / -dl output:

  1. Keep address, raw machine bytes, mnemonic, and operand columns stable.
  2. Align B.IOS with B.IOT, B.IOR, B.DIM, and bundle headers.
  3. Keep 16/32/48/64-bit instructions aligned in the same columns without drift.
  4. Make tabs/spaces deterministic across terminals, GitHub rendering, and
    FileCheck input. Prefer one documented policy rather than emitter-specific
    whitespace.
  5. Keep operand punctuation and arrow spacing canonical and consistent with
    [PTO v0.58][MC] Canonicalize B.IOS/B.IOT/B.IOR assembly and disassembly #38.
  6. If bundle indentation is added, apply it deterministically to descriptor
    instructions without changing parseable assembly text.
  7. Do not change decode selection, instruction sizes, encodings, queue roles,
    PE masks, TSize semantics, or any other architecture behavior.

A display-only target could look like:

0x11406  08011181  BSTART.TLSU  TLOAD, FP32
0x1140a  00048043    B.DIM       a7, 0, ->lb0
0x1140e  00049043    B.DIM       a7, 0, ->lb1
0x11412  a03c        C.B.DIMI    128, ->lb2
0x11414  00051813    B.IOS       mask=0001, ->S0<64KB>
0x11418  01418013    B.IOR       [a1, x0], []

The exact column widths and whether bundle descriptors receive extra visual
indentation are implementation decisions, but the result must be deterministic
and tested.

Minimal reproduction

Use binaries from the same build directory and record provenance:

BIN=/path/to/llvm/build/bin
"$BIN/clang" --version
"$BIN/llvm-objdump" --version

printf '.text\n.globl bios_format_probe\nbios_format_probe:\n C.BSTART.STD\n B.IOS S0, mask=1111\n C.B.DIMI 8, ->LB2\n B.IOS mask=0001, ->S1<128B>\n C.BSTOP\n' \
  | "$BIN/llvm-mc" -triple=linx64 -filetype=obj -o - \
  | "$BIN/llvm-objdump" -d --triple=linx64 -

Add 48-bit and 64-bit forms to the test stream so the raw-byte column contract
is exercised across every supported instruction width.

Acceptance criteria

  • Add LinxISA MC/lit/FileCheck coverage for both B.IOS forms:
    • B.IOS S0, mask=0000/0001/1111;
    • B.IOS mask=..., ->S0/S255<128B..8KB>.
  • Interleave those forms with representative 16-, 32-, 48-, and 64-bit
    instructions in one object.
  • Check integrated llvm-objdump output, not only llvm-mc -show-encoding or
    mnemonic regexes.
  • Assert stable address/raw-byte/mnemonic/operand columns and deterministic
    whitespace for B.IOS, B.IOT, B.IOR, and B.DIM.
  • Preserve the canonical operand spellings and semantic-size contract tracked
    by [PTO v0.58][MC] Canonicalize B.IOS/B.IOT/B.IOR assembly and disassembly #38.
  • Demonstrate byte-identical object output before and after any formatting-only
    change.
  • Decide and document whether legacy Clang/LLD 15.0.4 artifacts are regenerated
    with their compatible decoder, receive a targeted backport, or remain frozen.
  • Never silently rewrite a legacy artifact with an incompatible decoder.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions