blob: 3e94fba2280645b2359c77a5b9806a6cdc1fc979 [file] [log] [blame]
Nicolas Geoffray818f2102014-02-18 16:43:35 +00001/*
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_BUILDER_H_
18#define ART_COMPILER_OPTIMIZING_BUILDER_H_
19
20#include "utils/allocation.h"
21
22namespace art {
23
24class ArenaAllocator;
25class Instruction;
26class HBasicBlock;
27class HGraph;
28
29class HGraphBuilder : public ValueObject {
30 public:
31 explicit HGraphBuilder(ArenaAllocator* arena)
32 : arena_(arena),
33 entry_block_(nullptr),
34 exit_block_(nullptr),
35 current_block_(nullptr),
36 graph_(nullptr) { }
37
38 HGraph* BuildGraph(const uint16_t* start, const uint16_t* end);
39
40 private:
41 // Analyzes the dex instruction and adds HInstruction to the graph
42 // to execute that instruction. Returns whether the instruction can
43 // be handled.
44 bool AnalyzeDexInstruction(const Instruction& instruction);
45
46 ArenaAllocator* const arena_;
47 HBasicBlock* entry_block_;
48 HBasicBlock* exit_block_;
49 HBasicBlock* current_block_;
50 HGraph* graph_;
51
52 DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
53};
54
55} // namespace art
56
57#endif // ART_COMPILER_OPTIMIZING_BUILDER_H_