diff --git a/hir/src/dataflow.rs b/hir/src/dataflow.rs index d8c9ca76..5ad48a8f 100644 --- a/hir/src/dataflow.rs +++ b/hir/src/dataflow.rs @@ -5,7 +5,7 @@ use intrusive_collections::UnsafeRef; use rustc_hash::FxHashMap; use smallvec::SmallVec; -use miden_diagnostics::{SourceSpan, Span}; +use miden_diagnostics::{SourceSpan, Span, Spanned}; use super::*; @@ -127,6 +127,13 @@ impl DataFlowGraph { self.values[v].ty() } + pub fn value_span(&self, v: Value) -> SourceSpan { + match &self.values[v] { + ValueData::Param { span, .. } => *span, + ValueData::Inst { inst, .. } => self.inst_span(*inst), + } + } + #[inline(always)] pub fn value_data(&self, v: Value) -> &ValueData { &self.values[v] @@ -152,6 +159,10 @@ impl DataFlowGraph { &mut self.insts[inst] } + pub fn inst_span(&self, inst: Inst) -> SourceSpan { + self.inst(inst).span() + } + pub fn inst_args(&self, inst: Inst) -> &[Value] { self.insts[inst].arguments(&self.value_lists) }