buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_DEX_FRONTEND_H_ |
| 18 | #define ART_COMPILER_DEX_FRONTEND_H_ |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 20 | #include "dex_file.h" |
Vladimir Marko | 05bded2 | 2014-01-21 11:38:17 +0000 | [diff] [blame] | 21 | #include "invoke_type.h" |
Dragos Sbirlea | 7467ee0 | 2013-06-21 09:20:34 -0700 | [diff] [blame] | 22 | |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 23 | namespace llvm { |
| 24 | class Module; |
| 25 | class LLVMContext; |
| 26 | } |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 27 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 28 | namespace art { |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 29 | namespace llvm { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 30 | class IntrinsicHelper; |
| 31 | class IRBuilder; |
| 32 | } |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 33 | |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 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 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 41 | // Suppress optimization if corresponding bit set. |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 42 | enum opt_control_vector { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 43 | kLoadStoreElimination = 0, |
| 44 | kLoadHoisting, |
| 45 | kSuppressLoads, |
| 46 | kNullCheckElimination, |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 47 | kClassInitCheckElimination, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 48 | kPromoteRegs, |
| 49 | kTrackLiveTemps, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 50 | kSafeOptimizations, |
| 51 | kBBOpt, |
| 52 | kMatch, |
| 53 | kPromoteCompilerTemps, |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 54 | kBranchFusing, |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 55 | kSuppressExceptionEdges, |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 56 | kSuppressMethodInlining, |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 59 | // Force code generation paths for testing. |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 60 | enum debugControlVector { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 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, |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 74 | kDebugDumpCheckStats, |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 75 | kDebugDumpBitcodeFile, |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 76 | kDebugVerifyBitcode, |
buzbee | a5abf70 | 2013-04-12 14:39:29 -0700 | [diff] [blame] | 77 | kDebugShowSummaryMemoryUsage, |
buzbee | ee17e0a | 2013-07-31 10:47:37 -0700 | [diff] [blame] | 78 | kDebugShowFilterStats, |
buzbee | b01bf15 | 2014-05-13 15:59:07 -0700 | [diff] [blame] | 79 | kDebugTimings, |
| 80 | kDebugCodegenDump |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 83 | class LLVMInfo { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 84 | public: |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 85 | LLVMInfo(); |
| 86 | ~LLVMInfo(); |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 87 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 88 | ::llvm::LLVMContext* GetLLVMContext() { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 89 | return llvm_context_.get(); |
| 90 | } |
| 91 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 92 | ::llvm::Module* GetLLVMModule() { |
TDYa127 | 55e5e6c | 2012-09-11 15:14:42 -0700 | [diff] [blame] | 93 | return llvm_module_; |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 96 | art::llvm::IntrinsicHelper* GetIntrinsicHelper() { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 97 | return intrinsic_helper_.get(); |
| 98 | } |
| 99 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 100 | art::llvm::IRBuilder* GetIRBuilder() { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 101 | return ir_builder_.get(); |
| 102 | } |
| 103 | |
| 104 | private: |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 105 | std::unique_ptr< ::llvm::LLVMContext> llvm_context_; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 106 | ::llvm::Module* llvm_module_; // Managed by context_. |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 107 | std::unique_ptr<art::llvm::IntrinsicHelper> intrinsic_helper_; |
| 108 | std::unique_ptr<art::llvm::IRBuilder> ir_builder_; |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 109 | }; |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 110 | |
Ian Rogers | b48b9eb | 2014-02-28 16:20:21 -0800 | [diff] [blame] | 111 | class CompiledMethod; |
Vladimir Marko | 05bded2 | 2014-01-21 11:38:17 +0000 | [diff] [blame] | 112 | class CompilerDriver; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 113 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 114 | } // namespace art |
| 115 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 116 | extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 117 | const art::DexFile::CodeItem* code_item, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 118 | uint32_t access_flags, |
| 119 | art::InvokeType invoke_type, |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 120 | uint16_t class_def_idx, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 121 | uint32_t method_idx, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 122 | jobject class_loader, |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 123 | const art::DexFile& dex_file); |
| 124 | |
Dragos Sbirlea | 7467ee0 | 2013-06-21 09:20:34 -0700 | [diff] [blame] | 125 | |
| 126 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 127 | #endif // ART_COMPILER_DEX_FRONTEND_H_ |