summary refs log tree commit diff
path: root/lisc/test
diff options
context:
space:
mode:
Diffstat (limited to 'lisc/test')
-rw-r--r--lisc/test/fpcnv.ssa26
1 files changed, 26 insertions, 0 deletions
diff --git a/lisc/test/fpcnv.ssa b/lisc/test/fpcnv.ssa
new file mode 100644
index 0000000..462e0e1
--- /dev/null
+++ b/lisc/test/fpcnv.ssa
@@ -0,0 +1,26 @@
+# floating point casts and conversions
+
+function s $fneg(s %f) {
+@fneg
+	%b0 =w cast %f
+	%b1 =w xor 2147483648, %b0
+	%rs =s cast %b1
+	ret %rs
+}
+
+function d $ftrunc(d %f) {
+@ftrunc
+	%l0 =l ftosi %f
+	%rt =d sitof %l0
+	ret %rt
+}
+
+# >>> driver
+# extern float fneg(float);
+# extern double ftrunc(double);
+# int main() {
+# 	if (fneg(1.234f) != -1.234f) return 1;
+# 	if (ftrunc(3.1415) != 3.0) return 2;
+# 	return 0;
+# }
+# <<<