blob: f6e4d3ef99bc75f2b4a8552f7e6c22a0fb5cb62e [file] [log] [blame]
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_OPTIMIZING_PREPARE_FOR_REGISTER_ALLOCATION_H_
18#define ART_COMPILER_OPTIMIZING_PREPARE_FOR_REGISTER_ALLOCATION_H_
19
20#include "nodes.h"
21
22namespace art {
23
Igor Murashkin6ef45672017-08-08 13:59:55 -070024class OptimizingCompilerStats;
25
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010026/**
27 * A simplification pass over the graph before doing register allocation.
28 * For example it changes uses of null checks and bounds checks to the original
29 * objects, to avoid creating a live range for these checks.
30 */
Nicolas Geoffray360231a2014-10-08 21:07:48 +010031class PrepareForRegisterAllocation : public HGraphDelegateVisitor {
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010032 public:
Igor Murashkin6ef45672017-08-08 13:59:55 -070033 explicit PrepareForRegisterAllocation(HGraph* graph,
34 OptimizingCompilerStats* stats = nullptr)
35 : HGraphDelegateVisitor(graph, stats) {}
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010036
37 void Run();
38
Mingyao Yang700347e2016-03-02 14:59:32 -080039 static constexpr const char* kPrepareForRegisterAllocationPassName =
40 "prepare_for_register_allocation";
41
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010042 private:
Vladimir Marko175e7862018-03-27 09:03:13 +000043 void VisitCheckCast(HCheckCast* check_cast) OVERRIDE;
44 void VisitInstanceOf(HInstanceOf* instance_of) OVERRIDE;
Alexandre Rames2ed20af2015-03-06 13:55:35 +000045 void VisitNullCheck(HNullCheck* check) OVERRIDE;
46 void VisitDivZeroCheck(HDivZeroCheck* check) OVERRIDE;
47 void VisitBoundsCheck(HBoundsCheck* check) OVERRIDE;
48 void VisitBoundType(HBoundType* bound_type) OVERRIDE;
Roland Levillainb133ec62016-03-23 12:40:35 +000049 void VisitArraySet(HArraySet* instruction) OVERRIDE;
Alexandre Rames2ed20af2015-03-06 13:55:35 +000050 void VisitClinitCheck(HClinitCheck* check) OVERRIDE;
51 void VisitCondition(HCondition* condition) OVERRIDE;
Igor Murashkind01745e2017-04-05 16:40:31 -070052 void VisitConstructorFence(HConstructorFence* constructor_fence) OVERRIDE;
Roland Levillain4c0eb422015-04-24 16:43:49 +010053 void VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) OVERRIDE;
Nicolas Geoffray6f8e2c92017-03-23 14:37:26 +000054 void VisitDeoptimize(HDeoptimize* deoptimize) OVERRIDE;
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010055
David Brazdilb3e773e2016-01-26 11:28:37 +000056 bool CanMoveClinitCheck(HInstruction* input, HInstruction* user) const;
57 bool CanEmitConditionAt(HCondition* condition, HInstruction* user) const;
Vladimir Markofbb184a2015-11-13 14:47:00 +000058
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010059 DISALLOW_COPY_AND_ASSIGN(PrepareForRegisterAllocation);
60};
61
62} // namespace art
63
64#endif // ART_COMPILER_OPTIMIZING_PREPARE_FOR_REGISTER_ALLOCATION_H_