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> |
| 21 | #include <llvm/IR/Module.h> |
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" |
| 27 | #include "llvm/intrinsic_helper.h" |
| 28 | #include "llvm/ir_builder.h" |
| 29 | #include "safe_map.h" |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 30 | #include "base/timing_logger.h" |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame^] | 31 | #include "utils/arena_allocator.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 32 | |
| 33 | namespace art { |
| 34 | |
| 35 | class LLVMInfo; |
| 36 | namespace llvm { |
| 37 | class LlvmCompilationUnit; |
| 38 | } // namespace llvm |
| 39 | |
| 40 | struct ArenaMemBlock; |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 41 | class Backend; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 42 | struct Memstats; |
| 43 | class MIRGraph; |
| 44 | class Mir2Lir; |
| 45 | |
| 46 | struct CompilationUnit { |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 47 | explicit CompilationUnit(ArenaPool* pool); |
| 48 | ~CompilationUnit(); |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 49 | |
| 50 | void StartTimingSplit(const char* label); |
| 51 | void NewTimingSplit(const char* label); |
| 52 | void EndTiming(); |
| 53 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 54 | /* |
| 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 Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 62 | uint16_t class_def_idx; // compiling method's defining class definition index. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 63 | 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 Geoffray | f5df897 | 2014-02-14 18:37:08 +0000 | [diff] [blame] | 71 | const CompilerBackend* compiler_backend; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 72 | InstructionSet instruction_set; |
| 73 | |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 74 | const InstructionSetFeatures& GetInstructionSetFeatures() { |
| 75 | return compiler_driver->GetInstructionSetFeatures(); |
| 76 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 77 | // TODO: much of this info available elsewhere. Go to the original source? |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 78 | uint16_t num_dalvik_registers; // method->registers_size. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 79 | const uint16_t* insns; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 80 | uint16_t num_ins; |
| 81 | uint16_t num_outs; |
| 82 | uint16_t num_regs; // Unlike num_dalvik_registers, does not include ins. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 83 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 84 | // 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 Rogers | 5fe9af7 | 2013-11-14 00:17:20 -0800 | [diff] [blame] | 94 | TimingLogger timings; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | } // namespace art |
| 98 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 99 | #endif // ART_COMPILER_DEX_COMPILER_IR_H_ |