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

Unified Diff: src/hydrogen-instructions.cc

Issue 12189006: Suggestions for iDef infrastructure classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 4163b50045d8c61a114efbe119d5566e9f24db2e..2ef5007f600963dde83d176ce17d80af01a1e593 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -676,6 +676,44 @@ void HValue::ComputeInitialRange(Zone* zone) {
}
+bool HValue::DecomposeValuePlusConstant(HValue** value, int32_t* constant) {
+ if (IsAdd()) {
+ HAdd* add = HAdd::cast(this);
+ if (add->right()->IsConstant() &&
+ HConstant::cast(add->right())->HasInteger32Value()) {
+ *value = add->left();
+ *constant = HConstant::cast(add->right())->Integer32Value();
+ return true;
+ } else if (add->left()->IsConstant() &&
+ HConstant::cast(add->left())->HasInteger32Value()) {
+ *value = add->right();
+ *constant = HConstant::cast(add->left())->Integer32Value();
+ return true;
+ }
+ } else if (IsSub()) {
+ HSub* sub = HSub::cast(this);
+ if (sub->right()->IsConstant() &&
+ HConstant::cast(sub->right())->HasInteger32Value()) {
+ *value = sub->left();
+ *constant = -HConstant::cast(sub->right())->Integer32Value();
+ return true;
+ }
+ }
+ *value = NULL;
+ *constant = 0;
+ return false;
+}
+
+
+HValue* HValue::InsertNumericConstraint(HInstruction* insertion_point,
+ NumericRelation relation,
+ HValue* other,
+ int32_t offset) {
+ return HNumericConstraint::New(
+ insertion_point, this, relation, other, offset);
+}
+
+
void HInstruction::PrintTo(StringStream* stream) {
PrintMnemonicTo(stream);
PrintDataTo(stream);
@@ -794,6 +832,71 @@ void HInstruction::Verify() {
#endif
+HNumericConstraint::HNumericConstraint(HInstruction* insertion_point,
+ HValue* input,
+ NumericRelation constraint,
+ HValue* value,
+ int delta)
+ : constraint_(constraint),
+ delta_(delta) {
+ SetOperandAt(0, input);
+ SetOperandAt(1, value);
+ set_representation(input->representation());
+ InsertAfter(insertion_point);
+}
+
+
+HNumericConstraint* HNumericConstraint::Create(
+ HInstruction* insertion_point,
+ HValue* input,
+ NumericRelation constraint,
+ HValue* value,
+ int delta) {
+ return new (previous_definition->block()->zone()) HNumericConstraint(
Jakob Kummerow 2013/02/04 17:06:09 what's previous_definition?
+ insertion_point, input, constraint, value, delta);
+}
+
+
+HNumericConstraint* HNumericConstraint::New(
+ HInstruction* insertion_point,
+ HValue* input,
+ NumericRelation constraint,
+ HValue* value,
+ int delta) {
+ HNumericConstraint* result = Create(
+ insertion_point, input, constraint, value, delta);
+ AddImpliedConstraints(input, input, constraint, value, delta);
+ return result;
+}
+
+
+
+void HNumericConstraint::AddInformativeDefinitions() {}
+
+void HNumericConstraint::PrintDataTo(StringStream* stream) {
+ stream->Add("(");
+ input()->PrintNameTo(stream);
+ stream->Add(" %s ", constraint().Mnemonic());
+ value()->PrintNameTo(stream);
+ if (delta() > 0) {
+ stream->Add(" + %d", delta());
+ } else if (delta() < 0) {
+ stream->Add(" - %d", -delta());
+ }
+ stream->Add(")");
+}
+
+
+bool HNumericConstraint::CheckRelation(NumericRelation relation,
+ HValue* other,
+ int32_t offset) {
+ if (other == value() && relation.Includes(constraint(), offset, delta())) {
Jakob Kummerow 2013/02/04 17:06:09 I don't see "Includes()" defined anywhere. Do you
+ return true;
+ }
+ return input()->IsRelationTrue(relation, other, offset);
Jakob Kummerow 2013/02/04 17:06:09 When you have two methods recursively calling each
+}
+
+
void HDummyUse::PrintDataTo(StringStream* stream) {
value()->PrintNameTo(stream);
}
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698