This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
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
1 parent
f3f7cad
commit 1c185ff
Showing
4 changed files
with
169 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//! Frame layout item changes. | ||
use crate::ir::entities::Inst; | ||
use crate::isa::RegUnit; | ||
use std::boxed::Box; | ||
|
||
#[cfg(not(feature = "std"))] | ||
use hashmap_core::HashMap; | ||
#[cfg(feature = "std")] | ||
use std::collections::HashMap; | ||
|
||
/// Change in the frame layout information. | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] | ||
pub enum FrameLayoutChange { | ||
/// Base CFA pointer moved to different register/offset. | ||
CallFrameAddressAt { | ||
/// CFA register. | ||
reg: RegUnit, | ||
/// CFA offset. | ||
offset: isize, | ||
}, | ||
/// Register saved at. | ||
RegAt { | ||
/// Saved register. | ||
reg: RegUnit, | ||
/// Offset in the frame (offset from CFA). | ||
cfa_offset: isize, | ||
}, | ||
/// Return address saved at. | ||
RaAt { | ||
/// Offset in the frame (offset from CFA). | ||
cfa_offset: isize, | ||
}, | ||
} | ||
|
||
/// Set of frame layout changes. | ||
pub type FrameLayoutChanges = Box<[FrameLayoutChange]>; | ||
|
||
/// Frame items layout for (prologue/epilog) instructions. | ||
#[derive(Debug, Clone)] | ||
pub struct FrameLayout { | ||
/// Initial frame layout. | ||
pub initial: FrameLayoutChanges, | ||
|
||
/// Instruction frame layout (changes). | ||
pub instructions: HashMap<Inst, FrameLayoutChanges>, | ||
} | ||
|
||
impl FrameLayout { | ||
/// Creates instance of FrameLayout. | ||
pub fn new() -> Self { | ||
FrameLayout { | ||
initial: vec![].into_boxed_slice(), | ||
instructions: HashMap::new(), | ||
} | ||
} | ||
|
||
/// Clear the structure. | ||
pub fn clear(&mut self) { | ||
self.initial = vec![].into_boxed_slice(); | ||
self.instructions.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