Commit Graph
67 Commits
Author SHA1 Message Date
naciandyusufcanislek b2699fb3a8 lifter: model XGETBV deterministically (#107)
* lifter: model XGETBV deterministically

Add XGETBV opcode support and model selector 0 as a deterministic XCR0 value (0x7: x87+SSE+AVX enabled), with zero returned for other selectors. This follows the existing CPUID deterministic-model approach for static lifting/deobfuscation.

Verification:

- build_iced lifter rewrite_microtests

- rewrite_microtests.exe xgetbv_returns_deterministic_xcr0 int29_fastfail_lowered_to_noreturn_call solve_path_widens_mapped_rva_target normalize_runtime_target_widens_mapped_rva_target

- python test.py quick

- python test.py vmp

* rewrite: seed deterministic XGETBV handler

The XGETBV semantics patch is deterministic by design, so the full-handler oracle pipeline must not use Unicorn's host-specific result. Add a manual handler seed entry for xgetbv bytes and computed expected outputs, then regenerate the enriched seed and oracle vectors to match the lifter model (selector 0 -> EAX=0x7, EDX=0).

Verification:

- scripts\rewrite\run_all_handlers.cmd

- python test.py quick

- python test.py vmp

---------

Co-authored-by: yusufcanislek <yusuf.canislek@meetdandy.com>
2026-04-20 19:29:01 +03:00
naciandNaC-L 0fbc2e9a52 Upgrade rewrite gate clang-cl to 21.1.8; re-enable calc_fib/calc_sum_array (#96)
The windows-latest preinstalled clang-cl (currently 20.1.8 at
`C:\Program Files\LLVM\bin\clang-cl.exe`) produces a lifter binary
that segfaults on calc_fib before emitting any IR, causing the rewrite
gate to fail. Clang 21.1.8 has been verified locally to compile the
lifter into a binary that lifts both calc_fib and calc_sum_array to
their expected constant returns (`ret i64 13` and `ret i64 150`).

Rolling back to clang 18.x is not an option: the runner image's MSVC STL
(14.44+) hard-requires clang 19.0.0 or newer via a static_assert in
yvals_core.h. Clang 21 satisfies that bound and dodges the clang 20.1.8
miscompile.

Upgrading via `choco upgrade llvm --version=21.1.8` keeps the existing
`C:\Program Files\LLVM\bin\clang-cl.exe` path valid, so the rest of
the pipeline (Resolve LLVM_DIR, Resolve clang-cl, Configure, Build) is
unchanged.

## Changes
- `.github/workflows/rewrite-strict-gate.yml`: add an "Upgrade clang-cl
  to 21.1.8" step before `Resolve LLVM_DIR` that runs `choco upgrade
  llvm` and pins `CMAKE_{C,CXX}_COMPILER` to the upgraded binary.
- `scripts/rewrite/instruction_microtests.json`: drop the `ci_skip`
  entries on `calc_fib` and `calc_sum_array`.
- `docs/SCOPE.md`: bump the corpus counts to 33 samples / 177 runtime
  semantic cases.

## Follow-up
Investigating the underlying clang 20.1.8 miscompile in the lifter is
still worth doing \u2014 it's almost certainly UB somewhere in the
structured-loop recovery path that clang 21 happens to tolerate. Tracked
separately.

Co-authored-by: NaC-L <nac-l@users.noreply.github.com>
2026-04-07 18:33:05 +03:00
naciandNaC-L 9bbe285b0e Fold select-chain dispatch into a real switch (#94)
The lifter emits Hex-Rays-style straight-line jump tables as a chain of
`icmp eq %idx, K_i; select V_i, prev` instructions, with the chain head
flowing into a join phi. The chain is structurally a switch but neither
SimplifyCFG nor downstream readers recognize it as one, so dispatches
like calc_jumptable_large still emitted 15 icmp/select pairs after O2.

This change adds two pieces:

1. SelectChainToSwitchPass (new, runs before SwitchNormalizationPass)
   detects a chain whose head feeds a single phi in the unique successor,
   verifies all comparisons share one %idx and all values are constants
   (including the terminating false branch), and rewrites the chain into
   a switch on %idx whose case-i blocks are trampolines that supply the
   case-specific value to the join phi. The chain instructions are erased
   in head-first order so each link is dead by the time we reach it.

2. SwitchNormalizationPass is restructured to support two normalization
   modes against the same switch:
     Mode A (index-arithmetic) walks the switch operand back through
       trunc/select-chain to recover (originalInput, addrBase, addrStride)
       and converts each case constant via (case - addrBase) / addrStride.
       This produces true logical indices and now also handles the
       "folded default" pattern where the chain's default branch is the
       case for logical 0: when rangeSize == numCases + 1 and minLogical
       == 1, the old default block is promoted to an explicit case 0 and
       the new default becomes an unreachable trampoline.
     Mode B (sorted-position fallback) preserves the previous behavior
       for switches whose case constants are jump-table TARGET addresses
       rather than table-entry indices (e.g. jumptable_basic). When the
       cases form an arithmetic progression and rangeSize == numCases,
       sorted-position i becomes logical i.

Verification: `python test.py all` green; semantic 33/33; calc_jumptable
and calc_jumptable_large now lift to clean `switch i64 %RCX` with logical
0..N-1 cases and an unreachable default for the folded-default shape.
All other jumptable samples (basic/dense/rel32/shifted/shared_targets/
computation) still pass via the Mode B fallback. Patterns updated for
calc_jumptable and calc_jumptable_large.

Co-authored-by: NaC-L <nac-l@users.noreply.github.com>
2026-04-07 17:26:22 +03:00
naciandNaC-L acab499d3f Re-skip calc_fib and calc_sum_array in CI (#95)
PR #93 un-skipped both samples after a clean local Release build proved
they lift correctly, but the windows-latest CI lane still fails on them
`Lifter failed for calc_fib` (run 24077021868). The HANDOFF note that
windows-latest clang-cl produces a different codegen shape than the
locally pinned clang-cl turned out to be the actual root cause; the
"stale build cache" theory only explained the local symptom.

Restoring the `ci_skip` entries unbreaks the rewrite-strict-gate and
rewrite-quick-gate workflows. Real fix tracked as a follow-up: either
teach the lifter the CI codegen shape, or pin the rewrite CI lane to a
toolchain that matches the local one byte-for-byte.

Also reverts the `docs/SCOPE.md` corpus counts to 31 samples / 175 cases.

Co-authored-by: NaC-L <nac-l@users.noreply.github.com>
2026-04-07 17:04:16 +03:00
naciandNaC-L 089e10ac08 Re-enable calc_fib and calc_sum_array in rewrite gate (#93)
Both samples were originally CI-skipped because windows-latest clang-cl
produced loop/array codegen shapes that tripped the lifter on CI even
though local runs passed. Since then the rewrite CI lane has been pinned
to the same LLVM 18.1.8 clang-cl used locally (eb49a35, 949acaa, a28a368)
and several structured loop recovery fixes have landed (2989e5a, 2eaa22e),
so the codegen mismatch that motivated the skips is gone.

Verified locally with a clean Release build (`cmd /c scripts\dev\configure_iced.cmd`
followed by `build_iced.cmd`):
- `calc_fib` lifts to `ret i64 13` and passes its semantic case
- `calc_sum_array` lifts to `ret i64 150` and passes its semantic case
- `python test.py all` is fully green: semantic 33/33 (was 31/31),
  baseline, micro --check-flags, full handler suite 115/119, determinism

Drops the two `ci_skip` entries from `instruction_microtests.json` and
updates `docs/SCOPE.md` corpus counts to 33 samples / 177 cases.

Co-authored-by: NaC-L <nac-l@users.noreply.github.com>
2026-04-07 13:38:38 +03:00
naciandNaC-L 5ccd498998 Implement PUNPCKLQDQ and re-enable calc_cout (#92)
- Add lift_punpcklqdq handler in Semantics_Misc.ipp (XMM dest, low-quadword
  interleave from dest+src into a 128-bit result; rejects MMX/non-XMM forms
  via the standard not_implemented bailout)
- Wire OPCODE(punpcklqdq, PUNPCKLQDQ) in x86_64_opcodes.x and add a missing
  trailing newline
- Add manual punpcklqdq case to TestInstructions.cpp (rdrand-style XMM seed)
  and matching seeds in build_full_handler_seed.py
- Regenerate oracle_seed_full_handlers{,_enriched}.json, oracle_seed_vectors.json,
  and oracle_vectors_full_handlers.json with two punpcklqdq vectors
  (basic interleave, low-source-zero edge case)
- Drop ci_skip on calc_cout in instruction_microtests.json now that the STL
  PUNPCKLQDQ path lifts cleanly (4/4 semantic cases pass locally)
- Keep calc_fib and calc_sum_array ci_skipped: they still trip a separate
  lifter dyn_cast assertion that is not related to PUNPCKLQDQ; tracked as
  follow-up
- Update docs/SCOPE.md handler counts (115/119 covered, 4 intentional skips)
  and corpus counts (31 active samples / 175 cases)

Co-authored-by: NaC-L <nac-l@users.noreply.github.com>
2026-04-07 12:58:44 +03:00
yusufcanislek fa95a27dae CI-skip calc_sum_array on windows-latest 2026-04-04 16:46:34 +03:00
yusufcanislek 81bc3a89da CI-skip calc_fib on windows-latest 2026-04-04 16:34:38 +03:00
yusufcanislek eb49a35cc7 Pin rewrite CI clang-cl toolchain 2026-04-04 15:53:28 +03:00
yusufcanislek ce77dc514d Fix loop recovery and clang-cl CI gaps 2026-04-04 15:12:49 +03:00
yusufcanislek 555a23def5 Force pinned LLVM clang in rewrite CI 2026-04-04 09:56:03 +03:00
yusufcanislek 2fd523b4e4 Pin CI clang toolchain selection 2026-04-04 09:47:18 +03:00
yusufcanislek 67c26c9bab Fix iced CI cargo detection 2026-04-03 20:28:26 +03:00
yusufcanislek 2989e5ab58 Recover structured loop lifting safely 2026-04-03 19:54:51 +03:00
yusufcanislek 8fba033cc6 Fix VMP gate and loop safety 2026-04-03 15:00:42 +03:00
yusufcanislek 35e9fb38bd feat: add symbolic loop driver and lift budget guard 2026-04-02 14:14:24 +03:00
yusufcanislek c6a6211744 feat: add loop-family instruction support 2026-04-01 14:34:31 +03:00
yusufcanislek 7801597897 fix movq gating and restore calc_cout skip 2026-04-01 12:53:55 +03:00
yusufcanislek 6e1b035e98 feat: add movq semantics support 2026-04-01 11:33:47 +03:00
yusufcanislek 460e845aed fix: stabilize full-handler oracle fixtures 2026-04-01 06:55:56 +03:00
yusufcanislek cdd52c271a feat: profile VMP samples and speed up lifting
- add nested lift diagnostics and helper-level profiling for protected381 targets
- refactor function signature specs and optimize folderBinOps fast paths
- implement the full SCAS family and document VMP 3.6 INT dispatcher findings
- add reproducible profiling scripts and root VMP testing notes
2026-03-31 22:02:57 +03:00
yusufcanislek bb1af2c073 fix: un-skip calc_cout test — .pdata auto-outline already handles it
The calc_cout test was skipped since Phase 1 with the assumption that
statically-linked STL calls required a new inline policy. In reality,
the .pdata auto-outline (PR #78) already registers all STL functions
as outline targets, and the lifter correctly outlines the operator<<
call and lifts the pure computation (x*3+7).

The test was failing because it used the wrong symbol name ('calc_cout'
instead of the MSVC-mangled '?calc_cout@@YAHH@Z').

Changes:
- Un-skip calc_cout, fix symbol to mangled name, add 4 semantic cases
- Add _INTTOPTR_CALL_RE to strip outlined calls to concrete addresses
  (they segfault in lli but are provably dead for return value)
- Golden hashes: 42 -> 44 files

Zero skipped tests remaining. 29/29 samples, 150 semantic cases.
2026-03-29 12:07:26 +03:00
yusufcanislek 10211de85d feat: normalize jump table switch dispatch to logical case indices
New SwitchNormalizationPass that rewrites switch instructions dispatching
on concrete code addresses to use the original input register with logical
case indices (0, 1, 2, ...).

Before:
  switch i32 %trunc7, label %default [
    i32 1073745941, label %bb6    ; 0x40001015
    i32 1073745948, label %bb5    ; 0x4000101C
    i32 1073745955, label %bb4
    i32 1073745962, label %bb3
  ]

After:
  switch i64 %RCX, label %default [
    i64 0, label %bb6
    i64 1, label %bb5
    i64 2, label %bb4
    i64 3, label %bb3
  ]

Detection:
- Finds switches with case values forming an arithmetic progression
- Skips if values are small (<0x10000, already logical)
- Verifies range guard matches case count (prevents mishandling shared targets)
- Traces through select chain + trunc + add + and + shl to find original input
- Handles both icmp ult and and+icmp eq 0 range guard patterns
- Cleans up dead trunc instructions after rewriting

Normalized: jumptable_basic, jumptable_dense, jumptable_rel32 (4 samples)
Correctly skipped: jumptable_shared_targets, jumptable_shifted, jumptable_computation,
  switch_3way, switch_sparse, calc_switch (non-uniform stride or logical values)

All 28 samples pass, 146 semantic cases, 42 golden hashes.
2026-03-29 11:30:36 +03:00
yusufcanislek 1020775ec0 feat: prototype minimization + canonical IR naming
Two new post-optimization passes that run after the final O2 pipeline:

PrototypeMinimizationPass:
- Removes unused function arguments based on Argument::use_empty()
- Typical reduction: 34 params -> 0-2 (e.g. @main(i64 %RCX) instead of all 16 GPRs + 16 XMMs + 2 ptrs)
- Splices basic blocks into new function, remaps argument uses, erases old function
- Updated check_semantic.py to parse actual IR signatures instead of hardcoded 34-param list

CanonicalNamingPass:
- Strips address-derived suffixes from block/value names for deterministic output
- Blocks: entry, bb1, bb2, ... (sequential)
- Values: semantic prefix preserved, address suffix removed (realadd-5368713230- -> realadd)
- Same input now produces byte-identical IR across rebuilds

Also fixed writeFunctionToFile to use stored module pointer M instead of
fnc->getParent() (dangling after prototype minimization erases the old function).

Review fixes:
- CanonicalNamingPass: use StringMap<unsigned> instead of DenseMap<StringRef> (dangling key)
- PrototypeMinimizationPass: restrict call rewriting to CallInst (not InvokeInst/CallBrInst)
- PrototypeMinimizationPass: guard F->eraseFromParent() with use_empty() check
- check_semantic.py: widen define regex to handle dso_local and other prefixes

All 28 samples pass, 146 semantic cases, 56 golden hashes updated.
2026-03-29 11:00:07 +03:00
naciandyusufcanislek 6ee50d315e test: add jump table regression suite (5 samples, 39 semantic cases) (#80)
* test: add jump table regression suite (5 samples, 39 semantic cases)

Add 5 new jump table test cases covering the major dispatch patterns:

- jumptable_rel32.asm: RIP-relative dword offset table (lea+movsxd+add+jmp)
- jumptable_shifted.asm: base-shifted range check (sub before index)
- jumptable_shared_targets.asm: multiple cases sharing handlers
- jumptable_computation.asm: case bodies with symbolic arithmetic
- calc_jumptable_large.c: 16-case dense C switch compiled at /O2

All 5 pass lifting and semantic validation (39 new cases, 146 total).
Update golden hashes (46 -> 56 files), manifest, and docs.

* fix(ci): exclude C-compiled samples from golden IR hashes

C-compiled samples (calc_*) produce address-dependent IR because the
linker places symbols at different addresses depending on toolchain
version, link order, and build environment. The determinism check
comment (test.py L123-125) already documented this exclusion policy
but the golden hash file included them anyway, causing rewrite-quick-gate
to fail on CI.

Remove all 14 calc_* entries from golden_ir_hashes.json (56 -> 42).
C-compiled sample correctness is still validated by semantic tests.

---------

Co-authored-by: yusufcanislek <yusuf.canislek@meetdandy.com>
2026-03-29 09:46:52 +03:00
yusufcanislek 727a3c58fc fix: track check_semantic.py (was excluded by check_*.py gitignore)
The check_*.py gitignore pattern was intended for dev scratch scripts
but also excluded scripts/rewrite/check_semantic.py, which is the
runtime semantic regression runner invoked by test.py quick/all.

CI failed with 'No such file or directory' because the file was never
committed. Add a gitignore exception and track it.
2026-03-26 08:13:13 +03:00
yusufcanislek 37884febd1 fix: remove toolchain-dependent [ 512, pattern from calc_jumptable
The phi incoming value [ 512, depends on whether the compiler emits
all 10 switch cases in a form the lifter can recover. Different clang
versions on CI produce different code structures.

The 12-case semantic test validates all return values including 512
(2^9 for input 9), making this pattern check redundant.
2026-03-26 08:06:53 +03:00
yusufcanislek b3a47cac1c fix: make calc_switch and calc_jumptable patterns address-agnostic for CI
C-compiled samples produce binaries with different layouts depending on
the toolchain version and host. The lifted IR contains absolute virtual
addresses from the binary, so patterns that check specific addresses
(e.g., i64 5368713307) fail on CI where clang produces different code.

calc_switch: reduce to structural patterns (switch i32, phi i64).
calc_jumptable: keep only address-independent patterns (icmp ult,
select i1, phi i64, return value).

The semantic tests (107 cases across all samples) are the real
correctness gate — they verify computed results, not IR shape.

Regenerated golden hashes to match.
2026-03-26 08:01:07 +03:00
yusufcanislek eb10474eb8 feat: commit working-tree changes required by rewrite gates
Lifter improvements:
- PathSolver.ipp: enhanced path memoization, switch-target diagnostics
- GEPTracker.ipp: expanded value tracking, graceful bail-out paths
- Semantics_Misc.ipp: clean up CPUID handler (remove dead comments,
  simplify constant emission)

Rewrite infrastructure:
- instruction_microtests.json: add jumptable manifest entries
  (calc_jumptable, jumptable_basic, jumptable_dense) with semantic cases
- golden_ir_hashes.json: add hashes for new jumptable samples
- build_samples.cmd: support C jumptable /O2 compilation pass
- oracle vectors: regenerated (oracle_vectors.json trimmed to current
  seed set, full-handler vectors updated with new handlers)
- run_microtests.cmd / run_all_handlers.cmd: script improvements
- test.py: add jumptable semantic cases to coverage

Dev scripts:
- configure_iced/zydis.cmd, build_iced/zydis.cmd: improved toolchain
  detection and MERGEN_BUILD_JOBS support

Review automation:
- format_comment.py, invariant_guard.py, risk_map.py, shard_pr.py:
  minor fixes aligned with verify_plan public API rename

Docs:
- REWRITE_BASELINE.md: updated coverage summary and script docs
- REVIEWER_RULES.md: minor formatting
2026-03-26 07:53:43 +03:00
yusufcanislek 981dbb8eda fix: address PR #74 review findings (P1 stackMemory, P2 private API, P2 wide-load diagnostic)
- CustomPasses.hpp: move stackMemory declaration inside the per-function
  loop so each function gets its own alloca with correct size and
  ownership. Previously dormant (single-function modules) but wrong.

- verify_plan.py: rename _build_plan -> build_plan, _run_plan -> run_plan.
  These are used cross-module by run_review.py and should be public API.

- run_review.py: update callers to use the renamed public functions.

- FileReader.hpp: add fprintf(stderr) diagnostic before silent return 0
  on byteSize > 8 (wide SSE/AVX loads). Uses fprintf instead of
  printvalue2 to avoid cross-layer dependency (memory -> core).
2026-03-26 07:45:10 +03:00
yusufcanislek 108355dd84 chore: remove dead files, track missing test sources, clean up .gitignore
- Remove scripts/rewrite/oracle_vectors.json (stale copy of
  lifter/test/test_vectors/oracle_vectors.json, unreferenced)
- Remove tests/rewrite_microtests.cpp (superseded by
  lifter/test/TestInstructions.cpp, unreferenced)
- Remove root cmkr.cmake (duplicate of cmake/cmkr.cmake, unreferenced)
- Track testcases/rewrite_smoke/{calc_jumptable.c, jumptable_basic.asm,
  jumptable_dense.asm} (referenced by manifest but untracked)
- Rewrite .gitignore:
  - Fix broken x64 pattern (backslash -> **/x64/)
  - Fix wrong flagstress path (/lifter/test_vectors/ -> /lifter/test/test_vectors/)
  - Remove dead check_calc_jumptable_semantic.py exception (file doesn't exist)
  - Add IDA Pro database extensions (.i64, .id0, .id1, .id2, .nam, .til)
  - Add .vtil files
  - Ignore /simple/ (binaries and research scratch; sources in testcases/)
  - Organize into labeled sections
2026-03-26 07:19:09 +03:00
yusufcanislek 3308ad7f65 feat: add review automation toolkit with full cutover
- review_buckets.py: shared bucket/risk/check taxonomy
- risk_map.py: PR risk assessment from diff
- invariant_guard.py: vector schema, manifest, backend invariant checks
- verify_plan.py: targeted verification planner with execution mode
- shard_pr.py: refactored to use shared bucket metadata
- run_review.py: orchestrator wiring all modules
- format_comment.py: markdown rendering for review comments
- docs/REVIEWER_RULES.md: reviewer rules with automation shortcuts
- .gitignore: ignore artifacts/ and tmp_*.json

Removed parallel/duplicate review scripts (verification_plan.py,
invariant_checks.py, lint_vectors.py, build_repro.py, __init__.py)
by full cutover to canonical modules.
2026-03-19 19:04:59 +03:00
yusufcanislek 2c93ac705f fix: update sleigh RIP on control-flow exits and fallthrough 2026-03-19 16:20:11 +03:00
yusufcanislek aa5112788f fix: address PR review issues in cargo lookup, RVA mapping, and oracle semantics 2026-03-19 02:46:52 +03:00
yusufcanislek 96f1caa06a build: make iced/zydis selection deterministic in scripts and cmake 2026-03-19 01:59:44 +03:00
yusufcanislek eb5589f7d1 rewrite: centralize manifest validation and add negative contract checks 2026-03-19 01:59:20 +03:00
yusufcanislek ba8b3b9dd9 Support module-mode Sleigh provider import resolution 2026-03-08 22:14:02 +03:00
yusufcanislek 25da4f8b3c Fix XMM31 helper ranges and tighten baseline parity checks 2026-03-08 18:07:54 +03:00
yusufcanislek 433eb12532 Fix unknown provider error path and baseline parity docs 2026-03-08 16:29:15 +03:00
yusufcanislek f53308d3e4 Fix Sleigh dependency fallback path and baseline doc parity note 2026-03-08 16:07:02 +03:00
yusufcanislek f2d2b3b89b Fix latest review findings for pcode loops and SIMD gating 2026-03-08 00:10:04 +03:00
yusufcanislek 8bbb432f69 Stabilize nested branch matcher and refresh golden hashes 2026-03-07 21:02:30 +03:00
yusufcanislek 25c2318ebe Fix fourth-pass review findings for memory and oracle correctness 2026-03-07 20:54:27 +03:00
yusufcanislek 75691e0fd4 Fix PR blocker issues for SIMD oracle and tests 2026-03-07 19:23:32 +03:00
yusufcanislek 8e2ada491f Add SSE2 integer XMM lifting and oracle coverage 2026-03-07 16:14:34 +03:00
yusufcanislek 5ab77e0588 Address review: fix unique-space truncation, dead code, doc comments
sleigh_oracle.py:
  - Fix: unique-space read now truncates oversized data to requested size.
    Prior code only padded short reads but never sliced long reads, causing
    int.from_bytes to consume excess bytes and produce wrong values.
  - Delete dead _op_store method (dispatch table uses _op_store_fixed)
  - Delete dead FLAG_BITS constant (never referenced)
  - Add doc comment on branch offset semantics: empirically verified as
    relative (BSF P-code loop: CBRANCH +7, CBRANCH +3, BRANCH -5)
  - Add doc comment on AF heuristic limitation for ADC/SBB

generate_oracle_vectors.py:
  - Move import sys to module level (was imported inside conditionals)
2026-03-06 21:04:36 +03:00
yusufcanislek dd08c9f318 Add Sleigh/P-code oracle provider for cross-validated test vectors
New file: scripts/rewrite/sleigh_oracle.py
  - PcodeEmulatorState: sparse register/unique/RAM storage
  - PcodeEmulator: concrete P-code executor (30 opcodes, intra-instruction
    branching, AF computation for x86_64)
  - SleighOracleProvider: translates x86_64 bytes to P-code via pypcode,
    emulates, returns register/flag results

Integration: scripts/rewrite/generate_oracle_vectors.py
  - Added 'sleigh' to create_provider() factory
  - --providers unicorn,sleigh enables cross-validation
  - --strict flag controls mismatch behavior (warn vs raise)
  - Secondary provider errors are non-fatal (logged as warnings)

Coverage: 77/85 oracle vector cases match Unicorn exactly.
  7 flag-only mismatches on architecturally undefined flags:
    BEXTR/BSF/BSR (PF), BLSI (CF), BLSMSK/BLSR (AF), MUL (SF)
  1 case unsupported: PDEP (requires CALLOTHER opcode)

Usage:
  pip install pypcode
  python scripts/rewrite/generate_oracle_vectors.py --providers unicorn,sleigh
2026-03-06 20:23:30 +03:00
yusufcanislek a86257c2ad Fix: restore payload/cases loading accidentally deleted in flag-stress rewrite 2026-03-06 19:18:14 +03:00
yusufcanislek caacc3d566 Address review: fix flag-stress generator, stale opcode default, CMakeLists headers
Bug 1 (P1): generate_flag_stress_vectors.py now reads all Semantics_*.ipp
files from the semantics directory instead of a single file. Supports both
directory (default) and single-file modes via --semantics arg.

Bug 2 (P2): TestInstructions.h default opcode path updated to
lifter/semantics/x86_64_opcodes.x.

Issue 3 (P2): rewrite_microtests_SOURCES in CMakeLists.txt now includes
all headers matching the lifter target, fixing IDE source groups.
2026-03-06 18:56:12 +03:00
yusufcanislek 7c597f7174 Fix stale hardcoded paths missed during rename sweep
- lifter/core/Lifter.cpp: lifter/x86_64_opcodes.x -> lifter/semantics/x86_64_opcodes.x
- scripts/rewrite/generate_flag_stress_vectors.py: lifter/Semantics.ipp -> lifter/semantics/Semantics.ipp
2026-03-06 18:39:11 +03:00