tms-c-compiler

A modern C toolchain for the DEC VT1200 / TI TMS34010, built as a small fork of upstream LLVM.

Status: M12 complete (tractable conformance gaps). Branch m12 is the repository default on both repositories; m11 is the previous snapshot (m10 before it). Repository policy: each milestone branch is promoted to the default immediately after its clean final review, and the previous default stays as a snapshot. M12 flips 17 curated rows and triages the runtime-abort class; the two-tier full suite is 1,912 = 1,635 pass / 277 skip / 0 fail / 0 crash, and every M0–M11 gate plus the M11 end-to-end build stays green. See "What M12 provides". The M12 state that reproduces the suite and Generic numbers is project eb9ca73 (docs tip 7350684) with compiler 00ddde6b55ca (docs tip 1cacd5975f0a); the M11 code state (project 7fcae6e, compiler 1d5e14d60141) is the previous milestone and the M10 code state (project 9694497, compiler eb28be2faf8d) the snapshot before that. M9.1 closes the two highest-value remaining conformance classes: vector .data initializers (exact element bytes in the raw GSPA and native TI-COFF paths) and inline-asm r/=r/&r constraints (the A-register classes). M9.2 replaces the M8 raw-offset assumption with a DWARF v5 form-aware multi-object input gate and exercises .debug_rnglists with a two-TU fixture; pre-v5 producers and unrelocated section-relative fields are refused loudly. M9.3 adds a single-DIVU 64/32 divide fast path. M9.4 records the final counts, the deferred hardware status and the M9/M10 boundary. The fresh two-tier full suite accounts for 1,912 = 1,618 pass / 294 skip / 0 fail / 0 crash (c-torture 1,692 = 1,408 / 284 / 0 / 0, c-testsuite 220 = 210 / 10 / 0 / 0); 22 rows flipped from the M9.1 classes (20 inline-asm r, plus simd-5 and pr123625-2), and the 10 loader exceptions remain explicit in scripts/tests/m7/full-suite.full-loader. The four-phase MAME divide measurement is fast 88, slow 3,302, wide 221 and div32 120 frames: 37.5× (fast) and 14.9× (wide) versus the loop, and 1.8× for div32 versus the two-DIVU wide phase, status 600D600D, checksums 000000011E6F9AB4/00000000007512AE/ F56810CFEDA9D656/00002C61C63842EE. The shipped tiers report lit 132/132 (128 CodeGen + 4 MC) plus clang 10 (8 CodeGen + 1 Driver + 1 Sema) = 142, M5 c-torture 79/79 at -O0 and -O2, M6 c-torture 79 at -O0 plus the 20-test bounded -O2 subset, shipped c-testsuite 48 pass / 172 skip / 220, and Generic 197 = 151 pass / 46 unsupported / 0 crash. The serial M0–M8 gate list is 58 invocations across 54 distinct gate scripts, all passing; the real VT1200 run remains DEFERRED (VT1200_HOST is unset; scripts/tests/m7/hardware.sh prints HARDWARE: DEFERRED and passes on the MAME-equivalent acceptance). m12 is the repository default; m11 is the previous snapshot, with m10 before it.

M7.3 widened the validated VT1200 Xlib surface, added real stderr capture to the conformance runtime, and shipped the real-hardware marker harness. The v2.2 table has 36 validated entries, including XMapSubwindows, XChangeWindowAttributes, XConfigureWindow, XInternAtom, XChangeProperty and XChangeGC; the xmore client exercises them in MAME with zero X errors. The conformance shim has a second 16 KiB stderr stream (01B30000, length 01B00060) with fprintf/vfprintf/fputs/fputc/fwrite, compared exactly by the runner. scripts/tests/m7/hardware.sh links a C-only marker client at the proven hardware origins with tms-link (GSPLNK oracle), checks the same marker cells in MAME, and runs hostload.py --marker only when VT1200_HOST is set; the real-unit run is DEFERRED and the gate prints HARDWARE: DEFERRED without a unit. M7.3 changed no compiler code or TI ABI, kept the default branch, and changed no M2–M7.2 gate outcome or count (the M4/M5 harness fixtures and the M5 JR byte constant were updated for the six new stubs). M7.2 completed the native object path. llc -march=tms34010 -filetype=obj emits optional .cinit init records and DWARF .debug_* sections in TI-COFF, and the new tools/tms-link links those objects without GSPLNK while GSPLNK remains the permanent byte/symbol oracle. Public names longer than 31 characters resolve on the object path (the asm path keeps GSPA's truncation), and -g is object-only: the GSPA .s path never gains .loc/.debug_*. M7.2 did not change the TI ABI, the language surface, the default branch or the M2–M7.1 gates. The TI language surface is complete for the M6 scope, and M7.1 closed the three M6 correctness/ABI residuals: the -O2 bit-pointer over-scale (an opaque @__tms_bitptr(i32, ptr) barrier carried through opt, a post-opt scale of optimizer-created byte GEPs only, --lower-bitptr and a final InstCombine make the default -O2 p += n correct), the sub-byte array/nested-record stride (a default-on -Wtms34010-subbyte-stride diagnostic; the byte-rounded layout is unchanged), and the .data initializer gap (i64 LSW-first, i24/i40/i48/i56, structs, unions, bitfield storage, arrays and aggregate zero, in both raw GSPA and native TI-COFF modes). The M6 language surface is unchanged: long long, float and double arguments/returns/arithmetic, general va_list varargs, packed bitfields, aggregates by value and return, the linked 1990 flib.lib/rts.lib runtime with the printf/sprintf shim, and the expanded conformance tier. llc -march=tms34010 -filetype=obj emits TI-COFF objects that tms-link (or GSPLNK 2.00, the permanent oracle) links and the existing VT1200 loader runs; the M4 -filetype=asm → GSPA/GSPLNK path remains the oracle and fallback. The TI ABI is unchanged: arguments are pushed on the program stack, scalar results are returned in A8, float/double/i64/aggregate results use the caller-allocated hidden slot with RETS 2, frames use A13/A14/A15, and functions end in RETS 2 (RETS 0 without arguments). M5 added the native object path, the full MC encoder/assembler/disassembler, JR/branch relaxation, MMTM/MMFM register-list saves, dynamic alloca, byval, narrow returns, target memcpy/memset, the switch-table GEP fix and the first pinned external conformance tier. M6 adds float/double soft-float via GSP flib calls, long long with an inline divide/remainder loop, va_list/va_start/va_arg/va_copy, TI packed bitfields, aggregate returns through the hidden slot (explicit sret is rejected), the linked flib/rts runtime, and the 79-test c-torture / 48-test c-testsuite curated tiers. M7.2 did not change the default branch or the ABI. M7.3 added the wider Xlib surface, stderr capture and the deferred hardware harness. M7.4 added the full-corpus accounting, the i64 divide/remainder fast path and the conformance-loader COFF repair. M8 then delivered native .lib linking, multi-TU DWARF merging, the bit-op/64-32 divide work and the final M8/M9 boundary; the hardware run is still deferred.

M7.1 correctness. The M6 -O2 p += n over-scale is fixed: a source p += n derived pointer is correct at the default -O2, and the conformance shim's memmove workaround is gone (the natural d += n backward copy is gated at -O2 in MAME). The final InstCombine restores the M0 pointer shapes: int_diff returns 8 and int_diff4 returns 32, and late carries the 24-bit addend (never 192).

Branch m12 is the repository default (M12); m11 is the previous snapshot (M11), and m10 is the one before that (M10), m9 the snapshot (M9.4), m8 the one before that, m7 the one before that, m6 before that, m5 before that, m4 before that, m3 the M3 snapshot, m2 the M2 tip and m1 the reproducible M1 snapshot.

Repositories

  • Compiler fork: https://git.wut.ee/opencode.siil.arti.ee/llvm-tms34010 (branch m11) — the full buildable LLVM 23.1.5 tree with the TMS34010 target, clang bit-address changes, the M2–M9 backend, the M10 native pipeline (ToolChain + bit-address passes) and the M11 sysroot discovery and tms-link link job. Branch m12 is the repository default; m11 is the previous snapshot (M11) and m10 the one before that (M10). Branch m8 is before that, m7 is before that, m6 is before that, m5 is before that, m4 is before that, branch m3 is before that, branch m2 is the M2 tip and branch tms34010 is the M1 tip and keeps the original M1 backend and suite.
  • This project: https://git.wut.ee/opencode.siil.arti.ee/tms-c-compiler (branch m11) — plans/specs, VT1200 integration tooling, tms-bitaddr, tms-clang, the sdk/ sysroot sources and scripts/tms-sdk, symbols, the M2–M11 harnesses and the conformance tier. Branch m12 is the repository default; m11 is the previous snapshot (M11) and m10 the one before that (M10). Branch m8 is before that, m7 is before that, m6 is before that, m5 is before that, m4 is before that, m3 is before that, m2 is the M2 snapshot and m1 is the reproducible M1 snapshot, including the retired M1 harness.

The compiler fork is the canonical source for all target code. patches/llvm here is a frozen M0 mirror used by the default upstream+patches build; M2–M9 do not change it; M10/M11/M12 extend patches/llvm/0005-tms34010-toolchain.patch (the ToolChain, its registration, its sysroot discovery and the link job; M12 adds the st GCC register name and the inline-asm operand tests).

What M10 provides

M10 is Phase 2: the native clang pipeline. Native clang --target=tms34010 -c is now semantically correct with no flags and no wrapper — the TMS34010 target owns both the bit-address transform and its compile defaults. Full target rules are in build/llvm-clean/TMS34010.md ("M10 state"); the binding design is docs/superpowers/specs/2026-11-17-tms34010-phase-2-3-design.md.

  • The ToolChain and its defaults. A dedicated clang/lib/Driver/ToolChains/TMS34010.{h,cpp} (a BareMetal subclass) is registered in clang/lib/Driver/CMakeLists.txt and Driver.cpp, so tms34010-unknown-none and plain --target=tms34010 resolve to it. It supplies this target's compile defaults: -ffreestanding, -fno-builtin, -mllvm -replexitval=never, -disable-O0-optnone, and no system include directories (-I still works; builtin headers stay reachable via -resource-dir). It is exported as patches/llvm/0005-tms34010-toolchain.patch and has no link job yet — -c/-S are the M10 surface; M11 extends the same file with the link job.
  • The pipeline. TMS34010TargetMachine::registerPassBuilderCallbacks registers the bit-address passes: at pipeline start the opaque @__tms_bitptr(i32, ptr) barrier runs (and, at -O0, the lowering immediately after it); at optimizer-last the scale → lower → final InstCombine runs (gated to Level != O0). A "tms.bitaddr" module flag (absent → 1 → 2) makes the barrier idempotent, and a legacy lowering pass in TMS34010PassConfig::addISelPrepare is the codegen safety net for IR that still carries barrier calls. llc keeps its M9 IR contract (it builds no new-PM pipeline) and opt builds no TargetMachine, so both are unaffected.
  • -O0 byte identity. scripts/tests/m10/equivalence.sh proves native clang --target=tms34010 -O0 [-g] -c objects are byte-identical to the frozen M9 oracle (legacy-tms-clang) across the whole 23-file corpus (46/46 at -O0 and -O0 -g); an -O2 asm-shape phase pins the aggregate-return and switch shapes. scripts/tests/m10/bitaddr-idempotent.sh proves the flag-2 re-entry path.
  • tms-clang becomes a flag mapper. scripts/tms-clang keeps its argument parser and the TMS_CLANG/TMS_CLANG_EXTRA_FLAGS overrides, then execs clang --target=tms34010 with -O0/-O2, -g, -I and -S -emit-llvm -o OUT.ll. No tms-bitaddr, no opt, no awk static-variadic guard. The four gates that traced its internals (m4/mul.sh, m5/jr.sh, m5/policy.sh, m3/run.sh) now assert the same invariants at the driver seam.
  • Gate edits. m5/jr.sh re-pins the linked .text size: native -O2 initially tightened it to 850 bytes, but that size was measured while the -O2 path still misread bit offsets as byte offsets (DAGCombiner re-chained a memcpy source load and the f64 MSW store past the stores producing them) and folded f32/f64 constants to IEEE bits; the debug-cycle correctness fixes (below) cost instructions and restore the M9 legacy value of 910 bytes, which m5/jr.sh now pins. The JR count (14) and the zero-displacement JA count are unchanged.
  • Breadth proof. Because tms-clang is the thin wrapper, the fresh full-suite run (build/m10-bare) now compiles every row through native clang — so it is the breadth proof for the new pipeline, not just a regression check. The total is unchanged at 1,912 = 1,618 pass / 294 skip / 0 fail / 0 crash.
  • The -O2 bit-address aliasing fix — three causes. The sweep found two -O2-only miscompiles, and fixing them uncovered a third:
    1. f32/f64 constant folding. -O2 folded bitcast(float C to i32) / IPSCCP results to IEEE bits before the late float-constant pass could emit the GSP encodings — fixed by protecting f32/f64 constants before the optimizer (TMS34010LowerFloatConstantsPass at pipeline start for -O1+ loads them from GSP globals as volatile).
    2. BaseIndexOffset byte misread. DAGCombiner's BaseIndexOffset read bit addresses as byte offsets and reordered memory operations (the aggregate marker-1 byte load and the f64 MSW float markers) — fixed by a TMS34010ISD::BITADDR node (selected straight to ADDI) at the target-computed offset sites, so BaseIndexOffset falls back to the byte-accurate MachinePointerInfo.
    3. The underlying class. Closing those exposed it: any address built as inttoptr(add(ptrtoint, bits)) folds to a plain ISD::ADD on this 32-bit-pointer target, so ordinary source pointer arithmetic was still miscompiled at -O2 (reproducer: p[0]=v; p[1]=w; ((char*)p)[5]=0x7f; stored the byte before the word store). Fixed by a target intrinsic llvm.tms34010.bitaddr that lowers to BITADDR, now used by every runtime pointer-offset emitter: the barrier lowering, the aggregate/i64/narrow-mem leaves, and both GEP-scaling passes. Regression tests: m10-bitaddr-chain-i64.ll, bitaddr-chain-o2.c. A zero offset stays the base itself, so -O0 objects are unchanged. scripts/m3/run.sh compiles branch with -fno-inline at -O2 (not -O0, which would change the pinned condition codes) so m3/dis-roundtrip.sh keeps its _sumto/_max2/_lt calls. m6/float.sh, m6/aggregate.sh, m6/i64.sh, m6/bitfield.sh, m6/varargs.sh and m6/runtime.sh now pass at both -O0 and -O2.
  • Residual (documented, not reachable at -O2). scaleConstantGep emits a compile-time ConstantExpr address, which cannot hold a call; it folds to a GlobalAddress+offset, so no runtime ADD exists to mis-decompose.
  • Boundary. M10 is complete: native -O0 is byte-identical to M9 and -O2 is correct across the shipped gates after the debug-cycle fixes above. M11 (Phase 3) makes the flow fully conventional: a committed CRT (crt0.o via llc — the M11 design corrected llvm-mc, which emits ELF), headers (sdk/include), a library (libtms.a), a sysroot, and a tms-link link job, so clang --target=tms34010 hello.c -o hello works with no wrapper and no project variables.

What M12 provides

M12 is the tractable conformance-gap milestone. The binding design is docs/superpowers/specs/2026-11-19-tms34010-m12-tractable-gaps-design.md. It flips 17 curated rows across five backend/driver classes and delivers the runtime-abort triage that M13 plans from; it changes no TI ABI rule, no language semantics and no default branch. m12 is the milestone branch on both repositories; promotion is pending the controller's review.

  • 17 flips, row by row. Every row below was curated in scripts/tests/m7/full-suite.skip and is now removed and passing:

    class rows fix
    inline-asm m/g memory operands pr103376, pr40022, pr40657, pr56866, pr65053-2, pr68328, pr81588, pr82954, pr85156, pr94130 SelectInlineAsmMemoryOperand over the load/store addressing modes
    computed goto (blockaddress) 920501-3, 990208-1 jump Rd + ISD::BRIND + section-relative block address
    level-0 return/frame address 20030811-1, frame-address, pr17377 prologue capture into an A13 slot; frameaddress(0) = A13
    dynamic alloca 20070824-1 scale the folded constant and the variable size in bits
    instrumentation flag eeprof-1 forward -finstrument-functions from dg-options (the one-flag/one-condition harness fix)

    Accounting: pass 1,618 + 17 = 1,635, skip 294 − 17 = 277 (c-torture 1,692 = 1,425 pass / 267 skip, c-testsuite 210 / 10 unchanged), 0 fail / 0 crash. The eleventh inline-asm row, stkalign, is not a flip: its memory operand now selects, but it aborts on its own __alignof__(s) == 64 premise under the packed-struct ABI, so it was re-reasoned as runtime-abort-alignment (M13's alignment class). 990208-1 passes at -O0 (the gated mode); its -O2 run aborts in its own #ifdef __OPTIMIZE__ branch because generic LLVM refuses to inline a function whose block address is taken (InlineCost.cpp), and host clang behaves identically.

  • Inline-asm memory operands, and the ST/o/V decisions. TMS34010DAGToDAGISel::SelectInlineAsmMemoryOperand now matches the reachable memory forms (the same addressing-mode selection as loads and stores) for m and g, with a named error for an unmatchable operand. o is accepted only in the non-post-increment, non-negative-displacement form; V (non-offsettable memory) stays loud because this LLVM has no InlineAsm::ConstraintCode entry for it, so it cannot be honoured — SelectionDAGBuilder asserts before the target hook, and adding the entry is a core LLVM change outside M12's target-only charter. "st" is added to clang's GCC register list, so ~{st} names the status register as a clobber; ST remains outside every register class and every inline-asm operand class, so ST as a value operand is still rejected and no save/restore is emitted for ~{st}. A template that names the operand now prints *An/*An(disp) (PrintAsmMemoryOperand); the corpus rows use empty templates, so this is pinned by the extended m12-inline-asm-mem-forms.ll check. The M5 Generic compile sweep moves from 151 pass / 46 unsupported to 152 / 45: addr-label flips because blockaddress now lowers, while the two inline-asm memory rows stay unsupported through the parser rather than being classified as crashes. Three manifest rows were re-pinned to the parser diagnostic (2007-04-27-LargeMemObject, 2007-12-17-InvokeAsm, 2008-02-20-MatchingMem).

  • jump Rd and computed goto. The ISA's indirect jump (opcode 0x0160, from the vendor ONEREG table) is implemented end to end: instruction definition, MC encoding, asm parser, printer and disassembler. ISD::BRIND lowers to it (a fresh ARegs register for a dynamic target, MOVI plus jump for a constant), and ISD::BlockAddress lowers through the normal MOVI/R-RELLONG relocation path to a section-relative bit address — no absolute load address. Both corpus rows pass at -O0; m12-jump-reg.s pins jump A0 = [0x60, 0x01] and jump B3 = [0x73, 0x01].

  • Level-0 return and frame address. The return word lives on the system stack, not at an A13 slot. A first SP-relative use-site load was reproduced sinking into the caller's saved-STK push window at -O1/-O2 (it read the saved A13); the final lowering captures the word once in the prologue, immediately after the FP/callee-save pushes, from SP + NumSaved*32 (measured from the post-MMTM pointer) into a normal A13-relative stack object. The two capture-scratch pushes move SP, so the shipped sequence forms SP + (NumSaved + 2)*32: PUSH32 A0; PUSH32 A1; MOVE A15, A0; ADDI A0, A0, (1 + CSI.size() + 2)*32; MOVE32Load A0, A0; MOVEFP A1; [ADDI slotoff, A1;] MOVE32Store A0, A1; POP32 A1; POP32 A0. Every llvm.returnaddress(0) use loads that stable A13 slot. The prologue store and use-site loads carry matching fixed-stack MMOs so post-RA scheduling cannot reorder them. llvm.frameaddress(0) is A13. Levels above 0 remain a named fatal error stating the intrinsic and level, so 20010122-1 (level 1) and 20030323-1 (level 100) stay curated.

  • Dynamic alloca. The failure was not a missing byte→bit scale: M5 already emitted it. 20070824-1's __builtin_alloca sits in a non-entry block with a constant count, so the DAG constant-folds the SHL 3 and the M8-era shape assertion (which required the shift to survive) aborted. The lowering now scales the constant and variable forms explicitly and asserts nothing about the node shape; m12-dynalloca.ll pins the folded 64-bit advance and a variable byte-count case at both -O0 and -O2.

  • Abort triage (M13 input). A harness (scripts/tests/m12/abort-triage.sh, started with --work build/m12-abort-triage) discovers the abort set from the curated table, re-runs each row uncurated at -O0 and -O2 through the standard runner, and records the runner result, status word, completion magic and cause. Headline: 54 rows (52 aborts + 2 wrong results), 108 runs in 133 s, no timeouts and no runner crashes, grouped into 11 causes — aggregate varargs 13, vectors 12, 64-bit/packed bitfields 7, endianness macro + SSO 5, packed/over-alignment 4, pointer↔int 4, signed zero 3, float↔int 2, RTS/shim 2, function-instrumentation 1, freestanding builtins 1. The one qualifying one-flag/one-condition fix (-finstrument-functions forwarding, eeprof-1) is taken in M12; the BigEndian = false single change is explicitly rejected because it regresses 20230630-2/-4 once they select scalar_storage_order("big-endian"). The report, its per-file table and its M13 ordering are docs/superpowers/research/2026-11-19-tms34010-abort-triage.md; the representative probe sources and logs are committed under scripts/tests/m12/probes/. M13's suggested order is varargs → vectors → wide bitfields → endianness+SSO → alignment, then the float groups.

  • Permanently out of scope. Nested functions (30 rows; clang frontend function definition is not allowed here), VLA-in-struct (9; fields must have a constant size … will never be supported), dialect strictness (8; -Wint-conversion/-Wparen/K&R errors under the pinned language mode) and the loader/region timeouts (37; the 45 KiB program / 64 KiB RAM image budget or the 1000-frame loader window) are not compiler gaps for this milestone and stay curated. Pointer↔int model (4), RTS/shim runtime (2) and freestanding builtins (1) from the triage are likewise out: they are target-model/runtime policy, not lowering defects.

  • The M12/M13 boundary. M13 owns the ABI shapes (sret, aggregate/variadic/float arguments and returns) and the triaged abort causes in the order above; M14 is performance plus the real VT1200 run (still HARDWARE: DEFERRED); M15 is optional hosted I/O. Every M0–M11 gate and the M11 end-to-end build stay green, and the four-phase divide measurement is unchanged.

What M11 provides

M11 is Phase 3: the conventional toolchain. After one scripts/tms-sdk, clang --target=tms34010 hello.c -o hello links a loader-valid TI-COFF image through tms-link and scripts/tms-run hello prints hello — no wrapper, no project variables, no M4_*/TMS_* environment. The binding design is docs/superpowers/specs/2026-11-18-tms34010-m11-conventional-toolchain-design.md.

  • The sysroot and scripts/tms-sdk. scripts/tms-sdk [--sysroot DIR] builds sdk/crt0.ll with llc -march=tms34010 -filetype=obj and sdk/{shim,heap}.c with clang --target=tms34010 -O2 -c + llvm-ar rcsD into libtms.a, then installs <sysroot>/{include,lib,bin}: the 10 headers (assert, limits, math, stdarg, stdbool, stddef, stdint, stdio, stdlib, string — there is no ctype.h), lib/{crt0.o,libtms.a,flib.lib, rts.lib} and the tms-link/tmscoff.py pair. The default sysroot is <clang -print-resource-dir>/tms34010-unknown-none; installing is idempotent.
  • python3 is a link-time dependency. The installed tms-link is a Python program; the driver pre-flights python3 and reports its absence by name and tells the user to install python3 (the missing-sysroot and missing-linker diagnostics point at scripts/tms-sdk).
  • The CRT is IR, built by llc. sdk/crt0.ll is a naked _start with inline asm blocks. llvm-mc emits ELF for this triple (and the generic COFF path refuses a non-Windows triple), so the target's TI-COFF writer is reachable only through CodeGen — hence llc -filetype=obj. The rewrite preserves the runtime contract (the setf state, the 4 KiB _cstack, the {"conformance", NULL} argv, the result block at 01B00000/40/60, the output buffers 01B10000/01B30000, and _start).
  • The link job. The TMS34010Linker invokes <sysroot>/bin/tms-link (or --tms-linker=PATH) with --entry _start --text 018A0000 --bss 01A00000 --prog-len 40000h --ram-len 80000h, a default --map, -g → --keep-debug, -Wl, passthrough (-Map=/-Map,<file> mapped to --map=<file>), the CRT, the user objects, libtms.a flib.lib rts.lib, -L <sysroot>/lib and the user -L/-l. The emitted image passes scripts/m4/coff-check.py unaided: M11 moved the .bss rounding into tms-link, so coff-check.py --repair is no longer on the production path (it survives only for the legacy GSPLNK harness).
  • Link-reduction knobs. -nostartfiles drops crt0.o, -nodefaultlibs drops libtms/flib/rts, -nostdlib implies both; -l tms links libtms.a once per request (a repeated -l tms links the archive again).
  • tms-cc stays as a compatibility alias (it adds --run and the M4 defaults); new documentation points at clang --target=tms34010.
  • Known limitations. A bare -Wl,-Map sets an explicit-map request but names no file, so it suppresses the default map and produces none (use -Wl,-Map=<file>); a repeated -l tms under -nodefaultlibs duplicates the archive.
  • The M11/M12 boundary was M12 — conformance classes (inline-asm memory constraints, the ST clobber, blockaddress, the level-0 frame intrinsics, dynamic alloca, the runtime-abort triage) per the roadmap; see "What M12 provides" for the current M12/M13 boundary.

The Task 6 sweep's one stale gate check was fixed in 7fcae6e: m7/debug.sh now asserts the llvm.tms34010.bitaddr spelling (the M10 aliasing fix replaced the add i32 lowering) and still requires !dbg on the barrier instructions.

What M9 provides

M9 is the conformance-class, debug-depth and performance milestone. It fixes vector .data and inline-asm r (the two highest-value remaining full-suite classes), closes the M8 future-producer and .debug_rnglists caveats, adds a measured single-DIVU 64/32 divide fast path, and records the M9/M10 boundary. It changes no TI ABI rule or language semantics. Full target rules are in build/llvm-clean/TMS34010.md ("M9 state").

  • M9.1 — vector .data and inline-asm r. Fixed vectors of i8/i16/i32/i64/f32/f64 elements emit their exact little-endian bytes when each element's allocation stride equals its store size and stride * count is the allocation size, in both the raw GSPA and native TI-COFF paths; arrays/records of vectors recurse. A vector zeroinitializer emits its store size and the caller/trailer adds the allocation padding once, so a padded <3 x i32> zero global is exactly its 16-byte allocation and a record member stays at its DataLayout offset; non-zero padded/packed shapes are loud (vector elements do not fill the allocation). Inline asm r/=r/&r maps to the allocatable ARegs class for i8/i16/i32/f32, named A-register clobbers are modelled, and register/immediate operands print through PrintAsmOperand (A15 as SP). t and the memory constraints m/o/V fail with TMS34010-named diagnostics; i64 r (no allocatable even/odd pair) fails loudly with the generic allocator message (a target-named message is M10). The lit suite is 129/129 (125 CodeGen + 4 MC; the nine new m9-* tests are m9-vector-data, -padded-zero, two vector rejects, m9-inline-asm, two inline-asm rejects, the memory reject and m9-i64div-64-32). The fresh full-suite re-run flips 22 rows: 20 inline-asm r tests (20001009-2, 20020107-1, 960312-1, 990130-1, pr108498-1, pr110252-2, pr38533, pr43385, pr43560, pr45695, pr49279, pr49390, pr52286, pr65053-1, pr65648, pr65956, pr80421, pr84524, pr85756, pr88904) and two vector .data tests (simd-5, pr123625-2). Five candidates stay curated with corrected reasons: 20030222-1 (64-bit value tied to a 32-bit r output), pr23135 (timeout), simd-1/simd-2 (vector runtime abort) and stkalign (memory operand).
  • M9.2 — DWARF v5 form gate and .debug_rnglists. In a multi-object --keep-debug link, tms-link now walks every CU/DIE through .debug_abbrev (including DW_FORM_indirect and DW_FORM_implicit_const), the v5 line-table directory/file entries, every .debug_rnglists/ .debug_loclists unit and DW_RLE_*/DW_LLE_* entry, every .debug_str_offsets entry and every .debug_addr address. Every section-relative form (strp, line_strp, sec_offset, ref_addr) and every DW_FORM_addr must start on an R-RELLONG relocation (the GNU supplementary/alternate refs are consumed but not required, since they do not name the sections being concatenated); a missing one is a loud LinkError, and pre-v5 producers (whose DW_FORM_data4/data8 statement list cannot be rehomed) and DWARF64 are refused. The CU debug_abbrev_offset keeps the documented raw-patch exception. .debug_rnglists is now exercised by a synthetic two-TU fixture (DW_AT_rnglists_base, DW_AT_addr_base, DW_AT_ranges via DW_FORM_rnglistx, DW_RLE_start_end and DW_RLE_startx_length) and by a real -O2 -g inlining producer; scripts/tests/m9/dwarf-ranges.sh links both, wraps the kept sections in the M7 ELF container and requires llvm-dwarfdump to resolve both TUs' ranges and address table. The single-TU link keeps the M8 byte layout and the default strip is .text/.data/.bss, unchanged. tools/tms-link/tests/ run.sh adds per-walker unrelocated-field negatives and the DWARF v4 refusal.
  • M9.3 — single-DIVU 64/32 divide. After the signed-magnitude normalization, a zero divisor high word reaches i64div.check32: if hi(N) < D the quotient fits 32 bits and one even-destination DIVU on (hi, lo) produces it, with the remainder reconstructed as the low 32 bits of lo(N) - q*D; if hi(N) >= D the M8.3 two-DIVU outlined helper is kept. The fits-32 path, the 64-step loop, the shared sign fixup and divide-by-zero UB are unchanged. INT64_MIN never fits 32 bits: it keeps the two-step helper for a divisor of at most 2^31 and takes the single-DIVU path for a divisor in (2^31, 2^32). m9-i64div-64-32.ll pins the new block, the JRLO quotient-fit branch, one even- and one odd-destination DIVU per caller and the unchanged wide helper at -O0 and -O2. The four-phase MAME measurement (scripts/tests/m7/i64div.sh, 16,384 iterations each) is fast 88, slow 3,302, wide 221 and div32 120 frames: 37.5× (fast) and 14.9× (wide) versus the loop; 1.8× for div32 versus the two-DIVU wide phase, status 600D600D, checksums 000000011E6F9AB4/00000000007512AE/F56810CFEDA9D656/ 00002C61C63842EE. The slow phase measures 3,302 frames here (M8 measured 2,440); the 37.5× and 14.9× ratios are computed against that current slow phase, and the 1.8× is wide/div32.
  • M9.4 — hardware and counts. The real VT1200 run remains DEFERRED: VT1200_HOST is unset and no unit is available. scripts/tests/m7/hardware.sh builds the marker COFF at the proven origins, validates it in MAME through the dwt loader and prints HARDWARE: DEFERRED; setting VT1200_HOST additionally runs hostload.py --marker. No hardware pass is claimed. The fresh two-tier full suite (bare tier by default plus the 10-row scripts/tests/m7/full-suite.full-loader list) is 1,912 = 1,618 pass / 294 skip / 0 fail / 0 crash (c-torture 1,408 / 284, c-testsuite 210 / 10); the 294 skips are 64 classifier plus 230 curated rows, each with a reason. The retained TSV/report are build/m9-bare-full/ and scripts/tests/m7/full-suite-report.txt. The other shipped tiers are unchanged: lit 129/129, clang 5/5, M5 c-torture 79/79 at -O0 and -O2, M6 c-torture 79 at -O0 plus the 20-test bounded -O2 subset, shipped c-testsuite 48 pass / 172 skip / 220, Generic 197 = 151 pass / 46 unsupported / 0 crash.
  • Boundary. M9 is complete. The remaining genuine conformance classes are blockaddress; vector runtime arithmetic (the backend still has no vector register class); inline-asm memory constraints (m/o/V, loud today); nested functions; VLAs; sret/aggregate/variadic/float return shapes; libm; and the remaining runtime aborts. The pre-existing pr63843 hang, the real VT1200 run and further performance work are M10.

What M8 provides

M8 is the object/link-completeness, conformance-depth and hardware close-out. It adds native archive linking and multi-TU DWARF to tms-link, fixes the remaining rotate/count/byte-swap lowering class, adds a 64/32 i64 divide fast path, and records the final M8/M9 boundary. It changes no TI ABI rule, no language semantics and no default branch. Full target rules are in build/llvm-clean/TMS34010.md ("M8 state").

  • M8.1 — native .lib linking. tools/tms-link reads System V ar archives (!<arch> with TI-COFF members; the 1990 FLIB.LIB/RTS.LIB are this shape). It validates the 60-byte headers, decimal sizes, even padding, / symbol index and ////N long names; a malformed archive or index is loud. Members are candidates only: a member is extracted when it defines a still-undefined symbol, scanned in the archive's index order (which matches GSPLNK's member layout), never extracted twice, and the archive sequence is iterated to a fixpoint. Duplicate definitions and unresolved externals fail with member/object labels (member labels include the offset, so same-named members stay distinct). -l LIB/-lLIB and -L DIR resolve LIB, LIB.lib, LIB.LIB and libLIB.a; explicit objects and archives may be mixed in any order, with explicit objects laid out first. TI-COFF relocation addends are read as signed 32-bit values (the termtris link exposed a -160 .bss addend). GSPLNK remains the default linker and the permanent oracle: M4_LINKER=tms-link (with M4_NATIVE_LIBS/M4_NATIVE_RTS), M5_NATIVE_LINKER=tms-link and M6_LINKER=tms-link are opt-ins, and the native library gate (scripts/tests/m8/native-lib.sh) requires the same allocated bytes, section origins/flags, optional header and 16 public C_EXT addresses as GSPLNK, plus the MAME markers. Limits: an empty .cinit is omitted (GSPLNK emits a listed empty one), an indexed archive parses a member only when needed (so an irrelevant unsupported member is harmless), a no-index archive must be scanned member by member, and a second archive that redefines an already-satisfied symbol is not pulled in or flagged, matching traditional archive semantics.
  • M8.2 — multi-TU DWARF merging. tms-link --keep-debug concatenates the debug sections of every debug-bearing object in object order and rehomes every section-relative contribution: the CU debug_abbrev_offset (raw fallback when no relocation covers it), str_offsets_base, stmt_list, addr_base, loclists_base/rnglists_base, .debug_str and .debug_line_str string offsets, .debug_addr entries and .debug_line addresses. Supported multi-object sections are .debug_info, .debug_abbrev, .debug_str, .debug_str_offsets, .debug_addr, .debug_line, .debug_line_str, .debug_loclists and .debug_rnglists; any other .debug_* shape (.debug_frame, aranges, types, macros, …) is refused loudly in a multi-object keep link. LLVM 23.1.5 -g objects use the supported shapes; DWARF64 is refused. The gate (scripts/tests/m8/dwarf-multi.sh) links two -g TUs, wraps the kept sections in the M7 ELF container and requires llvm-dwarfdump to show both CU names, both line tables, every subprogram name/low-high PC/line, and the second CU's bases shifted to the first object's merged contribution sizes (e.g. abbr_offset=0x5a, str_offsets_base=0x34, stmt_list=0x80, addr_base=0x1c). It also links the same TUs as an archive member and runs the stripped image in MAME with all four markers. The single-TU link is byte-identical to M7, and the stripped load image is unchanged. Caveats: a future producer that emits an unrelocated section-relative field other than the CU abbreviation offset is not silently rewritten (it needs a form-aware DIE walker; this compiler relocates every such field), and .debug_rnglists was in the concat set but the M8 fixtures did not emit it (non-contiguous ranges), so it was supported but unexercised. M9.2 closes both caveats (see "What M9 provides").
  • M8.3 — conformance depth and performance. The M7.4 classifier stopped on Cannot select for rotates, cttz, ctpop/ctlz and bswap. They now lower without inventing instructions: rotl/rotr are Expanded and SelectionDAG masks both counts with ANDI 31 (rotate by 0/32 is the identity); cttz is the custom popcount(~x & (x-1)) sequence (the generic expander would need a constant-pool table this target cannot emit); ctpop/ctlz use the stock legal shift/mask/add/multiply bit-hacks; and bswap is a shift/mask/or byte-lane sequence. m8-bitops.ll pins both -O0 and -O2, the zero-poison forms and the literal rotate-by-0/32 identities. The new i64div.wide path handles "dividend wider than 32 bits, divisor fits 32 bits" with two even-destination DIVUs (q1 = hi/d, r1 < d, q0 = (r1:lo)/d, q = q1<<32 | q0, r = lo - q0*d), shared with the existing signed magnitude/sign fixup; it is outlined into __tms34010_i64_udiv32/..._urem32 so the 64-step loop stays spill-free. The existing one-DIVU fits-32 path is unchanged. At M8 scripts/tests/m7/i64div.sh measured three equal 16,384-iteration phases: fast 87 frames, slow 2,440 (28.0×) and wide 218 (11.2×), status 600D600D, checksums 000000011E6F9AB4, 00000000007512AE and 00025AF70AF974E0. M9.3 makes the gate four-phase and narrows the wide input to force the two-DIVU helper, so it supersedes the M8 wide frame/checksum number (see "What M9 provides").
  • M8.3 flips and loader budgets. Twenty curated rows flipped to pass: six rotates (20020226-1, 20020508-1, 20100805-1, 20180112-1, pr119428, pr97386-2), six cttz (builtin-bitops-1, ffs-1, ffs-2, pr37780, pr61725, pr97325), four bswap (bswap-1, pr108064, pr64718, pr90025) and four frame-limited runtime rows (20040811-1, pr43220, strcmp-1, vla-dealloc-1). The last four carry a validated per-test LOADER_END=2000 in scripts/tests/m7/full-suite.loader-end; the shipped default stays 1000, and a table row may be above or below an explicit global LOADER_END because it records the budget the row was validated at (1000 floor, 20000 sanity cap). pr63843 remains a skip: the M7.4 pin failed its bar with a bswap Cannot select, the M8 base already compiled it to shifts, and it then reaches a pre-existing runtime hang (status 1, no completion magic). The reduced bar()-only reproducer and both logs are retained under build/m8-task3-pr63843/reduced/.
  • M8.4 — hardware. The real VT1200 run remains DEFERRED: VT1200_HOST is unset and no unit is available. scripts/tests/m7/hardware.sh still builds the marker COFF at the proven hardware origins, validates it in MAME through the dwt loader and prints HARDWARE: DEFERRED; setting VT1200_HOST additionally runs hostload.py --marker over rdebug. No hardware pass is claimed.
  • Counts at M8. lit 120/120 (116 CodeGen: 34 m2-*, 8 m3-*, 18 m4-*, 15 m5-*, 28 m6-*, 11 m7-*, 2 m8-*; plus 4 MC), clang Sema/CodeGen 5/5, M5 c-torture 79/79 at -O0 and -O2, M6 c-torture 79 at -O0 + 20 bounded -O2, shipped c-testsuite 48 pass / 172 skip / 220, Generic 197 = 151 pass / 46 unsupported / 0 crash (M8.3 removed the 2008-02-04-Ctlz and llvm-ct-intrinsics expected-fails). The fresh end-to-end full suite is 1,912 = 1,596 pass / 316 skip / 0 fail / 0 crash; the 316 skips are 64 classifier and 252 curated rows, every one with a reason. The M7.1–M7.4 counts are otherwise unchanged.
  • Boundary. M8 is complete. M9 closed vector .data, inline-asm r, the DWARF future-producer/.debug_rnglists caveats and the 64/32 divide path. The remaining genuine conformance classes (M9/M10 boundary) are blockaddress, vector runtime, inline-asm memory constraints, nested functions, VLAs, sret/aggregate/variadic/float returns, libm and the remaining runtime aborts; the pre-existing pr63843 hang and further performance work are also open. The real VT1200 run remains deferred until the unit is available.

What M7.4 provides

M7.4 is the conformance/performance close-out and the final M7 boundary. It adds one compiler feature (the i64 divide/remainder fast path), one project full-suite driver and one loader repair; it changes no TI ABI rule, no language semantics and no default branch. Full target rules are in build/llvm-clean/TMS34010.md ("M7.4 state").

  • Full external suites. scripts/tests/m7/full-suite.sh runs every .c in both pinned corpora through the M5 conformance runner and classifier: GCC 16.2.0 gcc.c-torture/execute (gcc-16.2.0.tar.xz, SHA-256 e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e) and c-testsuite single-exec (commit 5c7275656d751de0e68b2d340a95b5681858ed07). Settings are -O0, --mode native, LOADER_AT=200, LOADER_END=1000, serial, 120 s MAME/210 s outer wall per test. Each file gets exactly one pass, skip:<reason> or fail:<category> row (compile, diagnostic, loader, status, output, timeout, crash, harness, unclassified). A compiler abort is fail:crash; a missing tool or classifier error is fail:harness; a bare runner exit 2 is a skip only with a real CONFORMANCE: SKIP row. The driver records the compiler source revision plus the clang/llc binary hash, refuses a resume across a pin or settings change, and resumes per id. The retained scripts/tests/m7/full-suite-report.txt, the TSV results and the per-test logs are reproducible from those pins.
  • Final accounting. c-torture 1,692 = 1,366 pass / 326 skip / 0 fail / 0 crash; c-testsuite 220 = 210 pass / 10 skip / 0 fail / 0 crash; all 1,912 = 1,576 pass / 336 skip / 0 fail / 0 crash. Nothing is unclassified and no crash is counted as a pass.
  • Two-tier conformance harness. The suite defaults to a bare-metal MAME tier: the COFF sections are mapped at their paddrs, .bss is zeroed, PC/SP are set, and the test runs without the VT1200 firmware or COFF loader. The fresh M9 totals are 1,618 / 294 / 0 / 0 (the M8 run was 1,596 / 316 / 0 / 0), and the run is ~35 minutes instead of ~2 h 52 m. The bare tier uses the 1990 r5.01 OS/2 assembler through 2ine (direct loader; qemu-i386 fallback) and the host tms-link; scripts/m8/setup-os2.sh provisions it. The full-loader tier remains for the curated M5/M6 gates, X11/runtime/loader and hardware, plus an explicit 10-test scripts/tests/m7/full-suite.full-loader list (each with a reason); M5_CONFORMANCE_BARE=0 selects it, and M5_CONFORMANCE_BARE=1 is the default for the corpus driver.
  • Skip classes. The 294 skips are 64 classifier skips and 230 curated rows, each with a reason. The main classes (with c-torture counts) are nested functions 30, timeouts 21 (loader/run; M9's pr23135 remains here), inline-asm memory/other constraints 13 (down from 33 after the r flips; the remaining rows need m/o/V or an i64 pair), file I/O 18, wide characters 16, __int128 15, image/region size 15, .data initializers 14, runtime aborts 14, unknown builtins 11, sret/aggregate/variadic/float return shapes 10 plus 9 sret and 3 variadic-return, runtime abort variants (i64 10, bitfield 9, varargs 6, float 5, vector 5, alignment 2), VLAs 9, compiler-internal crashes 6 (unknown custom lowering, dynamic-alloca assertion; other codegen/asm rows abort with a feature diagnostic), setjmp/longjmp 6, missing gcc.dg corpus sources 5, float arguments 4, signals 4, codegen gaps 2 plus 2 float-codegen and 2 vector rows, indirect calls 2, and one each of byval, odd .data pointer, decimal float, out-of-range float constant, libc prototype and the 16 KiB output cap. c-testsuite skips are wide characters 4, file I/O 3, an unimplemented printf conversion set 1, libm sin/float formatting 1 and one 1000-frame timeout. The full per-reason table is in the retained report.
  • 112 pass flips. Honest harness fixes turned 112 former failures into passes: 98 fail:compile (per-test -std=gnu89 from explicit directives plus full-suite.gnu89 for 68 directive-free files; assert.h, stdbool.h, minimal math.h and malloc/calloc/free in stdlib.h), 3 fail:status (20020406-1, 20071018-1, 20071120-1) and 11 fail:loader. The remaining 272 supported failures were curated after re-running them with an empty skip file: 272/272 still failed.
  • i64 divide/remainder fast path. TMS34010LowerI64::lowerDivRem keeps the existing signed absolute-value normalization and tests the normalized operands' high words. When both are zero it computes the quotient and remainder with one 32-bit DIVU (zext of the truncated operands) instead of the 64-step restoring loop; the loop is unchanged as the slow path and the shared quotient/remainder sign fixup is applied once after the fast/loop phi. Divide-by-zero stays undefined, and INT64_MIN stays on the slow path because its magnitude's high word is 0x80000000. m7-i64div-fast.ll pins the high-word test, the JREQ target, the fast DIVU, the still-present loop and RETS 2 at -O0 and -O2; m6-i64.ll keeps every original fact (its div/rem checks became order-independent because the new CFG changes block placement).
  • Measurement. scripts/tests/m7/i64div.sh runs two equal 16,384-iteration C workloads through GSPA/GSPLNK, the dwt loader and MAME: a 32-bit-operand fast-path phase and a nonzero-high-word slow-loop phase. The driver self-checks both paths first (status 600D600D) and the Lua pins both deterministic phase checksums. The M7.4 evidence line is fast_frames=90 slow_frames=2424 ratio=26.9 status=600D600D cs_fast=000000011E6F9AB4 cs_slow=00000000007512AE. A frame is a fixed number of emulated 50 MHz cycles, so the ratio is a reproducible cycle proxy. -O2 is only an optimizer baseline (instcombine narrows some fast divisions to i32); the default -O0 run is the fast-path evidence.
  • Conformance COFF repair. GSPLNK 2.00 can write a zeroed 48-byte file/optional header (observed on links whose test object contributed no initialized .data; the section table at byte 48 is valid) and can emit an odd .bss bit size. scripts/m4/coff-check.py validates the magic/table/sizes, reconstructs only that known shape from the section table and the map entry point, and rounds only .bss up to a 16-bit word; scripts/m4/run.sh runs it after every link (M4_COFF_REPAIR=0 for validate-only). This is a post-link repair, not a general malformed-COFF reader, and native .lib linking remains M8.
  • Counts at M7.4. lit 118/118 (114 CodeGen: 34 m2-*, 8 m3-*, 18 m4-*, 15 m5-*, 28 m6-*, 11 m7-*; plus 4 MC), clang Sema/CodeGen 5/5, M5 c-torture 79/79 at -O0 and -O2, M6 c-torture 79 at -O0 + 20 bounded -O2, shipped c-testsuite 48 pass / 172 skip / 220, Generic 197 = 149 pass / 48 unsupported / 0 crash. The M7.1/M7.2/M7.3 counts are otherwise unchanged.
  • Boundary. M7 is complete. The limitations carried into M8 were: one debug-bearing TU per link (multi-TU DWARF merging is loud), .lib archives not readable by tms-link and the native-link/CONFORMANCE path keeping GSPLNK, a kept-debug image not being a load image, and the real VT1200 hardware run still DEFERRED. M8 delivered native archive linking, multi-TU DWARF merging, the rotate/count/byte-swap lowering and the 64/32 i64 divide path. The remaining classes (sret/varargs/float returns, nested functions, VLAs, inline-asm constraints, vector data, blockaddress, libm and the runtime aborts), the pre-existing pr63843 hang, further performance work and the real unit run are the M8/M9 boundary.

What M7.3 provides

M7.3 is the runtime/hardware milestone on top of M7.2. It changes no compiler code or TI ABI and keeps the default branch; no M2–M7.2 gate outcome changes (the M4/M5 harness fixtures and the M5 JR byte constant follow the six new stubs). It adds two project-side runtime surfaces and one deferred hardware harness; the full target rules are in build/llvm-clean/TMS34010.md ("M7.3 state").

  • Wider Xlib surface. The v2.2 table is 36 entries: the M4 30 plus six validated M7.3 entries, each from the GUI_APPS table and checked by scripts/m4/validate-syms.sh (ROM range, 16-bit alignment, real mmtm prologue, plus an address pin and an opcode/helper pin):

    symbol bit address opcode ROM evidence
    XMapSubwindows 0x3FD64BF0 9 movk 9,a11; movb a11,*a10
    XChangeWindowAttributes 0x3FD38770 2 value walker calla 0x3FDAA550
    XConfigureWindow 0x3FD3A510 12 fixed mask 15; x/y/width/height from a13-12/-16/-20/-24
    XInternAtom 0x3FD5E420 16 calla 0x3FB458D0 (strlen); only_if_exists at a13-12
    XChangeProperty 0x3FD37330 18 blit_copy (0x3FB44400) for the value bytes
    XChangeGC 0x3F999F80 56 (0x38) GC value-cache serializer (0x3F997AD0)

    Two signatures are the ROM shapes, not the public X11R4 wrappers, and scripts/m4/x11m4.h/symbols/vt1200-v22.syms say so: XConfigureWindow(d, w, x, y, width, height) is the fixed CWX|CWY|CWWidth|CWHeight mask-15 move/resize builder (the XMoveResizeWindow body), and XChangeGC(d, gc) is the two-argument opcode-56 cache flush, not the four-argument value setter. The client also documents the default-font finding: the ROM XLoadFont handle is not a usable GCFont XID (passing it raises BadFont/BadGC), so the GC uses the server's default 6x13 font; XLoadFont is still called and marked, and XDrawString is proven by pixels.

  • xmore client and gate. scripts/m7/xmore.c creates a parent (100,100 400x300) and a child (40,40 240x160, background 1), maps the subwindows, moves/resizes the child to (20,20 200x150), writes the WM_NAME property (the predefined X11R4 atom 39), sets CWBackPixel=0, draws with a GC, and round-trips a heap XCreateImage/XPutImage/XGetImage/ XPutImage/XDestroyImage image. Markers live at 0x018A8000 + n*0x20: property_called, attrs_called, gcchange, text_pixels, image, errors, stage and the window/child/gc/atom/font/ fill values. scripts/tests/m7/xlib.sh runs one MAME pass and requires errors=0, stage=14 (or 15 after a real-unit atom return), property_called=1, attrs_called=1, gcchange=2 (the two XChangeGC source call sites; runtime entry is not proven), image=0x13F (the white pixel plus all six round-trip flags), text_pixels (67 observed; a real glyph count in a 64x16 XGetImage band), and a black CWBackPixel margin outside the 160x120 fill (the gate prints the four exact VRAM samples: fill, heap image, get/put-back and the attribute-only margin). property_called/attrs_called are post-call flags (the ROM builders do not set A8, so there is no server read-back); the attribute is independently proven by the margin and the configure marker is client-computed (the move is pixel-proven, the size is not read back).

  • XInternAtom skip (environmental). XInternAtom("WM_NAME", False) is attempted last and reaches the call site, but it blocks in the emulated ROM _XSend scatter/WRITEV path (0x3F9B44C0 → 0x3F9BF870 → the 0x3F70D150 service write): the request buffer holds only the 8-byte InternAtom header and the name never arrives, so the server waits. This is the same loader-harness _XSend limitation the M4 XPutImage finding records, not an ABI choice. The gate marks it atom=0xFFFFFFFF and internatom=SKIP, accepted only with stage=14 plus a nonzero pre-call Display marker; a MAME breakpoint could not write the entry cell under -debugger none, so the isolated probe (XSync/XGetInputFocus return, CPU inside _XSend while blocked) is narrative entry evidence, not a gate check. On a real unit the call returns, the client rewrites the property with the returned atom and advances to stage 15; the Lua accepts that path too. The property is written first with atom 39, so the run has zero X errors either way.

  • stderr capture. The conformance result block now has a second 16 KiB stream. Bit addresses: 01B00020 stdout length, 01B10000..01B2FFFF stdout (exclusive; unchanged), 01B00060 stderr length, and 01B30000..01B4FFFF stderr. The shim provides fprintf/vfprintf (reusing the M6 conf_format sink), fputs, fputc and fwrite; printf/putchar/puts remain stdout. Return values are the untruncated C results while the buffer is capped at 16 KiB, and len >= CAP/errlen >= CAP is a truncation failure, not a pass. The runner accepts --expect-stderr TEXT and the status=N;stdout=TEXT;stderr=TEXT spec grammar (either stream field order, missing fields are empty), compares both streams byte-for-byte, and prints stderr_len= after stdout_len=. The M6 runtime-entry.asm clears both length cells before _runtime_run, and exit()/abort() publish both shadows, so MAME prefill cannot fake a stream. The conformance selftest adds dual-stream (stdout_len=12292 stderr_len=2), default-empty (selftest-stderr-default must fail as a mismatch) and truncate-return (selftest-truncate-return, selftest-stderr-truncate-return) cases on top of the formatted-stderr and empty-stderr cases. Existing stdout counts and byte streams are unchanged.

  • Hardware harness (DEFERRED). scripts/m7/hwmark.c is a C-only client (entry _start; no assembly trampoline) linked with tms-link at the proven VT1200 origins: .text 018C0000, .data 018D0000, .bss 018D8000, with prog [018C0000,018D8000) and ram [018D8000,018E0000). The marker cells match dwt/loader/hostload.py's MARKER_CELLS: 018E0000 start (0x018C0000), 018E0020 data (0xDEADBEEF), 018E0040 data2 (0x12345678), 018E0060 bss (0, proving the loader zero-fill of an A5A5-prefilled section) and 018E0080 the live counter. GSPLNK 2.00 links the same object with explicit origins as the oracle; the gate requires identical entry, origins/sizes and allocated bytes (726-byte COFF observed, sha256 e03d353716b7c28d2128f87786fece508f520351fcf0525773f3aa4ee9e33d33). scripts/tests/m7/hardware.sh loads the COFF in MAME through the same dwt loader as the unit path and requires loader status 0, the five cells and a counter that advances (count=103->109), then prints HARDWARE: DEFERRED unless VT1200_HOST is set. With VT1200_HOST it runs python3 vendor/vt1200/dwt/loader/hostload.py --host "$VT1200_HOST" --coff build/m7-hardware/hw-marker.coff --marker --out build/m7-hardware/evidence/hostload --tag hwmark, saves the log under build/m7-hardware/evidence/, and propagates any failure. The unit is a stock v2.2 VT1200: MAC 08-00-2B-16-4B-5A, static IP 100.103.100.103 (lab host 100.103.255.254); the emulator lab is 192.168.99.2 and rdebug listens on TCP 771. No hardware pass is claimed without a unit.

  • Gate counts. At M7.3 these were unchanged because the compiler was unchanged: lit 117/117 (113 CodeGen + 4 MC), clang Sema/CodeGen 5/5, M5 c-torture 79/79 at -O0 and -O2, M6 c-torture 79 at -O0 plus the 20-test bounded -O2 subset, c-testsuite 48 pass / 172 skip / 220 (the curated shipped tier; the M7.4 full sweep is 210/10), Generic 197 = 149 pass / 48 unsupported / 0 crash. M7.4 adds the i64 fast-path lit test, so lit is now 118/118 (114 CodeGen + 4 MC); the other counts are unchanged.

What M7.2 provides

M7.2 is the object/debug milestone on top of M7.1. It changes no language rule or ABI contract and keeps every M2–M7.1 gate. Full target rules and object evidence are in build/llvm-clean/TMS34010.md ("M7.2 state"); the M7.3 runtime/hardware contracts are in its "M7.3 state".

  • TI-COFF object writer. The dynamic section list is .text, .data, optional .cinit, .bss, then optional non-allocated .debug_*. .cinit is the TI init-record table (data flags 0x40) and is emitted only when non-empty; .debug_* sections have flags 0, R-RELLONG relocations and long names written through the COFF string table as /offset. Names and section headers share the table (4-byte size prefix). Empty debug sections are omitted, so an object with no .cinit and no debug IR is still the original .text/.data/.bss shape. Data-only/.cinit-only objects are valid (.text size 0 with its section symbol). Object-mode explicit data sections are restricted to .cinit; .bss/.text fail with "initialized data in section '...' cannot be represented in TI-COFF" and any other non-debug section with "section '...' has no TI-COFF representation".
  • Debug addends. A relocation address (raddr) is always a bit address, in every section. The relocated field's unit depends on the containing section: allocated .text/.data/.cinit fields are bit addends (S_bits + addend_bits); .debug_* fields are byte addends (S_bytes + addend_bytes, with an allocated target at output_paddr/8 and a debug-section target kept section-relative at 0). A resolved symbol difference such as DW_AT_high_pc is already bytes and is never rescaled.
  • Debug is object-only. SupportsDebugInformation is on, but the target AsmPrinter disables DwarfDebug when the streamer has raw-text support, so -filetype=asm still emits no .loc/.debug_* text and GSPA is not weakened. scripts/tms-clang -g passes exactly -g to clang on the IR step; -g1/-g3 are not passed through.
  • tools/tms-link. A Python 3 linker reads the relocatable TI-COFF inputs and writes a position-dependent image with no relocations. CLI: tms-link -o OUT [--map MAP] [--entry SYM] [--text ADDR] [--data ADDR] [--cinit ADDR] [--bss ADDR] [--prog-len BITS] [--ram-len BITS] [--keep-debug|--strip-debug] OBJ.... Addresses and sizes are bits; .text defaults to 018A0000, .data follows it 16-bit aligned, .cinit follows .data (only when the total size is nonzero), and .bss defaults to 01A00000. .cinit is placed after .data and its records' u32 destinations link to bit addresses. The linker resolves the exact public C_EXT name (including names longer than GSPA's 31 characters), refuses duplicate/undefined symbols loudly, and applies the R-RELLONG rules above. It writes GSPLNK-shaped .text/etext/.data/edata/.bss/end symbols and a public cinit at the .cinit origin when a total non-empty .cinit exists (an input definition wins). The optional header is 28 bytes (0x0108, vstamp 199, text/data/bss sizes in bits, entry, text/data start); file flags are 0x0103. The map carries section allocation and global symbols (source-line ranges are the kept .debug_line data, read with llvm-dwarfdump, not a linker DWARF parser).
  • Strip/keep debug. .debug_* are stripped by default; --keep-debug keeps them with relocations resolved into DWARF byte space, nreloc 0, paddr/vaddr 0. More than one debug-bearing object is refused in M7.2 (multi-TU DWARF merging is M8). A kept-debug image is not a load image; only the stripped image runs in MAME.
  • Oracle and limits. GSPLNK stays the oracle: scripts/tests/m7/oracle.sh links the same M5 objects both ways and requires identical allocated bytes, section paddr/vaddr/size/flags, optional header and the exact defined public C_EXT set, asserts the documented C_STAT difference (GSPLNK keeps per-input section symbols; tms-link emits one per output section), and runs both images in MAME with identical markers. The .cinit gate covers a real C table and the copy loop, longname.sh a 44-character cross-TU public function (the 45-character _tms... linked symbol), and debug.sh DWARF at -O0 (exact) and -O2 -g (smoke). tms-link does not read .lib members yet; scripts/m4/run.sh keeps GSPLNK as the default and exposes the M4_NATIVE=1 M4_LINKER=tms-link opt-in (no libraries). A total-empty .cinit is omitted and defines no cinit; a reference then fails loudly (GSPLNK's fallback is not reproduced; cinitz.asm is the zero-count fallback). The asm path's 31-character public-name truncation is unchanged and is an assembler limitation.

What M7.1 provides

M7.1 is a correctness/ABI milestone on top of M6; it changes no language rule or ABI contract and keeps every M2–M6 gate. Target rules and evidence are in build/llvm-clean/TMS34010.md ("M7.1 state").

  • The -O2 bit-pointer barrier. Source GEPs and source bit-offset inttoptr(add(ptrtoint,...)) shapes are hidden behind an opaque @__tms_bitptr(i32 bitoff, ptr base) call (nounwind readnone) before opt, so the optimizer cannot re-canonicalize an already-bit address into a byte GEP. The pipeline is clang → --bitptr → opt → --scale → --lower-bitptr → instcombine at -O2 (clang → --bitptr → --lower-bitptr at -O0); the post-opt --scale shifts only optimizer-created byte GEPs (SROA/switch tables), and the final InstCombine restores the M0 folding. The default -O2 p += n is now correct (one scale), the conformance shim's constant-step memmove workaround is gone (the natural d += n backward copy is gated), and the M0 contract is unchanged: int_diff returns 8, int_diff4 returns 32, and late carries 24 (never 192). The pre-existing i64/narrow/sext shapes are barriered too: (unsigned long long)(unsigned)p + 24 and (long long)(int)p + 24 keep the low word, while narrowing base casts such as (unsigned short)p + 24 keep their mask (late64, late64s, narrow16, narrow8 are runtime markers in the gate).
  • Sub-byte stride diagnostic. A default-on warning, -Wtms34010-subbyte-stride, fires when an array element or nested member is a record whose bit content is not a byte multiple: "array element or nested member of type 'struct s' advances by the byte-rounded size 40 bits; the TMS34010 ABI advances by 36 bits". It is silent for byte-multiple records, standalone sub-byte records and union members (a union member never advances), and the target guard keeps x86 silent. The rule is deliberately one level: the warning fires at the defining field or array, not again at every container whose byte-rounded content happens to be a multiple. The layout/ABI is still Clang's byte-rounded one; the diagnostic makes the 1987 divergence visible but does not change sizeof, field offsets or the stride. A :0 bitfield can make the reported TI number a message-accuracy edge, but the warning still fires.
  • Recursive .data initializers. Both the raw GSPA emitter and the native TI-COFF object emitter now handle i64 (two little-endian 32-bit words, LSW first), i24/i40/i48/i56 (exact value bytes), structs/unions (including packed records and bitfield storage, with padding zero-filled and the active union member exact), arrays, aggregate zero and bit-addend pointer relocations. The raw path emits exact little-endian .byte sequences at odd byte offsets because GSPA implicitly word-aligns .word/.long; the object path writes unaligned bytes directly. GSPA limitation: a non-null pointer field at an odd .data byte offset cannot be represented in the text path (a 32-bit relocation cannot be split across .byte lines), so the raw compile fails loudly with TMS34010: a pointer field at an odd .data byte offset cannot be represented in GSPA assembly; the native object path supports it (R-RELLONG at the odd bit address) and is gated end-to-end through GSPLNK/MAME. Unsupported shapes (vectors, i128, half/bfloat/fp128, non-byte-multiple i33..i63) remain loud with the reworded TMS34010: unsupported .data initializer (...) diagnostic. Two uniformity notes: raw mode rejects [N x i1] (and object mode rejects a non-zero ConstantArray<i1>) while object mode zeroes a zeroinitializer [N x i1] as opaque bytes, and an aggregate-zero record/array containing an otherwise unsupported member is zero-filled without inspecting the members (the bytes are exact zeros, so this is a diagnostic-uniformity exception, not a correctness bug). The i64 argument/hidden-slot order stays MSW-first; only the memory image is LSW-first.

The M7.1 gates are scripts/tests/m7/pointer-o2.sh (the -O2 p += n and natural memmove driver in MAME plus one-scale IR/asm evidence), scripts/tests/m7/stride.sh (oracle 36-vs-40 warnings, controls, union and x86 negatives) and scripts/tests/m7/data.sh (raw and native .data, exact object bytes/relocations, the object-mode i24/i40/i48/i56/[2 x i24] bytes and the odd-offset pointer). The TMS34010 lit suite is now 114/114 CodeGen (34 m2-*, 8 m3-*, 18 m4-*, 15 m5-*, 28 m6-*, 11 m7-*) plus 4/4 MC (118/118 total), and the clang Sema/CodeGen lit is 5/5. The M5/M6 counts below are unchanged except the Generic sweep, which is 149 pass / 48 unsupported / 0 crash (three former .data expected-fails now compile). The eleven m7-* CodeGen tests are the four M7.1 .data tests, the six M7.2 object tests (m7-cinit-section, m7-cinit-only, m7-no-cinit, m7-debug-info, m7-unknown-section, m7-bss-import) and M7.4's m7-i64div-fast.

What M6 provides

M6 closes the TI C language surface on the M5 all-stack ABI, native TI-COFF path and asm oracle. Full target rules and evidence are in build/llvm-clean/TMS34010.md ("M6 state").

  • long long. Two 32-bit argument slots and an 8-byte caller-allocated hidden return slot (RETS 2, no A8). Add/sub use post-RA ADDC/SUBB; multiply uses the 32-bit MUL/MPYS/MPYU path; shifts use SHL/SRL/SRA_PARTS; unsigned/signed divide and remainder use a correct inline 64-iteration restoring loop because rts.lib has no 64-bit helper. i64 objects in memory are little-endian (LSW at the lower address) per the design spec and the e data layout; the argument/hidden-return stack slot is MSW-first, a separate M6 ABI choice pinned by the Task 1 probe. Variadic i64 returns and atomic i64 accesses are rejected loudly; i64 .data initializers were an M6 limitation and are supported from M7.1.
  • float/double soft-float. GSP-format values and flib.lib stack entries: arithmetic pushes its result on A14, compares return in A8, conversions use A8/A14; every call saves/restores A14 and A8. f32 lives in ARegs, f64 in an ARegsPair with pair spills. IEEE IR constants are converted to GSP words (exponent+1, half-up), with a GSP constant pool and the TMS34010LowerFloatConstants pass for store/return/argument literals. GSP has no NaN, denormals or signed zero: -0.0 is canonicalised to +0, and NaN/denormal/overflow literals are rejected loudly. Only i32 float↔int conversions and no libm (fsqrt/fma/frem) are available.
  • Hidden returns. float, double, i64 and aggregates share one caller-allocated slot rule: ADDI 32/64/alignTo(size,2) before saving STK, the callee writes at saved_STK-size, restores A14 and ends RETS 2 (even with no arguments). Scalar A8 returns are unchanged.
  • General varargs. va_list is a 32-bit char *; the caller saves STK for every variadic call, va_start = FP-(fixed_argument_bytes+4)*8, and va_arg walks downward with per-type word orders. va_copy/va_end and an int f(...) definition work; a variadic i64/float hidden return and a va_arg of a struct are rejected. The M4 contiguous &last_fixed pattern still works.
  • Packed bitfields. LSB-first, no padding between adjacent fields, an unnamed/leading :0 is ignored, and fields may cross 32 bits. SEXT1 handles int s:1; TMS34010ExpandNarrowMem splits i24/i40/i48/i56 containers in IR so the byte offsets stay bit addresses. A 31-bit field at bit 33 and a 57-bit field use the little-endian i64 memory split. Remaining divergence: TI advances nested/array objects by the bit content (36 bits for struct s) while Clang uses the byte-rounded sizeof (5 bytes); field offsets, sizeof and standalone 16-bit-rounded allocation agree. M7.1 adds the default-on -Wtms34010-subbyte-stride diagnostic for that shape (the layout itself is still byte-rounded).
  • Aggregates by value and return. Clang's target ABI classifies a record return as direct, so the IR has no sret parameter; the callee writes flattened leaves directly at their object offsets in the rounded hidden slot and the caller copies them out. Struct/union arguments keep the M5 byval form. An explicit sret pointer is rejected with a clear diagnostic; a packed bitfield struct returned by value is covered end-to-end in the aggregate gate. TMS34010ExpandAggMem splits aggregate load/stores before LowerI64 and ExpandNarrowMem so no byte offset is added to a bit address.
  • Runtime and formats. The 1990 SDK flib.lib (GSP soft-float) and rts.lib are linked with the 1987 GSPA/GSPLNK tools (the $ symbols need no alias; the 1990 tools are OS/2-only). The shared conformance shim implements printf/sprintf with %d %i %u %o %x %X %p %c %s %%, h/hh/l/ll, %ld/%lu/%lld/%llu, %f, width/precision (including *) and %s precision. %c honours width and - (space padding; 0 is not meaningful and is ignored). %f precision is capped at 6 and the integer part at 2^31-128; sprintf has a 256-byte cap and returns the untruncated length; there is no snprintf. %e/%g/%a/%F, %n, positional $, %j and wide formats remain unsupported (no libm, 32-bit shim reads); %z/%t work. A linked-runtime gate checks 587 output bytes exactly and the flib entries plus the rts-backed _isascii in the GSPLNK map at -O0 and -O2.
  • Conformance. The pins are GCC 16.2.0 (SHA-256 e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e) and c-testsuite 5c7275656d751de0e68b2d340a95b5681858ed07. The curated c-torture list is 79 tests (59 M5 + 20 M6). The M5 gate passes 79/79 at -O0 and -O2; the M6 wrapper runs all 79 at -O0 and the committed 20-test bounded -O2 subset. The shipped c-testsuite tier is 48 pass / 172 skip / 220 with exact stdout (curated; every skip has a reason and there are no crashes). M7.4 runs the full corpus through the same runner, independent of that curated list, and reports 210 pass / 10 skip / 220. Generic is 197 files with 149 pass / 48 unsupported / 0 crash (M6 was 146/51; M7.1's .data extension lets three former expected-fails compile).

Known M6 limitations closed by M7.1: the general -O2 p += n over-scale (the bit-pointer barrier), the sub-byte record-stride warning gap (now diagnosed, layout still byte-rounded) and the .data aggregate/bitfield/i64-global initializer gap. Remaining M6 limitations are the GSP value/%f/printf caps, the explicit-sret rejection, the byte-rounded sub-byte stride itself (diagnostic only), and the odd-offset raw-GSPA pointer shape. The M6 native-linker/.cinit gap is closed by M7.2 (see "What M7.2 provides").

M9/M10 boundary. M7, M8 and M9 are complete. M7.1 delivered the -O2 bit-pointer barrier, the sub-byte stride diagnostic and the .data aggregate-initializer extension; M7.2 the debug object sections, .cinit and tools/tms-link (including public long names); M7.3 the six wider Xlib entries, xmore, the stderr stream and the deferred hardware harness; M7.4 the full external suites, the i64 divide/remainder fast path and the conformance-loader COFF repair. M8.1 added native ar archive linking with GSPLNK parity; M8.2 multi-TU DWARF merging; M8.3 the bit-op lowering, the 64/32 i64 divide path, 20 full-suite flips and per-test loader budgets; M8.4 the final M8 docs and boundary. M9.1 fixed vector .data and inline-asm r (22 flips), M9.2 added the DWARF v5 form gate and .debug_rnglists coverage, M9.3 the single-DIVU 64/32 path, and M9.4 the final M9 counts and boundary. Real-hardware confirmation is still deferred (the unit is away); MAME plus the existing dwt loader is the acceptance environment, and VT1200_HOST enables the real run without changing the gate. M10 owns the remaining conformance classes (blockaddress, vector runtime, inline-asm memory constraints, nested functions, VLAs, sret/aggregate/variadic/float returns, libm, runtime aborts), the pre-existing pr63843 hang, further performance work and the real VT1200 run once the unit is available.

What M5 provides

M5 added the native object path and the first external conformance tier while keeping the M4 assembly path as the oracle; M6 builds the language/runtime surface on top. The M5 state below is the baseline.

  • Native TI-COFF objects. llc -march=tms34010 -filetype=obj writes a relocatable TI-COFF object with .text/.data/.bss, three section symbols with GSPA's 18-byte aux records, C_EXT globals and undefined externals, and 10-byte R-RELLONG (0x11) relocations whose addends are bit addresses. GSPLNK 2.00 links the object (same-section 0xFFFF, cross-section section symbols, and section-0 externals), and the existing dwt loader runs the linked image. Sizes in the object are bits, as in GSPA; .data and .bss are word-granular because the loader requires whole 16-bit words. At M5 there was no new linker and no new object format: the M4 asm path is unchanged and is still the default in scripts/m4/run.sh. M7.2 adds tools/tms-link plus the optional .cinit/.debug_* sections while keeping GSPLNK as the oracle (see "What M7.2 provides"). scripts/m5/native.sh and scripts/tests/m5/native.sh build xshow and the six-TU termtris through the object path; the native and asm linked .text decode to the same instruction streams (757 xshow and 6,135 termtris instructions), and the native termtris links .text 166,608 bits (20,826 bytes), .data 9,536 bits (1,192 bytes) and .bss 121,808 bits with loader status 0.
  • Full MC layer. TMS34010MCCodeEmitter, MCAsmBackend, the TI-COFF MCObjectWriter/MCStreamer, an MCAsmParser and an MCDisassembler cover the supported instruction table. llvm-mc -triple=tms34010 assembles/disassembles it; encodings.s pins 126 -show-encoding cases, disassembler.s 77 inverse checks, and roundtrip.s 90 instructions round-trip through the 1987 dis34. The expected bytes come from GSPA listings, not from the new encoder. llvm-mc -filetype=obj uses LLVM's generic ELF writer; only llc -filetype=obj produces TI-COFF. The 10-byte MOVE @a,@b/MOVB @a,@b forms are not modeled and fail loudly.
  • JR and branch relaxation. Selection still builds the three-word absolute JAUC/JA<cc> branches; a pre-emit TMS34010BranchRelaxation pass then assumes the one-word relative JR/JR<cc> form and grows a branch back to JA* when its signed 8-bit word displacement is out of range (±127 words = ±2032 bits), zero, odd, or its target is unknown. The MC backend independently relaxes a symbolic JR with the FK_JR8 fixup, so llvm-mc input relaxes too. Relative to the M4 938-byte M3 image, 14 JR branches save 56 bytes and the MMTM/MMFM change saves another 8, giving 874 at M5. M7.3's six added ROM-import stubs add 36 bytes (6 × 6), so the M7.3 M3 image is 910 bytes (the all-JA baseline is 966); m5/jr.sh pins the current number and still requires exactly 14 in-range JRs.
  • MMTM/MMFM register-list saves. The prologue saves the callee-saved set with one MMTM SP, ... and the epilogue restores it with one MMFM SP, ... (ascending register list; MMTM mask 0xd400 / MMFM mask 0x002b for A0,A1,A3,A5). The old-STK slot, A13 save, A8 return and RETS 2 arithmetic are unchanged. For a list of n saved registers the old per-register sequence cost 4n bytes and the new pair costs 8: n=1 grows by 4 bytes, n=2 breaks even, n=3 saves 4 and n=4 saves 8.
  • alloca, byval, narrow returns and memcpy/memset. Dynamic alloca adjusts A14 in bits (size << 3), honors the requested alignment in bits, and supports stacksave/stackrestore; a no-argument function with a VLA rebuilds A14 from FP in the epilogue. byval copies the object to the program stack and advances A14 by alignTo(size,2) bytes (×8 bits). i8/i16 returns leave A8 with the declared zeroext/signext and the caller truncates/extends. Constant-size memcpy/memset become word/byte copies and runtime sizes become inline loops with bit-scaled GEPs. A constant memmove (including sizes <= 64 bytes, which PreISel leaves alone) is expanded by a target pass into the same overlap-safe forward/backward loops; no _memcpy/_memset/_memmove libcall is emitted. robust.sh checks alloca=408 byval=64 narrow=1056 mem=438 alloca_use=1496 byval6=64 memmove=2148 in both the asm and native paths.
  • Driver policies. -switch-to-lookup=false is gone. tms-clang runs clang → tms-bitaddr --bitptr → opt → --scale → --lower-bitptr → instcombine at -O2 (and --bitptr → --lower-bitptr at -O0): source GEPs and bit-offset pointer-int shapes are opaque @__tms_bitptr calls through opt, the post-opt --scale converts only the byte-indexed GEPs that opt introduces (the M4 switch and termtris lookup tables, and the .fca.N.gep loads that SROA creates when a returned aggregate is taken apart; +4 bytes must become +32 bits), --lower-bitptr restores the M0 bit-addressed inttoptr(add(ptrtoint,...)) form, and the final InstCombine restores the pointer-difference/late folding. The default -O2 p += n is correct (one scale), and the conformance shim's memmove uses the natural d += n (the M6 constant-step workaround is gone). -replexitval=never remains a documented tms-clang TMS34010 policy for the i33 IndVarSimplify closed-form shape even though i64 lowering exists: llc rejects a raw-pipeline i33 multiply with an actionable diagnostic (and keeps the 64-bit multiply diagnostic separate), and tms-clang -O2 rejects a static variadic definition before dead-argument elimination can drop its .... -O0 and the external sprintf still work.
  • Private-label cap. GSPA keeps only 31 identifier characters. M5 keeps the _<8 hex> module token, caps the base at 22 characters, and folds a longer base into a second 8-hex token before appending the module token, so two TUs with the same long static name still link. Public names longer than 31 characters were GSPA-truncated on the asm path; the M7.2 object/linker path preserves the full name.
  • Conformance fixes. The tier exposed and fixed several real defects: SETF16 must be sign-extending (SETF 16, 1, 0, 0x0570; fe=0 would zero-extend), a PHI copy can land between CMP and Jcc (MOVE writes the flags), so selection now emits a fused CMPBR/CMPIBR that is split after register allocation, and gc.statepoint calls get a target diagnostic instead of a StatepointLowering assertion. Object-mode .bss word granularity and the object SRAK/SRLK encoding were fixed as well.
  • M3 tightening. m3-cmpi.ll pins the -O0/-O2 MOVI order with CHECK/CHECK-NEXT, and scripts/m3/dis-roundtrip.sh parses the nine-argument XCreateSimpleWindow pushes by value/register instead of hardcoding the registers.
  • Conformance tier. scripts/tests/m5/conformance/run.sh compiles a test with tms-clang, links the shim.c + entry.asm harness (native TI-COFF first, asm/GSPA fallback for the exploratory runner), runs it in MAME through the pinned loader, and compares a status/stdout/stderr block (01B00000, 01B10000, 01B30000; the length cells are 01B00020 and 01B00060). The c-testsuite tier forces --mode native, so an asm fallback is a gate failure. classify.sh rejects unsupported features with a reason; a skip is never a pass. The corpus is pinned to GCC 16.2.0 (gcc-16.2.0.tar.xz, SHA-256 e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e) and c-testsuite commit 5c7275656d751de0e68b2d340a95b5681858ed07, materialized under the ignored vendor/conformance (test-only; GCC is GPL and c-testsuite keeps its own per-test licenses; neither is distributed). The GCC version is only the c-torture corpus source; the compiler under test is tms-clang. The shipped tiers at the M9 head are LLVM CodeGen/Generic (197 .ll: 151 pass / 46 unsupported / 0 crash, plus a 24-file curated allowlist), GCC c-torture execute (curated 79/79 at -O0 and -O2; M6 Task 8 expanded the shared list from 59 to 79), and c-testsuite single-exec (curated 48 pass / 172 skip / 220, with exact .c.expected output). M9 re-runs the full corpora end-to-end through the classifier and runner: c-torture 1,692 = 1,408 pass / 284 skip / 0 fail / 0 crash, c-testsuite 220 = 210 pass / 10 skip / 0 fail / 0 crash (all 1,912 = 1,618 / 294 / 0 / 0). The shim provides printf/sprintf with a real va_list walk and %ld/%lld/%f plus width/precision, putchar/puts, exit/abort, a 16 KiB stdout buffer, a distinct 16 KiB stderr stream (fprintf/vfprintf/fputs/fputc/fwrite, length at 01B00060, bytes at 01B30000), and a small string/integer surface. stderr is compared exactly (--expect-stderr or ;stderr=), so a stderr-writing test is checked rather than skipped. On the reference machine the Generic gate takes about 6–7 minutes, the 79-test c-torture gate about 22–25 minutes and c-testsuite about 5–7 minutes; the serial MAME boot dominates.

What M4 provides (branch m4, the previous snapshot)

M4 closed the remaining Xlib path to a real image/event client and a full-game integration, still assembly-only on that branch. M5 keeps this as the regression baseline and adds the native object path beside it.

  • Function pointers and CALL Rs. A function pointer is a 32-bit bit address; an indirect call lowers to the one-word register call CALL Rs (GSPA 0x0920, dis34 call aN), with the same old-STK save, argument pushes, SETF fixup and RETS 2 as a direct call. Direct calls remain CALLA _sym. m4-fnptr.ll + scripts/tests/m4/fnptr.sh.
  • 32-bit multiply/divide. MPYS/MPYU/DIVS/DIVU with an odd destination (the even form is the Rd:Rd+1 pair and would clobber the next register); remainder is quotient + MPYS + SUB. There is no compiler multiply/divide helper in RTS.LIB; _div is only the C div() wrapper. m4-mul.ll + scripts/tests/m4/mul.sh.
  • Zero-extending and extending narrow loads. ZEXTLOAD/EXTLOAD i8/i16 lower to the sign-extending load plus ANDI 255/ANDI 65535; an i1 load is a byte load masked to one bit. m4-zext.ll, m4-anyext.ll, m4-i1load.ll.
  • Module-unique private labels. Every local symbol gets a custom 64-bit string-hash token (FNV-style, not canonical FNV-1a), so two TUs with literals no longer collide in GSPA's flat table; public names are unchanged. m4-private.ll and the two-TU scripts/tests/m4/private.sh. M5 caps a long private base so the module token survives GSPA's 31-character limit; see "What M5 provides".
  • i8/i16 fixed arguments (M4; M5 adds narrow returns). Promoted to a 4-byte stack slot; the caller sign/zero-extends per the parameter attribute and the callee truncates. i8/i16/i64/float/aggregate returns are rejected on m4; M5 adds i8/i16 returns in A8. m4-arg8.ll, m5-narrow-ret.ll.
  • Contiguous-stack varargs. Only the &last_fixed walk used by termtris' sprintf; no va_list/va_start/va_arg. Zero-fixed and i8/i16-anchor definitions are rejected. On m4, static variadic definitions can lose ... under -O2 dead-argument elimination; M5 adds the tms-clang diagnostic and the llc check, while the external termtris sprintf remains supported. m4-varargs.ll, m4-reject-vararg0.ll, m4-reject-vararg-narrow{,16}.ll, scripts/tests/m4/varargs.sh, m5-reject-static-vararg.ll.
  • Driver policies (M4 branch). scripts/tms-clang passes -replexitval=never (the i33 exit-value multiply is unselectable on this i64-less target); M5 keeps it as a documented policy and adds the llc diagnostic for the raw pipeline. M4 also passed -switch-to-lookup=false (a late byte-offset GEP after --scale would be read as a bit offset, an 8x address bug); M5 removed that flag for the switch-table GEP, and M6 Task 6 generalizes it: tms-clang keeps the pre-opt --scale (bit-addressed pointer casts) and scales every late byte GEP after opt, which also fixes aggregate-split .fca.N.gep loads. The known p += n over-scale from InstCombine canonicalizing a bit-offset inttoptr back into a GEP is documented above and worked around in the conformance shim's memmove; M7 owns the proper fix. All policies are driver-side because opt has no target machine.
  • X11R4 XImage/XEvent/XErrorEvent layouts and the image client. The real 32-bit packed offsets: XImage data 16, byte_order 20, bytes_per_line 40, bits_per_pixel 44, f 64, sizeof 88; XEvent 96; XErrorEvent 20 (with the explicit X11R4 object-size compatibility pad); Display.screens byte 0x90 / bit 0x480, Screen.root byte 0x8 / bit 0x40. The client draws a 1-bit LSBFirst checker through an aligned pixmap + XCopyArea (12-pixel phase) and 15 bands of 32 rows (the ROM request buffer is 16 KiB), with .bss at 0x01A00000 and prog at 0x018A0000. XCopyArea copies IMG_W - 12 = 628 source columns (0–627) to window x = 12–639, so the image's rightmost 12 source columns (628–639, the final 12 px of the last 32-px cell) are never displayed; that last cell is visible only as its left 20 px. The 12-pixel prefix at window x = 0–11 is filled with the preceding cell's colour, so the checker phase is shifted by 12 px inside the (20,20) window while the cells remain 32 px. It asserts the checker pixels, the real LK401 q (keycode 193 / keysym 0x71), window focus and zero X errors in MAME.
  • Corrected 30-entry v2.2 symbol table. XMapWindow is 0x3FD64F60 (MapWindow opcode 8); 0x3FD645B0 is XRaiseWindow (ConfigureWindow opcode 12, CWStackMode=Above). The XG block and the image/error-handler entries are validated by scripts/m4/validate-syms.sh and scripts/tests/m4/symbols.sh.
  • Pinned termtris. The full game builds with this compiler and the 1987 GSPA/GSPLNK + rts.lib, at the pinned vt1200-termtris commit, and runs board/move/panels/quit in MAME with real key injection, the 0x40000-bit prog region and the required thresholds. The tree is test-only (GPLv3).
  • Differential goldens. The 1987 TI compiler's function-pointer and image/struct-offset assembly is stored under scripts/tests/m4/diff/; the check compares ABI shape without running DOSBox.

What M3 provides (branch m3)

M3 adds integer control flow and the first compiled C Xlib client, still assembly-only:

  • Conditional and unconditional branches for i32 and pointer values: CMP/CMPI plus JAEQ/JANE, the signed JALT/JALE/JAGT/JAGE, the unsigned JALO/JALS/JAHI/JAHS, and JAUC for an unconditional jump. Ordinary while/for loops (subject to the M3 limitations below), if/else and ?: work; ?: expands to a compare plus a two-block diamond (SELECTCC), and setcc becomes that diamond over 1/0.
  • Integer ALU and shift operations: SUB, AND, OR, XOR, NEG, NOT, SLL, SRL, SRA, plus ADDI/ANDI/SLLK/SRAK/SRLK immediates.
  • The first compiled C Xlib window: XOpenDisplay, XCreateSimpleWindow (nine arguments in the ROM's order: display, root, x, y, width, height, border width, border, background), XMapWindow and XSync. All four go through validated ROM import stubs.
  • The ROM's Display/Screen field displacements are bit offsets 0x480 (Display.screens) and 0x40 (Screen.root), i.e. byte offsets 0x90 and 0x8 in scripts/m3/vt1200_xlib.h.
  • Misaligned accesses: MOVE/MOVB and the FS0/FS1 field-size forms have no alignment requirement on the TMS34010, so packed and bit-addressed struct fields select directly instead of being split into byte-wide accesses.
  • Nine m3-*.ll lit tests on the m3 branch (46 with the M2 suite); M4 removes five obsolete M2 refusal tests (m2-reject-arg8, m2-reject-call-arg8, m2-reject-call-indirect, m2-reject-call-vararg, m2-reject-vararg) and m3-reject-zext.ll, and adds 18 m4-* tests: 46 - 5 - 1 + 18 = 58 total with the M2 suite.

M3 remains an i32/pointer milestone. setcc is supported, but narrow (i8/i16) parameters and returns are still rejected. Branches on i64, floats, aggregates, varargs and indirect calls are not supported. The backend still emits assembly only.

M3 limitations

  • Narrow loads are sign-extending only. MOVB handles signed char and the FS0 MOVE handles signed short; unsigned char, unsigned short and _Bool loads need a zero-extending pattern that M3 does not have. They stop llc with a raw Cannot select, which m3-reject-zext.ll pins. M4 adds the zero-extending loads; do not assume general narrow-load support in M3.
  • -O2 loop exit-value rewriting is not lowered. IndVarSimplify can turn sumto's loop into a closed-form i33 multiply, which M3 cannot select. The M3 harness therefore builds branch.c with -replexitval=never. Ordinary while/for loops that keep a real back-edge and phi work. M4 adds multiply/divide and moves the -replexitval=never policy into scripts/tms-clang; see "What M4 provides".

What M2 provides (branch m2)

M2 replaces the M1 test convention with the TI ABI and stops at assembly:

  • llc -march=tms34010 -filetype=asm for straight-line i32/pointer functions with calls, frames and locals.
  • A caller saves A14 (STK) on the system stack, pushes arguments on the program stack in reverse order (each a 32-bit slot), emits CALLA, then re-establishes both field sizes (SETF 16,1,0, SETF 32,0,1).
  • A callee starts with SETF 16,1,0/SETF 32,0,1, saves the used A0–A7/A9–A12 registers and the old FP on the system stack, sets FP = STK, allocates the frame with ADDI, and restores both stacks in the epilogue. The first explicit argument is at FP(-32), the second at FP(-64), and so on; locals live at positive FP offsets.
  • void, i32 and pointer returns, in A8; RETS 2 when the function has explicit arguments, RETS 0 otherwise.
  • Initialized globals, string/byte-array literals and pointer initializers in .data; zero-initialized mutable globals stay in .bss. The loader copies .data along with .text.
  • ROM import stubs generated from symbols/vt1200-v22.syms. M2 consumes strlen only: _strlen: jauc 3FB458D0h. CALLA _strlen pushes the return PC, the stub jumps to the ROM, and the ROM's RETS 2 returns directly to our caller.
  • Thirty-seven llvm-lit/FileCheck tests under llvm/test/CodeGen/TMS34010/m2-*.ll, including negative tests that pin the loud refusals. The ABI/data coverage includes m2-returned, m2-returned-call, m2-call-noret, m2-data-align, m2-data-avail, m2-data-z64 and m2-data-i1.
  • End-to-end MAME and dis34 gates, plus a differential check against assembly generated once by the 1987 TI compiler (see below).

The TI ABI

M1 test convention (branch m1) TI ABI (M2–M9)
Integer/pointer arguments A0–A3, four maximum program stack via A14 (STK), pushed in reverse
Argument slots registers first at FP(-32), second at FP(-64), …
Return value A0 A8 for scalars; float/double/i64/aggregates use a caller-allocated hidden slot
Frame none; leaf functions only A13 FP, A14 STK, A15 system stack
Locals none positive FP offsets
Return instruction RETS 0 RETS 2 with arguments or a hidden return, RETS 0 without
Calls, callee-saves, stack args rejected required
Field size harness sets FS1/FS0 before entry FS0 = 16, fe = 1 (sign-extending) and FS1 = 32, set in the prologue and after every call

The callee-saved set is A0–A7 and A9–A12; A8 is the return register and A13–A15 are reserved. After n system-stack pushes the saved old STK is at SP + (n+1)*32, and RETS N pops the return PC and advances SP by 32 + 16N. FS0 must be 16 with the field-extension bit set (SETF 16,1,0, sign-extending) and FS1 must be 32 at function entry and immediately after every CALLA (SETF 16,1,0 then SETF 32,0,1), because ROM code may change either field size. FS0 drives short loads/stores and FS1 drives 32-bit words.

Compile C with clang (M11)

M11's headline command is the conventional one: after a single scripts/tms-sdk, plain clang --target=tms34010 compiles and links with no flags and no wrapper.

cd /home/arti/code/tms-c-compiler
scripts/tms-sdk                        # once: build + install the resource-dir sysroot

clang --target=tms34010 hello.c -o hello   # compile + link through tms-link
scripts/tms-run hello                  # prints status 0, magic 434F4E46 and stdout

# Conventional stages and options
clang --target=tms34010 -c hello.c -o hello.o   # relocatable TI-COFF
clang --target=tms34010 -S hello.c -o hello.s   # GSPA assembly
clang --target=tms34010 -E hello.c -o hello.i   # preprocessed (headers resolved)
clang --target=tms34010 -O0 -g a.c b.c -o app   # multiple TUs, optimization, debug
clang --target=tms34010 -nostdlib start.c -o x  # user _start, no CRT/libs
clang -### --target=tms34010 hello.c -o hello   # show the real compile + link jobs

The sysroot, the CRT, the 10 headers, libtms.a and the vendor flib.lib/rts.lib are all discovered from <resource-dir>/tms34010-unknown-none (override with --tms-sysroot=DIR); --tms-linker=PATH overrides the linker. python3 must be on PATH (the installed tms-link is a Python program). -nostartfiles drops crt0.o, -nodefaultlibs drops the default libraries, -nostdlib implies both. See "What M11 provides" for the layout and the known limitations.

Compile C with tms-cc

tms-cc is the Phase 1 usability driver, kept as a compatibility alias. It hides the bit-address IR barrier, llc, the OS/2/GSPA entry assembly and the native linker:

cd /home/arti/code/tms-c-compiler

# Compile, link with the freestanding conformance shim + entry, run in MAME.
scripts/tms-cc hello.c -o hello.coff
scripts/tms-run hello.coff          # prints status and captured stdout/stderr

# Raw stages when you need them
scripts/tms-cc -c hello.c -o hello.o   # relocatable TI-COFF
scripts/tms-cc -S hello.c -o hello.s   # GSPA assembly

# Multiple TUs, optimization, debug, extra libraries
scripts/tms-cc -O0 -g a.c b.c -o app.coff
scripts/tms-cc -L lib -l flib hello.c -o hello.coff
  • The default link uses the freestanding conformance shim (printf, sprintf, malloc/free, string functions) and its _start; use -nostdlib if your program provides all symbols/entry itself.
  • Default layout: .text 018A0000, .bss 01A00000, prog 40000h, ram 80000h; override with --text, --bss, --prog-len, --ram-len.
  • -l archives are resolved from -L dirs or the extracted SDK (build/m6-sdk, build/m4-sdk); the SDK flib.lib/rts.lib are linked by default for the shim's %f path.
  • The entry is assembled with the 2ine OS/2 tools when present, otherwise DOSBox/GSPA; linking always uses tools/tms-link.
  • -g is supported for -c objects (and the link pipeline); the linked load image is stripped as usual.
  • The target is freestanding: no hosted libc or file I/O; tms-run reads the conformance result block. For X11/ROM-call programs, use the M4 harness and scripts/m4/x11m4.h.

scripts/tms-clang is now a thin flag mapper over native clang: it keeps its argument parser and TMS_CLANG/TMS_CLANG_EXTRA_FLAGS overrides, then execs clang --target=tms34010 with the requested -O0/-O2, -g, -I and -S -emit-llvm -o OUT.ll. The bit-address barrier, the compile defaults and the static-variadic guard all live in the target now, so the wrapper carries none of them. Native clang --target=tms34010 -c is correct for pointer code at -O0 and -O2 (M10).

Run the M12 gates

These are the documented commands on branch m12; all must pass. The MAME and conformance gates are slow, share the M4 SDK image, and must run serially (no two gates at once). The M12 gate list is the M7.1/M7.2/M7.3/M7.4/M8.1/M8.2/M5/M6 list plus the M9.1/M9.2 lit additions and DWARF form/rnglists gate (step 3g), the fresh end-to-end two-tier suite and the four-phase i64 performance gate (step 3f), the M10 gates (step 3h), the M11 gates (step 3i: the sysroot installer, the llc-built CRT, and the single-command end-to-end build), and the M12 triage harness (evidence only; it does not gate a count). The serial M0–M8 gate list is 58 invocations across 54 distinct gate scripts, all passing (the four env-variant re-runs are m5/native.sh, m6/runtime.sh, m6/i64.sh and m4/run.sh) and the hardware gate prints HARDWARE: DEFERRED. The count change from M11 is: TMS34010 lit 132 → 142 (128 → 137 CodeGen + 4 → 5 MC) and clang 13 → 15 (10 → 12 CodeGen, 2 Driver, 1 Sema), for 157 lit in total. The fresh full-suite total is 1,912 = 1,635 pass / 277 skip / 0 fail / 0 crash.

# 0. One-time SDK install (the M11 acceptance precondition)
scripts/tms-sdk                          # resource-dir sysroot; no flags after
# 1. Build llc, the assembler/disassembler driver and dwarfdump
ninja -C build/llvm-clean-build -j4 llc clang opt llvm-mc llvm-dwarfdump llvm-ar

# 3i. M11 gates (hermetic except e2e's sysroot install)
scripts/tests/m11/sdk.sh                 # sysroot layout + idempotent rebuilds
scripts/tests/m11/crt.sh                 # llc-built CRT linked and run
scripts/tests/m11/e2e.sh                 # single-command build, all sub-cases

# 2. LLVM codegen tests: 137 passed
#    (34 m2-* + 8 m3-* + 18 m4-* + 15 m5-* + 29 m6-* + 11 m7-* + 2 m8-*
#     + 9 m9-* + 2 m10-* + 9 m12-*)
build/llvm-clean-build/bin/llvm-lit -v \
  build/llvm-clean/llvm/test/CodeGen/TMS34010

# 3. MC tests: 5 passed (encodings, disassembler, round-trip, JR range, jump Rd)
build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/llvm/test/MC/TMS34010

# 3b. Clang tests: 15 passed (12 CodeGen + 2 Driver + 1 Sema)
build/llvm-clean-build/bin/llvm-lit -v \
  build/llvm-clean/clang/test/Sema/tms34010-subbyte-stride.c \
  build/llvm-clean/clang/test/CodeGen/TMS34010 \
  build/llvm-clean/clang/test/Driver/tms34010-defaults.c \
  build/llvm-clean/clang/test/Driver/TMS34010-link.c

# 3h. M10 gates (hermetic; the equivalence gate compiles the whole corpus
#     through native clang and the frozen M9 oracle)
scripts/tests/m10/equivalence.sh       # -O0 / -O0 -g byte identity + -O2 shapes
scripts/tests/m10/bitaddr-idempotent.sh # "tms.bitaddr" flag re-entry

# 3a. M7.1 correctness/ABI gates (MAME; run serially)
scripts/tests/m7/pointer-o2.sh         # default -O2 p += n + natural memmove
scripts/tests/m7/stride.sh             # sub-byte array/nested stride diagnostic
scripts/tests/m7/data.sh               # .data i64/aggregate/bitfield, raw+native

# 3c. M7.2 object/debug/native-linker gates
tools/tms-link/tests/run.sh            # linker unit/self-test (loud failures)
scripts/tests/m7/link.sh               # tms-link vs GSPLNK bytes/symbols
scripts/tests/m7/oracle.sh             # both images in MAME, dis34, exact C_EXT
scripts/tests/m7/cinit.sh              # TI .cinit table + copy loop in MAME
scripts/tests/m7/longname.sh           # 45-char public name across two TUs
scripts/tests/m7/debug.sh              # -O0 exact DWARF + -O2 -g dwarfdump smoke

# 3d. M7.3 wider-Xlib and hardware gates (MAME; run serially)
scripts/tests/m7/xlib.sh               # xmore: 36-entry table, 0 X errors, stage 14
scripts/tests/m7/hardware.sh           # marker COFF (tms-link + GSPLNK oracle)
# -> HARDWARE: DEFERRED without a unit; the MAME cells are the acceptance.
# On the real unit (rdebug TCP 771; stock v2.2: MAC 08-00-2B-16-4B-5A,
# real unit IP 100.103.100.103; the emulator lab is 192.168.99.2):
VT1200_HOST=100.103.100.103 scripts/tests/m7/hardware.sh
# -> runs hostload.py --marker --coff ... --tag hwmark and propagates failure

# 3e. M8.1 native archive/library and M8.2 multi-TU DWARF gates (MAME; serial)
scripts/tests/m8/native-lib.sh         # FLIB/RTS through tms-link, GSPLNK parity
scripts/tests/m8/dwarf-multi.sh        # two -g TUs, dwarfdump, stripped MAME
M5_NATIVE_LINKER=tms-link scripts/tests/m5/native.sh
M6_LINKER=tms-link scripts/tests/m6/runtime.sh
M6_LINKER=tms-link scripts/tests/m6/i64.sh
# -> the M5/M6 library links accept tms-link; GSPLNK stays the default/oracle

# 3f. full external suites (two-tier: bare default ~35 min; serial) and
#     the four-phase i64 performance gate (MAME; serial)
scripts/m8/setup-os2.sh            # once: direct 2ine + qemu-i386 fallback
LLVM_BIN=$PWD/build/llvm-clean-build/bin \
  scripts/tests/m7/full-suite.sh --corpus all --work build/m12-final
# -> c-torture 1692 = 1425 pass / 267 skip / 0 fail / 0 crash
#    c-testsuite 220 = 210 pass / 10 skip / 0 fail / 0 crash
#    all 1912 = 1635 pass / 277 skip / 0 fail / 0 crash
# The bare tier is the driver default (M5_CONFORMANCE_BARE=1). The explicit
# 10-test full-loader exception list is scripts/tests/m7/full-suite.full-loader;
# the curated M5/M6 gates below are the full-loader tier by default
# (M5_CONFORMANCE_BARE=0). The fresh TSV/report are in build/m12-final
# (full-suite-results.tsv / full-suite-report.txt); the M12 abort triage is
# scripts/tests/m12/abort-triage.sh --work build/m12-abort-triage (evidence).
scripts/tests/m7/i64div.sh             # fast/slow/wide/div32 DIVU paths in MAME
# -> M7 I64DIV PERF: PASS; fast_frames=88 slow_frames=3302 wide_frames=221
#    div32_frames=120 ratio=37.5 wide_ratio=14.9 div32_ratio=1.8
#    status=600D600D
#    cs_fast=000000011E6F9AB4 cs_slow=00000000007512AE
#    cs_wide=F56810CFEDA9D656 cs_div32=00002C61C63842EE

# 3g. M9.2 DWARF v5 form gate and two-TU .debug_rnglists fixture (hermetic)
scripts/tests/m9/dwarf-ranges.sh       # dwarfdump ranges/addresses, single-TU bytes
# -> M9 dwarf-ranges: PASS

# 4. M6 language/runtime gates (MAME; run serially)
scripts/tests/m6/spike.sh              # hand-written flib/rts ABI probe
scripts/tests/m6/i64.sh                # long long ABI/arithmetic/memory
scripts/tests/m6/float.sh              # float/double soft-float, -O0 and -O2
scripts/tests/m6/varargs.sh            # va_list/va_start/va_arg/va_copy
scripts/tests/m6/bitfield.sh           # TI packed layout and lowering
scripts/tests/m6/aggregate.sh          # aggregates by value and return
scripts/tests/m6/runtime.sh            # linked flib/rts + printf/sprintf, both -O levels
# i64/varargs/bitfield default to -O0; run the -O2 level with
# I64_OPT=-O2 / VARARGS_OPT=-O2 / BITFIELD_OPT=-O2.

# 5. Native object, link and MC round-trip
scripts/tests/m5/object-smoke.sh      # native .text == GSPA .text
scripts/tests/m5/native-link.sh       # GSPLNK link + loader/MAME markers
scripts/tests/m5/mc-roundtrip.sh      # 90 instructions through dis34

# 6. The real M4 clients through the native object path
scripts/tests/m5/native.sh
# -> native xshow markers + termtris board/move/panels/quit + dis34 compare
scripts/tests/m5/jr.sh                 # JR/relaxation + M3 MAME
scripts/tests/m5/mmtm.sh               # MMTM/MMFM + M2/M3 MAME
scripts/tests/m5/robust.sh             # alloca/byval/narrow/mem, both paths

# 7. Driver policy, private names and the conformance harness
scripts/tests/m5/policy.sh
scripts/tests/m5/private-long.sh
scripts/tests/m5/conformance/selftest.sh

# 8. The conformance tiers (curated M5/M6 gates are the full-loader tier;
#    M5_CONFORMANCE_BARE=0 is their default, =1 selects the bare tier)
scripts/tests/m5/generic.sh            # Generic allowlist + no-crash sweep
scripts/tests/m5/c-torture.sh          # 79 tests at -O0 and -O2
scripts/tests/m5/c-testsuite.sh        # 48 output tests + 172 reported skips
scripts/tests/m6/c-torture.sh          # 79 at -O0 + the 20-test bounded -O2 subset
scripts/tests/m6/c-testsuite.sh        # 48 exact-output tests at -O0

# 9. M4, M3 and M2 regressions and the GEP tool
scripts/tests/m4/run.sh
M4_NATIVE=1 M4_LINKER=tms-link scripts/tests/m4/run.sh
scripts/tests/m4/dis-roundtrip.sh
scripts/tests/m4/layout.sh
scripts/tests/m4/symbols.sh
scripts/tests/m4/termtris.sh
scripts/tests/m4/diff/check.sh
scripts/tests/m4/unsigned.sh
scripts/tests/m4/private.sh
scripts/tests/m4/mul.sh
scripts/tests/m4/fnptr.sh
scripts/tests/m4/varargs.sh
scripts/tests/m3/run.sh
scripts/tests/m3/dis-roundtrip.sh
scripts/tests/m3/layout.sh
scripts/tests/m3/diff/check.sh
scripts/tests/m3/diff/negative-control.sh
scripts/tests/m2/run.sh
scripts/tests/m2/dis-roundtrip.sh
scripts/tests/m2/diff/check.sh
tools/tms-bitaddr/tests/run.sh

scripts/fetch-conformance.sh materializes the pinned corpora under the ignored vendor/conformance (GCC 16.2.0 gcc.c-torture/execute and c-testsuite single-exec; vendor/conformance/PINS records the pins). scripts/tests/m6/runtime.sh extracts the 1990 SDK flib.lib/rts.lib into build/m6-sdk on first use (the SDK is a prerequisite; nothing is vendored). The gate log prints each tier's counts; skipped tests carry a feature reason and are never counted as passes. The conformance tiers run serially because M4_SDK is shared; the MAME boot dominates the runtime.

Run the M4 gates (branch m4; also green on m5–m12)

These are the documented commands on branch m4; all must pass. On branches m5–m12, use the M12 list above (it includes llvm-mc, llvm-dwarfdump, the M7.2 gates and the M5/M6 gates); the M4 commands below remain the historical regression set and use the m4 test counts. The MAME gates are slow and are run once.

# 1. Build llc, opt, clang and the test tools
ninja -C build/llvm-clean-build llc opt clang llvm-config FileCheck count not

# 2. LLVM codegen tests: 58 passed (32 m2-* + 8 m3-* + 18 m4-*)
build/llvm-clean-build/bin/llvm-lit -v \
  build/llvm-clean/llvm/test/CodeGen/TMS34010 --filter='(m2|m3|m4)-'

# 3. M4 image/event client in MAME (also runs layout.sh + validate-syms.sh)
scripts/tests/m4/run.sh
# -> m4 xshow: PASS (1-bit image + real q key + window focus + 0 X errors)

# 4. Linked .text decoded with dis34 (ROM stubs, CALL A?, SETF, RETS, checker)
scripts/tests/m4/dis-roundtrip.sh
# -> M4 dis34 round-trip: PASS

# 5. Layouts, the 36-entry symbol table, and the correction negative control
scripts/tests/m4/layout.sh
scripts/tests/m4/symbols.sh

# 6. The pinned termtris full-game integration
scripts/tests/m4/termtris.sh
# -> m4 termtris: PASS (board/move/panels/quit; .../termtris_*_3200.png)

# 7. Differential TI-compiler function-pointer/image ABI check (no DOSBox)
scripts/tests/m4/diff/check.sh
# -> M4 diff: PASS (goldens + negative controls)

# 8. The smaller M4 runtime gates
scripts/tests/m4/unsigned.sh
scripts/tests/m4/private.sh
scripts/tests/m4/mul.sh
scripts/tests/m4/fnptr.sh
scripts/tests/m4/varargs.sh

# 9. M2/M3 regressions and the GEP tool tests
scripts/tests/m3/run.sh
scripts/tests/m3/dis-roundtrip.sh
scripts/tests/m3/layout.sh
scripts/tests/m2/run.sh
scripts/tests/m2/dis-roundtrip.sh
scripts/tests/m2/diff/check.sh
tools/tms-bitaddr/tests/run.sh
# -> tms-bitaddr: PASS

scripts/tests/m4/run.sh first runs layout.sh and scripts/m4/validate-syms.sh, then compiles scripts/m4/xshow.c and scripts/m4/xgfix.c with scripts/tms-clang -O2, runs llc -march=tms34010 -O0 -filetype=asm, generates the ROM import stubs, concatenates scripts/m4/xshow-entry.asm, assembles/links with GSPA/GSPLNK 2.00 under DOSBox, loads the COFF in MAME, injects the real LK401 Q, and requires the checker pixels, quit=1, keycode 193 / keysym 0x71, xerrors=0, focus 0x400001 and the last event KeyPress. The 12-pixel prefix is checked as the preceding checker cell in bands 0 and 1.

scripts/tests/m4/termtris.sh runs the pinned tree through scripts/m4/termtris/build.sh and play_keys.sh; it enforces loops >= 100 for all four modes, events >= 6 for move/panels/quit (>= 2 for board), quit = 1 only for quit, focus = the created termtris window, status=0 (OK) and a non-empty screenshot each time. The vendored tree is test-only (GPLv3).

scripts/tests/m4/diff/check.sh is the new CI golden check. It compiles our function-pointer and image equivalents with scripts/tms-clang + llc and compares ABI shape with scripts/tests/m4/diff/ti-fnptr.s and ti-image.s: an indirect CALL A?, the old-STK save, argument/return/RETS 2, ten XCreateImage and ten XPutImage pushes (the plan's 10/9 is a typo; XPutImage takes display, drawable, gc, image, src_x, src_y, dest_x, dest_y, width, height), nine XCreateSimpleWindow pushes, the leading constant/Display-last order, and the Display/Screen/XImage bit displacements. It then mutates copies of the goldens (removing the indirect call and reversing the XPutImage argument pushes) and requires the check to fail; the stored goldens are not modified. The goldens were generated once with GSP C Compiler 2.01 under DOSBox; CI never runs DOSBox.

Paths are overridable with TMS_CLANG, TMS_OPT, TMS_BITADDR, TMS_LLC, MAME, DOSBOX, SDK_IMG, the per-gate work/COFF variables and M4_SYMS. M4_NATIVE_SKIP_ASM=1 skips the native run's GSPA .s arm when a source is intentionally raw-rejected (used by scripts/tests/m7/data.sh for the odd-offset pointer); the default native gate still exercises both arms.

Run the M3 gates (branch m3)

These are the documented commands on branch m3; all must pass.

# 1. Build llc, opt, clang and the test tools
ninja -C build/llvm-clean-build llc opt clang llvm-config FileCheck count not

# 2. LLVM codegen tests: 46 passed (37 m2-* + 9 m3-*)
build/llvm-clean-build/bin/llvm-lit -v \
  build/llvm-clean-build/test/CodeGen/TMS34010 --filter='(m2|m3)-'

# 3. Layout/symbols, then compile, assemble, link and run in MAME
scripts/tests/m3/run.sh
# -> layout.sh: PASS (Display.screens=0x480, Screen.root=0x40; ...)
# -> M3 MAME: PASS
#    (display/root/window nonzero, sum=55 max=22 lt=1, screens=0x480 root=0x40)

# 4. Rebuild the COFF and check the GSPA encodings with dis34
scripts/tests/m3/dis-roundtrip.sh
# -> M3 dis34 round-trip: PASS

# 5. Differential TI-compiler control-flow/Xlib check (no DOSBox)
scripts/tests/m3/diff/check.sh
# -> M3 diff: PASS

# 6. Negative controls: the same check must reject a wrong TI displacement
scripts/tests/m3/diff/negative-control.sh
# -> M3 diff negative controls: PASS

# 7. GEP scaling/normalization tool tests
tools/tms-bitaddr/tests/run.sh
# -> tms-bitaddr: PASS

scripts/tests/m3/run.sh first runs scripts/tests/m3/layout.sh (the ROM's 0x480/0x40 bit displacements in both our asm and the 1987 golden) and scripts/m3/validate-syms.sh (the four Xlib imports), then compiles scripts/m3/branch.c, layout.c and xhello.c with scripts/tms-clang -O2, runs llc -march=tms34010 -O0 -filetype=asm, generates the per-ROM import stubs, concatenates the result with scripts/m3/entry.asm, assembles/links with GSPA/GSPLNK 2.00 under DOSBox, and loads the COFF in MAME. branch.c is built with opt -replexitval=never, because the default exit-value rewrite turns sumto's loop into an i33 multiply that this target cannot select; the loop itself is the point of the test.

The MAME run pins VT1200_MONITOR=VR319 (the real 2048-bit row pitch) and checks the ABI markers — nonzero display/root/window ids, sumto(10) == 55, max2(20, 22) == 22, lt(5, 7) == 1, layout_screens() == 0x480, layout_root() == 0x40 — and, decisively, two all-white 32-bit client words in VRAM at (150,150) and (250,200) inside the mapped window. A markers-only run or a root-window bit is a failure. Paths are overridable with TMS_CLANG, TMS_OPT, TMS_BITADDR, TMS_LLC, MAME, DOSBOX, SDK_IMG, M3_WORK, M3_COFF and M3_SDK.

scripts/tests/m3/dis-roundtrip.sh rebuilds through the normal GSPA/GSPLNK path and uses dis34 to check the linked Xlib stubs (JAUC to the ROM bit addresses), the nine-argument XCreateSimpleWindow push order, the branch code (CMP, JALT, JAGT, JAEQ, JAUC, LBB… labels), the old-STK restore offsets, and the "0::0" .data bytes.

scripts/tests/m3/diff/check.sh is the CI golden check. It compares the ABI shape of our assembly with stored output from the 1987 TI compiler for the same K&R sources: a conditional branch and an unconditional loop back-edge in sumto, a conditional branch in max2, the function's last RETS being RETS 2, nine XCreateSimpleWindow argument pushes, and the 0x480/0x40 bit displacements. The displacements must appear in the load that uses them (TI *A7(1152) and *A7(64),*FP(32),1; ours an ADDI 1152/ADDI 64 feeding a load through the same register), with exact token boundaries, so an unrelated local at *FP(64), the constant 0x400, or a prefix such as 0x4800 cannot satisfy them. scripts/tests/m3/diff/negative-control.sh mutates the stored TI displacement to 512 (and to 0x4800) and requires check.sh to fail. The check does not verify the result register or argument order: the MAME gate checks the returned values and dis-roundtrip.sh checks the push order. It does not compare instruction selection byte-for-byte. The stored ti-branch.s and ti-xhello.s were generated once with gspcpp/gspcc/gspcg (GSP C Compiler 2.01) under DOSBox; CI never runs DOSBox, it greps the stored files. As in the MAME gate, branch.c must be built with -replexitval=never; the default exit-value rewrite turns sumto's loop into an unselectable i33 multiply.

Run the M2 gates (branch m2)

These are the M2 commands; they also pass on m3 (verified on branch m3 on 2026-11-11: M2 MAME: PASS, M2 dis34 round-trip: PASS, M2 diff: PASS). The M1 harness and suite are on branch m1 and are not M2 gates: they encode the retired M1 register convention.

# 1. Build llc, opt, clang and the test tools
ninja -C build/llvm-clean-build llc opt clang llvm-config FileCheck count not

# 2. LLVM codegen tests: 37 passed
build/llvm-clean-build/bin/llvm-lit -v \
  build/llvm-clean-build/test/CodeGen/TMS34010 --filter='m2-'

# 3. Compile, assemble, link and run in MAME
scripts/tests/m2/run.sh
# -> M2 MAME: PASS
#    (check=4 first=20 second=22 caller=42 locals=7 keep=16)

# 4. Rebuild the COFF and check the GSPA encodings with dis34
scripts/tests/m2/dis-roundtrip.sh
# -> M2 dis34 round-trip: PASS

# 5. Differential TI-compiler ABI check (no DOSBox)
scripts/tests/m2/diff/check.sh
# -> M2 diff: PASS

# 6. GEP scaling/normalization tool tests
tools/tms-bitaddr/tests/run.sh
# -> tms-bitaddr: PASS

scripts/tests/m2/run.sh compiles five C inputs with scripts/tms-clang -O2, runs llc -march=tms34010 -O0 -filetype=asm on the normalized IR, generates the per-ROM import stubs, concatenates the result with scripts/m2/entry.asm, assembles/links with GSPA/GSPLNK 2.00 under DOSBox, then loads the COFF in MAME. It checks strlen("0::0") == 4, two-argument order, a direct call, a local frame, and callee-saved preservation. Paths are overridable with TMS_CLANG, TMS_OPT, TMS_BITADDR, TMS_LLC, MAME, DOSBOX, SDK_IMG, M2_WORK, M2_COFF and M2_SDK.

dis-roundtrip.sh runs the same build and disassembles the linked .text with the VT1200 tree's dis34, checking the TI-ABI instructions at their linked bit addresses, the old-STK restore offset against the push count, and the copied .data bytes.

scripts/tests/m2/diff/check.sh is the CI golden check. It compares the ABI shape of our assembly with stored output from the 1987 TI compiler for the same K&R sources: first argument at FP(-32), second at FP(-64), result in A8, RETS 2 for add2, a nonzero frame and RETS 0 for locals. It does not compare instruction selection byte-for-byte. The stored ti-add2.s and ti-locals.s were generated once with gspcpp/gspcc/gspcg (GSP C Compiler 2.01) under DOSBox; CI never runs DOSBox, it greps the stored files.

.data, strings and the loader

GSPA 2.00 has no ELF sections. The compiler emits raw .data text, never .rodata, .asciz, .p2align or .section:

  • i8 scalar or byte/string array: .byte with GSPA hex (068h)
  • i16 scalar: .word
  • i32 scalar: .long
  • i64: two .long words, LSW first (0x1122334455667788 → .long 55667788h, .long 11223344h); i24/i40/i48/i56 emit exactly 3/5/6/7 value bytes
  • packed structs/records, unions and bitfield storage: recursive emission at the DataLayout offsets with zero padding, exact little-endian bytes at odd byte offsets (GSPA implicitly word-aligns .word/.long, so the raw path uses .byte sequences there)
  • arrays: element-wise recursion; i64 elements are supported and each element carries its allocation-stride padding
  • aggregate zero: the whole getTypeAllocSize image, including record and element padding
  • pointer: .long _symbol+<bit addend> (the addend is already in bits)
  • .even before a .data global whose alignment is at least 16 bits, so the label and the following .word/.long agree.

A scalar's directive must match its width, otherwise the next global's offset is wrong. GSPA's .even aligns to a 16-bit boundary only, so an explicit align 4/align 8 on a .data object is not honored: the target's standalone object alignment is 2 bytes. Private/local symbol names are sanitized to GSPA-safe names (_HH for non-alphanumerics). The native TI-COFF object path (llc -filetype=obj) emits the same recursive images with R-RELLONG pointer relocations whose addends are bit addresses; it can place a pointer at an odd byte offset, which raw GSPA text cannot (see below).

GSPA odd-offset pointer limitation. A non-null pointer field at an odd .data byte offset (for example a packed struct { char c; long long *p; }) cannot be represented in GSPA text: the only 32-bit relocatable directive is .long, which GSPA realigns, and a relocation cannot be split across .byte lines. The raw compile fails loudly with TMS34010: a pointer field at an odd .data byte offset cannot be represented in GSPA assembly; the native object path emits the unaligned bytes plus an R-RELLONG at the odd bit address, and scripts/tests/m7/data.sh links and runs that shape through GSPLNK/MAME.

Unsupported initializer shapes — vectors, i128, half/bfloat/fp128, non-byte-multiple i33..i63, and [N x i1] in raw mode — fail loudly with TMS34010: unsupported .data initializer (expected an integer of at most 64 bits, a pointer, f32/f64, a record/union, an array or a zero aggregate) and a specific detail. The old M2 message and the M2 "no i64 arrays" restriction are retired. Two intentional uniformity exceptions remain: a zero-initialized [N x i1] is rejected in raw mode but zeroed as opaque bytes in object mode (a non-zero ConstantArray<i1> is rejected in both), and an aggregate-zero record/array containing an otherwise unsupported member is zero-filled without inspecting the members; the bytes are exact zeros in both cases. Zero-initialized mutable globals remain .bss and are zeroed by the loader.

ROM imports

ROM entry points are per-ROM-revision bit addresses, kept out of the compiler in symbols/vt1200-v22.syms. scripts/m2/gen-rom-imports.sh turns each entry into an absolute-jump stub:

	.globl _strlen
_strlen:
	jauc 3FB458D0h

JAUC is the TMS34010 unconditional absolute jump; GSPA 2.00 rejects bare ja. M2 uses only strlen. M3 adds the four Xlib entries (XOpenDisplay, XCreateSimpleWindow, XMapWindow, XSync) and validates their stubs in scripts/m3/validate-syms.sh and in MAME; M4 extends the table to the image/event/GC/error-handler set, and M7.3 adds six wider entries (36 total), all validated by scripts/m4/validate-syms.sh. symbols/README.md records the evidence. Do not add another Xlib dependency until its ROM address/opcode passes that validator.

M2 non-goals

M2 deliberately rejects or omits:

  • Branches/control flow: conditional and unconditional branches, loops, and spill/fixup paths that need them. A branch that reaches ISel fails loudly; M3 owns control flow.
  • Floating point: float/double arguments, returns and arithmetic (M6).
  • Aggregates: structs/unions by value, sret, byval, bitfields (M5 adds byval; the rest are M6).
  • Varargs: ... functions and calls (M4 adds the contiguous form; general va_list is M6).
  • Function pointers and indirect calls (M4).
  • Tail calls: ordinary tail markers are demoted to ordinary calls; musttail is not implemented (M2 C does not emit it). Real tail calls remain a later milestone.
  • Narrow ABI types: i8/i16 parameters, i64, and narrow returns remain rejected. Narrow accesses inside a function are sign-extending only: MOVB for signed char and FS0 MOVE for signed short; zero-extending unsigned char/unsigned short/_Bool loads are M4 work.
  • Object output: no MCCodeEmitter, object writer, llc -filetype=obj, clang -c or native COFF. GSPA assembles and GSPLNK links the asm.
  • Xlib and clients: no X11 headers, Xlib calls or real VT1200 clients in M2; only the strlen ROM call.

The optimizer's returned argument attribute is accepted because it does not affect the stack-slot ABI; sret/byval/inreg/nest remain rejected.

M3 non-goals

M3 deliberately stops at the first window and ordinary integer control flow:

  • XImage/XEvent and the real client: no image transfer, event handling, full X11R4 headers or real VT1200 client (M4). M3 uses exactly the four Xlib calls above and no other Xlib entry.
  • Aggregates by value: structs/unions passed or returned by value, sret, bitfields (M5 adds byval; the rest are M6). Struct fields through pointers are supported.
  • Function pointers and indirect calls: the callee must be a direct global symbol (M4).
  • Floating point and i64: no float/double or 64-bit integer arguments, returns, arithmetic or branches (M6).
  • Object output: still no MCCodeEmitter, object writer, llc -filetype=obj, clang -c or native COFF; GSPA/GSPLNK produce the COFF. M5 adds the native path and the JR/branch-relaxation pass.
  • Varargs, musttail, narrow ABI parameters/returns: unchanged from M2.

M3 carry-forwards in M4

M4 closes three of the five final-M3 prerequisites: zero-extending loads replaced the reject test, private labels are module-unique, and unsigned/<= runtime coverage exists. The new M4 harness and scripts/tests/m4/dis-roundtrip.sh are operand/register-independent, and layout.sh was tightened. M5 completes the remaining M3 test-hardening carry-forwards: m3-cmpi.ll now pins the -O0/-O2 MOVI order with CHECK/CHECK-NEXT, and scripts/m3/dis-roundtrip.sh parses the nine XCreateSimpleWindow push values/registers instead of hardcoding them. The M3 MAME values are unchanged.

M5 non-goals and the M6 boundary

M5 closed the M4 gaps for the native object path, JR/relaxation, MMTM/MMFM, narrow returns, byval and the switch-table policy. It deliberately stopped before:

  • Floating point and long long: no float/double or i64 arguments, returns, arithmetic or branches; the i33/-replexitval policy stayed until the i64 lowering landed. M6 closes this.
  • General varargs: no va_list, va_start or va_arg; only the contiguous &last_fixed pattern used by termtris sprintf. M5 used that same pattern inside the conformance shim; true va_list tests were skipped. M6 closes this.
  • Bitfields and aggregates by value: bitfields, sret, aggregate returns and general aggregate arguments were unsupported; byval arguments and struct fields through pointers were supported. M6 adds packed bitfields and aggregate returns; an explicit sret pointer remains rejected because the TI ABI has no such argument.
  • Debug info and the wider Xlib surface: at M5 there was no debug info, and the M5 client uses only the validated image, event, GC, window and error-handler entries. It does not implement the whole Xlib surface, XGetImage, or XDestroyImage on a non-heap image. M7.2 adds object-path DWARF and M7.3 adds the wider Xlib surface (six validated entries and the xmore client, including a heap XGetImage round trip); the whole Xlib surface remains out of scope.
  • Full external suites and stderr (historical): the three tiers are curated subsets, not the full GCC/LLVM suites. At M5 the conformance shim captured stdout only, so tests that write stderr were skipped. M7.3 captures stderr exactly (--expect-stderr/;stderr=), and M7.4 runs the full pinned corpora through the classifier and runner (1,912 files, 336 reasoned skips, 0 fail, 0 crash). Tests whose required libc (stdio/file I/O, libm, wide characters, setjmp) is outside the freestanding shim are curated with a reason, not counted as passes.
  • Deeper libc/runtime coverage: M5's shim is freestanding and does not add RTS.LIB entries. M6 links the 1990 flib.lib/rts.lib and expands printf/sprintf; a broader libc surface remains later conformance work.
  • Native .cinit and public long names: at M5 the object writer accepted only .text/.data/.bss (termtris's .cinit is GSPA assembly and fails loudly if a C TU tries to emit it), and public identifiers longer than GSPA's 31 characters were truncated on the asm path (only private names are capped). M7.2 adds the .cinit object section, tools/tms-link and untruncated public names on the object path; the asm path keeps the limit.

The pinned GCC and c-testsuite trees are test-only and are not part of the compiler or project distribution (GCC is GPL; c-testsuite keeps its own per-test licenses). The 1990 SDK flib.lib/rts.lib used by the M6 runtime gates are likewise test/runtime inputs, extracted from the SDK into build/m6-sdk; they are not vendored or distributed.

Repository layout

build/llvm-clean/        compiler fork checkout used for M2–M9 (ignored)
build/llvm-clean-build/  its Ninja build tree (ignored)
build/m6-sdk/            extracted 1990 flib.lib/rts.lib (ignored, not vendored)
build/llvm-src/          M0 working fork (ignored)
patches/llvm/            frozen M0 patch series against llvmorg-23.1.5
tools/tms-bitaddr/       GEP scale/normalize/bitptr barrier tool
scripts/tms-clang        IR pipeline wrapper (clang + tms-bitaddr + opt)
scripts/m2/              M2 harness: C inputs, entry.asm, link.cmd, stubs, checks
scripts/m3/              M3 harness: branch/xhello/layout inputs, Xlib header, entry/link
scripts/m4/              M4 harness: unsigned/private/mul/fnptr/varargs, XImage client,
                         XG fix, termtris build, symbols validator
scripts/m5/              M5 harness: native entry/link files and long-private-name inputs
scripts/m6/              M6 harness: ABI spike asm, i64/float/varargs/bitfield/
                         aggregate/runtime drivers, GSP link command files, checkers
scripts/tests/m2/        M2 gates (run.sh, dis-roundtrip.sh)
scripts/tests/m2/diff/   TI golden asm and the differential ABI check
scripts/tests/m3/        M3 gates (run.sh, dis-roundtrip.sh, layout.sh)
scripts/tests/m3/diff/   TI branch/Xlib goldens, differential check + negative controls
scripts/tests/m4/        M4 gates (run/dis-roundtrip/layout/symbols/termtris and the
                         unsigned/private/mul/fnptr/varargs gates)
scripts/tests/m4/diff/   TI function-pointer/image goldens + the differential check
scripts/tests/m5/        M5 gates (object/link/MC/native/JR/MMTM/robust/policy/private)
scripts/tests/m5/conformance/
                         conformance runner, shim, entry, classifier, pins, manifests
scripts/tests/m6/        M6 gates (spike/i64/float/varargs/bitfield/aggregate/runtime
                         and the c-torture/c-testsuite wrappers)
scripts/tests/m7/        M7.1/M7.2/M7.3/M7.4 gates and drivers (pointer-o2/stride/data;
                         link/oracle/cinit/longname/debug/xlib/hardware;
                         full-suite/i64div)
scripts/m8/              M8 archive/library and multi-TU DWARF fixtures/checkers
scripts/tests/m8/        M8.1 native-lib and M8.2 dwarf-multi gates (+ COFF parity)
scripts/m9/              M9 DWARF rnglists fixtures and producer shapes
scripts/tests/m9/        M9.2 dwarf-ranges gate (v5 form gate + rnglists)
scripts/m1/              M1 harness (historical; also on branch `m1`, not an M2 gate)
scripts/tests/m1/        M1 gates (historical; also on branch `m1`, not an M2 gate)
scripts/tests/m0/        M0 integration tests
scripts/build-llvm.sh    fork or upstream+patches build
scripts/fetch-vt1200.sh  fetch the VT1200 RE tree at its pinned commit
spike/                   measurement corpus and reports
symbols/                 per-ROM import tables (v2.2 subset)
vendor/                  fetched assets and LLVM sources (ignored)
docs/                    design and plans

Prerequisites

cmake, ninja-build, ccache, a C++17 host compiler (GCC 14 is used here), Python 3, and about 20 GB of disk for the LLVM source and build. The M2–M9 MAME and dis34 gates additionally need dosbox, mtools (mcopy), the VT1200 SDK image, the dwt COFF loader, dis34, and a built MAME vt1200 binary (build/mame-src/vt1200). The termtris gate also needs the pinned vendor/vt1200-termtris tree (test-only). The conformance tiers need the pinned vendor/conformance corpora (test-only; see scripts/fetch-conformance.sh). The differential golden check needs no DOSBox/MAME/SDK; it needs only the built clang, opt, llc and tools/tms-bitaddr/tms-bitaddr. On Debian:

sudo apt-get install -y cmake ninja-build ccache dosbox mtools

Fetch the VT1200 assets

The compiler contract is checked against the VT1200 tree (TI hello.s, the Xlib call sequence, as34, dis34, SDKs, manuals). It is not vendored:

./scripts/fetch-vt1200.sh          # -> vendor/vt1200, pinned 17dfd24...

Build the compiler

Compiler fork (M11, the normal path)

The fork checkout already exists at build/llvm-clean on m11 (the milestone branch; m10 is the repository default pending the promotion). Build it in place:

LLVM_SRC=$PWD/build/llvm-clean LLVM_BRANCH=m11 ./scripts/build-llvm.sh
# binaries: build/llvm-clean-build/bin/{llc,llvm-mc,clang,opt,llvm-config,FileCheck}
# lit driver: build/llvm-clean-build/bin/llvm-lit

To clone the fork first instead of using an existing checkout:

LLVM_REPO=gitea@git.wut.ee:opencode.siil.arti.ee/llvm-tms34010.git \
LLVM_BRANCH=m11 ./scripts/build-llvm.sh

Fork mode never checks out, resets, cleans or patches the source tree; it only runs CMake and Ninja. Local commits on the branch are safe. Use LLVM_BUILD=... to keep a separate build directory. It builds llc, llvm-mc, clang, opt, llvm-config, FileCheck and the test helpers with X86 (host) and TMS34010; a first build takes roughly 20–40 minutes.

Upstream + patches (frozen M0 path)

./scripts/build-llvm.sh

This mode clones llvmorg-23.1.5, applies patches/llvm/*.patch, and builds build/llvm-clean-build. It owns and resets only a plain llvm-project clone: if build/llvm-clean has some other origin (for example the M2–M6 fork), it refuses rather than destroying it. Use fork mode for that checkout.

scripts/export-patches.sh regenerates the committed M0 patch series with git diff (including new files via git add -N); it is not used for M1–M6.

Build the M0 support tools

The M2–M9 pipeline uses tms-bitaddr (--scale, --normalize, --bitptr, --lower-bitptr) and tms-clang:

LLVM_CONFIG=$PWD/build/llvm-clean-build/bin/llvm-config \
  tools/tms-bitaddr/build.sh

M0 regression test (optional in M2–M9):

TMS_CLANG=$PWD/build/llvm-clean-build/bin/clang \
TMS_OPT=$PWD/build/llvm-clean-build/bin/opt \
TMS_BITADDR=$PWD/tools/tms-bitaddr/tms-bitaddr \
  ./scripts/tests/m0/run.sh
# -> M0 pipeline: PASS

Emit assembly or a native object by hand

# The driver defaults to the fork build (build/llvm-clean-build/bin); pass
# TMS_CLANG/TMS_OPT/TMS_BITADDR to override.
scripts/tms-clang -O2 -o /tmp/add2.ll scripts/tests/m2/diff/ti-add2.c

build/llvm-clean-build/bin/llc -march=tms34010 -O0 -filetype=asm \
  /tmp/add2.ll -o /tmp/add2.s
build/llvm-clean-build/bin/llc -march=tms34010 -O0 -filetype=obj \
  /tmp/add2.ll -o /tmp/add2.o        # TI-COFF, link with GSPLNK

The resulting function loads its arguments at FP(-32) and FP(-64), returns in A8, and ends in RETS 2. Always produce the IR with scripts/tms-clang before llc: raw clang IR carries byte GEP offsets, but llc treats every surviving GEP offset as a bit offset, so addresses would be 8× too small. Run llc -O0 on the bit-addressed IR that tms-clang already optimized and lowered.

At -O2, tms-clang runs clang → tms-bitaddr --bitptr → opt → tms-bitaddr --scale → tms-bitaddr --lower-bitptr → opt -passes=instcombine. --bitptr hides every source GEP (and source bit-offset pointer-int add) behind an opaque @__tms_bitptr(i32, ptr) call, so the optimizer cannot fold an already-bit address back into a byte GEP; after opt, every remaining GEP is one the optimizer created and indexes bytes (SROA's aggregate-split loads, switch tables), so --scale shifts exactly those by 3; --lower-bitptr restores inttoptr(add(ptrtoint,...)); the final InstCombine restores the M0 pointer folding. At -O0 the two barrier modes run back to back (no optimizer). This makes the default -O2 p += n correct with a single scale. If you feed already bit-addressed IR by hand, tms-bitaddr --normalize rejects a typed (non-i8 or switch.table.*) or vector GEP instead of emitting its byte offset as bits. The lit tests use llc -march=tms34010 -O2 -filetype=asm on hand-written IR to exercise the selector pipeline directly. -filetype=obj writes a TI-COFF object that GSPLNK 2.00 links; the existing loader runs the linked image. llvm-mc -triple=tms34010 assembles and disassembles the same instruction table.

M6 ABI foundation (Task 1)

The m6 branch keeps the M5 all-stack TI ABI. Task 1 fixed and proved the language-runtime contract that tasks 2/3/6 consume (the lowering itself is in the M6 sections above):

  • 1990 SDK libraries. flib.lib is the GSP-format floating-point library; flibc.lib/flibi.lib are identified as the 34082/IEEE variants from member-code inspection (not from running the OS/2-only 1990 compiler) and are not the M6 link input. rts.lib is the C runtime and has no 64-bit helper (_div/_ldiv are the 32-bit wrappers); i64 multiply/divide use target sequences.
  • Tools and symbols. The 1990 r5.01 tools are OS/2 1.x NE binaries and do not run under DOSBox; the 1987 GSPA 2.00/GSPLNK 2.00 tools link the 1990 TI-COFF libraries unchanged. The $ symbols (FS$ADD, FD$ADD, ...) need no alias. The exact link line is M6.OBJ + -l flib.lib + -l rts.lib with -e _start (scripts/m6/link.cmd); the symbol snapshot is scripts/m6/flib-symbols.txt.
  • flib result conventions. There are three, not one:
    • arithmetic (FS$ADD/SUB/MUL/DIV/NEG/INC/DEC and FD$...) pushes its result on A14;
    • compares (FS$EQ/NE/LT/LE/GT/GE and FD$...) pop both operands and return the boolean in A8, with nothing pushed;
    • conversions use A8 for the integer side: FD$FTOI/FTOU/ DTOI/DTOU pop the float/double from A14 and return the integer in A8; FD$ITOF/UTOF/ITOD/UTOD take the integer in A8 and push one float or two double words on A14; FD$FTOD/FD$DTOF pop and push. flib ends in RETS (not RETS 2), so the caller pops any pushed result and then restores A14 from the old-STK word it saved on the system stack. FS$SUB_R/FD$SUB_R (and the DIV_R pair) are for the reversed operand order.
  • GSP format. float is one 32-bit word; double is two GSP words with the least-significant word at the lower address. 1.5 is 40600000h (float) and 00000000h/400C0000h (double LSW/MSW); 4.0 is 41400000h and 00000000h/40280000h. This is not IEEE; do not mix flib.lib with IEEE constants. The compiler converts IR IEEE bits to GSP words as described in the M6 float section.
  • Hidden return. A float/double/i64/aggregate return is written by the callee into a caller-allocated slot immediately below the STK value the caller saved: float 32 bits, double/i64 64 bits, aggregate rounded to 16 bits. The caller does ADDI 32/64,STK, saves STK, pushes the arguments, and CALLA; the callee writes at saved_STK-size, restores A14 and RETS 2. A hidden-return call always saves STK, so it uses RETS 2 even with no explicit arguments. The one-slot float argument rule is pinned by the M6 float.sh gate (the 1987 K&R oracle promotes float parameters to double and does not independently pin it).
  • i64 word order. long long arguments occupy two 32-bit slots, and the argument and hidden-return stack slot is MSW-first (the high word at the lower address). A long long object in memory is the opposite: little-endian, LSW at the lower address, per design spec §4.1 and the e data layout. The two rules are separate: the stack slot is the M6 ABI choice pinned by the probe, while memory matches the optimizer/Clang layout (Task 5 corrected the original "big-endian memory" ruling). The Task 1/2 wording that called i64 memory big-endian is superseded.
  • Gate. scripts/tests/m6/spike.sh assembles the hand-written spike-entry.asm/spike-probe.asm, links flib.lib/rts.lib, loads the COFF with the existing dwt loader and runs it in MAME. It checks 13 markers covering float/double arithmetic, double and float hidden returns, the i64 two-slot return, FS$SUB push order, FS$EQ in A8, FD$FTOI/FD$ITOF, and a post-return marker after _m6_probe returns. It passes with M6: fs_add=41400000 fd_add=40280000/00000000 dadd=40280000/00000000 i64=2345678A/00000001 fsub=40400000 feq=1 ftoi=1 itof=40400000 fadd=41400000 ret=5A5A5A5A, loader status 0 and .text placed with 0 differing bytes. The full rule is in build/llvm-clean/TMS34010.md, "M6 state".

Later milestones

M7.1 completes the M6 correctness/ABI residuals (the -O2 bit-pointer barrier, the sub-byte stride diagnostic and the .data aggregate/i64/bitfield initializers). M7.2 is complete: object-path debug info, the .cinit object section, tools/tms-link and public long names, with GSPLNK as the permanent oracle. M7.3 is complete: the wider validated Xlib surface and xmore client, exact stderr capture, and the hardware marker harness with MAME-equivalent acceptance (the real-unit run is deferred; set VT1200_HOST to run it). M7.4 is complete: the full external suites, the i64 divide/remainder fast path and the final M7/M8 boundary. M8 is complete: native .lib archive linking in tms-link, multi-TU DWARF merging, the rotate/count/byte-swap lowering and 64/32 i64 divide path, 20 conformance flips and the final M8/M9 boundary. M9 is complete: vector .data and inline-asm r (22 flips), the DWARF v5 form gate and .debug_rnglists, the single-DIVU 64/32 path and the final M9/M10 boundary. M10 (Phase 2) is complete: native clang --target=tms34010 -c is correct for pointer code at -O0 and -O2 with no extra flags (the target owns the bit-address transform and its compile defaults), -O0 objects are byte-identical to the M9 path (46/46), and the full suite and every gate — including the -O2 float/aggregate/round-trip gates — stay green after a debug cycle that closed the -O2 bit-address aliasing gap (a BITADDR node plus the llvm.tms34010.bitaddr intrinsic) and protected f32/f64 constants before the optimizer (see "What M10 provides"). M11 (Phase 3) makes the flow fully conventional — a committed CRT (crt0.o via llc), headers (sdk/include), a library (libtms.a), a sysroot and a tms-link link job, so clang --target=tms34010 hello.c -o hello works with no wrapper and no project variables. The remaining genuine conformance classes (blockaddress, vector runtime, inline-asm memory constraints, nested functions, VLAs, sret/aggregate/variadic/float returns, libm, runtime aborts), the pre-existing pr63843 hang, further performance work and the real VT1200 run (still deferred until the unit is available) remain open. 2ine r5.01 is a later speed-up for the GSPA/GSPLNK step. The compiler fork is canonical for target code; this project holds the plan, harness, pins and integration tests.

S
Description
TMS34010/VT1200 compiler project: plans, integration tooling, spike, symbols
Readme
1.2 MiB
0 Stars 1 Watchers 0 Forks
Languages
Shell 56.8%
Python 14.6%
C 14.1%
Lua 7%
Assembly 3.5%
Other 4%