Skip to content

Commit

Permalink
Inline brillig calls with all constants by executing them with the VM
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Nov 18, 2024
1 parent b2e6e10 commit c2786ea
Show file tree
Hide file tree
Showing 2 changed files with 414 additions and 45 deletions.
19 changes: 19 additions & 0 deletions compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ impl FunctionContext {
}
}

pub(crate) fn try_ssa_type_to_parameter(typ: &Type) -> Option<BrilligParameter> {
match typ {
Type::Numeric(_) | Type::Reference(_) => {
Some(BrilligParameter::SingleAddr(get_bit_size_from_ssa_type(typ)))
}
Type::Array(item_type, size) => {
let mut parameters = Vec::new();
for item_typ in item_type.iter() {
let Some(param) = FunctionContext::try_ssa_type_to_parameter(item_typ) else {
return None;
};
parameters.push(param);
}
Some(BrilligParameter::Array(parameters, *size))
}
_ => None,
}
}

/// Collects the return values of a given function
pub(crate) fn return_values(func: &Function) -> Vec<BrilligParameter> {
func.returns()
Expand Down
Loading

0 comments on commit c2786ea

Please sign in to comment.