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

Unified Diff: src/IceOperand.h

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/IceInstX8632.cpp ('k') | src/IceOperand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceOperand.h
diff --git a/src/IceOperand.h b/src/IceOperand.h
index 4ae217c5f3b36676469e1dd635920ecd0d1e0704..ae6668bb3af0a25cddf75cb04af46de6ba9236e0 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -117,9 +117,21 @@ public:
return Kind >= kConst_Base && Kind <= kConst_Num;
}
+ // Judge if this given immediate should be randomized or pooled
+ // By default should return false, only constant integers should
+ // truly go through this method.
+ virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) {
+ (void)Ctx;
+ return false;
+ }
+
+ void setShouldBePooled(bool R) { shouldBePooled = R; }
+
+ bool getShouldBePooled() const { return shouldBePooled; }
+
protected:
Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID)
- : Operand(Kind, Ty), PoolEntryID(PoolEntryID) {
+ : Operand(Kind, Ty), PoolEntryID(PoolEntryID), shouldBePooled(false) {
Vars = nullptr;
NumVars = 0;
}
@@ -128,6 +140,9 @@ protected:
// within its constant pool. It is used for building the constant
// pool in the object code and for referencing its entries.
const uint32_t PoolEntryID;
+ // Whether we should pool this constant. Usually Float/Double and pooled
+ // Integers should be flagged true.
+ bool shouldBePooled;
};
// ConstantPrimitive<> wraps a primitive type.
@@ -160,6 +175,11 @@ public:
return Operand->getKind() == K;
}
+ virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) override {
+ (void)Ctx;
+ return false;
+ }
+
private:
ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID)
: Constant(K, Ty, PoolEntryID), Value(Value) {}
@@ -182,6 +202,10 @@ inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
Str << static_cast<int32_t>(getValue());
}
+// Specialization of the template member function for ConstantInteger32
+template <>
+bool ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx);
+
template <>
inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const {
if (!ALLOW_DUMP)
« no previous file with comments | « src/IceInstX8632.cpp ('k') | src/IceOperand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698