#[derive(Debug, Clone, Default)]
pub struct CfgExpectation {
pub min_blocks: usize,
pub max_blocks: usize,
pub has_loops: bool,
pub min_exits: usize,
pub max_exits: usize,
}
impl CfgExpectation {
#[must_use]
pub const fn sequential() -> Self {
Self {
min_blocks: 1,
max_blocks: 1,
has_loops: false,
min_exits: 1,
max_exits: 1,
}
}
#[must_use]
pub const fn conditional(min_blocks: usize, max_blocks: usize) -> Self {
Self {
min_blocks,
max_blocks,
has_loops: false,
min_exits: 1,
max_exits: 2,
}
}
#[must_use]
pub const fn with_loops(min_blocks: usize, max_blocks: usize) -> Self {
Self {
min_blocks,
max_blocks,
has_loops: true,
min_exits: 1,
max_exits: 1,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct SsaExpectation {
pub num_args: usize,
pub min_locals: usize,
pub max_locals: usize,
pub has_phi_nodes: bool,
pub min_phi_count: usize,
pub max_phi_count: usize,
}
impl SsaExpectation {
#[must_use]
pub const fn no_phi(num_args: usize, num_locals: usize) -> Self {
Self {
num_args,
min_locals: num_locals,
max_locals: num_locals + 4, has_phi_nodes: false,
min_phi_count: 0,
max_phi_count: 0,
}
}
#[must_use]
pub const fn with_phi(
num_args: usize,
num_locals: usize,
min_phi: usize,
max_phi: usize,
) -> Self {
Self {
num_args,
min_locals: num_locals,
max_locals: num_locals + 4, has_phi_nodes: true,
min_phi_count: min_phi,
max_phi_count: max_phi,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct CallGraphExpectation {
pub min_call_sites: usize,
pub max_call_sites: usize,
pub is_recursive: bool,
pub is_leaf: bool,
}
impl CallGraphExpectation {
#[must_use]
pub const fn leaf() -> Self {
Self {
min_call_sites: 0,
max_call_sites: 0,
is_recursive: false,
is_leaf: true,
}
}
#[must_use]
pub const fn with_calls(min_calls: usize, max_calls: usize) -> Self {
Self {
min_call_sites: min_calls,
max_call_sites: max_calls,
is_recursive: false,
is_leaf: false,
}
}
#[must_use]
pub const fn recursive() -> Self {
Self {
min_call_sites: 1,
max_call_sites: 1,
is_recursive: true,
is_leaf: false,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct DataFlowExpectation {
pub has_constants: bool,
pub has_dead_code: bool,
pub all_blocks_reachable: bool,
}
impl DataFlowExpectation {
#[must_use]
pub const fn all_live() -> Self {
Self {
has_constants: false,
has_dead_code: false,
all_blocks_reachable: true,
}
}
#[must_use]
pub const fn with_constants() -> Self {
Self {
has_constants: true,
has_dead_code: false,
all_blocks_reachable: true,
}
}
#[must_use]
pub const fn with_dead_code() -> Self {
Self {
has_constants: true,
has_dead_code: true,
all_blocks_reachable: false,
}
}
}