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

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: Avoid calling randomizationOrPoolImmediate() multiple times on a same operand" 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..5fab998fd5cd213b875be8d4b0b6751bcc36c629 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -491,4 +491,26 @@ Ostream &operator<<(Ostream &Str, const RegWeight &W) {
return Str;
}
+// =========== Immediate Randomization and Pooling routines ==============
+// Immediates randomization and pooling threshold, we should not
+// randomize or pool small constants e.g. 2,4 etc.
+static const uint32_t X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD = 0x1;
Jim Stichnoth 2015/06/19 16:51:03 Do you really mean to set such a low threshold? I
qining 2015/06/19 20:22:25 Done. Chang back to 0xffff. Do we need to add a co
Jim Stichnoth 2015/06/19 23:12:15 I think a command line option would be most excell
qining 2015/06/20 00:22:28 Done.
+
+// Specialization of the template member function for ConstantInteger32
Jim Stichnoth 2015/06/19 16:51:03 It seems that you're trying to specialize for i32
qining 2015/06/19 20:22:25 Done. I've labeled that with a TODO tag. But actua
+template <>
+bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx) {
+ if (Ctx->getFlags().getRandomizeAndPoolImmediatesOption() == RPI_None)
+ return false;
+ if (getType() != IceType_i32 && getType() != IceType_i16 &&
+ getType() != IceType_i8)
+ return false;
+ // if(getType() != IceType_i32) return false;
Jim Stichnoth 2015/06/19 16:51:03 remove commented code
+ // The Following checks if the signed representation of Value is between
+ // -THRESHOLD/2 and +THRESHOLD/2
+ bool largerThanThreshold =
+ X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD / 2 + Value >=
+ X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD;
+ return largerThanThreshold;
+}
+
} // end of namespace Ice

Powered by Google App Engine
This is Rietveld 408576698