tnj_air/instructions/
value.rs1mod block;
2mod constant;
3mod inst;
4
5use arch::reg::Reg;
6pub use block::*;
7pub use constant::*;
8pub use inst::*;
9
10#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
13pub enum Value {
14 Inst(Inst),
16 Const(Const),
18 Label(BasicBlock),
20 Reg(Reg),
22 BlockParam(BlockParam),
24 Undef,
26}
27
28impl Value {
29 pub fn is_inst(&self) -> bool {
31 matches!(self, Self::Inst(_))
32 }
33 pub fn is_const(&self) -> bool {
35 matches!(self, Self::Const(_))
36 }
37}
38
39macro_rules! value_from {
40 ($variant:ident, $inner:ident) => {
41 impl From<$inner> for Value {
42 fn from(value: $inner) -> Value {
43 Value::$variant(value)
44 }
45 }
46 };
47}
48
49value_from!(Inst, Inst);
50value_from!(Const, Const);
51value_from!(Label, BasicBlock);
52value_from!(Reg, Reg);
53value_from!(BlockParam, BlockParam);