aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
Diffstat (limited to 'validation')
-rw-r--r--validation/backend/arithmetic-ops.c20
-rw-r--r--validation/fp-ops.c57
2 files changed, 77 insertions, 0 deletions
diff --git a/validation/backend/arithmetic-ops.c b/validation/backend/arithmetic-ops.c
index 55996d9c..fc4f0e5a 100644
--- a/validation/backend/arithmetic-ops.c
+++ b/validation/backend/arithmetic-ops.c
@@ -88,6 +88,26 @@ static unsigned int umod(unsigned int x, unsigned int y)
return x % y;
}
+static int neg(int x)
+{
+ return -x;
+}
+
+static unsigned int uneg(unsigned int x)
+{
+ return -x;
+}
+
+static float fneg(float x)
+{
+ return -x;
+}
+
+static double dneg(double x)
+{
+ return -x;
+}
+
/*
* check-name: Arithmetic operator code generation
* check-command: sparsec -c $file -o tmp.o
diff --git a/validation/fp-ops.c b/validation/fp-ops.c
new file mode 100644
index 00000000..7f58a72f
--- /dev/null
+++ b/validation/fp-ops.c
@@ -0,0 +1,57 @@
+double fadd(double x, double y) { return x + y; }
+double fsub(double x, double y) { return x - y; }
+double fmul(double x, double y) { return x * y; }
+double fdiv(double x, double y) { return x / y; }
+double fneg(double x) { return -x; }
+_Bool ftst(double x) { return !x; }
+
+/*
+ * check-name: floating-point ops
+ * check-command: ./test-linearize -Wno-decl $file
+
+ * check-output-start
+fadd:
+.L0:
+ <entry-point>
+ fadd.64 %r3 <- %arg1, %arg2
+ ret.64 %r3
+
+
+fsub:
+.L2:
+ <entry-point>
+ fsub.64 %r7 <- %arg1, %arg2
+ ret.64 %r7
+
+
+fmul:
+.L4:
+ <entry-point>
+ fmul.64 %r11 <- %arg1, %arg2
+ ret.64 %r11
+
+
+fdiv:
+.L6:
+ <entry-point>
+ fdiv.64 %r15 <- %arg1, %arg2
+ ret.64 %r15
+
+
+fneg:
+.L8:
+ <entry-point>
+ fneg.64 %r18 <- %arg1
+ ret.64 %r18
+
+
+ftst:
+.L10:
+ <entry-point>
+ set.64 %r21 <- 0.000000
+ fcmpoeq.1 %r23 <- %arg1, %r21
+ ret.1 %r23
+
+
+ * check-output-end
+ */