pub mod access_kind;
pub mod alias_facts;
pub mod bank_conflict;
pub mod candidate_plan;
pub mod coalesce;
pub mod common_subexpr;
pub mod const_buffer_promote;
pub mod dead_op;
pub mod def_use;
pub mod layout_aos_to_soa;
pub(crate) mod load_counts;
pub mod op_histogram;
pub mod reaching_def_facts;
pub mod shared_mem_promote;
pub mod texture_promote;
pub mod value_range;
pub mod vec_pack;
pub mod weir_alias;
pub mod weir_reaching_def;
pub mod workgroup_uniform;
use crate::KernelOpKind;
pub(crate) fn child_body_operands<'a>(
kind: &KernelOpKind,
operands: &'a [u32],
) -> impl Iterator<Item = u32> + 'a {
let start = match kind {
KernelOpKind::StructuredIfThen | KernelOpKind::StructuredIfThenElse => 1,
KernelOpKind::StructuredForLoop { .. } => 2,
KernelOpKind::StructuredBlock | KernelOpKind::Region { .. } => 0,
_ => operands.len(),
};
operands.iter().skip(start).copied()
}
#[cfg(test)]
mod dedup_guard {
use std::path::{Path, PathBuf};
#[test]
fn child_body_operands_has_single_owner() {
let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("src/analyses");
let mut hits = Vec::new();
visit(&dir, &mut hits);
hits.sort();
assert_eq!(
hits,
vec![dir.join("mod.rs")],
"Fix: child_body_operands must have exactly ONE owner (analyses/mod.rs); a copy reappeared: {hits:?}"
);
}
fn visit(dir: &Path, hits: &mut Vec<PathBuf>) {
for entry in std::fs::read_dir(dir).unwrap() {
let path = entry.unwrap().path();
if path.is_dir() {
visit(&path, hits);
} else if path.extension().is_some_and(|e| e == "rs")
&& std::fs::read_to_string(&path)
.unwrap()
.contains("fn child_body_operands")
{
hits.push(path);
}
}
}
}
pub use access_kind::AccessKind;
pub use bank_conflict::{analyze as analyze_bank_conflict, BankConflictReport};
pub use coalesce::{analyze as analyze_coalesce, CoalescenceReport};
pub use common_subexpr::{analyze as analyze_common_subexpr, CommonSubexprReport};
pub use const_buffer_promote::{analyze as analyze_const_buffer_promote, ConstBufferPlan};
pub use dead_op::{analyze as analyze_dead_op, DeadOpReport};
pub use def_use::{
analyze as analyze_def_use, dead_by_no_use, DefUseReport, PerBodyChains, UseSite,
};
pub use layout_aos_to_soa::{analyze as analyze_layout_aos_to_soa, LayoutTransformPlan};
pub use op_histogram::{analyze as analyze_op_histogram, OpHistogram};
pub use reaching_def_facts::import_descriptor_reaching_defs;
pub use shared_mem_promote::{analyze as analyze_shared_mem_promote, PromotionPlan};
pub use texture_promote::{analyze as analyze_texture_promote, TexturePromotionPlan};
pub use value_range::{analyze as analyze_value_range, IntRange, ValueRangeReport};
pub use workgroup_uniform::{analyze as analyze_workgroup_uniform, WorkgroupUniformReport};