compiler_ir.h revision 0b9203e7996ee1856f620f95d95d8a273c43a3df
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 200b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe#include "jni.h" 21bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru#include <string> 22a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include <vector> 23f3e2cc4a38389aa75eb8ee3973a535254bf1c8d2Nicolas Geoffray 24a61f49539a59b610e557b5513695295639496750buzbee#include "base/timing_logger.h" 250b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe#include "invoke_type.h" 260b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe#include "safe_map.h" 27818f2107e6d2d9e80faac8ae8c92faffa83cbd11Nicolas Geoffray#include "utils/arena_allocator.h" 280b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe#include "utils/scoped_arena_allocator.h" 2967bf885d62b1473c833bece1c9e0bb624e6ba391buzbee 3011d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughesnamespace art { 3111d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughes 3225724efbf84cce5734d1869e636cf59bc3f95941Vladimir Markoclass Backend; 3353c913bb71b218714823c8c87a1f92830c336f61Andreas Gampeclass ClassLinker; 340b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampeclass CompilerDriver; 35311ca169f4727d46a55bdc8dfa0059719fa72b65buzbeeclass MIRGraph; 3653c913bb71b218714823c8c87a1f92830c336f61Andreas Gampe 37719ace4734f519c67fd2c1ff7a232c079309a615Elliott Hughesstruct CompilationUnit { 380b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe CompilationUnit(ArenaPool* pool, InstructionSet isa, CompilerDriver* driver, ClassLinker* linker); 3925724efbf84cce5734d1869e636cf59bc3f95941Vladimir Marko ~CompilationUnit(); 40a61f49539a59b610e557b5513695295639496750buzbee 41a61f49539a59b610e557b5513695295639496750buzbee void StartTimingSplit(const char* label); 42a61f49539a59b610e557b5513695295639496750buzbee void NewTimingSplit(const char* label); 43a61f49539a59b610e557b5513695295639496750buzbee void EndTiming(); 44a61f49539a59b610e557b5513695295639496750buzbee 45311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee /* 46311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee * Fields needed/generated by common frontend and generally used throughout 47311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee * the compiler. 48311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee */ 490b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe CompilerDriver* const compiler_driver; 500b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe ClassLinker* const class_linker; // Linker to resolve fields and methods. 510b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe const DexFile* dex_file; // DexFile containing the method being compiled. 520b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe jobject class_loader; // compiling method's class loader. 530b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe uint16_t class_def_idx; // compiling method's defining class definition index. 540b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe uint32_t method_idx; // compiling method's index into method_ids of DexFile. 550b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe uint32_t access_flags; // compiling method's access flags. 560b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe InvokeType invoke_type; // compiling method's invocation type. 570b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe const char* shorty; // compiling method's shorty. 580b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe uint32_t disable_opt; // opt_control_vector flags. 590b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe uint32_t enable_debug; // debugControlVector flags. 60311ca169f4727d46a55bdc8dfa0059719fa72b65buzbee bool verbose; 610b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe const InstructionSet instruction_set; 620b9203e7996ee1856f620f95d95d8a273c43a3dfAndreas Gampe const bool target64; 631fd3346740dfb7f47be9922312b68a4227fada96buzbee 641fd3346740dfb7f47be9922312b68a4227fada96buzbee // TODO: move memory management to mir_graph, or just switch to using standard containers. 65862a76027076c341c26aa6cd4a30a7cdd6dc2143buzbee ArenaAllocator arena; 6683cc7ae96d4176533dd0391a1591d321b0a87f4fVladimir Marko ArenaStack arena_stack; // Arenas for ScopedArenaAllocator. 67265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 68700a402244a1a423da4f3ba8032459f4b65fa18fIan Rogers std::unique_ptr<MIRGraph> mir_graph; // MIR container. 69700a402244a1a423da4f3ba8032459f4b65fa18fIan Rogers std::unique_ptr<Backend> cg; // Target-specific codegen. 705fe9af720048673e62ee29597a30bb9e54c903c5Ian Rogers TimingLogger timings; 718bceccec7eddff8cd872aa20505b4a3a6be60a16Jean Christophe Beyler bool print_pass; // Do we want to print a pass or not? 72bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru 73bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru /** 74bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru * @brief Holds pass options for current pass being applied to compilation unit. 75bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru * @details This is updated for every pass to contain the overridden pass options 76bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru * that were specified by user. The pass itself will check this to see if the 77bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru * default settings have been changed. The key is simply the option string without 78bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru * the pass name. 79bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru */ 80bd25d4bff69e4775b7844d48630618b5ad8d3343Razvan A Lupusoru SafeMap<const std::string, int> overridden_pass_options; 8116da88c70c4bdbd97b8482be8b42103a52f22d59buzbee}; 8216da88c70c4bdbd97b8482be8b42103a52f22d59buzbee 8311d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughes} // namespace art 8411d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughes 85fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_COMPILER_DEX_COMPILER_IR_H_ 86