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

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..e053b9a6ee5f8f5b7f2f2c8aa46b638cca11b3d9 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -92,11 +92,11 @@ bool LiveRange::overlapsInst(InstNumberT OtherBegin, bool UseTrimmed) const {
}
}
#if 0
- // An equivalent but less inefficient implementation:
- LiveRange Temp;
- Temp.addSegment(OtherBegin, OtherBegin + 1);
- bool Validation = overlaps(Temp);
- assert(Result == Validation);
+ // An equivalent but less inefficient implementation:
+ LiveRange Temp;
+ Temp.addSegment(OtherBegin, OtherBegin + 1);
+ bool Validation = overlaps(Temp);
+ assert(Result == Validation);
#endif
JF 2015/06/17 11:29:18 `#if 0` and tabs are sad. Could you make this a co
qining 2015/06/17 18:20:36 Sorry for the unnecessary tabs. I will remove them
Jim Stichnoth 2015/06/19 16:51:02 Let's keep the #if code. This was meant to give a
return Result;
}
@@ -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.
+const uint32_t X86_INT_IMMEDIATE_RANDOMIZATION_THRESHOLD = 0x1;
qining 2015/06/17 04:28:55 The THRESHOLD is set to 0x1.
JF 2015/06/17 11:29:18 This isn't use by other files? It's currently expo
qining 2015/06/17 18:20:36 Yes, you are right, I should confine this to a sma
+
+// Specialization of the template member function for ConstantInteger32
+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)
qining 2015/06/17 04:28:55 Consider i8, 16 constant integers.
+ return false;
+ // if(getType() != IceType_i32) return false;
+ // 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