blob: c15dae5ca4fdae2f6cef41fb3697a3cdd71d29a3 [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:
TDYa12728f1a142012-03-15 21:51:52 -070065 llvm::Value* LoadFromObjectOffset(llvm::Value* object_addr, int32_t offset, llvm::Type* type);
66
TDYa12731a99332012-03-19 02:58:02 -070067 void StoreToObjectOffset(llvm::Value* object_addr, int32_t offset, llvm::Value* new_value);
TDYa12728f1a142012-03-15 21:51:52 -070068
Logan Chien8b977d32012-02-21 19:14:55 +080069 CompilationUnit* cunit_;
Logan Chien88894ee2012-02-13 16:42:22 +080070 Compiler const* compiler_;
Logan Chien88894ee2012-02-13 16:42:22 +080071
72 llvm::Module* module_;
73 llvm::LLVMContext* context_;
74 IRBuilder& irb_;
75
76 OatCompilationUnit* oat_compilation_unit_;
77
78 uint32_t access_flags_;
79 uint32_t method_idx_;
80 ClassLinker * class_linker_;
81 ClassLoader const* class_loader_;
82 DexCache const* dex_cache_;
83 DexFile const* dex_file_;
84 Method* method_;
85
Logan Chien88894ee2012-02-13 16:42:22 +080086 llvm::Function* func_;
87};
88
89
90} // namespace compiler_llvm
91} // namespace art
92
93
94#endif // ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_