|
PS2GL
OpenGL*-like API for the PS2
|
Functions | |
| str | _normalize_mnemonic (str tok) |
| str | _extract_flag (str tok) |
| bool | _is_mnemonic_token (str tok) |
| parse_vsm (str path) | |
| _diff_counters (Counter a, Counter b) | |
| int | main (argv) |
Variables | |
| tuple | _DIRECTIVE_PREFIXES = (".vu", ".align", ".global", ".name", ".end") |
| _COMMENT_RE = re.compile(r"^\s*;.*") | |
| _LABEL_RE = re.compile(r"^\s*([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(?:;.*)?$") | |
| _PIPE_SPLIT_RE = re.compile(r"\s{15,}") | |
| _FLAG_RE = re.compile(r"^([a-z0-9.]+?)(\[[A-Za-z]+\])?$") | |
Compare two VU1 .vsm files at the semantic level. Used as a CTest target in ps2gl to verify that openvcl produces the same *set* of operations as Sony's proprietary vcl for each VU1 renderer. Differences in pipe-pairing, register-allocator choices, and whitespace are intentionally ignored -- the goal is to surface real divergences (missing instructions, wrong opcodes, missing labels) and to track how close openvcl is getting to the reference as the dual-pipe scheduler matures. Usage: vsm_diff.py <reference.vsm> <openvcl.vsm> Exit codes: 0 = histograms and labels match. 1 = real divergence (different opcode set, different label set). 2 = file read / parse error. The script is intentionally permissive about pipe placement: only the opcode mix matters. A separate "instruction-count delta" line is printed to track scheduler progress over time.
|
protected |
Lowercase the mnemonic and strip any [E]/[I]/[D]/[T] flag suffix. Keep dest fields (`.xyz`, `.w`) attached to the mnemonic so we can distinguish `addi.xy` from `addi.xyz` -- they're semantically different operations on different fields.
Definition at line 58 of file vsm_diff.py.
Referenced by parse_vsm().
|
protected |
Return the flag suffix (e.g. "[E]") if present, else "".
Definition at line 69 of file vsm_diff.py.
Referenced by parse_vsm().
|
protected |
True iff `tok` looks like a VU1 mnemonic (as opposed to a register
or immediate operand).
Sony's reference output uses uppercase mnemonics with comma-joined
operands and no space between them; openvcl's output uses lowercase
mnemonics with space-separated operands. A consistent classifier
over both is to bucket each whitespace-separated token by what it
looks like:
mnemonic: starts with a letter, is not a register name
register: V[FI]<digit>... or ACC[component] or single-letter I/Q/P/R
immediate: starts with a digit (incl. 0x...)
indirect: contains '(' (e.g. 62(VI00))
label-ref: trailing ':' -- handled before this function gets called
Definition at line 75 of file vsm_diff.py.
Referenced by parse_vsm().
| vsm_diff.parse_vsm | ( | str | path | ) |
Return (opcode_histogram, flag_histogram, label_set, instr_count). instr_count is the total number of pipe slots filled with anything other than `nop` -- a rough "work-per-cycle" signal for the scheduler.
Definition at line 116 of file vsm_diff.py.
References _extract_flag(), _is_mnemonic_token(), and _normalize_mnemonic().
Referenced by _diff_counters().
|
protected |
Return dict {key: (a, b)} for keys where a and b disagree.
Definition at line 167 of file vsm_diff.py.
References _diff_counters(), and parse_vsm().
Referenced by _diff_counters().
| int vsm_diff.main | ( | argv | ) |
Definition at line 176 of file vsm_diff.py.
|
protected |
Definition at line 31 of file vsm_diff.py.
|
protected |
Definition at line 38 of file vsm_diff.py.
|
protected |
Definition at line 41 of file vsm_diff.py.
|
protected |
Definition at line 50 of file vsm_diff.py.
|
protected |
Definition at line 55 of file vsm_diff.py.