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 | |
| 50 | class IRBuilder; |
| 51 | |
| 52 | class CompilerLLVM { |
| 53 | public: |
| 54 | CompilerLLVM(Compiler* compiler, InstructionSet insn_set); |
| 55 | |
| 56 | ~CompilerLLVM(); |
| 57 | |
| 58 | void MaterializeLLVMModule(); |
| 59 | |
| 60 | void WriteBitcodeToFile(std::string const &filename); |
| 61 | |
| 62 | Compiler* GetCompiler() const { |
| 63 | return compiler_; |
| 64 | } |
| 65 | |
| 66 | InstructionSet GetInstructionSet() const { |
| 67 | return insn_set_; |
| 68 | } |
| 69 | |
| 70 | llvm::Module* GetModule() const { |
| 71 | return module_; |
| 72 | } |
| 73 | |
| 74 | llvm::LLVMContext* GetLLVMContext() const { |
| 75 | return context_.get(); |
| 76 | } |
| 77 | |
| 78 | IRBuilder* GetIRBuilder() const { |
| 79 | return irb_.get(); |
| 80 | } |
| 81 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame^] | 82 | CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 83 | |
Logan Chien | f04364f | 2012-02-10 12:01:39 +0800 | [diff] [blame] | 84 | CompiledInvokeStub* CreateInvokeStub(bool is_static, char const *shorty); |
| 85 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 86 | private: |
| 87 | Compiler* compiler_; |
| 88 | |
| 89 | Mutex compiler_lock_; |
| 90 | |
| 91 | InstructionSet insn_set_; |
| 92 | |
| 93 | UniquePtr<llvm::LLVMContext> context_; |
| 94 | |
| 95 | UniquePtr<IRBuilder> irb_; |
| 96 | |
| 97 | llvm::Module* module_; |
| 98 | |
| 99 | DISALLOW_COPY_AND_ASSIGN(CompilerLLVM); |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | } // namespace compiler_llvm |
| 104 | } // namespace art |
| 105 | |
| 106 | #endif // ART_SRC_COMPILER_LLVM_LLVM_COMPILER_H_ |