From 441a76a6b156e8eedc5ef9bb72c5772d89b657bc Mon Sep 17 00:00:00 2001 From: Raymond Toy <toy.raymond@gmail.com> Date: Sat, 11 Aug 2012 16:50:28 -0700 Subject: [PATCH] Move the FPU save/restore stuff from os.h to arch.h * src/lisp/os.h * Move macros and definitions for FPU save/restore from here. * src/lisp/arch.h * Put architecture neutral stuff from os.h here. * src/lisp/ppc-arch.h * src/lisp/sparc-arch.h * src/lisp/x86-arch.h * Implement the FPU save/restore macros here for each supported architecture. --- src/lisp/arch.h | 22 ++++++++++++++++------ src/lisp/os.h | 39 --------------------------------------- src/lisp/ppc-arch.h | 19 +++++++++++++++++++ src/lisp/sparc-arch.h | 23 +++++++++++++++++++++++ src/lisp/x86-arch.h | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 45 deletions(-) create mode 100644 src/lisp/ppc-arch.h create mode 100644 src/lisp/sparc-arch.h create mode 100644 src/lisp/x86-arch.h diff --git a/src/lisp/arch.h b/src/lisp/arch.h index b8ebf3f2a..3c6dd9f55 100644 --- a/src/lisp/arch.h +++ b/src/lisp/arch.h @@ -30,18 +30,28 @@ extern lispobj funcall2(lispobj function, lispobj arg0, lispobj arg1); extern lispobj funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2); +extern void arch_make_linkage_entry(long, void *, long); +extern long arch_linkage_entry(unsigned long); +void arch_make_lazy_linkage(long linkage_entry); +long arch_linkage_entry(unsigned long retaddr); + + extern void fpu_save(void *); extern void fpu_restore(void *); extern void sse_save(void *); extern void sse_restore(void *); +extern void save_fpu_state(void*); +extern void restore_fpu_state(void*); -extern void arch_make_linkage_entry(long, void *, long); -extern long arch_linkage_entry(unsigned long); -void arch_make_lazy_linkage(long linkage_entry); -long arch_linkage_entry(unsigned long retaddr); +#if defined(i386) || defined(__x86_64) +#include "x86-arch.h" +#endif -#ifdef i386 -extern int arch_support_sse2(void); +#if defined(DARWIN) && defined(__ppc__) +#include "ppc-arch.h" #endif +#if defined(sparc) +#include "sparc-arch.h" +#endif #endif /* __ARCH_H__ */ diff --git a/src/lisp/os.h b/src/lisp/os.h index c99647481..5d4344658 100644 --- a/src/lisp/os.h +++ b/src/lisp/os.h @@ -116,45 +116,6 @@ unsigned long *os_sigcontext_pc(ucontext_t *); unsigned char *os_sigcontext_fpu_reg(ucontext_t *, int); unsigned int os_sigcontext_fpu_modes(ucontext_t *); -#ifdef i386 -extern boolean os_support_sse2(void); -#endif - char* convert_lisp_string(char* c_string, void* lisp_string, int len); -/* - * Define macro to allocate a local array of the appropriate size - * where the fpu state can be stored. - */ -#if defined(i386) || defined(__x86_64) -#define FPU_STATE_SIZE 27 - /* - * Need 512 byte area, aligned on a 16-byte boundary. So allocate - * 512+16 bytes of space and let the routine adjust use the - * appropriate alignment. - */ -#define SSE_STATE_SIZE ((512+16)/4) - -/* - * Just use the SSE size for both x87 and sse2 since the SSE size is - * enough for either. - */ -#define FPU_STATE(name) int name[SSE_STATE_SIZE]; - -#elif defined(sparc) -/* - * 32 (single-precision) FP registers, and the FP state register. - * But Sparc V9 has 32 double-precision registers (equivalent to 64 - * single-precision, but can't be accessed), so we leave enough room - * for that. - */ -#define FPU_STATE_SIZE (((32 + 32 + 1) + 1)/2) -#define FPU_STATE(name) long long name[FPU_STATE_SIZE]; -#elif defined(DARWIN) && defined(__ppc__) -#define FPU_STATE_SIZE 32 -#define FPU_STATE(name) long long name[FPU_STATE_SIZE]; -#endif -extern void save_fpu_state(void*); -extern void restore_fpu_state(void*); - #endif /* _OS_H_ */ diff --git a/src/lisp/ppc-arch.h b/src/lisp/ppc-arch.h new file mode 100644 index 000000000..c4698a733 --- /dev/null +++ b/src/lisp/ppc-arch.h @@ -0,0 +1,19 @@ +/* + + This code was written as part of the CMU Common Lisp project and has + been placed in the public domain. + +*/ +#ifndef __PPC_ARCH_H +#define __PPC_ARCH_H + +/* + * Define macro to allocate a local array of the appropriate size + * where the fpu state can be stored. + * + * PPC has 32 (double-precision) floating-point registers. + */ +#define FPU_STATE_SIZE 32 +#define FPU_STATE(name) long long name[FPU_STATE_SIZE]; + +#endif diff --git a/src/lisp/sparc-arch.h b/src/lisp/sparc-arch.h new file mode 100644 index 000000000..3a9838405 --- /dev/null +++ b/src/lisp/sparc-arch.h @@ -0,0 +1,23 @@ +/* + + This code was written as part of the CMU Common Lisp project and has + been placed in the public domain. + +*/ +#ifndef __SPARC_ARCH_H +#define __SPARC_ARCH_H + +/* + * Define macro to allocate a local array of the appropriate size + * where the fpu state can be stored. + * + * + * 32 (single-precision) FP registers, and the FP state register. + * But Sparc V9 has 32 double-precision registers (equivalent to 64 + * single-precision, but can't be accessed), so we leave enough room + * for that. + */ +#define FPU_STATE_SIZE (((32 + 32 + 1) + 1)/2) +#define FPU_STATE(name) long long name[FPU_STATE_SIZE]; + +#endif diff --git a/src/lisp/x86-arch.h b/src/lisp/x86-arch.h new file mode 100644 index 000000000..8314063fd --- /dev/null +++ b/src/lisp/x86-arch.h @@ -0,0 +1,32 @@ +/* + + This code was written as part of the CMU Common Lisp project and has + been placed in the public domain. + +*/ +#ifndef __X86_ARCH_H + +extern int arch_support_sse2(void); +extern boolean os_support_sse2(void); + +/* + * Define macro to allocate a local array of the appropriate size + * where the fpu state can be stored. + */ + +#define FPU_STATE_SIZE 27 + +/* + * Need 512 byte area, aligned on a 16-byte boundary. So allocate + * 512+16 bytes of space and let the routine adjust the appropriate + * alignment. + */ +#define SSE_STATE_SIZE ((512+16)/4) + +/* + * Just use the SSE size for both x87 and sse2 since the SSE size is + * enough for either. + */ +#define FPU_STATE(name) int name[SSE_STATE_SIZE]; + +#endif -- GitLab