jni_compiler.h revision 7940e44f4517de5e2634a7e07d58d0fb26160513
1/*
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_JNI_PORTABLE_JNI_COMPILER_H_
18#define ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
19
20#include <stdint.h>
21
22#include <string>
23
24namespace art {
25  class ClassLinker;
26  class CompiledMethod;
27  class CompilerDriver;
28  class DexFile;
29  class DexCompilationUnit;
30  namespace mirror {
31    class AbstractMethod;
32    class ClassLoader;
33    class DexCache;
34  }  // namespace mirror
35}  // namespace art
36
37namespace llvm {
38  class AllocaInst;
39  class Function;
40  class FunctionType;
41  class BasicBlock;
42  class LLVMContext;
43  class Module;
44  class Type;
45  class Value;
46}  // namespace llvm
47
48namespace art {
49namespace llvm {
50
51class LlvmCompilationUnit;
52class IRBuilder;
53
54class JniCompiler {
55 public:
56  JniCompiler(LlvmCompilationUnit* cunit,
57              const CompilerDriver& driver,
58              const DexCompilationUnit* dex_compilation_unit);
59
60  CompiledMethod* Compile();
61
62 private:
63  void CreateFunction(const std::string& symbol);
64
65  ::llvm::FunctionType* GetFunctionType(uint32_t method_idx,
66                                        bool is_static, bool is_target_function);
67
68 private:
69  LlvmCompilationUnit* cunit_;
70  const CompilerDriver* const driver_;
71
72  ::llvm::Module* module_;
73  ::llvm::LLVMContext* context_;
74  IRBuilder& irb_;
75
76  const DexCompilationUnit* const dex_compilation_unit_;
77
78  ::llvm::Function* func_;
79  uint16_t elf_func_idx_;
80};
81
82
83}  // namespace llvm
84}  // namespace art
85
86
87#endif  // ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
88