cranelift_codegen::souper_harvest: Move preopt out of Context, into clif-util
This allows for more flexibility of when/where to harvest LHS candidates. For example, we could choose to harvest candidates that overlap with and supercede our current preopt peepholes. This commit also makes sure that we compute the CFG before running preopt, when harvesting LHS candidates via `clif-util souper-harvest`.
This commit is contained in:
@@ -457,10 +457,8 @@ impl Context {
|
|||||||
#[cfg(feature = "souper-harvest")]
|
#[cfg(feature = "souper-harvest")]
|
||||||
pub fn souper_harvest(
|
pub fn souper_harvest(
|
||||||
&mut self,
|
&mut self,
|
||||||
isa: &dyn TargetIsa,
|
|
||||||
out: &mut std::sync::mpsc::Sender<String>,
|
out: &mut std::sync::mpsc::Sender<String>,
|
||||||
) -> CodegenResult<()> {
|
) -> CodegenResult<()> {
|
||||||
self.preopt(isa)?;
|
|
||||||
do_souper_harvest(&self.func, out);
|
do_souper_harvest(&self.func, out);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,11 @@ pub fn run(target: &str, input: &str, output: &str, flag_set: &[String]) -> Resu
|
|||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
ctx.func = func;
|
ctx.func = func;
|
||||||
|
|
||||||
ctx.souper_harvest(fisa.isa.unwrap(), send)
|
ctx.compute_cfg();
|
||||||
|
ctx.preopt(fisa.isa.unwrap())
|
||||||
|
.map_err(|e| format!("failed to run preopt: {}", e))?;
|
||||||
|
|
||||||
|
ctx.souper_harvest(send)
|
||||||
.map_err(|e| format!("failed to run souper harvester: {}", e))?;
|
.map_err(|e| format!("failed to run souper harvester: {}", e))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user