aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2020-10-29 09:00:42 +0100
committerLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2020-10-29 09:00:42 +0100
commitf57103ff244a72201e12864e998eae791681e68f (patch)
tree0f3c1673c5f3189de607fda24686e9dbbc25cbe9 /test
parenta839b5446846d7a22b4f3bbf2bc6e263a8c30a68 (diff)
downloadcompcert-kvx-f57103ff244a72201e12864e998eae791681e68f.tar.gz
compcert-kvx-f57103ff244a72201e12864e998eae791681e68f.zip
Some tests and load/store instr
Diffstat (limited to 'test')
-rwxr-xr-xtest/aarch64/asmb_aarch64_gen_test.sh13
-rw-r--r--test/aarch64/c/biggest_of_3_int.c10
-rw-r--r--test/aarch64/c/floop.c8
-rw-r--r--test/aarch64/c/floor.c29
-rw-r--r--test/aarch64/c/funcs.c36
-rw-r--r--test/aarch64/c/hello.c6
-rw-r--r--test/aarch64/c/msb_pos.c20
-rw-r--r--test/aarch64/c/prime.c23
-rw-r--r--test/aarch64/c/wloop.c8
9 files changed, 146 insertions, 7 deletions
diff --git a/test/aarch64/asmb_aarch64_gen_test.sh b/test/aarch64/asmb_aarch64_gen_test.sh
index 5a839539..19149265 100755
--- a/test/aarch64/asmb_aarch64_gen_test.sh
+++ b/test/aarch64/asmb_aarch64_gen_test.sh
@@ -8,26 +8,25 @@ while getopts ':c' 'OPTKEY'; do
done
FILES=c/*
-CCOMP_BBLOCKS=../../ccomp
-CCOMP_REF=../../../CompCert_master/ccomp
+CCOMP_BBLOCKS="../../ccomp"
+CCOMP_REF="../../../CompCert_master/ccomp"
for f in $FILES
do
- echo "Processing $f file... $(basename $f)"
-
BNAME=$(basename -s .c $f)
SNAME="$BNAME".s
SREFNAME="$BNAME"_ref.s
./$CCOMP_BBLOCKS -S $f -o $SNAME
./$CCOMP_REF -dmach -S $f -o $SREFNAME
- diff -I '^//*' <(cut -c-5 $SNAME) <(cut -c-5 $SREFNAME) > /dev/null 2>&1
+ #diff -I '^//*' <(cut -c-5 $SNAME) <(cut -c-5 $SREFNAME) > /dev/null 2>&1
+ diff -I '^//*' $SNAME $SREFNAME > /dev/null 2>&1
error=$?
if [ $error -eq 0 ]
then
- echo "$BNAME test OK"
+ echo "[$BNAME] OK"
elif [ $error -eq 1 ]
then
- echo "$BNAME test FAIL"
+ echo "[$BNAME] FAIL"
diff -I '^//*' -y $SNAME $SREFNAME
else
echo "[WARNING] There was something wrong with the diff command !"
diff --git a/test/aarch64/c/biggest_of_3_int.c b/test/aarch64/c/biggest_of_3_int.c
new file mode 100644
index 00000000..346908fc
--- /dev/null
+++ b/test/aarch64/c/biggest_of_3_int.c
@@ -0,0 +1,10 @@
+int main(int a, int b, int c) {
+ if ((a > b) && (a > c)) {
+ return a;
+ } else if (b > c) {
+ return b;
+ } else {
+ return c;
+ }
+ return 0;
+}
diff --git a/test/aarch64/c/floop.c b/test/aarch64/c/floop.c
new file mode 100644
index 00000000..30270892
--- /dev/null
+++ b/test/aarch64/c/floop.c
@@ -0,0 +1,8 @@
+int main(int x)
+{
+ int y = 4;
+ int s = 23;
+ for(int i = 0; i <= x; i++)
+ y << s;
+ return y;
+}
diff --git a/test/aarch64/c/floor.c b/test/aarch64/c/floor.c
new file mode 100644
index 00000000..33a57af3
--- /dev/null
+++ b/test/aarch64/c/floor.c
@@ -0,0 +1,29 @@
+int main(int n)
+{
+ int x = 1, i;
+
+ /* for positive values */
+ if (n > 0)
+ {
+ for (; x <= n >> 1;)
+ {
+ x = x << 1;
+ }
+ n = x;
+ }
+ /* for negative values */
+ else
+ {
+ n = ~n;
+ n = n + 1;
+ for (; x <= n >> 1;)
+ {
+ x = x << 1;
+ }
+ x = x << 1;
+ x = ~x;
+ x = x + 1;
+ n = x;
+ }
+ return n;
+}
diff --git a/test/aarch64/c/funcs.c b/test/aarch64/c/funcs.c
new file mode 100644
index 00000000..fba46033
--- /dev/null
+++ b/test/aarch64/c/funcs.c
@@ -0,0 +1,36 @@
+/* funcs.c -- More examples of functions
+ */
+
+#include <stdio.h>
+
+int getint(void); /*It prompts user to enter an integer, which it returns*/
+
+int getmax(int a, int b, int c); /*It returns value of largest of a, b, c*/
+
+/* Main program: Using the various functions */
+int main (void) {
+ int x, y, z;
+
+ x = getint();
+ y = getint();
+ z = getint();
+ printf("The largest of %d, %d, and %d is %d\n", x, y, z, getmax(x,y,z));
+}
+
+int getint(void) {
+ int a;
+
+ /*printf("Please enter an integer > ");*/
+ scanf("%d", &a);
+ return(a);
+}
+
+int getmax(int a, int b, int c){
+ int m = a;
+
+ if (m<b)
+ m = b;
+ if (m<c)
+ m = c;
+ return(m);
+}
diff --git a/test/aarch64/c/hello.c b/test/aarch64/c/hello.c
new file mode 100644
index 00000000..0279269e
--- /dev/null
+++ b/test/aarch64/c/hello.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void) {
+ printf("Hello World!\n");
+ return 0;
+}
diff --git a/test/aarch64/c/msb_pos.c b/test/aarch64/c/msb_pos.c
new file mode 100644
index 00000000..f2e7fe09
--- /dev/null
+++ b/test/aarch64/c/msb_pos.c
@@ -0,0 +1,20 @@
+/* Function to find the MSB bit position */
+int main(int n)
+{
+ int i = 0, bit;
+ while (i < 32)
+ {
+ bit = n & 0x80000000;
+ if (bit == -0x80000000)
+ {
+ bit = 1;
+ }
+
+ if (bit == 1)
+ break;
+
+ n = n << 1;
+ i++;
+ }
+ return i;
+}
diff --git a/test/aarch64/c/prime.c b/test/aarch64/c/prime.c
new file mode 100644
index 00000000..6c51db32
--- /dev/null
+++ b/test/aarch64/c/prime.c
@@ -0,0 +1,23 @@
+/* prime1.c It prompts the user to enter an integer N. It prints out
+ * if it is a prime or not. If not, it prints out a factor of N.
+ */
+
+#include <stdio.h>
+
+int main(int n) {
+ int i;
+ int flag;
+
+ flag = 1;
+ for (i=2; (i<(n/2)) && flag; ) { /* May be we do not need to test
+ values of i greater than the square root of n? */
+ if ((n % i) == 0) /* If true n is divisible by i */
+ flag = 0;
+ else
+ i++;
+ }
+
+ if (flag)
+ return 1;
+ return 0;
+}
diff --git a/test/aarch64/c/wloop.c b/test/aarch64/c/wloop.c
new file mode 100644
index 00000000..5ba67419
--- /dev/null
+++ b/test/aarch64/c/wloop.c
@@ -0,0 +1,8 @@
+int main(int x)
+{
+ int y = 4;
+ int s = 23;
+ while(s < x)
+ y << s;
+ return y;
+}