xref: /aosp_15_r20/art/compiler/optimizing/builder.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2014 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_COMPILER_OPTIMIZING_BUILDER_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_COMPILER_OPTIMIZING_BUILDER_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include "base/arena_object.h"
21*795d594fSAndroid Build Coastguard Worker #include "base/array_ref.h"
22*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
23*795d594fSAndroid Build Coastguard Worker #include "dex/code_item_accessors.h"
24*795d594fSAndroid Build Coastguard Worker #include "dex/dex_file-inl.h"
25*795d594fSAndroid Build Coastguard Worker #include "dex/dex_file.h"
26*795d594fSAndroid Build Coastguard Worker #include "nodes.h"
27*795d594fSAndroid Build Coastguard Worker 
28*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
29*795d594fSAndroid Build Coastguard Worker 
30*795d594fSAndroid Build Coastguard Worker class ArtMethod;
31*795d594fSAndroid Build Coastguard Worker class CodeGenerator;
32*795d594fSAndroid Build Coastguard Worker class DexCompilationUnit;
33*795d594fSAndroid Build Coastguard Worker class OptimizingCompilerStats;
34*795d594fSAndroid Build Coastguard Worker 
35*795d594fSAndroid Build Coastguard Worker class HGraphBuilder : public ValueObject {
36*795d594fSAndroid Build Coastguard Worker  public:
37*795d594fSAndroid Build Coastguard Worker   HGraphBuilder(HGraph* graph,
38*795d594fSAndroid Build Coastguard Worker                 const CodeItemDebugInfoAccessor& accessor,
39*795d594fSAndroid Build Coastguard Worker                 const DexCompilationUnit* dex_compilation_unit,
40*795d594fSAndroid Build Coastguard Worker                 const DexCompilationUnit* outer_compilation_unit,
41*795d594fSAndroid Build Coastguard Worker                 CodeGenerator* code_generator,
42*795d594fSAndroid Build Coastguard Worker                 OptimizingCompilerStats* compiler_stats);
43*795d594fSAndroid Build Coastguard Worker 
44*795d594fSAndroid Build Coastguard Worker   // Only for unit testing.
45*795d594fSAndroid Build Coastguard Worker   HGraphBuilder(HGraph* graph,
46*795d594fSAndroid Build Coastguard Worker                 const DexCompilationUnit* dex_compilation_unit,
47*795d594fSAndroid Build Coastguard Worker                 const CodeItemDebugInfoAccessor& accessor,
48*795d594fSAndroid Build Coastguard Worker                 DataType::Type return_type = DataType::Type::kInt32);
49*795d594fSAndroid Build Coastguard Worker 
50*795d594fSAndroid Build Coastguard Worker   GraphAnalysisResult BuildGraph();
51*795d594fSAndroid Build Coastguard Worker   void BuildIntrinsicGraph(ArtMethod* method);
52*795d594fSAndroid Build Coastguard Worker 
53*795d594fSAndroid Build Coastguard Worker   static constexpr const char* kBuilderPassName = "builder";
54*795d594fSAndroid Build Coastguard Worker 
55*795d594fSAndroid Build Coastguard Worker  private:
56*795d594fSAndroid Build Coastguard Worker   bool SkipCompilation();
57*795d594fSAndroid Build Coastguard Worker 
58*795d594fSAndroid Build Coastguard Worker   HGraph* const graph_;
59*795d594fSAndroid Build Coastguard Worker   const DexFile* const dex_file_;
60*795d594fSAndroid Build Coastguard Worker   const CodeItemDebugInfoAccessor code_item_accessor_;  // null for intrinsic graph.
61*795d594fSAndroid Build Coastguard Worker 
62*795d594fSAndroid Build Coastguard Worker   // The compilation unit of the current method being compiled. Note that
63*795d594fSAndroid Build Coastguard Worker   // it can be an inlined method.
64*795d594fSAndroid Build Coastguard Worker   const DexCompilationUnit* const dex_compilation_unit_;
65*795d594fSAndroid Build Coastguard Worker 
66*795d594fSAndroid Build Coastguard Worker   // The compilation unit of the enclosing method being compiled.
67*795d594fSAndroid Build Coastguard Worker   const DexCompilationUnit* const outer_compilation_unit_;
68*795d594fSAndroid Build Coastguard Worker 
69*795d594fSAndroid Build Coastguard Worker   CodeGenerator* const code_generator_;
70*795d594fSAndroid Build Coastguard Worker 
71*795d594fSAndroid Build Coastguard Worker   OptimizingCompilerStats* const compilation_stats_;
72*795d594fSAndroid Build Coastguard Worker   const DataType::Type return_type_;
73*795d594fSAndroid Build Coastguard Worker 
74*795d594fSAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
75*795d594fSAndroid Build Coastguard Worker };
76*795d594fSAndroid Build Coastguard Worker 
77*795d594fSAndroid Build Coastguard Worker }  // namespace art
78*795d594fSAndroid Build Coastguard Worker 
79*795d594fSAndroid Build Coastguard Worker #endif  // ART_COMPILER_OPTIMIZING_BUILDER_H_
80