summaryrefslogtreecommitdiff
path: root/yjit/src/asm/arm64/arg
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2022-07-11 17:51:58 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:46:59 -0700
commit8864691bde2560ef440c4a8dac16b2c661faa228 (patch)
tree4934f9dc7c92daa820a22b5b11c6dc8a61079b19 /yjit/src/asm/arm64/arg
parente1f3f038e93d5b36ed6e6a15feac478bf3cfe1fa (diff)
Better label refs (https://github.com/Shopify/ruby/pull/310)
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.
Diffstat (limited to 'yjit/src/asm/arm64/arg')
-rw-r--r--yjit/src/asm/arm64/arg/condition.rs34
1 files changed, 18 insertions, 16 deletions
diff --git a/yjit/src/asm/arm64/arg/condition.rs b/yjit/src/asm/arm64/arg/condition.rs
index db269726d7..e791e4b078 100644
--- a/yjit/src/asm/arm64/arg/condition.rs
+++ b/yjit/src/asm/arm64/arg/condition.rs
@@ -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
}