1184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray/* 2184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * Copyright (C) 2014 The Android Open Source Project 3184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * 4184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License"); 5184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * you may not use this file except in compliance with the License. 6184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * You may obtain a copy of the License at 7184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * 8184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * http://www.apache.org/licenses/LICENSE-2.0 9184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * 10184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * Unless required by applicable law or agreed to in writing, software 11184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS, 12184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * See the License for the specific language governing permissions and 14184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray * limitations under the License. 15184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray */ 16184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 17184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray#ifndef ART_COMPILER_OPTIMIZING_SSA_TYPE_PROPAGATION_H_ 18184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray#define ART_COMPILER_OPTIMIZING_SSA_TYPE_PROPAGATION_H_ 19184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 20184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray#include "nodes.h" 21184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 22184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffraynamespace art { 23184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 24184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray// Compute and propagate types of phis in the graph. 25184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffrayclass SsaTypePropagation : public ValueObject { 26184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray public: 27184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray explicit SsaTypePropagation(HGraph* graph) 28184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray : graph_(graph), worklist_(graph->GetArena(), kDefaultWorklistSize) {} 29184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 30184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray void Run(); 31184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 32184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray private: 33184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray void VisitBasicBlock(HBasicBlock* block); 34184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray void ProcessWorklist(); 35184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray void AddToWorklist(HPhi* phi); 36184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray void AddDependentInstructionsToWorklist(HPhi* phi); 37184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 38184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray HGraph* const graph_; 39184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray GrowableArray<HPhi*> worklist_; 40184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 41184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray static constexpr size_t kDefaultWorklistSize = 8; 42184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 43184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(SsaTypePropagation); 44184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray}; 45184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 46184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray} // namespace art 47184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray 48184d640d2a3ac86d871dab58386a50cc9bb973f9Nicolas Geoffray#endif // ART_COMPILER_OPTIMIZING_SSA_TYPE_PROPAGATION_H_ 49