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 | /* |
| 18 | * This file contains codegen for the Thumb2 ISA and is intended to be |
| 19 | * includes by: |
| 20 | * |
| 21 | * Codegen-$(TARGET_ARCH_VARIANT).c |
| 22 | * |
| 23 | */ |
| 24 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 25 | #include "oat_compilation_unit.h" |
| 26 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 27 | namespace art { |
| 28 | |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame^] | 29 | /* Return a RegLocation that describes an in-register argument */ |
| 30 | RegLocation argLoc(CompilationUnit* cUnit, RegLocation loc, int sReg) |
| 31 | { |
| 32 | loc.location = kLocPhysReg; |
| 33 | int base = SRegToVReg(cUnit, sReg) - cUnit->numRegs; |
| 34 | loc.sRegLow = sReg; |
| 35 | loc.lowReg = rARG1 + base; |
| 36 | loc.home = true; |
| 37 | if (loc.wide) { |
| 38 | loc.highReg = loc.lowReg + 1; |
| 39 | oatLockTemp(cUnit, loc.lowReg); |
| 40 | oatLockTemp(cUnit, loc.highReg); |
| 41 | } else { |
| 42 | oatLockTemp(cUnit, loc.lowReg); |
| 43 | } |
| 44 | return loc; |
| 45 | } |
| 46 | |
| 47 | /* Find the next MIR, which may be in a following basic block */ |
| 48 | MIR* getNextMir(CompilationUnit* cUnit, BasicBlock** pBb, MIR* mir) |
| 49 | { |
| 50 | BasicBlock* bb = *pBb; |
| 51 | MIR* origMir = mir; |
| 52 | while (bb != NULL) { |
| 53 | if (mir != NULL) { |
| 54 | mir = mir->next; |
| 55 | } |
| 56 | if (mir != NULL) { |
| 57 | return mir; |
| 58 | } else { |
| 59 | bb = bb->fallThrough; |
| 60 | *pBb = bb; |
| 61 | if (bb) { |
| 62 | mir = bb->firstMIRInsn; |
| 63 | if (mir != NULL) { |
| 64 | return mir; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | return origMir; |
| 70 | } |
| 71 | |
| 72 | /* Used for the "printMe" listing */ |
| 73 | void genPrintLabel(CompilationUnit *cUnit, MIR* mir) |
| 74 | { |
| 75 | LIR* boundaryLIR; |
| 76 | /* Mark the beginning of a Dalvik instruction for line tracking */ |
| 77 | char* instStr = cUnit->printMe ? |
| 78 | oatGetDalvikDisassembly(cUnit, mir->dalvikInsn, "") : NULL; |
| 79 | boundaryLIR = newLIR1(cUnit, kPseudoDalvikByteCodeBoundary, |
| 80 | (intptr_t) instStr); |
| 81 | cUnit->boundaryMap.insert(std::make_pair(mir->offset, |
| 82 | (LIR*)boundaryLIR)); |
| 83 | /* Don't generate the SSA annotation unless verbose mode is on */ |
| 84 | if (cUnit->printMe && mir->ssaRep) { |
| 85 | char* ssaString = oatGetSSAString(cUnit, mir->ssaRep); |
| 86 | newLIR1(cUnit, kPseudoSSARep, (int) ssaString); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | MIR* specialIGet(CompilationUnit* cUnit, BasicBlock** bb, MIR* mir, |
| 91 | OpSize size, bool longOrDouble, bool isObject) |
| 92 | { |
| 93 | int fieldOffset; |
| 94 | bool isVolatile; |
| 95 | uint32_t fieldIdx = mir->dalvikInsn.vC; |
| 96 | bool fastPath = fastInstance(cUnit, fieldIdx, fieldOffset, isVolatile, |
| 97 | false); |
| 98 | if (!fastPath) { |
| 99 | return NULL; |
| 100 | } |
| 101 | mir->optimizationFlags |= MIR_IGNORE_NULL_CHECK; |
| 102 | genPrintLabel(cUnit, mir); |
| 103 | RegLocation rlObj = oatGetSrc(cUnit, mir, 0); |
| 104 | rlObj = argLoc(cUnit, rlObj, mir->ssaRep->uses[0]); |
| 105 | RegLocation rlDest; |
| 106 | if (longOrDouble) { |
| 107 | rlDest = oatGetReturnWide(cUnit, false); |
| 108 | } else { |
| 109 | rlDest = oatGetReturn(cUnit, false); |
| 110 | } |
| 111 | genIGet(cUnit, mir, size, rlDest, rlObj, longOrDouble, isObject); |
| 112 | return getNextMir(cUnit, bb, mir); |
| 113 | } |
| 114 | |
| 115 | MIR* specialIPut(CompilationUnit* cUnit, BasicBlock** bb, MIR* mir, |
| 116 | OpSize size, bool longOrDouble, bool isObject) |
| 117 | { |
| 118 | int fieldOffset; |
| 119 | bool isVolatile; |
| 120 | uint32_t fieldIdx = mir->dalvikInsn.vC; |
| 121 | bool fastPath = fastInstance(cUnit, fieldIdx, fieldOffset, isVolatile, |
| 122 | false); |
| 123 | if (!fastPath) { |
| 124 | return NULL; |
| 125 | } |
| 126 | mir->optimizationFlags |= MIR_IGNORE_NULL_CHECK; |
| 127 | genPrintLabel(cUnit, mir); |
| 128 | RegLocation rlSrc; |
| 129 | RegLocation rlObj; |
| 130 | int sSreg = mir->ssaRep->uses[0]; |
| 131 | int oSreg; |
| 132 | if (longOrDouble) { |
| 133 | rlSrc = oatGetSrcWide(cUnit, mir, 0, 1); |
| 134 | rlObj = oatGetSrc(cUnit, mir, 2); |
| 135 | oSreg = mir->ssaRep->uses[2]; |
| 136 | } else { |
| 137 | rlSrc = oatGetSrc(cUnit, mir, 0); |
| 138 | rlObj = oatGetSrc(cUnit, mir, 1); |
| 139 | oSreg = mir->ssaRep->uses[1]; |
| 140 | } |
| 141 | rlSrc = argLoc(cUnit, rlSrc, sSreg); |
| 142 | rlObj = argLoc(cUnit, rlObj, oSreg); |
| 143 | genIPut(cUnit, mir, size, rlSrc, rlObj, longOrDouble, isObject); |
| 144 | return getNextMir(cUnit, bb, mir); |
| 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Special-case code genration for simple non-throwing leaf methods. |
| 149 | */ |
| 150 | void genSpecialCase(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir, |
| 151 | SpecialCaseHandler specialCase) |
| 152 | { |
| 153 | cUnit->currentDalvikOffset = mir->offset; |
| 154 | MIR* nextMir = NULL; |
| 155 | switch(specialCase) { |
| 156 | case kNullMethod: |
| 157 | DCHECK(mir->dalvikInsn.opcode == Instruction::RETURN_VOID); |
| 158 | nextMir = mir; |
| 159 | break; |
| 160 | case kConstFunction: |
| 161 | genPrintLabel(cUnit, mir); |
| 162 | loadConstant(cUnit, rRET0, mir->dalvikInsn.vB); |
| 163 | nextMir = getNextMir(cUnit, &bb, mir); |
| 164 | break; |
| 165 | case kIGet: |
| 166 | nextMir = specialIGet(cUnit, &bb, mir, kWord, false, false); |
| 167 | break;; |
| 168 | case kIGetBoolean: |
| 169 | case kIGetByte: |
| 170 | nextMir = specialIGet(cUnit, &bb, mir, kUnsignedByte, false, false); |
| 171 | break;; |
| 172 | case kIGetObject: |
| 173 | nextMir = specialIGet(cUnit, &bb, mir, kWord, false, true); |
| 174 | break;; |
| 175 | case kIGetChar: |
| 176 | nextMir = specialIGet(cUnit, &bb, mir, kUnsignedHalf, false, false); |
| 177 | break;; |
| 178 | case kIGetShort: |
| 179 | nextMir = specialIGet(cUnit, &bb, mir, kSignedHalf, false, false); |
| 180 | break;; |
| 181 | case kIGetWide: |
| 182 | nextMir = specialIGet(cUnit, &bb, mir, kLong, true, false); |
| 183 | break;; |
| 184 | case kIPut: |
| 185 | nextMir = specialIPut(cUnit, &bb, mir, kWord, false, false); |
| 186 | break;; |
| 187 | case kIPutBoolean: |
| 188 | case kIPutByte: |
| 189 | nextMir = specialIPut(cUnit, &bb, mir, kUnsignedByte, false, false); |
| 190 | break;; |
| 191 | case kIPutObject: |
| 192 | nextMir = specialIPut(cUnit, &bb, mir, kWord, false, true); |
| 193 | break;; |
| 194 | case kIPutChar: |
| 195 | nextMir = specialIPut(cUnit, &bb, mir, kUnsignedHalf, false, false); |
| 196 | break;; |
| 197 | case kIPutShort: |
| 198 | nextMir = specialIPut(cUnit, &bb, mir, kSignedHalf, false, false); |
| 199 | break;; |
| 200 | case kIPutWide: |
| 201 | nextMir = specialIPut(cUnit, &bb, mir, kLong, true, false); |
| 202 | break;; |
| 203 | default: |
| 204 | return; |
| 205 | } |
| 206 | if (nextMir != NULL) { |
| 207 | cUnit->currentDalvikOffset = nextMir->offset; |
| 208 | genPrintLabel(cUnit, nextMir); |
| 209 | newLIR1(cUnit, kThumbBx, rLR); |
| 210 | cUnit->coreSpillMask = 0; |
| 211 | cUnit->numCoreSpills = 0; |
| 212 | cUnit->fpSpillMask = 0; |
| 213 | cUnit->numFPSpills = 0; |
| 214 | cUnit->frameSize = 0; |
| 215 | cUnit->coreVmapTable.clear(); |
| 216 | cUnit->fpVmapTable.clear(); |
| 217 | } |
| 218 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 219 | |
| 220 | /* |
| 221 | * Generate a Thumb2 IT instruction, which can nullify up to |
| 222 | * four subsequent instructions based on a condition and its |
| 223 | * inverse. The condition applies to the first instruction, which |
| 224 | * is executed if the condition is met. The string "guide" consists |
| 225 | * of 0 to 3 chars, and applies to the 2nd through 4th instruction. |
| 226 | * A "T" means the instruction is executed if the condition is |
| 227 | * met, and an "E" means the instruction is executed if the condition |
| 228 | * is not met. |
| 229 | */ |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 230 | LIR* opIT(CompilationUnit* cUnit, ArmConditionCode code, const char* guide) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 231 | { |
| 232 | int mask; |
| 233 | int condBit = code & 1; |
| 234 | int altBit = condBit ^ 1; |
| 235 | int mask3 = 0; |
| 236 | int mask2 = 0; |
| 237 | int mask1 = 0; |
| 238 | |
| 239 | //Note: case fallthroughs intentional |
| 240 | switch(strlen(guide)) { |
| 241 | case 3: |
| 242 | mask1 = (guide[2] == 'T') ? condBit : altBit; |
| 243 | case 2: |
| 244 | mask2 = (guide[1] == 'T') ? condBit : altBit; |
| 245 | case 1: |
| 246 | mask3 = (guide[0] == 'T') ? condBit : altBit; |
| 247 | break; |
| 248 | case 0: |
| 249 | break; |
| 250 | default: |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 251 | LOG(FATAL) << "OAT: bad case in opIT"; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 252 | } |
| 253 | mask = (mask3 << 3) | (mask2 << 2) | (mask1 << 1) | |
| 254 | (1 << (3 - strlen(guide))); |
| 255 | return newLIR2(cUnit, kThumb2It, code, mask); |
| 256 | } |
| 257 | |
| 258 | /* |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 259 | * The sparse table in the literal pool is an array of <key,displacement> |
| 260 | * pairs. For each set, we'll load them as a pair using ldmia. |
| 261 | * This means that the register number of the temp we use for the key |
| 262 | * must be lower than the reg for the displacement. |
| 263 | * |
| 264 | * The test loop will look something like: |
| 265 | * |
| 266 | * adr rBase, <table> |
| 267 | * ldr rVal, [rSP, vRegOff] |
| 268 | * mov rIdx, #tableSize |
| 269 | * lp: |
| 270 | * ldmia rBase!, {rKey, rDisp} |
| 271 | * sub rIdx, #1 |
| 272 | * cmp rVal, rKey |
| 273 | * ifeq |
| 274 | * add rPC, rDisp ; This is the branch from which we compute displacement |
| 275 | * cbnz rIdx, lp |
| 276 | */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 277 | void genSparseSwitch(CompilationUnit* cUnit, MIR* mir, RegLocation rlSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 278 | { |
| 279 | const u2* table = cUnit->insns + mir->offset + mir->dalvikInsn.vB; |
| 280 | if (cUnit->printMe) { |
| 281 | dumpSparseSwitchTable(table); |
| 282 | } |
| 283 | // Add the table to the list - we'll process it later |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 284 | SwitchTable *tabRec = (SwitchTable *)oatNew(cUnit, sizeof(SwitchTable), |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 285 | true, kAllocData); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 286 | tabRec->table = table; |
| 287 | tabRec->vaddr = mir->offset; |
| 288 | int size = table[1]; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 289 | tabRec->targets = (LIR* *)oatNew(cUnit, size * sizeof(LIR*), true, |
| 290 | kAllocLIR); |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 291 | oatInsertGrowableList(cUnit, &cUnit->switchTables, (intptr_t)tabRec); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 292 | |
| 293 | // Get the switch value |
| 294 | rlSrc = loadValue(cUnit, rlSrc, kCoreReg); |
| 295 | int rBase = oatAllocTemp(cUnit); |
| 296 | /* Allocate key and disp temps */ |
| 297 | int rKey = oatAllocTemp(cUnit); |
| 298 | int rDisp = oatAllocTemp(cUnit); |
| 299 | // Make sure rKey's register number is less than rDisp's number for ldmia |
| 300 | if (rKey > rDisp) { |
| 301 | int tmp = rDisp; |
| 302 | rDisp = rKey; |
| 303 | rKey = tmp; |
| 304 | } |
| 305 | // Materialize a pointer to the switch table |
buzbee | 03fa263 | 2011-09-20 17:10:57 -0700 | [diff] [blame] | 306 | newLIR3(cUnit, kThumb2Adr, rBase, 0, (intptr_t)tabRec); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 307 | // Set up rIdx |
| 308 | int rIdx = oatAllocTemp(cUnit); |
| 309 | loadConstant(cUnit, rIdx, size); |
| 310 | // Establish loop branch target |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 311 | LIR* target = newLIR0(cUnit, kPseudoTargetLabel); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 312 | // Load next key/disp |
| 313 | newLIR2(cUnit, kThumb2LdmiaWB, rBase, (1 << rKey) | (1 << rDisp)); |
| 314 | opRegReg(cUnit, kOpCmp, rKey, rlSrc.lowReg); |
| 315 | // Go if match. NOTE: No instruction set switch here - must stay Thumb2 |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 316 | opIT(cUnit, kArmCondEq, ""); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 317 | LIR* switchBranch = newLIR1(cUnit, kThumb2AddPCR, rDisp); |
buzbee | c5159d5 | 2012-03-03 11:48:39 -0800 | [diff] [blame] | 318 | tabRec->anchor = switchBranch; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 319 | // Needs to use setflags encoding here |
| 320 | newLIR3(cUnit, kThumb2SubsRRI12, rIdx, rIdx, 1); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 321 | opCondBranch(cUnit, kCondNe, target); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 325 | void genPackedSwitch(CompilationUnit* cUnit, MIR* mir, RegLocation rlSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 326 | { |
| 327 | const u2* table = cUnit->insns + mir->offset + mir->dalvikInsn.vB; |
| 328 | if (cUnit->printMe) { |
| 329 | dumpPackedSwitchTable(table); |
| 330 | } |
| 331 | // Add the table to the list - we'll process it later |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 332 | SwitchTable *tabRec = (SwitchTable *)oatNew(cUnit, sizeof(SwitchTable), |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 333 | true, kAllocData); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 334 | tabRec->table = table; |
| 335 | tabRec->vaddr = mir->offset; |
| 336 | int size = table[1]; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 337 | tabRec->targets = (LIR* *)oatNew(cUnit, size * sizeof(LIR*), true, |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 338 | kAllocLIR); |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 339 | oatInsertGrowableList(cUnit, &cUnit->switchTables, (intptr_t)tabRec); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 340 | |
| 341 | // Get the switch value |
| 342 | rlSrc = loadValue(cUnit, rlSrc, kCoreReg); |
| 343 | int tableBase = oatAllocTemp(cUnit); |
| 344 | // Materialize a pointer to the switch table |
buzbee | 03fa263 | 2011-09-20 17:10:57 -0700 | [diff] [blame] | 345 | newLIR3(cUnit, kThumb2Adr, tableBase, 0, (intptr_t)tabRec); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 346 | int lowKey = s4FromSwitchData(&table[2]); |
| 347 | int keyReg; |
| 348 | // Remove the bias, if necessary |
| 349 | if (lowKey == 0) { |
| 350 | keyReg = rlSrc.lowReg; |
| 351 | } else { |
| 352 | keyReg = oatAllocTemp(cUnit); |
| 353 | opRegRegImm(cUnit, kOpSub, keyReg, rlSrc.lowReg, lowKey); |
| 354 | } |
| 355 | // Bounds check - if < 0 or >= size continue following switch |
| 356 | opRegImm(cUnit, kOpCmp, keyReg, size-1); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 357 | LIR* branchOver = opCondBranch(cUnit, kCondHi, NULL); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 358 | |
| 359 | // Load the displacement from the switch table |
| 360 | int dispReg = oatAllocTemp(cUnit); |
| 361 | loadBaseIndexed(cUnit, tableBase, keyReg, dispReg, 2, kWord); |
| 362 | |
| 363 | // ..and go! NOTE: No instruction set switch here - must stay Thumb2 |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 364 | LIR* switchBranch = newLIR1(cUnit, kThumb2AddPCR, dispReg); |
buzbee | c5159d5 | 2012-03-03 11:48:39 -0800 | [diff] [blame] | 365 | tabRec->anchor = switchBranch; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 366 | |
| 367 | /* branchOver target here */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 368 | LIR* target = newLIR0(cUnit, kPseudoTargetLabel); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 369 | branchOver->target = (LIR*)target; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | /* |
| 373 | * Array data table format: |
| 374 | * ushort ident = 0x0300 magic value |
| 375 | * ushort width width of each element in the table |
| 376 | * uint size number of elements in the table |
| 377 | * ubyte data[size*width] table of data values (may contain a single-byte |
| 378 | * padding at the end) |
| 379 | * |
| 380 | * Total size is 4+(width * size + 1)/2 16-bit code units. |
| 381 | */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 382 | void genFillArrayData(CompilationUnit* cUnit, MIR* mir, RegLocation rlSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 383 | { |
| 384 | const u2* table = cUnit->insns + mir->offset + mir->dalvikInsn.vB; |
| 385 | // Add the table to the list - we'll process it later |
| 386 | FillArrayData *tabRec = (FillArrayData *) |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 387 | oatNew(cUnit, sizeof(FillArrayData), true, kAllocData); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 388 | tabRec->table = table; |
| 389 | tabRec->vaddr = mir->offset; |
| 390 | u2 width = tabRec->table[1]; |
| 391 | u4 size = tabRec->table[2] | (((u4)tabRec->table[3]) << 16); |
| 392 | tabRec->size = (size * width) + 8; |
| 393 | |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 394 | oatInsertGrowableList(cUnit, &cUnit->fillArrayData, (intptr_t)tabRec); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 395 | |
| 396 | // Making a call - use explicit registers |
| 397 | oatFlushAllRegs(cUnit); /* Everything to home location */ |
| 398 | loadValueDirectFixed(cUnit, rlSrc, r0); |
| 399 | loadWordDisp(cUnit, rSELF, |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 400 | OFFSETOF_MEMBER(Thread, pHandleFillArrayDataFromCode), rLR); |
buzbee | e6d6196 | 2011-08-27 11:58:19 -0700 | [diff] [blame] | 401 | // Materialize a pointer to the fill data image |
buzbee | 03fa263 | 2011-09-20 17:10:57 -0700 | [diff] [blame] | 402 | newLIR3(cUnit, kThumb2Adr, r1, 0, (intptr_t)tabRec); |
Ian Rogers | ab2b55d | 2012-03-18 00:06:11 -0700 | [diff] [blame] | 403 | oatClobberCalleeSave(cUnit); |
| 404 | opReg(cUnit, kOpBlx, rLR); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 405 | } |
| 406 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 407 | void genNegFloat(CompilationUnit* cUnit, RegLocation rlDest, RegLocation rlSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 408 | { |
| 409 | RegLocation rlResult; |
| 410 | rlSrc = loadValue(cUnit, rlSrc, kFPReg); |
| 411 | rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true); |
| 412 | newLIR2(cUnit, kThumb2Vnegs, rlResult.lowReg, rlSrc.lowReg); |
| 413 | storeValue(cUnit, rlDest, rlResult); |
| 414 | } |
| 415 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 416 | void genNegDouble(CompilationUnit* cUnit, RegLocation rlDest, RegLocation rlSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 417 | { |
| 418 | RegLocation rlResult; |
| 419 | rlSrc = loadValueWide(cUnit, rlSrc, kFPReg); |
| 420 | rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true); |
| 421 | newLIR2(cUnit, kThumb2Vnegd, S2D(rlResult.lowReg, rlResult.highReg), |
| 422 | S2D(rlSrc.lowReg, rlSrc.highReg)); |
| 423 | storeValueWide(cUnit, rlDest, rlResult); |
| 424 | } |
| 425 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 426 | /* |
| 427 | * Handle simple case (thin lock) inline. If it's complicated, bail |
| 428 | * out to the heavyweight lock/unlock routines. We'll use dedicated |
| 429 | * registers here in order to be in the right position in case we |
| 430 | * to bail to dvm[Lock/Unlock]Object(self, object) |
| 431 | * |
| 432 | * r0 -> self pointer [arg0 for dvm[Lock/Unlock]Object |
| 433 | * r1 -> object [arg1 for dvm[Lock/Unlock]Object |
| 434 | * r2 -> intial contents of object->lock, later result of strex |
| 435 | * r3 -> self->threadId |
| 436 | * r12 -> allow to be used by utilities as general temp |
| 437 | * |
| 438 | * The result of the strex is 0 if we acquire the lock. |
| 439 | * |
| 440 | * See comments in Sync.c for the layout of the lock word. |
| 441 | * Of particular interest to this code is the test for the |
| 442 | * simple case - which we handle inline. For monitor enter, the |
| 443 | * simple case is thin lock, held by no-one. For monitor exit, |
| 444 | * the simple case is thin lock, held by the unlocking thread with |
| 445 | * a recurse count of 0. |
| 446 | * |
| 447 | * A minor complication is that there is a field in the lock word |
| 448 | * unrelated to locking: the hash state. This field must be ignored, but |
| 449 | * preserved. |
| 450 | * |
| 451 | */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 452 | void genMonitorEnter(CompilationUnit* cUnit, MIR* mir, RegLocation rlSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 453 | { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 454 | oatFlushAllRegs(cUnit); |
Elliott Hughes | 5f79133 | 2011-09-15 17:45:30 -0700 | [diff] [blame] | 455 | DCHECK_EQ(LW_SHAPE_THIN, 0); |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 456 | loadValueDirectFixed(cUnit, rlSrc, r0); // Get obj |
buzbee | 2e748f3 | 2011-08-29 21:02:19 -0700 | [diff] [blame] | 457 | oatLockCallTemps(cUnit); // Prepare for explicit register usage |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 458 | genNullCheck(cUnit, rlSrc.sRegLow, r0, mir); |
| 459 | loadWordDisp(cUnit, rSELF, Thread::ThinLockIdOffset().Int32Value(), r2); |
| 460 | newLIR3(cUnit, kThumb2Ldrex, r1, r0, |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 461 | Object::MonitorOffset().Int32Value() >> 2); // Get object->lock |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 462 | // Align owner |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 463 | opRegImm(cUnit, kOpLsl, r2, LW_LOCK_OWNER_SHIFT); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 464 | // Is lock unheld on lock or held by us (==threadId) on unlock? |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 465 | newLIR4(cUnit, kThumb2Bfi, r2, r1, 0, LW_LOCK_OWNER_SHIFT - 1); |
| 466 | newLIR3(cUnit, kThumb2Bfc, r1, LW_HASH_STATE_SHIFT, LW_LOCK_OWNER_SHIFT - 1); |
buzbee | 05eba36 | 2012-03-10 20:11:27 -0800 | [diff] [blame] | 467 | opRegImm(cUnit, kOpCmp, r1, 0); |
| 468 | opIT(cUnit, kArmCondEq, ""); |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 469 | newLIR4(cUnit, kThumb2Strex, r1, r2, r0, |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 470 | Object::MonitorOffset().Int32Value() >> 2); |
buzbee | 05eba36 | 2012-03-10 20:11:27 -0800 | [diff] [blame] | 471 | opRegImm(cUnit, kOpCmp, r1, 0); |
| 472 | opIT(cUnit, kArmCondNe, "T"); |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 473 | // Go expensive route - artLockObjectFromCode(self, obj); |
| 474 | loadWordDisp(cUnit, rSELF, OFFSETOF_MEMBER(Thread, pLockObjectFromCode), |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 475 | rLR); |
Ian Rogers | ab2b55d | 2012-03-18 00:06:11 -0700 | [diff] [blame] | 476 | oatClobberCalleeSave(cUnit); |
| 477 | opReg(cUnit, kOpBlx, rLR); |
buzbee | 05eba36 | 2012-03-10 20:11:27 -0800 | [diff] [blame] | 478 | oatGenMemBarrier(cUnit, kSY); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | /* |
| 482 | * For monitor unlock, we don't have to use ldrex/strex. Once |
| 483 | * we've determined that the lock is thin and that we own it with |
| 484 | * a zero recursion count, it's safe to punch it back to the |
| 485 | * initial, unlock thin state with a store word. |
| 486 | */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 487 | void genMonitorExit(CompilationUnit* cUnit, MIR* mir, RegLocation rlSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 488 | { |
Elliott Hughes | 5f79133 | 2011-09-15 17:45:30 -0700 | [diff] [blame] | 489 | DCHECK_EQ(LW_SHAPE_THIN, 0); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 490 | oatFlushAllRegs(cUnit); |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 491 | loadValueDirectFixed(cUnit, rlSrc, r0); // Get obj |
buzbee | 2e748f3 | 2011-08-29 21:02:19 -0700 | [diff] [blame] | 492 | oatLockCallTemps(cUnit); // Prepare for explicit register usage |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 493 | genNullCheck(cUnit, rlSrc.sRegLow, r0, mir); |
| 494 | loadWordDisp(cUnit, r0, Object::MonitorOffset().Int32Value(), r1); // Get lock |
| 495 | loadWordDisp(cUnit, rSELF, Thread::ThinLockIdOffset().Int32Value(), r2); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 496 | // Is lock unheld on lock or held by us (==threadId) on unlock? |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 497 | opRegRegImm(cUnit, kOpAnd, r3, r1, (LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT)); |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 498 | // Align owner |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 499 | opRegImm(cUnit, kOpLsl, r2, LW_LOCK_OWNER_SHIFT); |
| 500 | newLIR3(cUnit, kThumb2Bfc, r1, LW_HASH_STATE_SHIFT, LW_LOCK_OWNER_SHIFT - 1); |
| 501 | opRegReg(cUnit, kOpSub, r1, r2); |
buzbee | 05eba36 | 2012-03-10 20:11:27 -0800 | [diff] [blame] | 502 | opIT(cUnit, kArmCondEq, "EE"); |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 503 | storeWordDisp(cUnit, r0, Object::MonitorOffset().Int32Value(), r3); |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 504 | // Go expensive route - UnlockObjectFromCode(obj); |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 505 | loadWordDisp(cUnit, rSELF, OFFSETOF_MEMBER(Thread, pUnlockObjectFromCode), |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 506 | rLR); |
Ian Rogers | ab2b55d | 2012-03-18 00:06:11 -0700 | [diff] [blame] | 507 | oatClobberCalleeSave(cUnit); |
| 508 | opReg(cUnit, kOpBlx, rLR); |
buzbee | 05eba36 | 2012-03-10 20:11:27 -0800 | [diff] [blame] | 509 | oatGenMemBarrier(cUnit, kSY); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | /* |
| 513 | * 64-bit 3way compare function. |
| 514 | * mov rX, #-1 |
| 515 | * cmp op1hi, op2hi |
| 516 | * blt done |
| 517 | * bgt flip |
| 518 | * sub rX, op1lo, op2lo (treat as unsigned) |
| 519 | * beq done |
| 520 | * ite hi |
| 521 | * mov(hi) rX, #-1 |
| 522 | * mov(!hi) rX, #1 |
| 523 | * flip: |
| 524 | * neg rX |
| 525 | * done: |
| 526 | */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 527 | void genCmpLong(CompilationUnit* cUnit, MIR* mir, RegLocation rlDest, |
| 528 | RegLocation rlSrc1, RegLocation rlSrc2) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 529 | { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 530 | LIR* target1; |
| 531 | LIR* target2; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 532 | rlSrc1 = loadValueWide(cUnit, rlSrc1, kCoreReg); |
| 533 | rlSrc2 = loadValueWide(cUnit, rlSrc2, kCoreReg); |
buzbee | b29e4d1 | 2011-09-26 15:05:48 -0700 | [diff] [blame] | 534 | int tReg = oatAllocTemp(cUnit); |
| 535 | loadConstant(cUnit, tReg, -1); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 536 | opRegReg(cUnit, kOpCmp, rlSrc1.highReg, rlSrc2.highReg); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 537 | LIR* branch1 = opCondBranch(cUnit, kCondLt, NULL); |
| 538 | LIR* branch2 = opCondBranch(cUnit, kCondGt, NULL); |
buzbee | b29e4d1 | 2011-09-26 15:05:48 -0700 | [diff] [blame] | 539 | opRegRegReg(cUnit, kOpSub, tReg, rlSrc1.lowReg, rlSrc2.lowReg); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 540 | LIR* branch3 = opCondBranch(cUnit, kCondEq, NULL); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 541 | |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 542 | opIT(cUnit, kArmCondHi, "E"); |
buzbee | b29e4d1 | 2011-09-26 15:05:48 -0700 | [diff] [blame] | 543 | newLIR2(cUnit, kThumb2MovImmShift, tReg, modifiedImmediate(-1)); |
| 544 | loadConstant(cUnit, tReg, 1); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 545 | genBarrier(cUnit); |
| 546 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 547 | target2 = newLIR0(cUnit, kPseudoTargetLabel); |
buzbee | b29e4d1 | 2011-09-26 15:05:48 -0700 | [diff] [blame] | 548 | opRegReg(cUnit, kOpNeg, tReg, tReg); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 549 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 550 | target1 = newLIR0(cUnit, kPseudoTargetLabel); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 551 | |
buzbee | b29e4d1 | 2011-09-26 15:05:48 -0700 | [diff] [blame] | 552 | RegLocation rlTemp = LOC_C_RETURN; // Just using as template, will change |
| 553 | rlTemp.lowReg = tReg; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 554 | storeValue(cUnit, rlDest, rlTemp); |
buzbee | b29e4d1 | 2011-09-26 15:05:48 -0700 | [diff] [blame] | 555 | oatFreeTemp(cUnit, tReg); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 556 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 557 | branch1->target = (LIR*)target1; |
| 558 | branch2->target = (LIR*)target2; |
| 559 | branch3->target = branch1->target; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 560 | } |
| 561 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 562 | /* |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 563 | * Generate a register comparison to an immediate and branch. Caller |
| 564 | * is responsible for setting branch target field. |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 565 | */ |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 566 | LIR* opCmpImmBranch(CompilationUnit* cUnit, ConditionCode cond, int reg, |
| 567 | int checkValue, LIR* target) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 568 | { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 569 | LIR* branch; |
| 570 | int modImm; |
| 571 | ArmConditionCode armCond = oatArmConditionEncoding(cond); |
| 572 | if ((LOWREG(reg)) && (checkValue == 0) && |
| 573 | ((armCond == kArmCondEq) || (armCond == kArmCondNe))) { |
| 574 | branch = newLIR2(cUnit, |
| 575 | (armCond == kArmCondEq) ? kThumb2Cbz : kThumb2Cbnz, |
| 576 | reg, 0); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 577 | } else { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 578 | modImm = modifiedImmediate(checkValue); |
| 579 | if (LOWREG(reg) && ((checkValue & 0xff) == checkValue)) { |
| 580 | newLIR2(cUnit, kThumbCmpRI8, reg, checkValue); |
| 581 | } else if (modImm >= 0) { |
| 582 | newLIR2(cUnit, kThumb2CmpRI8, reg, modImm); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 583 | } else { |
buzbee | 58f9274 | 2011-10-01 11:22:17 -0700 | [diff] [blame] | 584 | int tReg = oatAllocTemp(cUnit); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 585 | loadConstant(cUnit, tReg, checkValue); |
| 586 | opRegReg(cUnit, kOpCmp, reg, tReg); |
buzbee | 58f9274 | 2011-10-01 11:22:17 -0700 | [diff] [blame] | 587 | } |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 588 | branch = newLIR2(cUnit, kThumbBCond, 0, armCond); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 589 | } |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 590 | branch->target = target; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 591 | return branch; |
| 592 | } |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 593 | LIR* opRegCopyNoInsert(CompilationUnit* cUnit, int rDest, int rSrc) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 594 | { |
| 595 | LIR* res; |
| 596 | ArmOpcode opcode; |
| 597 | if (FPREG(rDest) || FPREG(rSrc)) |
| 598 | return fpRegCopy(cUnit, rDest, rSrc); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 599 | if (LOWREG(rDest) && LOWREG(rSrc)) |
| 600 | opcode = kThumbMovRR; |
| 601 | else if (!LOWREG(rDest) && !LOWREG(rSrc)) |
| 602 | opcode = kThumbMovRR_H2H; |
| 603 | else if (LOWREG(rDest)) |
| 604 | opcode = kThumbMovRR_H2L; |
| 605 | else |
| 606 | opcode = kThumbMovRR_L2H; |
buzbee | a2ebdd7 | 2012-03-04 14:57:06 -0800 | [diff] [blame] | 607 | res = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, rDest, rSrc); |
buzbee | 86a4bce | 2012-03-06 18:15:00 -0800 | [diff] [blame] | 608 | if (!(cUnit->disableOpt & (1 << kSafeOptimizations)) && rDest == rSrc) { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 609 | res->flags.isNop = true; |
| 610 | } |
| 611 | return res; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 612 | } |
| 613 | |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 614 | LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 615 | { |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 616 | LIR* res = opRegCopyNoInsert(cUnit, rDest, rSrc); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 617 | oatAppendLIR(cUnit, (LIR*)res); |
| 618 | return res; |
| 619 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 620 | |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 621 | void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 622 | int srcLo, int srcHi) |
| 623 | { |
| 624 | bool destFP = FPREG(destLo) && FPREG(destHi); |
| 625 | bool srcFP = FPREG(srcLo) && FPREG(srcHi); |
| 626 | DCHECK_EQ(FPREG(srcLo), FPREG(srcHi)); |
| 627 | DCHECK_EQ(FPREG(destLo), FPREG(destHi)); |
| 628 | if (destFP) { |
| 629 | if (srcFP) { |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 630 | opRegCopy(cUnit, S2D(destLo, destHi), S2D(srcLo, srcHi)); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 631 | } else { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 632 | newLIR3(cUnit, kThumb2Fmdrr, S2D(destLo, destHi), srcLo, srcHi); |
| 633 | } |
| 634 | } else { |
| 635 | if (srcFP) { |
| 636 | newLIR3(cUnit, kThumb2Fmrrd, destLo, destHi, S2D(srcLo, srcHi)); |
| 637 | } else { |
| 638 | // Handle overlap |
| 639 | if (srcHi == destLo) { |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 640 | opRegCopy(cUnit, destHi, srcHi); |
| 641 | opRegCopy(cUnit, destLo, srcLo); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 642 | } else { |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 643 | opRegCopy(cUnit, destLo, srcLo); |
| 644 | opRegCopy(cUnit, destHi, srcHi); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 645 | } |
| 646 | } |
| 647 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 648 | } |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 649 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 650 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 651 | } // namespace art |