Changeset 6008
 Timestamp:
 Mar 9, 2007, 5:23:29 AM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ccl/level0/PPC/ppcnumbers.lisp
r4463 r6008 322 322 ; Use the two fixnums in state to generate a random fixnum >= 0 and < 65536 323 323 ; Scramble those fixnums up a bit. 324 #+ppc32target 325 (defppclapfunction %nextrandomseed ((state arg_z)) 326 (let ((seed0 imm0) 327 (seed1 imm1) 328 (temp imm2)) 329 (checknargs 1) ; check 330 (lhz seed1 (+ ppc32::miscdataoffset 4) state) 331 (lwi temp #.(* 2 48271)) ; 48271 * 2 332 (lhz seed0 (+ ppc32::miscdataoffset 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^311 338 (rlwinm seed0 seed0 31 1 31) 339 (addze. seed0 seed0) 340 (insrwi seed1 seed0 16 16) 341 (sth seed1 (+ ppc32::miscdataoffset 8) state) 342 (rotlwi seed0 seed0 16) 343 (bne @storehigh) 344 (addi seed0 seed0 1) 345 @storehigh 346 (sth seed0 (+ ppc32::miscdataoffset 4) state) 347 (clrlwi temp seed1 16) 348 (boxfixnum arg_z temp) 349 (blr))) 350 351 352 353 #+ppc64target 354 (defun %nextrandomseed (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 (multiplevaluebind (seedlow seedhigh) (%multiply seed (* 2 48271)) 359 (setq seed (logand #xffffffff (+ seedlow seedhigh))) 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) seedlow) (byte 8 8) (ldb (byte 8 3) seedhigh))))) 324 325 #+ppc32target 326 (defppclapfunction %nextrandompair ((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 (setnargs 2) 339 (ba .SPvalues)) 340 341 342 343 344 345 363 346 364 347
Note: See TracChangeset
for help on using the changeset viewer.