use crate::ir::model::expr::Expr;
use crate::ir::model::types::{BinOp, UnOp};
impl Expr {
#[must_use]
#[inline(always)]
pub fn min(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Min,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn max(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Max,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn floor(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Floor,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn ceil(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Ceil,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn round(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Round,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn trunc(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Trunc,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn sign(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Sign,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn is_nan(operand: Self) -> Self {
Self::UnOp {
op: UnOp::IsNan,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn is_inf(operand: Self) -> Self {
Self::UnOp {
op: UnOp::IsInf,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn is_finite(operand: Self) -> Self {
Self::UnOp {
op: UnOp::IsFinite,
operand: Box::new(operand),
}
}
}