blob: e7717a3fd43d36ebef8e146c6a8e8ae7f5a60d96 [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 {
Shih-wei Liaod1fec812012-02-13 09:51:10 -080033 class CompiledMethod;
Ian Rogers1212a022013-03-04 10:48:41 -080034 class CompilerDriver;
Ian Rogers89756f22013-03-04 16:40:02 -080035 class DexCompilationUnit;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080036 namespace mirror {
37 class AbstractMethod;
38 class ClassLoader;
39 } // namespace mirror
40} // namespace art
Shih-wei Liaod1fec812012-02-13 09:51:10 -080041
42
43namespace llvm {
44 class Function;
45 class LLVMContext;
46 class Module;
47 class PointerType;
48 class StructType;
49 class Type;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080050} // namespace llvm
Shih-wei Liaod1fec812012-02-13 09:51:10 -080051
52
53namespace art {
Ian Rogers4c1c2832013-03-04 18:30:13 -080054namespace llvm {
Shih-wei Liaod1fec812012-02-13 09:51:10 -080055
Brian Carlstrom641ce032013-01-31 15:21:37 -080056class LlvmCompilationUnit;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080057class IRBuilder;
58
59class CompilerLLVM {
60 public:
Ian Rogers1212a022013-03-04 10:48:41 -080061 CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080062
63 ~CompilerLLVM();
64
Ian Rogers1212a022013-03-04 10:48:41 -080065 CompilerDriver* GetCompiler() const {
66 return compiler_driver_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080067 }
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
Ian Rogers89756f22013-03-04 16:40:02 -080077 CompiledMethod* CompileDexMethod(DexCompilationUnit* dex_compilation_unit,
Shih-wei Liaobb33f2f2012-08-23 13:20:00 -070078 InvokeType invoke_type);
79
Ian Rogers89756f22013-03-04 16:40:02 -080080 CompiledMethod* CompileGBCMethod(DexCompilationUnit* dex_compilation_unit, std::string* func);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080081
Ian Rogers89756f22013-03-04 16:40:02 -080082 CompiledMethod* CompileNativeMethod(DexCompilationUnit* dex_compilation_unit);
Logan Chien88894ee2012-02-13 16:42:22 +080083
Shih-wei Liaod1fec812012-02-13 09:51:10 -080084 private:
Brian Carlstrom641ce032013-01-31 15:21:37 -080085 LlvmCompilationUnit* AllocateCompilationUnit();
Logan Chien8b977d32012-02-21 19:14:55 +080086
Ian Rogers0d94eb62013-03-06 15:20:50 -080087 CompilerDriver* const compiler_driver_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080088
Ian Rogers0d94eb62013-03-06 15:20:50 -080089 const InstructionSet insn_set_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080090
Brian Carlstrom265091e2013-01-30 14:08:26 -080091 Mutex next_cunit_id_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
92 size_t next_cunit_id_ GUARDED_BY(next_cunit_id_lock_);
Shih-wei Liaod1fec812012-02-13 09:51:10 -080093
Logan Chien8b977d32012-02-21 19:14:55 +080094 std::string bitcode_filename_;
Shih-wei Liaod1fec812012-02-13 09:51:10 -080095
96 DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
97};
98
99
Ian Rogers4c1c2832013-03-04 18:30:13 -0800100} // namespace llvm
Shih-wei Liaod1fec812012-02-13 09:51:10 -0800101} // namespace art
102
Logan Chiend6e614b2012-03-01 20:57:44 +0800103#endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_