blob: 0cd08a7a3998f559a0cd7dc4a9493431d2d2f773 [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
Brian Carlstrom641ce032013-01-31 15:21:37 -080058class LlvmCompilationUnit;
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
Shih-wei Liaobb33f2f2012-08-23 13:20:00 -070082 CompiledMethod* CompileGBCMethod(OatCompilationUnit* oat_compilation_unit, std::string* func);
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:
Brian Carlstrom641ce032013-01-31 15:21:37 -080095 LlvmCompilationUnit* 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_