Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: src/IceGlobalContext.cpp

Issue 455593004: Subzero: Add a random number generator. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceGlobalContext.cpp
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 5dd8b6306ec89c6a8eaa1c62c5785b7363020556..56d025c6c2726ad82c7346b5d6d94347bd978898 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -15,6 +15,8 @@
#include <ctype.h> // isdigit(), isupper()
#include <locale> // locale
+#include "llvm/Support/CommandLine.h"
+
#include "IceDefs.h"
#include "IceTypes.h"
#include "IceCfg.h"
@@ -24,6 +26,14 @@
namespace Ice {
+namespace {
+namespace cl = llvm::cl;
+
+cl::opt<uint64_t> RandomSeed("random-seed",
+ cl::desc("Seed the random number generator"),
+ cl::init(1));
Jim Stichnoth 2014/08/08 05:05:38 Can you default initialize to time(0) or something
wala 2014/08/08 16:36:13 Done.
+} // end anonymous namespace
+
// TypePool maps constants of type KeyType (e.g. float) to pointers to
// type ValueType (e.g. ConstantFloat). KeyType values are compared
// using memcmp() because of potential NaN values in KeyType values.
@@ -119,7 +129,8 @@ GlobalContext::GlobalContext(llvm::raw_ostream *OsDump,
IceString TestPrefix)
: StrDump(OsDump), StrEmit(OsEmit), VMask(Mask),
ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt),
- TestPrefix(TestPrefix), HasEmittedFirstMethod(false) {}
+ TestPrefix(TestPrefix), HasEmittedFirstMethod(false),
+ RNG(RandomSeed) {}
// Scan a string for S[0-9A-Z]*_ patterns and replace them with
// S<num>_ where <num> is the next base-36 value. If a type name
« src/IceGlobalContext.h ('K') | « src/IceGlobalContext.h ('k') | src/IceRNG.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698