Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 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_SRC_COMPILER_LLVM_LLVM_COMPILER_H_ |
| 18 | #define ART_SRC_COMPILER_LLVM_LLVM_COMPILER_H_ |
| 19 | |
| 20 | #include "constants.h" |
| 21 | #include "dex_file.h" |
| 22 | #include "macros.h" |
| 23 | |
| 24 | #include <UniquePtr.h> |
| 25 | |
| 26 | #include <string> |
| 27 | |
| 28 | namespace art { |
| 29 | class ClassLoader; |
Logan Chien | f04364f | 2012-02-10 12:01:39 +0800 | [diff] [blame] | 30 | class CompiledInvokeStub; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 31 | class CompiledMethod; |
| 32 | class Compiler; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 33 | class OatCompilationUnit; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | |
| 37 | namespace llvm { |
| 38 | class Function; |
| 39 | class LLVMContext; |
| 40 | class Module; |
| 41 | class PointerType; |
| 42 | class StructType; |
| 43 | class Type; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | namespace art { |
| 48 | namespace compiler_llvm { |
| 49 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 50 | class CompilationUnit; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 51 | class IRBuilder; |
| 52 | |
| 53 | class CompilerLLVM { |
| 54 | public: |
| 55 | CompilerLLVM(Compiler* compiler, InstructionSet insn_set); |
| 56 | |
| 57 | ~CompilerLLVM(); |
| 58 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 59 | void MaterializeEveryCompilationUnit(); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 60 | |
| 61 | Compiler* GetCompiler() const { |
| 62 | return compiler_; |
| 63 | } |
| 64 | |
| 65 | InstructionSet GetInstructionSet() const { |
| 66 | return insn_set_; |
| 67 | } |
| 68 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 69 | void SetElfFileName(std::string const& filename) { |
| 70 | elf_filename_ = filename; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 71 | } |
| 72 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 73 | void SetBitcodeFileName(std::string const& filename) { |
| 74 | bitcode_filename_ = filename; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 77 | CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 78 | |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 79 | CompiledMethod* CompileNativeMethod(OatCompilationUnit* oat_compilation_unit); |
| 80 | |
Logan Chien | f04364f | 2012-02-10 12:01:39 +0800 | [diff] [blame] | 81 | CompiledInvokeStub* CreateInvokeStub(bool is_static, char const *shorty); |
| 82 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 83 | private: |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 84 | void EnsureCompilationUnit(); |
| 85 | |
| 86 | void MaterializeCompilationUnit(); |
| 87 | |
| 88 | void MaterializeCompilationUnitSafePoint(); |
| 89 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 90 | Compiler* compiler_; |
| 91 | |
| 92 | Mutex compiler_lock_; |
| 93 | |
| 94 | InstructionSet insn_set_; |
| 95 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 96 | UniquePtr<CompilationUnit> cunit_; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 97 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 98 | unsigned cunit_counter_; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 99 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 100 | std::string elf_filename_; |
| 101 | |
| 102 | std::string bitcode_filename_; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 103 | |
| 104 | DISALLOW_COPY_AND_ASSIGN(CompilerLLVM); |
| 105 | }; |
| 106 | |
| 107 | |
| 108 | } // namespace compiler_llvm |
| 109 | } // namespace art |
| 110 | |
| 111 | #endif // ART_SRC_COMPILER_LLVM_LLVM_COMPILER_H_ |