blob: 13dc063d723bb2124060eac946117e8233d8a20f [file] [log] [blame]
Shih-wei Liaod1fec812012-02-13 09:51:10 -08001/*
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_SRC_COMPILER_LLVM_LLVM_COMPILER_H_
18#define ART_SRC_COMPILER_LLVM_LLVM_COMPILER_H_
19
20#include "constants.h"
21#include "dex_file.h"
22#include "macros.h"
23
24#include <UniquePtr.h>
25
26#include <string>
27
28namespace art {
29 class ClassLoader;
Logan Chienf04364f2012-02-10 12:01:39 +080030 class CompiledInvokeStub;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080031 class CompiledMethod;
32 class Compiler;
Logan Chien4dd96f52012-02-29 01:26:58 +080033 class OatCompilationUnit;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080034}
35
36
37namespace llvm {
38 class Function;
39 class LLVMContext;
40 class Module;
41 class PointerType;
42 class StructType;
43 class Type;
44}
45
46
47namespace art {
48namespace compiler_llvm {
49
50class IRBuilder;
51
52class CompilerLLVM {
53 public:
54 CompilerLLVM(Compiler* compiler, InstructionSet insn_set);
55
56 ~CompilerLLVM();
57
58 void MaterializeLLVMModule();
59
60 void WriteBitcodeToFile(std::string const &filename);
61
62 Compiler* GetCompiler() const {
63 return compiler_;
64 }
65
66 InstructionSet GetInstructionSet() const {
67 return insn_set_;
68 }
69
70 llvm::Module* GetModule() const {
71 return module_;
72 }
73
74 llvm::LLVMContext* GetLLVMContext() const {
75 return context_.get();
76 }
77
78 IRBuilder* GetIRBuilder() const {
79 return irb_.get();
80 }
81
Logan Chien4dd96f52012-02-29 01:26:58 +080082 CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080083
Logan Chienf04364f2012-02-10 12:01:39 +080084 CompiledInvokeStub* CreateInvokeStub(bool is_static, char const *shorty);
85
Shih-wei Liaod1fec812012-02-13 09:51:10 -080086 private:
87 Compiler* compiler_;
88
89 Mutex compiler_lock_;
90
91 InstructionSet insn_set_;
92
93 UniquePtr<llvm::LLVMContext> context_;
94
95 UniquePtr<IRBuilder> irb_;
96
97 llvm::Module* module_;
98
99 DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
100};
101
102
103} // namespace compiler_llvm
104} // namespace art
105
106#endif // ART_SRC_COMPILER_LLVM_LLVM_COMPILER_H_