blob: 77841d8564fe2104d18654b965e4fdc96aca5876 [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
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
32namespace art {
33 class CompiledMethod;
34 class CompilerDriver;
35 class DexCompilationUnit;
36 namespace mirror {
37 class AbstractMethod;
38 class ClassLoader;
39 } // namespace mirror
40} // namespace art
41
42
43namespace llvm {
44 class Function;
45 class LLVMContext;
46 class Module;
47 class PointerType;
48 class StructType;
49 class Type;
50} // namespace llvm
51
52
53namespace art {
54namespace llvm {
55
56class LlvmCompilationUnit;
57class IRBuilder;
58
59class 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
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700103#endif // ART_COMPILER_LLVM_COMPILER_LLVM_H_