Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_LLVM_COMPILER_LLVM_H_ |
| 18 | #define ART_COMPILER_LLVM_COMPILER_LLVM_H_ |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 20 | #include <memory> |
| 21 | #include <string> |
| 22 | #include <utility> |
| 23 | #include <vector> |
| 24 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 25 | #include "base/macros.h" |
| 26 | #include "dex_file.h" |
| 27 | #include "driver/compiler_driver.h" |
| 28 | #include "instruction_set.h" |
| 29 | #include "mirror/object.h" |
| 30 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 31 | namespace art { |
| 32 | class CompiledMethod; |
| 33 | class CompilerDriver; |
| 34 | class DexCompilationUnit; |
| 35 | namespace mirror { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 36 | class ArtMethod; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 37 | class ClassLoader; |
| 38 | } // namespace mirror |
| 39 | } // namespace art |
| 40 | |
| 41 | |
| 42 | namespace llvm { |
| 43 | class Function; |
| 44 | class LLVMContext; |
| 45 | class Module; |
| 46 | class PointerType; |
| 47 | class StructType; |
| 48 | class Type; |
| 49 | } // namespace llvm |
| 50 | |
| 51 | |
| 52 | namespace art { |
| 53 | namespace llvm { |
| 54 | |
| 55 | class LlvmCompilationUnit; |
| 56 | class IRBuilder; |
| 57 | |
| 58 | class CompilerLLVM { |
| 59 | public: |
| 60 | CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set); |
| 61 | |
| 62 | ~CompilerLLVM(); |
| 63 | |
| 64 | CompilerDriver* GetCompiler() const { |
| 65 | return compiler_driver_; |
| 66 | } |
| 67 | |
| 68 | InstructionSet GetInstructionSet() const { |
| 69 | return insn_set_; |
| 70 | } |
| 71 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 72 | void SetBitcodeFileName(const std::string& filename) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 73 | bitcode_filename_ = filename; |
| 74 | } |
| 75 | |
| 76 | CompiledMethod* CompileDexMethod(DexCompilationUnit* dex_compilation_unit, |
| 77 | InvokeType invoke_type); |
| 78 | |
| 79 | CompiledMethod* CompileGBCMethod(DexCompilationUnit* dex_compilation_unit, std::string* func); |
| 80 | |
| 81 | CompiledMethod* CompileNativeMethod(DexCompilationUnit* dex_compilation_unit); |
| 82 | |
| 83 | private: |
| 84 | LlvmCompilationUnit* AllocateCompilationUnit(); |
| 85 | |
| 86 | CompilerDriver* const compiler_driver_; |
| 87 | |
| 88 | const InstructionSet insn_set_; |
| 89 | |
| 90 | Mutex next_cunit_id_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
| 91 | size_t next_cunit_id_ GUARDED_BY(next_cunit_id_lock_); |
| 92 | |
| 93 | std::string bitcode_filename_; |
| 94 | |
| 95 | DISALLOW_COPY_AND_ASSIGN(CompilerLLVM); |
| 96 | }; |
| 97 | |
| 98 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 99 | } // namespace llvm |
| 100 | } // namespace art |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 101 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 102 | #endif // ART_COMPILER_LLVM_COMPILER_LLVM_H_ |