mod context;
mod loop_lower;
mod lower;
mod module;
mod types;
pub use context::LlvmContext;
pub use loop_lower::{lower_loop_ir, lower_loop_irs, LoopLowering};
pub use lower::{
lower_core_module, lower_core_module_multimodule,
lower_core_module_multimodule_with_constructors, CompiledSymbol, ConstructorMeta, Lowering,
};
pub use module::{LlvmModule, LlvmModuleExt};
pub use types::TypeMapper;
use crate::{CodegenConfig, CodegenResult};
use bhc_target::TargetSpec;
pub struct LlvmBackend {
_private: (),
}
impl LlvmBackend {
#[must_use]
pub fn new() -> Self {
inkwell::targets::Target::initialize_all(&inkwell::targets::InitializationConfig::default());
Self { _private: () }
}
#[must_use]
pub const fn is_available(&self) -> bool {
true
}
#[must_use]
pub const fn name(&self) -> &'static str {
"llvm"
}
#[must_use]
pub fn supports_target(&self, target: &TargetSpec) -> bool {
let triple = inkwell::targets::TargetTriple::create(&target.triple());
inkwell::targets::Target::from_triple(&triple).is_ok()
}
pub fn create_context(&self, config: CodegenConfig) -> CodegenResult<LlvmContext> {
LlvmContext::new(config)
}
}
impl Default for LlvmBackend {
fn default() -> Self {
Self::new()
}
}