diff options
author | Kevin Newton <kddnewton@gmail.com> | 2022-08-04 15:29:31 -0400 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-29 08:47:09 -0700 |
commit | 3f42028e3e7df7d476e71cc995608e26208e3ae0 (patch) | |
tree | 458691bd695213b04fa3010825db1a4796bf3cc8 /yjit/src/backend/tests.rs | |
parent | 49c9f893f863108f741b6b6535dc53126733ded0 (diff) |
Iterator (https://github.com/Shopify/ruby/pull/372)
* Iterator
* Use the new iterator for the X86 backend split
* Use iterator for reg alloc, remove forward pass
* Fix up iterator usage on AArch64
* Update yjit/src/backend/ir.rs
Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* Various PR feedback for iterators for IR
* Use a local mutable reference for a64_split
* Move tests from ir.rs to tests.rs in backend
* Fix x86 shift instructions live range calculation
* Iterator
* Use the new iterator for the X86 backend split
* Fix up x86 iterator usage
* Fix ARM iterator usage
* Remove unintentionally duplicated tests
Diffstat (limited to 'yjit/src/backend/tests.rs')
-rw-r--r-- | yjit/src/backend/tests.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/yjit/src/backend/tests.rs b/yjit/src/backend/tests.rs index a31e16071b..e4ab95d4ee 100644 --- a/yjit/src/backend/tests.rs +++ b/yjit/src/backend/tests.rs @@ -299,3 +299,41 @@ fn test_bake_string() { asm.bake_string("Hello, world!"); asm.compile_with_num_regs(&mut cb, 0); } + +#[test] +fn test_draining_iterator() { + let mut asm = Assembler::new(); + + asm.load(Opnd::None); + asm.store(Opnd::None, Opnd::None); + asm.add(Opnd::None, Opnd::None); + + let mut iter = asm.into_draining_iter(); + + while let Some((index, insn)) = iter.next_unmapped() { + match index { + 0 => assert_eq!(insn.op, Op::Load), + 1 => assert_eq!(insn.op, Op::Store), + 2 => assert_eq!(insn.op, Op::Add), + _ => panic!("Unexpected instruction index"), + }; + } +} + +#[test] +fn test_lookback_iterator() { + let mut asm = Assembler::new(); + + asm.load(Opnd::None); + asm.store(Opnd::None, Opnd::None); + asm.store(Opnd::None, Opnd::None); + + let mut iter = asm.into_lookback_iter(); + + while let Some((index, insn)) = iter.next_unmapped() { + if index > 0 { + assert_eq!(iter.get_previous().unwrap().opnds[0], Opnd::None); + assert_eq!(insn.op, Op::Store); + } + } +} |