Home | History | Annotate | Download | only in portable
      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_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
     18 #define ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
     19 
     20 #include <stdint.h>
     21 
     22 #include <string>
     23 
     24 namespace art {
     25   class ClassLinker;
     26   class CompiledMethod;
     27   class CompilerDriver;
     28   class DexFile;
     29   class DexCompilationUnit;
     30   namespace mirror {
     31     class ArtMethod;
     32     class ClassLoader;
     33     class DexCache;
     34   }  // namespace mirror
     35 }  // namespace art
     36 
     37 namespace 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 
     48 namespace art {
     49 namespace llvm {
     50 
     51 class LlvmCompilationUnit;
     52 class IRBuilder;
     53 
     54 class JniCompiler {
     55  public:
     56   JniCompiler(LlvmCompilationUnit* cunit,
     57               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   CompilerDriver* 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_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
     88