blob: 39223ef1256b4b2777f0485578cb0ab5eb37fb43 [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
Logan Chiend6e614b2012-03-01 20:57:44 +080017#ifndef ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_
18#define ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_
Shih-wei Liaod1fec812012-02-13 09:51:10 -080019
Logan Chiendf576142012-03-20 17:36:32 +080020#include "compiler.h"
Shih-wei Liaod1fec812012-02-13 09:51:10 -080021#include "dex_file.h"
Elliott Hughes0f3c5532012-03-30 14:51:51 -070022#include "instruction_set.h"
Shih-wei Liaod1fec812012-02-13 09:51:10 -080023#include "macros.h"
Logan Chienf7015fd2012-03-18 01:19:37 +080024#include "object.h"
Logan Chien971bf3f2012-05-01 15:47:55 +080025#include "procedure_linkage_table.h"
Shih-wei Liaod1fec812012-02-13 09:51:10 -080026
27#include <UniquePtr.h>
28
29#include <string>
Logan Chiendf576142012-03-20 17:36:32 +080030#include <utility>
31#include <vector>
Shih-wei Liaod1fec812012-02-13 09:51:10 -080032
33namespace art {
34 class ClassLoader;
Logan Chienf04364f2012-02-10 12:01:39 +080035 class CompiledInvokeStub;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080036 class CompiledMethod;
37 class Compiler;
Logan Chien4dd96f52012-02-29 01:26:58 +080038 class OatCompilationUnit;
Mathieu Chartier66f19252012-09-18 08:57:04 -070039 class AbstractMethod;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080040}
41
42
43namespace llvm {
44 class Function;
45 class LLVMContext;
46 class Module;
47 class PointerType;
48 class StructType;
49 class Type;
50}
51
52
53namespace art {
54namespace compiler_llvm {
55
Logan Chien8b977d32012-02-21 19:14:55 +080056class CompilationUnit;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080057class IRBuilder;
58
59class CompilerLLVM {
60 public:
61 CompilerLLVM(Compiler* compiler, InstructionSet insn_set);
62
63 ~CompilerLLVM();
64
Shih-wei Liaod1fec812012-02-13 09:51:10 -080065 Compiler* GetCompiler() const {
66 return compiler_;
67 }
68
69 InstructionSet GetInstructionSet() const {
70 return insn_set_;
71 }
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
Shih-wei Liaobb33f2f2012-08-23 13:20:00 -070077 CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit,
78 InvokeType invoke_type);
79
80#if defined(ART_USE_LLVM_COMPILER) && defined(ART_USE_QUICK_COMPILER)
81 CompiledMethod* CompileGBCMethod(OatCompilationUnit* oat_compilation_unit, std::string* func);
82#endif
Shih-wei Liaod1fec812012-02-13 09:51:10 -080083
Logan Chien88894ee2012-02-13 16:42:22 +080084 CompiledMethod* CompileNativeMethod(OatCompilationUnit* oat_compilation_unit);
85
Logan Chien7a2a23a2012-06-06 11:01:00 +080086 CompiledInvokeStub* CreateInvokeStub(bool is_static, const char *shorty);
87
88 CompiledInvokeStub* CreateProxyStub(const char *shorty);
Logan Chienf04364f2012-02-10 12:01:39 +080089
Logan Chien971bf3f2012-05-01 15:47:55 +080090 const ProcedureLinkageTable& GetProcedureLinkageTable() const {
91 return plt_;
92 }
93
Shih-wei Liaod1fec812012-02-13 09:51:10 -080094 private:
Logan Chien971bf3f2012-05-01 15:47:55 +080095 CompilationUnit* AllocateCompilationUnit();
Logan Chien8b977d32012-02-21 19:14:55 +080096
Shih-wei Liaod1fec812012-02-13 09:51:10 -080097 Compiler* compiler_;
98
Shih-wei Liaod1fec812012-02-13 09:51:10 -080099 InstructionSet insn_set_;
100
TDYa12755e5e6c2012-09-11 15:14:42 -0700101 Mutex num_cunits_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
102 size_t num_cunits_ GUARDED_BY(num_cunits_lock_);
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800103
Logan Chien8b977d32012-02-21 19:14:55 +0800104 std::string bitcode_filename_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800105
Logan Chien971bf3f2012-05-01 15:47:55 +0800106 ProcedureLinkageTable plt_;
Logan Chienf7015fd2012-03-18 01:19:37 +0800107
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800108 DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
109};
110
111
112} // namespace compiler_llvm
113} // namespace art
114
Logan Chiend6e614b2012-03-01 20:57:44 +0800115#endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_