OSDN Git Service

am b148ad48: am f72fd02c: Merge "Quick compiler: disable GVN DO NOT MERGE" into lmp-dev
[android-x86/art.git] / compiler / llvm / compiler_llvm.h
1 /*
2  * Copyright (C) 2012 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
17 #ifndef ART_COMPILER_LLVM_COMPILER_LLVM_H_
18 #define ART_COMPILER_LLVM_COMPILER_LLVM_H_
19
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <vector>
24
25 #include "base/macros.h"
26 #include "dex_file.h"
27 #include "driver/compiler_driver.h"
28 #include "instruction_set.h"
29 #include "mirror/object.h"
30
31 namespace art {
32   class CompiledMethod;
33   class CompilerDriver;
34   class DexCompilationUnit;
35   namespace mirror {
36     class ArtMethod;
37     class ClassLoader;
38   }  // namespace mirror
39 }  // namespace art
40
41
42 namespace llvm {
43   class Function;
44   class LLVMContext;
45   class Module;
46   class PointerType;
47   class StructType;
48   class Type;
49 }  // namespace llvm
50
51
52 namespace art {
53 namespace llvm {
54
55 class LlvmCompilationUnit;
56 class IRBuilder;
57
58 class CompilerLLVM {
59  public:
60   CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set);
61
62   ~CompilerLLVM();
63
64   CompilerDriver* GetCompiler() const {
65     return compiler_driver_;
66   }
67
68   InstructionSet GetInstructionSet() const {
69     return insn_set_;
70   }
71
72   void SetBitcodeFileName(const std::string& filename) {
73     bitcode_filename_ = filename;
74   }
75
76   CompiledMethod* CompileDexMethod(DexCompilationUnit* dex_compilation_unit,
77                                    InvokeType invoke_type);
78
79   CompiledMethod* CompileGBCMethod(DexCompilationUnit* dex_compilation_unit, std::string* func);
80
81   CompiledMethod* CompileNativeMethod(DexCompilationUnit* dex_compilation_unit);
82
83  private:
84   LlvmCompilationUnit* AllocateCompilationUnit();
85
86   CompilerDriver* const compiler_driver_;
87
88   const InstructionSet insn_set_;
89
90   Mutex next_cunit_id_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
91   size_t next_cunit_id_ GUARDED_BY(next_cunit_id_lock_);
92
93   std::string bitcode_filename_;
94
95   DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
96 };
97
98 void ArtInitCompilerContext(CompilerDriver* driver);
99
100 void ArtUnInitCompilerContext(CompilerDriver* driver);
101
102 CompiledMethod* ArtCompileMethod(CompilerDriver* driver, const DexFile::CodeItem* code_item,
103                                  uint32_t access_flags, InvokeType invoke_type,
104                                  uint16_t class_def_idx, uint32_t method_idx, jobject class_loader,
105                                  const DexFile& dex_file);
106
107 CompiledMethod* ArtLLVMJniCompileMethod(CompilerDriver* driver, uint32_t access_flags,
108                                         uint32_t method_idx, const DexFile& dex_file);
109
110 void compilerLLVMSetBitcodeFileName(const CompilerDriver& driver, const std::string& filename);
111
112 }  // namespace llvm
113 }  // namespace art
114
115 #endif  // ART_COMPILER_LLVM_COMPILER_LLVM_H_