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" |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 21 | #include "dex_instruction.h" |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 22 | |
Dragos Sbirlea | 7467ee0 | 2013-06-21 09:20:34 -0700 | [diff] [blame] | 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 28 | namespace llvm { |
| 29 | class Module; |
| 30 | class LLVMContext; |
| 31 | } |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 32 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 33 | namespace art { |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 34 | namespace llvm { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 35 | class IntrinsicHelper; |
| 36 | class IRBuilder; |
| 37 | } |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 38 | |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 39 | /* |
| 40 | * Assembly is an iterative process, and usually terminates within |
| 41 | * two or three passes. This should be high enough to handle bizarre |
| 42 | * cases, but detect an infinite loop bug. |
| 43 | */ |
| 44 | #define MAX_ASSEMBLER_RETRIES 50 |
| 45 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 46 | // Suppress optimization if corresponding bit set. |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 47 | enum opt_control_vector { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 48 | kLoadStoreElimination = 0, |
| 49 | kLoadHoisting, |
| 50 | kSuppressLoads, |
| 51 | kNullCheckElimination, |
| 52 | kPromoteRegs, |
| 53 | kTrackLiveTemps, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 54 | kSafeOptimizations, |
| 55 | kBBOpt, |
| 56 | kMatch, |
| 57 | kPromoteCompilerTemps, |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 58 | kBranchFusing, |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 61 | // Force code generation paths for testing. |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 62 | enum debugControlVector { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 63 | kDebugVerbose, |
| 64 | kDebugDumpCFG, |
| 65 | kDebugSlowFieldPath, |
| 66 | kDebugSlowInvokePath, |
| 67 | kDebugSlowStringPath, |
| 68 | kDebugSlowTypePath, |
| 69 | kDebugSlowestFieldPath, |
| 70 | kDebugSlowestStringPath, |
| 71 | kDebugExerciseResolveMethod, |
| 72 | kDebugVerifyDataflow, |
| 73 | kDebugShowMemoryUsage, |
| 74 | kDebugShowNops, |
| 75 | kDebugCountOpcodes, |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 76 | kDebugDumpCheckStats, |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 77 | kDebugDumpBitcodeFile, |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 78 | kDebugVerifyBitcode, |
buzbee | a5abf70 | 2013-04-12 14:39:29 -0700 | [diff] [blame] | 79 | kDebugShowSummaryMemoryUsage, |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 82 | class LLVMInfo { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 83 | public: |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 84 | LLVMInfo(); |
| 85 | ~LLVMInfo(); |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 86 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 87 | ::llvm::LLVMContext* GetLLVMContext() { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 88 | return llvm_context_.get(); |
| 89 | } |
| 90 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 91 | ::llvm::Module* GetLLVMModule() { |
TDYa127 | 55e5e6c | 2012-09-11 15:14:42 -0700 | [diff] [blame] | 92 | return llvm_module_; |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 95 | art::llvm::IntrinsicHelper* GetIntrinsicHelper() { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 96 | return intrinsic_helper_.get(); |
| 97 | } |
| 98 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 99 | art::llvm::IRBuilder* GetIRBuilder() { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 100 | return ir_builder_.get(); |
| 101 | } |
| 102 | |
| 103 | private: |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 104 | UniquePtr< ::llvm::LLVMContext> llvm_context_; |
| 105 | ::llvm::Module* llvm_module_; // Managed by context_. |
| 106 | UniquePtr<art::llvm::IntrinsicHelper> intrinsic_helper_; |
| 107 | UniquePtr<art::llvm::IRBuilder> ir_builder_; |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 108 | }; |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 109 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 110 | struct CompilationUnit; |
| 111 | struct BasicBlock; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 112 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 113 | } // namespace art |
| 114 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 115 | extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 116 | const art::DexFile::CodeItem* code_item, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 117 | uint32_t access_flags, |
| 118 | art::InvokeType invoke_type, |
buzbee | 26f10ee | 2012-12-21 11:16:29 -0800 | [diff] [blame] | 119 | uint32_t class_dex_idx, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 120 | uint32_t method_idx, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 121 | jobject class_loader, |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 122 | const art::DexFile& dex_file); |
| 123 | |
Dragos Sbirlea | 7467ee0 | 2013-06-21 09:20:34 -0700 | [diff] [blame] | 124 | |
| 125 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 126 | #endif // ART_COMPILER_DEX_FRONTEND_H_ |