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 | |
| 17 | #ifndef ART_SRC_COMPILER_COMPILER_IR_H_ |
| 18 | #define ART_SRC_COMPILER_COMPILER_IR_H_ |
| 19 | |
| 20 | #include "codegen/Optimizer.h" |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 21 | #include "CompilerUtility.h" |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 22 | #include <vector> |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 23 | #include "oat_compilation_unit.h" |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 24 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 25 | namespace art { |
| 26 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 27 | #define SLOW_FIELD_PATH (cUnit->enableDebug & (1 << kDebugSlowFieldPath)) |
| 28 | #define SLOW_INVOKE_PATH (cUnit->enableDebug & (1 << kDebugSlowInvokePath)) |
| 29 | #define SLOW_STRING_PATH (cUnit->enableDebug & (1 << kDebugSlowStringPath)) |
| 30 | #define SLOW_TYPE_PATH (cUnit->enableDebug & (1 << kDebugSlowTypePath)) |
| 31 | #define EXERCISE_SLOWEST_FIELD_PATH (cUnit->enableDebug & \ |
| 32 | (1 << kDebugSlowestFieldPath)) |
| 33 | #define EXERCISE_SLOWEST_STRING_PATH (cUnit->enableDebug & \ |
| 34 | (1 << kDebugSlowestStringPath)) |
| 35 | #define EXERCISE_RESOLVE_METHOD (cUnit->enableDebug & \ |
| 36 | (1 << kDebugExerciseResolveMethod)) |
| 37 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 38 | enum RegisterClass { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 39 | kCoreReg, |
| 40 | kFPReg, |
| 41 | kAnyReg, |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 42 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 43 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 44 | enum RegLocationType { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 45 | kLocDalvikFrame = 0, // Normal Dalvik register |
| 46 | kLocPhysReg, |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 47 | kLocCompilerTemp, |
buzbee | e62076c | 2012-03-21 14:26:16 -0700 | [diff] [blame^] | 48 | kLocInvalid |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 49 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 50 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 51 | struct PromotionMap { |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 52 | RegLocationType coreLocation:3; |
| 53 | u1 coreReg; |
| 54 | RegLocationType fpLocation:3; |
| 55 | u1 fpReg; |
| 56 | bool firstInPair; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 57 | }; |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 58 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 59 | struct RegLocation { |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 60 | RegLocationType location:3; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 61 | unsigned wide:1; |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 62 | unsigned defined:1; // Do we know the type? |
| 63 | unsigned fp:1; // Floating point? |
| 64 | unsigned core:1; // Non-floating point? |
| 65 | unsigned highWord:1; // High word of pair? |
| 66 | unsigned home:1; // Does this represent the home location? |
| 67 | u1 lowReg; // First physical register |
| 68 | u1 highReg; // 2nd physical register (if wide) |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 69 | int32_t sRegLow; // SSA name for low Dalvik word |
| 70 | }; |
| 71 | |
| 72 | struct CompilerTemp { |
| 73 | int sReg; |
| 74 | ArenaBitVector* bv; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 75 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 76 | |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 77 | /* |
| 78 | * Data structure tracking the mapping between a Dalvik register (pair) and a |
| 79 | * native register (pair). The idea is to reuse the previously loaded value |
| 80 | * if possible, otherwise to keep the value in a native register as long as |
| 81 | * possible. |
| 82 | */ |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 83 | struct RegisterInfo { |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 84 | int reg; // Reg number |
| 85 | bool inUse; // Has it been allocated? |
| 86 | bool isTemp; // Can allocate as temp? |
| 87 | bool pair; // Part of a register pair? |
| 88 | int partner; // If pair, other reg of pair |
| 89 | bool live; // Is there an associated SSA name? |
| 90 | bool dirty; // If live, is it dirty? |
| 91 | int sReg; // Name of live value |
| 92 | struct LIR *defStart; // Starting inst in last def sequence |
| 93 | struct LIR *defEnd; // Ending inst in last def sequence |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 94 | }; |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 95 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 96 | struct RegisterPool { |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 97 | int numCoreRegs; |
| 98 | RegisterInfo *coreRegs; |
| 99 | int nextCoreReg; |
| 100 | int numFPRegs; |
| 101 | RegisterInfo *FPRegs; |
| 102 | int nextFPReg; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 103 | }; |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 104 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 105 | #define INVALID_SREG (-1) |
buzbee | 3ddc0d1 | 2011-10-05 10:36:21 -0700 | [diff] [blame] | 106 | #define INVALID_VREG (0xFFFFU) |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 107 | #define INVALID_REG (0xFF) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 108 | #define INVALID_OFFSET (-1) |
| 109 | |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 110 | /* SSA encodings for special registers */ |
buzbee | 9c044ce | 2012-03-18 13:24:07 -0700 | [diff] [blame] | 111 | #define SSA_METHOD_BASEREG (-2) |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 112 | /* First compiler temp basereg, grows smaller */ |
buzbee | 9c044ce | 2012-03-18 13:24:07 -0700 | [diff] [blame] | 113 | #define SSA_CTEMP_BASEREG (SSA_METHOD_BASEREG - 1) |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 114 | |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 115 | /* |
| 116 | * Some code patterns cause the generation of excessively large |
| 117 | * methods - in particular initialization sequences. There isn't much |
| 118 | * benefit in optimizing these methods, and the cost can be very high. |
| 119 | * We attempt to identify these cases, and avoid performing most dataflow |
| 120 | * analysis. Two thresholds are used - one for known initializers and one |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 121 | * for everything else. |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 122 | */ |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 123 | #define MANY_BLOCKS_INITIALIZER 1000 /* Threshold for switching dataflow off */ |
| 124 | #define MANY_BLOCKS 4000 /* Non-initializer threshold */ |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 125 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 126 | enum BBType { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 127 | kEntryBlock, |
| 128 | kDalvikByteCode, |
| 129 | kExitBlock, |
| 130 | kExceptionHandling, |
| 131 | kCatchEntry, |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 132 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 133 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 134 | /* Utility macros to traverse the LIR list */ |
| 135 | #define NEXT_LIR(lir) (lir->next) |
| 136 | #define PREV_LIR(lir) (lir->prev) |
| 137 | |
| 138 | #define NEXT_LIR_LVALUE(lir) (lir)->next |
| 139 | #define PREV_LIR_LVALUE(lir) (lir)->prev |
| 140 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 141 | struct LIR { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 142 | int offset; // Offset of this instruction |
| 143 | int dalvikOffset; // Offset of Dalvik opcode |
| 144 | struct LIR* next; |
| 145 | struct LIR* prev; |
| 146 | struct LIR* target; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 147 | int opcode; |
Ian Rogers | b5d09b2 | 2012-03-06 22:14:17 -0800 | [diff] [blame] | 148 | int operands[5]; // [0..4] = [dest, src1, src2, extra, extra2] |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 149 | struct { |
| 150 | bool isNop:1; // LIR is optimized away |
| 151 | bool pcRelFixup:1; // May need pc-relative fixup |
| 152 | unsigned int age:4; // default is 0, set lazily by the optimizer |
buzbee | 71ac994 | 2012-03-01 17:23:10 -0800 | [diff] [blame] | 153 | unsigned int size:5; // in bytes |
| 154 | unsigned int unused:21; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 155 | } flags; |
| 156 | int aliasInfo; // For Dalvik register & litpool disambiguation |
| 157 | u8 useMask; // Resource mask for use |
| 158 | u8 defMask; // Resource mask for def |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 159 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 160 | |
| 161 | enum ExtendedMIROpcode { |
| 162 | kMirOpFirst = kNumPackedOpcodes, |
| 163 | kMirOpPhi = kMirOpFirst, |
| 164 | kMirOpNullNRangeUpCheck, |
| 165 | kMirOpNullNRangeDownCheck, |
| 166 | kMirOpLowerBound, |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 167 | kMirOpCopy, |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 168 | kMirOpLast, |
| 169 | }; |
| 170 | |
| 171 | struct SSARepresentation; |
| 172 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 173 | enum MIROptimizationFlagPositons { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 174 | kMIRIgnoreNullCheck = 0, |
| 175 | kMIRNullCheckOnly, |
| 176 | kMIRIgnoreRangeCheck, |
| 177 | kMIRRangeCheckOnly, |
| 178 | kMIRInlined, // Invoke is inlined (ie dead) |
| 179 | kMIRInlinedPred, // Invoke is inlined via prediction |
| 180 | kMIRCallee, // Instruction is inlined from callee |
buzbee | c1f4504 | 2011-09-21 16:03:19 -0700 | [diff] [blame] | 181 | kMIRIgnoreSuspendCheck, |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 182 | kMIRDup, |
buzbee | 239c4e7 | 2012-03-16 08:42:29 -0700 | [diff] [blame] | 183 | kMIRMark, // Temporary node mark |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 184 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 185 | |
| 186 | #define MIR_IGNORE_NULL_CHECK (1 << kMIRIgnoreNullCheck) |
| 187 | #define MIR_NULL_CHECK_ONLY (1 << kMIRNullCheckOnly) |
| 188 | #define MIR_IGNORE_RANGE_CHECK (1 << kMIRIgnoreRangeCheck) |
| 189 | #define MIR_RANGE_CHECK_ONLY (1 << kMIRRangeCheckOnly) |
| 190 | #define MIR_INLINED (1 << kMIRInlined) |
| 191 | #define MIR_INLINED_PRED (1 << kMIRInlinedPred) |
| 192 | #define MIR_CALLEE (1 << kMIRCallee) |
buzbee | c1f4504 | 2011-09-21 16:03:19 -0700 | [diff] [blame] | 193 | #define MIR_IGNORE_SUSPEND_CHECK (1 << kMIRIgnoreSuspendCheck) |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 194 | #define MIR_DUP (1 << kMIRDup) |
buzbee | 239c4e7 | 2012-03-16 08:42:29 -0700 | [diff] [blame] | 195 | #define MIR_MARK (1 << kMIRMark) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 196 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 197 | struct CallsiteInfo { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 198 | const char* classDescriptor; |
| 199 | Object* classLoader; |
| 200 | const Method* method; |
| 201 | LIR* misPredBranchOver; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 202 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 203 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 204 | struct MIR { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 205 | DecodedInstruction dalvikInsn; |
| 206 | unsigned int width; |
| 207 | unsigned int offset; |
| 208 | struct MIR* prev; |
| 209 | struct MIR* next; |
| 210 | struct SSARepresentation* ssaRep; |
buzbee | 43a3642 | 2011-09-14 14:00:13 -0700 | [diff] [blame] | 211 | int optimizationFlags; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 212 | int seqNum; |
| 213 | union { |
| 214 | // Used by the inlined insn from the callee to find the mother method |
| 215 | const Method* calleeMethod; |
| 216 | // Used by the inlined invoke to find the class and method pointers |
| 217 | CallsiteInfo* callsiteInfo; |
buzbee | c0ecd65 | 2011-09-25 18:11:54 -0700 | [diff] [blame] | 218 | // Used to quickly locate all Phi opcodes |
| 219 | struct MIR* phiNext; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 220 | } meta; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 221 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 222 | |
| 223 | struct BasicBlockDataFlow; |
| 224 | |
| 225 | /* For successorBlockList */ |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 226 | enum BlockListType { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 227 | kNotUsed = 0, |
| 228 | kCatch, |
| 229 | kPackedSwitch, |
| 230 | kSparseSwitch, |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 231 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 232 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 233 | struct BasicBlock { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 234 | int id; |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 235 | int dfsId; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 236 | bool visited; |
| 237 | bool hidden; |
buzbee | 43a3642 | 2011-09-14 14:00:13 -0700 | [diff] [blame] | 238 | bool catchEntry; |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 239 | bool fallThroughTarget; // Reached via fallthrough |
buzbee | 239c4e7 | 2012-03-16 08:42:29 -0700 | [diff] [blame] | 240 | uint16_t startOffset; |
| 241 | uint16_t nestingDepth; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 242 | const Method* containingMethod; // For blocks from the callee |
| 243 | BBType blockType; |
| 244 | bool needFallThroughBranch; // For blocks ended due to length limit |
| 245 | bool isFallThroughFromInvoke; // True means the block needs alignment |
| 246 | MIR* firstMIRInsn; |
| 247 | MIR* lastMIRInsn; |
| 248 | struct BasicBlock* fallThrough; |
| 249 | struct BasicBlock* taken; |
| 250 | struct BasicBlock* iDom; // Immediate dominator |
| 251 | struct BasicBlockDataFlow* dataFlowInfo; |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 252 | GrowableList* predecessors; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 253 | ArenaBitVector* dominators; |
| 254 | ArenaBitVector* iDominated; // Set nodes being immediately dominated |
| 255 | ArenaBitVector* domFrontier; // Dominance frontier |
| 256 | struct { // For one-to-many successors like |
| 257 | BlockListType blockListType; // switch and exception handling |
| 258 | GrowableList blocks; |
| 259 | } successorBlockList; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 260 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 261 | |
| 262 | /* |
| 263 | * The "blocks" field in "successorBlockList" points to an array of |
| 264 | * elements with the type "SuccessorBlockInfo". |
| 265 | * For catch blocks, key is type index for the exception. |
| 266 | * For swtich blocks, key is the case value. |
| 267 | */ |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 268 | struct SuccessorBlockInfo { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 269 | BasicBlock* block; |
| 270 | int key; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 271 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 272 | |
| 273 | struct LoopAnalysis; |
| 274 | struct RegisterPool; |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 275 | struct ArenaMemBlock; |
| 276 | struct Memstats; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 277 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 278 | enum AssemblerStatus { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 279 | kSuccess, |
| 280 | kRetryAll, |
| 281 | kRetryHalve |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 282 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 283 | |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 284 | #define NOTVISITED (-1) |
| 285 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 286 | struct CompilationUnit { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 287 | int numInsts; |
| 288 | int numBlocks; |
| 289 | GrowableList blockList; |
Ian Rogers | 996cc58 | 2012-02-14 22:23:29 -0800 | [diff] [blame] | 290 | Compiler* compiler; // Compiler driving this compiler |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 291 | ClassLinker* class_linker; // Linker to resolve fields and methods |
| 292 | const DexFile* dex_file; // DexFile containing the method being compiled |
| 293 | DexCache* dex_cache; // DexFile's corresponding cache |
| 294 | const ClassLoader* class_loader; // compiling method's class loader |
Ian Rogers | a3760aa | 2011-11-14 14:32:37 -0800 | [diff] [blame] | 295 | uint32_t method_idx; // compiling method's index into method_ids of DexFile |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 296 | const DexFile::CodeItem* code_item; // compiling method's DexFile code_item |
Ian Rogers | a3760aa | 2011-11-14 14:32:37 -0800 | [diff] [blame] | 297 | uint32_t access_flags; // compiling method's access flags |
| 298 | const char* shorty; // compiling method's shorty |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 299 | LIR* firstLIRInsn; |
| 300 | LIR* lastLIRInsn; |
| 301 | LIR* literalList; // Constants |
Ian Rogers | 3fa1379 | 2012-03-18 15:53:45 -0700 | [diff] [blame] | 302 | LIR* methodLiteralList; // Method literals requiring patching |
| 303 | LIR* codeLiteralList; // Code literals requiring patching |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 304 | LIR* classPointerList; // Relocatable |
| 305 | int numClassPointers; |
| 306 | LIR* chainCellOffsetLIR; |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 307 | uint32_t disableOpt; // optControlVector flags |
| 308 | uint32_t enableDebug; // debugControlVector flags |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 309 | int headerSize; // bytes before the first code ptr |
| 310 | int dataOffset; // starting offset of literal pool |
| 311 | int totalSize; // header + code size |
| 312 | AssemblerStatus assemblerStatus; // Success or fix and retry |
| 313 | int assemblerRetries; |
Ian Rogers | ab058bb | 2012-03-11 22:19:38 -0700 | [diff] [blame] | 314 | std::vector<uint8_t> codeBuffer; |
buzbee | 4ef7652 | 2011-09-08 10:00:32 -0700 | [diff] [blame] | 315 | std::vector<uint32_t> mappingTable; |
buzbee | 3ddc0d1 | 2011-10-05 10:36:21 -0700 | [diff] [blame] | 316 | std::vector<uint16_t> coreVmapTable; |
| 317 | std::vector<uint16_t> fpVmapTable; |
buzbee | 44b412b | 2012-02-04 08:50:53 -0800 | [diff] [blame] | 318 | bool genDebugger; // Generate code for debugger |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 319 | bool printMe; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 320 | bool hasClassLiterals; // Contains class ptrs used as literals |
| 321 | bool hasLoop; // Contains a loop |
| 322 | bool hasInvoke; // Contains an invoke instruction |
| 323 | bool heapMemOp; // Mark mem ops for self verification |
buzbee | a7c1268 | 2012-03-19 13:13:53 -0700 | [diff] [blame] | 324 | bool qdMode; // Compile for code size/compile time |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 325 | bool usesLinkRegister; // For self-verification only |
| 326 | bool methodTraceSupport; // For TraceView profiling |
| 327 | struct RegisterPool* regPool; |
| 328 | int optRound; // round number to tell an LIR's age |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 329 | InstructionSet instructionSet; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 330 | /* Number of total regs used in the whole cUnit after SSA transformation */ |
| 331 | int numSSARegs; |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 332 | /* Map SSA reg i to the base virtual register/subscript */ |
| 333 | GrowableList* ssaBaseVRegs; |
| 334 | GrowableList* ssaSubscripts; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 335 | |
| 336 | /* The following are new data structures to support SSA representations */ |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 337 | /* Map original Dalvik virtual reg i to the current SSA name */ |
| 338 | int* vRegToSSAMap; // length == method->registersSize |
buzbee | f0cde54 | 2011-09-13 14:55:02 -0700 | [diff] [blame] | 339 | int* SSALastDefs; // length == method->registersSize |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 340 | ArenaBitVector* isConstantV; // length == numSSAReg |
| 341 | int* constantValues; // length == numSSAReg |
buzbee | c0ecd65 | 2011-09-25 18:11:54 -0700 | [diff] [blame] | 342 | int* phiAliasMap; // length == numSSAReg |
| 343 | MIR* phiList; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 344 | |
buzbee | 239c4e7 | 2012-03-16 08:42:29 -0700 | [diff] [blame] | 345 | /* Use counts of ssa names */ |
| 346 | GrowableList useCounts; |
| 347 | |
| 348 | /* Optimization support */ |
| 349 | GrowableList loopHeaders; |
| 350 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 351 | /* Map SSA names to location */ |
| 352 | RegLocation* regLocation; |
| 353 | int sequenceNumber; |
| 354 | |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 355 | /* Keep track of Dalvik vReg to physical register mappings */ |
| 356 | PromotionMap* promotionMap; |
| 357 | |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 358 | /* SSA name for Method* */ |
| 359 | int methodSReg; |
| 360 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 361 | /* |
| 362 | * Set to the Dalvik PC of the switch instruction if it has more than |
| 363 | * MAX_CHAINED_SWITCH_CASES cases. |
| 364 | */ |
| 365 | const u2* switchOverflowPad; |
| 366 | |
| 367 | int numReachableBlocks; |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 368 | int numDalvikRegisters; // method->registersSize |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 369 | BasicBlock* entryBlock; |
| 370 | BasicBlock* exitBlock; |
| 371 | BasicBlock* curBlock; |
| 372 | BasicBlock* nextCodegenBlock; // for extended trace codegen |
| 373 | GrowableList dfsOrder; |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 374 | GrowableList dfsPostOrder; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 375 | GrowableList domPostOrderTraversal; |
buzbee | 5ade1d2 | 2011-09-09 14:44:52 -0700 | [diff] [blame] | 376 | GrowableList throwLaunchpads; |
buzbee | c1f4504 | 2011-09-21 16:03:19 -0700 | [diff] [blame] | 377 | GrowableList suspendLaunchpads; |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 378 | GrowableList compilerTemps; |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 379 | int* iDomList; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 380 | ArenaBitVector* tryBlockAddr; |
| 381 | ArenaBitVector** defBlockMatrix; // numDalvikRegister x numBlocks |
| 382 | ArenaBitVector* tempBlockV; |
| 383 | ArenaBitVector* tempDalvikRegisterV; |
| 384 | ArenaBitVector* tempSSARegisterV; // numSSARegs |
| 385 | bool printSSANames; |
| 386 | void* blockLabelList; |
| 387 | bool quitLoopMode; // cold path/complex bytecode |
| 388 | int preservedRegsUsed; // How many callee save regs used |
| 389 | /* |
buzbee | 5ade1d2 | 2011-09-09 14:44:52 -0700 | [diff] [blame] | 390 | * Frame layout details. |
| 391 | * NOTE: for debug support it will be necessary to add a structure |
| 392 | * to map the Dalvik virtual registers to the promoted registers. |
| 393 | * NOTE: "num" fields are in 4-byte words, "Size" and "Offset" in bytes. |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 394 | */ |
| 395 | int numIns; |
| 396 | int numOuts; |
Ian Rogers | a3760aa | 2011-11-14 14:32:37 -0800 | [diff] [blame] | 397 | int numRegs; // Unlike numDalvikRegisters, does not include ins |
buzbee | bbaf894 | 2011-10-02 13:08:29 -0700 | [diff] [blame] | 398 | int numCoreSpills; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 399 | int numFPSpills; |
buzbee | efccc56 | 2012-03-11 11:19:28 -0700 | [diff] [blame] | 400 | int numCompilerTemps; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 401 | int frameSize; |
| 402 | unsigned int coreSpillMask; |
| 403 | unsigned int fpSpillMask; |
buzbee | cefd187 | 2011-09-09 09:59:52 -0700 | [diff] [blame] | 404 | unsigned int attrs; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 405 | /* |
| 406 | * CLEANUP/RESTRUCTURE: The code generation utilities don't have a built-in |
buzbee | 03fa263 | 2011-09-20 17:10:57 -0700 | [diff] [blame] | 407 | * mechanism to propagate the original Dalvik opcode address to the |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 408 | * associated generated instructions. For the trace compiler, this wasn't |
| 409 | * necessary because the interpreter handled all throws and debugging |
| 410 | * requests. For now we'll handle this by placing the Dalvik offset |
| 411 | * in the CompilationUnit struct before codegen for each instruction. |
| 412 | * The low-level LIR creation utilites will pull it from here. Should |
| 413 | * be rewritten. |
| 414 | */ |
| 415 | int currentDalvikOffset; |
| 416 | GrowableList switchTables; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 417 | GrowableList fillArrayData; |
| 418 | const u2* insns; |
| 419 | u4 insnsSize; |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 420 | bool disableDataflow; // Skip dataflow analysis if possible |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 421 | std::map<unsigned int, BasicBlock*> blockMap; // findBlock lookup cache |
buzbee | 85d8c1e | 2012-01-27 15:52:35 -0800 | [diff] [blame] | 422 | std::map<unsigned int, LIR*> boundaryMap; // boundary lookup cache |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 423 | int defCount; // Used to estimate number of SSA names |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 424 | std::string* compilerMethodMatch; |
| 425 | bool compilerFlipMatch; |
| 426 | struct ArenaMemBlock* arenaHead; |
| 427 | struct ArenaMemBlock* currentArena; |
| 428 | int numArenaBlocks; |
| 429 | struct Memstats* mstats; |
buzbee | a7c1268 | 2012-03-19 13:13:53 -0700 | [diff] [blame] | 430 | int* opcodeCount; // Count Dalvik opcodes for tuning |
buzbee | 3d66194 | 2012-03-14 17:37:27 -0700 | [diff] [blame] | 431 | #ifndef NDEBUG |
| 432 | /* |
| 433 | * Sanity checking for the register temp tracking. The same ssa |
| 434 | * name should never be associated with one temp register per |
| 435 | * instruction compilation. |
| 436 | */ |
| 437 | int liveSReg; |
| 438 | #endif |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 439 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 440 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 441 | enum OpSize { |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 442 | kWord, |
| 443 | kLong, |
| 444 | kSingle, |
| 445 | kDouble, |
| 446 | kUnsignedHalf, |
| 447 | kSignedHalf, |
| 448 | kUnsignedByte, |
| 449 | kSignedByte, |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 450 | }; |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 451 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 452 | enum OpKind { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 453 | kOpMov, |
| 454 | kOpMvn, |
| 455 | kOpCmp, |
| 456 | kOpLsl, |
| 457 | kOpLsr, |
| 458 | kOpAsr, |
| 459 | kOpRor, |
| 460 | kOpNot, |
| 461 | kOpAnd, |
| 462 | kOpOr, |
| 463 | kOpXor, |
| 464 | kOpNeg, |
| 465 | kOpAdd, |
| 466 | kOpAdc, |
| 467 | kOpSub, |
| 468 | kOpSbc, |
| 469 | kOpRsub, |
| 470 | kOpMul, |
| 471 | kOpDiv, |
| 472 | kOpRem, |
| 473 | kOpBic, |
| 474 | kOpCmn, |
| 475 | kOpTst, |
| 476 | kOpBkpt, |
| 477 | kOpBlx, |
| 478 | kOpPush, |
| 479 | kOpPop, |
| 480 | kOp2Char, |
| 481 | kOp2Short, |
| 482 | kOp2Byte, |
| 483 | kOpCondBr, |
| 484 | kOpUncondBr, |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 485 | kOpBx, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 486 | kOpInvalid, |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 487 | }; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 488 | |
Ian Rogers | 680b1bd | 2012-03-07 20:18:49 -0800 | [diff] [blame] | 489 | std::ostream& operator<<(std::ostream& os, const OpKind& kind); |
| 490 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 491 | enum ConditionCode { |
Ian Rogers | b5d09b2 | 2012-03-06 22:14:17 -0800 | [diff] [blame] | 492 | kCondEq, // equal |
| 493 | kCondNe, // not equal |
| 494 | kCondCs, // carry set (unsigned less than) |
| 495 | kCondUlt = kCondCs, |
| 496 | kCondCc, // carry clear (unsigned greater than or same) |
| 497 | kCondUge = kCondCc, |
| 498 | kCondMi, // minus |
| 499 | kCondPl, // plus, positive or zero |
| 500 | kCondVs, // overflow |
| 501 | kCondVc, // no overflow |
| 502 | kCondHi, // unsigned greater than |
| 503 | kCondLs, // unsigned lower or same |
| 504 | kCondGe, // signed greater than or equal |
| 505 | kCondLt, // signed less than |
| 506 | kCondGt, // signed greater than |
| 507 | kCondLe, // signed less than or equal |
| 508 | kCondAl, // always |
| 509 | kCondNv, // never |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 510 | }; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 511 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 512 | enum ThrowKind { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 513 | kThrowNullPointer, |
| 514 | kThrowDivZero, |
| 515 | kThrowArrayBounds, |
| 516 | kThrowVerificationError, |
| 517 | kThrowNegArraySize, |
| 518 | kThrowNoSuchMethod, |
| 519 | kThrowStackOverflow, |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 520 | }; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 521 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 522 | struct SwitchTable { |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 523 | int offset; |
| 524 | const u2* table; // Original dex table |
| 525 | int vaddr; // Dalvik offset of switch opcode |
buzbee | c5159d5 | 2012-03-03 11:48:39 -0800 | [diff] [blame] | 526 | LIR* anchor; // Reference instruction for relative offsets |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 527 | LIR** targets; // Array of case targets |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 528 | }; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 529 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 530 | struct FillArrayData { |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 531 | int offset; |
| 532 | const u2* table; // Original dex table |
| 533 | int size; |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 534 | int vaddr; // Dalvik offset of FILL_ARRAY_DATA opcode |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 535 | }; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 536 | |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 537 | #define MAX_PATTERN_LEN 5 |
| 538 | |
| 539 | enum SpecialCaseHandler { |
| 540 | kNoHandler, |
| 541 | kNullMethod, |
| 542 | kConstFunction, |
| 543 | kIGet, |
| 544 | kIGetBoolean, |
| 545 | kIGetObject, |
| 546 | kIGetByte, |
| 547 | kIGetChar, |
| 548 | kIGetShort, |
| 549 | kIGetWide, |
| 550 | kIPut, |
| 551 | kIPutBoolean, |
| 552 | kIPutObject, |
| 553 | kIPutByte, |
| 554 | kIPutChar, |
| 555 | kIPutShort, |
| 556 | kIPutWide, |
buzbee | e62076c | 2012-03-21 14:26:16 -0700 | [diff] [blame^] | 557 | kIdentity, |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 558 | }; |
| 559 | |
| 560 | struct CodePattern { |
| 561 | const Instruction::Code opcodes[MAX_PATTERN_LEN]; |
| 562 | const SpecialCaseHandler handlerCode; |
| 563 | }; |
| 564 | |
| 565 | static const CodePattern specialPatterns[] = { |
| 566 | {{Instruction::RETURN_VOID}, kNullMethod}, |
| 567 | {{Instruction::CONST, Instruction::RETURN}, kConstFunction}, |
| 568 | {{Instruction::CONST_4, Instruction::RETURN}, kConstFunction}, |
Ian Rogers | f24132c | 2012-03-21 01:34:31 -0700 | [diff] [blame] | 569 | {{Instruction::CONST_4, Instruction::RETURN_OBJECT}, kConstFunction}, |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 570 | {{Instruction::CONST_16, Instruction::RETURN}, kConstFunction}, |
| 571 | {{Instruction::IGET, Instruction:: RETURN}, kIGet}, |
Ian Rogers | f24132c | 2012-03-21 01:34:31 -0700 | [diff] [blame] | 572 | {{Instruction::IGET_BOOLEAN, Instruction::RETURN}, kIGetBoolean}, |
| 573 | {{Instruction::IGET_OBJECT, Instruction::RETURN_OBJECT}, kIGetObject}, |
| 574 | {{Instruction::IGET_BYTE, Instruction::RETURN}, kIGetByte}, |
| 575 | {{Instruction::IGET_CHAR, Instruction::RETURN}, kIGetChar}, |
| 576 | {{Instruction::IGET_SHORT, Instruction::RETURN}, kIGetShort}, |
| 577 | {{Instruction::IGET_WIDE, Instruction::RETURN_WIDE}, kIGetWide}, |
| 578 | {{Instruction::IPUT, Instruction::RETURN_VOID}, kIPut}, |
| 579 | {{Instruction::IPUT_BOOLEAN, Instruction::RETURN_VOID}, kIPutBoolean}, |
| 580 | {{Instruction::IPUT_OBJECT, Instruction::RETURN_VOID}, kIPutObject}, |
| 581 | {{Instruction::IPUT_BYTE, Instruction::RETURN_VOID}, kIPutByte}, |
| 582 | {{Instruction::IPUT_CHAR, Instruction::RETURN_VOID}, kIPutChar}, |
| 583 | {{Instruction::IPUT_SHORT, Instruction::RETURN_VOID}, kIPutShort}, |
| 584 | {{Instruction::IPUT_WIDE, Instruction::RETURN_VOID}, kIPutWide}, |
buzbee | e62076c | 2012-03-21 14:26:16 -0700 | [diff] [blame^] | 585 | {{Instruction::RETURN}, kIdentity}, |
| 586 | {{Instruction::RETURN_OBJECT}, kIdentity}, |
| 587 | {{Instruction::RETURN_WIDE}, kIdentity}, |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 588 | }; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 589 | |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 590 | BasicBlock* oatNewBB(CompilationUnit* cUnit, BBType blockType, int blockId); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 591 | |
| 592 | void oatAppendMIR(BasicBlock* bb, MIR* mir); |
| 593 | |
| 594 | void oatPrependMIR(BasicBlock* bb, MIR* mir); |
| 595 | |
| 596 | void oatInsertMIRAfter(BasicBlock* bb, MIR* currentMIR, MIR* newMIR); |
| 597 | |
| 598 | void oatAppendLIR(CompilationUnit* cUnit, LIR* lir); |
| 599 | |
| 600 | void oatInsertLIRBefore(LIR* currentLIR, LIR* newLIR); |
| 601 | |
| 602 | void oatInsertLIRAfter(LIR* currentLIR, LIR* newLIR); |
| 603 | |
| 604 | /* Debug Utilities */ |
| 605 | void oatDumpCompilationUnit(CompilationUnit* cUnit); |
| 606 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 607 | } // namespace art |
| 608 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 609 | #endif // ART_SRC_COMPILER_COMPILER_IR_H_ |