blob: 982d6d40310ca543ba17004c3541779efc7109bd [file] [log] [blame]
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +00001/*
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 Geoffrayd4dd2552014-02-28 10:23:58 +000018
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070019#include "entrypoints/quick/quick_entrypoints.h"
Nicolas Geoffray1a43dd72014-07-17 15:15:34 +010020#include "gc/accounting/card_table.h"
Ian Rogers7e70b002014-10-08 11:47:24 -070021#include "mirror/array-inl.h"
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000022#include "mirror/art_method.h"
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +010023#include "mirror/class.h"
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070024#include "thread.h"
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010025#include "utils/assembler.h"
26#include "utils/arm/assembler_arm.h"
27#include "utils/arm/managed_register_arm.h"
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +010028#include "utils/stack_checks.h"
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000029
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000030namespace art {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +010031
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000032namespace arm {
33
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +000034static DRegister FromLowSToD(SRegister reg) {
35 DCHECK_EQ(reg % 2, 0);
36 return static_cast<DRegister>(reg / 2);
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +010037}
38
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +010039static constexpr bool kExplicitStackOverflowCheck = false;
40
41static constexpr int kNumberOfPushedRegistersAtEntry = 1 + 2; // LR, R6, R7
42static constexpr int kCurrentMethodStackOffset = 0;
43
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +010044static constexpr Register kRuntimeParameterCoreRegisters[] = { R0, R1, R2 };
45static constexpr size_t kRuntimeParameterCoreRegistersLength =
46 arraysize(kRuntimeParameterCoreRegisters);
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +000047static constexpr SRegister kRuntimeParameterFpuRegisters[] = { };
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010048static constexpr size_t kRuntimeParameterFpuRegistersLength = 0;
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +010049
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +000050class InvokeRuntimeCallingConvention : public CallingConvention<Register, SRegister> {
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +010051 public:
52 InvokeRuntimeCallingConvention()
53 : CallingConvention(kRuntimeParameterCoreRegisters,
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010054 kRuntimeParameterCoreRegistersLength,
55 kRuntimeParameterFpuRegisters,
56 kRuntimeParameterFpuRegistersLength) {}
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +010057
58 private:
59 DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention);
60};
61
Nicolas Geoffraye5038322014-07-04 09:41:32 +010062#define __ reinterpret_cast<ArmAssembler*>(codegen->GetAssembler())->
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +010063#define QUICK_ENTRY_POINT(x) QUICK_ENTRYPOINT_OFFSET(kArmWordSize, x).Int32Value()
Nicolas Geoffraye5038322014-07-04 09:41:32 +010064
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +010065class SlowPathCodeARM : public SlowPathCode {
66 public:
67 SlowPathCodeARM() : entry_label_(), exit_label_() {}
68
69 Label* GetEntryLabel() { return &entry_label_; }
70 Label* GetExitLabel() { return &exit_label_; }
71
72 private:
73 Label entry_label_;
74 Label exit_label_;
75
76 DISALLOW_COPY_AND_ASSIGN(SlowPathCodeARM);
77};
78
79class NullCheckSlowPathARM : public SlowPathCodeARM {
Nicolas Geoffraye5038322014-07-04 09:41:32 +010080 public:
Nicolas Geoffray39468442014-09-02 15:17:15 +010081 explicit NullCheckSlowPathARM(HNullCheck* instruction) : instruction_(instruction) {}
Nicolas Geoffraye5038322014-07-04 09:41:32 +010082
83 virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +010084 CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen);
Nicolas Geoffraye5038322014-07-04 09:41:32 +010085 __ Bind(GetEntryLabel());
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +010086 arm_codegen->InvokeRuntime(
87 QUICK_ENTRY_POINT(pThrowNullPointer), instruction_, instruction_->GetDexPc());
Nicolas Geoffraye5038322014-07-04 09:41:32 +010088 }
89
90 private:
Nicolas Geoffray39468442014-09-02 15:17:15 +010091 HNullCheck* const instruction_;
Nicolas Geoffraye5038322014-07-04 09:41:32 +010092 DISALLOW_COPY_AND_ASSIGN(NullCheckSlowPathARM);
93};
94
Calin Juravled0d48522014-11-04 16:40:20 +000095class DivZeroCheckSlowPathARM : public SlowPathCodeARM {
96 public:
97 explicit DivZeroCheckSlowPathARM(HDivZeroCheck* instruction) : instruction_(instruction) {}
98
99 virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE {
100 CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen);
101 __ Bind(GetEntryLabel());
102 arm_codegen->InvokeRuntime(
103 QUICK_ENTRY_POINT(pThrowDivZero), instruction_, instruction_->GetDexPc());
104 }
105
106 private:
107 HDivZeroCheck* const instruction_;
108 DISALLOW_COPY_AND_ASSIGN(DivZeroCheckSlowPathARM);
109};
110
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100111class StackOverflowCheckSlowPathARM : public SlowPathCodeARM {
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100112 public:
113 StackOverflowCheckSlowPathARM() {}
114
115 virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE {
116 __ Bind(GetEntryLabel());
117 __ LoadFromOffset(kLoadWord, PC, TR,
118 QUICK_ENTRYPOINT_OFFSET(kArmWordSize, pThrowStackOverflow).Int32Value());
119 }
120
121 private:
122 DISALLOW_COPY_AND_ASSIGN(StackOverflowCheckSlowPathARM);
123};
124
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100125class SuspendCheckSlowPathARM : public SlowPathCodeARM {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000126 public:
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100127 explicit SuspendCheckSlowPathARM(HSuspendCheck* instruction, HBasicBlock* successor)
128 : instruction_(instruction), successor_(successor) {}
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000129
130 virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE {
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100131 CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen);
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000132 __ Bind(GetEntryLabel());
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100133 codegen->SaveLiveRegisters(instruction_->GetLocations());
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100134 arm_codegen->InvokeRuntime(
135 QUICK_ENTRY_POINT(pTestSuspend), instruction_, instruction_->GetDexPc());
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100136 codegen->RestoreLiveRegisters(instruction_->GetLocations());
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100137 if (successor_ == nullptr) {
138 __ b(GetReturnLabel());
139 } else {
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100140 __ b(arm_codegen->GetLabelOf(successor_));
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100141 }
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000142 }
143
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100144 Label* GetReturnLabel() {
145 DCHECK(successor_ == nullptr);
146 return &return_label_;
147 }
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000148
149 private:
150 HSuspendCheck* const instruction_;
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100151 // If not null, the block to branch to after the suspend check.
152 HBasicBlock* const successor_;
153
154 // If `successor_` is null, the label to branch to after the suspend check.
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000155 Label return_label_;
156
157 DISALLOW_COPY_AND_ASSIGN(SuspendCheckSlowPathARM);
158};
159
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100160class BoundsCheckSlowPathARM : public SlowPathCodeARM {
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100161 public:
Roland Levillain5799fc02014-09-25 12:15:20 +0100162 BoundsCheckSlowPathARM(HBoundsCheck* instruction,
163 Location index_location,
164 Location length_location)
Nicolas Geoffray39468442014-09-02 15:17:15 +0100165 : instruction_(instruction),
166 index_location_(index_location),
167 length_location_(length_location) {}
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100168
169 virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE {
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100170 CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100171 __ Bind(GetEntryLabel());
172 InvokeRuntimeCallingConvention calling_convention;
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100173 arm_codegen->Move32(
174 Location::RegisterLocation(calling_convention.GetRegisterAt(0)), index_location_);
175 arm_codegen->Move32(
176 Location::RegisterLocation(calling_convention.GetRegisterAt(1)), length_location_);
177 arm_codegen->InvokeRuntime(
178 QUICK_ENTRY_POINT(pThrowArrayBounds), instruction_, instruction_->GetDexPc());
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100179 }
180
181 private:
Nicolas Geoffray39468442014-09-02 15:17:15 +0100182 HBoundsCheck* const instruction_;
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100183 const Location index_location_;
184 const Location length_location_;
185
186 DISALLOW_COPY_AND_ASSIGN(BoundsCheckSlowPathARM);
187};
188
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000189class LoadClassSlowPathARM : public SlowPathCodeARM {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100190 public:
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000191 LoadClassSlowPathARM(HLoadClass* cls,
192 HInstruction* at,
193 uint32_t dex_pc,
194 bool do_clinit)
195 : cls_(cls), at_(at), dex_pc_(dex_pc), do_clinit_(do_clinit) {
196 DCHECK(at->IsLoadClass() || at->IsClinitCheck());
197 }
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100198
199 virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE {
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000200 LocationSummary* locations = at_->GetLocations();
201
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100202 CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen);
203 __ Bind(GetEntryLabel());
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000204 codegen->SaveLiveRegisters(locations);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100205
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100206 InvokeRuntimeCallingConvention calling_convention;
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000207 __ LoadImmediate(calling_convention.GetRegisterAt(0), cls_->GetTypeIndex());
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100208 arm_codegen->LoadCurrentMethod(calling_convention.GetRegisterAt(1));
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000209 int32_t entry_point_offset = do_clinit_
210 ? QUICK_ENTRY_POINT(pInitializeStaticStorage)
211 : QUICK_ENTRY_POINT(pInitializeType);
212 arm_codegen->InvokeRuntime(entry_point_offset, at_, dex_pc_);
213
214 // Move the class to the desired location.
215 if (locations->Out().IsValid()) {
216 DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg()));
217 arm_codegen->Move32(locations->Out(), Location::RegisterLocation(R0));
218 }
219 codegen->RestoreLiveRegisters(locations);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100220 __ b(GetExitLabel());
221 }
222
223 private:
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000224 // The class this slow path will load.
225 HLoadClass* const cls_;
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100226
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000227 // The instruction where this slow path is happening.
228 // (Might be the load class or an initialization check).
229 HInstruction* const at_;
230
231 // The dex PC of `at_`.
232 const uint32_t dex_pc_;
233
234 // Whether to initialize the class.
235 const bool do_clinit_;
236
237 DISALLOW_COPY_AND_ASSIGN(LoadClassSlowPathARM);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100238};
239
Nicolas Geoffrayb5f62b32014-10-30 10:58:41 +0000240class LoadStringSlowPathARM : public SlowPathCodeARM {
241 public:
242 explicit LoadStringSlowPathARM(HLoadString* instruction) : instruction_(instruction) {}
243
244 virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE {
245 LocationSummary* locations = instruction_->GetLocations();
246 DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg()));
247
248 CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen);
249 __ Bind(GetEntryLabel());
250 codegen->SaveLiveRegisters(locations);
251
252 InvokeRuntimeCallingConvention calling_convention;
253 arm_codegen->LoadCurrentMethod(calling_convention.GetRegisterAt(0));
254 __ LoadImmediate(calling_convention.GetRegisterAt(1), instruction_->GetStringIndex());
255 arm_codegen->InvokeRuntime(
256 QUICK_ENTRY_POINT(pResolveString), instruction_, instruction_->GetDexPc());
257 arm_codegen->Move32(locations->Out(), Location::RegisterLocation(R0));
258
259 codegen->RestoreLiveRegisters(locations);
260 __ b(GetExitLabel());
261 }
262
263 private:
264 HLoadString* const instruction_;
265
266 DISALLOW_COPY_AND_ASSIGN(LoadStringSlowPathARM);
267};
268
269#undef __
270
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100271#undef __
272#define __ reinterpret_cast<ArmAssembler*>(GetAssembler())->
Dave Allison20dfc792014-06-16 20:44:29 -0700273
274inline Condition ARMCondition(IfCondition cond) {
275 switch (cond) {
276 case kCondEQ: return EQ;
277 case kCondNE: return NE;
278 case kCondLT: return LT;
279 case kCondLE: return LE;
280 case kCondGT: return GT;
281 case kCondGE: return GE;
282 default:
283 LOG(FATAL) << "Unknown if condition";
284 }
285 return EQ; // Unreachable.
286}
287
288inline Condition ARMOppositeCondition(IfCondition cond) {
289 switch (cond) {
290 case kCondEQ: return NE;
291 case kCondNE: return EQ;
292 case kCondLT: return GE;
293 case kCondLE: return GT;
294 case kCondGT: return LE;
295 case kCondGE: return LT;
296 default:
297 LOG(FATAL) << "Unknown if condition";
298 }
299 return EQ; // Unreachable.
300}
301
Nicolas Geoffraya7062e02014-05-22 12:50:17 +0100302void CodeGeneratorARM::DumpCoreRegister(std::ostream& stream, int reg) const {
303 stream << ArmManagedRegister::FromCoreRegister(Register(reg));
304}
305
306void CodeGeneratorARM::DumpFloatingPointRegister(std::ostream& stream, int reg) const {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000307 stream << ArmManagedRegister::FromSRegister(SRegister(reg));
Nicolas Geoffraya7062e02014-05-22 12:50:17 +0100308}
309
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100310size_t CodeGeneratorARM::SaveCoreRegister(size_t stack_index, uint32_t reg_id) {
311 __ StoreToOffset(kStoreWord, static_cast<Register>(reg_id), SP, stack_index);
312 return kArmWordSize;
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100313}
314
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100315size_t CodeGeneratorARM::RestoreCoreRegister(size_t stack_index, uint32_t reg_id) {
316 __ LoadFromOffset(kLoadWord, static_cast<Register>(reg_id), SP, stack_index);
317 return kArmWordSize;
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100318}
319
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100320CodeGeneratorARM::CodeGeneratorARM(HGraph* graph)
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000321 : CodeGenerator(graph, kNumberOfCoreRegisters, kNumberOfSRegisters, kNumberOfRegisterPairs),
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100322 block_labels_(graph->GetArena(), 0),
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100323 location_builder_(graph, this),
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +0100324 instruction_visitor_(graph, this),
Nicolas Geoffray8d486732014-07-16 16:23:40 +0100325 move_resolver_(graph->GetArena(), this),
326 assembler_(true) {}
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100327
Nicolas Geoffrayab032bc2014-07-15 12:55:21 +0100328size_t CodeGeneratorARM::FrameEntrySpillSize() const {
329 return kNumberOfPushedRegistersAtEntry * kArmWordSize;
330}
331
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100332Location CodeGeneratorARM::AllocateFreeRegister(Primitive::Type type) const {
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100333 switch (type) {
334 case Primitive::kPrimLong: {
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100335 size_t reg = FindFreeEntry(blocked_register_pairs_, kNumberOfRegisterPairs);
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100336 ArmManagedRegister pair =
337 ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(reg));
Calin Juravle34bacdf2014-10-07 20:23:36 +0100338 DCHECK(!blocked_core_registers_[pair.AsRegisterPairLow()]);
339 DCHECK(!blocked_core_registers_[pair.AsRegisterPairHigh()]);
340
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100341 blocked_core_registers_[pair.AsRegisterPairLow()] = true;
342 blocked_core_registers_[pair.AsRegisterPairHigh()] = true;
Calin Juravle34bacdf2014-10-07 20:23:36 +0100343 UpdateBlockedPairRegisters();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100344 return Location::RegisterPairLocation(pair.AsRegisterPairLow(), pair.AsRegisterPairHigh());
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100345 }
346
347 case Primitive::kPrimByte:
348 case Primitive::kPrimBoolean:
349 case Primitive::kPrimChar:
350 case Primitive::kPrimShort:
351 case Primitive::kPrimInt:
352 case Primitive::kPrimNot: {
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100353 int reg = FindFreeEntry(blocked_core_registers_, kNumberOfCoreRegisters);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100354 // Block all register pairs that contain `reg`.
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100355 for (int i = 0; i < kNumberOfRegisterPairs; i++) {
356 ArmManagedRegister current =
357 ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(i));
358 if (current.AsRegisterPairLow() == reg || current.AsRegisterPairHigh() == reg) {
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100359 blocked_register_pairs_[i] = true;
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100360 }
361 }
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100362 return Location::RegisterLocation(reg);
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100363 }
364
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000365 case Primitive::kPrimFloat: {
366 int reg = FindFreeEntry(blocked_fpu_registers_, kNumberOfSRegisters);
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100367 return Location::FpuRegisterLocation(reg);
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100368 }
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100369
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000370 case Primitive::kPrimDouble: {
Nicolas Geoffray3c035032014-10-28 10:46:40 +0000371 int reg = FindTwoFreeConsecutiveAlignedEntries(blocked_fpu_registers_, kNumberOfSRegisters);
372 DCHECK_EQ(reg % 2, 0);
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000373 return Location::FpuRegisterPairLocation(reg, reg + 1);
374 }
375
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100376 case Primitive::kPrimVoid:
377 LOG(FATAL) << "Unreachable type " << type;
378 }
379
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100380 return Location();
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100381}
382
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100383void CodeGeneratorARM::SetupBlockedRegisters() const {
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100384 // Don't allocate the dalvik style register pair passing.
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100385 blocked_register_pairs_[R1_R2] = true;
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100386
387 // Stack register, LR and PC are always reserved.
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100388 blocked_core_registers_[SP] = true;
389 blocked_core_registers_[LR] = true;
390 blocked_core_registers_[PC] = true;
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100391
392 // Reserve R4 for suspend check.
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100393 blocked_core_registers_[R4] = true;
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100394
395 // Reserve thread register.
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100396 blocked_core_registers_[TR] = true;
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100397
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +0100398 // Reserve temp register.
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100399 blocked_core_registers_[IP] = true;
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +0100400
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100401 // TODO: We currently don't use Quick's callee saved registers.
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100402 // We always save and restore R6 and R7 to make sure we can use three
403 // register pairs for long operations.
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100404 blocked_core_registers_[R5] = true;
405 blocked_core_registers_[R8] = true;
406 blocked_core_registers_[R10] = true;
407 blocked_core_registers_[R11] = true;
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100408
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000409 blocked_fpu_registers_[S16] = true;
410 blocked_fpu_registers_[S17] = true;
411 blocked_fpu_registers_[S18] = true;
412 blocked_fpu_registers_[S19] = true;
413 blocked_fpu_registers_[S20] = true;
414 blocked_fpu_registers_[S21] = true;
415 blocked_fpu_registers_[S22] = true;
416 blocked_fpu_registers_[S23] = true;
Nicolas Geoffray3c035032014-10-28 10:46:40 +0000417 blocked_fpu_registers_[S24] = true;
418 blocked_fpu_registers_[S25] = true;
419 blocked_fpu_registers_[S26] = true;
420 blocked_fpu_registers_[S27] = true;
421 blocked_fpu_registers_[S28] = true;
422 blocked_fpu_registers_[S29] = true;
423 blocked_fpu_registers_[S30] = true;
424 blocked_fpu_registers_[S31] = true;
Calin Juravle34bacdf2014-10-07 20:23:36 +0100425
426 UpdateBlockedPairRegisters();
427}
428
429void CodeGeneratorARM::UpdateBlockedPairRegisters() const {
430 for (int i = 0; i < kNumberOfRegisterPairs; i++) {
431 ArmManagedRegister current =
432 ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(i));
433 if (blocked_core_registers_[current.AsRegisterPairLow()]
434 || blocked_core_registers_[current.AsRegisterPairHigh()]) {
435 blocked_register_pairs_[i] = true;
436 }
437 }
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100438}
439
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100440InstructionCodeGeneratorARM::InstructionCodeGeneratorARM(HGraph* graph, CodeGeneratorARM* codegen)
441 : HGraphVisitor(graph),
442 assembler_(codegen->GetAssembler()),
443 codegen_(codegen) {}
444
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000445void CodeGeneratorARM::GenerateFrameEntry() {
Dave Allison648d7112014-07-25 16:15:27 -0700446 bool skip_overflow_check = IsLeafMethod() && !FrameNeedsStackCheck(GetFrameSize(), InstructionSet::kArm);
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100447 if (!skip_overflow_check) {
448 if (kExplicitStackOverflowCheck) {
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100449 SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) StackOverflowCheckSlowPathARM();
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100450 AddSlowPath(slow_path);
451
452 __ LoadFromOffset(kLoadWord, IP, TR, Thread::StackEndOffset<kArmWordSize>().Int32Value());
453 __ cmp(SP, ShifterOperand(IP));
454 __ b(slow_path->GetEntryLabel(), CC);
455 } else {
456 __ AddConstant(IP, SP, -static_cast<int32_t>(GetStackOverflowReservedBytes(kArm)));
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100457 __ LoadFromOffset(kLoadWord, IP, IP, 0);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100458 RecordPcInfo(nullptr, 0);
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100459 }
460 }
461
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100462 core_spill_mask_ |= (1 << LR | 1 << R6 | 1 << R7);
463 __ PushList(1 << LR | 1 << R6 | 1 << R7);
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000464
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100465 // The return PC has already been pushed on the stack.
Nicolas Geoffray707c8092014-04-04 10:50:14 +0100466 __ AddConstant(SP, -(GetFrameSize() - kNumberOfPushedRegistersAtEntry * kArmWordSize));
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100467 __ StoreToOffset(kStoreWord, R0, SP, 0);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000468}
469
470void CodeGeneratorARM::GenerateFrameExit() {
Nicolas Geoffray707c8092014-04-04 10:50:14 +0100471 __ AddConstant(SP, GetFrameSize() - kNumberOfPushedRegistersAtEntry * kArmWordSize);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100472 __ PopList(1 << PC | 1 << R6 | 1 << R7);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000473}
474
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100475void CodeGeneratorARM::Bind(HBasicBlock* block) {
476 __ Bind(GetLabelOf(block));
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000477}
478
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100479Location CodeGeneratorARM::GetStackLocation(HLoadLocal* load) const {
480 switch (load->GetType()) {
481 case Primitive::kPrimLong:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100482 case Primitive::kPrimDouble:
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100483 return Location::DoubleStackSlot(GetStackSlot(load->GetLocal()));
484 break;
485
486 case Primitive::kPrimInt:
487 case Primitive::kPrimNot:
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100488 case Primitive::kPrimFloat:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100489 return Location::StackSlot(GetStackSlot(load->GetLocal()));
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100490
491 case Primitive::kPrimBoolean:
492 case Primitive::kPrimByte:
493 case Primitive::kPrimChar:
494 case Primitive::kPrimShort:
495 case Primitive::kPrimVoid:
496 LOG(FATAL) << "Unexpected type " << load->GetType();
497 }
498
499 LOG(FATAL) << "Unreachable";
500 return Location();
501}
502
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100503Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type) {
504 switch (type) {
505 case Primitive::kPrimBoolean:
506 case Primitive::kPrimByte:
507 case Primitive::kPrimChar:
508 case Primitive::kPrimShort:
509 case Primitive::kPrimInt:
510 case Primitive::kPrimNot: {
511 uint32_t index = gp_index_++;
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000512 uint32_t stack_index = stack_index_++;
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100513 if (index < calling_convention.GetNumberOfRegisters()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100514 return Location::RegisterLocation(calling_convention.GetRegisterAt(index));
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100515 } else {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000516 return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index));
Nicolas Geoffraydb928fc2014-04-16 17:38:32 +0100517 }
Nicolas Geoffraydb928fc2014-04-16 17:38:32 +0100518 }
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100519
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000520 case Primitive::kPrimLong: {
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100521 uint32_t index = gp_index_;
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000522 uint32_t stack_index = stack_index_;
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100523 gp_index_ += 2;
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000524 stack_index_ += 2;
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100525 if (index + 1 < calling_convention.GetNumberOfRegisters()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100526 ArmManagedRegister pair = ArmManagedRegister::FromRegisterPair(
527 calling_convention.GetRegisterPairAt(index));
528 return Location::RegisterPairLocation(pair.AsRegisterPairLow(), pair.AsRegisterPairHigh());
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100529 } else if (index + 1 == calling_convention.GetNumberOfRegisters()) {
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000530 return Location::QuickParameter(index, stack_index);
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100531 } else {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000532 return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index));
533 }
534 }
535
536 case Primitive::kPrimFloat: {
537 uint32_t stack_index = stack_index_++;
538 if (float_index_ % 2 == 0) {
539 float_index_ = std::max(double_index_, float_index_);
540 }
541 if (float_index_ < calling_convention.GetNumberOfFpuRegisters()) {
542 return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(float_index_++));
543 } else {
544 return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index));
545 }
546 }
547
548 case Primitive::kPrimDouble: {
549 double_index_ = std::max(double_index_, RoundUp(float_index_, 2));
550 uint32_t stack_index = stack_index_;
551 stack_index_ += 2;
552 if (double_index_ + 1 < calling_convention.GetNumberOfFpuRegisters()) {
553 uint32_t index = double_index_;
554 double_index_ += 2;
555 return Location::FpuRegisterPairLocation(
556 calling_convention.GetFpuRegisterAt(index),
557 calling_convention.GetFpuRegisterAt(index + 1));
558 } else {
559 return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index));
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100560 }
561 }
562
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100563 case Primitive::kPrimVoid:
564 LOG(FATAL) << "Unexpected parameter type " << type;
565 break;
Nicolas Geoffraydb928fc2014-04-16 17:38:32 +0100566 }
Nicolas Geoffraya747a392014-04-17 14:56:23 +0100567 return Location();
568}
Nicolas Geoffraydb928fc2014-04-16 17:38:32 +0100569
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000570Location InvokeDexCallingConventionVisitor::GetReturnLocation(Primitive::Type type) {
571 switch (type) {
572 case Primitive::kPrimBoolean:
573 case Primitive::kPrimByte:
574 case Primitive::kPrimChar:
575 case Primitive::kPrimShort:
576 case Primitive::kPrimInt:
577 case Primitive::kPrimNot: {
578 return Location::RegisterLocation(R0);
579 }
580
581 case Primitive::kPrimFloat: {
582 return Location::FpuRegisterLocation(S0);
583 }
584
585 case Primitive::kPrimLong: {
586 return Location::RegisterPairLocation(R0, R1);
587 }
588
589 case Primitive::kPrimDouble: {
590 return Location::FpuRegisterPairLocation(S0, S1);
591 }
592
593 case Primitive::kPrimVoid:
594 return Location();
595 }
596 UNREACHABLE();
597 return Location();
598}
599
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100600void CodeGeneratorARM::Move32(Location destination, Location source) {
601 if (source.Equals(destination)) {
602 return;
603 }
604 if (destination.IsRegister()) {
605 if (source.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100606 __ Mov(destination.As<Register>(), source.As<Register>());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100607 } else if (source.IsFpuRegister()) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000608 __ vmovrs(destination.As<Register>(), source.As<SRegister>());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100609 } else {
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100610 __ LoadFromOffset(kLoadWord, destination.As<Register>(), SP, source.GetStackIndex());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100611 }
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100612 } else if (destination.IsFpuRegister()) {
613 if (source.IsRegister()) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000614 __ vmovsr(destination.As<SRegister>(), source.As<Register>());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100615 } else if (source.IsFpuRegister()) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000616 __ vmovs(destination.As<SRegister>(), source.As<SRegister>());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100617 } else {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000618 __ LoadSFromOffset(destination.As<SRegister>(), SP, source.GetStackIndex());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100619 }
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100620 } else {
621 DCHECK(destination.IsStackSlot());
622 if (source.IsRegister()) {
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100623 __ StoreToOffset(kStoreWord, source.As<Register>(), SP, destination.GetStackIndex());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100624 } else if (source.IsFpuRegister()) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000625 __ StoreSToOffset(source.As<SRegister>(), SP, destination.GetStackIndex());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100626 } else {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100627 DCHECK(source.IsStackSlot());
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100628 __ LoadFromOffset(kLoadWord, IP, SP, source.GetStackIndex());
629 __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100630 }
631 }
632}
633
634void CodeGeneratorARM::Move64(Location destination, Location source) {
635 if (source.Equals(destination)) {
636 return;
637 }
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100638 if (destination.IsRegisterPair()) {
639 if (source.IsRegisterPair()) {
640 __ Mov(destination.AsRegisterPairLow<Register>(), source.AsRegisterPairLow<Register>());
641 __ Mov(destination.AsRegisterPairHigh<Register>(), source.AsRegisterPairHigh<Register>());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100642 } else if (source.IsFpuRegister()) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000643 UNIMPLEMENTED(FATAL);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100644 } else if (source.IsQuickParameter()) {
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000645 uint16_t register_index = source.GetQuickParameterRegisterIndex();
646 uint16_t stack_index = source.GetQuickParameterStackIndex();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100647 InvokeDexCallingConvention calling_convention;
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100648 __ Mov(destination.AsRegisterPairLow<Register>(),
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000649 calling_convention.GetRegisterAt(register_index));
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100650 __ LoadFromOffset(kLoadWord, destination.AsRegisterPairHigh<Register>(),
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000651 SP, calling_convention.GetStackOffsetOf(stack_index + 1) + GetFrameSize());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100652 } else {
653 DCHECK(source.IsDoubleStackSlot());
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100654 if (destination.AsRegisterPairLow<Register>() == R1) {
655 DCHECK_EQ(destination.AsRegisterPairHigh<Register>(), R2);
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100656 __ LoadFromOffset(kLoadWord, R1, SP, source.GetStackIndex());
657 __ LoadFromOffset(kLoadWord, R2, SP, source.GetHighStackIndex(kArmWordSize));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100658 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100659 __ LoadFromOffset(kLoadWordPair, destination.AsRegisterPairLow<Register>(),
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100660 SP, source.GetStackIndex());
661 }
662 }
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000663 } else if (destination.IsFpuRegisterPair()) {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100664 if (source.IsDoubleStackSlot()) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000665 __ LoadDFromOffset(FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()),
666 SP,
667 source.GetStackIndex());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100668 } else {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000669 UNIMPLEMENTED(FATAL);
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100670 }
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100671 } else if (destination.IsQuickParameter()) {
672 InvokeDexCallingConvention calling_convention;
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000673 uint16_t register_index = destination.GetQuickParameterRegisterIndex();
674 uint16_t stack_index = destination.GetQuickParameterStackIndex();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100675 if (source.IsRegisterPair()) {
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000676 __ Mov(calling_convention.GetRegisterAt(register_index),
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100677 source.AsRegisterPairLow<Register>());
678 __ StoreToOffset(kStoreWord, source.AsRegisterPairHigh<Register>(),
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000679 SP, calling_convention.GetStackOffsetOf(stack_index + 1));
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100680 } else if (source.IsFpuRegister()) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000681 UNIMPLEMENTED(FATAL);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100682 } else {
683 DCHECK(source.IsDoubleStackSlot());
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000684 __ LoadFromOffset(
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000685 kLoadWord, calling_convention.GetRegisterAt(register_index), SP, source.GetStackIndex());
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100686 __ LoadFromOffset(kLoadWord, R0, SP, source.GetHighStackIndex(kArmWordSize));
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000687 __ StoreToOffset(kStoreWord, R0, SP, calling_convention.GetStackOffsetOf(stack_index + 1));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100688 }
689 } else {
690 DCHECK(destination.IsDoubleStackSlot());
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100691 if (source.IsRegisterPair()) {
692 if (source.AsRegisterPairLow<Register>() == R1) {
693 DCHECK_EQ(source.AsRegisterPairHigh<Register>(), R2);
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100694 __ StoreToOffset(kStoreWord, R1, SP, destination.GetStackIndex());
695 __ StoreToOffset(kStoreWord, R2, SP, destination.GetHighStackIndex(kArmWordSize));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100696 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100697 __ StoreToOffset(kStoreWordPair, source.AsRegisterPairLow<Register>(),
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100698 SP, destination.GetStackIndex());
699 }
700 } else if (source.IsQuickParameter()) {
701 InvokeDexCallingConvention calling_convention;
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000702 uint16_t register_index = source.GetQuickParameterRegisterIndex();
703 uint16_t stack_index = source.GetQuickParameterStackIndex();
704 __ StoreToOffset(kStoreWord, calling_convention.GetRegisterAt(register_index),
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100705 SP, destination.GetStackIndex());
706 __ LoadFromOffset(kLoadWord, R0,
Nicolas Geoffray0a6c4592014-10-30 16:37:57 +0000707 SP, calling_convention.GetStackOffsetOf(stack_index + 1) + GetFrameSize());
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100708 __ StoreToOffset(kStoreWord, R0, SP, destination.GetHighStackIndex(kArmWordSize));
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000709 } else if (source.IsFpuRegisterPair()) {
710 __ StoreDToOffset(FromLowSToD(source.AsFpuRegisterPairLow<SRegister>()),
711 SP,
712 destination.GetStackIndex());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100713 } else {
714 DCHECK(source.IsDoubleStackSlot());
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100715 __ LoadFromOffset(kLoadWord, IP, SP, source.GetStackIndex());
716 __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex());
717 __ LoadFromOffset(kLoadWord, IP, SP, source.GetHighStackIndex(kArmWordSize));
718 __ StoreToOffset(kStoreWord, IP, SP, destination.GetHighStackIndex(kArmWordSize));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100719 }
720 }
721}
722
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100723void CodeGeneratorARM::Move(HInstruction* instruction, Location location, HInstruction* move_for) {
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100724 LocationSummary* locations = instruction->GetLocations();
725 if (locations != nullptr && locations->Out().Equals(location)) {
726 return;
727 }
728
Roland Levillain476df552014-10-09 17:51:36 +0100729 if (instruction->IsIntConstant()) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100730 int32_t value = instruction->AsIntConstant()->GetValue();
731 if (location.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100732 __ LoadImmediate(location.As<Register>(), value);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100733 } else {
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100734 DCHECK(location.IsStackSlot());
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +0100735 __ LoadImmediate(IP, value);
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100736 __ StoreToOffset(kStoreWord, IP, SP, location.GetStackIndex());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100737 }
Roland Levillain476df552014-10-09 17:51:36 +0100738 } else if (instruction->IsLongConstant()) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100739 int64_t value = instruction->AsLongConstant()->GetValue();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100740 if (location.IsRegisterPair()) {
741 __ LoadImmediate(location.AsRegisterPairLow<Register>(), Low32Bits(value));
742 __ LoadImmediate(location.AsRegisterPairHigh<Register>(), High32Bits(value));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100743 } else {
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100744 DCHECK(location.IsDoubleStackSlot());
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +0100745 __ LoadImmediate(IP, Low32Bits(value));
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100746 __ StoreToOffset(kStoreWord, IP, SP, location.GetStackIndex());
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +0100747 __ LoadImmediate(IP, High32Bits(value));
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100748 __ StoreToOffset(kStoreWord, IP, SP, location.GetHighStackIndex(kArmWordSize));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100749 }
Roland Levillain476df552014-10-09 17:51:36 +0100750 } else if (instruction->IsLoadLocal()) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100751 uint32_t stack_slot = GetStackSlot(instruction->AsLoadLocal()->GetLocal());
752 switch (instruction->GetType()) {
753 case Primitive::kPrimBoolean:
754 case Primitive::kPrimByte:
755 case Primitive::kPrimChar:
756 case Primitive::kPrimShort:
757 case Primitive::kPrimInt:
758 case Primitive::kPrimNot:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100759 case Primitive::kPrimFloat:
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100760 Move32(location, Location::StackSlot(stack_slot));
761 break;
762
763 case Primitive::kPrimLong:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100764 case Primitive::kPrimDouble:
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100765 Move64(location, Location::DoubleStackSlot(stack_slot));
766 break;
767
768 default:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100769 LOG(FATAL) << "Unexpected type " << instruction->GetType();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100770 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000771 } else {
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100772 DCHECK((instruction->GetNext() == move_for) || instruction->GetNext()->IsTemporary());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100773 switch (instruction->GetType()) {
774 case Primitive::kPrimBoolean:
775 case Primitive::kPrimByte:
776 case Primitive::kPrimChar:
777 case Primitive::kPrimShort:
778 case Primitive::kPrimNot:
779 case Primitive::kPrimInt:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100780 case Primitive::kPrimFloat:
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100781 Move32(location, locations->Out());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100782 break;
783
784 case Primitive::kPrimLong:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100785 case Primitive::kPrimDouble:
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100786 Move64(location, locations->Out());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100787 break;
788
789 default:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100790 LOG(FATAL) << "Unexpected type " << instruction->GetType();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100791 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000792 }
793}
794
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100795void CodeGeneratorARM::InvokeRuntime(int32_t entry_point_offset,
796 HInstruction* instruction,
797 uint32_t dex_pc) {
798 __ LoadFromOffset(kLoadWord, LR, TR, entry_point_offset);
799 __ blx(LR);
800 RecordPcInfo(instruction, dex_pc);
801 DCHECK(instruction->IsSuspendCheck()
802 || instruction->IsBoundsCheck()
803 || instruction->IsNullCheck()
Calin Juravled0d48522014-11-04 16:40:20 +0000804 || instruction->IsDivZeroCheck()
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100805 || !IsLeafMethod());
806}
807
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000808void LocationsBuilderARM::VisitGoto(HGoto* got) {
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000809 got->SetLocations(nullptr);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000810}
811
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000812void InstructionCodeGeneratorARM::VisitGoto(HGoto* got) {
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000813 HBasicBlock* successor = got->GetSuccessor();
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100814 DCHECK(!successor->IsExitBlock());
815
816 HBasicBlock* block = got->GetBlock();
817 HInstruction* previous = got->GetPrevious();
818
819 HLoopInformation* info = block->GetLoopInformation();
820 if (info != nullptr && info->IsBackEdge(block) && info->HasSuspendCheck()) {
821 codegen_->ClearSpillSlotsFromLoopPhisInStackMap(info->GetSuspendCheck());
822 GenerateSuspendCheck(info->GetSuspendCheck(), successor);
823 return;
824 }
825
826 if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) {
827 GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr);
828 }
829 if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) {
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000830 __ b(codegen_->GetLabelOf(successor));
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000831 }
832}
833
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000834void LocationsBuilderARM::VisitExit(HExit* exit) {
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000835 exit->SetLocations(nullptr);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000836}
837
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000838void InstructionCodeGeneratorARM::VisitExit(HExit* exit) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700839 UNUSED(exit);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000840 if (kIsDebugBuild) {
841 __ Comment("Unreachable");
842 __ bkpt(0);
843 }
844}
845
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000846void LocationsBuilderARM::VisitIf(HIf* if_instr) {
Nicolas Geoffray39468442014-09-02 15:17:15 +0100847 LocationSummary* locations =
848 new (GetGraph()->GetArena()) LocationSummary(if_instr, LocationSummary::kNoCall);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100849 HInstruction* cond = if_instr->InputAt(0);
Nicolas Geoffray01ef3452014-10-01 11:32:17 +0100850 if (!cond->IsCondition() || cond->AsCondition()->NeedsMaterialization()) {
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +0100851 locations->SetInAt(0, Location::RequiresRegister());
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100852 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000853}
854
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000855void InstructionCodeGeneratorARM::VisitIf(HIf* if_instr) {
Dave Allison20dfc792014-06-16 20:44:29 -0700856 HInstruction* cond = if_instr->InputAt(0);
Roland Levillain3a3fd0f2014-10-10 13:56:31 +0100857 if (cond->IsIntConstant()) {
858 // Constant condition, statically compared against 1.
859 int32_t cond_value = cond->AsIntConstant()->GetValue();
860 if (cond_value == 1) {
861 if (!codegen_->GoesToNextBlock(if_instr->GetBlock(),
862 if_instr->IfTrueSuccessor())) {
863 __ b(codegen_->GetLabelOf(if_instr->IfTrueSuccessor()));
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100864 }
Roland Levillain3a3fd0f2014-10-10 13:56:31 +0100865 return;
866 } else {
867 DCHECK_EQ(cond_value, 0);
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100868 }
Roland Levillain3a3fd0f2014-10-10 13:56:31 +0100869 } else {
870 if (!cond->IsCondition() || cond->AsCondition()->NeedsMaterialization()) {
871 // Condition has been materialized, compare the output to 0
872 DCHECK(if_instr->GetLocations()->InAt(0).IsRegister());
873 __ cmp(if_instr->GetLocations()->InAt(0).As<Register>(),
874 ShifterOperand(0));
875 __ b(codegen_->GetLabelOf(if_instr->IfTrueSuccessor()), NE);
876 } else {
877 // Condition has not been materialized, use its inputs as the
878 // comparison and its condition as the branch condition.
879 LocationSummary* locations = cond->GetLocations();
880 if (locations->InAt(1).IsRegister()) {
881 __ cmp(locations->InAt(0).As<Register>(),
882 ShifterOperand(locations->InAt(1).As<Register>()));
883 } else {
884 DCHECK(locations->InAt(1).IsConstant());
885 int32_t value =
886 locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
887 ShifterOperand operand;
888 if (ShifterOperand::CanHoldArm(value, &operand)) {
889 __ cmp(locations->InAt(0).As<Register>(), ShifterOperand(value));
890 } else {
891 Register temp = IP;
892 __ LoadImmediate(temp, value);
893 __ cmp(locations->InAt(0).As<Register>(), ShifterOperand(temp));
894 }
895 }
896 __ b(codegen_->GetLabelOf(if_instr->IfTrueSuccessor()),
897 ARMCondition(cond->AsCondition()->GetCondition()));
898 }
Dave Allison20dfc792014-06-16 20:44:29 -0700899 }
Roland Levillain3a3fd0f2014-10-10 13:56:31 +0100900 if (!codegen_->GoesToNextBlock(if_instr->GetBlock(),
901 if_instr->IfFalseSuccessor())) {
Dave Allison20dfc792014-06-16 20:44:29 -0700902 __ b(codegen_->GetLabelOf(if_instr->IfFalseSuccessor()));
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000903 }
904}
905
Dave Allison20dfc792014-06-16 20:44:29 -0700906
907void LocationsBuilderARM::VisitCondition(HCondition* comp) {
Nicolas Geoffray39468442014-09-02 15:17:15 +0100908 LocationSummary* locations =
909 new (GetGraph()->GetArena()) LocationSummary(comp, LocationSummary::kNoCall);
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +0100910 locations->SetInAt(0, Location::RequiresRegister());
911 locations->SetInAt(1, Location::RegisterOrConstant(comp->InputAt(1)));
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100912 if (comp->NeedsMaterialization()) {
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +0100913 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100914 }
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000915}
916
Dave Allison20dfc792014-06-16 20:44:29 -0700917void InstructionCodeGeneratorARM::VisitCondition(HCondition* comp) {
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100918 if (!comp->NeedsMaterialization()) return;
919
920 LocationSummary* locations = comp->GetLocations();
921 if (locations->InAt(1).IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100922 __ cmp(locations->InAt(0).As<Register>(),
923 ShifterOperand(locations->InAt(1).As<Register>()));
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100924 } else {
925 DCHECK(locations->InAt(1).IsConstant());
926 int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
927 ShifterOperand operand;
928 if (ShifterOperand::CanHoldArm(value, &operand)) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100929 __ cmp(locations->InAt(0).As<Register>(), ShifterOperand(value));
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100930 } else {
931 Register temp = IP;
932 __ LoadImmediate(temp, value);
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100933 __ cmp(locations->InAt(0).As<Register>(), ShifterOperand(temp));
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100934 }
Dave Allison20dfc792014-06-16 20:44:29 -0700935 }
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100936 __ it(ARMCondition(comp->GetCondition()), kItElse);
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100937 __ mov(locations->Out().As<Register>(), ShifterOperand(1),
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100938 ARMCondition(comp->GetCondition()));
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100939 __ mov(locations->Out().As<Register>(), ShifterOperand(0),
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100940 ARMOppositeCondition(comp->GetCondition()));
Dave Allison20dfc792014-06-16 20:44:29 -0700941}
942
943void LocationsBuilderARM::VisitEqual(HEqual* comp) {
944 VisitCondition(comp);
945}
946
947void InstructionCodeGeneratorARM::VisitEqual(HEqual* comp) {
948 VisitCondition(comp);
949}
950
951void LocationsBuilderARM::VisitNotEqual(HNotEqual* comp) {
952 VisitCondition(comp);
953}
954
955void InstructionCodeGeneratorARM::VisitNotEqual(HNotEqual* comp) {
956 VisitCondition(comp);
957}
958
959void LocationsBuilderARM::VisitLessThan(HLessThan* comp) {
960 VisitCondition(comp);
961}
962
963void InstructionCodeGeneratorARM::VisitLessThan(HLessThan* comp) {
964 VisitCondition(comp);
965}
966
967void LocationsBuilderARM::VisitLessThanOrEqual(HLessThanOrEqual* comp) {
968 VisitCondition(comp);
969}
970
971void InstructionCodeGeneratorARM::VisitLessThanOrEqual(HLessThanOrEqual* comp) {
972 VisitCondition(comp);
973}
974
975void LocationsBuilderARM::VisitGreaterThan(HGreaterThan* comp) {
976 VisitCondition(comp);
977}
978
979void InstructionCodeGeneratorARM::VisitGreaterThan(HGreaterThan* comp) {
980 VisitCondition(comp);
981}
982
983void LocationsBuilderARM::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) {
984 VisitCondition(comp);
985}
986
987void InstructionCodeGeneratorARM::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) {
988 VisitCondition(comp);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000989}
990
991void LocationsBuilderARM::VisitLocal(HLocal* local) {
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000992 local->SetLocations(nullptr);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000993}
994
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000995void InstructionCodeGeneratorARM::VisitLocal(HLocal* local) {
996 DCHECK_EQ(local->GetBlock(), GetGraph()->GetEntryBlock());
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000997}
998
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000999void LocationsBuilderARM::VisitLoadLocal(HLoadLocal* load) {
Nicolas Geoffray4a34a422014-04-03 10:38:37 +01001000 load->SetLocations(nullptr);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001001}
1002
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001003void InstructionCodeGeneratorARM::VisitLoadLocal(HLoadLocal* load) {
Nicolas Geoffray4a34a422014-04-03 10:38:37 +01001004 // Nothing to do, this is driven by the code generator.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001005 UNUSED(load);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001006}
1007
1008void LocationsBuilderARM::VisitStoreLocal(HStoreLocal* store) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001009 LocationSummary* locations =
1010 new (GetGraph()->GetArena()) LocationSummary(store, LocationSummary::kNoCall);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001011 switch (store->InputAt(1)->GetType()) {
1012 case Primitive::kPrimBoolean:
1013 case Primitive::kPrimByte:
1014 case Primitive::kPrimChar:
1015 case Primitive::kPrimShort:
1016 case Primitive::kPrimInt:
1017 case Primitive::kPrimNot:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001018 case Primitive::kPrimFloat:
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001019 locations->SetInAt(1, Location::StackSlot(codegen_->GetStackSlot(store->GetLocal())));
1020 break;
1021
1022 case Primitive::kPrimLong:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001023 case Primitive::kPrimDouble:
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001024 locations->SetInAt(1, Location::DoubleStackSlot(codegen_->GetStackSlot(store->GetLocal())));
1025 break;
1026
1027 default:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001028 LOG(FATAL) << "Unexpected local type " << store->InputAt(1)->GetType();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001029 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001030}
1031
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001032void InstructionCodeGeneratorARM::VisitStoreLocal(HStoreLocal* store) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001033 UNUSED(store);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001034}
1035
1036void LocationsBuilderARM::VisitIntConstant(HIntConstant* constant) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001037 LocationSummary* locations =
1038 new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall);
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001039 locations->SetOut(Location::ConstantLocation(constant));
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001040}
1041
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001042void InstructionCodeGeneratorARM::VisitIntConstant(HIntConstant* constant) {
Roland Levillain3a3fd0f2014-10-10 13:56:31 +01001043 // Will be generated at use site.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001044 UNUSED(constant);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001045}
1046
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001047void LocationsBuilderARM::VisitLongConstant(HLongConstant* constant) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001048 LocationSummary* locations =
1049 new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall);
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001050 locations->SetOut(Location::ConstantLocation(constant));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001051}
1052
1053void InstructionCodeGeneratorARM::VisitLongConstant(HLongConstant* constant) {
1054 // Will be generated at use site.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001055 UNUSED(constant);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001056}
1057
Nicolas Geoffray102cbed2014-10-15 18:31:05 +01001058void LocationsBuilderARM::VisitFloatConstant(HFloatConstant* constant) {
1059 LocationSummary* locations =
1060 new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall);
1061 locations->SetOut(Location::ConstantLocation(constant));
1062}
1063
1064void InstructionCodeGeneratorARM::VisitFloatConstant(HFloatConstant* constant) {
1065 // Will be generated at use site.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001066 UNUSED(constant);
Nicolas Geoffray102cbed2014-10-15 18:31:05 +01001067}
1068
1069void LocationsBuilderARM::VisitDoubleConstant(HDoubleConstant* constant) {
1070 LocationSummary* locations =
1071 new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall);
1072 locations->SetOut(Location::ConstantLocation(constant));
1073}
1074
1075void InstructionCodeGeneratorARM::VisitDoubleConstant(HDoubleConstant* constant) {
1076 // Will be generated at use site.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001077 UNUSED(constant);
Nicolas Geoffray102cbed2014-10-15 18:31:05 +01001078}
1079
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001080void LocationsBuilderARM::VisitReturnVoid(HReturnVoid* ret) {
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001081 ret->SetLocations(nullptr);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001082}
1083
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001084void InstructionCodeGeneratorARM::VisitReturnVoid(HReturnVoid* ret) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001085 UNUSED(ret);
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001086 codegen_->GenerateFrameExit();
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +00001087}
1088
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001089void LocationsBuilderARM::VisitReturn(HReturn* ret) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001090 LocationSummary* locations =
1091 new (GetGraph()->GetArena()) LocationSummary(ret, LocationSummary::kNoCall);
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001092 locations->SetInAt(0, parameter_visitor_.GetReturnLocation(ret->InputAt(0)->GetType()));
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001093}
1094
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001095void InstructionCodeGeneratorARM::VisitReturn(HReturn* ret) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001096 UNUSED(ret);
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001097 codegen_->GenerateFrameExit();
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001098}
1099
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +00001100void LocationsBuilderARM::VisitInvokeStatic(HInvokeStatic* invoke) {
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001101 HandleInvoke(invoke);
1102}
1103
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001104void CodeGeneratorARM::LoadCurrentMethod(Register reg) {
Nicolas Geoffray360231a2014-10-08 21:07:48 +01001105 __ LoadFromOffset(kLoadWord, reg, SP, kCurrentMethodStackOffset);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001106}
1107
1108void InstructionCodeGeneratorARM::VisitInvokeStatic(HInvokeStatic* invoke) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001109 Register temp = invoke->GetLocations()->GetTemp(0).As<Register>();
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001110
1111 // TODO: Implement all kinds of calls:
1112 // 1) boot -> boot
1113 // 2) app -> boot
1114 // 3) app -> app
1115 //
1116 // Currently we implement the app -> app logic, which looks up in the resolve cache.
1117
1118 // temp = method;
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001119 codegen_->LoadCurrentMethod(temp);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001120 // temp = temp->dex_cache_resolved_methods_;
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001121 __ LoadFromOffset(
1122 kLoadWord, temp, temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value());
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001123 // temp = temp[index_in_cache]
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001124 __ LoadFromOffset(
1125 kLoadWord, temp, temp, CodeGenerator::GetCacheOffset(invoke->GetIndexInDexCache()));
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001126 // LR = temp[offset_of_quick_compiled_code]
Nicolas Geoffray360231a2014-10-08 21:07:48 +01001127 __ LoadFromOffset(kLoadWord, LR, temp,
1128 mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value());
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001129 // LR()
1130 __ blx(LR);
1131
1132 codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
1133 DCHECK(!codegen_->IsLeafMethod());
1134}
1135
1136void LocationsBuilderARM::VisitInvokeVirtual(HInvokeVirtual* invoke) {
1137 HandleInvoke(invoke);
1138}
1139
1140void LocationsBuilderARM::HandleInvoke(HInvoke* invoke) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001141 LocationSummary* locations =
1142 new (GetGraph()->GetArena()) LocationSummary(invoke, LocationSummary::kCall);
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001143 locations->AddTemp(Location::RegisterLocation(R0));
Nicolas Geoffraydb928fc2014-04-16 17:38:32 +01001144
1145 InvokeDexCallingConventionVisitor calling_convention_visitor;
Nicolas Geoffrayc32e7702014-04-24 12:43:16 +01001146 for (size_t i = 0; i < invoke->InputCount(); i++) {
Nicolas Geoffraydb928fc2014-04-16 17:38:32 +01001147 HInstruction* input = invoke->InputAt(i);
1148 locations->SetInAt(i, calling_convention_visitor.GetNextLocation(input->GetType()));
1149 }
1150
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001151 locations->SetOut(calling_convention_visitor.GetReturnLocation(invoke->GetType()));
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +00001152}
1153
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +00001154
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001155void InstructionCodeGeneratorARM::VisitInvokeVirtual(HInvokeVirtual* invoke) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001156 Register temp = invoke->GetLocations()->GetTemp(0).As<Register>();
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001157 uint32_t method_offset = mirror::Class::EmbeddedVTableOffset().Uint32Value() +
1158 invoke->GetVTableIndex() * sizeof(mirror::Class::VTableEntry);
1159 LocationSummary* locations = invoke->GetLocations();
1160 Location receiver = locations->InAt(0);
1161 uint32_t class_offset = mirror::Object::ClassOffset().Int32Value();
1162 // temp = object->GetClass();
1163 if (receiver.IsStackSlot()) {
Nicolas Geoffray360231a2014-10-08 21:07:48 +01001164 __ LoadFromOffset(kLoadWord, temp, SP, receiver.GetStackIndex());
1165 __ LoadFromOffset(kLoadWord, temp, temp, class_offset);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001166 } else {
Nicolas Geoffray360231a2014-10-08 21:07:48 +01001167 __ LoadFromOffset(kLoadWord, temp, receiver.As<Register>(), class_offset);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001168 }
1169 // temp = temp->GetMethodAt(method_offset);
1170 uint32_t entry_point = mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value();
Nicolas Geoffray360231a2014-10-08 21:07:48 +01001171 __ LoadFromOffset(kLoadWord, temp, temp, method_offset);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001172 // LR = temp->GetEntryPoint();
Nicolas Geoffray360231a2014-10-08 21:07:48 +01001173 __ LoadFromOffset(kLoadWord, LR, temp, entry_point);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001174 // LR();
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +00001175 __ blx(LR);
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +01001176 DCHECK(!codegen_->IsLeafMethod());
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +01001177 codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +00001178}
1179
Roland Levillain88cb1752014-10-20 16:36:47 +01001180void LocationsBuilderARM::VisitNeg(HNeg* neg) {
1181 LocationSummary* locations =
1182 new (GetGraph()->GetArena()) LocationSummary(neg, LocationSummary::kNoCall);
1183 switch (neg->GetResultType()) {
1184 case Primitive::kPrimInt:
Roland Levillain2e07b4f2014-10-23 18:12:09 +01001185 case Primitive::kPrimLong: {
1186 bool output_overlaps = (neg->GetResultType() == Primitive::kPrimLong);
Roland Levillain88cb1752014-10-20 16:36:47 +01001187 locations->SetInAt(0, Location::RequiresRegister());
Roland Levillain2e07b4f2014-10-23 18:12:09 +01001188 locations->SetOut(Location::RequiresRegister(), output_overlaps);
Roland Levillain88cb1752014-10-20 16:36:47 +01001189 break;
Roland Levillain2e07b4f2014-10-23 18:12:09 +01001190 }
Roland Levillain88cb1752014-10-20 16:36:47 +01001191
Roland Levillain88cb1752014-10-20 16:36:47 +01001192 case Primitive::kPrimFloat:
1193 case Primitive::kPrimDouble:
1194 LOG(FATAL) << "Not yet implemented neg type " << neg->GetResultType();
1195 break;
1196
1197 default:
1198 LOG(FATAL) << "Unexpected neg type " << neg->GetResultType();
1199 }
1200}
1201
1202void InstructionCodeGeneratorARM::VisitNeg(HNeg* neg) {
1203 LocationSummary* locations = neg->GetLocations();
1204 Location out = locations->Out();
1205 Location in = locations->InAt(0);
1206 switch (neg->GetResultType()) {
1207 case Primitive::kPrimInt:
1208 DCHECK(in.IsRegister());
Roland Levillainb762d2e2014-10-22 10:11:06 +01001209 __ rsb(out.As<Register>(), in.As<Register>(), ShifterOperand(0));
Roland Levillain88cb1752014-10-20 16:36:47 +01001210 break;
1211
1212 case Primitive::kPrimLong:
Roland Levillain2e07b4f2014-10-23 18:12:09 +01001213 DCHECK(in.IsRegisterPair());
1214 // out.lo = 0 - in.lo (and update the carry/borrow (C) flag)
1215 __ rsbs(out.AsRegisterPairLow<Register>(),
1216 in.AsRegisterPairLow<Register>(),
1217 ShifterOperand(0));
1218 // We cannot emit an RSC (Reverse Subtract with Carry)
1219 // instruction here, as it does not exist in the Thumb-2
1220 // instruction set. We use the following approach
1221 // using SBC and SUB instead.
1222 //
1223 // out.hi = -C
1224 __ sbc(out.AsRegisterPairHigh<Register>(),
1225 out.AsRegisterPairHigh<Register>(),
1226 ShifterOperand(out.AsRegisterPairHigh<Register>()));
1227 // out.hi = out.hi - in.hi
1228 __ sub(out.AsRegisterPairHigh<Register>(),
1229 out.AsRegisterPairHigh<Register>(),
1230 ShifterOperand(in.AsRegisterPairHigh<Register>()));
1231 break;
1232
Roland Levillain88cb1752014-10-20 16:36:47 +01001233 case Primitive::kPrimFloat:
1234 case Primitive::kPrimDouble:
1235 LOG(FATAL) << "Not yet implemented neg type " << neg->GetResultType();
1236 break;
1237
1238 default:
1239 LOG(FATAL) << "Unexpected neg type " << neg->GetResultType();
1240 }
1241}
1242
Roland Levillaindff1f282014-11-05 14:15:05 +00001243void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) {
1244 LocationSummary* locations =
1245 new (GetGraph()->GetArena()) LocationSummary(conversion, LocationSummary::kNoCall);
1246 Primitive::Type result_type = conversion->GetResultType();
1247 Primitive::Type input_type = conversion->GetInputType();
1248 switch (result_type) {
1249 case Primitive::kPrimLong:
1250 switch (input_type) {
1251 case Primitive::kPrimByte:
1252 case Primitive::kPrimShort:
1253 case Primitive::kPrimInt:
1254 // int-to-long conversion.
1255 locations->SetInAt(0, Location::RequiresRegister());
1256 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
1257 break;
1258
1259 case Primitive::kPrimFloat:
1260 case Primitive::kPrimDouble:
1261 LOG(FATAL) << "Type conversion from " << input_type << " to "
1262 << result_type << " not yet implemented";
1263 break;
1264
1265 default:
1266 LOG(FATAL) << "Unexpected type conversion from " << input_type
1267 << " to " << result_type;
1268 }
1269 break;
1270
1271 case Primitive::kPrimInt:
1272 case Primitive::kPrimFloat:
1273 case Primitive::kPrimDouble:
1274 LOG(FATAL) << "Type conversion from " << input_type
1275 << " to " << result_type << " not yet implemented";
1276 break;
1277
1278 default:
1279 LOG(FATAL) << "Unexpected type conversion from " << input_type
1280 << " to " << result_type;
1281 }
1282}
1283
1284void InstructionCodeGeneratorARM::VisitTypeConversion(HTypeConversion* conversion) {
1285 LocationSummary* locations = conversion->GetLocations();
1286 Location out = locations->Out();
1287 Location in = locations->InAt(0);
1288 Primitive::Type result_type = conversion->GetResultType();
1289 Primitive::Type input_type = conversion->GetInputType();
1290 switch (result_type) {
1291 case Primitive::kPrimLong:
1292 switch (input_type) {
1293 case Primitive::kPrimByte:
1294 case Primitive::kPrimShort:
1295 case Primitive::kPrimInt:
1296 // int-to-long conversion.
1297 DCHECK(out.IsRegisterPair());
1298 DCHECK(in.IsRegister());
1299 __ Mov(out.AsRegisterPairLow<Register>(), in.As<Register>());
1300 // Sign extension.
1301 __ Asr(out.AsRegisterPairHigh<Register>(),
1302 out.AsRegisterPairLow<Register>(),
1303 31);
1304 break;
1305
1306 case Primitive::kPrimFloat:
1307 case Primitive::kPrimDouble:
1308 LOG(FATAL) << "Type conversion from " << input_type << " to "
1309 << result_type << " not yet implemented";
1310 break;
1311
1312 default:
1313 LOG(FATAL) << "Unexpected type conversion from " << input_type
1314 << " to " << result_type;
1315 }
1316 break;
1317
1318 case Primitive::kPrimInt:
1319 case Primitive::kPrimFloat:
1320 case Primitive::kPrimDouble:
1321 LOG(FATAL) << "Type conversion from " << input_type
1322 << " to " << result_type << " not yet implemented";
1323 break;
1324
1325 default:
1326 LOG(FATAL) << "Unexpected type conversion from " << input_type
1327 << " to " << result_type;
1328 }
1329}
1330
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001331void LocationsBuilderARM::VisitAdd(HAdd* add) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001332 LocationSummary* locations =
1333 new (GetGraph()->GetArena()) LocationSummary(add, LocationSummary::kNoCall);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001334 switch (add->GetResultType()) {
Nicolas Geoffraya7aca372014-04-28 17:47:12 +01001335 case Primitive::kPrimInt:
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001336 case Primitive::kPrimLong: {
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001337 bool output_overlaps = (add->GetResultType() == Primitive::kPrimLong);
1338 locations->SetInAt(0, Location::RequiresRegister());
1339 locations->SetInAt(1, Location::RegisterOrConstant(add->InputAt(1)));
1340 locations->SetOut(Location::RequiresRegister(), output_overlaps);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001341 break;
1342 }
1343
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001344 case Primitive::kPrimFloat:
1345 case Primitive::kPrimDouble: {
1346 locations->SetInAt(0, Location::RequiresFpuRegister());
1347 locations->SetInAt(1, Location::RequiresFpuRegister());
Calin Juravle7c4954d2014-10-28 16:57:40 +00001348 locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001349 break;
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001350 }
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001351
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001352 default:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001353 LOG(FATAL) << "Unexpected add type " << add->GetResultType();
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001354 }
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001355}
1356
1357void InstructionCodeGeneratorARM::VisitAdd(HAdd* add) {
1358 LocationSummary* locations = add->GetLocations();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001359 Location out = locations->Out();
1360 Location first = locations->InAt(0);
1361 Location second = locations->InAt(1);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001362 switch (add->GetResultType()) {
1363 case Primitive::kPrimInt:
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001364 if (second.IsRegister()) {
1365 __ add(out.As<Register>(), first.As<Register>(), ShifterOperand(second.As<Register>()));
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001366 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001367 __ AddConstant(out.As<Register>(),
1368 first.As<Register>(),
1369 second.GetConstant()->AsIntConstant()->GetValue());
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001370 }
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001371 break;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001372
1373 case Primitive::kPrimLong:
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001374 __ adds(out.AsRegisterPairLow<Register>(),
1375 first.AsRegisterPairLow<Register>(),
1376 ShifterOperand(second.AsRegisterPairLow<Register>()));
1377 __ adc(out.AsRegisterPairHigh<Register>(),
1378 first.AsRegisterPairHigh<Register>(),
1379 ShifterOperand(second.AsRegisterPairHigh<Register>()));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001380 break;
1381
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001382 case Primitive::kPrimFloat:
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001383 __ vadds(out.As<SRegister>(), first.As<SRegister>(), second.As<SRegister>());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001384 break;
1385
1386 case Primitive::kPrimDouble:
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001387 __ vaddd(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()),
1388 FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()),
1389 FromLowSToD(second.AsFpuRegisterPairLow<SRegister>()));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001390 break;
1391
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001392 default:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001393 LOG(FATAL) << "Unexpected add type " << add->GetResultType();
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001394 }
1395}
1396
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001397void LocationsBuilderARM::VisitSub(HSub* sub) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001398 LocationSummary* locations =
1399 new (GetGraph()->GetArena()) LocationSummary(sub, LocationSummary::kNoCall);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001400 switch (sub->GetResultType()) {
Nicolas Geoffraya7aca372014-04-28 17:47:12 +01001401 case Primitive::kPrimInt:
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001402 case Primitive::kPrimLong: {
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001403 bool output_overlaps = (sub->GetResultType() == Primitive::kPrimLong);
1404 locations->SetInAt(0, Location::RequiresRegister());
1405 locations->SetInAt(1, Location::RegisterOrConstant(sub->InputAt(1)));
1406 locations->SetOut(Location::RequiresRegister(), output_overlaps);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001407 break;
1408 }
Calin Juravle11351682014-10-23 15:38:15 +01001409 case Primitive::kPrimFloat:
1410 case Primitive::kPrimDouble: {
1411 locations->SetInAt(0, Location::RequiresFpuRegister());
1412 locations->SetInAt(1, Location::RequiresFpuRegister());
Calin Juravle7c4954d2014-10-28 16:57:40 +00001413 locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001414 break;
Calin Juravle11351682014-10-23 15:38:15 +01001415 }
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001416 default:
Calin Juravle11351682014-10-23 15:38:15 +01001417 LOG(FATAL) << "Unexpected sub type " << sub->GetResultType();
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001418 }
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001419}
1420
1421void InstructionCodeGeneratorARM::VisitSub(HSub* sub) {
1422 LocationSummary* locations = sub->GetLocations();
Calin Juravle11351682014-10-23 15:38:15 +01001423 Location out = locations->Out();
1424 Location first = locations->InAt(0);
1425 Location second = locations->InAt(1);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001426 switch (sub->GetResultType()) {
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001427 case Primitive::kPrimInt: {
Calin Juravle11351682014-10-23 15:38:15 +01001428 if (second.IsRegister()) {
1429 __ sub(out.As<Register>(), first.As<Register>(), ShifterOperand(second.As<Register>()));
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001430 } else {
Calin Juravle11351682014-10-23 15:38:15 +01001431 __ AddConstant(out.As<Register>(),
1432 first.As<Register>(),
1433 -second.GetConstant()->AsIntConstant()->GetValue());
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001434 }
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001435 break;
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01001436 }
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001437
Calin Juravle11351682014-10-23 15:38:15 +01001438 case Primitive::kPrimLong: {
1439 __ subs(out.AsRegisterPairLow<Register>(),
1440 first.AsRegisterPairLow<Register>(),
1441 ShifterOperand(second.AsRegisterPairLow<Register>()));
1442 __ sbc(out.AsRegisterPairHigh<Register>(),
1443 first.AsRegisterPairHigh<Register>(),
1444 ShifterOperand(second.AsRegisterPairHigh<Register>()));
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001445 break;
Calin Juravle11351682014-10-23 15:38:15 +01001446 }
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001447
Calin Juravle11351682014-10-23 15:38:15 +01001448 case Primitive::kPrimFloat: {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001449 __ vsubs(out.As<SRegister>(), first.As<SRegister>(), second.As<SRegister>());
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001450 break;
Calin Juravle11351682014-10-23 15:38:15 +01001451 }
1452
1453 case Primitive::kPrimDouble: {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001454 __ vsubd(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()),
1455 FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()),
1456 FromLowSToD(second.AsFpuRegisterPairLow<SRegister>()));
Calin Juravle11351682014-10-23 15:38:15 +01001457 break;
1458 }
1459
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001460
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001461 default:
Calin Juravle11351682014-10-23 15:38:15 +01001462 LOG(FATAL) << "Unexpected sub type " << sub->GetResultType();
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001463 }
1464}
1465
Calin Juravle34bacdf2014-10-07 20:23:36 +01001466void LocationsBuilderARM::VisitMul(HMul* mul) {
1467 LocationSummary* locations =
1468 new (GetGraph()->GetArena()) LocationSummary(mul, LocationSummary::kNoCall);
1469 switch (mul->GetResultType()) {
1470 case Primitive::kPrimInt:
1471 case Primitive::kPrimLong: {
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001472 locations->SetInAt(0, Location::RequiresRegister());
1473 locations->SetInAt(1, Location::RequiresRegister());
1474 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
Calin Juravle34bacdf2014-10-07 20:23:36 +01001475 break;
1476 }
1477
Calin Juravleb5bfa962014-10-21 18:02:24 +01001478 case Primitive::kPrimFloat:
1479 case Primitive::kPrimDouble: {
1480 locations->SetInAt(0, Location::RequiresFpuRegister());
1481 locations->SetInAt(1, Location::RequiresFpuRegister());
Calin Juravle7c4954d2014-10-28 16:57:40 +00001482 locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
Calin Juravle34bacdf2014-10-07 20:23:36 +01001483 break;
Calin Juravleb5bfa962014-10-21 18:02:24 +01001484 }
Calin Juravle34bacdf2014-10-07 20:23:36 +01001485
1486 default:
Calin Juravleb5bfa962014-10-21 18:02:24 +01001487 LOG(FATAL) << "Unexpected mul type " << mul->GetResultType();
Calin Juravle34bacdf2014-10-07 20:23:36 +01001488 }
1489}
1490
1491void InstructionCodeGeneratorARM::VisitMul(HMul* mul) {
1492 LocationSummary* locations = mul->GetLocations();
1493 Location out = locations->Out();
1494 Location first = locations->InAt(0);
1495 Location second = locations->InAt(1);
1496 switch (mul->GetResultType()) {
1497 case Primitive::kPrimInt: {
1498 __ mul(out.As<Register>(), first.As<Register>(), second.As<Register>());
1499 break;
1500 }
1501 case Primitive::kPrimLong: {
1502 Register out_hi = out.AsRegisterPairHigh<Register>();
1503 Register out_lo = out.AsRegisterPairLow<Register>();
1504 Register in1_hi = first.AsRegisterPairHigh<Register>();
1505 Register in1_lo = first.AsRegisterPairLow<Register>();
1506 Register in2_hi = second.AsRegisterPairHigh<Register>();
1507 Register in2_lo = second.AsRegisterPairLow<Register>();
1508
1509 // Extra checks to protect caused by the existence of R1_R2.
1510 // The algorithm is wrong if out.hi is either in1.lo or in2.lo:
1511 // (e.g. in1=r0_r1, in2=r2_r3 and out=r1_r2);
1512 DCHECK_NE(out_hi, in1_lo);
1513 DCHECK_NE(out_hi, in2_lo);
1514
1515 // input: in1 - 64 bits, in2 - 64 bits
1516 // output: out
1517 // formula: out.hi : out.lo = (in1.lo * in2.hi + in1.hi * in2.lo)* 2^32 + in1.lo * in2.lo
1518 // parts: out.hi = in1.lo * in2.hi + in1.hi * in2.lo + (in1.lo * in2.lo)[63:32]
1519 // parts: out.lo = (in1.lo * in2.lo)[31:0]
1520
1521 // IP <- in1.lo * in2.hi
1522 __ mul(IP, in1_lo, in2_hi);
1523 // out.hi <- in1.lo * in2.hi + in1.hi * in2.lo
1524 __ mla(out_hi, in1_hi, in2_lo, IP);
1525 // out.lo <- (in1.lo * in2.lo)[31:0];
1526 __ umull(out_lo, IP, in1_lo, in2_lo);
1527 // out.hi <- in2.hi * in1.lo + in2.lo * in1.hi + (in1.lo * in2.lo)[63:32]
1528 __ add(out_hi, out_hi, ShifterOperand(IP));
1529 break;
1530 }
Calin Juravleb5bfa962014-10-21 18:02:24 +01001531
1532 case Primitive::kPrimFloat: {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001533 __ vmuls(out.As<SRegister>(), first.As<SRegister>(), second.As<SRegister>());
Calin Juravle34bacdf2014-10-07 20:23:36 +01001534 break;
Calin Juravleb5bfa962014-10-21 18:02:24 +01001535 }
1536
1537 case Primitive::kPrimDouble: {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +00001538 __ vmuld(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()),
1539 FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()),
1540 FromLowSToD(second.AsFpuRegisterPairLow<SRegister>()));
Calin Juravleb5bfa962014-10-21 18:02:24 +01001541 break;
1542 }
Calin Juravle34bacdf2014-10-07 20:23:36 +01001543
1544 default:
Calin Juravleb5bfa962014-10-21 18:02:24 +01001545 LOG(FATAL) << "Unexpected mul type " << mul->GetResultType();
Calin Juravle34bacdf2014-10-07 20:23:36 +01001546 }
1547}
1548
Calin Juravle7c4954d2014-10-28 16:57:40 +00001549void LocationsBuilderARM::VisitDiv(HDiv* div) {
1550 LocationSummary* locations =
1551 new (GetGraph()->GetArena()) LocationSummary(div, LocationSummary::kNoCall);
1552 switch (div->GetResultType()) {
Calin Juravled0d48522014-11-04 16:40:20 +00001553 case Primitive::kPrimInt: {
1554 locations->SetInAt(0, Location::RequiresRegister());
1555 locations->SetInAt(1, Location::RequiresRegister());
1556 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
1557 break;
1558 }
Calin Juravle7c4954d2014-10-28 16:57:40 +00001559 case Primitive::kPrimLong: {
1560 LOG(FATAL) << "Not implemented div type" << div->GetResultType();
1561 break;
1562 }
1563 case Primitive::kPrimFloat:
1564 case Primitive::kPrimDouble: {
1565 locations->SetInAt(0, Location::RequiresFpuRegister());
1566 locations->SetInAt(1, Location::RequiresFpuRegister());
1567 locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
1568 break;
1569 }
1570
1571 default:
1572 LOG(FATAL) << "Unexpected div type " << div->GetResultType();
1573 }
1574}
1575
1576void InstructionCodeGeneratorARM::VisitDiv(HDiv* div) {
1577 LocationSummary* locations = div->GetLocations();
1578 Location out = locations->Out();
1579 Location first = locations->InAt(0);
1580 Location second = locations->InAt(1);
1581
1582 switch (div->GetResultType()) {
Calin Juravled0d48522014-11-04 16:40:20 +00001583 case Primitive::kPrimInt: {
1584 __ sdiv(out.As<Register>(), first.As<Register>(), second.As<Register>());
1585 break;
1586 }
1587
Calin Juravle7c4954d2014-10-28 16:57:40 +00001588 case Primitive::kPrimLong: {
1589 LOG(FATAL) << "Not implemented div type" << div->GetResultType();
1590 break;
1591 }
1592
1593 case Primitive::kPrimFloat: {
1594 __ vdivs(out.As<SRegister>(), first.As<SRegister>(), second.As<SRegister>());
1595 break;
1596 }
1597
1598 case Primitive::kPrimDouble: {
1599 __ vdivd(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()),
1600 FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()),
1601 FromLowSToD(second.AsFpuRegisterPairLow<SRegister>()));
1602 break;
1603 }
1604
1605 default:
1606 LOG(FATAL) << "Unexpected div type " << div->GetResultType();
1607 }
1608}
1609
Calin Juravled0d48522014-11-04 16:40:20 +00001610void LocationsBuilderARM::VisitDivZeroCheck(HDivZeroCheck* instruction) {
1611 LocationSummary* locations =
1612 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
1613 locations->SetInAt(0, Location::RequiresRegister());
1614 if (instruction->HasUses()) {
1615 locations->SetOut(Location::SameAsFirstInput());
1616 }
1617}
1618
1619void InstructionCodeGeneratorARM::VisitDivZeroCheck(HDivZeroCheck* instruction) {
1620 SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) DivZeroCheckSlowPathARM(instruction);
1621 codegen_->AddSlowPath(slow_path);
1622
1623 LocationSummary* locations = instruction->GetLocations();
1624 Location value = locations->InAt(0);
1625
1626 DCHECK(value.IsRegister()) << value;
1627 __ cmp(value.As<Register>(), ShifterOperand(0));
1628 __ b(slow_path->GetEntryLabel(), EQ);
1629}
1630
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +01001631void LocationsBuilderARM::VisitNewInstance(HNewInstance* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001632 LocationSummary* locations =
1633 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall);
Nicolas Geoffraya7aca372014-04-28 17:47:12 +01001634 InvokeRuntimeCallingConvention calling_convention;
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001635 locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1636 locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1637 locations->SetOut(Location::RegisterLocation(R0));
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +01001638}
1639
1640void InstructionCodeGeneratorARM::VisitNewInstance(HNewInstance* instruction) {
1641 InvokeRuntimeCallingConvention calling_convention;
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001642 codegen_->LoadCurrentMethod(calling_convention.GetRegisterAt(1));
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +01001643 __ LoadImmediate(calling_convention.GetRegisterAt(0), instruction->GetTypeIndex());
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001644 codegen_->InvokeRuntime(
1645 QUICK_ENTRY_POINT(pAllocObjectWithAccessCheck), instruction, instruction->GetDexPc());
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +01001646}
1647
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001648void LocationsBuilderARM::VisitNewArray(HNewArray* instruction) {
1649 LocationSummary* locations =
1650 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall);
1651 InvokeRuntimeCallingConvention calling_convention;
1652 locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1653 locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1654 locations->SetOut(Location::RegisterLocation(R0));
1655 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(2)));
1656}
1657
1658void InstructionCodeGeneratorARM::VisitNewArray(HNewArray* instruction) {
1659 InvokeRuntimeCallingConvention calling_convention;
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001660 codegen_->LoadCurrentMethod(calling_convention.GetRegisterAt(1));
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001661 __ LoadImmediate(calling_convention.GetRegisterAt(0), instruction->GetTypeIndex());
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001662 codegen_->InvokeRuntime(
1663 QUICK_ENTRY_POINT(pAllocArrayWithAccessCheck), instruction, instruction->GetDexPc());
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001664}
1665
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001666void LocationsBuilderARM::VisitParameterValue(HParameterValue* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001667 LocationSummary* locations =
1668 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffraya747a392014-04-17 14:56:23 +01001669 Location location = parameter_visitor_.GetNextLocation(instruction->GetType());
1670 if (location.IsStackSlot()) {
1671 location = Location::StackSlot(location.GetStackIndex() + codegen_->GetFrameSize());
1672 } else if (location.IsDoubleStackSlot()) {
1673 location = Location::DoubleStackSlot(location.GetStackIndex() + codegen_->GetFrameSize());
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001674 }
Nicolas Geoffraya747a392014-04-17 14:56:23 +01001675 locations->SetOut(location);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001676}
1677
1678void InstructionCodeGeneratorARM::VisitParameterValue(HParameterValue* instruction) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001679 // Nothing to do, the parameter is already at its location.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001680 UNUSED(instruction);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001681}
1682
Roland Levillain1cc5f2512014-10-22 18:06:21 +01001683void LocationsBuilderARM::VisitNot(HNot* not_) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001684 LocationSummary* locations =
Roland Levillain1cc5f2512014-10-22 18:06:21 +01001685 new (GetGraph()->GetArena()) LocationSummary(not_, LocationSummary::kNoCall);
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001686 locations->SetInAt(0, Location::RequiresRegister());
1687 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +01001688}
1689
Roland Levillain1cc5f2512014-10-22 18:06:21 +01001690void InstructionCodeGeneratorARM::VisitNot(HNot* not_) {
1691 LocationSummary* locations = not_->GetLocations();
1692 Location out = locations->Out();
1693 Location in = locations->InAt(0);
1694 switch (not_->InputAt(0)->GetType()) {
1695 case Primitive::kPrimBoolean:
1696 __ eor(out.As<Register>(), in.As<Register>(), ShifterOperand(1));
1697 break;
1698
1699 case Primitive::kPrimInt:
1700 __ mvn(out.As<Register>(), ShifterOperand(in.As<Register>()));
1701 break;
1702
1703 case Primitive::kPrimLong:
Roland Levillain70566432014-10-24 16:20:17 +01001704 __ mvn(out.AsRegisterPairLow<Register>(),
1705 ShifterOperand(in.AsRegisterPairLow<Register>()));
1706 __ mvn(out.AsRegisterPairHigh<Register>(),
1707 ShifterOperand(in.AsRegisterPairHigh<Register>()));
Roland Levillain1cc5f2512014-10-22 18:06:21 +01001708 break;
1709
1710 default:
1711 LOG(FATAL) << "Unimplemented type for not operation " << not_->GetResultType();
1712 }
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +01001713}
1714
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001715void LocationsBuilderARM::VisitCompare(HCompare* compare) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001716 LocationSummary* locations =
1717 new (GetGraph()->GetArena()) LocationSummary(compare, LocationSummary::kNoCall);
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001718 locations->SetInAt(0, Location::RequiresRegister());
1719 locations->SetInAt(1, Location::RequiresRegister());
1720 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001721}
1722
1723void InstructionCodeGeneratorARM::VisitCompare(HCompare* compare) {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001724 LocationSummary* locations = compare->GetLocations();
1725 switch (compare->InputAt(0)->GetType()) {
1726 case Primitive::kPrimLong: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001727 Register output = locations->Out().As<Register>();
1728 Location left = locations->InAt(0);
1729 Location right = locations->InAt(1);
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001730 Label less, greater, done;
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001731 __ cmp(left.AsRegisterPairHigh<Register>(),
1732 ShifterOperand(right.AsRegisterPairHigh<Register>())); // Signed compare.
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001733 __ b(&less, LT);
1734 __ b(&greater, GT);
Nicolas Geoffray8d486732014-07-16 16:23:40 +01001735 // Do LoadImmediate before any `cmp`, as LoadImmediate might affect
1736 // the status flags.
1737 __ LoadImmediate(output, 0);
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001738 __ cmp(left.AsRegisterPairLow<Register>(),
1739 ShifterOperand(right.AsRegisterPairLow<Register>())); // Unsigned compare.
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001740 __ b(&done, EQ);
1741 __ b(&less, CC);
1742
1743 __ Bind(&greater);
1744 __ LoadImmediate(output, 1);
1745 __ b(&done);
1746
1747 __ Bind(&less);
1748 __ LoadImmediate(output, -1);
1749
1750 __ Bind(&done);
1751 break;
1752 }
1753 default:
1754 LOG(FATAL) << "Unimplemented compare type " << compare->InputAt(0)->GetType();
1755 }
1756}
1757
Nicolas Geoffrayc32e7702014-04-24 12:43:16 +01001758void LocationsBuilderARM::VisitPhi(HPhi* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001759 LocationSummary* locations =
1760 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffray31d76b42014-06-09 15:02:22 +01001761 for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) {
1762 locations->SetInAt(i, Location::Any());
1763 }
1764 locations->SetOut(Location::Any());
Nicolas Geoffrayc32e7702014-04-24 12:43:16 +01001765}
1766
1767void InstructionCodeGeneratorARM::VisitPhi(HPhi* instruction) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001768 UNUSED(instruction);
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01001769 LOG(FATAL) << "Unreachable";
Nicolas Geoffrayc32e7702014-04-24 12:43:16 +01001770}
1771
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001772void LocationsBuilderARM::VisitInstanceFieldSet(HInstanceFieldSet* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001773 LocationSummary* locations =
1774 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffray9ae0daa2014-09-30 22:40:23 +01001775 bool is_object_type = instruction->GetFieldType() == Primitive::kPrimNot;
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001776 locations->SetInAt(0, Location::RequiresRegister());
1777 locations->SetInAt(1, Location::RequiresRegister());
Nicolas Geoffray1a43dd72014-07-17 15:15:34 +01001778 // Temporary registers for the write barrier.
Nicolas Geoffray9ae0daa2014-09-30 22:40:23 +01001779 if (is_object_type) {
Nicolas Geoffray1a43dd72014-07-17 15:15:34 +01001780 locations->AddTemp(Location::RequiresRegister());
1781 locations->AddTemp(Location::RequiresRegister());
1782 }
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001783}
1784
1785void InstructionCodeGeneratorARM::VisitInstanceFieldSet(HInstanceFieldSet* instruction) {
1786 LocationSummary* locations = instruction->GetLocations();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001787 Register obj = locations->InAt(0).As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001788 uint32_t offset = instruction->GetFieldOffset().Uint32Value();
Nicolas Geoffray39468442014-09-02 15:17:15 +01001789 Primitive::Type field_type = instruction->GetFieldType();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001790
1791 switch (field_type) {
1792 case Primitive::kPrimBoolean:
1793 case Primitive::kPrimByte: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001794 Register value = locations->InAt(1).As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001795 __ StoreToOffset(kStoreByte, value, obj, offset);
1796 break;
1797 }
1798
1799 case Primitive::kPrimShort:
1800 case Primitive::kPrimChar: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001801 Register value = locations->InAt(1).As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001802 __ StoreToOffset(kStoreHalfword, value, obj, offset);
1803 break;
1804 }
1805
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001806 case Primitive::kPrimInt:
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001807 case Primitive::kPrimNot: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001808 Register value = locations->InAt(1).As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001809 __ StoreToOffset(kStoreWord, value, obj, offset);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001810 if (field_type == Primitive::kPrimNot) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001811 Register temp = locations->GetTemp(0).As<Register>();
1812 Register card = locations->GetTemp(1).As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001813 codegen_->MarkGCCard(temp, card, obj, value);
1814 }
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001815 break;
1816 }
1817
1818 case Primitive::kPrimLong: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001819 Location value = locations->InAt(1);
1820 __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow<Register>(), obj, offset);
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001821 break;
1822 }
1823
1824 case Primitive::kPrimFloat:
1825 case Primitive::kPrimDouble:
1826 LOG(FATAL) << "Unimplemented register type " << field_type;
Ian Rogersfc787ec2014-10-09 21:56:44 -07001827 UNREACHABLE();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001828 case Primitive::kPrimVoid:
1829 LOG(FATAL) << "Unreachable type " << field_type;
Ian Rogersfc787ec2014-10-09 21:56:44 -07001830 UNREACHABLE();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001831 }
1832}
1833
1834void LocationsBuilderARM::VisitInstanceFieldGet(HInstanceFieldGet* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001835 LocationSummary* locations =
1836 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001837 locations->SetInAt(0, Location::RequiresRegister());
1838 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001839}
1840
1841void InstructionCodeGeneratorARM::VisitInstanceFieldGet(HInstanceFieldGet* instruction) {
1842 LocationSummary* locations = instruction->GetLocations();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001843 Register obj = locations->InAt(0).As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001844 uint32_t offset = instruction->GetFieldOffset().Uint32Value();
1845
1846 switch (instruction->GetType()) {
1847 case Primitive::kPrimBoolean: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001848 Register out = locations->Out().As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001849 __ LoadFromOffset(kLoadUnsignedByte, out, obj, offset);
1850 break;
1851 }
1852
1853 case Primitive::kPrimByte: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001854 Register out = locations->Out().As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001855 __ LoadFromOffset(kLoadSignedByte, out, obj, offset);
1856 break;
1857 }
1858
1859 case Primitive::kPrimShort: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001860 Register out = locations->Out().As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001861 __ LoadFromOffset(kLoadSignedHalfword, out, obj, offset);
1862 break;
1863 }
1864
1865 case Primitive::kPrimChar: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001866 Register out = locations->Out().As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001867 __ LoadFromOffset(kLoadUnsignedHalfword, out, obj, offset);
1868 break;
1869 }
1870
1871 case Primitive::kPrimInt:
1872 case Primitive::kPrimNot: {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001873 Register out = locations->Out().As<Register>();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001874 __ LoadFromOffset(kLoadWord, out, obj, offset);
1875 break;
1876 }
1877
1878 case Primitive::kPrimLong: {
1879 // TODO: support volatile.
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001880 Location out = locations->Out();
1881 __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow<Register>(), obj, offset);
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001882 break;
1883 }
1884
1885 case Primitive::kPrimFloat:
1886 case Primitive::kPrimDouble:
1887 LOG(FATAL) << "Unimplemented register type " << instruction->GetType();
Ian Rogersfc787ec2014-10-09 21:56:44 -07001888 UNREACHABLE();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001889 case Primitive::kPrimVoid:
1890 LOG(FATAL) << "Unreachable type " << instruction->GetType();
Ian Rogersfc787ec2014-10-09 21:56:44 -07001891 UNREACHABLE();
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001892 }
1893}
1894
1895void LocationsBuilderARM::VisitNullCheck(HNullCheck* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001896 LocationSummary* locations =
1897 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001898 locations->SetInAt(0, Location::RequiresRegister());
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +01001899 if (instruction->HasUses()) {
1900 locations->SetOut(Location::SameAsFirstInput());
1901 }
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001902}
1903
1904void InstructionCodeGeneratorARM::VisitNullCheck(HNullCheck* instruction) {
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +01001905 SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) NullCheckSlowPathARM(instruction);
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001906 codegen_->AddSlowPath(slow_path);
1907
1908 LocationSummary* locations = instruction->GetLocations();
1909 Location obj = locations->InAt(0);
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001910
1911 if (obj.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001912 __ cmp(obj.As<Register>(), ShifterOperand(0));
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +01001913 __ b(slow_path->GetEntryLabel(), EQ);
1914 } else {
1915 DCHECK(obj.IsConstant()) << obj;
1916 DCHECK_EQ(obj.GetConstant()->AsIntConstant()->GetValue(), 0);
1917 __ b(slow_path->GetEntryLabel());
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001918 }
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001919}
1920
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001921void LocationsBuilderARM::VisitArrayGet(HArrayGet* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01001922 LocationSummary* locations =
1923 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01001924 locations->SetInAt(0, Location::RequiresRegister());
1925 locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1)));
1926 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001927}
1928
1929void InstructionCodeGeneratorARM::VisitArrayGet(HArrayGet* instruction) {
1930 LocationSummary* locations = instruction->GetLocations();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001931 Register obj = locations->InAt(0).As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001932 Location index = locations->InAt(1);
1933
1934 switch (instruction->GetType()) {
1935 case Primitive::kPrimBoolean: {
1936 uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001937 Register out = locations->Out().As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001938 if (index.IsConstant()) {
1939 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset;
1940 __ LoadFromOffset(kLoadUnsignedByte, out, obj, offset);
1941 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001942 __ add(IP, obj, ShifterOperand(index.As<Register>()));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001943 __ LoadFromOffset(kLoadUnsignedByte, out, IP, data_offset);
1944 }
1945 break;
1946 }
1947
1948 case Primitive::kPrimByte: {
1949 uint32_t data_offset = mirror::Array::DataOffset(sizeof(int8_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001950 Register out = locations->Out().As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001951 if (index.IsConstant()) {
1952 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset;
1953 __ LoadFromOffset(kLoadSignedByte, out, obj, offset);
1954 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001955 __ add(IP, obj, ShifterOperand(index.As<Register>()));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001956 __ LoadFromOffset(kLoadSignedByte, out, IP, data_offset);
1957 }
1958 break;
1959 }
1960
1961 case Primitive::kPrimShort: {
1962 uint32_t data_offset = mirror::Array::DataOffset(sizeof(int16_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001963 Register out = locations->Out().As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001964 if (index.IsConstant()) {
1965 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset;
1966 __ LoadFromOffset(kLoadSignedHalfword, out, obj, offset);
1967 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001968 __ add(IP, obj, ShifterOperand(index.As<Register>(), LSL, TIMES_2));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001969 __ LoadFromOffset(kLoadSignedHalfword, out, IP, data_offset);
1970 }
1971 break;
1972 }
1973
1974 case Primitive::kPrimChar: {
1975 uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001976 Register out = locations->Out().As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001977 if (index.IsConstant()) {
1978 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset;
1979 __ LoadFromOffset(kLoadUnsignedHalfword, out, obj, offset);
1980 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001981 __ add(IP, obj, ShifterOperand(index.As<Register>(), LSL, TIMES_2));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001982 __ LoadFromOffset(kLoadUnsignedHalfword, out, IP, data_offset);
1983 }
1984 break;
1985 }
1986
1987 case Primitive::kPrimInt:
1988 case Primitive::kPrimNot: {
1989 DCHECK_EQ(sizeof(mirror::HeapReference<mirror::Object>), sizeof(int32_t));
1990 uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001991 Register out = locations->Out().As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001992 if (index.IsConstant()) {
1993 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset;
1994 __ LoadFromOffset(kLoadWord, out, obj, offset);
1995 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01001996 __ add(IP, obj, ShifterOperand(index.As<Register>(), LSL, TIMES_4));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001997 __ LoadFromOffset(kLoadWord, out, IP, data_offset);
1998 }
1999 break;
2000 }
2001
2002 case Primitive::kPrimLong: {
2003 uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002004 Location out = locations->Out();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002005 if (index.IsConstant()) {
2006 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset;
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002007 __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow<Register>(), obj, offset);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002008 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002009 __ add(IP, obj, ShifterOperand(index.As<Register>(), LSL, TIMES_8));
2010 __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow<Register>(), IP, data_offset);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002011 }
2012 break;
2013 }
2014
2015 case Primitive::kPrimFloat:
2016 case Primitive::kPrimDouble:
2017 LOG(FATAL) << "Unimplemented register type " << instruction->GetType();
Ian Rogersfc787ec2014-10-09 21:56:44 -07002018 UNREACHABLE();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002019 case Primitive::kPrimVoid:
2020 LOG(FATAL) << "Unreachable type " << instruction->GetType();
Ian Rogersfc787ec2014-10-09 21:56:44 -07002021 UNREACHABLE();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002022 }
2023}
2024
2025void LocationsBuilderARM::VisitArraySet(HArraySet* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01002026 Primitive::Type value_type = instruction->GetComponentType();
2027 bool is_object = value_type == Primitive::kPrimNot;
2028 LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(
2029 instruction, is_object ? LocationSummary::kCall : LocationSummary::kNoCall);
2030 if (is_object) {
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002031 InvokeRuntimeCallingConvention calling_convention;
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002032 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
2033 locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
2034 locations->SetInAt(2, Location::RegisterLocation(calling_convention.GetRegisterAt(2)));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002035 } else {
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01002036 locations->SetInAt(0, Location::RequiresRegister());
2037 locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1)));
2038 locations->SetInAt(2, Location::RequiresRegister());
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002039 }
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002040}
2041
2042void InstructionCodeGeneratorARM::VisitArraySet(HArraySet* instruction) {
2043 LocationSummary* locations = instruction->GetLocations();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002044 Register obj = locations->InAt(0).As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002045 Location index = locations->InAt(1);
Nicolas Geoffray39468442014-09-02 15:17:15 +01002046 Primitive::Type value_type = instruction->GetComponentType();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002047
2048 switch (value_type) {
2049 case Primitive::kPrimBoolean:
2050 case Primitive::kPrimByte: {
2051 uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002052 Register value = locations->InAt(2).As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002053 if (index.IsConstant()) {
2054 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset;
2055 __ StoreToOffset(kStoreByte, value, obj, offset);
2056 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002057 __ add(IP, obj, ShifterOperand(index.As<Register>()));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002058 __ StoreToOffset(kStoreByte, value, IP, data_offset);
2059 }
2060 break;
2061 }
2062
2063 case Primitive::kPrimShort:
2064 case Primitive::kPrimChar: {
2065 uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002066 Register value = locations->InAt(2).As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002067 if (index.IsConstant()) {
2068 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset;
2069 __ StoreToOffset(kStoreHalfword, value, obj, offset);
2070 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002071 __ add(IP, obj, ShifterOperand(index.As<Register>(), LSL, TIMES_2));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002072 __ StoreToOffset(kStoreHalfword, value, IP, data_offset);
2073 }
2074 break;
2075 }
2076
2077 case Primitive::kPrimInt: {
2078 uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002079 Register value = locations->InAt(2).As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002080 if (index.IsConstant()) {
2081 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset;
2082 __ StoreToOffset(kStoreWord, value, obj, offset);
2083 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002084 __ add(IP, obj, ShifterOperand(index.As<Register>(), LSL, TIMES_4));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002085 __ StoreToOffset(kStoreWord, value, IP, data_offset);
2086 }
2087 break;
2088 }
2089
2090 case Primitive::kPrimNot: {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002091 codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pAputObject), instruction, instruction->GetDexPc());
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002092 break;
2093 }
2094
2095 case Primitive::kPrimLong: {
2096 uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002097 Location value = locations->InAt(2);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002098 if (index.IsConstant()) {
2099 size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset;
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002100 __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow<Register>(), obj, offset);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002101 } else {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002102 __ add(IP, obj, ShifterOperand(index.As<Register>(), LSL, TIMES_8));
2103 __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow<Register>(), IP, data_offset);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002104 }
2105 break;
2106 }
2107
2108 case Primitive::kPrimFloat:
2109 case Primitive::kPrimDouble:
2110 LOG(FATAL) << "Unimplemented register type " << instruction->GetType();
Ian Rogersfc787ec2014-10-09 21:56:44 -07002111 UNREACHABLE();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002112 case Primitive::kPrimVoid:
2113 LOG(FATAL) << "Unreachable type " << instruction->GetType();
Ian Rogersfc787ec2014-10-09 21:56:44 -07002114 UNREACHABLE();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002115 }
2116}
2117
2118void LocationsBuilderARM::VisitArrayLength(HArrayLength* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01002119 LocationSummary* locations =
2120 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +01002121 locations->SetInAt(0, Location::RequiresRegister());
2122 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002123}
2124
2125void InstructionCodeGeneratorARM::VisitArrayLength(HArrayLength* instruction) {
2126 LocationSummary* locations = instruction->GetLocations();
2127 uint32_t offset = mirror::Array::LengthOffset().Uint32Value();
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002128 Register obj = locations->InAt(0).As<Register>();
2129 Register out = locations->Out().As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002130 __ LoadFromOffset(kLoadWord, out, obj, offset);
2131}
2132
2133void LocationsBuilderARM::VisitBoundsCheck(HBoundsCheck* instruction) {
Nicolas Geoffray39468442014-09-02 15:17:15 +01002134 LocationSummary* locations =
2135 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002136 locations->SetInAt(0, Location::RequiresRegister());
2137 locations->SetInAt(1, Location::RequiresRegister());
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +01002138 if (instruction->HasUses()) {
2139 locations->SetOut(Location::SameAsFirstInput());
2140 }
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002141}
2142
2143void InstructionCodeGeneratorARM::VisitBoundsCheck(HBoundsCheck* instruction) {
2144 LocationSummary* locations = instruction->GetLocations();
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +01002145 SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) BoundsCheckSlowPathARM(
Nicolas Geoffray39468442014-09-02 15:17:15 +01002146 instruction, locations->InAt(0), locations->InAt(1));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002147 codegen_->AddSlowPath(slow_path);
2148
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002149 Register index = locations->InAt(0).As<Register>();
2150 Register length = locations->InAt(1).As<Register>();
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01002151
2152 __ cmp(index, ShifterOperand(length));
2153 __ b(slow_path->GetEntryLabel(), CS);
2154}
2155
2156void CodeGeneratorARM::MarkGCCard(Register temp, Register card, Register object, Register value) {
2157 Label is_null;
2158 __ CompareAndBranchIfZero(value, &is_null);
2159 __ LoadFromOffset(kLoadWord, card, TR, Thread::CardTableOffset<kArmWordSize>().Int32Value());
2160 __ Lsr(temp, object, gc::accounting::CardTable::kCardShift);
2161 __ strb(card, Address(card, temp));
2162 __ Bind(&is_null);
2163}
2164
Nicolas Geoffraye5038322014-07-04 09:41:32 +01002165void LocationsBuilderARM::VisitTemporary(HTemporary* temp) {
2166 temp->SetLocations(nullptr);
2167}
2168
2169void InstructionCodeGeneratorARM::VisitTemporary(HTemporary* temp) {
2170 // Nothing to do, this is driven by the code generator.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07002171 UNUSED(temp);
Nicolas Geoffraye5038322014-07-04 09:41:32 +01002172}
2173
Nicolas Geoffray4e3d23a2014-05-22 18:32:45 +01002174void LocationsBuilderARM::VisitParallelMove(HParallelMove* instruction) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07002175 UNUSED(instruction);
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002176 LOG(FATAL) << "Unreachable";
Nicolas Geoffray4e3d23a2014-05-22 18:32:45 +01002177}
2178
2179void InstructionCodeGeneratorARM::VisitParallelMove(HParallelMove* instruction) {
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002180 codegen_->GetMoveResolver()->EmitNativeCode(instruction);
2181}
2182
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +00002183void LocationsBuilderARM::VisitSuspendCheck(HSuspendCheck* instruction) {
2184 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCallOnSlowPath);
2185}
2186
2187void InstructionCodeGeneratorARM::VisitSuspendCheck(HSuspendCheck* instruction) {
Nicolas Geoffray3c049742014-09-24 18:10:46 +01002188 HBasicBlock* block = instruction->GetBlock();
2189 if (block->GetLoopInformation() != nullptr) {
2190 DCHECK(block->GetLoopInformation()->GetSuspendCheck() == instruction);
2191 // The back edge will generate the suspend check.
2192 return;
2193 }
2194 if (block->IsEntryBlock() && instruction->GetNext()->IsGoto()) {
2195 // The goto will generate the suspend check.
2196 return;
2197 }
2198 GenerateSuspendCheck(instruction, nullptr);
2199}
2200
2201void InstructionCodeGeneratorARM::GenerateSuspendCheck(HSuspendCheck* instruction,
2202 HBasicBlock* successor) {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +00002203 SuspendCheckSlowPathARM* slow_path =
Nicolas Geoffray3c049742014-09-24 18:10:46 +01002204 new (GetGraph()->GetArena()) SuspendCheckSlowPathARM(instruction, successor);
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +00002205 codegen_->AddSlowPath(slow_path);
2206
Nicolas Geoffray9ae0daa2014-09-30 22:40:23 +01002207 __ subs(R4, R4, ShifterOperand(1));
Nicolas Geoffray3c049742014-09-24 18:10:46 +01002208 if (successor == nullptr) {
Nicolas Geoffray9ae0daa2014-09-30 22:40:23 +01002209 __ b(slow_path->GetEntryLabel(), EQ);
Nicolas Geoffray3c049742014-09-24 18:10:46 +01002210 __ Bind(slow_path->GetReturnLabel());
2211 } else {
Nicolas Geoffray9ae0daa2014-09-30 22:40:23 +01002212 __ b(codegen_->GetLabelOf(successor), NE);
Nicolas Geoffray3c049742014-09-24 18:10:46 +01002213 __ b(slow_path->GetEntryLabel());
2214 }
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +00002215}
2216
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002217ArmAssembler* ParallelMoveResolverARM::GetAssembler() const {
2218 return codegen_->GetAssembler();
2219}
2220
2221void ParallelMoveResolverARM::EmitMove(size_t index) {
2222 MoveOperands* move = moves_.Get(index);
2223 Location source = move->GetSource();
2224 Location destination = move->GetDestination();
2225
2226 if (source.IsRegister()) {
2227 if (destination.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002228 __ Mov(destination.As<Register>(), source.As<Register>());
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002229 } else {
2230 DCHECK(destination.IsStackSlot());
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002231 __ StoreToOffset(kStoreWord, source.As<Register>(),
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002232 SP, destination.GetStackIndex());
2233 }
2234 } else if (source.IsStackSlot()) {
2235 if (destination.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002236 __ LoadFromOffset(kLoadWord, destination.As<Register>(),
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002237 SP, source.GetStackIndex());
2238 } else {
2239 DCHECK(destination.IsStackSlot());
2240 __ LoadFromOffset(kLoadWord, IP, SP, source.GetStackIndex());
2241 __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex());
2242 }
2243 } else {
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01002244 DCHECK(source.IsConstant());
Roland Levillain476df552014-10-09 17:51:36 +01002245 DCHECK(source.GetConstant()->IsIntConstant());
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01002246 int32_t value = source.GetConstant()->AsIntConstant()->GetValue();
2247 if (destination.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002248 __ LoadImmediate(destination.As<Register>(), value);
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01002249 } else {
2250 DCHECK(destination.IsStackSlot());
2251 __ LoadImmediate(IP, value);
Nicolas Geoffray360231a2014-10-08 21:07:48 +01002252 __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex());
Nicolas Geoffray96f89a22014-07-11 10:57:49 +01002253 }
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002254 }
2255}
2256
2257void ParallelMoveResolverARM::Exchange(Register reg, int mem) {
2258 __ Mov(IP, reg);
2259 __ LoadFromOffset(kLoadWord, reg, SP, mem);
2260 __ StoreToOffset(kStoreWord, IP, SP, mem);
2261}
2262
2263void ParallelMoveResolverARM::Exchange(int mem1, int mem2) {
2264 ScratchRegisterScope ensure_scratch(this, IP, R0, codegen_->GetNumberOfCoreRegisters());
2265 int stack_offset = ensure_scratch.IsSpilled() ? kArmWordSize : 0;
2266 __ LoadFromOffset(kLoadWord, static_cast<Register>(ensure_scratch.GetRegister()),
2267 SP, mem1 + stack_offset);
2268 __ LoadFromOffset(kLoadWord, IP, SP, mem2 + stack_offset);
2269 __ StoreToOffset(kStoreWord, static_cast<Register>(ensure_scratch.GetRegister()),
2270 SP, mem2 + stack_offset);
2271 __ StoreToOffset(kStoreWord, IP, SP, mem1 + stack_offset);
2272}
2273
2274void ParallelMoveResolverARM::EmitSwap(size_t index) {
2275 MoveOperands* move = moves_.Get(index);
2276 Location source = move->GetSource();
2277 Location destination = move->GetDestination();
2278
2279 if (source.IsRegister() && destination.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002280 DCHECK_NE(source.As<Register>(), IP);
2281 DCHECK_NE(destination.As<Register>(), IP);
2282 __ Mov(IP, source.As<Register>());
2283 __ Mov(source.As<Register>(), destination.As<Register>());
2284 __ Mov(destination.As<Register>(), IP);
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002285 } else if (source.IsRegister() && destination.IsStackSlot()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002286 Exchange(source.As<Register>(), destination.GetStackIndex());
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002287 } else if (source.IsStackSlot() && destination.IsRegister()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +01002288 Exchange(destination.As<Register>(), source.GetStackIndex());
Nicolas Geoffraye27f31a2014-06-12 17:53:14 +01002289 } else if (source.IsStackSlot() && destination.IsStackSlot()) {
2290 Exchange(source.GetStackIndex(), destination.GetStackIndex());
2291 } else {
2292 LOG(FATAL) << "Unimplemented";
2293 }
2294}
2295
2296void ParallelMoveResolverARM::SpillScratch(int reg) {
2297 __ Push(static_cast<Register>(reg));
2298}
2299
2300void ParallelMoveResolverARM::RestoreScratch(int reg) {
2301 __ Pop(static_cast<Register>(reg));
Nicolas Geoffray4e3d23a2014-05-22 18:32:45 +01002302}
2303
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002304void LocationsBuilderARM::VisitLoadClass(HLoadClass* cls) {
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002305 LocationSummary::CallKind call_kind = cls->CanCallRuntime()
2306 ? LocationSummary::kCallOnSlowPath
2307 : LocationSummary::kNoCall;
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002308 LocationSummary* locations =
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002309 new (GetGraph()->GetArena()) LocationSummary(cls, call_kind);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002310 locations->SetOut(Location::RequiresRegister());
2311}
2312
2313void InstructionCodeGeneratorARM::VisitLoadClass(HLoadClass* cls) {
2314 Register out = cls->GetLocations()->Out().As<Register>();
2315 if (cls->IsReferrersClass()) {
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002316 DCHECK(!cls->CanCallRuntime());
2317 DCHECK(!cls->MustGenerateClinitCheck());
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002318 codegen_->LoadCurrentMethod(out);
2319 __ LoadFromOffset(kLoadWord, out, out, mirror::ArtMethod::DeclaringClassOffset().Int32Value());
2320 } else {
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002321 DCHECK(cls->CanCallRuntime());
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002322 codegen_->LoadCurrentMethod(out);
2323 __ LoadFromOffset(
2324 kLoadWord, out, out, mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value());
2325 __ LoadFromOffset(kLoadWord, out, out, CodeGenerator::GetCacheOffset(cls->GetTypeIndex()));
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002326
2327 SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathARM(
2328 cls, cls, cls->GetDexPc(), cls->MustGenerateClinitCheck());
2329 codegen_->AddSlowPath(slow_path);
2330 __ cmp(out, ShifterOperand(0));
2331 __ b(slow_path->GetEntryLabel(), EQ);
2332 if (cls->MustGenerateClinitCheck()) {
2333 GenerateClassInitializationCheck(slow_path, out);
2334 } else {
2335 __ Bind(slow_path->GetExitLabel());
2336 }
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002337 }
2338}
2339
2340void LocationsBuilderARM::VisitClinitCheck(HClinitCheck* check) {
2341 LocationSummary* locations =
2342 new (GetGraph()->GetArena()) LocationSummary(check, LocationSummary::kCallOnSlowPath);
2343 locations->SetInAt(0, Location::RequiresRegister());
2344 if (check->HasUses()) {
2345 locations->SetOut(Location::SameAsFirstInput());
2346 }
2347}
2348
2349void InstructionCodeGeneratorARM::VisitClinitCheck(HClinitCheck* check) {
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002350 // We assume the class is not null.
2351 SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathARM(
2352 check->GetLoadClass(), check, check->GetDexPc(), true);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002353 codegen_->AddSlowPath(slow_path);
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002354 GenerateClassInitializationCheck(slow_path, check->GetLocations()->InAt(0).As<Register>());
2355}
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002356
Nicolas Geoffray424f6762014-11-03 14:51:25 +00002357void InstructionCodeGeneratorARM::GenerateClassInitializationCheck(
2358 SlowPathCodeARM* slow_path, Register class_reg) {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01002359 __ LoadFromOffset(kLoadWord, IP, class_reg, mirror::Class::StatusOffset().Int32Value());
2360 __ cmp(IP, ShifterOperand(mirror::Class::kStatusInitialized));
2361 __ b(slow_path->GetEntryLabel(), LT);
2362 // Even if the initialized flag is set, we may be in a situation where caches are not synced
2363 // properly. Therefore, we do a memory fence.
2364 __ dmb(ISH);
2365 __ Bind(slow_path->GetExitLabel());
2366}
2367
2368void LocationsBuilderARM::VisitStaticFieldGet(HStaticFieldGet* instruction) {
2369 LocationSummary* locations =
2370 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
2371 locations->SetInAt(0, Location::RequiresRegister());
2372 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
2373}
2374
2375void InstructionCodeGeneratorARM::VisitStaticFieldGet(HStaticFieldGet* instruction) {
2376 LocationSummary* locations = instruction->GetLocations();
2377 Register cls = locations->InAt(0).As<Register>();
2378 uint32_t offset = instruction->GetFieldOffset().Uint32Value();
2379
2380 switch (instruction->GetType()) {
2381 case Primitive::kPrimBoolean: {
2382 Register out = locations->Out().As<Register>();
2383 __ LoadFromOffset(kLoadUnsignedByte, out, cls, offset);
2384 break;
2385 }
2386
2387 case Primitive::kPrimByte: {
2388 Register out = locations->Out().As<Register>();
2389 __ LoadFromOffset(kLoadSignedByte, out, cls, offset);
2390 break;
2391 }
2392
2393 case Primitive::kPrimShort: {
2394 Register out = locations->Out().As<Register>();
2395 __ LoadFromOffset(kLoadSignedHalfword, out, cls, offset);
2396 break;
2397 }
2398
2399 case Primitive::kPrimChar: {
2400 Register out = locations->Out().As<Register>();
2401 __ LoadFromOffset(kLoadUnsignedHalfword, out, cls, offset);
2402 break;
2403 }
2404
2405 case Primitive::kPrimInt:
2406 case Primitive::kPrimNot: {
2407 Register out = locations->Out().As<Register>();
2408 __ LoadFromOffset(kLoadWord, out, cls, offset);
2409 break;
2410 }
2411
2412 case Primitive::kPrimLong: {
2413 // TODO: support volatile.
2414 Location out = locations->Out();
2415 __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow<Register>(), cls, offset);
2416 break;
2417 }
2418
2419 case Primitive::kPrimFloat:
2420 case Primitive::kPrimDouble:
2421 LOG(FATAL) << "Unimplemented register type " << instruction->GetType();
2422 UNREACHABLE();
2423 case Primitive::kPrimVoid:
2424 LOG(FATAL) << "Unreachable type " << instruction->GetType();
2425 UNREACHABLE();
2426 }
2427}
2428
2429void LocationsBuilderARM::VisitStaticFieldSet(HStaticFieldSet* instruction) {
2430 LocationSummary* locations =
2431 new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall);
2432 bool is_object_type = instruction->GetFieldType() == Primitive::kPrimNot;
2433 locations->SetInAt(0, Location::RequiresRegister());
2434 locations->SetInAt(1, Location::RequiresRegister());
2435 // Temporary registers for the write barrier.
2436 if (is_object_type) {
2437 locations->AddTemp(Location::RequiresRegister());
2438 locations->AddTemp(Location::RequiresRegister());
2439 }
2440}
2441
2442void InstructionCodeGeneratorARM::VisitStaticFieldSet(HStaticFieldSet* instruction) {
2443 LocationSummary* locations = instruction->GetLocations();
2444 Register cls = locations->InAt(0).As<Register>();
2445 uint32_t offset = instruction->GetFieldOffset().Uint32Value();
2446 Primitive::Type field_type = instruction->GetFieldType();
2447
2448 switch (field_type) {
2449 case Primitive::kPrimBoolean:
2450 case Primitive::kPrimByte: {
2451 Register value = locations->InAt(1).As<Register>();
2452 __ StoreToOffset(kStoreByte, value, cls, offset);
2453 break;
2454 }
2455
2456 case Primitive::kPrimShort:
2457 case Primitive::kPrimChar: {
2458 Register value = locations->InAt(1).As<Register>();
2459 __ StoreToOffset(kStoreHalfword, value, cls, offset);
2460 break;
2461 }
2462
2463 case Primitive::kPrimInt:
2464 case Primitive::kPrimNot: {
2465 Register value = locations->InAt(1).As<Register>();
2466 __ StoreToOffset(kStoreWord, value, cls, offset);
2467 if (field_type == Primitive::kPrimNot) {
2468 Register temp = locations->GetTemp(0).As<Register>();
2469 Register card = locations->GetTemp(1).As<Register>();
2470 codegen_->MarkGCCard(temp, card, cls, value);
2471 }
2472 break;
2473 }
2474
2475 case Primitive::kPrimLong: {
2476 Location value = locations->InAt(1);
2477 __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow<Register>(), cls, offset);
2478 break;
2479 }
2480
2481 case Primitive::kPrimFloat:
2482 case Primitive::kPrimDouble:
2483 LOG(FATAL) << "Unimplemented register type " << field_type;
2484 UNREACHABLE();
2485 case Primitive::kPrimVoid:
2486 LOG(FATAL) << "Unreachable type " << field_type;
2487 UNREACHABLE();
2488 }
2489}
2490
Nicolas Geoffrayb5f62b32014-10-30 10:58:41 +00002491void LocationsBuilderARM::VisitLoadString(HLoadString* load) {
2492 LocationSummary* locations =
2493 new (GetGraph()->GetArena()) LocationSummary(load, LocationSummary::kCallOnSlowPath);
2494 locations->SetOut(Location::RequiresRegister());
2495}
2496
2497void InstructionCodeGeneratorARM::VisitLoadString(HLoadString* load) {
2498 SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) LoadStringSlowPathARM(load);
2499 codegen_->AddSlowPath(slow_path);
2500
2501 Register out = load->GetLocations()->Out().As<Register>();
2502 codegen_->LoadCurrentMethod(out);
2503 __ LoadFromOffset(
2504 kLoadWord, out, out, mirror::ArtMethod::DexCacheStringsOffset().Int32Value());
2505 __ LoadFromOffset(kLoadWord, out, out, CodeGenerator::GetCacheOffset(load->GetStringIndex()));
2506 __ cmp(out, ShifterOperand(0));
2507 __ b(slow_path->GetEntryLabel(), EQ);
2508 __ Bind(slow_path->GetExitLabel());
2509}
2510
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +00002511} // namespace arm
2512} // namespace art