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 | |
Razvan A Lupusoru | bd25d4b | 2014-07-02 18:16:51 -0700 | [diff] [blame] | 20 | #include <string> |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 21 | #include <vector> |
Nicolas Geoffray | f3e2cc4 | 2014-02-18 18:37:26 +0000 | [diff] [blame] | 22 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 23 | #include "compiler_enums.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 24 | #include "driver/compiler_driver.h" |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 25 | #include "utils/scoped_arena_allocator.h" |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 26 | #include "base/timing_logger.h" |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 27 | #include "utils/arena_allocator.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 28 | |
| 29 | namespace art { |
| 30 | |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 31 | class Backend; |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 32 | class ClassLinker; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 33 | class MIRGraph; |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * TODO: refactoring pass to move these (and other) typedefs towards usage style of runtime to |
| 37 | * add type safety (see runtime/offsets.h). |
| 38 | */ |
| 39 | typedef uint32_t DexOffset; // Dex offset in code units. |
| 40 | typedef uint16_t NarrowDexOffset; // For use in structs, Dex offsets range from 0 .. 0xffff. |
| 41 | typedef uint32_t CodeOffset; // Native code offset in bytes. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 42 | |
| 43 | struct CompilationUnit { |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 44 | explicit CompilationUnit(ArenaPool* pool); |
| 45 | ~CompilationUnit(); |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 46 | |
| 47 | void StartTimingSplit(const char* label); |
| 48 | void NewTimingSplit(const char* label); |
| 49 | void EndTiming(); |
| 50 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 51 | /* |
| 52 | * Fields needed/generated by common frontend and generally used throughout |
| 53 | * the compiler. |
| 54 | */ |
| 55 | CompilerDriver* compiler_driver; |
| 56 | ClassLinker* class_linker; // Linker to resolve fields and methods. |
| 57 | const DexFile* dex_file; // DexFile containing the method being compiled. |
| 58 | jobject class_loader; // compiling method's class loader. |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 59 | uint16_t class_def_idx; // compiling method's defining class definition index. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 60 | uint32_t method_idx; // compiling method's index into method_ids of DexFile. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 61 | uint32_t access_flags; // compiling method's access flags. |
| 62 | InvokeType invoke_type; // compiling method's invocation type. |
| 63 | const char* shorty; // compiling method's shorty. |
| 64 | uint32_t disable_opt; // opt_control_vector flags. |
| 65 | uint32_t enable_debug; // debugControlVector flags. |
| 66 | bool verbose; |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 67 | const Compiler* compiler; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 68 | InstructionSet instruction_set; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 69 | bool target64; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 70 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 71 | InstructionSetFeatures GetInstructionSetFeatures() { |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 72 | return compiler_driver->GetInstructionSetFeatures(); |
| 73 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 74 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 75 | // If non-empty, apply optimizer/debug flags only to matching methods. |
| 76 | std::string compiler_method_match; |
| 77 | // Flips sense of compiler_method_match - apply flags if doesn't match. |
| 78 | bool compiler_flip_match; |
| 79 | |
| 80 | // TODO: move memory management to mir_graph, or just switch to using standard containers. |
| 81 | ArenaAllocator arena; |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 82 | ArenaStack arena_stack; // Arenas for ScopedArenaAllocator. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 83 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 84 | std::unique_ptr<MIRGraph> mir_graph; // MIR container. |
| 85 | std::unique_ptr<Backend> cg; // Target-specific codegen. |
Ian Rogers | 5fe9af7 | 2013-11-14 00:17:20 -0800 | [diff] [blame] | 86 | TimingLogger timings; |
Jean Christophe Beyler | 8bcecce | 2014-04-29 13:42:08 -0700 | [diff] [blame] | 87 | bool print_pass; // Do we want to print a pass or not? |
Razvan A Lupusoru | bd25d4b | 2014-07-02 18:16:51 -0700 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * @brief Holds pass options for current pass being applied to compilation unit. |
| 91 | * @details This is updated for every pass to contain the overridden pass options |
| 92 | * that were specified by user. The pass itself will check this to see if the |
| 93 | * default settings have been changed. The key is simply the option string without |
| 94 | * the pass name. |
| 95 | */ |
| 96 | SafeMap<const std::string, int> overridden_pass_options; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } // namespace art |
| 100 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 101 | #endif // ART_COMPILER_DEX_COMPILER_IR_H_ |