From 9f4310f7295298e85668fe9e0b6ce344f9aaff7f Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 23 Mar 2023 17:35:51 -0700 Subject: [PATCH] Add some convenience bits to `op_traits`, and export `MemoryArg`. --- src/lib.rs | 2 +- src/op_traits.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c527f4c..13623f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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::*; diff --git a/src/op_traits.rs b/src/op_traits.rs index bda859f..8e6a887 100644 --- a/src/op_traits.rs +++ b/src/op_traits.rs @@ -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 {