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 | |
Logan Chien | d6e614b | 2012-03-01 20:57:44 +0800 | [diff] [blame] | 17 | #ifndef ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ |
| 18 | #define ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 19 | |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 20 | #include "base/macros.h" |
Logan Chien | df57614 | 2012-03-20 17:36:32 +0800 | [diff] [blame] | 21 | #include "compiler.h" |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 22 | #include "dex_file.h" |
Elliott Hughes | 0f3c553 | 2012-03-30 14:51:51 -0700 | [diff] [blame] | 23 | #include "instruction_set.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 24 | #include "mirror/object.h" |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 25 | #include "procedure_linkage_table.h" |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 26 | |
| 27 | #include <UniquePtr.h> |
| 28 | |
| 29 | #include <string> |
Logan Chien | df57614 | 2012-03-20 17:36:32 +0800 | [diff] [blame] | 30 | #include <utility> |
| 31 | #include <vector> |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 32 | |
| 33 | namespace art { |
Logan Chien | f04364f | 2012-02-10 12:01:39 +0800 | [diff] [blame] | 34 | class CompiledInvokeStub; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 35 | class CompiledMethod; |
| 36 | class Compiler; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 37 | class OatCompilationUnit; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 38 | namespace mirror { |
| 39 | class AbstractMethod; |
| 40 | class ClassLoader; |
| 41 | } // namespace mirror |
| 42 | } // namespace art |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 43 | |
| 44 | |
| 45 | namespace llvm { |
| 46 | class Function; |
| 47 | class LLVMContext; |
| 48 | class Module; |
| 49 | class PointerType; |
| 50 | class StructType; |
| 51 | class Type; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 52 | } // namespace llvm |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 53 | |
| 54 | |
| 55 | namespace art { |
| 56 | namespace compiler_llvm { |
| 57 | |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 58 | class LlvmCompilationUnit; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 59 | class IRBuilder; |
| 60 | |
| 61 | class CompilerLLVM { |
| 62 | public: |
| 63 | CompilerLLVM(Compiler* compiler, InstructionSet insn_set); |
| 64 | |
| 65 | ~CompilerLLVM(); |
| 66 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 67 | Compiler* GetCompiler() const { |
| 68 | return compiler_; |
| 69 | } |
| 70 | |
| 71 | InstructionSet GetInstructionSet() const { |
| 72 | return insn_set_; |
| 73 | } |
| 74 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 75 | void SetBitcodeFileName(std::string const& filename) { |
| 76 | bitcode_filename_ = filename; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 77 | } |
| 78 | |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 79 | CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit, |
| 80 | InvokeType invoke_type); |
| 81 | |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 82 | CompiledMethod* CompileGBCMethod(OatCompilationUnit* oat_compilation_unit, std::string* func); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 83 | |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 84 | CompiledMethod* CompileNativeMethod(OatCompilationUnit* oat_compilation_unit); |
| 85 | |
Logan Chien | 7a2a23a | 2012-06-06 11:01:00 +0800 | [diff] [blame] | 86 | CompiledInvokeStub* CreateInvokeStub(bool is_static, const char *shorty); |
| 87 | |
| 88 | CompiledInvokeStub* CreateProxyStub(const char *shorty); |
Logan Chien | f04364f | 2012-02-10 12:01:39 +0800 | [diff] [blame] | 89 | |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 90 | const ProcedureLinkageTable& GetProcedureLinkageTable() const { |
| 91 | return plt_; |
| 92 | } |
| 93 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 94 | private: |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 95 | LlvmCompilationUnit* AllocateCompilationUnit(); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 96 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 97 | Compiler* compiler_; |
| 98 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 99 | InstructionSet insn_set_; |
| 100 | |
TDYa127 | 55e5e6c | 2012-09-11 15:14:42 -0700 | [diff] [blame] | 101 | Mutex num_cunits_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 102 | size_t num_cunits_ GUARDED_BY(num_cunits_lock_); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 103 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 104 | std::string bitcode_filename_; |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 105 | |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 106 | ProcedureLinkageTable plt_; |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 107 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 108 | DISALLOW_COPY_AND_ASSIGN(CompilerLLVM); |
| 109 | }; |
| 110 | |
| 111 | |
| 112 | } // namespace compiler_llvm |
| 113 | } // namespace art |
| 114 | |
Logan Chien | d6e614b | 2012-03-01 20:57:44 +0800 | [diff] [blame] | 115 | #endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ |