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