diff options
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r-- | compiler/optimizing/nodes.h | 106 |
1 files changed, 42 insertions, 64 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 53396dbb72..4a0be10b77 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2366,8 +2366,7 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> { HInstruction* prev_not_move = GetPreviousDisregardingMoves(); while (prev_not_move != nullptr && prev_not_move->IsEmittedAtUseSite()) { if (prev_not_move->IsNullCheck()) { - // TODO: Remove "OrNull". - return prev_not_move->AsNullCheckOrNull(); + return prev_not_move->AsNullCheck(); } prev_not_move = prev_not_move->GetPreviousDisregardingMoves(); } @@ -2553,6 +2552,8 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> { #undef INSTRUCTION_TYPE_CHECK #define INSTRUCTION_TYPE_CAST(type, super) \ + const H##type* As##type() const; \ + H##type* As##type(); \ const H##type* As##type##OrNull() const; \ H##type* As##type##OrNull(); @@ -3166,18 +3167,14 @@ class HPhi final : public HVariableInputSizeInstruction { return other != nullptr && other->IsPhi() && other->GetBlock() == GetBlock() - // TODO: Remove "OrNull". - && other->AsPhiOrNull()->GetRegNumber() == GetRegNumber(); + && other->AsPhi()->GetRegNumber() == GetRegNumber(); } bool HasEquivalentPhi() const { - // TODO: Remove "OrNull". - if (GetPrevious() != nullptr && - GetPrevious()->AsPhiOrNull()->GetRegNumber() == GetRegNumber()) { + if (GetPrevious() != nullptr && GetPrevious()->AsPhi()->GetRegNumber() == GetRegNumber()) { return true; } - // TODO: Remove "OrNull". - if (GetNext() != nullptr && GetNext()->AsPhiOrNull()->GetRegNumber() == GetRegNumber()) { + if (GetNext() != nullptr && GetNext()->AsPhi()->GetRegNumber() == GetRegNumber()) { return true; } return false; @@ -3188,11 +3185,9 @@ class HPhi final : public HVariableInputSizeInstruction { // It assumes that phis with the same dex register are adjacent. HPhi* GetNextEquivalentPhiWithSameType() { HInstruction* next = GetNext(); - // TODO: Remove "OrNull". - while (next != nullptr && next->AsPhiOrNull()->GetRegNumber() == reg_number_) { + while (next != nullptr && next->AsPhi()->GetRegNumber() == reg_number_) { if (next->GetType() == GetType()) { - // TODO: Remove "OrNull". - return next->AsPhiOrNull(); + return next->AsPhi(); } next = next->GetNext(); } @@ -3313,8 +3308,7 @@ class HIntConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsIntConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsIntConstantOrNull()->value_ == value_; + return other->AsIntConstant()->value_ == value_; } size_t ComputeHashCode() const override { return GetValue(); } @@ -3358,8 +3352,7 @@ class HLongConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsLongConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsLongConstantOrNull()->value_ == value_; + return other->AsLongConstant()->value_ == value_; } size_t ComputeHashCode() const override { return static_cast<size_t>(GetValue()); } @@ -3395,8 +3388,7 @@ class HFloatConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsFloatConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsFloatConstantOrNull()->GetValueAsUint64() == GetValueAsUint64(); + return other->AsFloatConstant()->GetValueAsUint64() == GetValueAsUint64(); } size_t ComputeHashCode() const override { return static_cast<size_t>(GetValue()); } @@ -3453,8 +3445,7 @@ class HDoubleConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsDoubleConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsDoubleConstantOrNull()->GetValueAsUint64() == GetValueAsUint64(); + return other->AsDoubleConstant()->GetValueAsUint64() == GetValueAsUint64(); } size_t ComputeHashCode() const override { return static_cast<size_t>(GetValue()); } @@ -3651,8 +3642,7 @@ class HDeoptimize final : public HVariableInputSizeInstruction { bool InstructionDataEquals(const HInstruction* other) const override { return (other->CanBeMoved() == CanBeMoved()) && - // TODO: Remove "OrNull". - (other->AsDeoptimizeOrNull()->GetDeoptimizationKind() == GetDeoptimizationKind()); + (other->AsDeoptimize()->GetDeoptimizationKind() == GetDeoptimizationKind()); } bool NeedsEnvironment() const override { return true; } @@ -3761,9 +3751,8 @@ class HClassTableGet final : public HExpression<1> { bool IsClonable() const override { return true; } bool CanBeMoved() const override { return true; } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return other->AsClassTableGetOrNull()->GetIndex() == index_ && - other->AsClassTableGetOrNull()->GetPackedFields() == GetPackedFields(); + return other->AsClassTableGet()->GetIndex() == index_ && + other->AsClassTableGet()->GetPackedFields() == GetPackedFields(); } TableKind GetTableKind() const { return GetPackedField<TableKindField>(); } @@ -3999,8 +3988,7 @@ class HCondition : public HBinaryOperation { void SetBias(ComparisonBias bias) { SetPackedField<ComparisonBiasField>(bias); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return GetPackedFields() == other->AsConditionOrNull()->GetPackedFields(); + return GetPackedFields() == other->AsCondition()->GetPackedFields(); } bool IsFPConditionTrueIfNaN() const { @@ -4525,8 +4513,7 @@ class HCompare final : public HBinaryOperation { } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return GetPackedFields() == other->AsCompareOrNull()->GetPackedFields(); + return GetPackedFields() == other->AsCompare()->GetPackedFields(); } ComparisonBias GetBias() const { return GetPackedField<ComparisonBiasField>(); } @@ -4626,8 +4613,7 @@ class HNewInstance final : public HExpression<1> { input = input->InputAt(0); } DCHECK(input->IsLoadClass()); - // TODO: Remove "OrNull". - return input->AsLoadClassOrNull(); + return input->AsLoadClass(); } bool IsStringAlloc() const; @@ -4759,8 +4745,7 @@ class HInvoke : public HVariableInputSizeInstruction { bool CanBeMoved() const override { return IsIntrinsic() && !DoesAnyWrite(); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return intrinsic_ != Intrinsics::kNone && intrinsic_ == other->AsInvokeOrNull()->intrinsic_; + return intrinsic_ != Intrinsics::kNone && intrinsic_ == other->AsInvoke()->intrinsic_; } uint32_t* GetIntrinsicOptimizations() { @@ -5365,8 +5350,7 @@ class HNewArray final : public HExpression<2> { HLoadClass* GetLoadClass() const { DCHECK(InputAt(0)->IsLoadClass()); - // TODO: Remove "OrNull". - return InputAt(0)->AsLoadClassOrNull(); + return InputAt(0)->AsLoadClass(); } HInstruction* GetLength() const { @@ -6306,8 +6290,7 @@ class HInstanceFieldGet final : public HExpression<1> { bool CanBeMoved() const override { return !IsVolatile(); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - const HInstanceFieldGet* other_get = other->AsInstanceFieldGetOrNull(); + const HInstanceFieldGet* other_get = other->AsInstanceFieldGet(); return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue(); } @@ -6396,8 +6379,7 @@ class HPredicatedInstanceFieldGet final : public HExpression<2> { } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - const HPredicatedInstanceFieldGet* other_get = other->AsPredicatedInstanceFieldGetOrNull(); + const HPredicatedInstanceFieldGet* other_get = other->AsPredicatedInstanceFieldGet(); return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue() && GetDefaultValue() == other_get->GetDefaultValue(); } @@ -7457,8 +7439,7 @@ class HClinitCheck final : public HExpression<1> { HLoadClass* GetLoadClass() const { DCHECK(InputAt(0)->IsLoadClass()); - // TODO: Remove "OrNull". - return InputAt(0)->AsLoadClassOrNull(); + return InputAt(0)->AsLoadClass(); } DECLARE_INSTRUCTION(ClinitCheck); @@ -7498,8 +7479,7 @@ class HStaticFieldGet final : public HExpression<1> { bool CanBeMoved() const override { return !IsVolatile(); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - const HStaticFieldGet* other_get = other->AsStaticFieldGetOrNull(); + const HStaticFieldGet* other_get = other->AsStaticFieldGet(); return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue(); } @@ -7634,8 +7614,7 @@ class HStringBuilderAppend final : public HVariableInputSizeInstruction { } HIntConstant* GetFormat() { - // TODO: Remove "OrNull". - return InputAt(FormatIndex())->AsIntConstantOrNull(); + return InputAt(FormatIndex())->AsIntConstant(); } bool NeedsEnvironment() const override { return true; } @@ -7898,24 +7877,21 @@ class HTypeCheckInstruction : public HVariableInputSizeInstruction { DCHECK_NE(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck); HInstruction* load_class = InputAt(1); DCHECK(load_class->IsLoadClass()); - // TODO: Remove "OrNull". - return load_class->AsLoadClassOrNull(); + return load_class->AsLoadClass(); } uint32_t GetBitstringPathToRoot() const { DCHECK_EQ(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck); HInstruction* path_to_root = InputAt(2); DCHECK(path_to_root->IsIntConstant()); - // TODO: Remove "OrNull". - return static_cast<uint32_t>(path_to_root->AsIntConstantOrNull()->GetValue()); + return static_cast<uint32_t>(path_to_root->AsIntConstant()->GetValue()); } uint32_t GetBitstringMask() const { DCHECK_EQ(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck); HInstruction* mask = InputAt(3); DCHECK(mask->IsIntConstant()); - // TODO: Remove "OrNull". - return static_cast<uint32_t>(mask->AsIntConstantOrNull()->GetValue()); + return static_cast<uint32_t>(mask->AsIntConstant()->GetValue()); } bool IsClonable() const override { return true; } @@ -8719,11 +8695,9 @@ class HBlocksInLoopReversePostOrderIterator : public ValueObject { // Returns int64_t value of a properly typed constant. inline int64_t Int64FromConstant(HConstant* constant) { if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - return constant->AsLongConstantOrNull()->GetValue(); + return constant->AsLongConstant()->GetValue(); } else { DCHECK(constant->IsNullConstant()) << constant->DebugName(); return 0; @@ -8733,12 +8707,10 @@ inline int64_t Int64FromConstant(HConstant* constant) { // Returns true iff instruction is an integral constant (and sets value on success). inline bool IsInt64AndGet(HInstruction* instruction, /*out*/ int64_t* value) { if (instruction->IsIntConstant()) { - // TODO: Remove "OrNull". - *value = instruction->AsIntConstantOrNull()->GetValue(); + *value = instruction->AsIntConstant()->GetValue(); return true; } else if (instruction->IsLongConstant()) { - // TODO: Remove "OrNull". - *value = instruction->AsLongConstantOrNull()->GetValue(); + *value = instruction->AsLongConstant()->GetValue(); return true; } else if (instruction->IsNullConstant()) { *value = 0; @@ -8755,8 +8727,7 @@ inline bool IsInt64Value(HInstruction* instruction, int64_t value) { // Returns true iff instruction is a zero bit pattern. inline bool IsZeroBitPattern(HInstruction* instruction) { - // TODO: Remove "OrNull". - return instruction->IsConstant() && instruction->AsConstantOrNull()->IsZeroBitPattern(); + return instruction->IsConstant() && instruction->AsConstant()->IsZeroBitPattern(); } // Implement HInstruction::Is##type() for concrete instructions. @@ -8783,6 +8754,14 @@ inline bool IsZeroBitPattern(HInstruction* instruction) { #undef INSTRUCTION_TYPE_CHECK_RESULT #define INSTRUCTION_TYPE_CAST(type, super) \ + inline const H##type* HInstruction::As##type() const { \ + DCHECK(Is##type()); \ + return down_cast<const H##type*>(this); \ + } \ + inline H##type* HInstruction::As##type() { \ + DCHECK(Is##type()); \ + return down_cast<H##type*>(this); \ + } \ inline const H##type* HInstruction::As##type##OrNull() const { \ return Is##type() ? down_cast<const H##type*>(this) : nullptr; \ } \ @@ -8817,8 +8796,7 @@ inline HInstruction* HuntForDeclaration(HInstruction* instruction) { instruction->IsNullCheck() || instruction->IsNewArray()) { instruction = instruction->IsNewArray() - // TODO: Remove "OrNull". - ? instruction->AsNewArrayOrNull()->GetLength() + ? instruction->AsNewArray()->GetLength() : instruction->InputAt(0); } return instruction; |