[decompiler] ASM Branching Support (#677)

* basic example working in geometry

* before updating offline'

* clean up

* temp

* progress
This commit is contained in:
water111
2021-07-05 16:07:07 -04:00
committed by GitHub
parent 54c63ff42c
commit 551a9c4955
42 changed files with 4161 additions and 272 deletions
@@ -1526,4 +1526,100 @@ TEST_F(FormRegressionTest, Method23Trsqv) {
std::string expected =
"(vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg1 (-> arg0 trans)))";
test_with_stack_structures(func, type, expected, R"([[16, "vector"]])");
}
TEST_F(FormRegressionTest, VectorLineDistance) {
std::string func =
"sll r0, r0, 0\n"
"\n"
" daddiu sp, sp, -128\n"
" sd ra, 0(sp)\n"
" sd fp, 8(sp)\n"
" or fp, t9, r0\n"
" sq s4, 80(sp)\n"
" sq s5, 96(sp)\n"
" sq gp, 112(sp)\n"
" or s5, a0, r0\n"
" or s4, a1, r0\n"
" lw t9, vector-normalize!(s7)\n"
" daddiu a0, sp, 16\n"
" sq r0, 0(a0)\n"
" or v1, a2, r0\n"
" or a1, s4, r0\n"
" lqc2 vf4, 0(v1)\n"
" lqc2 vf5, 0(a1)\n"
" vmove.w vf6, vf0\n"
" vsub.xyz vf6, vf4, vf5\n"
" sqc2 vf6, 0(a0)\n"
//" lw a1, L125(fp)\n"
" or a1, r0, r0\n"
" jalr ra, t9\n"
" sll v0, ra, 0\n"
" or a1, v0, r0\n"
" daddiu gp, sp, 32\n"
" sq r0, 0(gp)\n"
" lqc2 vf4, 0(s5)\n"
" lqc2 vf5, 0(s4)\n"
" vmove.w vf6, vf0\n"
" vsub.xyz vf6, vf4, vf5\n"
" sqc2 vf6, 0(gp)\n"
" or a0, a1, r0\n"
" or v1, gp, r0\n"
" lwc1 f0, 0(a0)\n"
" lwc1 f1, 4(a0)\n"
" lwc1 f2, 8(a0)\n"
" lwc1 f3, 0(v1)\n"
" lwc1 f4, 4(v1)\n"
" lwc1 f5, 8(v1)\n"
" mula.s f0, f3\n"
" madda.s f1, f4\n"
" madd.s f0, f2, f5\n"
" mfc1 v1, f0\n"
" mtc1 f0, v1\n"
" lw t9, vector-float*!(s7)\n"
" daddiu a0, sp, 48\n"
" sq r0, 0(a0)\n"
" mfc1 a2, f0\n"
" jalr ra, t9\n"
" sll v0, ra, 0\n"
" or v1, v0, r0\n"
" lw t9, vector-length(s7)\n"
" daddiu a0, sp, 64\n"
" sq r0, 0(a0)\n"
" lqc2 vf4, 0(gp)\n"
" lqc2 vf5, 0(v1)\n"
" vmove.w vf6, vf0\n"
" vsub.xyz vf6, vf4, vf5\n"
" sqc2 vf6, 0(a0)\n"
" jalr ra, t9\n"
" sll v0, ra, 0\n"
" ld ra, 0(sp)\n"
" ld fp, 8(sp)\n"
" lq gp, 112(sp)\n"
" lq s5, 96(sp)\n"
" lq s4, 80(sp)\n"
" jr ra\n"
" daddiu sp, sp, 128\n"
" sll r0, r0, 0\n"
" sll r0, r0, 0\n";
std::string type = "(function vector vector vector float)";
std::string expected =
"(let*\n"
" ((a1-3\n"
" (vector-normalize!\n"
" (vector-! (new-stack-vector0) arg2 arg1)\n"
" (the-as float 0)\n"
" )\n"
" )\n"
" (gp-1 (vector-! (new-stack-vector0) arg0 arg1))\n"
" (f0-1 (vector-dot a1-3 gp-1))\n"
" (v1-3 (vector-float*! (new-stack-vector0) a1-3 f0-1))\n"
" )\n"
" (vector-length (vector-! (new-stack-vector0) gp-1 v1-3))\n"
" )";
test_with_stack_structures(func, type, expected,
R"([[16, "vector"], [32, "vector"], [48, "vector"], [64, "vector"]])");
}