diff --git a/SheepShaver/src/Unix/Makefile.in b/SheepShaver/src/Unix/Makefile.in index 820b3863..e546cccf 100644 --- a/SheepShaver/src/Unix/Makefile.in +++ b/SheepShaver/src/Unix/Makefile.in @@ -24,6 +24,7 @@ LIBS = @LIBS@ SYSSRCS = @SYSSRCS@ CPUSRCS = @CPUSRCS@ MONSRCS = @MONSRCS@ +PERL = @PERL@ USE_DYNGEN = @USE_DYNGEN@ DYNGENSRCS = @DYNGENSRCS@ DYNGEN_CC = @DYNGEN_CC@ @@ -142,7 +143,7 @@ $(OBJ_DIR)/%.o : %.S # Kheperix CPU emulator kpxsrcdir = ../kpx_cpu/src -GENEXEC = $(kpxsrcdir)/cpu/ppc/genexec.pl +GENEXECPL = $(kpxsrcdir)/cpu/ppc/genexec.pl DYNGEN = dyngen$(EXEEXT) ifeq ($(USE_DYNGEN),yes) @@ -167,8 +168,8 @@ $(OBJ_DIR)/sheepshaver_glue.o $(OBJ_DIR)/ppc-cpu.o $(OBJ_DIR)/ppc-decode.o $(OBJ endif $(OBJ_DIR)/ppc-execute.o: ppc-execute-impl.cpp -ppc-execute-impl.cpp: $(kpxsrcdir)/cpu/ppc/ppc-decode.cpp $(GENEXEC) $(DYNGENDEPS) - $(CPP) $(CPPFLAGS) -DGENEXEC $< | $(GENEXEC) > $@ +ppc-execute-impl.cpp: $(kpxsrcdir)/cpu/ppc/ppc-decode.cpp $(GENEXECPL) $(DYNGENDEPS) + $(CPP) $(CPPFLAGS) -DGENEXEC $< | $(PERL) $(GENEXECPL) > $@ # PowerPC CPU tester TESTSRCS_ = mathlib/ieeefp.cpp cpu/ppc/ppc-cpu.cpp cpu/ppc/ppc-decode.cpp cpu/ppc/ppc-execute.cpp cpu/ppc/ppc-translate.cpp test/test-powerpc.cpp $(MONSRCS) vm_alloc.cpp diff --git a/SheepShaver/src/Unix/configure.ac b/SheepShaver/src/Unix/configure.ac index fe8bd0f4..3d6502ce 100644 --- a/SheepShaver/src/Unix/configure.ac +++ b/SheepShaver/src/Unix/configure.ac @@ -48,7 +48,8 @@ AC_PROG_CXX AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_EGREP -AC_CHECK_PROGS(FILE, [file false]) +AC_PATH_PROGS(FILE, [file false]) +AC_PATH_PROG(PERL, [perl]) dnl Check for PowerPC target CPU. HAVE_PPC=no @@ -305,7 +306,7 @@ AC_CHECK_FUNCS(sigaction signal) AC_CHECK_FUNCS(mmap mprotect munmap) AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) AC_CHECK_FUNCS(posix_memalign memalign valloc) -AC_CHECK_FUNCS(exp2f log2f exp2 log2) +AC_CHECK_FUNCS(exp2f log2f exp2 log2 trunc) dnl Darwin seems to define mach_task_self() instead of task_self(). AC_CHECK_FUNCS(mach_task_self task_self) @@ -1070,7 +1071,7 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h) ;; esac - DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000" + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000 -g0" if [[ "x$HAVE_GCC30" = "xyes" ]]; then DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls" fi @@ -1123,6 +1124,7 @@ if [[ "x$WANT_JIT" = "xyes" ]]; then fi dnl Generate Makefile. +AC_SUBST(PERL) AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen]) AC_SUBST(DYNGENSRCS) AC_SUBST(DYNGEN_CC) diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-execute.cpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-execute.cpp index 7d4d913a..da627dda 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-execute.cpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-execute.cpp @@ -24,7 +24,6 @@ #include #include -#include "mathlib/ieeefp.hpp" #include "cpu/vm.hpp" #include "cpu/ppc/ppc-cpu.hpp" #include "cpu/ppc/ppc-bitfields.hpp" diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp index 00b63d06..c27ee2b6 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp @@ -22,6 +22,7 @@ #define PPC_OPERATIONS_H #include +#include "mathlib/ieeefp.hpp" /** * Define an unary/binary/trinary operation diff --git a/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.cpp b/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.cpp index 476f8570..5e0ebab0 100755 --- a/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.cpp +++ b/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.cpp @@ -108,3 +108,21 @@ int fesetround(int round) return 0; } + +// Truncate double value +#ifndef HAVE_TRUNC +#define HAVE_TRUNC +double trunc(double x) +{ + volatile unsigned short int cw; + volatile unsigned short int cwtmp; + double value; + + __asm__ __volatile__("fnstcw %0" : "=m" (cw)); + cwtmp = (cw & 0xf3ff) | 0x0c00; /* toward zero */ + __asm__ __volatile__("fldcw %0" : : "m" (cwtmp)); + __asm__ __volatile__("frndint" : "=t" (value) : "0" (x)); + __asm__ __volatile__("fldcw %0" : : "m" (cw)); + return value; +} +#endif diff --git a/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.hpp b/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.hpp index 0ce79030..682e2b50 100755 --- a/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.hpp +++ b/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp-i386.hpp @@ -1,7 +1,8 @@ /* - * ieeefp-i386.hpp - Access to FPU environment, x86 specific code + * ieeefp-i386.hpp - IEEE754 Floating-Point Math library, x86 specific code * * Kheperix (C) 2003-2005 Gwenole Beauchesne + * Code derived from the GNU C Library * * 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 @@ -18,8 +19,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef IEEEFP_FENV_I386_H -#define IEEEFP_FENV_I386_H +#ifndef IEEEFP_I386_H +#define IEEEFP_I386_H + +// 7.6 Floating-point environment +#ifndef HAVE_FENV_H // Exceptions enum { @@ -49,4 +53,25 @@ enum { #define FE_TOWARDZERO FE_TOWARDZERO }; -#endif /* IEEEFP_FENV_I386_H */ +#endif + +// 7.12.14 Comparison macros +#if defined(__GNUC__) +#ifndef isless +#define isless(x, y) \ +({ register char __result; \ + __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \ + : "=a" (__result) : "u" (x), "t" (y) : "cc", "st", "st(1)"); \ + __result; }) +#endif + +#ifndef isgreater +#define isgreater(x, y) \ +({ register char __result; \ + __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \ + __result; }) +#endif +#endif + +#endif /* IEEEFP_I386_H */ diff --git a/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp.hpp b/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp.hpp index 6c89c2e2..4053b055 100755 --- a/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp.hpp +++ b/SheepShaver/src/kpx_cpu/src/mathlib/ieeefp.hpp @@ -1,5 +1,5 @@ /* - * ieeefp.hpp - Access to FPU environment + * ieeefp.hpp - IEEE754 Floating-Point Math library * * Kheperix (C) 2003-2005 Gwenole Beauchesne * @@ -18,21 +18,35 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef IEEEFP_FENV_H -#define IEEEFP_FENV_H - -#ifdef HAVE_FENV_H -#include -#else +#ifndef IEEEFP_H +#define IEEEFP_H // Arch-dependent definitions #if defined(__i386__) #include "mathlib/ieeefp-i386.hpp" #endif +#ifdef HAVE_FENV_H +#include +#else + // Rounding control extern "C" int fegetround(void); extern "C" int fesetround(int); #endif /* FENV_H */ -#endif /* IEEEFP_FENV_H */ + +// Rounding +#ifndef HAVE_TRUNC +extern "C" double trunc(double); +#endif + +// Comparison macros +#ifndef isless +#define isless(x, y) ((x) < (y)) +#endif +#ifndef isgreater +#define isgreater(x, y) ((x) > (y)) +#endif + +#endif /* IEEEFP_H */