Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
23 changes: 23 additions & 0 deletions crates/celox-frontend-veryl/src/ff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ pub struct FfGroupParseResult<A = RegionedVarAddr> {
pub dynamic_write_vars: HashSet<VarId>,
}

#[derive(Clone)]
struct FunctionArrayView {
backing_var_id: VarId,
// Registers preserve this invocation's values if a nested invocation
// temporarily reuses the same formal working region.
elements: Vec<RegisterId>,
// Aliased forwarding views do not write their backing and therefore do
// not require the caller's snapshot to be restored.
owns_backing: bool,
// Branch-local lazy initialization is represented explicitly at control
// flow joins. `None` means every path reaching the current block has a
// valid backing view; `Some` guards the carried element snapshot.
initialized: Option<RegisterId>,
}

impl<A> Default for FfGroupParseResult<A> {
fn default() -> Self {
Self {
Expand All @@ -277,6 +292,12 @@ pub struct FfParser<'a> {
loop_exit_blocks: Vec<BlockId>,
reset: Option<FfReset>,
function_arg_stack: Vec<HashMap<VarId, Expression>>,
// Invocation-wide analysis records which formals will eventually need a
// complete view, without evaluating their actual arguments early.
function_array_view_plan_stack: Vec<HashSet<VarId>>,
// Maps an active array formal to its call-specific register snapshot and
// the formal working region used for O(1) dynamic element loads.
function_array_view_stack: Vec<HashMap<VarId, FunctionArrayView>>,
runtime_errors: HashMap<i64, RuntimeErrorInfo<VarId>>,
runtime_event_sites: Vec<RuntimeEventSite>,
next_runtime_error_code: i64,
Expand Down Expand Up @@ -314,6 +335,8 @@ impl<'a> FfParser<'a> {
loop_exit_blocks: Vec::new(),
reset: None,
function_arg_stack: Vec::new(),
function_array_view_plan_stack: Vec::new(),
function_array_view_stack: Vec::new(),
runtime_errors: HashMap::default(),
runtime_event_sites: Vec::new(),
next_runtime_error_code: 2000,
Expand Down
Loading