Add some convenience bits to op_traits, and export MemoryArg.

This commit is contained in:
Chris Fallin 2023-03-23 17:35:51 -07:00
parent 21b2907e17
commit 9f4310f729
2 changed files with 15 additions and 1 deletions

View file

@ -18,7 +18,7 @@ mod scoped_map;
pub use errors::*;
pub use ir::*;
pub use ops::{Ieee32, Ieee64, Operator};
pub use ops::{Ieee32, Ieee64, MemoryArg, Operator};
mod interp;
pub use interp::*;

View file

@ -641,6 +641,20 @@ impl Operator {
pub fn is_pure(&self) -> bool {
self.effects().is_empty()
}
pub fn is_call(&self) -> bool {
match self {
Operator::Call { .. } | Operator::CallIndirect { .. } => true,
_ => false,
}
}
pub fn accesses_memory(&self) -> bool {
self.effects().iter().any(|e| match e {
SideEffect::ReadMem | SideEffect::WriteMem => true,
_ => false,
})
}
}
impl std::fmt::Display for Operator {