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