Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
314ad047f4 | ||
|
|
429ac96405 | ||
|
|
73506844a8 | ||
|
|
9a99acb01e | ||
|
|
eb9ca73950 | ||
|
|
320e0117c1 | ||
|
|
7f1fc06bd8 | ||
|
|
c7e9e3a58b | ||
|
|
507dd6c615 | ||
|
|
2601c8485f | ||
|
|
cbe617e2c0 | ||
|
|
1fbf2a2598 | ||
|
|
f5facf7d28 | ||
|
|
1f6ac7820c | ||
|
|
61ed4ef070 | ||
|
|
817b6a03ec | ||
|
|
c779c7a725 | ||
|
|
4bb6ce7e4c | ||
|
|
ef8a8545ac | ||
|
|
536c80a797 | ||
|
|
8c1468978a | ||
|
|
537ed27d26 | ||
|
|
dfd13ab1c1 | ||
|
|
7fcae6e520 | ||
|
|
7fada4d9d7 | ||
|
|
d705e43d41 | ||
|
|
9916bbce92 | ||
|
|
12fa71d394 | ||
|
|
c6b437b738 | ||
|
|
28779e1800 | ||
|
|
20789d07f3 | ||
|
|
41c30eee99 | ||
|
|
e17c28a5d5 | ||
|
|
a7bbefad47 |
No files matched your search
@@ -3,18 +3,20 @@
|
||||
A modern C toolchain for the DEC VT1200 / TI TMS34010, built as a small fork of
|
||||
upstream LLVM.
|
||||
|
||||
**Status: M10 complete (Phase 2 — the native clang pipeline).** Branch `m10` is
|
||||
the repository default on both repositories (the promotion lands with this
|
||||
push; `m9` becomes the previous snapshot). Repository
|
||||
policy: each milestone branch is promoted to the default immediately after its
|
||||
clean final review, and the previous default stays as a snapshot. M10 makes
|
||||
native `clang --target=tms34010 -c` correct for pointer code at `-O0` and `-O2`
|
||||
with no extra flags and no wrapper — the
|
||||
TMS34010 target owns both the bit-address transform and its compile defaults —
|
||||
and `-O0` objects are byte-identical to the M9 path. See "What M10 provides".
|
||||
The M10 code state (project `9694497`, compiler `eb28be2faf8d`) is the tip
|
||||
before this documentation commit; the M9 code state (project `24eca1c`,
|
||||
compiler `bec449573fe3`) is the previous snapshot.
|
||||
**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
|
||||
@@ -38,11 +40,12 @@ 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 **56/56 PASS**; the real
|
||||
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). M10 is the milestone branch and repository default;
|
||||
`m9` is the previous snapshot.
|
||||
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
|
||||
@@ -110,8 +113,9 @@ boundary; the hardware run is still deferred.
|
||||
> the M0 pointer shapes: `int_diff` returns 8 and `int_diff4` returns 32,
|
||||
> and `late` carries the 24-bit addend (never 192).
|
||||
|
||||
Branch `m10` is the repository default (M10); `m9` is the previous
|
||||
snapshot (M9.4), `m8` the one before that, `m7` the one before that,
|
||||
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.
|
||||
|
||||
@@ -137,19 +141,23 @@ snapshot (M9.4), `m8` the one before that, `m7` the one before that,
|
||||
## Repositories
|
||||
|
||||
- **Compiler fork:** <https://git.wut.ee/opencode.siil.arti.ee/llvm-tms34010>
|
||||
(branch `m10`) — the full buildable LLVM 23.1.5 tree with the TMS34010
|
||||
target, clang bit-address changes, the M2–M9 backend and the M10 native
|
||||
pipeline (`ToolChain` + bit-address passes).
|
||||
Branch `m10` is the repository default (M10); `m9` is the previous snapshot.
|
||||
(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 `m10`) — plans/specs, VT1200 integration tooling, `tms-bitaddr`,
|
||||
`tms-clang`, symbols, the M2–M10 harnesses and the conformance tier.
|
||||
Branch `m10` is the repository default (M10); `m9` is the previous snapshot.
|
||||
(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
|
||||
@@ -157,8 +165,10 @@ snapshot (M9.4), `m8` the one before that, `m7` the one before that,
|
||||
|
||||
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 adds `patches/llvm/0005-tms34010-toolchain.patch`
|
||||
(the `ToolChain` and its registration).
|
||||
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
|
||||
|
||||
@@ -250,11 +260,187 @@ the binding design is
|
||||
- **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 `llvm-mc`), headers
|
||||
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`](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`](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`](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
|
||||
@@ -1280,9 +1466,39 @@ 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.
|
||||
|
||||
```sh
|
||||
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. It hides the bit-address IR barrier,
|
||||
`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:
|
||||
|
||||
```sh
|
||||
@@ -1325,42 +1541,51 @@ 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 M10 gates
|
||||
## Run the M12 gates
|
||||
|
||||
These are the documented commands on branch `m10`; all must pass. The MAME and
|
||||
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 M10 gate list is the
|
||||
(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), plus the M10 gates (step 3h). The serial M0–M8 gate list is
|
||||
**56/56 PASS** and the hardware gate prints `HARDWARE: DEFERRED`. The count
|
||||
change from M9 is: TMS34010 lit **129 → 132** (128 CodeGen — three new tests,
|
||||
`m10-state1-lower`, `m6-memcpy-chain` and `m10-bitaddr-chain-i64` — plus 4 MC)
|
||||
and clang **5 → 10** (8 CodeGen + 1 Driver + 1 Sema), for **142** lit in
|
||||
total. The fresh
|
||||
full-suite total is unchanged at
|
||||
**1,912 = 1,618 pass / 294 skip / 0 fail / 0 crash**.
|
||||
(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**.
|
||||
|
||||
```sh
|
||||
# 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 llc clang opt llvm-mc llvm-dwarfdump
|
||||
ninja -C build/llvm-clean-build -j4 llc clang opt llvm-mc llvm-dwarfdump llvm-ar
|
||||
|
||||
# 2. LLVM codegen tests: 128 passed
|
||||
# 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 m9-* + 2 m10-* + 9 m12-*)
|
||||
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)
|
||||
# 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: 10 passed (8 CodeGen + the Sema subbyte-stride warning +
|
||||
# the driver tms34010-defaults.c)
|
||||
# 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-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)
|
||||
@@ -1401,15 +1626,16 @@ M6_LINKER=tms-link scripts/tests/m6/i64.sh
|
||||
# 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/m10-bare
|
||||
# -> c-torture 1692 = 1408 pass / 284 skip / 0 fail / 0 crash
|
||||
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 = 1618 pass / 294 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/m10-bare
|
||||
# (full-suite-results.tsv / full-suite-report.txt).
|
||||
# (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
|
||||
@@ -1490,10 +1716,10 @@ 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`–`m10`)
|
||||
## 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`–`m9`, use the M9 list above (it includes `llvm-mc`,
|
||||
`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.
|
||||
@@ -1974,14 +2200,14 @@ Xlib call sequence, `as34`, `dis34`, SDKs, manuals). It is not vendored:
|
||||
|
||||
## Build the compiler
|
||||
|
||||
### Compiler fork (M9, the normal path)
|
||||
### Compiler fork (M11, the normal path)
|
||||
|
||||
The fork checkout already exists at `build/llvm-clean` on `m9` (the current
|
||||
milestone branch and repository default). Build it in
|
||||
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:
|
||||
|
||||
```sh
|
||||
LLVM_SRC=$PWD/build/llvm-clean LLVM_BRANCH=m9 ./scripts/build-llvm.sh
|
||||
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
|
||||
```
|
||||
@@ -1990,7 +2216,7 @@ To clone the fork first instead of using an existing checkout:
|
||||
|
||||
```sh
|
||||
LLVM_REPO=gitea@git.wut.ee:opencode.siil.arti.ee/llvm-tms34010.git \
|
||||
LLVM_BRANCH=m9 ./scripts/build-llvm.sh
|
||||
LLVM_BRANCH=m11 ./scripts/build-llvm.sh
|
||||
```
|
||||
|
||||
Fork mode **never** checks out, resets, cleans or patches the source tree; it
|
||||
@@ -2165,7 +2391,7 @@ 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 `llvm-mc`),
|
||||
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
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
# TMS34010 M11 (Phase 3) — Conventional Toolchain Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Make `clang --target=tms34010 hello.c -o hello` build a loader-valid image that `tms-run` can execute — CRT, headers and `libtms` found through a resource-directory sysroot, linked by `tms-link` through a real driver link job, with no wrapper and no project variables.
|
||||
|
||||
**Architecture:** `sdk/` holds the sources (CRT IR, shim, heap, headers, committed vendor archives); `scripts/tms-sdk` builds `crt0.o` with `llc` and `libtms.a` with `llvm-ar`, then installs everything plus the `tms-link`/`tmscoff.py` pair into `<resource-dir>/tms34010-unknown-none/{include,lib,bin}`. `TMS34010ToolChain` grows sysroot discovery and a `TMS34010Linker` Tool that maps driver flags onto `tms-link`. `tms-link` must emit loader-valid COFF on its own, because the production path no longer runs `coff-check.py --repair`.
|
||||
|
||||
**Tech Stack:** LLVM/Clang 23.1.5 fork (`llvm-tms34010`), clang driver `ToolChains/TMS34010.*`, `llc`, `llvm-ar`, `tools/tms-link` (Python + `tmscoff.py`), TMS34010 GSPA assembly, TI-COFF, MAME + the dwt loader, shell gates.
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-11-18-tms34010-m11-conventional-toolchain-design.md` (§8 is this milestone; §11 is the roadmap, not this plan).
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Baseline: project `m10`/`a7bbefa`, compiler `m10`/`7fc2ac37b5ad`. Cut `m11` in both repos before Task 1; never force-push.
|
||||
- LLVM/Clang stay pinned at 23.1.5. All driver work stays inside `clang/lib/Driver/ToolChains/TMS34010.{h,cpp}` plus its two registration lines; patch `0005` grows, nothing else.
|
||||
- The driver must never bake in a checkout path: discovery is `--tms-sysroot=`, then `--sysroot`/`-isysroot`, then `<resource-dir>/tms34010-unknown-none`.
|
||||
- M10's contract must not regress: `clang --target=tms34010 -c` stays correct at `-O0`/`-O2`, and `-O0` objects stay byte-identical to the M9 path (`scripts/tests/m10/equivalence.sh` is the gate).
|
||||
- The CRT/runtime contract is fixed: status `01B00000`, out-len `01B00020`, magic `01B00040` = `0x434F4E46`, err-len `01B00060`, output `01B10000`, error `01B30000` (16 KiB each), `_cstack` 32768 bits (4096 bytes) at 16-bit alignment, `_conformance_argv` 64 bits, `_start` entry; `libtms`'s `exit`/`abort` publish and spin.
|
||||
- Link defaults: `--entry _start --text 018A0000 --bss 01A00000 --prog-len 40000h --ram-len 80000h`.
|
||||
- `coff-check.py --repair` leaves the production path; `tms-link` emits valid images unaided.
|
||||
- Vendor `flib.lib`/`rts.lib` are committed and gated against freshly extracted copies.
|
||||
- Existing gates stay green: lit suites, the serial M0–M10 list, the two-tier suite **1,618 pass / 294 skip / 0 fail / 0 crash**, i64div `88/3302/221/120` with the same four checksums, `HARDWARE: DEFERRED`.
|
||||
- No force-push, no default-branch change before the whole-branch review.
|
||||
|
||||
## Review Focus
|
||||
|
||||
1. **A fresh shell after one setup command** — `clang --target=tms34010 hello.c -o hello` must work with no `M4_*`, `TMS_*`, `PATH` or include entries, from a directory outside the repo (Task 5).
|
||||
2. **Link-reduction knobs** — `-nostdlib`, `-nostartfiles`, `-nodefaultlibs` must each drop exactly their part and still link (Task 4).
|
||||
3. **Missing pieces are diagnosed, not guessed** — no sysroot, no installed `tms-link`, no `python3` must each name the cause and `scripts/tms-sdk`, never a raw linker error (Task 4).
|
||||
4. **CRT contract** — argv vector, 4 KiB stack, result-block addresses, `_start`, and `exit`/`abort` publishing must survive the assembly rewrite, because `tms-run` and the harness read them (Task 2).
|
||||
5. **M10 is untouched** — `clang -c` at `-O0`/`-O2` and the `-O0` byte-identity gate stay exactly as they were; the link work must not perturb codegen (Task 6).
|
||||
|
||||
---
|
||||
|
||||
### Task 1: `tms-link` emits loader-valid images unaided
|
||||
|
||||
**Files:**
|
||||
- Modify: `tools/tms-link/tmscoff.py` (`write_coff`, only if the header is defective)
|
||||
- Modify: `tools/tms-link/tms-link` (only if the writer needs input)
|
||||
- Modify: `tools/tms-link/tests/{run.sh,linktest.py}`
|
||||
- Test: a new case in `tools/tms-link/tests/`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `tmscoff.write_coff(path, sections, symbols, *, entry, text_size, data_size, …)` and the existing `scripts/m4/coff-check.py [--repair] [--entry HEX] FILE` validator.
|
||||
- Produces: whatever the linker emits today must pass `coff-check.py` **without** `--repair`, including an odd-length `.bss`.
|
||||
|
||||
- [ ] **Step 1: Write the failing gate case**
|
||||
|
||||
Add to `tools/tms-link/tests/run.sh` a case that links a small object (reuse an existing fixture) and then runs
|
||||
`python3 scripts/m4/coff-check.py OUT.coff` expecting exit 0, plus a fixture whose `.bss` length is odd (e.g. one 8-bit symbol) checked the same way.
|
||||
|
||||
- [ ] **Step 2: Run it red**
|
||||
|
||||
Run: `tools/tms-link/tests/run.sh`
|
||||
Expected: FAIL on the new case with the validator's magic/size complaint (or on the odd-`.bss` case).
|
||||
|
||||
- [ ] **Step 3: Fix the writer**
|
||||
|
||||
If the file/optional header or section table is defective, fix `write_coff`. If an odd `.bss` is emitted unrounded, round only `.bss` to a whole 16-bit word, as `coff-check.py --repair` does. Do not change `.text`/`.data` contents, relocation handling, or the entry point.
|
||||
|
||||
- [ ] **Step 4: Run it green**
|
||||
|
||||
Run: `tools/tms-link/tests/run.sh`
|
||||
Expected: PASS, including the two new cases.
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add tools/tms-link/tmscoff.py tools/tms-link/tms-link tools/tms-link/tests/
|
||||
git commit -m "m11: tms-link emits loader-valid COFF without repair"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: `sdk/crt0.ll` — the CRT as IR with a naked `_start`
|
||||
|
||||
**Files:**
|
||||
- Create: `sdk/crt0.ll`
|
||||
- Create: `scripts/tests/m11/crt.sh`
|
||||
- Test: `scripts/tests/m11/crt.sh`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `llc -march=tms34010 -filetype=obj`, `tools/tms-link/tms-link`, `scripts/tms-run`, and the result-block contract in Global Constraints.
|
||||
- Produces: `sdk/crt0.ll`, a `naked` `_start` built by `llc`, defining `_start`, `_conformance_name` (12 bytes, `"conformance\0"`), `_conformance_argv` (64 bits), `_cstack` (32768 bits, 16-bit alignment), and preserving the register/stack setup of `scripts/tests/m5/conformance/entry.asm`.
|
||||
|
||||
- [ ] **Step 1: Write the failing contract test**
|
||||
|
||||
`scripts/tests/m11/crt.sh` builds `sdk/crt0.ll` with `llc`, compiles a heredoc `main.c` (`int main(int argc, char **argv) { printf("%d %s\n", argc, argv[0]); return 7; }`), links them with `tms-link` (`--entry _start --text 018A0000 --bss 01A00000 --prog-len 40000h --ram-len 80000h`) plus the existing conformance `shim.o`, and runs `scripts/tms-run`. Expected: status 7, stdout `1 conformance`.
|
||||
|
||||
- [ ] **Step 2: Record the red state**
|
||||
|
||||
Run: `scripts/tests/m11/crt.sh`
|
||||
Expected: FAIL — `sdk/crt0.ll` does not exist. Also record the known fact that `llvm-mc` emits ELF for this triple (and rejects `scripts/tests/m5/conformance/entry.asm`'s `.bss` operands, `h`-suffixed hex, `.even`), so this is an IR rewrite built with `llc`, not a copy.
|
||||
|
||||
- [ ] **Step 3: Write `sdk/crt0.ll`**
|
||||
|
||||
Express the CRT as IR (`sdk/crt0.ll`) with a `naked` `@start` whose single inline-asm block carries the instruction sequence, plus module globals for `_conformance_name`, `_conformance_argv` and `_cstack`. Keep the contract: `setf 16,1,0`/`setf 32,0,1`, clear the four result cells, point `A14` at `_cstack` and `A13` at it, build `argv = { _conformance_name, NULL }`, push `argv` then `1`, `calla _main`, store `A8` as the status and `0x434F4E46` as the magic, `rets`. Build it with `llc -march=tms34010 -filetype=obj`: `llvm-mc` emits ELF for this triple, so only CodeGen reaches the TI-COFF writer.
|
||||
|
||||
- [ ] **Step 4: Run the contract test**
|
||||
|
||||
Run: `scripts/tests/m11/crt.sh`
|
||||
Expected: `m11 crt: PASS` (status 7, stdout `1 conformance`).
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add sdk/crt0.ll scripts/tests/m11/crt.sh
|
||||
git commit -m "m11: add the llc CRT with the conformance runtime contract"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: `sdk/` sources and `scripts/tms-sdk`
|
||||
|
||||
**Files:**
|
||||
- Create: `sdk/include/` (moved from `scripts/tests/m5/conformance/include`, 10 headers)
|
||||
- Create: `sdk/shim.c`, `sdk/heap.c` (moved from `scripts/tests/m5/conformance/`)
|
||||
- Create: `sdk/lib/flib.lib`, `sdk/lib/rts.lib` (committed copies of `build/m6-sdk/{flib,rts}.lib`)
|
||||
- Create: `scripts/tms-sdk`
|
||||
- Create: `scripts/tests/m11/sdk.sh`
|
||||
- Modify: `scripts/tests/m5/conformance/run.sh` (point at `sdk/include`)
|
||||
- Test: `scripts/tests/m11/sdk.sh`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `sdk/crt0.ll` (Task 2), `llc`, `clang --target=tms34010 -c`, `llvm-ar`, `tools/tms-link/{tms-link,tmscoff.py}`.
|
||||
- Produces: `scripts/tms-sdk [--sysroot DIR]`, which installs `<sysroot>/{include,lib,bin}` with `include/*.h`, `lib/{crt0.o,libtms.a,flib.lib,rts.lib}`, `bin/{tms-link,tmscoff.py}`. Default sysroot: `$(clang -print-resource-dir)/tms34010-unknown-none`.
|
||||
|
||||
- [ ] **Step 1: Write the failing gate**
|
||||
|
||||
`scripts/tests/m11/sdk.sh` runs `scripts/tms-sdk --sysroot "$TMP/sysroot"` and asserts: the seven expected layout entries exist; `llvm-ar t libtms.a` lists `shim.o` and `heap.o`; a second run is idempotent; `cmp` of `crt0.o` against a fresh `llc` build is identical; `cmp` of `libtms.a` against a fresh `llvm-ar rcsD` build is identical; `sdk/lib/{flib,rts}.lib` match `build/m6-sdk/{flib,rts}.lib` when those exist.
|
||||
|
||||
- [ ] **Step 2: Run it red**
|
||||
|
||||
Run: `scripts/tests/m11/sdk.sh`
|
||||
Expected: FAIL — `scripts/tms-sdk` does not exist.
|
||||
|
||||
- [ ] **Step 3: Move the sources and commit the archives**
|
||||
|
||||
Move the headers, `shim.c` and `heap.c` into `sdk/`; copy `build/m6-sdk/{flib,rts}.lib` to `sdk/lib/`; update the conformance runner and any harness path that referenced `scripts/tests/m5/conformance/include` so exactly one copy exists.
|
||||
|
||||
- [ ] **Step 4: Implement `scripts/tms-sdk`**
|
||||
|
||||
Build `crt0.o` with `llc`, `shim.o`/`heap.o` with `clang --target=tms34010 -O2 -c`, `libtms.a` with `llvm-ar rcsD`, then install the layout above (copying the linker pair and marking `tms-link` executable). Rebuild `llvm-ar` if missing: `ninja -C build/llvm-clean-build llvm-ar`.
|
||||
|
||||
- [ ] **Step 5: Run it green**
|
||||
|
||||
Run: `scripts/tests/m11/sdk.sh`
|
||||
Expected: `m11 sdk: PASS`.
|
||||
|
||||
- [ ] **Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git add sdk scripts/tms-sdk scripts/tests/m11/sdk.sh scripts/tests/m5/conformance/run.sh
|
||||
git commit -m "m11: add the sdk sources and the sysroot installer"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: ToolChain sysroot discovery and the link job
|
||||
|
||||
**Files:**
|
||||
- Modify: `clang/lib/Driver/ToolChains/TMS34010.h`, `TMS34010.cpp`
|
||||
- Create: `clang/test/Driver/TMS34010-link.c`
|
||||
- Test: that driver test plus `clang/test/Driver/tms34010-defaults.c` (unchanged)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: the installed sysroot from Task 3 and `tms-link`'s CLI (`--entry --text --bss --prog-len --ram-len --map --keep-debug -L -l`).
|
||||
- Produces: `class TMS34010Linker final : public Tool` with `ConstructJob`; `TMS34010ToolChain::buildLinker()`; sysroot-derived include/lib paths; `--tms-linker=PATH`; `-nostartfiles`/`-nodefaultlibs`/`-nostdlib`; `-g` → `--keep-debug`; `-Wl,` passthrough.
|
||||
|
||||
- [ ] **Step 1: Write the failing driver tests**
|
||||
|
||||
`clang/test/Driver/TMS34010-link.c` (model on `avr-link-nostdlib-nodefaultlibs.c`), using `-###`:
|
||||
- default link: `tms-link`, `--entry _start`, `--text 018A0000`, `--bss 01A00000`, the objects, `libtms.a`, `flib.lib`, `rts.lib`;
|
||||
- `-nostdlib`: none of `crt0.o`, `libtms.a`, `flib.lib`, `rts.lib`;
|
||||
- `-nostartfiles`: no `crt0.o`, libraries still present;
|
||||
- `-nodefaultlibs`: `crt0.o` present, no libraries;
|
||||
- `-g`: `--keep-debug`;
|
||||
- `-Wl,--prog-len=80000h`: appears verbatim;
|
||||
- `--tms-linker=/tmp/x`: that path replaces the sysroot linker;
|
||||
- `-l tms`: accepted, and `libtms.a` appears once;
|
||||
- a nonexistent `--tms-sysroot=/nope` and a sysroot without `bin/tms-link`: each produces the named "run scripts/tms-sdk" diagnostic, not a linker error;
|
||||
- `-c`: no link job at all.
|
||||
|
||||
- [ ] **Step 2: Run them red**
|
||||
|
||||
Run: `build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/clang/test/Driver/TMS34010-link.c`
|
||||
Expected: FAIL — clang emits no link job for this target.
|
||||
|
||||
- [ ] **Step 3: Implement discovery and the linker Tool**
|
||||
|
||||
Search order `--tms-sysroot=`, `--sysroot`/`-isysroot`, `<resource-dir>/tms34010-unknown-none`. Add `<sysroot>/include` as a system include and `<sysroot>/lib` as a library path, without touching the M10 freestanding defaults. Implement `ConstructJob` with the argument order in the spec §8.2, and make a missing sysroot, missing `tms-link` or missing `python3` a `Diag` naming `scripts/tms-sdk` (check `python3` with `llvm::sys::findProgramByName`).
|
||||
|
||||
- [ ] **Step 4: Run them green**
|
||||
|
||||
Run: `ninja -C build/llvm-clean-build clang FileCheck && build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/clang/test/Driver/TMS34010-link.c build/llvm-clean/clang/test/Driver/tms34010-defaults.c`
|
||||
Expected: PASS for both files.
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git -C build/llvm-clean add clang/lib/Driver/ToolChains/TMS34010.h \
|
||||
clang/lib/Driver/ToolChains/TMS34010.cpp clang/test/Driver/TMS34010-link.c
|
||||
git -C build/llvm-clean commit -m "tms34010: add sysroot discovery and the tms-link job"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: Single-command build end to end
|
||||
|
||||
**Files:**
|
||||
- Create: `scripts/tests/m11/e2e.sh`
|
||||
- Test: `scripts/tests/m11/e2e.sh`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `scripts/tms-sdk` (Task 3), the link job (Task 4), `scripts/tms-run`.
|
||||
- Produces: the acceptance gate for the milestone's headline command.
|
||||
|
||||
- [ ] **Step 1: Write the failing gate**
|
||||
|
||||
`scripts/tests/m11/e2e.sh` (run from a temp directory outside the repo, with `env -u M4_WORK -u TMS_CLANG …`): install the sysroot into a temp dir with `scripts/tms-sdk --sysroot`, export `CLANG` and pass `--tms-sysroot` once, then:
|
||||
- `clang --target=tms34010 hello.c -o hello` (a heredoc `hello.c` printing one line) and `tms-run hello` → status 0, stdout matches, and `hello.map` exists;
|
||||
- a two-TU build (`add.c` + `main.c`) → `add=42`;
|
||||
- `-c`, `-S`, `-E` produce an object, assembly and preprocessed source respectively;
|
||||
- `-O0` and `-O2` both run correctly;
|
||||
- `-g` links and the image keeps `.debug_*` while a default link is stripped;
|
||||
- `-nostdlib` with a user `_start` links;
|
||||
- `clang -### --target=tms34010 hello.c -o hello` contains no checkout path.
|
||||
|
||||
- [ ] **Step 2: Run it red**
|
||||
|
||||
Run: `scripts/tests/m11/e2e.sh`
|
||||
Expected: FAIL at the first link with the missing-sysroot/link-job diagnostic.
|
||||
|
||||
- [ ] **Step 3: Fix what the gate exposes**
|
||||
|
||||
Only driver/ToolToolchain or `tms-sdk` changes belong here; if a defect is in `tms-link`, note it and fix it with its own test.
|
||||
|
||||
- [ ] **Step 4: Run it green**
|
||||
|
||||
Run: `scripts/tests/m11/e2e.sh`
|
||||
Expected: `m11 e2e: PASS`.
|
||||
|
||||
- [ ] **Step 5: Verify one existing harness program and the compatibility alias**
|
||||
|
||||
Run the M4 harness with `M4_NATIVE=1 M4_LINKER=tms-link` on one program (e.g. `scripts/m4/unsigned.c`) and confirm its MAME markers still pass. Then run `scripts/tms-cc hello.c -o hello` and `scripts/tms-run hello` to confirm the Phase 1 alias still works after the sysroot change.
|
||||
|
||||
- [ ] **Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git add scripts/tests/m11/e2e.sh
|
||||
git commit -m "m11: gate the single-command build end to end"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: Docs, full sweep, patch export, promote `m11`
|
||||
|
||||
**Files:**
|
||||
- Modify: `README.md`, `build/llvm-clean/TMS34010.md`, `docs/superpowers/specs/2026-11-10-tms34010-llvm-design.md`
|
||||
- Modify: `patches/llvm/0005-*.patch`
|
||||
- Test: the full M0–M11 gate list
|
||||
|
||||
- [ ] **Step 1: Re-export the driver patch**
|
||||
|
||||
Run: `git -C build/llvm-clean diff m9..m11 -- clang/ > patches/llvm/0005-tms34010-toolchain.patch`
|
||||
Expected: only `ToolChains/TMS34010.{h,cpp}`, the two registration edits and the M10/M11 clang tests.
|
||||
|
||||
- [ ] **Step 2: Run the compiler and toolchain tests**
|
||||
|
||||
Run: lit for `llvm/test/CodeGen/TMS34010`, `llvm/test/MC/TMS34010`, `clang/test/CodeGen/TMS34010`, `clang/test/Driver/TMS34010*`; `tools/tms-link/tests/run.sh`; `tools/tms-bitaddr/tests/run.sh`.
|
||||
Expected: all PASS.
|
||||
|
||||
- [ ] **Step 3: Run the M11 gates and the M10 regressions**
|
||||
|
||||
Run: `scripts/tests/m11/{sdk,crt,e2e}.sh`, `scripts/tests/m10/equivalence.sh` (`pass=46 fail=0`), `scripts/tests/m10/bitaddr-idempotent.sh`, `scripts/tests/m9/dwarf-ranges.sh`, `scripts/tests/m8/dwarf-multi.sh`, `scripts/tests/m7/debug.sh`.
|
||||
Expected: all PASS.
|
||||
|
||||
- [ ] **Step 4: Run the suite and the divide measurement**
|
||||
|
||||
Run: `scripts/tests/m7/full-suite.sh --corpus all --work build/m11-final`
|
||||
Expected: `all total=1912 pass=1618 skip=294 fail=0 crash=0`.
|
||||
Run: `scripts/tests/m7/i64div.sh`
|
||||
Expected: `88/3302/221/120`, ratios 37.5/14.9/1.8, the same four checksums.
|
||||
|
||||
- [ ] **Step 5: Run the remaining M0–M10 gate list**
|
||||
|
||||
The serial list from `README.md`'s gate section, including `hardware.sh` → `HARDWARE: DEFERRED`.
|
||||
Expected: every gate PASS.
|
||||
|
||||
- [ ] **Step 6: Update the docs**
|
||||
|
||||
Record M11 complete: the single command, the sysroot layout and `scripts/tms-sdk`, `python3` as a link-time dependency, the link-reduction knobs, the CRT dialect rewrite and its preserved contract, the `tms-link` validity fix, `tms-cc` as a compatibility alias, and the M11/M12 boundary with a pointer to the roadmap (§11 of the design).
|
||||
|
||||
- [ ] **Step 7: Commit, review, push, promote**
|
||||
|
||||
```bash
|
||||
git -C build/llvm-clean add TMS34010.md
|
||||
git -C build/llvm-clean commit -m "docs: record the M11 toolchain"
|
||||
git add README.md docs/superpowers/specs/2026-11-10-tms34010-llvm-design.md \
|
||||
patches/llvm/0005-tms34010-toolchain.patch
|
||||
git commit -m "m11: document the conventional toolchain"
|
||||
```
|
||||
|
||||
Then run the whole-branch review, and only when it is clean: push `m11` in both repositories, set it as the default on both remotes, and update the README's default-branch wording. `m10` stays as the previous snapshot.
|
||||
|
||||
---
|
||||
|
||||
## Execution Handoff
|
||||
|
||||
M11 ends with `clang --target=tms34010 hello.c -o hello` working from a clean shell after one `scripts/tms-sdk`, every M0–M10 gate still green, and the suite unchanged at 1,618 passes. M12 (conformance classes) is the next milestone per the roadmap; it gets its own design and plan.
|
||||
@@ -0,0 +1,383 @@
|
||||
# TMS34010 M12 — Tractable Conformance Gaps Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Close the backend gaps that account for 17 curated full-suite skips — inline-asm memory operands, the `ST` clobber, computed `goto`, return/frame address at level 0, and dynamic-alloca scaling — and produce a costed triage of the runtime-abort skips for M13.
|
||||
|
||||
**Architecture:** All compiler work stays in `llvm/lib/Target/TMS34010/` (plus `"st"` in clang's target register list). Inline-asm memory operands get a real selector in `TMS34010ISelDAGToDAG::SelectInlineAsmMemoryOperand`; computed goto needs the ISA's `jump Rd` instruction end to end plus `ISD::BlockAddress`/`ISD::BRIND` lowering; the frame intrinsics lower against the existing system-stack layout; the alloca fix keeps bit units throughout. The abort triage is a harness plus a research document, not a fix pass.
|
||||
|
||||
**Tech Stack:** LLVM/Clang 23.1.5 fork (`llvm-tms34010`), SelectionDAG/ISel, MC (encoding, parser, printer, disassembler), lit/FileCheck, the TMS34010 MAME harness, shell gates.
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-11-19-tms34010-m12-tractable-gaps-design.md` (§7 per workstream, §8 acceptance).
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Baseline: project `m11`/`ef8a854`, compiler `m11`/`18b7fc9cd6df`. Cut `m12` in both repos before Task 1; never force-push.
|
||||
- LLVM/Clang stay pinned at 23.1.5. No generic-LLVM behaviour changes: `InlineAsm::ConstraintCode` is not extended, so `V` stays loud.
|
||||
- No TI ABI change: the all-stack convention, argument slots, the bit pointer model and the frame layout are unchanged.
|
||||
- `clang --target=tms34010 -c` and the M11 `hello.c -o hello` flow must keep working, including `-O0` byte identity (`scripts/tests/m10/equivalence.sh` `pass=46 fail=0`).
|
||||
- Build with `-j4` on this host (unbounded ninja has been OOM-killed).
|
||||
- Every gate stays green; the suite stays `0 fail / 0 crash`. A curated row is removed only in the task that makes it pass, with the flip recorded.
|
||||
- No gate expectation, checksum or recorded count moves beyond those recorded flips.
|
||||
- Out of scope, permanently: nested functions and VLA-in-struct (clang frontend refusals), dialect strictness, timeouts and region limits.
|
||||
|
||||
## Review Focus
|
||||
|
||||
1. **Inline-asm memory operands that are not a plain `*An`** — a user writing `"m"(*p)` where `p` is an argument, an sp-relative local, or a post-increment form must get a valid address, or a named error — never a silent register copy (Task 1).
|
||||
2. **Computed `goto` and the new instruction's encoding round-trip** — the block address must be section-relative, and `jump Rd` must assemble, disassemble and select consistently (Task 2).
|
||||
3. **`__builtin_return_address(0)` after a dynamic alloca or in a variadic callee** — the frame may not hold a fixed offset; the level-0 value must still be the caller's return address (Task 3).
|
||||
4. **A dynamic alloca whose size is not a multiple of 32 bits** — the stack adjust and the pointer arithmetic must agree (Task 4).
|
||||
5. **The triage's own honesty** — a row that aborts must be recorded with its actual status and cause, and the harness must not turn a curated skip into a fail row (Task 5).
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Inline-asm memory operands and the `ST` clobber
|
||||
|
||||
**Files:**
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010ISelDAGToDAG.cpp:35-45` (`SelectInlineAsmMemoryOperand`)
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010ISelLowering.cpp:650` (`getConstraintType`) if `o`/`V` need distinguishing
|
||||
- Modify: `clang/lib/Basic/Targets/TMS34010.cpp:73` (`getGCCRegNames`)
|
||||
- Test: `clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c`, `llvm/test/CodeGen/TMS34010/m12-inline-asm-st.ll`, `llvm/test/CodeGen/TMS34010/m12-inline-asm-mem-reject.ll`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: the target's existing addressing-mode selection (the matcher used by `LD`/`ST` in `TMS34010ISelDAGToDAG.cpp`) and the M9 constraint plumbing (`getRegForInlineAsmConstraint`, `getConstraintType`).
|
||||
- Produces: `bool TMS34010DAGToDAGISel::SelectInlineAsmMemoryOperand(const SDValue &Op, InlineAsm::ConstraintCode ConstraintID, SmallVectorImpl<SDValue> &OutOps)` that selects the five ISA memory forms (`*An`, `*An(disp)`, `*An+`, `*-An`, `*An(disp),N`) for `m`/`g`, and a named error for anything else; `"st"` present in clang's GCC register list.
|
||||
|
||||
- [ ] **Step 1: Write the failing tests**
|
||||
|
||||
```c
|
||||
// clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c
|
||||
// RUN: %clang_cc1 -triple tms34010-unknown-none -O0 -S -o - %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -triple tms34010-unknown-none -O2 -S -o - %s | FileCheck %s
|
||||
int load_via_asm(int *p) {
|
||||
int x;
|
||||
__asm__ volatile("" : "=r"(x) : "m"(*p) : "memory");
|
||||
return x;
|
||||
}
|
||||
int store_via_asm(int *p, int v) {
|
||||
__asm__ volatile("" : : "m"(*p), "r"(v) : "memory");
|
||||
return v;
|
||||
}
|
||||
// CHECK-LABEL: _load_via_asm:
|
||||
// CHECK-NOT: error:
|
||||
// CHECK-LABEL: _store_via_asm:
|
||||
```
|
||||
|
||||
```llvm
|
||||
; llvm/test/CodeGen/TMS34010/m12-inline-asm-st.ll
|
||||
; RUN: llc -march=tms34010 -O0 -filetype=asm < %s | FileCheck %s
|
||||
define i32 @clobber_st(i32 %x) {
|
||||
%r = call i32 asm sideeffect "", "=r,0,~{st}"(i32 %x)
|
||||
ret i32 %r
|
||||
}
|
||||
; CHECK-LABEL: _clobber_st:
|
||||
; CHECK-NOT: error:
|
||||
```
|
||||
|
||||
```llvm
|
||||
; llvm/test/CodeGen/TMS34010/m12-inline-asm-mem-reject.ll
|
||||
; RUN: not llc -march=tms34010 -O0 -filetype=asm < %s 2>&1 | FileCheck %s
|
||||
define i32 @bad(i32 %x) {
|
||||
%r = call i32 asm sideeffect "", "=r,0,~{memory}"(i32 %x)
|
||||
ret i32 %r
|
||||
}
|
||||
; CHECK: TMS34010: unsupported inline asm
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Run them red**
|
||||
|
||||
Run: `build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c build/llvm-clean/llvm/test/CodeGen/TMS34010/m12-inline-asm-st.ll`
|
||||
Expected: FAIL — the first with `TMS34010: inline asm memory constraints ('m'/'o'/'V') are not supported`, the second with `unknown register name 'st' in asm`.
|
||||
|
||||
- [ ] **Step 3: Implement the selector and the clobber name**
|
||||
|
||||
In `SelectInlineAsmMemoryOperand`, match the operand to a memory form using the same `SelectAddr`-style helper the loads/stores use; push the base register and the displacement (if any) as `OutOps`. For `m`/`g` accept any matched form; for `o` accept only forms without a post-increment and with a non-negative displacement; for `V` keep the existing named error, extended to say that `V` needs core LLVM support. Add `"st"` to `getGCCRegNames()`; leave the register class and operand constraints untouched so `ST` is clobber-only.
|
||||
|
||||
- [ ] **Step 4: Run them green**
|
||||
|
||||
Run: `ninja -C build/llvm-clean-build -j4 clang llc FileCheck && build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c build/llvm-clean/llvm/test/CodeGen/TMS34010/m12-inline-asm-st.ll build/llvm-clean/llvm/test/CodeGen/TMS34010/m12-inline-asm-mem-reject.ll`
|
||||
Expected: PASS for all three.
|
||||
|
||||
- [ ] **Step 5: Flip the eleven corpus rows**
|
||||
|
||||
```sh
|
||||
awk -F'\t' '$2 ~ /^inline-asm: TMS34010 memory constraints/ {print $1}' \
|
||||
scripts/tests/m7/full-suite.skip > /tmp/opencode/m12-inline.txt
|
||||
scripts/tests/m7/full-suite.sh --corpus c-torture --list /tmp/opencode/m12-inline.txt \
|
||||
--redo --work build/m12-inline
|
||||
```
|
||||
Expected: all pass. Remove exactly those rows from `scripts/tests/m7/full-suite.skip` and record the count.
|
||||
|
||||
- [ ] **Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git -C build/llvm-clean add llvm/lib/Target/TMS34010/TMS34010ISelDAGToDAG.cpp \
|
||||
llvm/lib/Target/TMS34010/TMS34010ISelLowering.cpp clang/lib/Basic/Targets/TMS34010.cpp \
|
||||
llvm/test/CodeGen/TMS34010/m12-inline-asm-*.ll clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c
|
||||
git -C build/llvm-clean commit -m "tms34010: select inline-asm memory operands and name the st clobber"
|
||||
git add scripts/tests/m7/full-suite.skip
|
||||
git commit -m "m12: flip the inline-asm memory-constraint rows"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: `jump Rd`, `BRIND` and computed `goto`
|
||||
|
||||
**Files:**
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010InstrInfo.td` (new `JumpReg` definition, opcode `0x0160`)
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010InstrInfo.cpp` if the instruction needs custom sizing
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010ISelLowering.cpp` (`LowerOperation`: `ISD::BlockAddress`, `ISD::BRIND`; `setOperationAction`)
|
||||
- Modify: `llvm/lib/Target/TMS34010/MCTargetDesc/{TMS34010AsmParser,TMS34010InstPrinter,TMS34010MCCodeEmitter,TMS34010Disassembler}.cpp` as the generated tables require
|
||||
- Test: `llvm/test/MC/TMS34010/m12-jump-reg.s`, `llvm/test/CodeGen/TMS34010/m12-computed-goto.ll`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: the existing branch machinery (`JUncond`, `JR`, `TMS34010Jrc`) and `TMS34010TargetLowering::LowerOperation`'s switch.
|
||||
- Produces: instruction `TMS34010::JumpReg` (`"jump $src"`), `ISD::BRIND` lowered to it, and `ISD::BlockAddress` lowered to a section-relative bit address (`TMS34010ISD::BITADDR`-style constant material, with the existing relocation path).
|
||||
|
||||
- [ ] **Step 1: Write the failing MC test**
|
||||
|
||||
```asm
|
||||
# llvm/test/MC/TMS34010/m12-jump-reg.s
|
||||
# RUN: llvm-mc -triple=tms34010 -show-encoding %s | FileCheck %s
|
||||
# RUN: llvm-mc -triple=tms34010 -filetype=obj %s -o %t.o
|
||||
# RUN: llvm-mc -triple=tms34010 -disassemble %t.o | FileCheck %s --check-prefix=DIS
|
||||
# CHECK: jump a0 # encoding: [0x60,0x01,0x00,0x00]
|
||||
# DIS: jump a0
|
||||
jump a0
|
||||
```
|
||||
|
||||
Confirm the expected encoding against `vendor/vt1200/tools/smart34010/README.md` (opcode `0x0160`) and the ISA's word order before pinning the bytes.
|
||||
|
||||
- [ ] **Step 2: Run it red**
|
||||
|
||||
Run: `build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/llvm/test/MC/TMS34010/m12-jump-reg.s`
|
||||
Expected: FAIL — `invalid instruction mnemonic 'jump'`.
|
||||
|
||||
- [ ] **Step 3: Define the instruction and its MC surface**
|
||||
|
||||
Add `def JumpReg : TMS34010Inst<(outs), (ins ARegs:$src), "jump $src", …>` with the opcode and encoding the ISA specifies; update the assembler match table, printer and disassembler as generated. The disassembly assertion in the test is what proves the round-trip; keep `JUncond`/`JR` untouched.
|
||||
|
||||
- [ ] **Step 4: Run the MC test green and the MC suite**
|
||||
|
||||
Run: `ninja -C build/llvm-clean-build -j4 llvm-mc llc FileCheck && build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/llvm/test/MC/TMS34010`
|
||||
Expected: the new test plus the four existing MC tests pass.
|
||||
|
||||
- [ ] **Step 5: Write the failing computed-goto test**
|
||||
|
||||
```llvm
|
||||
; llvm/test/CodeGen/TMS34010/m12-computed-goto.ll
|
||||
; RUN: llc -march=tms34010 -O0 -filetype=asm < %s | FileCheck %s
|
||||
define i32 @cg(i32 %x) {
|
||||
entry:
|
||||
indirectbr ptr blockaddress(@cg, %a), [label %a, label %b]
|
||||
a:
|
||||
ret i32 1
|
||||
b:
|
||||
ret i32 2
|
||||
}
|
||||
; CHECK-LABEL: _cg:
|
||||
; CHECK: jump
|
||||
; CHECK-LABEL: .Lcg$a:
|
||||
```
|
||||
|
||||
- [ ] **Step 6: Run it red, then implement the lowerings**
|
||||
|
||||
Run: `build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/llvm/test/CodeGen/TMS34010/m12-computed-goto.ll`
|
||||
Expected: FAIL — `Cannot select: … BlockAddress`.
|
||||
|
||||
Implement `ISD::BlockAddress` (section-relative bit address with the existing relocation path) and `ISD::BRIND` (jump through the selected register) in `LowerOperation`, and mark both `Custom` in the constructor. Then rerun the test.
|
||||
|
||||
- [ ] **Step 7: Flip the two corpus rows**
|
||||
|
||||
Run the two rows (`c-torture/920501-3`, `c-torture/990208-1`) through the suite in isolation; both must pass at `-O0` and `-O2`. Remove them from `full-suite.skip`.
|
||||
|
||||
- [ ] **Step 8: Commit**
|
||||
|
||||
```bash
|
||||
git -C build/llvm-clean add llvm/lib/Target/TMS34010 llvm/test/MC/TMS34010/m12-jump-reg.s \
|
||||
llvm/test/CodeGen/TMS34010/m12-computed-goto.ll
|
||||
git -C build/llvm-clean commit -m "tms34010: add jump Rd, BRIND and blockaddress lowering"
|
||||
git add scripts/tests/m7/full-suite.skip
|
||||
git commit -m "m12: flip the computed-goto rows"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: Return and frame address at level 0
|
||||
|
||||
**Files:**
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010ISelLowering.cpp` (`LowerOperation`, `setOperationAction` for `ISD::RETURNADDR`/`ISD::FRAMEADDR`)
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010FrameLowering.cpp` only if the level-0 value needs a slot recorded
|
||||
- Test: `llvm/test/CodeGen/TMS34010/m12-frameaddr.ll`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: the system-stack layout documented in `TMS34010FrameLowering.cpp:120-145` — the callee saves the caller's state below the return address, and `LOADSTK`/`ADDSTK` already encode `(NumSaved + 1) * 32`.
|
||||
- Produces: `ISD::RETURNADDR` at level 0 → the caller's return address (a slot computed from the saved-register count or an `SP`-relative load emitted after PEI); `ISD::FRAMEADDR` at level 0 → `A13`; levels above 0 → a named error that says which intrinsic and level.
|
||||
|
||||
- [ ] **Step 1: Write the failing test**
|
||||
|
||||
```llvm
|
||||
; llvm/test/CodeGen/TMS34010/m12-frameaddr.ll
|
||||
; RUN: llc -march=tms34010 -O0 -filetype=asm < %s | FileCheck %s
|
||||
declare ptr @llvm.returnaddress(i32)
|
||||
declare ptr @llvm.frameaddress(i32)
|
||||
define ptr @ra0() {
|
||||
%p = call ptr @llvm.returnaddress(i32 0)
|
||||
ret ptr %p
|
||||
}
|
||||
define ptr @fa0() {
|
||||
%p = call ptr @llvm.frameaddress(i32 0)
|
||||
ret ptr %p
|
||||
}
|
||||
; CHECK-LABEL: _ra0:
|
||||
; CHECK-NOT: error
|
||||
; CHECK-LABEL: _fa0:
|
||||
; CHECK-NOT: error
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Run it red**
|
||||
|
||||
Run: `build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/llvm/test/CodeGen/TMS34010/m12-frameaddr.ll`
|
||||
Expected: FAIL with `unexpected TMS34010 custom lowering operation`.
|
||||
|
||||
- [ ] **Step 3: Implement the two lowerings**
|
||||
|
||||
Read `TMS34010FrameLowering.cpp` to derive the level-0 return-address offset from the saved-register count (the same expression the prologue/epilogue use), and lower `RETURNADDR(0)` to a load from it; `FRAMEADDR(0)` is `A13`. For a level above 0, fail with `TMS34010: <intrinsic> level <n> is unsupported (only level 0)`.
|
||||
|
||||
- [ ] **Step 4: Run the test green, then probe the frame cases**
|
||||
|
||||
Add a case with a dynamic alloca and a variadic callee to the same test and confirm the emitted offset changes with the frame instead of being hard-coded. Run the test.
|
||||
|
||||
- [ ] **Step 5: Flip the three corpus rows**
|
||||
|
||||
Run `c-torture/20030811-1`, `c-torture/frame-address`, `c-torture/pr17377` through the suite; remove those three from `full-suite.skip`. `20010122-1` and `20030323-1` stay curated; update their reasons to `level > 0 unsupported` if they do not already say so.
|
||||
|
||||
- [ ] **Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git -C build/llvm-clean add llvm/lib/Target/TMS34010/TMS34010ISelLowering.cpp \
|
||||
llvm/test/CodeGen/TMS34010/m12-frameaddr.ll
|
||||
git -C build/llvm-clean commit -m "tms34010: lower returnaddress/frameaddress at level 0"
|
||||
git add scripts/tests/m7/full-suite.skip
|
||||
git commit -m "m12: flip the level-0 frame rows and restate the level>0 skips"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: Dynamic alloca scaling
|
||||
|
||||
**Files:**
|
||||
- Modify: `llvm/lib/Target/TMS34010/TMS34010ISelLowering.cpp:1894` (`ISD::DYNAMIC_STACKALLOC` case) and whatever size scaling feeds it
|
||||
- Test: `llvm/test/CodeGen/TMS34010/m12-dynalloca.ll`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: the bit-unit pointer model and the `MOVE A14, A13` / `ADDSTK FrameBits` epilogue path for `hasVarSizedObjects()` (`TMS34010FrameLowering.cpp:133-143`).
|
||||
- Produces: a dynamic alloca whose stack adjustment and returned pointer agree in bits for non-multiple-of-32 sizes.
|
||||
|
||||
- [ ] **Step 1: Reproduce and write the failing test**
|
||||
|
||||
Run: `scripts/tests/m7/full-suite.sh --corpus c-torture --list <(echo c-torture/20070824-1) --redo --work build/m12-dyn` and capture the failure.
|
||||
|
||||
Then write `m12-dynalloca.ll` with a `dynamic alloca i8, i32 %n` and a store/load through the returned pointer, asserting the stack adjust is `8*n` bits (not `n`), at `-O0` and `-O2`.
|
||||
|
||||
- [ ] **Step 2: Run it red**
|
||||
|
||||
Run: `build/llvm-clean-build/bin/llvm-lit -v build/llvm-clean/llvm/test/CodeGen/TMS34010/m12-dynalloca.ll`
|
||||
Expected: FAIL — the assertion from the corpus run, or the wrong stack-adjust constant.
|
||||
|
||||
- [ ] **Step 3: Fix the scaling**
|
||||
|
||||
Make the alloca size arrive in bits (multiply the byte size by 8 where the DAG builds it, or scale in the `DYNAMIC_STACKALLOC` lowering), and keep alignment rounding in bits.
|
||||
|
||||
- [ ] **Step 4: Run the test and the corpus row green**
|
||||
|
||||
Run the lit test, then the corpus row alone. Then remove `c-torture/20070824-1` from `full-suite.skip`.
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git -C build/llvm-clean add llvm/lib/Target/TMS34010/TMS34010ISelLowering.cpp \
|
||||
llvm/test/CodeGen/TMS34010/m12-dynalloca.ll
|
||||
git -C build/llvm-clean commit -m "tms34010: scale dynamic alloca sizes in bit units"
|
||||
git add scripts/tests/m7/full-suite.skip
|
||||
git commit -m "m12: flip the dynamic-alloca row"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: Abort triage
|
||||
|
||||
**Files:**
|
||||
- Create: `scripts/tests/m12/abort-triage.sh`
|
||||
- Create: `docs/superpowers/research/2026-11-19-tms34010-abort-triage.md`
|
||||
- Test: the harness itself (run it; it must produce the document)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `scripts/tests/m7/full-suite.sh` (for corpus discovery and the classifier), `scripts/tests/m5/conformance/run.sh --classify --mode native --expect-status 0`, and the manifest's status/marker contract.
|
||||
- Produces: a document with one row per abort-skipped file: `corpus/name`, `-O0` result, `-O2` result, status word, first wrong marker or abort PC, cause class, evidence pointer, estimated cost; plus a summary grouped by cause and a proposed M13 scope. The harness discovers its set by re-running every curated `runtime-abort*`/wrong-result row, and must not edit `full-suite.skip`.
|
||||
|
||||
- [ ] **Step 1: Write the harness**
|
||||
|
||||
`scripts/tests/m12/abort-triage.sh`: enumerate the curated abort rows from `full-suite.skip`, run each at `-O0` and `-O2`, capture the runner's status and the first differing marker (reuse the runner's own output format), and emit the Markdown table. It must be hermetic apart from MAME, and serial.
|
||||
|
||||
- [ ] **Step 2: Run it and record the raw output**
|
||||
|
||||
Run: `scripts/tests/m12/abort-triage.sh`
|
||||
Expected: a table covering the discovered set (49–51 rows at the time of writing) with no `fail` rows added to the suite file.
|
||||
|
||||
- [ ] **Step 3: Group and write the research document**
|
||||
|
||||
Fill `2026-11-19-tms34010-abort-triage.md` from the harness output: one row per file, cause classes with the evidence, and an M13 proposal ordering the causes by files affected and estimated cost. Apply the plan's ruling: at most three fixes may be proposed as one-line fixes inside M12.
|
||||
|
||||
- [ ] **Step 4: Commit**
|
||||
|
||||
```bash
|
||||
git add scripts/tests/m12/abort-triage.sh docs/superpowers/research/2026-11-19-tms34010-abort-triage.md
|
||||
git commit -m "m12: triage the runtime-abort skips for M13"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: Accounting, docs, full sweep, promote `m12`
|
||||
|
||||
**Files:**
|
||||
- Modify: `README.md`, `build/llvm-clean/TMS34010.md`, `docs/superpowers/specs/2026-11-10-tms34010-llvm-design.md`
|
||||
- Modify: `patches/llvm/0005-*.patch` (the compiler delta for M12)
|
||||
- Test: the full M0–M12 gate list
|
||||
|
||||
- [ ] **Step 1: Re-record the suite accounting**
|
||||
|
||||
Run: `scripts/tests/m7/full-suite.sh --corpus all --work build/m12-final`
|
||||
Expected: `0 fail / 0 crash`, pass = 1,618 + 17 (plus any abort fixes taken), skip = 294 − the same number, and every removed row named in the commit history.
|
||||
|
||||
- [ ] **Step 2: Run the compiler and toolchain tests**
|
||||
|
||||
Run: lit for `llvm/test/CodeGen/TMS34010`, `llvm/test/MC/TMS34010`, `clang/test/CodeGen/TMS34010`, `clang/test/Driver/TMS34010*`; `tools/tms-link/tests/run.sh`; `tools/tms-bitaddr/tests/run.sh`; `scripts/tests/m11/{sdk,crt,e2e}.sh`; `scripts/tests/m10/equivalence.sh` (`pass=46 fail=0`).
|
||||
Expected: all PASS.
|
||||
|
||||
- [ ] **Step 3: Run the M0–M11 gate list and the divide measurement**
|
||||
|
||||
The serial list from `README.md`'s gate section, plus `scripts/tests/m7/i64div.sh` (expect `88/3302/221/120` and the four checksums) and `hardware.sh` (`HARDWARE: DEFERRED`).
|
||||
Expected: every gate PASS.
|
||||
|
||||
- [ ] **Step 4: Export the patch and update the docs**
|
||||
|
||||
Re-export `patches/llvm/0005-*.patch`; record M12 complete in the three documents: the 17 flips with their rows, the `ST`/`o`/`V` decisions, `jump Rd`, the level-0 frame intrinsics, the alloca fix, the triage report's path and headline (what M13 inherits), the permanently-out classes, and `m12` as the milestone branch pending promotion.
|
||||
|
||||
- [ ] **Step 5: Commit and hand off for review**
|
||||
|
||||
```bash
|
||||
git -C build/llvm-clean add TMS34010.md
|
||||
git -C build/llvm-clean commit -m "docs: record the M12 state"
|
||||
git add README.md docs/superpowers/specs/2026-11-10-tms34010-llvm-design.md \
|
||||
patches/llvm/0005-tms34010-toolchain.patch
|
||||
git commit -m "m12: document the conformance fixes and the abort triage"
|
||||
```
|
||||
|
||||
Then run the whole-branch review. Only when it is clean: push `m12` in both repositories, set it as the default on both remotes, and update the README's default-branch wording.
|
||||
|
||||
---
|
||||
|
||||
## Execution Handoff
|
||||
|
||||
M12 ends with 17 more files passing, a triaged abort list that makes M13 plannable, and every M0–M11 gate plus the M11 end-to-end build still green. M13 (ABI shapes + the triaged abort causes) is planned after this milestone is promoted.
|
||||
@@ -0,0 +1,93 @@
|
||||
# Multi-model review observations (M12)
|
||||
|
||||
Started 2026-11-19. The partner asked for two reviewers per task (DeepSeek Flash always, plus a free
|
||||
OpenCode model) and for anything noteworthy this surfaces to be written down.
|
||||
|
||||
## Protocol
|
||||
|
||||
| seat | model | role |
|
||||
|---|---|---|
|
||||
| A | `deepseek/deepseek-flash` | always present, first reader |
|
||||
| B | `opencode/tidepool-alpha-free` | second opinion on every task review |
|
||||
| C | `opencode/nemotron-3.5-super-vl-free` | third seat for the whole-branch review and risky tasks |
|
||||
|
||||
Both seats get the same brief, report and diff file, and neither sees the other's verdict. Findings
|
||||
are compared by the controller; disagreements are adjudicated in the normal fix loop.
|
||||
|
||||
## Findings caught by a second seat that seat A missed
|
||||
|
||||
| task | seat | finding | outcome |
|
||||
|---|---|---|---|
|
||||
| 3 | A (flash) | **Critical**: the level-0 return-address load was chained only to the entry node, so at `-O1+` it sank into the caller's saved-STK push window and read the saved frame pointer. Reproduced from C. Seat B had approved after checking only `-O0`. | Fix round 1: capture the RA in the prologue into an A13-relative slot; test now uses the RA after an argument-bearing call. **This is the first genuine severity divergence between the seats.** |
|
||||
| 1 | B (tidepool) | `ConstraintCode::X` is also accepted by the new memory selector (an unspecified superset, not in the rulings) | parked as Minor; harmless, `X` is an "any value" code |
|
||||
| 1 | B (tidepool) | `stkalign`'s new skip reason is report-attested only — the test source is not in the pinned repo | parked; the assert status (0x86) is recorded |
|
||||
|
||||
## Findings caught by seat A that a second seat missed
|
||||
|
||||
| task | seat A finding | outcome |
|
||||
|---|---|---|
|
||||
| (none yet) | | |
|
||||
|
||||
## Notes on the free seats
|
||||
|
||||
- Task 1: both seats independently verified the same core contracts (no register-copy fallback,
|
||||
`ST` outside every register class, skip accounting). Seat B added the `X`-superset observation and
|
||||
the "report-attested reason" caveat; seat A added the release-build `llvm_unreachable` safety nit
|
||||
and three test-strength nits. Neither found a defect the other's verdict would have missed at
|
||||
Critical/Important level.
|
||||
|
||||
## Task 2
|
||||
|
||||
- Both seats independently reproduced the same escalation: `990208-1`'s `-O2` abort comes from
|
||||
generic LLVM refusing to inline a function whose address is taken (`InlineCost.cpp:3320`), and the
|
||||
test's own `__OPTIMIZE__` guard then aborts on x86-64 too. Neither seat treated it as a TMS34010
|
||||
defect; the controller ruled to keep the row and record the caveat.
|
||||
- Distinct contributions: seat A found the constant-integer `BRIND` path has no lit coverage and that
|
||||
`920501-3` only ever adds a zero offset (so bit-unit scaling of a nonzero block-address offset is
|
||||
untested); seat B checked the object-smoke direction and the `MO_BlockAddress` symbol path in
|
||||
detail. Neither found a defect at Critical/Important that the other missed.
|
||||
|
||||
## Task 3 follow-ups
|
||||
|
||||
- The severity divergence was real and the fix loop needed two rounds: round 1 fixed the scheduling
|
||||
bug but introduced illegal `A8` operands (caught by seat A via `-verify-machineinstrs`); round 2
|
||||
used `A0`/`A1` and added the verifier to both tests.
|
||||
- Seat B, whose original review had approved, caught a **stale diff** in the re-review: the diff file
|
||||
described the A8 variant while the tree already carried the A0/A1 fix. It resolved the discrepancy
|
||||
by verifying the head tree and flagging it explicitly — a failure mode worth remembering when
|
||||
reviews and implementers overlap.
|
||||
|
||||
## Task 4
|
||||
|
||||
- Both seats converged on the same judgment: the dropped assertion only fired on constant-folded input,
|
||||
so it guarded nothing real, and both paths now scale by value. No divergence.
|
||||
- Seat A caught an evidence-hygiene problem nobody else would have looked for: the corpus RED log had
|
||||
been overwritten by the post-fix run, so the claimed reproduction is no longer inspectable. Keep
|
||||
pre-fix logs in their own work directory next time.
|
||||
|
||||
## Task 5
|
||||
|
||||
- Both seats approved and both independently re-derived the 54-row set from the skip file (52 aborts +
|
||||
2 wrong results) and reconciled all three count tables.
|
||||
- Seat A caught the evidence-durability problem: the load-bearing probe results lived only in an
|
||||
untracked `build/` directory, which would leave an M13 engineer unable to re-inspect the claims that
|
||||
killed the endianness "fix". Ruled: commit the probe sources.
|
||||
- Seat B added the note that the report's "one-line" candidate is really one-flag/one-condition, and
|
||||
that the stale 49-51/58 bounds should be read as history.
|
||||
|
||||
## Milestone summary
|
||||
|
||||
- Seats used: A = `deepseek/deepseek-flash` (every review), B = `opencode/tidepool-alpha-free` (every
|
||||
task review), C = `opencode/nemotron-3.5-super-vl-free` (whole-branch review).
|
||||
- **One genuine severity divergence:** Task 3, where seat B approved a return-address load that seat A
|
||||
reproduced as a miscompile at `-O1+`. The reproducer decided it; the fix needed two rounds because
|
||||
round 1 introduced illegal `A8` operands.
|
||||
- **Second-seat value:** seat B caught a stale diff (round-1 text vs round-2 tree) and reasoned about
|
||||
the tree; seat A caught an evidence-durability gap (probes only in `build/`); seat C contributed the
|
||||
pointer↔int "invalid for the target model" analysis and the `OpNo > 0` printer guard.
|
||||
- **Where the process was weakest:** two controller-supplied test/premise errors (a reject case using
|
||||
a supported clobber; the `-O2` requirement for a test that only makes sense at `-O0`), and one
|
||||
controller wording instruction that was simply wrong (`V` vs `v`). Each was caught by a review, but
|
||||
the controller was the source.
|
||||
- **Where the extra seats cost:** doubled review latency per task and several near-duplicate verdicts
|
||||
on mechanical tasks (1, 4). The divergence on 3 alone justified the protocol for this milestone.
|
||||
@@ -0,0 +1,451 @@
|
||||
# TMS34010 runtime-abort triage (M12)
|
||||
|
||||
Date: 2026-11-19. Milestone: M12 (Task 5). Status: **evidence only — no
|
||||
curated row was flipped and `full-suite.skip` was not modified.**
|
||||
|
||||
The M12 plan turns the largest remaining skip bucket into a costed list for
|
||||
M13. This document is that list. Every row below was discovered from the
|
||||
curated table, re-run uncurated at `-O0` and `-O2`, and assigned a cause with
|
||||
runtime and source evidence. The harness is
|
||||
`scripts/tests/m12/abort-triage.sh`.
|
||||
|
||||
## 1. Method
|
||||
|
||||
Discovery is mechanical, not a hardcoded list:
|
||||
|
||||
1. Read `scripts/tests/m7/full-suite.skip` and select every row whose reason
|
||||
starts with `runtime-abort` plus every wrong-result row (reason contains
|
||||
`wrong` and `result`).
|
||||
2. Re-run each selected row through the standard M5 runner with the M7
|
||||
driver's settings: `--classify --mode native --expect-status 0`, bare
|
||||
tier, `LOADER_AT=200`, `LOADER_END=1000` (per-test overrides honored), the
|
||||
driver's `-std`/`-fgnu89-inline`/`-fwrapv` dialect rules, and a 120 s MAME
|
||||
timeout.
|
||||
3. Run at `-O0` and `-O2`, serially, and capture the runner result, the status
|
||||
word, the completion magic, and the last non-empty stdout marker.
|
||||
|
||||
The shipped bare checker does not expose the abort PC, and every discovered
|
||||
test is silent (`stdout_len=0`). There is therefore no output marker to
|
||||
compare; the table's marker column is **status-derived**: `0x86` is `abort()`
|
||||
(the shim writes 134), and the two wrong-result rows return their wrong value
|
||||
as the status. Where a group needed a sharper cause, a small probe was run
|
||||
through the same runner; the probe sources, their run logs and the cause map
|
||||
are committed under `scripts/tests/m12/probes/` (see its `README.md`).
|
||||
|
||||
Command and cost:
|
||||
|
||||
```
|
||||
scripts/tests/m12/abort-triage.sh --work build/m12-abort-triage
|
||||
```
|
||||
|
||||
108 serial MAME runs (54 rows × 2 opt levels) in **133 s**. All 108 runs
|
||||
completed with magic `CONF` (`0x434F4E46`); there were no timeouts, no missing
|
||||
completions, and no crash/unclassified runner rows in the baseline.
|
||||
|
||||
## 2. Discovered set
|
||||
|
||||
**54 rows**, all `c-torture`. The plan estimated 49–51 and the spec's §7.6
|
||||
says 58; those numbers are stale. The 54-row table below is the Task 5
|
||||
snapshot; Task 6 then removed the one flipped row (`eeprof-1`), so a re-run
|
||||
of the harness now discovers 53. `m11` had 53 rows matching this rule; M12
|
||||
re-reasoned `stkalign` from `inline-asm` to `runtime-abort-alignment`, adding
|
||||
the 54th. The breakdown is 52 aborts plus 2 wrong results (`bitfld-6`,
|
||||
`bitfld-7`).
|
||||
|
||||
| curated class | rows |
|
||||
|---|---:|
|
||||
| `runtime-abort` | 14 |
|
||||
| `runtime-abort-alignment` | 3 |
|
||||
| `runtime-abort-bitfield` | 9 |
|
||||
| `runtime-abort-float` | 5 |
|
||||
| `runtime-abort-i64` | 10 |
|
||||
| `runtime-abort-varargs` | 6 |
|
||||
| `runtime-abort-vector` | 5 |
|
||||
| `runtime-bitfield` | 2 |
|
||||
|
||||
Seven rows pass at `-O2` and fail at `-O0`: `20031003-1`, `20050607-1`,
|
||||
`pr123625`, `pr65427`, `pr79737-2`, `pr94412`, `scal-to-vec3`. No row passes
|
||||
at `-O0`; no row fails only at `-O2`. The suite gate is `-O0`, so the `-O2`
|
||||
passes do not flip any row, but they are a useful hint that generic
|
||||
optimization folds away some of the `-O0` lowering bugs.
|
||||
|
||||
## 3. Per-file results
|
||||
|
||||
Status words are the runner's 8-digit hex; magic is `CONF` for every row.
|
||||
The status column is the `-O0` status; the seven rows that pass at `-O2`
|
||||
return `0x0` there (the raw table in `build/m12-abort-triage/abort-triage.md`
|
||||
shows both opt levels explicitly). Evidence pointers are relative to
|
||||
`build/m12-abort-triage/`:
|
||||
`O0/O2: NAME` means `logs/-O0/c-torture/NAME.log` and
|
||||
`logs/-O2/c-torture/NAME.log` (the `.rc` files sit beside them, and the
|
||||
per-opt `result.txt` is under `run-O0/` or `run-O2/`). Costs are group costs
|
||||
from §4 (`S` small, `M` medium, `L` large, `out` permanently out of scope).
|
||||
A `probes/NAME` citation in §4–§5 means `scripts/tests/m12/probes/NAME`, where
|
||||
the sources and their historical logs are committed.
|
||||
|
||||
| corpus/name | curated class | -O0 | -O2 | status | magic | status-derived marker | cause | cost | evidence |
|
||||
|---|---|---|---|---|---|---|---|---|---|
|
||||
| c-torture/20010904-1 | runtime-abort-alignment | fail:status | fail:status | 00000086 | CONF | abort (0x86) | align-packed-abi | L | O0/O2: 20010904-1 |
|
||||
| c-torture/20010904-2 | runtime-abort-alignment | fail:status | fail:status | 00000086 | CONF | abort (0x86) | align-packed-abi | L | O0/O2: 20010904-2 |
|
||||
| c-torture/20021127-1 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | freestanding-builtin | out | O0/O2: 20021127-1 |
|
||||
| c-torture/20031003-1 | runtime-abort-float | fail:status | pass | 00000086 | CONF | abort (0x86) | float-conv | M | O0/O2: 20031003-1 |
|
||||
| c-torture/20050604-1 | runtime-abort-float | fail:status | fail:status | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: 20050604-1 |
|
||||
| c-torture/20050607-1 | runtime-abort-i64 | fail:status | pass | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: 20050607-1 |
|
||||
| c-torture/20060420-1 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: 20060420-1 |
|
||||
| c-torture/20080502-1 | runtime-abort-float | fail:status | fail:status | 00000086 | CONF | abort (0x86) | signed-zero | M | O0/O2: 20080502-1 |
|
||||
| c-torture/20230630-1 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | endian-macro+sso | M | O0/O2: 20230630-1 |
|
||||
| c-torture/20230630-3 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | endian-macro+sso | M | O0/O2: 20230630-3 |
|
||||
| c-torture/920428-1 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | ptr-int-model | out | O0/O2: 920428-1 |
|
||||
| c-torture/920625-1 | runtime-abort-varargs | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 920625-1 |
|
||||
| c-torture/931004-10 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 931004-10 |
|
||||
| c-torture/931004-12 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 931004-12 |
|
||||
| c-torture/931004-14 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 931004-14 |
|
||||
| c-torture/931004-2 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 931004-2 |
|
||||
| c-torture/931004-4 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 931004-4 |
|
||||
| c-torture/931004-6 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 931004-6 |
|
||||
| c-torture/931004-8 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: 931004-8 |
|
||||
| c-torture/991112-1 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | rts-shim | S | O0/O2: 991112-1 |
|
||||
| c-torture/bitfld-3 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | bitfield-64 | M | O0/O2: bitfld-3 |
|
||||
| c-torture/bitfld-5 | runtime-abort-bitfield | fail:status | fail:status | 00000086 | CONF | abort (0x86) | bitfield-64 | M | O0/O2: bitfld-5 |
|
||||
| c-torture/bitfld-6 | runtime-bitfield | fail:status | fail:status | 00033333 | CONF | wrong result (0x33333) | endian-macro+sso | M | O0/O2: bitfld-6 |
|
||||
| c-torture/bitfld-7 | runtime-bitfield | fail:status | fail:status | 00222222 | CONF | wrong result (0x222222) | endian-macro+sso | M | O0/O2: bitfld-7 |
|
||||
| c-torture/eeprof-1 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | instr-flag | S | O0/O2: eeprof-1 |
|
||||
| c-torture/floatunsisf-1 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | float-conv | M | O0/O2: floatunsisf-1 |
|
||||
| c-torture/pr103255 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | ptr-int-model | out | O0/O2: pr103255 |
|
||||
| c-torture/pr123625 | runtime-abort | fail:status | pass | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: pr123625 |
|
||||
| c-torture/pr32244-1 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | bitfield-64 | M | O0/O2: pr32244-1 |
|
||||
| c-torture/pr34971 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | bitfield-64 | M | O0/O2: pr34971 |
|
||||
| c-torture/pr35456 | runtime-abort-float | fail:status | fail:status | 00000086 | CONF | abort (0x86) | signed-zero | M | O0/O2: pr35456 |
|
||||
| c-torture/pr38051 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | ptr-int-model | out | O0/O2: pr38051 |
|
||||
| c-torture/pr38151 | runtime-abort-varargs | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: pr38151 |
|
||||
| c-torture/pr44575 | runtime-abort-varargs | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: pr44575 |
|
||||
| c-torture/pr44683 | runtime-abort-float | fail:status | fail:status | 00000086 | CONF | abort (0x86) | signed-zero | M | O0/O2: pr44683 |
|
||||
| c-torture/pr57344-3 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | bitfield-64 | M | O0/O2: pr57344-3 |
|
||||
| c-torture/pr57344-4 | runtime-abort-i64 | fail:status | fail:status | 00000086 | CONF | abort (0x86) | bitfield-64 | M | O0/O2: pr57344-4 |
|
||||
| c-torture/pr58209 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | ptr-int-model | out | O0/O2: pr58209 |
|
||||
| c-torture/pr65401 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | endian-macro+sso | M | O0/O2: pr65401 |
|
||||
| c-torture/pr65427 | runtime-abort | fail:status | pass | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: pr65427 |
|
||||
| c-torture/pr79327 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | rts-shim | S | O0/O2: pr79327 |
|
||||
| c-torture/pr79737-2 | runtime-abort | fail:status | pass | 00000086 | CONF | abort (0x86) | bitfield-64 | M | O0/O2: pr79737-2 |
|
||||
| c-torture/pr85169 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: pr85169 |
|
||||
| c-torture/pr94412 | runtime-abort | fail:status | pass | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: pr94412 |
|
||||
| c-torture/scal-to-vec1 | runtime-abort-vector | fail:status | fail:status | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: scal-to-vec1 |
|
||||
| c-torture/scal-to-vec2 | runtime-abort-vector | fail:status | fail:status | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: scal-to-vec2 |
|
||||
| c-torture/scal-to-vec3 | runtime-abort-vector | fail:status | pass | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: scal-to-vec3 |
|
||||
| c-torture/simd-1 | runtime-abort-vector | fail:status | fail:status | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: simd-1 |
|
||||
| c-torture/simd-2 | runtime-abort-vector | fail:status | fail:status | 00000086 | CONF | abort (0x86) | vector-ops | L | O0/O2: simd-2 |
|
||||
| c-torture/stdarg-3 | runtime-abort-varargs | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: stdarg-3 |
|
||||
| c-torture/stkalign | runtime-abort-alignment | fail:status | fail:status | 00000086 | CONF | abort (0x86) | align-packed-abi | L | O0/O2: stkalign |
|
||||
| c-torture/strct-stdarg-1 | runtime-abort-varargs | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: strct-stdarg-1 |
|
||||
| c-torture/strct-varg-1 | runtime-abort-varargs | fail:status | fail:status | 00000086 | CONF | abort (0x86) | aggregate-varargs | L | O0/O2: strct-varg-1 |
|
||||
| c-torture/zerolen-2 | runtime-abort | fail:status | fail:status | 00000086 | CONF | abort (0x86) | align-packed-abi | L | O0/O2: zerolen-2 |
|
||||
|
||||
## 4. Causes, grouped
|
||||
|
||||
| cause | rows | cost | one-flag/one-condition? |
|
||||
|---|---:|---|---|
|
||||
| aggregate varargs | 13 | L | no |
|
||||
| vector arithmetic | 12 | L | no |
|
||||
| 64-bit / packed bitfields | 7 | M | no |
|
||||
| endianness macro + SSO | 5 | M | no (see §5) |
|
||||
| packed/over-alignment ABI | 4 | L | no |
|
||||
| pointer↔int model | 4 | out | no — not a compiler gap |
|
||||
| signed zero / signbit | 3 | M | no |
|
||||
| float↔int conversion | 2 | M | no |
|
||||
| RTS / shim runtime | 2 | S–out | no |
|
||||
| function-instrumentation flag | 1 | S | **yes** |
|
||||
| freestanding builtins | 1 | out | no |
|
||||
|
||||
### 4.1 Aggregate varargs — 13 rows, L
|
||||
|
||||
`920625-1`, `931004-2/4/6/8/10/12/14`, `pr38151`, `pr44575`, `stdarg-3`,
|
||||
`strct-stdarg-1`, `strct-varg-1`.
|
||||
|
||||
Every row takes an aggregate through `va_arg` (`struct tiny`, `point`,
|
||||
`struct S`, `struct S1/S2`, or `__builtin_va_arg`). Seven are curated as
|
||||
`runtime-abort-bitfield` but contain **no bitfields**; they are the same
|
||||
`931004` aggregate-vararg family with different struct sizes. A representative
|
||||
probe (`probes/va931004probe.c`) returns status 1: the very first
|
||||
`va_arg(ap, struct tiny)` is wrong (`x.c != 10`); the trailing `long` is never
|
||||
reached. Status is `0x86` at both opt levels.
|
||||
|
||||
This is the aggregate/variadic-argument ABI shape that M13 already owns, and
|
||||
the largest single bucket. Cost L: one varargs/aggregate-call path, but it has
|
||||
to be consistent between the caller, callee, and `va_arg` layout.
|
||||
|
||||
### 4.2 Vector arithmetic — 12 rows, L
|
||||
|
||||
`scal-to-vec1/2/3`, `simd-1/2`, `20050604-1`, `20050607-1`, `20060420-1`,
|
||||
`pr123625`, `pr65427`, `pr85169`, `pr94412`.
|
||||
|
||||
The simplest operation is already wrong: a probe derived from `simd-1`
|
||||
(`probes/simd1probe.c`) returns status `0x0A`, the line of the first
|
||||
`k = i + j` check — vector **add** fails at `-O0`. Five rows pass at `-O2`
|
||||
(`20050607-1`, `pr123625`, `pr65427`, `pr94412`, `scal-to-vec3`), so the gap
|
||||
is in the `-O0` vector lowering/scalarization, not in vector loads/stores or
|
||||
`.data` (which already pass). The remaining rows mix integer, float, `i64`,
|
||||
and over-sized vector shapes and fail at both levels. Cost L: a vector
|
||||
lowering family, not a single combine.
|
||||
|
||||
### 4.3 64-bit / packed bitfields — 7 rows, M
|
||||
|
||||
`bitfld-3`, `bitfld-5`, `pr32244-1`, `pr34971`, `pr57344-3`, `pr57344-4`,
|
||||
`pr79737-2`.
|
||||
|
||||
These are fields wider than a word (33/40/41, 40, 40), packed 64-bit fields
|
||||
(43/59), and a packed 18/24/15/14/1 layout. `pr79737-2` passes at `-O2`; the
|
||||
others fail at both levels with `0x86`. This is extraction/insertion and
|
||||
arithmetic on >32-bit (and packed) bitfields, distinct from the endianness
|
||||
group. Cost M: a bounded set of wide-bitfield lowering cases, but each needs
|
||||
an oracle check.
|
||||
|
||||
### 4.4 Endianness macro + `scalar_storage_order` — 5 rows, M
|
||||
|
||||
`20230630-1`, `20230630-3`, `bitfld-6`, `bitfld-7`, `pr65401`.
|
||||
|
||||
All five branch on `__BYTE_ORDER__`. The target's `TargetInfo` defines
|
||||
`__BIG_ENDIAN__` (`__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__`) because the
|
||||
unknown triple makes `TargetInfo::BigEndian` true, while the DataLayout is
|
||||
`e` (little-endian) and the emitted bitfield loads/stores are little-endian.
|
||||
`bitfld-6`/`bitfld-7` return wrong results (`0x33333`, `0x222222`): the
|
||||
source takes the big-endian branch, but the IR extracts the **low** 20/24 bits
|
||||
(`and 0xFFFFF` / `and 0xFFFFFF`), which is the little-endian extraction.
|
||||
|
||||
The evidence for the macro half is a frontend-only override
|
||||
(`probes/` runs with `-U__BIG_ENDIAN__ -D__BYTE_ORDER__=1234`):
|
||||
|
||||
- `bitfld-6`, `bitfld-7`, `20230630-3`, `pr65401` pass at both `-O0` and
|
||||
`-O2` with the override.
|
||||
- `20230630-1` passes at `-O2` and through the full-loader tier at `-O0`,
|
||||
but the bare tier **host-segfaults** at `-O0`; that is the same class of
|
||||
bare-MAME instability already listed in `full-suite.full-loader`.
|
||||
- The same override **regresses two currently passing rows**:
|
||||
`20230630-2` (full-loader) and `20230630-4` (native) fail because they
|
||||
select `scalar_storage_order("big-endian")` once the macro flips, and this
|
||||
target does not honor the reversed storage order. They only pass today
|
||||
because the macro is wrong in the matching direction.
|
||||
|
||||
So this is not a clean one-flag/one-condition fix: the macro and
|
||||
`scalar_storage_order` must be corrected together. That is why the apparent
|
||||
`BigEndian = false` single change is rejected in §5. Cost M, with a regression
|
||||
guard on the two `20230630-*` passers.
|
||||
|
||||
### 4.5 Packed / over-alignment ABI — 4 rows, L
|
||||
|
||||
`20010904-1`, `20010904-2`, `stkalign`, `zerolen-2`.
|
||||
|
||||
Probes:
|
||||
|
||||
- `probes/astkalign.c` returns `1` for `__alignof__(struct { char c
|
||||
__attribute__((aligned(64))); })`: the requested 64-byte member alignment
|
||||
is clamped.
|
||||
- `probes/azerolen.c` returns `2`: `sizeof(word) == sizeof(struct foo)` but
|
||||
`__alignof__(word) != __alignof(struct foo)`.
|
||||
- `20010904-*`: the linked `.bss` gives `Y` a stride of 1028 bytes (two `Y`
|
||||
objects are 2056 bytes), not the 32-byte-aligned 1056; the test's
|
||||
`(char *)&y[1] - (char *)&y[0]` is therefore `4 mod 32`, and the check is
|
||||
legitimately true. The `if (expr & 31)` form folds to `true` while the
|
||||
`return expr & 31` form folds to `0`; that fold disagreement is a second
|
||||
symptom of the same layout confusion.
|
||||
|
||||
The root is the target's packed-struct policy (`Opts.PackStruct = 1`,
|
||||
`UseBitFieldTypeAlignment = false`) not honoring over-alignment on members
|
||||
and structs. Cost L: an ABI-level layout change, and it needs a decision about
|
||||
what the 1987-compatible packed rule should do with `aligned(N)`.
|
||||
|
||||
### 4.6 Pointer↔integer model — 4 rows, out
|
||||
|
||||
`920428-1`, `pr103255`, `pr38051`, `pr58209`.
|
||||
|
||||
These test `(int)/(long)/(size_t)ptr` arithmetic as if a pointer value were a
|
||||
byte address. On this ABI it is a **bit** address: a probe
|
||||
(`probes/ptrdiff.c`) returns status `8` for
|
||||
`(int)&a[1] - (int)&a[0]` with `char a[2]`. The tests then add byte counts to
|
||||
integer-cast pointers (`ss + 1`, `srcp1 += 1`, `s + sizeof(T)`) or compare a
|
||||
pointer cast to a byte address, so they are invalid for the target model, not
|
||||
miscompiled. `pr103255` additionally compares `(size_t)&h->b` with
|
||||
`ADDR + OFF + offsetof` as a byte address. Curate these with the bit-pointer
|
||||
reason; no M13 code change.
|
||||
|
||||
### 4.7 Signed zero / signbit — 3 rows, M
|
||||
|
||||
`20080502-1`, `pr35456`, `pr44683`.
|
||||
|
||||
Probes: `pr35456` returns `1` (`not_fabs(-0.0)` loses the sign), `pr44683`
|
||||
returns `3` (`__builtin_copysign(1.0, -0.0) < 0.0` is false), and `20080502-1`
|
||||
returns `1` (`long double` signbit / literal comparison). The first two are
|
||||
`-0.0` sign preservation and `copysign`; `20080502-1` may be the long-double
|
||||
representation. Cost M: a small set of float semantics, but each needs its own
|
||||
oracle.
|
||||
|
||||
### 4.8 Float↔int conversion — 2 rows, M
|
||||
|
||||
`20031003-1`, `floatunsisf-1`.
|
||||
|
||||
Probes: `20031003-1` returns `3` — **both** `(int)2147483648.0f` and
|
||||
`(int)(float)2147483647` differ from `INT_MAX`; `floatunsisf-1` returns `1`
|
||||
(`(float)volatile 0x80000081` differs from the literal conversion). The former
|
||||
is C UB (out-of-range conversion) that GCC nevertheless tests; the latter is
|
||||
a real unsigned→float rounding case. `20031003-1` passes at `-O2`. Cost M.
|
||||
|
||||
### 4.9 RTS / shim runtime — 2 rows, S–out
|
||||
|
||||
- `991112-1`: the test calls `isprint`. The 1990 `rts.lib` `_isprint` reads
|
||||
`__ctypes_` at `01A080A0`, which is zero in the bare tier; a probe returns
|
||||
status 2 (`isprint('a')` is false). This is a bare-tier runtime setup gap,
|
||||
not compiler codegen.
|
||||
- `pr79327`: a probe for `%#hhx` of 0 returns `3` (`"0x0"`); `sdk/shim.c`
|
||||
documents this as a **known pre-existing M5 deviation** (C says `"0"`,
|
||||
one byte) kept byte-identical. It is not a compiler gap; changing it would
|
||||
move the documented shim output and gates.
|
||||
|
||||
### 4.10 Function-instrumentation flag — 1 row, S
|
||||
|
||||
`eeprof-1` carries `dg-options -finstrument-functions`, but
|
||||
`full-suite.sh`'s `dialect_flags()` forwards only `-std`,
|
||||
`-fgnu89-inline`, and `-fwrapv`. Without the flag no
|
||||
`__cyg_profile_func_enter/exit` calls are emitted, so the test's counters stay
|
||||
zero and it aborts. Running the unmodified test with the flag passes at both
|
||||
`-O0` and `-O2`. This is a driver omission, not a compiler bug; it is the one
|
||||
one-flag/one-condition candidate in §5. Task 6 took it: `dialect_flags()` now
|
||||
forwards the flag per row, the row was removed from `full-suite.skip`, and the
|
||||
gate suite passes it (see §9).
|
||||
|
||||
### 4.11 Freestanding builtins — 1 row, out
|
||||
|
||||
`20021127-1` calls `llabs(-1)` after defining `llabs` to `abort()`. The TMS
|
||||
driver forces `-ffreestanding -fno-builtin`, so Clang does not recognize
|
||||
`llabs` as a library builtin and calls the aborting definition. Host Clang
|
||||
folds the same file to `llvm.abs.i64`. This is the target's freestanding
|
||||
policy, not a TMS codegen gap; curate it as such (or revisit hosted mode
|
||||
outside M13).
|
||||
|
||||
## 5. One-flag/one-condition ruling
|
||||
|
||||
At most three one-flag/one-condition fixes may be proposed for M12. The triage
|
||||
supports **one**; the strongest-looking single-change compiler candidate is
|
||||
explicitly rejected.
|
||||
|
||||
### Accepted candidate (harness, not compiler): forward `-finstrument-functions`
|
||||
|
||||
Add the flag to `dialect_flags()` in `scripts/tests/m7/full-suite.sh` when the
|
||||
source's `dg-options` asks for it. Why it qualifies:
|
||||
|
||||
- Single shared cause: the driver drops one dg-option; the test compiles and
|
||||
passes unchanged when it is forwarded (verified at `-O0` and `-O2`).
|
||||
- One flag/one condition, one row affected (`eeprof-1`), no other abort row
|
||||
requests the flag, and no compiler or ABI change.
|
||||
- It is a harness fix, so it was taken as its own Task 6 commit: the
|
||||
`eeprof-1` curated row is removed with the recorded flip. This Task 5
|
||||
document did not edit the skip file.
|
||||
|
||||
### Rejected: `BigEndian = false` in `TMS34010TargetInfo`
|
||||
|
||||
This looked like the textbook one-flag/one-condition candidate: it would make
|
||||
`__BYTE_ORDER__` agree with the little-endian DataLayout and flips `bitfld-6`, `bitfld-7`,
|
||||
`20230630-3`, and `pr65401` at both levels (and `20230630-1` through the full
|
||||
loader). But the same change flips `20230630-2` and `20230630-4` from pass to
|
||||
`0x86`, because they then select `scalar_storage_order("big-endian")`, which
|
||||
the target does not honor. A single-change fix that regresses two passing rows
|
||||
is not a clean single-cause fix. The endianness macro and
|
||||
`scalar_storage_order` belong together in M13.
|
||||
|
||||
### Rejected: shim `%#x`/`%#X` zero prefix
|
||||
|
||||
`pr79327` would flip if `emit_uint()` stopped printing `0x` for zero, but the
|
||||
deviation is explicitly documented in `sdk/shim.c` as a pre-existing M5
|
||||
byte-identical behavior. Changing it would move shim output and gate bytes;
|
||||
not a safe M12 one-flag fix.
|
||||
|
||||
No other group qualifies: varargs, vectors, wide bitfields, alignment,
|
||||
signed zero, and conversions are multi-line lowering/ABI work; pointer↔int
|
||||
and freestanding builtins are target-model/policy, not defects to fix.
|
||||
|
||||
## 6. Proposed M13 scope
|
||||
|
||||
Ordered by files affected, with cost and dependencies. The counts cover 54
|
||||
rows; 25 of them (varargs + vectors) are the first two items.
|
||||
|
||||
| order | cause | rows | cost | note |
|
||||
|---:|---|---:|---|---|
|
||||
| 1 | aggregate varargs | 13 | L | overlaps M13's ABI-shape work; one caller/callee/`va_arg` contract |
|
||||
| 2 | vector arithmetic | 12 | L | `-O0` lowering/scalarization; 5 rows already pass at `-O2` |
|
||||
| 3 | 64-bit / packed bitfields | 7 | M | wide and packed extraction/insertion; oracle-backed |
|
||||
| 4 | endianness macro + SSO | 5 | M | fix `__BYTE_ORDER__`/`BigEndian` **and** reversed storage order; guard the two `20230630-*` passers |
|
||||
| 5 | packed/over-alignment ABI | 4 | L | `aligned(N)` under the packed default; ABI decision first |
|
||||
| 6 | signed zero / signbit | 3 | M | `-0.0`, `copysign`, long double |
|
||||
| 7 | float↔int conversion | 2 | M | `20031003-1` is UB; decide whether to chase GCC's answer |
|
||||
| — | pointer↔int model | 4 | out | re-curate with the bit-pointer reason; no code |
|
||||
| — | RTS / shim runtime | 2 | out | bare-tier `__ctypes_` / documented `%#x` deviation |
|
||||
| — | freestanding builtins | 1 | out | `-ffreestanding -fno-builtin` is deliberate |
|
||||
| M12 (done) | instrumentation flag | 1 | S | the accepted one-flag/one-condition harness fix; `eeprof-1` flipped in Task 6 |
|
||||
|
||||
Suggested M13 execution order: **varargs → vectors → wide bitfields →
|
||||
endianness+SSO → alignment**. Take the two float groups after the structural
|
||||
work, and keep the four pointer↔int rows and the two runtime rows curated
|
||||
with accurate reasons rather than spending M13 on them.
|
||||
|
||||
## 7. Curated label vs actual cause
|
||||
|
||||
The curated labels are not a cause taxonomy. This is the most important input
|
||||
for M13 planning:
|
||||
|
||||
| curated class | rows | actual causes |
|
||||
|---|---:|---|
|
||||
| `runtime-abort` | 14 | 4 vector, 3 endianness, 2 pointer↔int, 2 RTS/shim, 1 alignment, 1 wide bitfield, 1 instrumentation |
|
||||
| `runtime-abort-alignment` | 3 | 3 packed/over-alignment |
|
||||
| `runtime-abort-bitfield` | 9 | **7 aggregate varargs**, 2 wide bitfields |
|
||||
| `runtime-abort-float` | 5 | 3 signed zero, 1 conversion, 1 vector |
|
||||
| `runtime-abort-i64` | 10 | 4 wide bitfields, 2 vector, 2 pointer↔int, 1 conversion, 1 freestanding builtin |
|
||||
| `runtime-abort-varargs` | 6 | 6 aggregate varargs |
|
||||
| `runtime-abort-vector` | 5 | 5 vector |
|
||||
| `runtime-bitfield` | 2 | 2 endianness |
|
||||
|
||||
In particular, the `i64` label contains **no** plain 64-bit-codegen row: its one
|
||||
conversion row (`floatunsisf-1`) is float↔int, and the rest are wide
|
||||
bitfields, vectors, or pointer↔int. The `931004-*` rows are the clearest
|
||||
mislabel: seven vararg tests curated as bitfields.
|
||||
|
||||
## 8. Limits and concerns
|
||||
|
||||
- **No abort PC.** The bare checker writes only the result block; it has no
|
||||
PC hook, and every discovered test is silent. The status word plus the
|
||||
source predicate is the evidence, and representative probes localize the
|
||||
group causes. A future harness could tap the `abort` symbol/return address
|
||||
in MAME, but that is a runner change, not this triage.
|
||||
- **Probes are representative, not exhaustive.** The 13 varargs rows share the
|
||||
same `va_arg` shape; one probe proves the first aggregate is wrong. The 12
|
||||
vector rows share lowering; one probe proves vector add is wrong. Individual
|
||||
rows may have additional causes (e.g. `pr123625` also has `i64` and `switch`
|
||||
structure), which M13 will find when it touches each family.
|
||||
- **`-O2` passes are not correctness evidence.** They show generic
|
||||
optimization can fold the failing shape; the suite gate is `-O0`.
|
||||
- **`20031003-1` is C UB** (out-of-range float→int). It is listed as a
|
||||
conversion difference, not a promise to match GCC's saturated answer.
|
||||
- **`20230630-1` has a bare-tier host segfault** once its check passes. Any
|
||||
endianness fix must either add it to `full-suite.full-loader` (it passes
|
||||
there) or resolve the MAME instability first.
|
||||
- **The endianness one-flag change is a trap.** The regression on `20230630-2/-4`
|
||||
is the reason it is not proposed; record it before M13 starts.
|
||||
|
||||
## 9. Raw evidence
|
||||
|
||||
- Harness: `scripts/tests/m12/abort-triage.sh`
|
||||
- Raw Markdown table: `build/m12-abort-triage/abort-triage.md`
|
||||
- Machine-readable tables: `build/m12-abort-triage/abort-triage.tsv`,
|
||||
`build/m12-abort-triage/abort-triage.evidence.tsv`
|
||||
- Per-test logs and results: `build/m12-abort-triage/logs/` and
|
||||
`build/m12-abort-triage/run-O0/` / `run-O2/`
|
||||
- Representative probe sources: `scripts/tests/m12/probes/` (with its
|
||||
`README.md`, `cause-map.tsv` and historical `logs/`); the same files were
|
||||
originally written under `build/m12-abort-triage/probes/`
|
||||
|
||||
## 10. Task 6 outcome
|
||||
|
||||
`eeprof-1` is the only row this triage fixes in M12. Task 6 added
|
||||
`-finstrument-functions` forwarding to `dialect_flags()` (per row, when
|
||||
`dg-options` asks for it), verified the unmodified test at `-O0` and `-O2`
|
||||
through the M5 runner, and removed the curated row. The other 53 rows stay
|
||||
curated with the causes above and are M13's input. The suite accounting moves
|
||||
by this one row (1,618 → 1,635 pass, 294 → 277 skip across all M12 flips; see
|
||||
the README's M12 section for the per-row list).
|
||||
@@ -745,7 +745,8 @@ idempotency is
|
||||
`scripts/tests/m10/bitaddr-idempotent.sh`. TMS34010 lit is **132/132** (128
|
||||
CodeGen + 4 MC) and clang is **10** (8 CodeGen + the driver
|
||||
`tms34010-defaults.c` + the Sema subbyte-stride test), for **142** lit in
|
||||
total; the serial M0–M8 gate list is **56/56 PASS** with `HARDWARE: DEFERRED`.
|
||||
total; the serial M0–M8 gate list is **58 invocations across 54 distinct gate
|
||||
scripts, all passing**, with `HARDWARE: DEFERRED`.
|
||||
The fresh two-tier full
|
||||
suite is unchanged at **1,912 = 1,618 pass / 294 skip / 0 fail / 0 crash**, the
|
||||
four-phase i64 gate is unchanged at fast **88** / slow **3,302** / wide **221** /
|
||||
@@ -789,6 +790,159 @@ these, `m6/float.sh` (8 float markers), `m6/aggregate.sh` (2 markers),
|
||||
**M10/M11 boundary** is Phase 3: a committed CRT
|
||||
(`crt0.o` via `llvm-mc`), headers, `libtms.a`, a sysroot and a `tms-link` link
|
||||
job, so `clang --target=tms34010 hello.c -o hello` works with no wrapper.
|
||||
(The M11 design corrected the CRT build path: `llc -filetype=obj`, not
|
||||
`llvm-mc` — see the M11 section below.)
|
||||
|
||||
### M11 — the conventional toolchain (Phase 3)
|
||||
|
||||
M11 closes the gap between "a compiler that emits objects" and "a toolchain you
|
||||
can use": `clang --target=tms34010 hello.c -o hello` links a loader-valid TI-COFF
|
||||
image through `tms-link`, with a CRT, headers and a C library discovered through
|
||||
a sysroot — after one `scripts/tms-sdk`. The binding design is
|
||||
`2026-11-18-tms34010-m11-conventional-toolchain-design.md` §8.
|
||||
|
||||
- **The sysroot.** `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` plus `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`; `--sysroot DIR` installs
|
||||
elsewhere (the driver then needs `--tms-sysroot=DIR`). Installing is
|
||||
idempotent: `llc` and `llvm-ar rcsD` rebuild byte-identically.
|
||||
- **The CRT.** `sdk/crt0.ll` is a `naked` `_start` with inline asm blocks, built
|
||||
by `llc -filetype=obj`: `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. The rewrite preserves the contract, not the
|
||||
text: `setf 16/32`, the 4 KiB `_cstack`, the `{"conformance", NULL}` argv, the
|
||||
result block at `01B00000`/`40`/`60`, the output buffers `01B10000`/`01B30000`,
|
||||
and the `_start` symbol for `--entry`.
|
||||
- **The link job.** `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`
|
||||
(not `-g0`/`-ggdb0`), `-Wl,` passthrough (with `-Map=`/`-Map,<file>`
|
||||
translated to `--map=<file>`), the CRT, the user objects, `libtms.a flib.lib
|
||||
rts.lib`, `-L <sysroot>/lib` and the user `-L`/`-l`. A missing
|
||||
sysroot/linker/`python3` is a named diagnostic pointing at `scripts/tms-sdk`
|
||||
(except `python3`, which names installing `python3`) — `python3` is a
|
||||
link-time dependency because `tms-link` is a Python program. A sysroot
|
||||
directory that exists but lacks `crt0.o`/`libtms.a`/`flib.lib`/`rts.lib`
|
||||
names the missing artifact instead of handing `tms-link` a bare name.
|
||||
- **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; new documentation points at
|
||||
`clang --target=tms34010`.
|
||||
|
||||
M11 acceptance: `scripts/tests/m11/{sdk,crt,e2e}.sh` PASS — the headline
|
||||
command from a clean shell, two TUs, `-c`/`-S`/`-E`, `-O0`/`-O2`, `-g` vs
|
||||
stripped, `-nostdlib`, and the no-checkout-path assertion. TMS34010 lit is
|
||||
**132/132** (128 CodeGen + 4 MC), clang **13** (10 CodeGen + 2 Driver + 1 Sema),
|
||||
`tools/tms-link`/`tools/tms-bitaddr` tests PASS, the two-tier suite is unchanged
|
||||
at **1,912 = 1,618 pass / 294 skip / 0 fail / 0 crash**, the four-phase i64
|
||||
gate is unchanged at fast **88** / slow **3,302** / wide **221** / div32 **120**
|
||||
frames (37.5× / 14.9× / 1.8×, checksums `000000011E6F9AB4` /
|
||||
`00000000007512AE` / `F56810CFEDA9D656` / `00002C61C63842EE`), and
|
||||
`HARDWARE: DEFERRED`. The linker emits images that pass
|
||||
`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). 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>`) — and a repeated `-l tms`
|
||||
under `-nodefaultlibs` duplicates the archive. The Task 6
|
||||
sweep's one stale M7 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.
|
||||
### M12 — tractable conformance gaps, and the abort triage
|
||||
|
||||
M12 takes the conformance classes with known backend/driver mechanics and
|
||||
turns the largest unknown bucket (runtime aborts) into a costed M13 list. The
|
||||
binding design is
|
||||
`2026-11-19-tms34010-m12-tractable-gaps-design.md`; the triage report is
|
||||
`../research/2026-11-19-tms34010-abort-triage.md`. Branch `m12` is the
|
||||
milestone branch on both repositories; promotion is pending the controller's
|
||||
review (`m11` remains the default until then).
|
||||
|
||||
- **The 17 flips, row by row.** The inline-asm memory rows `pr103376`,
|
||||
`pr40022`, `pr40657`, `pr56866`, `pr65053-2`, `pr68328`, `pr81588`,
|
||||
`pr82954`, `pr85156`, `pr94130` (10); the computed-goto rows `920501-3`,
|
||||
`990208-1` (2); the level-0 frame rows `20030811-1`, `frame-address`,
|
||||
`pr17377` (3); the dynamic-alloca row `20070824-1` (1); and `eeprof-1` (1),
|
||||
the one-flag/one-condition harness fix that forwards
|
||||
`-finstrument-functions` from the test's own `dg-options`. The eleventh
|
||||
inline-asm row, `stkalign`, now selects its memory operand but aborts on
|
||||
`__alignof__(s) == 64` under the packed-struct ABI; it was re-reasoned as
|
||||
`runtime-abort-alignment`, not flipped. Suite accounting is
|
||||
**1,912 = 1,635 pass / 277 skip / 0 fail / 0 crash** (1,618 + 17,
|
||||
294 − 17; c-torture 1,425/267, c-testsuite 210/10).
|
||||
- **Inline-asm memory operands; the `ST`/`o`/`V` decisions.**
|
||||
`SelectInlineAsmMemoryOperand` matches the reachable load/store addressing
|
||||
forms for `m` and `g`; an unmatchable operand is a named error. A selected
|
||||
memory operand must also print: `PrintAsmMemoryOperand` emits `*An` or
|
||||
`*An(disp)` with the folded bit displacement (`SP` for `A15`), pinned by a
|
||||
`-no-integrated-as` check; previously only empty templates worked. `o`
|
||||
accepts only the non-post-increment, non-negative-displacement form. `V` stays loud:
|
||||
`InlineAsm::ConstraintCode` has no `V` and `SelectionDAGBuilder` asserts
|
||||
before the target hook, so it needs a core enum change outside this charter.
|
||||
`"st"` joins `getGCCRegNames()` so `~{st}` is a nameable clobber, while `ST`
|
||||
remains outside every register class and every operand constraint (no
|
||||
allocation, no save/restore, value operands still rejected).
|
||||
- **`jump Rd` and computed goto.** The ISA's indirect jump (opcode `0x0160`,
|
||||
vendor ONEREG table) is implemented end to end (instruction definition, MC
|
||||
encoding `jump A0` = `[0x60, 0x01]`, parser, printer, disassembler);
|
||||
`ISD::BRIND` lowers to it, and `ISD::BlockAddress` lowers to a
|
||||
section-relative **bit** address through the normal `MOVI`/R-RELLONG path —
|
||||
no absolute load address.
|
||||
- **Level-0 frame intrinsics, with the capture mechanism.** The return word is
|
||||
on the system stack at `SP + NumSaved*32` measured from the post-FP/`MMTM`
|
||||
pointer. A use-site SP-relative load was reproduced sinking into the
|
||||
saved-STK push window at `-O1`/`-O2` (it read the saved `A13`); the shipped
|
||||
lowering captures the word once in the prologue — after the FP/callee-save
|
||||
pushes — into a normal `A13`-relative stack object with matching
|
||||
fixed-stack MMOs, and every `llvm.returnaddress(0)` use loads that stable
|
||||
slot. The two capture-scratch pushes move SP, so the 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`.
|
||||
`llvm.frameaddress(0)` is `A13`. Levels above 0 stay a named error naming
|
||||
the intrinsic and level.
|
||||
- **Dynamic alloca.** The byte→bit scale already existed; the failure was the
|
||||
M8 shape assertion firing when the DAG constant-folds the `SHL 3` for a
|
||||
non-entry-block constant-count alloca (`20070824-1`). Both the constant and
|
||||
variable shapes now scale explicitly and no node shape is asserted.
|
||||
- **Abort triage (M13 input).** `scripts/tests/m12/abort-triage.sh` discovers
|
||||
the abort rows from the curated table and re-runs each at `-O0` and `-O2`:
|
||||
**54 rows** (52 aborts + 2 wrong results), **108 runs in 133 s**, **11
|
||||
causes** — aggregate varargs 13, vectors 12, 64-bit/packed bitfields 7,
|
||||
endian macro + SSO 5, packed/over-alignment 4, pointer↔int 4, signed zero 3,
|
||||
float↔int 2, RTS/shim 2, instrumentation 1, freestanding builtins 1. The
|
||||
report (`docs/superpowers/research/2026-11-19-tms34010-abort-triage.md`)
|
||||
carries the per-file evidence and §6's M13 ordering: **varargs → vectors →
|
||||
wide bitfields → endianness+SSO → alignment**, then the float groups.
|
||||
`eeprof-1` is the only row fixed here. The endianness `BigEndian = false`
|
||||
single change is rejected: it regresses `20230630-2`/`-4` once they select
|
||||
`scalar_storage_order("big-endian")`.
|
||||
- **Permanently out of scope.** Nested functions (30 rows; clang frontend
|
||||
refusal), VLA-in-struct (9; `will never be supported`), dialect strictness
|
||||
(8; `-Wint-conversion`/`-Wparen`/K&R under the pinned language mode) and
|
||||
timeouts/region limits (37; loader budget or the 45 KiB/64 KiB image
|
||||
regions). The triage's pointer↔int (4), RTS/shim (2) and freestanding
|
||||
builtins (1) are target-model/runtime policy and stay curated as well.
|
||||
- **The M12/M13 boundary.** M13 is the ABI shapes (sret,
|
||||
aggregate/variadic/float arguments and returns) plus the triaged abort
|
||||
causes in the order above; M14 is performance and 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 gate is
|
||||
unchanged (88/3,302/221/120).
|
||||
|
||||
M12 acceptance: the full suite is **0 fail / 0 crash** with the accounting
|
||||
above; TMS34010 lit **142/142** (137 CodeGen + 5 MC), clang **15** (12 CodeGen +
|
||||
2 Driver + 1 Sema), the Generic sweep **197 = 152 pass / 45 unsupported**
|
||||
(`addr-label` flips with `blockaddress`), `tools/tms-link` and
|
||||
`tools/tms-bitaddr` PASS; the M11 gates, M10 equivalence (46/0) and the
|
||||
M0–M11 serial list PASS; `HARDWARE: DEFERRED`.
|
||||
|
||||
## 9. Risks and mitigations
|
||||
|
||||
|
||||
@@ -0,0 +1,306 @@
|
||||
# TMS34010 M11 (Phase 3) — Conventional Toolchain Design
|
||||
|
||||
Status: proposed. M10 is complete and `m10` is the default on both repositories
|
||||
(project `4809185`, compiler `7fc2ac37b5ad`). This document also carries the
|
||||
short roadmap for M12 and later.
|
||||
|
||||
Decision already taken by the human partner: M11 is Phase 3 of
|
||||
`docs/superpowers/specs/2026-11-17-tms34010-phase-2-3-design.md` §8 — a
|
||||
freestanding toolchain with conventional UX — and its artifacts are discovered
|
||||
through a resource-directory sysroot built and installed by a script
|
||||
(approach A below).
|
||||
|
||||
## 1. Intent and why
|
||||
|
||||
M10 made `clang --target=tms34010 -c` correct. M11 closes the remaining gap
|
||||
between "a compiler that emits objects" and "a toolchain you can use": a
|
||||
single command that produces a runnable image.
|
||||
|
||||
Today the pieces exist but only the project knows how to wire them:
|
||||
|
||||
- `scripts/tms-cc` compiles each TU through `scripts/tms-clang` and `llc`, then
|
||||
drives `scripts/m4/run.sh` with `M4_*` environment variables, which assembles
|
||||
`entry.asm` with the 1987 tools and links with `tools/tms-link`.
|
||||
- Headers live in `scripts/tests/m5/conformance/include`; the runtime is
|
||||
`shim.c` + `heap.c` compiled on every invocation; the SDK archives come from
|
||||
`build/m6-sdk`.
|
||||
- Nothing tells `clang` where a CRT, headers or a library are.
|
||||
|
||||
The goal is that a user with a built compiler and one setup command can run:
|
||||
|
||||
```sh
|
||||
clang --target=tms34010 hello.c -o hello
|
||||
tms-run hello
|
||||
```
|
||||
|
||||
and see `hello`, with no project variables, no wrapper script, and no DOSBox.
|
||||
|
||||
## 2. Goals
|
||||
|
||||
1. `clang --target=tms34010 hello.c -o hello` links to a loader-valid TI-COFF
|
||||
image through `tms-link`, with a CRT, headers and a C library found through
|
||||
a sysroot.
|
||||
2. The sysroot is produced from in-repo sources by one documented command and
|
||||
installed at a relocatable, conventional location.
|
||||
3. `-c`, `-S`, `-E`, `-O0`, `-O2`, `-g`, multiple TUs, `-I`, `-L`, `-l` and
|
||||
`-nostdlib` behave the way they do for any freestanding clang target, and
|
||||
`-###` shows the real compile and link jobs.
|
||||
4. The CRT is reproducible from source with `llc` — no DOSBox, no 2ine, no
|
||||
vendor assembler. (`llvm-mc` cannot be used: it emits ELF for this triple, and
|
||||
the generic COFF path refuses a non-Windows triple. The target's TI-COFF
|
||||
writer is reachable only through CodeGen, so the CRT is an IR file whose
|
||||
`_start` is `naked` with inline assembly.)
|
||||
5. `libtms.a` is built from `shim.c` + `heap.c` with `llvm-ar`; the committed
|
||||
vendor `flib.lib`/`rts.lib` supply the `%f` formatting path.
|
||||
6. `tms-link` emits a loader-valid image on its own, so the production path no
|
||||
longer needs `coff-check.py --repair`.
|
||||
7. Every M0–M10 gate, the lit suites and the 1,912-row conformance suite stay
|
||||
unchanged.
|
||||
|
||||
## 3. Non-goals
|
||||
|
||||
- **Hosted C library.** No file I/O, no console driver, no `libm`, no locale.
|
||||
`printf` keeps writing the conformance result block that `tms-run` reads.
|
||||
- **A new linker.** `tms-link` stays the linker; M11 only calls it correctly.
|
||||
- **lld.** TI-COFF is not an lld flavour.
|
||||
- **Changing the TI ABI, the all-stack convention, the pointer model, or the
|
||||
M10 pipeline.** M11 adds no codegen behaviour.
|
||||
- **Bare-metal debugger integration** beyond `-g` → `--keep-debug`.
|
||||
- **Removing `tms-cc`.** It stays as a compatibility alias.
|
||||
|
||||
## 4. Anti-goals
|
||||
|
||||
- A driver that shells out to project scripts or bakes a checkout path into
|
||||
`clang`. Both break the "conventional toolchain" property.
|
||||
- Committing built `crt0.o`/`libtms.a`. Sources are the truth; a drift gate is
|
||||
still cheaper than a checked-in binary.
|
||||
- Growing the driver patch into generic clang code. The fork's driver change
|
||||
stays inside `clang/lib/Driver/ToolChains/TMS34010.*` plus its two
|
||||
registration lines, exported as an extension of patch `0005`.
|
||||
- Making the conformance harness depend on the installed sysroot in a way that
|
||||
breaks its hermetic MAME runs.
|
||||
|
||||
## 5. Constraints
|
||||
|
||||
- LLVM/Clang stay pinned at 23.1.5; the fork's exported patches remain
|
||||
`patches/llvm/0001..0005`.
|
||||
- Branch `m11` from `m10`; promote only after a clean whole-branch review, per
|
||||
standing repository policy.
|
||||
- Every existing gate and the two-tier harness stay green; `HARDWARE` stays
|
||||
`DEFERRED` until a unit exists.
|
||||
- No force-push, no history rewrite.
|
||||
- `clang --target=tms34010 -c` (M10's contract) must not regress, including
|
||||
`-O0` byte identity with the M9 path.
|
||||
|
||||
## 6. Current state (verified on `m10`)
|
||||
|
||||
| Fact | Evidence |
|
||||
|---|---|
|
||||
| CodeGen emits TI-COFF; `llvm-mc` does not | `llc -march=tms34010 -filetype=obj` writes the target's COFF object; `llvm-mc -triple=tms34010 -filetype=obj` writes ELF (`7f 45 4c 46`), and `-triple=tms34010-unknown-none-coff` aborts with "cannot initialize MC for non-Windows COFF object files" |
|
||||
| A `naked` function keeps inline asm verbatim | `llc` on a `naked` `_start` with `setf`/`movi`/`move`/`rets` inline asm emits no prologue and no epilogue |
|
||||
| `tms-link` already has the driver's surface | `--entry --text --data --cinit --bss --prog-len --ram-len --map --keep-debug -L -l` |
|
||||
| A working `_start` exists | `scripts/tests/m5/conformance/entry.asm`: `setf` 16/32, 4 KiB `_cstack`, argv vector `{"conformance", NULL}`, result block at `01B00000`/`20`/`40`/`60`, output buffers `01B10000`/`01B30000`, `exit`/`abort` publish status themselves |
|
||||
| Headers exist but uninstalled | 10 headers in `scripts/tests/m5/conformance/include` (`assert, limits, math, stdarg, stdbool, stddef, stdint, stdio, stdlib, string`) |
|
||||
| Runtime sources exist | `scripts/tests/m5/conformance/{shim.c,heap.c}` |
|
||||
| SDK archives are extracted, not committed | `build/m6-sdk/{flib,rts}.lib`; the design commits them in M11 |
|
||||
| The link path needs a repair step today | `scripts/m4/run.sh` always runs `coff-check.py --repair --entry 018A0000` |
|
||||
| The driver file exists | `clang/lib/Driver/ToolChains/TMS34010.{h,cpp}` from M10, patched by `0005` |
|
||||
| No sysroot or link job exists | `clang -###` shows compile jobs only |
|
||||
|
||||
## 7. Approaches considered
|
||||
|
||||
**A. Resource-directory sysroot, built and installed by a script (chosen).**
|
||||
`sdk/` holds the sources; `scripts/tms-sdk` builds `crt0.o` and `libtms.a` and
|
||||
installs them, with the headers and the committed vendor archives, into
|
||||
`<resource-dir>/tms34010-unknown-none/{include,lib}`. The `ToolChain` searches
|
||||
there. Sources stay authoritative, the location is the conventional one for
|
||||
cross targets, and clang stays relocatable. Cost: one setup command after a
|
||||
compiler build.
|
||||
|
||||
**B. Repo-relative `sdk/` with committed prebuilt artifacts.** No setup step,
|
||||
but it bakes a checkout path into the driver, breaks when clang moves, and puts
|
||||
binaries in git that can drift. Rejected: it trades a real property
|
||||
(relocatable clang) for skipping one command.
|
||||
|
||||
**C. Explicit `--tms-sysroot` only.** Most predictable, worst UX, and it fails
|
||||
goal 1 (working from a shell with no flags). Rejected.
|
||||
|
||||
**Why A.** It is the only option that keeps both properties the milestone is
|
||||
for: a single conventional command, and a clang that can be moved or installed
|
||||
anywhere.
|
||||
|
||||
## 8. Design
|
||||
|
||||
### 8.1 Artifacts and layout
|
||||
|
||||
| Source | Built by | Installed to |
|
||||
|---|---|---|
|
||||
| `sdk/crt0.ll` (a `naked` `_start` with inline asm) | `llc -march=tms34010 -filetype=obj` | `<sysroot>/lib/crt0.o` |
|
||||
| `sdk/shim.c`, `sdk/heap.c` | `clang --target=tms34010 -c` + `llvm-ar` | `<sysroot>/lib/libtms.a` |
|
||||
| `sdk/include/*.h` (moved from the conformance harness) | — | `<sysroot>/include/` |
|
||||
| `sdk/lib/{flib,rts}.lib` (committed copies of the extracted 1987 archives) | — | `<sysroot>/lib/` |
|
||||
| `tools/tms-link/{tms-link,tmscoff.py}` | copied as a pair (the script imports its sibling) | `<sysroot>/bin/` |
|
||||
|
||||
The installed linker is a Python program: `python3` is a documented runtime
|
||||
dependency of the toolchain, and the driver reports its absence by name rather
|
||||
than as a bare link failure.
|
||||
|
||||
`<resource-dir>` is `clang -print-resource-dir` (for this fork,
|
||||
`build/llvm-clean-build/lib/clang/23`), so the sysroot defaults to
|
||||
`<resource-dir>/tms34010-unknown-none`.
|
||||
|
||||
`scripts/tms-sdk` performs all four steps, is idempotent, and accepts
|
||||
`--sysroot DIR` to install elsewhere (the driver then needs
|
||||
`--tms-sysroot=DIR`). The conformance harness points at `sdk/` for its headers
|
||||
so there is exactly one copy.
|
||||
|
||||
### 8.2 Driver discovery and the link job
|
||||
|
||||
`TMS34010ToolChain` gains:
|
||||
|
||||
- **Sysroot search order:** `--tms-sysroot=DIR`, then `--sysroot`/`-isysroot`,
|
||||
then `<resource-dir>/tms34010-unknown-none`. Headers come from
|
||||
`<sysroot>/include`; libraries from `<sysroot>/lib` plus `-L` paths.
|
||||
- **A link `Tool`** (`TMS34010Linker`) that invokes the installed
|
||||
`tms-link`. **Linker discovery:** `--tms-linker=PATH` first, otherwise
|
||||
`<sysroot>/bin/tms-link` — the same sysroot the headers and libraries come
|
||||
from, so one setup command covers everything and nothing is baked into the
|
||||
driver. A missing sysroot, a missing linker or a missing `python3` is a named
|
||||
diagnostic, never a bare link error; the first two point at `scripts/tms-sdk`
|
||||
and the `python3` one says to install `python3`.
|
||||
|
||||
Arguments: `-o <output>`, `--entry _start`, `--text 018A0000`,
|
||||
`--bss 01A00000`, `--prog-len 40000h`, `--ram-len 80000h`,
|
||||
`--map <output>.map` when `-Wl,-Map` is absent, the objects, then
|
||||
`libtms.a`, `flib.lib`, `rts.lib` (unless `-nostdlib`/`-nodefaultlibs`), then
|
||||
user `-L`/`-l`. `-Wl,` arguments pass through verbatim.
|
||||
- **`-g`** also passes `--keep-debug` to the link so the image keeps its DWARF;
|
||||
the default stays stripped.
|
||||
- **`-###`** shows both jobs, and `clang/test/Driver/TMS34010-link.c` pins the
|
||||
link command line and the include path.
|
||||
|
||||
Compile jobs are unchanged from M10.
|
||||
|
||||
### 8.3 CRT contract
|
||||
|
||||
`sdk/crt0.ll` expresses the CRT as LLVM IR: `_start` is a `naked` function whose
|
||||
body is a sequence of `call void asm sideeffect "…"` blocks (`setf`, `movi`,
|
||||
`move`, `calla _main`, the status/magic stores, `rets`), plus globals for
|
||||
`_conformance_name` (`"conformance\0"`), `_conformance_argv` and `_cstack`.
|
||||
`llc -filetype=obj` lowers it through CodeGen and the target's TI-COFF writer,
|
||||
which is the only path that emits this object format; `llvm-mc` is not usable
|
||||
(see the current-state table). `naked` is required so no prologue touches the
|
||||
stack before `_start` sets it.
|
||||
|
||||
What the rewrite must preserve is the **contract**, not the text:
|
||||
|
||||
- `setf 16,1,0` / `setf 32,0,1`, and a 4 KiB `_cstack` at 16-bit alignment;
|
||||
- the two-element argv vector `{"conformance", NULL}` so `main(int, char**)`
|
||||
keeps working (`main(void)` is unaffected);
|
||||
- the result block exactly as today: status at `01B00000`, magic at
|
||||
`01B00040` set after `main` returns, and `libtms`'s output/error buffers at
|
||||
`01B10000`/`01B30000` with their length cells;
|
||||
- the `_start` symbol that `--entry _start` names;
|
||||
- `exit`/`abort` in `libtms` still publish status and spin.
|
||||
|
||||
Those addresses and sizes are the interface `tms-run` and the conformance
|
||||
harness already rely on.
|
||||
|
||||
### 8.4 Library policy
|
||||
|
||||
`libtms.a` always links when the CRT does. `flib.lib`/`rts.lib` are needed by
|
||||
`libtms`'s `%f` path, so they link by default. The conventional knobs are
|
||||
independent: `-nostartfiles` drops `crt0.o` but keeps the libraries,
|
||||
`-nodefaultlibs` keeps `crt0.o` but drops `libtms`/`flib`/`rts`, and
|
||||
`-nostdlib` implies both. `-l tms` is accepted and is a no-op beyond ensuring
|
||||
the archive is present once. Order is fixed: CRT, user objects, `libtms`,
|
||||
`flib`, `rts`, user `-l` archives.
|
||||
|
||||
### 8.5 `tms-link` prerequisite
|
||||
|
||||
`coff-check.py --repair` leaves the production path. `tms-link` must emit a
|
||||
valid file header, optional header and section table, and round `.bss` to whole
|
||||
16-bit words itself; `coff-check.py` stays in the gates as a checker (`--repair`
|
||||
becomes test-only). This is small linker work and it is the reason the link job
|
||||
can stay clean.
|
||||
|
||||
### 8.6 `tms-cc`
|
||||
|
||||
Kept as a compatibility alias documented as such: it adds `--run` and the
|
||||
project's M4 defaults. New documentation points at `clang --target=tms34010`.
|
||||
It is not deleted in M11.
|
||||
|
||||
### 8.7 Acceptance
|
||||
|
||||
1. From a clean shell after `scripts/tms-sdk`:
|
||||
`clang --target=tms34010 hello.c -o hello` then `tms-run hello` prints
|
||||
`hello` with status 0. No `M4_*`, `TMS_*`, or include paths set.
|
||||
2. `-c`, `-S`, `-E`, `-O0`, `-O2`, `-g`, two-TU linking and `-nostdlib` all
|
||||
behave conventionally; `clang/test/Driver/TMS34010-link.c` pins the jobs.
|
||||
3. `crt0.o` and `libtms.a` rebuild byte-identically from `sdk/` (`llc`
|
||||
self-consistency, not parity with the 1987 assembler), and a gate compares
|
||||
the committed `flib.lib`/`rts.lib` against the extracted originals.
|
||||
4. One existing M4/M5/M6 harness program builds through the new path and still
|
||||
passes its MAME markers. (M11 adds no separate harness-program-through-driver
|
||||
case: `scripts/tests/m11/e2e.sh` plus the unchanged full suite cover that
|
||||
risk.)
|
||||
5. The conformance suite stays `1,912 = 1,618 / 294 / 0 / 0`; lit and every
|
||||
M0–M10 gate stay green; `HARDWARE: DEFERRED`.
|
||||
|
||||
## 9. What is left to the builder
|
||||
|
||||
1. Whether `scripts/tms-sdk` is a shell script, a CMake custom target, or both
|
||||
(a `make sdk` shim is likely enough).
|
||||
2. The exact `Tool` subclass shape (`GnuTool`-style vs plain `Tool`), and
|
||||
whether `-Wl,` parsing belongs in the Tool or the ToolChain.
|
||||
3. Whether `libtms` also carries `__tms_bitptr`-adjacent helpers or stays
|
||||
purely C.
|
||||
4. The precise `clang -###` line splits the driver test pins.
|
||||
5. Whether `-Map` defaults on or only on `-Wl,-Map` (leaning: default on, next
|
||||
to the output, because the map is the debugging surface this toolchain has).
|
||||
6. How the installed `tms-link` should signal a missing interpreter (shebang
|
||||
plus the driver's pre-flight check), and whether `tms-sdk` normalises the
|
||||
copied pair's permissions.
|
||||
|
||||
## 10. Risks and mitigations
|
||||
|
||||
| Risk | Mitigation |
|
||||
|---|---|
|
||||
| Sysroot drift from sources | `scripts/tms-sdk` is the only writer; a gate rebuilds and compares the CRT and library |
|
||||
| Committed vendor archives drift | A gate compares them against freshly extracted copies |
|
||||
| Installed linker drifts from `tools/tms-link` | `scripts/tms-sdk` copies it; a gate compares the installed pair against the sources |
|
||||
| `python3` missing at link time | The driver detects it and names `scripts/tms-sdk` and `python3` in the diagnostic |
|
||||
| The IR CRT shifts the runtime contract | The contract list in §8.3 is the test: `tms-run` output, argv, status and buffer addresses |
|
||||
| `naked` + inline asm is fragile across LLVM bumps | The CRT gate pins the emitted bytes and `llc`'s no-prologue output |
|
||||
| Driver bakes in a checkout path | Discovery is resource-dir relative; the driver test asserts it |
|
||||
| Link failures from an uninstalled sysroot | A missing sysroot is a named diagnostic telling the user to run `scripts/tms-sdk`, not a link error |
|
||||
| `tms-link` header defects surface late | M11.1 fixes the linker first and `coff-check` gates it |
|
||||
| Conformance harness forks its headers | Harness and sysroot share `sdk/include` |
|
||||
| `-g` silently stripped | Driver test pins `--keep-debug`; an M8-style dwarfdump check confirms the linked image |
|
||||
| Driver patch grows into generic clang | All new code stays in `ToolChains/TMS34010.*`; patch `0005` grows, nothing else |
|
||||
|
||||
## 11. Roadmap after M11
|
||||
|
||||
| Milestone | Scope | Why this order |
|
||||
|---|---|---|
|
||||
| **M12 — conformance classes** | inline-asm memory constraints (`m`/`o`/`V`), the `ST` clobber, `blockaddress`, nested functions, VLAs, sret/aggregate/variadic/float returns, runtime aborts, `pr63843` | Raises the suite's pass rate from 1,618 and removes the largest remaining silent-failure classes |
|
||||
| **M13 — performance and hardware** | attribute the slow-phase 2,440 → 3,302-frame delta; further divide/loop work; the real VT1200 run when a unit exists | Needs a stable correctness baseline (M10–M12) before measuring |
|
||||
| **M14 — hosted I/O (optional)** | real console/serial output, then file APIs; a terminal `printf` instead of the result block | Largest scope and the least certain requirement; deliberately last |
|
||||
|
||||
Each milestone gets its own design and plan; this table only fixes the order.
|
||||
|
||||
## 12. Decisions log
|
||||
|
||||
| Decision | Choice | By |
|
||||
|---|---|---|
|
||||
| M11 scope | Phase 3: freestanding toolchain with conventional UX | user (earlier) |
|
||||
| Artifact discovery | Resource-directory sysroot built and installed by `scripts/tms-sdk` (approach A) | user |
|
||||
| Linker discovery | `scripts/tms-sdk` installs `tms-link` + `tmscoff.py` into `<sysroot>/bin/`; the driver resolves it relative to the sysroot, `--tms-linker=` overrides | user |
|
||||
| CRT source/build | `sdk/crt0.ll` (naked `_start` + inline asm) built by `llc`; acceptance is `llc` self-consistency | this doc (corrected during M11 execution: `llvm-mc` emits ELF) |
|
||||
| Link-reduction knobs | `-nostartfiles`, `-nodefaultlibs`, `-nostdlib` all supported | this doc |
|
||||
| `libtms.a` fidelity | Rebuild-and-compare against `sdk/`, plus the suite | this doc |
|
||||
| Vendor archives | Committed to the repo, compared by a gate | user (earlier) |
|
||||
| Hosted libc | Out of scope | user (earlier) |
|
||||
| `tms-cc` | Kept as a compatibility alias | this doc |
|
||||
| `coff-check --repair` | Leaves the production path; `tms-link` emits valid images | this doc |
|
||||
| Milestone order | M11 → M12 (conformance) → M13 (performance/hardware) → M14 (hosted I/O, optional) | this doc |
|
||||
@@ -0,0 +1,274 @@
|
||||
# TMS34010 M12 — Tractable Conformance Gaps (Design)
|
||||
|
||||
Status: proposed. M11 is complete and `m11` is the default on both repositories
|
||||
(project `536c80a`, compiler `18b7fc9cd6df`).
|
||||
|
||||
The human partner chose this split: M12 takes the gaps that are backend or
|
||||
driver work with known mechanics, and **nested functions and VLA-in-struct are
|
||||
out of scope permanently** because both are frontend refusals, not gaps in our
|
||||
backend. The runtime-abort class is triaged here and fixed in M13.
|
||||
|
||||
## 1. Intent and why
|
||||
|
||||
The suite accounts for 1,912 files: 1,618 pass, 294 skip, none fail. The skips
|
||||
are curated, not random — each carries a reason. This milestone removes the
|
||||
ones that are genuinely ours and reachable, and turns the largest unknown
|
||||
bucket ("runtime aborts", 58 files) into a costed list.
|
||||
|
||||
Everything below was verified against the `m11` compiler, not inferred from the
|
||||
skip file.
|
||||
|
||||
| Class | Files | Verified failure | Verdict |
|
||||
|---|---|---|---|
|
||||
| inline-asm memory constraints | 11 | `LLVM ERROR: TMS34010: inline asm memory constraints ('m'/'o'/'V') are not supported; use a register or an immediate operand` — the target's own diagnostic, added deliberately in M9. All eleven use `m`/`g` with an empty template; **no corpus row uses `o`, `V`, or `~{st}`** | ours, bounded |
|
||||
| `ST` clobber | 0 (feature) | `ST` exists in `TMS34010RegisterInfo.td:46` but not in clang's GCC register list (`clang/lib/Basic/Targets/TMS34010.cpp:73`), so `~{st}` cannot be named | ours, small, no suite flip |
|
||||
| inline-asm, not memory-operand | 2 | `20030222-1`: i64 value tied to a 32-bit `r`; `990413-2`: an x86-only test (`=t`) that does not belong in this corpus | out of scope (separate gaps) |
|
||||
| `blockaddress` + computed goto | 2 | `llc`: `Cannot select: BlockAddress<@execute, %base>`; and `920501-3` needs an indirect branch the backend cannot select (the ISA has `jump Rd`, unimplemented) | ours, bounded |
|
||||
| return/frame address | 3 of 5 | `LLVM ERROR: TMS34010: unexpected custom lowering operation (return address)` / `(frame address)`. `20010122-1` checks level 1 and `20030323-1` walks to level 100; only `20030811-1`, `frame-address`, `pr17377` are level-0 | ours, bounded |
|
||||
| dynamic alloca scaling | 1 | `dynamic alloca size scaling assertion` (`c-torture/20070824-1`) | ours, bounded |
|
||||
| runtime aborts | 49–51 | compile and run, then abort with status `0x86` or a wrong result (i64, bitfield, varargs, vector, float, plain) | **triage only** |
|
||||
| nested functions | 30 | clang: `error: function definition is not allowed here` | out of scope |
|
||||
| VLA in struct | 9 | clang: `fields must have a constant size: 'variable length array in structure' extension will never be supported` | out of scope |
|
||||
| dialect strictness | 8 | `-Wint-conversion`, `-Wparen`, K&R-style errors under the pinned language mode | out of scope |
|
||||
| timeouts, region limits | 37 | loader budget or the 45 KiB/64 KiB image region | out of scope (environment) |
|
||||
|
||||
So M12 can flip **17 files** (11 + 2 + 3 + 1) plus at most three abort fixes, and
|
||||
must produce one new artefact: the abort triage report.
|
||||
|
||||
## 2. Goals
|
||||
|
||||
1. Inline-asm `m`/`o`/`V` memory operands work for the addressing modes this
|
||||
target can select, with unsupported shapes still loud and named.
|
||||
2. `~{st}` is a nameable clobber, and using `ST` as a value operand stays
|
||||
rejected.
|
||||
3. Computed `goto` works: `blockaddress` lowers to a section-relative bit
|
||||
address and jumps correctly.
|
||||
4. `llvm.returnaddress(0)` and `llvm.frameaddress(0)` lower on this ABI; levels
|
||||
above 0 stay a named error.
|
||||
5. Dynamic allocas (VLAs and `alloca`) scale sizes in bits correctly.
|
||||
6. **Abort triage:** the set is *discovered*, not asserted — every curated
|
||||
`runtime-abort*` and runtime-wrong-result row is re-run uncurated at `-O0`
|
||||
and `-O2`, its failure mode captured, and the results grouped into named
|
||||
causes with evidence and a proposed M13 cost. At most three single-cause cheap fixes may
|
||||
be taken inside M12; everything else is deferred with a recorded reason.
|
||||
7. Each fixed class flips its files in the full suite, and the accounting is
|
||||
re-recorded (pass count rises, skip count falls by the same amount).
|
||||
8. All M0–M11 gates, the M11 end-to-end build and the two-tier harness stay
|
||||
green.
|
||||
|
||||
## 3. Non-goals
|
||||
|
||||
- **Nested functions** and **VLA in struct**: frontend features clang refuses;
|
||||
implementing them means LLVM frontend work outside this milestone's charter.
|
||||
They stay curated with those reasons.
|
||||
- **ABI shapes** (sret, aggregate/variadic/float arguments and returns): M13,
|
||||
together with the aborts they probably overlap.
|
||||
- **Dialect strictness** (the 8 `compile:` rows): the corpus is compiled in a
|
||||
pinned language mode; relaxing it would change what the suite measures.
|
||||
- **Timeouts and region limits**: environment, not compiler defects.
|
||||
- **Performance work and the hardware run**: M14.
|
||||
- **Hosted I/O**: M15, optional.
|
||||
|
||||
## 4. Anti-goals
|
||||
|
||||
- Un-curating a test without fixing it. A class is flipped only when its
|
||||
reason is gone.
|
||||
- Supporting memory operands by falling back to a register copy behind the
|
||||
user's back. If a shape cannot be an address, it stays an error that names
|
||||
the constraint and the operand shape.
|
||||
- A blockaddress implementation that bakes in a load address or breaks the
|
||||
pic-free model.
|
||||
- Making `returnaddress`/`frameaddress` return plausible nonsense for levels
|
||||
the ABI cannot express.
|
||||
- A triage report that lists "aborts" as one bucket. Its whole value is named
|
||||
causes.
|
||||
|
||||
## 5. Constraints
|
||||
|
||||
- LLVM/Clang stay pinned at 23.1.5; branch `m12` from `m11`; promote only after
|
||||
a clean whole-branch review.
|
||||
- No TI ABI change: the all-stack convention, argument slots, and the bit
|
||||
pointer model stay as they are.
|
||||
- Every gate stays green; the suite stays `0 fail / 0 crash`; the abort triage
|
||||
may not turn a curated skip into a *failure* row.
|
||||
- No gate expectation, checksum or recorded count moves except the suite rows
|
||||
this milestone legitimately flips (and those are recorded individually).
|
||||
- Build with `-j4` on this host (unbounded builds have been OOM-killed).
|
||||
|
||||
## 6. Approaches considered
|
||||
|
||||
### 6.1 Inline-asm memory operands
|
||||
|
||||
**A. Full addressing-mode support (chosen).** Teach `SelectInlineAsmMemoryOperands`
|
||||
and `TMS34010DAGToDAGISel` to match the ISA's memory forms — `*An`,
|
||||
`*An(disp)`, `*An+`, `*-An`, `*An(disp),N` — and let LLVM pick one for an `m`
|
||||
operand. `o` (offsettable) and `V` (non-offsettable) map onto the same matcher
|
||||
with their respective restrictions. Unmatchable shapes stay loud.
|
||||
|
||||
**B. Minimal support.** Accept only a plain `*An` and keep everything else
|
||||
loud. Less work, but the 13 files use varied shapes and most would stay
|
||||
skipped.
|
||||
|
||||
**C. Keep it loud.** Costs nothing and flips nothing; rejected because these
|
||||
are ordinary C `asm` statements the corpus already contains.
|
||||
|
||||
**Why A.** The ISA has few, regular memory forms; the matcher is the natural
|
||||
home for them, and the loud fallback keeps the residual honest.
|
||||
|
||||
### 6.2 Abort triage
|
||||
|
||||
**A. Full uncurated re-run (chosen).** Re-run all 58 with the same driver, at
|
||||
both `-O0` and `-O2`, capture status and the first wrong marker or abort site,
|
||||
then group. Costs one MAME pass but produces evidence for every file.
|
||||
|
||||
**B. Sample.** Cheap, but a plan built on a sample repeats last milestone's
|
||||
guesswork; rejected.
|
||||
|
||||
**C. Fix-as-you-go.** Debug each abort inside M12. Rejected: unbounded, and the
|
||||
milestone's point is to make M13 plannable.
|
||||
|
||||
## 7. Design
|
||||
|
||||
### 7.1 Inline-asm memory constraints
|
||||
|
||||
- `TMS34010TargetLowering::getConstraintType` already distinguishes `m`; add
|
||||
`TMS34010TargetLowering::SelectInlineAsmMemoryOperand` (the hook M9 replaced
|
||||
with a fatal error) that produces a memory operand the DAG can select.
|
||||
- Add a `TMS34010DAGToDAGISel` matcher for the five memory forms, reusing the
|
||||
existing addressing-mode selection used by loads/stores.
|
||||
- `constraint 'o'` requires a non-post-increment, non-negative-displacement
|
||||
form. `'V'` stays loud: `InlineAsm::ConstraintCode` has no `V`, and
|
||||
`SelectionDAGBuilder` asserts on an unknown memory constraint before the
|
||||
target hook runs, so honouring its "non-offsettable" restriction would need
|
||||
a core LLVM enum change — outside this milestone's target-only charter.
|
||||
- Tests: one `.c` per form at `-O0` and `-O2`, plus a negative for an
|
||||
unmatchable operand, and a check that the emitted asm uses the expected
|
||||
addressing form rather than a register copy.
|
||||
|
||||
### 7.2 `ST` clobber
|
||||
|
||||
- Add `"st"` to `TMS34010TargetInfo::getGCCRegNames()`; `ST` already exists in
|
||||
the register info (`TMS34010RegisterInfo.td:46`).
|
||||
- Keep `ST` out of the allocatable set and out of the inline-asm *operand*
|
||||
classes; only the clobber path accepts it.
|
||||
- Tests: `~{st}` accepted, no save/restore emitted for it (it is a status
|
||||
register), and `asm("" : "=r"(x) : ...)` unchanged.
|
||||
|
||||
### 7.3 `blockaddress` and computed goto
|
||||
|
||||
- Lower `ISD::BlockAddress` in `TMS34010TargetLowering::LowerOperation` to the
|
||||
target's address node for a label: a section-relative bit address with the
|
||||
existing relocation machinery, no absolute load address.
|
||||
- Add the ISA's indirect jump `jump Rd` (opcode `0x0160`, documented in the
|
||||
vendor README) end to end: instruction definition, MC encoding, asm parser,
|
||||
printer and disassembler, and `ISD::BRIND` lowering to it. Without this,
|
||||
`goto *` cannot select even once the constant works.
|
||||
- Tests: computed `goto` in C at `-O0`/`-O2` for both corpus shapes; an `llc`
|
||||
lit test that the constant is a `.text`-relative bit address; MC tests for
|
||||
the encoding, parser and disassembler; and a negative that an out-of-range
|
||||
target stays loud.
|
||||
|
||||
### 7.4 Return and frame address
|
||||
|
||||
- The return address lives on the **system stack**, not at an `A13`-relative
|
||||
slot: after the callee's FP/callee-save `MMTM` the word is at
|
||||
`SP + NumSaved*32` (`NumSaved = 1 + callee-save-count`). The shipped
|
||||
lowering captures it once in the prologue; the two capture-scratch pushes
|
||||
put it at `SP + (NumSaved + 2)*32`, and the copy is stored in an `A13`
|
||||
slot. Level 0 reads that stable frame slot, not an `SP`-relative load at
|
||||
the use site (which can sink into the caller's saved-STK push window).
|
||||
- `llvm.frameaddress(0)` is the current frame pointer (`A13`).
|
||||
- Levels above 0: keep the loud error, but name the intrinsic and the level.
|
||||
`20010122-1` (level 1) and `20030323-1` (levels 1–100) stay curated with a
|
||||
precise "level > 0 unsupported" reason.
|
||||
- Tests: the three level-0 corpus files, plus lit covering level 0 and the
|
||||
loud non-zero case.
|
||||
|
||||
### 7.5 Dynamic alloca scaling
|
||||
|
||||
- Reproduce `c-torture/20070824-1`; the recorded failure is a size-scaling
|
||||
assertion. Fix the bit-vs-byte scaling in the dynamic-alloca path so the
|
||||
stack adjustment matches the pointer arithmetic (both are bit units).
|
||||
- Test: the corpus file plus a lit case pinning the stack-adjust arithmetic for
|
||||
a non-constant size.
|
||||
|
||||
### 7.6 Abort triage (deliverable, not a fix)
|
||||
|
||||
- A harness `scripts/tests/m12/abort-triage.sh` that re-runs each of the 58
|
||||
abort rows through the standard driver at `-O0` and `-O2`, capturing status,
|
||||
the completion magic, and the first differing marker/abort PC.
|
||||
- Output: `docs/superpowers/research/2026-11-19-tms34010-abort-triage.md`, one
|
||||
row per file with class → cause → evidence → estimated cost, plus a summary
|
||||
by cause.
|
||||
- Ruling: at most three fixes may be taken inside M12, each only if the triage
|
||||
shows a single shared cause with a one-line fix; all others defer to M13. Any
|
||||
taken fix is its own task with a recorded flip.
|
||||
|
||||
### 7.7 Suite accounting
|
||||
|
||||
Each class fix records the exact flipped rows in `full-suite.skip`'s removal
|
||||
commit and in the docs. The final numbers are expected to be
|
||||
**1,618 + N pass / 294 − N skip**, with N ≈ 20 (13 inline-asm + 2 blockaddress
|
||||
+ 4 return/frame address + 1 dynamic alloca), plus any abort fixes.
|
||||
|
||||
## 8. Acceptance
|
||||
|
||||
1. The 10 memory-constraint rows pass (`stkalign` is re-reasoned, not
|
||||
flipped); `~{st}` is accepted as a clobber;
|
||||
unmatchable shapes and `V` still fail with a named error.
|
||||
2. Both `blockaddress` rows pass with correct control flow at `-O0` and `-O2`,
|
||||
including the new `jump Rd` encoding, parser and disassembler tests.
|
||||
3. The three level-0 return/frame-address rows pass; levels above 0 stay a
|
||||
named error.
|
||||
4. The dynamic-alloca row passes.
|
||||
5. The abort triage report exists, covers the harness-discovered set, groups it
|
||||
by named cause, and proposes an M13 scope with costs.
|
||||
6. The full suite is re-recorded with `0 fail / 0 crash`, pass/skip consistent,
|
||||
and each flip individually justified.
|
||||
7. All M0–M11 gates green, M11's `clang hello.c -o hello` still works, i64div
|
||||
numbers unchanged, `HARDWARE: DEFERRED`.
|
||||
|
||||
## 9. Risks and mitigations
|
||||
|
||||
| Risk | Mitigation |
|
||||
|---|---|
|
||||
| Memory-operand matcher accepts a shape it selects wrongly | Each form has an asm-shape test; unmatchable shapes stay loud |
|
||||
| `ST` becomes allocatable by accident | Register class untouched; test asserts it never appears as an operand class |
|
||||
| Blockaddress bakes a load address | Lit test pins the section-relative form and a link-time check that `--text` relocation still works |
|
||||
| `returnaddress` picks the wrong slot | The four corpus files run in MAME; a wrong slot aborts loudly |
|
||||
| Abort triage turns a skip into a crash row | The triage re-runs out of tree and never edits the curated file unless a fix lands |
|
||||
| Suite accounting drifts | Flips recorded per row; the report shows the arithmetic |
|
||||
|
||||
## 10. What is left to the builder
|
||||
|
||||
1. Which of the five memory forms `o`/`V` should accept (the ISA table decides;
|
||||
document the mapping).
|
||||
2. Whether `returnaddress` can rely on a fixed A13 displacement or needs the
|
||||
frame-size recorded in the function.
|
||||
3. Whether the dynamic-alloca failure is one bug or two (size and alignment).
|
||||
4. The triage harness's exact failure-capture (marker diff vs abort PC).
|
||||
5. Which three abort fixes, if any, meet the one-line bar.
|
||||
|
||||
## 11. Roadmap (renumbered)
|
||||
|
||||
| Milestone | Scope |
|
||||
|---|---|
|
||||
| **M12 (this)** | inline-asm memory constraints + `ST` clobber, `blockaddress`, return/frame address, dynamic alloca, abort triage |
|
||||
| **M13** | ABI shapes (sret, aggregate/variadic/float args and returns) and the abort causes triaged here |
|
||||
| **M14** | performance and the real VT1200 run |
|
||||
| **M15** | hosted I/O (optional) |
|
||||
| out of scope for good | nested functions, VLA in struct (frontend refusals), dialect strictness, timeouts and region limits |
|
||||
|
||||
## 12. Decisions log
|
||||
|
||||
| Decision | Choice | By |
|
||||
|---|---|---|
|
||||
| Split the conformance work | Feature/gap classes in M12, ABI + aborts in M13 | user |
|
||||
| Nested functions | Permanently out of scope (clang frontend feature) | user |
|
||||
| Return/frame address | Level 0 only; levels above 0 stay a named error | user |
|
||||
| Computed goto | Add `jump Rd` + `BRIND` lowering so both rows flip | user |
|
||||
| `V` constraint | Kept loud (needs a core LLVM enum change) | this doc |
|
||||
| Inline-asm flips | 10 rows; `stkalign` is re-reasoned, and `ST` is a feature-only change | this doc |
|
||||
| VLA in struct | Out of scope (clang: "will never be supported") | this doc |
|
||||
| Memory operands | Full addressing-mode support with a loud fallback | this doc |
|
||||
| Abort handling in M12 | Triage only, at most three one-line fixes | this doc |
|
||||
@@ -1,3 +1,55 @@
|
||||
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
index ae3eecc60fc7..eef40fc1306d 100644
|
||||
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
@@ -787,6 +787,14 @@ def warn_drv_darwin_sdk_invalid_settings : Warning<
|
||||
InGroup<DiagGroup<"darwin-sdk-settings">>;
|
||||
|
||||
def err_missing_sysroot : Error<"no such sysroot directory: '%0'">;
|
||||
+def err_drv_tms34010_missing_sysroot : Error<
|
||||
+ "TMS34010 sysroot not found: '%0'; run 'scripts/tms-sdk' to build and install it">;
|
||||
+def err_drv_tms34010_missing_linker : Error<
|
||||
+ "TMS34010 linker not found: '%0'; run 'scripts/tms-sdk' to install it">;
|
||||
+def err_drv_tms34010_missing_python3 : Error<
|
||||
+ "python3 not found on PATH; the TMS34010 linker requires it (install python3)">;
|
||||
+def err_drv_tms34010_missing_artifact : Error<
|
||||
+ "TMS34010 sysroot is incomplete: '%0' is missing; run 'scripts/tms-sdk' to install it">;
|
||||
def err_drv_darwin_sdk_missing_arclite : Error<
|
||||
"SDK does not contain 'libarclite' at the path '%0'; try increasing the minimum deployment target">;
|
||||
|
||||
diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td
|
||||
index f893d858d526..5ada0996811e 100644
|
||||
--- a/clang/include/clang/Options/Options.td
|
||||
+++ b/clang/include/clang/Options/Options.td
|
||||
@@ -6981,6 +6981,14 @@ def _help_hidden : Flag<["--"], "help-hidden">,
|
||||
HelpText<"Display help for hidden options">;
|
||||
def _sysroot_EQ : Joined<["--"], "sysroot=">, Visibility<[ClangOption, FlangOption]>;
|
||||
def _sysroot : Separate<["--"], "sysroot">, Alias<_sysroot_EQ>;
|
||||
+def tms_sysroot_EQ : Joined<["--"], "tms-sysroot=">,
|
||||
+ Visibility<[ClangOption, FlangOption]>,
|
||||
+ HelpText<"Use the given directory as the TMS34010 sysroot (default: "
|
||||
+ "<resource-dir>/tms34010-unknown-none)">;
|
||||
+def tms_linker_EQ : Joined<["--"], "tms-linker=">,
|
||||
+ Visibility<[ClangOption, FlangOption]>,
|
||||
+ HelpText<"Use the given executable as the TMS34010 linker (default: "
|
||||
+ "<sysroot>/bin/tms-link)">;
|
||||
def no_xcselect : Flag<["--"], "no-xcselect">,
|
||||
HelpText<"Disable xcselect SDK injection on macOS">;
|
||||
|
||||
diff --git a/clang/lib/Basic/Targets/TMS34010.cpp b/clang/lib/Basic/Targets/TMS34010.cpp
|
||||
index ad27642ae9aa..37cf9243e848 100644
|
||||
--- a/clang/lib/Basic/Targets/TMS34010.cpp
|
||||
+++ b/clang/lib/Basic/Targets/TMS34010.cpp
|
||||
@@ -76,6 +76,9 @@ ArrayRef<const char *> TMS34010TargetInfo::getGCCRegNames() const {
|
||||
"a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
|
||||
"b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7",
|
||||
"b8", "b9", "b10", "b11", "b12", "b13", "b14", "b15",
|
||||
+ // The status register is nameable as a clobber only: ST is outside
|
||||
+ // every register class, so it can never be chosen as an operand.
|
||||
+ "st",
|
||||
};
|
||||
return Names;
|
||||
}
|
||||
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
|
||||
index 506536cdc04f..71ce08e3e5b6 100644
|
||||
--- a/clang/lib/Driver/CMakeLists.txt
|
||||
@@ -34,10 +86,10 @@ index e606cdc4c1cf..8a36e6a29fae 100644
|
||||
case llvm::Triple::riscv32be:
|
||||
diff --git a/clang/lib/Driver/ToolChains/TMS34010.cpp b/clang/lib/Driver/ToolChains/TMS34010.cpp
|
||||
new file mode 100644
|
||||
index 000000000000..a2fc8eb68917
|
||||
index 000000000000..238913e830b0
|
||||
--- /dev/null
|
||||
+++ b/clang/lib/Driver/ToolChains/TMS34010.cpp
|
||||
@@ -0,0 +1,44 @@
|
||||
@@ -0,0 +1,264 @@
|
||||
+//===--- TMS34010.cpp - TMS34010 ToolChain ----------------------*- C++ -*-===//
|
||||
+//
|
||||
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
@@ -48,14 +100,46 @@ index 000000000000..a2fc8eb68917
|
||||
+
|
||||
+#include "TMS34010.h"
|
||||
+
|
||||
+#include "clang/Driver/Compilation.h"
|
||||
+#include "clang/Driver/Driver.h"
|
||||
+#include "clang/Driver/InputInfo.h"
|
||||
+#include "clang/Driver/Tool.h"
|
||||
+#include "clang/Options/Options.h"
|
||||
+#include "llvm/Option/ArgList.h"
|
||||
+#include "llvm/Support/FileSystem.h"
|
||||
+#include "llvm/Support/Path.h"
|
||||
+#include "llvm/Support/Program.h"
|
||||
+
|
||||
+using namespace clang;
|
||||
+using namespace clang::driver;
|
||||
+using namespace clang::driver::toolchains;
|
||||
+using namespace clang::driver::tools;
|
||||
+using namespace llvm::opt;
|
||||
+
|
||||
+TMS34010ToolChain::TMS34010ToolChain(const Driver &D, const llvm::Triple &Triple,
|
||||
+ const ArgList &Args)
|
||||
+ : BareMetal(D, Triple, Args) {}
|
||||
+ : BareMetal(D, Triple, Args) {
|
||||
+ // Sysroot search order: --tms-sysroot=DIR, then --sysroot/-isysroot, then the
|
||||
+ // resource directory. Nothing here bakes a checkout path: the resource-dir
|
||||
+ // fallback is derived from the clang binary, so the toolchain stays
|
||||
+ // relocatable.
|
||||
+ if (const Arg *A = Args.getLastArg(options::OPT_tms_sysroot_EQ))
|
||||
+ SysRoot = A->getValue();
|
||||
+ else if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ,
|
||||
+ options::OPT_isysroot))
|
||||
+ SysRoot = A->getValue();
|
||||
+ else {
|
||||
+ SmallString<128> P(D.ResourceDir);
|
||||
+ llvm::sys::path::append(P, "tms34010-unknown-none");
|
||||
+ SysRoot = std::string(P.str());
|
||||
+ }
|
||||
+
|
||||
+ // Objects and libraries come from <sysroot>/lib.
|
||||
+ SmallString<128> LibDir(SysRoot);
|
||||
+ llvm::sys::path::append(LibDir, "lib");
|
||||
+ getFilePaths().push_back(std::string(LibDir.str()));
|
||||
+ getLibraryPaths().push_back(std::string(LibDir.str()));
|
||||
+}
|
||||
+
|
||||
+void TMS34010ToolChain::addClangTargetOptions(
|
||||
+ const ArgList &DriverArgs, ArgStringList &CC1Args, BoundArch BA,
|
||||
@@ -77,17 +161,205 @@ index 000000000000..a2fc8eb68917
|
||||
+ BareMetal::addClangTargetOptions(DriverArgs, CC1Args, BA, DeviceOffloadKind);
|
||||
+}
|
||||
+
|
||||
+void TMS34010ToolChain::AddClangSystemIncludeArgs(const ArgList &,
|
||||
+ ArgStringList &) const {
|
||||
+ // No system include paths for this target. The builtin headers are located
|
||||
+ // through -resource-dir, matching the previous generic bare-metal behaviour.
|
||||
+void TMS34010ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
||||
+ ArgStringList &CC1Args) const {
|
||||
+ if (DriverArgs.hasArg(options::OPT_nostdinc))
|
||||
+ return;
|
||||
+
|
||||
+ // The target's headers live in <sysroot>/include; the builtin headers keep
|
||||
+ // being found through -resource-dir, matching the M10 freestanding defaults.
|
||||
+ if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
|
||||
+ SmallString<128> IncDir(SysRoot);
|
||||
+ llvm::sys::path::append(IncDir, "include");
|
||||
+ addSystemInclude(DriverArgs, CC1Args, IncDir.str());
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+Tool *TMS34010ToolChain::buildLinker() const {
|
||||
+ return new tools::tms34010::TMS34010Linker(*this);
|
||||
+}
|
||||
+
|
||||
+void tms34010::TMS34010Linker::ConstructJob(
|
||||
+ Compilation &C, const JobAction &JA, const InputInfo &Output,
|
||||
+ const InputInfoList &Inputs, const ArgList &Args,
|
||||
+ const char *LinkingOutput) const {
|
||||
+ const auto &TC =
|
||||
+ static_cast<const toolchains::TMS34010ToolChain &>(getToolChain());
|
||||
+ const Driver &D = TC.getDriver();
|
||||
+ const std::string &SysRoot = TC.getTMS34010SysRoot();
|
||||
+
|
||||
+ // Linker discovery: --tms-linker=PATH first, else <sysroot>/bin/tms-link.
|
||||
+ const bool UseDefaultLinker = !Args.hasArg(options::OPT_tms_linker_EQ);
|
||||
+ std::string Linker;
|
||||
+ if (const Arg *A = Args.getLastArg(options::OPT_tms_linker_EQ)) {
|
||||
+ Linker = A->getValue();
|
||||
+ } else {
|
||||
+ SmallString<128> DefaultLinker(SysRoot);
|
||||
+ llvm::sys::path::append(DefaultLinker, "bin", "tms-link");
|
||||
+ Linker = std::string(DefaultLinker.str());
|
||||
+ }
|
||||
+
|
||||
+ // A missing sysroot, a missing linker or a missing python3 is a named
|
||||
+ // diagnostic telling the user to run scripts/tms-sdk -- never a bare link
|
||||
+ // error. The explicit --tms-linker path is trusted verbatim, so neither the
|
||||
+ // linker-existence nor the python3 check applies to it.
|
||||
+ if (!llvm::sys::fs::exists(SysRoot)) {
|
||||
+ D.Diag(diag::err_drv_tms34010_missing_sysroot) << SysRoot;
|
||||
+ return;
|
||||
+ }
|
||||
+ if (UseDefaultLinker && !llvm::sys::fs::exists(Linker)) {
|
||||
+ D.Diag(diag::err_drv_tms34010_missing_linker) << Linker;
|
||||
+ return;
|
||||
+ }
|
||||
+ // The installed tms-link is a Python program; name python3 if it is missing.
|
||||
+ if (UseDefaultLinker && !llvm::sys::findProgramByName("python3")) {
|
||||
+ D.Diag(diag::err_drv_tms34010_missing_python3);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Fixed link order: CRT, user objects, the three default libraries, then
|
||||
+ // user -L/-l archives.
|
||||
+ const bool WantStartFiles =
|
||||
+ !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
|
||||
+ const bool WantDefaultLibs =
|
||||
+ !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
|
||||
+
|
||||
+ // A sysroot directory can exist while the artifacts the default link needs
|
||||
+ // are absent (a partial install). Name the missing file instead of handing
|
||||
+ // tms-link a bare name it will fail to open.
|
||||
+ bool MissingArtifact = false;
|
||||
+ auto CheckArtifact = [&](StringRef Name) {
|
||||
+ SmallString<128> P(SysRoot);
|
||||
+ llvm::sys::path::append(P, "lib", Name);
|
||||
+ if (llvm::sys::fs::exists(P))
|
||||
+ return;
|
||||
+ D.Diag(diag::err_drv_tms34010_missing_artifact) << std::string(P.str());
|
||||
+ MissingArtifact = true;
|
||||
+ };
|
||||
+ if (WantStartFiles)
|
||||
+ CheckArtifact("crt0.o");
|
||||
+ if (WantDefaultLibs) {
|
||||
+ CheckArtifact("libtms.a");
|
||||
+ CheckArtifact("flib.lib");
|
||||
+ CheckArtifact("rts.lib");
|
||||
+ }
|
||||
+ if (MissingArtifact)
|
||||
+ return;
|
||||
+
|
||||
+ ArgStringList CmdArgs;
|
||||
+
|
||||
+ CmdArgs.push_back("-o");
|
||||
+ CmdArgs.push_back(Output.getFilename());
|
||||
+
|
||||
+ CmdArgs.push_back("--entry");
|
||||
+ CmdArgs.push_back("_start");
|
||||
+ CmdArgs.push_back("--text");
|
||||
+ CmdArgs.push_back("018A0000");
|
||||
+ CmdArgs.push_back("--bss");
|
||||
+ CmdArgs.push_back("01A00000");
|
||||
+ CmdArgs.push_back("--prog-len");
|
||||
+ CmdArgs.push_back("40000h");
|
||||
+ CmdArgs.push_back("--ram-len");
|
||||
+ CmdArgs.push_back("80000h");
|
||||
+
|
||||
+ // -Wl,-Map suppresses the default --map; -Wl,-Map=<file> and the
|
||||
+ // -Wl,-Map,<file> comma form select an explicit map file. tms-link spells
|
||||
+ // its map option --map, so both forms become --map=<file> below.
|
||||
+ auto WlValues = Args.getAllArgValues(options::OPT_Wl_COMMA);
|
||||
+ bool HasExplicitMap = false;
|
||||
+ for (const std::string &Value : WlValues) {
|
||||
+ StringRef V(Value);
|
||||
+ if (V == "-Map" || V.starts_with("-Map="))
|
||||
+ HasExplicitMap = true;
|
||||
+ }
|
||||
+
|
||||
+ // The map is this toolchain's debugging surface: default it next to the
|
||||
+ // output unless the user asked for a -Wl,-Map* form.
|
||||
+ if (!HasExplicitMap) {
|
||||
+ std::string MapFile = std::string(Output.getFilename()) + ".map";
|
||||
+ CmdArgs.push_back("--map");
|
||||
+ CmdArgs.push_back(Args.MakeArgString(MapFile));
|
||||
+ }
|
||||
+
|
||||
+ // -g keeps the DWARF in the linked image; the default stays stripped. -g0
|
||||
+ // (and -ggdb0) request no debug info, so they must not add --keep-debug.
|
||||
+ if (Arg *A = Args.getLastArg(options::OPT_g_Group))
|
||||
+ if (!A->getOption().matches(options::OPT_g0) &&
|
||||
+ !A->getOption().matches(options::OPT_ggdb0))
|
||||
+ CmdArgs.push_back("--keep-debug");
|
||||
+
|
||||
+ // Pass the remaining -Wl, arguments through verbatim, translating the map
|
||||
+ // requests. -Wl,-Map,<file> keeps the path in the following comma element.
|
||||
+ for (size_t I = 0, E = WlValues.size(); I != E; ++I) {
|
||||
+ StringRef V(WlValues[I]);
|
||||
+ if (V == "-Map") {
|
||||
+ // A bare -Wl,-Map has no path and produces no map (it still suppresses
|
||||
+ // the default map, as above); a following element is the map path.
|
||||
+ if (I + 1 != E) {
|
||||
+ std::string MapArg = "--map=" + std::string(WlValues[++I]);
|
||||
+ CmdArgs.push_back(Args.MakeArgString(MapArg));
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (V.starts_with("-Map=")) {
|
||||
+ std::string MapArg = "--map=" + std::string(V.drop_front(5));
|
||||
+ CmdArgs.push_back(Args.MakeArgString(MapArg));
|
||||
+ continue;
|
||||
+ }
|
||||
+ CmdArgs.push_back(Args.MakeArgString(V));
|
||||
+ }
|
||||
+
|
||||
+ // Fixed link order: CRT, user objects, the three default libraries, then
|
||||
+ // user -L/-l archives.
|
||||
+ if (WantStartFiles)
|
||||
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
|
||||
+
|
||||
+ for (const auto &II : Inputs) {
|
||||
+ if (II.isFilename())
|
||||
+ CmdArgs.push_back(II.getFilename());
|
||||
+ }
|
||||
+
|
||||
+ if (WantDefaultLibs) {
|
||||
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("libtms.a")));
|
||||
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("flib.lib")));
|
||||
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("rts.lib")));
|
||||
+ }
|
||||
+
|
||||
+ // Make the sysroot's own library directory reachable for -l lookups before
|
||||
+ // any user -L paths.
|
||||
+ SmallString<128> SysRootLib(SysRoot);
|
||||
+ llvm::sys::path::append(SysRootLib, "lib");
|
||||
+ CmdArgs.push_back("-L");
|
||||
+ CmdArgs.push_back(Args.MakeArgString(SysRootLib.str()));
|
||||
+
|
||||
+ for (const std::string &LibPath : Args.getAllArgValues(options::OPT_L)) {
|
||||
+ CmdArgs.push_back("-L");
|
||||
+ CmdArgs.push_back(Args.MakeArgString(LibPath));
|
||||
+ }
|
||||
+ for (const std::string &Lib : Args.getAllArgValues(options::OPT_l)) {
|
||||
+ // -l tms means "ensure libtms.a is linked". With the defaults it is already
|
||||
+ // a positional input, so it is a no-op; with -nodefaultlibs/-nostdlib the
|
||||
+ // user's -l tms is the only request, so resolve it to the archive so it is
|
||||
+ // linked once per request (repeating -l tms links the archive again).
|
||||
+ if (StringRef(Lib) == "tms") {
|
||||
+ if (!WantDefaultLibs)
|
||||
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("libtms.a")));
|
||||
+ continue;
|
||||
+ }
|
||||
+ CmdArgs.push_back("-l");
|
||||
+ CmdArgs.push_back(Args.MakeArgString(Lib));
|
||||
+ }
|
||||
+
|
||||
+ C.addCommand(std::make_unique<Command>(
|
||||
+ JA, *this, ResponseFileSupport::None(),
|
||||
+ Args.MakeArgString(Linker), CmdArgs, Inputs, Output));
|
||||
+}
|
||||
diff --git a/clang/lib/Driver/ToolChains/TMS34010.h b/clang/lib/Driver/ToolChains/TMS34010.h
|
||||
new file mode 100644
|
||||
index 000000000000..598f85ba4b8f
|
||||
index 000000000000..e69011479677
|
||||
--- /dev/null
|
||||
+++ b/clang/lib/Driver/ToolChains/TMS34010.h
|
||||
@@ -0,0 +1,37 @@
|
||||
@@ -0,0 +1,68 @@
|
||||
+//===--- TMS34010.h - TMS34010 ToolChain ------------------------*- C++ -*-===//
|
||||
+//
|
||||
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
@@ -100,6 +372,7 @@ index 000000000000..598f85ba4b8f
|
||||
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_TMS34010_H
|
||||
+
|
||||
+#include "BareMetal.h"
|
||||
+#include "clang/Driver/Tool.h"
|
||||
+
|
||||
+namespace clang {
|
||||
+namespace driver {
|
||||
@@ -118,13 +391,73 @@ index 000000000000..598f85ba4b8f
|
||||
+ void
|
||||
+ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
||||
+ llvm::opt::ArgStringList &CC1Args) const override;
|
||||
+
|
||||
+ /// The sysroot this target's headers, libraries and linker come from,
|
||||
+ /// resolved from --tms-sysroot=, --sysroot/-isysroot, or the resource dir.
|
||||
+ std::string getTMS34010SysRoot() const { return SysRoot; }
|
||||
+
|
||||
+protected:
|
||||
+ Tool *buildLinker() const override;
|
||||
+
|
||||
+private:
|
||||
+ std::string SysRoot;
|
||||
+};
|
||||
+
|
||||
+} // namespace toolchains
|
||||
+
|
||||
+namespace tools {
|
||||
+namespace tms34010 {
|
||||
+
|
||||
+class LLVM_LIBRARY_VISIBILITY TMS34010Linker final : public Tool {
|
||||
+public:
|
||||
+ TMS34010Linker(const ToolChain &TC)
|
||||
+ : Tool("tms34010::Linker", "tms-link", TC) {}
|
||||
+
|
||||
+ bool isLinkJob() const override { return true; }
|
||||
+ bool hasIntegratedCPP() const override { return false; }
|
||||
+
|
||||
+ void ConstructJob(Compilation &C, const JobAction &JA,
|
||||
+ const InputInfo &Output, const InputInfoList &Inputs,
|
||||
+ const llvm::opt::ArgList &TCArgs,
|
||||
+ const char *LinkingOutput) const override;
|
||||
+};
|
||||
+
|
||||
+} // namespace tms34010
|
||||
+} // namespace tools
|
||||
+} // namespace driver
|
||||
+} // namespace clang
|
||||
+
|
||||
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_TMS34010_H
|
||||
diff --git a/clang/test/CodeGen/TMS34010/bitaddr-chain-o2.c b/clang/test/CodeGen/TMS34010/bitaddr-chain-o2.c
|
||||
new file mode 100644
|
||||
index 000000000000..8d4a838ac157
|
||||
--- /dev/null
|
||||
+++ b/clang/test/CodeGen/TMS34010/bitaddr-chain-o2.c
|
||||
@@ -0,0 +1,24 @@
|
||||
+// RUN: %clang_cc1 -triple tms34010-unknown-none -O2 -mllvm -replexitval=never -S -o - %s | FileCheck %s
|
||||
+//
|
||||
+// Source-level pointer arithmetic goes through the pre-optimizer barrier
|
||||
+// (@__tms_bitptr) and is lowered back by tms34010LowerBitPtr. If that lowering
|
||||
+// emitted the foldable `inttoptr(add(ptrtoint base, off))` form, the already-bit
|
||||
+// offsets would fold to a plain ISD::ADD on `p:32` and DAGCombiner's
|
||||
+// BaseIndexOffset aliasing would read them as *bytes*: the word store to p+32
|
||||
+// bits and the byte store to p+40 bits would be misread as +32 and +40 bytes
|
||||
+// and reported non-aliasing, and parallelizeChainedStores would hoist the byte
|
||||
+// store ahead of the word store (the word store then overwrites the byte).
|
||||
+//
|
||||
+// The lowering emits llvm.tms34010.bitaddr instead, which lowers to a
|
||||
+// TMS34010ISD::BITADDR node that BaseIndexOffset cannot decompose, so the byte
|
||||
+// store keeps its program-order position after the word store.
|
||||
+
|
||||
+void f(int *p, int v, int w) { p[0] = v; p[1] = w; ((char *)p)[5] = 0x7f; }
|
||||
+
|
||||
+// The word store to p+32 bits (MOVE ..., *..., 1 after ADDI 32) must be
|
||||
+// scheduled before the byte store to p+40 bits (MOVB after ADDI 40).
|
||||
+// CHECK-LABEL: _f:
|
||||
+// CHECK: ADDI 32, A{{[0-9]+}}
|
||||
+// CHECK: MOVE A{{[0-9]+}}, *A{{[0-9]+}}, 1
|
||||
+// CHECK: ADDI 40, A{{[0-9]+}}
|
||||
+// CHECK: MOVB A{{[0-9]+}}, *A{{[0-9]+}}
|
||||
diff --git a/clang/test/CodeGen/TMS34010/bitaddr-o0.c b/clang/test/CodeGen/TMS34010/bitaddr-o0.c
|
||||
new file mode 100644
|
||||
index 000000000000..e62cab807aa3
|
||||
@@ -149,6 +482,32 @@ index 000000000000..e62cab807aa3
|
||||
+// CHECK: ADDI 16, A{{[0-9]+}}
|
||||
+// CHECK-LABEL: _load_b:
|
||||
+// CHECK: ADDI 32, A{{[0-9]+}}
|
||||
diff --git a/clang/test/CodeGen/TMS34010/bitaddr-o1.c b/clang/test/CodeGen/TMS34010/bitaddr-o1.c
|
||||
new file mode 100644
|
||||
index 000000000000..acefd9de2af6
|
||||
--- /dev/null
|
||||
+++ b/clang/test/CodeGen/TMS34010/bitaddr-o1.c
|
||||
@@ -0,0 +1,20 @@
|
||||
+// RUN: %clang_cc1 -triple tms34010-unknown-none -O1 -S -o - %s | FileCheck %s
|
||||
+//
|
||||
+// The -O0 sibling (bitaddr-o0.c) pins the byte-indexed-GEP bit-address shape
|
||||
+// on the no-optimizer path. -O1 takes the optimizer-last path instead: the
|
||||
+// bit-address barrier hides each source GEP before the optimizer, the post-opt
|
||||
+// scale rescales the byte GEPs the optimizer creates, and lowering undoes the
|
||||
+// barrier. This test pins the same shape on that path, which is otherwise
|
||||
+// covered only indirectly by the static-variadic guard test.
|
||||
+
|
||||
+int load_i(int *p) { return p[1]; }
|
||||
+short load_h(short *p) { return p[1]; }
|
||||
+int load_b(char *p) { return p[4]; }
|
||||
+
|
||||
+// CHECK-LABEL: _load_i:
|
||||
+// CHECK: ADDI 32, A{{[0-9]+}}
|
||||
+// CHECK-NOT: ADDI 4, A
|
||||
+// CHECK-LABEL: _load_h:
|
||||
+// CHECK: ADDI 16, A{{[0-9]+}}
|
||||
+// CHECK-LABEL: _load_b:
|
||||
+// CHECK: ADDI 32, A{{[0-9]+}}
|
||||
diff --git a/clang/test/CodeGen/TMS34010/bitaddr-o2.c b/clang/test/CodeGen/TMS34010/bitaddr-o2.c
|
||||
new file mode 100644
|
||||
index 000000000000..39b0f38ce948
|
||||
@@ -174,27 +533,255 @@ index 000000000000..39b0f38ce948
|
||||
+// CHECK-LABEL: _sumto:
|
||||
diff --git a/clang/test/CodeGen/TMS34010/bitaddr-static-vararg.c b/clang/test/CodeGen/TMS34010/bitaddr-static-vararg.c
|
||||
new file mode 100644
|
||||
index 000000000000..78aecf0a8424
|
||||
index 000000000000..fc6867b143b4
|
||||
--- /dev/null
|
||||
+++ b/clang/test/CodeGen/TMS34010/bitaddr-static-vararg.c
|
||||
@@ -0,0 +1,6 @@
|
||||
+// RUN: not %clang_cc1 -triple tms34010-unknown-none -O1 -emit-obj %s -o /dev/null 2>&1 | FileCheck %s
|
||||
+// RUN: not %clang_cc1 -triple tms34010-unknown-none -O2 -emit-obj %s -o /dev/null 2>&1 | FileCheck %s
|
||||
+// RUN: %clang_cc1 -triple tms34010-unknown-none -O0 -emit-obj %s -o /dev/null
|
||||
+// CHECK: static variadic definition 'sum' loses its '...' arguments
|
||||
+// CHECK: static variadic definition 'sum' loses its '...' arguments when optimizing
|
||||
+static int sum(int n, ...) { int *p = &n; return p[0] + p[1]; }
|
||||
+int call(void) { return sum(1, 2); }
|
||||
diff --git a/clang/test/CodeGen/TMS34010/float-const-o2.c b/clang/test/CodeGen/TMS34010/float-const-o2.c
|
||||
new file mode 100644
|
||||
index 000000000000..4f244591b61a
|
||||
--- /dev/null
|
||||
+++ b/clang/test/CodeGen/TMS34010/float-const-o2.c
|
||||
@@ -0,0 +1,26 @@
|
||||
+// RUN: %clang_cc1 -triple tms34010-unknown-none -O2 -mllvm -replexitval=never -S -o - %s | FileCheck %s
|
||||
+//
|
||||
+// A float literal stored to memory through a union (or returned by a helper
|
||||
+// whose constant result IPSCCP propagates) must be materialised from a
|
||||
+// GSP-initialised global. The early float-constant protection keeps the
|
||||
+// constant a load before the optimizer can fold it through the union bitcast
|
||||
+// to its IEEE bits; the AsmPrinter then emits the GSP words.
|
||||
+
|
||||
+typedef unsigned int u32;
|
||||
+typedef union { float f; u32 u; } fu;
|
||||
+extern volatile u32 markers[];
|
||||
+
|
||||
+static void mark_f(u32 n, float v) { fu x; x.f = v; markers[n] = x.u; }
|
||||
+float fnegzero(void) { return -0.0f; }
|
||||
+
|
||||
+void run(void) {
|
||||
+ mark_f(0, 7.0f); // GSP 41700000h, never IEEE 40E00000h
|
||||
+ mark_f(1, fnegzero()); // GSP +0, never IEEE -0 (80000000h)
|
||||
+}
|
||||
+
|
||||
+// 7.0f is GSP 41700000h and -0.0f canonicalises to +0 (all zeroes); the IEEE
|
||||
+// bits (40E00000h / 80000000h) must never be stored anywhere.
|
||||
+// CHECK-DAG: .long 41700000h
|
||||
+// CHECK-DAG: .long 00000000h
|
||||
+// CHECK-NOT: .long 40E00000h
|
||||
+// CHECK-NOT: .long 80000000h
|
||||
diff --git a/clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c b/clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c
|
||||
new file mode 100644
|
||||
index 000000000000..9a1512116c74
|
||||
--- /dev/null
|
||||
+++ b/clang/test/CodeGen/TMS34010/m12-inline-asm-mem.c
|
||||
@@ -0,0 +1,19 @@
|
||||
+// RUN: %clang_cc1 -triple tms34010-unknown-none -O0 -S -o - %s | FileCheck %s
|
||||
+// RUN: %clang_cc1 -triple tms34010-unknown-none -O2 -S -o - %s | FileCheck %s
|
||||
+//
|
||||
+// M12: an `m` operand is a memory operand the backend can now address. The
|
||||
+// asm template is empty, so the bar is that the selector finds a valid
|
||||
+// TMS34010 address for the operand instead of the M9 named error; the
|
||||
+// addressing form itself is covered by m12-inline-asm-mem-forms.ll.
|
||||
+int load_via_asm(int *p) {
|
||||
+ int x;
|
||||
+ __asm__ volatile("" : "=r"(x) : "m"(*p) : "memory");
|
||||
+ return x;
|
||||
+}
|
||||
+int store_via_asm(int *p, int v) {
|
||||
+ __asm__ volatile("" : : "m"(*p), "r"(v) : "memory");
|
||||
+ return v;
|
||||
+}
|
||||
+// CHECK-LABEL: _load_via_asm:
|
||||
+// CHECK-NOT: error:
|
||||
+// CHECK-LABEL: _store_via_asm:
|
||||
diff --git a/clang/test/CodeGen/TMS34010/m12-inline-asm-st.c b/clang/test/CodeGen/TMS34010/m12-inline-asm-st.c
|
||||
new file mode 100644
|
||||
index 000000000000..ca1f041f709d
|
||||
--- /dev/null
|
||||
+++ b/clang/test/CodeGen/TMS34010/m12-inline-asm-st.c
|
||||
@@ -0,0 +1,11 @@
|
||||
+// RUN: %clang_cc1 -triple tms34010-unknown-none -O0 -S -o - %s | FileCheck %s
|
||||
+//
|
||||
+// M12: `st` names the status register as a clobber. Before M12 clang rejected
|
||||
+// the name ("unknown register name 'st' in asm") because getGCCRegNames()
|
||||
+// listed only the A/B files. ST stays out of every register class and out of
|
||||
+// the operand constraints, so this only makes the clobber nameable.
|
||||
+int clobber_st(int x) {
|
||||
+ __asm__ volatile("" : "+r"(x) : : "st");
|
||||
+ return x;
|
||||
+}
|
||||
+// CHECK-LABEL: _clobber_st:
|
||||
diff --git a/clang/test/Driver/TMS34010-link.c b/clang/test/Driver/TMS34010-link.c
|
||||
new file mode 100644
|
||||
index 000000000000..3b067d9eb3b6
|
||||
--- /dev/null
|
||||
+++ b/clang/test/Driver/TMS34010-link.c
|
||||
@@ -0,0 +1,147 @@
|
||||
+// Check that the TMS34010 driver discovers its sysroot and turns a link into a
|
||||
+// real tms-link job, and that the link-reduction knobs, -g and -Wl, behave.
|
||||
+//
|
||||
+// The link cases below use a fake sysroot so the test is hermetic and does
|
||||
+// not depend on `scripts/tms-sdk` having been run: the CRT and the three
|
||||
+// libraries are empty placeholders under <sysroot>/lib, and the linker is the
|
||||
+// touched placeholder under <sysroot>/bin.
|
||||
+
|
||||
+// RUN: rm -rf %t.sysroot && mkdir -p %t.sysroot/bin %t.sysroot/lib %t.sysroot/include
|
||||
+// RUN: touch %t.sysroot/bin/tms-link %t.sysroot/lib/crt0.o %t.sysroot/lib/libtms.a %t.sysroot/lib/flib.lib %t.sysroot/lib/rts.lib
|
||||
+
|
||||
+// Default link: the sysroot linker, the fixed flags, the CRT, the object and
|
||||
+// the three default libraries, plus the sysroot include path and a default map.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot %s -o %t.out 2>&1 | FileCheck %s --check-prefix=DEFAULT
|
||||
+// DEFAULT: "-internal-isystem" "{{.*}}sysroot{{/|\\}}include"
|
||||
+// DEFAULT: "{{.*}}tms-link"
|
||||
+// DEFAULT-SAME: "-o" "{{.*}}.out"
|
||||
+// DEFAULT-SAME: "--entry" "_start"
|
||||
+// DEFAULT-SAME: "--text" "018A0000"
|
||||
+// DEFAULT-SAME: "--bss" "01A00000"
|
||||
+// DEFAULT-SAME: "--prog-len" "40000h"
|
||||
+// DEFAULT-SAME: "--ram-len" "80000h"
|
||||
+// DEFAULT-SAME: "--map" "{{.*}}.out.map"
|
||||
+// DEFAULT-SAME: crt0.o
|
||||
+// DEFAULT-SAME: libtms.a
|
||||
+// DEFAULT-SAME: flib.lib
|
||||
+// DEFAULT-SAME: rts.lib
|
||||
+// DEFAULT-SAME: "-L" "{{.*}}sysroot{{/|\\}}lib"
|
||||
+
|
||||
+// -nostdlib drops the CRT and all three libraries.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -nostdlib %s -o %t.out 2>&1 | FileCheck %s --check-prefix=NOSTDLIB
|
||||
+// NOSTDLIB: "{{.*}}tms-link"
|
||||
+// NOSTDLIB-NOT: crt0.o
|
||||
+// NOSTDLIB-NOT: libtms.a
|
||||
+// NOSTDLIB-NOT: flib.lib
|
||||
+// NOSTDLIB-NOT: rts.lib
|
||||
+
|
||||
+// -nostartfiles drops only the CRT; the libraries remain.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -nostartfiles %s -o %t.out 2>&1 | FileCheck %s --check-prefix=NOSTART
|
||||
+// NOSTART: "{{.*}}tms-link"
|
||||
+// NOSTART-NOT: crt0.o
|
||||
+// NOSTART-SAME: libtms.a
|
||||
+// NOSTART-SAME: flib.lib
|
||||
+// NOSTART-SAME: rts.lib
|
||||
+
|
||||
+// -nodefaultlibs keeps the CRT but drops the three libraries.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -nodefaultlibs %s -o %t.out 2>&1 | FileCheck %s --check-prefix=NODEFLTLIBS
|
||||
+// NODEFLTLIBS: "{{.*}}tms-link"
|
||||
+// NODEFLTLIBS-SAME: crt0.o
|
||||
+// NODEFLTLIBS-NOT: libtms.a
|
||||
+// NODEFLTLIBS-NOT: flib.lib
|
||||
+// NODEFLTLIBS-NOT: rts.lib
|
||||
+
|
||||
+// With -nodefaultlibs, -l tms is the user's only way to ask for the archive;
|
||||
+// it must resolve to libtms.a exactly once, with no flib/rts.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -nodefaultlibs -l tms %s -o %t.out 2>&1 | FileCheck %s --check-prefix=NODEFL_LTMS
|
||||
+// NODEFL_LTMS: "{{.*}}tms-link"
|
||||
+// NODEFL_LTMS-SAME: crt0.o
|
||||
+// NODEFL_LTMS-SAME: libtms.a
|
||||
+// NODEFL_LTMS-NOT: libtms.a
|
||||
+// NODEFL_LTMS-NOT: flib.lib
|
||||
+// NODEFL_LTMS-NOT: rts.lib
|
||||
+// NODEFL_LTMS-NOT: "-l" "tms"
|
||||
+
|
||||
+// -g adds --keep-debug.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -g %s -o %t.out 2>&1 | FileCheck %s --check-prefix=G
|
||||
+// G: "{{.*}}tms-link"
|
||||
+// G-SAME: "--keep-debug"
|
||||
+
|
||||
+// -g0 and -ggdb0 request no debug info, so no --keep-debug.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -g0 %s -o %t.out 2>&1 | FileCheck %s --check-prefix=G0
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -ggdb0 %s -o %t.out 2>&1 | FileCheck %s --check-prefix=G0
|
||||
+// G0: "{{.*}}tms-link"
|
||||
+// G0-NOT: "--keep-debug"
|
||||
+
|
||||
+// -Wl, arguments pass through verbatim.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -Wl,--prog-len=80000h %s -o %t.out 2>&1 | FileCheck %s --check-prefix=WL
|
||||
+// WL: "{{.*}}tms-link"
|
||||
+// WL-SAME: "--prog-len=80000h"
|
||||
+
|
||||
+// -Wl,-Map=<file> selects that map file and suppresses the default --map.
|
||||
+// The NOT range starts at the linker token so a stray default map (which
|
||||
+// would be emitted before the translated --map=) is caught too.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -Wl,-Map=foo.map %s -o %t.out 2>&1 | FileCheck %s --check-prefix=MAPEQ
|
||||
+// MAPEQ: "{{.*}}tms-link"
|
||||
+// MAPEQ-NOT: "--map" "{{.*}}.out.map"
|
||||
+// MAPEQ: "--map=foo.map"
|
||||
+// MAPEQ-NOT: "foo.map"
|
||||
+
|
||||
+// -Wl,-Map,<file> (the comma form) consumes the next element as the map path
|
||||
+// instead of forwarding the filename as a linker input.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -Wl,-Map,foo.map %s -o %t.out 2>&1 | FileCheck %s --check-prefix=MAPCOMMA
|
||||
+// MAPCOMMA: "{{.*}}tms-link"
|
||||
+// MAPCOMMA-NOT: "--map" "{{.*}}.out.map"
|
||||
+// MAPCOMMA: "--map=foo.map"
|
||||
+// MAPCOMMA-NOT: "foo.map"
|
||||
+
|
||||
+// --tms-linker=PATH replaces the sysroot linker.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot --tms-linker=/tmp/x %s -o %t.out 2>&1 | FileCheck %s --check-prefix=LINKER
|
||||
+// LINKER: "/tmp/x"
|
||||
+// LINKER-SAME: "--entry" "_start"
|
||||
+
|
||||
+// -l tms is accepted and does not duplicate libtms.a.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -l tms %s -o %t.out 2>&1 | FileCheck %s --check-prefix=LTMS
|
||||
+// LTMS: "{{.*}}tms-link"
|
||||
+// LTMS-SAME: libtms.a
|
||||
+// LTMS-NOT: "-l" "tms"
|
||||
+
|
||||
+// A nonexistent sysroot is a named diagnostic, not a link error.
|
||||
+// RUN: not %clang -### --target=tms34010 --tms-sysroot=/nope %s -o %t.out 2>&1 | FileCheck %s --check-prefix=NOSYSROOT
|
||||
+// NOSYSROOT: error: TMS34010 sysroot not found
|
||||
+// NOSYSROOT-SAME: run 'scripts/tms-sdk'
|
||||
+// NOSYSROOT-NOT: "tms-link"
|
||||
+
|
||||
+// A sysroot without bin/tms-link is a named diagnostic, not a link error.
|
||||
+// RUN: rm -rf %t.nolink && mkdir -p %t.nolink
|
||||
+// RUN: not %clang -### --target=tms34010 --tms-sysroot=%t.nolink %s -o %t.out 2>&1 | FileCheck %s --check-prefix=NOLINKER
|
||||
+// NOLINKER: error: TMS34010 linker not found
|
||||
+// NOLINKER-SAME: run 'scripts/tms-sdk'
|
||||
+// NOLINKER-NOT: "tms-link"
|
||||
+
|
||||
+// A sysroot directory that exists but lacks the artifacts the default link
|
||||
+// needs names each missing file and points at scripts/tms-sdk, instead of
|
||||
+// handing tms-link bare names.
|
||||
+// RUN: rm -rf %t.partial && mkdir -p %t.partial/bin %t.partial/lib %t.partial/include
|
||||
+// RUN: touch %t.partial/bin/tms-link
|
||||
+// RUN: not %clang -### --target=tms34010 --tms-sysroot=%t.partial %s -o %t.out 2>&1 | FileCheck %s --check-prefix=PARTIAL
|
||||
+// PARTIAL-DAG: error: TMS34010 sysroot is incomplete: '{{.*}}crt0.o' is missing
|
||||
+// PARTIAL-DAG: error: TMS34010 sysroot is incomplete: '{{.*}}libtms.a' is missing
|
||||
+// PARTIAL-DAG: error: TMS34010 sysroot is incomplete: '{{.*}}flib.lib' is missing
|
||||
+// PARTIAL-DAG: error: TMS34010 sysroot is incomplete: '{{.*}}rts.lib' is missing
|
||||
+// PARTIAL-DAG: run 'scripts/tms-sdk'
|
||||
+
|
||||
+// With -nostdlib nothing is needed from the sysroot's lib directory, so the
|
||||
+// same partial sysroot still reaches the (placeholder) linker.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.partial -nostdlib %s -o %t.out 2>&1 | FileCheck %s --check-prefix=PARTIALNOSTDLIB
|
||||
+// PARTIALNOSTDLIB: "{{.*}}tms-link"
|
||||
+// PARTIALNOSTDLIB-NOT: sysroot is incomplete
|
||||
+
|
||||
+// Compile-only modes emit no link job.
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -c %s 2>&1 | FileCheck %s --check-prefix=NOLINK
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -S %s 2>&1 | FileCheck %s --check-prefix=NOLINK
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -E %s 2>&1 | FileCheck %s --check-prefix=NOLINK
|
||||
+// RUN: %clang -### --target=tms34010 --tms-sysroot=%t.sysroot -S -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=NOLINK
|
||||
+// NOLINK-NOT: tms-link
|
||||
+
|
||||
+int f(int n) { return n + 1; }
|
||||
diff --git a/clang/test/Driver/tms34010-defaults.c b/clang/test/Driver/tms34010-defaults.c
|
||||
new file mode 100644
|
||||
index 000000000000..670b094fd7bb
|
||||
index 000000000000..568a4a0b3434
|
||||
--- /dev/null
|
||||
+++ b/clang/test/Driver/tms34010-defaults.c
|
||||
@@ -0,0 +1,8 @@
|
||||
@@ -0,0 +1,9 @@
|
||||
+// RUN: %clang -### --target=tms34010 -c %s 2>&1 | FileCheck %s --check-prefix=FLAGS
|
||||
+// RUN: %clang -### --target=tms34010 -c %s 2>&1 | FileCheck %s --check-prefix=NOSYS
|
||||
+// FLAGS: "-cc1" {{.*}}-ffreestanding
|
||||
+// FLAGS-SAME: -fno-builtin
|
||||
+// FLAGS-SAME: "-mllvm" "-replexitval=never"
|
||||
+// FLAGS-SAME: "-disable-O0-optnone"
|
||||
+// NOSYS-NOT: "-internal-isystem"
|
||||
+// NOSYS: "-internal-isystem" "{{.*}}tms34010-unknown-none{{/|\\}}include"
|
||||
+// NOSYS-NOT: "-internal-isystem" "/usr/"
|
||||
+int f(int n) { return n + 1; }
|
||||
@@ -31,7 +31,7 @@ LLC=${LLC:-$LLVM_BIN/llc}
|
||||
FILECHECK=${FILECHECK:-$LLVM_BIN/FileCheck}
|
||||
LEGACY=$ROOT/scripts/tests/m10/legacy-tms-clang
|
||||
WORK=${M10_EQUIV_WORK:-$ROOT/build/m10-equivalence}
|
||||
INC=$ROOT/scripts/tests/m5/conformance/include
|
||||
INC=$ROOT/sdk/include
|
||||
|
||||
# The frozen legacy script derives its ROOT from its own path
|
||||
# (scripts/tests/m10), so its default tool paths are wrong. Point it at the real
|
||||
@@ -63,8 +63,8 @@ corpus() {
|
||||
*) printf '%s\n' "$f" ;;
|
||||
esac
|
||||
done
|
||||
printf '%s\n' "$ROOT/scripts/tests/m5/conformance/shim.c"
|
||||
printf '%s\n' "$ROOT/scripts/tests/m5/conformance/heap.c"
|
||||
printf '%s\n' "$ROOT/sdk/shim.c"
|
||||
printf '%s\n' "$ROOT/sdk/heap.c"
|
||||
}
|
||||
|
||||
# compare_mode MODE -- compile every corpus file native vs legacy and cmp.
|
||||
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
#!/bin/sh
|
||||
# M11 Task 2 gate: the CRT built with llc, linked and run end to end.
|
||||
#
|
||||
# scripts/tests/m11/crt.sh
|
||||
#
|
||||
# Builds sdk/crt0.ll with llc -march=tms34010 -filetype=obj (the TI-COFF
|
||||
# object path; llvm-mc's MC path emits ELF, which tms-link cannot read),
|
||||
# compiles a heredoc main.c and the existing conformance shim with
|
||||
# clang --target=tms34010 -O2 -c, links everything with tools/tms-link, and
|
||||
# runs the image with scripts/tms-run. The CRT contract is the result block
|
||||
# the conformance shim and tms-run already share: main returns 7, so the run
|
||||
# must report `status: 7` and stdout exactly `1 conformance`
|
||||
# (argv = { "conformance", NULL }). It also pins the CRT object size and
|
||||
# asserts the emitted `_start` has no frame prologue before its inline-asm
|
||||
# block (the `naked` attribute must survive).
|
||||
#
|
||||
# Overridable: LLVM_BIN CLANG LLC TMS_LINK M11_CRT_WORK
|
||||
set -eu
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
|
||||
LLVM_BIN=${LLVM_BIN:-$ROOT/build/llvm-clean-build/bin}
|
||||
CLANG=${CLANG:-$LLVM_BIN/clang}
|
||||
LLC=${LLC:-$LLVM_BIN/llc}
|
||||
TMS_LINK=${TMS_LINK:-$ROOT/tools/tms-link/tms-link}
|
||||
WORK=${M11_CRT_WORK:-$ROOT/build/m11-crt}
|
||||
|
||||
CRT0=$ROOT/sdk/crt0.ll
|
||||
SHIM=$ROOT/sdk/shim.c
|
||||
CONF_INCLUDE=$ROOT/sdk/include
|
||||
# The shim's %f path pulls FD$* float-library symbols; link the committed
|
||||
# 1990 flib/rts archives from sdk/lib (the same files a production install
|
||||
# places in <sysroot>/lib) to satisfy them.
|
||||
FLIB=$ROOT/sdk/lib/flib.lib
|
||||
RTS=$ROOT/sdk/lib/rts.lib
|
||||
|
||||
fail() {
|
||||
echo "m11 crt: FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
for tool in "$CLANG" "$LLC"; do
|
||||
[ -x "$tool" ] || fail "missing tool: $tool"
|
||||
done
|
||||
[ -x "$TMS_LINK" ] || fail "missing linker: $TMS_LINK"
|
||||
[ -f "$CRT0" ] || fail "missing CRT source: $CRT0"
|
||||
[ -f "$SHIM" ] || fail "missing conformance shim: $SHIM"
|
||||
[ -f "$FLIB" ] || fail "missing flib.lib: $FLIB"
|
||||
[ -f "$RTS" ] || fail "missing rts.lib: $RTS"
|
||||
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK"
|
||||
|
||||
echo "== build $CRT0 with llc (TI-COFF object)"
|
||||
"$LLC" -march=tms34010 -filetype=obj "$CRT0" -o "$WORK/crt0.o" \
|
||||
|| fail "llc could not build $CRT0"
|
||||
python3 - "$WORK/crt0.o" <<'PY' || fail "crt0.o is not TI-COFF"
|
||||
import sys
|
||||
|
||||
data = open(sys.argv[1], "rb").read()
|
||||
if len(data) < 2 or data[:2] != b"\x90\x00":
|
||||
sys.exit("first two bytes are %r, want the TI-COFF magic 90 00"
|
||||
% (data[:2],))
|
||||
print(" crt0.o: %d bytes, TI-COFF magic 90 00" % len(data))
|
||||
PY
|
||||
|
||||
# Pin the CRT's size: the naked _start's code must not grow a frame.
|
||||
SIZE=$(wc -c < "$WORK/crt0.o")
|
||||
[ "$SIZE" -eq 540 ] \
|
||||
|| fail "crt0.o size changed: $SIZE bytes (want the pinned 540)"
|
||||
|
||||
echo "== check _start has no prologue before its inline-asm block"
|
||||
"$LLC" -march=tms34010 -filetype=asm "$CRT0" -o "$WORK/crt0.s" \
|
||||
|| fail "llc could not emit assembly for $CRT0"
|
||||
# Everything from the _start label up to the first inline-asm block (;APP).
|
||||
awk '/^_start:/{f=1} f&&/;APP/{exit} f' "$WORK/crt0.s" > "$WORK/start-pre.s"
|
||||
# A non-naked function starts with the frame setup (push A13, save registers,
|
||||
# point A14 past the frame). Any of those before the asm block means the
|
||||
# `naked` attribute was lost.
|
||||
if grep -Eq 'MMTM[[:space:]]+SP|MOVE[[:space:]]+A13,[[:space:]]*-\*SP|ADDI[[:space:]]+-?[0-9]+,[[:space:]]*A14' "$WORK/start-pre.s"; then
|
||||
fail "naked _start gained a frame prologue: $(tr '\n' ' ' < "$WORK/start-pre.s")"
|
||||
fi
|
||||
|
||||
cat > "$WORK/main.c" <<'EOF'
|
||||
int main(int argc, char **argv) { printf("%d %s\n", argc, argv[0]); return 7; }
|
||||
EOF
|
||||
|
||||
echo "== compile main.c and shim.c"
|
||||
# The heredoc main.c calls printf without a declaration; force-include the
|
||||
# conformance stdio.h so it compiles as written.
|
||||
"$CLANG" --target=tms34010 -O2 -c -include stdio.h -I "$CONF_INCLUDE" \
|
||||
"$WORK/main.c" -o "$WORK/main.o" \
|
||||
|| fail "clang -c main.c failed"
|
||||
"$CLANG" --target=tms34010 -O2 -c "$SHIM" -o "$WORK/shim.o" \
|
||||
|| fail "clang -c shim.c failed"
|
||||
|
||||
echo "== link with tms-link"
|
||||
"$TMS_LINK" -o "$WORK/crt.coff" --entry _start \
|
||||
--text 018A0000 --bss 01A00000 --prog-len 40000h --ram-len 80000h \
|
||||
"$WORK/crt0.o" "$WORK/main.o" "$WORK/shim.o" "$FLIB" "$RTS" \
|
||||
|| fail "tms-link failed"
|
||||
|
||||
echo "== run with tms-run"
|
||||
# tms-run exits nonzero for a nonzero status (it is built for status 0), so
|
||||
# capture its stdout and check the contract ourselves.
|
||||
"$ROOT/scripts/tms-run" "$WORK/crt.coff" > "$WORK/run.out" 2> "$WORK/run.err" \
|
||||
|| true
|
||||
if [ -s "$WORK/run.err" ]; then
|
||||
cat "$WORK/run.err" >&2
|
||||
fail "tms-run failed (see stderr above)"
|
||||
fi
|
||||
|
||||
python3 - "$WORK/run.out" <<'PY' || fail "contract check failed"
|
||||
import sys
|
||||
|
||||
data = open(sys.argv[1], "rb").read()
|
||||
fields = {}
|
||||
for line in data.split(b"\n"):
|
||||
for key in (b"status: ", b"magic: "):
|
||||
if line.startswith(key):
|
||||
fields[key] = line[len(key):].split(b" ", 1)[0]
|
||||
|
||||
status = fields.get(b"status: ")
|
||||
magic = fields.get(b"magic: ")
|
||||
if status != b"7":
|
||||
sys.exit("expected `status: 7`, got %r (full output: %r)"
|
||||
% (status, data))
|
||||
if magic != b"434F4E46":
|
||||
sys.exit("expected `magic: 434F4E46`, got %r (full output: %r)"
|
||||
% (magic, data))
|
||||
|
||||
marker = b"stdout:\n"
|
||||
if marker not in data:
|
||||
sys.exit("tms-run printed no stdout (full output: %r)" % (data,))
|
||||
out = data.split(marker, 1)[1]
|
||||
# tms-run appends a newline when the captured stream did not end with one;
|
||||
# the contract is the 12 bytes `1 conformance` with no trailing newline.
|
||||
if out.endswith(b"\n"):
|
||||
out = out[:-1]
|
||||
if out != b"1 conformance":
|
||||
sys.exit("stdout is not exactly `1 conformance` (got %r, full output: %r)"
|
||||
% (out, data))
|
||||
|
||||
sys.stdout.write(" status 7, magic 434F4E46, stdout `1 conformance`\n")
|
||||
PY
|
||||
|
||||
echo "m11 crt: PASS"
|
||||
Executable
+265
@@ -0,0 +1,265 @@
|
||||
#!/bin/sh
|
||||
# M11 Task 5 gate: the single-command build, end to end.
|
||||
#
|
||||
# scripts/tests/m11/e2e.sh
|
||||
#
|
||||
# The milestone's headline acceptance: after one `scripts/tms-sdk` (no
|
||||
# arguments), a plain `clang --target=tms34010 hello.c -o hello` from a
|
||||
# directory outside the repo links a loader-valid image that `tms-run`
|
||||
# executes, with no project variables and no sysroot flag. The isolated
|
||||
# sub-cases (two TUs, -I with a custom header and -L/-l with a user archive,
|
||||
# -c, -S, -E, -O0/-O2, -g vs stripped, -nostdlib with a
|
||||
# user _start, and the -### no-checkout-path assertion) run against a temp
|
||||
# sysroot installed with `scripts/tms-sdk --sysroot`, so the default
|
||||
# discovery path is exercised exactly once and nothing depends on a repo
|
||||
# source tree.
|
||||
#
|
||||
# The compiler, the installer and the runner are invoked through absolute
|
||||
# repo paths; the only environment the compile/link sees is a scrubbed one
|
||||
# (no M4_*/TMS_*/CPATH/LIBRARY_PATH/COMPILER_PATH), so PATH (which tms-link
|
||||
# needs to find python3) is the sole inherited convenience.
|
||||
#
|
||||
# Overridable: LLVM_BIN CLANG LLC LLVM_AR
|
||||
set -eu
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
|
||||
LLVM_BIN=${LLVM_BIN:-$ROOT/build/llvm-clean-build/bin}
|
||||
CLANG=${CLANG:-$LLVM_BIN/clang}
|
||||
LLC=${LLC:-$LLVM_BIN/llc}
|
||||
LLVM_AR=${LLVM_AR:-$LLVM_BIN/llvm-ar}
|
||||
TMS_SDK=$ROOT/scripts/tms-sdk
|
||||
TMS_RUN=$ROOT/scripts/tms-run
|
||||
|
||||
WORK=$(mktemp -d "${TMPDIR:-/tmp}/m11-e2e.XXXXXX")
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
SYSROOT=$WORK/sysroot
|
||||
|
||||
fail() {
|
||||
echo "m11 e2e: FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Scrub the environment the compile/link sees: the toolchain must need no
|
||||
# M4_*/TMS_* variable, no host include/library path and no tool-search
|
||||
# override. PATH survives (tms-link's shebang and the driver's python3
|
||||
# pre-flight both search it).
|
||||
clean() {
|
||||
env -u M4_WORK -u M4_SDK -u M4_COFF -u M4_SOURCES -u M4_ENTRY \
|
||||
-u M4_NATIVE -u M4_LINKER -u M4_SKIP_MAME -u M4_CLANG_OPT \
|
||||
-u M4_LLC_OPT -u M4_EXTRA_INCLUDES -u M4_EXTRA_CFLAGS \
|
||||
-u M4_NATIVE_PROG_LEN -u M4_NATIVE_RAM_LEN -u M4_NATIVE_LIBS \
|
||||
-u M4_OS2 -u M4_OS2_LX \
|
||||
-u TMS_CLANG -u TMS_LLC -u TMS_OPT -u TMS_BITADDR \
|
||||
-u TMS_CLANG_EXTRA_FLAGS -u TMS_LINKER \
|
||||
-u CLANG -u LLC -u LLVM_AR -u LLVM_BIN \
|
||||
-u CPATH -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
|
||||
-u OBJC_INCLUDE_PATH -u LIBRARY_PATH \
|
||||
-u COMPILER_PATH -u GCC_EXEC_PREFIX \
|
||||
"$@"
|
||||
}
|
||||
|
||||
# run_check IMAGE WANT DESC -- run the image with tms-run and assert the
|
||||
# result contract: status 0, magic 434F4E46, and stdout exactly WANT.
|
||||
run_check() {
|
||||
img=$1
|
||||
want=$2
|
||||
desc=$3
|
||||
"$TMS_RUN" "$img" > "$WORK/run.out" 2> "$WORK/run.err" \
|
||||
|| { cat "$WORK/run.err" >&2; fail "$desc: tms-run failed"; }
|
||||
python3 - "$WORK/run.out" "$want" <<'PY' || fail "$desc: output mismatch"
|
||||
import sys
|
||||
|
||||
data = open(sys.argv[1], "rb").read()
|
||||
want = sys.argv[2].encode()
|
||||
status = magic = None
|
||||
for line in data.split(b"\n"):
|
||||
if line.startswith(b"status: "):
|
||||
status = line[len(b"status: "):].split(b" ", 1)[0]
|
||||
elif line.startswith(b"magic: "):
|
||||
magic = line[len(b"magic: "):].split(b" ", 1)[0]
|
||||
if status != b"0":
|
||||
sys.exit("status %r != 0 (full: %r)" % (status, data))
|
||||
if magic != b"434F4E46":
|
||||
sys.exit("magic %r != 434F4E46 (full: %r)" % (magic, data))
|
||||
marker = b"stdout:\n"
|
||||
if want == b"":
|
||||
if marker in data:
|
||||
sys.exit("unexpected stdout in %r" % (data,))
|
||||
else:
|
||||
if marker not in data:
|
||||
sys.exit("no stdout marker in %r" % (data,))
|
||||
out = data.split(marker, 1)[1]
|
||||
if out.endswith(b"\n"):
|
||||
out = out[:-1]
|
||||
if out != want:
|
||||
sys.exit("stdout %r != want %r (full: %r)" % (out, want, data))
|
||||
PY
|
||||
}
|
||||
|
||||
[ -x "$TMS_SDK" ] || fail "missing installer: $TMS_SDK"
|
||||
[ -x "$TMS_RUN" ] || fail "missing runner: $TMS_RUN"
|
||||
for tool in "$CLANG" "$LLC" "$LLVM_AR"; do
|
||||
[ -x "$tool" ] || fail "missing tool: $tool"
|
||||
done
|
||||
|
||||
cd "$WORK"
|
||||
|
||||
# --- Part A: the headline command through the default discovery path ------
|
||||
# Install the real resource-dir sysroot (no --sysroot argument), then run the
|
||||
# plain command with no sysroot flag and no project environment.
|
||||
echo "== install the default resource-dir sysroot (tms-sdk, no arguments)"
|
||||
clean "$TMS_SDK" || fail "default tms-sdk install failed"
|
||||
|
||||
cat > hello.c <<'EOF'
|
||||
#include <stdio.h>
|
||||
int main(void) { printf("hello\n"); return 0; }
|
||||
EOF
|
||||
|
||||
echo "== clang --target=tms34010 hello.c -o hello (no flags, no env)"
|
||||
clean "$CLANG" --target=tms34010 hello.c -o hello \
|
||||
|| fail "headline command failed"
|
||||
[ -f hello ] || fail "headline command produced no image"
|
||||
[ -f hello.map ] || fail "headline command produced no hello.map"
|
||||
|
||||
run_check hello "hello" "headline" || fail "headline run failed"
|
||||
# The default link is stripped: the map has no .debug_* sections.
|
||||
grep -q '\.debug_' hello.map \
|
||||
&& fail "default link keeps .debug_* sections (should be stripped)" || true
|
||||
|
||||
# --- Part B: isolated sub-cases against a temp sysroot --------------------
|
||||
echo "== install a temp sysroot for the isolated sub-cases"
|
||||
clean "$TMS_SDK" --sysroot "$SYSROOT" || fail "temp sysroot install failed"
|
||||
|
||||
# 1. two TUs link and run.
|
||||
cat > add.c <<'EOF'
|
||||
int add(int a, int b) { return a + b; }
|
||||
EOF
|
||||
cat > main.c <<'EOF'
|
||||
#include <stdio.h>
|
||||
int add(int, int);
|
||||
int main(void) { printf("add=%d\n", add(20, 22)); return 0; }
|
||||
EOF
|
||||
echo "== two-TU link (add.c + main.c)"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" add.c main.c -o add42 \
|
||||
|| fail "two-TU link failed"
|
||||
run_check add42 "add=42" "two-TU" || fail "two-TU run failed"
|
||||
|
||||
# 1b. -I, -L and -l end to end: a header from a custom include directory and a
|
||||
# small user archive whose member main calls.
|
||||
mkdir -p inc libsrc libdir
|
||||
cat > inc/answer.h <<'EOF'
|
||||
#define ANSWER 42
|
||||
int user_answer(void);
|
||||
EOF
|
||||
cat > libsrc/user.c <<'EOF'
|
||||
#include "answer.h"
|
||||
int user_answer(void) { return ANSWER; }
|
||||
EOF
|
||||
cat > uselib.c <<'EOF'
|
||||
#include <stdio.h>
|
||||
#include "answer.h"
|
||||
int main(void) { printf("user=%d\n", user_answer()); return 0; }
|
||||
EOF
|
||||
echo "== -I header and -L/-l user archive"
|
||||
clean "$CLANG" --target=tms34010 -c -I inc libsrc/user.c -o user.o \
|
||||
|| fail "-I compile of the user library failed"
|
||||
clean "$LLVM_AR" rcsD libdir/libuser.a user.o \
|
||||
|| fail "building the user archive failed"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" \
|
||||
-I inc uselib.c -L libdir -l user -o uselib \
|
||||
|| fail "-I/-L/-l link failed"
|
||||
run_check uselib "user=42" "-I/-L/-l" || fail "-I/-L/-l run failed"
|
||||
|
||||
# 2. -c produces a TI-COFF object.
|
||||
echo "== -c (object)"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" -c hello.c -o hello.o \
|
||||
|| fail "-c failed"
|
||||
python3 - hello.o <<'PY' || fail "hello.o is not TI-COFF"
|
||||
import sys
|
||||
|
||||
data = open(sys.argv[1], "rb").read()
|
||||
if len(data) < 2 or data[:2] != b"\x90\x00":
|
||||
sys.exit("first two bytes are %r, want the TI-COFF magic 90 00"
|
||||
% (data[:2],))
|
||||
PY
|
||||
|
||||
# 3. -S produces GSPA assembly naming main and the printf call.
|
||||
echo "== -S (assembly)"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" -S hello.c -o hello.s \
|
||||
|| fail "-S failed"
|
||||
grep -q '_main' hello.s || fail "hello.s has no _main symbol"
|
||||
grep -q '_printf' hello.s || fail "hello.s has no _printf call"
|
||||
|
||||
# 4. -E produces preprocessed source (headers resolved, source present).
|
||||
echo "== -E (preprocessed)"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" -E hello.c -o hello.i \
|
||||
|| fail "-E failed"
|
||||
grep -q 'int printf(const char \*fmt, ...);' hello.i \
|
||||
|| fail "hello.i did not expand the stdio.h printf declaration"
|
||||
grep -q 'printf("hello\\n")' hello.i \
|
||||
|| fail "hello.i lost the hello.c source line"
|
||||
|
||||
# 5. -O0 and -O2 both run correctly.
|
||||
for opt in -O0 -O2; do
|
||||
tag=$(echo "$opt" | tr -d -)
|
||||
echo "== $opt"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" \
|
||||
"$opt" hello.c -o "hello_$tag" || fail "$opt link failed"
|
||||
run_check "hello_$tag" "hello" "$opt" || fail "$opt run failed"
|
||||
done
|
||||
|
||||
# 6. -g keeps the .debug_* sections in the linked image; the default link
|
||||
# (hello_O0/hello_O2 above, and hello in Part A) is stripped.
|
||||
echo "== -g keeps .debug_* (vs stripped default)"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" -g hello.c -o hello_g \
|
||||
|| fail "-g link failed"
|
||||
grep -q '\.debug_' hello_g.map || fail "-g link has no .debug_* sections"
|
||||
grep -q '\.debug_' hello_O0.map \
|
||||
&& fail "default link keeps .debug_* sections (should be stripped)" || true
|
||||
|
||||
# 7. -nostdlib drops the CRT and the user supplies _start.
|
||||
cat > nostdlib.c <<'EOF'
|
||||
/* On this target C globals gain a leading underscore, so a C function named
|
||||
* `start` lands on the `_start` symbol the link job uses as its entry. */
|
||||
__attribute__((naked)) void start(void) {
|
||||
__asm__ volatile(
|
||||
"setf 16, 1, 0\n\t"
|
||||
"setf 32, 0, 1\n\t"
|
||||
"movi 0x01B00000, a1\n\t"
|
||||
"sub a0, a0\n\t"
|
||||
"move a0, *a1, 1\n\t"
|
||||
"movi 0x01B00040, a1\n\t"
|
||||
"movi 0x434F4E46, a0\n\t"
|
||||
"move a0, *a1, 1\n"
|
||||
"1: jruc 1b\n\t");
|
||||
}
|
||||
EOF
|
||||
echo "== -nostdlib with a user _start"
|
||||
clean "$CLANG" --target=tms34010 --tms-sysroot="$SYSROOT" \
|
||||
-nostdlib nostdlib.c -o nostdlib_img || fail "-nostdlib link failed"
|
||||
grep -q '"_start"' nostdlib_img.map \
|
||||
|| fail "-nostdlib image has no _start entry"
|
||||
run_check nostdlib_img "" "-nostdlib" || fail "-nostdlib run failed"
|
||||
|
||||
# 8. -### must show the sysroot-derived linker/include/CRT/libraries and
|
||||
# never a repo source path (the driver shells out only to the installed
|
||||
# sysroot; it never bakes in the checkout's sdk/tools/scripts trees).
|
||||
echo "== -### contains no checkout path"
|
||||
clean "$CLANG" -### --target=tms34010 --tms-sysroot="$SYSROOT" hello.c -o hello \
|
||||
> "$WORK/verbose.txt" 2>&1
|
||||
grep -Fq "$SYSROOT/bin/tms-link" "$WORK/verbose.txt" \
|
||||
|| fail "-### does not invoke the sysroot linker"
|
||||
grep -Fq "$SYSROOT/include" "$WORK/verbose.txt" \
|
||||
|| fail "-### does not use the sysroot include path"
|
||||
for src in "$SYSROOT/lib/crt0.o" "$SYSROOT/lib/libtms.a" \
|
||||
"$SYSROOT/lib/flib.lib" "$SYSROOT/lib/rts.lib"; do
|
||||
grep -Fq "$src" "$WORK/verbose.txt" \
|
||||
|| fail "-### does not reference $src"
|
||||
done
|
||||
for leak in "$ROOT/sdk" "$ROOT/tools/tms-link" "$ROOT/scripts" \
|
||||
"$ROOT/build/m6-sdk"; do
|
||||
grep -Fq "$leak" "$WORK/verbose.txt" \
|
||||
&& fail "-### leaks a repo source path: $leak" || true
|
||||
done
|
||||
|
||||
echo "m11 e2e: PASS"
|
||||
Executable
+166
@@ -0,0 +1,166 @@
|
||||
#!/bin/sh
|
||||
# M11 Task 3 gate: the sysroot installer and its installed layout.
|
||||
#
|
||||
# scripts/tests/m11/sdk.sh
|
||||
#
|
||||
# Runs scripts/tms-sdk --sysroot "$TMP/sysroot" and asserts:
|
||||
# - the seven expected layout entries exist (include/, lib/{crt0.o,libtms.a,
|
||||
# flib.lib,rts.lib}, bin/{tms-link,tmscoff.py}) and every sdk/include/*.h
|
||||
# is installed;
|
||||
# - the installed tms-link is executable;
|
||||
# - `llvm-ar t libtms.a` lists exactly shim.o and heap.o;
|
||||
# - a second install is idempotent (crt0.o and libtms.a are byte-identical);
|
||||
# - the installed crt0.o matches a fresh llc build of sdk/crt0.ll;
|
||||
# - the installed libtms.a matches a fresh llvm-ar rcsD build of the same
|
||||
# shim.o/heap.o objects;
|
||||
# - the installed tms-link/tmscoff.py match tools/tms-link/*;
|
||||
# - a directory that is not an M11 sysroot (no marker) is refused before its
|
||||
# include/ is touched;
|
||||
# - reinstalling removes a header deleted from sdk/include;
|
||||
# - sdk/lib/{flib,rts}.lib match build/m6-sdk/{flib,rts}.lib when those exist
|
||||
# (otherwise the comparison prints SKIP (vendor tree absent)).
|
||||
#
|
||||
# Overridable: LLVM_BIN CLANG LLC LLVM_AR M11_SDK_WORK
|
||||
set -eu
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
|
||||
LLVM_BIN=${LLVM_BIN:-$ROOT/build/llvm-clean-build/bin}
|
||||
CLANG=${CLANG:-$LLVM_BIN/clang}
|
||||
LLC=${LLC:-$LLVM_BIN/llc}
|
||||
LLVM_AR=${LLVM_AR:-$LLVM_BIN/llvm-ar}
|
||||
TMS_SDK=$ROOT/scripts/tms-sdk
|
||||
WORK=${M11_SDK_WORK:-$ROOT/build/m11-sdk}
|
||||
SYSROOT=$WORK/sysroot
|
||||
# A temporary header used to prove that a reinstall removes deleted headers.
|
||||
EXTRA_HEADER=$ROOT/sdk/include/zz-m11-sdk-gate.h
|
||||
|
||||
fail() {
|
||||
echo "m11 sdk: FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -f "$EXTRA_HEADER"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
[ -x "$TMS_SDK" ] || fail "missing installer: $TMS_SDK"
|
||||
for tool in "$CLANG" "$LLC" "$LLVM_AR"; do
|
||||
[ -x "$tool" ] || fail "missing tool: $tool"
|
||||
done
|
||||
[ -f "$ROOT/sdk/crt0.ll" ] || fail "missing CRT source: $ROOT/sdk/crt0.ll"
|
||||
[ -f "$ROOT/sdk/shim.c" ] || fail "missing shim source: $ROOT/sdk/shim.c"
|
||||
[ -f "$ROOT/sdk/heap.c" ] || fail "missing heap source: $ROOT/sdk/heap.c"
|
||||
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK"
|
||||
|
||||
# A non-empty directory without the install marker is not ours to overwrite.
|
||||
echo "== refuse a non-M11 sysroot directory"
|
||||
FOREIGN=$WORK/foreign
|
||||
mkdir -p "$FOREIGN/include"
|
||||
echo keep > "$FOREIGN/include/keepme.h"
|
||||
if "$TMS_SDK" --sysroot "$FOREIGN" > "$WORK/foreign.log" 2>&1; then
|
||||
fail "tms-sdk overwrote a directory that is not an M11 sysroot"
|
||||
fi
|
||||
grep -q "not an M11 sysroot" "$WORK/foreign.log" \
|
||||
|| fail "refusal did not explain that the directory is not an M11 sysroot"
|
||||
[ -f "$FOREIGN/include/keepme.h" ] \
|
||||
|| fail "refused install deleted include/keepme.h"
|
||||
[ ! -e "$FOREIGN/.tms-sdk" ] \
|
||||
|| fail "refused install wrote an install marker"
|
||||
|
||||
echo "== install to $SYSROOT"
|
||||
"$TMS_SDK" --sysroot "$SYSROOT" || fail "first install failed"
|
||||
|
||||
# 1. the seven layout entries.
|
||||
for f in \
|
||||
"$SYSROOT/lib/crt0.o" \
|
||||
"$SYSROOT/lib/libtms.a" \
|
||||
"$SYSROOT/lib/flib.lib" \
|
||||
"$SYSROOT/lib/rts.lib" \
|
||||
"$SYSROOT/bin/tms-link" \
|
||||
"$SYSROOT/bin/tmscoff.py"; do
|
||||
[ -f "$f" ] || fail "missing installed file: $f"
|
||||
done
|
||||
[ -d "$SYSROOT/include" ] || fail "missing installed include directory"
|
||||
[ -x "$SYSROOT/bin/tms-link" ] || fail "installed tms-link is not executable"
|
||||
[ -f "$SYSROOT/.tms-sdk" ] || fail "missing install marker: $SYSROOT/.tms-sdk"
|
||||
for h in "$ROOT"/sdk/include/*.h; do
|
||||
[ -f "$SYSROOT/include/$(basename "$h")" ] \
|
||||
|| fail "missing installed header: $(basename "$h")"
|
||||
done
|
||||
|
||||
# The installed linker pair must be the project sources (a real
|
||||
# installed-vs-source check, not a copy of the destination onto itself).
|
||||
cmp "$SYSROOT/bin/tms-link" "$ROOT/tools/tms-link/tms-link" \
|
||||
|| fail "installed tms-link differs from tools/tms-link/tms-link"
|
||||
cmp "$SYSROOT/bin/tmscoff.py" "$ROOT/tools/tms-link/tmscoff.py" \
|
||||
|| fail "installed tmscoff.py differs from tools/tms-link/tmscoff.py"
|
||||
|
||||
# 2. libtms.a members are exactly shim.o and heap.o.
|
||||
"$LLVM_AR" t "$SYSROOT/lib/libtms.a" > "$WORK/ar-t.txt" \
|
||||
|| fail "llvm-ar t libtms.a failed"
|
||||
for m in shim.o heap.o; do
|
||||
grep -qx "$m" "$WORK/ar-t.txt" || fail "libtms.a has no $m member"
|
||||
done
|
||||
if [ "$(wc -l < "$WORK/ar-t.txt")" -ne 2 ]; then
|
||||
fail "libtms.a has unexpected members: $(tr '\n' ' ' < "$WORK/ar-t.txt")"
|
||||
fi
|
||||
|
||||
# Snapshot the build outputs before the idempotency re-install.
|
||||
cp "$SYSROOT/lib/crt0.o" "$WORK/crt0.first.o"
|
||||
cp "$SYSROOT/lib/libtms.a" "$WORK/libtms.first.a"
|
||||
|
||||
# 3. a second install is idempotent (byte-identical rebuilds), and a third
|
||||
# install after deleting a source header removes the stale installed one.
|
||||
echo "== re-install (idempotency)"
|
||||
printf '/* gate-only header */\n' > "$EXTRA_HEADER"
|
||||
"$TMS_SDK" --sysroot "$SYSROOT" || fail "second install failed"
|
||||
cmp "$SYSROOT/lib/crt0.o" "$WORK/crt0.first.o" \
|
||||
|| fail "crt0.o changed across reinstall"
|
||||
cmp "$SYSROOT/lib/libtms.a" "$WORK/libtms.first.a" \
|
||||
|| fail "libtms.a changed across reinstall"
|
||||
[ -f "$SYSROOT/include/$(basename "$EXTRA_HEADER")" ] \
|
||||
|| fail "install did not copy $(basename "$EXTRA_HEADER")"
|
||||
|
||||
echo "== re-install after deleting a header (stale header removal)"
|
||||
rm -f "$EXTRA_HEADER"
|
||||
"$TMS_SDK" --sysroot "$SYSROOT" || fail "third install failed"
|
||||
[ ! -e "$SYSROOT/include/$(basename "$EXTRA_HEADER")" ] \
|
||||
|| fail "stale header survived a reinstall: $(basename "$EXTRA_HEADER")"
|
||||
|
||||
# 4. the installed crt0.o matches a fresh llc build.
|
||||
echo "== fresh crt0.o (llc)"
|
||||
"$LLC" -march=tms34010 -filetype=obj "$ROOT/sdk/crt0.ll" -o "$WORK/crt0.fresh.o" \
|
||||
|| fail "fresh llc build of sdk/crt0.ll failed"
|
||||
cmp "$SYSROOT/lib/crt0.o" "$WORK/crt0.fresh.o" \
|
||||
|| fail "installed crt0.o differs from a fresh llc build"
|
||||
|
||||
# 5. the installed libtms.a matches a fresh llvm-ar rcsD build.
|
||||
echo "== fresh libtms.a (llvm-ar rcsD)"
|
||||
"$CLANG" --target=tms34010 -O2 -c -I "$ROOT/sdk/include" \
|
||||
"$ROOT/sdk/shim.c" -o "$WORK/shim.o" || fail "fresh shim.o build failed"
|
||||
"$CLANG" --target=tms34010 -O2 -c -I "$ROOT/sdk/include" \
|
||||
"$ROOT/sdk/heap.c" -o "$WORK/heap.o" || fail "fresh heap.o build failed"
|
||||
( cd "$WORK" && "$LLVM_AR" rcsD libtms.fresh.a shim.o heap.o ) \
|
||||
|| fail "fresh llvm-ar build failed"
|
||||
cmp "$SYSROOT/lib/libtms.a" "$WORK/libtms.fresh.a" \
|
||||
|| fail "installed libtms.a differs from a fresh llvm-ar build"
|
||||
|
||||
# 6. the committed vendor archives match the extracted originals.
|
||||
echo "== vendor archive comparison"
|
||||
if [ -f "$ROOT/build/m6-sdk/flib.lib" ]; then
|
||||
cmp "$ROOT/sdk/lib/flib.lib" "$ROOT/build/m6-sdk/flib.lib" \
|
||||
|| fail "sdk/lib/flib.lib differs from build/m6-sdk/flib.lib"
|
||||
else
|
||||
echo " SKIP (vendor tree absent): no build/m6-sdk/flib.lib to compare"
|
||||
fi
|
||||
if [ -f "$ROOT/build/m6-sdk/rts.lib" ]; then
|
||||
cmp "$ROOT/sdk/lib/rts.lib" "$ROOT/build/m6-sdk/rts.lib" \
|
||||
|| fail "sdk/lib/rts.lib differs from build/m6-sdk/rts.lib"
|
||||
else
|
||||
echo " SKIP (vendor tree absent): no build/m6-sdk/rts.lib to compare"
|
||||
fi
|
||||
|
||||
echo "m11 sdk: PASS"
|
||||
Executable
+524
@@ -0,0 +1,524 @@
|
||||
#!/bin/sh
|
||||
# M12 runtime-abort triage harness (serial; evidence only, edits nothing).
|
||||
#
|
||||
# scripts/tests/m12/abort-triage.sh [options]
|
||||
#
|
||||
# Discovers the curated runtime-abort rows from full-suite.skip -- every row
|
||||
# whose reason starts with "runtime-abort" plus every wrong-result row whose
|
||||
# reason says so -- then re-runs each one at -O0 and -O2 through the M5
|
||||
# conformance runner with the same settings the M7 full-suite driver uses.
|
||||
# The curated skip table is only read; this harness cannot flip a row.
|
||||
#
|
||||
# For every row it records the runner result, the status word, the completion
|
||||
# magic, a status-derived marker (a non-zero status or a missing magic -- the
|
||||
# silent tests expose no output marker), and the first difference between -O0
|
||||
# and -O2. Per-opt logs and result.txt files are retained so the research
|
||||
# document can cite them; the per-opt work dirs are run-O0/ and run-O2/.
|
||||
#
|
||||
# --work DIR work/results directory (default build/m12-abort-triage)
|
||||
# --timeout SEC per-test MAME timeout (default 120)
|
||||
# --redo re-run rows already recorded
|
||||
# --limit N attempt at most N rows (sample use)
|
||||
# -h, --help this help (exit 0)
|
||||
#
|
||||
# Overridable: M12_ABORT_WORK M12_ABORT_TIMEOUT
|
||||
# LLVM_BIN TMS_CLANG TMS_LLC MAME LOADER_AT LOADER_END
|
||||
set -eu
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
SKIP_FILE=$ROOT/scripts/tests/m7/full-suite.skip
|
||||
GNU89_FILE=$ROOT/scripts/tests/m7/full-suite.gnu89
|
||||
LOADER_FILE=$ROOT/scripts/tests/m7/full-suite.loader-end
|
||||
FULL_LOADER_FILE=$ROOT/scripts/tests/m7/full-suite.full-loader
|
||||
CONFORMANCE_DIR=${M5_CONFORMANCE_DIR:-$ROOT/scripts/tests/m5/conformance}
|
||||
RUN=$CONFORMANCE_DIR/run.sh
|
||||
C_TORTURE_DIR=${C_TORTURE_DIR:-$ROOT/vendor/conformance/gcc-16.2.0/gcc/testsuite/gcc.c-torture/execute}
|
||||
C_TESTSUITE_DIR=${C_TESTSUITE_DIR:-$ROOT/vendor/conformance/c-testsuite/tests/single-exec}
|
||||
|
||||
WORK=${M12_ABORT_WORK:-$ROOT/build/m12-abort-triage}
|
||||
TIME_LIMIT=${M12_ABORT_TIMEOUT:-120}
|
||||
LOADER_AT=${LOADER_AT:-200}
|
||||
LOADER_END=${LOADER_END:-1000}
|
||||
REDO=0
|
||||
LIMIT=0
|
||||
EVIDENCE=$WORK/abort-triage.evidence.tsv
|
||||
TSV=$WORK/abort-triage.tsv
|
||||
TABLE=$WORK/abort-triage.md
|
||||
|
||||
fail() {
|
||||
echo "abort-triage: FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
sed -n '2,/^set -eu/p' "$0" | sed '$d' | sed 's/^# \{0,1\}//' >&2
|
||||
exit "${1:-1}"
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--work)
|
||||
[ $# -ge 2 ] || usage
|
||||
WORK=$2
|
||||
EVIDENCE=$WORK/abort-triage.evidence.tsv
|
||||
TSV=$WORK/abort-triage.tsv
|
||||
TABLE=$WORK/abort-triage.md
|
||||
shift 2
|
||||
;;
|
||||
--timeout)
|
||||
[ $# -ge 2 ] || usage
|
||||
TIME_LIMIT=$2
|
||||
shift 2
|
||||
;;
|
||||
--redo)
|
||||
REDO=1
|
||||
shift
|
||||
;;
|
||||
--limit)
|
||||
[ $# -ge 2 ] || usage
|
||||
LIMIT=$2
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
fail "unknown option: $1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case $TIME_LIMIT in
|
||||
''|*[!0-9]*) fail "timeout must be a positive integer: '$TIME_LIMIT'" ;;
|
||||
esac
|
||||
[ "$TIME_LIMIT" -gt 0 ] || fail "timeout must be a positive integer"
|
||||
case $LIMIT in
|
||||
''|*[!0-9]*) fail "--limit must be a non-negative integer: '$LIMIT'" ;;
|
||||
esac
|
||||
|
||||
[ -f "$SKIP_FILE" ] || fail "missing skip table: $SKIP_FILE"
|
||||
[ -f "$GNU89_FILE" ] || fail "missing gnu89 list: $GNU89_FILE"
|
||||
[ -f "$LOADER_FILE" ] || fail "missing loader-end list: $LOADER_FILE"
|
||||
[ -f "$RUN" ] || fail "missing conformance runner: $RUN"
|
||||
[ -d "$C_TORTURE_DIR" ] || fail "missing pinned c-torture tree: $C_TORTURE_DIR"
|
||||
[ -d "$C_TESTSUITE_DIR" ] || fail "missing pinned c-testsuite tree: $C_TESTSUITE_DIR"
|
||||
|
||||
mkdir -p "$WORK/logs" "$WORK/run-O0" "$WORK/run-O2"
|
||||
|
||||
# Discover, never hardcode. The two accepted shapes are the reason prefix
|
||||
# runtime-abort* and the wrong-result rows (reason says "wrong ... result").
|
||||
# Order follows the curated file so a diff is readable.
|
||||
ROWS=$WORK/abort-rows.tsv
|
||||
CLASSES=$WORK/abort-classes.tsv
|
||||
: > "$ROWS"
|
||||
: > "$CLASSES"
|
||||
while IFS= read -r line; do
|
||||
case $line in
|
||||
''|\#*) continue ;;
|
||||
esac
|
||||
id=${line%% *}
|
||||
reason=${line#* }
|
||||
[ "$id" != "$line" ] || fail "malformed skip row (no tab): $line"
|
||||
case $reason in
|
||||
runtime-abort*) ;;
|
||||
*wrong*result*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
corpus=${id%%/*}
|
||||
name=${id#*/}
|
||||
[ "$corpus" != "$id" ] || fail "malformed skip id: $id"
|
||||
case $corpus in
|
||||
c-torture) src=$C_TORTURE_DIR/$name.c ;;
|
||||
c-testsuite) src=$C_TESTSUITE_DIR/$name.c ;;
|
||||
*) fail "unknown corpus in curated row: $id" ;;
|
||||
esac
|
||||
[ -f "$src" ] || fail "curated abort row names a missing source: $id"
|
||||
cls=${reason%%:*}
|
||||
printf '%s\t%s\n' "$id" "$reason" >> "$ROWS"
|
||||
printf '%s\t%s\t%s\n' "$id" "$cls" "$reason" >> "$CLASSES"
|
||||
done < "$SKIP_FILE"
|
||||
[ -s "$ROWS" ] || fail "discovered no runtime-abort rows in $SKIP_FILE"
|
||||
DISCOVERED=$(wc -l < "$ROWS" | tr -d ' ')
|
||||
|
||||
# Reuse the driver's dialect and loader-budget rules so a row is run under the
|
||||
# conditions the full suite would use if it were not curated.
|
||||
dialect_flags() {
|
||||
corpus=$1
|
||||
name=$2
|
||||
src=$3
|
||||
if [ "$corpus" != c-torture ]; then
|
||||
return 0
|
||||
fi
|
||||
directives=$(grep -E 'dg-(additional-)?options' "$src" 2>/dev/null || true)
|
||||
std=$(printf '%s\n' "$directives" \
|
||||
| grep -o -- '-std=[A-Za-z0-9+_-]*' | head -n 1 || true)
|
||||
if [ -n "$std" ]; then
|
||||
flags=$std
|
||||
elif grep -Fxq "$name" "$GNU89_FILE"; then
|
||||
flags=-std=gnu89
|
||||
else
|
||||
flags=
|
||||
fi
|
||||
if printf '%s\n' "$directives" | grep -q -- '-fgnu89-inline'; then
|
||||
flags="${flags:+$flags }-fgnu89-inline"
|
||||
fi
|
||||
if printf '%s\n' "$directives" | grep -q -- '-fwrapv'; then
|
||||
flags="${flags:+$flags }-fwrapv"
|
||||
fi
|
||||
if printf '%s\n' "$directives" | grep -q -- '-finstrument-functions'; then
|
||||
flags="${flags:+$flags }-finstrument-functions"
|
||||
fi
|
||||
printf '%s' "$flags"
|
||||
}
|
||||
|
||||
loader_end_for() {
|
||||
awk -F '\t' -v id="$1" '$1 == id { print $2; exit }' "$LOADER_FILE"
|
||||
}
|
||||
|
||||
full_loader_for() {
|
||||
awk -F '\t' -v n="$1" '$1 == n && $1 !~ /^#/ { print $2 "\t" $3; exit }' \
|
||||
"$FULL_LOADER_FILE"
|
||||
}
|
||||
|
||||
# Stable driver-compatible category for a failed runner invocation. The
|
||||
# ordering mirrors scripts/tests/m7/full-suite.sh classify_failure().
|
||||
classify_failure() {
|
||||
log=$1
|
||||
rc=$2
|
||||
runwork=$3
|
||||
if [ -n "$runwork" ] && [ -f "$runwork/result.txt" ] \
|
||||
&& grep -q '== run the COFF in MAME' "$log" 2>/dev/null; then
|
||||
loader_hex=$(sed -n 's/^loader=//p' "$runwork/result.txt" \
|
||||
| tr -d '\r' | head -n 1)
|
||||
case $loader_hex in
|
||||
''|00000000) ;;
|
||||
*)
|
||||
echo loader
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $rc in
|
||||
124|137)
|
||||
echo timeout
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
if grep -q 'MAME exited 124' "$log" 2>/dev/null \
|
||||
|| grep -q 'timed out' "$log" 2>/dev/null; then
|
||||
echo timeout
|
||||
elif grep -q 'no completion magic' "$log" 2>/dev/null; then
|
||||
echo timeout
|
||||
elif grep -q 'LLVM ERROR:' "$log" 2>/dev/null \
|
||||
|| grep -q 'PLEASE submit a bug report' "$log" 2>/dev/null \
|
||||
|| grep -q 'Stack dump' "$log" 2>/dev/null \
|
||||
|| grep -q 'Aborted' "$log" 2>/dev/null \
|
||||
|| grep -q 'Segmentation fault' "$log" 2>/dev/null \
|
||||
|| grep -q 'Bus error' "$log" 2>/dev/null \
|
||||
|| grep -q 'Illegal instruction' "$log" 2>/dev/null; then
|
||||
echo crash
|
||||
elif grep -q 'missing tool:' "$log" 2>/dev/null \
|
||||
|| grep -q 'classifier error' "$log" 2>/dev/null \
|
||||
|| grep -q 'missing source' "$log" 2>/dev/null \
|
||||
|| grep -q 'missing expected output' "$log" 2>/dev/null; then
|
||||
echo harness
|
||||
elif grep -q 'COFF loader rejected' "$log" 2>/dev/null; then
|
||||
echo loader
|
||||
elif grep -q 'output mismatch' "$log" 2>/dev/null \
|
||||
|| grep -q 'stderr mismatch' "$log" 2>/dev/null \
|
||||
|| grep -q 'output truncated' "$log" 2>/dev/null \
|
||||
|| grep -q 'stderr truncated' "$log" 2>/dev/null; then
|
||||
echo output
|
||||
elif grep -q 'status mismatch' "$log" 2>/dev/null; then
|
||||
echo status
|
||||
elif grep -q 'compile/link failed' "$log" 2>/dev/null \
|
||||
|| grep -q 'linker produced no map' "$log" 2>/dev/null \
|
||||
|| grep -q 'has no M4 LINK: PASS' "$log" 2>/dev/null \
|
||||
|| grep -q 'linker produced no COFF' "$log" 2>/dev/null; then
|
||||
echo compile
|
||||
elif grep -q 'MAME produced no CONF result' "$log" 2>/dev/null \
|
||||
|| grep -q 'loader did not verify' "$log" 2>/dev/null \
|
||||
|| grep -q 'result file has no' "$log" 2>/dev/null \
|
||||
|| grep -q 'MAME exited' "$log" 2>/dev/null; then
|
||||
echo crash
|
||||
elif grep -q '^CONFORMANCE: FAIL ' "$log" 2>/dev/null; then
|
||||
echo status
|
||||
else
|
||||
echo unclassified
|
||||
fi
|
||||
}
|
||||
|
||||
result_field() {
|
||||
file=$1
|
||||
key=$2
|
||||
if [ ! -f "$file" ]; then
|
||||
printf ''
|
||||
return 0
|
||||
fi
|
||||
sed -n "s/^$key=//p" "$file" | tr -d '\r' | head -n 1
|
||||
}
|
||||
|
||||
# Decode the runner's uppercase hex stdout and return its last non-empty line,
|
||||
# sanitised to printable ASCII. This is normally the test's last check before
|
||||
# an abort (many c-torture tests print a marker per subtest).
|
||||
decode_lastline() {
|
||||
printf '%s\n' "$1" | awk 'BEGIN { hex = "0123456789ABCDEF" }
|
||||
{
|
||||
s = toupper($0)
|
||||
if (length(s) % 2 == 1) s = "0" s
|
||||
out = ""
|
||||
for (i = 1; i < length(s); i += 2) {
|
||||
hi = index(hex, substr(s, i, 1)) - 1
|
||||
lo = index(hex, substr(s, i + 1, 1)) - 1
|
||||
if (hi < 0 || lo < 0) continue
|
||||
out = out sprintf("%c", hi * 16 + lo)
|
||||
}
|
||||
n = split(out, lines, "\n")
|
||||
last = ""
|
||||
for (j = 1; j <= n; j++) {
|
||||
line = lines[j]
|
||||
gsub(/[^ -~]/, ".", line)
|
||||
gsub(/^[ \t]+|[ \t]+$/, "", line)
|
||||
if (line != "") last = line
|
||||
}
|
||||
printf "%s", last
|
||||
}'
|
||||
}
|
||||
|
||||
run_one() {
|
||||
id=$1
|
||||
opt=$2
|
||||
corpus=${id%%/*}
|
||||
name=${id#*/}
|
||||
safe_id=$(printf '%s' "$id" | tr -c 'A-Za-z0-9._-' '_')
|
||||
src=
|
||||
expected=
|
||||
case $corpus in
|
||||
c-torture) src=$C_TORTURE_DIR/$name.c ;;
|
||||
c-testsuite)
|
||||
src=$C_TESTSUITE_DIR/$name.c
|
||||
expected=$C_TESTSUITE_DIR/$name.c.expected
|
||||
[ -f "$expected" ] || expected=$C_TESTSUITE_DIR/$name.expected
|
||||
;;
|
||||
esac
|
||||
|
||||
logdir=$WORK/logs/$opt/$corpus
|
||||
mkdir -p "$logdir"
|
||||
log=$logdir/$name.log
|
||||
runwork=$WORK/run-${opt#-}/$safe_id
|
||||
|
||||
extra_cflags=$(dialect_flags "$corpus" "$name" "$src")
|
||||
test_loader_end=$(loader_end_for "$id")
|
||||
[ -n "$test_loader_end" ] || test_loader_end=$LOADER_END
|
||||
|
||||
bare=1
|
||||
full_row=$(full_loader_for "$name")
|
||||
full_linker=os2
|
||||
if [ -n "$full_row" ]; then
|
||||
bare=0
|
||||
full_linker=$(printf '%s' "$full_row" | cut -f2)
|
||||
[ -n "$full_linker" ] || full_linker=os2
|
||||
fi
|
||||
os2=1
|
||||
if [ "$bare" = 0 ] && [ "$full_linker" = 1987 ]; then
|
||||
os2=0
|
||||
fi
|
||||
|
||||
start=$(date +%s)
|
||||
set +e
|
||||
if [ "$corpus" = c-torture ]; then
|
||||
LOADER_AT=$LOADER_AT LOADER_END=$test_loader_end \
|
||||
MAME_TIMEOUT=$TIME_LIMIT \
|
||||
M5_CONFORMANCE_WORK=$WORK/run-${opt#-} \
|
||||
M5_CONFORMANCE_CLANG_OPT=$opt M5_CONFORMANCE_LLC_OPT=$opt \
|
||||
M5_CONFORMANCE_MODE=native \
|
||||
M5_CONFORMANCE_BARE=$bare \
|
||||
M4_OS2=$os2 \
|
||||
M5_CONFORMANCE_EXTRA_CFLAGS=$extra_cflags \
|
||||
timeout --kill-after=10 "$((TIME_LIMIT + 90))" \
|
||||
"$RUN" --id "$id" --classify --mode native \
|
||||
--expect-status 0 --ignore-output --timeout "$TIME_LIMIT" \
|
||||
"$src" > "$log" 2>&1
|
||||
else
|
||||
LOADER_AT=$LOADER_AT LOADER_END=$test_loader_end \
|
||||
MAME_TIMEOUT=$TIME_LIMIT \
|
||||
M5_CONFORMANCE_WORK=$WORK/run-${opt#-} \
|
||||
M5_CONFORMANCE_CLANG_OPT=$opt M5_CONFORMANCE_LLC_OPT=$opt \
|
||||
M5_CONFORMANCE_MODE=native \
|
||||
M5_CONFORMANCE_BARE=$bare \
|
||||
M4_OS2=$os2 \
|
||||
M5_CONFORMANCE_EXTRA_CFLAGS= \
|
||||
timeout --kill-after=10 "$((TIME_LIMIT + 90))" \
|
||||
"$RUN" --id "$id" --classify --mode native \
|
||||
--expect-status 0 --expect-output-file "$expected" \
|
||||
--timeout "$TIME_LIMIT" "$src" > "$log" 2>&1
|
||||
fi
|
||||
rc=$?
|
||||
set -e
|
||||
end=$(date +%s)
|
||||
printf '%s\n' "$rc" > "$log.rc"
|
||||
elapsed=$((end - start))
|
||||
|
||||
case $rc in
|
||||
0)
|
||||
result=pass
|
||||
;;
|
||||
2)
|
||||
if grep -q '^CONFORMANCE: SKIP ' "$log" 2>/dev/null; then
|
||||
skip_reason=$(sed -n 's/^CONFORMANCE: SKIP id=[^ ]* reason=//p' \
|
||||
"$log" | head -n 1)
|
||||
[ -n "$skip_reason" ] || skip_reason=classifier
|
||||
result="skip:$skip_reason"
|
||||
else
|
||||
category=$(classify_failure "$log" "$rc" "$runwork")
|
||||
result="fail:$category"
|
||||
fi
|
||||
;;
|
||||
1)
|
||||
category=$(classify_failure "$log" "$rc" "$runwork")
|
||||
result="fail:$category"
|
||||
;;
|
||||
124|137)
|
||||
result=fail:timeout
|
||||
;;
|
||||
*)
|
||||
result=fail:crash
|
||||
;;
|
||||
esac
|
||||
|
||||
result_file=$runwork/result.txt
|
||||
status=$(result_field "$result_file" status)
|
||||
magic=$(result_field "$result_file" magic)
|
||||
out=$(result_field "$result_file" out)
|
||||
err=$(result_field "$result_file" err)
|
||||
len=$(result_field "$result_file" len)
|
||||
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' \
|
||||
"$id" "$opt" "$rc" "$result" "$status" "$magic" "$out" "$err" \
|
||||
"$len" "$log" >> "$EVIDENCE"
|
||||
printf '%-44s %-2s %-12s status=%s magic=%s (%ss)\n' \
|
||||
"$id" "$opt" "$result" "${status:-none}" "${magic:-none}" "$elapsed"
|
||||
}
|
||||
|
||||
if [ "$REDO" -eq 1 ]; then
|
||||
rm -f "$EVIDENCE"
|
||||
fi
|
||||
[ -f "$EVIDENCE" ] || : > "$EVIDENCE"
|
||||
|
||||
ROWS_ATTEMPTED=0
|
||||
while IFS= read -r row; do
|
||||
[ -n "$row" ] || continue
|
||||
if [ "$LIMIT" -gt 0 ] && [ "$ROWS_ATTEMPTED" -ge "$LIMIT" ]; then
|
||||
break
|
||||
fi
|
||||
id=${row%% *}
|
||||
for opt in -O0 -O2; do
|
||||
if [ "$REDO" -eq 0 ] \
|
||||
&& awk -F '\t' -v i="$id" -v o="$opt" \
|
||||
'$1 == i && $2 == o { found = 1 } END { exit !found }' \
|
||||
"$EVIDENCE" 2>/dev/null; then
|
||||
continue
|
||||
fi
|
||||
run_one "$id" "$opt"
|
||||
done
|
||||
ROWS_ATTEMPTED=$((ROWS_ATTEMPTED + 1))
|
||||
done < "$ROWS"
|
||||
|
||||
# --- assemble the machine-readable TSV and the raw Markdown table ----------
|
||||
# One row per discovered file, joining the curated class table with the two
|
||||
# opt-level evidence lines. A missing opt level is shown as "not-run".
|
||||
awk -F '\t' '
|
||||
FNR == NR { cls[$1] = $2; next }
|
||||
{
|
||||
id = $1; opt = $2; rc = $3; result = $4
|
||||
stv = $5; mgv = $6; outv = $7; errv = $8; logf = $10
|
||||
if (!(id in seen)) { seen[id] = 1; order[++n] = id }
|
||||
res[id, opt] = result
|
||||
st[id, opt] = stv
|
||||
mg[id, opt] = mgv
|
||||
out[id, opt] = outv
|
||||
err[id, opt] = errv
|
||||
logp[id, opt] = logf
|
||||
}
|
||||
END {
|
||||
print "corpus/name\tcurated class\t-O0 result\t-O2 result\tstatus O0\tstatus O2\tmagic O0\tmagic O2\tfirst differing marker\tfirst O0/O2 difference\tevidence"
|
||||
for (k = 1; k <= n; k++) {
|
||||
id = order[k]
|
||||
s0 = st[id, "-O0"]; s2 = st[id, "-O2"]
|
||||
m0 = mg[id, "-O0"]; m2 = mg[id, "-O2"]
|
||||
r0 = res[id, "-O0"]; r2 = res[id, "-O2"]
|
||||
if (r0 == "") r0 = "not-run"
|
||||
if (r2 == "") r2 = "not-run"
|
||||
marker = ""
|
||||
if (s0 != "" && s0 != "00000000") marker = "status=" s0
|
||||
if (s2 != "" && s2 != "00000000")
|
||||
marker = marker (marker == "" ? "" : "; ") "status=" s2
|
||||
if (m0 != "" && m0 != "434F4E46")
|
||||
marker = marker (marker == "" ? "" : "; ") "magic=" m0
|
||||
if (m2 != "" && m2 != "434F4E46")
|
||||
marker = marker (marker == "" ? "" : "; ") "magic=" m2
|
||||
if (marker == "") {
|
||||
if (r0 ~ /^fail:/ || r2 ~ /^fail:/) marker = "runner " r0 " / " r2
|
||||
else marker = "-"
|
||||
}
|
||||
diff = ""
|
||||
if (r0 != "not-run" && r2 != "not-run") {
|
||||
if (s0 != s2) diff = "status " s0 " -> " s2
|
||||
else if (out[id, "-O0"] != out[id, "-O2"]) diff = "stdout bytes differ"
|
||||
else if (err[id, "-O0"] != err[id, "-O2"]) diff = "stderr bytes differ"
|
||||
else diff = "none"
|
||||
} else diff = "not-run"
|
||||
ev = logp[id, "-O2"]
|
||||
if (ev == "") ev = logp[id, "-O0"]
|
||||
printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", \
|
||||
id, cls[id], r0, r2, s0, s2, m0, m2, marker, diff, ev
|
||||
}
|
||||
}' "$CLASSES" "$EVIDENCE" > "$TSV"
|
||||
|
||||
# Markdown table: add the decoded last output line (the abort marker) by
|
||||
# re-reading each result.txt through the shell decoder once per row.
|
||||
{
|
||||
echo "# M12 runtime-abort triage (raw)"
|
||||
echo
|
||||
echo "- generated: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
|
||||
echo "- discovered rows: $DISCOVERED (from scripts/tests/m7/full-suite.skip; the file was not modified)"
|
||||
echo "- opt levels: -O0 and -O2"
|
||||
echo "- per-test MAME timeout: ${TIME_LIMIT}s, outer wall $((TIME_LIMIT + 90))s"
|
||||
echo "- work: $WORK"
|
||||
echo
|
||||
echo "| corpus/name | curated class | -O0 | -O2 | status (-O0 / -O2) | magic (-O0 / -O2) | last output marker | first O0/O2 difference |"
|
||||
echo "|---|---|---|---|---|---|---|---|"
|
||||
} > "$TABLE"
|
||||
|
||||
tail -n +2 "$TSV" | while IFS=' ' read -r id cls r0 r2 s0 s2 m0 m2 marker diff ev; do
|
||||
o0file=$WORK/run-O0/$(printf '%s' "$id" | tr -c 'A-Za-z0-9._-' '_')/result.txt
|
||||
o2file=$WORK/run-O2/$(printf '%s' "$id" | tr -c 'A-Za-z0-9._-' '_')/result.txt
|
||||
line0=$(decode_lastline "$(result_field "$o0file" out)")
|
||||
line2=$(decode_lastline "$(result_field "$o2file" out)")
|
||||
[ -n "$line0" ] || line0=-
|
||||
[ -n "$line2" ] || line2=-
|
||||
outmarker=$line0
|
||||
if [ "$line0" != "$line2" ]; then
|
||||
outmarker="$line0 / $line2"
|
||||
fi
|
||||
printf '| %s | %s | %s | %s | %s / %s | %s / %s | %s | %s |\n' \
|
||||
"$id" "$cls" "$r0" "$r2" "${s0:--}" "${s2:--}" "${m0:--}" "${m2:--}" \
|
||||
"$outmarker" "$diff" >> "$TABLE"
|
||||
done
|
||||
|
||||
# Summary by curated class, counted from the discovered rows (not guessed).
|
||||
{
|
||||
echo
|
||||
echo "## Discovered rows by curated class"
|
||||
echo
|
||||
echo "| class | rows |"
|
||||
echo "|---|---|"
|
||||
cut -f2 "$CLASSES" | LC_ALL=C sort | uniq -c \
|
||||
| awk '{ printf "| %s | %d |\n", $2, $1 }'
|
||||
} >> "$TABLE"
|
||||
|
||||
echo
|
||||
echo "abort-triage: discovered $DISCOVERED rows"
|
||||
echo "abort-triage: table $TABLE"
|
||||
echo "abort-triage: tsv $TSV"
|
||||
echo "abort-triage: logs $WORK/logs"
|
||||
@@ -0,0 +1,61 @@
|
||||
# M12 abort-triage probes
|
||||
|
||||
Source for the representative probes cited by
|
||||
`docs/superpowers/research/2026-11-19-tms34010-abort-triage.md` (§4 causes,
|
||||
§5 one-flag ruling). They are kept in the repository so the triage's
|
||||
load-bearing claims can be re-inspected and re-run; the historical run logs
|
||||
are under `logs/`.
|
||||
|
||||
Each probe is compiled and run through the same M5 conformance runner and the
|
||||
same bare-tier settings the triage harness uses. From the repository root:
|
||||
|
||||
```sh
|
||||
probe=simd1probe
|
||||
M5_CONFORMANCE_WORK=build/m12-probe-run \
|
||||
M5_CONFORMANCE_MODE=native M5_CONFORMANCE_BARE=1 \
|
||||
M5_CONFORMANCE_CLANG_OPT=-O0 M5_CONFORMANCE_LLC_OPT=-O0 \
|
||||
M4_OS2=1 LOADER_AT=200 LOADER_END=1000 MAME_TIMEOUT=120 \
|
||||
scripts/tests/m5/conformance/run.sh --id "probe/$probe" --classify \
|
||||
--mode native --expect-status 0 --ignore-output --timeout 120 \
|
||||
"scripts/tests/m12/probes/$probe.c"
|
||||
```
|
||||
|
||||
The probe's `main` return value becomes the runner status under
|
||||
`--expect-status 0`, so a `CONFORMANCE: FAIL ... status=0000000A` line means
|
||||
the probe returned 10. `logs/` keeps the original run output, including the
|
||||
`MAME exited 139` cases.
|
||||
|
||||
The endianness probes (`pr65401probe.c`, and the `20230630-*`/`bitfld-*` files
|
||||
run under the override) add the frontend-only macro override:
|
||||
|
||||
```sh
|
||||
M5_CONFORMANCE_EXTRA_CFLAGS='-U__BIG_ENDIAN__ -D__BYTE_ORDER__=1234'
|
||||
```
|
||||
|
||||
## What each probe shows
|
||||
|
||||
| Probe | Claim it supports | Observed |
|
||||
|---|---|---|
|
||||
| `va931004probe.c` | aggregate `va_arg` returns the wrong struct; the trailing `long` is never reached (§4.1) | status `0x1` |
|
||||
| `simd1probe.c` | vector **add** is already wrong; first failing check is `k = i + j` (§4.2) | status `0xA` |
|
||||
| `astkalign.c` | `__alignof__(aligned(64))` is clamped under the packed default (§4.5) | status `0x1` |
|
||||
| `azerolen.c` | zero-length-array struct alignment differs from its `int` (§4.5) | status `0x2` |
|
||||
| `a20010904.c` | `return (char-diff & 31)` folds to 0 (§4.5) | pass (`0`) |
|
||||
| `a20010904b.c` | the same expression as `if (expr & 31) return 1` folds to true (§4.5) | status `0x1` |
|
||||
| `a20010904c.c` | the probe's own linked stride is small; the corpus mismatch is the real 1028-byte stride (§4.5) | pass (`0`) |
|
||||
| `ptrdiff.c` | `(int)&a[1] - (int)&a[0]` is in bit units, not bytes (§4.6) | status `0x8` |
|
||||
| `fpr35456.c` | `x >= 0 ? x : -x` loses the sign of `-0.0` (§4.7) | status `0x1` |
|
||||
| `fpr44683.c` | `copysign(1.0, -0.0) < 0.0` is false (§4.7) | status `0x3` |
|
||||
| `f20080502.c` | `long double` signbit path differs (§4.7) | status `0x1` |
|
||||
| `f20031003.c` | both out-of-range float→int conversions differ from `INT_MAX` (§4.8) | status `0x3` |
|
||||
| `ffloatunsisf.c` | unsigned→float rounding differs from the literal conversion (§4.8) | status `0x1` |
|
||||
| `isprint.c` | bare-tier `_isprint` reads a zero `__ctypes_` (§4.9) | no log retained; `isprint('a') == 1` is false |
|
||||
| `sprintfhex.c` | `sprintf("%#hhx", 0)` returns 3, i.e. `"0x0"` (§4.9) | status `0x3` |
|
||||
| `sprintf6.c` | the same `%#hhx`-of-zero deviation inside the full test's checks (§4.9) | status `0x2` |
|
||||
| `pr65401probe.c` | the test's own loops pass with the little-endian macro override; the failure is the `__BYTE_ORDER__` branch (§4.4) | pass with override |
|
||||
| `firstbyte.c`, `firstbyte3.c` | bitfield first-byte extraction probes (§4.4) | `firstbyte.c` host-segfaults (`MAME exited 139`); the bare-tier instability noted in §8 |
|
||||
| `20230630-1` (`log-e-*`) | the macro override passes through the full loader; the bare tier host-segfaults (§4.4, §8) | pass (full loader); `MAME exited 139` (bare `-O0`) |
|
||||
|
||||
`isprint.c` and `sprintfret.c`/`sprintfret2.c` are retained sources whose
|
||||
historical logs were not kept; their claims are stated in the research
|
||||
document and are reproducible with the command above.
|
||||
@@ -0,0 +1,4 @@
|
||||
typedef struct x { int a; int b; } __attribute__((aligned(32))) X;
|
||||
typedef struct y { X x[32]; int c; } Y;
|
||||
Y y[2];
|
||||
int main(void){ return ((char*)&y[1] - (char*)&y[0]) & 31; }
|
||||
@@ -0,0 +1,4 @@
|
||||
typedef struct x { int a; int b; } __attribute__((aligned(32))) X;
|
||||
typedef struct y { X x[32]; int c; } Y;
|
||||
Y y[2];
|
||||
int main(void){ if (((char*)&y[1] - (char*)&y[0]) & 31) return 1; return 0; }
|
||||
@@ -0,0 +1,4 @@
|
||||
typedef struct x { int a; int b; } __attribute__((aligned(32))) X;
|
||||
typedef struct y { X x[32]; int c; } Y;
|
||||
Y y[2];
|
||||
int main(void){ long d = (char*)&y[1] - (char*)&y[0]; return (int)(d >> 8); }
|
||||
@@ -0,0 +1 @@
|
||||
int main(void){ static struct { char c __attribute__((aligned(64))); } s; return __alignof__(s); }
|
||||
@@ -0,0 +1,3 @@
|
||||
typedef int word __attribute__((mode(word)));
|
||||
struct foo { word x; word y[0]; };
|
||||
int main(){ return (sizeof(word)!=sizeof(struct foo)) + 2*(__alignof__(word)!=__alignof__(struct foo)); }
|
||||
@@ -0,0 +1,54 @@
|
||||
c-torture/20010904-1 align-packed-abi L
|
||||
c-torture/20010904-2 align-packed-abi L
|
||||
c-torture/20021127-1 freestanding-builtin out
|
||||
c-torture/20031003-1 float-conv M
|
||||
c-torture/20050604-1 vector-ops L
|
||||
c-torture/20050607-1 vector-ops L
|
||||
c-torture/20060420-1 vector-ops L
|
||||
c-torture/20080502-1 signed-zero M
|
||||
c-torture/20230630-1 endian-macro+sso M
|
||||
c-torture/20230630-3 endian-macro+sso M
|
||||
c-torture/920428-1 ptr-int-model out
|
||||
c-torture/920625-1 aggregate-varargs L
|
||||
c-torture/931004-10 aggregate-varargs L
|
||||
c-torture/931004-12 aggregate-varargs L
|
||||
c-torture/931004-14 aggregate-varargs L
|
||||
c-torture/931004-2 aggregate-varargs L
|
||||
c-torture/931004-4 aggregate-varargs L
|
||||
c-torture/931004-6 aggregate-varargs L
|
||||
c-torture/931004-8 aggregate-varargs L
|
||||
c-torture/991112-1 rts-shim S
|
||||
c-torture/bitfld-3 bitfield-64 M
|
||||
c-torture/bitfld-5 bitfield-64 M
|
||||
c-torture/bitfld-6 endian-macro+sso M
|
||||
c-torture/bitfld-7 endian-macro+sso M
|
||||
c-torture/eeprof-1 instr-flag S
|
||||
c-torture/floatunsisf-1 float-conv M
|
||||
c-torture/pr103255 ptr-int-model out
|
||||
c-torture/pr123625 vector-ops L
|
||||
c-torture/pr32244-1 bitfield-64 M
|
||||
c-torture/pr34971 bitfield-64 M
|
||||
c-torture/pr35456 signed-zero M
|
||||
c-torture/pr38051 ptr-int-model out
|
||||
c-torture/pr38151 aggregate-varargs L
|
||||
c-torture/pr44575 aggregate-varargs L
|
||||
c-torture/pr44683 signed-zero M
|
||||
c-torture/pr57344-3 bitfield-64 M
|
||||
c-torture/pr57344-4 bitfield-64 M
|
||||
c-torture/pr58209 ptr-int-model out
|
||||
c-torture/pr65401 endian-macro+sso M
|
||||
c-torture/pr65427 vector-ops L
|
||||
c-torture/pr79327 rts-shim S
|
||||
c-torture/pr79737-2 bitfield-64 M
|
||||
c-torture/pr85169 vector-ops L
|
||||
c-torture/pr94412 vector-ops L
|
||||
c-torture/scal-to-vec1 vector-ops L
|
||||
c-torture/scal-to-vec2 vector-ops L
|
||||
c-torture/scal-to-vec3 vector-ops L
|
||||
c-torture/simd-1 vector-ops L
|
||||
c-torture/simd-2 vector-ops L
|
||||
c-torture/stdarg-3 aggregate-varargs L
|
||||
c-torture/stkalign align-packed-abi L
|
||||
c-torture/strct-stdarg-1 aggregate-varargs L
|
||||
c-torture/strct-varg-1 aggregate-varargs L
|
||||
c-torture/zerolen-2 align-packed-abi L
|
||||
|
@@ -0,0 +1,3 @@
|
||||
int f1(){ return (int)2147483648.0f; }
|
||||
int f2(){ return (int)(float)(2147483647); }
|
||||
int main(){ return (f1()!=2147483647) + 2*(f2()!=2147483647); }
|
||||
@@ -0,0 +1,2 @@
|
||||
long double __attribute__((noinline)) foo (long double x) { return __builtin_signbit(x) ? 3.1415926535897932384626433832795029L : 0.0; }
|
||||
int main(void){ return foo(-1.0L) != 3.1415926535897932384626433832795029L; }
|
||||
@@ -0,0 +1,3 @@
|
||||
volatile unsigned u = 0x80000081;
|
||||
volatile float f1, f2;
|
||||
int main(void){ f1=(float)u; f2=(float)0x80000081; return f1!=f2; }
|
||||
@@ -0,0 +1,2 @@
|
||||
struct S { short int i : 12; char c1 : 1; char c2 : 1; char c3 : 1; char c4 : 1; };
|
||||
int main(void) { struct S s0 = { 341, 1, 1, 1, 1 }; volatile char *p = (char *)&s0; return (unsigned char)*p; }
|
||||
@@ -0,0 +1,2 @@
|
||||
struct S { __INT32_TYPE__ i : 24; char c1:1,c2:1,c3:1,c4:1,c5:1,c6:1,c7:1,c8:1; };
|
||||
int main(void) { struct S s0 = { 1193046,1,1,1,1,1,1,1,1 }; char *p=(char*)&s0; return (unsigned char)*p; }
|
||||
@@ -0,0 +1,2 @@
|
||||
double __attribute__((noinline)) not_fabs (double x) { return x >= 0.0 ? x : -x; }
|
||||
int main(){ double x=-0.0; double y=not_fabs(x); return __builtin_signbit(y)?0:1; }
|
||||
@@ -0,0 +1,2 @@
|
||||
int __attribute__((noinline,noclone)) copysign_bug (double x){ if (x != 0.0 && (x*0.5 == x)) return 1; if (__builtin_copysign(1.0,x) < 0.0) return 2; return 3; }
|
||||
int main(void){ double x=-0.0; return copysign_bug(x); }
|
||||
@@ -0,0 +1,2 @@
|
||||
int isprint(int);
|
||||
int main(void) { return isprint('a') == 1 ? 0 : (isprint('a') ? 1 : 2); }
|
||||
@@ -0,0 +1,12 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20230630-1-O0, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/20230630-1-O0/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
Warning: -video none doesn't make much sense without -seconds_to_run
|
||||
ALSA lib seq_hw.c:540:(snd_seq_hw_open) open /dev/snd/seq failed: Permission denied
|
||||
vt1200: screen_update#1 frame=0 clip_y=0..0 screen=1280x901
|
||||
vt1200: screen_update#2 frame=0 clip_y=1..900 screen=1280x901
|
||||
vt1200: guard#1 frame=0 dump_frame=-1 dump_ram=-1
|
||||
BARE: entry=018A0000 sp=01A80000 sections=3
|
||||
Segmentation fault
|
||||
conformance: FAIL: MAME exited 139
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20230630-1-O2, -O2, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/20230630-1-O2/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=20230630-1-O2 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20230630-3-O0, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/20230630-3-O0/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=20230630-3-O0 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20230630-3-O2, -O2, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/20230630-3-O2/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=20230630-3-O2 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (bitfld-6-O0, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/bitfld-6-O0/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=bitfld-6-O0 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (bitfld-6-O2, -O2, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/bitfld-6-O2/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=bitfld-6-O2 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (bitfld-7-O0, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/bitfld-7-O0/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=bitfld-7-O0 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (bitfld-7-O2, -O2, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work-endian/bitfld-7-O2/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=bitfld-7-O2 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (a20010904, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/a20010904/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=a20010904 status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (astkalign, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/astkalign/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=astkalign status=00000001 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000001
|
||||
work dir: /tmp/opencode/abort-probes/work2/astkalign
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (azerolen, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/azerolen/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=azerolen status=00000002 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000002
|
||||
work dir: /tmp/opencode/abort-probes/work2/azerolen
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (f20031003, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/f20031003/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=f20031003 status=00000003 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000003
|
||||
work dir: /tmp/opencode/abort-probes/work2/f20031003
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (f20080502, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/f20080502/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=f20080502 status=00000001 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000001
|
||||
work dir: /tmp/opencode/abort-probes/work2/f20080502
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (ffloatunsisf, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/ffloatunsisf/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=ffloatunsisf status=00000001 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000001
|
||||
work dir: /tmp/opencode/abort-probes/work2/ffloatunsisf
|
||||
@@ -0,0 +1,12 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (firstbyte, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/firstbyte/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
Warning: -video none doesn't make much sense without -seconds_to_run
|
||||
ALSA lib seq_hw.c:540:(snd_seq_hw_open) open /dev/snd/seq failed: Permission denied
|
||||
vt1200: screen_update#1 frame=0 clip_y=0..0 screen=1280x901
|
||||
vt1200: screen_update#2 frame=0 clip_y=1..900 screen=1280x901
|
||||
vt1200: guard#1 frame=0 dump_frame=-1 dump_ram=-1
|
||||
BARE: entry=018A0000 sp=01A80000 sections=3
|
||||
Segmentation fault
|
||||
conformance: FAIL: MAME exited 139
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (fpr35456, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/fpr35456/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=fpr35456 status=00000001 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000001
|
||||
work dir: /tmp/opencode/abort-probes/work2/fpr35456
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (fpr44683, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/fpr44683/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=fpr44683 status=00000003 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000003
|
||||
work dir: /tmp/opencode/abort-probes/work2/fpr44683
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (sprintf6, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work2/sprintf6/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=sprintf6 status=00000002 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000002
|
||||
work dir: /tmp/opencode/abort-probes/work2/sprintf6
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (a20010904b, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work3/a20010904b/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=a20010904b status=00000001 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000001
|
||||
work dir: /tmp/opencode/abort-probes/work3/a20010904b
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (a20010904c, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work3/a20010904c/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=a20010904c status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (sprintfhex, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work3/sprintfhex/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=sprintfhex status=00000003 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000003
|
||||
work dir: /tmp/opencode/abort-probes/work3/sprintfhex
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (pr65401probe, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work4/pr65401probe/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=pr65401probe status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (simd1probe, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work4/simd1probe/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=simd1probe status=0000000A expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 0000000A
|
||||
work dir: /tmp/opencode/abort-probes/work4/simd1probe
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (va931004probe, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work4/va931004probe/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=va931004probe status=00000001 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000001
|
||||
work dir: /tmp/opencode/abort-probes/work4/va931004probe
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (ptrdiff, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work5/ptrdiff/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=ptrdiff status=00000008 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000008
|
||||
work dir: /tmp/opencode/abort-probes/work5/ptrdiff
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20031003-notrap, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work6/20031003-notrap/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=20031003-notrap status=00000086 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000086
|
||||
work dir: /tmp/opencode/abort-probes/work6/20031003-notrap
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20230630-1-endian-full, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work6/20230630-1-endian-full/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=20230630-1-endian-full status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (stkalign-noinline, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work6/stkalign-noinline/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=stkalign-noinline status=00000086 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000086
|
||||
work dir: /tmp/opencode/abort-probes/work6/stkalign-noinline
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20230630-2-ovr, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work7/20230630-2-ovr/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=20230630-2-ovr status=00000086 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000086
|
||||
work dir: /tmp/opencode/abort-probes/work7/20230630-2-ovr
|
||||
@@ -0,0 +1,7 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (20230630-4-ovr, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work7/20230630-4-ovr/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: FAIL id=20230630-4-ovr status=00000086 expected_status=00000000 stdout_len=0 stderr_len=0
|
||||
status mismatch: expected 00000000, got 00000086
|
||||
work dir: /tmp/opencode/abort-probes/work7/20230630-4-ovr
|
||||
@@ -0,0 +1,5 @@
|
||||
== extract the 1990 flib.lib/rts.lib for the shim's %f
|
||||
== compile and link (pr98853-1-ovr, -O0, mode=native)
|
||||
linked /tmp/opencode/abort-probes/work7/pr98853-1-ovr/m4/m4.coff (native)
|
||||
== run the COFF in MAME (native bare)
|
||||
CONFORMANCE: PASS id=pr98853-1-ovr status=00000000 stdout_len=0 stderr_len=0 link=native
|
||||
@@ -0,0 +1,19 @@
|
||||
struct S { unsigned short s[64]; };
|
||||
__attribute__((noinline, noclone)) void foo (struct S *x) {
|
||||
unsigned int i; unsigned char *s = (unsigned char *) x->s;
|
||||
for (i = 0; i < 64; i++) x->s[i] = s[i * 2] | (s[i * 2 + 1] << 8);
|
||||
}
|
||||
__attribute__((noinline, noclone)) void bar (struct S *x) {
|
||||
unsigned int i; unsigned char *s = (unsigned char *) x->s;
|
||||
for (i = 0; i < 64; i++) x->s[i] = (s[i * 2] << 8) | s[i * 2 + 1];
|
||||
}
|
||||
int main () {
|
||||
unsigned int i; struct S s;
|
||||
for (i = 0; i < 64; i++) s.s[i] = i + ((64 - i) << 8);
|
||||
foo (&s);
|
||||
for (i = 0; i < 64; i++) if (s.s[i] != i + ((64 - i) << 8)) return 1;
|
||||
for (i = 0; i < 64; i++) s.s[i] = i + ((64 - i) << 8);
|
||||
bar (&s);
|
||||
for (i = 0; i < 64; i++) if (s.s[i] != (64 - i) + (i << 8)) return 2;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
int main(){ char a[2]; return (int)&a[1] - (int)&a[0]; }
|
||||
@@ -0,0 +1,19 @@
|
||||
void exit (int);
|
||||
typedef int __attribute__((mode(SI))) __attribute__((vector_size (16))) vecint;
|
||||
typedef int __attribute__((mode(SI))) siint;
|
||||
vecint i = { 150, 100, 150, 200 };
|
||||
vecint j = { 10, 13, 20, 30 };
|
||||
vecint k;
|
||||
union { vecint v; siint i[4]; } res;
|
||||
#define CHK(a,b,c,d) do { if (res.i[0]!=(a)||res.i[1]!=(b)||res.i[2]!=(c)||res.i[3]!=(d)) return __LINE__; } while (0)
|
||||
int main () {
|
||||
k = i + j; res.v = k; CHK(160,113,170,230);
|
||||
k = i * j; res.v = k; CHK(1500,1300,3000,6000);
|
||||
k = i / j; res.v = k; CHK(15,7,7,6);
|
||||
k = i & j; res.v = k; CHK(2,4,20,8);
|
||||
k = i | j; res.v = k; CHK(158,109,150,222);
|
||||
k = i ^ j; res.v = k; CHK(156,105,130,214);
|
||||
k = -i; res.v = k; CHK(-150,-100,-150,-200);
|
||||
k = ~i; res.v = k; CHK(-151,-101,-151,-201);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
int main(void){
|
||||
char buf[64]; volatile int a; int r;
|
||||
a=0; r=__builtin_sprintf(buf,"%#hho",a); if(r!=1) return 1;
|
||||
r=__builtin_sprintf(buf,"%#hhx",a); if(r!=1) return 2;
|
||||
a=1; r=__builtin_sprintf(buf,"%#hho",a); if(r!=2) return 3;
|
||||
r=__builtin_sprintf(buf,"%#hhx",a); if(r!=3) return 4;
|
||||
a=127; r=__builtin_sprintf(buf,"%#hho",a); if(r!=4) return 5;
|
||||
r=__builtin_sprintf(buf,"%#hhx",a); if(r!=4) return 6;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
int main(void){ char buf[64]; volatile int a=0; return __builtin_sprintf(buf,"%#hhx",a); }
|
||||
@@ -0,0 +1 @@
|
||||
int main(void){ char buf[64]; volatile int a=0; int r=__builtin_sprintf(buf,"%#hho",a); return r; }
|
||||
@@ -0,0 +1 @@
|
||||
int main(void){ char buf[64]; volatile int a=127; int r=__builtin_sprintf(buf,"%#hho",a); return r; }
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <stdarg.h>
|
||||
struct tiny { int c; };
|
||||
int f (int n, ...) {
|
||||
struct tiny x; int i; va_list ap; va_start (ap,n);
|
||||
for (i = 0; i < n; i++) { x = va_arg (ap,struct tiny); if (x.c != i + 10) return 1 + i; }
|
||||
{ long x = va_arg (ap, long); if (x != 123) return 10; }
|
||||
va_end (ap); return 0;
|
||||
}
|
||||
int main (void) { struct tiny x[3]; x[0].c=10; x[1].c=11; x[2].c=12; return f (3, x[0], x[1], x[2], (long) 123); }
|
||||
@@ -342,7 +342,7 @@ if [ "$BARE" != 1 ]; then
|
||||
[ -f "$LOADER_LUA" ] || fail "missing COFF loader: $LOADER_LUA"
|
||||
[ -f "$LOADER_BIN" ] || fail "missing COFF loader payload: $LOADER_BIN"
|
||||
fi
|
||||
[ -f "$HERE/shim.c" ] || fail "missing shim: $HERE/shim.c"
|
||||
[ -f "$ROOT/sdk/shim.c" ] || fail "missing shim: $ROOT/sdk/shim.c"
|
||||
[ -f "$HERE/entry.asm" ] || fail "missing entry: $HERE/entry.asm"
|
||||
|
||||
rm -rf "$WORK"
|
||||
@@ -377,9 +377,9 @@ cp "$SRC" "$COMPILE_SRC"
|
||||
# Link the optional heap object only when the test actually references the
|
||||
# allocator surface. Keeping it out of the common shim preserves the code
|
||||
# layout (and the shipped 300/600-frame gate timing) for non-heap tests.
|
||||
TEST_SOURCES="$COMPILE_SRC $HERE/shim.c"
|
||||
TEST_SOURCES="$COMPILE_SRC $ROOT/sdk/shim.c"
|
||||
if grep -Eq '(malloc|calloc|free)[[:space:]]*\(' "$COMPILE_SRC"; then
|
||||
TEST_SOURCES="$TEST_SOURCES $HERE/heap.c"
|
||||
TEST_SOURCES="$TEST_SOURCES $ROOT/sdk/heap.c"
|
||||
fi
|
||||
|
||||
link_once() {
|
||||
@@ -390,7 +390,7 @@ link_once() {
|
||||
M4_CLANG_OPT="$CLANG_OPT" \
|
||||
M4_LLC_OPT="$LLC_OPT" \
|
||||
M4_EXTRA_CFLAGS="${M5_CONFORMANCE_EXTRA_CFLAGS:-}" \
|
||||
M4_EXTRA_INCLUDES="-I $HERE/include -I $SRC_DIR" \
|
||||
M4_EXTRA_INCLUDES="-I $ROOT/sdk/include -I $SRC_DIR" \
|
||||
M4_WORK="$WORK/m4" \
|
||||
M4_COFF="$WORK/m4/m4.coff" \
|
||||
M4_SDK="$M4_SDK" \
|
||||
|
||||
@@ -47,7 +47,7 @@ fail() {
|
||||
|
||||
[ -f "$RUN" ] || fail "missing runner: $RUN"
|
||||
[ -x "$RUN" ] || fail "runner is not executable: $RUN"
|
||||
[ -f "$HERE/shim.c" ] || fail "missing shim: $HERE/shim.c"
|
||||
[ -f "$ROOT/sdk/shim.c" ] || fail "missing shim: $ROOT/sdk/shim.c"
|
||||
[ -f "$HERE/entry.asm" ] || fail "missing entry: $HERE/entry.asm"
|
||||
[ -f "$CLASSIFY" ] || fail "missing classifier: $CLASSIFY"
|
||||
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
# lowering landed. M9.1's inline-asm `r` support lets two x86-asm Generic
|
||||
# tests reach the target asm parser, so their reason is the new "inline asm
|
||||
# text is not TMS34010 assembly" (still unsupported, never counted as a pass).
|
||||
# M12 removed addr-label: blockaddress lowering made it compile. The `m`/`o`
|
||||
# memory-operand rows stay unsupported, but now fail in the asm parser rather
|
||||
# than in the memory-constraint hook (M12 also made the selected operand print).
|
||||
2007-04-08-MultipleFrameIndices inline asm register constraint cannot be allocated
|
||||
2007-04-27-InlineAsm-X-Dest inline asm text is not TMS34010 assembly
|
||||
2007-04-27-LargeMemObject inline asm memory constraint is not supported
|
||||
2007-12-17-InvokeAsm inline asm memory constraint is not supported
|
||||
2008-02-20-MatchingMem inline asm memory constraint is not supported
|
||||
2007-04-27-LargeMemObject inline asm syntax is not supported by the TMS34010 parser
|
||||
2007-12-17-InvokeAsm inline asm text is not TMS34010 assembly
|
||||
2008-02-20-MatchingMem inline asm syntax is not supported by the TMS34010 parser
|
||||
2008-08-07-PtrToInt-SmallerInt target rejection: unsupported .data initializer
|
||||
2010-ZeroSizedArg target rejection: TMS34010 supports only integer (<=64 bit) and pointer arguments
|
||||
APIntParam target rejection: TMS34010 supports only integer (<=64 bit) and pointer arguments
|
||||
@@ -30,7 +33,6 @@ APIntSextParam target rejection: TMS34010 supports only integer (<=64 bit) and p
|
||||
APIntZextParam target rejection: TMS34010 supports only integer (<=64 bit) and pointer arguments
|
||||
GlobalISel/irtranslator-byte-type target rejection: M2 supports only void/integer(<=64)/pointer returns
|
||||
add-with-overflow-128 target rejection: TMS34010 supports only integer (<=64 bit) and pointer arguments
|
||||
addr-label blockaddress values are not supported
|
||||
annotate target rejection: unsupported .data initializer
|
||||
bfloat target rejection: M2 supports only void/integer(<=64)/pointer returns
|
||||
bfloat-op missing libcall lowering (floats/vectors are deferred to M6)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# scripts/tests/m6/runtime.sh
|
||||
#
|
||||
# Compiles the C driver scripts/m6/runtime-main.c and the shared conformance
|
||||
# shim scripts/tests/m5/conformance/shim.c (a separate translation unit),
|
||||
# shim sdk/shim.c (a separate translation unit),
|
||||
# assembles/links them with GSPA/GSPLNK 2.00 and the 1990 flib.lib/rts.lib
|
||||
# under DOSBox, loads the COFF with the existing dwt loader and runs it in
|
||||
# MAME. Both -O0 and -O2 run by default; RUNTIME_OPT=-O0 (or -O2) selects one.
|
||||
@@ -42,7 +42,7 @@ set -eu
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
|
||||
DIR=$ROOT/scripts/m6
|
||||
SHIM=$ROOT/scripts/tests/m5/conformance/shim.c
|
||||
SHIM=$ROOT/sdk/shim.c
|
||||
|
||||
LLVM_BIN=${LLVM_BIN:-$ROOT/build/llvm-clean-build/bin}
|
||||
TMS_LLC=${TMS_LLC:-$LLVM_BIN/llc}
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
# bit-pointer barrier) and `llc -filetype=obj`; require the object's
|
||||
# long-named `.debug_*` sections and assert, in the final IR, that the
|
||||
# `@debug_ptr` body's barrier-synthesized instructions (`mul`, `shl i32`,
|
||||
# `ptrtoint ptr`, `add i32`, `inttoptr i32`) plus its loads/stores carry
|
||||
# `ptrtoint ptr`, `llvm.tms34010.bitaddr`, `inttoptr i32`) plus its
|
||||
# loads/stores carry
|
||||
# `!dbg`. The TU has three functions: debug_mul (int arithmetic),
|
||||
# debug_add (int arithmetic), and debug_ptr (`p += debug_index; return *p`,
|
||||
# a runtime GEP the barrier rewrites).
|
||||
# 2. Also build the same TU with `tms-clang -g -O2` (the full
|
||||
# --bitptr -> opt -> --scale -> --lower-bitptr -> instcombine path), require
|
||||
# 2. Also build the same TU with `tms-clang -g -O2` (the native M10 new-PM
|
||||
# pipeline: `TMS34010BitPtrPass` -> optimizer -> `TMS34010ScaleGEPPass` ->
|
||||
# `TMS34010LowerBitPtrPass` -> instcombine), require
|
||||
# the six core `.debug_*` sections, link it with `--keep-debug`, wrap it and
|
||||
# smoke-check `debug.c`, a subprogram name and the linked base address with
|
||||
# llvm-dwarfdump. The optimized layout is not stable, so the exact
|
||||
@@ -88,7 +90,7 @@ echo "== compile scripts/m7/debug.c with tms-clang -g and llc -filetype=obj"
|
||||
grep -q '!dbg' "$WORK/debug.ll" || fail "debug.ll has no !dbg metadata"
|
||||
|
||||
# The barrier-synthesized instructions must carry !dbg, not just the ordinary
|
||||
# loads/stores. Extract @debug_ptr and check the --bitptr / --lower-bitptr
|
||||
# loads/stores. Extract @debug_ptr and check the llvm.tms34010.bitaddr
|
||||
# chain plus the load/store through the computed pointer. This is the
|
||||
# attribution the line-table rows alone cannot prove.
|
||||
awk '
|
||||
@@ -116,7 +118,7 @@ check_dbg_line() { # check_dbg_line LABEL ERE
|
||||
check_dbg_line "GEP index multiply" 'mul i32 .*'
|
||||
check_dbg_line "bit-offset shl" 'shl i32 .* 3'
|
||||
check_dbg_line "ptrtoint base" 'ptrtoint ptr .* to i32'
|
||||
check_dbg_line "bit-address add" 'add i32 .*'
|
||||
check_dbg_line "bit-address intrinsic" 'call i32 @llvm\.tms34010\.bitaddr'
|
||||
check_dbg_line "lowered inttoptr" 'inttoptr i32 .* to ptr'
|
||||
for op in store load; do
|
||||
grep -E "^[[:space:]]*${op} |^[[:space:]]*%[^ ]+ = ${op} " \
|
||||
@@ -129,7 +131,7 @@ for op in store load; do
|
||||
fail "@debug_ptr has a $op without !dbg"
|
||||
fi
|
||||
done
|
||||
echo " @debug_ptr barrier IR: mul/shl/ptrtoint/add/inttoptr + loads/stores"
|
||||
echo " @debug_ptr barrier IR: mul/shl/ptrtoint/bitaddr/inttoptr + loads/stores"
|
||||
echo " all carry !dbg"
|
||||
|
||||
"$TMS_LLC" -march=tms34010 -O0 -filetype=obj \
|
||||
@@ -153,8 +155,9 @@ print(" object debug sections: " + " ".join(debug))
|
||||
PY
|
||||
|
||||
echo "== build the same TU at -O2 -g (full barrier/optimizer pipeline)"
|
||||
# -O2 runs clang -> --bitptr -> opt -> --scale -> --lower-bitptr ->
|
||||
# instcombine. Requiring the object's .debug_* sections from this build (and
|
||||
# -O2 runs clang's native M10 new-PM pipeline: TMS34010BitPtrPass (barrier) ->
|
||||
# optimizer -> TMS34010ScaleGEPPass -> TMS34010LowerBitPtrPass -> instcombine.
|
||||
# Requiring the object's .debug_* sections from this build (and
|
||||
# the dwarfdump check below) proves !dbg survives the barrier and the
|
||||
# optimizer, not just the -O0 path.
|
||||
( cd "$DIR" && "$TMS_CLANG" -g -O2 -o "$WORK/debug-o2.ll" debug.c ) \
|
||||
|
||||
@@ -501,6 +501,12 @@ dialect_flags() {
|
||||
if printf '%s\n' "$directives" | grep -q -- '-fwrapv'; then
|
||||
flags="${flags:+$flags }-fwrapv"
|
||||
fi
|
||||
# eeprof-1 asks for GCC's function-entry/exit instrumentation hooks via
|
||||
# dg-options; without them its counters stay zero and it aborts. Forward
|
||||
# the one flag, per row, exactly as the other dg-options are forwarded.
|
||||
if printf '%s\n' "$directives" | grep -q -- '-finstrument-functions'; then
|
||||
flags="${flags:+$flags }-finstrument-functions"
|
||||
fi
|
||||
printf '%s' "$flags"
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,38 @@
|
||||
# (20 `r` constraint rows plus simd-5 and pr123625-2). The five remaining
|
||||
# rows from that class now carry an accurate reason: 20030222-1 ties a 64-bit
|
||||
# input to a 32-bit `r` output, pr23135 compiles but does not finish, simd-1/
|
||||
# simd-2 compile but abort during vector arithmetic, and stkalign still needs
|
||||
# an unsupported memory operand.
|
||||
# simd-2 compile but abort during vector arithmetic, and stkalign still needed
|
||||
# an unsupported memory operand at M9.1 (M12 supplies it; see the M12 note
|
||||
# below).
|
||||
# M12 removed the 10 inline-asm memory-constraint rows that now pass
|
||||
# (pr103376, pr40022, pr40657, pr56866, pr65053-2, pr68328, pr81588, pr82954,
|
||||
# pr85156, pr94130). The eleventh row of that class, stkalign, now selects
|
||||
# its memory operand but aborts on its own __alignof__ premise under the
|
||||
# packed-struct ABI (aligned(64) is clamped to 1), so it was re-reasoned as
|
||||
# runtime-abort-alignment rather than flipped.
|
||||
# M12 also removed the two computed-goto rows (920501-3, 990208-1) once
|
||||
# `jump Rd`, BRIND and blockaddress lowered. Both pass at -O0 (the gated
|
||||
# mode). 990208-1's -O2 run aborts in its own `#ifdef __OPTIMIZE__` branch
|
||||
# because LLVM refuses to inline a function whose block address is taken
|
||||
# (InlineCost: "blockaddress used"); clang-19 on x86-64 aborts the same way,
|
||||
# so that is a generic-LLVM limitation, not a TMS34010 codegen gap.
|
||||
# M12 also removed the three level-0 return/frame-address rows (20030811-1,
|
||||
# frame-address, pr17377) once llvm.returnaddress(0) lowered to the
|
||||
# system-stack return word and llvm.frameaddress(0) to A13. The other two
|
||||
# rows of that class stay curated because they ask for levels above 0
|
||||
# (20010122-1 uses level 1, 20030323-1 walks to level 100), which remain a
|
||||
# named error, so their reasons were restated rather than removed.
|
||||
# M12 also removed 20070824-1. Its `__builtin_alloca` sits in a non-entry
|
||||
# block with a constant count, so the DAG folds the byte->bit shift of the
|
||||
# dynamic alloca size; the lowering's shape assertion aborted on the folded
|
||||
# constant. The size is now scaled explicitly in both shapes, and the bit
|
||||
# advance is pinned by m12-dynalloca.ll.
|
||||
# M12 also removed eeprof-1, the one qualifying one-flag/one-condition abort
|
||||
# fix: the test's own dg-options asks for -finstrument-functions, but
|
||||
# dialect_flags() forwarded only -std/-fgnu89-inline/-fwrapv, so no
|
||||
# __cyg_profile_func_enter/exit calls were emitted and its counters stayed
|
||||
# zero. dialect_flags() now forwards that flag per row; the unmodified test
|
||||
# passes at -O0 (the gated mode) and -O2 (verified through the M5 runner).
|
||||
#
|
||||
# Categories: compiler-crash, codegen, inline-asm, nested-function, vla,
|
||||
# data-init, data-vector, data-odd-pointer, abi-*, builtin, libm, memory,
|
||||
@@ -28,7 +58,7 @@ c-testsuite/00040 timeout: did not finish within LOADER_END=1000
|
||||
c-testsuite/00174 libm: sin/float formatting differs from the expected libm output
|
||||
c-torture/20000822-1 nested-function: nested function definitions are unsupported
|
||||
c-torture/20001111-1 builtin: use of unknown builtin '__builtin_exit' [-Wimplicit-function-declaration]
|
||||
c-torture/20010122-1 compiler-crash: unexpected TMS34010 custom lowering operation (return address)
|
||||
c-torture/20010122-1 compiler-crash: llvm.returnaddress level > 0 unsupported (only level 0)
|
||||
c-torture/20010209-1 nested-function: nested function definitions are unsupported
|
||||
c-torture/20010605-1 nested-function: nested function definitions are unsupported
|
||||
c-torture/20010605-2 libc: call to undeclared function 'exit'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
|
||||
@@ -43,9 +73,8 @@ c-torture/20021010-2 data-init: unsupported .data initializer
|
||||
c-torture/20021127-1 runtime-abort-i64: test abort (status 0x86)
|
||||
c-torture/20030209-1 memory: linked image exceeds the 45 KiB program / 64 KiB RAM region
|
||||
c-torture/20030222-1 inline-asm: a 64-bit "0" input tied to a 32-bit 'r' output has no allocatable register pair
|
||||
c-torture/20030323-1 compiler-crash: unexpected TMS34010 custom lowering operation
|
||||
c-torture/20030323-1 compiler-crash: llvm.returnaddress level > 0 unsupported (only level 0)
|
||||
c-torture/20030501-1 nested-function: nested function definitions are unsupported
|
||||
c-torture/20030811-1 compiler-crash: unexpected TMS34010 custom lowering operation
|
||||
c-torture/20031003-1 runtime-abort-float: test abort (status 0x86)
|
||||
c-torture/20040223-1 compile: incompatible integer to pointer conversion passing 'int' to parameter of type 'char *' [-Wint-conversion]
|
||||
c-torture/20040302-1 data-init: unsupported .data initializer
|
||||
@@ -67,7 +96,6 @@ c-torture/20051012-1 timeout: did not finish within LOADER_END=1000
|
||||
c-torture/20060420-1 runtime-abort-i64: test abort (status 0x86)
|
||||
c-torture/20061220-1 nested-function: nested function definitions are unsupported
|
||||
c-torture/20070614-1 abi-sret: aggregate return via an sret pointer is unsupported
|
||||
c-torture/20070824-1 compiler-crash: dynamic alloca size scaling assertion
|
||||
c-torture/20070919-1 vla: variable-length array in a struct is unsupported
|
||||
c-torture/20071210-1 data-init: unsupported .data initializer
|
||||
c-torture/20071220-1 data-init: unsupported .data initializer
|
||||
@@ -82,7 +110,6 @@ c-torture/920302-1 compile: incompatible pointer types passing 'short (*)[5]' to
|
||||
c-torture/920415-1 nested-function: nested function definitions are unsupported
|
||||
c-torture/920428-1 runtime-abort: test abort (status 0x86)
|
||||
c-torture/920428-2 nested-function: nested function definitions are unsupported
|
||||
c-torture/920501-3 codegen: t24: i32 = BlockAddress<@execute, %base> 0
|
||||
c-torture/920501-4 data-init: unsupported .data initializer
|
||||
c-torture/920501-5 data-init: unsupported .data initializer
|
||||
c-torture/920501-7 nested-function: nested function definitions are unsupported
|
||||
@@ -107,7 +134,6 @@ c-torture/941202-1 timeout: did not finish within LOADER_END=1000
|
||||
c-torture/960512-1 abi-sret: aggregate return via an sret pointer is unsupported
|
||||
c-torture/960521-1 timeout: did not finish within LOADER_END=1000
|
||||
c-torture/980709-1 timeout: did not finish within LOADER_END=1000
|
||||
c-torture/990208-1 codegen: t5: i32 = BlockAddress<@doit, %here> 0
|
||||
c-torture/990413-2 inline-asm: invalid output constraint '=t'
|
||||
c-torture/991112-1 runtime-abort: test abort (status 0x86)
|
||||
c-torture/align-nest vla: variable-length array in a struct is unsupported
|
||||
@@ -126,9 +152,7 @@ c-torture/complex-2 abi-sret: aggregate return via an sret pointer is unsupporte
|
||||
c-torture/complex-5 abi-sret: aggregate return via an sret pointer is unsupported
|
||||
c-torture/complex-6 abi-sret: aggregate return via an sret pointer is unsupported
|
||||
c-torture/conversion codegen-float: only 32-bit integer sources are supported for float/double conversions
|
||||
c-torture/eeprof-1 runtime-abort: test abort (status 0x86)
|
||||
c-torture/floatunsisf-1 runtime-abort-i64: test abort (status 0x86)
|
||||
c-torture/frame-address compiler-crash: unexpected TMS34010 custom lowering operation (frame address)
|
||||
c-torture/memclr memory: linked image exceeds the 45 KiB program / 64 KiB RAM region
|
||||
c-torture/memcpy-1 output: test writes more than the 16 KiB shim cap
|
||||
c-torture/memcpy-a1 memory: linked image exceeds the 45 KiB program / 64 KiB RAM region
|
||||
@@ -145,7 +169,6 @@ c-torture/nestfunc-6 nested-function: nested function definitions are unsupporte
|
||||
c-torture/nestfunc-7 nested-function: nested function definitions are unsupported
|
||||
c-torture/pr103052 builtin: use of unknown builtin '__builtin_exit' [-Wimplicit-function-declaration]
|
||||
c-torture/pr103255 runtime-abort-i64: test abort (status 0x86)
|
||||
c-torture/pr103376 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr103405 nested-function: nested function definitions are unsupported
|
||||
c-torture/pr105777 corpus: references a gcc.dg source absent from the pinned execute tree
|
||||
c-torture/pr105984 builtin: use of unknown builtin '__builtin_mul_overflow_p' [-Wimplicit-function-declaration]
|
||||
@@ -162,7 +185,6 @@ c-torture/pr123864 builtin: use of unknown builtin '__builtin_mul_overflow_p' [-
|
||||
c-torture/pr125291 abi-indirect-call: indirect call through a non-function value
|
||||
c-torture/pr126405-3 abi-return: unsupported aggregate/variadic return shape
|
||||
c-torture/pr17252 timeout: did not finish within LOADER_END=1000
|
||||
c-torture/pr17377 compiler-crash: unexpected TMS34010 custom lowering operation
|
||||
c-torture/pr20621-1 timeout: compilation did not finish within the 210s outer wall
|
||||
c-torture/pr22061-1 compile: incompatible integer to pointer conversion assigning to 'void *' from 'int' [-Wint-conversion]
|
||||
c-torture/pr22061-3 nested-function: nested function definitions are unsupported
|
||||
@@ -181,8 +203,6 @@ c-torture/pr38051 runtime-abort-i64: test abort (status 0x86)
|
||||
c-torture/pr38151 runtime-abort-varargs: test abort (status 0x86)
|
||||
c-torture/pr38969 abi-sret: aggregate return via an sret pointer is unsupported
|
||||
c-torture/pr39228 builtin: use of unknown builtin '__builtin_isinff' [-Wimplicit-function-declaration]
|
||||
c-torture/pr40022 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr40657 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr41935 vla: variable-length array in a struct is unsupported
|
||||
c-torture/pr44575 runtime-abort-varargs: test abort (status 0x86)
|
||||
c-torture/pr44683 runtime-abort-float: test abort (status 0x86)
|
||||
@@ -192,7 +212,6 @@ c-torture/pr51581-1 memory: linked image exceeds the 45 KiB program / 64 KiB RAM
|
||||
c-torture/pr51581-2 memory: linked image exceeds the 45 KiB program / 64 KiB RAM region
|
||||
c-torture/pr53645 data-init: unsupported .data initializer
|
||||
c-torture/pr53645-2 data-init: unsupported .data initializer
|
||||
c-torture/pr56866 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr57344-3 runtime-abort-i64: test abort (status 0x86)
|
||||
c-torture/pr57344-4 runtime-abort-i64: test abort (status 0x86)
|
||||
c-torture/pr58209 runtime-abort: test abort (status 0x86)
|
||||
@@ -202,11 +221,9 @@ c-torture/pr60822 memory: linked image exceeds the 45 KiB program / 64 KiB RAM r
|
||||
c-torture/pr60960 abi-return: unsupported aggregate/variadic return shape
|
||||
c-torture/pr63843 timeout: codegen fixed at the M7.4 pin; already compiled at the M8 base and hangs identically (status 1, no completion magic)
|
||||
c-torture/pr64242 setjmp: __builtin_longjmp is unsupported
|
||||
c-torture/pr65053-2 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr65401 runtime-abort: test abort (status 0x86)
|
||||
c-torture/pr65427 runtime-abort: test abort (status 0x86)
|
||||
c-torture/pr67037 timeout: did not finish within LOADER_END=1000
|
||||
c-torture/pr68328 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr68390 abi-varargs-return: float/double/i64/aggregate return from a variadic definition is unsupported
|
||||
c-torture/pr70460 data-init: unsupported .data initializer
|
||||
c-torture/pr70566 timeout: did not finish within LOADER_END=1000
|
||||
@@ -218,15 +235,11 @@ c-torture/pr78791 data-init: unsupported .data initializer
|
||||
c-torture/pr79327 runtime-abort: test abort (status 0x86)
|
||||
c-torture/pr79737-2 runtime-abort: test abort (status 0x86)
|
||||
c-torture/pr80692 extension: GNU decimal float type is unsupported
|
||||
c-torture/pr81588 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr82210 vla: variable-length array in a struct is unsupported
|
||||
c-torture/pr82954 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr84521 setjmp: __builtin_longjmp is unsupported
|
||||
c-torture/pr85156 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr85169 runtime-abort: test abort (status 0x86)
|
||||
c-torture/pr85331 builtin: use of unknown builtin '__builtin_shuffle' [-Wimplicit-function-declaration]
|
||||
c-torture/pr92618 abi-return: unsupported aggregate/variadic return shape
|
||||
c-torture/pr94130 inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/pr94412 runtime-abort: test abort (status 0x86)
|
||||
c-torture/pr94524-1 abi-return: unsupported aggregate/variadic return shape
|
||||
c-torture/pr94524-2 abi-return: unsupported aggregate/variadic return shape
|
||||
@@ -241,7 +254,7 @@ c-torture/simd-2 runtime-abort-vector: test abort (status 0x86)
|
||||
c-torture/simd-4 abi-float-args: float/double arguments are unsupported
|
||||
c-torture/simd-6 abi-return: unsupported aggregate/variadic return shape
|
||||
c-torture/stdarg-3 runtime-abort-varargs: test abort (status 0x86)
|
||||
c-torture/stkalign inline-asm: TMS34010 memory constraints ('m'/'o'/'V') are unsupported (no addressing-mode matcher)
|
||||
c-torture/stkalign runtime-abort-alignment: packed-struct ABI makes __alignof__(aligned(64)) 1, so the test's assert aborts; the inline-asm memory operand now selects (status 0x86)
|
||||
c-torture/strct-stdarg-1 runtime-abort-varargs: test abort (status 0x86)
|
||||
c-torture/strct-varg-1 runtime-abort-varargs: test abort (status 0x86)
|
||||
c-torture/string-opt-18 timeout: did not finish within LOADER_END=1000
|
||||
|
||||
+4
-3
@@ -31,9 +31,10 @@ LLC = Path(os.environ.get("TMS_LLC", ROOT / "build/llvm-clean-build/bin/llc"))
|
||||
RUN_SH = ROOT / "scripts/m4/run.sh"
|
||||
CONF = ROOT / "scripts/tests/m5/conformance"
|
||||
ENTRY = CONF / "entry.asm"
|
||||
SHIM = CONF / "shim.c"
|
||||
HEAP = CONF / "heap.c"
|
||||
INCLUDE = CONF / "include"
|
||||
SDK = ROOT / "sdk"
|
||||
SHIM = SDK / "shim.c"
|
||||
HEAP = SDK / "heap.c"
|
||||
INCLUDE = SDK / "include"
|
||||
TMS_LINK = ROOT / "tools/tms-link/tms-link"
|
||||
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ def main(argv):
|
||||
out = bytes.fromhex(vals.get("out", ""))
|
||||
err = bytes.fromhex(vals.get("err", ""))
|
||||
print(f"status: {status} (0x{status:08X})")
|
||||
print(f"magic: {magic}")
|
||||
sys.stdout.flush()
|
||||
if out:
|
||||
sys.stdout.buffer.write(b"stdout:\n" + out)
|
||||
|
||||
Executable
+140
@@ -0,0 +1,140 @@
|
||||
#!/bin/sh
|
||||
# tms-sdk -- build and install the TMS34010 freestanding sysroot.
|
||||
#
|
||||
# scripts/tms-sdk [--sysroot DIR]
|
||||
#
|
||||
# Builds sdk/crt0.ll with llc and sdk/{shim,heap}.c with clang into libtms.a,
|
||||
# then installs a sysroot the M11 driver searches:
|
||||
#
|
||||
# <sysroot>/include/*.h (from sdk/include)
|
||||
# <sysroot>/lib/crt0.o (llc -filetype=obj)
|
||||
# <sysroot>/lib/libtms.a (llvm-ar rcsD of shim.o + heap.o)
|
||||
# <sysroot>/lib/{flib,rts}.lib (the committed 1990 vendor archives)
|
||||
# <sysroot>/bin/{tms-link,tmscoff.py} (the linker and its sibling module)
|
||||
#
|
||||
# The default sysroot is <clang -print-resource-dir>/tms34010-unknown-none;
|
||||
# --sysroot DIR installs elsewhere (the driver then needs --tms-sysroot=DIR).
|
||||
# Installing is idempotent: llc and llvm-ar rcsD rebuild byte-identically.
|
||||
# A successful install writes <sysroot>/.tms-sdk; an existing non-empty
|
||||
# directory without that marker is refused, so include/ is never replaced in
|
||||
# a directory this script did not create (and `/` is rejected outright).
|
||||
#
|
||||
# Overridable: LLVM_BIN CLANG LLC LLVM_AR
|
||||
set -eu
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
||||
LLVM_BIN=${LLVM_BIN:-$ROOT/build/llvm-clean-build/bin}
|
||||
CLANG=${CLANG:-$LLVM_BIN/clang}
|
||||
LLC=${LLC:-$LLVM_BIN/llc}
|
||||
LLVM_AR=${LLVM_AR:-$LLVM_BIN/llvm-ar}
|
||||
|
||||
SYSROOT=
|
||||
|
||||
fail() {
|
||||
echo "tms-sdk: error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--sysroot)
|
||||
[ $# -ge 2 ] || fail "--sysroot needs an argument"
|
||||
SYSROOT=$2
|
||||
shift 2
|
||||
;;
|
||||
--sysroot=*)
|
||||
SYSROOT=${1#--sysroot=}
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
fail "unknown argument: $1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for tool in "$CLANG" "$LLC"; do
|
||||
[ -x "$tool" ] || fail "missing tool: $tool"
|
||||
done
|
||||
|
||||
# llvm-ar is not part of the default ninja target set the other gates build;
|
||||
# rebuild it on demand so a fresh checkout still installs.
|
||||
if [ ! -x "$LLVM_AR" ]; then
|
||||
echo "tms-sdk: llvm-ar missing; running: ninja -C $ROOT/build/llvm-clean-build llvm-ar"
|
||||
ninja -C "$ROOT/build/llvm-clean-build" llvm-ar || fail "ninja llvm-ar failed"
|
||||
[ -x "$LLVM_AR" ] || fail "llvm-ar still missing after ninja: $LLVM_AR"
|
||||
fi
|
||||
|
||||
if [ -z "$SYSROOT" ]; then
|
||||
RESOURCE_DIR=$("$CLANG" -print-resource-dir) \
|
||||
|| fail "clang -print-resource-dir failed"
|
||||
SYSROOT=$RESOURCE_DIR/tms34010-unknown-none
|
||||
fi
|
||||
|
||||
MARKER=.tms-sdk
|
||||
MARKER_TEXT="tms-sdk M11 tms34010-unknown-none"
|
||||
|
||||
# SYSROOT is user-supplied, so never treat an arbitrary directory as
|
||||
# disposable. Only an absent/empty target or one this script installed (it
|
||||
# carries the marker) may have its include/ replaced.
|
||||
case $SYSROOT in
|
||||
/) fail "refusing unsafe sysroot '/'" ;;
|
||||
esac
|
||||
BASE=$(basename "$SYSROOT")
|
||||
[ -n "$BASE" ] || fail "refusing sysroot with an empty basename: '$SYSROOT'"
|
||||
if [ -e "$SYSROOT" ]; then
|
||||
[ -d "$SYSROOT" ] || fail "sysroot is not a directory: $SYSROOT"
|
||||
if [ -n "$(ls -A "$SYSROOT" 2>/dev/null)" ] && [ ! -f "$SYSROOT/$MARKER" ]; then
|
||||
fail "refusing to overwrite $SYSROOT: not an M11 sysroot (no $MARKER file); pass an empty directory or use the default"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -f "$ROOT/sdk/crt0.ll" ] || fail "missing CRT source: $ROOT/sdk/crt0.ll"
|
||||
[ -f "$ROOT/sdk/shim.c" ] || fail "missing shim source: $ROOT/sdk/shim.c"
|
||||
[ -f "$ROOT/sdk/heap.c" ] || fail "missing heap source: $ROOT/sdk/heap.c"
|
||||
[ -d "$ROOT/sdk/include" ] || fail "missing header directory: $ROOT/sdk/include"
|
||||
[ -f "$ROOT/sdk/lib/flib.lib" ] || fail "missing vendor archive: $ROOT/sdk/lib/flib.lib"
|
||||
[ -f "$ROOT/sdk/lib/rts.lib" ] || fail "missing vendor archive: $ROOT/sdk/lib/rts.lib"
|
||||
[ -f "$ROOT/tools/tms-link/tms-link" ] || fail "missing linker: $ROOT/tools/tms-link/tms-link"
|
||||
[ -f "$ROOT/tools/tms-link/tmscoff.py" ] || fail "missing linker module: $ROOT/tools/tms-link/tmscoff.py"
|
||||
|
||||
WORK=$(mktemp -d "${TMPDIR:-/tmp}/tms-sdk.XXXXXX")
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
echo "== build crt0.o from sdk/crt0.ll (llc)"
|
||||
"$LLC" -march=tms34010 -filetype=obj "$ROOT/sdk/crt0.ll" -o "$WORK/crt0.o" \
|
||||
|| fail "llc could not build sdk/crt0.ll"
|
||||
|
||||
echo "== build shim.o and heap.o (clang --target=tms34010 -O2 -c)"
|
||||
"$CLANG" --target=tms34010 -O2 -c -I "$ROOT/sdk/include" \
|
||||
"$ROOT/sdk/shim.c" -o "$WORK/shim.o" || fail "clang -c shim.c failed"
|
||||
"$CLANG" --target=tms34010 -O2 -c -I "$ROOT/sdk/include" \
|
||||
"$ROOT/sdk/heap.c" -o "$WORK/heap.o" || fail "clang -c heap.c failed"
|
||||
|
||||
echo "== archive libtms.a (llvm-ar rcsD)"
|
||||
( cd "$WORK" && "$LLVM_AR" rcsD libtms.a shim.o heap.o ) \
|
||||
|| fail "llvm-ar rcsD failed"
|
||||
|
||||
echo "== install into $SYSROOT"
|
||||
# Replace the installed header set so a header deleted from sdk/include is
|
||||
# removed here too (copying would leave stale headers behind).
|
||||
rm -rf "$SYSROOT/include"
|
||||
mkdir -p "$SYSROOT/include" "$SYSROOT/lib" "$SYSROOT/bin"
|
||||
|
||||
for h in "$ROOT"/sdk/include/*.h; do
|
||||
cp "$h" "$SYSROOT/include/"
|
||||
done
|
||||
|
||||
cp "$WORK/crt0.o" "$SYSROOT/lib/crt0.o"
|
||||
cp "$WORK/libtms.a" "$SYSROOT/lib/libtms.a"
|
||||
cp "$ROOT/sdk/lib/flib.lib" "$SYSROOT/lib/flib.lib"
|
||||
cp "$ROOT/sdk/lib/rts.lib" "$SYSROOT/lib/rts.lib"
|
||||
|
||||
cp "$ROOT/tools/tms-link/tms-link" "$SYSROOT/bin/tms-link"
|
||||
cp "$ROOT/tools/tms-link/tmscoff.py" "$SYSROOT/bin/tmscoff.py"
|
||||
chmod +x "$SYSROOT/bin/tms-link"
|
||||
|
||||
# Mark the directory as ours so a later install may replace its include/.
|
||||
printf '%s\n' "$MARKER_TEXT" > "$SYSROOT/$MARKER"
|
||||
|
||||
NHEADERS=$(find "$SYSROOT/include" -name '*.h' | wc -l)
|
||||
echo "tms-sdk: installed $NHEADERS headers, crt0.o, libtms.a, flib.lib, rts.lib, and the tms-link pair into $SYSROOT"
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
; crt0.ll -- the TMS34010 CRT, expressed as LLVM IR and built with llc.
|
||||
;
|
||||
; The CRT's machine code is a `naked` `_start` whose body is one inline-asm
|
||||
; block; llc -filetype=obj routes it through the target's TI-COFF writer (the
|
||||
; MC llvm-mc path emits ELF, which tms-link cannot read). The instruction
|
||||
; sequence is byte-identical to the reference in
|
||||
; scripts/tests/m5/conformance/entry.asm; only the carrier changed.
|
||||
;
|
||||
; Runtime contract (unchanged from entry.asm):
|
||||
; 01B00000 status main's return value (A8), cleared on entry
|
||||
; 01B00020 out_len maintained by the conformance shim
|
||||
; 01B00040 magic 0x434F4E46 written after main returns
|
||||
; 01B00060 err_len maintained by the conformance shim
|
||||
;
|
||||
; A14 (the program stack) and A13 (the frame pointer) start at _cstack, a
|
||||
; 4 KiB / 32768-bit stack at 16-bit alignment. main is called as
|
||||
; main(1, argv) with argv = { _conformance_name, NULL }, where
|
||||
; _conformance_name is the 12 bytes "conformance\0" and _conformance_argv is
|
||||
; 64 bits (8 bytes). argv is filled at runtime in the asm block rather than
|
||||
; with a pointer initialiser, so the CRT needs no pointer-initialiser
|
||||
; relocation.
|
||||
;
|
||||
; LLVM prefixes global symbols with `_` on this target, so the IR names here
|
||||
; carry no leading underscore and the inline asm refers to the final names
|
||||
; (_cstack, _conformance_argv, _conformance_name, _main).
|
||||
|
||||
target triple = "tms34010"
|
||||
|
||||
@conformance_name = constant [12 x i8] c"conformance\00", align 1
|
||||
@conformance_argv = global [2 x i32] zeroinitializer, align 2
|
||||
@cstack = global [4096 x i8] zeroinitializer, align 2
|
||||
|
||||
; `_main` is referenced by name inside the inline-asm block below (calla _main);
|
||||
; the MC parser creates the undefined symbol, so no IR declaration is needed.
|
||||
|
||||
define void @start() #0 {
|
||||
entry:
|
||||
; setf 16,1,0 / setf 32,0,1; clear the four result cells; point A14/A13 at
|
||||
; _cstack; build argv = { _conformance_name, NULL }; push argv then 1 and
|
||||
; calla _main; publish A8 as the status and 0x434F4E46 as the magic. The
|
||||
; trailing `rets` is the function's own `ret`.
|
||||
call void asm sideeffect "setf 16, 1, 0\0A\09setf 32, 0, 1\0A\09movi 0x01B00000, a1\0A\09sub a0, a0\0A\09move a0, *a1, 1\0A\09movi 0x01B00020, a1\0A\09move a0, *a1, 1\0A\09movi 0x01B00040, a1\0A\09move a0, *a1, 1\0A\09movi 0x01B00060, a1\0A\09move a0, *a1, 1\0A\09movi _cstack, a14\0A\09move a14, a13\0A\09movi _conformance_argv, a0\0A\09movi _conformance_name, a1\0A\09move a1, *a0, 1\0A\09sub a1, a1\0A\09move a1, *a0(32), 1\0A\09move a14, -*sp, 1\0A\09move a0, *a14+, 1\0A\09movi 1, a1\0A\09move a1, *a14+, 1\0A\09calla _main\0A\09setf 16, 1, 0\0A\09setf 32, 0, 1\0A\09movi 0x01B00000, a1\0A\09move a8, *a1, 1\0A\09movi 0x01B00040, a1\0A\09movi 0x434F4E46, a0\0A\09move a0, *a1, 1", ""()
|
||||
ret void
|
||||
}
|
||||
|
||||
attributes #0 = { naked }
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
File renamed without changes.
@@ -979,6 +979,20 @@ def raw_debug(work):
|
||||
% (u32(data, 8), u32(data, 13 + 8)))
|
||||
|
||||
|
||||
def make_odd_bss(work):
|
||||
"""Write a minimal input whose .bss is an odd 8-bit size (one byte).
|
||||
|
||||
llc rounds .bss up to a whole 16-bit word, but GSPA can emit a single
|
||||
8-bit .bss symbol and GSPLNK forwards that odd size, which the dwt loader
|
||||
rejects. tms-link must accept the odd .bss and round it up on output.
|
||||
"""
|
||||
write_minimal_object(os.path.join(work, "odd-bss.o"), [
|
||||
(".text", 0x20, b"\x00\x00\x00\x00"),
|
||||
(".data", 0x40, b""),
|
||||
(".bss", 0x80, b"\x00"),
|
||||
])
|
||||
|
||||
|
||||
def make_empty_cinit(work):
|
||||
"""Write a minimal 4-section input with a listed-but-empty .cinit."""
|
||||
path = os.path.join(work, "empty-cinit.o")
|
||||
@@ -1014,6 +1028,21 @@ def empty_cinit(work):
|
||||
% [s.name for s in out.sections])
|
||||
|
||||
|
||||
def odd_bss(work):
|
||||
"""An 8-bit .bss input must be rounded up to a whole 16-bit word."""
|
||||
out = read_object(os.path.join(work, "oddbss.out"), relocatable=False)
|
||||
bss = out.section_by_name[".bss"]
|
||||
check(bss.size == 16,
|
||||
".bss size %d bits, want 16 (rounded up from 8)" % bss.size)
|
||||
check(all(s.nreloc == 0 for s in out.sections),
|
||||
"odd-.bss output has relocations")
|
||||
globals_out = {s.name: s.value for s in out.symbols if s.sclass == C_EXT}
|
||||
check(globals_out.get("end") == bss.paddr + bss.size,
|
||||
"end symbol %#x, want .bss end %#x"
|
||||
% (globals_out.get("end"), bss.paddr + bss.size))
|
||||
print(" odd .bss: 8-bit input rounded to %d bits" % bss.size)
|
||||
|
||||
|
||||
def libflags(work):
|
||||
"""1990 metadata section bits are accepted; output stays classic."""
|
||||
obj = read_object(os.path.join(work, "patched-libflags.o"))
|
||||
@@ -1134,6 +1163,10 @@ def main(argv):
|
||||
explicit_layout(work)
|
||||
elif mode == "make-empty-cinit":
|
||||
make_empty_cinit(work)
|
||||
elif mode == "make-odd-bss":
|
||||
make_odd_bss(work)
|
||||
elif mode == "odd-bss":
|
||||
odd_bss(work)
|
||||
elif mode == "make-raw-debug":
|
||||
make_raw_debug(work)
|
||||
elif mode == "make-bad-debug":
|
||||
|
||||
@@ -50,6 +50,21 @@ echo "== positive link: two TUs, .cinit, long name, map"
|
||||
python3 "$DIR/linktest.py" positive "$WORK" \
|
||||
|| fail "positive assertions failed"
|
||||
|
||||
echo "== loader validity: emitted COFF passes coff-check unaided"
|
||||
"$TMS_LINK" -o "$WORK/coffcheck.out" --entry _shared_fn "$WORK/defs.o" \
|
||||
|| fail "coffcheck link failed"
|
||||
python3 "$ROOT/scripts/m4/coff-check.py" "$WORK/coffcheck.out" \
|
||||
|| fail "coff-check rejected the default image"
|
||||
|
||||
echo "== loader validity: odd-length .bss is rounded to a whole word"
|
||||
python3 "$DIR/linktest.py" make-odd-bss "$WORK" >/dev/null
|
||||
"$TMS_LINK" -o "$WORK/oddbss.out" "$WORK/odd-bss.o" \
|
||||
|| fail "odd-.bss link failed"
|
||||
python3 "$DIR/linktest.py" odd-bss "$WORK" \
|
||||
|| fail "odd-.bss rounding assertions failed"
|
||||
python3 "$ROOT/scripts/m4/coff-check.py" "$WORK/oddbss.out" \
|
||||
|| fail "coff-check rejected the odd-.bss image"
|
||||
|
||||
echo "== archives: selective extraction to a fixpoint"
|
||||
python3 "$DIR/linktest.py" make-archive "$WORK" >/dev/null \
|
||||
|| fail "could not write archive fixtures"
|
||||
|
||||
@@ -916,6 +916,13 @@ class Linker:
|
||||
self.data_size = self._total_size(".data")
|
||||
self.cinit_size = self._total_size(".cinit")
|
||||
self.bss_size = self._total_size(".bss")
|
||||
# The dwt loader requires a whole 16-bit .bss; GSPA may emit an odd
|
||||
# .bss (e.g. a single 8-bit symbol) and GSPLNK forwards it unrounded,
|
||||
# which the loader rejects. Round only .bss up to a whole word here
|
||||
# (the trailing bits stay allocated, matching scripts/m4/coff-check.py
|
||||
# --repair); .text/.data/.cinit, relocations and the entry point are
|
||||
# untouched.
|
||||
self.bss_size = align16(self.bss_size)
|
||||
# An input may contain a listed-but-empty .cinit (GSPA/GSPLNK shape).
|
||||
# It contributes no bytes and must not create an output section or the
|
||||
# public cinit symbol, matching GSPLNK's empty flags-0 section.
|
||||
@@ -1040,7 +1047,7 @@ class Linker:
|
||||
continue
|
||||
self.placements[(obj.path, ".bss")] = (out, bitoff)
|
||||
bitoff += sec.size
|
||||
if bitoff != self.bss_size:
|
||||
if bitoff != self._total_size(".bss"):
|
||||
raise LinkError("internal: .bss size mismatch")
|
||||
|
||||
def _add_debug(self, objects):
|
||||
|
||||
@@ -336,7 +336,13 @@ def read_object(path=None, relocatable=True, *, data=None, label=None):
|
||||
"number of bytes" % (path, name, size))
|
||||
|
||||
if name in ALLOCATED_NAMES:
|
||||
if size % 16:
|
||||
# .text/.data/.cinit carry whole 16-bit words; .bss is a virtual
|
||||
# section whose trailing byte is a legal TMS34010 bit address.
|
||||
# GSPA emits a single 8-bit .bss symbol and GSPLNK forwards it
|
||||
# unrounded, which the dwt loader rejects, so tms-link accepts the
|
||||
# odd .bss here and rounds it up on output (see write_coff's
|
||||
# caller and scripts/m4/coff-check.py).
|
||||
if size % 16 and name != ".bss":
|
||||
raise CoffError("%s: section %r size %d bits is not a whole "
|
||||
"number of 16-bit words"
|
||||
% (path, name, size))
|
||||
|
||||
Reference in new issue
Block a user