Logan Chien | 88894ee | 2012-02-13 16:42:22 +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_JNI_COMPILER_H_ |
| 18 | #define ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_ |
| 19 | |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | |
| 22 | namespace art { |
| 23 | class ClassLinker; |
| 24 | class ClassLoader; |
| 25 | class CompiledMethod; |
| 26 | class Compiler; |
| 27 | class DexCache; |
| 28 | class DexFile; |
| 29 | class Method; |
| 30 | class OatCompilationUnit; |
| 31 | } |
| 32 | |
| 33 | namespace llvm { |
TDYa127 | 28f1a14 | 2012-03-15 21:51:52 -0700 | [diff] [blame] | 34 | class AllocaInst; |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 35 | class Function; |
| 36 | class FunctionType; |
TDYa127 | 28f1a14 | 2012-03-15 21:51:52 -0700 | [diff] [blame] | 37 | class BasicBlock; |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 38 | class LLVMContext; |
| 39 | class Module; |
TDYa127 | 28f1a14 | 2012-03-15 21:51:52 -0700 | [diff] [blame] | 40 | class Type; |
| 41 | class Value; |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | namespace art { |
| 45 | namespace compiler_llvm { |
| 46 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 47 | class CompilationUnit; |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 48 | class IRBuilder; |
| 49 | |
| 50 | class JniCompiler { |
| 51 | public: |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 52 | JniCompiler(CompilationUnit* cunit, |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 53 | Compiler const& compiler, |
| 54 | OatCompilationUnit* oat_compilation_unit); |
| 55 | |
| 56 | CompiledMethod* Compile(); |
| 57 | |
| 58 | private: |
| 59 | void CreateFunction(); |
| 60 | |
| 61 | llvm::FunctionType* GetFunctionType(uint32_t method_idx, |
TDYa127 | 28f1a14 | 2012-03-15 21:51:52 -0700 | [diff] [blame] | 62 | bool is_static, bool is_target_function); |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 63 | |
| 64 | private: |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 65 | CompilationUnit* cunit_; |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 66 | Compiler const* compiler_; |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 67 | |
| 68 | llvm::Module* module_; |
| 69 | llvm::LLVMContext* context_; |
| 70 | IRBuilder& irb_; |
| 71 | |
| 72 | OatCompilationUnit* oat_compilation_unit_; |
| 73 | |
| 74 | uint32_t access_flags_; |
| 75 | uint32_t method_idx_; |
| 76 | ClassLinker * class_linker_; |
| 77 | ClassLoader const* class_loader_; |
| 78 | DexCache const* dex_cache_; |
| 79 | DexFile const* dex_file_; |
| 80 | Method* method_; |
| 81 | |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 82 | llvm::Function* func_; |
Logan Chien | 937105a | 2012-04-02 02:37:37 +0800 | [diff] [blame] | 83 | uint16_t elf_func_idx_; |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | |
| 87 | } // namespace compiler_llvm |
| 88 | } // namespace art |
| 89 | |
| 90 | |
| 91 | #endif // ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_ |