diff --git a/archive/rust-llvm-backend/RESTORE.md b/archive/rust-llvm-backend/RESTORE.md new file mode 100644 index 00000000..1220107a --- /dev/null +++ b/archive/rust-llvm-backend/RESTORE.md @@ -0,0 +1,7 @@ +# RESTORE — Rust LLVM backend + +To restore the archived backend back to the original location: + + git mv archive/rust-llvm-backend/llvm src/backend/ + +Rationale: Python llvmlite is the primary LLVM path. The Rust backend was deprecated and archived as part of the De‑Rust Phase‑0. diff --git a/src/backend/llvm/README.md b/archive/rust-llvm-backend/llvm/README.md similarity index 100% rename from src/backend/llvm/README.md rename to archive/rust-llvm-backend/llvm/README.md diff --git a/src/backend/llvm/compiler/codegen/function.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/function.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/function.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/function.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/arith.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/arith.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/arith.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/arith.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/arith_ops.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/arith_ops.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/arith_ops.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/arith_ops.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/arrays.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/arrays.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/arrays.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/arrays.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/blocks.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/blocks.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/blocks.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/blocks.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/boxcall.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/boxcall.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/boxcall/fields.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall/fields.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/boxcall/fields.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall/fields.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/boxcall/invoke.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall/invoke.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/boxcall/invoke.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall/invoke.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/boxcall/marshal.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall/marshal.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/boxcall/marshal.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/boxcall/marshal.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/builder_cursor.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/builder_cursor.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/builder_cursor.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/builder_cursor.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/call.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/call.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/call.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/call.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/consts.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/consts.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/consts.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/consts.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/ctx.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/ctx.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/ctx.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/ctx.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/externcall/console.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/externcall/console.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/externcall/console.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/externcall/console.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/externcall/env.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/externcall/env.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/externcall/env.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/externcall/env.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/externcall/mod.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/externcall/mod.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/externcall/mod.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/externcall/mod.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/flow.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/flow.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/flow.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/flow.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/loopform.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/loopform.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/loopform.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/loopform.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/maps.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/maps.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/maps.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/maps.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/mem.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/mem.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/mem.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/mem.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/mod.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/mod.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/mod.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/mod.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/newbox.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/newbox.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/newbox.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/newbox.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/resolver.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/resolver.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/resolver.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/resolver.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/select.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/select.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/select.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/select.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/string_ops.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/string_ops.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/string_ops.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/string_ops.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/strings.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/strings.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/strings.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/strings.rs diff --git a/src/backend/llvm/compiler/codegen/instructions/terminators.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/instructions/terminators.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/instructions/terminators.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/instructions/terminators.rs diff --git a/src/backend/llvm/compiler/codegen/mod.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/mod.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/mod.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/mod.rs diff --git a/src/backend/llvm/compiler/codegen/object.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/object.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/object.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/object.rs diff --git a/src/backend/llvm/compiler/codegen/types.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/types.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/types.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/types.rs diff --git a/src/backend/llvm/compiler/codegen/utils.rs b/archive/rust-llvm-backend/llvm/compiler/codegen/utils.rs similarity index 100% rename from src/backend/llvm/compiler/codegen/utils.rs rename to archive/rust-llvm-backend/llvm/compiler/codegen/utils.rs diff --git a/src/backend/llvm/compiler/interpreter.rs b/archive/rust-llvm-backend/llvm/compiler/interpreter.rs similarity index 100% rename from src/backend/llvm/compiler/interpreter.rs rename to archive/rust-llvm-backend/llvm/compiler/interpreter.rs diff --git a/src/backend/llvm/mod.rs b/archive/rust-llvm-backend/llvm/mod.rs similarity index 100% rename from src/backend/llvm/mod.rs rename to archive/rust-llvm-backend/llvm/mod.rs diff --git a/docs/development/strategies/de-rust-gap-analysis.md b/docs/development/strategies/de-rust-gap-analysis.md new file mode 100644 index 00000000..1e301c66 --- /dev/null +++ b/docs/development/strategies/de-rust-gap-analysis.md @@ -0,0 +1,35 @@ +# De‑Rust Gap Analysis (Phase 21.9) + +This memo enumerates gaps to execute Phase‑1/2 tasks safely. + +## hv1_inline → Parity +- JSON support: ensure compare/branch/jump/phi/mir_call minimal are covered. +- Parity canaries: phase2037/* (flow), phase2170/* (state). +- Env guard: consider `HAKO_VERIFY_DISABLE_INLINE=1` for hard opt‑out (optional). + +## TLV Codec → C shim +- Minimal C API: tlv_encode(buf,len, out_ptr, out_len) / tlv_decode(...) +- FFI wrapper in Rust; map errors to Result. +- Tests: round‑trip on byte arrays; malformed inputs; size limits. + +## MIR Interpreter (Rust) — Diagnostic mode +- Keep as fallback/diagnostic; Primary = Hakovm. +- Ensure boxcall/mir_call minimal parity for sample set. +- Gate via env to avoid accidental use in primary flows. + +## LLVM Wrapper → Hako/C Harness +- Keep Python llvmlite primary until Hako IR is mature. +- Hako wrapper CLI to drive harness with env (`NYASH_LLVM_USE_HARNESS=1`). +- Tests: small end‑to‑end const/ret and simple branch; IR dump gate remains. + +## Resolver/Using SSOT (Hako First) +- Runner policy and HakoCheck strip/order unified; document precedence. +- Strict profiles disallow path‑literal using. + +## FileBox Core → C (later) +- Small C layer for read‑only (Analyzer) and read/write (dev) under caps; Rust shim remains. + +## Acceptance Summary +- Build: cargo build (default) green. +- Smokes: quick/core green; parity canaries pass. +- Docs: roadmap + plan page + restore steps present. diff --git a/docs/development/strategies/de-rust-roadmap.md b/docs/development/strategies/de-rust-roadmap.md index 0f44e180..0d4dcd46 100644 --- a/docs/development/strategies/de-rust-roadmap.md +++ b/docs/development/strategies/de-rust-roadmap.md @@ -16,11 +16,21 @@ Purpose: reduce Rust surface (non‑plugin) while keeping correctness and revers - TLV codec → C shim (FFI) with thin Rust wrapper. - LLVM wrapper → Hako/C harness (Python stays primary until Hako IR is ready). +Deliverables & Tests +- hv1_inline: parity canaries = phase2037/flow + phase2170/state; add `HAKO_VERIFY_DISABLE_INLINE` opt-out (optional). +- TLV C shim: round‑trip tests (encode→decode) on representative payloads; FFI error mapping spec. +- MIR interpreter: keep as diagnostic path; parity sample set (const/binop/compare/branch/jump/ret/phi/mir_call minimal). +- LLVM wrapper: unify CLI entry; ensure `NYASH_LLVM_USE_HARNESS=1` path stays green. + ### Phase 2 — Core Thinning (2–4 months) - Plugin loader thin C wrapper (dlopen/dlsym), unify host ABI. - Basic boxes (Array/Map/File) small C core (handle‑based), keep Rust shim. - Resolver/Using: SSOT in Hako; runner uses shared policy. +SSOT for Using/Resolver (summary) +- Resolution order: modules (nyash.toml) → relative path inference → not found (warn) with verbose details. +- Analyzer/HakoCheck follows the same order; runner shares policy helpers. No path‑literal using in strict profiles. + ### Phase 3 — Long‑haul (3–6 months) - Python llvmlite → Hako IR builder + C ABI. - Parser/MIR builder fully Hako‑first; Rust becomes fallback. @@ -36,3 +46,8 @@ Purpose: reduce Rust surface (non‑plugin) while keeping correctness and revers 2) Add phase docs (docs/private/roadmap/phases/phase-21.9/PLAN.md). 3) Keep CI/dev instructions intact (no build break when features=none). +## Test Strategy (gates) +- Quick: tools/smokes/v2/profiles/quick/core/* (phase2037 flow, phase2170 state) — green. +- Verify routing: HAKO_VERIFY_PRIMARY=hakovm (default); hv1_inline perf path parity (env toggles only). +- Build: `cargo build --release` (default features); LLVM paths are opt‑in. +- Docs: keep RESTORE steps for any archived parts; small diffs, easy rollback.