blob: a6ddce389726cf0ac9045736e5d37048165a4cd6 [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
20#include "constants.h"
21
22#include <stdint.h>
23
24namespace art {
25 class ClassLinker;
26 class ClassLoader;
27 class CompiledMethod;
28 class Compiler;
29 class DexCache;
30 class DexFile;
31 class Method;
32 class OatCompilationUnit;
33}
34
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;
Logan Chien88894ee2012-02-13 16:42:22 +080044}
45
46namespace art {
47namespace compiler_llvm {
48
Logan Chien8b977d32012-02-21 19:14:55 +080049class CompilationUnit;
Logan Chien88894ee2012-02-13 16:42:22 +080050class IRBuilder;
51
52class JniCompiler {
53 public:
Logan Chien8b977d32012-02-21 19:14:55 +080054 JniCompiler(CompilationUnit* 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:
TDYa12728f1a142012-03-15 21:51:52 -070067 llvm::Value* LoadFromObjectOffset(llvm::Value* object_addr, int32_t offset, llvm::Type* type);
68
TDYa12731a99332012-03-19 02:58:02 -070069 void StoreToObjectOffset(llvm::Value* object_addr, int32_t offset, llvm::Value* new_value);
TDYa12728f1a142012-03-15 21:51:52 -070070
Logan Chien8b977d32012-02-21 19:14:55 +080071 CompilationUnit* cunit_;
Logan Chien88894ee2012-02-13 16:42:22 +080072 Compiler const* compiler_;
Logan Chien88894ee2012-02-13 16:42:22 +080073
74 llvm::Module* module_;
75 llvm::LLVMContext* context_;
76 IRBuilder& irb_;
77
78 OatCompilationUnit* oat_compilation_unit_;
79
80 uint32_t access_flags_;
81 uint32_t method_idx_;
82 ClassLinker * class_linker_;
83 ClassLoader const* class_loader_;
84 DexCache const* dex_cache_;
85 DexFile const* dex_file_;
86 Method* method_;
87
TDYa12728f1a142012-03-15 21:51:52 -070088 llvm::BasicBlock* basic_block_;
89 llvm::AllocaInst* shadow_frame_;
90
Logan Chien88894ee2012-02-13 16:42:22 +080091 llvm::Function* func_;
92};
93
94
95} // namespace compiler_llvm
96} // namespace art
97
98
99#endif // ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_