[cmucl-commit] [git] CMU Common Lisp branch master updated. begin-x87-removal-5-g1dbe0c4
Raymond Toy
rtoy at common-lisp.net
Sun Apr 6 15:16:21 UTC 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".
The branch, master has been updated
via 1dbe0c4b5e5e05cc6a9377bc3c6505a9a3e60efc (commit)
via 29359293d89d79c7c0099917c93c98258fae12d1 (commit)
from 0592141ab9256ca0382a501b418523194ed66e3c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1dbe0c4b5e5e05cc6a9377bc3c6505a9a3e60efc
Author: Raymond Toy <toy.raymond at gmail.com>
Date: Sun Apr 6 08:16:07 2014 -0700
Remove commented-out stuff and clean up comments.
diff --git a/src/compiler/x86/c-call.lisp b/src/compiler/x86/c-call.lisp
index 93f1072..4b4e69b 100644
--- a/src/compiler/x86/c-call.lisp
+++ b/src/compiler/x86/c-call.lisp
@@ -111,12 +111,14 @@
(declare (ignore type))
(let ((num-results (result-state-num-results state)))
(setf (result-state-num-results state) (1+ num-results))
+ ;; The XMM registers start at 8.
(my-make-wired-tn 'double-float 'double-reg (+ num-results 8))))
(def-alien-type-method (single-float :result-tn) (type state)
(declare (ignore type))
(let ((num-results (result-state-num-results state)))
(setf (result-state-num-results state) (1+ num-results))
+ ;; The XMM registers start at 8.
(my-make-wired-tn 'single-float 'single-reg (+ num-results 8))))
(def-alien-type-method (values :result-tn) (type state)
diff --git a/src/compiler/x86/sse2-c-call.lisp b/src/compiler/x86/sse2-c-call.lisp
index 641f0cb..edd226b 100644
--- a/src/compiler/x86/sse2-c-call.lisp
+++ b/src/compiler/x86/sse2-c-call.lisp
@@ -44,11 +44,12 @@
(:generator 0
(cond ((policy node (> space speed))
(move eax function)
- ;; call_into_c has arranged for the result to be in ST(0)
- ;; (aka fr0), so there's nothing we need to do now. The
- ;; compiler will move fr0 to the appropriate XMM register.
(inst call (make-fixup (extern-alien-name "call_into_c") :foreign))
(when (and results (location= (tn-ref-tn results) xmm0-tn))
+ ;; If there is a float result from the foreign call,
+ ;; call_into_c has arranged for the result to be in XMM0,
+ ;; as a double. If we wanted a single float, do the
+ ;; conversion here.
(sc-case (tn-ref-tn results)
(single-reg
(inst cvtsd2ss xmm0-tn xmm0-tn))
@@ -57,42 +58,21 @@
;; the result as a double.
))))
(t
- ;; Setup the NPX for C; all the FP registers need to be
- ;; empty; pop them all.
- #+nil
- (dotimes (i 8)
- (fp-pop))
-
(inst call function)
;; To give the debugger a clue. XX not really internal-error?
(note-this-location vop :internal-error)
- ;; Restore the NPX for lisp; insure no regs are empty. But
- ;; we only do 7 registers here.
- #+nil
- (dotimes (i 7)
- (inst fldz))
-
- (cond ((and results
- (location= (tn-ref-tn results) xmm0-tn))
- ;; If there's a float result, it would have been
- ;; returned in fr0, which is now in fr7, thanks to
- ;; the fldz's above. Swap fr7 with fr0. The
- ;; compiler will arrange to move fr0 to the
- ;; appropriate XMM register.
- #+nil
- (inst fxch fr7-tn)
- (sc-case (tn-ref-tn results)
- (single-reg
- (inst fstp (ea-for-sf-stack temp-single))
- (inst movss xmm0-tn (ea-for-sf-stack temp-single)))
- (double-reg
- (inst fstpd (ea-for-df-stack temp-double))
- (inst movsd xmm0-tn (ea-for-df-stack temp-double)))))
- (t
- ;; Fill up the last x87 register
- #+nil
- (inst fldz)))))))
+ (when (and results
+ (location= (tn-ref-tn results) xmm0-tn))
+ ;; If there's a float result, it would have been returned
+ ;; in fr0 according to the ABI. We want it in xmm0.
+ (sc-case (tn-ref-tn results)
+ (single-reg
+ (inst fstp (ea-for-sf-stack temp-single))
+ (inst movss xmm0-tn (ea-for-sf-stack temp-single)))
+ (double-reg
+ (inst fstpd (ea-for-df-stack temp-double))
+ (inst movsd xmm0-tn (ea-for-df-stack temp-double)))))))))
(define-vop (alloc-number-stack-space)
(:info amount)
diff --git a/src/lisp/x86-assem.S b/src/lisp/x86-assem.S
index a0222c5..b01fa5f 100644
--- a/src/lisp/x86-assem.S
+++ b/src/lisp/x86-assem.S
@@ -98,17 +98,6 @@ FUNCDEF(call_into_c)
/* Save the return lisp address in ebx */
popl %ebx
-#if 0
-/* Setup the NPX for C */
- fstp %st(0)
- fstp %st(0)
- fstp %st(0)
- fstp %st(0)
- fstp %st(0)
- fstp %st(0)
- fstp %st(0)
- fstp %st(0)
-#endif
call *%eax # normal callout using Lisp stack
movl %eax,%ecx # remember integer return value
@@ -121,17 +110,6 @@ FUNCDEF(call_into_c)
jne Lfp_rtn_value
/* The return value is in eax, or eax,edx? */
-#if 0
-/* Setup the NPX stack for lisp */
- fldz # insure no regs are empty
- fldz
- fldz
- fldz
- fldz
- fldz
- fldz
- fldz
-#endif
no_fldz:
/* Restore the return value */
movl %ecx,%eax # maybe return value
@@ -141,18 +119,13 @@ no_fldz:
jmp *%ebx
Lfp_rtn_value:
-#if 0
-/* The return result is in st(0) */
-/* Setup the NPX stack for lisp, placing the result in st(0) */
- fldz # insure no regs are empty
- fldz
- fldz
- fldz
- fldz
- fldz
- fldz
- fxch %st(7) # move the result back to st(0)
-#endif
+
+/*
+ * The float result is in st(0). We want it in xmm0. For
+ * consistency, save st(0) out as a double and load it into xmm0 as a
+ * double. The call-out vop will arrange to convert it to a single-float
+ * if necessary.
+ */
subl $8, %esp # Space for a double float
fstpl 0(%esp)
movsd 0(%esp), %xmm0
@@ -208,17 +181,6 @@ x87_save:
fldcw (%esp) # Recover modes
popl %eax
npx_save_done:
-#if 0
- /* Is this still necessary with sse2? */
- fldz # insure no FP regs are empty
- fldz
- fldz
- fldz
- fldz
- fldz
- fldz
- fldz
-#endif
/* Save C regs: ebx esi edi */
pushl %ebx
pushl %esi
commit 29359293d89d79c7c0099917c93c98258fae12d1
Author: Raymond Toy <toy.raymond at gmail.com>
Date: Sat Apr 5 14:46:17 2014 -0700
Simplify call-out for sse2.
For sse2, we don't need to do the fldz/fstp dance when doing a
foreign function call.
A cross-compile is needed!
* src/bootfiles/20e/boot-2014-04-cross-x86.lisp:
* Cross-compile script to enable these changes.
* src/compiler/x86/c-call.lisp:
* Make the float result tn be xmm registers, not x87 fpu registers.
* src/compiler/x86/sse2-c-call.lisp:
* Simplify call-out not to use fldz/fstp except for the minimum
required for the 32-bit ABI.
* src/lisp/x86-assem.S
* Comment out the fstp/fldz insts that aren't needed for SSE2.
diff --git a/src/bootfiles/20e/boot-2014-04-cross-x86.lisp b/src/bootfiles/20e/boot-2014-04-cross-x86.lisp
new file mode 100644
index 0000000..7bfecf8
--- /dev/null
+++ b/src/bootfiles/20e/boot-2014-04-cross-x86.lisp
@@ -0,0 +1,8 @@
+;; Cross-compile script needed for updating the SSE2 call-out VOP and
+;; x86 call_into_c. In both places, we remove the need to do the fldz
+;; and fstp dance to set up the FPU for C and Lisp. SSE2 doesn't use
+;; the FPU.
+
+#+x86
+(load "target:tools/cross-scripts/cross-x86-x86.lisp")
+
diff --git a/src/compiler/x86/c-call.lisp b/src/compiler/x86/c-call.lisp
index 4554a0e..93f1072 100644
--- a/src/compiler/x86/c-call.lisp
+++ b/src/compiler/x86/c-call.lisp
@@ -111,13 +111,13 @@
(declare (ignore type))
(let ((num-results (result-state-num-results state)))
(setf (result-state-num-results state) (1+ num-results))
- (my-make-wired-tn 'double-float 'double-reg (* num-results 2))))
+ (my-make-wired-tn 'double-float 'double-reg (+ num-results 8))))
(def-alien-type-method (single-float :result-tn) (type state)
(declare (ignore type))
(let ((num-results (result-state-num-results state)))
(setf (result-state-num-results state) (1+ num-results))
- (my-make-wired-tn 'single-float 'single-reg (* num-results 2))))
+ (my-make-wired-tn 'single-float 'single-reg (+ num-results 8))))
(def-alien-type-method (values :result-tn) (type state)
(let ((values (alien-values-type-values type)))
diff --git a/src/compiler/x86/sse2-c-call.lisp b/src/compiler/x86/sse2-c-call.lisp
index a5bd80f..641f0cb 100644
--- a/src/compiler/x86/sse2-c-call.lisp
+++ b/src/compiler/x86/sse2-c-call.lisp
@@ -34,6 +34,8 @@
:from :eval :to :result) ecx)
(:temporary (:sc unsigned-reg :offset edx-offset
:from :eval :to :result) edx)
+ (:temporary (:sc single-stack) temp-single)
+ (:temporary (:sc double-stack) temp-double)
(:node-var node)
(:vop-var vop)
(:save-p t)
@@ -45,10 +47,19 @@
;; call_into_c has arranged for the result to be in ST(0)
;; (aka fr0), so there's nothing we need to do now. The
;; compiler will move fr0 to the appropriate XMM register.
- (inst call (make-fixup (extern-alien-name "call_into_c") :foreign)))
+ (inst call (make-fixup (extern-alien-name "call_into_c") :foreign))
+ (when (and results (location= (tn-ref-tn results) xmm0-tn))
+ (sc-case (tn-ref-tn results)
+ (single-reg
+ (inst cvtsd2ss xmm0-tn xmm0-tn))
+ (double-reg
+ ;; Nothing needed for double because call_into_c saved
+ ;; the result as a double.
+ ))))
(t
;; Setup the NPX for C; all the FP registers need to be
;; empty; pop them all.
+ #+nil
(dotimes (i 8)
(fp-pop))
@@ -58,19 +69,29 @@
;; Restore the NPX for lisp; insure no regs are empty. But
;; we only do 7 registers here.
+ #+nil
(dotimes (i 7)
(inst fldz))
(cond ((and results
- (location= (tn-ref-tn results) fr0-tn))
+ (location= (tn-ref-tn results) xmm0-tn))
;; If there's a float result, it would have been
;; returned in fr0, which is now in fr7, thanks to
;; the fldz's above. Swap fr7 with fr0. The
;; compiler will arrange to move fr0 to the
;; appropriate XMM register.
- (inst fxch fr7-tn))
+ #+nil
+ (inst fxch fr7-tn)
+ (sc-case (tn-ref-tn results)
+ (single-reg
+ (inst fstp (ea-for-sf-stack temp-single))
+ (inst movss xmm0-tn (ea-for-sf-stack temp-single)))
+ (double-reg
+ (inst fstpd (ea-for-df-stack temp-double))
+ (inst movsd xmm0-tn (ea-for-df-stack temp-double)))))
(t
;; Fill up the last x87 register
+ #+nil
(inst fldz)))))))
(define-vop (alloc-number-stack-space)
diff --git a/src/lisp/x86-assem.S b/src/lisp/x86-assem.S
index 57b69c0..a0222c5 100644
--- a/src/lisp/x86-assem.S
+++ b/src/lisp/x86-assem.S
@@ -98,6 +98,7 @@ FUNCDEF(call_into_c)
/* Save the return lisp address in ebx */
popl %ebx
+#if 0
/* Setup the NPX for C */
fstp %st(0)
fstp %st(0)
@@ -107,6 +108,7 @@ FUNCDEF(call_into_c)
fstp %st(0)
fstp %st(0)
fstp %st(0)
+#endif
call *%eax # normal callout using Lisp stack
movl %eax,%ecx # remember integer return value
@@ -119,6 +121,7 @@ FUNCDEF(call_into_c)
jne Lfp_rtn_value
/* The return value is in eax, or eax,edx? */
+#if 0
/* Setup the NPX stack for lisp */
fldz # insure no regs are empty
fldz
@@ -128,6 +131,7 @@ FUNCDEF(call_into_c)
fldz
fldz
fldz
+#endif
no_fldz:
/* Restore the return value */
movl %ecx,%eax # maybe return value
@@ -137,6 +141,7 @@ no_fldz:
jmp *%ebx
Lfp_rtn_value:
+#if 0
/* The return result is in st(0) */
/* Setup the NPX stack for lisp, placing the result in st(0) */
fldz # insure no regs are empty
@@ -147,6 +152,11 @@ Lfp_rtn_value:
fldz
fldz
fxch %st(7) # move the result back to st(0)
+#endif
+ subl $8, %esp # Space for a double float
+ fstpl 0(%esp)
+ movsd 0(%esp), %xmm0
+ addl $8, %esp
/* Don't need to restore eax as the result is in st(0) */
@@ -198,6 +208,7 @@ x87_save:
fldcw (%esp) # Recover modes
popl %eax
npx_save_done:
+#if 0
/* Is this still necessary with sse2? */
fldz # insure no FP regs are empty
fldz
@@ -207,7 +218,7 @@ npx_save_done:
fldz
fldz
fldz
-
+#endif
/* Save C regs: ebx esi edi */
pushl %ebx
pushl %esi
-----------------------------------------------------------------------
Summary of changes:
src/bootfiles/20e/boot-2014-04-cross-x86.lisp | 8 ++++
src/compiler/x86/c-call.lisp | 6 ++-
src/compiler/x86/sse2-c-call.lisp | 51 +++++++++++++------------
src/lisp/x86-assem.S | 49 ++++++------------------
4 files changed, 49 insertions(+), 65 deletions(-)
create mode 100644 src/bootfiles/20e/boot-2014-04-cross-x86.lisp
hooks/post-receive
--
CMU Common Lisp
More information about the cmucl-commit
mailing list