diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-04-20 14:06:21 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-04-20 14:06:21 +0200 |
commit | 168393089024b5f926836cb813fddf14e6b6e4d4 (patch) | |
tree | 5d018198dc26be847544f162b87ad3dcecbab479 /test/mppa/instr | |
parent | 633b72565b022f159526338b5bbb9fcac86dfd2b (diff) | |
parent | b3431b1d9ee5121883d307cff0b62b7e53369891 (diff) | |
download | compcert-kvx-168393089024b5f926836cb813fddf14e6b6e4d4.tar.gz compcert-kvx-168393089024b5f926836cb813fddf14e6b6e4d4.zip |
Merge remote-tracking branch 'origin/mppa-work' into mppa-fast-div
(unfinished)
Diffstat (limited to 'test/mppa/instr')
-rw-r--r-- | test/mppa/instr/Makefile | 78 | ||||
-rw-r--r-- | test/mppa/instr/builtin32.c | 12 | ||||
-rw-r--r-- | test/mppa/instr/builtin64.c | 17 | ||||
-rw-r--r-- | test/mppa/instr/i32.c | 68 | ||||
-rw-r--r-- | test/mppa/instr/i64.c | 62 |
5 files changed, 220 insertions, 17 deletions
diff --git a/test/mppa/instr/Makefile b/test/mppa/instr/Makefile index ea86114c..37f7d0ab 100644 --- a/test/mppa/instr/Makefile +++ b/test/mppa/instr/Makefile @@ -1,11 +1,15 @@ -K1CC ?= k1-mbr-gcc +SHELL := /bin/bash + +K1CC ?= k1-cos-gcc CC ?= gcc CCOMP ?= ccomp OPTIM ?= -O2 CFLAGS ?= $(OPTIM) +CCOMPFLAGS ?= $(CFLAGS) SIMU ?= k1-mppa TIMEOUT ?= --signal=SIGTERM 120s DIFF ?= python2.7 floatcmp.py -reltol .00001 +HARDRUN ?= k1-jtag-runner DIR=./ SRCDIR=$(DIR) @@ -27,10 +31,11 @@ SIMUPATH=$(shell which $(SIMU)) TESTNAMES?=$(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))) +GCC_SIMUOUT=$(addprefix $(OUTDIR)/,$(addsuffix .gcc.simu.out,$(TESTNAMES))) +CCOMP_SIMUOUT=$(addprefix $(OUTDIR)/,$(addsuffix .ccomp.simu.out,$(TESTNAMES))) +GCC_HARDOUT=$(addprefix $(OUTDIR)/,$(addsuffix .gcc.hard.out,$(TESTNAMES))) +CCOMP_HARDOUT=$(addprefix $(OUTDIR)/,$(addsuffix .ccomp.hard.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))) @@ -43,15 +48,52 @@ all: $(BIN) GREEN=\033[0;32m RED=\033[0;31m +YELLOW=\033[0;33m NC=\033[0m +.PHONY: +test: simutest + +.PHONY: +check: simucheck + .PHONY: -test: $(X86_GCC_OUT) $(GCC_OUT) +simutest: $(X86_GCC_OUT) $(GCC_SIMUOUT) @echo "Comparing x86 gcc output to k1 gcc.." + for test in $(TESTNAMES); do\ + x86out=$(OUTDIR)/$$test.x86-gcc.out;\ + gccout=$(OUTDIR)/$$test.gcc.simu.out;\ + if grep "__K1C__" -q $$test.c; then\ + printf "$(YELLOW)UNTESTED: $$test.c contains an \`#ifdef __K1C__\`\n";\ + elif $(DIFF) $$x86out $$gccout > /dev/null; test $${PIPESTATUS[0]} -ne 0; then\ + >&2 printf "$(RED)ERROR: $$x86out and $$gccout differ$(NC)\n";\ + else\ + printf "$(GREEN)GOOD: $$x86out and $$gccout concur$(NC)\n";\ + fi;\ + done + +.PHONY: +simucheck: $(GCC_SIMUOUT) $(CCOMP_SIMUOUT) + @echo "Comparing k1 gcc output to ccomp.." @for test in $(TESTNAMES); do\ + gccout=$(OUTDIR)/$$test.gcc.simu.out;\ + ccompout=$(OUTDIR)/$$test.ccomp.simu.out;\ + if $(DIFF) $$ccompout $$gccout > /dev/null; test $${PIPESTATUS[0]} -ne 0; then\ + >&2 printf "$(RED)ERROR: $$ccompout and $$gccout differ$(NC)\n";\ + else\ + printf "$(GREEN)GOOD: $$ccompout and $$gccout concur$(NC)\n";\ + fi;\ + done + +.PHONY: +hardtest: $(X86_GCC_OUT) $(GCC_HARDOUT) + @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 > /dev/null; test $${PIPESTATUS[0]} -ne 0; then\ + gccout=$(OUTDIR)/$$test.gcc.hard.out;\ + if grep "__K1C__" -q $$test.c; then\ + printf "$(YELLOW)UNTESTED: $$test.c contains an \`#ifdef __K1C__\`\n";\ + elif $(DIFF) $$x86out $$gccout > /dev/null; test $${PIPESTATUS[0]} -ne 0; then\ >&2 printf "$(RED)ERROR: $$x86out and $$gccout differ$(NC)\n";\ else\ printf "$(GREEN)GOOD: $$x86out and $$gccout concur$(NC)\n";\ @@ -59,11 +101,11 @@ test: $(X86_GCC_OUT) $(GCC_OUT) done .PHONY: -check: $(GCC_OUT) $(CCOMP_OUT) +hardcheck: $(GCC_HARDOUT) $(CCOMP_HARDOUT) @echo "Comparing k1 gcc output to ccomp.." @for test in $(TESTNAMES); do\ - gccout=$(OUTDIR)/$$test.gcc.out;\ - ccompout=$(OUTDIR)/$$test.ccomp.out;\ + gccout=$(OUTDIR)/$$test.gcc.hard.out;\ + ccompout=$(OUTDIR)/$$test.ccomp.hard.out;\ if $(DIFF) $$ccompout $$gccout > /dev/null; test $${PIPESTATUS[0]} -ne 0; then\ >&2 printf "$(RED)ERROR: $$ccompout and $$gccout differ$(NC)\n";\ else\ @@ -89,14 +131,22 @@ $(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) +$(OUTDIR)/%.gcc.simu.out: $(BINDIR)/%.gcc.bin $(SIMUPATH) @mkdir -p $(@D) ret=0; timeout $(TIMEOUT) $(SIMU) -- $< > $@ || { ret=$$?; }; echo $$ret >> $@ -$(OUTDIR)/%.ccomp.out: $(BINDIR)/%.ccomp.bin $(SIMUPATH) +$(OUTDIR)/%.ccomp.simu.out: $(BINDIR)/%.ccomp.bin $(SIMUPATH) @mkdir -p $(@D) ret=0; timeout $(TIMEOUT) $(SIMU) -- $< > $@ || { ret=$$?; }; echo $$ret >> $@ +$(OUTDIR)/%.gcc.hard.out: $(BINDIR)/%.gcc.bin $(SIMUPATH) + @mkdir -p $(@D) + ret=0; timeout $(TIMEOUT) $(HARDRUN) --exec-file=Cluster0:$< > $@ || { ret=$$?; }; echo $$ret >> $@ + +$(OUTDIR)/%.ccomp.hard.out: $(BINDIR)/%.ccomp.bin $(SIMUPATH) + @mkdir -p $(@D) + ret=0; timeout $(TIMEOUT) $(HARDRUN) --exec-file=Cluster0:$< > $@ || { ret=$$?; }; echo $$ret >> $@ + # Assembly to binary $(BINDIR)/%.x86-gcc.bin: $(ASMDIR)/%.x86-gcc.s $(LIB) $(CCPATH) @@ -109,7 +159,7 @@ $(BINDIR)/%.gcc.bin: $(ASMDIR)/%.gcc.s $(K1LIB) $(K1CCPATH) $(BINDIR)/%.ccomp.bin: $(ASMDIR)/%.ccomp.s $(K1LIB) $(CCOMPPATH) @mkdir -p $(@D) - $(CCOMP) $(CFLAGS) $(filter-out $(CCOMPPATH),$^) -o $@ + $(CCOMP) $(CCOMPFLAGS) $(filter-out $(CCOMPPATH),$^) -o $@ # Source to assembly @@ -123,4 +173,4 @@ $(ASMDIR)/%.gcc.s: $(SRCDIR)/%.c $(K1CCPATH) $(ASMDIR)/%.ccomp.s: $(SRCDIR)/%.c $(CCOMPPATH) @mkdir -p $(@D) - $(CCOMP) $(CFLAGS) -S $< -o $@ + $(CCOMP) $(CCOMPFLAGS) -S $< -o $@ diff --git a/test/mppa/instr/builtin32.c b/test/mppa/instr/builtin32.c new file mode 100644 index 00000000..c7689dc8 --- /dev/null +++ b/test/mppa/instr/builtin32.c @@ -0,0 +1,12 @@ +#include "framework.h" + +BEGIN_TEST(int) + int *ptr = &c; +#ifdef __K1C__ + int d = c; + a = __builtin_k1_alclrw(ptr); + c = d; + +#endif +END_TEST32() + diff --git a/test/mppa/instr/builtin64.c b/test/mppa/instr/builtin64.c new file mode 100644 index 00000000..dbbb1886 --- /dev/null +++ b/test/mppa/instr/builtin64.c @@ -0,0 +1,17 @@ +#include "framework.h" + +BEGIN_TEST(long long) + long long *ptr = &c; +#ifdef __K1C__ + long long d = c; + a = __builtin_k1_alclrd(ptr); + c = d; + c += a; + + c += __builtin_clzll(a); + + /* Removed the AFADDD builtin who was incorrect in CompCert, see #157 */ + // a = __builtin_k1_afaddd(ptr, a); + // a = __builtin_k1_afaddd(ptr, a); +#endif +END_TEST64() diff --git a/test/mppa/instr/i32.c b/test/mppa/instr/i32.c index c48531b1..e350931c 100644 --- a/test/mppa/instr/i32.c +++ b/test/mppa/instr/i32.c @@ -12,6 +12,14 @@ int tailsum(int a, int b){ return make(a+b); } +int fact(int a){ + int r = 1; + int i; + for (i = 1; i < a; i++) + r *= i; + return r; +} + float int2float(int v){ return v; } @@ -20,6 +28,52 @@ BEGIN_TEST(int) c = a+b; c += a&b; + /* testing if, cb version */ + if ((a & 0x1) == 1) + c += fact(1); + else + c += fact(2); + + if (a & 0x1 == 0) + c += fact(4); + else + c += fact(8); + + if (a & 0x1 == 0) + c += fact(4); + else + c += fact(8); + + b = !(a & 0x01); + if (!b) + c += fact(16); + else + c += fact(32); + + c += sum(make(a), make(b)); + c += (long long) a; + + if (0 > (a & 0x1) - 1) + c += fact(64); + else + c += fact(128); + + if (0 >= (a & 0x1)) + c += fact(256); + else + c += fact(512); + + if ((a & 0x1) > 0) + c += fact(1024); + else + c += fact(2048); + + if ((a & 0x1) - 1 >= 0) + c += fact(4096); + else + c += fact(8192); + + /* cmoved version */ if ((a & 0x1) == 1) c += 1; else @@ -30,15 +84,17 @@ BEGIN_TEST(int) else c += 8; + if (a & 0x1 == 0) + c += 4; + else + c += 8; + b = !(a & 0x01); if (!b) c += 16; else c += 32; - c += sum(make(a), make(b)); - c += (long long) a; - if (0 > (a & 0x1) - 1) c += 64; else @@ -65,6 +121,12 @@ BEGIN_TEST(int) c += (a < b); c += (a + b) / 2; c += (int) int2float(a) + (int) int2float(b) + (int) int2float(42.3); + c += (a << 4); // addx16w + c += (a << 3); // addx8w + c += (a << 2); // addx4w + c += (a << 1); // addx2w + + c += ~a & b; // andnw int j; for (j = 0 ; j < 10 ; j++) diff --git a/test/mppa/instr/i64.c b/test/mppa/instr/i64.c index 00eb159d..e869d93c 100644 --- a/test/mppa/instr/i64.c +++ b/test/mppa/instr/i64.c @@ -30,6 +30,14 @@ long long random_op(long long a, long long b){ return op(a, b); } +long fact(long a){ + long r = 1; + long i; + for (i = 1; i < a; i++) + r *= i; + return r; +} + double long2double(long v){ return v; } @@ -43,6 +51,12 @@ BEGIN_TEST(long long) c += a >> (b & 0x8LL); c += a >> (b & 0x8ULL); c += a % b; + c += (a << 4); // addx16d + c += (a << 3); // addx8d + c += (a << 2); // addx4d + c += (a << 1); // addx2d + + c += ~a & b; // andnd long long d = 3; long long (*op)(long long, long long); @@ -60,6 +74,49 @@ BEGIN_TEST(long long) c += a^b; c += (unsigned int) a; + /* Testing if, cb */ + if (0 != (a & 0x1LL)) + c += fact(1); + else + c += fact(2); + + if (0 > (a & 0x1LL)) + c += fact(4); + else + c += fact(8); + + if (0 >= (a & 0x1LL) - 1) + c += fact(16); + else + c += fact(32); + + if ((unsigned long long)(a & 0x1LL) >= 1) + c += fact(18); + else + c += fact(31); + + + if (a-41414141 > 0) + c += fact(13); + else + c += fact(31); + + if (a & 0x1LL > 0) + c += fact(64); + else + c += fact(128); + + if ((a & 0x1LL) - 1 >= 0) + c += fact(256); + else + c += fact(512); + + if (0 == (a & 0x1LL)) + c += fact(1024); + else + c += fact(2048); + + /* Testing if, cmoved */ if (0 != (a & 0x1LL)) c += 1; else @@ -75,6 +132,11 @@ BEGIN_TEST(long long) else c += 32; + if (a-41414141 > 0) + c += 13; + else + c += 31; + if (a & 0x1LL > 0) c += 64; else |