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/IceOperand.cpp

Issue 1185703004: Add constant blinding/pooling option for X8632 code translation (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: reformat Created 5 years, 6 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/IceOperand.cpp
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index 2d2c8cf2c3276fbf3ce89d28d116a74cdca3f54b..7231f4b688e3547b5cd6f4678ab5f7ca96adf6b0 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -491,4 +491,21 @@ Ostream &operator<<(Ostream &Str, const RegWeight &W) {
return Str;
}
+// =========== Immediate Radomization and Pooling routines ==============
Jim Stichnoth 2015/06/12 23:48:17 Randomization
qining 2015/06/17 04:28:53 Done.
+// Immediate randomization and pooling threshold, we should not
+// randomize or pool small constants e.g. 2,4 etc.
+const uint32_t X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD = 0xffff;
+
+// Specialization of the template member function for ConstantInteger32
+template <>
+bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx) {
+ if (Ctx->getFlags().shouldNotRandomizeOrPoolImmediates() == true)
+ return false;
+ bool typeCorrect = getType() == IceType_i32;
Jim Stichnoth 2015/06/12 23:48:17 Can you just do this? if (getType() != IceType_i
qining 2015/06/17 04:28:53 Done. I've also add IceType_i8, IceType_i16 as val
+ bool largerThanThreshold =
+ X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD / 2 + Value >=
Jim Stichnoth 2015/06/12 23:48:17 Could you add a comment explaining that this check
qining 2015/06/17 04:28:53 Done.
+ X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD;
+ return typeCorrect && largerThanThreshold;
+}
+
} // end of namespace Ice

Powered by Google App Engine
This is Rietveld 408576698