mirror of
https://github.com/Druthulu/BFM-decomp
synced 2026-09-27 22:45:39 -04:00
a1f1a948af
- BANKED (each whole-binary byte-gated; make check-all -> 140 passed, 0 failed of 140): func_80130D48 ×4 (1,064) · func_8018F3E4 (478) · func_8018B3D0 (478) · 13 × 223-ins siblings of func_8017E6D8 (2,899). distinct-code 3,833,224 -> 3,838,143 = 68.0% -> 68.1%. - TWO OF MY OWN COUNTS COLLAPSED UNDER SCRUTINY BEFORE I ACTED ON EITHER (R14/R35): "func_8017CA80's family = 102 unmatched" was really 13 -- my count tallied family members whose NAME appears as a stub anywhere in the fleet, not instances actually unmatched (a semantics error, not arithmetic). "56,267 ins remappable" was really 8,114 -- 86% was the known -O0 / deferred set (the func_80144B9C whale, the func_8013C414 cluster). I nearly recommended a target on the first number. - THE §77 CARRY GAP IS THE DOMINANT COST OF MECHANICAL REMAP: 23 of 27 first-pass CC1-FAILs. NEW .run/giants/s19_remap_tu.py sources the preamble from the exemplar's OVERLAY TU (the block between the previous top-level `}` and the def), applies family_remap's own substitution map, and adds the two includes match_one never adds -> 21 drafts went 0 MATCH -> 14 MATCH. The 13 223-ins siblings share ONE exemplar, so a single preamble fix cleared all 13. - USEFUL ASYMMETRY: func_8018F3E4/func_8018B3D0 FAILED match_one but BANKED in the whole-binary gate -- the real TU supplies decls the standalone compile lacks. A match_one CC1 FAIL is not a reason to skip the real gate on a remapped sibling. - RESIDUAL 3,195 ins, causes NAMED not guessed: func_8017D5C0 (952) matches standalone, gate reports `conflicting types for memcpy` = the §58 red-herring (a warning from an unrelated TU position; SESSION-14 hit the same label and the true cause needed a hand-splice + real cc1 stderr). func_80166994 ×3 + func_8016A290 ×4 still CC1-FAIL after the TU carry. - FULL R22 DEFERRED DELIBERATELY: make clean wipes asm/, which the concurrently-running BF14 agent reads on every probe. This batch changed only src/*.c (no config), so check-all is sound; the clean R22 must still run once the agent finishes.
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Structure map of func_8017BF14's target asm: labels, branch edges, loops."""
|
|
import re, sys, collections
|
|
F='/home/musashi/bfm-decomp/asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8017AE2C/func_8017BF14.s'
|
|
ins=[] # (idx, addr, text)
|
|
lab={} # label -> idx
|
|
lines=open(F).read().splitlines()
|
|
idx=0
|
|
pend=[]
|
|
for L in lines:
|
|
m=re.match(r'\s*\.?(\.L[0-9A-F]+):',L) or re.match(r'\s*(\.L[0-9A-F]+):',L)
|
|
if m: lab[m.group(1)]=idx; continue
|
|
m=re.match(r'\s*/\* \w+ ([0-9A-F]{8}) [0-9A-F]{8} \*/\s+(.*?)\s*$',L)
|
|
if m:
|
|
ins.append((idx,int(m.group(1),16),re.sub(r'\s+',' ',m.group(2))))
|
|
idx+=1
|
|
addr2idx={a:i for i,a,t in ins}
|
|
idx2addr={i:a for i,a,t in ins}
|
|
# edges
|
|
edges=collections.defaultdict(list)
|
|
for i,a,t in ins:
|
|
m=re.search(r'\b(b\w*|j)\s+.*?(\.L[0-9A-F]+)',t)
|
|
if m and m.group(2) in lab:
|
|
edges[lab[m.group(2)]].append(i)
|
|
if '--labels' in sys.argv:
|
|
for name,i in sorted(lab.items(), key=lambda kv:kv[1]):
|
|
srcs=edges.get(i,[])
|
|
back=[s for s in srcs if s>i]
|
|
print('%-14s idx=%5d addr=%08X preds=%d %s' % (name,i,idx2addr.get(i,0),len(srcs),
|
|
(' <== LOOP back from %s' % back) if back else ''))
|
|
if '--loops' in sys.argv:
|
|
for name,i in sorted(lab.items(), key=lambda kv:kv[1]):
|
|
back=[s for s in edges.get(i,[]) if s>i]
|
|
if back:
|
|
print('LOOP head %-12s idx=%5d addr=%08X body %d ins, back-edges at %s' %
|
|
(name,i,idx2addr.get(i,0),max(back)-i+1,[idx2addr[b] for b in back]))
|
|
if '--dump' in sys.argv:
|
|
lo=int(sys.argv[sys.argv.index('--dump')+1]); hi=int(sys.argv[sys.argv.index('--dump')+2])
|
|
rev={v:k for k,v in lab.items()}
|
|
for i,a,t in ins[lo:hi]:
|
|
if i in rev: print('%s:' % rev[i])
|
|
print('%5d %08X %s' % (i,a,t))
|
|
print('# total ins=%d labels=%d' % (len(ins),len(lab)), file=sys.stderr)
|