Raymond Toy pushed to branch master at cmucl / cmucl

Commits:

6 changed files:

Changes:

  • bin/create-target.sh
    ... ... @@ -78,7 +78,7 @@ case $uname_s in
    78 78
    		OpenBSD*) motif_variant=OpenBSD ;;
    
    79 79
    		*_darwin) motif_variant=Darwin ;;
    
    80 80
    		sun4_solaris_gcc|sparc_gcc) motif_variant=solaris ;;
    
    81
    		sun4_solaris_sunc|sparc_sunc|x86_solaris_sunc) motif_variant=solaris_sunc ;;
    
    81
    		sun4_solaris_sunc|sparc_sunc|x86_solaris_sunc|sparc64_sunc) motif_variant=solaris_sunc ;;
    
    82 82
    		sun4c*) motif_variant=sun4c_411 ;;
    
    83 83
    		hp700*) motif_variant=hpux_cc ;;
    
    84 84
    		pmax_mach) motif_variant=pmax_mach ;;
    

  • src/assembly/sparcv9/alloc.lisp deleted
    1
    ;;; -*- Package: SPARC -*-
    
    2
    ;;;
    
    3
    ;;; **********************************************************************
    
    4
    ;;; This code was written as part of the CMU Common Lisp project at
    
    5
    ;;; Carnegie Mellon University, and has been placed in the public domain.
    
    6
    ;;;
    
    7
    (ext:file-comment
    
    8
      "$Header: src/assembly/sparc/alloc.lisp $")
    
    9
    ;;;
    
    10
    ;;; **********************************************************************
    
    11
    ;;;
    
    12
    ;;; Stuff to handle allocating simple objects.
    
    13
    ;;;
    
    14
    ;;; Written by William Lott.
    
    15
    ;;;
    
    16
    
    
    17
    (in-package "SPARC")
    
    18
    
    
    19
    ;;; But we do everything inline now that we have a better pseudo-atomic.

  • src/assembly/sparcv9/arith.lisp deleted
    1
    ;;; -*- Package: SPARC -*-
    
    2
    ;;;
    
    3
    ;;; **********************************************************************
    
    4
    ;;; This code was written as part of the CMU Common Lisp project at
    
    5
    ;;; Carnegie Mellon University, and has been placed in the public domain.
    
    6
    ;;;
    
    7
    (ext:file-comment
    
    8
      "$Header: src/assembly/sparc/arith.lisp $")
    
    9
    ;;;
    
    10
    ;;; **********************************************************************
    
    11
    ;;;
    
    12
    ;;; Stuff to handle simple cases for generic arithmetic.
    
    13
    ;;;
    
    14
    ;;; Written by William Lott.
    
    15
    ;;;
    
    16
    
    
    17
    (in-package "SPARC")
    
    18
    
    
    19
    
    
    20
    
    
    21
    ;;;; Addition and subtraction.
    
    22
    
    
    23
    (define-assembly-routine (generic-+
    
    24
    			  (:cost 10)
    
    25
    			  (:return-style :full-call)
    
    26
    			  (:translate +)
    
    27
    			  (:policy :safe)
    
    28
    			  (:save-p t))
    
    29
    			 ((:arg x (descriptor-reg any-reg) a0-offset)
    
    30
    			  (:arg y (descriptor-reg any-reg) a1-offset)
    
    31
    
    
    32
    			  (:res res (descriptor-reg any-reg) a0-offset)
    
    33
    
    
    34
    			  (:temp temp non-descriptor-reg nl0-offset)
    
    35
    			  (:temp temp2 non-descriptor-reg nl1-offset)
    
    36
    			  (:temp lra descriptor-reg lra-offset)
    
    37
    			  (:temp nargs any-reg nargs-offset)
    
    38
    			  (:temp ocfp any-reg ocfp-offset))
    
    39
      (inst andcc zero-tn x fixnum-tag-mask)
    
    40
      (inst b :ne DO-STATIC-FUN)
    
    41
      (inst andcc zero-tn y fixnum-tag-mask)
    
    42
      (inst b :ne DO-STATIC-FUN)
    
    43
      (inst nop)
    
    44
      (inst addcc temp x y)
    
    45
      (inst b :vc done)
    
    46
      (inst nop)
    
    47
    
    
    48
      (inst sra temp x fixnum-tag-bits)
    
    49
      (inst sra temp2 y fixnum-tag-bits)
    
    50
      (inst add temp2 temp)
    
    51
      (with-fixed-allocation (res temp bignum-type (1+ bignum-digits-offset))
    
    52
        (storew temp2 res bignum-digits-offset other-pointer-type))
    
    53
      (lisp-return lra :offset 2)
    
    54
    
    
    55
      DO-STATIC-FUN
    
    56
      (inst ld code-tn null-tn (static-function-offset 'two-arg-+))
    
    57
      (inst li nargs (fixnumize 2))
    
    58
      (inst move ocfp cfp-tn)
    
    59
      (inst j code-tn
    
    60
    	(- (* function-code-offset word-bytes) function-pointer-type))
    
    61
      (inst move cfp-tn csp-tn)
    
    62
    
    
    63
      DONE
    
    64
      (move res temp))
    
    65
    
    
    66
    
    
    67
    (define-assembly-routine (generic--
    
    68
    			  (:cost 10)
    
    69
    			  (:return-style :full-call)
    
    70
    			  (:translate -)
    
    71
    			  (:policy :safe)
    
    72
    			  (:save-p t))
    
    73
    			 ((:arg x (descriptor-reg any-reg) a0-offset)
    
    74
    			  (:arg y (descriptor-reg any-reg) a1-offset)
    
    75
    
    
    76
    			  (:res res (descriptor-reg any-reg) a0-offset)
    
    77
    
    
    78
    			  (:temp temp non-descriptor-reg nl0-offset)
    
    79
    			  (:temp temp2 non-descriptor-reg nl1-offset)
    
    80
    			  (:temp lra descriptor-reg lra-offset)
    
    81
    			  (:temp nargs any-reg nargs-offset)
    
    82
    			  (:temp ocfp any-reg ocfp-offset))
    
    83
      (inst andcc zero-tn x fixnum-tag-mask)
    
    84
      (inst b :ne DO-STATIC-FUN)
    
    85
      (inst andcc zero-tn y fixnum-tag-mask)
    
    86
      (inst b :ne DO-STATIC-FUN)
    
    87
      (inst nop)
    
    88
      (inst subcc temp x y)
    
    89
      (inst b :vc done)
    
    90
      (inst nop)
    
    91
    
    
    92
      (inst sra temp x fixnum-tag-bits)
    
    93
      (inst sra temp2 y fixnum-tag-bits)
    
    94
      (inst sub temp2 temp temp2)
    
    95
      (with-fixed-allocation (res temp bignum-type (1+ bignum-digits-offset))
    
    96
        (storew temp2 res bignum-digits-offset other-pointer-type))
    
    97
      (lisp-return lra :offset 2)
    
    98
    
    
    99
      DO-STATIC-FUN
    
    100
      (inst ld code-tn null-tn (static-function-offset 'two-arg--))
    
    101
      (inst li nargs (fixnumize 2))
    
    102
      (inst move ocfp cfp-tn)
    
    103
      (inst j code-tn
    
    104
    	(- (* function-code-offset word-bytes) function-pointer-type))
    
    105
      (inst move cfp-tn csp-tn)
    
    106
    
    
    107
      DONE
    
    108
      (move res temp))
    
    109
    
    
    110
    
    
    111
    
    
    112
    ;;;; Multiplication
    
    113
    
    
    114
    
    
    115
    (define-assembly-routine (generic-*
    
    116
    			  (:cost 50)
    
    117
    			  (:return-style :full-call)
    
    118
    			  (:translate *)
    
    119
    			  (:policy :safe)
    
    120
    			  (:save-p t))
    
    121
    			 ((:arg x (descriptor-reg any-reg) a0-offset)
    
    122
    			  (:arg y (descriptor-reg any-reg) a1-offset)
    
    123
    
    
    124
    			  (:res res (descriptor-reg any-reg) a0-offset)
    
    125
    
    
    126
    			  (:temp temp non-descriptor-reg nl0-offset)
    
    127
    			  (:temp lo non-descriptor-reg nl1-offset)
    
    128
    			  (:temp hi non-descriptor-reg nl2-offset)
    
    129
    			  (:temp lra descriptor-reg lra-offset)
    
    130
    			  (:temp nargs any-reg nargs-offset)
    
    131
    			  (:temp ocfp any-reg ocfp-offset))
    
    132
      ;; If either arg is not a fixnum, call the static function.
    
    133
      (inst andcc zero-tn x fixnum-tag-mask)
    
    134
      (inst b :ne DO-STATIC-FUN)
    
    135
      (inst andcc zero-tn y fixnum-tag-mask)
    
    136
      (inst b :ne DO-STATIC-FUN)
    
    137
      (inst nop)
    
    138
    
    
    139
      ;; Remove the tag from one arg so that the result will have the correct
    
    140
      ;; fixnum tag.
    
    141
      (inst sra temp x fixnum-tag-bits)
    
    142
      ;; Compute the produce temp * y and return the double-word product
    
    143
      ;; in hi:lo.
    
    144
      (cond ((backend-featurep :sparc-64)
    
    145
    	 ;; Sign extend y to a full 64-bits.  temp was already
    
    146
    	 ;; sign-extended by the sra instruction above.
    
    147
    	 (inst sra y 0)
    
    148
    	 (inst mulx hi temp y)
    
    149
    	 (inst move lo hi)
    
    150
    	 (inst srax hi 32))
    
    151
    	((or (backend-featurep :sparc-v8)
    
    152
    	     (backend-featurep :sparc-v9))
    
    153
    	 (inst smul lo temp y)
    
    154
    	 (inst rdy hi))
    
    155
    	(t
    
    156
    	 (let ((MULTIPLIER-POSITIVE (gen-label)))
    
    157
    	   (inst wry temp)
    
    158
    	   (inst andcc hi zero-tn)
    
    159
    	   (inst nop)
    
    160
    	   (inst nop)
    
    161
    	   (dotimes (i 32)
    
    162
    	     (inst mulscc hi y))
    
    163
    	   (inst mulscc hi zero-tn)
    
    164
    	   (inst cmp x)
    
    165
    	   (inst b :ge MULTIPLIER-POSITIVE)
    
    166
    	   (inst nop)
    
    167
    	   (inst sub hi y)
    
    168
    	   (emit-label MULTIPLIER-POSITIVE)
    
    169
    	   (inst rdy lo))))
    
    170
    
    
    171
      ;; Check to see if the result will fit in a fixnum.  (I.e. the high word
    
    172
      ;; is just 32 copies of the sign bit of the low word).
    
    173
      (inst sra temp lo 31)
    
    174
      (inst xorcc temp hi)
    
    175
      (inst b :eq LOW-FITS-IN-FIXNUM)
    
    176
      ;; Shift the double word hi:lo down two bits to get rid of the fixnum tag.
    
    177
      (inst sll temp hi 30)
    
    178
      (inst srl lo fixnum-tag-bits)
    
    179
      (inst or lo temp)
    
    180
      (inst sra hi fixnum-tag-bits)
    
    181
      ;; Allocate a BIGNUM for the result. We always allocate 2 words for
    
    182
      ;; the bignum result, even if we only need one.  The copying GC will
    
    183
      ;; take care of the extra word if it isn't needed.
    
    184
      (with-fixed-allocation
    
    185
          (res temp bignum-type (+ 2 bignum-digits-offset))
    
    186
        (let ((one-word (gen-label)))
    
    187
          ;; We start out assuming that we need one word.  Is that correct?
    
    188
          (inst sra temp lo 31)
    
    189
          (inst xorcc temp hi)
    
    190
          (inst b :eq one-word)
    
    191
          (inst li temp (logior (ash 1 type-bits) bignum-type))
    
    192
          ;; Need 2 words.  Set the header appropriately, and save the
    
    193
          ;; high and low parts.
    
    194
          (inst li temp (logior (ash 2 type-bits) bignum-type))
    
    195
          (storew hi res (1+ bignum-digits-offset) other-pointer-type)
    
    196
          (emit-label one-word)
    
    197
          (storew temp res 0 other-pointer-type)
    
    198
          (storew lo res bignum-digits-offset other-pointer-type)))
    
    199
      ;; Out of here
    
    200
      (lisp-return lra :offset 2)
    
    201
    
    
    202
      DO-STATIC-FUN
    
    203
      (inst ld code-tn null-tn (static-function-offset 'two-arg-*))
    
    204
      (inst li nargs (fixnumize 2))
    
    205
      (inst move ocfp cfp-tn)
    
    206
      (inst j code-tn
    
    207
    	(- (* function-code-offset word-bytes) function-pointer-type))
    
    208
      (inst move cfp-tn csp-tn)
    
    209
    
    
    210
      LOW-FITS-IN-FIXNUM
    
    211
      (move res lo))
    
    212
    
    
    213
    
    
    214
    ;;;; Comparison
    
    215
    
    
    216
    (macrolet
    
    217
        ((define-cond-assem-rtn (name translate static-fn cmp)
    
    218
           `(define-assembly-routine (,name
    
    219
    				  (:cost 10)
    
    220
    				  (:return-style :full-call)
    
    221
    				  (:policy :safe)
    
    222
    				  (:translate ,translate)
    
    223
    				  (:save-p t))
    
    224
    				 ((:arg x (descriptor-reg any-reg) a0-offset)
    
    225
    				  (:arg y (descriptor-reg any-reg) a1-offset)
    
    226
    				  
    
    227
    				  (:res res descriptor-reg a0-offset)
    
    228
    				  
    
    229
    				  (:temp nargs any-reg nargs-offset)
    
    230
    				  (:temp ocfp any-reg ocfp-offset))
    
    231
    	  (inst andcc zero-tn x fixnum-tag-mask)
    
    232
    	  (inst b :ne DO-STATIC-FN)
    
    233
    	  (inst andcc zero-tn y fixnum-tag-mask)
    
    234
    	  (inst b :eq DO-COMPARE)
    
    235
    	  (inst cmp x y)
    
    236
    	  
    
    237
    	  DO-STATIC-FN
    
    238
    	  (inst ld code-tn null-tn (static-function-offset ',static-fn))
    
    239
    	  (inst li nargs (fixnumize 2))
    
    240
    	  (inst move ocfp cfp-tn)
    
    241
    	  (inst j code-tn
    
    242
    		(- (* function-code-offset word-bytes) function-pointer-type))
    
    243
    	  (inst move cfp-tn csp-tn)
    
    244
    	  
    
    245
    	  DO-COMPARE
    
    246
    	  (inst b ,cmp done)
    
    247
    	  (load-symbol res t)
    
    248
    	  (inst move res null-tn)
    
    249
    	  DONE)))
    
    250
    
    
    251
      (define-cond-assem-rtn generic-< < two-arg-< :lt)
    
    252
      (define-cond-assem-rtn generic-<= <= two-arg-<= :le)
    
    253
      (define-cond-assem-rtn generic-> > two-arg-> :gt)
    
    254
      (define-cond-assem-rtn generic->= >= two-arg->= :ge))
    
    255
    
    
    256
    
    
    257
    (define-assembly-routine (generic-eql
    
    258
    			  (:cost 10)
    
    259
    			  (:return-style :full-call)
    
    260
    			  (:policy :safe)
    
    261
    			  (:translate eql)
    
    262
    			  (:save-p t))
    
    263
    			 ((:arg x (descriptor-reg any-reg) a0-offset)
    
    264
    			  (:arg y (descriptor-reg any-reg) a1-offset)
    
    265
    			  
    
    266
    			  (:res res descriptor-reg a0-offset)
    
    267
    
    
    268
    			  (:temp lra descriptor-reg lra-offset)
    
    269
    			  (:temp nargs any-reg nargs-offset)
    
    270
    			  (:temp ocfp any-reg ocfp-offset))
    
    271
      (inst cmp x y)
    
    272
      (inst b :eq RETURN-T)
    
    273
      (inst andcc zero-tn x fixnum-tag-mask)
    
    274
      (inst b :eq RETURN-NIL)
    
    275
      (inst andcc zero-tn y fixnum-tag-mask)
    
    276
      (inst b :ne DO-STATIC-FN)
    
    277
      (inst nop)
    
    278
    
    
    279
      RETURN-NIL
    
    280
      (inst move res null-tn)
    
    281
      (lisp-return lra :offset 2)
    
    282
    
    
    283
      DO-STATIC-FN
    
    284
      (inst ld code-tn null-tn (static-function-offset 'eql))
    
    285
      (inst li nargs (fixnumize 2))
    
    286
      (inst move ocfp cfp-tn)
    
    287
      (inst j code-tn
    
    288
    	(- (* function-code-offset word-bytes) function-pointer-type))
    
    289
      (inst move cfp-tn csp-tn)
    
    290
    
    
    291
      RETURN-T
    
    292
      (load-symbol res t))
    
    293
    
    
    294
    (define-assembly-routine (generic-=
    
    295
    			  (:cost 10)
    
    296
    			  (:return-style :full-call)
    
    297
    			  (:policy :safe)
    
    298
    			  (:translate =)
    
    299
    			  (:save-p t))
    
    300
    			 ((:arg x (descriptor-reg any-reg) a0-offset)
    
    301
    			  (:arg y (descriptor-reg any-reg) a1-offset)
    
    302
    
    
    303
    			  (:res res descriptor-reg a0-offset)
    
    304
    
    
    305
    			  (:temp lra descriptor-reg lra-offset)
    
    306
    			  (:temp nargs any-reg nargs-offset)
    
    307
    			  (:temp ocfp any-reg ocfp-offset))
    
    308
      (inst andcc zero-tn x fixnum-tag-mask)
    
    309
      (inst b :ne DO-STATIC-FN)
    
    310
      (inst andcc zero-tn y fixnum-tag-mask)
    
    311
      (inst b :ne DO-STATIC-FN)
    
    312
      (inst cmp x y)
    
    313
      (inst b :eq RETURN-T)
    
    314
      (inst nop)
    
    315
    
    
    316
      (inst move res null-tn)
    
    317
      (lisp-return lra :offset 2)
    
    318
    
    
    319
      DO-STATIC-FN
    
    320
      (inst ld code-tn null-tn (static-function-offset 'two-arg-=))
    
    321
      (inst li nargs (fixnumize 2))
    
    322
      (inst move ocfp cfp-tn)
    
    323
      (inst j code-tn
    
    324
    	(- (* function-code-offset word-bytes) function-pointer-type))
    
    325
      (inst move cfp-tn csp-tn)
    
    326
    
    
    327
      RETURN-T
    
    328
      (load-symbol res t))
    
    329
    
    
    330
    (define-assembly-routine (generic-/=
    
    331
    			  (:cost 10)
    
    332
    			  (:return-style :full-call)
    
    333
    			  (:policy :safe)
    
    334
    			  (:translate /=)
    
    335
    			  (:save-p t))
    
    336
    			 ((:arg x (descriptor-reg any-reg) a0-offset)
    
    337
    			  (:arg y (descriptor-reg any-reg) a1-offset)
    
    338
    
    
    339
    			  (:res res descriptor-reg a0-offset)
    
    340
    
    
    341
    			  (:temp lra descriptor-reg lra-offset)
    
    342
    			  (:temp nargs any-reg nargs-offset)
    
    343
    			  (:temp ocfp any-reg ocfp-offset))
    
    344
      (inst cmp x y)
    
    345
      (inst b :eq RETURN-NIL)
    
    346
      (inst andcc zero-tn x fixnum-tag-mask)
    
    347
      (inst b :ne DO-STATIC-FN)
    
    348
      (inst andcc zero-tn y fixnum-tag-mask)
    
    349
      (inst b :ne DO-STATIC-FN)
    
    350
      (inst nop)
    
    351
    
    
    352
      (load-symbol res t)
    
    353
      (lisp-return lra :offset 2)
    
    354
    
    
    355
      DO-STATIC-FN
    
    356
      (inst ld code-tn null-tn (static-function-offset 'two-arg-=))
    
    357
      (inst li nargs (fixnumize 2))
    
    358
      (inst move ocfp cfp-tn)
    
    359
      (inst j code-tn
    
    360
    	(- (* function-code-offset word-bytes) function-pointer-type))
    
    361
      (inst move cfp-tn csp-tn)
    
    362
    
    
    363
      RETURN-NIL
    
    364
      (inst move res null-tn))

  • src/assembly/sparcv9/array.lisp deleted
    1
    ;;; -*- Package: SPARC -*-
    
    2
    ;;;
    
    3
    ;;; **********************************************************************
    
    4
    ;;; This code was written as part of the CMU Common Lisp project at
    
    5
    ;;; Carnegie Mellon University, and has been placed in the public domain.
    
    6
    ;;;
    
    7
    (ext:file-comment
    
    8
      "$Header: src/assembly/sparc/array.lisp $")
    
    9
    ;;;
    
    10
    ;;; **********************************************************************
    
    11
    ;;;
    
    12
    ;;; $Header: src/assembly/sparc/array.lisp $
    
    13
    ;;;
    
    14
    ;;;    This file contains the support routines for arrays and vectors.
    
    15
    ;;;
    
    16
    ;;; Written by William Lott.
    
    17
    ;;; 
    
    18
    (in-package "SPARC")
    
    19
    
    
    20
    
    
    21
    (define-assembly-routine (allocate-vector
    
    22
    			  (:policy :fast-safe)
    
    23
    			  (:translate allocate-vector)
    
    24
    			  (:arg-types positive-fixnum
    
    25
    				      positive-fixnum
    
    26
    				      positive-fixnum))
    
    27
    			 ((:arg type any-reg a0-offset)
    
    28
    			  (:arg length any-reg a1-offset)
    
    29
    			  (:arg words any-reg a2-offset)
    
    30
    			  (:res result descriptor-reg a0-offset)
    
    31
    
    
    32
    			  (:temp ndescr non-descriptor-reg nl0-offset)
    
    33
    			  (:temp gc-temp non-descriptor-reg nl1-offset)
    
    34
    			  (:temp vector descriptor-reg a3-offset))
    
    35
      (pseudo-atomic ()
    
    36
        (inst add ndescr words (* (1+ vm:vector-data-offset) vm:word-bytes))
    
    37
        (inst andn ndescr vm:lowtag-mask)
    
    38
        (allocation vector ndescr other-pointer-type :temp-tn gc-temp)
    
    39
        #+gencgc
    
    40
        (progn
    
    41
          ;; ndescr points to one word past the end of the allocated
    
    42
          ;; space.  Fill the last word with a zero.
    
    43
          (inst add ndescr vector)
    
    44
          (storew zero-tn ndescr -1 vm:other-pointer-type))
    
    45
        (inst srl ndescr type vm:word-shift)
    
    46
        (storew ndescr vector 0 vm:other-pointer-type)
    
    47
        (storew length vector vm:vector-length-slot vm:other-pointer-type))
    
    48
      ;; This makes sure the zero byte at the end of a string is paged in so
    
    49
      ;; the kernel doesn't bitch if we pass it the string.
    
    50
      ;;
    
    51
      ;; This used to write to the word after the last allocated word.  I
    
    52
      ;; (RLT) made it write to the last allocated word, which is where
    
    53
      ;; the zero-byte of the string is.  Look at the deftransform for
    
    54
      ;; make-array in array-tran.lisp.  For strings we always allocate
    
    55
      ;; enough space to hold the zero-byte.
    
    56
      #-gencgc
    
    57
      (storew zero-tn alloc-tn -1)
    
    58
      (move result vector))
    
    59
    
    
    60
    
    
    61
    
    
    62
    ;;;; Hash primitives
    
    63
    
    
    64
    #+assembler
    
    65
    (defparameter sxhash-simple-substring-entry (gen-label))
    
    66
    
    
    67
    (define-assembly-routine (sxhash-simple-string
    
    68
    			  (:translate %sxhash-simple-string)
    
    69
    			  (:policy :fast-safe)
    
    70
    			  (:result-types positive-fixnum))
    
    71
    			 ((:arg string descriptor-reg a0-offset)
    
    72
    			  (:res result any-reg a0-offset)
    
    73
    
    
    74
    			  (:temp length any-reg a1-offset)
    
    75
    			  (:temp accum non-descriptor-reg nl0-offset)
    
    76
    			  (:temp data non-descriptor-reg nl1-offset)
    
    77
    			  (:temp temp non-descriptor-reg nl2-offset)
    
    78
    			  (:temp offset non-descriptor-reg nl3-offset))
    
    79
    
    
    80
      (declare (ignore result accum data temp offset))
    
    81
    
    
    82
      (inst b sxhash-simple-substring-entry)
    
    83
      (loadw length string vm:vector-length-slot vm:other-pointer-type))
    
    84
    
    
    85
    
    
    86
    ;; Implement the one-at-a-time algorithm designed by Bob Jenkins
    
    87
    ;; (see <http://burtleburtle.net/bob/hash/doobs.html> for some
    
    88
    ;; more information).
    
    89
    ;;
    
    90
    ;; For completeness, here is the hash function, in C, from that web
    
    91
    ;; page.  ub4 is an unsigned 32-bit integer.
    
    92
    
    
    93
    #||
    
    94
    ub4 one_at_a_time(char *key, ub4 len)
    
    95
    {
    
    96
      ub4   hash, i;
    
    97
      for (hash=0, i=0; i<len; ++i)
    
    98
      {
    
    99
        hash += key[i];
    
    100
        hash += (hash << 10);
    
    101
        hash ^= (hash >> 6);
    
    102
      }
    
    103
      hash += (hash << 3);
    
    104
      hash ^= (hash >> 11);
    
    105
      hash += (hash << 15);
    
    106
      return (hash & mask);
    
    107
    } 
    
    108
    
    
    109
    ||#
    
    110
    
    
    111
    
    
    112
    (define-assembly-routine (sxhash-simple-substring
    
    113
    			  (:translate %sxhash-simple-substring)
    
    114
    			  (:policy :fast-safe)
    
    115
    			  (:arg-types * positive-fixnum)
    
    116
    			  (:result-types positive-fixnum))
    
    117
    			 ((:arg string descriptor-reg a0-offset)
    
    118
    			  (:arg length any-reg a1-offset)
    
    119
    			  (:res result any-reg a0-offset)
    
    120
    
    
    121
    			  (:temp accum non-descriptor-reg nl0-offset)
    
    122
    			  (:temp data non-descriptor-reg nl1-offset)
    
    123
    			  (:temp temp non-descriptor-reg nl2-offset)
    
    124
    			  (:temp offset non-descriptor-reg nl3-offset))
    
    125
      (emit-label sxhash-simple-substring-entry)
    
    126
    
    
    127
      #+unicode
    
    128
      (inst sll length 1)		  ; Number of bytes = twice the length
    
    129
      
    
    130
      (inst li offset (- (* vector-data-offset word-bytes) other-pointer-type))
    
    131
      (inst b test)
    
    132
      (move accum zero-tn)
    
    133
    
    
    134
      LOOP
    
    135
    
    
    136
      ;; hash += key[i]
    
    137
      (inst add accum data)
    
    138
      ;; hash += (hash << 10)
    
    139
      (inst slln temp accum 10)
    
    140
      (inst add accum temp)
    
    141
      ;; hash ^= (hash >> 6)
    
    142
      (inst srln temp accum 6)
    
    143
      (inst xor accum temp)
    
    144
      (inst add offset 1)
    
    145
      
    
    146
      TEST
    
    147
    
    
    148
      (inst subcc length (fixnumize 1))
    
    149
      (inst b :ge loop)
    
    150
      (inst ldub data string offset)
    
    151
    
    
    152
      ;; hash += (hash << 3)
    
    153
      (inst slln temp accum 3)
    
    154
      (inst add accum temp)
    
    155
      ;; hash ^= (hash >> 11)
    
    156
      (inst srln temp accum 11)
    
    157
      (inst xor accum temp)
    
    158
      ;; hash += (hash << 15)
    
    159
      (inst slln temp accum 15)
    
    160
      (inst add accum temp)
    
    161
      
    
    162
      ;;(inst li temp most-positive-fixnum)
    
    163
      ;;(inst and accum temp)
    
    164
      ;; Make it a fixnum result
    
    165
    
    
    166
      ;; Make the result a positive fixnum.  Shifting it left, then right
    
    167
      ;; does what we want, and extracts the bits we need.
    
    168
      (inst slln accum (1+ vm:fixnum-tag-bits))
    
    169
      (inst srln result accum 1))

  • src/assembly/sparcv9/assem-rtns.lisp deleted
    1
    ;;; -*- Package: SPARC -*-
    
    2
    ;;;
    
    3
    ;;; **********************************************************************
    
    4
    ;;; This code was written as part of the CMU Common Lisp project at
    
    5
    ;;; Carnegie Mellon University, and has been placed in the public domain.
    
    6
    ;;;
    
    7
    (ext:file-comment
    
    8
      "$Header: src/assembly/sparc/assem-rtns.lisp $")
    
    9
    ;;;
    
    10
    ;;; **********************************************************************
    
    11
    ;;;
    
    12
    ;;; $Header: src/assembly/sparc/assem-rtns.lisp $
    
    13
    ;;;
    
    14
    ;;;
    
    15
    (in-package "SPARC")
    
    16
    
    
    17
    
    
    18
    ;;;; Return-multiple with other than one value
    
    19
    
    
    20
    #+assembler ;; we don't want a vop for this one.
    
    21
    (define-assembly-routine
    
    22
        (return-multiple
    
    23
         (:return-style :none))
    
    24
    
    
    25
         ;; These four are really arguments.
    
    26
        ((:temp nvals any-reg nargs-offset)
    
    27
         (:temp vals any-reg nl0-offset)
    
    28
         (:temp ocfp any-reg nl1-offset)
    
    29
         (:temp lra descriptor-reg lra-offset)
    
    30
    
    
    31
         ;; These are just needed to facilitate the transfer
    
    32
         (:temp count any-reg nl2-offset)
    
    33
         (:temp src any-reg nl3-offset)
    
    34
         (:temp dst any-reg nl4-offset)
    
    35
         (:temp temp descriptor-reg cname-offset)
    
    36
    
    
    37
         ;; These are needed so we can get at the register args.
    
    38
         (:temp a0 descriptor-reg a0-offset)
    
    39
         (:temp a1 descriptor-reg a1-offset)
    
    40
         (:temp a2 descriptor-reg a2-offset)
    
    41
         (:temp a3 descriptor-reg a3-offset)
    
    42
         (:temp a4 descriptor-reg a4-offset)
    
    43
         (:temp a5 descriptor-reg a5-offset))
    
    44
    
    
    45
      ;; Note, because of the way the return-multiple vop is written, we can
    
    46
      ;; assume that we are never called with nvals == 1 and that a0 has already
    
    47
      ;; been loaded.
    
    48
      (inst cmp nvals)
    
    49
      (inst b :le default-a0-and-on)
    
    50
      (inst cmp nvals (fixnumize 2))
    
    51
      (inst b :le default-a2-and-on)
    
    52
      (inst ld a1 vals (* 1 vm:word-bytes))
    
    53
      (inst cmp nvals (fixnumize 3))
    
    54
      (inst b :le default-a3-and-on)
    
    55
      (inst ld a2 vals (* 2 vm:word-bytes))
    
    56
      (inst cmp nvals (fixnumize 4))
    
    57
      (inst b :le default-a4-and-on)
    
    58
      (inst ld a3 vals (* 3 vm:word-bytes))
    
    59
      (inst cmp nvals (fixnumize 5))
    
    60
      (inst b :le default-a5-and-on)
    
    61
      (inst ld a4 vals (* 4 vm:word-bytes))
    
    62
      (inst cmp nvals (fixnumize 6))
    
    63
      (inst b :le done)
    
    64
      (inst ld a5 vals (* 5 vm:word-bytes))
    
    65
    
    
    66
      ;; Copy the remaining args to the top of the stack.
    
    67
      (inst add src vals (* 6 vm:word-bytes))
    
    68
      (inst add dst cfp-tn (* 6 vm:word-bytes))
    
    69
      (inst subcc count nvals (fixnumize 6))
    
    70
    
    
    71
      LOOP
    
    72
      (inst ld temp src)
    
    73
      (inst add src vm:word-bytes)
    
    74
      (inst st temp dst)
    
    75
      (inst add dst vm:word-bytes)
    
    76
      (inst b :gt loop)
    
    77
      (inst subcc count (fixnumize 1))
    
    78
    		
    
    79
      (inst b done)
    
    80
      (inst nop)
    
    81
    
    
    82
      DEFAULT-A0-AND-ON
    
    83
      (inst move a0 null-tn)
    
    84
      (inst move a1 null-tn)
    
    85
      DEFAULT-A2-AND-ON
    
    86
      (inst move a2 null-tn)
    
    87
      DEFAULT-A3-AND-ON
    
    88
      (inst move a3 null-tn)
    
    89
      DEFAULT-A4-AND-ON
    
    90
      (inst move a4 null-tn)
    
    91
      DEFAULT-A5-AND-ON
    
    92
      (inst move a5 null-tn)
    
    93
      DONE
    
    94
      
    
    95
      ;; Clear the stack.
    
    96
      (move ocfp-tn cfp-tn)
    
    97
      (move cfp-tn ocfp)
    
    98
      (inst add csp-tn ocfp-tn nvals)
    
    99
      
    
    100
      ;; Return.
    
    101
      (lisp-return lra))
    
    102
    
    
    103
    
    
    104
    
    
    105
    ;;;; tail-call-variable.
    
    106
    
    
    107
    #+assembler ;; no vop for this one either.
    
    108
    (define-assembly-routine
    
    109
        (tail-call-variable
    
    110
         (:return-style :none))
    
    111
    
    
    112
        ;; These are really args.
    
    113
        ((:temp args any-reg nl0-offset)
    
    114
         (:temp lexenv descriptor-reg lexenv-offset)
    
    115
    
    
    116
         ;; We need to compute this
    
    117
         (:temp nargs any-reg nargs-offset)
    
    118
    
    
    119
         ;; These are needed by the blitting code.
    
    120
         (:temp src any-reg nl1-offset)
    
    121
         (:temp dst any-reg nl2-offset)
    
    122
         (:temp count any-reg nl3-offset)
    
    123
         (:temp temp descriptor-reg cname-offset)
    
    124
    
    
    125
         ;; These are needed so we can get at the register args.
    
    126
         (:temp a0 descriptor-reg a0-offset)
    
    127
         (:temp a1 descriptor-reg a1-offset)
    
    128
         (:temp a2 descriptor-reg a2-offset)
    
    129
         (:temp a3 descriptor-reg a3-offset)
    
    130
         (:temp a4 descriptor-reg a4-offset)
    
    131
         (:temp a5 descriptor-reg a5-offset))
    
    132
    
    
    133
    
    
    134
      ;; Calculate NARGS (as a fixnum)
    
    135
      (inst sub nargs csp-tn args)
    
    136
         
    
    137
      ;; Load the argument regs (must do this now, 'cause the blt might
    
    138
      ;; trash these locations)
    
    139
      (inst ld a0 args (* 0 vm:word-bytes))
    
    140
      (inst ld a1 args (* 1 vm:word-bytes))
    
    141
      (inst ld a2 args (* 2 vm:word-bytes))
    
    142
      (inst ld a3 args (* 3 vm:word-bytes))
    
    143
      (inst ld a4 args (* 4 vm:word-bytes))
    
    144
      (inst ld a5 args (* 5 vm:word-bytes))
    
    145
    
    
    146
      ;; Calc SRC, DST, and COUNT
    
    147
      (inst addcc count nargs (fixnumize (- register-arg-count)))
    
    148
      (inst b :le done)
    
    149
      (inst add src args (* vm:word-bytes register-arg-count))
    
    150
      (inst add dst cfp-tn (* vm:word-bytes register-arg-count))
    
    151
    	
    
    152
      LOOP
    
    153
      ;; Copy one arg.
    
    154
      (inst ld temp src)
    
    155
      (inst add src src vm:word-bytes)
    
    156
      (inst st temp dst)
    
    157
      (inst addcc count (fixnumize -1))
    
    158
      (inst b :gt loop)
    
    159
      (inst add dst dst vm:word-bytes)
    
    160
    	
    
    161
      DONE
    
    162
      ;; We are done.  Do the jump.
    
    163
      (loadw temp lexenv vm:closure-function-slot vm:function-pointer-type)
    
    164
      (lisp-jump temp))
    
    165
    
    
    166
    
    
    167
    
    
    168
    ;;;; Non-local exit noise.
    
    169
    
    
    170
    (define-assembly-routine (unwind
    
    171
    			  (:return-style :none)
    
    172
    			  (:translate %continue-unwind)
    
    173
    			  (:policy :fast-safe))
    
    174
    			 ((:arg block (any-reg descriptor-reg) a0-offset)
    
    175
    			  (:arg start (any-reg descriptor-reg) ocfp-offset)
    
    176
    			  (:arg count (any-reg descriptor-reg) nargs-offset)
    
    177
    			  (:temp lra descriptor-reg lra-offset)
    
    178
    			  (:temp cur-uwp any-reg nl0-offset)
    
    179
    			  (:temp next-uwp any-reg nl1-offset)
    
    180
    			  (:temp target-uwp any-reg nl2-offset))
    
    181
      (declare (ignore start count))
    
    182
    
    
    183
      (let ((error (generate-error-code nil invalid-unwind-error)))
    
    184
        (inst cmp block)
    
    185
        (inst b :eq error))
    
    186
      
    
    187
      (load-symbol-value cur-uwp lisp::*current-unwind-protect-block*)
    
    188
      (loadw target-uwp block vm:unwind-block-current-uwp-slot)
    
    189
      (inst cmp cur-uwp target-uwp)
    
    190
      (inst b :ne do-uwp)
    
    191
      (inst nop)
    
    192
          
    
    193
      (move cur-uwp block)
    
    194
    
    
    195
      DO-EXIT
    
    196
          
    
    197
      (loadw cfp-tn cur-uwp vm:unwind-block-current-cont-slot)
    
    198
      (loadw code-tn cur-uwp vm:unwind-block-current-code-slot)
    
    199
      (loadw lra cur-uwp vm:unwind-block-entry-pc-slot)
    
    200
      (lisp-return lra :frob-code nil)
    
    201
    
    
    202
      DO-UWP
    
    203
    
    
    204
      (loadw next-uwp cur-uwp vm:unwind-block-current-uwp-slot)
    
    205
      (inst b do-exit)
    
    206
      (store-symbol-value next-uwp lisp::*current-unwind-protect-block*))
    
    207
    
    
    208
    
    
    209
    (define-assembly-routine (throw
    
    210
    			  (:return-style :none))
    
    211
    			 ((:arg target descriptor-reg a0-offset)
    
    212
    			  (:arg start any-reg ocfp-offset)
    
    213
    			  (:arg count any-reg nargs-offset)
    
    214
    			  (:temp catch any-reg a1-offset)
    
    215
    			  (:temp tag descriptor-reg a2-offset)
    
    216
    			  (:temp temp non-descriptor-reg nl0-offset))
    
    217
      
    
    218
      (declare (ignore start count))
    
    219
    
    
    220
      (load-symbol-value catch lisp::*current-catch-block*)
    
    221
      
    
    222
      loop
    
    223
      
    
    224
      (let ((error (generate-error-code nil unseen-throw-tag-error target)))
    
    225
        (inst cmp catch)
    
    226
        (inst b :eq error)
    
    227
        (inst nop))
    
    228
      
    
    229
      (loadw tag catch vm:catch-block-tag-slot)
    
    230
      (inst cmp tag target)
    
    231
      (inst b :eq exit)
    
    232
      (inst nop)
    
    233
      (loadw catch catch vm:catch-block-previous-catch-slot)
    
    234
      (inst b loop)
    
    235
      (inst nop)
    
    236
      
    
    237
      exit
    
    238
      
    
    239
      (move target catch)
    
    240
      (inst li temp (make-fixup 'unwind :assembly-routine))
    
    241
      (inst j temp)
    
    242
      (inst nop))
    
    243
    
    
    244
    
    
    245
    
    
    246
    
    
    247
    ;; Assembly routines for undefined_tramp and closure_tramp
    
    248
    
    
    249
    #+assembler
    
    250
    (define-assembly-routine (closure-tramp-function-alignment
    
    251
    			  (:return-style :none))
    
    252
                             ()
    
    253
      ;; Align to a dualword and put in the magic function header stuff so
    
    254
      ;; that closure-tramp looks like a normal function with a function
    
    255
      ;; tag.
    
    256
      (align vm:lowtag-bits)
    
    257
      (inst byte 0))
    
    258
    
    
    259
    #+assembler
    
    260
    (define-assembly-routine (closure-tramp
    
    261
    			  (:return-style :none))
    
    262
                             ()
    
    263
      (inst byte 0)
    
    264
      (inst byte 0)
    
    265
      (inst byte vm:function-header-type)
    
    266
      ;; This is supposed to be closure-tramp, not 0.
    
    267
      (inst word 0)
    
    268
      (inst word (kernel:get-lisp-obj-address nil))
    
    269
      (inst word (kernel:get-lisp-obj-address nil))
    
    270
      (inst word (kernel:get-lisp-obj-address nil))
    
    271
      (inst word (kernel:get-lisp-obj-address nil))
    
    272
    
    
    273
      (loadw lexenv-tn cname-tn fdefn-function-slot other-pointer-type)
    
    274
      (loadw code-tn lexenv-tn closure-function-slot function-pointer-type)
    
    275
      (inst j code-tn (- (* function-code-offset word-bytes) function-pointer-type))
    
    276
      (inst nop)
    
    277
      ;; Make sure following routine is dual-word aligned
    
    278
      (align vm:lowtag-bits))
    
    279
    
    
    280
    #+assembler
    
    281
    (define-assembly-routine (undefined-tramp-function-alignment
    
    282
    			  (:return-style :none))
    
    283
                             ()
    
    284
      ;; Align to a dualword and put in the magic function header stuff so
    
    285
      ;; that closure-tramp looks like a normal function with a function
    
    286
      ;; tag.
    
    287
      (align vm:lowtag-bits)
    
    288
      (inst byte 0))
    
    289
    
    
    290
    #+assembler
    
    291
    (define-assembly-routine (undefined-tramp
    
    292
    			  (:return-style :none))
    
    293
                             ()
    
    294
      (inst byte 0)
    
    295
      (inst byte 0)
    
    296
      (inst byte vm:function-header-type)
    
    297
      ;; This is supposed to be undefined-tramp, not 0.
    
    298
      (inst word 0)
    
    299
      (inst word (kernel:get-lisp-obj-address nil))
    
    300
      (inst word (kernel:get-lisp-obj-address nil))
    
    301
      (inst word (kernel:get-lisp-obj-address nil))
    
    302
      (inst word (kernel:get-lisp-obj-address nil))
    
    303
    
    
    304
      (let ((error (generate-cerror-code nil undefined-symbol-error cname-tn)))
    
    305
        (inst b error)
    
    306
        (inst nop)
    
    307
        ;; I don't think we ever return from the undefined-symbol-error
    
    308
        ;; handler, but the assembly code did this so we'll do it too.
    
    309
        (loadw code-tn cname-tn fdefn-raw-addr-slot other-pointer-type)
    
    310
        (inst j code-tn (- (* function-code-offset word-bytes) function-pointer-type))
    
    311
        (inst nop)))

  • src/assembly/sparcv9/support.lisp deleted
    1
    ;;; -*- Package: SPARC -*-
    
    2
    ;;;
    
    3
    ;;; **********************************************************************
    
    4
    ;;; This code was written as part of the CMU Common Lisp project at
    
    5
    ;;; Carnegie Mellon University, and has been placed in the public domain.
    
    6
    ;;;
    
    7
    (ext:file-comment
    
    8
      "$Header: src/assembly/sparc/support.lisp $")
    
    9
    ;;;
    
    10
    ;;; **********************************************************************
    
    11
    ;;;
    
    12
    (in-package "SPARC")
    
    13
    
    
    14
    (def-vm-support-routine generate-call-sequence (name style vop)
    
    15
      (ecase style
    
    16
        (:raw
    
    17
         (let ((temp (make-symbol "TEMP"))
    
    18
    	   (lip (make-symbol "LIP")))
    
    19
           (values 
    
    20
    	`((inst jali ,lip ,temp (make-fixup ',name :assembly-routine))
    
    21
    	  (inst nop))
    
    22
    	`((:temporary (:scs (non-descriptor-reg) :from (:eval 0) :to (:eval 1))
    
    23
    		      ,temp)
    
    24
    	  (:temporary (:scs (interior-reg) :from (:eval 0) :to (:eval 1))
    
    25
    		      ,lip)))))
    
    26
        (:full-call
    
    27
         (let ((temp (make-symbol "TEMP"))
    
    28
    	   (nfp-save (make-symbol "NFP-SAVE"))
    
    29
    	   (lra (make-symbol "LRA")))
    
    30
           (values
    
    31
    	`((let ((lra-label (gen-label))
    
    32
    		(cur-nfp (current-nfp-tn ,vop)))
    
    33
    	    (when cur-nfp
    
    34
    	      (store-stack-tn ,nfp-save cur-nfp))
    
    35
    	    (inst compute-lra-from-code ,lra code-tn lra-label ,temp)
    
    36
    	    (note-next-instruction ,vop :call-site)
    
    37
    	    (inst ji ,temp (make-fixup ',name :assembly-routine))
    
    38
    	    (inst nop)
    
    39
    	    (emit-return-pc lra-label)
    
    40
    	    (note-this-location ,vop :single-value-return)
    
    41
    	    (without-scheduling ()
    
    42
    	      (move csp-tn ocfp-tn)
    
    43
    	      (inst nop))
    
    44
    	    (inst compute-code-from-lra code-tn code-tn
    
    45
    		  lra-label ,temp)
    
    46
    	    (when cur-nfp
    
    47
    	      (load-stack-tn cur-nfp ,nfp-save))))
    
    48
    	`((:temporary (:scs (non-descriptor-reg) :from (:eval 0) :to (:eval 1))
    
    49
    		      ,temp)
    
    50
    	  (:temporary (:sc descriptor-reg :offset lra-offset
    
    51
    			   :from (:eval 0) :to (:eval 1))
    
    52
    		      ,lra)
    
    53
    	  (:temporary (:scs (control-stack) :offset nfp-save-offset)
    
    54
    		      ,nfp-save)
    
    55
    	  (:save-p :compute-only)))))
    
    56
        (:none
    
    57
         (let ((temp (make-symbol "TEMP")))
    
    58
           (values 
    
    59
    	`((inst ji ,temp (make-fixup ',name :assembly-routine))
    
    60
    	  (inst nop))
    
    61
    	`((:temporary (:scs (non-descriptor-reg) :from (:eval 0) :to (:eval 1))
    
    62
    		      ,temp)))))))
    
    63
    
    
    64
    (def-vm-support-routine generate-return-sequence (style)
    
    65
      (ecase style
    
    66
        (:raw
    
    67
         `((inst j
    
    68
    	     (make-random-tn :kind :normal
    
    69
    			     :sc (sc-or-lose 'interior-reg *backend*)
    
    70
    			     :offset lip-offset)
    
    71
    	     8)
    
    72
           (inst nop)))
    
    73
        (:full-call
    
    74
         `((lisp-return (make-random-tn :kind :normal
    
    75
    				    :sc (sc-or-lose 'descriptor-reg *backend*)
    
    76
    				    :offset lra-offset)
    
    77
    		    :offset 2)))
    
    78
        (:none)))