blob: 208edfcd22cee8fdec3bd975f91c40336a36c6d3 [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
Logan Chien8b977d32012-02-21 19:14:55 +080050class CompilationUnit;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080051class IRBuilder;
52
53class CompilerLLVM {
54 public:
55 CompilerLLVM(Compiler* compiler, InstructionSet insn_set);
56
57 ~CompilerLLVM();
58
Logan Chien8b977d32012-02-21 19:14:55 +080059 void MaterializeEveryCompilationUnit();
Shih-wei Liaod1fec812012-02-13 09:51:10 -080060
61 Compiler* GetCompiler() const {
62 return compiler_;
63 }
64
65 InstructionSet GetInstructionSet() const {
66 return insn_set_;
67 }
68
Logan Chien8b977d32012-02-21 19:14:55 +080069 void SetElfFileName(std::string const& filename) {
70 elf_filename_ = filename;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080071 }
72
Logan Chien8b977d32012-02-21 19:14:55 +080073 void SetBitcodeFileName(std::string const& filename) {
74 bitcode_filename_ = filename;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080075 }
76
Logan Chien4dd96f52012-02-29 01:26:58 +080077 CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080078
Logan Chien88894ee2012-02-13 16:42:22 +080079 CompiledMethod* CompileNativeMethod(OatCompilationUnit* oat_compilation_unit);
80
Logan Chienf04364f2012-02-10 12:01:39 +080081 CompiledInvokeStub* CreateInvokeStub(bool is_static, char const *shorty);
82
Shih-wei Liaod1fec812012-02-13 09:51:10 -080083 private:
Logan Chien8b977d32012-02-21 19:14:55 +080084 void EnsureCompilationUnit();
85
86 void MaterializeCompilationUnit();
87
88 void MaterializeCompilationUnitSafePoint();
89
Shih-wei Liaod1fec812012-02-13 09:51:10 -080090 Compiler* compiler_;
91
92 Mutex compiler_lock_;
93
94 InstructionSet insn_set_;
95
Logan Chien8b977d32012-02-21 19:14:55 +080096 UniquePtr<CompilationUnit> cunit_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080097
Logan Chien8b977d32012-02-21 19:14:55 +080098 unsigned cunit_counter_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080099
Logan Chien8b977d32012-02-21 19:14:55 +0800100 std::string elf_filename_;
101
102 std::string bitcode_filename_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800103
104 DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
105};
106
107
108} // namespace compiler_llvm
109} // namespace art
110
111#endif // ART_SRC_COMPILER_LLVM_LLVM_COMPILER_H_