blob: cc74deb7be8f5669b4ffdf92351777ad18a8c09e [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
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_LLVM_COMPILER_LLVM_H_
18#define ART_COMPILER_LLVM_COMPILER_LLVM_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
Ian Rogers700a4022014-05-19 16:49:03 -070020#include <memory>
21#include <string>
22#include <utility>
23#include <vector>
24
Brian Carlstrom7940e442013-07-12 13:46:57 -070025#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 Carlstrom7940e442013-07-12 13:46:57 -070031namespace art {
32 class CompiledMethod;
33 class CompilerDriver;
34 class DexCompilationUnit;
35 namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070036 class ArtMethod;
Brian Carlstrom7940e442013-07-12 13:46:57 -070037 class ClassLoader;
38 } // namespace mirror
39} // namespace art
40
41
42namespace llvm {
43 class Function;
44 class LLVMContext;
45 class Module;
46 class PointerType;
47 class StructType;
48 class Type;
49} // namespace llvm
50
51
52namespace art {
53namespace llvm {
54
55class LlvmCompilationUnit;
56class IRBuilder;
57
58class 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 Rogers3d504072014-03-01 09:16:49 -080072 void SetBitcodeFileName(const std::string& filename) {
Brian Carlstrom7940e442013-07-12 13:46:57 -070073 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 Carlstrom7934ac22013-07-26 10:54:15 -070099} // namespace llvm
100} // namespace art
Brian Carlstrom7940e442013-07-12 13:46:57 -0700101
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700102#endif // ART_COMPILER_LLVM_COMPILER_LLVM_H_