duskphantom_middle/ir/instruction/
binary_inst.rs1use super::*;
18use crate::impl_binary_inst;
19use ValueType::{Bool, Float, Int};
20
21pub trait BinaryInst {
23 fn get_lhs(&self) -> &Operand;
24 fn set_lhs(&mut self, lhs: Operand);
25 fn get_rhs(&self) -> &Operand;
26 fn set_rhs(&mut self, rhs: Operand);
27}
28
29impl_binary_inst!(Add, "i32", get_add, lhs, rhs, Int);
30impl_binary_inst!(FAdd, "float", get_fadd, lhs, rhs, Float);
31impl_binary_inst!(Sub, "i32", get_sub, lhs, rhs, Int);
32impl_binary_inst!(FSub, "float", get_fsub, lhs, rhs, Float);
33impl_binary_inst!(Mul, "i32", get_mul, lhs, rhs, Int);
34impl_binary_inst!(FMul, "float", get_fmul, lhs, rhs, Float);
35impl_binary_inst!(UDiv, "i32", get_udiv, lhs, rhs, Int);
36impl_binary_inst!(SDiv, "i32", get_sdiv, lhs, rhs, Int);
37impl_binary_inst!(FDiv, "float", get_fdiv, lhs, rhs, Float);
38impl_binary_inst!(URem, "i32", get_urem, lhs, rhs, Int);
39impl_binary_inst!(SRem, "i32", get_srem, lhs, rhs, Int);
40impl_binary_inst!(Shl, "i32", get_shl, value, shiftamt, Int);
41impl_binary_inst!(LShr, "i32", get_lshr, value, shiftamt, Int);
42impl_binary_inst!(AShr, "i32", get_ashr, value, shiftamt, Int);
43impl_binary_inst!(And, "i1", get_and, lhs, rhs, Bool);
44impl_binary_inst!(Or, "i1", get_or, lhs, rhs, Bool);
45impl_binary_inst!(Xor, "i1", get_xor, lhs, rhs, Bool);