Files
hakorune/src/backend/llvm/mod.rs

41 lines
1.1 KiB
Rust
Raw Normal View History

/*!
* LLVM Backend Module - Compile MIR to LLVM IR for AOT execution
2025-09-11 04:20:28 +09:00
*
* This module provides LLVM-based compilation of Nyash MIR to native code.
* Phase 9.78 PoC implementation focused on minimal "return 42" support.
*/
2025-09-11 04:20:28 +09:00
pub mod box_types;
pub mod compiler;
2025-09-11 04:20:28 +09:00
pub mod context;
2025-09-11 04:20:28 +09:00
use crate::box_trait::{IntegerBox, NyashBox};
use crate::mir::function::MirModule;
/// Compile MIR module to object file and execute
pub fn compile_and_execute(
mir_module: &MirModule,
output_path: &str,
) -> Result<Box<dyn NyashBox>, String> {
let mut compiler = compiler::LLVMCompiler::new()?;
compiler.compile_and_execute(mir_module, output_path)
}
/// Compile MIR module to object file only
2025-09-11 04:20:28 +09:00
pub fn compile_to_object(mir_module: &MirModule, output_path: &str) -> Result<(), String> {
let compiler = compiler::LLVMCompiler::new()?;
compiler.compile_module(mir_module, output_path)
}
#[cfg(test)]
mod tests {
use super::*;
2025-09-11 04:20:28 +09:00
#[test]
fn test_llvm_module_creation() {
// Basic test to ensure the module can be loaded
// Actual compilation tests require full MIR infrastructure
assert!(true);
}
2025-09-11 04:20:28 +09:00
}