blob: 9bdf35ef10f2cfa19b279c938bc90dfd8abccc14 [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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
18#define ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
Logan Chien88894ee2012-02-13 16:42:22 +080019
Logan Chien88894ee2012-02-13 16:42:22 +080020#include <stdint.h>
21
Brian Carlstrom265091e2013-01-30 14:08:26 -080022#include <string>
23
Logan Chien88894ee2012-02-13 16:42:22 +080024namespace art {
25 class ClassLinker;
Logan Chien88894ee2012-02-13 16:42:22 +080026 class CompiledMethod;
Ian Rogers1212a022013-03-04 10:48:41 -080027 class CompilerDriver;
Logan Chien88894ee2012-02-13 16:42:22 +080028 class DexFile;
Ian Rogers89756f22013-03-04 16:40:02 -080029 class DexCompilationUnit;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030 namespace mirror {
31 class AbstractMethod;
32 class ClassLoader;
33 class DexCache;
34 } // namespace mirror
35} // namespace art
Logan Chien88894ee2012-02-13 16:42:22 +080036
37namespace llvm {
TDYa12728f1a142012-03-15 21:51:52 -070038 class AllocaInst;
Logan Chien88894ee2012-02-13 16:42:22 +080039 class Function;
40 class FunctionType;
TDYa12728f1a142012-03-15 21:51:52 -070041 class BasicBlock;
Logan Chien88894ee2012-02-13 16:42:22 +080042 class LLVMContext;
43 class Module;
TDYa12728f1a142012-03-15 21:51:52 -070044 class Type;
45 class Value;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080046} // namespace llvm
Logan Chien88894ee2012-02-13 16:42:22 +080047
48namespace art {
Ian Rogers4c1c2832013-03-04 18:30:13 -080049namespace llvm {
Logan Chien88894ee2012-02-13 16:42:22 +080050
Brian Carlstrom641ce032013-01-31 15:21:37 -080051class LlvmCompilationUnit;
Logan Chien88894ee2012-02-13 16:42:22 +080052class IRBuilder;
53
54class JniCompiler {
55 public:
Brian Carlstrom641ce032013-01-31 15:21:37 -080056 JniCompiler(LlvmCompilationUnit* cunit,
Ian Rogers1212a022013-03-04 10:48:41 -080057 const CompilerDriver& driver,
Ian Rogers89756f22013-03-04 16:40:02 -080058 const DexCompilationUnit* dex_compilation_unit);
Logan Chien88894ee2012-02-13 16:42:22 +080059
60 CompiledMethod* Compile();
61
62 private:
Brian Carlstrom265091e2013-01-30 14:08:26 -080063 void CreateFunction(const std::string& symbol);
Logan Chien88894ee2012-02-13 16:42:22 +080064
Ian Rogers4c1c2832013-03-04 18:30:13 -080065 ::llvm::FunctionType* GetFunctionType(uint32_t method_idx,
Brian Carlstrom265091e2013-01-30 14:08:26 -080066 bool is_static, bool is_target_function);
Logan Chien88894ee2012-02-13 16:42:22 +080067
68 private:
Brian Carlstrom641ce032013-01-31 15:21:37 -080069 LlvmCompilationUnit* cunit_;
Ian Rogers1212a022013-03-04 10:48:41 -080070 const CompilerDriver* const driver_;
Logan Chien88894ee2012-02-13 16:42:22 +080071
Ian Rogers4c1c2832013-03-04 18:30:13 -080072 ::llvm::Module* module_;
73 ::llvm::LLVMContext* context_;
Logan Chien88894ee2012-02-13 16:42:22 +080074 IRBuilder& irb_;
75
Ian Rogers89756f22013-03-04 16:40:02 -080076 const DexCompilationUnit* const dex_compilation_unit_;
Logan Chien88894ee2012-02-13 16:42:22 +080077
Ian Rogers4c1c2832013-03-04 18:30:13 -080078 ::llvm::Function* func_;
Logan Chien937105a2012-04-02 02:37:37 +080079 uint16_t elf_func_idx_;
Logan Chien88894ee2012-02-13 16:42:22 +080080};
81
82
Ian Rogers4c1c2832013-03-04 18:30:13 -080083} // namespace llvm
Ian Rogers89756f22013-03-04 16:40:02 -080084} // namespace art
Logan Chien88894ee2012-02-13 16:42:22 +080085
86
Brian Carlstromfc0e3212013-07-17 14:40:12 -070087#endif // ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_