diff options
author | Stan Shebs <shebs@codesourcery.com> | 1999-04-16 01:34:07 +0000 |
---|---|---|
committer | Stan Shebs <shebs@codesourcery.com> | 1999-04-16 01:34:07 +0000 |
commit | 071ea11e85eb9d529cc5eb3d35f6247466a21b99 (patch) | |
tree | 5deda65b8d7b04d1f4cbc534c3206d328e1267ec /sim/testsuite/common | |
parent | 1730ec6b1848f0f32154277f788fb29f88d8475b (diff) | |
download | gdb-071ea11e85eb9d529cc5eb3d35f6247466a21b99.zip gdb-071ea11e85eb9d529cc5eb3d35f6247466a21b99.tar.gz gdb-071ea11e85eb9d529cc5eb3d35f6247466a21b99.tar.bz2 |
Initial creation of sourceware repository
Diffstat (limited to 'sim/testsuite/common')
-rw-r--r-- | sim/testsuite/common/.Sanitize | 44 | ||||
-rw-r--r-- | sim/testsuite/common/Make-common.in | 48 | ||||
-rw-r--r-- | sim/testsuite/common/Makefile.in | 33 | ||||
-rw-r--r-- | sim/testsuite/common/alu-n-tst.h | 87 | ||||
-rw-r--r-- | sim/testsuite/common/alu-tst.c | 100 | ||||
-rw-r--r-- | sim/testsuite/common/bits-gen.c | 259 | ||||
-rw-r--r-- | sim/testsuite/common/bits-tst.c | 347 | ||||
-rw-r--r-- | sim/testsuite/common/fpu-tst.c | 538 |
8 files changed, 0 insertions, 1456 deletions
diff --git a/sim/testsuite/common/.Sanitize b/sim/testsuite/common/.Sanitize deleted file mode 100644 index 15bdeaa..0000000 --- a/sim/testsuite/common/.Sanitize +++ /dev/null @@ -1,44 +0,0 @@ -# .Sanitize for devo/sim/testsuite - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -Make-common.in -Makefile.in -bits-gen.c -bits-tst.c -fpu-tst.c -alu-n-tst.h -alu-tst.c - -Things-to-lose: - -Do-last: - -for i in * ; do - if test ! -d $i && (grep sanitize $i > /dev/null) ; then - echo '***' Some mentions of Sanitize are still left in $i! 1>&2 - fi -done - -# End of file. diff --git a/sim/testsuite/common/Make-common.in b/sim/testsuite/common/Make-common.in deleted file mode 100644 index a51876a..0000000 --- a/sim/testsuite/common/Make-common.in +++ /dev/null @@ -1,48 +0,0 @@ -check: sanity $(TESTS) -sanity: - @eval echo AS_FOR_TARGET = $(AS_FOR_TARGET) - @eval echo LD_FOR_TARGET = $(LD_FOR_TARGET) - @eval echo RUN_FOR_TARGET = $(RUN_FOR_TARGET) - -# Rules for running the tests - -.SUFFIXES: .ok .run .hi .ko -.run.ok: - rm -f tmp-$* $*.hi - ulimit -t 5 ; \ - $(RUN_FOR_TARGET) $(RUNFLAGS_FOR_TARGET) $*.run > tmp-$* - mv tmp-$* $*.ok -.run.hi: - rm -f tmp-$* $*.hi diff-$* - ulimit -t 5 ; \ - $(RUN_FOR_TARGET) $(RUNFLAGS_FOR_TARGET) $*.run > tmp-$* - echo 'Hello World!' | diff - tmp-$* > diff-$* - cat tmp-$* diff-$* > $*.hi -.run.ko: - rm -f tmp-$* $*.ko - set +e ; \ - ulimit -t 5 ; \ - $(RUN_FOR_TARGET) $(RUNFLAGS_FOR_TARGET) $*.run > tmp-$* ; \ - if [ $$? -eq 47 ] ; then \ - exit 0 ; \ - else \ - exit 1 ; \ - fi - mv tmp-$* $*.ko - - -# Rules for building the test -# Preference is for obtaining the executable (.run) from a prebuilt image - -.SUFFIXES: .uue .s .S .run -.uue.run: - head $* | grep $*.run > /dev/null - uudecode $*.uue -.run.u: - uuencode < $*.run $*.run > $*.u -.o.run: - $(LD_FOR_TARGET) $(LDFLAGS_FOR_TARGET) -o $*.run $*.o -.s.o: - $(AS_FOR_TARGET) $(ASFLAGS_FOR_TARGET) $(srcdir)/$*.s -o $*.o -.S.o: - $(AS_FOR_TARGET) $(ASFLAGS_FOR_TARGET) $(srcdir)/$*.S -o $*.o diff --git a/sim/testsuite/common/Makefile.in b/sim/testsuite/common/Makefile.in deleted file mode 100644 index 12e0977..0000000 --- a/sim/testsuite/common/Makefile.in +++ /dev/null @@ -1,33 +0,0 @@ -CFLAGS = -Wall -Werror -I../../common -I../../../include -g - -check: bits32m0.ok bits32m31.ok bits64m0.ok bits64m63.ok - -clean: - rm -f *.o - rm -f *.ok - rm -f bits32m0 bits32m31 bits64m0 bits64m63 bits-gen - rm -f tmp-* - -.SUFIXES: .ok -%.ok: % - ./$< - touch $<.ok - -all: bits32m0 bits32m31 bits64m0 bits64m63 - -bits32m0.c: bits-gen bits-tst.c - ./bits-gen 32 0 > tmp-bits32m0.c - cat bits-tst.c >> tmp-bits32m0.c - mv tmp-bits32m0.c bits32m0.c -bits32m31.c: bits-gen bits-tst.c - ./bits-gen 32 31 > tmp-bits32m31.c - cat bits-tst.c >> tmp-bits32m31.c - mv tmp-bits32m31.c bits32m31.c -bits64m0.c: bits-gen bits-tst.c - ./bits-gen 64 0 > tmp-bits64m0.c - cat bits-tst.c >> tmp-bits64m0.c - mv tmp-bits64m0.c bits64m0.c -bits64m63.c: bits-gen bits-tst.c - ./bits-gen 64 63 > tmp-bits64m63.c - cat bits-tst.c >> tmp-bits64m63.c - mv tmp-bits64m63.c bits64m63.c diff --git a/sim/testsuite/common/alu-n-tst.h b/sim/testsuite/common/alu-n-tst.h deleted file mode 100644 index bf2635f..0000000 --- a/sim/testsuite/common/alu-n-tst.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef N -#error "N must be #defined" -#endif - -#include "sim-xcat.h" - -/* NOTE: see end of file for #undef of these macros */ -#define unsignedN XCONCAT2(unsigned,N) -#define OP_BEGIN XCONCAT3(ALU,N,_BEGIN) -#define OP_ADD XCONCAT3(ALU,N,_ADD) -#define OP_SUB XCONCAT3(ALU,N,_SUB) -#define HAD_OVERFLOW (XCONCAT3(ALU,N,_HAD_OVERFLOW) != 0) -#define HAD_CARRY (XCONCAT3(ALU,N,_HAD_CARRY) != 0) -#define RESULT XCONCAT3(ALU,N,_RESULT) -#define OVERFLOW_RESULT XCONCAT3(ALU,N,_OVERFLOW_RESULT) -#define CARRY_RESULT XCONCAT3(ALU,N,_CARRY_RESULT) -#define do_op_N XCONCAT2(do_op_,N) - -void -do_op_N (const alu_test *tst) -{ - const alu_op *op; - /* without type cast */ - { - OP_BEGIN (tst->begin); - print_hex (tst->begin, N); - for (op = tst->ops; op->op != NULL; op++) - { - printf (" %s ", op->op); - print_hex (op->arg, N); - if (strcmp (op->op, "add") == 0 - || strcmp (op->op, "ADD") == 0) - OP_ADD (op->arg); - else if (strcmp (op->op, "sub") == 0 - || strcmp (op->op, "SUB") == 0) - OP_SUB (op->arg); - else - { - printf (" -- operator unknown\n"); - abort (); - } - } - printf (" = "); - print_hex (tst->result, N); - printf (" C%d V%d", tst->carry, tst->overflow); - if (tst->carry != HAD_CARRY) - { - printf (" -- carry wrong %d", HAD_CARRY); - errors ++; - } - if (tst->overflow != HAD_OVERFLOW) - { - printf (" -- overflow wrong %d", HAD_OVERFLOW); - errors ++; - } - if ((unsignedN) CARRY_RESULT != (unsignedN) tst->result) - { - printf (" -- carry result wrong "); - print_hex (CARRY_RESULT, N); - errors ++; - } - if ((unsignedN) OVERFLOW_RESULT != (unsignedN) tst->result) - { - printf (" -- overflow result wrong "); - print_hex (OVERFLOW_RESULT, N); - errors ++; - } - if ((unsignedN) RESULT != (unsignedN) tst->result) - { - printf (" -- result wrong "); - print_hex (RESULT, N); - errors ++; - } - printf ("\n"); - } -} - -#undef OP_BEGIN -#undef OP_ADD -#undef OP_SUB -#undef HAD_OVERFLOW -#undef HAD_CARRY -#undef OVERFLOW_RESULT -#undef CARRY_RESULT -#undef RESULT -#undef do_op_N -#undef unsignedN diff --git a/sim/testsuite/common/alu-tst.c b/sim/testsuite/common/alu-tst.c deleted file mode 100644 index f03ebd5..0000000 --- a/sim/testsuite/common/alu-tst.c +++ /dev/null @@ -1,100 +0,0 @@ -#define WITH_TARGET_WORD_MSB 0 -#define WITH_TARGET_WORD_BITSIZE 64 -#define WITH_HOST_WORD_BITSIZE (sizeof (int) * 8) - -#define ASSERT(EXPRESSION) \ -{ \ - if (!(EXPRESSION)) { \ - fprintf (stderr, "%s:%d: assertion failed - %s\n", \ - __FILE__, __LINE__, #EXPRESSION); \ - abort (); \ - } \ -} - -#define SIM_BITS_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE) - -#include "sim-basics.h" -#include "sim-types.h" -#include "sim-bits.h" - -#include "sim-alu.h" - -#include <stdio.h> - - -typedef struct { - char *op; - unsigned64 arg; -} alu_op; - -typedef struct { - unsigned64 begin; - alu_op ops[3]; - unsigned64 result; - int carry; - int overflow; -} alu_test; - -#define MAX_INT16 (32767) -#define MIN_INT16 (32768) - -const alu_test alu16_tests[] = { - /* */ - { MAX_INT16, { { "ADD", 1 }, }, MIN_INT16, 0, 1, }, - { MIN_INT16, { { "ADD", -1 }, }, MAX_INT16, 1, 1, }, - { MAX_INT16, { { "ADD", MIN_INT16 }, }, -1, 0, 0, }, - { MIN_INT16, { { "ADD", MAX_INT16 }, }, -1, 0, 0, }, - { MAX_INT16, { { "ADD", MAX_INT16 }, }, MAX_INT16 * 2, 0, 1, }, - { MIN_INT16, { { "ADD", MIN_INT16 }, }, 0, 1, 1, }, - /* */ - { 0, { { "SUB", MIN_INT16 }, }, MIN_INT16, 0, 1, }, - { MAX_INT16, { { "SUB", MAX_INT16 }, }, 0, 0, 0, }, -}; - - -static void -print_hex (unsigned64 val, int nr_bits) -{ - switch (nr_bits) - { - case 16: - printf ("0x%04lx", (long) (unsigned16) (val)); - break; - case 32: - printf ("0x%08lx", (long) (unsigned32) (val)); - break; - case 64: - printf ("0x%08lx%08lx", - (long) (unsigned32) (val >> 32), - (long) (unsigned32) (val)); - default: - abort (); - } -} - - -int errors = 0; - - -#define N 16 -#include "alu-n-tst.h" -#undef N - -#if 0 -#define N 32 -#include "alu-n-tst.h" -#undef N - -#define N 64 -#include "alu-n-tst.h" -#undef N -#endif - -int -main () -{ - int i; - for (i = 0; i < sizeof (alu16_tests) / sizeof (*alu16_tests); i++) - do_op_16 (alu16_tests + i); - return (errors != 0); -} diff --git a/sim/testsuite/common/bits-gen.c b/sim/testsuite/common/bits-gen.c deleted file mode 100644 index 5feb5a0..0000000 --- a/sim/testsuite/common/bits-gen.c +++ /dev/null @@ -1,259 +0,0 @@ -/* Miscellaneous simulator utilities. - Copyright (C) 1997 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of GDB, the GNU debugger. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - - -#include <stdio.h> - - -void -gen_struct (void) -{ - printf ("\n"); - printf ("typedef struct _test_tuples {\n"); - printf (" int line;\n"); - printf (" int row;\n"); - printf (" int col;\n"); - printf (" long long val;\n"); - printf (" long long check;\n"); - printf ("} test_tuples;\n"); - printf ("\n"); - printf ("typedef struct _test_spec {\n"); - printf (" const char *file;\n"); - printf (" const char *macro;\n"); - printf (" int nr_rows;\n"); - printf (" int nr_cols;\n"); - printf (" test_tuples *tuples;\n"); - printf ("} test_spec;\n"); -} - - -void -gen_bit (int bitsize, - int msb, - const char *macro, - int nr_bits) -{ - int i; - - printf ("\n/* Test the BIT%s macro */\n", macro); - printf ("test_tuples bit%s_tuples[%d] = {\n", macro, nr_bits); - for (i = 0; i < nr_bits; i++) - { - /* compute what we think the value is */ - long long bit = 1; - if (msb == 0) - bit <<= nr_bits - i - 1; - else - bit <<= i; - if (bitsize == 32) - bit = (long) bit; - /* write it out */ - printf (" { __LINE__, "); - printf ("%d, %d, ", -1, i); - printf ("BIT%s (%2d), ", macro, i); - printf ("0x%08lx%08lxLL, ", (long) (bit >> 32), (long) bit); - printf ("},\n"); - } - printf ("};\n"); - printf ("\n"); - printf ("test_spec bit%s_test = { __FILE__, \"BIT%s\", 1, %d, bit%s_tuples, };\n", - macro, macro, nr_bits, macro); - printf ("\n"); -} - - -void -gen_mask (int bitsize, - const char *msb, - const char *macro, - int nr_bits) -{ - int l; - int h; - printf ("\n/* Test the %sMASK%s macro */\n", msb, macro); - printf ("test_tuples mask%s_tuples[%d][%d] = {\n", macro, nr_bits, nr_bits); - for (l = 0; l < nr_bits; l++) - { - printf (" {\n"); - for (h = 0; h < nr_bits; h++) - { - printf (" { __LINE__, "); - if ((strcmp (msb, "MS") == 0 && l <= h) - || (strcmp (msb, "MS") != 0 && l >= h) - || (strcmp (macro, "") == 0)) - { - /* compute the mask */ - long long mask = 0; - int b; - for (b = 0; b < nr_bits; b++) - { - long long bit = 1; - if (strcmp (msb, "MS") == 0) - { - if ((l <= b && b <= h) - || (h < l && (b <= h || b >= l))) - bit <<= (nr_bits - b - 1); - else - bit = 0; - } - else - { - if ((l >= b && b >= h) - || (h > l && (b >= h || b <= l))) - bit <<= b; - else - bit = 0; - } - mask |= bit; - } - if (bitsize == 32) - mask = (unsigned long) mask; - printf ("%d, %d, ", l, h); - printf ("%sMASK%s (%2d, %2d), ", msb, macro, l, h); - printf ("0x%08lx%08lxLL, ", (long) (mask >> 32), (long) mask); - } - else - printf ("-1, -1, "); - printf ("},\n"); - } - printf (" },\n"); - } - printf ("};\n"); - printf ("\n"); - printf ("test_spec mask%s_test = { __FILE__, \"%sMASK%s\", %d, %d, &mask%s_tuples[0][0], };\n", - macro, msb, macro, nr_bits, nr_bits, macro); - printf ("\n"); -} - - -void -usage (int reason) -{ - fprintf (stderr, "Usage:\n"); - fprintf (stderr, " bits-gen <nr-bits> <msb>\n"); - fprintf (stderr, "Generate a test case for the simulator bit manipulation code\n"); - fprintf (stderr, " <nr-bits> = { 32 | 64 }\n"); - fprintf (stderr, " <msb> = { 0 | { 31 | 63 } }\n"); - - switch (reason) - { - case 1: fprintf (stderr, "Wrong number of arguments\n"); - break; - case 2: - fprintf (stderr, "Invalid <nr-bits> argument\n"); - break; - case 3: - fprintf (stderr, "Invalid <msb> argument\n"); - break; - default: - } - - exit (1); -} - - - -int -main (argc, argv) - int argc; - char **argv; -{ - int bitsize; - int msb; - char *ms; - - /* parse the only argument */ - if (argc != 3) - usage (1); - if (strcmp (argv [1], "32") == 0) - bitsize = 32; - else if (strcmp (argv [1], "64") == 0) - bitsize = 64; - else - usage (2); - if (strcmp (argv [2], "0") == 0) - msb = 0; - else if (strcmp (argv [2], "31") == 0 && bitsize == 32) - msb = 31; - else if (strcmp (argv [2], "63") == 0 && bitsize == 64) - msb = 63; - else - usage (3); - if (msb == 0) - ms = "MS"; - else - ms = "LS"; - - printf ("#define WITH_TARGET_WORD_BITSIZE %d\n", bitsize); - printf ("#define WITH_TARGET_WORD_MSB %d\n", msb); - printf ("#define WITH_HOST_WORD_BITSIZE %d\n", sizeof (int) * 8); - printf ("\n"); - printf ("#define SIM_BITS_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE)\n"); - printf ("\n"); - printf ("#define ASSERT(X) do { if (!(X)) abort(); } while (0)\n"); - printf ("\n"); - printf ("#include \"sim-basics.h\"\n"); - printf ("#include \"sim-types.h\"\n"); - printf ("#include \"sim-bits.h\"\n"); - - gen_struct (); - - - - printf ("#define DO_BIT_TESTS\n"); - gen_bit ( 4, msb, "4", 4); - gen_bit ( 5, msb, "5", 5); - gen_bit ( 8, msb, "8", 8); - gen_bit (10, msb, "10", 10); - gen_bit (16, msb, "16", 16); - gen_bit (32, msb, "32", 32); - gen_bit (64, msb, "64", 64); - gen_bit (bitsize, msb, "", 64); - - printf ("test_spec *(bit_tests[]) = {\n"); - printf (" &bit4_test,\n"); - printf (" &bit5_test,\n"); - printf (" &bit8_test,\n"); - printf (" &bit10_test,\n"); - printf (" &bit16_test,\n"); - printf (" &bit32_test,\n"); - printf (" &bit64_test,\n"); - printf (" &bit_test,\n"); - printf (" 0,\n"); - printf ("};\n\n"); - - - - printf ("#define DO_MASK_TESTS\n"); - gen_mask (16, ms, "16", 16); - gen_mask (32, ms, "32", 32); - gen_mask (64, ms, "64", 64); - gen_mask (bitsize, ms, "", 64); - - printf ("test_spec *(mask_tests[]) = {\n"); - printf (" &mask16_test,\n"); - printf (" &mask32_test,\n"); - printf (" &mask64_test,\n"); - printf (" &mask_test,\n"); - printf (" 0,\n"); - printf ("};\n\n"); - - return 0; -} diff --git a/sim/testsuite/common/bits-tst.c b/sim/testsuite/common/bits-tst.c deleted file mode 100644 index cb33544..0000000 --- a/sim/testsuite/common/bits-tst.c +++ /dev/null @@ -1,347 +0,0 @@ -# 2 "bits-tst.c" - -/* Drive the bit test routines */ - - -long long -calc (const char *call, - long long val, - int row, - int col) -{ - if (strcmp (call, "MASK") == 0) - return MASKED (val, row, col); - if (strcmp (call, "MASK16") == 0) - return MASKED16 (val, row, col); - if (strcmp (call, "MASK32") == 0) - return MASKED32 (val, row, col); - if (strcmp (call, "MASK64") == 0) - return MASKED64 (val, row, col); - - if (strcmp (call, "EXTRACT") == 0) - return EXTRACTED (val, row, col); - if (strcmp (call, "EXTRACT16") == 0) - return EXTRACTED16 (val, row, col); - if (strcmp (call, "EXTRACT32") == 0) - return EXTRACTED32 (val, row, col); - if (strcmp (call, "EXTRACT64") == 0) - return EXTRACTED64 (val, row, col); - - if (strcmp (call, "LSEXTRACT") == 0) - return LSEXTRACTED (val, row, col); - if (strcmp (call, "LSEXTRACT16") == 0) - return LSEXTRACTED16 (val, row, col); - if (strcmp (call, "LSEXTRACT32") == 0) - return LSEXTRACTED32 (val, row, col); - if (strcmp (call, "LSEXTRACT64") == 0) - return LSEXTRACTED64 (val, row, col); - - if (strcmp (call, "MSEXTRACT") == 0) - return MSEXTRACTED (val, row, col); - if (strcmp (call, "MSEXTRACT16") == 0) - return MSEXTRACTED16 (val, row, col); - if (strcmp (call, "MSEXTRACT32") == 0) - return MSEXTRACTED32 (val, row, col); - if (strcmp (call, "MSEXTRACT64") == 0) - return MSEXTRACTED64 (val, row, col); - - if (strcmp (call, "INSERT") == 0) - return INSERTED (val, row, col); - if (strcmp (call, "INSERT16") == 0) - return INSERTED16 (val, row, col); - if (strcmp (call, "INSERT32") == 0) - return INSERTED32 (val, row, col); - if (strcmp (call, "INSERT64") == 0) - return INSERTED64 (val, row, col); - - if (strcmp (call, "LSINSERT") == 0) - return LSINSERTED (val, row, col); - if (strcmp (call, "LSINSERT16") == 0) - return LSINSERTED16 (val, row, col); - if (strcmp (call, "LSINSERT32") == 0) - return LSINSERTED32 (val, row, col); - if (strcmp (call, "LSINSERT64") == 0) - return LSINSERTED64 (val, row, col); - - if (strcmp (call, "MSINSERT") == 0) - return MSINSERTED (val, row, col); - if (strcmp (call, "MSINSERT16") == 0) - return MSINSERTED16 (val, row, col); - if (strcmp (call, "MSINSERT32") == 0) - return MSINSERTED32 (val, row, col); - if (strcmp (call, "MSINSERT64") == 0) - return MSINSERTED64 (val, row, col); - - if (strcmp (call, "MSMASK") == 0) - return MSMASKED (val, row, col); - if (strcmp (call, "MSMASK16") == 0) - return MSMASKED16 (val, row, col); - if (strcmp (call, "MSMASK32") == 0) - return MSMASKED32 (val, row, col); - if (strcmp (call, "MSMASK64") == 0) - return MSMASKED64 (val, row, col); - - if (strcmp (call, "LSMASK") == 0) - return LSMASKED (val, row, col); - if (strcmp (call, "LSMASK16") == 0) - return LSMASKED16 (val, row, col); - if (strcmp (call, "LSMASK32") == 0) - return LSMASKED32 (val, row, col); - if (strcmp (call, "LSMASK64") == 0) - return LSMASKED64 (val, row, col); - - if (strcmp (call, "ROT16") == 0) - return ROT16 (val, col); - if (strcmp (call, "ROT32") == 0) - return ROT32 (val, col); - if (strcmp (call, "ROT64") == 0) - return ROT64 (val, col); - - if (strcmp (call, "SEXT16") == 0) - return SEXT16 (val, col); - if (strcmp (call, "SEXT32") == 0) - return SEXT32 (val, col); - if (strcmp (call, "SEXT64") == 0) - return SEXT64 (val, col); - if (strcmp (call, "SEXT") == 0) - return SEXT (val, col); - - if (strcmp (call, "LSSEXT16") == 0) - return LSSEXT16 (val, col); - if (strcmp (call, "LSSEXT32") == 0) - return LSSEXT32 (val, col); - if (strcmp (call, "LSSEXT64") == 0) - return LSSEXT64 (val, col); - if (strcmp (call, "LSSEXT") == 0) - return LSSEXT (val, col); - - if (strcmp (call, "MSSEXT16") == 0) - return MSSEXT16 (val, col); - if (strcmp (call, "MSSEXT32") == 0) - return MSSEXT32 (val, col); - if (strcmp (call, "MSSEXT64") == 0) - return MSSEXT64 (val, col); - if (strcmp (call, "MSSEXT") == 0) - return MSSEXT (val, col); - - else - { - fprintf (stderr, "Unknown call passed to calc (%s, 0x%08lx%08lx, %d, %d)\n", - call, (long)(val >> 32), (long)val, row, col); - abort (); - return val; - } -} - - -int -check_sext (int nr_bits, - const char *sexted, - const char *masked, - const char *msmasked) -{ - int errors = 0; - int col; - for (col = 0; col < nr_bits; col ++) - { - long long mask = calc (masked, -1, col, col); - long long msmask = calc (msmasked, -1, - 0, (WITH_TARGET_WORD_MSB ? nr_bits - col - 1 : col)); - long long sext = calc (sexted, mask, -1, col); - long long mask_1 = mask >> 1; - long long sext_1 = calc (sexted, mask_1, -1, col); - if (mask_1 != sext_1) - { - fprintf (stderr, "%s:%d: ", __FILE__, __LINE__); - fprintf (stderr, " %s(0x%08lx%08lx,%d) != 0x%08lx%08lx\n", - sexted, - (long)(mask_1 >> 32), (long)mask_1, - col, - (long)(sext_1 >> 32), (long)sext_1); - errors ++; - } - if (sext != msmask) - { - fprintf (stderr, "%s:%d: ", __FILE__, __LINE__); - fprintf (stderr, " %s(0x%08lx%08lx,%d) == 0x%08lx%08lx wrong, != 0x%08lx%08lx\n", - sexted, (long)(mask >> 32), (long)mask, col, - (long)(sext >> 32), (long)sext, - (long)(msmask >> 32), (long)msmask); - errors ++; - } - - } - return errors; -} - - -int -check_rot (int nr_bits, - const char *roted, - const char *masked) -{ - int errors = 0; - int row; - int col; - for (row = 0; row < nr_bits; row++) - for (col = 0; col < nr_bits; col++) - if ((WITH_TARGET_WORD_MSB == 0 && row <= col) - || (WITH_TARGET_WORD_MSB != 0 && row >= col)) - { - long long mask = calc (masked, -1, row, col); - int shift; - for (shift = -nr_bits + 1; shift < nr_bits; shift ++) - { - long long rot = calc (roted, mask, -1, shift); - long long urot = calc (roted, rot, -1, -shift); - if (mask != urot - || (shift == 0 && rot != mask) - || (shift != 0 && rot == mask && abs(row - col) != (nr_bits - 1))) - { - fprintf (stderr, "%s:%d: ", __FILE__, __LINE__); - fprintf (stderr, " %s(%s(0x%08lx%08lx,%d) == 0x%08lx%08lx, %d) failed\n", - roted, roted, - (long)(mask >> 32), (long)mask, shift, - (long)(urot >> 32), (long)urot, -shift); - errors ++; - } - } - } - return errors; -} - - -int -check_extract (int nr_bits, - const char *extracted, - const char *inserted, - const char *masked) -{ - int errors = 0; - int row; - int col; - for (row = 0; row < nr_bits; row++) - for (col = 0; col < nr_bits; col ++) - if ((WITH_TARGET_WORD_MSB == 0 && row <= col) - || (WITH_TARGET_WORD_MSB != 0 && row >= col)) - { - long long mask = calc (masked, -1, row, col); - long long extr = calc (extracted, mask, row, col); - long long inst = calc (inserted, extr, row, col); - if (mask != inst) - { - fprintf (stderr, "%s:%d: ", __FILE__, __LINE__); - fprintf (stderr, " %s(%d,%d)=0x%08lx%08lx -> %s=0x%08lx%08lx -> %s=0x%08lx%08lx failed\n", - masked, row, col, (long)(mask >> 32), (long)mask, - extracted, (long)(extr >> 32), (long)extr, - inserted, (long)(inst >> 32), (long)inst); - errors ++; - } - } - return errors; -} - - -int -check_bits (int call, - test_spec **tests) -{ - int r; - int c; - int errors = 0; - while (*tests != NULL) - { - int nr_rows = (*tests)->nr_rows; - int nr_cols = (*tests)->nr_cols; - test_tuples *tuples = (*tests)->tuples; - for (r = 0; r < nr_rows; r++) - for (c = 0; c < nr_cols; c++) - { - int i = r * nr_rows + c; - test_tuples *tuple = &tuples[i]; - if (tuple->col >= 0) - { - long long val = (!call ? tuple->val : calc ((*tests)->macro, -1, - tuple->row, tuple->col)); - long long check = tuple->check; - if (val != check) - { - fprintf (stderr, "%s:%d:", (*tests)->file, tuple->line); - fprintf (stderr, " %s", (*tests)->macro); - if (tuple->row >= 0) - fprintf (stderr, " (%d, %d)", tuple->row, tuple->col); - else - fprintf (stderr, " (%d)", tuple->col); - fprintf (stderr, " == 0x%08lx%08lx wrong, != 0x%08lx%08lx)\n", - (long) (val >> 32), (long) val, - (long) (check >> 32), (long) check); - errors ++; - } - } - } - tests ++; - } - return errors; -} - - -int -main (argc, argv) - int argc; - char **argv; -{ - int errors = 0; - - -#if defined (DO_BIT_TESTS) - printf ("Checking BIT*\n"); - errors += check_bits (0, bit_tests); -#endif - - -#if defined (DO_MASK_TESTS) - printf ("Checking MASK*\n"); - errors += check_bits (0, mask_tests); - - printf ("Checking MASKED*\n"); - errors += check_bits (1, mask_tests); -#endif - - -#if defined (DO_LSMASK_TESTS) - printf ("Checking LSMASK*\n"); - errors += check_bits (0, lsmask_tests); - - printf ("Checking LSMASKED*\n"); - errors += check_bits (1, lsmask_tests); -#endif - - -#if defined (DO_MSMASK_TESTS) - printf ("Checking MSMASK*\n"); - errors += check_bits (0, msmask_tests); - - printf ("Checking MSMASKED*\n"); - errors += check_bits (1, msmask_tests); -#endif - - - printf ("Checking EXTRACTED*\n"); - errors += check_extract (16, "EXTRACT16", "INSERT16", "MASK16"); - errors += check_extract (32, "EXTRACT32", "INSERT32", "MASK32"); - errors += check_extract (64, "EXTRACT64", "INSERT64", "MASK64"); - errors += check_extract (64, "EXTRACT", "INSERT", "MASK"); - - printf ("Checking SEXT*\n"); - errors += check_sext (16, "SEXT16", "MASK16", "MSMASK16"); - errors += check_sext (32, "SEXT32", "MASK32", "MSMASK32"); - errors += check_sext (64, "SEXT64", "MASK64", "MSMASK64"); - errors += check_sext (64, "SEXT", "MASK", "MSMASK"); - - printf ("Checking ROT*\n"); - errors += check_rot (16, "ROT16", "MASK16"); - errors += check_rot (32, "ROT32", "MASK32"); - errors += check_rot (64, "ROT64", "MASK64"); - - return errors != 0; -} diff --git a/sim/testsuite/common/fpu-tst.c b/sim/testsuite/common/fpu-tst.c deleted file mode 100644 index d347e12..0000000 --- a/sim/testsuite/common/fpu-tst.c +++ /dev/null @@ -1,538 +0,0 @@ -#define ASSERT(EXPRESSION) \ -do { \ - if (!(EXPRESSION)) { \ - fprintf (stderr, "%s:%d: assertion failed - %s\n", \ - __FILE__, __LINE__, #EXPRESSION); \ - abort (); \ - } \ -} while (0) - -#define SIM_BITS_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE) - -#include "milieu.h" -#include "softfloat.h" -#include "systfloat.h" -#include "systmodes.h" - -/* #define SIM_FPU_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE) */ - - -#include "sim-bits.h" -#include "sim-fpu.h" -#include "sim-fpu.c" - - - -static int flags; - -int8 -syst_float_flags_clear () -{ - int old_flags = 0; - int i = 1; - while (flags >= i) - { - switch ((sim_fpu_status) (flags & i)) - { - case sim_fpu_status_denorm: - break; - case sim_fpu_status_invalid_snan: - case sim_fpu_status_invalid_qnan: - case sim_fpu_status_invalid_isi: - case sim_fpu_status_invalid_idi: - case sim_fpu_status_invalid_zdz: - case sim_fpu_status_invalid_imz: - case sim_fpu_status_invalid_cvi: - case sim_fpu_status_invalid_cmp: - case sim_fpu_status_invalid_sqrt: - old_flags |= float_flag_invalid; /* v */ - break; - case sim_fpu_status_inexact: - old_flags |= float_flag_inexact; /* x */ - break; - case sim_fpu_status_overflow: - old_flags |= float_flag_overflow; /* o */ - break; - case sim_fpu_status_underflow: - old_flags |= float_flag_underflow; /* u */ - break; - case sim_fpu_status_invalid_div0: - old_flags |= float_flag_divbyzero; /* z */ - break; - case sim_fpu_status_rounded: - break; - } - i <<= 1; - } - flags = 0; - return old_flags; -} - - -sim_fpu_round rounding_mode; - -void -syst_float_set_rounding_mode(int8 mode) -{ - switch (mode) - { - case float_round_nearest_even: - rounding_mode = sim_fpu_round_near; - break; - case float_round_down: - rounding_mode = sim_fpu_round_down; - break; - case float_round_up: - rounding_mode = sim_fpu_round_up; - break; - case float_round_to_zero: - rounding_mode = sim_fpu_round_zero; - break; - } -} - - -float32 -syst_int32_to_float32(int32 a) -{ - float32 z; - sim_fpu s; - flags |= sim_fpu_i32to (&s, a, rounding_mode); - flags |= sim_fpu_round_32 (&s, rounding_mode, 0); - sim_fpu_to32 (&z, &s); - return z; -} - -float64 -syst_int32_to_float64( int32 a ) -{ - float64 z; - sim_fpu s; - flags |= sim_fpu_i32to (&s, a, rounding_mode); - sim_fpu_to64 (&z, &s); - return z; -} - -int32 -syst_float32_to_int32_round_to_zero( float32 a ) -{ - int32 z; - sim_fpu s; - sim_fpu_32to (&s, a); - flags |= sim_fpu_to32i (&z, &s, sim_fpu_round_zero); - return z; -} - -float64 -syst_float32_to_float64 (float32 a) -{ - float64 z; - sim_fpu s; - sim_fpu_32to (&s, a); - flags |= sim_fpu_round_64 (&s, rounding_mode, 0); - sim_fpu_to64 (&z, &s); - return z; -} - -float32 syst_float32_add( float32 a, float32 b ) -{ - float32 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); -#if 0 - fprintf (stdout, "\n "); - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n+ "); - sim_fpu_print_fpu (&B, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n= "); -#endif - flags |= sim_fpu_add (&ans, &A, &B); - flags |= sim_fpu_round_32 (&ans, rounding_mode, 0); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n"); -#endif - sim_fpu_to32 (&z, &ans); - return z; -} - -float32 syst_float32_sub( float32 a, float32 b ) -{ - float32 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " + "); - sim_fpu_print_fpu (&B, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " = "); -#endif - flags |= sim_fpu_sub (&ans, &A, &B); - flags |= sim_fpu_round_32 (&ans, rounding_mode, 0); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n"); -#endif - sim_fpu_to32 (&z, &ans); - return z; -} - -float32 syst_float32_mul( float32 a, float32 b ) -{ - float32 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " + "); - sim_fpu_print_fpu (&B, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " = "); -#endif - flags |= sim_fpu_mul (&ans, &A, &B); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); -#endif - flags |= sim_fpu_round_32 (&ans, rounding_mode, 0); -#if 0 - sim_fpu_print_status (flags, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n"); -#endif - sim_fpu_to32 (&z, &ans); - return z; -} - -float32 syst_float32_div( float32 a, float32 b ) -{ - float32 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); - flags |= sim_fpu_div (&ans, &A, &B); - flags |= sim_fpu_round_32 (&ans, rounding_mode, 0); - sim_fpu_to32 (&z, &ans); - return z; -} - -float32 syst_float32_sqrt( float32 a ) -{ - float32 z; - sim_fpu A; - sim_fpu ans; - sim_fpu_32to (&A, a); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " sqrt> "); -#endif - flags |= sim_fpu_sqrt (&ans, &A); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); -#endif - flags |= sim_fpu_round_32 (&ans, rounding_mode, 0); -#if 0 - fprintf (stdout, " (%x)\n", flags); -#endif - sim_fpu_to32 (&z, &ans); - return z; -} - -flag syst_float32_eq( float32 a, float32 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); - flags |= (sim_fpu_eq (&is, &A, &B) & ~sim_fpu_status_invalid_qnan); - return is; -} - -flag syst_float32_eq_signaling( float32 a, float32 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); - flags |= sim_fpu_eq (&is, &A, &B); - return is; -} - -flag syst_float32_le( float32 a, float32 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); - flags |= sim_fpu_le (&is, &A, &B); - return is; -} - -flag syst_float32_le_quiet( float32 a, float32 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); - flags |= (sim_fpu_le (&is, &A, &B) & ~sim_fpu_status_invalid_qnan); - return is; -} - -flag syst_float32_lt( float32 a, float32 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); - flags |= sim_fpu_lt (&is, &A, &B); - return is; -} - -flag syst_float32_lt_quiet( float32 a, float32 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_32to (&A, a); - sim_fpu_32to (&B, b); - flags |= (sim_fpu_lt (&is, &A, &B) & ~sim_fpu_status_invalid_qnan); - return is; -} - -int32 syst_float64_to_int32_round_to_zero( float64 a ) -{ - int32 z; - sim_fpu s; - sim_fpu_64to (&s, a); - flags |= sim_fpu_to32i (&z, &s, sim_fpu_round_zero); - return z; -} - -float32 syst_float64_to_float32( float64 a ) -{ - float32 z; - sim_fpu s; - sim_fpu_64to (&s, a); -#if 0 - sim_fpu_print_fpu (&s, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " -> "); -#endif - flags |= sim_fpu_round_32 (&s, rounding_mode, 0); -#if 0 - sim_fpu_print_fpu (&s, (sim_fpu_print_func*) fprintf, stdout); - sim_fpu_print_status (flags, (sim_fpu_print_func*) fprintf, stdout); - printf ("\n"); -#endif - sim_fpu_to32 (&z, &s); - return z; -} - -float64 syst_float64_add( float64 a, float64 b ) -{ - float64 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " + "); - sim_fpu_print_fpu (&B, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " = "); -#endif - flags |= sim_fpu_add (&ans, &A, &B); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); -#endif - flags |= sim_fpu_round_64 (&ans, rounding_mode, 0); -#if 0 - fprintf (stdout, " (%x)\n", flags); -#endif - sim_fpu_to64 (&z, &ans); - return z; -} - -float64 syst_float64_sub( float64 a, float64 b ) -{ - float64 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " + "); - sim_fpu_print_fpu (&B, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " = "); -#endif - flags |= sim_fpu_sub (&ans, &A, &B); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); -#endif - flags |= sim_fpu_round_64 (&ans, rounding_mode, 0); -#if 0 - fprintf (stdout, " (%x)\n", flags); -#endif - sim_fpu_to64 (&z, &ans); - return z; -} - -float64 syst_float64_mul( float64 a, float64 b ) -{ - float64 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " * "); - sim_fpu_print_fpu (&B, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " = "); -#endif - flags |= sim_fpu_mul (&ans, &A, &B); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); -#endif - flags |= sim_fpu_round_64 (&ans, rounding_mode, 0); -#if 0 - sim_fpu_print_status (flags, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n"); -#endif - sim_fpu_to64 (&z, &ans); - return z; -} - -float64 syst_float64_div( float64 a, float64 b ) -{ - float64 z; - sim_fpu A; - sim_fpu B; - sim_fpu ans; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " + "); - sim_fpu_print_fpu (&B, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, " = "); -#endif - flags |= sim_fpu_div (&ans, &A, &B); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); -#endif - flags |= sim_fpu_round_64 (&ans, rounding_mode, 0); -#if 0 - sim_fpu_print_status (flags, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n"); -#endif - sim_fpu_to64 (&z, &ans); - return z; -} - -float64 syst_float64_sqrt( float64 a ) -{ - float64 z; - sim_fpu A; - sim_fpu ans; - sim_fpu_64to (&A, a); -#if 0 - sim_fpu_print_fpu (&A, (sim_fpu_print_func*) fprintf, stdout); - printf (" sqrt> "); - printf ("\n"); -#endif - flags |= sim_fpu_sqrt (&ans, &A); -#if 0 - sim_fpu_print_fpu (&ans, (sim_fpu_print_func*) fprintf, stdout); -#endif - flags |= sim_fpu_round_64 (&ans, rounding_mode, 0); -#if 0 - sim_fpu_print_status (flags, (sim_fpu_print_func*) fprintf, stdout); - fprintf (stdout, "\n"); -#endif - sim_fpu_to64 (&z, &ans); - return z; -} - -flag syst_float64_eq( float64 a, float64 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); - flags |= (sim_fpu_eq (&is, &A, &B) & ~sim_fpu_status_invalid_qnan); - return is; -} - -flag syst_float64_eq_signaling( float64 a, float64 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); - flags |= sim_fpu_eq (&is, &A, &B); - return is; -} - -flag syst_float64_le( float64 a, float64 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); - flags |= sim_fpu_le (&is, &A, &B); - return is; -} - -flag syst_float64_le_quiet( float64 a, float64 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); - flags |= (sim_fpu_le (&is, &A, &B) & ~sim_fpu_status_invalid_qnan); - return is; -} - -flag syst_float64_lt( float64 a, float64 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); - flags |= sim_fpu_lt (&is, &A, &B); - return is; -} - -flag syst_float64_lt_quiet( float64 a, float64 b ) -{ - sim_fpu A; - sim_fpu B; - int is; - sim_fpu_64to (&A, a); - sim_fpu_64to (&B, b); - flags |= (sim_fpu_lt (&is, &A, &B) & ~sim_fpu_status_invalid_qnan); - return is; -} - |