pub struct CodeGen { /* private fields */ }Implementations§
Source§impl CodeGen
impl CodeGen
Sourcepub fn codegen_program(
&mut self,
program: &Program,
type_map: HashMap<usize, Type>,
statement_types: HashMap<(String, usize), Type>,
) -> Result<String, CodeGenError>
pub fn codegen_program( &mut self, program: &Program, type_map: HashMap<usize, Type>, statement_types: HashMap<(String, usize), Type>, ) -> Result<String, CodeGenError>
Generate LLVM IR for entire program
Sourcepub fn codegen_program_with_config(
&mut self,
program: &Program,
type_map: HashMap<usize, Type>,
statement_types: HashMap<(String, usize), Type>,
config: &CompilerConfig,
) -> Result<String, CodeGenError>
pub fn codegen_program_with_config( &mut self, program: &Program, type_map: HashMap<usize, Type>, statement_types: HashMap<(String, usize), Type>, config: &CompilerConfig, ) -> Result<String, CodeGenError>
Generate LLVM IR for entire program with custom configuration
This allows external projects to extend the compiler with additional builtins that will be declared and callable from Seq code.
Sourcepub fn codegen_program_with_ffi(
&mut self,
program: &Program,
type_map: HashMap<usize, Type>,
statement_types: HashMap<(String, usize), Type>,
config: &CompilerConfig,
ffi_bindings: &FfiBindings,
) -> Result<String, CodeGenError>
pub fn codegen_program_with_ffi( &mut self, program: &Program, type_map: HashMap<usize, Type>, statement_types: HashMap<(String, usize), Type>, config: &CompilerConfig, ffi_bindings: &FfiBindings, ) -> Result<String, CodeGenError>
Generate LLVM IR for entire program with FFI support
This is the main entry point for compiling programs that use FFI.
Source§impl CodeGen
impl CodeGen
Sourcepub fn can_specialize(&self, word: &WordDef) -> Option<SpecSignature>
pub fn can_specialize(&self, word: &WordDef) -> Option<SpecSignature>
Check if a word can be specialized and return its signature if so
Sourcepub fn codegen_specialized_word(
&mut self,
word: &WordDef,
sig: &SpecSignature,
) -> Result<(), CodeGenError>
pub fn codegen_specialized_word( &mut self, word: &WordDef, sig: &SpecSignature, ) -> Result<(), CodeGenError>
Generate a specialized version of a word.
This creates a register-based function that passes values directly in
CPU registers instead of through the 40-byte %Value stack.
The generated function:
- Takes primitive arguments directly (i64 for Int/Bool, double for Float)
- Returns the result in a register (not via stack pointer)
- Uses
musttailfor recursive calls to guarantee TCO - Handles control flow with phi nodes for value merging
Example output for fib ( Int -- Int ):
define i64 @seq_fib_i64(i64 %arg0) {
; ... register-based implementation
}Source§impl CodeGen
impl CodeGen
pub fn new() -> Self
Sourcepub fn new_pure_inline_test() -> Self
pub fn new_pure_inline_test() -> Self
Create a CodeGen for pure inline testing. Bypasses the scheduler, returning top of stack as exit code. Only supports operations that are fully inlined (integers, arithmetic, stack ops).
Sourcepub fn set_aux_slot_counts(&mut self, counts: HashMap<String, usize>)
pub fn set_aux_slot_counts(&mut self, counts: HashMap<String, usize>)
Set per-word aux stack slot counts from typechecker (Issue #350)