Changeset 6008


Ignore:
Timestamp:
Mar 9, 2007, 5:23:29 AM (13 years ago)
Author:
gb
Message:

Just a 32-bit version of %next-random-pair.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-0/PPC/ppc-numbers.lisp

    r4463 r6008  
    322322; Use the two fixnums in state to generate a random fixnum >= 0 and < 65536
    323323; Scramble those fixnums up a bit.
    324 #+ppc32-target
    325 (defppclapfunction %next-random-seed ((state arg_z))
    326   (let ((seed0 imm0)
    327         (seed1 imm1)
    328         (temp imm2))
    329     (check-nargs 1)             ; check
    330     (lhz seed1 (+ ppc32::misc-data-offset 4) state)
    331     (lwi temp #.(* 2 48271))      ; 48271 * 2
    332     (lhz seed0 (+ ppc32::misc-data-offset 8) state)
    333     (rlwimi seed0 seed1 16 0 15)  ; combine into 32 bits, x
    334     (mullw  seed1 temp seed0)     ; seed1 = (x * 48271), lo, * 2
    335     (rlwinm temp temp 1 0 30)     ; 48271 * 2 * 2
    336     (mulhw  seed0 temp seed0)     ; seed0 = (x * 48271), hi, * 2
    337     (addc   seed0 seed0 seed1)    ; do mod 2^31-1
    338     (rlwinm seed0 seed0 31 1 31)
    339     (addze. seed0 seed0)
    340     (insrwi seed1 seed0 16 16)
    341     (sth seed1 (+ ppc32::misc-data-offset 8) state)
    342     (rotlwi seed0 seed0 16)
    343     (bne @storehigh)
    344     (addi seed0 seed0 1)
    345     @storehigh
    346     (sth seed0 (+ ppc32::misc-data-offset 4) state)
    347     (clrlwi temp seed1 16)
    348     (box-fixnum arg_z temp)
    349     (blr)))
    350 
    351 
    352 
    353 #+ppc64-target
    354 (defun %next-random-seed (state)
    355   (let* ((seed (dpb (ldb (byte 16 13) (%svref state 1))
    356                     (byte 16 16)
    357                     (ldb (byte 16 13) (%svref state 2)))))
    358     (multiple-value-bind (seed-low seed-high) (%multiply seed (* 2 48271))
    359       (setq seed (logand #xffffffff (+ seed-low seed-high)))
    360       (setf (%svref state 1) (ash (ldb (byte 16 16) seed) 13)
    361             (%svref state 2) (ash (ldb (byte 16 0) seed) 13))
    362       (dpb (ldb (byte 8 0) seed-low) (byte 8 8) (ldb (byte 8 3) seed-high)))))
     324
     325#+ppc32-target
     326(defppclapfunction %next-random-pair ((high arg_y) (low arg_z))
     327  (slwi imm0 high (- 16 ppc32::fixnumshift))
     328  (rlwimi imm0 low (- 32 ppc32::fixnumshift) 16 31)
     329  (lwi imm1 48271)
     330  (clrlwi imm0 imm0 1)
     331  (mullw imm0 imm1 imm0)
     332  (clrrwi arg_y imm0 16 )
     333  (srwi arg_y arg_y (- 16 ppc32::fixnumshift))
     334  (clrlslwi arg_z imm0 16 ppc32::fixnumshift)
     335  (mr temp0 vsp)
     336  (vpush arg_y)
     337  (vpush arg_z)
     338  (set-nargs 2)
     339  (ba .SPvalues))
     340
     341
     342
     343
     344
     345
    363346
    364347
Note: See TracChangeset for help on using the changeset viewer.