Skip to content

Commit

Permalink
feat: add dataflow apis for getting value/inst spans
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Sep 7, 2023
1 parent bf684c1 commit d1a1724
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion hir/src/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -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]
Expand All @@ -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)
}
Expand Down

0 comments on commit d1a1724

Please sign in to comment.