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> |
| 22 | #include "arena_allocator.h" |
| 23 | #include "backend.h" |
| 24 | #include "compiler_enums.h" |
| 25 | #include "dex/quick/mir_to_lir.h" |
| 26 | #include "dex_instruction.h" |
| 27 | #include "driver/compiler_driver.h" |
| 28 | #include "driver/dex_compilation_unit.h" |
| 29 | #include "llvm/intrinsic_helper.h" |
| 30 | #include "llvm/ir_builder.h" |
| 31 | #include "safe_map.h" |
| 32 | |
| 33 | namespace art { |
| 34 | |
| 35 | class LLVMInfo; |
| 36 | namespace llvm { |
| 37 | class LlvmCompilationUnit; |
| 38 | } // namespace llvm |
| 39 | |
| 40 | struct ArenaMemBlock; |
| 41 | struct Memstats; |
| 42 | class MIRGraph; |
| 43 | class Mir2Lir; |
| 44 | |
| 45 | struct CompilationUnit { |
| 46 | CompilationUnit() |
| 47 | : compiler_driver(NULL), |
| 48 | class_linker(NULL), |
| 49 | dex_file(NULL), |
| 50 | class_loader(NULL), |
| 51 | class_def_idx(0), |
| 52 | method_idx(0), |
| 53 | code_item(NULL), |
| 54 | access_flags(0), |
| 55 | invoke_type(kDirect), |
| 56 | shorty(NULL), |
| 57 | disable_opt(0), |
| 58 | enable_debug(0), |
| 59 | verbose(false), |
| 60 | compiler_backend(kNoBackend), |
| 61 | instruction_set(kNone), |
| 62 | num_dalvik_registers(0), |
| 63 | insns(NULL), |
| 64 | num_ins(0), |
| 65 | num_outs(0), |
| 66 | num_regs(0), |
| 67 | num_compiler_temps(0), |
| 68 | compiler_flip_match(false), |
| 69 | mir_graph(NULL), |
| 70 | cg(NULL) {} |
| 71 | /* |
| 72 | * Fields needed/generated by common frontend and generally used throughout |
| 73 | * the compiler. |
| 74 | */ |
| 75 | CompilerDriver* compiler_driver; |
| 76 | ClassLinker* class_linker; // Linker to resolve fields and methods. |
| 77 | const DexFile* dex_file; // DexFile containing the method being compiled. |
| 78 | jobject class_loader; // compiling method's class loader. |
| 79 | uint32_t class_def_idx; // compiling method's defining class definition index. |
| 80 | uint32_t method_idx; // compiling method's index into method_ids of DexFile. |
| 81 | const DexFile::CodeItem* code_item; // compiling method's DexFile code_item. |
| 82 | uint32_t access_flags; // compiling method's access flags. |
| 83 | InvokeType invoke_type; // compiling method's invocation type. |
| 84 | const char* shorty; // compiling method's shorty. |
| 85 | uint32_t disable_opt; // opt_control_vector flags. |
| 86 | uint32_t enable_debug; // debugControlVector flags. |
| 87 | bool verbose; |
| 88 | CompilerBackend compiler_backend; |
| 89 | InstructionSet instruction_set; |
| 90 | |
| 91 | // TODO: much of this info available elsewhere. Go to the original source? |
| 92 | int num_dalvik_registers; // method->registers_size. |
| 93 | const uint16_t* insns; |
| 94 | int num_ins; |
| 95 | int num_outs; |
| 96 | int num_regs; // Unlike num_dalvik_registers, does not include ins. |
| 97 | |
| 98 | // TODO: may want to move this to MIRGraph. |
| 99 | int num_compiler_temps; |
| 100 | |
| 101 | // If non-empty, apply optimizer/debug flags only to matching methods. |
| 102 | std::string compiler_method_match; |
| 103 | // Flips sense of compiler_method_match - apply flags if doesn't match. |
| 104 | bool compiler_flip_match; |
| 105 | |
| 106 | // TODO: move memory management to mir_graph, or just switch to using standard containers. |
| 107 | ArenaAllocator arena; |
| 108 | |
| 109 | UniquePtr<MIRGraph> mir_graph; // MIR container. |
| 110 | UniquePtr<Backend> cg; // Target-specific codegen. |
| 111 | }; |
| 112 | |
| 113 | } // namespace art |
| 114 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame^] | 115 | #endif // ART_COMPILER_DEX_COMPILER_IR_H_ |