tms-c-compiler
A modern C toolchain for the DEC VT1200 / TI TMS34010, built as a small fork of upstream LLVM.
Status: M7.2. M7.2 completes the native object path. llc -march=tms34010 -filetype=obj now 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 79 c-torture / 48 c-testsuite curated tests. M7.2
does not change the default branch or the ABI. The wider Xlib surface, stderr
and the full external suites beyond the curated supported subset are
M7.3–M7.4.
M7.1 correctness. The M6
-O2p += nover-scale is fixed: a sourcep += nderived pointer is correct at the default-O2, and the conformance shim'smemmoveworkaround is gone (the naturald += nbackward copy is gated at-O2in MAME). The final InstCombine restores the M0 pointer shapes:int_diffreturns 8 andint_diff4returns 32, andlatecarries the 24-bit addend (never 192).
Branch m7 is the current milestone snapshot (the repository default remains
m6; M7.2 makes no default change). Branch m6 is the previous snapshot,
m5 the one before that, m4 before that, m3 the M3 snapshot, m2 the M2
tip and m1 the reproducible M1 snapshot.
- Design:
docs/superpowers/specs/2026-11-10-tms34010-llvm-design.md - M0 plan:
docs/superpowers/plans/2026-11-10-tms34010-m0-fork-and-bit-address-semantics.md - M1 plan:
docs/superpowers/plans/2026-11-11-tms34010-m1-minimal-backend.md - M2 plan:
docs/superpowers/plans/2026-11-11-tms34010-m2-ti-abi-and-rom-calls.md - M3 plan:
docs/superpowers/plans/2026-11-11-tms34010-m3-control-flow-and-xlib-window.md - M4 plan:
docs/superpowers/plans/2026-11-12-tms34010-m4-xlib-image-events-and-termtris.md - M5 plan:
docs/superpowers/plans/2026-11-12-tms34010-m5-native-object-path-and-conformance.md - M6 plan:
docs/superpowers/plans/2026-11-13-tms34010-m6-language-runtime-and-floats.md - Spike:
spike/REPORT-23.md(current, LLVM 23.1.5);spike/REPORT.md(historical, 19.1.7)
Repositories
- Compiler fork: https://git.wut.ee/opencode.siil.arti.ee/llvm-tms34010
(branch
m7) — the full buildable LLVM 23.1.5 tree with the TMS34010 target, clang bit-address changes and the M2/M3/M4/M5/M6/M7.1 backend. Branchm7is the current milestone snapshot; the repository default ism6(M7.2 keeps it). Branchm6is the previous snapshot,m5is before that,m4is before that, branchm3is before that, branchm2is the M2 tip and branchtms34010is 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
m7) — plans/specs, VT1200 integration tooling,tms-bitaddr,tms-clang, symbols, the M2–M7.1 harnesses and the conformance tier. Branchm7is the current milestone snapshot; the repository default ism6(M7.2 keeps it). Branchm6is the previous snapshot,m5is before that,m4is before that,m3is before that,m2is the M2 snapshot andm1is 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–M7.2 do not change it.
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").
- TI-COFF object writer. The dynamic section list is
.text,.data, optional.cinit,.bss, then optional non-allocated.debug_*..cinitis the TI init-record table (data flags0x40) and is emitted only when non-empty;.debug_*sections have flags0, 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.cinitand no debug IR is still the original.text/.data/.bssshape. Data-only/.cinit-only objects are valid (.textsize 0 with its section symbol). Object-mode explicit data sections are restricted to.cinit;.bss/.textfail 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/.cinitfields are bit addends (S_bits + addend_bits);.debug_*fields are byte addends (S_bytes + addend_bytes, with an allocated target atoutput_paddr/8and a debug-section target kept section-relative at 0). A resolved symbol difference such asDW_AT_high_pcis already bytes and is never rescaled. - Debug is object-only.
SupportsDebugInformationis on, but the targetAsmPrinterdisablesDwarfDebugwhen the streamer has raw-text support, so-filetype=asmstill emits no.loc/.debug_*text and GSPA is not weakened.scripts/tms-clang -gpasses exactly-gto clang on the IR step;-g1/-g3are 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;.textdefaults to018A0000,.datafollows it 16-bit aligned,.cinitfollows.data(only when the total size is nonzero), and.bssdefaults to01A00000..cinitis placed after.dataand its records'u32destinations link to bit addresses. The linker resolves the exact publicC_EXTname (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/endsymbols and a publiccinitat the.cinitorigin when a total non-empty.cinitexists (an input definition wins). The optional header is 28 bytes (0x0108, vstamp199, text/data/bss sizes in bits, entry, text/data start); file flags are0x0103. The map carries section allocation and global symbols (source-line ranges are the kept.debug_linedata, read withllvm-dwarfdump, not a linker DWARF parser).- Strip/keep debug.
.debug_*are stripped by default;--keep-debugkeeps 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.shlinks the same M5 objects both ways and requires identical allocated bytes, section paddr/vaddr/size/flags, optional header and the exact defined publicC_EXTset, asserts the documented C_STAT difference (GSPLNK keeps per-input section symbols;tms-linkemits one per output section), and runs both images in MAME with identical markers. The.cinitgate covers a real C table and the copy loop,longname.sha 44-character cross-TU public function (the 45-character_tms...linked symbol), anddebug.shDWARF at-O0(exact) and-O2 -g(smoke).tms-linkdoes not read.libmembers yet;scripts/m4/run.shkeeps GSPLNK as the default and exposes theM4_NATIVE=1 M4_LINKER=tms-linkopt-in (no libraries). A total-empty.cinitis omitted and defines nocinit; a reference then fails loudly (GSPLNK's fallback is not reproduced;cinitz.asmis 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
-O2bit-pointer barrier. Source GEPs and source bit-offsetinttoptr(add(ptrtoint,...))shapes are hidden behind an opaque@__tms_bitptr(i32 bitoff, ptr base)call (nounwind readnone) beforeopt, so the optimizer cannot re-canonicalize an already-bit address into a byte GEP. The pipeline isclang → --bitptr → opt → --scale → --lower-bitptr → instcombineat-O2(clang → --bitptr → --lower-bitptrat-O0); the post-opt--scaleshifts only optimizer-created byte GEPs (SROA/switch tables), and the final InstCombine restores the M0 folding. The default-O2p += nis now correct (one scale), the conformance shim's constant-stepmemmoveworkaround is gone (the naturald += nbackward copy is gated), and the M0 contract is unchanged:int_diffreturns 8,int_diff4returns 32, andlatecarries 24 (never 192). The pre-existing i64/narrow/sext shapes are barriered too:(unsigned long long)(unsigned)p + 24and(long long)(int)p + 24keep the low word, while narrowing base casts such as(unsigned short)p + 24keep their mask (late64,late64s,narrow16,narrow8are 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 changesizeof, field offsets or the stride. A:0bitfield can make the reported TI number a message-accuracy edge, but the warning still fires. - Recursive
.datainitializers. 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.bytesequences 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.databyte offset cannot be represented in the text path (a 32-bit relocation cannot be split across.bytelines), so the raw compile fails loudly withTMS34010: 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 rewordedTMS34010: unsupported .data initializer (...)diagnostic. Two uniformity notes: raw mode rejects[N x i1](and object mode rejects a non-zeroConstantArray<i1>) while object mode zeroes azeroinitializer[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 113/113 CodeGen (34 m2-*, 8 m3-*, 18 m4-*, 15 m5-*, 28
m6-*, 10 m7-*) plus 4/4 MC (117/117 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 ten m7-* CodeGen tests are
the four M7.1 .data tests plus the six M7.2 object tests
(m7-cinit-section, m7-cinit-only, m7-no-cinit, m7-debug-info,
m7-unknown-section, m7-bss-import).
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, noA8). Add/sub use post-RAADDC/SUBB; multiply uses the 32-bitMUL/MPYS/MPYUpath; shifts useSHL/SRL/SRA_PARTS; unsigned/signed divide and remainder use a correct inline 64-iteration restoring loop becauserts.libhas no 64-bit helper. i64 objects in memory are little-endian (LSW at the lower address) per the design spec and theedata 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.datainitializers were an M6 limitation and are supported from M7.1.float/doublesoft-float. GSP-format values andflib.libstack entries: arithmetic pushes its result onA14, compares return inA8, conversions useA8/A14; every call saves/restoresA14andA8.f32lives inARegs,f64in anARegsPairwith pair spills. IEEE IR constants are converted to GSP words (exponent+1, half-up), with a GSP constant pool and theTMS34010LowerFloatConstantspass for store/return/argument literals. GSP has no NaN, denormals or signed zero:-0.0is 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,i64and aggregates share one caller-allocated slot rule:ADDI 32/64/alignTo(size,2)before saving STK, the callee writes atsaved_STK-size, restores A14 and endsRETS 2(even with no arguments). ScalarA8returns are unchanged. - General varargs.
va_listis a 32-bitchar *; the caller saves STK for every variadic call,va_start = FP-(fixed_argument_bytes+4)*8, andva_argwalks downward with per-type word orders.va_copy/va_endand anint f(...)definition work; a variadici64/float hidden return and ava_argof a struct are rejected. The M4 contiguous&last_fixedpattern still works. - Packed bitfields. LSB-first, no padding between adjacent fields, an
unnamed/leading
:0is ignored, and fields may cross 32 bits.SEXT1handlesint s:1;TMS34010ExpandNarrowMemsplits 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 forstruct s) while Clang uses the byte-roundedsizeof(5 bytes); field offsets,sizeofand standalone 16-bit-rounded allocation agree. M7.1 adds the default-on-Wtms34010-subbyte-stridediagnostic 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
sretparameter; 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 M5byvalform. An explicitsretpointer is rejected with a clear diagnostic; a packed bitfield struct returned by value is covered end-to-end in the aggregate gate.TMS34010ExpandAggMemsplits aggregate load/stores beforeLowerI64andExpandNarrowMemso no byte offset is added to a bit address. - Runtime and formats. The 1990 SDK
flib.lib(GSP soft-float) andrts.libare linked with the 1987 GSPA/GSPLNK tools (the$symbols need no alias; the 1990 tools are OS/2-only). The shared conformance shim implementsprintf/sprintfwith%d %i %u %o %x %X %p %c %s %%,h/hh/l/ll,%ld/%lu/%lld/%llu,%f, width/precision (including*) and%sprecision.%chonours width and-(space padding;0is not meaningful and is ignored).%fprecision is capped at 6 and the integer part at2^31-128;sprintfhas a 256-byte cap and returns the untruncated length; there is nosnprintf.%e/%g/%a/%F,%n, positional$,%jand wide formats remain unsupported (no libm, 32-bit shim reads);%z/%twork. A linked-runtime gate checks 587 output bytes exactly and theflibentries plus the rts-backed_isasciiin the GSPLNK map at-O0and-O2. - Conformance. The pins are GCC 16.2.0 (SHA-256
e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e) and c-testsuite5c7275656d751de0e68b2d340a95b5681858ed07. The curated c-torture list is 79 tests (59 M5 + 20 M6). The M5 gate passes 79/79 at-O0and-O2; the M6 wrapper runs all 79 at-O0and the committed 20-test bounded-O2subset. c-testsuite is 48 pass / 172 skip / 220 with exact stdout; every skip has a reason and there are no crashes. Generic is 197 files with 149 pass / 48 unsupported / 0 crash (M6 was 146/51; M7.1's.dataextension 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").
M7 boundary. M7.2 is complete; it added the debug object sections, the
.cinit object section and tools/tms-link (including public long names).
M7.3 owns the wider Xlib surface, stderr capture and real-hardware validation
(hardware is deferred; M6/M7.x acceptance is MAME plus the existing dwt
loader); M7.4 owns the full external suites beyond the curated supported
subset and performance work (for example an i64 divide fast path).
The -O2 bit-pointer barrier, the sub-byte array/nested-record diagnostic and
the .data aggregate-initializer extension are M7.1 and complete.
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=objwrites a relocatable TI-COFF object with.text/.data/.bss, three section symbols with GSPA's 18-byte aux records,C_EXTglobals and undefined externals, and 10-byteR-RELLONG(0x11) relocations whose addends are bit addresses. GSPLNK 2.00 links the object (same-section0xFFFF, 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;.dataand.bssare 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 inscripts/m4/run.sh. M7.2 addstools/tms-linkplus the optional.cinit/.debug_*sections while keeping GSPLNK as the oracle (see "What M7.2 provides").scripts/m5/native.shandscripts/tests/m5/native.shbuild xshow and the six-TU termtris through the object path; the native and asm linked.textdecode to the same instruction streams (753 xshow and 6,356 termtris instructions), and the native termtris links.text166,608 bits (20,826 bytes),.data9,536 bits (1,192 bytes) and.bss121,808 bits with loader status 0. - Full MC layer.
TMS34010MCCodeEmitter,MCAsmBackend, the TI-COFFMCObjectWriter/MCStreamer, anMCAsmParserand anMCDisassemblercover the supported instruction table.llvm-mc -triple=tms34010assembles/disassembles it;encodings.spins 126-show-encodingcases,disassembler.s77 inverse checks, androundtrip.s88 instructions round-trip through the 1987dis34. The expected bytes come from GSPA listings, not from the new encoder.llvm-mc -filetype=objuses LLVM's generic ELF writer; onlyllc -filetype=objproduces TI-COFF. The 10-byteMOVE @a,@b/MOVB @a,@bforms are not modeled and fail loudly. JRand branch relaxation. Selection still builds the three-word absoluteJAUC/JA<cc>branches; a pre-emitTMS34010BranchRelaxationpass then assumes the one-word relativeJR/JR<cc>form and grows a branch back toJA*when its signed 8-bit word displacement is out of range (±127words =±2032bits), zero, odd, or its target is unknown. The MC backend independently relaxes a symbolicJRwith theFK_JR8fixup, sollvm-mcinput relaxes too. Relative to the M4 938-byte M3 image, 14JRbranches save 56 bytes and the MMTM/MMFM change saves another 8, giving 874 (the current all-JAbaseline is 930).MMTM/MMFMregister-list saves. The prologue saves the callee-saved set with oneMMTM SP, ...and the epilogue restores it with oneMMFM SP, ...(ascending register list;MMTMmask0xd400/MMFMmask0x002bforA0,A1,A3,A5). The old-STK slot,A13save,A8return andRETS 2arithmetic 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 andmemcpy/memset. Dynamicallocaadjusts A14 in bits (size << 3), honors the requested alignment in bits, and supportsstacksave/stackrestore; a no-argument function with a VLA rebuilds A14 from FP in the epilogue.byvalcopies the object to the program stack and advances A14 byalignTo(size,2)bytes (×8 bits).i8/i16returns leaveA8with the declaredzeroext/signextand the caller truncates/extends. Constant-sizememcpy/memsetbecome word/byte copies and runtime sizes become inline loops with bit-scaled GEPs. A constantmemmove(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/_memmovelibcall is emitted.robust.shchecksalloca=408 byval=64 narrow=1056 mem=438 alloca_use=1496 byval6=64 memmove=2148in both the asm and native paths.- Driver policies.
-switch-to-lookup=falseis gone.tms-clangrunsclang → tms-bitaddr --bitptr → opt → --scale → --lower-bitptr → instcombineat-O2(and--bitptr → --lower-bitptrat-O0): source GEPs and bit-offset pointer-int shapes are opaque@__tms_bitptrcalls throughopt, the post-opt--scaleconverts only the byte-indexed GEPs thatoptintroduces (the M4 switch and termtris lookup tables, and the.fca.N.geploads that SROA creates when a returned aggregate is taken apart;+4bytes must become+32bits),--lower-bitptrrestores the M0 bit-addressedinttoptr(add(ptrtoint,...))form, and the final InstCombine restores the pointer-difference/latefolding. The default-O2p += nis correct (one scale), and the conformance shim'smemmoveuses the naturald += n(the M6 constant-step workaround is gone).-replexitval=neverremains a documentedtms-clangTMS34010 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), andtms-clang -O2rejects a static variadic definition before dead-argument elimination can drop its....-O0and the externalsprintfstill 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:
SETF16must be sign-extending (SETF 16, 1, 0,0x0570;fe=0would zero-extend), a PHI copy can land betweenCMPandJcc(MOVEwrites the flags), so selection now emits a fusedCMPBR/CMPIBRthat is split after register allocation, andgc.statepointcalls get a target diagnostic instead of aStatepointLoweringassertion. Object-mode.bssword granularity and the objectSRAK/SRLKencoding were fixed as well. - M3 tightening.
m3-cmpi.llpins the-O0/-O2MOVI order withCHECK/CHECK-NEXT, andscripts/m3/dis-roundtrip.shparses the nine-argumentXCreateSimpleWindowpushes by value/register instead of hardcoding the registers. - Conformance tier.
scripts/tests/m5/conformance/run.shcompiles a test withtms-clang, links theshim.c+entry.asmharness (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 are01B00020and01B00060). The c-testsuite tier forces--mode native, so an asm fallback is a gate failure.classify.shrejects 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-256e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e) and c-testsuite commit5c7275656d751de0e68b2d340a95b5681858ed07, materialized under the ignoredvendor/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 istms-clang. The three gates at the M6 head are LLVMCodeGen/Generic(197.ll: 149 pass / 48 unsupported / 0 crash at the M7.1 head, plus a 24-file curated allowlist), GCC c-tortureexecute(79/79 at-O0and-O2; M6 Task 8 expanded the shared list from 59 to 79 and the corpus classifier reports 1,636 supported / 56 skipped from 1,692 tests), and c-testsuitesingle-exec(48 pass / 172 skip / 220, with exact.c.expectedoutput). The shim providesprintf/sprintfwith a realva_listwalk and%ld/%lld/%fplus width/precision,putchar/puts,exit/abort, a 16 KiB stdout buffer, a distinct 16 KiB stderr stream (fprintf/vfprintf/fputs/fputc/fwrite, length at01B00060, bytes at01B30000), and a small string/integer surface. stderr is compared exactly (--expect-stderror;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 callCALL Rs(GSPA0x0920,dis34call aN), with the same old-STK save, argument pushes,SETFfixup andRETS 2as a direct call. Direct calls remainCALLA _sym.m4-fnptr.ll+scripts/tests/m4/fnptr.sh. - 32-bit multiply/divide.
MPYS/MPYU/DIVS/DIVUwith an odd destination (the even form is theRd:Rd+1pair and would clobber the next register); remainder is quotient +MPYS+SUB. There is no compiler multiply/divide helper inRTS.LIB;_divis only the Cdiv()wrapper.m4-mul.ll+scripts/tests/m4/mul.sh. - Zero-extending and extending narrow loads.
ZEXTLOAD/EXTLOADi8/i16 lower to the sign-extending load plusANDI 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.lland the two-TUscripts/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/i16fixed 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 onm4; M5 addsi8/i16returns inA8.m4-arg8.ll,m5-narrow-ret.ll.- Contiguous-stack varargs. Only the
&last_fixedwalk used by termtris'sprintf; nova_list/va_start/va_arg. Zero-fixed and i8/i16-anchor definitions are rejected. Onm4, static variadic definitions can lose...under-O2dead-argument elimination; M5 adds thetms-clangdiagnostic and the llc check, while the external termtrissprintfremains 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-clangpasses-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--scalewould 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-clangkeeps the pre-opt--scale(bit-addressed pointer casts) and scales every late byte GEP afteropt, which also fixes aggregate-split.fca.N.geploads. The knownp += nover-scale fromInstCombinecanonicalizing a bit-offsetinttoptrback into a GEP is documented above and worked around in the conformance shim'smemmove; M7 owns the proper fix. All policies are driver-side becauseopthas no target machine. - X11R4
XImage/XEvent/XErrorEventlayouts and the image client. The real 32-bit packed offsets:XImagedata 16, byte_order 20, bytes_per_line 40, bits_per_pixel 44, f 64,sizeof88;XEvent96;XErrorEvent20 (with the explicit X11R4 object-size compatibility pad);Display.screensbyte 0x90 / bit 0x480,Screen.rootbyte 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.bssat0x01A00000andprogat0x018A0000.XCopyAreacopiesIMG_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 LK401q(keycode 193 / keysym0x71), window focus and zero X errors in MAME. - Corrected 30-entry v2.2 symbol table.
XMapWindowis0x3FD64F60(MapWindow opcode 8);0x3FD645B0isXRaiseWindow(ConfigureWindow opcode 12,CWStackMode=Above). The XG block and the image/error-handler entries are validated byscripts/m4/validate-syms.shandscripts/tests/m4/symbols.sh. - Pinned termtris. The full game builds with this compiler and the 1987
GSPA/GSPLNK +
rts.lib, at the pinnedvt1200-termtriscommit, and runs board/move/panels/quit in MAME with real key injection, the0x40000-bitprogregion 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
i32and pointer values:CMP/CMPIplusJAEQ/JANE, the signedJALT/JALE/JAGT/JAGE, the unsignedJALO/JALS/JAHI/JAHS, andJAUCfor an unconditional jump. Ordinarywhile/forloops (subject to the M3 limitations below), if/else and?:work;?:expands to a compare plus a two-block diamond (SELECTCC), andsetccbecomes that diamond over 1/0. - Integer ALU and shift operations:
SUB,AND,OR,XOR,NEG,NOT,SLL,SRL,SRA, plusADDI/ANDI/SLLK/SRAK/SRLKimmediates. - 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),XMapWindowandXSync. All four go through validated ROM import stubs. - The ROM's
Display/Screenfield displacements are bit offsets0x480(Display.screens) and0x40(Screen.root), i.e. byte offsets0x90and0x8inscripts/m3/vt1200_xlib.h. - Misaligned accesses:
MOVE/MOVBand 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-*.lllit tests on them3branch (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) andm3-reject-zext.ll, and adds 18m4-*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.
MOVBhandles signedcharand the FS0MOVEhandles signedshort;unsigned char,unsigned shortand_Boolloads need a zero-extending pattern that M3 does not have. They stopllcwith a rawCannot select, whichm3-reject-zext.llpins. M4 adds the zero-extending loads; do not assume general narrow-load support in M3. -O2loop exit-value rewriting is not lowered. IndVarSimplify can turnsumto's loop into a closed-formi33multiply, which M3 cannot select. The M3 harness therefore buildsbranch.cwith-replexitval=never. Ordinarywhile/forloops that keep a real back-edge and phi work. M4 adds multiply/divide and moves the-replexitval=neverpolicy intoscripts/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=asmfor straight-linei32/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), emitsCALLA, 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, setsFP = STK, allocates the frame withADDI, and restores both stacks in the epilogue. The first explicit argument is atFP(-32), the second atFP(-64), and so on; locals live at positive FP offsets. void,i32and pointer returns, inA8;RETS 2when the function has explicit arguments,RETS 0otherwise.- Initialized globals, string/byte-array literals and pointer initializers in
.data; zero-initialized mutable globals stay in.bss. The loader copies.dataalong with.text. - ROM import stubs generated from
symbols/vt1200-v22.syms. M2 consumesstrlenonly:_strlen: jauc 3FB458D0h.CALLA _strlenpushes the return PC, the stub jumps to the ROM, and the ROM'sRETS 2returns directly to our caller. - Thirty-seven
llvm-lit/FileCheck tests underllvm/test/CodeGen/TMS34010/m2-*.ll, including negative tests that pin the loud refusals. The ABI/data coverage includesm2-returned,m2-returned-call,m2-call-noret,m2-data-align,m2-data-avail,m2-data-z64andm2-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–M7.1) | |
|---|---|---|
| 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.
Run the M7.2 gates
These are the documented commands on branch m7; 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 M7.2 gates sit on top of the unchanged M5/M6 list.
# 1. Build llc, the assembler/disassembler driver and dwarfdump
ninja -C build/llvm-clean-build llc clang opt llvm-mc llvm-dwarfdump
# 2. LLVM codegen tests: 113 passed
# (34 m2-* + 8 m3-* + 18 m4-* + 15 m5-* + 28 m6-* + 10 m7-*)
build/llvm-clean-build/bin/llvm-lit -v \
build/llvm-clean/llvm/test/CodeGen/TMS34010
# 3. MC tests: 4 passed (encodings, disassembler, round-trip, JR range)
build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/llvm/test/MC/TMS34010
# 3b. Clang tests: 5 passed (the sub-byte stride Sema warning and the
# TMS34010 CodeGen layout/ptrdiff/triple/aggregate cases)
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
# 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
# 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 # 88 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
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
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/m6/m7)
These are the documented commands on branch m4; all must pass. On branches
m5/m6/m7, use the M7.2 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 30-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:
i8scalar or byte/string array:.bytewith GSPA hex (068h)i16scalar:.wordi32scalar:.longi64: two.longwords, 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
DataLayoutoffsets with zero padding, exact little-endian bytes at odd byte offsets (GSPA implicitly word-aligns.word/.long, so the raw path uses.bytesequences there) - arrays: element-wise recursion;
i64elements are supported and each element carries its allocation-stride padding - aggregate zero: the whole
getTypeAllocSizeimage, including record and element padding - pointer:
.long _symbol+<bit addend>(the addend is already in bits) .evenbefore a.dataglobal whose alignment is at least 16 bits, so the label and the following.word/.longagree.
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; symbols/README.md
records the evidence. Do not add other Xlib dependencies until they are
validated.
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 addsbyval; the rest are M6). - Varargs:
...functions and calls (M4 adds the contiguous form; generalva_listis M6). - Function pointers and indirect calls (M4).
- Tail calls: ordinary
tailmarkers are demoted to ordinary calls;musttailis not implemented (M2 C does not emit it). Real tail calls remain a later milestone. - Narrow ABI types:
i8/i16parameters,i64, and narrow returns remain rejected. Narrow accesses inside a function are sign-extending only:MOVBfor signedcharand FS0MOVEfor signedshort; zero-extendingunsigned char/unsigned short/_Boolloads are M4 work. - Object output: no
MCCodeEmitter, object writer,llc -filetype=obj,clang -cor 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
strlenROM 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 addsbyval; 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 -cor native COFF; GSPA/GSPLNK produce the COFF. M5 adds the native path and theJR/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 ori64arguments, returns, arithmetic or branches; the i33/-replexitvalpolicy stayed until the i64 lowering landed. M6 closes this. - General varargs: no
va_list,va_startorva_arg; only the contiguous&last_fixedpattern used by termtrissprintf. M5 used that same pattern inside the conformance shim; trueva_listtests were skipped. M6 closes this. - Bitfields and aggregates by value: bitfields,
sret, aggregate returns and general aggregate arguments were unsupported;byvalarguments and struct fields through pointers were supported. M6 adds packed bitfields and aggregate returns; an explicitsretpointer 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 client uses
only the validated image, event, GC, window and error-handler entries. It
does not implement the whole Xlib surface,
XGetImage, orXDestroyImageon a non-heap image. M7.2 adds object-path DWARF; the wider Xlib surface is M7.3. - Full external suites and stderr: the three tiers are curated subsets, not the full GCC/LLVM suites. The conformance shim captures stdout only, so tests that write stderr are skipped; stderr capture is M7.3 and the full suites are M7.4.
- Deeper libc/runtime coverage: M5's shim is freestanding and does not add
RTS.LIBentries. M6 links the 1990flib.lib/rts.liband expandsprintf/sprintf; a broader libc surface remains M7.3/M7.4. - Native
.cinitand public long names: at M5 the object writer accepted only.text/.data/.bss(termtris's.cinitis 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.cinitobject section,tools/tms-linkand 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–M7.1 (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 gates and drivers (pointer-o2/stride/data;
link/oracle/cinit/longname/debug)
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–M7.1
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 (M7.1, the normal path)
The fork checkout already exists at build/llvm-clean on m7. Build it in
place:
LLVM_SRC=$PWD/build/llvm-clean LLVM_BRANCH=m7 ./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=m7 ./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–M7.1 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–M7.1):
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.libis the GSP-format floating-point library;flibc.lib/flibi.libare 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.libis the C runtime and has no 64-bit helper (_div/_ldivare 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 isM6.OBJ+-l flib.lib+-l rts.libwith-e _start(scripts/m6/link.cmd); the symbol snapshot isscripts/m6/flib-symbols.txt. flibresult conventions. There are three, not one:- arithmetic (
FS$ADD/SUB/MUL/DIV/NEG/INC/DECandFD$...) pushes its result on A14; - compares (
FS$EQ/NE/LT/LE/GT/GEandFD$...) pop both operands and return the boolean in A8, with nothing pushed; - conversions use A8 for the integer side:
FD$FTOI/FTOU/DTOI/DTOUpop the float/double from A14 and return the integer in A8;FD$ITOF/UTOF/ITOD/UTODtake the integer in A8 and push one float or two double words on A14;FD$FTOD/FD$DTOFpop and push.flibends inRETS(notRETS 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 theDIV_Rpair) are for the reversed operand order.
- arithmetic (
- GSP format.
floatis one 32-bit word;doubleis two GSP words with the least-significant word at the lower address. 1.5 is40600000h(float) and00000000h/400C0000h(double LSW/MSW); 4.0 is41400000hand00000000h/40280000h. This is not IEEE; do not mixflib.libwith 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 doesADDI 32/64,STK, saves STK, pushes the arguments, andCALLA; the callee writes atsaved_STK-size, restores A14 andRETS 2. A hidden-return call always saves STK, so it usesRETS 2even with no explicit arguments. The one-slotfloatargument rule is pinned by the M6float.shgate (the 1987 K&R oracle promotes float parameters to double and does not independently pin it). - i64 word order.
long longarguments occupy two 32-bit slots, and the argument and hidden-return stack slot is MSW-first (the high word at the lower address). Along longobject in memory is the opposite: little-endian, LSW at the lower address, per design spec §4.1 and theedata 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.shassembles the hand-writtenspike-entry.asm/spike-probe.asm, linksflib.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$SUBpush order,FS$EQin A8,FD$FTOI/FD$ITOF, and a post-return marker after_m6_probereturns. It passes withM6: 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.textplaced with 0 differing bytes. The full rule is inbuild/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 owns the wider Xlib surface, stderr capture and
real-hardware validation (hardware is deferred; M6/M7.x acceptance is MAME plus
the existing dwt loader); M7.4 owns the full external suites beyond the curated
supported subset and performance work (for example an i64 divide fast path).
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.