Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 22 | namespace art { |
| 23 | |
Igor Murashkin | 6ef4567 | 2017-08-08 13:59:55 -0700 | [diff] [blame] | 24 | class OptimizingCompilerStats; |
| 25 | |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 26 | /** |
| 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 Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 31 | class PrepareForRegisterAllocation : public HGraphDelegateVisitor { |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 32 | public: |
Igor Murashkin | 6ef4567 | 2017-08-08 13:59:55 -0700 | [diff] [blame] | 33 | explicit PrepareForRegisterAllocation(HGraph* graph, |
| 34 | OptimizingCompilerStats* stats = nullptr) |
| 35 | : HGraphDelegateVisitor(graph, stats) {} |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 36 | |
| 37 | void Run(); |
| 38 | |
Mingyao Yang | 700347e | 2016-03-02 14:59:32 -0800 | [diff] [blame] | 39 | static constexpr const char* kPrepareForRegisterAllocationPassName = |
| 40 | "prepare_for_register_allocation"; |
| 41 | |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 42 | private: |
Vladimir Marko | 175e786 | 2018-03-27 09:03:13 +0000 | [diff] [blame] | 43 | void VisitCheckCast(HCheckCast* check_cast) OVERRIDE; |
| 44 | void VisitInstanceOf(HInstanceOf* instance_of) OVERRIDE; |
Alexandre Rames | 2ed20af | 2015-03-06 13:55:35 +0000 | [diff] [blame] | 45 | 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 Levillain | b133ec6 | 2016-03-23 12:40:35 +0000 | [diff] [blame] | 49 | void VisitArraySet(HArraySet* instruction) OVERRIDE; |
Alexandre Rames | 2ed20af | 2015-03-06 13:55:35 +0000 | [diff] [blame] | 50 | void VisitClinitCheck(HClinitCheck* check) OVERRIDE; |
| 51 | void VisitCondition(HCondition* condition) OVERRIDE; |
Igor Murashkin | d01745e | 2017-04-05 16:40:31 -0700 | [diff] [blame] | 52 | void VisitConstructorFence(HConstructorFence* constructor_fence) OVERRIDE; |
Roland Levillain | 4c0eb42 | 2015-04-24 16:43:49 +0100 | [diff] [blame] | 53 | void VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) OVERRIDE; |
Nicolas Geoffray | 6f8e2c9 | 2017-03-23 14:37:26 +0000 | [diff] [blame] | 54 | void VisitDeoptimize(HDeoptimize* deoptimize) OVERRIDE; |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 55 | |
David Brazdil | b3e773e | 2016-01-26 11:28:37 +0000 | [diff] [blame] | 56 | bool CanMoveClinitCheck(HInstruction* input, HInstruction* user) const; |
| 57 | bool CanEmitConditionAt(HCondition* condition, HInstruction* user) const; |
Vladimir Marko | fbb184a | 2015-11-13 14:47:00 +0000 | [diff] [blame] | 58 | |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 59 | DISALLOW_COPY_AND_ASSIGN(PrepareForRegisterAllocation); |
| 60 | }; |
| 61 | |
| 62 | } // namespace art |
| 63 | |
| 64 | #endif // ART_COMPILER_OPTIMIZING_PREPARE_FOR_REGISTER_ALLOCATION_H_ |