Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | #include "code_generator_arm.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 18 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 19 | #include "entrypoints/quick/quick_entrypoints.h" |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 20 | #include "gc/accounting/card_table.h" |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 21 | #include "mirror/array.h" |
| 22 | #include "mirror/art_method.h" |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 23 | #include "thread.h" |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 24 | #include "utils/assembler.h" |
| 25 | #include "utils/arm/assembler_arm.h" |
| 26 | #include "utils/arm/managed_register_arm.h" |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 27 | #include "utils/stack_checks.h" |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 28 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 29 | namespace art { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 30 | |
| 31 | arm::ArmManagedRegister Location::AsArm() const { |
| 32 | return reg().AsArm(); |
| 33 | } |
| 34 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 35 | namespace arm { |
| 36 | |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 37 | static constexpr bool kExplicitStackOverflowCheck = false; |
| 38 | |
| 39 | static constexpr int kNumberOfPushedRegistersAtEntry = 1 + 2; // LR, R6, R7 |
| 40 | static constexpr int kCurrentMethodStackOffset = 0; |
| 41 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 42 | static Location ArmCoreLocation(Register reg) { |
| 43 | return Location::RegisterLocation(ArmManagedRegister::FromCoreRegister(reg)); |
| 44 | } |
| 45 | |
| 46 | static constexpr Register kRuntimeParameterCoreRegisters[] = { R0, R1, R2 }; |
| 47 | static constexpr size_t kRuntimeParameterCoreRegistersLength = |
| 48 | arraysize(kRuntimeParameterCoreRegisters); |
| 49 | |
| 50 | class InvokeRuntimeCallingConvention : public CallingConvention<Register> { |
| 51 | public: |
| 52 | InvokeRuntimeCallingConvention() |
| 53 | : CallingConvention(kRuntimeParameterCoreRegisters, |
| 54 | kRuntimeParameterCoreRegistersLength) {} |
| 55 | |
| 56 | private: |
| 57 | DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention); |
| 58 | }; |
| 59 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 60 | #define __ reinterpret_cast<ArmAssembler*>(codegen->GetAssembler())-> |
| 61 | |
| 62 | class NullCheckSlowPathARM : public SlowPathCode { |
| 63 | public: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 64 | explicit NullCheckSlowPathARM(HNullCheck* instruction) : instruction_(instruction) {} |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 65 | |
| 66 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 67 | __ Bind(GetEntryLabel()); |
| 68 | int32_t offset = QUICK_ENTRYPOINT_OFFSET(kArmWordSize, pThrowNullPointer).Int32Value(); |
| 69 | __ ldr(LR, Address(TR, offset)); |
| 70 | __ blx(LR); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 71 | codegen->RecordPcInfo(instruction_, instruction_->GetDexPc()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | private: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 75 | HNullCheck* const instruction_; |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 76 | DISALLOW_COPY_AND_ASSIGN(NullCheckSlowPathARM); |
| 77 | }; |
| 78 | |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 79 | class StackOverflowCheckSlowPathARM : public SlowPathCode { |
| 80 | public: |
| 81 | StackOverflowCheckSlowPathARM() {} |
| 82 | |
| 83 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 84 | __ Bind(GetEntryLabel()); |
| 85 | __ LoadFromOffset(kLoadWord, PC, TR, |
| 86 | QUICK_ENTRYPOINT_OFFSET(kArmWordSize, pThrowStackOverflow).Int32Value()); |
| 87 | } |
| 88 | |
| 89 | private: |
| 90 | DISALLOW_COPY_AND_ASSIGN(StackOverflowCheckSlowPathARM); |
| 91 | }; |
| 92 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 93 | class BoundsCheckSlowPathARM : public SlowPathCode { |
| 94 | public: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 95 | explicit BoundsCheckSlowPathARM(HBoundsCheck* instruction, |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 96 | Location index_location, |
| 97 | Location length_location) |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 98 | : instruction_(instruction), |
| 99 | index_location_(index_location), |
| 100 | length_location_(length_location) {} |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 101 | |
| 102 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 103 | CodeGeneratorARM* arm_codegen = reinterpret_cast<CodeGeneratorARM*>(codegen); |
| 104 | __ Bind(GetEntryLabel()); |
| 105 | InvokeRuntimeCallingConvention calling_convention; |
| 106 | arm_codegen->Move32(ArmCoreLocation(calling_convention.GetRegisterAt(0)), index_location_); |
| 107 | arm_codegen->Move32(ArmCoreLocation(calling_convention.GetRegisterAt(1)), length_location_); |
| 108 | int32_t offset = QUICK_ENTRYPOINT_OFFSET(kArmWordSize, pThrowArrayBounds).Int32Value(); |
| 109 | __ ldr(LR, Address(TR, offset)); |
| 110 | __ blx(LR); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 111 | codegen->RecordPcInfo(instruction_, instruction_->GetDexPc()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | private: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 115 | HBoundsCheck* const instruction_; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 116 | const Location index_location_; |
| 117 | const Location length_location_; |
| 118 | |
| 119 | DISALLOW_COPY_AND_ASSIGN(BoundsCheckSlowPathARM); |
| 120 | }; |
| 121 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 122 | #undef __ |
| 123 | #define __ reinterpret_cast<ArmAssembler*>(GetAssembler())-> |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 124 | |
| 125 | inline Condition ARMCondition(IfCondition cond) { |
| 126 | switch (cond) { |
| 127 | case kCondEQ: return EQ; |
| 128 | case kCondNE: return NE; |
| 129 | case kCondLT: return LT; |
| 130 | case kCondLE: return LE; |
| 131 | case kCondGT: return GT; |
| 132 | case kCondGE: return GE; |
| 133 | default: |
| 134 | LOG(FATAL) << "Unknown if condition"; |
| 135 | } |
| 136 | return EQ; // Unreachable. |
| 137 | } |
| 138 | |
| 139 | inline Condition ARMOppositeCondition(IfCondition cond) { |
| 140 | switch (cond) { |
| 141 | case kCondEQ: return NE; |
| 142 | case kCondNE: return EQ; |
| 143 | case kCondLT: return GE; |
| 144 | case kCondLE: return GT; |
| 145 | case kCondGT: return LE; |
| 146 | case kCondGE: return LT; |
| 147 | default: |
| 148 | LOG(FATAL) << "Unknown if condition"; |
| 149 | } |
| 150 | return EQ; // Unreachable. |
| 151 | } |
| 152 | |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 153 | void CodeGeneratorARM::DumpCoreRegister(std::ostream& stream, int reg) const { |
| 154 | stream << ArmManagedRegister::FromCoreRegister(Register(reg)); |
| 155 | } |
| 156 | |
| 157 | void CodeGeneratorARM::DumpFloatingPointRegister(std::ostream& stream, int reg) const { |
| 158 | stream << ArmManagedRegister::FromDRegister(DRegister(reg)); |
| 159 | } |
| 160 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 161 | CodeGeneratorARM::CodeGeneratorARM(HGraph* graph) |
| 162 | : CodeGenerator(graph, kNumberOfRegIds), |
| 163 | location_builder_(graph, this), |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 164 | instruction_visitor_(graph, this), |
Nicolas Geoffray | 8d48673 | 2014-07-16 16:23:40 +0100 | [diff] [blame] | 165 | move_resolver_(graph->GetArena(), this), |
| 166 | assembler_(true) {} |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 167 | |
Nicolas Geoffray | ab032bc | 2014-07-15 12:55:21 +0100 | [diff] [blame] | 168 | size_t CodeGeneratorARM::FrameEntrySpillSize() const { |
| 169 | return kNumberOfPushedRegistersAtEntry * kArmWordSize; |
| 170 | } |
| 171 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 172 | static bool* GetBlockedRegisterPairs(bool* blocked_registers) { |
| 173 | return blocked_registers + kNumberOfAllocIds; |
| 174 | } |
| 175 | |
| 176 | ManagedRegister CodeGeneratorARM::AllocateFreeRegister(Primitive::Type type, |
| 177 | bool* blocked_registers) const { |
| 178 | switch (type) { |
| 179 | case Primitive::kPrimLong: { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 180 | bool* blocked_register_pairs = GetBlockedRegisterPairs(blocked_registers); |
| 181 | size_t reg = AllocateFreeRegisterInternal(blocked_register_pairs, kNumberOfRegisterPairs); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 182 | ArmManagedRegister pair = |
| 183 | ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(reg)); |
| 184 | blocked_registers[pair.AsRegisterPairLow()] = true; |
| 185 | blocked_registers[pair.AsRegisterPairHigh()] = true; |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 186 | // Block all other register pairs that share a register with `pair`. |
| 187 | for (int i = 0; i < kNumberOfRegisterPairs; i++) { |
| 188 | ArmManagedRegister current = |
| 189 | ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(i)); |
| 190 | if (current.AsRegisterPairLow() == pair.AsRegisterPairLow() |
| 191 | || current.AsRegisterPairLow() == pair.AsRegisterPairHigh() |
| 192 | || current.AsRegisterPairHigh() == pair.AsRegisterPairLow() |
| 193 | || current.AsRegisterPairHigh() == pair.AsRegisterPairHigh()) { |
| 194 | blocked_register_pairs[i] = true; |
| 195 | } |
| 196 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 197 | return pair; |
| 198 | } |
| 199 | |
| 200 | case Primitive::kPrimByte: |
| 201 | case Primitive::kPrimBoolean: |
| 202 | case Primitive::kPrimChar: |
| 203 | case Primitive::kPrimShort: |
| 204 | case Primitive::kPrimInt: |
| 205 | case Primitive::kPrimNot: { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 206 | int reg = AllocateFreeRegisterInternal(blocked_registers, kNumberOfCoreRegisters); |
| 207 | // Block all register pairs that contain `reg`. |
| 208 | bool* blocked_register_pairs = GetBlockedRegisterPairs(blocked_registers); |
| 209 | for (int i = 0; i < kNumberOfRegisterPairs; i++) { |
| 210 | ArmManagedRegister current = |
| 211 | ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(i)); |
| 212 | if (current.AsRegisterPairLow() == reg || current.AsRegisterPairHigh() == reg) { |
| 213 | blocked_register_pairs[i] = true; |
| 214 | } |
| 215 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 216 | return ArmManagedRegister::FromCoreRegister(static_cast<Register>(reg)); |
| 217 | } |
| 218 | |
| 219 | case Primitive::kPrimFloat: |
| 220 | case Primitive::kPrimDouble: |
| 221 | LOG(FATAL) << "Unimplemented register type " << type; |
| 222 | |
| 223 | case Primitive::kPrimVoid: |
| 224 | LOG(FATAL) << "Unreachable type " << type; |
| 225 | } |
| 226 | |
| 227 | return ManagedRegister::NoRegister(); |
| 228 | } |
| 229 | |
| 230 | void CodeGeneratorARM::SetupBlockedRegisters(bool* blocked_registers) const { |
| 231 | bool* blocked_register_pairs = GetBlockedRegisterPairs(blocked_registers); |
| 232 | |
| 233 | // Don't allocate the dalvik style register pair passing. |
| 234 | blocked_register_pairs[R1_R2] = true; |
| 235 | |
| 236 | // Stack register, LR and PC are always reserved. |
| 237 | blocked_registers[SP] = true; |
| 238 | blocked_registers[LR] = true; |
| 239 | blocked_registers[PC] = true; |
| 240 | |
| 241 | // Reserve R4 for suspend check. |
| 242 | blocked_registers[R4] = true; |
| 243 | blocked_register_pairs[R4_R5] = true; |
| 244 | |
| 245 | // Reserve thread register. |
| 246 | blocked_registers[TR] = true; |
| 247 | |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 248 | // Reserve temp register. |
| 249 | blocked_registers[IP] = true; |
| 250 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 251 | // TODO: We currently don't use Quick's callee saved registers. |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 252 | // We always save and restore R6 and R7 to make sure we can use three |
| 253 | // register pairs for long operations. |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 254 | blocked_registers[R5] = true; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 255 | blocked_registers[R8] = true; |
| 256 | blocked_registers[R10] = true; |
| 257 | blocked_registers[R11] = true; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | size_t CodeGeneratorARM::GetNumberOfRegisters() const { |
| 261 | return kNumberOfRegIds; |
| 262 | } |
| 263 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 264 | InstructionCodeGeneratorARM::InstructionCodeGeneratorARM(HGraph* graph, CodeGeneratorARM* codegen) |
| 265 | : HGraphVisitor(graph), |
| 266 | assembler_(codegen->GetAssembler()), |
| 267 | codegen_(codegen) {} |
| 268 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 269 | void CodeGeneratorARM::GenerateFrameEntry() { |
Dave Allison | 648d711 | 2014-07-25 16:15:27 -0700 | [diff] [blame] | 270 | bool skip_overflow_check = IsLeafMethod() && !FrameNeedsStackCheck(GetFrameSize(), InstructionSet::kArm); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 271 | if (!skip_overflow_check) { |
| 272 | if (kExplicitStackOverflowCheck) { |
| 273 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) StackOverflowCheckSlowPathARM(); |
| 274 | AddSlowPath(slow_path); |
| 275 | |
| 276 | __ LoadFromOffset(kLoadWord, IP, TR, Thread::StackEndOffset<kArmWordSize>().Int32Value()); |
| 277 | __ cmp(SP, ShifterOperand(IP)); |
| 278 | __ b(slow_path->GetEntryLabel(), CC); |
| 279 | } else { |
| 280 | __ AddConstant(IP, SP, -static_cast<int32_t>(GetStackOverflowReservedBytes(kArm))); |
| 281 | __ ldr(IP, Address(IP, 0)); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 282 | RecordPcInfo(nullptr, 0); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 286 | core_spill_mask_ |= (1 << LR | 1 << R6 | 1 << R7); |
| 287 | __ PushList(1 << LR | 1 << R6 | 1 << R7); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 288 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 289 | // The return PC has already been pushed on the stack. |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 290 | __ AddConstant(SP, -(GetFrameSize() - kNumberOfPushedRegistersAtEntry * kArmWordSize)); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 291 | __ str(R0, Address(SP, 0)); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | void CodeGeneratorARM::GenerateFrameExit() { |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 295 | __ AddConstant(SP, GetFrameSize() - kNumberOfPushedRegistersAtEntry * kArmWordSize); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 296 | __ PopList(1 << PC | 1 << R6 | 1 << R7); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | void CodeGeneratorARM::Bind(Label* label) { |
| 300 | __ Bind(label); |
| 301 | } |
| 302 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 303 | Location CodeGeneratorARM::GetStackLocation(HLoadLocal* load) const { |
| 304 | switch (load->GetType()) { |
| 305 | case Primitive::kPrimLong: |
| 306 | return Location::DoubleStackSlot(GetStackSlot(load->GetLocal())); |
| 307 | break; |
| 308 | |
| 309 | case Primitive::kPrimInt: |
| 310 | case Primitive::kPrimNot: |
| 311 | return Location::StackSlot(GetStackSlot(load->GetLocal())); |
| 312 | |
| 313 | case Primitive::kPrimFloat: |
| 314 | case Primitive::kPrimDouble: |
| 315 | LOG(FATAL) << "Unimplemented type " << load->GetType(); |
| 316 | |
| 317 | case Primitive::kPrimBoolean: |
| 318 | case Primitive::kPrimByte: |
| 319 | case Primitive::kPrimChar: |
| 320 | case Primitive::kPrimShort: |
| 321 | case Primitive::kPrimVoid: |
| 322 | LOG(FATAL) << "Unexpected type " << load->GetType(); |
| 323 | } |
| 324 | |
| 325 | LOG(FATAL) << "Unreachable"; |
| 326 | return Location(); |
| 327 | } |
| 328 | |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 329 | Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type) { |
| 330 | switch (type) { |
| 331 | case Primitive::kPrimBoolean: |
| 332 | case Primitive::kPrimByte: |
| 333 | case Primitive::kPrimChar: |
| 334 | case Primitive::kPrimShort: |
| 335 | case Primitive::kPrimInt: |
| 336 | case Primitive::kPrimNot: { |
| 337 | uint32_t index = gp_index_++; |
| 338 | if (index < calling_convention.GetNumberOfRegisters()) { |
| 339 | return ArmCoreLocation(calling_convention.GetRegisterAt(index)); |
| 340 | } else { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 341 | return Location::StackSlot(calling_convention.GetStackOffsetOf(index)); |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 342 | } |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 343 | } |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 344 | |
| 345 | case Primitive::kPrimLong: { |
| 346 | uint32_t index = gp_index_; |
| 347 | gp_index_ += 2; |
| 348 | if (index + 1 < calling_convention.GetNumberOfRegisters()) { |
| 349 | return Location::RegisterLocation(ArmManagedRegister::FromRegisterPair( |
| 350 | calling_convention.GetRegisterPairAt(index))); |
| 351 | } else if (index + 1 == calling_convention.GetNumberOfRegisters()) { |
| 352 | return Location::QuickParameter(index); |
| 353 | } else { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 354 | return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(index)); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | |
| 358 | case Primitive::kPrimDouble: |
| 359 | case Primitive::kPrimFloat: |
| 360 | LOG(FATAL) << "Unimplemented parameter type " << type; |
| 361 | break; |
| 362 | |
| 363 | case Primitive::kPrimVoid: |
| 364 | LOG(FATAL) << "Unexpected parameter type " << type; |
| 365 | break; |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 366 | } |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 367 | return Location(); |
| 368 | } |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 369 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 370 | void CodeGeneratorARM::Move32(Location destination, Location source) { |
| 371 | if (source.Equals(destination)) { |
| 372 | return; |
| 373 | } |
| 374 | if (destination.IsRegister()) { |
| 375 | if (source.IsRegister()) { |
| 376 | __ Mov(destination.AsArm().AsCoreRegister(), source.AsArm().AsCoreRegister()); |
| 377 | } else { |
| 378 | __ ldr(destination.AsArm().AsCoreRegister(), Address(SP, source.GetStackIndex())); |
| 379 | } |
| 380 | } else { |
| 381 | DCHECK(destination.IsStackSlot()); |
| 382 | if (source.IsRegister()) { |
| 383 | __ str(source.AsArm().AsCoreRegister(), Address(SP, destination.GetStackIndex())); |
| 384 | } else { |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 385 | __ ldr(IP, Address(SP, source.GetStackIndex())); |
| 386 | __ str(IP, Address(SP, destination.GetStackIndex())); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | void CodeGeneratorARM::Move64(Location destination, Location source) { |
| 392 | if (source.Equals(destination)) { |
| 393 | return; |
| 394 | } |
| 395 | if (destination.IsRegister()) { |
| 396 | if (source.IsRegister()) { |
| 397 | __ Mov(destination.AsArm().AsRegisterPairLow(), source.AsArm().AsRegisterPairLow()); |
| 398 | __ Mov(destination.AsArm().AsRegisterPairHigh(), source.AsArm().AsRegisterPairHigh()); |
| 399 | } else if (source.IsQuickParameter()) { |
| 400 | uint32_t argument_index = source.GetQuickParameterIndex(); |
| 401 | InvokeDexCallingConvention calling_convention; |
| 402 | __ Mov(destination.AsArm().AsRegisterPairLow(), |
| 403 | calling_convention.GetRegisterAt(argument_index)); |
| 404 | __ ldr(destination.AsArm().AsRegisterPairHigh(), |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 405 | Address(SP, calling_convention.GetStackOffsetOf(argument_index + 1) + GetFrameSize())); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 406 | } else { |
| 407 | DCHECK(source.IsDoubleStackSlot()); |
| 408 | if (destination.AsArm().AsRegisterPair() == R1_R2) { |
| 409 | __ ldr(R1, Address(SP, source.GetStackIndex())); |
| 410 | __ ldr(R2, Address(SP, source.GetHighStackIndex(kArmWordSize))); |
| 411 | } else { |
| 412 | __ LoadFromOffset(kLoadWordPair, destination.AsArm().AsRegisterPairLow(), |
| 413 | SP, source.GetStackIndex()); |
| 414 | } |
| 415 | } |
| 416 | } else if (destination.IsQuickParameter()) { |
| 417 | InvokeDexCallingConvention calling_convention; |
| 418 | uint32_t argument_index = destination.GetQuickParameterIndex(); |
| 419 | if (source.IsRegister()) { |
| 420 | __ Mov(calling_convention.GetRegisterAt(argument_index), source.AsArm().AsRegisterPairLow()); |
| 421 | __ str(source.AsArm().AsRegisterPairHigh(), |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 422 | Address(SP, calling_convention.GetStackOffsetOf(argument_index + 1))); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 423 | } else { |
| 424 | DCHECK(source.IsDoubleStackSlot()); |
| 425 | __ ldr(calling_convention.GetRegisterAt(argument_index), Address(SP, source.GetStackIndex())); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 426 | __ ldr(R0, Address(SP, source.GetHighStackIndex(kArmWordSize))); |
| 427 | __ str(R0, Address(SP, calling_convention.GetStackOffsetOf(argument_index + 1))); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 428 | } |
| 429 | } else { |
| 430 | DCHECK(destination.IsDoubleStackSlot()); |
| 431 | if (source.IsRegister()) { |
| 432 | if (source.AsArm().AsRegisterPair() == R1_R2) { |
| 433 | __ str(R1, Address(SP, destination.GetStackIndex())); |
| 434 | __ str(R2, Address(SP, destination.GetHighStackIndex(kArmWordSize))); |
| 435 | } else { |
| 436 | __ StoreToOffset(kStoreWordPair, source.AsArm().AsRegisterPairLow(), |
| 437 | SP, destination.GetStackIndex()); |
| 438 | } |
| 439 | } else if (source.IsQuickParameter()) { |
| 440 | InvokeDexCallingConvention calling_convention; |
| 441 | uint32_t argument_index = source.GetQuickParameterIndex(); |
| 442 | __ str(calling_convention.GetRegisterAt(argument_index), |
| 443 | Address(SP, destination.GetStackIndex())); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 444 | __ ldr(R0, |
| 445 | Address(SP, calling_convention.GetStackOffsetOf(argument_index + 1) + GetFrameSize())); |
| 446 | __ str(R0, Address(SP, destination.GetHighStackIndex(kArmWordSize))); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 447 | } else { |
| 448 | DCHECK(source.IsDoubleStackSlot()); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 449 | __ ldr(IP, Address(SP, source.GetStackIndex())); |
| 450 | __ str(IP, Address(SP, destination.GetStackIndex())); |
| 451 | __ ldr(IP, Address(SP, source.GetHighStackIndex(kArmWordSize))); |
| 452 | __ str(IP, Address(SP, destination.GetHighStackIndex(kArmWordSize))); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 457 | void CodeGeneratorARM::Move(HInstruction* instruction, Location location, HInstruction* move_for) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 458 | LocationSummary* locations = instruction->GetLocations(); |
| 459 | if (locations != nullptr && locations->Out().Equals(location)) { |
| 460 | return; |
| 461 | } |
| 462 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 463 | if (instruction->AsIntConstant() != nullptr) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 464 | int32_t value = instruction->AsIntConstant()->GetValue(); |
| 465 | if (location.IsRegister()) { |
| 466 | __ LoadImmediate(location.AsArm().AsCoreRegister(), value); |
| 467 | } else { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 468 | DCHECK(location.IsStackSlot()); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 469 | __ LoadImmediate(IP, value); |
| 470 | __ str(IP, Address(SP, location.GetStackIndex())); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 471 | } |
| 472 | } else if (instruction->AsLongConstant() != nullptr) { |
| 473 | int64_t value = instruction->AsLongConstant()->GetValue(); |
| 474 | if (location.IsRegister()) { |
| 475 | __ LoadImmediate(location.AsArm().AsRegisterPairLow(), Low32Bits(value)); |
| 476 | __ LoadImmediate(location.AsArm().AsRegisterPairHigh(), High32Bits(value)); |
| 477 | } else { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 478 | DCHECK(location.IsDoubleStackSlot()); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 479 | __ LoadImmediate(IP, Low32Bits(value)); |
| 480 | __ str(IP, Address(SP, location.GetStackIndex())); |
| 481 | __ LoadImmediate(IP, High32Bits(value)); |
| 482 | __ str(IP, Address(SP, location.GetHighStackIndex(kArmWordSize))); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 483 | } |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 484 | } else if (instruction->AsLoadLocal() != nullptr) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 485 | uint32_t stack_slot = GetStackSlot(instruction->AsLoadLocal()->GetLocal()); |
| 486 | switch (instruction->GetType()) { |
| 487 | case Primitive::kPrimBoolean: |
| 488 | case Primitive::kPrimByte: |
| 489 | case Primitive::kPrimChar: |
| 490 | case Primitive::kPrimShort: |
| 491 | case Primitive::kPrimInt: |
| 492 | case Primitive::kPrimNot: |
| 493 | Move32(location, Location::StackSlot(stack_slot)); |
| 494 | break; |
| 495 | |
| 496 | case Primitive::kPrimLong: |
| 497 | Move64(location, Location::DoubleStackSlot(stack_slot)); |
| 498 | break; |
| 499 | |
| 500 | default: |
| 501 | LOG(FATAL) << "Unimplemented type " << instruction->GetType(); |
| 502 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 503 | } else { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 504 | DCHECK((instruction->GetNext() == move_for) || instruction->GetNext()->IsTemporary()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 505 | switch (instruction->GetType()) { |
| 506 | case Primitive::kPrimBoolean: |
| 507 | case Primitive::kPrimByte: |
| 508 | case Primitive::kPrimChar: |
| 509 | case Primitive::kPrimShort: |
| 510 | case Primitive::kPrimNot: |
| 511 | case Primitive::kPrimInt: |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 512 | Move32(location, locations->Out()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 513 | break; |
| 514 | |
| 515 | case Primitive::kPrimLong: |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 516 | Move64(location, locations->Out()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 517 | break; |
| 518 | |
| 519 | default: |
| 520 | LOG(FATAL) << "Unimplemented type " << instruction->GetType(); |
| 521 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 522 | } |
| 523 | } |
| 524 | |
| 525 | void LocationsBuilderARM::VisitGoto(HGoto* got) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 526 | got->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 527 | } |
| 528 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 529 | void InstructionCodeGeneratorARM::VisitGoto(HGoto* got) { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 530 | HBasicBlock* successor = got->GetSuccessor(); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 531 | if (GetGraph()->GetExitBlock() == successor) { |
| 532 | codegen_->GenerateFrameExit(); |
| 533 | } else if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) { |
| 534 | __ b(codegen_->GetLabelOf(successor)); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 538 | void LocationsBuilderARM::VisitExit(HExit* exit) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 539 | exit->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 540 | } |
| 541 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 542 | void InstructionCodeGeneratorARM::VisitExit(HExit* exit) { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 543 | if (kIsDebugBuild) { |
| 544 | __ Comment("Unreachable"); |
| 545 | __ bkpt(0); |
| 546 | } |
| 547 | } |
| 548 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 549 | void LocationsBuilderARM::VisitIf(HIf* if_instr) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 550 | LocationSummary* locations = |
| 551 | new (GetGraph()->GetArena()) LocationSummary(if_instr, LocationSummary::kNoCall); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 552 | HInstruction* cond = if_instr->InputAt(0); |
| 553 | DCHECK(cond->IsCondition()); |
| 554 | HCondition* condition = cond->AsCondition(); |
| 555 | if (condition->NeedsMaterialization()) { |
| 556 | locations->SetInAt(0, Location::Any()); |
| 557 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 558 | } |
| 559 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 560 | void InstructionCodeGeneratorARM::VisitIf(HIf* if_instr) { |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 561 | HInstruction* cond = if_instr->InputAt(0); |
| 562 | DCHECK(cond->IsCondition()); |
| 563 | HCondition* condition = cond->AsCondition(); |
| 564 | if (condition->NeedsMaterialization()) { |
| 565 | // Condition has been materialized, compare the output to 0 |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 566 | DCHECK(if_instr->GetLocations()->InAt(0).IsRegister()); |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 567 | __ cmp(if_instr->GetLocations()->InAt(0).AsArm().AsCoreRegister(), |
| 568 | ShifterOperand(0)); |
| 569 | __ b(codegen_->GetLabelOf(if_instr->IfTrueSuccessor()), EQ); |
| 570 | } else { |
| 571 | // Condition has not been materialized, use its inputs as the comparison and its |
| 572 | // condition as the branch condition. |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 573 | LocationSummary* locations = condition->GetLocations(); |
| 574 | if (locations->InAt(1).IsRegister()) { |
| 575 | __ cmp(locations->InAt(0).AsArm().AsCoreRegister(), |
| 576 | ShifterOperand(locations->InAt(1).AsArm().AsCoreRegister())); |
| 577 | } else { |
| 578 | DCHECK(locations->InAt(1).IsConstant()); |
| 579 | int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); |
| 580 | ShifterOperand operand; |
| 581 | if (ShifterOperand::CanHoldArm(value, &operand)) { |
| 582 | __ cmp(locations->InAt(0).AsArm().AsCoreRegister(), ShifterOperand(value)); |
| 583 | } else { |
| 584 | Register temp = IP; |
| 585 | __ LoadImmediate(temp, value); |
| 586 | __ cmp(locations->InAt(0).AsArm().AsCoreRegister(), ShifterOperand(temp)); |
| 587 | } |
| 588 | } |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 589 | __ b(codegen_->GetLabelOf(if_instr->IfTrueSuccessor()), |
| 590 | ARMCondition(condition->GetCondition())); |
| 591 | } |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 592 | |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 593 | if (!codegen_->GoesToNextBlock(if_instr->GetBlock(), if_instr->IfFalseSuccessor())) { |
| 594 | __ b(codegen_->GetLabelOf(if_instr->IfFalseSuccessor())); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 595 | } |
| 596 | } |
| 597 | |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 598 | |
| 599 | void LocationsBuilderARM::VisitCondition(HCondition* comp) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 600 | LocationSummary* locations = |
| 601 | new (GetGraph()->GetArena()) LocationSummary(comp, LocationSummary::kNoCall); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 602 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 603 | locations->SetInAt(1, Location::RegisterOrConstant(comp->InputAt(1))); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 604 | if (comp->NeedsMaterialization()) { |
| 605 | locations->SetOut(Location::RequiresRegister()); |
| 606 | } |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 609 | void InstructionCodeGeneratorARM::VisitCondition(HCondition* comp) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 610 | if (!comp->NeedsMaterialization()) return; |
| 611 | |
| 612 | LocationSummary* locations = comp->GetLocations(); |
| 613 | if (locations->InAt(1).IsRegister()) { |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 614 | __ cmp(locations->InAt(0).AsArm().AsCoreRegister(), |
| 615 | ShifterOperand(locations->InAt(1).AsArm().AsCoreRegister())); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 616 | } else { |
| 617 | DCHECK(locations->InAt(1).IsConstant()); |
| 618 | int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); |
| 619 | ShifterOperand operand; |
| 620 | if (ShifterOperand::CanHoldArm(value, &operand)) { |
| 621 | __ cmp(locations->InAt(0).AsArm().AsCoreRegister(), ShifterOperand(value)); |
| 622 | } else { |
| 623 | Register temp = IP; |
| 624 | __ LoadImmediate(temp, value); |
| 625 | __ cmp(locations->InAt(0).AsArm().AsCoreRegister(), ShifterOperand(temp)); |
| 626 | } |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 627 | } |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 628 | __ it(ARMCondition(comp->GetCondition()), kItElse); |
| 629 | __ mov(locations->Out().AsArm().AsCoreRegister(), ShifterOperand(1), |
| 630 | ARMCondition(comp->GetCondition())); |
| 631 | __ mov(locations->Out().AsArm().AsCoreRegister(), ShifterOperand(0), |
| 632 | ARMOppositeCondition(comp->GetCondition())); |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | void LocationsBuilderARM::VisitEqual(HEqual* comp) { |
| 636 | VisitCondition(comp); |
| 637 | } |
| 638 | |
| 639 | void InstructionCodeGeneratorARM::VisitEqual(HEqual* comp) { |
| 640 | VisitCondition(comp); |
| 641 | } |
| 642 | |
| 643 | void LocationsBuilderARM::VisitNotEqual(HNotEqual* comp) { |
| 644 | VisitCondition(comp); |
| 645 | } |
| 646 | |
| 647 | void InstructionCodeGeneratorARM::VisitNotEqual(HNotEqual* comp) { |
| 648 | VisitCondition(comp); |
| 649 | } |
| 650 | |
| 651 | void LocationsBuilderARM::VisitLessThan(HLessThan* comp) { |
| 652 | VisitCondition(comp); |
| 653 | } |
| 654 | |
| 655 | void InstructionCodeGeneratorARM::VisitLessThan(HLessThan* comp) { |
| 656 | VisitCondition(comp); |
| 657 | } |
| 658 | |
| 659 | void LocationsBuilderARM::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 660 | VisitCondition(comp); |
| 661 | } |
| 662 | |
| 663 | void InstructionCodeGeneratorARM::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 664 | VisitCondition(comp); |
| 665 | } |
| 666 | |
| 667 | void LocationsBuilderARM::VisitGreaterThan(HGreaterThan* comp) { |
| 668 | VisitCondition(comp); |
| 669 | } |
| 670 | |
| 671 | void InstructionCodeGeneratorARM::VisitGreaterThan(HGreaterThan* comp) { |
| 672 | VisitCondition(comp); |
| 673 | } |
| 674 | |
| 675 | void LocationsBuilderARM::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 676 | VisitCondition(comp); |
| 677 | } |
| 678 | |
| 679 | void InstructionCodeGeneratorARM::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 680 | VisitCondition(comp); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | void LocationsBuilderARM::VisitLocal(HLocal* local) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 684 | local->SetLocations(nullptr); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 685 | } |
| 686 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 687 | void InstructionCodeGeneratorARM::VisitLocal(HLocal* local) { |
| 688 | DCHECK_EQ(local->GetBlock(), GetGraph()->GetEntryBlock()); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 689 | } |
| 690 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 691 | void LocationsBuilderARM::VisitLoadLocal(HLoadLocal* load) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 692 | load->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 693 | } |
| 694 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 695 | void InstructionCodeGeneratorARM::VisitLoadLocal(HLoadLocal* load) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 696 | // Nothing to do, this is driven by the code generator. |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | void LocationsBuilderARM::VisitStoreLocal(HStoreLocal* store) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 700 | LocationSummary* locations = |
| 701 | new (GetGraph()->GetArena()) LocationSummary(store, LocationSummary::kNoCall); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 702 | switch (store->InputAt(1)->GetType()) { |
| 703 | case Primitive::kPrimBoolean: |
| 704 | case Primitive::kPrimByte: |
| 705 | case Primitive::kPrimChar: |
| 706 | case Primitive::kPrimShort: |
| 707 | case Primitive::kPrimInt: |
| 708 | case Primitive::kPrimNot: |
| 709 | locations->SetInAt(1, Location::StackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 710 | break; |
| 711 | |
| 712 | case Primitive::kPrimLong: |
| 713 | locations->SetInAt(1, Location::DoubleStackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 714 | break; |
| 715 | |
| 716 | default: |
| 717 | LOG(FATAL) << "Unimplemented local type " << store->InputAt(1)->GetType(); |
| 718 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 721 | void InstructionCodeGeneratorARM::VisitStoreLocal(HStoreLocal* store) { |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | void LocationsBuilderARM::VisitIntConstant(HIntConstant* constant) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 725 | LocationSummary* locations = |
| 726 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 727 | locations->SetOut(Location::ConstantLocation(constant)); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 728 | } |
| 729 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 730 | void InstructionCodeGeneratorARM::VisitIntConstant(HIntConstant* constant) { |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 731 | } |
| 732 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 733 | void LocationsBuilderARM::VisitLongConstant(HLongConstant* constant) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 734 | LocationSummary* locations = |
| 735 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 736 | locations->SetOut(Location::ConstantLocation(constant)); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | void InstructionCodeGeneratorARM::VisitLongConstant(HLongConstant* constant) { |
| 740 | // Will be generated at use site. |
| 741 | } |
| 742 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 743 | void LocationsBuilderARM::VisitReturnVoid(HReturnVoid* ret) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 744 | ret->SetLocations(nullptr); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 745 | } |
| 746 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 747 | void InstructionCodeGeneratorARM::VisitReturnVoid(HReturnVoid* ret) { |
| 748 | codegen_->GenerateFrameExit(); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 749 | } |
| 750 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 751 | void LocationsBuilderARM::VisitReturn(HReturn* ret) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 752 | LocationSummary* locations = |
| 753 | new (GetGraph()->GetArena()) LocationSummary(ret, LocationSummary::kNoCall); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 754 | switch (ret->InputAt(0)->GetType()) { |
| 755 | case Primitive::kPrimBoolean: |
| 756 | case Primitive::kPrimByte: |
| 757 | case Primitive::kPrimChar: |
| 758 | case Primitive::kPrimShort: |
| 759 | case Primitive::kPrimInt: |
| 760 | case Primitive::kPrimNot: |
| 761 | locations->SetInAt(0, ArmCoreLocation(R0)); |
| 762 | break; |
| 763 | |
| 764 | case Primitive::kPrimLong: |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 765 | locations->SetInAt( |
| 766 | 0, Location::RegisterLocation(ArmManagedRegister::FromRegisterPair(R0_R1))); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 767 | break; |
| 768 | |
| 769 | default: |
| 770 | LOG(FATAL) << "Unimplemented return type " << ret->InputAt(0)->GetType(); |
| 771 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 772 | } |
| 773 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 774 | void InstructionCodeGeneratorARM::VisitReturn(HReturn* ret) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 775 | if (kIsDebugBuild) { |
| 776 | switch (ret->InputAt(0)->GetType()) { |
| 777 | case Primitive::kPrimBoolean: |
| 778 | case Primitive::kPrimByte: |
| 779 | case Primitive::kPrimChar: |
| 780 | case Primitive::kPrimShort: |
| 781 | case Primitive::kPrimInt: |
| 782 | case Primitive::kPrimNot: |
| 783 | DCHECK_EQ(ret->GetLocations()->InAt(0).AsArm().AsCoreRegister(), R0); |
| 784 | break; |
| 785 | |
| 786 | case Primitive::kPrimLong: |
| 787 | DCHECK_EQ(ret->GetLocations()->InAt(0).AsArm().AsRegisterPair(), R0_R1); |
| 788 | break; |
| 789 | |
| 790 | default: |
| 791 | LOG(FATAL) << "Unimplemented return type " << ret->InputAt(0)->GetType(); |
| 792 | } |
| 793 | } |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 794 | codegen_->GenerateFrameExit(); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 795 | } |
| 796 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 797 | void LocationsBuilderARM::VisitInvokeStatic(HInvokeStatic* invoke) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 798 | LocationSummary* locations = |
| 799 | new (GetGraph()->GetArena()) LocationSummary(invoke, LocationSummary::kCall); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 800 | locations->AddTemp(ArmCoreLocation(R0)); |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 801 | |
| 802 | InvokeDexCallingConventionVisitor calling_convention_visitor; |
Nicolas Geoffray | c32e770 | 2014-04-24 12:43:16 +0100 | [diff] [blame] | 803 | for (size_t i = 0; i < invoke->InputCount(); i++) { |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 804 | HInstruction* input = invoke->InputAt(i); |
| 805 | locations->SetInAt(i, calling_convention_visitor.GetNextLocation(input->GetType())); |
| 806 | } |
| 807 | |
| 808 | switch (invoke->GetType()) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 809 | case Primitive::kPrimBoolean: |
| 810 | case Primitive::kPrimByte: |
| 811 | case Primitive::kPrimChar: |
| 812 | case Primitive::kPrimShort: |
| 813 | case Primitive::kPrimInt: |
| 814 | case Primitive::kPrimNot: |
| 815 | locations->SetOut(ArmCoreLocation(R0)); |
| 816 | break; |
| 817 | |
| 818 | case Primitive::kPrimLong: |
| 819 | locations->SetOut(Location::RegisterLocation(ArmManagedRegister::FromRegisterPair(R0_R1))); |
| 820 | break; |
| 821 | |
| 822 | case Primitive::kPrimVoid: |
| 823 | break; |
| 824 | |
| 825 | case Primitive::kPrimDouble: |
| 826 | case Primitive::kPrimFloat: |
| 827 | LOG(FATAL) << "Unimplemented return type " << invoke->GetType(); |
| 828 | break; |
| 829 | } |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | void InstructionCodeGeneratorARM::LoadCurrentMethod(Register reg) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 833 | __ ldr(reg, Address(SP, kCurrentMethodStackOffset)); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | void InstructionCodeGeneratorARM::VisitInvokeStatic(HInvokeStatic* invoke) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 837 | Register temp = invoke->GetLocations()->GetTemp(0).AsArm().AsCoreRegister(); |
Nicolas Geoffray | f61b537 | 2014-06-25 14:35:34 +0100 | [diff] [blame] | 838 | uint32_t heap_reference_size = sizeof(mirror::HeapReference<mirror::Object>); |
| 839 | size_t index_in_cache = mirror::Array::DataOffset(heap_reference_size).Int32Value() + |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 840 | invoke->GetIndexInDexCache() * kArmWordSize; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 841 | |
| 842 | // TODO: Implement all kinds of calls: |
| 843 | // 1) boot -> boot |
| 844 | // 2) app -> boot |
| 845 | // 3) app -> app |
| 846 | // |
| 847 | // Currently we implement the app -> app logic, which looks up in the resolve cache. |
| 848 | |
| 849 | // temp = method; |
| 850 | LoadCurrentMethod(temp); |
| 851 | // temp = temp->dex_cache_resolved_methods_; |
| 852 | __ ldr(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value())); |
| 853 | // temp = temp[index_in_cache] |
| 854 | __ ldr(temp, Address(temp, index_in_cache)); |
| 855 | // LR = temp[offset_of_quick_compiled_code] |
| 856 | __ ldr(LR, Address(temp, |
| 857 | mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value())); |
| 858 | // LR() |
| 859 | __ blx(LR); |
| 860 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 861 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 862 | DCHECK(!codegen_->IsLeafMethod()); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 863 | } |
| 864 | |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 865 | void LocationsBuilderARM::VisitAdd(HAdd* add) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 866 | LocationSummary* locations = |
| 867 | new (GetGraph()->GetArena()) LocationSummary(add, LocationSummary::kNoCall); |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 868 | switch (add->GetResultType()) { |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 869 | case Primitive::kPrimInt: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 870 | case Primitive::kPrimLong: { |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 871 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 872 | locations->SetInAt(1, Location::RegisterOrConstant(add->InputAt(1))); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 873 | locations->SetOut(Location::RequiresRegister()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 874 | break; |
| 875 | } |
| 876 | |
| 877 | case Primitive::kPrimBoolean: |
| 878 | case Primitive::kPrimByte: |
| 879 | case Primitive::kPrimChar: |
| 880 | case Primitive::kPrimShort: |
| 881 | LOG(FATAL) << "Unexpected add type " << add->GetResultType(); |
| 882 | break; |
| 883 | |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 884 | default: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 885 | LOG(FATAL) << "Unimplemented add type " << add->GetResultType(); |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 886 | } |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | void InstructionCodeGeneratorARM::VisitAdd(HAdd* add) { |
| 890 | LocationSummary* locations = add->GetLocations(); |
| 891 | switch (add->GetResultType()) { |
| 892 | case Primitive::kPrimInt: |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 893 | if (locations->InAt(1).IsRegister()) { |
| 894 | __ add(locations->Out().AsArm().AsCoreRegister(), |
| 895 | locations->InAt(0).AsArm().AsCoreRegister(), |
| 896 | ShifterOperand(locations->InAt(1).AsArm().AsCoreRegister())); |
| 897 | } else { |
| 898 | __ AddConstant(locations->Out().AsArm().AsCoreRegister(), |
| 899 | locations->InAt(0).AsArm().AsCoreRegister(), |
| 900 | locations->InAt(1).GetConstant()->AsIntConstant()->GetValue()); |
| 901 | } |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 902 | break; |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 903 | |
| 904 | case Primitive::kPrimLong: |
| 905 | __ adds(locations->Out().AsArm().AsRegisterPairLow(), |
| 906 | locations->InAt(0).AsArm().AsRegisterPairLow(), |
| 907 | ShifterOperand(locations->InAt(1).AsArm().AsRegisterPairLow())); |
| 908 | __ adc(locations->Out().AsArm().AsRegisterPairHigh(), |
| 909 | locations->InAt(0).AsArm().AsRegisterPairHigh(), |
| 910 | ShifterOperand(locations->InAt(1).AsArm().AsRegisterPairHigh())); |
| 911 | break; |
| 912 | |
| 913 | case Primitive::kPrimBoolean: |
| 914 | case Primitive::kPrimByte: |
| 915 | case Primitive::kPrimChar: |
| 916 | case Primitive::kPrimShort: |
| 917 | LOG(FATAL) << "Unexpected add type " << add->GetResultType(); |
| 918 | break; |
| 919 | |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 920 | default: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 921 | LOG(FATAL) << "Unimplemented add type " << add->GetResultType(); |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 922 | } |
| 923 | } |
| 924 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 925 | void LocationsBuilderARM::VisitSub(HSub* sub) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 926 | LocationSummary* locations = |
| 927 | new (GetGraph()->GetArena()) LocationSummary(sub, LocationSummary::kNoCall); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 928 | switch (sub->GetResultType()) { |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 929 | case Primitive::kPrimInt: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 930 | case Primitive::kPrimLong: { |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 931 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 932 | locations->SetInAt(1, Location::RegisterOrConstant(sub->InputAt(1))); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 933 | locations->SetOut(Location::RequiresRegister()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 934 | break; |
| 935 | } |
| 936 | |
| 937 | case Primitive::kPrimBoolean: |
| 938 | case Primitive::kPrimByte: |
| 939 | case Primitive::kPrimChar: |
| 940 | case Primitive::kPrimShort: |
| 941 | LOG(FATAL) << "Unexpected sub type " << sub->GetResultType(); |
| 942 | break; |
| 943 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 944 | default: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 945 | LOG(FATAL) << "Unimplemented sub type " << sub->GetResultType(); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 946 | } |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | void InstructionCodeGeneratorARM::VisitSub(HSub* sub) { |
| 950 | LocationSummary* locations = sub->GetLocations(); |
| 951 | switch (sub->GetResultType()) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 952 | case Primitive::kPrimInt: { |
| 953 | if (locations->InAt(1).IsRegister()) { |
| 954 | __ sub(locations->Out().AsArm().AsCoreRegister(), |
| 955 | locations->InAt(0).AsArm().AsCoreRegister(), |
| 956 | ShifterOperand(locations->InAt(1).AsArm().AsCoreRegister())); |
| 957 | } else { |
| 958 | __ AddConstant(locations->Out().AsArm().AsCoreRegister(), |
| 959 | locations->InAt(0).AsArm().AsCoreRegister(), |
| 960 | -locations->InAt(1).GetConstant()->AsIntConstant()->GetValue()); |
| 961 | } |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 962 | break; |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 963 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 964 | |
| 965 | case Primitive::kPrimLong: |
| 966 | __ subs(locations->Out().AsArm().AsRegisterPairLow(), |
| 967 | locations->InAt(0).AsArm().AsRegisterPairLow(), |
| 968 | ShifterOperand(locations->InAt(1).AsArm().AsRegisterPairLow())); |
| 969 | __ sbc(locations->Out().AsArm().AsRegisterPairHigh(), |
| 970 | locations->InAt(0).AsArm().AsRegisterPairHigh(), |
| 971 | ShifterOperand(locations->InAt(1).AsArm().AsRegisterPairHigh())); |
| 972 | break; |
| 973 | |
| 974 | case Primitive::kPrimBoolean: |
| 975 | case Primitive::kPrimByte: |
| 976 | case Primitive::kPrimChar: |
| 977 | case Primitive::kPrimShort: |
| 978 | LOG(FATAL) << "Unexpected sub type " << sub->GetResultType(); |
| 979 | break; |
| 980 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 981 | default: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 982 | LOG(FATAL) << "Unimplemented sub type " << sub->GetResultType(); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 983 | } |
| 984 | } |
| 985 | |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 986 | void LocationsBuilderARM::VisitNewInstance(HNewInstance* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 987 | LocationSummary* locations = |
| 988 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 989 | InvokeRuntimeCallingConvention calling_convention; |
| 990 | locations->AddTemp(ArmCoreLocation(calling_convention.GetRegisterAt(0))); |
| 991 | locations->AddTemp(ArmCoreLocation(calling_convention.GetRegisterAt(1))); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 992 | locations->SetOut(ArmCoreLocation(R0)); |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | void InstructionCodeGeneratorARM::VisitNewInstance(HNewInstance* instruction) { |
| 996 | InvokeRuntimeCallingConvention calling_convention; |
| 997 | LoadCurrentMethod(calling_convention.GetRegisterAt(1)); |
| 998 | __ LoadImmediate(calling_convention.GetRegisterAt(0), instruction->GetTypeIndex()); |
| 999 | |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 1000 | int32_t offset = QUICK_ENTRYPOINT_OFFSET(kArmWordSize, pAllocObjectWithAccessCheck).Int32Value(); |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 1001 | __ ldr(LR, Address(TR, offset)); |
| 1002 | __ blx(LR); |
| 1003 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1004 | codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 1005 | DCHECK(!codegen_->IsLeafMethod()); |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 1006 | } |
| 1007 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 1008 | void LocationsBuilderARM::VisitParameterValue(HParameterValue* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1009 | LocationSummary* locations = |
| 1010 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 1011 | Location location = parameter_visitor_.GetNextLocation(instruction->GetType()); |
| 1012 | if (location.IsStackSlot()) { |
| 1013 | location = Location::StackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
| 1014 | } else if (location.IsDoubleStackSlot()) { |
| 1015 | location = Location::DoubleStackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 1016 | } |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 1017 | locations->SetOut(location); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | void InstructionCodeGeneratorARM::VisitParameterValue(HParameterValue* instruction) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1021 | // Nothing to do, the parameter is already at its location. |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 1022 | } |
| 1023 | |
Nicolas Geoffray | b55f835 | 2014-04-07 15:26:35 +0100 | [diff] [blame] | 1024 | void LocationsBuilderARM::VisitNot(HNot* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1025 | LocationSummary* locations = |
| 1026 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 1027 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1028 | locations->SetOut(Location::RequiresRegister()); |
Nicolas Geoffray | b55f835 | 2014-04-07 15:26:35 +0100 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | void InstructionCodeGeneratorARM::VisitNot(HNot* instruction) { |
| 1032 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1033 | __ eor(locations->Out().AsArm().AsCoreRegister(), |
| 1034 | locations->InAt(0).AsArm().AsCoreRegister(), ShifterOperand(1)); |
Nicolas Geoffray | b55f835 | 2014-04-07 15:26:35 +0100 | [diff] [blame] | 1035 | } |
| 1036 | |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 1037 | void LocationsBuilderARM::VisitCompare(HCompare* compare) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1038 | LocationSummary* locations = |
| 1039 | new (GetGraph()->GetArena()) LocationSummary(compare, LocationSummary::kNoCall); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 1040 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1041 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1042 | locations->SetOut(Location::RequiresRegister()); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 1043 | } |
| 1044 | |
| 1045 | void InstructionCodeGeneratorARM::VisitCompare(HCompare* compare) { |
| 1046 | Label greater, done; |
| 1047 | LocationSummary* locations = compare->GetLocations(); |
| 1048 | switch (compare->InputAt(0)->GetType()) { |
| 1049 | case Primitive::kPrimLong: { |
| 1050 | Register output = locations->Out().AsArm().AsCoreRegister(); |
| 1051 | ArmManagedRegister left = locations->InAt(0).AsArm(); |
| 1052 | ArmManagedRegister right = locations->InAt(1).AsArm(); |
| 1053 | Label less, greater, done; |
| 1054 | __ cmp(left.AsRegisterPairHigh(), |
| 1055 | ShifterOperand(right.AsRegisterPairHigh())); // Signed compare. |
| 1056 | __ b(&less, LT); |
| 1057 | __ b(&greater, GT); |
Nicolas Geoffray | 8d48673 | 2014-07-16 16:23:40 +0100 | [diff] [blame] | 1058 | // Do LoadImmediate before any `cmp`, as LoadImmediate might affect |
| 1059 | // the status flags. |
| 1060 | __ LoadImmediate(output, 0); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 1061 | __ cmp(left.AsRegisterPairLow(), |
| 1062 | ShifterOperand(right.AsRegisterPairLow())); // Unsigned compare. |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 1063 | __ b(&done, EQ); |
| 1064 | __ b(&less, CC); |
| 1065 | |
| 1066 | __ Bind(&greater); |
| 1067 | __ LoadImmediate(output, 1); |
| 1068 | __ b(&done); |
| 1069 | |
| 1070 | __ Bind(&less); |
| 1071 | __ LoadImmediate(output, -1); |
| 1072 | |
| 1073 | __ Bind(&done); |
| 1074 | break; |
| 1075 | } |
| 1076 | default: |
| 1077 | LOG(FATAL) << "Unimplemented compare type " << compare->InputAt(0)->GetType(); |
| 1078 | } |
| 1079 | } |
| 1080 | |
Nicolas Geoffray | c32e770 | 2014-04-24 12:43:16 +0100 | [diff] [blame] | 1081 | void LocationsBuilderARM::VisitPhi(HPhi* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1082 | LocationSummary* locations = |
| 1083 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 31d76b4 | 2014-06-09 15:02:22 +0100 | [diff] [blame] | 1084 | for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { |
| 1085 | locations->SetInAt(i, Location::Any()); |
| 1086 | } |
| 1087 | locations->SetOut(Location::Any()); |
Nicolas Geoffray | c32e770 | 2014-04-24 12:43:16 +0100 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | void InstructionCodeGeneratorARM::VisitPhi(HPhi* instruction) { |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 1091 | LOG(FATAL) << "Unreachable"; |
Nicolas Geoffray | c32e770 | 2014-04-24 12:43:16 +0100 | [diff] [blame] | 1092 | } |
| 1093 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1094 | void LocationsBuilderARM::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1095 | LocationSummary* locations = |
| 1096 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1097 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1098 | locations->SetInAt(1, Location::RequiresRegister()); |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 1099 | // Temporary registers for the write barrier. |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1100 | if (instruction->GetFieldType() == Primitive::kPrimNot) { |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 1101 | locations->AddTemp(Location::RequiresRegister()); |
| 1102 | locations->AddTemp(Location::RequiresRegister()); |
| 1103 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1104 | } |
| 1105 | |
| 1106 | void InstructionCodeGeneratorARM::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
| 1107 | LocationSummary* locations = instruction->GetLocations(); |
| 1108 | Register obj = locations->InAt(0).AsArm().AsCoreRegister(); |
| 1109 | uint32_t offset = instruction->GetFieldOffset().Uint32Value(); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1110 | Primitive::Type field_type = instruction->GetFieldType(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1111 | |
| 1112 | switch (field_type) { |
| 1113 | case Primitive::kPrimBoolean: |
| 1114 | case Primitive::kPrimByte: { |
| 1115 | Register value = locations->InAt(1).AsArm().AsCoreRegister(); |
| 1116 | __ StoreToOffset(kStoreByte, value, obj, offset); |
| 1117 | break; |
| 1118 | } |
| 1119 | |
| 1120 | case Primitive::kPrimShort: |
| 1121 | case Primitive::kPrimChar: { |
| 1122 | Register value = locations->InAt(1).AsArm().AsCoreRegister(); |
| 1123 | __ StoreToOffset(kStoreHalfword, value, obj, offset); |
| 1124 | break; |
| 1125 | } |
| 1126 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1127 | case Primitive::kPrimInt: |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1128 | case Primitive::kPrimNot: { |
| 1129 | Register value = locations->InAt(1).AsArm().AsCoreRegister(); |
| 1130 | __ StoreToOffset(kStoreWord, value, obj, offset); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1131 | if (field_type == Primitive::kPrimNot) { |
| 1132 | Register temp = locations->GetTemp(0).AsArm().AsCoreRegister(); |
| 1133 | Register card = locations->GetTemp(1).AsArm().AsCoreRegister(); |
| 1134 | codegen_->MarkGCCard(temp, card, obj, value); |
| 1135 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1136 | break; |
| 1137 | } |
| 1138 | |
| 1139 | case Primitive::kPrimLong: { |
| 1140 | ArmManagedRegister value = locations->InAt(1).AsArm(); |
| 1141 | __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow(), obj, offset); |
| 1142 | break; |
| 1143 | } |
| 1144 | |
| 1145 | case Primitive::kPrimFloat: |
| 1146 | case Primitive::kPrimDouble: |
| 1147 | LOG(FATAL) << "Unimplemented register type " << field_type; |
| 1148 | |
| 1149 | case Primitive::kPrimVoid: |
| 1150 | LOG(FATAL) << "Unreachable type " << field_type; |
| 1151 | } |
| 1152 | } |
| 1153 | |
| 1154 | void LocationsBuilderARM::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1155 | LocationSummary* locations = |
| 1156 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1157 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1158 | locations->SetOut(Location::RequiresRegister()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | void InstructionCodeGeneratorARM::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
| 1162 | LocationSummary* locations = instruction->GetLocations(); |
| 1163 | Register obj = locations->InAt(0).AsArm().AsCoreRegister(); |
| 1164 | uint32_t offset = instruction->GetFieldOffset().Uint32Value(); |
| 1165 | |
| 1166 | switch (instruction->GetType()) { |
| 1167 | case Primitive::kPrimBoolean: { |
| 1168 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1169 | __ LoadFromOffset(kLoadUnsignedByte, out, obj, offset); |
| 1170 | break; |
| 1171 | } |
| 1172 | |
| 1173 | case Primitive::kPrimByte: { |
| 1174 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1175 | __ LoadFromOffset(kLoadSignedByte, out, obj, offset); |
| 1176 | break; |
| 1177 | } |
| 1178 | |
| 1179 | case Primitive::kPrimShort: { |
| 1180 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1181 | __ LoadFromOffset(kLoadSignedHalfword, out, obj, offset); |
| 1182 | break; |
| 1183 | } |
| 1184 | |
| 1185 | case Primitive::kPrimChar: { |
| 1186 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1187 | __ LoadFromOffset(kLoadUnsignedHalfword, out, obj, offset); |
| 1188 | break; |
| 1189 | } |
| 1190 | |
| 1191 | case Primitive::kPrimInt: |
| 1192 | case Primitive::kPrimNot: { |
| 1193 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1194 | __ LoadFromOffset(kLoadWord, out, obj, offset); |
| 1195 | break; |
| 1196 | } |
| 1197 | |
| 1198 | case Primitive::kPrimLong: { |
| 1199 | // TODO: support volatile. |
| 1200 | ArmManagedRegister out = locations->Out().AsArm(); |
| 1201 | __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow(), obj, offset); |
| 1202 | break; |
| 1203 | } |
| 1204 | |
| 1205 | case Primitive::kPrimFloat: |
| 1206 | case Primitive::kPrimDouble: |
| 1207 | LOG(FATAL) << "Unimplemented register type " << instruction->GetType(); |
| 1208 | |
| 1209 | case Primitive::kPrimVoid: |
| 1210 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
| 1211 | } |
| 1212 | } |
| 1213 | |
| 1214 | void LocationsBuilderARM::VisitNullCheck(HNullCheck* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1215 | LocationSummary* locations = |
| 1216 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1217 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1218 | // TODO: Have a normalization phase that makes this instruction never used. |
| 1219 | locations->SetOut(Location::SameAsFirstInput()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | void InstructionCodeGeneratorARM::VisitNullCheck(HNullCheck* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1223 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) NullCheckSlowPathARM(instruction); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1224 | codegen_->AddSlowPath(slow_path); |
| 1225 | |
| 1226 | LocationSummary* locations = instruction->GetLocations(); |
| 1227 | Location obj = locations->InAt(0); |
| 1228 | DCHECK(obj.Equals(locations->Out())); |
| 1229 | |
| 1230 | if (obj.IsRegister()) { |
| 1231 | __ cmp(obj.AsArm().AsCoreRegister(), ShifterOperand(0)); |
| 1232 | } |
| 1233 | __ b(slow_path->GetEntryLabel(), EQ); |
| 1234 | } |
| 1235 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1236 | void LocationsBuilderARM::VisitArrayGet(HArrayGet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1237 | LocationSummary* locations = |
| 1238 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1239 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1240 | locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 1241 | locations->SetOut(Location::RequiresRegister()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | void InstructionCodeGeneratorARM::VisitArrayGet(HArrayGet* instruction) { |
| 1245 | LocationSummary* locations = instruction->GetLocations(); |
| 1246 | Register obj = locations->InAt(0).AsArm().AsCoreRegister(); |
| 1247 | Location index = locations->InAt(1); |
| 1248 | |
| 1249 | switch (instruction->GetType()) { |
| 1250 | case Primitive::kPrimBoolean: { |
| 1251 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
| 1252 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1253 | if (index.IsConstant()) { |
| 1254 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
| 1255 | __ LoadFromOffset(kLoadUnsignedByte, out, obj, offset); |
| 1256 | } else { |
| 1257 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister())); |
| 1258 | __ LoadFromOffset(kLoadUnsignedByte, out, IP, data_offset); |
| 1259 | } |
| 1260 | break; |
| 1261 | } |
| 1262 | |
| 1263 | case Primitive::kPrimByte: { |
| 1264 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int8_t)).Uint32Value(); |
| 1265 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1266 | if (index.IsConstant()) { |
| 1267 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
| 1268 | __ LoadFromOffset(kLoadSignedByte, out, obj, offset); |
| 1269 | } else { |
| 1270 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister())); |
| 1271 | __ LoadFromOffset(kLoadSignedByte, out, IP, data_offset); |
| 1272 | } |
| 1273 | break; |
| 1274 | } |
| 1275 | |
| 1276 | case Primitive::kPrimShort: { |
| 1277 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int16_t)).Uint32Value(); |
| 1278 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1279 | if (index.IsConstant()) { |
| 1280 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
| 1281 | __ LoadFromOffset(kLoadSignedHalfword, out, obj, offset); |
| 1282 | } else { |
| 1283 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister(), LSL, TIMES_2)); |
| 1284 | __ LoadFromOffset(kLoadSignedHalfword, out, IP, data_offset); |
| 1285 | } |
| 1286 | break; |
| 1287 | } |
| 1288 | |
| 1289 | case Primitive::kPrimChar: { |
| 1290 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
| 1291 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1292 | if (index.IsConstant()) { |
| 1293 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
| 1294 | __ LoadFromOffset(kLoadUnsignedHalfword, out, obj, offset); |
| 1295 | } else { |
| 1296 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister(), LSL, TIMES_2)); |
| 1297 | __ LoadFromOffset(kLoadUnsignedHalfword, out, IP, data_offset); |
| 1298 | } |
| 1299 | break; |
| 1300 | } |
| 1301 | |
| 1302 | case Primitive::kPrimInt: |
| 1303 | case Primitive::kPrimNot: { |
| 1304 | DCHECK_EQ(sizeof(mirror::HeapReference<mirror::Object>), sizeof(int32_t)); |
| 1305 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
| 1306 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1307 | if (index.IsConstant()) { |
| 1308 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 1309 | __ LoadFromOffset(kLoadWord, out, obj, offset); |
| 1310 | } else { |
| 1311 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister(), LSL, TIMES_4)); |
| 1312 | __ LoadFromOffset(kLoadWord, out, IP, data_offset); |
| 1313 | } |
| 1314 | break; |
| 1315 | } |
| 1316 | |
| 1317 | case Primitive::kPrimLong: { |
| 1318 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
| 1319 | ArmManagedRegister out = locations->Out().AsArm(); |
| 1320 | if (index.IsConstant()) { |
| 1321 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 1322 | __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow(), obj, offset); |
| 1323 | } else { |
| 1324 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister(), LSL, TIMES_8)); |
| 1325 | __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow(), IP, data_offset); |
| 1326 | } |
| 1327 | break; |
| 1328 | } |
| 1329 | |
| 1330 | case Primitive::kPrimFloat: |
| 1331 | case Primitive::kPrimDouble: |
| 1332 | LOG(FATAL) << "Unimplemented register type " << instruction->GetType(); |
| 1333 | |
| 1334 | case Primitive::kPrimVoid: |
| 1335 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
| 1336 | } |
| 1337 | } |
| 1338 | |
| 1339 | void LocationsBuilderARM::VisitArraySet(HArraySet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1340 | Primitive::Type value_type = instruction->GetComponentType(); |
| 1341 | bool is_object = value_type == Primitive::kPrimNot; |
| 1342 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary( |
| 1343 | instruction, is_object ? LocationSummary::kCall : LocationSummary::kNoCall); |
| 1344 | if (is_object) { |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1345 | InvokeRuntimeCallingConvention calling_convention; |
| 1346 | locations->SetInAt(0, ArmCoreLocation(calling_convention.GetRegisterAt(0))); |
| 1347 | locations->SetInAt(1, ArmCoreLocation(calling_convention.GetRegisterAt(1))); |
| 1348 | locations->SetInAt(2, ArmCoreLocation(calling_convention.GetRegisterAt(2))); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1349 | } else { |
| 1350 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1351 | locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 1352 | locations->SetInAt(2, Location::RequiresRegister()); |
| 1353 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | void InstructionCodeGeneratorARM::VisitArraySet(HArraySet* instruction) { |
| 1357 | LocationSummary* locations = instruction->GetLocations(); |
| 1358 | Register obj = locations->InAt(0).AsArm().AsCoreRegister(); |
| 1359 | Location index = locations->InAt(1); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1360 | Primitive::Type value_type = instruction->GetComponentType(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1361 | |
| 1362 | switch (value_type) { |
| 1363 | case Primitive::kPrimBoolean: |
| 1364 | case Primitive::kPrimByte: { |
| 1365 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
| 1366 | Register value = locations->InAt(2).AsArm().AsCoreRegister(); |
| 1367 | if (index.IsConstant()) { |
| 1368 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
| 1369 | __ StoreToOffset(kStoreByte, value, obj, offset); |
| 1370 | } else { |
| 1371 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister())); |
| 1372 | __ StoreToOffset(kStoreByte, value, IP, data_offset); |
| 1373 | } |
| 1374 | break; |
| 1375 | } |
| 1376 | |
| 1377 | case Primitive::kPrimShort: |
| 1378 | case Primitive::kPrimChar: { |
| 1379 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
| 1380 | Register value = locations->InAt(2).AsArm().AsCoreRegister(); |
| 1381 | if (index.IsConstant()) { |
| 1382 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
| 1383 | __ StoreToOffset(kStoreHalfword, value, obj, offset); |
| 1384 | } else { |
| 1385 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister(), LSL, TIMES_2)); |
| 1386 | __ StoreToOffset(kStoreHalfword, value, IP, data_offset); |
| 1387 | } |
| 1388 | break; |
| 1389 | } |
| 1390 | |
| 1391 | case Primitive::kPrimInt: { |
| 1392 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
| 1393 | Register value = locations->InAt(2).AsArm().AsCoreRegister(); |
| 1394 | if (index.IsConstant()) { |
| 1395 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 1396 | __ StoreToOffset(kStoreWord, value, obj, offset); |
| 1397 | } else { |
| 1398 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister(), LSL, TIMES_4)); |
| 1399 | __ StoreToOffset(kStoreWord, value, IP, data_offset); |
| 1400 | } |
| 1401 | break; |
| 1402 | } |
| 1403 | |
| 1404 | case Primitive::kPrimNot: { |
| 1405 | int32_t offset = QUICK_ENTRYPOINT_OFFSET(kArmWordSize, pAputObject).Int32Value(); |
| 1406 | __ ldr(LR, Address(TR, offset)); |
| 1407 | __ blx(LR); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1408 | codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1409 | DCHECK(!codegen_->IsLeafMethod()); |
| 1410 | break; |
| 1411 | } |
| 1412 | |
| 1413 | case Primitive::kPrimLong: { |
| 1414 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
| 1415 | ArmManagedRegister value = locations->InAt(2).AsArm(); |
| 1416 | if (index.IsConstant()) { |
| 1417 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 1418 | __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow(), obj, offset); |
| 1419 | } else { |
| 1420 | __ add(IP, obj, ShifterOperand(index.AsArm().AsCoreRegister(), LSL, TIMES_8)); |
| 1421 | __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow(), IP, data_offset); |
| 1422 | } |
| 1423 | break; |
| 1424 | } |
| 1425 | |
| 1426 | case Primitive::kPrimFloat: |
| 1427 | case Primitive::kPrimDouble: |
| 1428 | LOG(FATAL) << "Unimplemented register type " << instruction->GetType(); |
| 1429 | |
| 1430 | case Primitive::kPrimVoid: |
| 1431 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
| 1432 | } |
| 1433 | } |
| 1434 | |
| 1435 | void LocationsBuilderARM::VisitArrayLength(HArrayLength* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1436 | LocationSummary* locations = |
| 1437 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1438 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1439 | locations->SetOut(Location::RequiresRegister()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | void InstructionCodeGeneratorARM::VisitArrayLength(HArrayLength* instruction) { |
| 1443 | LocationSummary* locations = instruction->GetLocations(); |
| 1444 | uint32_t offset = mirror::Array::LengthOffset().Uint32Value(); |
| 1445 | Register obj = locations->InAt(0).AsArm().AsCoreRegister(); |
| 1446 | Register out = locations->Out().AsArm().AsCoreRegister(); |
| 1447 | __ LoadFromOffset(kLoadWord, out, obj, offset); |
| 1448 | } |
| 1449 | |
| 1450 | void LocationsBuilderARM::VisitBoundsCheck(HBoundsCheck* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1451 | LocationSummary* locations = |
| 1452 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1453 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1454 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1455 | // TODO: Have a normalization phase that makes this instruction never used. |
| 1456 | locations->SetOut(Location::SameAsFirstInput()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1457 | } |
| 1458 | |
| 1459 | void InstructionCodeGeneratorARM::VisitBoundsCheck(HBoundsCheck* instruction) { |
| 1460 | LocationSummary* locations = instruction->GetLocations(); |
| 1461 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) BoundsCheckSlowPathARM( |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame^] | 1462 | instruction, locations->InAt(0), locations->InAt(1)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1463 | codegen_->AddSlowPath(slow_path); |
| 1464 | |
| 1465 | Register index = locations->InAt(0).AsArm().AsCoreRegister(); |
| 1466 | Register length = locations->InAt(1).AsArm().AsCoreRegister(); |
| 1467 | |
| 1468 | __ cmp(index, ShifterOperand(length)); |
| 1469 | __ b(slow_path->GetEntryLabel(), CS); |
| 1470 | } |
| 1471 | |
| 1472 | void CodeGeneratorARM::MarkGCCard(Register temp, Register card, Register object, Register value) { |
| 1473 | Label is_null; |
| 1474 | __ CompareAndBranchIfZero(value, &is_null); |
| 1475 | __ LoadFromOffset(kLoadWord, card, TR, Thread::CardTableOffset<kArmWordSize>().Int32Value()); |
| 1476 | __ Lsr(temp, object, gc::accounting::CardTable::kCardShift); |
| 1477 | __ strb(card, Address(card, temp)); |
| 1478 | __ Bind(&is_null); |
| 1479 | } |
| 1480 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1481 | void LocationsBuilderARM::VisitTemporary(HTemporary* temp) { |
| 1482 | temp->SetLocations(nullptr); |
| 1483 | } |
| 1484 | |
| 1485 | void InstructionCodeGeneratorARM::VisitTemporary(HTemporary* temp) { |
| 1486 | // Nothing to do, this is driven by the code generator. |
| 1487 | } |
| 1488 | |
Nicolas Geoffray | 4e3d23a | 2014-05-22 18:32:45 +0100 | [diff] [blame] | 1489 | void LocationsBuilderARM::VisitParallelMove(HParallelMove* instruction) { |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 1490 | LOG(FATAL) << "Unreachable"; |
Nicolas Geoffray | 4e3d23a | 2014-05-22 18:32:45 +0100 | [diff] [blame] | 1491 | } |
| 1492 | |
| 1493 | void InstructionCodeGeneratorARM::VisitParallelMove(HParallelMove* instruction) { |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 1494 | codegen_->GetMoveResolver()->EmitNativeCode(instruction); |
| 1495 | } |
| 1496 | |
| 1497 | ArmAssembler* ParallelMoveResolverARM::GetAssembler() const { |
| 1498 | return codegen_->GetAssembler(); |
| 1499 | } |
| 1500 | |
| 1501 | void ParallelMoveResolverARM::EmitMove(size_t index) { |
| 1502 | MoveOperands* move = moves_.Get(index); |
| 1503 | Location source = move->GetSource(); |
| 1504 | Location destination = move->GetDestination(); |
| 1505 | |
| 1506 | if (source.IsRegister()) { |
| 1507 | if (destination.IsRegister()) { |
| 1508 | __ Mov(destination.AsArm().AsCoreRegister(), source.AsArm().AsCoreRegister()); |
| 1509 | } else { |
| 1510 | DCHECK(destination.IsStackSlot()); |
| 1511 | __ StoreToOffset(kStoreWord, source.AsArm().AsCoreRegister(), |
| 1512 | SP, destination.GetStackIndex()); |
| 1513 | } |
| 1514 | } else if (source.IsStackSlot()) { |
| 1515 | if (destination.IsRegister()) { |
| 1516 | __ LoadFromOffset(kLoadWord, destination.AsArm().AsCoreRegister(), |
| 1517 | SP, source.GetStackIndex()); |
| 1518 | } else { |
| 1519 | DCHECK(destination.IsStackSlot()); |
| 1520 | __ LoadFromOffset(kLoadWord, IP, SP, source.GetStackIndex()); |
| 1521 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex()); |
| 1522 | } |
| 1523 | } else { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1524 | DCHECK(source.IsConstant()); |
| 1525 | DCHECK(source.GetConstant()->AsIntConstant() != nullptr); |
| 1526 | int32_t value = source.GetConstant()->AsIntConstant()->GetValue(); |
| 1527 | if (destination.IsRegister()) { |
| 1528 | __ LoadImmediate(destination.AsArm().AsCoreRegister(), value); |
| 1529 | } else { |
| 1530 | DCHECK(destination.IsStackSlot()); |
| 1531 | __ LoadImmediate(IP, value); |
| 1532 | __ str(IP, Address(SP, destination.GetStackIndex())); |
| 1533 | } |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | void ParallelMoveResolverARM::Exchange(Register reg, int mem) { |
| 1538 | __ Mov(IP, reg); |
| 1539 | __ LoadFromOffset(kLoadWord, reg, SP, mem); |
| 1540 | __ StoreToOffset(kStoreWord, IP, SP, mem); |
| 1541 | } |
| 1542 | |
| 1543 | void ParallelMoveResolverARM::Exchange(int mem1, int mem2) { |
| 1544 | ScratchRegisterScope ensure_scratch(this, IP, R0, codegen_->GetNumberOfCoreRegisters()); |
| 1545 | int stack_offset = ensure_scratch.IsSpilled() ? kArmWordSize : 0; |
| 1546 | __ LoadFromOffset(kLoadWord, static_cast<Register>(ensure_scratch.GetRegister()), |
| 1547 | SP, mem1 + stack_offset); |
| 1548 | __ LoadFromOffset(kLoadWord, IP, SP, mem2 + stack_offset); |
| 1549 | __ StoreToOffset(kStoreWord, static_cast<Register>(ensure_scratch.GetRegister()), |
| 1550 | SP, mem2 + stack_offset); |
| 1551 | __ StoreToOffset(kStoreWord, IP, SP, mem1 + stack_offset); |
| 1552 | } |
| 1553 | |
| 1554 | void ParallelMoveResolverARM::EmitSwap(size_t index) { |
| 1555 | MoveOperands* move = moves_.Get(index); |
| 1556 | Location source = move->GetSource(); |
| 1557 | Location destination = move->GetDestination(); |
| 1558 | |
| 1559 | if (source.IsRegister() && destination.IsRegister()) { |
| 1560 | DCHECK_NE(source.AsArm().AsCoreRegister(), IP); |
| 1561 | DCHECK_NE(destination.AsArm().AsCoreRegister(), IP); |
| 1562 | __ Mov(IP, source.AsArm().AsCoreRegister()); |
| 1563 | __ Mov(source.AsArm().AsCoreRegister(), destination.AsArm().AsCoreRegister()); |
| 1564 | __ Mov(destination.AsArm().AsCoreRegister(), IP); |
| 1565 | } else if (source.IsRegister() && destination.IsStackSlot()) { |
| 1566 | Exchange(source.AsArm().AsCoreRegister(), destination.GetStackIndex()); |
| 1567 | } else if (source.IsStackSlot() && destination.IsRegister()) { |
| 1568 | Exchange(destination.AsArm().AsCoreRegister(), source.GetStackIndex()); |
| 1569 | } else if (source.IsStackSlot() && destination.IsStackSlot()) { |
| 1570 | Exchange(source.GetStackIndex(), destination.GetStackIndex()); |
| 1571 | } else { |
| 1572 | LOG(FATAL) << "Unimplemented"; |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | void ParallelMoveResolverARM::SpillScratch(int reg) { |
| 1577 | __ Push(static_cast<Register>(reg)); |
| 1578 | } |
| 1579 | |
| 1580 | void ParallelMoveResolverARM::RestoreScratch(int reg) { |
| 1581 | __ Pop(static_cast<Register>(reg)); |
Nicolas Geoffray | 4e3d23a | 2014-05-22 18:32:45 +0100 | [diff] [blame] | 1582 | } |
| 1583 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1584 | } // namespace arm |
| 1585 | } // namespace art |