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:
committed by
Jakob Stoklund Olesen
parent
1d8efaad83
commit
c826aefa0a
@@ -46,6 +46,7 @@
|
||||
//! The index stored in an `EntityList` points to part 2, the list elements. The value 0 is
|
||||
//! reserved for the empty list which isn't allocated in the vector.
|
||||
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
|
||||
@@ -59,6 +60,10 @@ use entity_map::EntityRef;
|
||||
/// Entity lists can be cloned, but that operation should only be used as part of cloning the whole
|
||||
/// function they belong to. *Cloning an entity list does not allocate new memory for the clone*.
|
||||
/// It creates an alias of the same memory.
|
||||
///
|
||||
/// Entity lists can also be hashed and compared for equality, but those operations just panic if,
|
||||
/// they're ever actually called, because it's not possible to compare the contents of the list
|
||||
/// without the pool reference.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct EntityList<T: EntityRef> {
|
||||
index: u32,
|
||||
@@ -75,6 +80,19 @@ impl<T: EntityRef> Default for EntityList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EntityRef> Hash for EntityList<T> {
|
||||
fn hash<H: Hasher>(&self, _: &mut H) {
|
||||
panic!("hash called on EntityList");
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EntityRef> PartialEq for EntityList<T> {
|
||||
fn eq(&self, _: &EntityList<T>) -> bool {
|
||||
panic!("eq called on EntityList");
|
||||
}
|
||||
}
|
||||
impl<T: EntityRef> Eq for EntityList<T> {}
|
||||
|
||||
/// A memory pool for storing lists of `T`.
|
||||
#[derive(Clone)]
|
||||
pub struct ListPool<T: EntityRef> {
|
||||
|
||||
Reference in New Issue
Block a user