//! Slonik normalized SSA IR.

mod block;
mod body;
mod expr;
mod frontend;
mod stmt;
mod ty;
mod verify;
mod write;

pub use block::*;
pub use body::*;
pub use expr::*;
pub use frontend::*;
pub use stmt::*;
pub use ty::*;
pub use verify::*;
pub use write::*;

/// Defines a thin `u32` entity handle.
macro_rules! entity {
    (
        $(
            $(#[$meta:meta])*
            $vis:vis struct $name:ident = $prefix:literal;
        )*
    ) => {
        $(
            $(#[$meta])*
            #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
            $vis struct $name(u32);

            cranelift_entity::entity_impl!($name, $prefix);
        )*
    };
}

entity! {
    /// A handle to a basic block in a `Body`.
    pub struct Block = "block";

    /// A handle to an ordered statement node.
    pub struct Stmt = "stmt";

    /// A handle to an SSA value.
    pub struct Value = "v";

    /// A frontend-level source variable.
    pub struct Variable = "var";
}
