Module codegen

Module codegen 

Source
Expand description

LLVM IR Code Generation via Text

Generates LLVM IR as text (.ll files) and invokes clang to produce executables. This approach is simpler and more portable than using FFI bindings (inkwell).

§Code Generation Strategy

Stack is threaded through all operations as a pointer:

  1. Start with null stack pointer
  2. Each operation takes stack, returns new stack
  3. Final stack is ignored (should be null for well-typed programs)

§Runtime Function Declarations

All runtime functions follow the pattern:

  • define ptr @name(ptr %stack) { ... } for stack operations
  • define ptr @push_int(ptr %stack, i64 %value) { ... } for literals
  • Stack type is represented as ptr (opaque pointer in modern LLVM)

Structs§

CodeGen