aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2018-11-23 18:06:26 +0100
committerCyril SIX <cyril.six@kalray.eu>2018-11-23 18:06:26 +0100
commitf17faa9e318cb6e6c75b3c22387f13e57a9828f7 (patch)
tree9bd29c4d2b7a5f2bc4a782656318c69cf67abdde /test/mppa
parent0b9d1deb832dc93ce381f15f8e9774973f45e56e (diff)
downloadcompcert-kvx-f17faa9e318cb6e6c75b3c22387f13e57a9828f7.tar.gz
compcert-kvx-f17faa9e318cb6e6c75b3c22387f13e57a9828f7.zip
Interoperability tests passed (no va_arg yet)
Diffstat (limited to 'test/mppa')
-rw-r--r--test/mppa/do_test.sh8
-rw-r--r--test/mppa/interop/.gitignore1
-rw-r--r--test/mppa/interop/Makefile166
-rw-r--r--test/mppa/interop/common.c62
-rw-r--r--test/mppa/interop/common.h24
-rw-r--r--test/mppa/interop/framework.h37
-rw-r--r--test/mppa/interop/i_manyiargs.c9
-rw-r--r--test/mppa/interop/i_multiiargs.c6
-rw-r--r--test/mppa/interop/i_oneiarg.c6
-rw-r--r--test/mppa/interop/ll_manyllargs.c8
-rw-r--r--test/mppa/interop/ll_multillargs.c7
-rw-r--r--test/mppa/interop/ll_onellarg.c7
-rw-r--r--test/mppa/interop/ll_void.c7
-rw-r--r--test/mppa/interop/void_void.c7
14 files changed, 355 insertions, 0 deletions
diff --git a/test/mppa/do_test.sh b/test/mppa/do_test.sh
index ee7cbcf7..add87b66 100644
--- a/test/mppa/do_test.sh
+++ b/test/mppa/do_test.sh
@@ -30,4 +30,12 @@ cat << EOF
##
EOF
(cd instr && make $1 -j8)
+
+cat << EOF
+
+##
+# Interoperability with GCC
+##
+EOF
+(cd interop && make $1 -j8)
}
diff --git a/test/mppa/interop/.gitignore b/test/mppa/interop/.gitignore
new file mode 100644
index 00000000..ea1472ec
--- /dev/null
+++ b/test/mppa/interop/.gitignore
@@ -0,0 +1 @@
+output/
diff --git a/test/mppa/interop/Makefile b/test/mppa/interop/Makefile
new file mode 100644
index 00000000..18efaa24
--- /dev/null
+++ b/test/mppa/interop/Makefile
@@ -0,0 +1,166 @@
+K1CC ?= k1-mbr-gcc
+CC ?= gcc
+CCOMP ?= ccomp
+CFLAGS ?= -O2
+SIMU ?= k1-cluster
+TIMEOUT ?= --signal=SIGTERM 20s
+
+DIR=./
+SRCDIR=$(DIR)
+OUTDIR=$(DIR)/out
+BINDIR=$(DIR)/bin
+ASMDIR=$(DIR)/asm
+OBJDIR=$(DIR)/obj
+COMMON=common
+
+##
+# Intended flow : .c -> .gcc.s -> .gcc.o -> .gcc.bin -> .gcc.out
+# -> .ccomp.s -> .ccomp.o -> .ccomp.bin -> .ccomp.out
+# -> .x86-gcc.s -> .x86-gcc.o -> .x86-gcc.bin -> .x86-gcc.out
+#
+# The .o -> .bin part uses $(COMMON).gcc.o or $(COMMON).x86-gcc.o depending on the architecture
+##
+
+K1CCPATH=$(shell which $(K1CC))
+CCPATH=$(shell which $(CC))
+CCOMPPATH=$(shell which $(CCOMP))
+SIMUPATH=$(shell which $(SIMU))
+
+TESTNAMES=$(filter-out $(COMMON),$(notdir $(subst .c,,$(wildcard $(DIR)/*.c))))
+X86_GCC_OUT=$(addprefix $(OUTDIR)/,$(addsuffix .x86-gcc.out,$(TESTNAMES)))
+GCC_OUT=$(addprefix $(OUTDIR)/,$(addsuffix .gcc.out,$(TESTNAMES)))
+CCOMP_OUT=$(addprefix $(OUTDIR)/,$(addsuffix .ccomp.out,$(TESTNAMES)))
+
+OUT=$(X86_GCC_OUT) $(GCC_OUT) $(CCOMP_OUT)
+BIN=$(addprefix $(BINDIR)/,$(addsuffix .x86-gcc.bin,$(TESTNAMES)))\
+ $(addprefix $(BINDIR)/,$(addsuffix .gcc.bin,$(TESTNAMES)))\
+ $(addprefix $(BINDIR)/,$(addsuffix .ccomp.bin,$(TESTNAMES)))
+
+##
+# Targets
+##
+
+all: $(BIN)
+
+.PHONY:
+test: $(X86_GCC_OUT) $(GCC_OUT)
+ @echo "Comparing x86 gcc output to k1 gcc.."
+ @for test in $(TESTNAMES); do\
+ x86out=$(OUTDIR)/$$test.x86-gcc.out;\
+ gccout=$(OUTDIR)/$$test.gcc.out;\
+ if ! diff $$x86out $$gccout; then\
+ >&2 echo "ERROR: $$x86out and $$gccout differ";\
+ else\
+ echo "GOOD: $$x86out and $$gccout concur";\
+ fi;\
+ done
+
+.PHONY:
+check: $(GCC_OUT) $(CCOMP_OUT)
+ @echo "Comparing k1 gcc output to ccomp.."
+ @for test in $(TESTNAMES); do\
+ gccout=$(OUTDIR)/$$test.gcc.out;\
+ ccompout=$(OUTDIR)/$$test.ccomp.out;\
+ if ! diff $$ccompout $$gccout; then\
+ >&2 echo "ERROR: $$ccompout and $$gccout differ";\
+ else\
+ echo "GOOD: $$ccompout and $$gccout concur";\
+ fi;\
+ done
+
+##
+# Rules
+##
+
+.SECONDARY:
+
+##
+# Generating output
+##
+
+## Version sans les timeout
+#$(OUTDIR)/%.x86-gcc.out: $(BINDIR)/%.x86-gcc.bin
+# @mkdir -p $(@D)
+# ./$< > $@; echo $$? >> $@
+#
+#$(OUTDIR)/%.gcc.out: $(BINDIR)/%.gcc.bin $(SIMUPATH)
+# @mkdir -p $(@D)
+# $(SIMU) -- $< > $@ ; echo $$? >> $@
+#
+#$(OUTDIR)/%.ccomp.out: $(BINDIR)/%.ccomp.bin $(SIMUPATH)
+# @mkdir -p $(@D)
+# $(SIMU) -- $< > $@ ; echo $$? >> $@
+
+## Version avec timeout
+$(OUTDIR)/%.x86-gcc.out: $(BINDIR)/%.x86-gcc.bin
+ @mkdir -p $(@D)
+ ret=0; timeout $(TIMEOUT) ./$< > $@ || { ret=$$?; }; echo $$ret >> $@
+
+$(OUTDIR)/%.gcc.out: $(BINDIR)/%.gcc.bin $(SIMUPATH)
+ @mkdir -p $(@D)
+ ret=0; timeout $(TIMEOUT) $(SIMU) -- $< > $@ || { ret=$$?; }; echo $$ret >> $@
+
+$(OUTDIR)/%.ccomp.out: $(BINDIR)/%.ccomp.bin $(SIMUPATH)
+ @mkdir -p $(@D)
+ ret=0; timeout $(TIMEOUT) $(SIMU) -- $< > $@ || { ret=$$?; }; echo $$ret >> $@
+
+##
+# Object to binary
+##
+
+$(BINDIR)/$(COMMON).x86-gcc.bin: $(OBJDIR)/$(COMMON).x86-gcc.o $(CCPATH)
+ @mkdir -p $(@D)
+ $(CC) $(CFLAGS) $< -o $@
+
+$(BINDIR)/$(COMMON).gcc.bin: $(OBJDIR)/$(COMMON).gcc.o $(K1CCPATH)
+ @mkdir -p $(@D)
+ $(K1CC) $(CFLAGS) $< -o $@
+
+$(BINDIR)/$(COMMON).ccomp.bin: $(OBJDIR)/$(COMMON).ccomp.o $(CCOMPPATH)
+ @mkdir -p $(@D)
+ $(CCOMP) $(CFLAGS) $< -o $@
+
+$(BINDIR)/%.x86-gcc.bin: $(OBJDIR)/%.x86-gcc.o $(OBJDIR)/$(COMMON).x86-gcc.o $(CCPATH)
+ @mkdir -p $(@D)
+ $(CC) $(CFLAGS) $(wordlist 1,2,$^) -o $@
+
+$(BINDIR)/%.gcc.bin: $(OBJDIR)/%.gcc.o $(OBJDIR)/$(COMMON).gcc.o $(K1CCPATH)
+ @mkdir -p $(@D)
+ $(K1CC) $(CFLAGS) $(wordlist 1,2,$^) -o $@
+
+$(BINDIR)/%.ccomp.bin: $(OBJDIR)/%.ccomp.o $(OBJDIR)/$(COMMON).ccomp.o $(CCOMPPATH)
+ @mkdir -p $(@D)
+ $(CCOMP) $(CFLAGS) $(wordlist 1,2,$^) -o $@
+
+##
+# Assembly to object
+##
+
+$(OBJDIR)/%.x86-gcc.o: $(ASMDIR)/%.x86-gcc.s $(CCPATH)
+ @mkdir -p $(@D)
+ $(CC) -c $(CFLAGS) $< -o $@
+
+$(OBJDIR)/%.gcc.o: $(ASMDIR)/%.gcc.s $(K1CCPATH)
+ @mkdir -p $(@D)
+ $(K1CC) -c $(CFLAGS) $< -o $@
+
+$(OBJDIR)/%.ccomp.o: $(ASMDIR)/%.ccomp.s $(CCOMPPATH)
+ @mkdir -p $(@D)
+ $(CCOMP) -c $(CFLAGS) $< -o $@
+
+
+##
+# Source to assembly
+##
+
+$(ASMDIR)/%.x86-gcc.s: $(SRCDIR)/%.c $(CCPATH)
+ @mkdir -p $(@D)
+ $(CC) $(CFLAGS) -S $< -o $@
+
+$(ASMDIR)/%.gcc.s: $(SRCDIR)/%.c $(K1CCPATH)
+ @mkdir -p $(@D)
+ $(K1CC) $(CFLAGS) -S $< -o $@
+
+$(ASMDIR)/%.ccomp.s: $(SRCDIR)/%.c $(CCOMPPATH)
+ @mkdir -p $(@D)
+ $(CCOMP) $(CFLAGS) -S $< -o $@
diff --git a/test/mppa/interop/common.c b/test/mppa/interop/common.c
new file mode 100644
index 00000000..e3eea128
--- /dev/null
+++ b/test/mppa/interop/common.c
@@ -0,0 +1,62 @@
+#define STACK int a[100];\
+ a[42] = 42;
+
+#define ONEARG_OP(arg) (3*arg+2)
+
+#define MULTIARG_OP(arg1, arg2, arg3, arg4) (arg1 ^ arg2 << arg3 - arg4)
+
+#define MANYARG_OP(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,\
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,\
+ a20, a21, a22, a23, a24, a25, a26, a27, a28, a29)\
+ (a0 + a1 * a2 + a3 * a4 + a5 + a6 + a7 - a8 + a9 +\
+ a10 + a11 - a12 ^ a13 + a14 - a15 + a16 ^ a17 + a18 + a19 +\
+ a20 + a21 + a22 * a23 + a24 + a25 << a26 & a27 + a28 + a29)
+
+void void_void(){
+ STACK;
+}
+
+long long ll_void(){
+ STACK;
+ return 0xdeadbeefdeadbeefULL;
+}
+
+int i_oneiarg(int arg){
+ STACK;
+ return ONEARG_OP(arg);
+}
+
+int i_multiiargs(int arg1, char arg2, char arg3, int arg4){
+ STACK;
+ return MULTIARG_OP(arg1, arg2, arg3, arg4);
+}
+
+int i_manyiargs(char a0, int a1, char a2, int a3, char a4, char a5, int a6, int a7, char a8, int a9,
+ char a10, int a11, char a12, int a13, char a14, char a15, int a16, int a17, char a18, int a19,
+ char a20, int a21, char a22, int a23, char a24, char a25, int a26, int a27, char a28, int a29)
+{
+ STACK;
+ return MANYARG_OP(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
+ a20, a21, a22, a23, a24, a25, a26, a27, a28, a29);
+}
+
+int ll_onellarg(long long arg){
+ STACK;
+ return ONEARG_OP(arg);
+}
+
+long long ll_multillargs(long long arg1, char arg2, char arg3, long long arg4){
+ STACK;
+ return MULTIARG_OP(arg1, arg2, arg3, arg4);
+}
+
+long long ll_manyllargs(char a0, long long a1, char a2, long long a3, char a4, char a5, long long a6, long long a7, char a8, long long a9,
+ char a10, long long a11, char a12, long long a13, char a14, char a15, long long a16, long long a17, char a18, long long a19,
+ char a20, long long a21, char a22, long long a23, char a24, char a25, long long a26, long long a27, char a28, long long a29)
+{
+ STACK;
+ return MANYARG_OP(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
+ a20, a21, a22, a23, a24, a25, a26, a27, a28, a29);
+}
diff --git a/test/mppa/interop/common.h b/test/mppa/interop/common.h
new file mode 100644
index 00000000..7b381671
--- /dev/null
+++ b/test/mppa/interop/common.h
@@ -0,0 +1,24 @@
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+void void_void(void);
+
+long long ll_void(void);
+
+int i_oneiarg(int arg);
+
+int i_multiiargs(int arg1, char arg2, char arg3, int arg4);
+
+int i_manyiargs(char a0, int a1, char a2, int a3, char a4, char a5, int a6, int a7, char a8, int a9,
+ char a10, int a11, char a12, int a13, char a14, char a15, int a16, int a17, char a18, int a19,
+ char a20, int a21, char a22, int a23, char a24, char a25, int a26, int a27, char a28, int a29);
+
+int ll_onellarg(long long arg);
+
+long long ll_multillargs(long long arg1, char arg2, char arg3, long long arg4);
+
+long long ll_manyllargs(char a0, long long a1, char a2, long long a3, char a4, char a5, long long a6, long long a7, char a8, long long a9,
+ char a10, long long a11, char a12, long long a13, char a14, char a15, long long a16, long long a17, char a18, long long a19,
+ char a20, long long a21, char a22, long long a23, char a24, char a25, long long a26, long long a27, char a28, long long a29);
+
+#endif
diff --git a/test/mppa/interop/framework.h b/test/mppa/interop/framework.h
new file mode 100644
index 00000000..52ba97bc
--- /dev/null
+++ b/test/mppa/interop/framework.h
@@ -0,0 +1,37 @@
+#ifndef __FRAMEWORK_H__
+#define __FRAMEWORK_H__
+
+#include "../prng/prng.c"
+
+#define BEGIN_TEST_N(type, N)\
+ int main(void){\
+ type t[N], c, i, j, S;\
+ srand(0);\
+ S = 0;\
+ for (i = 0 ; i < 100 ; i++){\
+ c = randlong();\
+ for (j = 0 ; j < N ; j++)\
+ t[j] = randlong();\
+ /* END BEGIN_TEST_N */
+
+#define BEGIN_TEST(type)\
+ int main(void){\
+ type a, b, c, i, S;\
+ srand(0);\
+ S = 0;\
+ for (i = 0 ; i < 100 ; i++){\
+ c = randlong();\
+ a = randlong();\
+ b = randlong();
+ /* END BEGIN_TEST */
+
+/* In between BEGIN_TEST and END_TEST : definition of c */
+
+#define END_TEST()\
+ S += c;\
+ }\
+ return S;\
+ }
+ /* END END_TEST */
+
+#endif
diff --git a/test/mppa/interop/i_manyiargs.c b/test/mppa/interop/i_manyiargs.c
new file mode 100644
index 00000000..d674c26f
--- /dev/null
+++ b/test/mppa/interop/i_manyiargs.c
@@ -0,0 +1,9 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(int)
+ c = i_manyiargs(a, b, a-b, a+b, a*2, b*2, a*2-b, a+b*2, (a-b)*2, (a+b)*2,
+ -2*a, -2*b, a-b, a+b, a*3, b*3, a*3-b, a+b*3, (a-b)*3, (a+b)*3,
+ -3*a, -3*b, a-b, a+b, a*4, b*4, a*4-b, a+b*4, (a-b)*4, (a+b)*4);
+END_TEST()
+
diff --git a/test/mppa/interop/i_multiiargs.c b/test/mppa/interop/i_multiiargs.c
new file mode 100644
index 00000000..0e8c8936
--- /dev/null
+++ b/test/mppa/interop/i_multiiargs.c
@@ -0,0 +1,6 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(int)
+ c = i_multiiargs(a, b, a-b, a+b);
+END_TEST()
diff --git a/test/mppa/interop/i_oneiarg.c b/test/mppa/interop/i_oneiarg.c
new file mode 100644
index 00000000..42cd1540
--- /dev/null
+++ b/test/mppa/interop/i_oneiarg.c
@@ -0,0 +1,6 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(int)
+ c = i_oneiarg(a);
+END_TEST()
diff --git a/test/mppa/interop/ll_manyllargs.c b/test/mppa/interop/ll_manyllargs.c
new file mode 100644
index 00000000..6e0b3b36
--- /dev/null
+++ b/test/mppa/interop/ll_manyllargs.c
@@ -0,0 +1,8 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(long long)
+ c = ll_manyllargs(a, b, a-b, a+b, a*2, b*2, a*2-b, a+b*2, (a-b)*2, (a+b)*2,
+ -2*a, -2*b, a-b, a+b, a*3, b*3, a*3-b, a+b*3, (a-b)*3, (a+b)*3,
+ -3*a, -3*b, a-b, a+b, a*4, b*4, a*4-b, a+b*4, (a-b)*4, (a+b)*4);
+END_TEST()
diff --git a/test/mppa/interop/ll_multillargs.c b/test/mppa/interop/ll_multillargs.c
new file mode 100644
index 00000000..edb03b12
--- /dev/null
+++ b/test/mppa/interop/ll_multillargs.c
@@ -0,0 +1,7 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(long long)
+ c = ll_multillargs(a, b, a-b, a+b);
+END_TEST()
+
diff --git a/test/mppa/interop/ll_onellarg.c b/test/mppa/interop/ll_onellarg.c
new file mode 100644
index 00000000..0d182166
--- /dev/null
+++ b/test/mppa/interop/ll_onellarg.c
@@ -0,0 +1,7 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(long long)
+ c = ll_onellarg(a);
+END_TEST()
+
diff --git a/test/mppa/interop/ll_void.c b/test/mppa/interop/ll_void.c
new file mode 100644
index 00000000..fa350c9b
--- /dev/null
+++ b/test/mppa/interop/ll_void.c
@@ -0,0 +1,7 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(long long)
+ c = ll_void();
+ c += a;
+END_TEST()
diff --git a/test/mppa/interop/void_void.c b/test/mppa/interop/void_void.c
new file mode 100644
index 00000000..e729edb2
--- /dev/null
+++ b/test/mppa/interop/void_void.c
@@ -0,0 +1,7 @@
+#include "framework.h"
+#include "common.h"
+
+BEGIN_TEST(long long)
+ void_void();
+ c = a;
+END_TEST()