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
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 6b2c33e..d98dd06 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -1415,6 +1415,21 @@
typename HUseList<T>::iterator before_use_node_;
};
+// Helper class that extracts the input instruction from HUserRecord<HInstruction*>.
+// 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<HInstruction*>& record) const {
+ return record.GetInstruction();
+ }
+ const HInstruction* operator()(const HUserRecord<HInstruction*>& record) const {
+ return record.GetInstruction();
+ }
+};
+
+using HInputsRef = TransformArrayRef<HUserRecord<HInstruction*>, HInputExtractor>;
+using HConstInputsRef = TransformArrayRef<const HUserRecord<HInstruction*>, HInputExtractor>;
+
/**
* Side-effects representation.
*
@@ -1804,20 +1819,12 @@
const_cast<HInstruction*>(this)->GetInputRecords());
}
- auto GetInputs() {
- return MakeTransformArrayRef(
- GetInputRecords(),
- [](HUserRecord<HInstruction*>& record) -> HInstruction* {
- return record.GetInstruction();
- });
+ HInputsRef GetInputs() {
+ return MakeTransformArrayRef(GetInputRecords(), HInputExtractor());
}
- auto GetInputs() const {
- return MakeTransformArrayRef(
- GetInputRecords(),
- [](const HUserRecord<HInstruction*>& record) -> const HInstruction* {
- return record.GetInstruction();
- });
+ HConstInputsRef GetInputs() const {
+ return MakeTransformArrayRef(GetInputRecords(), HInputExtractor());
}
size_t InputCount() const { return GetInputRecords().size(); }
@@ -2408,7 +2415,7 @@
bool IsDead() const { return !IsLive(); }
bool IsLive() const { return GetPackedFlag<kFlagIsLive>(); }
- bool IsVRegEquivalentOf(HInstruction* other) const {
+ bool IsVRegEquivalentOf(const HInstruction* other) const {
return other != nullptr
&& other->IsPhi()
&& other->AsPhi()->GetBlock() == GetBlock()