Home | History | Annotate | Download | only in llvm
      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_LLVM_COMPILER_LLVM_H_
     18 #define ART_COMPILER_LLVM_COMPILER_LLVM_H_
     19 
     20 #include "base/macros.h"
     21 #include "dex_file.h"
     22 #include "driver/compiler_driver.h"
     23 #include "instruction_set.h"
     24 #include "mirror/object.h"
     25 
     26 #include <UniquePtr.h>
     27 
     28 #include <string>
     29 #include <utility>
     30 #include <vector>
     31 
     32 namespace art {
     33   class CompiledMethod;
     34   class CompilerDriver;
     35   class DexCompilationUnit;
     36   namespace mirror {
     37     class ArtMethod;
     38     class ClassLoader;
     39   }  // namespace mirror
     40 }  // namespace art
     41 
     42 
     43 namespace llvm {
     44   class Function;
     45   class LLVMContext;
     46   class Module;
     47   class PointerType;
     48   class StructType;
     49   class Type;
     50 }  // namespace llvm
     51 
     52 
     53 namespace art {
     54 namespace llvm {
     55 
     56 class LlvmCompilationUnit;
     57 class IRBuilder;
     58 
     59 class CompilerLLVM {
     60  public:
     61   CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set);
     62 
     63   ~CompilerLLVM();
     64 
     65   CompilerDriver* GetCompiler() const {
     66     return compiler_driver_;
     67   }
     68 
     69   InstructionSet GetInstructionSet() const {
     70     return insn_set_;
     71   }
     72 
     73   void SetBitcodeFileName(std::string const& filename) {
     74     bitcode_filename_ = filename;
     75   }
     76 
     77   CompiledMethod* CompileDexMethod(DexCompilationUnit* dex_compilation_unit,
     78                                    InvokeType invoke_type);
     79 
     80   CompiledMethod* CompileGBCMethod(DexCompilationUnit* dex_compilation_unit, std::string* func);
     81 
     82   CompiledMethod* CompileNativeMethod(DexCompilationUnit* dex_compilation_unit);
     83 
     84  private:
     85   LlvmCompilationUnit* AllocateCompilationUnit();
     86 
     87   CompilerDriver* const compiler_driver_;
     88 
     89   const InstructionSet insn_set_;
     90 
     91   Mutex next_cunit_id_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
     92   size_t next_cunit_id_ GUARDED_BY(next_cunit_id_lock_);
     93 
     94   std::string bitcode_filename_;
     95 
     96   DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
     97 };
     98 
     99 
    100 }  // namespace llvm
    101 }  // namespace art
    102 
    103 #endif  // ART_COMPILER_LLVM_COMPILER_LLVM_H_
    104