-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
571 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use rustc_hash::FxHashMap; | ||
|
||
use super::{Block, Value}; | ||
|
||
/// The mapping of values and blocks from the original to the cloned. | ||
#[derive(Default)] | ||
pub struct DeepCloneMap { | ||
value_map: FxHashMap<Value, Value>, | ||
block_map: FxHashMap<Block, Block>, | ||
} | ||
|
||
impl DeepCloneMap { | ||
pub fn insert_value(&mut self, old: Value, new: Value) { self.value_map.insert(old, new); } | ||
|
||
pub fn insert_block(&mut self, old: Block, new: Block) { self.block_map.insert(old, new); } | ||
|
||
pub fn get_value(&self, old: Value) -> Option<Value> { self.value_map.get(&old).copied() } | ||
|
||
pub fn get_block(&self, old: Block) -> Option<Block> { self.block_map.get(&old).copied() } | ||
|
||
pub fn get_value_or_old(&self, old: Value) -> Value { self.get_value(old).unwrap_or(old) } | ||
|
||
pub fn get_block_or_old(&self, old: Block) -> Block { self.get_block(old).unwrap_or(old) } | ||
|
||
pub fn clear(&mut self) { | ||
self.value_map.clear(); | ||
self.block_map.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ mod block; | |
mod call_graph; | ||
mod constant; | ||
mod context; | ||
mod deep_clone; | ||
mod fold; | ||
mod global; | ||
mod inst; | ||
|
Oops, something went wrong.