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