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 | |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 17 | #include "codegen_util.h" |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame^] | 18 | #include "compiler/compiler_ir.h" |
| 19 | #include "ralloc_util.h" |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 20 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 21 | namespace art { |
| 22 | |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 23 | /* This file contains target-independent codegen and support. */ |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 24 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 25 | /* |
| 26 | * Load an immediate value into a fixed or temp register. Target |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 27 | * register is clobbered, and marked in_use. |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 28 | */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 29 | LIR* Codegen::LoadConstant(CompilationUnit* cu, int r_dest, int value) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 30 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 31 | if (IsTemp(cu, r_dest)) { |
| 32 | Clobber(cu, r_dest); |
| 33 | MarkInUse(cu, r_dest); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 34 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 35 | return LoadConstantNoClobber(cu, r_dest, value); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 36 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 37 | |
buzbee | 5f61f67 | 2012-11-28 17:22:17 -0800 | [diff] [blame] | 38 | /* |
| 39 | * Temporary workaround for Issue 7250540. If we're loading a constant zero into a |
| 40 | * promoted floating point register, also copy a zero into the int/ref identity of |
| 41 | * that sreg. |
| 42 | */ |
buzbee | 7da142f | 2012-11-29 16:33:42 -0800 | [diff] [blame] | 43 | void Codegen::Workaround7250540(CompilationUnit* cu, RegLocation rl_dest, int zero_reg) |
buzbee | 5f61f67 | 2012-11-28 17:22:17 -0800 | [diff] [blame] | 44 | { |
buzbee | 7da142f | 2012-11-29 16:33:42 -0800 | [diff] [blame] | 45 | if (rl_dest.fp) { |
buzbee | 5f61f67 | 2012-11-28 17:22:17 -0800 | [diff] [blame] | 46 | int pmap_index = SRegToPMap(cu, rl_dest.s_reg_low); |
| 47 | if (cu->promotion_map[pmap_index].fp_location == kLocPhysReg) { |
buzbee | 7da142f | 2012-11-29 16:33:42 -0800 | [diff] [blame] | 48 | // Now, determine if this vreg is ever used as a reference. If not, we're done. |
buzbee | d850621 | 2012-12-20 14:15:05 -0800 | [diff] [blame] | 49 | if (!cu->gen_bitcode) { |
| 50 | // TUNING: We no longer have this info for QuickGBC - assume the worst |
| 51 | bool used_as_reference = false; |
| 52 | int base_vreg = SRegToVReg(cu, rl_dest.s_reg_low); |
| 53 | for (int i = 0; !used_as_reference && (i < cu->num_ssa_regs); i++) { |
| 54 | if (SRegToVReg(cu, cu->reg_location[i].s_reg_low) == base_vreg) { |
| 55 | used_as_reference |= cu->reg_location[i].ref; |
| 56 | } |
buzbee | 7da142f | 2012-11-29 16:33:42 -0800 | [diff] [blame] | 57 | } |
buzbee | d850621 | 2012-12-20 14:15:05 -0800 | [diff] [blame] | 58 | if (!used_as_reference) { |
| 59 | return; |
| 60 | } |
buzbee | 7da142f | 2012-11-29 16:33:42 -0800 | [diff] [blame] | 61 | } |
buzbee | 5f61f67 | 2012-11-28 17:22:17 -0800 | [diff] [blame] | 62 | if (cu->promotion_map[pmap_index].core_location == kLocPhysReg) { |
| 63 | // Promoted - just copy in a zero |
buzbee | 7da142f | 2012-11-29 16:33:42 -0800 | [diff] [blame] | 64 | OpRegCopy(cu, cu->promotion_map[pmap_index].core_reg, zero_reg); |
buzbee | 5f61f67 | 2012-11-28 17:22:17 -0800 | [diff] [blame] | 65 | } else { |
| 66 | // Lives in the frame, need to store. |
buzbee | 7da142f | 2012-11-29 16:33:42 -0800 | [diff] [blame] | 67 | StoreBaseDisp(cu, TargetReg(kSp), SRegOffset(cu, rl_dest.s_reg_low), zero_reg, kWord); |
buzbee | 5f61f67 | 2012-11-28 17:22:17 -0800 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 73 | /* Load a word at base + displacement. Displacement must be word multiple */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 74 | LIR* Codegen::LoadWordDisp(CompilationUnit* cu, int rBase, int displacement, int r_dest) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 75 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 76 | return LoadBaseDisp(cu, rBase, displacement, r_dest, kWord, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 77 | INVALID_SREG); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 78 | } |
| 79 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 80 | LIR* Codegen::StoreWordDisp(CompilationUnit* cu, int rBase, int displacement, int r_src) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 81 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 82 | return StoreBaseDisp(cu, rBase, displacement, r_src, kWord); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* |
| 86 | * Load a Dalvik register into a physical register. Take care when |
| 87 | * using this routine, as it doesn't perform any bookkeeping regarding |
| 88 | * register liveness. That is the responsibility of the caller. |
| 89 | */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 90 | void Codegen::LoadValueDirect(CompilationUnit* cu, RegLocation rl_src, int r_dest) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 91 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 92 | rl_src = UpdateLoc(cu, rl_src); |
| 93 | if (rl_src.location == kLocPhysReg) { |
| 94 | OpRegCopy(cu, r_dest, rl_src.low_reg); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 95 | } else { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 96 | DCHECK((rl_src.location == kLocDalvikFrame) || |
| 97 | (rl_src.location == kLocCompilerTemp)); |
buzbee | e6285f9 | 2012-12-06 15:57:46 -0800 | [diff] [blame] | 98 | if (rl_src.is_const && InexpensiveConstant(r_dest, cu->constant_values[rl_src.orig_sreg])) { |
| 99 | LoadConstantNoClobber(cu, r_dest, cu->constant_values[rl_src.orig_sreg]); |
| 100 | } else { |
| 101 | LoadWordDisp(cu, TargetReg(kSp), SRegOffset(cu, rl_src.s_reg_low), r_dest); |
| 102 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 103 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame] | 107 | * Similar to LoadValueDirect, but clobbers and allocates the target |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 108 | * register. Should be used when loading to a fixed register (for example, |
| 109 | * loading arguments to an out of line call. |
| 110 | */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 111 | void Codegen::LoadValueDirectFixed(CompilationUnit* cu, RegLocation rl_src, int r_dest) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 112 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 113 | Clobber(cu, r_dest); |
| 114 | MarkInUse(cu, r_dest); |
| 115 | LoadValueDirect(cu, rl_src, r_dest); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | /* |
| 119 | * Load a Dalvik register pair into a physical register[s]. Take care when |
| 120 | * using this routine, as it doesn't perform any bookkeeping regarding |
| 121 | * register liveness. That is the responsibility of the caller. |
| 122 | */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 123 | void Codegen::LoadValueDirectWide(CompilationUnit* cu, RegLocation rl_src, int reg_lo, |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 124 | int reg_hi) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 125 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 126 | rl_src = UpdateLocWide(cu, rl_src); |
| 127 | if (rl_src.location == kLocPhysReg) { |
| 128 | OpRegCopyWide(cu, reg_lo, reg_hi, rl_src.low_reg, rl_src.high_reg); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 129 | } else { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 130 | DCHECK((rl_src.location == kLocDalvikFrame) || |
| 131 | (rl_src.location == kLocCompilerTemp)); |
| 132 | LoadBaseDispWide(cu, TargetReg(kSp), SRegOffset(cu, rl_src.s_reg_low), |
| 133 | reg_lo, reg_hi, INVALID_SREG); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 134 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /* |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame] | 138 | * Similar to LoadValueDirect, but clobbers and allocates the target |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 139 | * registers. Should be used when loading to a fixed registers (for example, |
| 140 | * loading arguments to an out of line call. |
| 141 | */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 142 | void Codegen::LoadValueDirectWideFixed(CompilationUnit* cu, RegLocation rl_src, int reg_lo, |
| 143 | int reg_hi) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 144 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 145 | Clobber(cu, reg_lo); |
| 146 | Clobber(cu, reg_hi); |
| 147 | MarkInUse(cu, reg_lo); |
| 148 | MarkInUse(cu, reg_hi); |
| 149 | LoadValueDirectWide(cu, rl_src, reg_lo, reg_hi); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 150 | } |
| 151 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 152 | RegLocation Codegen::LoadValue(CompilationUnit* cu, RegLocation rl_src, RegisterClass op_kind) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 153 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 154 | rl_src = EvalLoc(cu, rl_src, op_kind, false); |
| 155 | if (rl_src.location != kLocPhysReg) { |
| 156 | DCHECK((rl_src.location == kLocDalvikFrame) || |
| 157 | (rl_src.location == kLocCompilerTemp)); |
| 158 | LoadValueDirect(cu, rl_src, rl_src.low_reg); |
| 159 | rl_src.location = kLocPhysReg; |
| 160 | MarkLive(cu, rl_src.low_reg, rl_src.s_reg_low); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 161 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 162 | return rl_src; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 163 | } |
| 164 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 165 | void Codegen::StoreValue(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 166 | { |
buzbee | 3d66194 | 2012-03-14 17:37:27 -0700 | [diff] [blame] | 167 | #ifndef NDEBUG |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 168 | /* |
| 169 | * Sanity checking - should never try to store to the same |
| 170 | * ssa name during the compilation of a single instruction |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame] | 171 | * without an intervening ClobberSReg(). |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 172 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 173 | DCHECK((cu->live_sreg == INVALID_SREG) || |
| 174 | (rl_dest.s_reg_low != cu->live_sreg)); |
| 175 | cu->live_sreg = rl_dest.s_reg_low; |
buzbee | 3d66194 | 2012-03-14 17:37:27 -0700 | [diff] [blame] | 176 | #endif |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 177 | LIR* def_start; |
| 178 | LIR* def_end; |
| 179 | DCHECK(!rl_dest.wide); |
| 180 | DCHECK(!rl_src.wide); |
| 181 | rl_src = UpdateLoc(cu, rl_src); |
| 182 | rl_dest = UpdateLoc(cu, rl_dest); |
| 183 | if (rl_src.location == kLocPhysReg) { |
| 184 | if (IsLive(cu, rl_src.low_reg) || |
| 185 | IsPromoted(cu, rl_src.low_reg) || |
| 186 | (rl_dest.location == kLocPhysReg)) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 187 | // Src is live/promoted or Dest has assigned reg. |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 188 | rl_dest = EvalLoc(cu, rl_dest, kAnyReg, false); |
| 189 | OpRegCopy(cu, rl_dest.low_reg, rl_src.low_reg); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 190 | } else { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 191 | // Just re-assign the registers. Dest gets Src's regs |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 192 | rl_dest.low_reg = rl_src.low_reg; |
| 193 | Clobber(cu, rl_src.low_reg); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 194 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 195 | } else { |
| 196 | // Load Src either into promoted Dest or temps allocated for Dest |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 197 | rl_dest = EvalLoc(cu, rl_dest, kAnyReg, false); |
| 198 | LoadValueDirect(cu, rl_src, rl_dest.low_reg); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 199 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 200 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 201 | // Dest is now live and dirty (until/if we flush it to home location) |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 202 | MarkLive(cu, rl_dest.low_reg, rl_dest.s_reg_low); |
| 203 | MarkDirty(cu, rl_dest); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 204 | |
| 205 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 206 | ResetDefLoc(cu, rl_dest); |
| 207 | if (IsDirty(cu, rl_dest.low_reg) && |
| 208 | oat_live_out(cu, rl_dest.s_reg_low)) { |
| 209 | def_start = cu->last_lir_insn; |
| 210 | StoreBaseDisp(cu, TargetReg(kSp), SRegOffset(cu, rl_dest.s_reg_low), |
| 211 | rl_dest.low_reg, kWord); |
| 212 | MarkClean(cu, rl_dest); |
| 213 | def_end = cu->last_lir_insn; |
buzbee | 5f61f67 | 2012-11-28 17:22:17 -0800 | [diff] [blame] | 214 | if (!rl_dest.ref) { |
| 215 | // Exclude references from store elimination |
| 216 | MarkDef(cu, rl_dest, def_start, def_end); |
| 217 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 218 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 219 | } |
| 220 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 221 | RegLocation Codegen::LoadValueWide(CompilationUnit* cu, RegLocation rl_src, RegisterClass op_kind) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 222 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 223 | DCHECK(rl_src.wide); |
| 224 | rl_src = EvalLoc(cu, rl_src, op_kind, false); |
| 225 | if (rl_src.location != kLocPhysReg) { |
| 226 | DCHECK((rl_src.location == kLocDalvikFrame) || |
| 227 | (rl_src.location == kLocCompilerTemp)); |
| 228 | LoadValueDirectWide(cu, rl_src, rl_src.low_reg, rl_src.high_reg); |
| 229 | rl_src.location = kLocPhysReg; |
| 230 | MarkLive(cu, rl_src.low_reg, rl_src.s_reg_low); |
| 231 | MarkLive(cu, rl_src.high_reg, |
| 232 | GetSRegHi(rl_src.s_reg_low)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 233 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 234 | return rl_src; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 235 | } |
| 236 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 237 | void Codegen::StoreValueWide(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 238 | { |
buzbee | 3d66194 | 2012-03-14 17:37:27 -0700 | [diff] [blame] | 239 | #ifndef NDEBUG |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 240 | /* |
| 241 | * Sanity checking - should never try to store to the same |
| 242 | * ssa name during the compilation of a single instruction |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame] | 243 | * without an intervening ClobberSReg(). |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 244 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 245 | DCHECK((cu->live_sreg == INVALID_SREG) || |
| 246 | (rl_dest.s_reg_low != cu->live_sreg)); |
| 247 | cu->live_sreg = rl_dest.s_reg_low; |
buzbee | 3d66194 | 2012-03-14 17:37:27 -0700 | [diff] [blame] | 248 | #endif |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 249 | LIR* def_start; |
| 250 | LIR* def_end; |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 251 | DCHECK_EQ(IsFpReg(rl_src.low_reg), IsFpReg(rl_src.high_reg)); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 252 | DCHECK(rl_dest.wide); |
| 253 | DCHECK(rl_src.wide); |
| 254 | if (rl_src.location == kLocPhysReg) { |
| 255 | if (IsLive(cu, rl_src.low_reg) || |
| 256 | IsLive(cu, rl_src.high_reg) || |
| 257 | IsPromoted(cu, rl_src.low_reg) || |
| 258 | IsPromoted(cu, rl_src.high_reg) || |
| 259 | (rl_dest.location == kLocPhysReg)) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 260 | // Src is live or promoted or Dest has assigned reg. |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 261 | rl_dest = EvalLoc(cu, rl_dest, kAnyReg, false); |
| 262 | OpRegCopyWide(cu, rl_dest.low_reg, rl_dest.high_reg, |
| 263 | rl_src.low_reg, rl_src.high_reg); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 264 | } else { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 265 | // Just re-assign the registers. Dest gets Src's regs |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 266 | rl_dest.low_reg = rl_src.low_reg; |
| 267 | rl_dest.high_reg = rl_src.high_reg; |
| 268 | Clobber(cu, rl_src.low_reg); |
| 269 | Clobber(cu, rl_src.high_reg); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 270 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 271 | } else { |
| 272 | // Load Src either into promoted Dest or temps allocated for Dest |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 273 | rl_dest = EvalLoc(cu, rl_dest, kAnyReg, false); |
| 274 | LoadValueDirectWide(cu, rl_src, rl_dest.low_reg, rl_dest.high_reg); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 275 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 276 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 277 | // Dest is now live and dirty (until/if we flush it to home location) |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 278 | MarkLive(cu, rl_dest.low_reg, rl_dest.s_reg_low); |
| 279 | MarkLive(cu, rl_dest.high_reg, GetSRegHi(rl_dest.s_reg_low)); |
| 280 | MarkDirty(cu, rl_dest); |
| 281 | MarkPair(cu, rl_dest.low_reg, rl_dest.high_reg); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 282 | |
| 283 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 284 | ResetDefLocWide(cu, rl_dest); |
| 285 | if ((IsDirty(cu, rl_dest.low_reg) || |
| 286 | IsDirty(cu, rl_dest.high_reg)) && |
| 287 | (oat_live_out(cu, rl_dest.s_reg_low) || |
| 288 | oat_live_out(cu, GetSRegHi(rl_dest.s_reg_low)))) { |
| 289 | def_start = cu->last_lir_insn; |
| 290 | DCHECK_EQ((SRegToVReg(cu, rl_dest.s_reg_low)+1), |
| 291 | SRegToVReg(cu, GetSRegHi(rl_dest.s_reg_low))); |
| 292 | StoreBaseDispWide(cu, TargetReg(kSp), SRegOffset(cu, rl_dest.s_reg_low), |
| 293 | rl_dest.low_reg, rl_dest.high_reg); |
| 294 | MarkClean(cu, rl_dest); |
| 295 | def_end = cu->last_lir_insn; |
| 296 | MarkDefWide(cu, rl_dest, def_start, def_end); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 297 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 298 | } |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 299 | |
buzbee | e196567 | 2012-03-11 18:39:19 -0700 | [diff] [blame] | 300 | /* Utilities to load the current Method* */ |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 301 | void Codegen::LoadCurrMethodDirect(CompilationUnit *cu, int r_tgt) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 302 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 303 | LoadValueDirectFixed(cu, cu->method_loc, r_tgt); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 304 | } |
| 305 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 306 | RegLocation Codegen::LoadCurrMethod(CompilationUnit *cu) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 307 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 308 | return LoadValue(cu, cu->method_loc, kCoreReg); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 309 | } |
| 310 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 311 | } // namespace art |