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
Track frame layout changes. #679
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,73 @@ | ||
//! Frame layout item changes. | ||
|
||
use crate::ir::entities::Inst; | ||
use crate::isa::RegUnit; | ||
use std::boxed::Box; | ||
|
||
#[cfg(not(feature = "std"))] | ||
use crate::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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if it's obvious from context here, would be nice to explicit CFA in this file at least once. |
||
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. | ||
ReturnAddressAt { | ||
/// Offset in the frame (offset from CFA). | ||
cfa_offset: isize, | ||
}, | ||
/// The entire frame layout must be preserved somewhere to be restored at a corresponding | ||
/// `Restore` change. | ||
/// | ||
/// This likely maps to the DWARF call frame instruction `.cfa_remember_state` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you end this sentence with a dot please? (ditto below for restore) |
||
Preserve, | ||
/// Restore the entire frame layout from a corresponding prior `Preserve` frame change. | ||
/// | ||
/// This likely maps to the DWARF call frame instruction `.cfa_restore_state` | ||
Restore, | ||
} | ||
|
||
/// Set of frame layout changes. | ||
pub type FrameLayoutChanges = Box<[FrameLayoutChange]>; | ||
|
||
/// Frame items layout for (prologue/epilogue) instructions. | ||
#[derive(Debug, Clone)] | ||
pub struct FrameLayout { | ||
/// Initial frame layout. | ||
pub initial: FrameLayoutChanges, | ||
|
||
/// Instruction frame layout (changes). Because the map will not be dense, | ||
/// a HashMap is used instead of a SecondaryMap. | ||
pub instructions: HashMap<Inst, FrameLayoutChanges>, | ||
yurydelendik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we don't need to guard against the std feature here and we can just
use crate::HashMap;
, right?