diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-14 10:26:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 13:26:05 -0400 |
commit | 76f2031884a7857649490f2ef8bcda534bd69c0c (patch) | |
tree | acdbdc268040732261b7e46701993738ca74a1bc /yjit/src/backend | |
parent | 548086b34e3dd125edabf5dc1e46b891fad3ea9c (diff) | |
download | ruby-76f2031884a7857649490f2ef8bcda534bd69c0c.tar.gz |
YJIT: Allow testing assembler with disasm (#7470)
* YJIT: Allow testing assembler with disasm
* YJIT: Drop new dependencies
* YJIT: Avoid address manipulation
* YJIT: Introduce assert_disasm! macro
* YJIT: Update the comment about assert_disasm
Diffstat (limited to 'yjit/src/backend')
-rw-r--r-- | yjit/src/backend/x86_64/mod.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/yjit/src/backend/x86_64/mod.rs b/yjit/src/backend/x86_64/mod.rs index 11716e1fca..03ccc10928 100644 --- a/yjit/src/backend/x86_64/mod.rs +++ b/yjit/src/backend/x86_64/mod.rs @@ -765,6 +765,10 @@ impl Assembler #[cfg(test)] mod tests { + use crate::disasm::{assert_disasm}; + #[cfg(feature = "disasm")] + use crate::disasm::{unindent, disasm_addr_range}; + use super::*; fn setup_asm() -> (Assembler, CodeBlock) { @@ -938,19 +942,28 @@ mod tests { #[test] fn test_merge_lea_reg() { let (mut asm, mut cb) = setup_asm(); + let sp = asm.lea(Opnd::mem(64, SP, 8)); asm.mov(SP, sp); // should be merged to lea asm.compile_with_num_regs(&mut cb, 1); - assert_eq!(format!("{:x}", cb), "488d5b08"); + + assert_disasm!(cb, "488d5b08", {" + 0x0: lea rbx, [rbx + 8] + "}); } #[test] fn test_merge_lea_mem() { let (mut asm, mut cb) = setup_asm(); + let sp = asm.lea(Opnd::mem(64, SP, 8)); asm.mov(Opnd::mem(64, SP, 0), sp); // should NOT be merged to lea asm.compile_with_num_regs(&mut cb, 1); - assert_eq!(format!("{:x}", cb), "488d4308488903"); + + assert_disasm!(cb, "488d4308488903", {" + 0x0: lea rax, [rbx + 8] + 0x4: mov qword ptr [rbx], rax + "}); } #[test] |