blob: e7182a919bfb8121fdf2f1be9f14479efe01bc45 [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_DEX_COMPILER_IR_H_
18#define ART_COMPILER_DEX_COMPILER_IR_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
Andreas Gampe0b9203e2015-01-22 20:39:27 -080020#include "jni.h"
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070021#include <string>
Brian Carlstrom7940e442013-07-12 13:46:57 -070022#include <vector>
Nicolas Geoffrayf3e2cc42014-02-18 18:37:26 +000023
buzbeea61f4952013-08-23 14:27:06 -070024#include "base/timing_logger.h"
Andreas Gampe0b9203e2015-01-22 20:39:27 -080025#include "invoke_type.h"
26#include "safe_map.h"
Nicolas Geoffray818f2102014-02-18 16:43:35 +000027#include "utils/arena_allocator.h"
Andreas Gampe0b9203e2015-01-22 20:39:27 -080028#include "utils/scoped_arena_allocator.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070029
30namespace art {
31
Vladimir Marko25724ef2013-11-12 15:09:20 +000032class Backend;
Andreas Gampe53c913b2014-08-12 23:19:23 -070033class ClassLinker;
Andreas Gampe0b9203e2015-01-22 20:39:27 -080034class CompilerDriver;
Brian Carlstrom7940e442013-07-12 13:46:57 -070035class MIRGraph;
Andreas Gampe53c913b2014-08-12 23:19:23 -070036
Brian Carlstrom7940e442013-07-12 13:46:57 -070037struct CompilationUnit {
Andreas Gampe0b9203e2015-01-22 20:39:27 -080038 CompilationUnit(ArenaPool* pool, InstructionSet isa, CompilerDriver* driver, ClassLinker* linker);
Vladimir Marko25724ef2013-11-12 15:09:20 +000039 ~CompilationUnit();
buzbeea61f4952013-08-23 14:27:06 -070040
41 void StartTimingSplit(const char* label);
42 void NewTimingSplit(const char* label);
43 void EndTiming();
44
Brian Carlstrom7940e442013-07-12 13:46:57 -070045 /*
46 * Fields needed/generated by common frontend and generally used throughout
47 * the compiler.
48 */
Andreas Gampe0b9203e2015-01-22 20:39:27 -080049 CompilerDriver* const compiler_driver;
50 ClassLinker* const class_linker; // Linker to resolve fields and methods.
51 const DexFile* dex_file; // DexFile containing the method being compiled.
52 jobject class_loader; // compiling method's class loader.
53 uint16_t class_def_idx; // compiling method's defining class definition index.
54 uint32_t method_idx; // compiling method's index into method_ids of DexFile.
55 uint32_t access_flags; // compiling method's access flags.
56 InvokeType invoke_type; // compiling method's invocation type.
57 const char* shorty; // compiling method's shorty.
58 uint32_t disable_opt; // opt_control_vector flags.
59 uint32_t enable_debug; // debugControlVector flags.
Brian Carlstrom7940e442013-07-12 13:46:57 -070060 bool verbose;
Andreas Gampe0b9203e2015-01-22 20:39:27 -080061 const InstructionSet instruction_set;
62 const bool target64;
Brian Carlstrom7940e442013-07-12 13:46:57 -070063
64 // TODO: move memory management to mir_graph, or just switch to using standard containers.
65 ArenaAllocator arena;
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000066 ArenaStack arena_stack; // Arenas for ScopedArenaAllocator.
Brian Carlstrom7940e442013-07-12 13:46:57 -070067
Ian Rogers700a4022014-05-19 16:49:03 -070068 std::unique_ptr<MIRGraph> mir_graph; // MIR container.
69 std::unique_ptr<Backend> cg; // Target-specific codegen.
Ian Rogers5fe9af72013-11-14 00:17:20 -080070 TimingLogger timings;
Jean Christophe Beyler8bcecce2014-04-29 13:42:08 -070071 bool print_pass; // Do we want to print a pass or not?
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070072
73 /**
74 * @brief Holds pass options for current pass being applied to compilation unit.
75 * @details This is updated for every pass to contain the overridden pass options
76 * that were specified by user. The pass itself will check this to see if the
77 * default settings have been changed. The key is simply the option string without
78 * the pass name.
79 */
80 SafeMap<const std::string, int> overridden_pass_options;
Brian Carlstrom7940e442013-07-12 13:46:57 -070081};
82
83} // namespace art
84
Brian Carlstromfc0e3212013-07-17 14:40:12 -070085#endif // ART_COMPILER_DEX_COMPILER_IR_H_