Trait hugr_llvm::custom::prelude::PreludeCodegen

source ·
pub trait PreludeCodegen: Clone {
    // Provided methods
    fn usize_type<'c, H: HugrView>(
        &self,
        session: &TypingSession<'c, H>,
    ) -> IntType<'c> { ... }
    fn qubit_type<'c, H: HugrView>(
        &self,
        session: &TypingSession<'c, H>,
    ) -> impl BasicType<'c> { ... }
    fn array_type<'c, H: HugrView>(
        &self,
        _session: &TypingSession<'c, H>,
        elem_ty: BasicTypeEnum<'c>,
        size: u64,
    ) -> impl BasicType<'c> { ... }
    fn emit_new_array_alloc<'c, H: HugrView>(
        &self,
        ctx: &mut EmitFuncContext<'c, H>,
        elem_ty: BasicTypeEnum<'c>,
        elems: Vec<BasicValueEnum<'_>>,
    ) -> Result<BasicValueEnum<'c>> { ... }
    fn emit_print<H: HugrView>(
        &self,
        ctx: &mut EmitFuncContext<'_, H>,
        text: BasicValueEnum<'_>,
    ) -> Result<()> { ... }
    fn emit_panic<H: HugrView>(
        &self,
        ctx: &mut EmitFuncContext<'_, H>,
        signal: IntValue<'_>,
        msg: BasicValueEnum<'_>,
    ) -> Result<()> { ... }
}
Expand description

A helper trait for implementing CodegenExtensions for hugr::extension::prelude.

All methods have sensible defaults provided, and DefaultPreludeCodegen is trivial implementation of this trait, which delegates everything to those default implementations.

One should use either PreludeCodegenExtension::new, or CodegenExtsMap::add_prelude_extensions to work with the CodegenExtension.

TODO several types and ops are unimplemented. We expect to add methods to this trait as necessary, allowing downstream users to customise the lowering of prelude.

Provided Methods§

source

fn usize_type<'c, H: HugrView>( &self, session: &TypingSession<'c, H>, ) -> IntType<'c>

Return the llvm type of hugr::extension::prelude::USIZE_T. That type must be an IntType.

source

fn qubit_type<'c, H: HugrView>( &self, session: &TypingSession<'c, H>, ) -> impl BasicType<'c>

Return the llvm type of hugr::extension::prelude::QB_T.

source

fn array_type<'c, H: HugrView>( &self, _session: &TypingSession<'c, H>, elem_ty: BasicTypeEnum<'c>, size: u64, ) -> impl BasicType<'c>

Return the llvm type of hugr::extension::prelude::array_type.

source

fn emit_new_array_alloc<'c, H: HugrView>( &self, ctx: &mut EmitFuncContext<'c, H>, elem_ty: BasicTypeEnum<'c>, elems: Vec<BasicValueEnum<'_>>, ) -> Result<BasicValueEnum<'c>>

source

fn emit_print<H: HugrView>( &self, ctx: &mut EmitFuncContext<'_, H>, text: BasicValueEnum<'_>, ) -> Result<()>

source

fn emit_panic<H: HugrView>( &self, ctx: &mut EmitFuncContext<'_, H>, signal: IntValue<'_>, msg: BasicValueEnum<'_>, ) -> Result<()>

Object Safety§

This trait is not object safe.

Implementors§