blob: 15a789c64f9ebb2eff4562226a3e607f5d101073 [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;
24 class ClassLoader;
25 class CompiledMethod;
26 class Compiler;
27 class DexCache;
28 class DexFile;
29 class Method;
30 class OatCompilationUnit;
31}
32
33namespace llvm {
TDYa12728f1a142012-03-15 21:51:52 -070034 class AllocaInst;
Logan Chien88894ee2012-02-13 16:42:22 +080035 class Function;
36 class FunctionType;
TDYa12728f1a142012-03-15 21:51:52 -070037 class BasicBlock;
Logan Chien88894ee2012-02-13 16:42:22 +080038 class LLVMContext;
39 class Module;
TDYa12728f1a142012-03-15 21:51:52 -070040 class Type;
41 class Value;
Logan Chien88894ee2012-02-13 16:42:22 +080042}
43
44namespace art {
45namespace compiler_llvm {
46
Logan Chien8b977d32012-02-21 19:14:55 +080047class CompilationUnit;
Logan Chien88894ee2012-02-13 16:42:22 +080048class IRBuilder;
49
50class JniCompiler {
51 public:
Logan Chien8b977d32012-02-21 19:14:55 +080052 JniCompiler(CompilationUnit* cunit,
Logan Chien88894ee2012-02-13 16:42:22 +080053 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,
TDYa12728f1a142012-03-15 21:51:52 -070062 bool is_static, bool is_target_function);
Logan Chien88894ee2012-02-13 16:42:22 +080063
64 private:
Logan Chien8b977d32012-02-21 19:14:55 +080065 CompilationUnit* cunit_;
Logan Chien88894ee2012-02-13 16:42:22 +080066 Compiler const* compiler_;
Logan Chien88894ee2012-02-13 16:42:22 +080067
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 Chien88894ee2012-02-13 16:42:22 +080082 llvm::Function* func_;
Logan Chien937105a2012-04-02 02:37:37 +080083 uint16_t elf_func_idx_;
Logan Chien88894ee2012-02-13 16:42:22 +080084};
85
86
87} // namespace compiler_llvm
88} // namespace art
89
90
91#endif // ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_