Files
BFM-decomp/tools/cc1_dumps.sh
T
Drew T d242877065 feat(phase-30 S50): func_8017C294 frame residual decoded to the instruction level (§172) — crack REFUTED across the reachable space, wall documented
- tools/cc1_dumps.sh: run the pinned cc1 with -dr/-ds/-dj/-dc/-dl/-dg and count standalone
  (use (reg)) insns in the .combine dump — each is one 8-byte never-referenced reload slot.
  The NEAR-2 residual = 12 such orphans vs the target's 16, now ENUMERATED pseudo-by-pseudo
  instead of inferred from ablations.
- The orphan mechanism, exact (combine.c:10835 + mips.md force_not_mem): every short-mem read
  is a movhi+shift-pair triple; the fold orphans its ashift temp iff the HI reg carries an
  extra HImode use and the death-note walk hits a label/jump. Single-use loads never orphan;
  the head can never orphan (walk reaches insn 0).
- The zero-code +4 factory is byte-refuted: 18 new probe families x 3 placements (s16
  respellings, cast truncations, <<16>>16 factories, placement sweeps, loop t/n, dossier-file
  re-sweep) all land at vars=224-same-bytes or drift. p_optr reproduces the target's exact
  16-orphan frame at +7 insns — opacity that defeats cse equally blinds num_sign_bit_copies;
  fold-const closes the tree level. Three canonicalizers, one wall.
- Dossier NOTES.md updated with the S50 ledger; backlog klass -> WALL(P32) for both names.
- NOT banked: no 0-closeness draft exists. The dial draft (NEAR 2) remains the floor.
2026-08-14 12:08:50 -06:00

27 lines
1.5 KiB
Bash

#!/bin/bash
# usage: dump.sh <draft.c> <tag> -> .run/c294/<tag>.{s,greg,lreg,combine} + orphan-slot report
# gcc-2.7.2 cc1 writes dump files as <inputname>.<pass> in its CWD; we cd into a private dir so
# the repo root never collects gccdump.* droppings again.
cd /home/musashi/bfm-decomp
f="$1"; tag="$2"
d=.run/c294/dumps_$tag; rm -rf $d; mkdir -p $d
src=$d/$tag.c
if ! grep -q '#include "common.h"' "$f"; then echo '#include "common.h"' > $src; fi
cat "$f" >> $src
mipsel-linux-gnu-cpp -lang-c -Iinclude -undef -Wall -fno-builtin -Dmips -D__GNUC__=2 -D__OPTIMIZE__ -Dpsx -D_PSYQ -D_MIPSEL -D_LANGUAGE_C $src > $d/$tag.i
(cd $d && ../../../tools/bin/gcc-2.7.2-psx/cc1 -quiet -O2 -G0 -mips1 -mcpu=3000 -mgas -msoft-float -fgnu-linker -dr -ds -dj -dc -dl -dg $tag.i -o $tag.s 2>$tag.err)
echo "== $tag: dumps in $d"
grep -c "^(insn" $d/$tag.i.greg 2>/dev/null | sed 's/^/greg insns: /'
# orphan slots: pseudos whose ONLY appearance after reload is inside a (use ...) — count stack slots
python3 - "$d/$tag.i.greg" <<'PY'
import re, sys
t = open(sys.argv[1]).read()
# every "Register N ... in stack slot" style line differs by gcc version; instead pull the
# reload-era equivalences: (reg N) replaced by (mem (plus (reg 29) (const_int X)))
slots = {}
for m in re.finditer(r'\(insn [0-9]+ [0-9]+ [0-9]+[^\n]*\n?[^(]*\(use \(reg[^ ]* ([0-9]+)\)', t):
slots.setdefault(m.group(1), 0)
uses = re.findall(r'\(use \(reg[:A-Z]* ([0-9]+)[ )]', t)
print("USE-referenced pseudos in greg:", sorted(set(uses), key=int))
PY