mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-27 08:20:47 +00:00
e63abb0ea1
* Improved test namings for multi-operations, added new ones, still a few failures * Review - Modifications to get all tests passing
49 lines
13 KiB
C++
49 lines
13 KiB
C++
TEST(DecompilerAtomicOpBuilder, BEQ) {test_case(assembly_from_list({"L100:", "beq a0, a1, L100", "sll r0, r0, 0", ""}), {"(b! (= a0 a1) L100 (nop!))"}, {{""}}, {{"a0","a1"}}, {{""}});test_case(assembly_from_list({"L100:", "beq r0, r0, L100", "sll r0, r0, 0", ""}), {"(b! #t L100 (nop!))"}, {{""}}, {{""}}, {{""}});test_case(assembly_from_list({"L100:", "beq a0, r0, L100", "sll r0, r0, 0", ""}), {"(b! (zero? a0) L100 (nop!))"}, {{""}}, {{"a0"}}, {{""}});test_case(assembly_from_list({"L100:", "beq s7, a0, L100", "sll r0, r0, 0", ""}), {"(b! (not a0) L100 (nop!))"}, {{""}}, {{"a0"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, BEQL) {test_case(assembly_from_list({"L100:", "beql a0, a1, L100", "sll r0, r0, 0", ""}), {"(bl! (= a0 a1) L100 (nop!))"}, {{""}}, {{"a0","a1"}}, {{""}});test_case(assembly_from_list({"L100:", "beql r0, r0, L100", "sll r0, r0, 0", ""}), {"(bl! #t L100 (nop!))"}, {{""}}, {{""}}, {{""}});test_case(assembly_from_list({"L100:", "beql a0, r0, L100", "sll r0, r0, 0", ""}), {"(bl! (zero? a0) L100 (nop!))"}, {{""}}, {{"a0"}}, {{""}});test_case(assembly_from_list({"L100:", "beql s7, a0, L100", "sll r0, r0, 0", ""}), {"(bl! (not a0) L100 (nop!))"}, {{""}}, {{"a0"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, BGEZL) {test_case(assembly_from_list({"L100:", "bgezl a0, L100", "sll r0, r0, 0", ""}), {"(bl! (>=0.si a0) L100 (nop!))"}, {{""}}, {{"a0"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, BGTZL) {test_case(assembly_from_list({"L100:", "bgtzl a0, L100", "sll r0, r0, 0", ""}), {"(bl! (>0.si a0) L100 (nop!))"}, {{""}}, {{"a0"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, BLTZL) {test_case(assembly_from_list({"L100:", "bltzl a0, L100", "sll r0, r0, 0", ""}), {"(bl! (<0.si a0) L100 (nop!))"}, {{""}}, {{"a0"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, BNE) {test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "sll r0, r0, 0", ""}), {"(b! (!= a1 a2) L100 (nop!))"}, {{""}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "or a3, s7, r0", ""}), {"(b! (!= a1 a2) L100 (set! a3 #f))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "or a3, t0, r0", ""}), {"(b! (!= a1 a2) L100 (set! a3 t0))"}, {{"a3"}}, {{"a1","a2","t0"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "daddiu a3, s7, 8", ""}), {"(b! (!= a1 a2) L100 (set! a3 #t))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "lw a3, pair(s7)", ""}), {"(b! (!= a1 a2) L100 (set! a3 pair))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "lw a3, binteger(s7)", ""}), {"(b! (!= a1 a2) L100 (set! a3 binteger))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "dsllv a3, t0, t1", ""}), {"(b! (!= a1 a2) L100 (set! a3 (sll t0 t1)))"}, {{"a3"}}, {{"a1","a2","t0","t1"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, a2, L100", "dsubu a3, r0, t1", ""}), {"(b! (!= a1 a2) L100 (set! a3 (- t1)))"}, {{"a3"}}, {{"a1","a2","","t1"}}, {{""}});test_case(assembly_from_list({"L100:", "bne a1, r0, L100", "sll r0, r0, 0", ""}), {"(b! (nonzero? a1) L100 (nop!))"}, {{""}}, {{"a1"}}, {{""}});test_case(assembly_from_list({"L100:", "bne s7, a1, L100", "sll r0, r0, 0", ""}), {"(b! (truthy a1) L100 (nop!))"}, {{""}}, {{"a1"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, BNEL) {test_case(assembly_from_list({"L100:", "bnel a1, a2, L100", "sll r0, r0, 0", ""}), {"(bl! (!= a1 a2) L100 (nop!))"}, {{""}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"L100:", "bnel a1, r0, L100", "sll r0, r0, 0", ""}), {"(bl! (nonzero? a1) L100 (nop!))"}, {{""}}, {{"a1"}}, {{""}});test_case(assembly_from_list({"L100:", "bnel s7, a1, L100", "sll r0, r0, 0", ""}), {"(bl! (truthy a1) L100 (nop!))"}, {{""}}, {{"a1"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, C_EQ_S) {test_case(assembly_from_list({"L100:", "c.eq.s f1, f2", "bc1t L100", "sll r0, r0, 0", ""}), {"(b! (=.s f1 f2) L100 (nop!))"}, {{""}}, {{"f1","f2"}}, {{""}});test_case(assembly_from_list({"L100:", "c.eq.s f1, f2", "bc1f L100", "sll r0, r0, 0", ""}), {"(b! (!=.s f1 f2) L100 (nop!))"}, {{""}}, {{"f1","f2"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, C_LE_S) {test_case(assembly_from_list({"L100:", "c.le.s f1, f2", "bc1t L100", "sll r0, r0, 0", ""}), {"(b! (<=.s f1 f2) L100 (nop!))"}, {{""}}, {{"f1","f2"}}, {{""}});test_case(assembly_from_list({"L100:", "c.le.s f1, f2", "bc1f L100", "sll r0, r0, 0", ""}), {"(b! (>.s f1 f2) L100 (nop!))"}, {{""}}, {{"f1","f2"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, C_LT_S) {test_case(assembly_from_list({"L100:", "c.lt.s f1, f2", "bc1t L100", "sll r0, r0, 0", ""}), {"(b! (<.s f1 f2) L100 (nop!))"}, {{""}}, {{"f1","f2"}}, {{""}});test_case(assembly_from_list({"L100:", "c.lt.s f1, f2", "bc1f L100", "sll r0, r0, 0", ""}), {"(b! (>=.s f1 f2) L100 (nop!))"}, {{""}}, {{"f1","f2"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, DADDIU) {test_case(assembly_from_list({"daddiu a1, s7, 8", "movn a1, s7, a0", ""}), {"(set! a1 (zero? a0))"}, {{"a1"}}, {{"a0"}}, {{""}});test_case(assembly_from_list({"daddiu a1, s7, 8", "movz a1, s7, a0", ""}), {"(set! a1 (nonzero? a0))"}, {{"a1"}}, {{"a0"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, DADDU) {test_case(assembly_from_list({"daddu v1, r0, v0", ""}), {"(set! v1 (+ v0 0))"}, {{"v1"}}, {{"v0"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, DIV) {test_case(assembly_from_list({"div a1, a2", "mflo a3", ""}), {"(set! a3 (/.si a1 a2))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"div a1, a2", "mfhi a3", ""}), {"(set! a3 (mod.si a1 a2))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, DIVU) {test_case(assembly_from_list({"divu a1, a2", "mflo a3", ""}), {"(set! a3 (/.ui a1 a2))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});test_case(assembly_from_list({"divu a1, a2", "mfhi a3", ""}), {"(set! a3 (mod.ui a1 a2))"}, {{"a3"}}, {{"a1","a2"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, DSLL32) {test_case(assembly_from_list({"L100:", "dsll32 v1, s4, 30", "slt v1, v1, r0", "beq v1, r0, L100", "sll r0, r0, 0", ""}), {"(b! (not-pair? s4) L100 (nop!))"}, {{""}}, {{"s4"}}, {{"v1"}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, DSUBU) {test_case(assembly_from_list({"dsubu a0, a1, a2", "daddiu t0, s7, 8", "movn t0, s7, a0", ""}), {"(set! t0 (= a1 a2))"}, {{"t0"}}, {{"a1","a2"}}, {{"a0"}});test_case(assembly_from_list({"dsubu a0, a1, a2", "daddiu t0, s7, 8", "movz t0, s7, a0", ""}), {"(set! t0 (!= a1 a2))"}, {{"t0"}}, {{"a1","a2"}}, {{"a0"}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, JALR) {test_case(assembly_from_list({"jalr ra, t9", "sll v0, ra, 0", ""}), {"(call!)"}, {{""}}, {{"t9"}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, LUI) {test_case(assembly_from_list({"L100:", "lui a0, 2", "ori a1, a0, 3", ""}), {"(set! a1 131075)"}, {{"a1"}}, {{""}}, {{"a0"}});test_case(assembly_from_list({"L100:", "lui a0, 2", "ori a0, a0, 3", ""}), {"(set! a0 131075)"}, {{"a0"}}, {{""}}, {{""}});test_case(assembly_from_list({"L100:", "lui a0, L100", "ori a1, a0, L100", ""}), {"(set! a1 L100)"}, {{"a1"}}, {{""}}, {{"a0"}});test_case(assembly_from_list({"L100:", "lui a0, L100", "ori a0, a0, L100", ""}), {"(set! a0 L100)"}, {{"a0"}}, {{""}}, {{""}});test_case(assembly_from_list({"L100:", "lui a0, L100", "ori a1, a0, L100", "addu a1, fp, a1", ""}), {"(set! a1 L100)"}, {{"a1"}}, {{""}}, {{"a0"}});test_case(assembly_from_list({"L100:", "lui a1, L100", "ori a1, a1, L100", "addu a1, fp, a1", ""}), {"(set! a1 L100)"}, {{"a1"}}, {{""}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, MTC1) {test_case(assembly_from_list({"mtc1 f3, r0", ""}), {"(set! f3 0)"}, {{"f3"}}, {{""}}, {{""}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, SLT) {test_case(assembly_from_list({"slt a0, a1, a2", "movz a1, a2, a0", ""}), {"(set! a1 (min.si a1 a2))"}, {{"a1"}}, {{"a1","a2"}}, {{"a0"}});test_case(assembly_from_list({"slt a0, a1, a2", "movn a1, a2, a0", ""}), {"(set! a1 (max.si a1 a2))"}, {{"a1"}}, {{"a1","a2"}}, {{"a0"}});test_case(assembly_from_list({"L100:", "slt a3, a0, a1", "bne a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (<.si a0 a1) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0","a1"}}, {{""}});test_case(assembly_from_list({"L100:", "slt a3, a0, a1", "bne a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (<.si a0 a1) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});test_case(assembly_from_list({"L100:", "slt a3, a0, a1", "beq a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (>=.si a0 a1) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0","a1"}}, {{""}});test_case(assembly_from_list({"L100:", "slt a3, a0, a1", "beq a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (>=.si a0 a1) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});test_case(assembly_from_list({"slt a3, a0, a1", "daddiu a2, s7, 8", "movz a2, s7, a3", ""}), {"(set! a2 (<.si a0 a1))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});test_case(assembly_from_list({"slt a3, a0, r0", "daddiu a2, s7, 8", "movz a2, s7, a3", ""}), {"(set! a2 (<0.si a0))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"slt a3, a0, a1", "daddiu a2, s7, 8", "movn a2, s7, a3", ""}), {"(set! a2 (>=.si a0 a1))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});test_case(assembly_from_list({"slt a3, a0, r0", "daddiu a2, s7, 8", "movn a2, s7, a3", ""}), {"(set! a2 (>=0.si a0))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"slt a3, r0, a0", "daddiu a2, s7, 8", "movz a2, s7, a3", ""}), {"(set! a2 (>0.si a0))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"L100:", "slt v1, s2, r0", "beq v1, r0, L100", "or v1, s7, r0", ""}), {"(b! (>=0.si s2) L100 (set! v1 #f))"}, {{"v1"}}, {{"s2"}}, {{""}});test_case(assembly_from_list({"L100:", "slt v1, s2, r0", "beq v1, r0, L100", "or v0, s7, r0", ""}), {"(b! (>=0.si s2) L100 (set! v0 #f))"}, {{"v0"}}, {{"s2"}}, {{"v1"}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, SLTI) {test_case(assembly_from_list({"L100:", "slti a3, a0, 12", "bne a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (<.si a0 12) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0"}}, {{""}});test_case(assembly_from_list({"L100:", "slti a3, a0, 12", "bne a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (<.si a0 12) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"L100:", "slti a3, a0, 12", "beq a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (>=.si a0 12) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0"}}, {{""}});test_case(assembly_from_list({"L100:", "slti a3, a0, 12", "beq a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (>=.si a0 12) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"slti a3, a0, 12", "daddiu a2, s7, 8", "movz a2, s7, a3", ""}), {"(set! a2 (<.si a0 12))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"slti a3, a0, 12", "daddiu a2, s7, 8", "movn a2, s7, a3", ""}), {"(set! a2 (>=.si a0 12))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, SLTIU) {test_case(assembly_from_list({"L100:", "sltiu a3, a0, 12", "bne a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (<.ui a0 12) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0"}}, {{""}});test_case(assembly_from_list({"L100:", "sltiu a3, a0, 12", "bne a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (<.ui a0 12) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"L100:", "sltiu a3, a0, 12", "beq a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (>=.ui a0 12) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0"}}, {{""}});test_case(assembly_from_list({"L100:", "sltiu a3, a0, 12", "beq a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (>=.ui a0 12) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"sltiu a3, a0, 12", "daddiu a2, s7, 8", "movz a2, s7, a3", ""}), {"(set! a2 (<.ui a0 12))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});test_case(assembly_from_list({"sltiu a3, a0, 12", "daddiu a2, s7, 8", "movn a2, s7, a3", ""}), {"(set! a2 (>=.ui a0 12))"}, {{"a2"}}, {{"a0"}}, {{"a3"}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, SLTU) {test_case(assembly_from_list({"sltu a0, a1, a2", "movz a1, a2, a0", ""}), {"(set! a1 (min.ui a1 a2))"}, {{"a1"}}, {{"a1","a2"}}, {{"a0"}});test_case(assembly_from_list({"sltu a0, a1, a2", "movn a1, a2, a0", ""}), {"(set! a1 (max.ui a1 a2))"}, {{"a1"}}, {{"a1","a2"}}, {{"a0"}});test_case(assembly_from_list({"L100:", "sltu a3, a0, a1", "bne a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (<.ui a0 a1) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0","a1"}}, {{""}});test_case(assembly_from_list({"L100:", "sltu a3, a0, a1", "bne a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (<.ui a0 a1) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});test_case(assembly_from_list({"L100:", "sltu a3, a0, a1", "beq a3, r0, L100", "or a3, s7, r0", ""}), {"(b! (>=.ui a0 a1) L100 (set! a3 #f))"}, {{"a3"}}, {{"a0","a1"}}, {{""}});test_case(assembly_from_list({"L100:", "sltu a3, a0, a1", "beq a3, r0, L100", "or a2, s7, r0", ""}), {"(b! (>=.ui a0 a1) L100 (set! a2 #f))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});test_case(assembly_from_list({"sltu a3, a0, a1", "daddiu a2, s7, 8", "movz a2, s7, a3", ""}), {"(set! a2 (<.ui a0 a1))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});test_case(assembly_from_list({"sltu a3, a0, a1", "daddiu a2, s7, 8", "movn a2, s7, a3", ""}), {"(set! a2 (>=.ui a0 a1))"}, {{"a2"}}, {{"a0","a1"}}, {{"a3"}});}
|
|
|
|
TEST(DecompilerAtomicOpBuilder, SW) {test_case(assembly_from_list({"sw r0, test(s7)", ""}), {"(s.w! test 0)"}, {{""}}, {{""}}, {{""}});test_case(assembly_from_list({"sw r0, 2(a3)", ""}), {"(s.w! (+ a3 2) 0)"}, {{""}}, {{"a3"}}, {{""}});test_case(assembly_from_list({"sw r0, 0(a3)", ""}), {"(s.w! a3 0)"}, {{""}}, {{"a3"}}, {{""}});}
|
|
|