Start a very simple GVN pass (#79)

* Skeleton simple_gvn pass.
* Basic testing infrastructure for simple-gvn.
* Add can_load and can_store flags to instructions.
* Move the replace_values function into the DataFlowGraph.
* Make InstructionData derive from Hash, PartialEq, and Eq.
* Make EntityList's hash and eq functions panic.
* Change Ieee32 and Ieee64 to store u32 and u64, respectively.
This commit is contained in:
Dan Gohman
2017-05-18 18:18:57 -07:00
committed by Jakob Stoklund Olesen
parent 1d8efaad83
commit c826aefa0a
16 changed files with 256 additions and 57 deletions

View File

@@ -17,6 +17,7 @@ use legalize_function;
use regalloc;
use result::CtonResult;
use verifier;
use simple_gvn::do_simple_gvn;
/// Persistent data structures and compilation pipeline.
pub struct Context {
@@ -51,16 +52,16 @@ impl Context {
///
/// Also check that the dominator tree and control flow graph are consistent with the function.
///
/// The `TargetIsa` argument is currently unused, but the verifier will soon be able to also
/// The `isa` argument is currently unused, but the verifier will soon be able to also
/// check ISA-dependent constraints.
pub fn verify<'a, ISA: Into<Option<&'a TargetIsa>>>(&self, isa: ISA) -> verifier::Result {
verifier::verify_context(&self.func, &self.cfg, &self.domtree, isa.into())
pub fn verify<'a>(&self, isa: Option<&TargetIsa>) -> verifier::Result {
verifier::verify_context(&self.func, &self.cfg, &self.domtree, isa)
}
/// Run the verifier only if the `enable_verifier` setting is true.
pub fn verify_if(&self, isa: &TargetIsa) -> CtonResult {
if isa.flags().enable_verifier() {
self.verify(isa).map_err(Into::into)
self.verify(Some(isa)).map_err(Into::into)
} else {
Ok(())
}
@@ -78,6 +79,14 @@ impl Context {
self.domtree.compute(&self.func, &self.cfg);
}
/// Perform simple GVN on the function.
pub fn simple_gvn(&mut self) -> CtonResult {
do_simple_gvn(&mut self.func, &mut self.cfg);
// TODO: Factor things such that we can get a Flags and test
// enable_verifier().
self.verify(None).map_err(Into::into)
}
/// Run the register allocator.
pub fn regalloc(&mut self, isa: &TargetIsa) -> CtonResult {
self.regalloc