126a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray/* 226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * Copyright (C) 2014 The Android Open Source Project 326a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * 426a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License"); 526a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * you may not use this file except in compliance with the License. 626a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * You may obtain a copy of the License at 726a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * 826a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * http://www.apache.org/licenses/LICENSE-2.0 926a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * 1026a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * Unless required by applicable law or agreed to in writing, software 1126a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS, 1226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1326a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * See the License for the specific language governing permissions and 1426a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * limitations under the License. 1526a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray */ 1626a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 1726a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray#ifndef ART_COMPILER_OPTIMIZING_PREPARE_FOR_REGISTER_ALLOCATION_H_ 1826a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray#define ART_COMPILER_OPTIMIZING_PREPARE_FOR_REGISTER_ALLOCATION_H_ 1926a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 2026a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray#include "nodes.h" 2126a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 2226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffraynamespace art { 2326a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 246ef45677305048c2bf0600f1c4b98a11b2cfaffbIgor Murashkinclass OptimizingCompilerStats; 256ef45677305048c2bf0600f1c4b98a11b2cfaffbIgor Murashkin 2626a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray/** 2726a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * A simplification pass over the graph before doing register allocation. 2826a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * For example it changes uses of null checks and bounds checks to the original 2926a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray * objects, to avoid creating a live range for these checks. 3026a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray */ 31360231a056e796c36ffe62348507e904dc9efb9bNicolas Geoffrayclass PrepareForRegisterAllocation : public HGraphDelegateVisitor { 3226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray public: 336ef45677305048c2bf0600f1c4b98a11b2cfaffbIgor Murashkin explicit PrepareForRegisterAllocation(HGraph* graph, 346ef45677305048c2bf0600f1c4b98a11b2cfaffbIgor Murashkin OptimizingCompilerStats* stats = nullptr) 356ef45677305048c2bf0600f1c4b98a11b2cfaffbIgor Murashkin : HGraphDelegateVisitor(graph, stats) {} 3626a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 3726a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray void Run(); 3826a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 39700347e9bc6c2ed29046e0c13122a5ad57d2fc51Mingyao Yang static constexpr const char* kPrepareForRegisterAllocationPassName = 40700347e9bc6c2ed29046e0c13122a5ad57d2fc51Mingyao Yang "prepare_for_register_allocation"; 41700347e9bc6c2ed29046e0c13122a5ad57d2fc51Mingyao Yang 4226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray private: 432ed20afc6a1032e9e0cf919cb8d1b2b41e147182Alexandre Rames void VisitNullCheck(HNullCheck* check) OVERRIDE; 442ed20afc6a1032e9e0cf919cb8d1b2b41e147182Alexandre Rames void VisitDivZeroCheck(HDivZeroCheck* check) OVERRIDE; 452ed20afc6a1032e9e0cf919cb8d1b2b41e147182Alexandre Rames void VisitBoundsCheck(HBoundsCheck* check) OVERRIDE; 462ed20afc6a1032e9e0cf919cb8d1b2b41e147182Alexandre Rames void VisitBoundType(HBoundType* bound_type) OVERRIDE; 47b133ec6c39b4c953ed815ec731b0270f0d8f0ed9Roland Levillain void VisitArraySet(HArraySet* instruction) OVERRIDE; 482ed20afc6a1032e9e0cf919cb8d1b2b41e147182Alexandre Rames void VisitClinitCheck(HClinitCheck* check) OVERRIDE; 492ed20afc6a1032e9e0cf919cb8d1b2b41e147182Alexandre Rames void VisitCondition(HCondition* condition) OVERRIDE; 50d01745ef88bfd25df574a885d90a1a7785db5f5bIgor Murashkin void VisitConstructorFence(HConstructorFence* constructor_fence) OVERRIDE; 514c0eb42259d790fddcd9978b66328dbb3ab65615Roland Levillain void VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) OVERRIDE; 526f8e2c9913b24f746a154dda700f609cee3095f9Nicolas Geoffray void VisitDeoptimize(HDeoptimize* deoptimize) OVERRIDE; 5326a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 54b3e773eea39a156b3eacf915ba84e3af1a5c14faDavid Brazdil bool CanMoveClinitCheck(HInstruction* input, HInstruction* user) const; 55b3e773eea39a156b3eacf915ba84e3af1a5c14faDavid Brazdil bool CanEmitConditionAt(HCondition* condition, HInstruction* user) const; 56fbb184a1c6df22d9302b32b55206396c8278edcfVladimir Marko 5726a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(PrepareForRegisterAllocation); 5826a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray}; 5926a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 6026a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray} // namespace art 6126a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 6226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray#endif // ART_COMPILER_OPTIMIZING_PREPARE_FOR_REGISTER_ALLOCATION_H_ 63