X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86%2Fvm.lisp;h=39924ff8dec9b5442c8defe7a77eee765f8fd24f;hb=d5520a24b6c356918c2f91bf91dae60f62e1d065;hp=833dd739f00fd23a928d1bbd1acd522f0d997462;hpb=0d871fd7a98fc4af92a8b942a1154761466ad8c9;p=sbcl.git diff --git a/src/compiler/x86/vm.lisp b/src/compiler/x86/vm.lisp index 833dd73..39924ff 100644 --- a/src/compiler/x86/vm.lisp +++ b/src/compiler/x86/vm.lisp @@ -118,7 +118,7 @@ ;;; the new way: (define-storage-base float-registers :finite :size 8) -(define-storage-base stack :unbounded :size 8) +(define-storage-base stack :unbounded :size 4 :size-increment 1) (define-storage-base constant :non-packed) (define-storage-base immediate-constant :non-packed) (define-storage-base noise :unbounded :size 2) @@ -160,7 +160,8 @@ ;;; (What a KLUDGE! Anyone who wants to come in and clean up this mess ;;; has my gratitude.) (FIXME: Maybe this should be me..) (eval-when (:compile-toplevel :load-toplevel :execute) - (def!constant kludge-nondeterministic-catch-block-size 6)) + (def!constant kludge-nondeterministic-catch-block-size + #!-win32 5 #!+win32 7)) (!define-storage-classes @@ -169,7 +170,8 @@ ;; some FP constants can be generated in the i387 silicon (fp-constant immediate-constant) - + (fp-single-immediate immediate-constant) + (fp-double-immediate immediate-constant) (immediate immediate-constant) ;; @@ -231,6 +233,8 @@ (character-reg registers :locations #!-sb-unicode #.*byte-regs* #!+sb-unicode #.*dword-regs* + #!+sb-unicode #!+sb-unicode + :element-size 2 #!-sb-unicode #!-sb-unicode :reserve-locations (#.ah-offset #.al-offset) :constant-scs (immediate) @@ -279,14 +283,14 @@ ;; non-descriptor SINGLE-FLOATs (single-reg float-registers :locations (0 1 2 3 4 5 6 7) - :constant-scs (fp-constant) + :constant-scs (fp-constant fp-single-immediate) :save-p t :alternate-scs (single-stack)) ;; non-descriptor DOUBLE-FLOATs (double-reg float-registers :locations (0 1 2 3 4 5 6 7) - :constant-scs (fp-constant) + :constant-scs (fp-constant fp-double-immediate) :save-p t :alternate-scs (double-stack)) @@ -378,36 +382,71 @@ ;;; If value can be represented as an immediate constant, then return ;;; the appropriate SC number, otherwise return NIL. -(!def-vm-support-routine immediate-constant-sc (value) +(defun immediate-constant-sc (value) (typecase value ((or (integer #.sb!xc:most-negative-fixnum #.sb!xc:most-positive-fixnum) - #-sb-xc-host system-area-pointer character) + character) (sc-number-or-lose 'immediate)) (symbol (when (static-symbol-p value) (sc-number-or-lose 'immediate))) (single-float - (when (or (eql value 0f0) (eql value 1f0)) - (sc-number-or-lose 'fp-constant))) + (case value + ((0f0 1f0) (sc-number-or-lose 'fp-constant)) + (t (sc-number-or-lose 'fp-single-immediate)))) (double-float - (when (or (eql value 0d0) (eql value 1d0)) - (sc-number-or-lose 'fp-constant))) + (case value + ((0d0 1d0) (sc-number-or-lose 'fp-constant)) + (t (sc-number-or-lose 'fp-double-immediate)))) #!+long-float (long-float - (when (or (eql value 0l0) (eql value 1l0) - (eql value pi) - (eql value (log 10l0 2l0)) - (eql value (log 2.718281828459045235360287471352662L0 2l0)) - (eql value (log 2l0 10l0)) - (eql value (log 2l0 2.718281828459045235360287471352662L0))) - (sc-number-or-lose 'fp-constant))))) + (when (or (eql value 0l0) (eql value 1l0) + (eql value pi) + (eql value (log 10l0 2l0)) + (eql value (log 2.718281828459045235360287471352662L0 2l0)) + (eql value (log 2l0 10l0)) + (eql value (log 2l0 2.718281828459045235360287471352662L0))) + (sc-number-or-lose 'fp-constant))))) + +(defun boxed-immediate-sc-p (sc) + (eql sc (sc-number-or-lose 'immediate))) + +;; For an immediate TN, return its value encoded for use as a literal. +;; For any other TN, return the TN. Only works for FIXNUMs, +;; STATIC-SYMBOLs, and CHARACTERS (FLOATs and SAPs are handled +;; elsewhere). +(defun encode-value-if-immediate (tn) + (if (sc-is tn immediate) + (let ((val (tn-value tn))) + (etypecase val + (integer (fixnumize val)) + (symbol (+ nil-value (static-symbol-offset val))) + (character (logior (ash (char-code val) n-widetag-bits) + character-widetag)))) + tn)) ;;;; miscellaneous function call parameters -;;; offsets of special stack frame locations -(def!constant ocfp-save-offset 0) -(def!constant return-pc-save-offset 1) -(def!constant code-save-offset 2) +;;; Offsets of special stack frame locations relative to EBP. +;;; +;;; Consider the standard prologue PUSH EBP; MOV EBP, ESP: the return +;;; address is at EBP+4, the old control stack frame pointer is at +;;; EBP, the magic 3rd slot is at EBP-4. Then come the locals from +;;; EBP-8 on. +(def!constant return-pc-save-offset 0) +(def!constant ocfp-save-offset 1) +;;; Let SP be the stack pointer before CALLing, and FP is the frame +;;; pointer after the standard prologue. SP + +;;; FRAME-WORD-OFFSET(SP->FP-OFFSET + I) = FP + FRAME-WORD-OFFSET(I). +(def!constant sp->fp-offset 2) + +(declaim (inline frame-word-offset)) +(defun frame-word-offset (index) + (- (1- index))) + +(declaim (inline frame-byte-offset)) +(defun frame-byte-offset (index) + (* (frame-word-offset index) n-word-bytes)) ;;; FIXME: This is a bad comment (changed since when?) and there are others ;;; like it in this file. It'd be nice to clarify them. Failing that deleting @@ -424,7 +463,7 @@ ;;; This function is called by debug output routines that want a pretty name ;;; for a TN's location. It returns a thing that can be printed with PRINC. -(!def-vm-support-routine location-print-name (tn) +(defun location-print-name (tn) (declare (type tn tn)) (let* ((sc (tn-sc tn)) (sb (sb-name (sc-sb sc))) @@ -449,3 +488,34 @@ (immediate-constant "Immed") (noise (symbol-name (sc-name sc)))))) ;;; FIXME: Could this, and everything that uses it, be made #!+SB-SHOW? + +(defun combination-implementation-style (node) + (declare (type sb!c::combination node)) + (flet ((valid-funtype (args result) + (sb!c::valid-fun-use node + (sb!c::specifier-type + `(function ,args ,result))))) + (case (sb!c::combination-fun-source-name node) + (logtest + (cond + ((valid-funtype '(fixnum fixnum) '*) + (values :maybe nil)) + ((valid-funtype '((signed-byte 32) (signed-byte 32)) '*) + (values :maybe nil)) + ((valid-funtype '((unsigned-byte 32) (unsigned-byte 32)) '*) + (values :maybe nil)) + (t (values :default nil)))) + (logbitp + (cond + ((and (valid-funtype '((integer 0 29) fixnum) '*) + (sb!c::constant-lvar-p (first (sb!c::basic-combination-args node)))) + (values :transform '(lambda (index integer) + (%logbitp integer index)))) + ((valid-funtype '((integer 0 31) (signed-byte 32)) '*) + (values :transform '(lambda (index integer) + (%logbitp integer index)))) + ((valid-funtype '((integer 0 31) (unsigned-byte 32)) '*) + (values :transform '(lambda (index integer) + (%logbitp integer index)))) + (t (values :default nil)))) + (t (values :default nil)))))