aboutsummaryrefslogtreecommitdiff
path: root/deps/lightning/check/ret.tst
diff options
context:
space:
mode:
authorPaul Cercueil2020-01-30 12:33:44 -0300
committerPaul Cercueil2020-02-08 11:44:52 -0300
commit4a71579b757d3a2eb6902c84391f429838ad4912 (patch)
treec57430315f1b82497eebd3fef24c0f4c0336bf0d /deps/lightning/check/ret.tst
parentea884d3029c673e06a4084156ceb662598d8945a (diff)
downloadpcsx_rearmed-4a71579b757d3a2eb6902c84391f429838ad4912.tar.gz
pcsx_rearmed-4a71579b757d3a2eb6902c84391f429838ad4912.tar.bz2
pcsx_rearmed-4a71579b757d3a2eb6902c84391f429838ad4912.zip
git subrepo clone https://git.savannah.gnu.org/git/lightning.git deps/lightning
subrepo: subdir: "deps/lightning" merged: "b0b8eb5" upstream: origin: "https://git.savannah.gnu.org/git/lightning.git" branch: "master" commit: "b0b8eb5" git-subrepo: version: "0.4.1" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "a04d8c2"
Diffstat (limited to 'deps/lightning/check/ret.tst')
-rw-r--r--deps/lightning/check/ret.tst51
1 files changed, 51 insertions, 0 deletions
diff --git a/deps/lightning/check/ret.tst b/deps/lightning/check/ret.tst
new file mode 100644
index 0000000..de1d82c
--- /dev/null
+++ b/deps/lightning/check/ret.tst
@@ -0,0 +1,51 @@
+.data 16
+ok:
+.c "ok"
+
+.code
+ jmpi main
+
+/*
+ * very simple test on purpose because otherwise it would not trigger
+ * the bug where the retr %r0 or retr_d %f0 would be omitted because
+ * the argument was already the return register, but the register end
+ * clobbered by another instruction, like the div*, and the wrong
+ * value returned because the retr* was removed and this way, lost
+ * information that the register was live at function exit.
+ */
+
+check_r0:
+ prolog
+ movi %r0 1
+ movi %r2 10
+ // on x86 this changes %rax on other arches could use %r0 as temporary
+ divi %r1 %r2 3
+ // %r0 must still be 1
+ retr %r0
+ epilog
+
+check_f0:
+ prolog
+ movi_d %f0 0.5
+ movi_d %f2 10
+ divi_d %f1 %f2 3
+ retr_d %f0
+ epilog
+
+main:
+ prolog
+ calli check_r0
+ retval %r1
+ beqi r0_ok %r1 1
+ calli @abort
+r0_ok:
+ calli check_f0
+ retval_d %f1
+ beqi_d f0_ok %f1 0.5
+ calli @abort
+f0_ok:
+ prepare
+ pushargi ok
+ finishi @puts
+ ret
+ epilog