blob: cbee115feec3b94cdd8de3f695a24a6be826e9d2 [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"
Ian Rogers1212a022013-03-04 10:48:41 -080021#include "compiler/driver/compiler_driver.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"
Shih-wei Liaod1fec812012-02-13 09:51:10 -080025
26#include <UniquePtr.h>
27
28#include <string>
Logan Chiendf576142012-03-20 17:36:32 +080029#include <utility>
30#include <vector>
Shih-wei Liaod1fec812012-02-13 09:51:10 -080031
32namespace art {
Logan Chienf04364f2012-02-10 12:01:39 +080033 class CompiledInvokeStub;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080034 class CompiledMethod;
Ian Rogers1212a022013-03-04 10:48:41 -080035 class CompilerDriver;
Ian Rogers89756f22013-03-04 16:40:02 -080036 class DexCompilationUnit;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037 namespace mirror {
38 class AbstractMethod;
39 class ClassLoader;
40 } // namespace mirror
41} // namespace art
Shih-wei Liaod1fec812012-02-13 09:51:10 -080042
43
44namespace llvm {
45 class Function;
46 class LLVMContext;
47 class Module;
48 class PointerType;
49 class StructType;
50 class Type;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080051} // namespace llvm
Shih-wei Liaod1fec812012-02-13 09:51:10 -080052
53
54namespace art {
Ian Rogers4c1c2832013-03-04 18:30:13 -080055namespace llvm {
Shih-wei Liaod1fec812012-02-13 09:51:10 -080056
Brian Carlstrom641ce032013-01-31 15:21:37 -080057class LlvmCompilationUnit;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080058class IRBuilder;
59
60class CompilerLLVM {
61 public:
Ian Rogers1212a022013-03-04 10:48:41 -080062 CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080063
64 ~CompilerLLVM();
65
Ian Rogers1212a022013-03-04 10:48:41 -080066 CompilerDriver* GetCompiler() const {
67 return compiler_driver_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080068 }
69
70 InstructionSet GetInstructionSet() const {
71 return insn_set_;
72 }
73
Logan Chien8b977d32012-02-21 19:14:55 +080074 void SetBitcodeFileName(std::string const& filename) {
75 bitcode_filename_ = filename;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080076 }
77
Ian Rogers89756f22013-03-04 16:40:02 -080078 CompiledMethod* CompileDexMethod(DexCompilationUnit* dex_compilation_unit,
Shih-wei Liaobb33f2f2012-08-23 13:20:00 -070079 InvokeType invoke_type);
80
Ian Rogers89756f22013-03-04 16:40:02 -080081 CompiledMethod* CompileGBCMethod(DexCompilationUnit* dex_compilation_unit, std::string* func);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080082
Ian Rogers89756f22013-03-04 16:40:02 -080083 CompiledMethod* CompileNativeMethod(DexCompilationUnit* dex_compilation_unit);
Logan Chien88894ee2012-02-13 16:42:22 +080084
Logan Chien7a2a23a2012-06-06 11:01:00 +080085 CompiledInvokeStub* CreateInvokeStub(bool is_static, const char *shorty);
86
87 CompiledInvokeStub* CreateProxyStub(const char *shorty);
Logan Chienf04364f2012-02-10 12:01:39 +080088
Shih-wei Liaod1fec812012-02-13 09:51:10 -080089 private:
Brian Carlstrom641ce032013-01-31 15:21:37 -080090 LlvmCompilationUnit* AllocateCompilationUnit();
Logan Chien8b977d32012-02-21 19:14:55 +080091
Ian Rogers1212a022013-03-04 10:48:41 -080092 CompilerDriver* compiler_driver_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080093
Shih-wei Liaod1fec812012-02-13 09:51:10 -080094 InstructionSet insn_set_;
95
Brian Carlstrom265091e2013-01-30 14:08:26 -080096 Mutex next_cunit_id_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
97 size_t next_cunit_id_ GUARDED_BY(next_cunit_id_lock_);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080098
Logan Chien8b977d32012-02-21 19:14:55 +080099 std::string bitcode_filename_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800100
101 DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
102};
103
104
Ian Rogers4c1c2832013-03-04 18:30:13 -0800105} // namespace llvm
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800106} // namespace art
107
Logan Chiend6e614b2012-03-01 20:57:44 +0800108#endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_