Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1 | /* |
| 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 Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_DEX_COMPILER_IR_H_ |
| 18 | #define ART_COMPILER_DEX_COMPILER_IR_H_ |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 19 | |
| 20 | #include <vector> |
Nicolas Geoffray | f3e2cc4 | 2014-02-18 18:37:26 +0000 | [diff] [blame] | 21 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 22 | #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 Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 27 | #include "safe_map.h" |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 28 | #include "utils/scoped_arena_allocator.h" |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 29 | #include "base/timing_logger.h" |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 30 | #include "utils/arena_allocator.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 31 | |
| 32 | namespace art { |
| 33 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 34 | struct ArenaMemBlock; |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 35 | class Backend; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 36 | struct Memstats; |
| 37 | class MIRGraph; |
| 38 | class Mir2Lir; |
| 39 | |
| 40 | struct CompilationUnit { |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 41 | explicit CompilationUnit(ArenaPool* pool); |
| 42 | ~CompilationUnit(); |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 43 | |
| 44 | void StartTimingSplit(const char* label); |
| 45 | void NewTimingSplit(const char* label); |
| 46 | void EndTiming(); |
| 47 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 48 | /* |
| 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 Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 56 | uint16_t class_def_idx; // compiling method's defining class definition index. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 57 | 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 Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 65 | const Compiler* compiler; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 66 | InstructionSet instruction_set; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 67 | bool target64; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 68 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 69 | InstructionSetFeatures GetInstructionSetFeatures() { |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 70 | return compiler_driver->GetInstructionSetFeatures(); |
| 71 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 72 | // TODO: much of this info available elsewhere. Go to the original source? |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 73 | uint16_t num_dalvik_registers; // method->registers_size. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 74 | const uint16_t* insns; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 75 | uint16_t num_ins; |
| 76 | uint16_t num_outs; |
| 77 | uint16_t num_regs; // Unlike num_dalvik_registers, does not include ins. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 78 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 79 | // 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 Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 86 | ArenaStack arena_stack; // Arenas for ScopedArenaAllocator. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 87 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame^] | 88 | std::unique_ptr<MIRGraph> mir_graph; // MIR container. |
| 89 | std::unique_ptr<Backend> cg; // Target-specific codegen. |
Ian Rogers | 5fe9af7 | 2013-11-14 00:17:20 -0800 | [diff] [blame] | 90 | TimingLogger timings; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace art |
| 94 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 95 | #endif // ART_COMPILER_DEX_COMPILER_IR_H_ |