aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
commit1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68 (patch)
tree210ffc156c83f04fb0c61a40b4f9037d7ba8a7e1 /test/regression
parent222c9047d61961db9c6b19fed5ca49829223fd33 (diff)
parent12be46d59a2483a10d77fa8ee67f7e0ca1bd702f (diff)
downloadcompcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.tar.gz
compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.zip
Merge branch 'mppa-cse2' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa-work
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/Makefile17
-rw-r--r--test/regression/Results/varargs2-mppa_k1c11
-rw-r--r--test/regression/builtins-mppa_k1c.c72
-rw-r--r--test/regression/extasm.c1
-rw-r--r--test/regression/packedstruct1.c38
-rw-r--r--test/regression/varargs2.c16
6 files changed, 131 insertions, 24 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile
index 8e8d8762..3447d6a5 100644
--- a/test/regression/Makefile
+++ b/test/regression/Makefile
@@ -10,7 +10,7 @@ LIBS=$(LIBMATH)
# Can run, both in compiled mode and in interpreter mode,
# and have reference output in Results
-TESTS=int32 int64 floats floats-basics floats-lit \
+TESTS?=int32 int64 floats floats-basics floats-lit \
expr1 expr6 funptr2 initializers initializers2 initializers3 \
volatile1 volatile2 volatile3 volatile4 \
funct3 expr5 struct7 struct8 struct11 struct12 casts1 casts2 char1 \
@@ -20,15 +20,24 @@ TESTS=int32 int64 floats floats-basics floats-lit \
# Can run, but only in compiled mode, and have reference output in Results
-TESTS_COMP=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \
+TESTS_COMP?=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \
bitfields5 bitfields6 bitfields7 bitfields8 \
- builtins-$(ARCH) packedstruct1 packedstruct2 alignas \
- varargs1 varargs2 varargs3 sections alias aligned
+ builtins-$(ARCH) alignas \
+ varargs1 varargs2 varargs3 sections alias aligned\
+ packedstruct1 packedstruct2
+
+ifeq ($(ARCH),mppa_k1c)
+ TESTS_COMP:=$(filter-out packedstruct1,$(TESTS_COMP))
+ TESTS_COMP:=$(filter-out packedstruct2,$(TESTS_COMP))
+endif
# Can run, both in compiled mode and in interpreter mode,
# but produce processor-dependent results, so no reference output in Results
TESTS_DIFF=NaNs
+ifeq ($(ARCH),mppa_k1c)
+ TESTS_DIFF:=$(filter-out NaNs,$(TESTS_DIFF))
+endif
# Other tests: should compile to .s without errors (but expect warnings)
diff --git a/test/regression/Results/varargs2-mppa_k1c b/test/regression/Results/varargs2-mppa_k1c
new file mode 100644
index 00000000..f954927e
--- /dev/null
+++ b/test/regression/Results/varargs2-mppa_k1c
@@ -0,0 +1,11 @@
+An int: 42
+A long long: 123456789012345
+A string: Hello world
+A double: 3.141592654
+A mixture: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746
+Twice: -1 1.23
+Twice: -1 1.23
+With va_copy: -1 1.23
+With va_copy: -1 1.23
+With extra args: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746
+va_list compatibility: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746
diff --git a/test/regression/builtins-mppa_k1c.c b/test/regression/builtins-mppa_k1c.c
new file mode 100644
index 00000000..cbf51387
--- /dev/null
+++ b/test/regression/builtins-mppa_k1c.c
@@ -0,0 +1,72 @@
+/* Fun with builtins */
+
+#include <stdio.h>
+#include <math.h>
+
+char * check_relative_error(double exact, double actual, double precision)
+{
+ double relative_error = (actual - exact) / exact;
+ return fabs(relative_error) <= precision ? "OK" : "ERROR";
+}
+
+//unsigned int x = 0x12345678;
+//unsigned int y = 0xDEADBEEF;
+//unsigned long long xx = 0x1234567812345678ULL;
+//double a = 3.14159;
+//double b = 2.718;
+//double c = 1.414;
+//unsigned short s = 0x1234;
+
+int main(int argc, char ** argv)
+{
+ unsigned z;
+
+ //printf("mulhw(%x, %x) = %x\n", x, y, __builtin_mulhw(x, y));
+ //printf("mulhwu(%x, %x) = %x\n", x, y, __builtin_mulhwu(x, y));
+ //printf("clz(%x) = %d\n", x, __builtin_clz(x));
+ //printf("clzll(%llx) = %d\n", (unsigned long long) x, __builtin_clzll(x));
+ //printf("clzll(%llx) = %d\n", xx, __builtin_clzll(xx));
+ //z = __builtin_bswap(x);
+ //printf("clzll(%lx) = %d\n", z, __builtin_clzll(z));
+ //printf("bswap(%x) = %x\n", x, __builtin_bswap(x));
+ //printf("bswap16(%x) = %x\n", s, __builtin_bswap16(s));
+
+ //printf("fmadd(%f, %f, %f) = %f\n", a, b, c, __builtin_fmadd(a, b, c));
+ //printf("fmsub(%f, %f, %f) = %f\n", a, b, c, __builtin_fmsub(a, b, c));
+ //printf("fabs(%f) = %f\n", a, __builtin_fabs(a));
+ //printf("fabs(%f) = %f\n", -a, __builtin_fabs(-a));
+ //printf("fsqrt(%f) = %f\n", a, __builtin_fsqrt(a));
+ //printf("frsqrte(%f) = %s\n",
+ // a, check_relative_error(1.0 / sqrt(a), __builtin_frsqrte(a), 1./32.));
+ //printf("fres(%f) = %s\n",
+ // a, check_relative_error(1.0 / a, __builtin_fres(a), 1./256.));
+ //printf("fsel(%f, %f, %f) = %f\n", a, b, c, __builtin_fsel(a, b, c));
+ //printf("fsel(%f, %f, %f) = %f\n", -a, b, c, __builtin_fsel(-a, b, c));
+ //printf("fcti(%f) = %d\n", a, __builtin_fcti(a));
+ //printf("fcti(%f) = %d\n", b, __builtin_fcti(b));
+ //printf("fcti(%f) = %d\n", c, __builtin_fcti(c));
+ //__builtin_eieio();
+ //__builtin_sync();
+ //__builtin_isync();
+ //printf("isel(%d, %d, %d) = %d\n", 0, x, y, __builtin_isel(0, x, y));
+ //printf("isel(%d, %d, %d) = %d\n", 42, x, y, __builtin_isel(42, x, y));
+ //printf ("read_16_rev = %x\n", __builtin_read16_reversed(&s));
+ //printf ("read_32_rev = %x\n", __builtin_read32_reversed(&y));
+ //__builtin_write16_reversed(&s, 0x789A);
+ //printf ("after write_16_rev: %x\n", s);
+ //__builtin_write32_reversed(&y, 0x12345678);
+ //printf ("after write_32_rev: %x\n", y);
+ //y = 0;
+ //__builtin_write32_reversed(&y, 0x12345678);
+ //printf ("CSE write_32_rev: %s\n", y == 0x78563412 ? "ok" : "ERROR");
+ ///* Make sure that ignoring the result of a builtin
+ // doesn't cause an internal error */
+ //(void) __builtin_bswap(x);
+ //(void) __builtin_fsqrt(a);
+ return 0;
+}
+
+
+
+
+
diff --git a/test/regression/extasm.c b/test/regression/extasm.c
index 297178d1..352b930b 100644
--- a/test/regression/extasm.c
+++ b/test/regression/extasm.c
@@ -24,6 +24,7 @@ int clobbers(int x, int z)
|| (defined(ARCH_riscV) && defined(MODEL_64)) \
|| (defined(ARCH_powerpc) && defined(MODEL_ppc64)) \
|| (defined(ARCH_powerpc) && defined(MODEL_e5500)) \
+ || (defined(ARCH_mppa_k1c) && defined(MODEL_64)) \
|| defined(ARCH_aarch64)
#define SIXTYFOUR
#else
diff --git a/test/regression/packedstruct1.c b/test/regression/packedstruct1.c
index 5d3e7124..ac68c698 100644
--- a/test/regression/packedstruct1.c
+++ b/test/regression/packedstruct1.c
@@ -2,8 +2,8 @@
#include <stdio.h>
-/* offsetof is the offset computed by the verified front-end (cfrontend/) */
-#define offsetof(s,f) (int)&(((struct s *)0)->f)
+/* offsetOf is the offset computed by the verified front-end (cfrontend/) */
+#define offsetOf(s,f) (int)&(((struct s *)0)->f)
/* boffsetof is the offset computed by the elaborator (cparser/) */
#define boffsetof(s,f) (int)__builtin_offsetof(struct s, f)
@@ -23,9 +23,9 @@ void test1(void)
struct s1 s1;
printf("sizeof(struct s1) = %d\n", szof(s1));
printf("precomputed sizeof(struct s1) = %d\n", bszof(s1));
- printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
- offsetof(s1,x), offsetof(s1,y), offsetof(s1,z));
- printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
+ printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
+ offsetOf(s1,x), offsetOf(s1,y), offsetOf(s1,z));
+ printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
boffsetof(s1,x), boffsetof(s1,y), boffsetof(s1,z));
s1.x = 123; s1.y = -456; s1.z = 3.14159;
printf("s1 = {x = %d, y = %d, z = %.5f}\n\n", s1.x, s1.y, s1.z);
@@ -44,9 +44,9 @@ void test2(void)
printf("sizeof(struct s2) = %d\n", szof(s2));
printf("precomputed sizeof(struct s2) = %d\n", bszof(s2));
printf("&s2 mod 16 = %d\n", ((int) &s2) & 0xF);
- printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
- offsetof(s2,x), offsetof(s2,y), offsetof(s2,z));
- printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
+ printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
+ offsetOf(s2,x), offsetOf(s2,y), offsetOf(s2,z));
+ printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
boffsetof(s2,x), boffsetof(s2,y), boffsetof(s2,z));
s2.x = 12345; s2.y = -456; s2.z = 3.14159;
printf("s2 = {x = %d, y = %d, z = %.5f}\n\n", s2.x, s2.y, s2.z);
@@ -73,8 +73,8 @@ void test3(void)
printf("sizeof(struct s3) = %d\n", szof(s3));
printf("precomputed sizeof(struct s3) = %d\n", bszof(s3));
- printf("offsetof(s) = %d\n", offsetof(s3,s));
- printf("precomputed offsetof(s) = %d\n", boffsetof(s3,s));
+ printf("offsetOf(s) = %d\n", offsetOf(s3,s));
+ printf("precomputed offsetOf(s) = %d\n", boffsetof(s3,s));
s3.x = 123;
s3.y = 45678;
s3.z = 0x80000001U;
@@ -103,9 +103,9 @@ void test4(void)
printf("sizeof(struct s4) = %d\n", szof(s4));
printf("precomputed sizeof(struct s4) = %d\n", bszof(s4));
- printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
- offsetof(s4,x), offsetof(s4,y), offsetof(s4,z));
- printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
+ printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
+ offsetOf(s4,x), offsetOf(s4,y), offsetOf(s4,z));
+ printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
boffsetof(s4,x), boffsetof(s4,y), boffsetof(s4,z));
s4.x = 123; s4.y = -456; s4.z = 3.14159;
printf("s4 = {x = %d, y = %d, z = %.5f}\n\n", s4.x, s4.y, s4.z);
@@ -121,9 +121,9 @@ void test5(void)
printf("sizeof(struct s5) = %d\n", szof(s5));
printf("precomputed sizeof(struct s5) = %d\n", bszof(s5));
- printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
- offsetof(s5,x), offsetof(s5,y), offsetof(s5,z));
- printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
+ printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
+ offsetOf(s5,x), offsetOf(s5,y), offsetOf(s5,z));
+ printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
boffsetof(s5,x), boffsetof(s5,y), boffsetof(s5,z));
s5.x = 123; s5.y = -456; s5.z = 3.14159;
printf("s5 = {x = %d, y = %d, z = %.5f}\n\n", s5.x, s5.y, s5.z);
@@ -139,9 +139,9 @@ void test6(void)
printf("sizeof(struct s6) = %d\n", szof(s6));
printf("precomputed sizeof(struct s6) = %d\n", bszof(s6));
- printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
- offsetof(s6,x), offsetof(s6,y), offsetof(s6,z));
- printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n",
+ printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
+ offsetOf(s6,x), offsetOf(s6,y), offsetOf(s6,z));
+ printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n",
boffsetof(s6,x), boffsetof(s6,y), boffsetof(s6,z));
s62.x = 123; s62.y = -456; s62.z = 3.14159;
printf("s62 = {x = %d, y = %d, z = %.5f}\n\n", s62.x, s62.y, s62.z);
diff --git a/test/regression/varargs2.c b/test/regression/varargs2.c
index b96d1940..84860ef3 100644
--- a/test/regression/varargs2.c
+++ b/test/regression/varargs2.c
@@ -115,15 +115,27 @@ void printf_compat(const char * fmt, ...)
}
/* The test harness */
-
int main()
{
miniprintf("An int: %d\n", 42);
miniprintf("A long long: %l\n", 123456789012345LL);
miniprintf("A string: %s\n", "Hello world");
miniprintf("A double: %e\n", 3.141592654);
+
+#ifndef __K1C__
miniprintf("A small struct: %y\n", (struct Y) { 'x', 12 });
miniprintf("A bigger struct: %z\n", (struct Z) { 123, 456, 789 });
+#endif
+
+#ifdef __K1C__
+ miniprintf("A mixture: %c & %s & %d & %l & %e & %f\n",
+ 'x',
+ "Hello, world!",
+ 42,
+ 123456789012345LL,
+ 3.141592654,
+ 2.71828182);
+#else
miniprintf("A mixture: %c & %s & %y & %d & %l & %e & %f\n",
'x',
"Hello, world!",
@@ -132,6 +144,8 @@ int main()
123456789012345LL,
3.141592654,
2.71828182);
+#endif
+
miniprintf2("Twice: %d %e\n", -1, 1.23);
miniprintf3("With va_copy: %d %e\n", -1, 1.23);
miniprintf_extra(0, 1, 2, 3, 4, 5, 6, 7,