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