Skip to content

Commit

Permalink
compiler: Add FramePointer::ratchet
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Jun 23, 2024
1 parent acb6273 commit 7c0b5cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,20 @@ pub enum FramePointer {
MayOmit,
}

impl FramePointer {
/// It is intended that the "force frame pointer" transition is "one way"
/// so this convenience assures such if used
#[inline]
pub fn ratchet(&mut self, rhs: FramePointer) -> FramePointer {
*self = match (*self, rhs) {
(FramePointer::Always, _) | (_, FramePointer::Always) => FramePointer::Always,
(FramePointer::NonLeaf, _) | (_, FramePointer::NonLeaf) => FramePointer::NonLeaf,
_ => FramePointer::MayOmit,
};
*self
}
}

impl FromStr for FramePointer {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
Expand Down

0 comments on commit 7c0b5cf

Please sign in to comment.