diff options
author | Kevin Newton <kddnewton@gmail.com> | 2022-08-31 15:44:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-31 15:44:26 -0400 |
commit | be55b77cc75fe36b484a3feb6ad4178630d73242 (patch) | |
tree | d7f456fa5829ad1130bd4cd864f25d70c25e80cd /yjit/src/asm/arm64/arg | |
parent | 32a059151507876de804adbfbf4926937333e091 (diff) | |
download | ruby-be55b77cc75fe36b484a3feb6ad4178630d73242.tar.gz |
Better b.cond usage on AArch64 (#6305)
* Better b.cond usage on AArch64
When we're lowering a conditional jump, we previously had a bit of
a complicated setup where we could emit a conditional jump to skip
over a jump that was the next instruction, and then write out the
destination and use a branch register.
Now instead we use the b.cond instruction if our offset fits (not
common, but not unused either) and if it doesn't we write out an
inverse condition to jump past loading the destination and
branching directly.
* Added an inverse fn for Condition (#443)
Prevents the need to pass two params and potentially reduces errors.
Co-authored-by: Jimmy Miller <jimmyhmiller@jimmys-mbp.lan>
Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Co-authored-by: Jimmy Miller <jimmyhmiller@jimmys-mbp.lan>
Diffstat (limited to 'yjit/src/asm/arm64/arg')
-rw-r--r-- | yjit/src/asm/arm64/arg/condition.rs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/yjit/src/asm/arm64/arg/condition.rs b/yjit/src/asm/arm64/arg/condition.rs index e791e4b078..bb9ce570c3 100644 --- a/yjit/src/asm/arm64/arg/condition.rs +++ b/yjit/src/asm/arm64/arg/condition.rs @@ -19,4 +19,34 @@ impl Condition { 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 -} + + pub const fn inverse(condition: u8) -> u8 { + match condition { + Condition::EQ => Condition::NE, + Condition::NE => Condition::EQ, + + Condition::CS => Condition::CC, + Condition::CC => Condition::CS, + + Condition::MI => Condition::PL, + Condition::PL => Condition::MI, + + Condition::VS => Condition::VC, + Condition::VC => Condition::VS, + + Condition::HI => Condition::LS, + Condition::LS => Condition::HI, + + Condition::LT => Condition::GE, + Condition::GE => Condition::LT, + + Condition::GT => Condition::LE, + Condition::LE => Condition::GT, + + Condition::AL => Condition::AL, + + _ => panic!("Unknown condition") + + } + } +}
\ No newline at end of file |