haloumi_core/cmp.rs
1//! Comparison IR operator.
2
3/// Comparison operators between arithmetic expressions.
4#[derive(Copy, Clone, PartialEq, Eq, Debug, PartialOrd, Ord, Hash)]
5pub enum CmpOp {
6 /// Equality
7 Eq,
8 /// Less than
9 Lt,
10 /// Less than or equal
11 Le,
12 /// Greater than
13 Gt,
14 /// Greater than or equal
15 Ge,
16 /// Not equal
17 Ne,
18}
19
20impl std::fmt::Display for CmpOp {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 write!(
23 f,
24 "{}",
25 match self {
26 CmpOp::Eq => "==",
27 CmpOp::Lt => "<",
28 CmpOp::Le => "<=",
29 CmpOp::Gt => ">",
30 CmpOp::Ge => ">=",
31 CmpOp::Ne => "!=",
32 }
33 )
34 }
35}