mirror of
https://github.com/open-goal/jak-project
synced 2026-05-24 07:11:15 -04:00
[Decomp] Add SSA based check for expression building (#292)
* wip * tests pass * fix warnings
This commit is contained in:
@@ -266,7 +266,7 @@ TEST_F(FormRegressionTest, ExprAbs) {
|
||||
" jr ra\n"
|
||||
" daddu sp, sp, r0";
|
||||
std::string type = "(function int int)";
|
||||
std::string expected = "(abs arg0)";
|
||||
std::string expected = "(begin (set! v0-0 arg0) (abs v0-0))";
|
||||
test_with_expr(func, type, expected);
|
||||
}
|
||||
|
||||
@@ -2053,10 +2053,10 @@ TEST_F(FormRegressionTest, ExprPrintl) {
|
||||
" bgtzl v1, L62\n"
|
||||
" lw v1, pair(s7)\n"
|
||||
"\n"
|
||||
" lwu v1, -4(a0)\n" // want to cheat this read.
|
||||
" lwu v1, -4(a0)\n" // use 1
|
||||
"L62:\n"
|
||||
" lwu t9, 24(v1)\n"
|
||||
" jalr ra, t9\n"
|
||||
" jalr ra, t9\n" // use 2
|
||||
" sll v0, ra, 0\n"
|
||||
"\n"
|
||||
" or v1, v0, r0\n"
|
||||
@@ -2076,7 +2076,8 @@ TEST_F(FormRegressionTest, ExprPrintl) {
|
||||
|
||||
std::string expected =
|
||||
"(begin\n"
|
||||
" ((method-of-type (rtype-of a0-1) print) arg0)\n"
|
||||
" (set! a0-1 arg0)\n"
|
||||
" ((method-of-type (rtype-of a0-1) print) a0-1)\n"
|
||||
" (format (quote #t) \"~%\")\n"
|
||||
" arg0\n"
|
||||
" )";
|
||||
@@ -2535,36 +2536,40 @@ TEST_F(FormRegressionTest, ExprAssert) {
|
||||
std::string expected = "(begin (if (not arg0) (format (quote #t) \"A ~A\" arg1)) 0)";
|
||||
test_with_expr(func, type, expected, false, "", {{"L17", "A ~A"}});
|
||||
}
|
||||
//
|
||||
// TEST_F(FormRegressionTest, ExprTerminal2) {
|
||||
// std::string func =
|
||||
// "sll r0, r0, 0\n"
|
||||
// "L29:\n"
|
||||
// " daddiu sp, sp, -16\n"
|
||||
// " sd fp, 8(sp)\n"
|
||||
// " or fp, t9, r0\n"
|
||||
//
|
||||
// //" lwc1 f0, L71(fp)\n"
|
||||
// " mtc1 f0, r0\n"
|
||||
// " mtc1 f1, a0\n"
|
||||
// " mul.s f0, f0, f1\n"
|
||||
// " mtc1 f1, a1\n"
|
||||
// " sub.s f0, f0, f1\n"
|
||||
// " mtc1 f1, a2\n"
|
||||
// " div.s f0, f0, f1\n"
|
||||
// " sqrt.s f0, f0\n"
|
||||
// " mtc1 f1, a1\n"
|
||||
// " mtc1 f2, a2\n"
|
||||
// " mul.s f3, f0, f0\n"
|
||||
// " mul.s f2, f2, f3\n"
|
||||
// " add.s f1, f1, f2\n"
|
||||
// " sub.s f0, f0, f1\n"
|
||||
// " mfc1 v0, f0\n"
|
||||
// " ld fp, 8(sp)\n"
|
||||
// " jr ra\n"
|
||||
// " daddiu sp, sp, 16\n";
|
||||
// std::string type = "(function float float float float float)";
|
||||
//
|
||||
// std::string expected = "(begin (if (not arg0) (format (quote #t) \"A ~A\" arg1)) 0)";
|
||||
// test_with_expr(func, type, expected, false, "", {{"L17", "A ~A"}});
|
||||
//}
|
||||
|
||||
TEST_F(FormRegressionTest, ExprTerminal2) {
|
||||
std::string func =
|
||||
"sll r0, r0, 0\n"
|
||||
"L29:\n"
|
||||
" daddiu sp, sp, -16\n"
|
||||
" sd fp, 8(sp)\n"
|
||||
" or fp, t9, r0\n"
|
||||
|
||||
//" lwc1 f0, L71(fp)\n"
|
||||
" mtc1 f0, r0\n"
|
||||
" mtc1 f1, a0\n"
|
||||
" mul.s f0, f0, f1\n"
|
||||
" mtc1 f1, a1\n"
|
||||
" sub.s f0, f0, f1\n"
|
||||
" mtc1 f1, a2\n"
|
||||
" div.s f0, f0, f1\n"
|
||||
" sqrt.s f0, f0\n"
|
||||
" mtc1 f1, a1\n"
|
||||
" mtc1 f2, a2\n"
|
||||
" mul.s f3, f0, f0\n"
|
||||
" mul.s f2, f2, f3\n"
|
||||
" add.s f1, f1, f2\n"
|
||||
" sub.s f0, f0, f1\n"
|
||||
" mfc1 v0, f0\n"
|
||||
" ld fp, 8(sp)\n"
|
||||
" jr ra\n"
|
||||
" daddiu sp, sp, 16\n";
|
||||
std::string type = "(function float float float float float)";
|
||||
|
||||
std::string expected =
|
||||
"(begin\n"
|
||||
" (set! f0-4 (sqrt (/ (- (* 0.000000 arg0) arg1) arg2)))\n"
|
||||
" (- f0-4 (+ arg1 (* arg2 (* f0-4 f0-4))))\n"
|
||||
" )";
|
||||
test_with_expr(func, type, expected, false, "", {{"L17", "A ~A"}});
|
||||
}
|
||||
Reference in New Issue
Block a user