summaryrefslogtreecommitdiff
path: root/yjit/src/backend
AgeCommit message (Collapse)Author
2022-08-29Add 1 more allocatable reg on armMaxime Chevalier-Boisvert
2022-08-29Fix C call reg alloc bug reported by Noah & KokubunMaxime Chevalier-Boisvert
2022-08-29Implement iterators and double-linked list for IR SSAKevin Newton
2022-08-29Push first pass at SSA IR sketchMaxime Chevalier-Boisvert
2022-08-29Minor cleanups (https://github.com/Shopify/ruby/pull/345)Alan Wu
* Move allocation into Assembler::pos_marker We wanted to do this to begin with but didn't because we were confused about the lifetime parameter. It's actually talking about the lifetime of the references that the closure captures. Since all of our usages capture no references (they use `move`), it's fine to put a `+ 'static` here. * Use optional token syntax for calling convention macro * Explicitly request C ABI on ARM It looks like the Rust calling convention for functions are the same as the C ABI for now and it's unlikely to change, but it's easy for us to be explicit here. I also tried saying `extern "aapcs"` but that unfortunately doesn't work.
2022-08-29Port the YJIT defined opcode; fix C_ARG_REGS ↵Noah Gibbs
(https://github.com/Shopify/ruby/pull/342)
2022-08-29A64: Fix off by one in offset encoding for BL ↵Alan Wu
(https://github.com/Shopify/ruby/pull/344) * A64: Fix off by one in offset encoding for BL It's relative to the address of the instruction not the end of it. * A64: Fix off by one when encoding B It's relative to the start of the instruction not the end. * A64: Add some tests for boundary offsets
2022-08-29Fix a bug in the x86 backend wrt large integer values, enable more testsMaxime Chevalier-Boisvert
2022-08-29Fix IncrCounter on ARMAlan Wu
The order of operands to LDADDAL were flipped and the destination pointer was dereferenced instead of passed as an address.
2022-08-29Add LiveReg IR instruction to fix stats leave exit code ↵Alan Wu
(https://github.com/Shopify/ruby/pull/341) It allows for reserving a specific register and prevents the register allocator from clobbering it. Without this `./miniruby --yjit-stats --yjit-callthreshold=1 -e0` was crashing because the counter incrementing code was clobbering RAX incorrectly.
2022-08-29Fixes (https://github.com/Shopify/ruby/pull/340)Kevin Newton
* Fix conditional jumps to label * Bitmask immediates cannot be u64::MAX
2022-08-29Fixes for AArch64 (https://github.com/Shopify/ruby/pull/338)Kevin Newton
* Better splitting for Op::Add, Op::Sub, and Op::Cmp * Split stores if the displacement is too large * Use a shifted immediate argument * Split all places where shifted immediates are used * Add more tests to the cirrus workflow
2022-08-29Fix bug with opt_lt, csel on x86Maxime Chevalier-Boisvert
2022-08-29Work on opt_lt, fix x86 backend bug in cmp()Maxime Chevalier-Boisvert
2022-08-29Fixes (https://github.com/Shopify/ruby/pull/336)Kevin Newton
* Fix bitmask encoding to u32 * Fix splitting for Op::And to account for bitmask immediate
2022-08-29Better splitting for Op::Test on AArch64 ↵Kevin Newton
(https://github.com/Shopify/ruby/pull/335)
2022-08-29Fix crash in newhash ccallMaxime Chevalier-Boisvert
2022-08-29Fix corrupted X29 causing segfault, thanks Alan!Maxime Chevalier-Boisvert
2022-08-29Temporarily simplify code for emit_conditional_jump to fix a bugMaxime Chevalier-Boisvert
2022-08-29Refactor YJIT branches to use PosMarker ↵Maxime Chevalier-Boisvert
(https://github.com/Shopify/ruby/pull/333) * Refactor defer_compilation to use PosMarker * Port gen_direct_jump() to use PosMarker * Port gen_branch, branchunless * Port over gen_jump() * Port over branchif and branchnil * Fix use od record_boundary_patch_point in jump_to_next_insn
2022-08-29Update disasm to work on ARM (https://github.com/Shopify/ruby/pull/331)Noah Gibbs
2022-08-29Fix dupn (https://github.com/Shopify/ruby/pull/330)Noah Gibbs
* get_dupn was allocating and throwing away an Assembler object instead of using the one passed in * Uncomment remaining tests in codegen.rs, which seem to work now
2022-08-29Implement PosMarker instruction (https://github.com/Shopify/ruby/pull/328)Maxime Chevalier-Boisvert
* Implement PosMarker instruction * Implement PosMarker in the arm backend * Make bindgen run only for clang image * Fix if-else in cirrus CI file * Add missing semicolon * Try removing trailing semicolon * Try to fix shell/YAML syntax Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2022-08-29A lot of fixes coming from our pairing session ↵Kevin Newton
(https://github.com/Shopify/ruby/pull/329) * Move to/from SP on AArch64 * Consolidate loads and stores * Implement LDR post-index and LDR pre-index for AArch64 * Implement STR post-index and STR pre-index for AArch64 * Module entrypoints for LDR pre/post -index and STR pre/post -index * Use STR (pre-index) and LDR (post-index) to implement push/pop * Go back to using MOV for to/from SP
2022-08-29Fix push/pop and frame setup/teardown with Kevin & AlanMaxime Chevalier-Boisvert
2022-08-29BLR instruction for AArch64 (https://github.com/Shopify/ruby/pull/325)Kevin Newton
2022-08-29AArch64 frames (https://github.com/Shopify/ruby/pull/324)Kevin Newton
2022-08-29ADR fixes for LeaLabel and callsMaxime Chevalier-Boisvert
2022-08-29Conditionals (https://github.com/Shopify/ruby/pull/323)Kevin Newton
* CSEL on AArch64 * Implement various Op::CSel* instructions
2022-08-29Port print_int to the new backend (https://github.com/Shopify/ruby/pull/321)Kevin Newton
* Port print_int to the new backend * Tests for print_int and print_str
2022-08-29Fix jumps (https://github.com/Shopify/ruby/pull/322)Kevin Newton
2022-08-29Fix bug with LeaLabel on x86, add CI testMaxime Chevalier-Boisvert
2022-08-29Port print_str to new backend (https://github.com/Shopify/ruby/pull/318)Kevin Newton
* ADR and ADRP for AArch64 * Implement Op::Jbe on X86 * Lera instruction * Op::BakeString * LeaPC -> LeaLabel * Port print_str to the new backend * Port print_value to the new backend * Port print_ptr to the new backend * Write null-terminators in Op::BakeString * Fix up rebase issues on print-str port * Add back in panic for X86 backend for unsupported instructions being lowered * Fix target architecture
2022-08-29Port newhash, add tests for newhash, duphashMaxime Chevalier-Boisvert
2022-08-29Add extra assertion in new_label for KevinMaxime Chevalier-Boisvert
2022-08-29Exclude X0 (C_RET_REG) from allocatable registers on arm ↵Maxime Chevalier-Boisvert
(https://github.com/Shopify/ruby/pull/319) * Exclude X0 (C_RET_REG) from allocatable registers on arm * Add another small test snippett
2022-08-29Op::CPushAll and Op::CPopAll (https://github.com/Shopify/ruby/pull/317)Kevin Newton
Instructions for pushing all caller-save registers and the flags so that we can implement dump_insns.
2022-08-29Fix compile errors on arm on the CI (https://github.com/Shopify/ruby/pull/313)Maxime Chevalier-Boisvert
* Fix compile errors on arm on the CI * Fix typo
2022-08-29Port over setlocal_wc0Maxime Chevalier-Boisvert
2022-08-29Better label refs (https://github.com/Shopify/ruby/pull/310)Kevin Newton
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.
2022-08-29Fix jumps (https://github.com/Shopify/ruby/pull/309)Kevin Newton
* Jumps for A64 should be in # of instructions * More splitting for Arm64 https://github.com/Shopify/ruby/pull/309
2022-08-29More Arm64 lowering/backend work (https://github.com/Shopify/ruby/pull/307)Kevin Newton
* More Arm64 lowering/backend work * We now have encoding support for the LDR instruction for loading a PC-relative memory location * You can now call add/adds/sub/subs with signed immediates, which switches appropriately based on sign * We can now load immediates into registers appropriately, attempting to keep the minimal number of instructions: * If it fits into 16 bytes, we use just a single movz. * Else if it can be encoded into a bitmask immediate, we use a single mov. * Otherwise we use a movz, a movk, and then optionally another one or two movks. * Fixed a bunch of code to do with the Op::Load opcode. * We now handle GC-offsets properly for Op::Load by skipping around them with a jump instruction. (This will be made better by constant pools in the future.) * Op::Lea is doing what it's supposed to do now. * Fixed a bug in the backend tests to do with not using the result of an Op::Add. * Fix the remaining tests for Arm64 * Move split loads logic into each backend
2022-08-29Add #[must_use] annotations to asm instructionsMaxime Chevalier-Boisvert
2022-08-29Add a backend test with a load of a GC'd VALUEMaxime Chevalier-Boisvert
2022-08-29Get started on branchunless portMaxime Chevalier-Boisvert
2022-08-29Add test for direct jump to a code pointerMaxime Chevalier-Boisvert
2022-08-29Arm64 progress (https://github.com/Shopify/ruby/pull/304)Kevin Newton
* Get initial wiring up * Split IncrCounter instruction * Breakpoints in Arm64 * Support for ORR * MOV instruction encodings * Implement JmpOpnd and CRet * Add ORN * Add MVN * PUSH, POP, CCALL for Arm64 * Some formatting and implement Op::Not for Arm64 * Consistent constants when working with the Arm64 SP * Allow OR-ing values into the memory buffer * Test lowering Arm64 ADD * Emit unconditional jumps consistently in Arm64 * Begin emitting conditional jumps for A64 * Back out some labelref changes * Remove label API that no longer exists * Use a trait for the label encoders * Encode nop * Add in nops so jumps are the same width no matter what on Arm64 * Op::Jbe for CodePtr * Pass src_addr and dst_addr instead of calculated offset to label refs * Even more jump work for Arm64 * Fix up jumps to use consistent assertions * Handle splitting Add, Sub, and Not insns for Arm64 * More Arm64 splits and various fixes * PR feedback for Arm64 support * Split up jumps and conditional jump logic
2022-08-29Conscise IR disassembly (https://github.com/Shopify/ruby/pull/302)Alan Wu
The output from `dbg!` was too verbose. For `test_jo` the output went from 37 lines to 5 lines. The added index helps parsing InsnOut indicies. Samples: ``` test backend::tests::test_jo ... [src/backend/ir.rs:589] &self = Assembler 000 Load(Mem64[Reg(3) + 8]) -> Out64(0) 001 Sub(Out64(0), 1_i64) -> Out64(1) 002 Load(Out64(1)) -> Out64(2) 003 Add(Out64(2), Mem64[Reg(3)]) -> Out64(3) 004 Jo() target=CodePtr(CodePtr(0x5)) -> Out64(4) 005 Mov(Mem64[Reg(3)], Out64(3)) -> Out64(5) test backend::tests::test_reuse_reg ... [src/backend/ir.rs:589] &self = Assembler 000 Load(Mem64[Reg(3)]) -> Out64(0) 001 Add(Out64(0), 1_u64) -> Out64(1) 002 Load(Mem64[Reg(3) + 8]) -> Out64(2) 003 Add(Out64(2), 1_u64) -> Out64(3) 004 Add(Out64(1), 1_u64) -> Out64(4) 005 Add(Out64(1), Out64(4)) -> Out64(5) 006 Store(Mem64[Reg(3)], Out64(4)) -> Out64(6) 007 Store(Mem64[Reg(3) + 8], Out64(5)) -> Out64(7) ```
2022-08-29Delete dbg!() callsAlan Wu
2022-08-29Fix backend transform bug, add testMaxime Chevalier-Boisvert