Subzero: Add a random number generator.
This is inital work necessary for diversification support in Subzero.
The random number generator implementation is temporary. It will
eventually use a cryptographically secure pseudorandom number
generator (perhaps from LLVM, if LLVM gets one).
Add the -rng-seed= option to seed the random number generator from
the command line.
BUG=none
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/455593004
diff --git a/src/IceRNG.h b/src/IceRNG.h
new file mode 100644
index 0000000..423aee0
--- /dev/null
+++ b/src/IceRNG.h
@@ -0,0 +1,33 @@
+//===- subzero/src/IceRNG.h - Random number generator -----------*- C++ -*-===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares a random number generator.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUBZERO_SRC_ICERNG_H
+#define SUBZERO_SRC_ICERNG_H
+
+#include <stdint.h>
+#include "llvm/ADT/StringRef.h"
+
+namespace Ice {
+
+class RandomNumberGenerator {
+public:
+ RandomNumberGenerator(llvm::StringRef Salt);
+ uint64_t next(uint64_t Max);
+
+private:
+ uint64_t State;
+};
+
+} // end of namespace Ice
+
+#endif // SUBZERO_SRC_ICERNG_H