-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously we were using a `Box<dyn FnOnce>` to support patching the code when jumping to labels. We needed to do this because some of the closures that were being used to patch needed to capture local variables (on both X86 and ARM it was the type of condition for the conditional jumps). To get around that, we can instead use const generics since the condition codes are always known at compile-time. This means that the closures go from polymorphic to monomorphic, which means they can be represented as an `fn` instead of a `Box<dyn FnOnce>`, which means they can fall back to a plain function pointer. This simplifies the storage of the `LabelRef` structs and should hopefully be a better default going forward.
- Loading branch information
Showing
6 changed files
with
67 additions
and
65 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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
/// Various instructions in A64 can have condition codes attached. This enum | ||
/// includes all of the various kinds of conditions along with their respective | ||
/// encodings. | ||
pub enum Condition { | ||
EQ = 0b0000, // equal to | ||
NE = 0b0001, // not equal to | ||
CS = 0b0010, // carry set (alias for HS) | ||
CC = 0b0011, // carry clear (alias for LO) | ||
MI = 0b0100, // minus, negative | ||
PL = 0b0101, // positive or zero | ||
VS = 0b0110, // signed overflow | ||
VC = 0b0111, // no signed overflow | ||
HI = 0b1000, // greater than (unsigned) | ||
LS = 0b1001, // less than or equal to (unsigned) | ||
GE = 0b1010, // greater than or equal to (signed) | ||
LT = 0b1011, // less than (signed) | ||
GT = 0b1100, // greater than (signed) | ||
LE = 0b1101, // less than or equal to (signed) | ||
AL = 0b1110, // always | ||
pub struct Condition; | ||
|
||
impl Condition { | ||
pub const EQ: u8 = 0b0000; // equal to | ||
pub const NE: u8 = 0b0001; // not equal to | ||
pub const CS: u8 = 0b0010; // carry set (alias for HS) | ||
pub const CC: u8 = 0b0011; // carry clear (alias for LO) | ||
pub const MI: u8 = 0b0100; // minus, negative | ||
pub const PL: u8 = 0b0101; // positive or zero | ||
pub const VS: u8 = 0b0110; // signed overflow | ||
pub const VC: u8 = 0b0111; // no signed overflow | ||
pub const HI: u8 = 0b1000; // greater than (unsigned) | ||
pub const LS: u8 = 0b1001; // less than or equal to (unsigned) | ||
pub const GE: u8 = 0b1010; // greater than or equal to (signed) | ||
pub const LT: u8 = 0b1011; // less than (signed) | ||
pub const GT: u8 = 0b1100; // greater than (signed) | ||
pub const LE: u8 = 0b1101; // less than or equal to (signed) | ||
pub const AL: u8 = 0b1110; // always | ||
} |
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
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