Raymond Toy pushed to branch rtoy-xoro-default at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/compiler/sparc/arith.lisp
    ... ... @@ -2588,3 +2588,62 @@
    2588 2588
     		 (unsigned-byte 32))
    
    2589 2589
       "recode as shifts and adds"
    
    2590 2590
       (*-transformer y))
    
    2591
    +
    
    2592
    +(in-package "VM")
    
    2593
    +
    
    2594
    +#+random-xoroshiro
    
    2595
    +(progn
    
    2596
    +(defknown xoroshiro-next ((simple-array double-float (2)))
    
    2597
    +  (values (unsigned-byte 32) (unsigned-byte 32))
    
    2598
    +  (movable))
    
    2599
    +
    
    2600
    +(define-vop (xoroshiro-next)
    
    2601
    +  (:policy :fast-safe)
    
    2602
    +  (:translate xoroshiro-next)
    
    2603
    +  (:args (state :scs (descriptor-reg) :to (:result 3)))
    
    2604
    +  (:arg-types simple-array-double-float)
    
    2605
    +  (:results (r1 :scs (unsigned-reg))
    
    2606
    +	    (r0 :scs (unsigned-reg)))
    
    2607
    +  (:result-types unsigned-num unsigned-num)
    
    2608
    +  ;; Must be sure to use %o registers for temps because we want to use
    
    2609
    +  ;; 64-bit registers that will get preserved.
    
    2610
    +  (:temporary (:sc unsigned-reg :offset nl5-offset) s0)
    
    2611
    +  (:temporary (:sc unsigned-reg :offset nl4-offset) s1)
    
    2612
    +  (:temporary (:sc unsigned-reg :offset nl3-offset) t0)
    
    2613
    +  (:generator 10
    
    2614
    +    (inst ldx s0 state (+ (* 0 double-float-bytes)
    
    2615
    +			  (- (* vm:vector-data-offset vm:word-bytes)
    
    2616
    +			     vm:other-pointer-type)))
    
    2617
    +    (inst ldx s1 state (+ (* 1 double-float-bytes)
    
    2618
    +			  (- (* vm:vector-data-offset vm:word-bytes)
    
    2619
    +			     vm:other-pointer-type)))
    
    2620
    +    ;; result = s0 + s1, split into low 32-bits in r0 and high 32-bits
    
    2621
    +    ;; in r1
    
    2622
    +    (inst add r0 s0 s1)
    
    2623
    +    (inst srlx r1 r0 32)
    
    2624
    +
    
    2625
    +    ;; s1 = s1 ^ s0
    
    2626
    +    (inst xor s1 s1 s0)
    
    2627
    +
    
    2628
    +    ;; s0 = rotl(s0,55) = s0 << 55 | s0 >> 9
    
    2629
    +    (inst sllx s0 s0 55)
    
    2630
    +    (inst srlx t0 s0 9)
    
    2631
    +    (inst or s0 t0)
    
    2632
    +
    
    2633
    +    (inst xor s0 s1)			; s0 = s0 ^ s1
    
    2634
    +    (inst sllx t0 s1 14)		; t0 = s1 << 14
    
    2635
    +    (inst xor s0 t0)			; s0 = s0 ^ t0
    
    2636
    +
    
    2637
    +    (inst stx s0 state (+ (* 0 double-float-bytes)
    
    2638
    +			  (- (* vm:vector-data-offset vm:word-bytes)
    
    2639
    +			     vm:other-pointer-type)))
    
    2640
    +
    
    2641
    +    ;; s1 = rotl(s1, 36) = s1 << 36 | s1 >> 28, using t0 as temp
    
    2642
    +    (inst sllx s1 36)
    
    2643
    +    (inst srlx t0 s1 28)
    
    2644
    +    (inst or s1 t0)
    
    2645
    +
    
    2646
    +    (inst stx s1 state (+ (* 1 double-float-bytes)
    
    2647
    +			  (- (* vm:vector-data-offset vm:word-bytes)
    
    2648
    +			     vm:other-pointer-type)))))
    
    2649
    +)