| 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 <stdint.h> | 17 #include <stdint.h> | 
| 18 #include "llvm/ADT/StringRef.h" | 18 #include "llvm/ADT/StringRef.h" | 
|  | 19 #include "llvm/Support/Compiler.h" | 
| 19 | 20 | 
| 20 namespace Ice { | 21 namespace Ice { | 
| 21 | 22 | 
| 22 class RandomNumberGenerator { | 23 class RandomNumberGenerator { | 
| 23 public: | 24 public: | 
| 24   RandomNumberGenerator(llvm::StringRef Salt); | 25   RandomNumberGenerator(llvm::StringRef Salt); | 
| 25   uint64_t next(uint64_t Max); | 26   uint64_t next(uint64_t Max); | 
| 26 | 27 | 
| 27 private: | 28 private: | 
|  | 29   RandomNumberGenerator(const RandomNumberGenerator &) LLVM_DELETED_FUNCTION; | 
|  | 30   RandomNumberGenerator & | 
|  | 31   operator=(const RandomNumberGenerator &) LLVM_DELETED_FUNCTION; | 
|  | 32 | 
| 28   uint64_t State; | 33   uint64_t State; | 
| 29 }; | 34 }; | 
| 30 | 35 | 
|  | 36 // This class adds additional random number generator utilities. The | 
|  | 37 // reason for the wrapper class is that we want to keep the | 
|  | 38 // RandomNumberGenerator interface identical to LLVM's. | 
|  | 39 class RandomNumberGeneratorWrapper { | 
|  | 40 public: | 
|  | 41   uint64_t next(uint64_t Max) { return RNG.next(Max); } | 
|  | 42   bool getTrueWithProbability(float Probability); | 
|  | 43   RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {} | 
|  | 44 | 
|  | 45 private: | 
|  | 46   RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &) | 
|  | 47       LLVM_DELETED_FUNCTION; | 
|  | 48   RandomNumberGeneratorWrapper & | 
|  | 49   operator=(const RandomNumberGeneratorWrapper &) LLVM_DELETED_FUNCTION; | 
|  | 50 | 
|  | 51   RandomNumberGenerator &RNG; | 
|  | 52 }; | 
|  | 53 | 
| 31 } // end of namespace Ice | 54 } // end of namespace Ice | 
| 32 | 55 | 
| 33 #endif // SUBZERO_SRC_ICERNG_H | 56 #endif // SUBZERO_SRC_ICERNG_H | 
| OLD | NEW | 
|---|