summary refs log tree commit diff
path: root/test/fpcnv.ssa
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-27 15:00:45 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-27 15:00:45 -0400
commit36635660b40573f6a0c19d50dfdd9277589030de (patch)
treea1b4463f7260462c314bd8d7cb35b3d199143f33 /test/fpcnv.ssa
parentaad52241c88ad5327a8488c66dc906c8393c9c92 (diff)
downloadroux-36635660b40573f6a0c19d50dfdd9277589030de.tar.gz
extract tests out of src
Diffstat (limited to 'test/fpcnv.ssa')
-rw-r--r--test/fpcnv.ssa27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/fpcnv.ssa b/test/fpcnv.ssa
new file mode 100644
index 0000000..5fd3be9
--- /dev/null
+++ b/test/fpcnv.ssa
@@ -0,0 +1,27 @@
+# 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.23f) != -1.23f)  return 1;
+# 	if (ftrunc(3.1415) != 3.0)  return 2;
+# 	if (ftrunc(-1.234) != -1.0) return 3;
+# 	return 0;
+# }
+# <<<