From e90049140fdfb89080e5cc9b000b0c9be8c18bcd Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 16 Jun 2016 16:50:52 +0100 Subject: Create a typedef for HInstruction::GetInputs() return type. And some other cleanup after https://android-review.googlesource.com/230742 Test: No new tests. ART test suite passed (tested on host). Change-Id: I4743bf17544d0234c6ccb46dd0c1b9aae5c93e17 --- compiler/optimizing/nodes.h | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'compiler/optimizing/nodes.h') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 6b2c33e668..d98dd0608b 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -1415,6 +1415,21 @@ class HUserRecord : public ValueObject { typename HUseList::iterator before_use_node_; }; +// Helper class that extracts the input instruction from HUserRecord. +// This is used for HInstruction::GetInputs() to return a container wrapper providing +// HInstruction* values even though the underlying container has HUserRecord<>s. +struct HInputExtractor { + HInstruction* operator()(HUserRecord& record) const { + return record.GetInstruction(); + } + const HInstruction* operator()(const HUserRecord& record) const { + return record.GetInstruction(); + } +}; + +using HInputsRef = TransformArrayRef, HInputExtractor>; +using HConstInputsRef = TransformArrayRef, HInputExtractor>; + /** * Side-effects representation. * @@ -1804,20 +1819,12 @@ class HInstruction : public ArenaObject { const_cast(this)->GetInputRecords()); } - auto GetInputs() { - return MakeTransformArrayRef( - GetInputRecords(), - [](HUserRecord& record) -> HInstruction* { - return record.GetInstruction(); - }); + HInputsRef GetInputs() { + return MakeTransformArrayRef(GetInputRecords(), HInputExtractor()); } - auto GetInputs() const { - return MakeTransformArrayRef( - GetInputRecords(), - [](const HUserRecord& record) -> const HInstruction* { - return record.GetInstruction(); - }); + HConstInputsRef GetInputs() const { + return MakeTransformArrayRef(GetInputRecords(), HInputExtractor()); } size_t InputCount() const { return GetInputRecords().size(); } @@ -2408,7 +2415,7 @@ class HPhi FINAL : public HInstruction { bool IsDead() const { return !IsLive(); } bool IsLive() const { return GetPackedFlag(); } - bool IsVRegEquivalentOf(HInstruction* other) const { + bool IsVRegEquivalentOf(const HInstruction* other) const { return other != nullptr && other->IsPhi() && other->AsPhi()->GetBlock() == GetBlock() -- cgit v1.2.3-59-g8ed1b