blob: ded80054058b7bbc83df72658d86cac25a773ca1 [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
2 * Copyright (C) 2011 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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_DEX_COMPILER_IR_H_
18#define ART_COMPILER_DEX_COMPILER_IR_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
20#include <vector>
21#include <llvm/IR/Module.h>
Brian Carlstrom7940e442013-07-12 13:46:57 -070022#include "compiler_enums.h"
23#include "dex/quick/mir_to_lir.h"
24#include "dex_instruction.h"
25#include "driver/compiler_driver.h"
26#include "driver/dex_compilation_unit.h"
27#include "llvm/intrinsic_helper.h"
28#include "llvm/ir_builder.h"
29#include "safe_map.h"
buzbeea61f4952013-08-23 14:27:06 -070030#include "base/timing_logger.h"
Nicolas Geoffray818f2102014-02-18 16:43:35 +000031#include "utils/arena_allocator.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070032
33namespace art {
34
35class LLVMInfo;
36namespace llvm {
37class LlvmCompilationUnit;
38} // namespace llvm
39
40struct ArenaMemBlock;
Vladimir Marko25724ef2013-11-12 15:09:20 +000041class Backend;
Brian Carlstrom7940e442013-07-12 13:46:57 -070042struct Memstats;
43class MIRGraph;
44class Mir2Lir;
45
46struct CompilationUnit {
Vladimir Marko25724ef2013-11-12 15:09:20 +000047 explicit CompilationUnit(ArenaPool* pool);
48 ~CompilationUnit();
buzbeea61f4952013-08-23 14:27:06 -070049
50 void StartTimingSplit(const char* label);
51 void NewTimingSplit(const char* label);
52 void EndTiming();
53
Brian Carlstrom7940e442013-07-12 13:46:57 -070054 /*
55 * Fields needed/generated by common frontend and generally used throughout
56 * the compiler.
57 */
58 CompilerDriver* compiler_driver;
59 ClassLinker* class_linker; // Linker to resolve fields and methods.
60 const DexFile* dex_file; // DexFile containing the method being compiled.
61 jobject class_loader; // compiling method's class loader.
Ian Rogers8b2c0b92013-09-19 02:56:49 -070062 uint16_t class_def_idx; // compiling method's defining class definition index.
Brian Carlstrom7940e442013-07-12 13:46:57 -070063 uint32_t method_idx; // compiling method's index into method_ids of DexFile.
64 const DexFile::CodeItem* code_item; // compiling method's DexFile code_item.
65 uint32_t access_flags; // compiling method's access flags.
66 InvokeType invoke_type; // compiling method's invocation type.
67 const char* shorty; // compiling method's shorty.
68 uint32_t disable_opt; // opt_control_vector flags.
69 uint32_t enable_debug; // debugControlVector flags.
70 bool verbose;
Nicolas Geoffrayf5df8972014-02-14 18:37:08 +000071 const CompilerBackend* compiler_backend;
Brian Carlstrom7940e442013-07-12 13:46:57 -070072 InstructionSet instruction_set;
73
Dave Allison70202782013-10-22 17:52:19 -070074 const InstructionSetFeatures& GetInstructionSetFeatures() {
75 return compiler_driver->GetInstructionSetFeatures();
76 }
Brian Carlstrom7940e442013-07-12 13:46:57 -070077 // TODO: much of this info available elsewhere. Go to the original source?
buzbee0d829482013-10-11 15:24:55 -070078 uint16_t num_dalvik_registers; // method->registers_size.
Brian Carlstrom7940e442013-07-12 13:46:57 -070079 const uint16_t* insns;
buzbee0d829482013-10-11 15:24:55 -070080 uint16_t num_ins;
81 uint16_t num_outs;
82 uint16_t num_regs; // Unlike num_dalvik_registers, does not include ins.
Brian Carlstrom7940e442013-07-12 13:46:57 -070083
Brian Carlstrom7940e442013-07-12 13:46:57 -070084 // If non-empty, apply optimizer/debug flags only to matching methods.
85 std::string compiler_method_match;
86 // Flips sense of compiler_method_match - apply flags if doesn't match.
87 bool compiler_flip_match;
88
89 // TODO: move memory management to mir_graph, or just switch to using standard containers.
90 ArenaAllocator arena;
91
92 UniquePtr<MIRGraph> mir_graph; // MIR container.
93 UniquePtr<Backend> cg; // Target-specific codegen.
Ian Rogers5fe9af72013-11-14 00:17:20 -080094 TimingLogger timings;
Brian Carlstrom7940e442013-07-12 13:46:57 -070095};
96
97} // namespace art
98
Brian Carlstromfc0e3212013-07-17 14:40:12 -070099#endif // ART_COMPILER_DEX_COMPILER_IR_H_