blob: bb14c4916387f761406bbe7034f3b59dab24824a [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
Elliott Hughes76160052012-12-12 16:31:20 -080020#include "base/macros.h"
Logan Chiendf576142012-03-20 17:36:32 +080021#include "compiler.h"
Shih-wei Liaod1fec812012-02-13 09:51:10 -080022#include "dex_file.h"
Elliott Hughes0f3c5532012-03-30 14:51:51 -070023#include "instruction_set.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080024#include "mirror/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 {
Logan Chienf04364f2012-02-10 12:01:39 +080034 class CompiledInvokeStub;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080035 class CompiledMethod;
36 class Compiler;
Logan Chien4dd96f52012-02-29 01:26:58 +080037 class OatCompilationUnit;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080038 namespace mirror {
39 class AbstractMethod;
40 class ClassLoader;
41 } // namespace mirror
42} // namespace art
Shih-wei Liaod1fec812012-02-13 09:51:10 -080043
44
45namespace llvm {
46 class Function;
47 class LLVMContext;
48 class Module;
49 class PointerType;
50 class StructType;
51 class Type;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080052} // namespace llvm
Shih-wei Liaod1fec812012-02-13 09:51:10 -080053
54
55namespace art {
56namespace compiler_llvm {
57
Logan Chien8b977d32012-02-21 19:14:55 +080058class CompilationUnit;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080059class IRBuilder;
60
61class CompilerLLVM {
62 public:
63 CompilerLLVM(Compiler* compiler, InstructionSet insn_set);
64
65 ~CompilerLLVM();
66
Shih-wei Liaod1fec812012-02-13 09:51:10 -080067 Compiler* GetCompiler() const {
68 return compiler_;
69 }
70
71 InstructionSet GetInstructionSet() const {
72 return insn_set_;
73 }
74
Logan Chien8b977d32012-02-21 19:14:55 +080075 void SetBitcodeFileName(std::string const& filename) {
76 bitcode_filename_ = filename;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080077 }
78
Shih-wei Liaobb33f2f2012-08-23 13:20:00 -070079 CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit,
80 InvokeType invoke_type);
81
buzbeec531cef2012-10-18 07:09:20 -070082#if defined(ART_USE_PORTABLE_COMPILER)
Shih-wei Liaobb33f2f2012-08-23 13:20:00 -070083 CompiledMethod* CompileGBCMethod(OatCompilationUnit* oat_compilation_unit, std::string* func);
84#endif
Shih-wei Liaod1fec812012-02-13 09:51:10 -080085
Logan Chien88894ee2012-02-13 16:42:22 +080086 CompiledMethod* CompileNativeMethod(OatCompilationUnit* oat_compilation_unit);
87
Logan Chien7a2a23a2012-06-06 11:01:00 +080088 CompiledInvokeStub* CreateInvokeStub(bool is_static, const char *shorty);
89
90 CompiledInvokeStub* CreateProxyStub(const char *shorty);
Logan Chienf04364f2012-02-10 12:01:39 +080091
Logan Chien971bf3f2012-05-01 15:47:55 +080092 const ProcedureLinkageTable& GetProcedureLinkageTable() const {
93 return plt_;
94 }
95
Shih-wei Liaod1fec812012-02-13 09:51:10 -080096 private:
Logan Chien971bf3f2012-05-01 15:47:55 +080097 CompilationUnit* AllocateCompilationUnit();
Logan Chien8b977d32012-02-21 19:14:55 +080098
Shih-wei Liaod1fec812012-02-13 09:51:10 -080099 Compiler* compiler_;
100
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800101 InstructionSet insn_set_;
102
TDYa12755e5e6c2012-09-11 15:14:42 -0700103 Mutex num_cunits_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
104 size_t num_cunits_ GUARDED_BY(num_cunits_lock_);
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800105
Logan Chien8b977d32012-02-21 19:14:55 +0800106 std::string bitcode_filename_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800107
Logan Chien971bf3f2012-05-01 15:47:55 +0800108 ProcedureLinkageTable plt_;
Logan Chienf7015fd2012-03-18 01:19:37 +0800109
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800110 DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
111};
112
113
114} // namespace compiler_llvm
115} // namespace art
116
Logan Chiend6e614b2012-03-01 20:57:44 +0800117#endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_