cpu: lower bounded ADD/SUB/CMP to LAHF slice #1024

Merged
Ammmae0x merged 7 commits from upstream-pr/1031 into main 2026-11-24 00:16:08 +00:00
Ammmae0x commented 2026-11-23 22:11:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T22:11:11Z.


Change

Add a bounded leaf translator (tools/cpu_integer_flags_aot.py), MASM differential fixture (tests/cpu/integer_flags.asm, tests/cpu/integer_flags.def), verification suite (tests/cpu/integer_flags_check.py), CMake registration (cpu_aot_integer_flags), and documentation entry (docs/experiments.md) covering five uncovered x64 Integer mnemonics from docs/coverage/x64_zen2.tsv:

  • lahf: writes (SF<<7)|(ZF<<6)|(AF<<4)|(PF<<2)|0x02|CF to AH while preserving AL and RAX[63:16]
  • pushf / popf: 2-byte stack stride (RSP -/+ 2) for low 16-bit FLAGS (CF, PF, AF, ZF, SF, DF, OF, fixed bit 1, and ring-3 IF = 0x0202, preserving ID)
  • pushfq / popfq: 8-byte stack stride (RSP -/+ 8) for 64-bit RFLAGS, additionally modeling ID (bit 21)

Each export uses the leaf ABI void fn(word rcx, word rdx, word r8), modeling volatile GPRs (rax, rcx, rdx, r8, r9, r10, r11) across 8-, 16-, 32-, and 64-bit views (including high-byte ah/ch/dh), a bounded 256-byte local stack balanced to entry rsp at ret, per-flag definedness tracking (and/or/xor/test leave AF undefined, inc/dec preserve CF, sahf leaves OF/DF/ID unchanged, popf leaves ID unchanged), static DF=0 (cld) enforcement at ret, and std::atomic_signal_fence dead-read ordering. Nonvolatile GPRs, direct rsp arithmetic, branches/calls, prefixes, VEX/EVEX encodings, unbalanced rsp, stack overflow/underflow, non-zero DF at ret, undefined flag/GPR reads, and non-r8 stores are rejected.

Verification

Verified on both dev (Debug) and release (/O2) presets (0 errors, 0 warnings):

  • cmake --build --preset dev --clean-first --target cpu_integer_flags_original cpu_integer_flags_original_lifted cpu_integer_flags_altered cpu_integer_flags_altered_lifted cpu_integer_flags_controls: 0 errors, 0 warnings
  • cmake --build --preset release --clean-first --target cpu_integer_flags_original cpu_integer_flags_original_lifted cpu_integer_flags_altered cpu_integer_flags_altered_lifted cpu_integer_flags_controls: 0 errors, 0 warnings
  • ctest --preset dev --no-tests=error -R "^cpu_aot_integer_flags$" -V: 1/1 Passed (216 native/lifted/reference cases across 11 exports; 5 ALTER_IMM controls diverging on 16/21/21/16/25 cases; 6 mutated-C++ controls diverging on ctrl_wrong_af: 7, ctrl_wrong_pf: 13, ctrl_wrong_if: 16, ctrl_wrong_pushf_stride: 21, ctrl_wrong_popf_stride: 17, ctrl_lahf_clobber_rax: 21; op_discarded_read dead-read fault ordering; output-mutation control; 5 alternate-encoding lift checks; 41 unit rejection controls; 10 end-to-end PE-patched DLL rejection controls)
  • ctest --preset release --no-tests=error -R "^cpu_aot_integer_flags$" -V: 1/1 Passed with identical counts
  • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: passed
  • .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py: passed (13 Markdown files, 224 links)
  • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py: passed (871 tracked files)
  • .\out\pe-env\Scripts\python.exe -B tools/form_coverage.py on cpu_aot_integer_flags JUnit output: 24/948 x64 forms covered (Integer: 24/191 including lahf, pushf, popf, pushfq, popfq)

Evidence and follow-up

All fixtures are original source-built MASM and Python tests submitted under the MIT License (tests/cpu/integer_flags.asm, tests/cpu/integer_flags.def, tests/cpu/integer_flags_check.py) with synthetic nibble-carry/borrow boundaries, ID=0/ID=1/DF=0/DF=1 flag masks (keeping TF=0/AC=0/IOPL=0/NT=0), 2-byte vs 8-byte stack stride sentinels, and negative controls (ALTER_IMM, 6 mutated-C++ controls, dead-read ordering, single-bit output mutation, 41 unit rejections, and 10 PE-patched DLL rejections). TF/AC/NT trap or privilege side effects, control flow, and nonvolatile GPR prologues remain out of scope.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6569871548 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T22:11:11Z. --- ## Change Add a bounded leaf translator (`tools/cpu_integer_flags_aot.py`), MASM differential fixture (`tests/cpu/integer_flags.asm`, `tests/cpu/integer_flags.def`), verification suite (`tests/cpu/integer_flags_check.py`), CMake registration (`cpu_aot_integer_flags`), and documentation entry (`docs/experiments.md`) covering five uncovered x64 `Integer` mnemonics from `docs/coverage/x64_zen2.tsv`: - `lahf`: writes `(SF<<7)|(ZF<<6)|(AF<<4)|(PF<<2)|0x02|CF` to `AH` while preserving `AL` and `RAX[63:16]` - `pushf` / `popf`: 2-byte stack stride (`RSP -/+ 2`) for low 16-bit `FLAGS` (`CF`, `PF`, `AF`, `ZF`, `SF`, `DF`, `OF`, fixed bit 1, and ring-3 `IF` = `0x0202`, preserving `ID`) - `pushfq` / `popfq`: 8-byte stack stride (`RSP -/+ 8`) for 64-bit `RFLAGS`, additionally modeling `ID` (bit 21) Each export uses the leaf ABI `void fn(word rcx, word rdx, word r8)`, modeling volatile GPRs (`rax`, `rcx`, `rdx`, `r8`, `r9`, `r10`, `r11`) across 8-, 16-, 32-, and 64-bit views (including high-byte `ah`/`ch`/`dh`), a bounded 256-byte local stack balanced to entry `rsp` at `ret`, per-flag definedness tracking (`and`/`or`/`xor`/`test` leave `AF` undefined, `inc`/`dec` preserve `CF`, `sahf` leaves `OF`/`DF`/`ID` unchanged, `popf` leaves `ID` unchanged), static `DF=0` (`cld`) enforcement at `ret`, and `std::atomic_signal_fence` dead-read ordering. Nonvolatile GPRs, direct `rsp` arithmetic, branches/calls, prefixes, VEX/EVEX encodings, unbalanced `rsp`, stack overflow/underflow, non-zero `DF` at `ret`, undefined flag/GPR reads, and non-`r8` stores are rejected. ## Verification Verified on both `dev` (Debug) and `release` (`/O2`) presets (0 errors, 0 warnings): - `cmake --build --preset dev --clean-first --target cpu_integer_flags_original cpu_integer_flags_original_lifted cpu_integer_flags_altered cpu_integer_flags_altered_lifted cpu_integer_flags_controls`: 0 errors, 0 warnings - `cmake --build --preset release --clean-first --target cpu_integer_flags_original cpu_integer_flags_original_lifted cpu_integer_flags_altered cpu_integer_flags_altered_lifted cpu_integer_flags_controls`: 0 errors, 0 warnings - `ctest --preset dev --no-tests=error -R "^cpu_aot_integer_flags$" -V`: 1/1 Passed (216 native/lifted/reference cases across 11 exports; 5 `ALTER_IMM` controls diverging on 16/21/21/16/25 cases; 6 mutated-C++ controls diverging on `ctrl_wrong_af`: 7, `ctrl_wrong_pf`: 13, `ctrl_wrong_if`: 16, `ctrl_wrong_pushf_stride`: 21, `ctrl_wrong_popf_stride`: 17, `ctrl_lahf_clobber_rax`: 21; `op_discarded_read` dead-read fault ordering; output-mutation control; 5 alternate-encoding lift checks; 41 unit rejection controls; 10 end-to-end PE-patched DLL rejection controls) - `ctest --preset release --no-tests=error -R "^cpu_aot_integer_flags$" -V`: 1/1 Passed with identical counts - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: passed - `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py`: passed (13 Markdown files, 224 links) - `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py`: passed (871 tracked files) - `.\out\pe-env\Scripts\python.exe -B tools/form_coverage.py` on `cpu_aot_integer_flags` JUnit output: 24/948 x64 forms covered (`Integer`: 24/191 including `lahf`, `pushf`, `popf`, `pushfq`, `popfq`) ## Evidence and follow-up All fixtures are original source-built MASM and Python tests submitted under the MIT License (`tests/cpu/integer_flags.asm`, `tests/cpu/integer_flags.def`, `tests/cpu/integer_flags_check.py`) with synthetic nibble-carry/borrow boundaries, `ID=0`/`ID=1`/`DF=0`/`DF=1` flag masks (keeping `TF=0`/`AC=0`/`IOPL=0`/`NT=0`), 2-byte vs 8-byte stack stride sentinels, and negative controls (`ALTER_IMM`, 6 mutated-C++ controls, dead-read ordering, single-bit output mutation, 41 unit rejections, and 10 PE-patched DLL rejections). `TF`/`AC`/`NT` trap or privilege side effects, control flow, and nonvolatile GPR prologues remain out of scope. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:45:56 +00:00
R0Y00 commented 2026-11-24 06:49:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:18:11Z.


This is broader than the same-block LAHF slice in #1022. There is also a concrete input-contract problem in the stack forms: POPF/POPFQ accepts any initialized stack word (including a caller-loaded word), but the generated code silently drops TF/AC/NT while the native instruction can change observable execution. The test vectors intentionally never set those fields. Please make the first candidate the bounded ADD/SUB/CMP → LAHF slice in #1022, with the full RAX comparison, a live flag consumer, and CPUID gating for native LAHF. Preserve the flag-stack work separately. To revisit it, require a statically proven permitted input word or a checked caller contract with rejection before guest-visible effects.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115583564 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7115583564). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:18:11Z. --- This is broader than the same-block LAHF slice in #1022. There is also a concrete input-contract problem in the stack forms: POPF/POPFQ accepts any initialized stack word (including a caller-loaded word), but the generated code silently drops TF/AC/NT while the native instruction can change observable execution. The test vectors intentionally never set those fields. Please make the first candidate the bounded ADD/SUB/CMP → LAHF slice in #1022, with the full RAX comparison, a live flag consumer, and CPUID gating for native LAHF. Preserve the flag-stack work separately. To revisit it, require a statically proven permitted input word or a checked caller contract with rejection before guest-visible effects.
Ammmae0x commented 2026-11-24 06:49:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T22:40:38Z.


Refs #1022. Narrowed cpu/integer-flags (commit 2e761c0) to the bounded same-block register ADD/SUB/CMP -> LAHF slice and removed pushf/popf/pushfq/popfq (along with sahf/inc/dec/neg/adc/sbb/clc/stc/cmc and local stack forms) from this PR so flag-stack work stays separate:

  • Translator (tools/cpu_integer_flags_aot.py): accepts register-destination add/sub/cmp across 8-, 16-, 32-, and 64-bit register/immediate operands, same-block lahf (requiring CF/PF/AF/ZF/SF and RAX defined; preserving AL and RAX[63:16] without modifying flags), and setcc consumers; rejects pushf/popf/pushfq/popfq, and/xor/test/shl/imul, calls/branches, and undefined flag/GPR reads.
  • Fixture & checks (tests/cpu/integer_flags.asm, tests/cpu/integer_flags_check.py, CMakeLists.txt): added 8/16/32/64-bit add/sub/cmp -> lahf exports comparing full RAX plus 5 live setcc consumers (setb, setp, sete, sets, seto) after lahf; gated native execution on CPUID.80000001H:ECX[0] via host_has_lahf() with SKIP_RETURN_CODE 77; added #1022 mutation controls (ctrl_af_bit4, ctrl_pf_full_width, ctrl_lahf_bit1_cleared, ctrl_lahf_clobber_rax, ctrl_lahf_keep_old_ah, ctrl_lahf_clobber_flags) and 48 unit + 10 PE-patched rejection controls.
  • Verification: clean dev and release (/O2) builds of cpu_integer_flags_* (0 errors, 0 warnings); ctest --preset dev --no-tests=error -R "^cpu_aot_integer_flags$" -V and release both passed (460 native/lifted/reference cases across 16 exports, 4 ALTER_IMM controls, 6 C++ mutations, dead-read and output-mutation controls, 3 alt-encoding checks, 48 unit + 10 PE rejections); form_coverage.py covers lahf in Integer; form_coverage_check.py, docs_links_check.py, and bidi_controls_check.py passed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116048049 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7116048049). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T22:40:38Z. --- Refs #1022. Narrowed `cpu/integer-flags` (commit `2e761c0`) to the bounded same-block register `ADD`/`SUB`/`CMP` -> `LAHF` slice and removed `pushf`/`popf`/`pushfq`/`popfq` (along with `sahf`/`inc`/`dec`/`neg`/`adc`/`sbb`/`clc`/`stc`/`cmc` and local stack forms) from this PR so flag-stack work stays separate: - **Translator (`tools/cpu_integer_flags_aot.py`)**: accepts register-destination `add`/`sub`/`cmp` across 8-, 16-, 32-, and 64-bit register/immediate operands, same-block `lahf` (requiring `CF`/`PF`/`AF`/`ZF`/`SF` and `RAX` defined; preserving `AL` and `RAX[63:16]` without modifying flags), and `setcc` consumers; rejects `pushf`/`popf`/`pushfq`/`popfq`, `and`/`xor`/`test`/`shl`/`imul`, calls/branches, and undefined flag/GPR reads. - **Fixture & checks (`tests/cpu/integer_flags.asm`, `tests/cpu/integer_flags_check.py`, `CMakeLists.txt`)**: added 8/16/32/64-bit `add`/`sub`/`cmp` -> `lahf` exports comparing full `RAX` plus 5 live `setcc` consumers (`setb`, `setp`, `sete`, `sets`, `seto`) after `lahf`; gated native execution on `CPUID.80000001H:ECX[0]` via `host_has_lahf()` with `SKIP_RETURN_CODE 77`; added #1022 mutation controls (`ctrl_af_bit4`, `ctrl_pf_full_width`, `ctrl_lahf_bit1_cleared`, `ctrl_lahf_clobber_rax`, `ctrl_lahf_keep_old_ah`, `ctrl_lahf_clobber_flags`) and 48 unit + 10 PE-patched rejection controls. - **Verification**: clean `dev` and `release` (`/O2`) builds of `cpu_integer_flags_*` (0 errors, 0 warnings); `ctest --preset dev --no-tests=error -R "^cpu_aot_integer_flags$" -V` and `release` both passed (460 native/lifted/reference cases across 16 exports, 4 `ALTER_IMM` controls, 6 C++ mutations, dead-read and output-mutation controls, 3 alt-encoding checks, 48 unit + 10 PE rejections); `form_coverage.py` covers `lahf` in `Integer`; `form_coverage_check.py`, `docs_links_check.py`, and `bidi_controls_check.py` passed. AI-assisted.
zohaiblazuli commented 2026-11-24 06:49:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by zohaiblazuli on 2026-11-23T23:01:44Z.


Following the maintainer's note on #1022, I'm not opening a second PR. Two things for this one:

Review of AH preservation and AF/PF definedness (at 2e761c0, read only, not run):

  • AH preservation: lahf emits (rax & ~0xff00) | pack_lahf(...) << 8, so AL and RAX[63:16] are kept. The op_add8_al_lahf export covers a writer on AL followed by lahf.
  • Definedness: require_flags checks all five flags at lahf, and only add/sub/cmp define AF and PF. Branches and calls are refused outright, so there are no joins to reason about. One small observation: lahf also requires RAX to be defined, which refuses lahf straight after entry even though native lahf doesn't read RAX. That's harmless for this slice, but worth stating as a translator contract.

The shared-lowerer change. I have it as one commit on my fork: 235b10f on cpu/lahf. It's based on main at 64ecc87. You're welcome to take any of it into this PR.

  • tools/ffx_version_query.py: lahf_sources(body) accepts a lahf only when its flags come from a register add, sub or cmp (register or immediate source) earlier in the same straight-line block, with that instruction as the last writer of any status flag. It refuses at the entry, at a branch target, across a branch, call or join, in a function with an indirect branch, and after any other flag writer. That writer then also assigns aux and parity, which are declared only in functions with lahf. The lahf statement replaces AH only. Refusals keep the "unsupported query operation" text, so x87_compare and x87_status still pass unchanged.
  • tests/cpu/lahf.py (cpu_aot_lahf): 20 MASM exports, CPUID-gated, compared with native and a reference model on the whole RAX. Every RAX bit outside AH is preloaded, including all-set, so reserved bits 5, 3 and 1 show. There is a setl/jbe consumer after lahf, 19 refused shapes, and five mutated translations (AF never set, odd parity, whole-RAX write, bit 1 clear, OF changed before the consumer).
  • Local results on an Intel Core i5-14600K, Windows 11 build 26300: 38,720 cases matched. All 190 cpu_ tests (excluding _hardware) passed in both dev and release, and the FFX WARP tests passed in dev.

If you'd rather keep your translator and its fixture as the integration point, I'm happy to review whatever you take over, or to send the lowering change as a PR into your branch. Whichever is easier for you.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116467650 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7116467650). Originally posted by [zohaiblazuli](https://github.com/zohaiblazuli) on 2026-11-23T23:01:44Z. --- Following the maintainer's note on #1022, I'm not opening a second PR. Two things for this one: **Review of AH preservation and AF/PF definedness** (at `2e761c0`, read only, not run): - **AH preservation:** `lahf` emits `(rax & ~0xff00) | pack_lahf(...) << 8`, so AL and RAX[63:16] are kept. The `op_add8_al_lahf` export covers a writer on AL followed by `lahf`. - **Definedness:** `require_flags` checks all five flags at `lahf`, and only `add`/`sub`/`cmp` define AF and PF. Branches and calls are refused outright, so there are no joins to reason about. One small observation: `lahf` also requires RAX to be defined, which refuses `lahf` straight after entry even though native `lahf` doesn't read RAX. That's harmless for this slice, but worth stating as a translator contract. **The shared-lowerer change.** I have it as one commit on my fork: [`235b10f`](https://github.com/zohaiblazuli/Xbox2Windows/commit/235b10f) on `cpu/lahf`. It's based on `main` at `64ecc87`. You're welcome to take any of it into this PR. - **`tools/ffx_version_query.py`:** `lahf_sources(body)` accepts a `lahf` only when its flags come from a register `add`, `sub` or `cmp` (register or immediate source) earlier in the same straight-line block, with that instruction as the last writer of any status flag. It refuses at the entry, at a branch target, across a branch, call or join, in a function with an indirect branch, and after any other flag writer. That writer then also assigns `aux` and `parity`, which are declared only in functions with `lahf`. The `lahf` statement replaces AH only. Refusals keep the "unsupported query operation" text, so `x87_compare` and `x87_status` still pass unchanged. - **`tests/cpu/lahf.py` (`cpu_aot_lahf`):** 20 MASM exports, CPUID-gated, compared with native and a reference model on the whole RAX. Every RAX bit outside AH is preloaded, including all-set, so reserved bits 5, 3 and 1 show. There is a `setl`/`jbe` consumer after `lahf`, 19 refused shapes, and five mutated translations (AF never set, odd parity, whole-RAX write, bit 1 clear, OF changed before the consumer). - **Local results** on an Intel Core i5-14600K, Windows 11 build 26300: 38,720 cases matched. All 190 `cpu_` tests (excluding `_hardware`) passed in both `dev` and `release`, and the FFX WARP tests passed in `dev`. If you'd rather keep your translator and its fixture as the integration point, I'm happy to review whatever you take over, or to send the lowering change as a PR into your branch. Whichever is easier for you.
Ammmae0x commented 2026-11-24 06:49:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T23:16:23Z.


Merged upstream/main (b1d041c) into cpu/integer-flags at 096c61e to resolve the docs/experiments.md merge conflict.

Thanks @zohaiblazuli for reviewing 2e761c0! Confirmed the translator contract in docs/experiments.md: lahf requires RAX to be previously defined in the function so AL and RAX[63:16] are preserved (and lahf at entry with undefined RAX is rejected). To keep this PR focused on one reviewable behavior (cpu_integer_flags_aot.py), I'm keeping the shared tools/ffx_version_query.py lowering work separate rather than folding 235b10f into this branch.

Verification at 096c61e:

  • ctest --preset dev --no-tests=error -R '^cpu_aot_integer_flags$' -V: Passed (460 cases matched bit-for-bit, 3 alternate-encoding checks, 48 unit rejections, 10 PE-patched rejections, 4 ALTER_IMM, 6 C++ mutations, dead-read & output-mutation controls).
  • ctest --preset release --no-tests=error -R '^cpu_aot_integer_flags$' -V (/O2): Passed (same full suite).
  • form_coverage_check.py, docs_links_check.py, bidi_controls_check.py: Passed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116764835 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7116764835). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T23:16:23Z. --- Merged `upstream/main` (`b1d041c`) into `cpu/integer-flags` at `096c61e` to resolve the `docs/experiments.md` merge conflict. Thanks @zohaiblazuli for reviewing `2e761c0`! Confirmed the translator contract in `docs/experiments.md`: `lahf` requires `RAX` to be previously defined in the function so `AL` and `RAX[63:16]` are preserved (and `lahf` at entry with undefined `RAX` is rejected). To keep this PR focused on one reviewable behavior (`cpu_integer_flags_aot.py`), I'm keeping the shared `tools/ffx_version_query.py` lowering work separate rather than folding `235b10f` into this branch. Verification at `096c61e`: - `ctest --preset dev --no-tests=error -R '^cpu_aot_integer_flags$' -V`: Passed (460 cases matched bit-for-bit, 3 alternate-encoding checks, 48 unit rejections, 10 PE-patched rejections, 4 `ALTER_IMM`, 6 C++ mutations, dead-read & output-mutation controls). - `ctest --preset release --no-tests=error -R '^cpu_aot_integer_flags$' -V` (`/O2`): Passed (same full suite). - `form_coverage_check.py`, `docs_links_check.py`, `bidi_controls_check.py`: Passed. AI-assisted.
zohaiblazuli commented 2026-11-24 06:49:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by zohaiblazuli on 2026-11-23T23:18:21Z.


Happy to help :)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116802727 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7116802727). Originally posted by [zohaiblazuli](https://github.com/zohaiblazuli) on 2026-11-23T23:18:21Z. --- Happy to help :)
R0Y00 commented 2026-11-24 06:49:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T23:25:23Z.


Thanks for resolving the conflict and for the AH review. The updated branch still adds a second production lowerer for the same ADD/SUB/CMP → LAHF slice. For #1022, please carry the existing shared patch into this PR with its attribution, and keep the native fixture with the full-RAX, live-flags and refusal controls. The fixture and shared change can be separate commits here. @Ammmae0x @zohaiblazuli, please rerun the fixture through the shared path after combining them. The separate flag-stack forms can keep their scope.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116936579 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7116936579). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T23:25:23Z. --- Thanks for resolving the conflict and for the AH review. The updated branch still adds a second production lowerer for the same ADD/SUB/CMP → LAHF slice. For #1022, please carry the existing shared patch into this PR with its attribution, and keep the native fixture with the full-RAX, live-flags and refusal controls. The fixture and shared change can be separate commits here. @Ammmae0x @zohaiblazuli, please rerun the fixture through the shared path after combining them. The separate flag-stack forms can keep their scope.
Ammmae0x commented 2026-11-24 06:49:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T23:51:45Z.


Updated cpu/integer-flags ( 551f97, 8c82b4) to address the review feedback (Refs #1022):

  • Shared lowering ( 551f97): Integrated @zohaiblazuli's ools/ffx_version_query.py ADD/SUB/CMP -> LAHF patch (235b10f, with Co-authored-by: Zohaib [email protected]).
  • Fixture & build routing (8c82b4): Removed ools/cpu_integer_flags_aot.py and routed ests/cpu/integer_flags_check.py, CMakeLists.txt (cpu_integer_flags_{original,altered}_lifted, cpu_integer_flags_controls, cpu_aot_integer_flags), and docs/experiments.md through ools/ffx_version_query.py. Kept ests/cpu/integer_flags.asm with full RAX checks, live SETcc consumers (setb/setl/sete/sets/seto, replacing setp since fx_version_query.py intentionally rejects setp), CPUID.80000001H:ECX[0] gating (host_has_lahf()), op_discarded_read, 4 ALTER_IMM divergence controls, 6 mutated-C++ controls, 4 alternate-encoding checks, 38 unit rejection controls (including #1022 lahf_sources controls), and 11 PE-patched rejection controls.

Verified locally on both dev and
elease (/O2) presets (0 errors, 0 warnings on cpu_integer_flags_* and cpu_version_query*):

  • ctest --preset dev --no-tests=error -R "^(cpu_aot_integer_flags|cpu_aot_version_query|cpu_aot_x87_parity)$" -V: 3/3 passed (cpu_aot_integer_flags: 460 cases matched).
  • ctest --preset release --no-tests=error -R "^(cpu_aot_integer_flags|cpu_aot_version_query|cpu_aot_x87_parity)$" -V: 3/3 passed.
  • ests/form_coverage_check.py, ests/docs_links_check.py, and ests/bidi_controls_check.py: all passed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7117442895 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7117442895). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T23:51:45Z. --- Updated cpu/integer-flags ( 551f97, 8c82b4) to address the review feedback (Refs #1022): - **Shared lowering ( 551f97)**: Integrated @zohaiblazuli's ools/ffx_version_query.py ADD/SUB/CMP -> LAHF patch (235b10f, with Co-authored-by: Zohaib <[email protected]>). - **Fixture & build routing (8c82b4)**: Removed ools/cpu_integer_flags_aot.py and routed ests/cpu/integer_flags_check.py, CMakeLists.txt (cpu_integer_flags_{original,altered}_lifted, cpu_integer_flags_controls, cpu_aot_integer_flags), and docs/experiments.md through ools/ffx_version_query.py. Kept ests/cpu/integer_flags.asm with full RAX checks, live SETcc consumers (setb/setl/sete/sets/seto, replacing setp since fx_version_query.py intentionally rejects setp), CPUID.80000001H:ECX[0] gating (host_has_lahf()), op_discarded_read, 4 ALTER_IMM divergence controls, 6 mutated-C++ controls, 4 alternate-encoding checks, 38 unit rejection controls (including #1022 lahf_sources controls), and 11 PE-patched rejection controls. Verified locally on both dev and elease (/O2) presets (0 errors, 0 warnings on cpu_integer_flags_* and cpu_version_query*): - ctest --preset dev --no-tests=error -R "^(cpu_aot_integer_flags|cpu_aot_version_query|cpu_aot_x87_parity)$" -V: 3/3 passed (cpu_aot_integer_flags: 460 cases matched). - ctest --preset release --no-tests=error -R "^(cpu_aot_integer_flags|cpu_aot_version_query|cpu_aot_x87_parity)$" -V: 3/3 passed. - ests/form_coverage_check.py, ests/docs_links_check.py, and ests/bidi_controls_check.py: all passed. AI-assisted.
R0Y00 commented 2026-11-24 06:49:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T23:59:11Z.


The shared lowering and fixture are in place. I pushed bfe43124 after finding that a host_ops binding could replace the ADD with a no-op while LAHF still accepted it as the flag producer. The shared analysis now refuses an intervening opaque binding, with a direct regression. The LAHF and existing version-query CTests passed in both Windows presets, with all 460 native/lifted/reference rows retained.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7117577008 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1031#issuecomment-7117577008). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T23:59:11Z. --- The shared lowering and fixture are in place. I pushed bfe43124 after finding that a host_ops binding could replace the ADD with a no-op while LAHF still accepted it as the flag producer. The shared analysis now refuses an intervening opaque binding, with a direct regression. The LAHF and existing version-query CTests passed in both Windows presets, with all 460 native/lifted/reference rows retained.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1024
No description provided.