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 |