summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.h
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2016-06-16 16:50:52 +0100
committer Vladimir Marko <vmarko@google.com> 2016-07-01 13:26:24 +0100
commite90049140fdfb89080e5cc9b000b0c9be8c18bcd (patch)
tree66b45c052b6778fabd7847a44af5e610808fa867 /compiler/optimizing/nodes.h
parenta77ceae14a7be2494874d9256327efa8c522e234 (diff)
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
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r--compiler/optimizing/nodes.h33
1 files changed, 20 insertions, 13 deletions
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<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 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> {
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 @@ class HPhi FINAL : public HInstruction {
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()