167bf885d62b1473c833bece1c9e0bb624e6ba391buzbee/* 267bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * Copyright (C) 2011 The Android Open Source Project 367bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * 467bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * Licensed under the Apache License, Version 2.0 (the "License"); 567bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * you may not use this file except in compliance with the License. 667bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * You may obtain a copy of the License at 767bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * 867bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * http://www.apache.org/licenses/LICENSE-2.0 967bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * 1067bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * Unless required by applicable law or agreed to in writing, software 1167bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * distributed under the License is distributed on an "AS IS" BASIS, 1267bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1367bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * See the License for the specific language governing permissions and 1467bf885d62b1473c833bece1c9e0bb624e6ba391buzbee * limitations under the License. 1567bf885d62b1473c833bece1c9e0bb624e6ba391buzbee */ 1667bf885d62b1473c833bece1c9e0bb624e6ba391buzbee 17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_COMPILER_DEX_COMPILER_IR_H_ 18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_COMPILER_DEX_COMPILER_IR_H_ 1967bf885d62b1473c833bece1c9e0bb624e6ba391buzbee 20a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include <vector> 21f3e2cc4a38389aa75eb8ee3973a535254bf1c8d2Nicolas Geoffray 22cbd6d44c0a94f3d26671b5325aa21bbf1335ffe8buzbee#include "compiler_enums.h" 237940e44f4517de5e2634a7e07d58d0fb26160513Brian Carlstrom#include "dex/quick/mir_to_lir.h" 24265091e581c9f643b37e7966890911f09e223269Brian Carlstrom#include "dex_instruction.h" 257940e44f4517de5e2634a7e07d58d0fb26160513Brian Carlstrom#include "driver/compiler_driver.h" 267940e44f4517de5e2634a7e07d58d0fb26160513Brian Carlstrom#include "driver/dex_compilation_unit.h" 27265091e581c9f643b37e7966890911f09e223269Brian Carlstrom#include "safe_map.h" 2883cc7ae96d4176533dd0391a1591d321b0a87f4fVladimir Marko#include "utils/scoped_arena_allocator.h" 29a61f49539a59b610e557b5513695295639496750buzbee#include "base/timing_logger.h" 30818f2107e6d2d9e80faac8ae8c92faffa83cbd11Nicolas Geoffray#include "utils/arena_allocator.h" 3167bf885d62b1473c833bece1c9e0bb624e6ba391buzbee 3211d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughesnamespace art { 3311d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughes 34ba938cbb8d73a0dcf151dfaec4662496da6afdbfbuzbeestruct ArenaMemBlock; 3525724efbf84cce5734d1869e636cf59bc3f95941Vladimir Markoclass Backend; 36ba938cbb8d73a0dcf151dfaec4662496da6afdbfbuzbeestruct Memstats; 37311ca169f4727d46a55bdc8dfa0059719fa72b65buzbeeclass MIRGraph; 381fd3346740dfb7f47be9922312b68a4227fada96buzbeeclass Mir2Lir; 395b53710b4abcf8f35c91a963a475b72cb34757e6buzbee 40719ace4734f519c67fd2c1ff7a232c079309a615Elliott Hughesstruct CompilationUnit { 4125724efbf84cce5734d1869e636cf59bc3f95941Vladimir Marko explicit CompilationUnit(ArenaPool* pool); 4225724efbf84cce5734d1869e636cf59bc3f95941Vladimir Marko ~CompilationUnit(); 43a61f49539a59b610e557b5513695295639496750buzbee 44a61f49539a59b610e557b5513695295639496750buzbee void StartTimingSplit(const char* label); 45a61f49539a59b610e557b5513695295639496750buzbee void NewTimingSplit(const char* label); 46a61f49539a59b610e557b5513695295639496750buzbee void EndTiming(); 47a61f49539a59b610e557b5513695295639496750buzbee 48311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee /* 49311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee * Fields needed/generated by common frontend and generally used throughout 50311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee * the compiler. 51311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee */ 521212a022fa5f8ef9585d765b1809521812af882cIan Rogers CompilerDriver* compiler_driver; 5302031b185b4653e6c72e21f7a51238b903f6d638buzbee ClassLinker* class_linker; // Linker to resolve fields and methods. 5402031b185b4653e6c72e21f7a51238b903f6d638buzbee const DexFile* dex_file; // DexFile containing the method being compiled. 5502031b185b4653e6c72e21f7a51238b903f6d638buzbee jobject class_loader; // compiling method's class loader. 568b2c0b9abc3f520495f4387ea040132ba85cae69Ian Rogers uint16_t class_def_idx; // compiling method's defining class definition index. 5702031b185b4653e6c72e21f7a51238b903f6d638buzbee uint32_t method_idx; // compiling method's index into method_ids of DexFile. 5802031b185b4653e6c72e21f7a51238b903f6d638buzbee const DexFile::CodeItem* code_item; // compiling method's DexFile code_item. 5902031b185b4653e6c72e21f7a51238b903f6d638buzbee uint32_t access_flags; // compiling method's access flags. 6002031b185b4653e6c72e21f7a51238b903f6d638buzbee InvokeType invoke_type; // compiling method's invocation type. 6102031b185b4653e6c72e21f7a51238b903f6d638buzbee const char* shorty; // compiling method's shorty. 6202031b185b4653e6c72e21f7a51238b903f6d638buzbee uint32_t disable_opt; // opt_control_vector flags. 6302031b185b4653e6c72e21f7a51238b903f6d638buzbee uint32_t enable_debug; // debugControlVector flags. 64311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee bool verbose; 65b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const Compiler* compiler; 66fa57c47f1b72916371a9c2d5c1389219bce655b4buzbee InstructionSet instruction_set; 672da882315a61072664f7ce3c212307342e907207Andreas Gampe bool target64; 68a114add0300b95eeaae7465493f39144e07324e8Bill Buzbee 693d504075f7c1204d581923460754bf6d3714b13fIan Rogers InstructionSetFeatures GetInstructionSetFeatures() { 707020278bce98a0735dc6abcbd33bdf1ed2634f1dDave Allison return compiler_driver->GetInstructionSetFeatures(); 717020278bce98a0735dc6abcbd33bdf1ed2634f1dDave Allison } 721fd3346740dfb7f47be9922312b68a4227fada96buzbee // TODO: much of this info available elsewhere. Go to the original source? 730d82948094d9a198e01aa95f64012bdedd5b6fc9buzbee uint16_t num_dalvik_registers; // method->registers_size. 74311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee const uint16_t* insns; 750d82948094d9a198e01aa95f64012bdedd5b6fc9buzbee uint16_t num_ins; 760d82948094d9a198e01aa95f64012bdedd5b6fc9buzbee uint16_t num_outs; 770d82948094d9a198e01aa95f64012bdedd5b6fc9buzbee uint16_t num_regs; // Unlike num_dalvik_registers, does not include ins. 781fd3346740dfb7f47be9922312b68a4227fada96buzbee 79a114add0300b95eeaae7465493f39144e07324e8Bill Buzbee // If non-empty, apply optimizer/debug flags only to matching methods. 80fa57c47f1b72916371a9c2d5c1389219bce655b4buzbee std::string compiler_method_match; 81fa57c47f1b72916371a9c2d5c1389219bce655b4buzbee // Flips sense of compiler_method_match - apply flags if doesn't match. 82fa57c47f1b72916371a9c2d5c1389219bce655b4buzbee bool compiler_flip_match; 831fd3346740dfb7f47be9922312b68a4227fada96buzbee 841fd3346740dfb7f47be9922312b68a4227fada96buzbee // TODO: move memory management to mir_graph, or just switch to using standard containers. 85862a76027076c341c26aa6cd4a30a7cdd6dc2143buzbee ArenaAllocator arena; 8683cc7ae96d4176533dd0391a1591d321b0a87f4fVladimir Marko ArenaStack arena_stack; // Arenas for ScopedArenaAllocator. 87265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 88700a402244a1a423da4f3ba8032459f4b65fa18fIan Rogers std::unique_ptr<MIRGraph> mir_graph; // MIR container. 89700a402244a1a423da4f3ba8032459f4b65fa18fIan Rogers std::unique_ptr<Backend> cg; // Target-specific codegen. 905fe9af720048673e62ee29597a30bb9e54c903c5Ian Rogers TimingLogger timings; 918bceccec7eddff8cd872aa20505b4a3a6be60a16Jean Christophe Beyler bool print_pass; // Do we want to print a pass or not? 9216da88c70c4bdbd97b8482be8b42103a52f22d59buzbee}; 9316da88c70c4bdbd97b8482be8b42103a52f22d59buzbee 9411d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughes} // namespace art 9511d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughes 96fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_COMPILER_DEX_COMPILER_IR_H_ 97