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
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for CodeGen
impl RefUnwindSafe for CodeGen
impl Send for CodeGen
impl Sync for CodeGen
impl Unpin for CodeGen
impl UnwindSafe for CodeGen
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more