Skip to content

X64#1

Draft
StachuDotNet wants to merge 12 commits intomainfrom
x64
Draft

X64#1
StachuDotNet wants to merge 12 commits intomainfrom
x64

Conversation

@StachuDotNet
Copy link
Copy Markdown
Member

No description provided.

StachuDotNet and others added 12 commits April 8, 2026 21:03
- PlatformTypes.fs: OS/Arch DUs available early in compile order
- Platform.fs: x86_64 syscall numbers, architecture detection
- ArchConfig.fs: per-architecture calling convention configs
- DarkCompiler.fsproj: include new files, arm64/x64 directory structure
- Binary_ELF.fs: EM_X86_64 constant
- Dockerfile: add enscript/ghostscript for PDF code review
- devcontainer.json: VS Code devcontainer configuration
- .gitignore: scope x64/x86 patterns to repo root only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- X86_64.fs: instruction DU with ~47 variants (MOV, ADD, SSE2, etc.),
  registers (RAX-R15, XMM0-XMM15), conditions, and sizes
- 7_Encoding.fs: instruction-to-bytes encoder handling REX prefixes,
  ModRM/SIB bytes, and variable-length x86_64 encoding
- 7_Resolve.fs: two-pass label resolution for jump targets
- 8_Binary_Generation_ELF.fs: x86_64 Linux ELF executable output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Complete LIR-to-x86_64 translation (~3,000 lines) handling:
- Two-operand conflict resolution (dest==right clobbering) for all
  binary ops: commutative swap, non-commutative temp registers
- Register mapping: X0-X7 to RAX,RDI,RSI,RCX,R8,R9,R10,RDX
- X8-X17 aliasing to R11 (scratch) with SaveRegs/RestoreRegs for
  multi-operand instructions (RawSet, Msub, Madd)
- Heap allocation via bump pointer (R14) + free list (R15)
- String literal emission, file I/O syscalls (read/write/append/exists)
- IDIV with RDX save/restore, INT64_MIN/-1 overflow detection
- Reference counting helpers (implemented but disabled)
- Float operations via SSE2 with XMM15 temp for non-commutative ops

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 5_RegisterAllocation.fs: take Arch DU parameter instead of runtime
  CPU detection; x86_64-aware operand rewriting (keep right operand
  as StackSlot for two-operand codegen); reduced callee-saved set
  (3 vs ARM64's 8) due to R14/R15 reservation for heap/free-list
- CompilerLibrary.fs: dual-architecture compilation pipeline with
  runtime arch detection branching to x86_64 or ARM64 codegen
- Runtime.fs: x86_64 print routines, heap initialization via mmap,
  leak counter support, string refcounting intrinsics

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename arch-specific pass files into passes/arm64/ and passes/x64/
directories. Shared passes (1-5) remain in passes/. Makes the
architecture boundary explicit in the file structure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- X86_64EncodingTests.fs: byte-level verification for 11 instruction families
- X86_64CodeGenTests.fs: end-to-end compile-and-execute tests
- X86_64ResolveTests.fs: label resolution and instruction sizing
- X86_64BinaryTests.fs: ELF generation and execution tests
- TestRunner.fs: architecture-conditional test execution (qemu fallback)
- PhiResolutionTests.fs: pass Arch parameter to register allocator
- floats.e2e: tolerance fix for cross-platform float formatting

4,529/4,530 tests pass (99.98%). 1 known failure: memReclaimBurn
(requires reference counting, deferred).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- CLAUDE.md: x86_64 backend architecture, register mapping, known
  issues, devcontainer build instructions
- INITIATIVES.md: x86_64 progress tracking, remaining work, debugging
  clues for memReclaimBurn and RC implementation
- Diagnostic scripts: debug-stack.sh (callee-saved corruption),
  debug-x86-crash.sh (GDB crash analysis), disasm-func.sh,
  dump-lir-func.sh, generate-review-pdfs.sh

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- README: note dual-architecture support (ARM64 + x86_64)
- INITIATIVES.md: own ARC/RC implementation on x86_64 rather than
  waiting for ARM64 contributor; add phased plan for fixing the
  37-test regression and generic RefCountDec

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- benchmarks/HISTORY.md: add machine registry (paul=ARM64, major=x86_64),
  append x86_64 instruction counts from cachegrind quick check
- benchmarks/QUICK_BASELINE.txt: replace with x86_64 baseline for
  future regression detection on this architecture
- README.md: note dual-architecture support
- INITIATIVES.md: own ARC/RC implementation on x86_64 rather than
  waiting for ARM64 contributor; add phased plan

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- CLAUDE.md: generic build/test instructions, architecture overview,
  link to TODOs.md. No longer x64-specific.
- TODOs.md: thin index replacing INITIATIVES.md, links to detail docs
- docs/x64-refcounting.md: deep-dive on RC implementation status,
  37-test regression analysis, debugging clues, phased plan
- Remove INITIATIVES.md (content moved to TODOs.md + docs/)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generate PDFs for everything in the PR diff: new files in full, modified
files as diffs. 38 PDFs covering source, tests, docs, infra, scripts,
and benchmarks. 127 pages / 64 sheets double-sided.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant