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 | |
Elliott Hughes | a0e1806 | 2012-04-13 15:59:59 -0700 | [diff] [blame] | 20 | #include <vector> |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 21 | #include "dex_instruction.h" |
| 22 | #include "compiler.h" |
buzbee | efc6369 | 2012-11-14 16:31:52 -0800 | [diff] [blame] | 23 | #include "compiler_utility.h" |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 24 | #include "oat_compilation_unit.h" |
Elliott Hughes | a0e1806 | 2012-04-13 15:59:59 -0700 | [diff] [blame] | 25 | #include "safe_map.h" |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 26 | #include "greenland/ir_builder.h" |
| 27 | #include "llvm/Module.h" |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 28 | #include "compiler_enums.h" |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 29 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 30 | namespace art { |
| 31 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 32 | #define SLOW_FIELD_PATH (cUnit->enableDebug & (1 << kDebugSlowFieldPath)) |
| 33 | #define SLOW_INVOKE_PATH (cUnit->enableDebug & (1 << kDebugSlowInvokePath)) |
| 34 | #define SLOW_STRING_PATH (cUnit->enableDebug & (1 << kDebugSlowStringPath)) |
| 35 | #define SLOW_TYPE_PATH (cUnit->enableDebug & (1 << kDebugSlowTypePath)) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 36 | #define EXERCISE_SLOWEST_STRING_PATH (cUnit->enableDebug & \ |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 37 | (1 << kDebugSlowestStringPath)) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 38 | |
buzbee | ca7a5e4 | 2012-08-20 11:12:18 -0700 | [diff] [blame] | 39 | // Minimum field size to contain Dalvik vReg number |
| 40 | #define VREG_NUM_WIDTH 16 |
| 41 | |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 42 | struct ArenaBitVector; |
| 43 | struct LIR; |
| 44 | class LLVMInfo; |
| 45 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 46 | struct PromotionMap { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 47 | RegLocationType coreLocation:3; |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 48 | uint8_t coreReg; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 49 | RegLocationType fpLocation:3; |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 50 | uint8_t FpReg; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 51 | bool firstInPair; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 52 | }; |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 53 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 54 | struct RegLocation { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 55 | RegLocationType location:3; |
| 56 | unsigned wide:1; |
| 57 | unsigned defined:1; // Do we know the type? |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 58 | unsigned isConst:1; // Constant, value in cUnit->constantValues[] |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 59 | unsigned fp:1; // Floating point? |
| 60 | unsigned core:1; // Non-floating point? |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 61 | unsigned ref:1; // Something GC cares about |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 62 | unsigned highWord:1; // High word of pair? |
| 63 | unsigned home:1; // Does this represent the home location? |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 64 | uint8_t lowReg; // First physical register |
| 65 | uint8_t highReg; // 2nd physical register (if wide) |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 66 | int32_t sRegLow; // SSA name for low Dalvik word |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 67 | int32_t origSReg; // TODO: remove after Bitcode gen complete |
| 68 | // and consolodate usage w/ sRegLow |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | struct CompilerTemp { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 72 | int sReg; |
| 73 | ArenaBitVector* bv; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 74 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 75 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 76 | struct CallInfo { |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 77 | int numArgWords; // Note: word count, not arg count |
| 78 | RegLocation* args; // One for each word of arguments |
| 79 | RegLocation result; // Eventual target of MOVE_RESULT |
| 80 | int optFlags; |
| 81 | InvokeType type; |
| 82 | uint32_t dexIdx; |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 83 | uint32_t index; // Method idx for invokes, type idx for FilledNewArray |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 84 | uintptr_t directCode; |
| 85 | uintptr_t directMethod; |
| 86 | RegLocation target; // Target of following move_result |
| 87 | bool skipThis; |
| 88 | bool isRange; |
| 89 | int offset; // Dalvik offset |
| 90 | }; |
| 91 | |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 92 | /* |
| 93 | * Data structure tracking the mapping between a Dalvik register (pair) and a |
| 94 | * native register (pair). The idea is to reuse the previously loaded value |
| 95 | * if possible, otherwise to keep the value in a native register as long as |
| 96 | * possible. |
| 97 | */ |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 98 | struct RegisterInfo { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 99 | int reg; // Reg number |
| 100 | bool inUse; // Has it been allocated? |
| 101 | bool isTemp; // Can allocate as temp? |
| 102 | bool pair; // Part of a register pair? |
| 103 | int partner; // If pair, other reg of pair |
| 104 | bool live; // Is there an associated SSA name? |
| 105 | bool dirty; // If live, is it dirty? |
| 106 | int sReg; // Name of live value |
| 107 | LIR *defStart; // Starting inst in last def sequence |
| 108 | LIR *defEnd; // Ending inst in last def sequence |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 109 | }; |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 110 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 111 | struct RegisterPool { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 112 | int numCoreRegs; |
| 113 | RegisterInfo *coreRegs; |
| 114 | int nextCoreReg; |
| 115 | int numFPRegs; |
| 116 | RegisterInfo *FPRegs; |
| 117 | int nextFPReg; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 118 | }; |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 119 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 120 | #define INVALID_SREG (-1) |
buzbee | 3ddc0d1 | 2011-10-05 10:36:21 -0700 | [diff] [blame] | 121 | #define INVALID_VREG (0xFFFFU) |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 122 | #define INVALID_REG (0xFF) |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 123 | #define INVALID_OFFSET (0xDEADF00FU) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 124 | |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 125 | /* SSA encodings for special registers */ |
buzbee | 9c044ce | 2012-03-18 13:24:07 -0700 | [diff] [blame] | 126 | #define SSA_METHOD_BASEREG (-2) |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 127 | /* First compiler temp basereg, grows smaller */ |
buzbee | 9c044ce | 2012-03-18 13:24:07 -0700 | [diff] [blame] | 128 | #define SSA_CTEMP_BASEREG (SSA_METHOD_BASEREG - 1) |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 129 | |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 130 | /* |
| 131 | * Some code patterns cause the generation of excessively large |
| 132 | * methods - in particular initialization sequences. There isn't much |
| 133 | * benefit in optimizing these methods, and the cost can be very high. |
| 134 | * We attempt to identify these cases, and avoid performing most dataflow |
| 135 | * analysis. Two thresholds are used - one for known initializers and one |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 136 | * for everything else. |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 137 | */ |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 138 | #define MANY_BLOCKS_INITIALIZER 1000 /* Threshold for switching dataflow off */ |
| 139 | #define MANY_BLOCKS 4000 /* Non-initializer threshold */ |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 140 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 141 | /* Utility macros to traverse the LIR list */ |
| 142 | #define NEXT_LIR(lir) (lir->next) |
| 143 | #define PREV_LIR(lir) (lir->prev) |
| 144 | |
buzbee | ec13743 | 2012-11-13 12:13:16 -0800 | [diff] [blame] | 145 | /* Defines for aliasInfo (tracks Dalvik register references) */ |
| 146 | #define DECODE_ALIAS_INFO_REG(X) (X & 0xffff) |
| 147 | #define DECODE_ALIAS_INFO_WIDE_FLAG (0x80000000) |
| 148 | #define DECODE_ALIAS_INFO_WIDE(X) ((X & DECODE_ALIAS_INFO_WIDE_FLAG) ? 1 : 0) |
| 149 | #define ENCODE_ALIAS_INFO(REG, ISWIDE) (REG | (ISWIDE ? DECODE_ALIAS_INFO_WIDE_FLAG : 0)) |
| 150 | |
buzbee | ec13743 | 2012-11-13 12:13:16 -0800 | [diff] [blame] | 151 | /* Common resource macros */ |
| 152 | #define ENCODE_CCODE (1ULL << kCCode) |
| 153 | #define ENCODE_FP_STATUS (1ULL << kFPStatus) |
| 154 | |
| 155 | /* Abstract memory locations */ |
| 156 | #define ENCODE_DALVIK_REG (1ULL << kDalvikReg) |
| 157 | #define ENCODE_LITERAL (1ULL << kLiteral) |
| 158 | #define ENCODE_HEAP_REF (1ULL << kHeapRef) |
| 159 | #define ENCODE_MUST_NOT_ALIAS (1ULL << kMustNotAlias) |
| 160 | |
| 161 | #define ENCODE_ALL (~0ULL) |
| 162 | #define ENCODE_MEM (ENCODE_DALVIK_REG | ENCODE_LITERAL | \ |
| 163 | ENCODE_HEAP_REF | ENCODE_MUST_NOT_ALIAS) |
| 164 | |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 165 | #define isPseudoOpcode(opcode) (static_cast<int>(opcode) < 0) |
| 166 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 167 | struct LIR { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 168 | int offset; // Offset of this instruction |
| 169 | int dalvikOffset; // Offset of Dalvik opcode |
| 170 | LIR* next; |
| 171 | LIR* prev; |
| 172 | LIR* target; |
| 173 | int opcode; |
| 174 | int operands[5]; // [0..4] = [dest, src1, src2, extra, extra2] |
| 175 | struct { |
| 176 | bool isNop:1; // LIR is optimized away |
| 177 | bool pcRelFixup:1; // May need pc-relative fixup |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 178 | unsigned int size:5; // in bytes |
buzbee | f5f5a12 | 2012-09-21 13:57:36 -0700 | [diff] [blame] | 179 | unsigned int unused:25; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 180 | } flags; |
| 181 | int aliasInfo; // For Dalvik register & litpool disambiguation |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 182 | uint64_t useMask; // Resource mask for use |
| 183 | uint64_t defMask; // Resource mask for def |
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 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 186 | extern const char* extendedMIROpNames[kMirOpLast - kMirOpFirst]; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 187 | |
| 188 | struct SSARepresentation; |
| 189 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 190 | #define MIR_IGNORE_NULL_CHECK (1 << kMIRIgnoreNullCheck) |
| 191 | #define MIR_NULL_CHECK_ONLY (1 << kMIRNullCheckOnly) |
| 192 | #define MIR_IGNORE_RANGE_CHECK (1 << kMIRIgnoreRangeCheck) |
| 193 | #define MIR_RANGE_CHECK_ONLY (1 << kMIRRangeCheckOnly) |
| 194 | #define MIR_INLINED (1 << kMIRInlined) |
| 195 | #define MIR_INLINED_PRED (1 << kMIRInlinedPred) |
| 196 | #define MIR_CALLEE (1 << kMIRCallee) |
buzbee | c1f4504 | 2011-09-21 16:03:19 -0700 | [diff] [blame] | 197 | #define MIR_IGNORE_SUSPEND_CHECK (1 << kMIRIgnoreSuspendCheck) |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 198 | #define MIR_DUP (1 << kMIRDup) |
buzbee | 239c4e7 | 2012-03-16 08:42:29 -0700 | [diff] [blame] | 199 | #define MIR_MARK (1 << kMIRMark) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 200 | |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 201 | struct Checkstats { |
| 202 | int nullChecks; |
| 203 | int nullChecksEliminated; |
| 204 | int rangeChecks; |
| 205 | int rangeChecksEliminated; |
| 206 | }; |
| 207 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 208 | struct MIR { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 209 | DecodedInstruction dalvikInsn; |
| 210 | unsigned int width; |
| 211 | unsigned int offset; |
| 212 | MIR* prev; |
| 213 | MIR* next; |
| 214 | SSARepresentation* ssaRep; |
| 215 | int optimizationFlags; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 216 | union { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 217 | // Used to quickly locate all Phi opcodes |
| 218 | MIR* phiNext; |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 219 | // Establish link between two halves of throwing instructions |
| 220 | MIR* throwInsn; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 221 | } meta; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 222 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 223 | |
| 224 | struct BasicBlockDataFlow; |
| 225 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 226 | struct BasicBlock { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 227 | int id; |
| 228 | int dfsId; |
| 229 | bool visited; |
| 230 | bool hidden; |
| 231 | bool catchEntry; |
buzbee | 0967a25 | 2012-09-14 10:43:54 -0700 | [diff] [blame] | 232 | bool explicitThrow; |
| 233 | bool conditionalBranch; |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 234 | bool hasReturn; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 235 | uint16_t startOffset; |
| 236 | uint16_t nestingDepth; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 237 | BBType blockType; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 238 | MIR* firstMIRInsn; |
| 239 | MIR* lastMIRInsn; |
| 240 | BasicBlock* fallThrough; |
| 241 | BasicBlock* taken; |
| 242 | BasicBlock* iDom; // Immediate dominator |
| 243 | BasicBlockDataFlow* dataFlowInfo; |
| 244 | GrowableList* predecessors; |
| 245 | ArenaBitVector* dominators; |
| 246 | ArenaBitVector* iDominated; // Set nodes being immediately dominated |
| 247 | ArenaBitVector* domFrontier; // Dominance frontier |
| 248 | struct { // For one-to-many successors like |
| 249 | BlockListType blockListType; // switch and exception handling |
| 250 | GrowableList blocks; |
| 251 | } successorBlockList; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 252 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 253 | |
| 254 | /* |
| 255 | * The "blocks" field in "successorBlockList" points to an array of |
| 256 | * elements with the type "SuccessorBlockInfo". |
| 257 | * For catch blocks, key is type index for the exception. |
| 258 | * For swtich blocks, key is the case value. |
| 259 | */ |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 260 | struct SuccessorBlockInfo { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 261 | BasicBlock* block; |
| 262 | int key; |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 263 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 264 | |
| 265 | struct LoopAnalysis; |
| 266 | struct RegisterPool; |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 267 | struct ArenaMemBlock; |
| 268 | struct Memstats; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 269 | |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 270 | #define NOTVISITED (-1) |
| 271 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 272 | struct CompilationUnit { |
Elliott Hughes | e52e49b | 2012-04-02 16:05:44 -0700 | [diff] [blame] | 273 | CompilationUnit() |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 274 | : numBlocks(0), |
| 275 | compiler(NULL), |
| 276 | class_linker(NULL), |
| 277 | dex_file(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 278 | class_loader(NULL), |
| 279 | method_idx(0), |
| 280 | code_item(NULL), |
| 281 | access_flags(0), |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 282 | invoke_type(kDirect), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 283 | shorty(NULL), |
| 284 | firstLIRInsn(NULL), |
| 285 | lastLIRInsn(NULL), |
| 286 | literalList(NULL), |
| 287 | methodLiteralList(NULL), |
| 288 | codeLiteralList(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 289 | disableOpt(0), |
| 290 | enableDebug(0), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 291 | dataOffset(0), |
| 292 | totalSize(0), |
| 293 | assemblerStatus(kSuccess), |
| 294 | assemblerRetries(0), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 295 | printMe(false), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 296 | hasLoop(false), |
| 297 | hasInvoke(false), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 298 | qdMode(false), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 299 | regPool(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 300 | instructionSet(kNone), |
| 301 | numSSARegs(0), |
| 302 | ssaBaseVRegs(NULL), |
| 303 | ssaSubscripts(NULL), |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 304 | ssaStrings(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 305 | vRegToSSAMap(NULL), |
| 306 | SSALastDefs(NULL), |
| 307 | isConstantV(NULL), |
| 308 | constantValues(NULL), |
| 309 | phiAliasMap(NULL), |
| 310 | phiList(NULL), |
| 311 | regLocation(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 312 | promotionMap(NULL), |
| 313 | methodSReg(0), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 314 | numReachableBlocks(0), |
| 315 | numDalvikRegisters(0), |
| 316 | entryBlock(NULL), |
| 317 | exitBlock(NULL), |
| 318 | curBlock(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 319 | iDomList(NULL), |
| 320 | tryBlockAddr(NULL), |
| 321 | defBlockMatrix(NULL), |
| 322 | tempBlockV(NULL), |
| 323 | tempDalvikRegisterV(NULL), |
| 324 | tempSSARegisterV(NULL), |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 325 | tempSSABlockIdV(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 326 | blockLabelList(NULL), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 327 | numIns(0), |
| 328 | numOuts(0), |
| 329 | numRegs(0), |
| 330 | numCoreSpills(0), |
| 331 | numFPSpills(0), |
| 332 | numCompilerTemps(0), |
| 333 | frameSize(0), |
| 334 | coreSpillMask(0U), |
| 335 | fpSpillMask(0U), |
| 336 | attrs(0U), |
| 337 | currentDalvikOffset(0), |
| 338 | insns(NULL), |
| 339 | insnsSize(0U), |
| 340 | disableDataflow(false), |
| 341 | defCount(0), |
| 342 | compilerFlipMatch(false), |
| 343 | arenaHead(NULL), |
| 344 | currentArena(NULL), |
| 345 | numArenaBlocks(0), |
| 346 | mstats(NULL), |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 347 | checkstats(NULL), |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 348 | genBitcode(false), |
| 349 | context(NULL), |
| 350 | module(NULL), |
| 351 | func(NULL), |
| 352 | intrinsic_helper(NULL), |
| 353 | irb(NULL), |
| 354 | placeholderBB(NULL), |
| 355 | entryBB(NULL), |
buzbee | 4be777b | 2012-07-12 14:38:18 -0700 | [diff] [blame] | 356 | entryTargetBB(NULL), |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 357 | tempName(0), |
buzbee | b03f487 | 2012-06-11 15:22:11 -0700 | [diff] [blame] | 358 | numShadowFrameEntries(0), |
| 359 | shadowMap(NULL), |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 360 | #ifndef NDEBUG |
| 361 | liveSReg(0), |
| 362 | #endif |
| 363 | opcodeCount(NULL) {} |
Elliott Hughes | e52e49b | 2012-04-02 16:05:44 -0700 | [diff] [blame] | 364 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 365 | int numBlocks; |
| 366 | GrowableList blockList; |
| 367 | Compiler* compiler; // Compiler driving this compiler |
| 368 | ClassLinker* class_linker; // Linker to resolve fields and methods |
| 369 | const DexFile* dex_file; // DexFile containing the method being compiled |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 370 | jobject class_loader; // compiling method's class loader |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 371 | uint32_t method_idx; // compiling method's index into method_ids of DexFile |
| 372 | const DexFile::CodeItem* code_item; // compiling method's DexFile code_item |
| 373 | uint32_t access_flags; // compiling method's access flags |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 374 | InvokeType invoke_type; // compiling method's invocation type |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 375 | const char* shorty; // compiling method's shorty |
| 376 | LIR* firstLIRInsn; |
| 377 | LIR* lastLIRInsn; |
| 378 | LIR* literalList; // Constants |
| 379 | LIR* methodLiteralList; // Method literals requiring patching |
| 380 | LIR* codeLiteralList; // Code literals requiring patching |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 381 | uint32_t disableOpt; // optControlVector flags |
| 382 | uint32_t enableDebug; // debugControlVector flags |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 383 | int dataOffset; // starting offset of literal pool |
| 384 | int totalSize; // header + code size |
| 385 | AssemblerStatus assemblerStatus; // Success or fix and retry |
| 386 | int assemblerRetries; |
| 387 | std::vector<uint8_t> codeBuffer; |
Bill Buzbee | a5b3024 | 2012-09-28 07:19:44 -0700 | [diff] [blame] | 388 | /* |
| 389 | * Holds mapping from native PC to dex PC for safepoints where we may deoptimize. |
| 390 | * Native PC is on the return address of the safepointed operation. Dex PC is for |
| 391 | * the instruction being executed at the safepoint. |
| 392 | */ |
| 393 | std::vector<uint32_t> pc2dexMappingTable; |
| 394 | /* |
| 395 | * Holds mapping from Dex PC to native PC for catch entry points. Native PC and Dex PC |
| 396 | * immediately preceed the instruction. |
| 397 | */ |
| 398 | std::vector<uint32_t> dex2pcMappingTable; |
| 399 | std::vector<uint32_t> combinedMappingTable; |
buzbee | ca7a5e4 | 2012-08-20 11:12:18 -0700 | [diff] [blame] | 400 | std::vector<uint32_t> coreVmapTable; |
| 401 | std::vector<uint32_t> fpVmapTable; |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 402 | std::vector<uint8_t> nativeGcMap; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 403 | bool printMe; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 404 | bool hasLoop; // Contains a loop |
| 405 | bool hasInvoke; // Contains an invoke instruction |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 406 | bool qdMode; // Compile for code size/compile time |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 407 | RegisterPool* regPool; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 408 | InstructionSet instructionSet; |
| 409 | /* Number of total regs used in the whole cUnit after SSA transformation */ |
| 410 | int numSSARegs; |
| 411 | /* Map SSA reg i to the base virtual register/subscript */ |
| 412 | GrowableList* ssaBaseVRegs; |
| 413 | GrowableList* ssaSubscripts; |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 414 | GrowableList* ssaStrings; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 415 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 416 | /* The following are new data structures to support SSA representations */ |
| 417 | /* Map original Dalvik virtual reg i to the current SSA name */ |
| 418 | int* vRegToSSAMap; // length == method->registersSize |
| 419 | int* SSALastDefs; // length == method->registersSize |
| 420 | ArenaBitVector* isConstantV; // length == numSSAReg |
| 421 | int* constantValues; // length == numSSAReg |
| 422 | int* phiAliasMap; // length == numSSAReg |
| 423 | MIR* phiList; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 424 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 425 | /* Use counts of ssa names */ |
| 426 | GrowableList useCounts; // Weighted by nesting depth |
| 427 | GrowableList rawUseCounts; // Not weighted |
buzbee | 239c4e7 | 2012-03-16 08:42:29 -0700 | [diff] [blame] | 428 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 429 | /* Optimization support */ |
| 430 | GrowableList loopHeaders; |
buzbee | 239c4e7 | 2012-03-16 08:42:29 -0700 | [diff] [blame] | 431 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 432 | /* Map SSA names to location */ |
| 433 | RegLocation* regLocation; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 434 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 435 | /* Keep track of Dalvik vReg to physical register mappings */ |
| 436 | PromotionMap* promotionMap; |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 437 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 438 | /* SSA name for Method* */ |
| 439 | int methodSReg; |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 440 | RegLocation methodLoc; // Describes location of method* |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 441 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 442 | int numReachableBlocks; |
| 443 | int numDalvikRegisters; // method->registersSize |
| 444 | BasicBlock* entryBlock; |
| 445 | BasicBlock* exitBlock; |
| 446 | BasicBlock* curBlock; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 447 | GrowableList dfsOrder; |
| 448 | GrowableList dfsPostOrder; |
| 449 | GrowableList domPostOrderTraversal; |
| 450 | GrowableList throwLaunchpads; |
| 451 | GrowableList suspendLaunchpads; |
| 452 | GrowableList intrinsicLaunchpads; |
| 453 | GrowableList compilerTemps; |
| 454 | int* iDomList; |
| 455 | ArenaBitVector* tryBlockAddr; |
| 456 | ArenaBitVector** defBlockMatrix; // numDalvikRegister x numBlocks |
| 457 | ArenaBitVector* tempBlockV; |
| 458 | ArenaBitVector* tempDalvikRegisterV; |
| 459 | ArenaBitVector* tempSSARegisterV; // numSSARegs |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 460 | int* tempSSABlockIdV; // working storage for Phi labels |
buzbee | a1da8a5 | 2012-07-09 14:00:21 -0700 | [diff] [blame] | 461 | LIR* blockLabelList; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 462 | /* |
| 463 | * Frame layout details. |
| 464 | * NOTE: for debug support it will be necessary to add a structure |
| 465 | * to map the Dalvik virtual registers to the promoted registers. |
| 466 | * NOTE: "num" fields are in 4-byte words, "Size" and "Offset" in bytes. |
| 467 | */ |
| 468 | int numIns; |
| 469 | int numOuts; |
| 470 | int numRegs; // Unlike numDalvikRegisters, does not include ins |
| 471 | int numCoreSpills; |
| 472 | int numFPSpills; |
| 473 | int numCompilerTemps; |
| 474 | int frameSize; |
| 475 | unsigned int coreSpillMask; |
| 476 | unsigned int fpSpillMask; |
| 477 | unsigned int attrs; |
| 478 | /* |
| 479 | * CLEANUP/RESTRUCTURE: The code generation utilities don't have a built-in |
| 480 | * mechanism to propagate the original Dalvik opcode address to the |
| 481 | * associated generated instructions. For the trace compiler, this wasn't |
| 482 | * necessary because the interpreter handled all throws and debugging |
| 483 | * requests. For now we'll handle this by placing the Dalvik offset |
| 484 | * in the CompilationUnit struct before codegen for each instruction. |
| 485 | * The low-level LIR creation utilites will pull it from here. Should |
| 486 | * be rewritten. |
| 487 | */ |
| 488 | int currentDalvikOffset; |
| 489 | GrowableList switchTables; |
| 490 | GrowableList fillArrayData; |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 491 | const uint16_t* insns; |
| 492 | uint32_t insnsSize; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 493 | bool disableDataflow; // Skip dataflow analysis if possible |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 494 | SafeMap<unsigned int, BasicBlock*> blockMap; // FindBlock lookup cache |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 495 | SafeMap<unsigned int, unsigned int> blockIdMap; // Block collapse lookup cache |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 496 | SafeMap<unsigned int, LIR*> boundaryMap; // boundary lookup cache |
| 497 | int defCount; // Used to estimate number of SSA names |
Elliott Hughes | e52e49b | 2012-04-02 16:05:44 -0700 | [diff] [blame] | 498 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 499 | // If non-empty, apply optimizer/debug flags only to matching methods. |
| 500 | std::string compilerMethodMatch; |
| 501 | // Flips sense of compilerMethodMatch - apply flags if doesn't match. |
| 502 | bool compilerFlipMatch; |
| 503 | ArenaMemBlock* arenaHead; |
| 504 | ArenaMemBlock* currentArena; |
| 505 | int numArenaBlocks; |
| 506 | Memstats* mstats; |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 507 | Checkstats* checkstats; |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 508 | bool genBitcode; |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 509 | LLVMInfo* llvm_info; |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 510 | llvm::LLVMContext* context; |
| 511 | llvm::Module* module; |
| 512 | llvm::Function* func; |
| 513 | greenland::IntrinsicHelper* intrinsic_helper; |
| 514 | greenland::IRBuilder* irb; |
| 515 | llvm::BasicBlock* placeholderBB; |
| 516 | llvm::BasicBlock* entryBB; |
buzbee | 4be777b | 2012-07-12 14:38:18 -0700 | [diff] [blame] | 517 | llvm::BasicBlock* entryTargetBB; |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 518 | std::string bitcode_filename; |
| 519 | GrowableList llvmValues; |
| 520 | int32_t tempName; |
| 521 | SafeMap<llvm::BasicBlock*, LIR*> blockToLabelMap; // llvm bb -> LIR label |
| 522 | SafeMap<int32_t, llvm::BasicBlock*> idToBlockMap; // block id -> llvm bb |
| 523 | SafeMap<llvm::Value*, RegLocation> locMap; // llvm Value to loc rec |
buzbee | b03f487 | 2012-06-11 15:22:11 -0700 | [diff] [blame] | 524 | int numShadowFrameEntries; |
| 525 | int* shadowMap; |
buzbee | 0967a25 | 2012-09-14 10:43:54 -0700 | [diff] [blame] | 526 | std::set<llvm::BasicBlock*> llvmBlocks; |
buzbee | 3d66194 | 2012-03-14 17:37:27 -0700 | [diff] [blame] | 527 | #ifndef NDEBUG |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 528 | /* |
| 529 | * Sanity checking for the register temp tracking. The same ssa |
| 530 | * name should never be associated with one temp register per |
| 531 | * instruction compilation. |
| 532 | */ |
| 533 | int liveSReg; |
buzbee | 3d66194 | 2012-03-14 17:37:27 -0700 | [diff] [blame] | 534 | #endif |
buzbee | 6459e7c | 2012-10-02 14:42:41 -0700 | [diff] [blame] | 535 | std::set<uint32_t> catches; |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 536 | int* opcodeCount; // Count Dalvik opcodes for tuning |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 537 | }; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 538 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 539 | struct SwitchTable { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 540 | int offset; |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 541 | const uint16_t* table; // Original dex table |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 542 | int vaddr; // Dalvik offset of switch opcode |
| 543 | LIR* anchor; // Reference instruction for relative offsets |
| 544 | LIR** targets; // Array of case targets |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 545 | }; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 546 | |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 547 | struct FillArrayData { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 548 | int offset; |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 549 | const uint16_t* table; // Original dex table |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 550 | int size; |
| 551 | int vaddr; // Dalvik offset of FILL_ARRAY_DATA opcode |
Elliott Hughes | 719ace4 | 2012-03-09 18:06:03 -0800 | [diff] [blame] | 552 | }; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 553 | |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 554 | #define MAX_PATTERN_LEN 5 |
| 555 | |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 556 | struct CodePattern { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 557 | const Instruction::Code opcodes[MAX_PATTERN_LEN]; |
| 558 | const SpecialCaseHandler handlerCode; |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 559 | }; |
| 560 | |
| 561 | static const CodePattern specialPatterns[] = { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 562 | {{Instruction::RETURN_VOID}, kNullMethod}, |
| 563 | {{Instruction::CONST, Instruction::RETURN}, kConstFunction}, |
| 564 | {{Instruction::CONST_4, Instruction::RETURN}, kConstFunction}, |
| 565 | {{Instruction::CONST_4, Instruction::RETURN_OBJECT}, kConstFunction}, |
| 566 | {{Instruction::CONST_16, Instruction::RETURN}, kConstFunction}, |
| 567 | {{Instruction::IGET, Instruction:: RETURN}, kIGet}, |
| 568 | {{Instruction::IGET_BOOLEAN, Instruction::RETURN}, kIGetBoolean}, |
| 569 | {{Instruction::IGET_OBJECT, Instruction::RETURN_OBJECT}, kIGetObject}, |
| 570 | {{Instruction::IGET_BYTE, Instruction::RETURN}, kIGetByte}, |
| 571 | {{Instruction::IGET_CHAR, Instruction::RETURN}, kIGetChar}, |
| 572 | {{Instruction::IGET_SHORT, Instruction::RETURN}, kIGetShort}, |
| 573 | {{Instruction::IGET_WIDE, Instruction::RETURN_WIDE}, kIGetWide}, |
| 574 | {{Instruction::IPUT, Instruction::RETURN_VOID}, kIPut}, |
| 575 | {{Instruction::IPUT_BOOLEAN, Instruction::RETURN_VOID}, kIPutBoolean}, |
| 576 | {{Instruction::IPUT_OBJECT, Instruction::RETURN_VOID}, kIPutObject}, |
| 577 | {{Instruction::IPUT_BYTE, Instruction::RETURN_VOID}, kIPutByte}, |
| 578 | {{Instruction::IPUT_CHAR, Instruction::RETURN_VOID}, kIPutChar}, |
| 579 | {{Instruction::IPUT_SHORT, Instruction::RETURN_VOID}, kIPutShort}, |
| 580 | {{Instruction::IPUT_WIDE, Instruction::RETURN_VOID}, kIPutWide}, |
| 581 | {{Instruction::RETURN}, kIdentity}, |
| 582 | {{Instruction::RETURN_OBJECT}, kIdentity}, |
| 583 | {{Instruction::RETURN_WIDE}, kIdentity}, |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 584 | }; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 585 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 586 | BasicBlock* NewMemBB(CompilationUnit* cUnit, BBType blockType, int blockId); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 587 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 588 | void AppendMIR(BasicBlock* bb, MIR* mir); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 589 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 590 | void PrependMIR(BasicBlock* bb, MIR* mir); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 591 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 592 | void InsertMIRAfter(BasicBlock* bb, MIR* currentMIR, MIR* newMIR); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 593 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 594 | void AppendLIR(CompilationUnit* cUnit, LIR* lir); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 595 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 596 | void InsertLIRBefore(LIR* currentLIR, LIR* newLIR); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 597 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 598 | void InsertLIRAfter(LIR* currentLIR, LIR* newLIR); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 599 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 600 | MIR* FindMoveResult(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 601 | /* Debug Utilities */ |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame^] | 602 | void DumpCompilationUnit(CompilationUnit* cUnit); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 603 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 604 | } // namespace art |
| 605 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 606 | #endif // ART_SRC_COMPILER_COMPILER_IR_H_ |