1use pliron::{
4 context::{Context, Ptr},
5 derive::{op_interface, type_interface},
6 irbuild::dialect_conversion::{DialectConversionRewriter, OperandsInfo},
7 op::Op,
8 result::Result,
9 r#type::{Type, TypeObj},
10};
11
12pub mod attributes;
13pub mod from_llvm_ir;
14pub mod function_call_utils;
15pub mod interface_impls;
16pub mod llvm_sys;
17pub mod op_interfaces;
18pub mod ops;
19pub mod to_llvm_ir;
20pub mod types;
21
22#[op_interface]
24pub trait ToLLVMDialect {
25 fn rewrite(
27 &self,
28 ctx: &mut Context,
29 rewriter: &mut DialectConversionRewriter,
30 operands_info: &OperandsInfo,
31 ) -> Result<()>;
32
33 fn verify(_op: &dyn Op, _ctx: &Context) -> Result<()>
34 where
35 Self: Sized,
36 {
37 Ok(())
38 }
39}
40
41pub type ToLLVMTypeFn = fn(self_ty: Ptr<TypeObj>, &mut Context) -> Result<Ptr<TypeObj>>;
43
44#[type_interface]
46pub trait ToLLVMType {
47 fn converter(&self) -> ToLLVMTypeFn;
52
53 fn verify(_ty: &dyn Type, _ctx: &Context) -> Result<()>
54 where
55 Self: Sized,
56 {
57 Ok(())
58 }
59}