X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fppc%2Fcell.lisp;h=ff164784a7705c910cfdfe2427933300dadf0d57;hb=d319b944d934f3efbb01a2a345c46bafd40857d0;hp=23532f5c0ecfb801e8d9160b944168b8b9f8172b;hpb=4ed3f0d08c3a57a6762018d9622f253ab9d0f2b6;p=sbcl.git diff --git a/src/compiler/ppc/cell.lisp b/src/compiler/ppc/cell.lisp index 23532f5..ff16478 100644 --- a/src/compiler/ppc/cell.lisp +++ b/src/compiler/ppc/cell.lisp @@ -11,7 +11,6 @@ ;;;; files for more information. (in-package "SB!VM") - ;;;; Data object ref/set stuff. @@ -25,24 +24,21 @@ (define-vop (set-slot) (:args (object :scs (descriptor-reg)) - (value :scs (descriptor-reg any-reg))) + (value :scs (descriptor-reg any-reg))) (:info name offset lowtag) (:ignore name) (:results) (:generator 1 (storew value object offset lowtag))) - ;;;; Symbol hacking VOPs: ;;; The compiler likes to be able to directly SET symbols. -;;; (define-vop (set cell-set) (:variant symbol-value-slot other-pointer-lowtag)) ;;; Do a cell ref with an error check for being unbound. -;;; (define-vop (checked-cell-ref) (:args (object :scs (descriptor-reg) :target obj-temp)) (:results (value :scs (descriptor-reg any-reg))) @@ -51,9 +47,8 @@ (:save-p :compute-only) (:temporary (:scs (descriptor-reg) :from (:argument 0)) obj-temp)) -;;; With Symbol-Value, we check that the value isn't the trap object. So -;;; Symbol-Value of NIL is NIL. -;;; +;;; With SYMBOL-VALUE, we check that the value isn't the trap object. +;;; So SYMBOL-VALUE of NIL is NIL. (define-vop (symbol-value checked-cell-ref) (:translate symbol-value) (:generator 9 @@ -63,7 +58,8 @@ (inst cmpwi value unbound-marker-widetag) (inst beq err-lab)))) -;;; Like CHECKED-CELL-REF, only we are a predicate to see if the cell is bound. +;;; Like CHECKED-CELL-REF, only we are a predicate to see if the cell +;;; is bound. (define-vop (boundp-frob) (:args (object :scs (descriptor-reg))) (:conditional) @@ -83,6 +79,19 @@ (:policy :fast) (:translate symbol-value)) +(define-vop (symbol-hash) + (:policy :fast-safe) + (:translate symbol-hash) + (:args (symbol :scs (descriptor-reg))) + (:results (res :scs (any-reg))) + (:result-types positive-fixnum) + (:generator 2 + ;; The symbol-hash slot of NIL holds NIL because it is also the + ;; cdr slot, so we have to strip off the two low bits to make sure + ;; it is a fixnum. The lowtag selection magic that is required to + ;; ensure this is explained in the comment in objdef.lisp + (loadw res symbol symbol-hash-slot other-pointer-lowtag) + (inst clrrwi res res (1- n-lowtag-bits)))) ;;;; Fdefinition (fdefn) objects. @@ -106,7 +115,7 @@ (:policy :fast-safe) (:translate (setf fdefn-fun)) (:args (function :scs (descriptor-reg) :target result) - (fdefn :scs (descriptor-reg))) + (fdefn :scs (descriptor-reg))) (:temporary (:scs (interior-reg)) lip) (:temporary (:scs (non-descriptor-reg)) type) (:results (result :scs (descriptor-reg))) @@ -116,9 +125,9 @@ (inst cmpwi type simple-fun-header-widetag) ;;(inst mr lip function) (inst addi lip function - (- (ash simple-fun-code-offset word-shift) fun-pointer-lowtag)) + (- (ash simple-fun-code-offset word-shift) fun-pointer-lowtag)) (inst beq normal-fn) - (inst lr lip (make-fixup (extern-alien-name "closure_tramp") :foreign)) + (inst lr lip (make-fixup "closure_tramp" :foreign)) (emit-label normal-fn) (storew lip fdefn fdefn-raw-addr-slot other-pointer-lowtag) (storew function fdefn fdefn-fun-slot other-pointer-lowtag) @@ -132,7 +141,7 @@ (:results (result :scs (descriptor-reg))) (:generator 38 (storew null-tn fdefn fdefn-fun-slot other-pointer-lowtag) - (inst lr temp (make-fixup (extern-alien-name "undefined_tramp") :foreign)) + (inst lr temp (make-fixup "undefined_tramp" :foreign)) (storew temp fdefn fdefn-raw-addr-slot other-pointer-lowtag) (move result fdefn))) @@ -146,7 +155,7 @@ (define-vop (bind) (:args (val :scs (any-reg descriptor-reg)) - (symbol :scs (descriptor-reg))) + (symbol :scs (descriptor-reg))) (:temporary (:scs (descriptor-reg)) temp) (:generator 5 (loadw temp symbol symbol-value-slot other-pointer-lowtag) @@ -172,8 +181,8 @@ (:temporary (:scs (descriptor-reg)) symbol value) (:generator 0 (let ((loop (gen-label)) - (skip (gen-label)) - (done (gen-label))) + (skip (gen-label)) + (done (gen-label))) (move where arg) (inst cmpw where bsp-tn) (inst beq done) @@ -257,13 +266,13 @@ (:arg-types instance (:constant index) *)) (define-vop (instance-index-ref word-index-ref) - (:policy :fast-safe) + (:policy :fast-safe) (:translate %instance-ref) (:variant instance-slots-offset instance-pointer-lowtag) (:arg-types instance positive-fixnum)) (define-vop (instance-index-set word-index-set) - (:policy :fast-safe) + (:policy :fast-safe) (:translate %instance-set) (:variant instance-slots-offset instance-pointer-lowtag) (:arg-types instance positive-fixnum *)) @@ -283,3 +292,250 @@ (:policy :fast-safe) (:variant 0 other-pointer-lowtag)) + + +;;;; raw instance slot accessors + +(define-vop (raw-instance-ref/word) + (:translate %raw-instance-ref/word) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg))) + (:arg-types * positive-fixnum) + (:results (value :scs (unsigned-reg))) + (:temporary (:scs (non-descriptor-reg)) offset) + (:result-types unsigned-num) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (1- instance-slots-offset) n-word-bytes) + instance-pointer-lowtag)) + (inst lwzx value object offset))) + +(define-vop (raw-instance-set/word) + (:translate %raw-instance-set/word) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg)) + (value :scs (unsigned-reg))) + (:arg-types * positive-fixnum unsigned-num) + (:results (result :scs (unsigned-reg))) + (:temporary (:scs (non-descriptor-reg)) offset) + (:result-types unsigned-num) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (1- instance-slots-offset) n-word-bytes) + instance-pointer-lowtag)) + (inst stwx value object offset) + (move result value))) + +(define-vop (raw-instance-ref/single) + (:translate %raw-instance-ref/single) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg))) + (:arg-types * positive-fixnum) + (:results (value :scs (single-reg))) + (:temporary (:scs (non-descriptor-reg)) offset) + (:result-types single-float) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (1- instance-slots-offset) n-word-bytes) + instance-pointer-lowtag)) + (inst lfsx value object offset))) + +(define-vop (raw-instance-set/single) + (:translate %raw-instance-set/single) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg)) + (value :scs (single-reg) :target result)) + (:arg-types * positive-fixnum single-float) + (:results (result :scs (single-reg))) + (:result-types single-float) + (:temporary (:scs (non-descriptor-reg)) offset) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (1- instance-slots-offset) n-word-bytes) + instance-pointer-lowtag)) + (inst stfsx value object offset) + (unless (location= result value) + (inst frsp result value)))) + +(define-vop (raw-instance-ref/double) + (:translate %raw-instance-ref/double) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg))) + (:arg-types * positive-fixnum) + (:results (value :scs (double-reg))) + (:temporary (:scs (non-descriptor-reg)) offset) + (:result-types double-float) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (- instance-slots-offset 2) n-word-bytes) + instance-pointer-lowtag)) + (inst lfdx value object offset))) + +(define-vop (raw-instance-set/double) + (:translate %raw-instance-set/double) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg)) + (value :scs (double-reg) :target result)) + (:arg-types * positive-fixnum double-float) + (:results (result :scs (double-reg))) + (:result-types double-float) + (:temporary (:scs (non-descriptor-reg)) offset) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (- instance-slots-offset 2) n-word-bytes) + instance-pointer-lowtag)) + (inst stfdx value object offset) + (unless (location= result value) + (inst fmr result value)))) + +(define-vop (raw-instance-ref/complex-single) + (:translate %raw-instance-ref/complex-single) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg))) + (:arg-types * positive-fixnum) + (:results (value :scs (complex-single-reg))) + (:temporary (:scs (non-descriptor-reg)) offset) + (:result-types complex-single-float) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (- instance-slots-offset 2) n-word-bytes) + instance-pointer-lowtag)) + (inst lfsx (complex-single-reg-real-tn value) object offset) + (inst addi offset offset n-word-bytes) + (inst lfsx (complex-single-reg-imag-tn value) object offset))) + +(define-vop (raw-instance-set/complex-single) + (:translate %raw-instance-set/complex-single) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg)) + (value :scs (complex-single-reg) :target result)) + (:arg-types * positive-fixnum complex-single-float) + (:results (result :scs (complex-single-reg))) + (:result-types complex-single-float) + (:temporary (:scs (non-descriptor-reg)) offset) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (- instance-slots-offset 2) n-word-bytes) + instance-pointer-lowtag)) + (let ((value-real (complex-single-reg-real-tn value)) + (result-real (complex-single-reg-real-tn result))) + (inst stfsx value-real object offset) + (unless (location= result-real value-real) + (inst frsp result-real value-real))) + (inst addi offset offset n-word-bytes) + (let ((value-imag (complex-single-reg-imag-tn value)) + (result-imag (complex-single-reg-imag-tn result))) + (inst stfsx value-imag object offset) + (unless (location= result-imag value-imag) + (inst frsp result-imag value-imag))))) + +(define-vop (raw-instance-ref/complex-double) + (:translate %raw-instance-ref/complex-double) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg))) + (:arg-types * positive-fixnum) + (:results (value :scs (complex-double-reg))) + (:temporary (:scs (non-descriptor-reg)) offset) + (:result-types complex-double-float) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (- instance-slots-offset 4) n-word-bytes) + instance-pointer-lowtag)) + (inst lfdx (complex-double-reg-real-tn value) object offset) + (inst addi offset offset (* 2 n-word-bytes)) + (inst lfdx (complex-double-reg-imag-tn value) object offset))) + +(define-vop (raw-instance-set/complex-double) + (:translate %raw-instance-set/complex-double) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (any-reg)) + (value :scs (complex-double-reg) :target result)) + (:arg-types * positive-fixnum complex-double-float) + (:results (result :scs (complex-double-reg))) + (:result-types complex-double-float) + (:temporary (:scs (non-descriptor-reg)) offset) + (:generator 5 + (loadw offset object 0 instance-pointer-lowtag) + (inst srwi offset offset n-widetag-bits) + (inst slwi offset offset 2) + (inst subf offset index offset) + (inst addi + offset + offset + (- (* (- instance-slots-offset 4) n-word-bytes) + instance-pointer-lowtag)) + (let ((value-real (complex-double-reg-real-tn value)) + (result-real (complex-double-reg-real-tn result))) + (inst stfdx value-real object offset) + (unless (location= result-real value-real) + (inst fmr result-real value-real))) + (inst addi offset offset (* 2 n-word-bytes)) + (let ((value-imag (complex-double-reg-imag-tn value)) + (result-imag (complex-double-reg-imag-tn result))) + (inst stfdx value-imag object offset) + (unless (location= result-imag value-imag) + (inst fmr result-imag value-imag)))))