use crate::ir_inner::model::expr::Expr;
use crate::ir_inner::model::types::{BinOp, UnOp};
impl Expr {
#[must_use]
#[inline(always)]
pub fn bitxor(left: Expr, right: Expr) -> Expr {
Expr::BinOp {
op: BinOp::BitXor,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn bitand(left: Expr, right: Expr) -> Expr {
Expr::BinOp {
op: BinOp::BitAnd,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn bitor(left: Expr, right: Expr) -> Expr {
Expr::BinOp {
op: BinOp::BitOr,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn bitnot(operand: Expr) -> Expr {
Expr::UnOp {
op: UnOp::BitNot,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn shl(left: Expr, right: Expr) -> Expr {
Expr::BinOp {
op: BinOp::Shl,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn shr(left: Expr, right: Expr) -> Expr {
Expr::BinOp {
op: BinOp::Shr,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn reverse_bits(operand: Expr) -> Expr {
Expr::UnOp {
op: UnOp::ReverseBits,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn popcount(operand: Expr) -> Expr {
Expr::UnOp {
op: UnOp::Popcount,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn clz(operand: Expr) -> Expr {
Expr::UnOp {
op: UnOp::Clz,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn ctz(operand: Expr) -> Expr {
Expr::UnOp {
op: UnOp::Ctz,
operand: Box::new(operand),
}
}
}