summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason <jason@openbsd.org>2003-07-13 06:33:23 +0000
committerjason <jason@openbsd.org>2003-07-13 06:33:23 +0000
commitd8696cd4bb0cc0315d270955f1e6bde6bd0f8702 (patch)
treec0fd2a167540b16749e8c6b55a119c0d7734e2e5
parentmy loathing for gcc runneth over: another case where a bitfield isn't (diff)
downloadwireguard-openbsd-d8696cd4bb0cc0315d270955f1e6bde6bd0f8702.tar.xz
wireguard-openbsd-d8696cd4bb0cc0315d270955f1e6bde6bd0f8702.zip
regression for the sign extended immediate variant (which helped me find ANOTHER bug).
-rw-r--r--regress/sys/arch/sparc64/emul-ldqstq/Makefile4
-rw-r--r--regress/sys/arch/sparc64/emul-ldqstq/simm13/Makefile17
-rw-r--r--regress/sys/arch/sparc64/emul-ldqstq/simm13/genasm.pl47
-rw-r--r--regress/sys/arch/sparc64/emul-ldqstq/simm13/genc.pl154
4 files changed, 220 insertions, 2 deletions
diff --git a/regress/sys/arch/sparc64/emul-ldqstq/Makefile b/regress/sys/arch/sparc64/emul-ldqstq/Makefile
index fd3b9866067..d012da6270c 100644
--- a/regress/sys/arch/sparc64/emul-ldqstq/Makefile
+++ b/regress/sys/arch/sparc64/emul-ldqstq/Makefile
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile,v 1.2 2003/07/12 06:31:49 jason Exp $
+# $OpenBSD: Makefile,v 1.3 2003/07/13 06:33:23 jason Exp $
-SUBDIR=asi badfreg goodfreg
+SUBDIR=asi badfreg goodfreg simm13
.include <bsd.subdir.mk>
diff --git a/regress/sys/arch/sparc64/emul-ldqstq/simm13/Makefile b/regress/sys/arch/sparc64/emul-ldqstq/simm13/Makefile
new file mode 100644
index 00000000000..4fa30399a6a
--- /dev/null
+++ b/regress/sys/arch/sparc64/emul-ldqstq/simm13/Makefile
@@ -0,0 +1,17 @@
+# $OpenBSD: Makefile,v 1.1 2003/07/13 06:33:24 jason Exp $
+
+PROG=simm13
+NOMAN=
+SRCS=simm13_asm.S simm13.c fpregs.S
+CFLAGS+=-I${.CURDIR}/../goodfreg -O0 -g
+CLEANFILES+=simm13_asm.S simm13.c
+
+.PATH: ${.CURDIR}/../goodfreg
+
+simm13_asm.S: ${.CURDIR}/genasm.pl
+ perl ${.CURDIR}/genasm.pl > $@
+
+simm13.c: ${.CURDIR}/genc.pl
+ perl ${.CURDIR}/genc.pl > $@
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/arch/sparc64/emul-ldqstq/simm13/genasm.pl b/regress/sys/arch/sparc64/emul-ldqstq/simm13/genasm.pl
new file mode 100644
index 00000000000..f3d4b488539
--- /dev/null
+++ b/regress/sys/arch/sparc64/emul-ldqstq/simm13/genasm.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2003 Jason L. Wright (jason@thought.net)
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+print "#include <machine/asm.h>\n";
+print "#include <machine/ctlreg.h>\n\n";
+
+for ($i = -4096; $i <= 4095; $i++) {
+ if ($i < 0) {
+ $name = -$i;
+ $name = "_$name";
+ } else {
+ $name = $i;
+ }
+ print "ENTRY(simm13_ldq_$name)\n";
+ print " sub %o0, $i, %o0\n";
+ print " retl\n";
+ print " ldq [%o0 + $i], %f0\n\n";
+
+ print "ENTRY(simm13_stq_$name)\n";
+ print " sub %o0, $i, %o0\n";
+ print " retl\n";
+ print " stq %f0, [%o0 + $i]\n\n";
+}
diff --git a/regress/sys/arch/sparc64/emul-ldqstq/simm13/genc.pl b/regress/sys/arch/sparc64/emul-ldqstq/simm13/genc.pl
new file mode 100644
index 00000000000..258b95c008b
--- /dev/null
+++ b/regress/sys/arch/sparc64/emul-ldqstq/simm13/genc.pl
@@ -0,0 +1,154 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2003 Jason L. Wright (jason@thought.net)
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+print <<MY__EOF
+
+#include <stdio.h>
+#include <err.h>
+#include "fpregs.h"
+
+struct fpquad {
+ u_int32_t x1;
+ u_int32_t x2;
+ u_int32_t x3;
+ u_int32_t x4;
+};
+
+int
+compare_regs(union fpregs *fr1, union fpregs *fr2)
+{
+ return (memcmp(fr1, fr2, sizeof(*fr2)));
+}
+
+void
+dump_reg(union fpregs *fr)
+{
+ int i;
+
+ for (i = 0; i < 64; i++) {
+ if ((i & 3) == 0)
+ printf("f%-2d:", i);
+ printf(" %08x", fr->f_reg32[i]);
+ if ((i & 3) == 3)
+ printf("\n");
+ }
+}
+
+void
+dump_regs(union fpregs *fr1, union fpregs *fr2, union fpregs *fr3)
+{
+ printf("BEFORE ASM\n");
+ dump_reg(fr1);
+ printf("AFTER ASM\n");
+ dump_reg(fr2);
+ printf("MANUAL\n");
+ dump_reg(fr3);
+}
+
+void
+c_ldq(union fpregs *frp, int freg, struct fpquad *q)
+{
+ frp->f_reg32[freg] = q->x1;
+ frp->f_reg32[freg + 1] = q->x2;
+ frp->f_reg32[freg + 2] = q->x3;
+ frp->f_reg32[freg + 3] = q->x4;
+}
+
+MY__EOF
+;
+for ($i = -4096; $i <= 4095; $i++) {
+ if ($i < 0) {
+ $name = -$i;
+ $name = "_$name";
+ } else {
+ $name = $i;
+ }
+ print "void simm13_ldq_$name(struct fpquad *);\n";
+ print "void simm13_stq_$name(struct fpquad *);\n";
+}
+
+print <<MY__EOF
+void
+test_asm_ldq(char *desc, void (*func)(struct fpquad *))
+{
+ union fpregs fr1, fr2, fr3;
+ struct fpquad q;
+
+ q.x1 = 0x01234567;
+ q.x2 = 0x89abcdef;
+ q.x3 = 0x55aa55aa;
+ q.x4 = 0xaaaa5555;
+
+ initfpregs(&fr1);
+ initfpregs(&fr2);
+ initfpregs(&fr3);
+
+ loadfpregs(&fr1);
+ (*func)(&q);
+ savefpregs(&fr2);
+
+ c_ldq(&fr3, 0, &q);
+
+ if (compare_regs(&fr2, &fr3)) {
+ dump_regs(&fr1, &fr2, &fr3);
+ exit(1);
+ errx(1, "%s failed", desc);
+ }
+}
+MY__EOF
+;
+$j = 0;
+for ($i = -4096; $i <= 4095; $i++) {
+ if ($i < 0) {
+ $name = -$i;
+ $name = "_$name";
+ } else {
+ $name = $i;
+ }
+ if (($i % 256) == 0) {
+ print "void\n";
+ print "test_$j(void) {\n";
+ $j++;
+ }
+ print " test_asm_ldq(\"ldq [%o + $i], %f0\", simm13_ldq_$name);\n";
+ if (($i % 256) == 255) {
+ print "}\n";
+ }
+}
+
+print <<MY__EOF
+int
+main(void)
+{
+MY__EOF
+;
+
+for ($i = 0; $i < $j; $i++) {
+ print " test_$i();\n";
+}
+print " return (0);\n";
+print "}\n";