Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hashql_diagnostics::DiagnosticIssues;
use hashql_mir::{
context::MirContext,
intern::Interner,
pass::{Pass as _, analysis::DataDependencyAnalysis},
pass::{AnalysisPass as _, analysis::DataDependencyAnalysis},
};

use super::{RunContext, Suite, SuiteDiagnostic};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hashql_mir::{
context::MirContext,
def::{DefId, DefIdSlice, DefIdVec},
intern::Interner,
pass::{Pass as _, transform::CfgSimplify},
pass::{TransformPass as _, transform::CfgSimplify},
};

use super::{RunContext, Suite, SuiteDiagnostic, common::process_issues, mir_reify::mir_reify};
Expand Down
10 changes: 10 additions & 0 deletions libs/@local/hashql/core/src/id/bit_vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,16 @@ impl<T: Id> MixedBitSet<T> {
}
}

#[inline]
#[must_use]
pub fn new_filled(domain_size: usize) -> Self {
if domain_size <= CHUNK_BITS {
Self::Small(DenseBitSet::new_filled(domain_size))
} else {
Self::Large(ChunkedBitSet::new_filled(domain_size))
}
}

#[inline]
#[must_use]
pub fn is_empty(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion libs/@local/hashql/mir/src/body/terminator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use self::{
goto::Goto,
graph::{GraphRead, GraphReadBody, GraphReadHead, GraphReadLocation, GraphReadTail},
r#return::Return,
switch_int::{SwitchIf, SwitchInt, SwitchTargets},
switch_int::{SwitchIf, SwitchInt, SwitchIntValue, SwitchTargets},
target::Target,
};
use super::basic_block::BasicBlockId;
Expand Down
14 changes: 14 additions & 0 deletions libs/@local/hashql/mir/src/body/terminator/switch_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ pub struct SwitchIf<'heap> {
pub r#else: Target<'heap>,
}

/// Represents which branch of a [`SwitchInt`] terminator is being taken.
///
/// Used by dataflow analyses to apply edge-specific effects when propagating
/// state through switch branches. See
/// [`apply_switch_int_edge_effect`](crate::pass::analysis::dataflow::framework::DataflowAnalysis::apply_switch_int_edge_effect).
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum SwitchIntValue {
/// An explicit case with the given discriminant value.
Direct(u128),

/// The default/otherwise branch for unmatched values.
Otherwise,
}

/// A mapping from integer discriminant values to control flow targets.
///
/// Maps integer discriminant values to [`Target`]s for multi-way control flow.
Expand Down
2 changes: 2 additions & 0 deletions libs/@local/hashql/mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
int_roundings,
iter_array_chunks,
iter_collect_into,
iter_intersperse,
string_from_utf8_lossy_owned,
try_trait_v2,
)]
#![expect(clippy::indexing_slicing)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use crate::{
},
context::MirContext,
intern::Interner,
pass::Pass,
pass::AnalysisPass,
visit::Visitor,
};

Expand Down Expand Up @@ -427,8 +427,8 @@ impl Default for DataDependencyAnalysis<'_> {
}
}

impl<'env, 'heap, A: Allocator> Pass<'env, 'heap> for DataDependencyAnalysis<'heap, A> {
fn run(&mut self, context: &mut MirContext<'env, 'heap>, body: &mut Body<'heap>) {
impl<'env, 'heap, A: Allocator> AnalysisPass<'env, 'heap> for DataDependencyAnalysis<'heap, A> {
fn run(&mut self, context: &mut MirContext<'env, 'heap>, body: &Body<'heap>) {
self.graph.derive(&body.local_decls, |id, _| id);

let Ok(()) = DataDependencyAnalysisVisitor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ use hashql_hir::node::operation::InputOp;
use insta::{Settings, assert_snapshot};

use super::DataDependencyAnalysis;
use crate::{body::Body, context::MirContext, pass::Pass as _, scaffold};
use crate::{body::Body, context::MirContext, pass::AnalysisPass as _, scaffold};

#[track_caller]
fn assert_data_dependency<'heap>(
name: &'static str,
body: Body<'heap>,
body: &Body<'heap>,
context: &mut MirContext<'_, 'heap>,
) {
let mut body = body;

let mut analysis = DataDependencyAnalysis::new();
analysis.run(context, &mut body);
analysis.run(context, body);
let graph = analysis.finish();
let transient = graph.transient(context.interner);

Expand Down Expand Up @@ -63,7 +61,7 @@ fn load_simple() {

assert_data_dependency(
"load_simple",
body,
&body,
&mut MirContext {
heap: &heap,
env: &env,
Expand Down Expand Up @@ -108,7 +106,7 @@ fn load_chain() {

assert_data_dependency(
"load_chain",
body,
&body,
&mut MirContext {
heap: &heap,
env: &env,
Expand Down Expand Up @@ -156,7 +154,7 @@ fn load_with_projection() {

assert_data_dependency(
"load_with_projection",
body,
&body,
&mut MirContext {
heap: &heap,
env: &env,
Expand Down Expand Up @@ -211,7 +209,7 @@ fn load_then_projection() {

assert_data_dependency(
"load_then_projection",
body,
&body,
&mut MirContext {
heap: &heap,
env: &env,
Expand Down
Loading
Loading