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

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: change the default sz-seed back to 1. 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
« no previous file with comments | « src/IceOperand.h ('k') | src/IceTargetLoweringX8632.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceOperand.cpp
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index 2d2c8cf2c3276fbf3ce89d28d116a74cdca3f54b..459d0a07c19101f9ee537b2f63a8473858ce4de9 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -491,4 +491,22 @@ Ostream &operator<<(Ostream &Str, const RegWeight &W) {
return Str;
}
+// =========== Immediate Randomization and Pooling routines ==============
+// Specialization of the template member function for ConstantInteger32
+// TODO(stichnot): try to move this specialization into a target-specific
+// file.
+template <>
+bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx) {
+ uint32_t Threshold = Ctx->getFlags().getRandomizeAndPoolImmediatesThreshold();
+ if (Ctx->getFlags().getRandomizeAndPoolImmediatesOption() == RPI_None)
+ return false;
+ if (getType() != IceType_i32 && getType() != IceType_i16 &&
+ getType() != IceType_i8)
+ return false;
+ // The Following checks if the signed representation of Value is between
+ // -Threshold/2 and +Threshold/2
+ bool largerThanThreshold = Threshold / 2 + Value >= Threshold;
+ return largerThanThreshold;
+}
+
} // end of namespace Ice
« no previous file with comments | « src/IceOperand.h ('k') | src/IceTargetLoweringX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698