| OLD | NEW | 
|---|
| 1 //===- subzero/src/IceRNG.h - Random number generator -----------*- C++ -*-===// | 1 //===- subzero/src/IceRNG.h - Random number generator -----------*- C++ -*-===// | 
| 2 // | 2 // | 
| 3 //                        The Subzero Code Generator | 3 //                        The Subzero Code Generator | 
| 4 // | 4 // | 
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source | 
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. | 
| 7 // | 7 // | 
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// | 
| 9 // | 9 // | 
| 10 // This file declares a random number generator. | 10 // This file declares a random number generator. | 
| 11 // | 11 // | 
| 12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// | 
| 13 | 13 | 
| 14 #ifndef SUBZERO_SRC_ICERNG_H | 14 #ifndef SUBZERO_SRC_ICERNG_H | 
| 15 #define SUBZERO_SRC_ICERNG_H | 15 #define SUBZERO_SRC_ICERNG_H | 
| 16 | 16 | 
| 17 #include <cstdint> | 17 #include <cstdint> | 
| 18 | 18 | 
| 19 #include "llvm/ADT/StringRef.h" | 19 #include "llvm/ADT/StringRef.h" | 
| 20 #include "llvm/Support/Compiler.h" | 20 #include "llvm/Support/Compiler.h" | 
| 21 | 21 | 
| 22 namespace Ice { | 22 namespace Ice { | 
| 23 | 23 | 
| 24 class RandomNumberGenerator { | 24 class RandomNumberGenerator { | 
|  | 25   RandomNumberGenerator(const RandomNumberGenerator &) = delete; | 
|  | 26   RandomNumberGenerator &operator=(const RandomNumberGenerator &) = delete; | 
|  | 27 | 
| 25 public: | 28 public: | 
| 26   RandomNumberGenerator(llvm::StringRef Salt); | 29   RandomNumberGenerator(llvm::StringRef Salt); | 
| 27   uint64_t next(uint64_t Max); | 30   uint64_t next(uint64_t Max); | 
| 28 | 31 | 
| 29 private: | 32 private: | 
| 30   RandomNumberGenerator(const RandomNumberGenerator &) = delete; |  | 
| 31   RandomNumberGenerator &operator=(const RandomNumberGenerator &) = delete; |  | 
| 32 |  | 
| 33   uint64_t State; | 33   uint64_t State; | 
| 34 }; | 34 }; | 
| 35 | 35 | 
| 36 // This class adds additional random number generator utilities. The | 36 // This class adds additional random number generator utilities. The | 
| 37 // reason for the wrapper class is that we want to keep the | 37 // reason for the wrapper class is that we want to keep the | 
| 38 // RandomNumberGenerator interface identical to LLVM's. | 38 // RandomNumberGenerator interface identical to LLVM's. | 
| 39 class RandomNumberGeneratorWrapper { | 39 class RandomNumberGeneratorWrapper { | 
|  | 40   RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &) = delete; | 
|  | 41   RandomNumberGeneratorWrapper & | 
|  | 42   operator=(const RandomNumberGeneratorWrapper &) = delete; | 
|  | 43 | 
| 40 public: | 44 public: | 
| 41   uint64_t next(uint64_t Max) { return RNG.next(Max); } | 45   uint64_t next(uint64_t Max) { return RNG.next(Max); } | 
| 42   bool getTrueWithProbability(float Probability); | 46   bool getTrueWithProbability(float Probability); | 
| 43   RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {} | 47   RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {} | 
| 44 | 48 | 
| 45 private: | 49 private: | 
| 46   RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &) = delete; |  | 
| 47   RandomNumberGeneratorWrapper & |  | 
| 48   operator=(const RandomNumberGeneratorWrapper &) = delete; |  | 
| 49 |  | 
| 50   RandomNumberGenerator &RNG; | 50   RandomNumberGenerator &RNG; | 
| 51 }; | 51 }; | 
| 52 | 52 | 
| 53 } // end of namespace Ice | 53 } // end of namespace Ice | 
| 54 | 54 | 
| 55 #endif // SUBZERO_SRC_ICERNG_H | 55 #endif // SUBZERO_SRC_ICERNG_H | 
| OLD | NEW | 
|---|