blob: 35d777ec7afee592e0536259783158968b5c173c [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>
Nicolas Geoffrayf3e2cc42014-02-18 18:37:26 +000021
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"
Brian Carlstrom7940e442013-07-12 13:46:57 -070027#include "safe_map.h"
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000028#include "utils/scoped_arena_allocator.h"
buzbeea61f4952013-08-23 14:27:06 -070029#include "base/timing_logger.h"
Nicolas Geoffray818f2102014-02-18 16:43:35 +000030#include "utils/arena_allocator.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070031
32namespace art {
33
Brian Carlstrom7940e442013-07-12 13:46:57 -070034struct ArenaMemBlock;
Vladimir Marko25724ef2013-11-12 15:09:20 +000035class Backend;
Brian Carlstrom7940e442013-07-12 13:46:57 -070036struct Memstats;
37class MIRGraph;
38class Mir2Lir;
39
40struct CompilationUnit {
Vladimir Marko25724ef2013-11-12 15:09:20 +000041 explicit CompilationUnit(ArenaPool* pool);
42 ~CompilationUnit();
buzbeea61f4952013-08-23 14:27:06 -070043
44 void StartTimingSplit(const char* label);
45 void NewTimingSplit(const char* label);
46 void EndTiming();
47
Brian Carlstrom7940e442013-07-12 13:46:57 -070048 /*
49 * Fields needed/generated by common frontend and generally used throughout
50 * the compiler.
51 */
52 CompilerDriver* compiler_driver;
53 ClassLinker* class_linker; // Linker to resolve fields and methods.
54 const DexFile* dex_file; // DexFile containing the method being compiled.
55 jobject class_loader; // compiling method's class loader.
Ian Rogers8b2c0b92013-09-19 02:56:49 -070056 uint16_t class_def_idx; // compiling method's defining class definition index.
Brian Carlstrom7940e442013-07-12 13:46:57 -070057 uint32_t method_idx; // compiling method's index into method_ids of DexFile.
58 const DexFile::CodeItem* code_item; // compiling method's DexFile code_item.
59 uint32_t access_flags; // compiling method's access flags.
60 InvokeType invoke_type; // compiling method's invocation type.
61 const char* shorty; // compiling method's shorty.
62 uint32_t disable_opt; // opt_control_vector flags.
63 uint32_t enable_debug; // debugControlVector flags.
64 bool verbose;
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000065 const Compiler* compiler;
Brian Carlstrom7940e442013-07-12 13:46:57 -070066 InstructionSet instruction_set;
Andreas Gampe2da88232014-02-27 12:26:20 -080067 bool target64;
Brian Carlstrom7940e442013-07-12 13:46:57 -070068
Ian Rogers3d504072014-03-01 09:16:49 -080069 InstructionSetFeatures GetInstructionSetFeatures() {
Dave Allison70202782013-10-22 17:52:19 -070070 return compiler_driver->GetInstructionSetFeatures();
71 }
Brian Carlstrom7940e442013-07-12 13:46:57 -070072 // TODO: much of this info available elsewhere. Go to the original source?
buzbee0d829482013-10-11 15:24:55 -070073 uint16_t num_dalvik_registers; // method->registers_size.
Brian Carlstrom7940e442013-07-12 13:46:57 -070074 const uint16_t* insns;
buzbee0d829482013-10-11 15:24:55 -070075 uint16_t num_ins;
76 uint16_t num_outs;
77 uint16_t num_regs; // Unlike num_dalvik_registers, does not include ins.
Brian Carlstrom7940e442013-07-12 13:46:57 -070078
Brian Carlstrom7940e442013-07-12 13:46:57 -070079 // If non-empty, apply optimizer/debug flags only to matching methods.
80 std::string compiler_method_match;
81 // Flips sense of compiler_method_match - apply flags if doesn't match.
82 bool compiler_flip_match;
83
84 // TODO: move memory management to mir_graph, or just switch to using standard containers.
85 ArenaAllocator arena;
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000086 ArenaStack arena_stack; // Arenas for ScopedArenaAllocator.
Brian Carlstrom7940e442013-07-12 13:46:57 -070087
Ian Rogers700a4022014-05-19 16:49:03 -070088 std::unique_ptr<MIRGraph> mir_graph; // MIR container.
89 std::unique_ptr<Backend> cg; // Target-specific codegen.
Ian Rogers5fe9af72013-11-14 00:17:20 -080090 TimingLogger timings;
Brian Carlstrom7940e442013-07-12 13:46:57 -070091};
92
93} // namespace art
94
Brian Carlstromfc0e3212013-07-17 14:40:12 -070095#endif // ART_COMPILER_DEX_COMPILER_IR_H_