Skip to content

Tier 2: Fixed-size arrays and optimizations#32

Merged
kavanaghpatrick merged 17 commits intomainfrom
feat/tier2-arrays
Mar 8, 2026
Merged

Tier 2: Fixed-size arrays and optimizations#32
kavanaghpatrick merged 17 commits intomainfrom
feat/tier2-arrays

Conversation

@kavanaghpatrick
Copy link
Copy Markdown
Owner

Summary

  • Add 4 new array opcodes (ALLOC, ALOAD, ASTORE, ALEN) wired through full pipeline: opcodes β†’ VM β†’ bytecode β†’ Metal kernel β†’ GPU glue β†’ C compiler
  • Transpiler support for arr = [0.0] * N, arr[i] read/write, arr[i] += val augmented assignment
  • sum(arr) and len(arr) builtins for array variables
  • Constant folding: 4.0 * 3.14159 β†’ single PUSH at compile time
  • Type inference: skip unnecessary float coercion when dividend is known-float
  • GPU arrays: thread-local storage (8 arrays x 256 floats per thread)
  • 831 tests passing (48+ new tests added)

Closes #28

Test plan

  • Array allocation, read, write, augmented assignment in VM
  • Array bounds checking and error messages
  • Transpiler handles [0.0] * N, subscript access, sum(), len()
  • Constant folding reduces instruction count
  • Type inference skips float coercion for known-float variables
  • Bytecode encoding for all 4 array ops
  • Metal kernel compiles with array storage and opcodes
  • C compiler emits array declarations and access code
  • Full regression: 831 tests, 0 failures

πŸ€– Generated with Claude Code

claude added 17 commits March 8, 2026 11:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e inference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Allow ALLOC size 0 (empty array) instead of rejecting it
- Unify error messages: "Cell 'X' is not an array" for scalar-on-array ops
- Metal kernel already had all required bounds/limit checks from task 2.3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kavanaghpatrick kavanaghpatrick merged commit 162975d into main Mar 8, 2026
4 checks passed
@kavanaghpatrick kavanaghpatrick deleted the feat/tier2-arrays branch March 8, 2026 04:22
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.

Tier 2: Fixed-size arrays and optimizations

2 participants