blob: 46481802b5a78a592e96b14d9ced335f050a73b0 [file] [log] [blame]
Logan Chien88894ee2012-02-13 16:42:22 +08001/*
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 Chien88894ee2012-02-13 16:42:22 +080020#include <stdint.h>
21
22namespace art {
23 class ClassLinker;
Logan Chien88894ee2012-02-13 16:42:22 +080024 class CompiledMethod;
25 class Compiler;
Logan Chien88894ee2012-02-13 16:42:22 +080026 class DexFile;
Logan Chien88894ee2012-02-13 16:42:22 +080027 class OatCompilationUnit;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080028 namespace mirror {
29 class AbstractMethod;
30 class ClassLoader;
31 class DexCache;
32 } // namespace mirror
33} // namespace art
Logan Chien88894ee2012-02-13 16:42:22 +080034
35namespace llvm {
TDYa12728f1a142012-03-15 21:51:52 -070036 class AllocaInst;
Logan Chien88894ee2012-02-13 16:42:22 +080037 class Function;
38 class FunctionType;
TDYa12728f1a142012-03-15 21:51:52 -070039 class BasicBlock;
Logan Chien88894ee2012-02-13 16:42:22 +080040 class LLVMContext;
41 class Module;
TDYa12728f1a142012-03-15 21:51:52 -070042 class Type;
43 class Value;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080044} // namespace llvm
Logan Chien88894ee2012-02-13 16:42:22 +080045
46namespace art {
47namespace compiler_llvm {
48
Brian Carlstrom641ce032013-01-31 15:21:37 -080049class LlvmCompilationUnit;
Logan Chien88894ee2012-02-13 16:42:22 +080050class IRBuilder;
51
52class JniCompiler {
53 public:
Brian Carlstrom641ce032013-01-31 15:21:37 -080054 JniCompiler(LlvmCompilationUnit* cunit,
Logan Chien88894ee2012-02-13 16:42:22 +080055 Compiler const& compiler,
56 OatCompilationUnit* oat_compilation_unit);
57
58 CompiledMethod* Compile();
59
60 private:
61 void CreateFunction();
62
63 llvm::FunctionType* GetFunctionType(uint32_t method_idx,
TDYa12728f1a142012-03-15 21:51:52 -070064 bool is_static, bool is_target_function);
Logan Chien88894ee2012-02-13 16:42:22 +080065
66 private:
Brian Carlstrom641ce032013-01-31 15:21:37 -080067 LlvmCompilationUnit* cunit_;
Logan Chien12584172012-07-10 04:07:28 -070068 const Compiler* compiler_;
Logan Chien88894ee2012-02-13 16:42:22 +080069
70 llvm::Module* module_;
71 llvm::LLVMContext* context_;
72 IRBuilder& irb_;
73
74 OatCompilationUnit* oat_compilation_unit_;
75
76 uint32_t access_flags_;
77 uint32_t method_idx_;
Logan Chien12584172012-07-10 04:07:28 -070078 const DexFile* dex_file_;
Logan Chien88894ee2012-02-13 16:42:22 +080079
Logan Chien88894ee2012-02-13 16:42:22 +080080 llvm::Function* func_;
Logan Chien937105a2012-04-02 02:37:37 +080081 uint16_t elf_func_idx_;
Logan Chien88894ee2012-02-13 16:42:22 +080082};
83
84
85} // namespace compiler_llvm
86} // namespace art
87
88
89#endif // ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_