Chromium Code Reviews| 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); |
| } |