(:ignore name)
(:results)
(:generator 1
- (if (sc-is value immediate)
- (let ((val (tn-value value)))
- (etypecase val
- (integer
- (storew (fixnumize val)
- object offset lowtag))
- (symbol
- (storew (+ nil-value (static-symbol-offset val))
- object offset lowtag))
- (character
- (storew (logior (ash (char-code val) n-widetag-bits)
- character-widetag)
- object offset lowtag))))
- ;; Else, value not immediate.
- (storew value object offset lowtag))))
+ (storew (encode-value-if-immediate value) object offset lowtag)))
\f
(:variant-vars base lowtag)
(:info offset)
(:generator 4
- (if (sc-is value immediate)
- (let ((val (tn-value value)))
- (etypecase val
- (integer
- (storew (fixnumize val)
- object (+ base offset) lowtag))
- (symbol
- (storew (+ nil-value (static-symbol-offset val))
- object (+ base offset) lowtag))
- (character
- (storew (logior (ash (char-code val) n-widetag-bits)
- character-widetag)
- object (+ base offset) lowtag))))
- ;; Else, value not immediate.
- (storew value object (+ base offset) lowtag))))
+ (storew (encode-value-if-immediate value) object (+ base offset) lowtag)))
(define-vop (slot-set-conditional)
(:args (object :scs (descriptor-reg) :to :eval)
(define-move-fun (load-immediate 1) (vop x y)
((immediate)
(any-reg descriptor-reg))
- (let ((val (tn-value x)))
- (etypecase val
- (integer
- (if (zerop val)
- (inst xor y y)
- (inst mov y (fixnumize val))))
- (symbol
- (load-symbol y val))
- (character
- (inst mov y (logior (ash (char-code val) n-widetag-bits)
- character-widetag))))))
+ (let ((val (encode-value-if-immediate x)))
+ (if (zerop val)
+ (inst xor y y)
+ (inst mov y val))))
(define-move-fun (load-number 1) (vop x y)
((immediate) (signed-reg unsigned-reg))
(:generator 0
(if (and (sc-is x immediate)
(sc-is y any-reg descriptor-reg control-stack))
- (let ((val (tn-value x)))
- (etypecase val
- (integer
- (if (and (zerop val) (sc-is y any-reg descriptor-reg))
- (inst xor y y)
- (inst mov y (fixnumize val))))
- (symbol
- (inst mov y (+ nil-value (static-symbol-offset val))))
- (character
- (inst mov y (logior (ash (char-code val) n-widetag-bits)
- character-widetag)))))
+ (let ((val (encode-value-if-immediate x)))
+ (if (and (zerop val) (sc-is y any-reg descriptor-reg))
+ (inst xor y y)
+ (inst mov y val)))
(move y x))))
(define-move-vop move :move
(sc-case y
((any-reg descriptor-reg)
(if (sc-is x immediate)
- (let ((val (tn-value x)))
- (etypecase val
- (integer
- (if (zerop val)
- (inst xor y y)
- (inst mov y (fixnumize val))))
- (symbol
- (load-symbol y val))
- (character
- (inst mov y (logior (ash (char-code val) n-widetag-bits)
- character-widetag)))))
+ (let ((val (encode-value-if-immediate x)))
+ (if (zerop val)
+ (inst xor y y)
+ (inst mov y val)))
(move y x)))
((control-stack)
(let ((frame-offset (if (= (tn-offset fp) esp-offset)
(tn-offset y)
;; Lisp stack
(frame-word-offset (tn-offset y)))))
- (if (sc-is x immediate)
- (let ((val (tn-value x)))
- (etypecase val
- (integer
- (storew (fixnumize val) fp frame-offset))
- (symbol
- (storew (+ nil-value (static-symbol-offset val))
- fp frame-offset))
- (character
- (storew (logior (ash (char-code val) n-widetag-bits)
- character-widetag)
- fp frame-offset))))
- (storew x fp frame-offset)))))))
+ (storew (encode-value-if-immediate x) fp frame-offset))))))
(define-move-vop move-arg :move-arg
(any-reg descriptor-reg)
(:policy :fast-safe)
(:translate eq)
(:generator 3
- (cond
- ((sc-is y immediate)
- (let ((val (tn-value y)))
- (etypecase val
- (integer
- (if (and (zerop val) (sc-is x any-reg descriptor-reg))
- (inst test x x) ; smaller
- (inst cmp x (fixnumize val))))
- (symbol
- (inst cmp x (+ nil-value (static-symbol-offset val))))
- (character
- (inst cmp x (logior (ash (char-code val) n-widetag-bits)
- character-widetag))))))
- ((sc-is x immediate) ; and y not immediate
- ;; Swap the order to fit the compare instruction.
- (let ((val (tn-value x)))
- (etypecase val
- (integer
- (if (and (zerop val) (sc-is y any-reg descriptor-reg))
- (inst test y y) ; smaller
- (inst cmp y (fixnumize val))))
- (symbol
- (inst cmp y (+ nil-value (static-symbol-offset val))))
- (character
- (inst cmp y (logior (ash (char-code val) n-widetag-bits)
- character-widetag))))))
- (t
- (inst cmp x y)))
+ (let ((x-val (encode-value-if-immediate x))
+ (y-val (encode-value-if-immediate y)))
+ (cond
+ ;; Shorter instruction sequences for these two cases.
+ ((eql 0 y-val) (inst test x x))
+ ((eql 0 x-val) (inst test y y))
+
+ ;; An encoded value (literal integer) has to be the second argument.
+ ((sc-is x immediate) (inst cmp y x-val))
+
+ (t (inst cmp x y-val))))
(inst jmp (if not-p :ne :e) target)))
(eql value (log 2l0 10l0))
(eql value (log 2l0 2.718281828459045235360287471352662L0)))
(sc-number-or-lose 'fp-constant)))))
+
+;; 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))
\f
;;;; miscellaneous function call parameters
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.4.72"
+"1.0.4.73"