frontend.h revision 700a402244a1a423da4f3ba8032459f4b65fa18f
1/*
2 * Copyright (C) 2011 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
17#ifndef ART_COMPILER_DEX_FRONTEND_H_
18#define ART_COMPILER_DEX_FRONTEND_H_
19
20#include "dex_file.h"
21#include "invoke_type.h"
22
23namespace llvm {
24  class Module;
25  class LLVMContext;
26}
27
28namespace art {
29namespace llvm {
30  class IntrinsicHelper;
31  class IRBuilder;
32}
33
34/*
35 * Assembly is an iterative process, and usually terminates within
36 * two or three passes.  This should be high enough to handle bizarre
37 * cases, but detect an infinite loop bug.
38 */
39#define MAX_ASSEMBLER_RETRIES 50
40
41// Suppress optimization if corresponding bit set.
42enum opt_control_vector {
43  kLoadStoreElimination = 0,
44  kLoadHoisting,
45  kSuppressLoads,
46  kNullCheckElimination,
47  kClassInitCheckElimination,
48  kPromoteRegs,
49  kTrackLiveTemps,
50  kSafeOptimizations,
51  kBBOpt,
52  kMatch,
53  kPromoteCompilerTemps,
54  kBranchFusing,
55  kSuppressExceptionEdges,
56  kSuppressMethodInlining,
57};
58
59// Force code generation paths for testing.
60enum debugControlVector {
61  kDebugVerbose,
62  kDebugDumpCFG,
63  kDebugSlowFieldPath,
64  kDebugSlowInvokePath,
65  kDebugSlowStringPath,
66  kDebugSlowTypePath,
67  kDebugSlowestFieldPath,
68  kDebugSlowestStringPath,
69  kDebugExerciseResolveMethod,
70  kDebugVerifyDataflow,
71  kDebugShowMemoryUsage,
72  kDebugShowNops,
73  kDebugCountOpcodes,
74  kDebugDumpCheckStats,
75  kDebugDumpBitcodeFile,
76  kDebugVerifyBitcode,
77  kDebugShowSummaryMemoryUsage,
78  kDebugShowFilterStats,
79  kDebugTimings
80};
81
82class LLVMInfo {
83  public:
84    LLVMInfo();
85    ~LLVMInfo();
86
87    ::llvm::LLVMContext* GetLLVMContext() {
88      return llvm_context_.get();
89    }
90
91    ::llvm::Module* GetLLVMModule() {
92      return llvm_module_;
93    }
94
95    art::llvm::IntrinsicHelper* GetIntrinsicHelper() {
96      return intrinsic_helper_.get();
97    }
98
99    art::llvm::IRBuilder* GetIRBuilder() {
100      return ir_builder_.get();
101    }
102
103  private:
104    std::unique_ptr< ::llvm::LLVMContext> llvm_context_;
105    ::llvm::Module* llvm_module_;  // Managed by context_.
106    std::unique_ptr<art::llvm::IntrinsicHelper> intrinsic_helper_;
107    std::unique_ptr<art::llvm::IRBuilder> ir_builder_;
108};
109
110class CompiledMethod;
111class CompilerDriver;
112
113}  // namespace art
114
115extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver,
116                                                 const art::DexFile::CodeItem* code_item,
117                                                 uint32_t access_flags,
118                                                 art::InvokeType invoke_type,
119                                                 uint16_t class_def_idx,
120                                                 uint32_t method_idx,
121                                                 jobject class_loader,
122                                                 const art::DexFile& dex_file);
123
124
125
126#endif  // ART_COMPILER_DEX_FRONTEND_H_
127