Skip to content

Commit

Permalink
making more intuitive api
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubDoka committed Oct 3, 2024
1 parent 76bd940 commit 21c43e3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1602,19 +1602,22 @@ pub fn run<F: Function>(
}
}

/// Run the allocator.
pub fn run_with_ctx<F: Function>(
/// Run the allocator with reusable context.
///
/// Return value points to `ctx.output` that can be alternatively `std::mem::take`n.
pub fn run_with_ctx<'a, F: Function>(
func: &F,
env: &MachineEnv,
options: &RegallocOptions,
ctx: &mut Ctx,
) -> Result<(), RegAllocError> {
Ok(match options.algorithm {
ctx: &'a mut Ctx,
) -> Result<&'a Output, RegAllocError> {
match options.algorithm {
Algorithm::Ion => ion::run(func, env, ctx, options.verbose_log, options.validate_ssa)?,
Algorithm::Fastalloc => {
ctx.output = fastalloc::run(func, env, options.verbose_log, options.validate_ssa)?
}
})
}
Ok(&ctx.output)
}

#[derive(Clone, Copy, Debug, Default)]
Expand Down

0 comments on commit 21c43e3

Please sign in to comment.