docs: finish the M2 loader and returned reconciliation

This commit is contained in:
arti committed 2026-11-11 16:59:30 +00:00
1 parent b614e70851
commit fa00b8740b
1 file changed
+2 -2
@@ -549,7 +549,7 @@ if (N->getOpcode() == ISD::FrameIndex) {
`LowerFormalArguments`:
- Keep the M1 IR-signature validation, changing messages to `M2 ...`: reject varargs (`M2 does not support varargs`), i8/i16 parameters (`M2 supports only i32 and pointer arguments`), i64/float/double/aggregates/vectors (the same message), and `sret`/`byval`/`inreg`/`nest`/`returned` (`M2 supports only plain arguments (no sret/byval/inreg/nest)`). Allow only i32 and pointers.
- Keep the M1 IR-signature validation, changing messages to `M2 ...`: reject varargs (`M2 does not support varargs`), i8/i16 parameters (`M2 supports only i32 and pointer arguments`), i64/float/double/aggregates/vectors (the same message), and `sret`/`byval`/`inreg`/`nest` (`M2 supports only plain arguments (no sret/byval/inreg/nest)`); accept the optimizer's `returned` hint. Allow only i32 and pointers.
- For argument `i` (0-based), create a fixed object of 4 bytes at byte offset `-(i+1)*4` (`MFI.CreateFixedObject(4, -(i+1)*4, true)`), load `i32` from it with alignment 2, and push the result to `InVals`. M2 supports only i32 and pointer arguments; the IR-signature validation above rejects narrow parameters.
- Do not use M1's A0–A3 `CCValAssign` register path.
@@ -886,7 +886,7 @@ SECTIONS
- Concatenate `entry.asm`, the five `.s` files, and `rom-imports.asm` into `M2.ASM`.
- Extract the SDK if `GSPA.EXE` is missing, write `M2.CMD` with CRLF, run `gspa M2 M2.obj M2.lst -l` and `gsplnk M2.cmd` under DOSBox, require `No Errors` **and** `No Warnings`.
- Copy `M2.OUT` to `$M2_COFF`; resolve `_start`, `.text`, `.data`, `.bss` from `M2.MAP`; require `_start = 018A0000`, `.bss` origin `018A9000`, and a non-empty `.data`.
- Run MAME exactly as `scripts/m1/run.sh` does, with `LOADER_COFF=$M2_COFF`, `LOADER_OUT=$WORK/evidence`, `M2_LOADER_LUA=$ROOT/scripts/m2/m2-check.lua`, and pass the expected markers.
- Run MAME exactly as `scripts/m1/run.sh` does, with `LOADER_COFF=$M2_COFF`, `LOADER_OUT=$WORK/evidence`, `M2_LOADER_LUA=$ROOT/vendor/vt1200/dwt/loader/loader.lua` (the vendor loader; the MAME autoboot script is `scripts/m2/m2-check.lua`), and pass the expected markers.
- Fail if the loader does not report `status=0 (OK)` or if `.text` differs.
`scripts/m2/m2-check.lua` reads and checks: