Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "code_generator_arm.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 18 | |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 19 | #include "arch/arm/instruction_set_features_arm.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 20 | #include "art_method.h" |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 21 | #include "code_generator_utils.h" |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 22 | #include "compiled_method.h" |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 23 | #include "entrypoints/quick/quick_entrypoints.h" |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 24 | #include "gc/accounting/card_table.h" |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 25 | #include "intrinsics.h" |
| 26 | #include "intrinsics_arm.h" |
Ian Rogers | 7e70b00 | 2014-10-08 11:47:24 -0700 | [diff] [blame] | 27 | #include "mirror/array-inl.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 28 | #include "mirror/class-inl.h" |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 29 | #include "thread.h" |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 30 | #include "utils/arm/assembler_arm.h" |
| 31 | #include "utils/arm/managed_register_arm.h" |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 32 | #include "utils/assembler.h" |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 33 | #include "utils/stack_checks.h" |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 34 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 35 | namespace art { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 36 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 37 | namespace arm { |
| 38 | |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 39 | static bool ExpectedPairLayout(Location location) { |
| 40 | // We expected this for both core and fpu register pairs. |
| 41 | return ((location.low() & 1) == 0) && (location.low() + 1 == location.high()); |
| 42 | } |
| 43 | |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 44 | static constexpr int kCurrentMethodStackOffset = 0; |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 45 | static constexpr Register kMethodRegisterArgument = R0; |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 46 | |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 47 | // We unconditionally allocate R5 to ensure we can do long operations |
| 48 | // with baseline. |
| 49 | static constexpr Register kCoreSavedRegisterForBaseline = R5; |
| 50 | static constexpr Register kCoreCalleeSaves[] = |
Andreas Gampe | 501fd63 | 2015-09-10 16:11:06 -0700 | [diff] [blame] | 51 | { R5, R6, R7, R8, R10, R11, LR }; |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 52 | static constexpr SRegister kFpuCalleeSaves[] = |
| 53 | { S16, S17, S18, S19, S20, S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31 }; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 54 | |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 55 | // D31 cannot be split into two S registers, and the register allocator only works on |
| 56 | // S registers. Therefore there is no need to block it. |
| 57 | static constexpr DRegister DTMP = D31; |
| 58 | |
Roland Levillain | 62a46b2 | 2015-06-01 18:24:13 +0100 | [diff] [blame] | 59 | #define __ down_cast<ArmAssembler*>(codegen->GetAssembler())-> |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 60 | #define QUICK_ENTRY_POINT(x) QUICK_ENTRYPOINT_OFFSET(kArmWordSize, x).Int32Value() |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 61 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 62 | class NullCheckSlowPathARM : public SlowPathCode { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 63 | public: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 64 | explicit NullCheckSlowPathARM(HNullCheck* instruction) : instruction_(instruction) {} |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 65 | |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 66 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 67 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 68 | __ Bind(GetEntryLabel()); |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 69 | if (instruction_->CanThrowIntoCatchBlock()) { |
| 70 | // Live registers will be restored in the catch block if caught. |
| 71 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 72 | } |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 73 | arm_codegen->InvokeRuntime( |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 74 | QUICK_ENTRY_POINT(pThrowNullPointer), instruction_, instruction_->GetDexPc(), this); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 75 | } |
| 76 | |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 77 | bool IsFatal() const OVERRIDE { return true; } |
| 78 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 79 | const char* GetDescription() const OVERRIDE { return "NullCheckSlowPathARM"; } |
| 80 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 81 | private: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 82 | HNullCheck* const instruction_; |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 83 | DISALLOW_COPY_AND_ASSIGN(NullCheckSlowPathARM); |
| 84 | }; |
| 85 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 86 | class DivZeroCheckSlowPathARM : public SlowPathCode { |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 87 | public: |
| 88 | explicit DivZeroCheckSlowPathARM(HDivZeroCheck* instruction) : instruction_(instruction) {} |
| 89 | |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 90 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 91 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
| 92 | __ Bind(GetEntryLabel()); |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 93 | if (instruction_->CanThrowIntoCatchBlock()) { |
| 94 | // Live registers will be restored in the catch block if caught. |
| 95 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 96 | } |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 97 | arm_codegen->InvokeRuntime( |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 98 | QUICK_ENTRY_POINT(pThrowDivZero), instruction_, instruction_->GetDexPc(), this); |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 101 | bool IsFatal() const OVERRIDE { return true; } |
| 102 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 103 | const char* GetDescription() const OVERRIDE { return "DivZeroCheckSlowPathARM"; } |
| 104 | |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 105 | private: |
| 106 | HDivZeroCheck* const instruction_; |
| 107 | DISALLOW_COPY_AND_ASSIGN(DivZeroCheckSlowPathARM); |
| 108 | }; |
| 109 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 110 | class SuspendCheckSlowPathARM : public SlowPathCode { |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 111 | public: |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 112 | SuspendCheckSlowPathARM(HSuspendCheck* instruction, HBasicBlock* successor) |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 113 | : instruction_(instruction), successor_(successor) {} |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 114 | |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 115 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 116 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 117 | __ Bind(GetEntryLabel()); |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 118 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 119 | arm_codegen->InvokeRuntime( |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 120 | QUICK_ENTRY_POINT(pTestSuspend), instruction_, instruction_->GetDexPc(), this); |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 121 | RestoreLiveRegisters(codegen, instruction_->GetLocations()); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 122 | if (successor_ == nullptr) { |
| 123 | __ b(GetReturnLabel()); |
| 124 | } else { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 125 | __ b(arm_codegen->GetLabelOf(successor_)); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 126 | } |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 129 | Label* GetReturnLabel() { |
| 130 | DCHECK(successor_ == nullptr); |
| 131 | return &return_label_; |
| 132 | } |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 133 | |
Nicolas Geoffray | db216f4 | 2015-05-05 17:02:20 +0100 | [diff] [blame] | 134 | HBasicBlock* GetSuccessor() const { |
| 135 | return successor_; |
| 136 | } |
| 137 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 138 | const char* GetDescription() const OVERRIDE { return "SuspendCheckSlowPathARM"; } |
| 139 | |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 140 | private: |
| 141 | HSuspendCheck* const instruction_; |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 142 | // If not null, the block to branch to after the suspend check. |
| 143 | HBasicBlock* const successor_; |
| 144 | |
| 145 | // If `successor_` is null, the label to branch to after the suspend check. |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 146 | Label return_label_; |
| 147 | |
| 148 | DISALLOW_COPY_AND_ASSIGN(SuspendCheckSlowPathARM); |
| 149 | }; |
| 150 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 151 | class BoundsCheckSlowPathARM : public SlowPathCode { |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 152 | public: |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 153 | explicit BoundsCheckSlowPathARM(HBoundsCheck* instruction) |
| 154 | : instruction_(instruction) {} |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 155 | |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 156 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 157 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 158 | LocationSummary* locations = instruction_->GetLocations(); |
| 159 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 160 | __ Bind(GetEntryLabel()); |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 161 | if (instruction_->CanThrowIntoCatchBlock()) { |
| 162 | // Live registers will be restored in the catch block if caught. |
| 163 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 164 | } |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 165 | // We're moving two locations to locations that could overlap, so we need a parallel |
| 166 | // move resolver. |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 167 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 168 | codegen->EmitParallelMoves( |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 169 | locations->InAt(0), |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 170 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 171 | Primitive::kPrimInt, |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 172 | locations->InAt(1), |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 173 | Location::RegisterLocation(calling_convention.GetRegisterAt(1)), |
| 174 | Primitive::kPrimInt); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 175 | arm_codegen->InvokeRuntime( |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 176 | QUICK_ENTRY_POINT(pThrowArrayBounds), instruction_, instruction_->GetDexPc(), this); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 177 | } |
| 178 | |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 179 | bool IsFatal() const OVERRIDE { return true; } |
| 180 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 181 | const char* GetDescription() const OVERRIDE { return "BoundsCheckSlowPathARM"; } |
| 182 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 183 | private: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 184 | HBoundsCheck* const instruction_; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 185 | |
| 186 | DISALLOW_COPY_AND_ASSIGN(BoundsCheckSlowPathARM); |
| 187 | }; |
| 188 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 189 | class LoadClassSlowPathARM : public SlowPathCode { |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 190 | public: |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 191 | 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 Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 198 | |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 199 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 200 | LocationSummary* locations = at_->GetLocations(); |
| 201 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 202 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
| 203 | __ Bind(GetEntryLabel()); |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 204 | SaveLiveRegisters(codegen, locations); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 205 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 206 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 207 | __ LoadImmediate(calling_convention.GetRegisterAt(0), cls_->GetTypeIndex()); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 208 | int32_t entry_point_offset = do_clinit_ |
| 209 | ? QUICK_ENTRY_POINT(pInitializeStaticStorage) |
| 210 | : QUICK_ENTRY_POINT(pInitializeType); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 211 | arm_codegen->InvokeRuntime(entry_point_offset, at_, dex_pc_, this); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 212 | |
| 213 | // Move the class to the desired location. |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 214 | Location out = locations->Out(); |
| 215 | if (out.IsValid()) { |
| 216 | DCHECK(out.IsRegister() && !locations->GetLiveRegisters()->ContainsCoreRegister(out.reg())); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 217 | arm_codegen->Move32(locations->Out(), Location::RegisterLocation(R0)); |
| 218 | } |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 219 | RestoreLiveRegisters(codegen, locations); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 220 | __ b(GetExitLabel()); |
| 221 | } |
| 222 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 223 | const char* GetDescription() const OVERRIDE { return "LoadClassSlowPathARM"; } |
| 224 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 225 | private: |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 226 | // The class this slow path will load. |
| 227 | HLoadClass* const cls_; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 228 | |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 229 | // The instruction where this slow path is happening. |
| 230 | // (Might be the load class or an initialization check). |
| 231 | HInstruction* const at_; |
| 232 | |
| 233 | // The dex PC of `at_`. |
| 234 | const uint32_t dex_pc_; |
| 235 | |
| 236 | // Whether to initialize the class. |
| 237 | const bool do_clinit_; |
| 238 | |
| 239 | DISALLOW_COPY_AND_ASSIGN(LoadClassSlowPathARM); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 240 | }; |
| 241 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 242 | class LoadStringSlowPathARM : public SlowPathCode { |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 243 | public: |
| 244 | explicit LoadStringSlowPathARM(HLoadString* instruction) : instruction_(instruction) {} |
| 245 | |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 246 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 247 | LocationSummary* locations = instruction_->GetLocations(); |
| 248 | DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg())); |
| 249 | |
| 250 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
| 251 | __ Bind(GetEntryLabel()); |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 252 | SaveLiveRegisters(codegen, locations); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 253 | |
| 254 | InvokeRuntimeCallingConvention calling_convention; |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 255 | __ LoadImmediate(calling_convention.GetRegisterAt(0), instruction_->GetStringIndex()); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 256 | arm_codegen->InvokeRuntime( |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 257 | QUICK_ENTRY_POINT(pResolveString), instruction_, instruction_->GetDexPc(), this); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 258 | arm_codegen->Move32(locations->Out(), Location::RegisterLocation(R0)); |
| 259 | |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 260 | RestoreLiveRegisters(codegen, locations); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 261 | __ b(GetExitLabel()); |
| 262 | } |
| 263 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 264 | const char* GetDescription() const OVERRIDE { return "LoadStringSlowPathARM"; } |
| 265 | |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 266 | private: |
| 267 | HLoadString* const instruction_; |
| 268 | |
| 269 | DISALLOW_COPY_AND_ASSIGN(LoadStringSlowPathARM); |
| 270 | }; |
| 271 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 272 | class TypeCheckSlowPathARM : public SlowPathCode { |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 273 | public: |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 274 | TypeCheckSlowPathARM(HInstruction* instruction, bool is_fatal) |
| 275 | : instruction_(instruction), is_fatal_(is_fatal) {} |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 276 | |
Alexandre Rames | 67555f7 | 2014-11-18 10:55:16 +0000 | [diff] [blame] | 277 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 278 | LocationSummary* locations = instruction_->GetLocations(); |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 279 | Location object_class = instruction_->IsCheckCast() ? locations->GetTemp(0) |
| 280 | : locations->Out(); |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 281 | DCHECK(instruction_->IsCheckCast() |
| 282 | || !locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg())); |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 283 | |
| 284 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
| 285 | __ Bind(GetEntryLabel()); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 286 | |
| 287 | if (instruction_->IsCheckCast()) { |
| 288 | // The codegen for the instruction overwrites `temp`, so put it back in place. |
| 289 | Register obj = locations->InAt(0).AsRegister<Register>(); |
| 290 | Register temp = locations->GetTemp(0).AsRegister<Register>(); |
| 291 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
| 292 | __ LoadFromOffset(kLoadWord, temp, obj, class_offset); |
| 293 | __ MaybeUnpoisonHeapReference(temp); |
| 294 | } |
| 295 | |
| 296 | if (!is_fatal_) { |
| 297 | SaveLiveRegisters(codegen, locations); |
| 298 | } |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 299 | |
| 300 | // We're moving two locations to locations that could overlap, so we need a parallel |
| 301 | // move resolver. |
| 302 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 303 | codegen->EmitParallelMoves( |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 304 | locations->InAt(1), |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 305 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 306 | Primitive::kPrimNot, |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 307 | object_class, |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 308 | Location::RegisterLocation(calling_convention.GetRegisterAt(1)), |
| 309 | Primitive::kPrimNot); |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 310 | |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 311 | if (instruction_->IsInstanceOf()) { |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 312 | arm_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pInstanceofNonTrivial), |
| 313 | instruction_, |
| 314 | instruction_->GetDexPc(), |
| 315 | this); |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 316 | arm_codegen->Move32(locations->Out(), Location::RegisterLocation(R0)); |
| 317 | } else { |
| 318 | DCHECK(instruction_->IsCheckCast()); |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 319 | arm_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pCheckCast), |
| 320 | instruction_, |
| 321 | instruction_->GetDexPc(), |
| 322 | this); |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 323 | } |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 324 | |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 325 | if (!is_fatal_) { |
| 326 | RestoreLiveRegisters(codegen, locations); |
| 327 | __ b(GetExitLabel()); |
| 328 | } |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 331 | const char* GetDescription() const OVERRIDE { return "TypeCheckSlowPathARM"; } |
| 332 | |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 333 | bool IsFatal() const OVERRIDE { return is_fatal_; } |
| 334 | |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 335 | private: |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 336 | HInstruction* const instruction_; |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 337 | const bool is_fatal_; |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 338 | |
| 339 | DISALLOW_COPY_AND_ASSIGN(TypeCheckSlowPathARM); |
| 340 | }; |
| 341 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 342 | class DeoptimizationSlowPathARM : public SlowPathCode { |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 343 | public: |
| 344 | explicit DeoptimizationSlowPathARM(HInstruction* instruction) |
| 345 | : instruction_(instruction) {} |
| 346 | |
| 347 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 348 | __ Bind(GetEntryLabel()); |
| 349 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 350 | DCHECK(instruction_->IsDeoptimize()); |
| 351 | HDeoptimize* deoptimize = instruction_->AsDeoptimize(); |
| 352 | uint32_t dex_pc = deoptimize->GetDexPc(); |
| 353 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
| 354 | arm_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pDeoptimize), instruction_, dex_pc, this); |
| 355 | } |
| 356 | |
Alexandre Rames | 9931f31 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 357 | const char* GetDescription() const OVERRIDE { return "DeoptimizationSlowPathARM"; } |
| 358 | |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 359 | private: |
| 360 | HInstruction* const instruction_; |
| 361 | DISALLOW_COPY_AND_ASSIGN(DeoptimizationSlowPathARM); |
| 362 | }; |
| 363 | |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 364 | class ArraySetSlowPathARM : public SlowPathCode { |
| 365 | public: |
| 366 | explicit ArraySetSlowPathARM(HInstruction* instruction) : instruction_(instruction) {} |
| 367 | |
| 368 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 369 | LocationSummary* locations = instruction_->GetLocations(); |
| 370 | __ Bind(GetEntryLabel()); |
| 371 | SaveLiveRegisters(codegen, locations); |
| 372 | |
| 373 | InvokeRuntimeCallingConvention calling_convention; |
| 374 | HParallelMove parallel_move(codegen->GetGraph()->GetArena()); |
| 375 | parallel_move.AddMove( |
| 376 | locations->InAt(0), |
| 377 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), |
| 378 | Primitive::kPrimNot, |
| 379 | nullptr); |
| 380 | parallel_move.AddMove( |
| 381 | locations->InAt(1), |
| 382 | Location::RegisterLocation(calling_convention.GetRegisterAt(1)), |
| 383 | Primitive::kPrimInt, |
| 384 | nullptr); |
| 385 | parallel_move.AddMove( |
| 386 | locations->InAt(2), |
| 387 | Location::RegisterLocation(calling_convention.GetRegisterAt(2)), |
| 388 | Primitive::kPrimNot, |
| 389 | nullptr); |
| 390 | codegen->GetMoveResolver()->EmitNativeCode(¶llel_move); |
| 391 | |
| 392 | CodeGeneratorARM* arm_codegen = down_cast<CodeGeneratorARM*>(codegen); |
| 393 | arm_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pAputObject), |
| 394 | instruction_, |
| 395 | instruction_->GetDexPc(), |
| 396 | this); |
| 397 | RestoreLiveRegisters(codegen, locations); |
| 398 | __ b(GetExitLabel()); |
| 399 | } |
| 400 | |
| 401 | const char* GetDescription() const OVERRIDE { return "ArraySetSlowPathARM"; } |
| 402 | |
| 403 | private: |
| 404 | HInstruction* const instruction_; |
| 405 | |
| 406 | DISALLOW_COPY_AND_ASSIGN(ArraySetSlowPathARM); |
| 407 | }; |
| 408 | |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 409 | #undef __ |
Roland Levillain | 62a46b2 | 2015-06-01 18:24:13 +0100 | [diff] [blame] | 410 | #define __ down_cast<ArmAssembler*>(GetAssembler())-> |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 411 | |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 412 | inline Condition ARMCondition(IfCondition cond) { |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 413 | switch (cond) { |
| 414 | case kCondEQ: return EQ; |
| 415 | case kCondNE: return NE; |
| 416 | case kCondLT: return LT; |
| 417 | case kCondLE: return LE; |
| 418 | case kCondGT: return GT; |
| 419 | case kCondGE: return GE; |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 420 | case kCondB: return LO; |
| 421 | case kCondBE: return LS; |
| 422 | case kCondA: return HI; |
| 423 | case kCondAE: return HS; |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 424 | } |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 425 | LOG(FATAL) << "Unreachable"; |
| 426 | UNREACHABLE(); |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 427 | } |
| 428 | |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 429 | // Maps signed condition to unsigned condition. |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 430 | inline Condition ARMUnsignedCondition(IfCondition cond) { |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 431 | switch (cond) { |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 432 | case kCondEQ: return EQ; |
| 433 | case kCondNE: return NE; |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 434 | // Signed to unsigned. |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 435 | case kCondLT: return LO; |
| 436 | case kCondLE: return LS; |
| 437 | case kCondGT: return HI; |
| 438 | case kCondGE: return HS; |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 439 | // Unsigned remain unchanged. |
| 440 | case kCondB: return LO; |
| 441 | case kCondBE: return LS; |
| 442 | case kCondA: return HI; |
| 443 | case kCondAE: return HS; |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 444 | } |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 445 | LOG(FATAL) << "Unreachable"; |
| 446 | UNREACHABLE(); |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 449 | void CodeGeneratorARM::DumpCoreRegister(std::ostream& stream, int reg) const { |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 450 | stream << Register(reg); |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | void CodeGeneratorARM::DumpFloatingPointRegister(std::ostream& stream, int reg) const { |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 454 | stream << SRegister(reg); |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 455 | } |
| 456 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 457 | size_t CodeGeneratorARM::SaveCoreRegister(size_t stack_index, uint32_t reg_id) { |
| 458 | __ StoreToOffset(kStoreWord, static_cast<Register>(reg_id), SP, stack_index); |
| 459 | return kArmWordSize; |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 460 | } |
| 461 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 462 | size_t CodeGeneratorARM::RestoreCoreRegister(size_t stack_index, uint32_t reg_id) { |
| 463 | __ LoadFromOffset(kLoadWord, static_cast<Register>(reg_id), SP, stack_index); |
| 464 | return kArmWordSize; |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 465 | } |
| 466 | |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 467 | size_t CodeGeneratorARM::SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) { |
| 468 | __ StoreSToOffset(static_cast<SRegister>(reg_id), SP, stack_index); |
| 469 | return kArmWordSize; |
| 470 | } |
| 471 | |
| 472 | size_t CodeGeneratorARM::RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) { |
| 473 | __ LoadSFromOffset(static_cast<SRegister>(reg_id), SP, stack_index); |
| 474 | return kArmWordSize; |
| 475 | } |
| 476 | |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 477 | CodeGeneratorARM::CodeGeneratorARM(HGraph* graph, |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 478 | const ArmInstructionSetFeatures& isa_features, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 479 | const CompilerOptions& compiler_options, |
| 480 | OptimizingCompilerStats* stats) |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 481 | : CodeGenerator(graph, |
| 482 | kNumberOfCoreRegisters, |
| 483 | kNumberOfSRegisters, |
| 484 | kNumberOfRegisterPairs, |
| 485 | ComputeRegisterMask(reinterpret_cast<const int*>(kCoreCalleeSaves), |
| 486 | arraysize(kCoreCalleeSaves)), |
Nicolas Geoffray | 75d5b9b | 2015-10-05 07:40:35 +0000 | [diff] [blame] | 487 | ComputeRegisterMask(reinterpret_cast<const int*>(kFpuCalleeSaves), |
| 488 | arraysize(kFpuCalleeSaves)), |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 489 | compiler_options, |
| 490 | stats), |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 491 | block_labels_(nullptr), |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 492 | location_builder_(graph, this), |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 493 | instruction_visitor_(graph, this), |
Nicolas Geoffray | 8d48673 | 2014-07-16 16:23:40 +0100 | [diff] [blame] | 494 | move_resolver_(graph->GetArena(), this), |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 495 | assembler_(), |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 496 | isa_features_(isa_features), |
Vladimir Marko | 5233f93 | 2015-09-29 19:01:15 +0100 | [diff] [blame] | 497 | method_patches_(MethodReferenceComparator(), |
| 498 | graph->GetArena()->Adapter(kArenaAllocCodeGenerator)), |
| 499 | call_patches_(MethodReferenceComparator(), |
| 500 | graph->GetArena()->Adapter(kArenaAllocCodeGenerator)), |
| 501 | relative_call_patches_(graph->GetArena()->Adapter(kArenaAllocCodeGenerator)) { |
Andreas Gampe | 501fd63 | 2015-09-10 16:11:06 -0700 | [diff] [blame] | 502 | // Always save the LR register to mimic Quick. |
| 503 | AddAllocatedRegister(Location::RegisterLocation(LR)); |
Nicolas Geoffray | ab032bc | 2014-07-15 12:55:21 +0100 | [diff] [blame] | 504 | } |
| 505 | |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 506 | void CodeGeneratorARM::Finalize(CodeAllocator* allocator) { |
| 507 | // Ensure that we fix up branches and literal loads and emit the literal pool. |
| 508 | __ FinalizeCode(); |
| 509 | |
| 510 | // Adjust native pc offsets in stack maps. |
| 511 | for (size_t i = 0, num = stack_map_stream_.GetNumberOfStackMaps(); i != num; ++i) { |
| 512 | uint32_t old_position = stack_map_stream_.GetStackMap(i).native_pc_offset; |
| 513 | uint32_t new_position = __ GetAdjustedPosition(old_position); |
| 514 | stack_map_stream_.SetStackMapNativePcOffset(i, new_position); |
| 515 | } |
| 516 | // Adjust native pc offsets of block labels. |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 517 | for (HBasicBlock* block : *block_order_) { |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 518 | // Get the label directly from block_labels_ rather than through GetLabelOf() to avoid |
| 519 | // FirstNonEmptyBlock() which could lead to adjusting a label more than once. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 520 | DCHECK_LT(block->GetBlockId(), GetGraph()->GetBlocks().size()); |
| 521 | Label* block_label = &block_labels_[block->GetBlockId()]; |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 522 | DCHECK_EQ(block_label->IsBound(), !block->IsSingleJump()); |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 523 | if (block_label->IsBound()) { |
| 524 | __ AdjustLabelPosition(block_label); |
| 525 | } |
| 526 | } |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 527 | // Adjust pc offsets for the disassembly information. |
| 528 | if (disasm_info_ != nullptr) { |
| 529 | GeneratedCodeInterval* frame_entry_interval = disasm_info_->GetFrameEntryInterval(); |
| 530 | frame_entry_interval->start = __ GetAdjustedPosition(frame_entry_interval->start); |
| 531 | frame_entry_interval->end = __ GetAdjustedPosition(frame_entry_interval->end); |
| 532 | for (auto& it : *disasm_info_->GetInstructionIntervals()) { |
| 533 | it.second.start = __ GetAdjustedPosition(it.second.start); |
| 534 | it.second.end = __ GetAdjustedPosition(it.second.end); |
| 535 | } |
| 536 | for (auto& it : *disasm_info_->GetSlowPathIntervals()) { |
| 537 | it.code_interval.start = __ GetAdjustedPosition(it.code_interval.start); |
| 538 | it.code_interval.end = __ GetAdjustedPosition(it.code_interval.end); |
| 539 | } |
| 540 | } |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 541 | // Adjust pc offsets for relative call patches. |
| 542 | for (MethodPatchInfo<Label>& info : relative_call_patches_) { |
| 543 | __ AdjustLabelPosition(&info.label); |
| 544 | } |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 545 | |
| 546 | CodeGenerator::Finalize(allocator); |
| 547 | } |
| 548 | |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 549 | Location CodeGeneratorARM::AllocateFreeRegister(Primitive::Type type) const { |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 550 | switch (type) { |
| 551 | case Primitive::kPrimLong: { |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 552 | size_t reg = FindFreeEntry(blocked_register_pairs_, kNumberOfRegisterPairs); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 553 | ArmManagedRegister pair = |
| 554 | ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(reg)); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 555 | DCHECK(!blocked_core_registers_[pair.AsRegisterPairLow()]); |
| 556 | DCHECK(!blocked_core_registers_[pair.AsRegisterPairHigh()]); |
| 557 | |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 558 | blocked_core_registers_[pair.AsRegisterPairLow()] = true; |
| 559 | blocked_core_registers_[pair.AsRegisterPairHigh()] = true; |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 560 | UpdateBlockedPairRegisters(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 561 | return Location::RegisterPairLocation(pair.AsRegisterPairLow(), pair.AsRegisterPairHigh()); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | case Primitive::kPrimByte: |
| 565 | case Primitive::kPrimBoolean: |
| 566 | case Primitive::kPrimChar: |
| 567 | case Primitive::kPrimShort: |
| 568 | case Primitive::kPrimInt: |
| 569 | case Primitive::kPrimNot: { |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 570 | int reg = FindFreeEntry(blocked_core_registers_, kNumberOfCoreRegisters); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 571 | // Block all register pairs that contain `reg`. |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 572 | for (int i = 0; i < kNumberOfRegisterPairs; i++) { |
| 573 | ArmManagedRegister current = |
| 574 | ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(i)); |
| 575 | if (current.AsRegisterPairLow() == reg || current.AsRegisterPairHigh() == reg) { |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 576 | blocked_register_pairs_[i] = true; |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 577 | } |
| 578 | } |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 579 | return Location::RegisterLocation(reg); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 580 | } |
| 581 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 582 | case Primitive::kPrimFloat: { |
| 583 | int reg = FindFreeEntry(blocked_fpu_registers_, kNumberOfSRegisters); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 584 | return Location::FpuRegisterLocation(reg); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 585 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 586 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 587 | case Primitive::kPrimDouble: { |
Nicolas Geoffray | 3c03503 | 2014-10-28 10:46:40 +0000 | [diff] [blame] | 588 | int reg = FindTwoFreeConsecutiveAlignedEntries(blocked_fpu_registers_, kNumberOfSRegisters); |
| 589 | DCHECK_EQ(reg % 2, 0); |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 590 | return Location::FpuRegisterPairLocation(reg, reg + 1); |
| 591 | } |
| 592 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 593 | case Primitive::kPrimVoid: |
| 594 | LOG(FATAL) << "Unreachable type " << type; |
| 595 | } |
| 596 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 597 | return Location(); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 598 | } |
| 599 | |
Nicolas Geoffray | a0bb2bd | 2015-01-26 12:49:35 +0000 | [diff] [blame] | 600 | void CodeGeneratorARM::SetupBlockedRegisters(bool is_baseline) const { |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 601 | // Don't allocate the dalvik style register pair passing. |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 602 | blocked_register_pairs_[R1_R2] = true; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 603 | |
| 604 | // Stack register, LR and PC are always reserved. |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 605 | blocked_core_registers_[SP] = true; |
| 606 | blocked_core_registers_[LR] = true; |
| 607 | blocked_core_registers_[PC] = true; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 608 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 609 | // Reserve thread register. |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 610 | blocked_core_registers_[TR] = true; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 611 | |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 612 | // Reserve temp register. |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 613 | blocked_core_registers_[IP] = true; |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 614 | |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 615 | if (is_baseline) { |
| 616 | for (size_t i = 0; i < arraysize(kCoreCalleeSaves); ++i) { |
| 617 | blocked_core_registers_[kCoreCalleeSaves[i]] = true; |
| 618 | } |
Nicolas Geoffray | 5b4b898 | 2014-12-18 17:45:56 +0000 | [diff] [blame] | 619 | |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 620 | blocked_core_registers_[kCoreSavedRegisterForBaseline] = false; |
Nicolas Geoffray | ecf680d | 2015-10-05 11:15:37 +0100 | [diff] [blame] | 621 | } |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 622 | |
Nicolas Geoffray | ecf680d | 2015-10-05 11:15:37 +0100 | [diff] [blame] | 623 | if (is_baseline || GetGraph()->IsDebuggable()) { |
| 624 | // Stubs do not save callee-save floating point registers. If the graph |
| 625 | // is debuggable, we need to deal with these registers differently. For |
| 626 | // now, just block them. |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 627 | for (size_t i = 0; i < arraysize(kFpuCalleeSaves); ++i) { |
| 628 | blocked_fpu_registers_[kFpuCalleeSaves[i]] = true; |
| 629 | } |
| 630 | } |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 631 | |
| 632 | UpdateBlockedPairRegisters(); |
| 633 | } |
| 634 | |
| 635 | void CodeGeneratorARM::UpdateBlockedPairRegisters() const { |
| 636 | for (int i = 0; i < kNumberOfRegisterPairs; i++) { |
| 637 | ArmManagedRegister current = |
| 638 | ArmManagedRegister::FromRegisterPair(static_cast<RegisterPair>(i)); |
| 639 | if (blocked_core_registers_[current.AsRegisterPairLow()] |
| 640 | || blocked_core_registers_[current.AsRegisterPairHigh()]) { |
| 641 | blocked_register_pairs_[i] = true; |
| 642 | } |
| 643 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 644 | } |
| 645 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 646 | InstructionCodeGeneratorARM::InstructionCodeGeneratorARM(HGraph* graph, CodeGeneratorARM* codegen) |
| 647 | : HGraphVisitor(graph), |
| 648 | assembler_(codegen->GetAssembler()), |
| 649 | codegen_(codegen) {} |
| 650 | |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 651 | void CodeGeneratorARM::ComputeSpillMask() { |
| 652 | core_spill_mask_ = allocated_registers_.GetCoreRegisters() & core_callee_save_mask_; |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 653 | // Save one extra register for baseline. Note that on thumb2, there is no easy |
| 654 | // instruction to restore just the PC, so this actually helps both baseline |
| 655 | // and non-baseline to save and restore at least two registers at entry and exit. |
| 656 | core_spill_mask_ |= (1 << kCoreSavedRegisterForBaseline); |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 657 | DCHECK_NE(core_spill_mask_, 0u) << "At least the return address register must be saved"; |
| 658 | fpu_spill_mask_ = allocated_registers_.GetFloatingPointRegisters() & fpu_callee_save_mask_; |
| 659 | // We use vpush and vpop for saving and restoring floating point registers, which take |
| 660 | // a SRegister and the number of registers to save/restore after that SRegister. We |
| 661 | // therefore update the `fpu_spill_mask_` to also contain those registers not allocated, |
| 662 | // but in the range. |
| 663 | if (fpu_spill_mask_ != 0) { |
| 664 | uint32_t least_significant_bit = LeastSignificantBit(fpu_spill_mask_); |
| 665 | uint32_t most_significant_bit = MostSignificantBit(fpu_spill_mask_); |
| 666 | for (uint32_t i = least_significant_bit + 1 ; i < most_significant_bit; ++i) { |
| 667 | fpu_spill_mask_ |= (1 << i); |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 672 | static dwarf::Reg DWARFReg(Register reg) { |
David Srbecky | 9d8606d | 2015-04-12 09:35:32 +0100 | [diff] [blame] | 673 | return dwarf::Reg::ArmCore(static_cast<int>(reg)); |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | static dwarf::Reg DWARFReg(SRegister reg) { |
David Srbecky | 9d8606d | 2015-04-12 09:35:32 +0100 | [diff] [blame] | 677 | return dwarf::Reg::ArmFp(static_cast<int>(reg)); |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 678 | } |
| 679 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 680 | void CodeGeneratorARM::GenerateFrameEntry() { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 681 | bool skip_overflow_check = |
| 682 | IsLeafMethod() && !FrameNeedsStackCheck(GetFrameSize(), InstructionSet::kArm); |
Nicolas Geoffray | d97dc40 | 2015-01-22 13:50:01 +0000 | [diff] [blame] | 683 | DCHECK(GetCompilerOptions().GetImplicitStackOverflowChecks()); |
Nicolas Geoffray | 1cf9528 | 2014-12-12 19:22:03 +0000 | [diff] [blame] | 684 | __ Bind(&frame_entry_label_); |
| 685 | |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 686 | if (HasEmptyFrame()) { |
| 687 | return; |
| 688 | } |
| 689 | |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 690 | if (!skip_overflow_check) { |
Nicolas Geoffray | d97dc40 | 2015-01-22 13:50:01 +0000 | [diff] [blame] | 691 | __ AddConstant(IP, SP, -static_cast<int32_t>(GetStackOverflowReservedBytes(kArm))); |
| 692 | __ LoadFromOffset(kLoadWord, IP, IP, 0); |
| 693 | RecordPcInfo(nullptr, 0); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 694 | } |
| 695 | |
Andreas Gampe | 501fd63 | 2015-09-10 16:11:06 -0700 | [diff] [blame] | 696 | __ PushList(core_spill_mask_); |
| 697 | __ cfi().AdjustCFAOffset(kArmWordSize * POPCOUNT(core_spill_mask_)); |
| 698 | __ cfi().RelOffsetForMany(DWARFReg(kMethodRegisterArgument), 0, core_spill_mask_, kArmWordSize); |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 699 | if (fpu_spill_mask_ != 0) { |
| 700 | SRegister start_register = SRegister(LeastSignificantBit(fpu_spill_mask_)); |
| 701 | __ vpushs(start_register, POPCOUNT(fpu_spill_mask_)); |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 702 | __ cfi().AdjustCFAOffset(kArmWordSize * POPCOUNT(fpu_spill_mask_)); |
David Srbecky | 9d8606d | 2015-04-12 09:35:32 +0100 | [diff] [blame] | 703 | __ cfi().RelOffsetForMany(DWARFReg(S0), 0, fpu_spill_mask_, kArmWordSize); |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 704 | } |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 705 | int adjust = GetFrameSize() - FrameEntrySpillSize(); |
| 706 | __ AddConstant(SP, -adjust); |
| 707 | __ cfi().AdjustCFAOffset(adjust); |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 708 | __ StoreToOffset(kStoreWord, kMethodRegisterArgument, SP, 0); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | void CodeGeneratorARM::GenerateFrameExit() { |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 712 | if (HasEmptyFrame()) { |
| 713 | __ bx(LR); |
| 714 | return; |
| 715 | } |
David Srbecky | c34dc93 | 2015-04-12 09:27:43 +0100 | [diff] [blame] | 716 | __ cfi().RememberState(); |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 717 | int adjust = GetFrameSize() - FrameEntrySpillSize(); |
| 718 | __ AddConstant(SP, adjust); |
| 719 | __ cfi().AdjustCFAOffset(-adjust); |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 720 | if (fpu_spill_mask_ != 0) { |
| 721 | SRegister start_register = SRegister(LeastSignificantBit(fpu_spill_mask_)); |
| 722 | __ vpops(start_register, POPCOUNT(fpu_spill_mask_)); |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 723 | __ cfi().AdjustCFAOffset(-kArmPointerSize * POPCOUNT(fpu_spill_mask_)); |
| 724 | __ cfi().RestoreMany(DWARFReg(SRegister(0)), fpu_spill_mask_); |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 725 | } |
Andreas Gampe | 501fd63 | 2015-09-10 16:11:06 -0700 | [diff] [blame] | 726 | // Pop LR into PC to return. |
| 727 | DCHECK_NE(core_spill_mask_ & (1 << LR), 0U); |
| 728 | uint32_t pop_mask = (core_spill_mask_ & (~(1 << LR))) | 1 << PC; |
| 729 | __ PopList(pop_mask); |
David Srbecky | c34dc93 | 2015-04-12 09:27:43 +0100 | [diff] [blame] | 730 | __ cfi().RestoreState(); |
| 731 | __ cfi().DefCFAOffset(GetFrameSize()); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 732 | } |
| 733 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 734 | void CodeGeneratorARM::Bind(HBasicBlock* block) { |
| 735 | __ Bind(GetLabelOf(block)); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 736 | } |
| 737 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 738 | Location CodeGeneratorARM::GetStackLocation(HLoadLocal* load) const { |
| 739 | switch (load->GetType()) { |
| 740 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 741 | case Primitive::kPrimDouble: |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 742 | return Location::DoubleStackSlot(GetStackSlot(load->GetLocal())); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 743 | |
| 744 | case Primitive::kPrimInt: |
| 745 | case Primitive::kPrimNot: |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 746 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 747 | return Location::StackSlot(GetStackSlot(load->GetLocal())); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 748 | |
| 749 | case Primitive::kPrimBoolean: |
| 750 | case Primitive::kPrimByte: |
| 751 | case Primitive::kPrimChar: |
| 752 | case Primitive::kPrimShort: |
| 753 | case Primitive::kPrimVoid: |
| 754 | LOG(FATAL) << "Unexpected type " << load->GetType(); |
Andreas Gampe | 65b798e | 2015-04-06 09:35:22 -0700 | [diff] [blame] | 755 | UNREACHABLE(); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | LOG(FATAL) << "Unreachable"; |
Andreas Gampe | 65b798e | 2015-04-06 09:35:22 -0700 | [diff] [blame] | 759 | UNREACHABLE(); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 760 | } |
| 761 | |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 762 | Location InvokeDexCallingConventionVisitorARM::GetNextLocation(Primitive::Type type) { |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 763 | switch (type) { |
| 764 | case Primitive::kPrimBoolean: |
| 765 | case Primitive::kPrimByte: |
| 766 | case Primitive::kPrimChar: |
| 767 | case Primitive::kPrimShort: |
| 768 | case Primitive::kPrimInt: |
| 769 | case Primitive::kPrimNot: { |
| 770 | uint32_t index = gp_index_++; |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 771 | uint32_t stack_index = stack_index_++; |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 772 | if (index < calling_convention.GetNumberOfRegisters()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 773 | return Location::RegisterLocation(calling_convention.GetRegisterAt(index)); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 774 | } else { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 775 | return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index)); |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 776 | } |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 777 | } |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 778 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 779 | case Primitive::kPrimLong: { |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 780 | uint32_t index = gp_index_; |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 781 | uint32_t stack_index = stack_index_; |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 782 | gp_index_ += 2; |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 783 | stack_index_ += 2; |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 784 | if (index + 1 < calling_convention.GetNumberOfRegisters()) { |
Nicolas Geoffray | 69c15d3 | 2015-01-13 11:42:13 +0000 | [diff] [blame] | 785 | if (calling_convention.GetRegisterAt(index) == R1) { |
| 786 | // Skip R1, and use R2_R3 instead. |
| 787 | gp_index_++; |
| 788 | index++; |
| 789 | } |
| 790 | } |
| 791 | if (index + 1 < calling_convention.GetNumberOfRegisters()) { |
| 792 | DCHECK_EQ(calling_convention.GetRegisterAt(index) + 1, |
Nicolas Geoffray | af2c65c | 2015-01-14 09:40:32 +0000 | [diff] [blame] | 793 | calling_convention.GetRegisterAt(index + 1)); |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 794 | |
Nicolas Geoffray | 69c15d3 | 2015-01-13 11:42:13 +0000 | [diff] [blame] | 795 | return Location::RegisterPairLocation(calling_convention.GetRegisterAt(index), |
Nicolas Geoffray | af2c65c | 2015-01-14 09:40:32 +0000 | [diff] [blame] | 796 | calling_convention.GetRegisterAt(index + 1)); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 797 | } else { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 798 | return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index)); |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | case Primitive::kPrimFloat: { |
| 803 | uint32_t stack_index = stack_index_++; |
| 804 | if (float_index_ % 2 == 0) { |
| 805 | float_index_ = std::max(double_index_, float_index_); |
| 806 | } |
| 807 | if (float_index_ < calling_convention.GetNumberOfFpuRegisters()) { |
| 808 | return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(float_index_++)); |
| 809 | } else { |
| 810 | return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index)); |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | case Primitive::kPrimDouble: { |
| 815 | double_index_ = std::max(double_index_, RoundUp(float_index_, 2)); |
| 816 | uint32_t stack_index = stack_index_; |
| 817 | stack_index_ += 2; |
| 818 | if (double_index_ + 1 < calling_convention.GetNumberOfFpuRegisters()) { |
| 819 | uint32_t index = double_index_; |
| 820 | double_index_ += 2; |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 821 | Location result = Location::FpuRegisterPairLocation( |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 822 | calling_convention.GetFpuRegisterAt(index), |
| 823 | calling_convention.GetFpuRegisterAt(index + 1)); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 824 | DCHECK(ExpectedPairLayout(result)); |
| 825 | return result; |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 826 | } else { |
| 827 | return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index)); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 828 | } |
| 829 | } |
| 830 | |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 831 | case Primitive::kPrimVoid: |
| 832 | LOG(FATAL) << "Unexpected parameter type " << type; |
| 833 | break; |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 834 | } |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 835 | return Location(); |
| 836 | } |
Nicolas Geoffray | db928fc | 2014-04-16 17:38:32 +0100 | [diff] [blame] | 837 | |
Nicolas Geoffray | fd88f16 | 2015-06-03 11:23:52 +0100 | [diff] [blame] | 838 | Location InvokeDexCallingConventionVisitorARM::GetReturnLocation(Primitive::Type type) const { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 839 | switch (type) { |
| 840 | case Primitive::kPrimBoolean: |
| 841 | case Primitive::kPrimByte: |
| 842 | case Primitive::kPrimChar: |
| 843 | case Primitive::kPrimShort: |
| 844 | case Primitive::kPrimInt: |
| 845 | case Primitive::kPrimNot: { |
| 846 | return Location::RegisterLocation(R0); |
| 847 | } |
| 848 | |
| 849 | case Primitive::kPrimFloat: { |
| 850 | return Location::FpuRegisterLocation(S0); |
| 851 | } |
| 852 | |
| 853 | case Primitive::kPrimLong: { |
| 854 | return Location::RegisterPairLocation(R0, R1); |
| 855 | } |
| 856 | |
| 857 | case Primitive::kPrimDouble: { |
| 858 | return Location::FpuRegisterPairLocation(S0, S1); |
| 859 | } |
| 860 | |
| 861 | case Primitive::kPrimVoid: |
| 862 | return Location(); |
| 863 | } |
Nicolas Geoffray | 0d1652e | 2015-06-03 12:12:19 +0100 | [diff] [blame] | 864 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 865 | UNREACHABLE(); |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 866 | } |
| 867 | |
Nicolas Geoffray | fd88f16 | 2015-06-03 11:23:52 +0100 | [diff] [blame] | 868 | Location InvokeDexCallingConventionVisitorARM::GetMethodLocation() const { |
| 869 | return Location::RegisterLocation(kMethodRegisterArgument); |
| 870 | } |
| 871 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 872 | void CodeGeneratorARM::Move32(Location destination, Location source) { |
| 873 | if (source.Equals(destination)) { |
| 874 | return; |
| 875 | } |
| 876 | if (destination.IsRegister()) { |
| 877 | if (source.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 878 | __ Mov(destination.AsRegister<Register>(), source.AsRegister<Register>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 879 | } else if (source.IsFpuRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 880 | __ vmovrs(destination.AsRegister<Register>(), source.AsFpuRegister<SRegister>()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 881 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 882 | __ LoadFromOffset(kLoadWord, destination.AsRegister<Register>(), SP, source.GetStackIndex()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 883 | } |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 884 | } else if (destination.IsFpuRegister()) { |
| 885 | if (source.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 886 | __ vmovsr(destination.AsFpuRegister<SRegister>(), source.AsRegister<Register>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 887 | } else if (source.IsFpuRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 888 | __ vmovs(destination.AsFpuRegister<SRegister>(), source.AsFpuRegister<SRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 889 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 890 | __ LoadSFromOffset(destination.AsFpuRegister<SRegister>(), SP, source.GetStackIndex()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 891 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 892 | } else { |
Calin Juravle | a21f598 | 2014-11-13 15:53:04 +0000 | [diff] [blame] | 893 | DCHECK(destination.IsStackSlot()) << destination; |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 894 | if (source.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 895 | __ StoreToOffset(kStoreWord, source.AsRegister<Register>(), SP, destination.GetStackIndex()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 896 | } else if (source.IsFpuRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 897 | __ StoreSToOffset(source.AsFpuRegister<SRegister>(), SP, destination.GetStackIndex()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 898 | } else { |
Calin Juravle | a21f598 | 2014-11-13 15:53:04 +0000 | [diff] [blame] | 899 | DCHECK(source.IsStackSlot()) << source; |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 900 | __ LoadFromOffset(kLoadWord, IP, SP, source.GetStackIndex()); |
| 901 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 902 | } |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | void CodeGeneratorARM::Move64(Location destination, Location source) { |
| 907 | if (source.Equals(destination)) { |
| 908 | return; |
| 909 | } |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 910 | if (destination.IsRegisterPair()) { |
| 911 | if (source.IsRegisterPair()) { |
Nicolas Geoffray | 32b2a52 | 2014-11-27 14:54:18 +0000 | [diff] [blame] | 912 | EmitParallelMoves( |
| 913 | Location::RegisterLocation(source.AsRegisterPairHigh<Register>()), |
| 914 | Location::RegisterLocation(destination.AsRegisterPairHigh<Register>()), |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 915 | Primitive::kPrimInt, |
Nicolas Geoffray | 32b2a52 | 2014-11-27 14:54:18 +0000 | [diff] [blame] | 916 | Location::RegisterLocation(source.AsRegisterPairLow<Register>()), |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 917 | Location::RegisterLocation(destination.AsRegisterPairLow<Register>()), |
| 918 | Primitive::kPrimInt); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 919 | } else if (source.IsFpuRegister()) { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 920 | UNIMPLEMENTED(FATAL); |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 921 | } else if (source.IsFpuRegisterPair()) { |
| 922 | __ vmovrrd(destination.AsRegisterPairLow<Register>(), |
| 923 | destination.AsRegisterPairHigh<Register>(), |
| 924 | FromLowSToD(source.AsFpuRegisterPairLow<SRegister>())); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 925 | } else { |
| 926 | DCHECK(source.IsDoubleStackSlot()); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 927 | DCHECK(ExpectedPairLayout(destination)); |
| 928 | __ LoadFromOffset(kLoadWordPair, destination.AsRegisterPairLow<Register>(), |
| 929 | SP, source.GetStackIndex()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 930 | } |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 931 | } else if (destination.IsFpuRegisterPair()) { |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 932 | if (source.IsDoubleStackSlot()) { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 933 | __ LoadDFromOffset(FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()), |
| 934 | SP, |
| 935 | source.GetStackIndex()); |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 936 | } else if (source.IsRegisterPair()) { |
| 937 | __ vmovdrr(FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()), |
| 938 | source.AsRegisterPairLow<Register>(), |
| 939 | source.AsRegisterPairHigh<Register>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 940 | } else { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 941 | UNIMPLEMENTED(FATAL); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 942 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 943 | } else { |
| 944 | DCHECK(destination.IsDoubleStackSlot()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 945 | if (source.IsRegisterPair()) { |
Nicolas Geoffray | 32b2a52 | 2014-11-27 14:54:18 +0000 | [diff] [blame] | 946 | // No conflict possible, so just do the moves. |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 947 | if (source.AsRegisterPairLow<Register>() == R1) { |
| 948 | DCHECK_EQ(source.AsRegisterPairHigh<Register>(), R2); |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 949 | __ StoreToOffset(kStoreWord, R1, SP, destination.GetStackIndex()); |
| 950 | __ StoreToOffset(kStoreWord, R2, SP, destination.GetHighStackIndex(kArmWordSize)); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 951 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 952 | __ StoreToOffset(kStoreWordPair, source.AsRegisterPairLow<Register>(), |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 953 | SP, destination.GetStackIndex()); |
| 954 | } |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 955 | } else if (source.IsFpuRegisterPair()) { |
| 956 | __ StoreDToOffset(FromLowSToD(source.AsFpuRegisterPairLow<SRegister>()), |
| 957 | SP, |
| 958 | destination.GetStackIndex()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 959 | } else { |
| 960 | DCHECK(source.IsDoubleStackSlot()); |
Nicolas Geoffray | 32b2a52 | 2014-11-27 14:54:18 +0000 | [diff] [blame] | 961 | EmitParallelMoves( |
| 962 | Location::StackSlot(source.GetStackIndex()), |
| 963 | Location::StackSlot(destination.GetStackIndex()), |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 964 | Primitive::kPrimInt, |
Nicolas Geoffray | 32b2a52 | 2014-11-27 14:54:18 +0000 | [diff] [blame] | 965 | Location::StackSlot(source.GetHighStackIndex(kArmWordSize)), |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 966 | Location::StackSlot(destination.GetHighStackIndex(kArmWordSize)), |
| 967 | Primitive::kPrimInt); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 968 | } |
| 969 | } |
| 970 | } |
| 971 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 972 | void CodeGeneratorARM::Move(HInstruction* instruction, Location location, HInstruction* move_for) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 973 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 974 | if (instruction->IsCurrentMethod()) { |
| 975 | Move32(location, Location::StackSlot(kCurrentMethodStackOffset)); |
| 976 | } else if (locations != nullptr && locations->Out().Equals(location)) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 977 | return; |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 978 | } else if (locations != nullptr && locations->Out().IsConstant()) { |
Calin Juravle | a21f598 | 2014-11-13 15:53:04 +0000 | [diff] [blame] | 979 | HConstant* const_to_move = locations->Out().GetConstant(); |
Nicolas Geoffray | d6138ef | 2015-02-18 14:48:53 +0000 | [diff] [blame] | 980 | if (const_to_move->IsIntConstant() || const_to_move->IsNullConstant()) { |
| 981 | int32_t value = GetInt32ValueOf(const_to_move); |
Calin Juravle | a21f598 | 2014-11-13 15:53:04 +0000 | [diff] [blame] | 982 | if (location.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 983 | __ LoadImmediate(location.AsRegister<Register>(), value); |
Calin Juravle | a21f598 | 2014-11-13 15:53:04 +0000 | [diff] [blame] | 984 | } else { |
| 985 | DCHECK(location.IsStackSlot()); |
| 986 | __ LoadImmediate(IP, value); |
| 987 | __ StoreToOffset(kStoreWord, IP, SP, location.GetStackIndex()); |
| 988 | } |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 989 | } else { |
Nicolas Geoffray | 3747b48 | 2015-01-19 17:17:16 +0000 | [diff] [blame] | 990 | DCHECK(const_to_move->IsLongConstant()) << const_to_move->DebugName(); |
Calin Juravle | a21f598 | 2014-11-13 15:53:04 +0000 | [diff] [blame] | 991 | int64_t value = const_to_move->AsLongConstant()->GetValue(); |
| 992 | if (location.IsRegisterPair()) { |
| 993 | __ LoadImmediate(location.AsRegisterPairLow<Register>(), Low32Bits(value)); |
| 994 | __ LoadImmediate(location.AsRegisterPairHigh<Register>(), High32Bits(value)); |
| 995 | } else { |
| 996 | DCHECK(location.IsDoubleStackSlot()); |
| 997 | __ LoadImmediate(IP, Low32Bits(value)); |
| 998 | __ StoreToOffset(kStoreWord, IP, SP, location.GetStackIndex()); |
| 999 | __ LoadImmediate(IP, High32Bits(value)); |
| 1000 | __ StoreToOffset(kStoreWord, IP, SP, location.GetHighStackIndex(kArmWordSize)); |
| 1001 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1002 | } |
Roland Levillain | 476df55 | 2014-10-09 17:51:36 +0100 | [diff] [blame] | 1003 | } else if (instruction->IsLoadLocal()) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1004 | uint32_t stack_slot = GetStackSlot(instruction->AsLoadLocal()->GetLocal()); |
| 1005 | switch (instruction->GetType()) { |
| 1006 | case Primitive::kPrimBoolean: |
| 1007 | case Primitive::kPrimByte: |
| 1008 | case Primitive::kPrimChar: |
| 1009 | case Primitive::kPrimShort: |
| 1010 | case Primitive::kPrimInt: |
| 1011 | case Primitive::kPrimNot: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1012 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1013 | Move32(location, Location::StackSlot(stack_slot)); |
| 1014 | break; |
| 1015 | |
| 1016 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1017 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1018 | Move64(location, Location::DoubleStackSlot(stack_slot)); |
| 1019 | break; |
| 1020 | |
| 1021 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1022 | LOG(FATAL) << "Unexpected type " << instruction->GetType(); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1023 | } |
Nicolas Geoffray | f43083d | 2014-11-07 10:48:10 +0000 | [diff] [blame] | 1024 | } else if (instruction->IsTemporary()) { |
| 1025 | Location temp_location = GetTemporaryLocation(instruction->AsTemporary()); |
Calin Juravle | f97f9fb | 2014-11-11 15:38:19 +0000 | [diff] [blame] | 1026 | if (temp_location.IsStackSlot()) { |
| 1027 | Move32(location, temp_location); |
| 1028 | } else { |
| 1029 | DCHECK(temp_location.IsDoubleStackSlot()); |
| 1030 | Move64(location, temp_location); |
| 1031 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1032 | } else { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1033 | DCHECK((instruction->GetNext() == move_for) || instruction->GetNext()->IsTemporary()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1034 | switch (instruction->GetType()) { |
| 1035 | case Primitive::kPrimBoolean: |
| 1036 | case Primitive::kPrimByte: |
| 1037 | case Primitive::kPrimChar: |
| 1038 | case Primitive::kPrimShort: |
| 1039 | case Primitive::kPrimNot: |
| 1040 | case Primitive::kPrimInt: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1041 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1042 | Move32(location, locations->Out()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1043 | break; |
| 1044 | |
| 1045 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1046 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1047 | Move64(location, locations->Out()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1048 | break; |
| 1049 | |
| 1050 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1051 | LOG(FATAL) << "Unexpected type " << instruction->GetType(); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1052 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1053 | } |
| 1054 | } |
| 1055 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 1056 | void CodeGeneratorARM::MoveConstant(Location location, int32_t value) { |
| 1057 | DCHECK(location.IsRegister()); |
| 1058 | __ LoadImmediate(location.AsRegister<Register>(), value); |
| 1059 | } |
| 1060 | |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 1061 | void CodeGeneratorARM::MoveLocation(Location dst, Location src, Primitive::Type dst_type) { |
| 1062 | if (Primitive::Is64BitType(dst_type)) { |
| 1063 | Move64(dst, src); |
| 1064 | } else { |
| 1065 | Move32(dst, src); |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | void CodeGeneratorARM::AddLocationAsTemp(Location location, LocationSummary* locations) { |
| 1070 | if (location.IsRegister()) { |
| 1071 | locations->AddTemp(location); |
| 1072 | } else if (location.IsRegisterPair()) { |
| 1073 | locations->AddTemp(Location::RegisterLocation(location.AsRegisterPairLow<Register>())); |
| 1074 | locations->AddTemp(Location::RegisterLocation(location.AsRegisterPairHigh<Register>())); |
| 1075 | } else { |
| 1076 | UNIMPLEMENTED(FATAL) << "AddLocationAsTemp not implemented for location " << location; |
| 1077 | } |
| 1078 | } |
| 1079 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 1080 | void CodeGeneratorARM::InvokeRuntime(QuickEntrypointEnum entrypoint, |
| 1081 | HInstruction* instruction, |
| 1082 | uint32_t dex_pc, |
| 1083 | SlowPathCode* slow_path) { |
| 1084 | InvokeRuntime(GetThreadOffset<kArmWordSize>(entrypoint).Int32Value(), |
| 1085 | instruction, |
| 1086 | dex_pc, |
| 1087 | slow_path); |
| 1088 | } |
| 1089 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 1090 | void CodeGeneratorARM::InvokeRuntime(int32_t entry_point_offset, |
| 1091 | HInstruction* instruction, |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1092 | uint32_t dex_pc, |
| 1093 | SlowPathCode* slow_path) { |
Alexandre Rames | 78e3ef6 | 2015-08-12 13:43:29 +0100 | [diff] [blame] | 1094 | ValidateInvokeRuntime(instruction, slow_path); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 1095 | __ LoadFromOffset(kLoadWord, LR, TR, entry_point_offset); |
| 1096 | __ blx(LR); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1097 | RecordPcInfo(instruction, dex_pc, slow_path); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 1098 | } |
| 1099 | |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 1100 | void InstructionCodeGeneratorARM::HandleGoto(HInstruction* got, HBasicBlock* successor) { |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 1101 | DCHECK(!successor->IsExitBlock()); |
| 1102 | |
| 1103 | HBasicBlock* block = got->GetBlock(); |
| 1104 | HInstruction* previous = got->GetPrevious(); |
| 1105 | |
| 1106 | HLoopInformation* info = block->GetLoopInformation(); |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 1107 | if (info != nullptr && info->IsBackEdge(*block) && info->HasSuspendCheck()) { |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 1108 | codegen_->ClearSpillSlotsFromLoopPhisInStackMap(info->GetSuspendCheck()); |
| 1109 | GenerateSuspendCheck(info->GetSuspendCheck(), successor); |
| 1110 | return; |
| 1111 | } |
| 1112 | |
| 1113 | if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) { |
| 1114 | GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr); |
| 1115 | } |
| 1116 | if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 1117 | __ b(codegen_->GetLabelOf(successor)); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1118 | } |
| 1119 | } |
| 1120 | |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 1121 | void LocationsBuilderARM::VisitGoto(HGoto* got) { |
| 1122 | got->SetLocations(nullptr); |
| 1123 | } |
| 1124 | |
| 1125 | void InstructionCodeGeneratorARM::VisitGoto(HGoto* got) { |
| 1126 | HandleGoto(got, got->GetSuccessor()); |
| 1127 | } |
| 1128 | |
| 1129 | void LocationsBuilderARM::VisitTryBoundary(HTryBoundary* try_boundary) { |
| 1130 | try_boundary->SetLocations(nullptr); |
| 1131 | } |
| 1132 | |
| 1133 | void InstructionCodeGeneratorARM::VisitTryBoundary(HTryBoundary* try_boundary) { |
| 1134 | HBasicBlock* successor = try_boundary->GetNormalFlowSuccessor(); |
| 1135 | if (!successor->IsExitBlock()) { |
| 1136 | HandleGoto(try_boundary, successor); |
| 1137 | } |
| 1138 | } |
| 1139 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1140 | void LocationsBuilderARM::VisitExit(HExit* exit) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 1141 | exit->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1142 | } |
| 1143 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1144 | void InstructionCodeGeneratorARM::VisitExit(HExit* exit ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1145 | } |
| 1146 | |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1147 | void InstructionCodeGeneratorARM::GenerateCompareWithImmediate(Register left, int32_t right) { |
| 1148 | ShifterOperand operand; |
| 1149 | if (GetAssembler()->ShifterOperandCanHold(R0, left, CMP, right, &operand)) { |
| 1150 | __ cmp(left, operand); |
| 1151 | } else { |
| 1152 | Register temp = IP; |
| 1153 | __ LoadImmediate(temp, right); |
| 1154 | __ cmp(left, ShifterOperand(temp)); |
| 1155 | } |
| 1156 | } |
| 1157 | |
| 1158 | void InstructionCodeGeneratorARM::GenerateFPJumps(HCondition* cond, |
| 1159 | Label* true_label, |
| 1160 | Label* false_label) { |
| 1161 | __ vmstat(); // transfer FP status register to ARM APSR. |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1162 | // TODO: merge into a single branch (except "equal or unordered" and "not equal") |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1163 | if (cond->IsFPConditionTrueIfNaN()) { |
| 1164 | __ b(true_label, VS); // VS for unordered. |
| 1165 | } else if (cond->IsFPConditionFalseIfNaN()) { |
| 1166 | __ b(false_label, VS); // VS for unordered. |
| 1167 | } |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1168 | __ b(true_label, ARMCondition(cond->GetCondition())); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1169 | } |
| 1170 | |
| 1171 | void InstructionCodeGeneratorARM::GenerateLongComparesAndJumps(HCondition* cond, |
| 1172 | Label* true_label, |
| 1173 | Label* false_label) { |
| 1174 | LocationSummary* locations = cond->GetLocations(); |
| 1175 | Location left = locations->InAt(0); |
| 1176 | Location right = locations->InAt(1); |
| 1177 | IfCondition if_cond = cond->GetCondition(); |
| 1178 | |
| 1179 | Register left_high = left.AsRegisterPairHigh<Register>(); |
| 1180 | Register left_low = left.AsRegisterPairLow<Register>(); |
| 1181 | IfCondition true_high_cond = if_cond; |
| 1182 | IfCondition false_high_cond = cond->GetOppositeCondition(); |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1183 | Condition final_condition = ARMUnsignedCondition(if_cond); // unsigned on lower part |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1184 | |
| 1185 | // Set the conditions for the test, remembering that == needs to be |
| 1186 | // decided using the low words. |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1187 | // TODO: consider avoiding jumps with temporary and CMP low+SBC high |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1188 | switch (if_cond) { |
| 1189 | case kCondEQ: |
| 1190 | case kCondNE: |
| 1191 | // Nothing to do. |
| 1192 | break; |
| 1193 | case kCondLT: |
| 1194 | false_high_cond = kCondGT; |
| 1195 | break; |
| 1196 | case kCondLE: |
| 1197 | true_high_cond = kCondLT; |
| 1198 | break; |
| 1199 | case kCondGT: |
| 1200 | false_high_cond = kCondLT; |
| 1201 | break; |
| 1202 | case kCondGE: |
| 1203 | true_high_cond = kCondGT; |
| 1204 | break; |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1205 | case kCondB: |
| 1206 | false_high_cond = kCondA; |
| 1207 | break; |
| 1208 | case kCondBE: |
| 1209 | true_high_cond = kCondB; |
| 1210 | break; |
| 1211 | case kCondA: |
| 1212 | false_high_cond = kCondB; |
| 1213 | break; |
| 1214 | case kCondAE: |
| 1215 | true_high_cond = kCondA; |
| 1216 | break; |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1217 | } |
| 1218 | if (right.IsConstant()) { |
| 1219 | int64_t value = right.GetConstant()->AsLongConstant()->GetValue(); |
| 1220 | int32_t val_low = Low32Bits(value); |
| 1221 | int32_t val_high = High32Bits(value); |
| 1222 | |
| 1223 | GenerateCompareWithImmediate(left_high, val_high); |
| 1224 | if (if_cond == kCondNE) { |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1225 | __ b(true_label, ARMCondition(true_high_cond)); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1226 | } else if (if_cond == kCondEQ) { |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1227 | __ b(false_label, ARMCondition(false_high_cond)); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1228 | } else { |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1229 | __ b(true_label, ARMCondition(true_high_cond)); |
| 1230 | __ b(false_label, ARMCondition(false_high_cond)); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1231 | } |
| 1232 | // Must be equal high, so compare the lows. |
| 1233 | GenerateCompareWithImmediate(left_low, val_low); |
| 1234 | } else { |
| 1235 | Register right_high = right.AsRegisterPairHigh<Register>(); |
| 1236 | Register right_low = right.AsRegisterPairLow<Register>(); |
| 1237 | |
| 1238 | __ cmp(left_high, ShifterOperand(right_high)); |
| 1239 | if (if_cond == kCondNE) { |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1240 | __ b(true_label, ARMCondition(true_high_cond)); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1241 | } else if (if_cond == kCondEQ) { |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1242 | __ b(false_label, ARMCondition(false_high_cond)); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1243 | } else { |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1244 | __ b(true_label, ARMCondition(true_high_cond)); |
| 1245 | __ b(false_label, ARMCondition(false_high_cond)); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1246 | } |
| 1247 | // Must be equal high, so compare the lows. |
| 1248 | __ cmp(left_low, ShifterOperand(right_low)); |
| 1249 | } |
| 1250 | // The last comparison might be unsigned. |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1251 | // TODO: optimize cases where this is always true/false |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1252 | __ b(true_label, final_condition); |
| 1253 | } |
| 1254 | |
| 1255 | void InstructionCodeGeneratorARM::GenerateCompareTestAndBranch(HIf* if_instr, |
| 1256 | HCondition* condition, |
| 1257 | Label* true_target, |
| 1258 | Label* false_target, |
| 1259 | Label* always_true_target) { |
| 1260 | LocationSummary* locations = condition->GetLocations(); |
| 1261 | Location left = locations->InAt(0); |
| 1262 | Location right = locations->InAt(1); |
| 1263 | |
| 1264 | // We don't want true_target as a nullptr. |
| 1265 | if (true_target == nullptr) { |
| 1266 | true_target = always_true_target; |
| 1267 | } |
| 1268 | bool falls_through = (false_target == nullptr); |
| 1269 | |
| 1270 | // FP compares don't like null false_targets. |
| 1271 | if (false_target == nullptr) { |
| 1272 | false_target = codegen_->GetLabelOf(if_instr->IfFalseSuccessor()); |
| 1273 | } |
| 1274 | |
| 1275 | Primitive::Type type = condition->InputAt(0)->GetType(); |
| 1276 | switch (type) { |
| 1277 | case Primitive::kPrimLong: |
| 1278 | GenerateLongComparesAndJumps(condition, true_target, false_target); |
| 1279 | break; |
| 1280 | case Primitive::kPrimFloat: |
| 1281 | __ vcmps(left.AsFpuRegister<SRegister>(), right.AsFpuRegister<SRegister>()); |
| 1282 | GenerateFPJumps(condition, true_target, false_target); |
| 1283 | break; |
| 1284 | case Primitive::kPrimDouble: |
| 1285 | __ vcmpd(FromLowSToD(left.AsFpuRegisterPairLow<SRegister>()), |
| 1286 | FromLowSToD(right.AsFpuRegisterPairLow<SRegister>())); |
| 1287 | GenerateFPJumps(condition, true_target, false_target); |
| 1288 | break; |
| 1289 | default: |
| 1290 | LOG(FATAL) << "Unexpected compare type " << type; |
| 1291 | } |
| 1292 | |
| 1293 | if (!falls_through) { |
| 1294 | __ b(false_target); |
| 1295 | } |
| 1296 | } |
| 1297 | |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 1298 | void InstructionCodeGeneratorARM::GenerateTestAndBranch(HInstruction* instruction, |
| 1299 | Label* true_target, |
| 1300 | Label* false_target, |
| 1301 | Label* always_true_target) { |
| 1302 | HInstruction* cond = instruction->InputAt(0); |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1303 | if (cond->IsIntConstant()) { |
| 1304 | // Constant condition, statically compared against 1. |
| 1305 | int32_t cond_value = cond->AsIntConstant()->GetValue(); |
| 1306 | if (cond_value == 1) { |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 1307 | if (always_true_target != nullptr) { |
| 1308 | __ b(always_true_target); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1309 | } |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1310 | return; |
| 1311 | } else { |
| 1312 | DCHECK_EQ(cond_value, 0); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1313 | } |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1314 | } else { |
| 1315 | if (!cond->IsCondition() || cond->AsCondition()->NeedsMaterialization()) { |
| 1316 | // Condition has been materialized, compare the output to 0 |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 1317 | DCHECK(instruction->GetLocations()->InAt(0).IsRegister()); |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 1318 | __ CompareAndBranchIfNonZero(instruction->GetLocations()->InAt(0).AsRegister<Register>(), |
| 1319 | true_target); |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1320 | } else { |
| 1321 | // Condition has not been materialized, use its inputs as the |
| 1322 | // comparison and its condition as the branch condition. |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1323 | Primitive::Type type = |
| 1324 | cond->IsCondition() ? cond->InputAt(0)->GetType() : Primitive::kPrimInt; |
| 1325 | // Is this a long or FP comparison that has been folded into the HCondition? |
| 1326 | if (type == Primitive::kPrimLong || Primitive::IsFloatingPointType(type)) { |
| 1327 | // Generate the comparison directly. |
| 1328 | GenerateCompareTestAndBranch(instruction->AsIf(), cond->AsCondition(), |
| 1329 | true_target, false_target, always_true_target); |
| 1330 | return; |
| 1331 | } |
| 1332 | |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1333 | LocationSummary* locations = cond->GetLocations(); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 1334 | DCHECK(locations->InAt(0).IsRegister()) << locations->InAt(0); |
Nicolas Geoffray | 3bcc8ea | 2014-11-28 15:00:02 +0000 | [diff] [blame] | 1335 | Register left = locations->InAt(0).AsRegister<Register>(); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1336 | Location right = locations->InAt(1); |
| 1337 | if (right.IsRegister()) { |
| 1338 | __ cmp(left, ShifterOperand(right.AsRegister<Register>())); |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1339 | } else { |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1340 | DCHECK(right.IsConstant()); |
| 1341 | GenerateCompareWithImmediate(left, CodeGenerator::GetInt32ValueOf(right.GetConstant())); |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1342 | } |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1343 | __ b(true_target, ARMCondition(cond->AsCondition()->GetCondition())); |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1344 | } |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 1345 | } |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 1346 | if (false_target != nullptr) { |
| 1347 | __ b(false_target); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1348 | } |
| 1349 | } |
| 1350 | |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 1351 | void LocationsBuilderARM::VisitIf(HIf* if_instr) { |
| 1352 | LocationSummary* locations = |
| 1353 | new (GetGraph()->GetArena()) LocationSummary(if_instr, LocationSummary::kNoCall); |
| 1354 | HInstruction* cond = if_instr->InputAt(0); |
| 1355 | if (!cond->IsCondition() || cond->AsCondition()->NeedsMaterialization()) { |
| 1356 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | void InstructionCodeGeneratorARM::VisitIf(HIf* if_instr) { |
| 1361 | Label* true_target = codegen_->GetLabelOf(if_instr->IfTrueSuccessor()); |
| 1362 | Label* false_target = codegen_->GetLabelOf(if_instr->IfFalseSuccessor()); |
| 1363 | Label* always_true_target = true_target; |
| 1364 | if (codegen_->GoesToNextBlock(if_instr->GetBlock(), |
| 1365 | if_instr->IfTrueSuccessor())) { |
| 1366 | always_true_target = nullptr; |
| 1367 | } |
| 1368 | if (codegen_->GoesToNextBlock(if_instr->GetBlock(), |
| 1369 | if_instr->IfFalseSuccessor())) { |
| 1370 | false_target = nullptr; |
| 1371 | } |
| 1372 | GenerateTestAndBranch(if_instr, true_target, false_target, always_true_target); |
| 1373 | } |
| 1374 | |
| 1375 | void LocationsBuilderARM::VisitDeoptimize(HDeoptimize* deoptimize) { |
| 1376 | LocationSummary* locations = new (GetGraph()->GetArena()) |
| 1377 | LocationSummary(deoptimize, LocationSummary::kCallOnSlowPath); |
| 1378 | HInstruction* cond = deoptimize->InputAt(0); |
Aart Bik | bb245d1 | 2015-10-19 11:05:03 -0700 | [diff] [blame] | 1379 | if (!cond->IsCondition() || cond->AsCondition()->NeedsMaterialization()) { |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 1380 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | void InstructionCodeGeneratorARM::VisitDeoptimize(HDeoptimize* deoptimize) { |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 1385 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 1386 | DeoptimizationSlowPathARM(deoptimize); |
| 1387 | codegen_->AddSlowPath(slow_path); |
| 1388 | Label* slow_path_entry = slow_path->GetEntryLabel(); |
| 1389 | GenerateTestAndBranch(deoptimize, slow_path_entry, nullptr, slow_path_entry); |
| 1390 | } |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 1391 | |
Roland Levillain | 0d37cd0 | 2015-05-27 16:39:19 +0100 | [diff] [blame] | 1392 | void LocationsBuilderARM::VisitCondition(HCondition* cond) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1393 | LocationSummary* locations = |
Roland Levillain | 0d37cd0 | 2015-05-27 16:39:19 +0100 | [diff] [blame] | 1394 | new (GetGraph()->GetArena()) LocationSummary(cond, LocationSummary::kNoCall); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1395 | // Handle the long/FP comparisons made in instruction simplification. |
| 1396 | switch (cond->InputAt(0)->GetType()) { |
| 1397 | case Primitive::kPrimLong: |
| 1398 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1399 | locations->SetInAt(1, Location::RegisterOrConstant(cond->InputAt(1))); |
| 1400 | if (cond->NeedsMaterialization()) { |
| 1401 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
| 1402 | } |
| 1403 | break; |
| 1404 | |
| 1405 | case Primitive::kPrimFloat: |
| 1406 | case Primitive::kPrimDouble: |
| 1407 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1408 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 1409 | if (cond->NeedsMaterialization()) { |
| 1410 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1411 | } |
| 1412 | break; |
| 1413 | |
| 1414 | default: |
| 1415 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1416 | locations->SetInAt(1, Location::RegisterOrConstant(cond->InputAt(1))); |
| 1417 | if (cond->NeedsMaterialization()) { |
| 1418 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1419 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1420 | } |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1421 | } |
| 1422 | |
Roland Levillain | 0d37cd0 | 2015-05-27 16:39:19 +0100 | [diff] [blame] | 1423 | void InstructionCodeGeneratorARM::VisitCondition(HCondition* cond) { |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1424 | if (!cond->NeedsMaterialization()) { |
| 1425 | return; |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 1426 | } |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1427 | |
| 1428 | LocationSummary* locations = cond->GetLocations(); |
| 1429 | Location left = locations->InAt(0); |
| 1430 | Location right = locations->InAt(1); |
| 1431 | Register out = locations->Out().AsRegister<Register>(); |
| 1432 | Label true_label, false_label; |
| 1433 | |
| 1434 | switch (cond->InputAt(0)->GetType()) { |
| 1435 | default: { |
| 1436 | // Integer case. |
| 1437 | if (right.IsRegister()) { |
| 1438 | __ cmp(left.AsRegister<Register>(), ShifterOperand(right.AsRegister<Register>())); |
| 1439 | } else { |
| 1440 | DCHECK(right.IsConstant()); |
| 1441 | GenerateCompareWithImmediate(left.AsRegister<Register>(), |
| 1442 | CodeGenerator::GetInt32ValueOf(right.GetConstant())); |
| 1443 | } |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1444 | __ it(ARMCondition(cond->GetCondition()), kItElse); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1445 | __ mov(locations->Out().AsRegister<Register>(), ShifterOperand(1), |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1446 | ARMCondition(cond->GetCondition())); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1447 | __ mov(locations->Out().AsRegister<Register>(), ShifterOperand(0), |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1448 | ARMCondition(cond->GetOppositeCondition())); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 1449 | return; |
| 1450 | } |
| 1451 | case Primitive::kPrimLong: |
| 1452 | GenerateLongComparesAndJumps(cond, &true_label, &false_label); |
| 1453 | break; |
| 1454 | case Primitive::kPrimFloat: |
| 1455 | __ vcmps(left.AsFpuRegister<SRegister>(), right.AsFpuRegister<SRegister>()); |
| 1456 | GenerateFPJumps(cond, &true_label, &false_label); |
| 1457 | break; |
| 1458 | case Primitive::kPrimDouble: |
| 1459 | __ vcmpd(FromLowSToD(left.AsFpuRegisterPairLow<SRegister>()), |
| 1460 | FromLowSToD(right.AsFpuRegisterPairLow<SRegister>())); |
| 1461 | GenerateFPJumps(cond, &true_label, &false_label); |
| 1462 | break; |
| 1463 | } |
| 1464 | |
| 1465 | // Convert the jumps into the result. |
| 1466 | Label done_label; |
| 1467 | |
| 1468 | // False case: result = 0. |
| 1469 | __ Bind(&false_label); |
| 1470 | __ LoadImmediate(out, 0); |
| 1471 | __ b(&done_label); |
| 1472 | |
| 1473 | // True case: result = 1. |
| 1474 | __ Bind(&true_label); |
| 1475 | __ LoadImmediate(out, 1); |
| 1476 | __ Bind(&done_label); |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 1477 | } |
| 1478 | |
| 1479 | void LocationsBuilderARM::VisitEqual(HEqual* comp) { |
| 1480 | VisitCondition(comp); |
| 1481 | } |
| 1482 | |
| 1483 | void InstructionCodeGeneratorARM::VisitEqual(HEqual* comp) { |
| 1484 | VisitCondition(comp); |
| 1485 | } |
| 1486 | |
| 1487 | void LocationsBuilderARM::VisitNotEqual(HNotEqual* comp) { |
| 1488 | VisitCondition(comp); |
| 1489 | } |
| 1490 | |
| 1491 | void InstructionCodeGeneratorARM::VisitNotEqual(HNotEqual* comp) { |
| 1492 | VisitCondition(comp); |
| 1493 | } |
| 1494 | |
| 1495 | void LocationsBuilderARM::VisitLessThan(HLessThan* comp) { |
| 1496 | VisitCondition(comp); |
| 1497 | } |
| 1498 | |
| 1499 | void InstructionCodeGeneratorARM::VisitLessThan(HLessThan* comp) { |
| 1500 | VisitCondition(comp); |
| 1501 | } |
| 1502 | |
| 1503 | void LocationsBuilderARM::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 1504 | VisitCondition(comp); |
| 1505 | } |
| 1506 | |
| 1507 | void InstructionCodeGeneratorARM::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 1508 | VisitCondition(comp); |
| 1509 | } |
| 1510 | |
| 1511 | void LocationsBuilderARM::VisitGreaterThan(HGreaterThan* comp) { |
| 1512 | VisitCondition(comp); |
| 1513 | } |
| 1514 | |
| 1515 | void InstructionCodeGeneratorARM::VisitGreaterThan(HGreaterThan* comp) { |
| 1516 | VisitCondition(comp); |
| 1517 | } |
| 1518 | |
| 1519 | void LocationsBuilderARM::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 1520 | VisitCondition(comp); |
| 1521 | } |
| 1522 | |
| 1523 | void InstructionCodeGeneratorARM::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 1524 | VisitCondition(comp); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1525 | } |
| 1526 | |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1527 | void LocationsBuilderARM::VisitBelow(HBelow* comp) { |
| 1528 | VisitCondition(comp); |
| 1529 | } |
| 1530 | |
| 1531 | void InstructionCodeGeneratorARM::VisitBelow(HBelow* comp) { |
| 1532 | VisitCondition(comp); |
| 1533 | } |
| 1534 | |
| 1535 | void LocationsBuilderARM::VisitBelowOrEqual(HBelowOrEqual* comp) { |
| 1536 | VisitCondition(comp); |
| 1537 | } |
| 1538 | |
| 1539 | void InstructionCodeGeneratorARM::VisitBelowOrEqual(HBelowOrEqual* comp) { |
| 1540 | VisitCondition(comp); |
| 1541 | } |
| 1542 | |
| 1543 | void LocationsBuilderARM::VisitAbove(HAbove* comp) { |
| 1544 | VisitCondition(comp); |
| 1545 | } |
| 1546 | |
| 1547 | void InstructionCodeGeneratorARM::VisitAbove(HAbove* comp) { |
| 1548 | VisitCondition(comp); |
| 1549 | } |
| 1550 | |
| 1551 | void LocationsBuilderARM::VisitAboveOrEqual(HAboveOrEqual* comp) { |
| 1552 | VisitCondition(comp); |
| 1553 | } |
| 1554 | |
| 1555 | void InstructionCodeGeneratorARM::VisitAboveOrEqual(HAboveOrEqual* comp) { |
| 1556 | VisitCondition(comp); |
| 1557 | } |
| 1558 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1559 | void LocationsBuilderARM::VisitLocal(HLocal* local) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 1560 | local->SetLocations(nullptr); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 1561 | } |
| 1562 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 1563 | void InstructionCodeGeneratorARM::VisitLocal(HLocal* local) { |
| 1564 | DCHECK_EQ(local->GetBlock(), GetGraph()->GetEntryBlock()); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 1565 | } |
| 1566 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1567 | void LocationsBuilderARM::VisitLoadLocal(HLoadLocal* load) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 1568 | load->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1569 | } |
| 1570 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1571 | void InstructionCodeGeneratorARM::VisitLoadLocal(HLoadLocal* load ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 1572 | // Nothing to do, this is driven by the code generator. |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1573 | } |
| 1574 | |
| 1575 | void LocationsBuilderARM::VisitStoreLocal(HStoreLocal* store) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1576 | LocationSummary* locations = |
| 1577 | new (GetGraph()->GetArena()) LocationSummary(store, LocationSummary::kNoCall); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1578 | switch (store->InputAt(1)->GetType()) { |
| 1579 | case Primitive::kPrimBoolean: |
| 1580 | case Primitive::kPrimByte: |
| 1581 | case Primitive::kPrimChar: |
| 1582 | case Primitive::kPrimShort: |
| 1583 | case Primitive::kPrimInt: |
| 1584 | case Primitive::kPrimNot: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1585 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1586 | locations->SetInAt(1, Location::StackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 1587 | break; |
| 1588 | |
| 1589 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1590 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1591 | locations->SetInAt(1, Location::DoubleStackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 1592 | break; |
| 1593 | |
| 1594 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1595 | LOG(FATAL) << "Unexpected local type " << store->InputAt(1)->GetType(); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1596 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1597 | } |
| 1598 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1599 | void InstructionCodeGeneratorARM::VisitStoreLocal(HStoreLocal* store ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1600 | } |
| 1601 | |
| 1602 | void LocationsBuilderARM::VisitIntConstant(HIntConstant* constant) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1603 | LocationSummary* locations = |
| 1604 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1605 | locations->SetOut(Location::ConstantLocation(constant)); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 1606 | } |
| 1607 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1608 | void InstructionCodeGeneratorARM::VisitIntConstant(HIntConstant* constant ATTRIBUTE_UNUSED) { |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 1609 | // Will be generated at use site. |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1610 | } |
| 1611 | |
Nicolas Geoffray | d6138ef | 2015-02-18 14:48:53 +0000 | [diff] [blame] | 1612 | void LocationsBuilderARM::VisitNullConstant(HNullConstant* constant) { |
| 1613 | LocationSummary* locations = |
| 1614 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
| 1615 | locations->SetOut(Location::ConstantLocation(constant)); |
| 1616 | } |
| 1617 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1618 | void InstructionCodeGeneratorARM::VisitNullConstant(HNullConstant* constant ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | d6138ef | 2015-02-18 14:48:53 +0000 | [diff] [blame] | 1619 | // Will be generated at use site. |
Nicolas Geoffray | d6138ef | 2015-02-18 14:48:53 +0000 | [diff] [blame] | 1620 | } |
| 1621 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1622 | void LocationsBuilderARM::VisitLongConstant(HLongConstant* constant) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1623 | LocationSummary* locations = |
| 1624 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1625 | locations->SetOut(Location::ConstantLocation(constant)); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1626 | } |
| 1627 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1628 | void InstructionCodeGeneratorARM::VisitLongConstant(HLongConstant* constant ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 1629 | // Will be generated at use site. |
| 1630 | } |
| 1631 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1632 | void LocationsBuilderARM::VisitFloatConstant(HFloatConstant* constant) { |
| 1633 | LocationSummary* locations = |
| 1634 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
| 1635 | locations->SetOut(Location::ConstantLocation(constant)); |
| 1636 | } |
| 1637 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1638 | void InstructionCodeGeneratorARM::VisitFloatConstant(HFloatConstant* constant ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1639 | // Will be generated at use site. |
| 1640 | } |
| 1641 | |
| 1642 | void LocationsBuilderARM::VisitDoubleConstant(HDoubleConstant* constant) { |
| 1643 | LocationSummary* locations = |
| 1644 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
| 1645 | locations->SetOut(Location::ConstantLocation(constant)); |
| 1646 | } |
| 1647 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1648 | void InstructionCodeGeneratorARM::VisitDoubleConstant(HDoubleConstant* constant ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1649 | // Will be generated at use site. |
| 1650 | } |
| 1651 | |
Calin Juravle | 27df758 | 2015-04-17 19:12:31 +0100 | [diff] [blame] | 1652 | void LocationsBuilderARM::VisitMemoryBarrier(HMemoryBarrier* memory_barrier) { |
| 1653 | memory_barrier->SetLocations(nullptr); |
| 1654 | } |
| 1655 | |
| 1656 | void InstructionCodeGeneratorARM::VisitMemoryBarrier(HMemoryBarrier* memory_barrier) { |
| 1657 | GenerateMemoryBarrier(memory_barrier->GetBarrierKind()); |
| 1658 | } |
| 1659 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1660 | void LocationsBuilderARM::VisitReturnVoid(HReturnVoid* ret) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 1661 | ret->SetLocations(nullptr); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 1662 | } |
| 1663 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1664 | void InstructionCodeGeneratorARM::VisitReturnVoid(HReturnVoid* ret ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 1665 | codegen_->GenerateFrameExit(); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1666 | } |
| 1667 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1668 | void LocationsBuilderARM::VisitReturn(HReturn* ret) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1669 | LocationSummary* locations = |
| 1670 | new (GetGraph()->GetArena()) LocationSummary(ret, LocationSummary::kNoCall); |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 1671 | locations->SetInAt(0, parameter_visitor_.GetReturnLocation(ret->InputAt(0)->GetType())); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1672 | } |
| 1673 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1674 | void InstructionCodeGeneratorARM::VisitReturn(HReturn* ret ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 1675 | codegen_->GenerateFrameExit(); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 1676 | } |
| 1677 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 1678 | void LocationsBuilderARM::VisitInvokeUnresolved(HInvokeUnresolved* invoke) { |
| 1679 | // The trampoline uses the same calling convention as dex calling conventions, |
| 1680 | // except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
| 1681 | // the method_idx. |
| 1682 | HandleInvoke(invoke); |
| 1683 | } |
| 1684 | |
| 1685 | void InstructionCodeGeneratorARM::VisitInvokeUnresolved(HInvokeUnresolved* invoke) { |
| 1686 | codegen_->GenerateInvokeUnresolvedRuntimeCall(invoke); |
| 1687 | } |
| 1688 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 1689 | void LocationsBuilderARM::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) { |
Roland Levillain | 3e3d733 | 2015-04-28 11:00:54 +0100 | [diff] [blame] | 1690 | // When we do not run baseline, explicit clinit checks triggered by static |
| 1691 | // invokes must have been pruned by art::PrepareForRegisterAllocation. |
| 1692 | DCHECK(codegen_->IsBaseline() || !invoke->IsStaticWithExplicitClinitCheck()); |
Roland Levillain | 4c0eb42 | 2015-04-24 16:43:49 +0100 | [diff] [blame] | 1693 | |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 1694 | IntrinsicLocationsBuilderARM intrinsic(GetGraph()->GetArena(), |
Nicolas Geoffray | 5bd05a5 | 2015-10-13 09:48:30 +0100 | [diff] [blame] | 1695 | codegen_->GetAssembler(), |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 1696 | codegen_->GetInstructionSetFeatures()); |
| 1697 | if (intrinsic.TryDispatch(invoke)) { |
| 1698 | return; |
| 1699 | } |
| 1700 | |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1701 | HandleInvoke(invoke); |
| 1702 | } |
| 1703 | |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 1704 | static bool TryGenerateIntrinsicCode(HInvoke* invoke, CodeGeneratorARM* codegen) { |
| 1705 | if (invoke->GetLocations()->Intrinsified()) { |
| 1706 | IntrinsicCodeGeneratorARM intrinsic(codegen); |
| 1707 | intrinsic.Dispatch(invoke); |
| 1708 | return true; |
| 1709 | } |
| 1710 | return false; |
| 1711 | } |
| 1712 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 1713 | void InstructionCodeGeneratorARM::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) { |
Roland Levillain | 3e3d733 | 2015-04-28 11:00:54 +0100 | [diff] [blame] | 1714 | // When we do not run baseline, explicit clinit checks triggered by static |
| 1715 | // invokes must have been pruned by art::PrepareForRegisterAllocation. |
| 1716 | DCHECK(codegen_->IsBaseline() || !invoke->IsStaticWithExplicitClinitCheck()); |
Roland Levillain | 4c0eb42 | 2015-04-24 16:43:49 +0100 | [diff] [blame] | 1717 | |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 1718 | if (TryGenerateIntrinsicCode(invoke, codegen_)) { |
| 1719 | return; |
Nicolas Geoffray | 1cf9528 | 2014-12-12 19:22:03 +0000 | [diff] [blame] | 1720 | } |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1721 | |
Nicolas Geoffray | 38207af | 2015-06-01 15:46:22 +0100 | [diff] [blame] | 1722 | LocationSummary* locations = invoke->GetLocations(); |
| 1723 | codegen_->GenerateStaticOrDirectCall( |
| 1724 | invoke, locations->HasTemps() ? locations->GetTemp(0) : Location::NoLocation()); |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 1725 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1726 | } |
| 1727 | |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1728 | void LocationsBuilderARM::HandleInvoke(HInvoke* invoke) { |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 1729 | InvokeDexCallingConventionVisitorARM calling_convention_visitor; |
Nicolas Geoffray | fd88f16 | 2015-06-03 11:23:52 +0100 | [diff] [blame] | 1730 | CodeGenerator::CreateCommonInvokeLocationSummary(invoke, &calling_convention_visitor); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 1731 | } |
| 1732 | |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1733 | void LocationsBuilderARM::VisitInvokeVirtual(HInvokeVirtual* invoke) { |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 1734 | IntrinsicLocationsBuilderARM intrinsic(GetGraph()->GetArena(), |
Nicolas Geoffray | 5bd05a5 | 2015-10-13 09:48:30 +0100 | [diff] [blame] | 1735 | codegen_->GetAssembler(), |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 1736 | codegen_->GetInstructionSetFeatures()); |
| 1737 | if (intrinsic.TryDispatch(invoke)) { |
| 1738 | return; |
| 1739 | } |
| 1740 | |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1741 | HandleInvoke(invoke); |
| 1742 | } |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 1743 | |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1744 | void InstructionCodeGeneratorARM::VisitInvokeVirtual(HInvokeVirtual* invoke) { |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 1745 | if (TryGenerateIntrinsicCode(invoke, codegen_)) { |
| 1746 | return; |
| 1747 | } |
| 1748 | |
Andreas Gampe | bfb5ba9 | 2015-09-01 15:45:02 +0000 | [diff] [blame] | 1749 | codegen_->GenerateVirtualCall(invoke, invoke->GetLocations()->GetTemp(0)); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 1750 | DCHECK(!codegen_->IsLeafMethod()); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1751 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 1752 | } |
| 1753 | |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1754 | void LocationsBuilderARM::VisitInvokeInterface(HInvokeInterface* invoke) { |
| 1755 | HandleInvoke(invoke); |
| 1756 | // Add the hidden argument. |
| 1757 | invoke->GetLocations()->AddTemp(Location::RegisterLocation(R12)); |
| 1758 | } |
| 1759 | |
| 1760 | void InstructionCodeGeneratorARM::VisitInvokeInterface(HInvokeInterface* invoke) { |
| 1761 | // TODO: b/18116999, our IMTs can miss an IncompatibleClassChangeError. |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 1762 | Register temp = invoke->GetLocations()->GetTemp(0).AsRegister<Register>(); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1763 | uint32_t method_offset = mirror::Class::EmbeddedImTableEntryOffset( |
| 1764 | invoke->GetImtIndex() % mirror::Class::kImtSize, kArmPointerSize).Uint32Value(); |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1765 | LocationSummary* locations = invoke->GetLocations(); |
| 1766 | Location receiver = locations->InAt(0); |
| 1767 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
| 1768 | |
| 1769 | // Set the hidden argument. |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 1770 | __ LoadImmediate(invoke->GetLocations()->GetTemp(1).AsRegister<Register>(), |
| 1771 | invoke->GetDexMethodIndex()); |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1772 | |
| 1773 | // temp = object->GetClass(); |
| 1774 | if (receiver.IsStackSlot()) { |
| 1775 | __ LoadFromOffset(kLoadWord, temp, SP, receiver.GetStackIndex()); |
| 1776 | __ LoadFromOffset(kLoadWord, temp, temp, class_offset); |
| 1777 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 1778 | __ LoadFromOffset(kLoadWord, temp, receiver.AsRegister<Register>(), class_offset); |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1779 | } |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 1780 | codegen_->MaybeRecordImplicitNullCheck(invoke); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 1781 | __ MaybeUnpoisonHeapReference(temp); |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1782 | // temp = temp->GetImtEntryAt(method_offset); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1783 | uint32_t entry_point = ArtMethod::EntryPointFromQuickCompiledCodeOffset( |
Nicolas Geoffray | 86a8d7a | 2014-11-19 08:47:18 +0000 | [diff] [blame] | 1784 | kArmWordSize).Int32Value(); |
Nicolas Geoffray | 52839d1 | 2014-11-07 17:47:25 +0000 | [diff] [blame] | 1785 | __ LoadFromOffset(kLoadWord, temp, temp, method_offset); |
| 1786 | // LR = temp->GetEntryPoint(); |
| 1787 | __ LoadFromOffset(kLoadWord, LR, temp, entry_point); |
| 1788 | // LR(); |
| 1789 | __ blx(LR); |
| 1790 | DCHECK(!codegen_->IsLeafMethod()); |
| 1791 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
| 1792 | } |
| 1793 | |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1794 | void LocationsBuilderARM::VisitNeg(HNeg* neg) { |
| 1795 | LocationSummary* locations = |
| 1796 | new (GetGraph()->GetArena()) LocationSummary(neg, LocationSummary::kNoCall); |
| 1797 | switch (neg->GetResultType()) { |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 1798 | case Primitive::kPrimInt: { |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1799 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 1800 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1801 | break; |
| 1802 | } |
| 1803 | case Primitive::kPrimLong: { |
| 1804 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1805 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1806 | break; |
Roland Levillain | 2e07b4f | 2014-10-23 18:12:09 +0100 | [diff] [blame] | 1807 | } |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1808 | |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1809 | case Primitive::kPrimFloat: |
| 1810 | case Primitive::kPrimDouble: |
Roland Levillain | 3dbcb38 | 2014-10-28 17:30:07 +0000 | [diff] [blame] | 1811 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1812 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1813 | break; |
| 1814 | |
| 1815 | default: |
| 1816 | LOG(FATAL) << "Unexpected neg type " << neg->GetResultType(); |
| 1817 | } |
| 1818 | } |
| 1819 | |
| 1820 | void InstructionCodeGeneratorARM::VisitNeg(HNeg* neg) { |
| 1821 | LocationSummary* locations = neg->GetLocations(); |
| 1822 | Location out = locations->Out(); |
| 1823 | Location in = locations->InAt(0); |
| 1824 | switch (neg->GetResultType()) { |
| 1825 | case Primitive::kPrimInt: |
| 1826 | DCHECK(in.IsRegister()); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 1827 | __ rsb(out.AsRegister<Register>(), in.AsRegister<Register>(), ShifterOperand(0)); |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1828 | break; |
| 1829 | |
| 1830 | case Primitive::kPrimLong: |
Roland Levillain | 2e07b4f | 2014-10-23 18:12:09 +0100 | [diff] [blame] | 1831 | DCHECK(in.IsRegisterPair()); |
| 1832 | // out.lo = 0 - in.lo (and update the carry/borrow (C) flag) |
| 1833 | __ rsbs(out.AsRegisterPairLow<Register>(), |
| 1834 | in.AsRegisterPairLow<Register>(), |
| 1835 | ShifterOperand(0)); |
| 1836 | // We cannot emit an RSC (Reverse Subtract with Carry) |
| 1837 | // instruction here, as it does not exist in the Thumb-2 |
| 1838 | // instruction set. We use the following approach |
| 1839 | // using SBC and SUB instead. |
| 1840 | // |
| 1841 | // out.hi = -C |
| 1842 | __ sbc(out.AsRegisterPairHigh<Register>(), |
| 1843 | out.AsRegisterPairHigh<Register>(), |
| 1844 | ShifterOperand(out.AsRegisterPairHigh<Register>())); |
| 1845 | // out.hi = out.hi - in.hi |
| 1846 | __ sub(out.AsRegisterPairHigh<Register>(), |
| 1847 | out.AsRegisterPairHigh<Register>(), |
| 1848 | ShifterOperand(in.AsRegisterPairHigh<Register>())); |
| 1849 | break; |
| 1850 | |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1851 | case Primitive::kPrimFloat: |
Roland Levillain | 3dbcb38 | 2014-10-28 17:30:07 +0000 | [diff] [blame] | 1852 | DCHECK(in.IsFpuRegister()); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 1853 | __ vnegs(out.AsFpuRegister<SRegister>(), in.AsFpuRegister<SRegister>()); |
Roland Levillain | 3dbcb38 | 2014-10-28 17:30:07 +0000 | [diff] [blame] | 1854 | break; |
| 1855 | |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1856 | case Primitive::kPrimDouble: |
Roland Levillain | 3dbcb38 | 2014-10-28 17:30:07 +0000 | [diff] [blame] | 1857 | DCHECK(in.IsFpuRegisterPair()); |
| 1858 | __ vnegd(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), |
| 1859 | FromLowSToD(in.AsFpuRegisterPairLow<SRegister>())); |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1860 | break; |
| 1861 | |
| 1862 | default: |
| 1863 | LOG(FATAL) << "Unexpected neg type " << neg->GetResultType(); |
| 1864 | } |
| 1865 | } |
| 1866 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1867 | void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) { |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1868 | Primitive::Type result_type = conversion->GetResultType(); |
| 1869 | Primitive::Type input_type = conversion->GetInputType(); |
Nicolas Geoffray | 01fcc9e | 2014-12-01 14:16:20 +0000 | [diff] [blame] | 1870 | DCHECK_NE(result_type, input_type); |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 1871 | |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 1872 | // The float-to-long, double-to-long and long-to-float type conversions |
| 1873 | // rely on a call to the runtime. |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 1874 | LocationSummary::CallKind call_kind = |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 1875 | (((input_type == Primitive::kPrimFloat || input_type == Primitive::kPrimDouble) |
| 1876 | && result_type == Primitive::kPrimLong) |
| 1877 | || (input_type == Primitive::kPrimLong && result_type == Primitive::kPrimFloat)) |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 1878 | ? LocationSummary::kCall |
| 1879 | : LocationSummary::kNoCall; |
| 1880 | LocationSummary* locations = |
| 1881 | new (GetGraph()->GetArena()) LocationSummary(conversion, call_kind); |
| 1882 | |
David Brazdil | b2bd1c5 | 2015-03-25 11:17:37 +0000 | [diff] [blame] | 1883 | // The Java language does not allow treating boolean as an integral type but |
| 1884 | // our bit representation makes it safe. |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 1885 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1886 | switch (result_type) { |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 1887 | case Primitive::kPrimByte: |
| 1888 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 1889 | case Primitive::kPrimBoolean: |
| 1890 | // Boolean input is a result of code transformations. |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 1891 | case Primitive::kPrimShort: |
| 1892 | case Primitive::kPrimInt: |
| 1893 | case Primitive::kPrimChar: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 1894 | // Processing a Dex `int-to-byte' instruction. |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 1895 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1896 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1897 | break; |
| 1898 | |
| 1899 | default: |
| 1900 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1901 | << " to " << result_type; |
| 1902 | } |
| 1903 | break; |
| 1904 | |
Roland Levillain | 01a8d71 | 2014-11-14 16:27:39 +0000 | [diff] [blame] | 1905 | case Primitive::kPrimShort: |
| 1906 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 1907 | case Primitive::kPrimBoolean: |
| 1908 | // Boolean input is a result of code transformations. |
Roland Levillain | 01a8d71 | 2014-11-14 16:27:39 +0000 | [diff] [blame] | 1909 | case Primitive::kPrimByte: |
| 1910 | case Primitive::kPrimInt: |
| 1911 | case Primitive::kPrimChar: |
| 1912 | // Processing a Dex `int-to-short' instruction. |
| 1913 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1914 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1915 | break; |
| 1916 | |
| 1917 | default: |
| 1918 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1919 | << " to " << result_type; |
| 1920 | } |
| 1921 | break; |
| 1922 | |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 1923 | case Primitive::kPrimInt: |
| 1924 | switch (input_type) { |
| 1925 | case Primitive::kPrimLong: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 1926 | // Processing a Dex `long-to-int' instruction. |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 1927 | locations->SetInAt(0, Location::Any()); |
| 1928 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1929 | break; |
| 1930 | |
| 1931 | case Primitive::kPrimFloat: |
Roland Levillain | 3f8f936 | 2014-12-02 17:45:01 +0000 | [diff] [blame] | 1932 | // Processing a Dex `float-to-int' instruction. |
| 1933 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1934 | locations->SetOut(Location::RequiresRegister()); |
| 1935 | locations->AddTemp(Location::RequiresFpuRegister()); |
| 1936 | break; |
| 1937 | |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 1938 | case Primitive::kPrimDouble: |
Roland Levillain | 4c0b61f | 2014-12-05 12:06:01 +0000 | [diff] [blame] | 1939 | // Processing a Dex `double-to-int' instruction. |
| 1940 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1941 | locations->SetOut(Location::RequiresRegister()); |
| 1942 | locations->AddTemp(Location::RequiresFpuRegister()); |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 1943 | break; |
| 1944 | |
| 1945 | default: |
| 1946 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1947 | << " to " << result_type; |
| 1948 | } |
| 1949 | break; |
| 1950 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1951 | case Primitive::kPrimLong: |
| 1952 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 1953 | case Primitive::kPrimBoolean: |
| 1954 | // Boolean input is a result of code transformations. |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1955 | case Primitive::kPrimByte: |
| 1956 | case Primitive::kPrimShort: |
| 1957 | case Primitive::kPrimInt: |
Roland Levillain | 666c732 | 2014-11-10 13:39:43 +0000 | [diff] [blame] | 1958 | case Primitive::kPrimChar: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 1959 | // Processing a Dex `int-to-long' instruction. |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1960 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1961 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1962 | break; |
| 1963 | |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 1964 | case Primitive::kPrimFloat: { |
| 1965 | // Processing a Dex `float-to-long' instruction. |
| 1966 | InvokeRuntimeCallingConvention calling_convention; |
| 1967 | locations->SetInAt(0, Location::FpuRegisterLocation( |
| 1968 | calling_convention.GetFpuRegisterAt(0))); |
| 1969 | locations->SetOut(Location::RegisterPairLocation(R0, R1)); |
| 1970 | break; |
| 1971 | } |
| 1972 | |
Roland Levillain | 4c0b61f | 2014-12-05 12:06:01 +0000 | [diff] [blame] | 1973 | case Primitive::kPrimDouble: { |
| 1974 | // Processing a Dex `double-to-long' instruction. |
| 1975 | InvokeRuntimeCallingConvention calling_convention; |
| 1976 | locations->SetInAt(0, Location::FpuRegisterPairLocation( |
| 1977 | calling_convention.GetFpuRegisterAt(0), |
| 1978 | calling_convention.GetFpuRegisterAt(1))); |
| 1979 | locations->SetOut(Location::RegisterPairLocation(R0, R1)); |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1980 | break; |
Roland Levillain | 4c0b61f | 2014-12-05 12:06:01 +0000 | [diff] [blame] | 1981 | } |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1982 | |
| 1983 | default: |
| 1984 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1985 | << " to " << result_type; |
| 1986 | } |
| 1987 | break; |
| 1988 | |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 1989 | case Primitive::kPrimChar: |
| 1990 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 1991 | case Primitive::kPrimBoolean: |
| 1992 | // Boolean input is a result of code transformations. |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 1993 | case Primitive::kPrimByte: |
| 1994 | case Primitive::kPrimShort: |
| 1995 | case Primitive::kPrimInt: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 1996 | // Processing a Dex `int-to-char' instruction. |
| 1997 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1998 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1999 | break; |
| 2000 | |
| 2001 | default: |
| 2002 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2003 | << " to " << result_type; |
| 2004 | } |
| 2005 | break; |
| 2006 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2007 | case Primitive::kPrimFloat: |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2008 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2009 | case Primitive::kPrimBoolean: |
| 2010 | // Boolean input is a result of code transformations. |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2011 | case Primitive::kPrimByte: |
| 2012 | case Primitive::kPrimShort: |
| 2013 | case Primitive::kPrimInt: |
| 2014 | case Primitive::kPrimChar: |
| 2015 | // Processing a Dex `int-to-float' instruction. |
| 2016 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2017 | locations->SetOut(Location::RequiresFpuRegister()); |
| 2018 | break; |
| 2019 | |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 2020 | case Primitive::kPrimLong: { |
Roland Levillain | 6d0e483 | 2014-11-27 18:31:21 +0000 | [diff] [blame] | 2021 | // Processing a Dex `long-to-float' instruction. |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 2022 | InvokeRuntimeCallingConvention calling_convention; |
| 2023 | locations->SetInAt(0, Location::RegisterPairLocation( |
| 2024 | calling_convention.GetRegisterAt(0), calling_convention.GetRegisterAt(1))); |
| 2025 | locations->SetOut(Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(0))); |
Roland Levillain | 6d0e483 | 2014-11-27 18:31:21 +0000 | [diff] [blame] | 2026 | break; |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 2027 | } |
Roland Levillain | 6d0e483 | 2014-11-27 18:31:21 +0000 | [diff] [blame] | 2028 | |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2029 | case Primitive::kPrimDouble: |
Roland Levillain | 8964e2b | 2014-12-04 12:10:50 +0000 | [diff] [blame] | 2030 | // Processing a Dex `double-to-float' instruction. |
| 2031 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 2032 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2033 | break; |
| 2034 | |
| 2035 | default: |
| 2036 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2037 | << " to " << result_type; |
| 2038 | }; |
| 2039 | break; |
| 2040 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2041 | case Primitive::kPrimDouble: |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2042 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2043 | case Primitive::kPrimBoolean: |
| 2044 | // Boolean input is a result of code transformations. |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2045 | case Primitive::kPrimByte: |
| 2046 | case Primitive::kPrimShort: |
| 2047 | case Primitive::kPrimInt: |
| 2048 | case Primitive::kPrimChar: |
| 2049 | // Processing a Dex `int-to-double' instruction. |
| 2050 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2051 | locations->SetOut(Location::RequiresFpuRegister()); |
| 2052 | break; |
| 2053 | |
| 2054 | case Primitive::kPrimLong: |
Roland Levillain | 647b9ed | 2014-11-27 12:06:00 +0000 | [diff] [blame] | 2055 | // Processing a Dex `long-to-double' instruction. |
| 2056 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2057 | locations->SetOut(Location::RequiresFpuRegister()); |
Roland Levillain | 682393c | 2015-04-14 15:57:52 +0100 | [diff] [blame] | 2058 | locations->AddTemp(Location::RequiresFpuRegister()); |
Roland Levillain | 647b9ed | 2014-11-27 12:06:00 +0000 | [diff] [blame] | 2059 | locations->AddTemp(Location::RequiresFpuRegister()); |
| 2060 | break; |
| 2061 | |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2062 | case Primitive::kPrimFloat: |
Roland Levillain | 8964e2b | 2014-12-04 12:10:50 +0000 | [diff] [blame] | 2063 | // Processing a Dex `float-to-double' instruction. |
| 2064 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 2065 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2066 | break; |
| 2067 | |
| 2068 | default: |
| 2069 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2070 | << " to " << result_type; |
| 2071 | }; |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2072 | break; |
| 2073 | |
| 2074 | default: |
| 2075 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2076 | << " to " << result_type; |
| 2077 | } |
| 2078 | } |
| 2079 | |
| 2080 | void InstructionCodeGeneratorARM::VisitTypeConversion(HTypeConversion* conversion) { |
| 2081 | LocationSummary* locations = conversion->GetLocations(); |
| 2082 | Location out = locations->Out(); |
| 2083 | Location in = locations->InAt(0); |
| 2084 | Primitive::Type result_type = conversion->GetResultType(); |
| 2085 | Primitive::Type input_type = conversion->GetInputType(); |
Nicolas Geoffray | 01fcc9e | 2014-12-01 14:16:20 +0000 | [diff] [blame] | 2086 | DCHECK_NE(result_type, input_type); |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2087 | switch (result_type) { |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 2088 | case Primitive::kPrimByte: |
| 2089 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2090 | case Primitive::kPrimBoolean: |
| 2091 | // Boolean input is a result of code transformations. |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 2092 | case Primitive::kPrimShort: |
| 2093 | case Primitive::kPrimInt: |
| 2094 | case Primitive::kPrimChar: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 2095 | // Processing a Dex `int-to-byte' instruction. |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2096 | __ sbfx(out.AsRegister<Register>(), in.AsRegister<Register>(), 0, 8); |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 2097 | break; |
| 2098 | |
| 2099 | default: |
| 2100 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2101 | << " to " << result_type; |
| 2102 | } |
| 2103 | break; |
| 2104 | |
Roland Levillain | 01a8d71 | 2014-11-14 16:27:39 +0000 | [diff] [blame] | 2105 | case Primitive::kPrimShort: |
| 2106 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2107 | case Primitive::kPrimBoolean: |
| 2108 | // Boolean input is a result of code transformations. |
Roland Levillain | 01a8d71 | 2014-11-14 16:27:39 +0000 | [diff] [blame] | 2109 | case Primitive::kPrimByte: |
| 2110 | case Primitive::kPrimInt: |
| 2111 | case Primitive::kPrimChar: |
| 2112 | // Processing a Dex `int-to-short' instruction. |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2113 | __ sbfx(out.AsRegister<Register>(), in.AsRegister<Register>(), 0, 16); |
Roland Levillain | 01a8d71 | 2014-11-14 16:27:39 +0000 | [diff] [blame] | 2114 | break; |
| 2115 | |
| 2116 | default: |
| 2117 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2118 | << " to " << result_type; |
| 2119 | } |
| 2120 | break; |
| 2121 | |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 2122 | case Primitive::kPrimInt: |
| 2123 | switch (input_type) { |
| 2124 | case Primitive::kPrimLong: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 2125 | // Processing a Dex `long-to-int' instruction. |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 2126 | DCHECK(out.IsRegister()); |
| 2127 | if (in.IsRegisterPair()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2128 | __ Mov(out.AsRegister<Register>(), in.AsRegisterPairLow<Register>()); |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 2129 | } else if (in.IsDoubleStackSlot()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2130 | __ LoadFromOffset(kLoadWord, out.AsRegister<Register>(), SP, in.GetStackIndex()); |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 2131 | } else { |
| 2132 | DCHECK(in.IsConstant()); |
| 2133 | DCHECK(in.GetConstant()->IsLongConstant()); |
| 2134 | int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2135 | __ LoadImmediate(out.AsRegister<Register>(), static_cast<int32_t>(value)); |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 2136 | } |
| 2137 | break; |
| 2138 | |
Roland Levillain | 3f8f936 | 2014-12-02 17:45:01 +0000 | [diff] [blame] | 2139 | case Primitive::kPrimFloat: { |
| 2140 | // Processing a Dex `float-to-int' instruction. |
| 2141 | SRegister temp = locations->GetTemp(0).AsFpuRegisterPairLow<SRegister>(); |
| 2142 | __ vmovs(temp, in.AsFpuRegister<SRegister>()); |
| 2143 | __ vcvtis(temp, temp); |
| 2144 | __ vmovrs(out.AsRegister<Register>(), temp); |
| 2145 | break; |
| 2146 | } |
| 2147 | |
Roland Levillain | 4c0b61f | 2014-12-05 12:06:01 +0000 | [diff] [blame] | 2148 | case Primitive::kPrimDouble: { |
| 2149 | // Processing a Dex `double-to-int' instruction. |
| 2150 | SRegister temp_s = locations->GetTemp(0).AsFpuRegisterPairLow<SRegister>(); |
| 2151 | DRegister temp_d = FromLowSToD(temp_s); |
| 2152 | __ vmovd(temp_d, FromLowSToD(in.AsFpuRegisterPairLow<SRegister>())); |
| 2153 | __ vcvtid(temp_s, temp_d); |
| 2154 | __ vmovrs(out.AsRegister<Register>(), temp_s); |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 2155 | break; |
Roland Levillain | 4c0b61f | 2014-12-05 12:06:01 +0000 | [diff] [blame] | 2156 | } |
Roland Levillain | 946e143 | 2014-11-11 17:35:19 +0000 | [diff] [blame] | 2157 | |
| 2158 | default: |
| 2159 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2160 | << " to " << result_type; |
| 2161 | } |
| 2162 | break; |
| 2163 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2164 | case Primitive::kPrimLong: |
| 2165 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2166 | case Primitive::kPrimBoolean: |
| 2167 | // Boolean input is a result of code transformations. |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2168 | case Primitive::kPrimByte: |
| 2169 | case Primitive::kPrimShort: |
| 2170 | case Primitive::kPrimInt: |
Roland Levillain | 666c732 | 2014-11-10 13:39:43 +0000 | [diff] [blame] | 2171 | case Primitive::kPrimChar: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 2172 | // Processing a Dex `int-to-long' instruction. |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2173 | DCHECK(out.IsRegisterPair()); |
| 2174 | DCHECK(in.IsRegister()); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2175 | __ Mov(out.AsRegisterPairLow<Register>(), in.AsRegister<Register>()); |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2176 | // Sign extension. |
| 2177 | __ Asr(out.AsRegisterPairHigh<Register>(), |
| 2178 | out.AsRegisterPairLow<Register>(), |
| 2179 | 31); |
| 2180 | break; |
| 2181 | |
| 2182 | case Primitive::kPrimFloat: |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 2183 | // Processing a Dex `float-to-long' instruction. |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 2184 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pF2l), |
| 2185 | conversion, |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 2186 | conversion->GetDexPc(), |
| 2187 | nullptr); |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 2188 | break; |
| 2189 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2190 | case Primitive::kPrimDouble: |
Roland Levillain | 4c0b61f | 2014-12-05 12:06:01 +0000 | [diff] [blame] | 2191 | // Processing a Dex `double-to-long' instruction. |
| 2192 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pD2l), |
| 2193 | conversion, |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 2194 | conversion->GetDexPc(), |
| 2195 | nullptr); |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2196 | break; |
| 2197 | |
| 2198 | default: |
| 2199 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2200 | << " to " << result_type; |
| 2201 | } |
| 2202 | break; |
| 2203 | |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 2204 | case Primitive::kPrimChar: |
| 2205 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2206 | case Primitive::kPrimBoolean: |
| 2207 | // Boolean input is a result of code transformations. |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 2208 | case Primitive::kPrimByte: |
| 2209 | case Primitive::kPrimShort: |
| 2210 | case Primitive::kPrimInt: |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 2211 | // Processing a Dex `int-to-char' instruction. |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2212 | __ ubfx(out.AsRegister<Register>(), in.AsRegister<Register>(), 0, 16); |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 2213 | break; |
| 2214 | |
| 2215 | default: |
| 2216 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2217 | << " to " << result_type; |
| 2218 | } |
| 2219 | break; |
| 2220 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2221 | case Primitive::kPrimFloat: |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2222 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2223 | case Primitive::kPrimBoolean: |
| 2224 | // Boolean input is a result of code transformations. |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2225 | case Primitive::kPrimByte: |
| 2226 | case Primitive::kPrimShort: |
| 2227 | case Primitive::kPrimInt: |
| 2228 | case Primitive::kPrimChar: { |
| 2229 | // Processing a Dex `int-to-float' instruction. |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2230 | __ vmovsr(out.AsFpuRegister<SRegister>(), in.AsRegister<Register>()); |
| 2231 | __ vcvtsi(out.AsFpuRegister<SRegister>(), out.AsFpuRegister<SRegister>()); |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2232 | break; |
| 2233 | } |
| 2234 | |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 2235 | case Primitive::kPrimLong: |
Roland Levillain | 6d0e483 | 2014-11-27 18:31:21 +0000 | [diff] [blame] | 2236 | // Processing a Dex `long-to-float' instruction. |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 2237 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pL2f), |
| 2238 | conversion, |
| 2239 | conversion->GetDexPc(), |
| 2240 | nullptr); |
Roland Levillain | 6d0e483 | 2014-11-27 18:31:21 +0000 | [diff] [blame] | 2241 | break; |
Roland Levillain | 6d0e483 | 2014-11-27 18:31:21 +0000 | [diff] [blame] | 2242 | |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2243 | case Primitive::kPrimDouble: |
Roland Levillain | 8964e2b | 2014-12-04 12:10:50 +0000 | [diff] [blame] | 2244 | // Processing a Dex `double-to-float' instruction. |
| 2245 | __ vcvtsd(out.AsFpuRegister<SRegister>(), |
| 2246 | FromLowSToD(in.AsFpuRegisterPairLow<SRegister>())); |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2247 | break; |
| 2248 | |
| 2249 | default: |
| 2250 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2251 | << " to " << result_type; |
| 2252 | }; |
| 2253 | break; |
| 2254 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2255 | case Primitive::kPrimDouble: |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2256 | switch (input_type) { |
David Brazdil | 46e2a39 | 2015-03-16 17:31:52 +0000 | [diff] [blame] | 2257 | case Primitive::kPrimBoolean: |
| 2258 | // Boolean input is a result of code transformations. |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2259 | case Primitive::kPrimByte: |
| 2260 | case Primitive::kPrimShort: |
| 2261 | case Primitive::kPrimInt: |
| 2262 | case Primitive::kPrimChar: { |
| 2263 | // Processing a Dex `int-to-double' instruction. |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2264 | __ vmovsr(out.AsFpuRegisterPairLow<SRegister>(), in.AsRegister<Register>()); |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2265 | __ vcvtdi(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), |
| 2266 | out.AsFpuRegisterPairLow<SRegister>()); |
| 2267 | break; |
| 2268 | } |
| 2269 | |
Roland Levillain | 647b9ed | 2014-11-27 12:06:00 +0000 | [diff] [blame] | 2270 | case Primitive::kPrimLong: { |
| 2271 | // Processing a Dex `long-to-double' instruction. |
| 2272 | Register low = in.AsRegisterPairLow<Register>(); |
| 2273 | Register high = in.AsRegisterPairHigh<Register>(); |
| 2274 | SRegister out_s = out.AsFpuRegisterPairLow<SRegister>(); |
| 2275 | DRegister out_d = FromLowSToD(out_s); |
Roland Levillain | 682393c | 2015-04-14 15:57:52 +0100 | [diff] [blame] | 2276 | SRegister temp_s = locations->GetTemp(0).AsFpuRegisterPairLow<SRegister>(); |
Roland Levillain | 647b9ed | 2014-11-27 12:06:00 +0000 | [diff] [blame] | 2277 | DRegister temp_d = FromLowSToD(temp_s); |
Roland Levillain | 682393c | 2015-04-14 15:57:52 +0100 | [diff] [blame] | 2278 | SRegister constant_s = locations->GetTemp(1).AsFpuRegisterPairLow<SRegister>(); |
| 2279 | DRegister constant_d = FromLowSToD(constant_s); |
Roland Levillain | 647b9ed | 2014-11-27 12:06:00 +0000 | [diff] [blame] | 2280 | |
Roland Levillain | 682393c | 2015-04-14 15:57:52 +0100 | [diff] [blame] | 2281 | // temp_d = int-to-double(high) |
| 2282 | __ vmovsr(temp_s, high); |
| 2283 | __ vcvtdi(temp_d, temp_s); |
| 2284 | // constant_d = k2Pow32EncodingForDouble |
| 2285 | __ LoadDImmediate(constant_d, bit_cast<double, int64_t>(k2Pow32EncodingForDouble)); |
| 2286 | // out_d = unsigned-to-double(low) |
| 2287 | __ vmovsr(out_s, low); |
| 2288 | __ vcvtdu(out_d, out_s); |
| 2289 | // out_d += temp_d * constant_d |
| 2290 | __ vmlad(out_d, temp_d, constant_d); |
Roland Levillain | 647b9ed | 2014-11-27 12:06:00 +0000 | [diff] [blame] | 2291 | break; |
| 2292 | } |
| 2293 | |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2294 | case Primitive::kPrimFloat: |
Roland Levillain | 8964e2b | 2014-12-04 12:10:50 +0000 | [diff] [blame] | 2295 | // Processing a Dex `float-to-double' instruction. |
| 2296 | __ vcvtds(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), |
| 2297 | in.AsFpuRegister<SRegister>()); |
Roland Levillain | cff1374 | 2014-11-17 14:32:17 +0000 | [diff] [blame] | 2298 | break; |
| 2299 | |
| 2300 | default: |
| 2301 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2302 | << " to " << result_type; |
| 2303 | }; |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 2304 | break; |
| 2305 | |
| 2306 | default: |
| 2307 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 2308 | << " to " << result_type; |
| 2309 | } |
| 2310 | } |
| 2311 | |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2312 | void LocationsBuilderARM::VisitAdd(HAdd* add) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 2313 | LocationSummary* locations = |
| 2314 | new (GetGraph()->GetArena()) LocationSummary(add, LocationSummary::kNoCall); |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2315 | switch (add->GetResultType()) { |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2316 | case Primitive::kPrimInt: { |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 2317 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2318 | locations->SetInAt(1, Location::RegisterOrConstant(add->InputAt(1))); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2319 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2320 | break; |
| 2321 | } |
| 2322 | |
| 2323 | case Primitive::kPrimLong: { |
| 2324 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2325 | locations->SetInAt(1, Location::RequiresRegister()); |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 2326 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2327 | break; |
| 2328 | } |
| 2329 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 2330 | case Primitive::kPrimFloat: |
| 2331 | case Primitive::kPrimDouble: { |
| 2332 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 2333 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2334 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2335 | break; |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 2336 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2337 | |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2338 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 2339 | LOG(FATAL) << "Unexpected add type " << add->GetResultType(); |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2340 | } |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2341 | } |
| 2342 | |
| 2343 | void InstructionCodeGeneratorARM::VisitAdd(HAdd* add) { |
| 2344 | LocationSummary* locations = add->GetLocations(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2345 | Location out = locations->Out(); |
| 2346 | Location first = locations->InAt(0); |
| 2347 | Location second = locations->InAt(1); |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2348 | switch (add->GetResultType()) { |
| 2349 | case Primitive::kPrimInt: |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2350 | if (second.IsRegister()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 2351 | __ add(out.AsRegister<Register>(), |
| 2352 | first.AsRegister<Register>(), |
| 2353 | ShifterOperand(second.AsRegister<Register>())); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2354 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2355 | __ AddConstant(out.AsRegister<Register>(), |
| 2356 | first.AsRegister<Register>(), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2357 | second.GetConstant()->AsIntConstant()->GetValue()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2358 | } |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2359 | break; |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2360 | |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2361 | case Primitive::kPrimLong: { |
| 2362 | DCHECK(second.IsRegisterPair()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2363 | __ adds(out.AsRegisterPairLow<Register>(), |
| 2364 | first.AsRegisterPairLow<Register>(), |
| 2365 | ShifterOperand(second.AsRegisterPairLow<Register>())); |
| 2366 | __ adc(out.AsRegisterPairHigh<Register>(), |
| 2367 | first.AsRegisterPairHigh<Register>(), |
| 2368 | ShifterOperand(second.AsRegisterPairHigh<Register>())); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2369 | break; |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2370 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2371 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 2372 | case Primitive::kPrimFloat: |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 2373 | __ vadds(out.AsFpuRegister<SRegister>(), |
| 2374 | first.AsFpuRegister<SRegister>(), |
| 2375 | second.AsFpuRegister<SRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 2376 | break; |
| 2377 | |
| 2378 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 2379 | __ vaddd(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), |
| 2380 | FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()), |
| 2381 | FromLowSToD(second.AsFpuRegisterPairLow<SRegister>())); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2382 | break; |
| 2383 | |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2384 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 2385 | LOG(FATAL) << "Unexpected add type " << add->GetResultType(); |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 2386 | } |
| 2387 | } |
| 2388 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2389 | void LocationsBuilderARM::VisitSub(HSub* sub) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 2390 | LocationSummary* locations = |
| 2391 | new (GetGraph()->GetArena()) LocationSummary(sub, LocationSummary::kNoCall); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2392 | switch (sub->GetResultType()) { |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2393 | case Primitive::kPrimInt: { |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 2394 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2395 | locations->SetInAt(1, Location::RegisterOrConstant(sub->InputAt(1))); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2396 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2397 | break; |
| 2398 | } |
| 2399 | |
| 2400 | case Primitive::kPrimLong: { |
| 2401 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2402 | locations->SetInAt(1, Location::RequiresRegister()); |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 2403 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2404 | break; |
| 2405 | } |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2406 | case Primitive::kPrimFloat: |
| 2407 | case Primitive::kPrimDouble: { |
| 2408 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 2409 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2410 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2411 | break; |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2412 | } |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2413 | default: |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2414 | LOG(FATAL) << "Unexpected sub type " << sub->GetResultType(); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2415 | } |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2416 | } |
| 2417 | |
| 2418 | void InstructionCodeGeneratorARM::VisitSub(HSub* sub) { |
| 2419 | LocationSummary* locations = sub->GetLocations(); |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2420 | Location out = locations->Out(); |
| 2421 | Location first = locations->InAt(0); |
| 2422 | Location second = locations->InAt(1); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2423 | switch (sub->GetResultType()) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2424 | case Primitive::kPrimInt: { |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2425 | if (second.IsRegister()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 2426 | __ sub(out.AsRegister<Register>(), |
| 2427 | first.AsRegister<Register>(), |
| 2428 | ShifterOperand(second.AsRegister<Register>())); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2429 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 2430 | __ AddConstant(out.AsRegister<Register>(), |
| 2431 | first.AsRegister<Register>(), |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2432 | -second.GetConstant()->AsIntConstant()->GetValue()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2433 | } |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2434 | break; |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2435 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2436 | |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2437 | case Primitive::kPrimLong: { |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2438 | DCHECK(second.IsRegisterPair()); |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2439 | __ subs(out.AsRegisterPairLow<Register>(), |
| 2440 | first.AsRegisterPairLow<Register>(), |
| 2441 | ShifterOperand(second.AsRegisterPairLow<Register>())); |
| 2442 | __ sbc(out.AsRegisterPairHigh<Register>(), |
| 2443 | first.AsRegisterPairHigh<Register>(), |
| 2444 | ShifterOperand(second.AsRegisterPairHigh<Register>())); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2445 | break; |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2446 | } |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2447 | |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2448 | case Primitive::kPrimFloat: { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 2449 | __ vsubs(out.AsFpuRegister<SRegister>(), |
| 2450 | first.AsFpuRegister<SRegister>(), |
| 2451 | second.AsFpuRegister<SRegister>()); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2452 | break; |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2453 | } |
| 2454 | |
| 2455 | case Primitive::kPrimDouble: { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 2456 | __ vsubd(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), |
| 2457 | FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()), |
| 2458 | FromLowSToD(second.AsFpuRegisterPairLow<SRegister>())); |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2459 | break; |
| 2460 | } |
| 2461 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 2462 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2463 | default: |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 2464 | LOG(FATAL) << "Unexpected sub type " << sub->GetResultType(); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 2465 | } |
| 2466 | } |
| 2467 | |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2468 | void LocationsBuilderARM::VisitMul(HMul* mul) { |
| 2469 | LocationSummary* locations = |
| 2470 | new (GetGraph()->GetArena()) LocationSummary(mul, LocationSummary::kNoCall); |
| 2471 | switch (mul->GetResultType()) { |
| 2472 | case Primitive::kPrimInt: |
| 2473 | case Primitive::kPrimLong: { |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 2474 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2475 | locations->SetInAt(1, Location::RequiresRegister()); |
| 2476 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2477 | break; |
| 2478 | } |
| 2479 | |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 2480 | case Primitive::kPrimFloat: |
| 2481 | case Primitive::kPrimDouble: { |
| 2482 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 2483 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2484 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2485 | break; |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 2486 | } |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2487 | |
| 2488 | default: |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 2489 | LOG(FATAL) << "Unexpected mul type " << mul->GetResultType(); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2490 | } |
| 2491 | } |
| 2492 | |
| 2493 | void InstructionCodeGeneratorARM::VisitMul(HMul* mul) { |
| 2494 | LocationSummary* locations = mul->GetLocations(); |
| 2495 | Location out = locations->Out(); |
| 2496 | Location first = locations->InAt(0); |
| 2497 | Location second = locations->InAt(1); |
| 2498 | switch (mul->GetResultType()) { |
| 2499 | case Primitive::kPrimInt: { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 2500 | __ mul(out.AsRegister<Register>(), |
| 2501 | first.AsRegister<Register>(), |
| 2502 | second.AsRegister<Register>()); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2503 | break; |
| 2504 | } |
| 2505 | case Primitive::kPrimLong: { |
| 2506 | Register out_hi = out.AsRegisterPairHigh<Register>(); |
| 2507 | Register out_lo = out.AsRegisterPairLow<Register>(); |
| 2508 | Register in1_hi = first.AsRegisterPairHigh<Register>(); |
| 2509 | Register in1_lo = first.AsRegisterPairLow<Register>(); |
| 2510 | Register in2_hi = second.AsRegisterPairHigh<Register>(); |
| 2511 | Register in2_lo = second.AsRegisterPairLow<Register>(); |
| 2512 | |
| 2513 | // Extra checks to protect caused by the existence of R1_R2. |
| 2514 | // The algorithm is wrong if out.hi is either in1.lo or in2.lo: |
| 2515 | // (e.g. in1=r0_r1, in2=r2_r3 and out=r1_r2); |
| 2516 | DCHECK_NE(out_hi, in1_lo); |
| 2517 | DCHECK_NE(out_hi, in2_lo); |
| 2518 | |
| 2519 | // input: in1 - 64 bits, in2 - 64 bits |
| 2520 | // output: out |
| 2521 | // formula: out.hi : out.lo = (in1.lo * in2.hi + in1.hi * in2.lo)* 2^32 + in1.lo * in2.lo |
| 2522 | // parts: out.hi = in1.lo * in2.hi + in1.hi * in2.lo + (in1.lo * in2.lo)[63:32] |
| 2523 | // parts: out.lo = (in1.lo * in2.lo)[31:0] |
| 2524 | |
| 2525 | // IP <- in1.lo * in2.hi |
| 2526 | __ mul(IP, in1_lo, in2_hi); |
| 2527 | // out.hi <- in1.lo * in2.hi + in1.hi * in2.lo |
| 2528 | __ mla(out_hi, in1_hi, in2_lo, IP); |
| 2529 | // out.lo <- (in1.lo * in2.lo)[31:0]; |
| 2530 | __ umull(out_lo, IP, in1_lo, in2_lo); |
| 2531 | // out.hi <- in2.hi * in1.lo + in2.lo * in1.hi + (in1.lo * in2.lo)[63:32] |
| 2532 | __ add(out_hi, out_hi, ShifterOperand(IP)); |
| 2533 | break; |
| 2534 | } |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 2535 | |
| 2536 | case Primitive::kPrimFloat: { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 2537 | __ vmuls(out.AsFpuRegister<SRegister>(), |
| 2538 | first.AsFpuRegister<SRegister>(), |
| 2539 | second.AsFpuRegister<SRegister>()); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2540 | break; |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 2541 | } |
| 2542 | |
| 2543 | case Primitive::kPrimDouble: { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 2544 | __ vmuld(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), |
| 2545 | FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()), |
| 2546 | FromLowSToD(second.AsFpuRegisterPairLow<SRegister>())); |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 2547 | break; |
| 2548 | } |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2549 | |
| 2550 | default: |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 2551 | LOG(FATAL) << "Unexpected mul type " << mul->GetResultType(); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 2552 | } |
| 2553 | } |
| 2554 | |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2555 | void InstructionCodeGeneratorARM::DivRemOneOrMinusOne(HBinaryOperation* instruction) { |
| 2556 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 2557 | DCHECK(instruction->GetResultType() == Primitive::kPrimInt); |
| 2558 | |
| 2559 | LocationSummary* locations = instruction->GetLocations(); |
| 2560 | Location second = locations->InAt(1); |
| 2561 | DCHECK(second.IsConstant()); |
| 2562 | |
| 2563 | Register out = locations->Out().AsRegister<Register>(); |
| 2564 | Register dividend = locations->InAt(0).AsRegister<Register>(); |
| 2565 | int32_t imm = second.GetConstant()->AsIntConstant()->GetValue(); |
| 2566 | DCHECK(imm == 1 || imm == -1); |
| 2567 | |
| 2568 | if (instruction->IsRem()) { |
| 2569 | __ LoadImmediate(out, 0); |
| 2570 | } else { |
| 2571 | if (imm == 1) { |
| 2572 | __ Mov(out, dividend); |
| 2573 | } else { |
| 2574 | __ rsb(out, dividend, ShifterOperand(0)); |
| 2575 | } |
| 2576 | } |
| 2577 | } |
| 2578 | |
| 2579 | void InstructionCodeGeneratorARM::DivRemByPowerOfTwo(HBinaryOperation* instruction) { |
| 2580 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 2581 | DCHECK(instruction->GetResultType() == Primitive::kPrimInt); |
| 2582 | |
| 2583 | LocationSummary* locations = instruction->GetLocations(); |
| 2584 | Location second = locations->InAt(1); |
| 2585 | DCHECK(second.IsConstant()); |
| 2586 | |
| 2587 | Register out = locations->Out().AsRegister<Register>(); |
| 2588 | Register dividend = locations->InAt(0).AsRegister<Register>(); |
| 2589 | Register temp = locations->GetTemp(0).AsRegister<Register>(); |
| 2590 | int32_t imm = second.GetConstant()->AsIntConstant()->GetValue(); |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame] | 2591 | uint32_t abs_imm = static_cast<uint32_t>(std::abs(imm)); |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2592 | DCHECK(IsPowerOfTwo(abs_imm)); |
| 2593 | int ctz_imm = CTZ(abs_imm); |
| 2594 | |
| 2595 | if (ctz_imm == 1) { |
| 2596 | __ Lsr(temp, dividend, 32 - ctz_imm); |
| 2597 | } else { |
| 2598 | __ Asr(temp, dividend, 31); |
| 2599 | __ Lsr(temp, temp, 32 - ctz_imm); |
| 2600 | } |
| 2601 | __ add(out, temp, ShifterOperand(dividend)); |
| 2602 | |
| 2603 | if (instruction->IsDiv()) { |
| 2604 | __ Asr(out, out, ctz_imm); |
| 2605 | if (imm < 0) { |
| 2606 | __ rsb(out, out, ShifterOperand(0)); |
| 2607 | } |
| 2608 | } else { |
| 2609 | __ ubfx(out, out, 0, ctz_imm); |
| 2610 | __ sub(out, out, ShifterOperand(temp)); |
| 2611 | } |
| 2612 | } |
| 2613 | |
| 2614 | void InstructionCodeGeneratorARM::GenerateDivRemWithAnyConstant(HBinaryOperation* instruction) { |
| 2615 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 2616 | DCHECK(instruction->GetResultType() == Primitive::kPrimInt); |
| 2617 | |
| 2618 | LocationSummary* locations = instruction->GetLocations(); |
| 2619 | Location second = locations->InAt(1); |
| 2620 | DCHECK(second.IsConstant()); |
| 2621 | |
| 2622 | Register out = locations->Out().AsRegister<Register>(); |
| 2623 | Register dividend = locations->InAt(0).AsRegister<Register>(); |
| 2624 | Register temp1 = locations->GetTemp(0).AsRegister<Register>(); |
| 2625 | Register temp2 = locations->GetTemp(1).AsRegister<Register>(); |
| 2626 | int64_t imm = second.GetConstant()->AsIntConstant()->GetValue(); |
| 2627 | |
| 2628 | int64_t magic; |
| 2629 | int shift; |
| 2630 | CalculateMagicAndShiftForDivRem(imm, false /* is_long */, &magic, &shift); |
| 2631 | |
| 2632 | __ LoadImmediate(temp1, magic); |
| 2633 | __ smull(temp2, temp1, dividend, temp1); |
| 2634 | |
| 2635 | if (imm > 0 && magic < 0) { |
| 2636 | __ add(temp1, temp1, ShifterOperand(dividend)); |
| 2637 | } else if (imm < 0 && magic > 0) { |
| 2638 | __ sub(temp1, temp1, ShifterOperand(dividend)); |
| 2639 | } |
| 2640 | |
| 2641 | if (shift != 0) { |
| 2642 | __ Asr(temp1, temp1, shift); |
| 2643 | } |
| 2644 | |
| 2645 | if (instruction->IsDiv()) { |
| 2646 | __ sub(out, temp1, ShifterOperand(temp1, ASR, 31)); |
| 2647 | } else { |
| 2648 | __ sub(temp1, temp1, ShifterOperand(temp1, ASR, 31)); |
| 2649 | // TODO: Strength reduction for mls. |
| 2650 | __ LoadImmediate(temp2, imm); |
| 2651 | __ mls(out, temp1, temp2, dividend); |
| 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | void InstructionCodeGeneratorARM::GenerateDivRemConstantIntegral(HBinaryOperation* instruction) { |
| 2656 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 2657 | DCHECK(instruction->GetResultType() == Primitive::kPrimInt); |
| 2658 | |
| 2659 | LocationSummary* locations = instruction->GetLocations(); |
| 2660 | Location second = locations->InAt(1); |
| 2661 | DCHECK(second.IsConstant()); |
| 2662 | |
| 2663 | int32_t imm = second.GetConstant()->AsIntConstant()->GetValue(); |
| 2664 | if (imm == 0) { |
| 2665 | // Do not generate anything. DivZeroCheck would prevent any code to be executed. |
| 2666 | } else if (imm == 1 || imm == -1) { |
| 2667 | DivRemOneOrMinusOne(instruction); |
| 2668 | } else if (IsPowerOfTwo(std::abs(imm))) { |
| 2669 | DivRemByPowerOfTwo(instruction); |
| 2670 | } else { |
| 2671 | DCHECK(imm <= -2 || imm >= 2); |
| 2672 | GenerateDivRemWithAnyConstant(instruction); |
| 2673 | } |
| 2674 | } |
| 2675 | |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2676 | void LocationsBuilderARM::VisitDiv(HDiv* div) { |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2677 | LocationSummary::CallKind call_kind = LocationSummary::kNoCall; |
| 2678 | if (div->GetResultType() == Primitive::kPrimLong) { |
| 2679 | // pLdiv runtime call. |
| 2680 | call_kind = LocationSummary::kCall; |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2681 | } else if (div->GetResultType() == Primitive::kPrimInt && div->InputAt(1)->IsConstant()) { |
| 2682 | // sdiv will be replaced by other instruction sequence. |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2683 | } else if (div->GetResultType() == Primitive::kPrimInt && |
| 2684 | !codegen_->GetInstructionSetFeatures().HasDivideInstruction()) { |
| 2685 | // pIdivmod runtime call. |
| 2686 | call_kind = LocationSummary::kCall; |
| 2687 | } |
| 2688 | |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2689 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(div, call_kind); |
| 2690 | |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2691 | switch (div->GetResultType()) { |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2692 | case Primitive::kPrimInt: { |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2693 | if (div->InputAt(1)->IsConstant()) { |
| 2694 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2695 | locations->SetInAt(1, Location::RegisterOrConstant(div->InputAt(1))); |
| 2696 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2697 | int32_t abs_imm = std::abs(div->InputAt(1)->AsIntConstant()->GetValue()); |
| 2698 | if (abs_imm <= 1) { |
| 2699 | // No temp register required. |
| 2700 | } else { |
| 2701 | locations->AddTemp(Location::RequiresRegister()); |
| 2702 | if (!IsPowerOfTwo(abs_imm)) { |
| 2703 | locations->AddTemp(Location::RequiresRegister()); |
| 2704 | } |
| 2705 | } |
| 2706 | } else if (codegen_->GetInstructionSetFeatures().HasDivideInstruction()) { |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2707 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2708 | locations->SetInAt(1, Location::RequiresRegister()); |
| 2709 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2710 | } else { |
| 2711 | InvokeRuntimeCallingConvention calling_convention; |
| 2712 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 2713 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 2714 | // Note: divrem will compute both the quotient and the remainder as the pair R0 and R1, but |
| 2715 | // we only need the former. |
| 2716 | locations->SetOut(Location::RegisterLocation(R0)); |
| 2717 | } |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2718 | break; |
| 2719 | } |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2720 | case Primitive::kPrimLong: { |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2721 | InvokeRuntimeCallingConvention calling_convention; |
| 2722 | locations->SetInAt(0, Location::RegisterPairLocation( |
| 2723 | calling_convention.GetRegisterAt(0), calling_convention.GetRegisterAt(1))); |
| 2724 | locations->SetInAt(1, Location::RegisterPairLocation( |
| 2725 | calling_convention.GetRegisterAt(2), calling_convention.GetRegisterAt(3))); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2726 | locations->SetOut(Location::RegisterPairLocation(R0, R1)); |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2727 | break; |
| 2728 | } |
| 2729 | case Primitive::kPrimFloat: |
| 2730 | case Primitive::kPrimDouble: { |
| 2731 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 2732 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 2733 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 2734 | break; |
| 2735 | } |
| 2736 | |
| 2737 | default: |
| 2738 | LOG(FATAL) << "Unexpected div type " << div->GetResultType(); |
| 2739 | } |
| 2740 | } |
| 2741 | |
| 2742 | void InstructionCodeGeneratorARM::VisitDiv(HDiv* div) { |
| 2743 | LocationSummary* locations = div->GetLocations(); |
| 2744 | Location out = locations->Out(); |
| 2745 | Location first = locations->InAt(0); |
| 2746 | Location second = locations->InAt(1); |
| 2747 | |
| 2748 | switch (div->GetResultType()) { |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2749 | case Primitive::kPrimInt: { |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2750 | if (second.IsConstant()) { |
| 2751 | GenerateDivRemConstantIntegral(div); |
| 2752 | } else if (codegen_->GetInstructionSetFeatures().HasDivideInstruction()) { |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2753 | __ sdiv(out.AsRegister<Register>(), |
| 2754 | first.AsRegister<Register>(), |
| 2755 | second.AsRegister<Register>()); |
| 2756 | } else { |
| 2757 | InvokeRuntimeCallingConvention calling_convention; |
| 2758 | DCHECK_EQ(calling_convention.GetRegisterAt(0), first.AsRegister<Register>()); |
| 2759 | DCHECK_EQ(calling_convention.GetRegisterAt(1), second.AsRegister<Register>()); |
| 2760 | DCHECK_EQ(R0, out.AsRegister<Register>()); |
| 2761 | |
| 2762 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pIdivmod), div, div->GetDexPc(), nullptr); |
| 2763 | } |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2764 | break; |
| 2765 | } |
| 2766 | |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2767 | case Primitive::kPrimLong: { |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2768 | InvokeRuntimeCallingConvention calling_convention; |
| 2769 | DCHECK_EQ(calling_convention.GetRegisterAt(0), first.AsRegisterPairLow<Register>()); |
| 2770 | DCHECK_EQ(calling_convention.GetRegisterAt(1), first.AsRegisterPairHigh<Register>()); |
| 2771 | DCHECK_EQ(calling_convention.GetRegisterAt(2), second.AsRegisterPairLow<Register>()); |
| 2772 | DCHECK_EQ(calling_convention.GetRegisterAt(3), second.AsRegisterPairHigh<Register>()); |
| 2773 | DCHECK_EQ(R0, out.AsRegisterPairLow<Register>()); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 2774 | DCHECK_EQ(R1, out.AsRegisterPairHigh<Register>()); |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2775 | |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 2776 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pLdiv), div, div->GetDexPc(), nullptr); |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2777 | break; |
| 2778 | } |
| 2779 | |
| 2780 | case Primitive::kPrimFloat: { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 2781 | __ vdivs(out.AsFpuRegister<SRegister>(), |
| 2782 | first.AsFpuRegister<SRegister>(), |
| 2783 | second.AsFpuRegister<SRegister>()); |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 2784 | break; |
| 2785 | } |
| 2786 | |
| 2787 | case Primitive::kPrimDouble: { |
| 2788 | __ vdivd(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), |
| 2789 | FromLowSToD(first.AsFpuRegisterPairLow<SRegister>()), |
| 2790 | FromLowSToD(second.AsFpuRegisterPairLow<SRegister>())); |
| 2791 | break; |
| 2792 | } |
| 2793 | |
| 2794 | default: |
| 2795 | LOG(FATAL) << "Unexpected div type " << div->GetResultType(); |
| 2796 | } |
| 2797 | } |
| 2798 | |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2799 | void LocationsBuilderARM::VisitRem(HRem* rem) { |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2800 | Primitive::Type type = rem->GetResultType(); |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2801 | |
| 2802 | // Most remainders are implemented in the runtime. |
| 2803 | LocationSummary::CallKind call_kind = LocationSummary::kCall; |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2804 | if (rem->GetResultType() == Primitive::kPrimInt && rem->InputAt(1)->IsConstant()) { |
| 2805 | // sdiv will be replaced by other instruction sequence. |
| 2806 | call_kind = LocationSummary::kNoCall; |
| 2807 | } else if ((rem->GetResultType() == Primitive::kPrimInt) |
| 2808 | && codegen_->GetInstructionSetFeatures().HasDivideInstruction()) { |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2809 | // Have hardware divide instruction for int, do it with three instructions. |
| 2810 | call_kind = LocationSummary::kNoCall; |
| 2811 | } |
| 2812 | |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2813 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(rem, call_kind); |
| 2814 | |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2815 | switch (type) { |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2816 | case Primitive::kPrimInt: { |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2817 | if (rem->InputAt(1)->IsConstant()) { |
| 2818 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2819 | locations->SetInAt(1, Location::RegisterOrConstant(rem->InputAt(1))); |
| 2820 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2821 | int32_t abs_imm = std::abs(rem->InputAt(1)->AsIntConstant()->GetValue()); |
| 2822 | if (abs_imm <= 1) { |
| 2823 | // No temp register required. |
| 2824 | } else { |
| 2825 | locations->AddTemp(Location::RequiresRegister()); |
| 2826 | if (!IsPowerOfTwo(abs_imm)) { |
| 2827 | locations->AddTemp(Location::RequiresRegister()); |
| 2828 | } |
| 2829 | } |
| 2830 | } else if (codegen_->GetInstructionSetFeatures().HasDivideInstruction()) { |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2831 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2832 | locations->SetInAt(1, Location::RequiresRegister()); |
| 2833 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2834 | locations->AddTemp(Location::RequiresRegister()); |
| 2835 | } else { |
| 2836 | InvokeRuntimeCallingConvention calling_convention; |
| 2837 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 2838 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 2839 | // Note: divrem will compute both the quotient and the remainder as the pair R0 and R1, but |
| 2840 | // we only need the latter. |
| 2841 | locations->SetOut(Location::RegisterLocation(R1)); |
| 2842 | } |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2843 | break; |
| 2844 | } |
| 2845 | case Primitive::kPrimLong: { |
| 2846 | InvokeRuntimeCallingConvention calling_convention; |
| 2847 | locations->SetInAt(0, Location::RegisterPairLocation( |
| 2848 | calling_convention.GetRegisterAt(0), calling_convention.GetRegisterAt(1))); |
| 2849 | locations->SetInAt(1, Location::RegisterPairLocation( |
| 2850 | calling_convention.GetRegisterAt(2), calling_convention.GetRegisterAt(3))); |
| 2851 | // The runtime helper puts the output in R2,R3. |
| 2852 | locations->SetOut(Location::RegisterPairLocation(R2, R3)); |
| 2853 | break; |
| 2854 | } |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2855 | case Primitive::kPrimFloat: { |
| 2856 | InvokeRuntimeCallingConvention calling_convention; |
| 2857 | locations->SetInAt(0, Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(0))); |
| 2858 | locations->SetInAt(1, Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(1))); |
| 2859 | locations->SetOut(Location::FpuRegisterLocation(S0)); |
| 2860 | break; |
| 2861 | } |
| 2862 | |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2863 | case Primitive::kPrimDouble: { |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2864 | InvokeRuntimeCallingConvention calling_convention; |
| 2865 | locations->SetInAt(0, Location::FpuRegisterPairLocation( |
| 2866 | calling_convention.GetFpuRegisterAt(0), calling_convention.GetFpuRegisterAt(1))); |
| 2867 | locations->SetInAt(1, Location::FpuRegisterPairLocation( |
| 2868 | calling_convention.GetFpuRegisterAt(2), calling_convention.GetFpuRegisterAt(3))); |
| 2869 | locations->SetOut(Location::Location::FpuRegisterPairLocation(S0, S1)); |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2870 | break; |
| 2871 | } |
| 2872 | |
| 2873 | default: |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2874 | LOG(FATAL) << "Unexpected rem type " << type; |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2875 | } |
| 2876 | } |
| 2877 | |
| 2878 | void InstructionCodeGeneratorARM::VisitRem(HRem* rem) { |
| 2879 | LocationSummary* locations = rem->GetLocations(); |
| 2880 | Location out = locations->Out(); |
| 2881 | Location first = locations->InAt(0); |
| 2882 | Location second = locations->InAt(1); |
| 2883 | |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2884 | Primitive::Type type = rem->GetResultType(); |
| 2885 | switch (type) { |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2886 | case Primitive::kPrimInt: { |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 2887 | if (second.IsConstant()) { |
| 2888 | GenerateDivRemConstantIntegral(rem); |
| 2889 | } else if (codegen_->GetInstructionSetFeatures().HasDivideInstruction()) { |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2890 | Register reg1 = first.AsRegister<Register>(); |
| 2891 | Register reg2 = second.AsRegister<Register>(); |
| 2892 | Register temp = locations->GetTemp(0).AsRegister<Register>(); |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2893 | |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2894 | // temp = reg1 / reg2 (integer division) |
Vladimir Marko | 73cf0fb | 2015-07-30 15:07:22 +0100 | [diff] [blame] | 2895 | // dest = reg1 - temp * reg2 |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2896 | __ sdiv(temp, reg1, reg2); |
Vladimir Marko | 73cf0fb | 2015-07-30 15:07:22 +0100 | [diff] [blame] | 2897 | __ mls(out.AsRegister<Register>(), temp, reg2, reg1); |
Andreas Gampe | b51cdb3 | 2015-03-29 17:32:48 -0700 | [diff] [blame] | 2898 | } else { |
| 2899 | InvokeRuntimeCallingConvention calling_convention; |
| 2900 | DCHECK_EQ(calling_convention.GetRegisterAt(0), first.AsRegister<Register>()); |
| 2901 | DCHECK_EQ(calling_convention.GetRegisterAt(1), second.AsRegister<Register>()); |
| 2902 | DCHECK_EQ(R1, out.AsRegister<Register>()); |
| 2903 | |
| 2904 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pIdivmod), rem, rem->GetDexPc(), nullptr); |
| 2905 | } |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2906 | break; |
| 2907 | } |
| 2908 | |
| 2909 | case Primitive::kPrimLong: { |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 2910 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pLmod), rem, rem->GetDexPc(), nullptr); |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2911 | break; |
| 2912 | } |
| 2913 | |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2914 | case Primitive::kPrimFloat: { |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 2915 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pFmodf), rem, rem->GetDexPc(), nullptr); |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2916 | break; |
| 2917 | } |
| 2918 | |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2919 | case Primitive::kPrimDouble: { |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 2920 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pFmod), rem, rem->GetDexPc(), nullptr); |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2921 | break; |
| 2922 | } |
| 2923 | |
| 2924 | default: |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 2925 | LOG(FATAL) << "Unexpected rem type " << type; |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 2926 | } |
| 2927 | } |
| 2928 | |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2929 | void LocationsBuilderARM::VisitDivZeroCheck(HDivZeroCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 2930 | LocationSummary::CallKind call_kind = instruction->CanThrowIntoCatchBlock() |
| 2931 | ? LocationSummary::kCallOnSlowPath |
| 2932 | : LocationSummary::kNoCall; |
| 2933 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2934 | locations->SetInAt(0, Location::RegisterOrConstant(instruction->InputAt(0))); |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2935 | if (instruction->HasUses()) { |
| 2936 | locations->SetOut(Location::SameAsFirstInput()); |
| 2937 | } |
| 2938 | } |
| 2939 | |
| 2940 | void InstructionCodeGeneratorARM::VisitDivZeroCheck(HDivZeroCheck* instruction) { |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 2941 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) DivZeroCheckSlowPathARM(instruction); |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2942 | codegen_->AddSlowPath(slow_path); |
| 2943 | |
| 2944 | LocationSummary* locations = instruction->GetLocations(); |
| 2945 | Location value = locations->InAt(0); |
| 2946 | |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2947 | switch (instruction->GetType()) { |
Serguei Katkov | 8c0676c | 2015-08-03 13:55:33 +0600 | [diff] [blame] | 2948 | case Primitive::kPrimByte: |
| 2949 | case Primitive::kPrimChar: |
| 2950 | case Primitive::kPrimShort: |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2951 | case Primitive::kPrimInt: { |
| 2952 | if (value.IsRegister()) { |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 2953 | __ CompareAndBranchIfZero(value.AsRegister<Register>(), slow_path->GetEntryLabel()); |
Calin Juravle | d6fb6cf | 2014-11-11 19:07:44 +0000 | [diff] [blame] | 2954 | } else { |
| 2955 | DCHECK(value.IsConstant()) << value; |
| 2956 | if (value.GetConstant()->AsIntConstant()->GetValue() == 0) { |
| 2957 | __ b(slow_path->GetEntryLabel()); |
| 2958 | } |
| 2959 | } |
| 2960 | break; |
| 2961 | } |
| 2962 | case Primitive::kPrimLong: { |
| 2963 | if (value.IsRegisterPair()) { |
| 2964 | __ orrs(IP, |
| 2965 | value.AsRegisterPairLow<Register>(), |
| 2966 | ShifterOperand(value.AsRegisterPairHigh<Register>())); |
| 2967 | __ b(slow_path->GetEntryLabel(), EQ); |
| 2968 | } else { |
| 2969 | DCHECK(value.IsConstant()) << value; |
| 2970 | if (value.GetConstant()->AsLongConstant()->GetValue() == 0) { |
| 2971 | __ b(slow_path->GetEntryLabel()); |
| 2972 | } |
| 2973 | } |
| 2974 | break; |
| 2975 | default: |
| 2976 | LOG(FATAL) << "Unexpected type for HDivZeroCheck " << instruction->GetType(); |
| 2977 | } |
| 2978 | } |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 2979 | } |
| 2980 | |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 2981 | void LocationsBuilderARM::HandleShift(HBinaryOperation* op) { |
| 2982 | DCHECK(op->IsShl() || op->IsShr() || op->IsUShr()); |
| 2983 | |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 2984 | LocationSummary* locations = |
| 2985 | new (GetGraph()->GetArena()) LocationSummary(op, LocationSummary::kNoCall); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 2986 | |
| 2987 | switch (op->GetResultType()) { |
| 2988 | case Primitive::kPrimInt: { |
| 2989 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2990 | locations->SetInAt(1, Location::RegisterOrConstant(op->InputAt(1))); |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 2991 | // Make the output overlap, as it will be used to hold the masked |
| 2992 | // second input. |
| 2993 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 2994 | break; |
| 2995 | } |
| 2996 | case Primitive::kPrimLong: { |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 2997 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2998 | locations->SetInAt(1, Location::RequiresRegister()); |
| 2999 | locations->AddTemp(Location::RequiresRegister()); |
| 3000 | locations->SetOut(Location::RequiresRegister()); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3001 | break; |
| 3002 | } |
| 3003 | default: |
| 3004 | LOG(FATAL) << "Unexpected operation type " << op->GetResultType(); |
| 3005 | } |
| 3006 | } |
| 3007 | |
| 3008 | void InstructionCodeGeneratorARM::HandleShift(HBinaryOperation* op) { |
| 3009 | DCHECK(op->IsShl() || op->IsShr() || op->IsUShr()); |
| 3010 | |
| 3011 | LocationSummary* locations = op->GetLocations(); |
| 3012 | Location out = locations->Out(); |
| 3013 | Location first = locations->InAt(0); |
| 3014 | Location second = locations->InAt(1); |
| 3015 | |
| 3016 | Primitive::Type type = op->GetResultType(); |
| 3017 | switch (type) { |
| 3018 | case Primitive::kPrimInt: { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3019 | Register out_reg = out.AsRegister<Register>(); |
| 3020 | Register first_reg = first.AsRegister<Register>(); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3021 | // Arm doesn't mask the shift count so we need to do it ourselves. |
| 3022 | if (second.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3023 | Register second_reg = second.AsRegister<Register>(); |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3024 | __ and_(out_reg, second_reg, ShifterOperand(kMaxIntShiftValue)); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3025 | if (op->IsShl()) { |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3026 | __ Lsl(out_reg, first_reg, out_reg); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3027 | } else if (op->IsShr()) { |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3028 | __ Asr(out_reg, first_reg, out_reg); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3029 | } else { |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3030 | __ Lsr(out_reg, first_reg, out_reg); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3031 | } |
| 3032 | } else { |
| 3033 | int32_t cst = second.GetConstant()->AsIntConstant()->GetValue(); |
| 3034 | uint32_t shift_value = static_cast<uint32_t>(cst & kMaxIntShiftValue); |
| 3035 | if (shift_value == 0) { // arm does not support shifting with 0 immediate. |
| 3036 | __ Mov(out_reg, first_reg); |
| 3037 | } else if (op->IsShl()) { |
| 3038 | __ Lsl(out_reg, first_reg, shift_value); |
| 3039 | } else if (op->IsShr()) { |
| 3040 | __ Asr(out_reg, first_reg, shift_value); |
| 3041 | } else { |
| 3042 | __ Lsr(out_reg, first_reg, shift_value); |
| 3043 | } |
| 3044 | } |
| 3045 | break; |
| 3046 | } |
| 3047 | case Primitive::kPrimLong: { |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3048 | Register o_h = out.AsRegisterPairHigh<Register>(); |
| 3049 | Register o_l = out.AsRegisterPairLow<Register>(); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3050 | |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3051 | Register temp = locations->GetTemp(0).AsRegister<Register>(); |
| 3052 | |
| 3053 | Register high = first.AsRegisterPairHigh<Register>(); |
| 3054 | Register low = first.AsRegisterPairLow<Register>(); |
| 3055 | |
| 3056 | Register second_reg = second.AsRegister<Register>(); |
| 3057 | |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3058 | if (op->IsShl()) { |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3059 | __ and_(o_l, second_reg, ShifterOperand(kMaxLongShiftValue)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3060 | // Shift the high part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3061 | __ Lsl(o_h, high, o_l); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3062 | // Shift the low part and `or` what overflew on the high part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3063 | __ rsb(temp, o_l, ShifterOperand(kArmBitsPerWord)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3064 | __ Lsr(temp, low, temp); |
| 3065 | __ orr(o_h, o_h, ShifterOperand(temp)); |
| 3066 | // If the shift is > 32 bits, override the high part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3067 | __ subs(temp, o_l, ShifterOperand(kArmBitsPerWord)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3068 | __ it(PL); |
Vladimir Marko | 73cf0fb | 2015-07-30 15:07:22 +0100 | [diff] [blame] | 3069 | __ Lsl(o_h, low, temp, PL); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3070 | // Shift the low part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3071 | __ Lsl(o_l, low, o_l); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3072 | } else if (op->IsShr()) { |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3073 | __ and_(o_h, second_reg, ShifterOperand(kMaxLongShiftValue)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3074 | // Shift the low part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3075 | __ Lsr(o_l, low, o_h); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3076 | // Shift the high part and `or` what underflew on the low part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3077 | __ rsb(temp, o_h, ShifterOperand(kArmBitsPerWord)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3078 | __ Lsl(temp, high, temp); |
| 3079 | __ orr(o_l, o_l, ShifterOperand(temp)); |
| 3080 | // If the shift is > 32 bits, override the low part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3081 | __ subs(temp, o_h, ShifterOperand(kArmBitsPerWord)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3082 | __ it(PL); |
Vladimir Marko | 73cf0fb | 2015-07-30 15:07:22 +0100 | [diff] [blame] | 3083 | __ Asr(o_l, high, temp, PL); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3084 | // Shift the high part |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3085 | __ Asr(o_h, high, o_h); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3086 | } else { |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3087 | __ and_(o_h, second_reg, ShifterOperand(kMaxLongShiftValue)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3088 | // same as Shr except we use `Lsr`s and not `Asr`s |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3089 | __ Lsr(o_l, low, o_h); |
| 3090 | __ rsb(temp, o_h, ShifterOperand(kArmBitsPerWord)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3091 | __ Lsl(temp, high, temp); |
| 3092 | __ orr(o_l, o_l, ShifterOperand(temp)); |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3093 | __ subs(temp, o_h, ShifterOperand(kArmBitsPerWord)); |
Guillaume "Vermeille" Sanchez | fd18f5a | 2015-03-11 14:57:40 +0000 | [diff] [blame] | 3094 | __ it(PL); |
Vladimir Marko | 73cf0fb | 2015-07-30 15:07:22 +0100 | [diff] [blame] | 3095 | __ Lsr(o_l, high, temp, PL); |
Nicolas Geoffray | a4f3581 | 2015-06-22 23:12:45 +0100 | [diff] [blame] | 3096 | __ Lsr(o_h, high, o_h); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3097 | } |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 3098 | break; |
| 3099 | } |
| 3100 | default: |
| 3101 | LOG(FATAL) << "Unexpected operation type " << type; |
| 3102 | } |
| 3103 | } |
| 3104 | |
| 3105 | void LocationsBuilderARM::VisitShl(HShl* shl) { |
| 3106 | HandleShift(shl); |
| 3107 | } |
| 3108 | |
| 3109 | void InstructionCodeGeneratorARM::VisitShl(HShl* shl) { |
| 3110 | HandleShift(shl); |
| 3111 | } |
| 3112 | |
| 3113 | void LocationsBuilderARM::VisitShr(HShr* shr) { |
| 3114 | HandleShift(shr); |
| 3115 | } |
| 3116 | |
| 3117 | void InstructionCodeGeneratorARM::VisitShr(HShr* shr) { |
| 3118 | HandleShift(shr); |
| 3119 | } |
| 3120 | |
| 3121 | void LocationsBuilderARM::VisitUShr(HUShr* ushr) { |
| 3122 | HandleShift(ushr); |
| 3123 | } |
| 3124 | |
| 3125 | void InstructionCodeGeneratorARM::VisitUShr(HUShr* ushr) { |
| 3126 | HandleShift(ushr); |
| 3127 | } |
| 3128 | |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 3129 | void LocationsBuilderARM::VisitNewInstance(HNewInstance* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3130 | LocationSummary* locations = |
| 3131 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 3132 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 3133 | locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
Nicolas Geoffray | 69aa601 | 2015-06-09 10:34:25 +0100 | [diff] [blame] | 3134 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 3135 | locations->SetOut(Location::RegisterLocation(R0)); |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 3136 | } |
| 3137 | |
| 3138 | void InstructionCodeGeneratorARM::VisitNewInstance(HNewInstance* instruction) { |
| 3139 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 3140 | __ LoadImmediate(calling_convention.GetRegisterAt(0), instruction->GetTypeIndex()); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3141 | // Note: if heap poisoning is enabled, the entry point takes cares |
| 3142 | // of poisoning the reference. |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 3143 | codegen_->InvokeRuntime(instruction->GetEntrypoint(), |
Nicolas Geoffray | cb1b00a | 2015-01-28 14:50:01 +0000 | [diff] [blame] | 3144 | instruction, |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 3145 | instruction->GetDexPc(), |
| 3146 | nullptr); |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 3147 | } |
| 3148 | |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 3149 | void LocationsBuilderARM::VisitNewArray(HNewArray* instruction) { |
| 3150 | LocationSummary* locations = |
| 3151 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 3152 | InvokeRuntimeCallingConvention calling_convention; |
| 3153 | locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 3154 | locations->SetOut(Location::RegisterLocation(R0)); |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 3155 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
Nicolas Geoffray | 69aa601 | 2015-06-09 10:34:25 +0100 | [diff] [blame] | 3156 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(2))); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 3157 | } |
| 3158 | |
| 3159 | void InstructionCodeGeneratorARM::VisitNewArray(HNewArray* instruction) { |
| 3160 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 3161 | __ LoadImmediate(calling_convention.GetRegisterAt(0), instruction->GetTypeIndex()); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3162 | // Note: if heap poisoning is enabled, the entry point takes cares |
| 3163 | // of poisoning the reference. |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 3164 | codegen_->InvokeRuntime(instruction->GetEntrypoint(), |
Nicolas Geoffray | cb1b00a | 2015-01-28 14:50:01 +0000 | [diff] [blame] | 3165 | instruction, |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 3166 | instruction->GetDexPc(), |
| 3167 | nullptr); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 3168 | } |
| 3169 | |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 3170 | void LocationsBuilderARM::VisitParameterValue(HParameterValue* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3171 | LocationSummary* locations = |
| 3172 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 3173 | Location location = parameter_visitor_.GetNextLocation(instruction->GetType()); |
| 3174 | if (location.IsStackSlot()) { |
| 3175 | location = Location::StackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
| 3176 | } else if (location.IsDoubleStackSlot()) { |
| 3177 | location = Location::DoubleStackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 3178 | } |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 3179 | locations->SetOut(location); |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 3180 | } |
| 3181 | |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 3182 | void InstructionCodeGeneratorARM::VisitParameterValue( |
| 3183 | HParameterValue* instruction ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 3184 | // Nothing to do, the parameter is already at its location. |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 3185 | } |
| 3186 | |
| 3187 | void LocationsBuilderARM::VisitCurrentMethod(HCurrentMethod* instruction) { |
| 3188 | LocationSummary* locations = |
| 3189 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 3190 | locations->SetOut(Location::RegisterLocation(kMethodRegisterArgument)); |
| 3191 | } |
| 3192 | |
| 3193 | void InstructionCodeGeneratorARM::VisitCurrentMethod(HCurrentMethod* instruction ATTRIBUTE_UNUSED) { |
| 3194 | // Nothing to do, the method is already at its location. |
Nicolas Geoffray | f583e59 | 2014-04-07 13:20:42 +0100 | [diff] [blame] | 3195 | } |
| 3196 | |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 3197 | void LocationsBuilderARM::VisitNot(HNot* not_) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3198 | LocationSummary* locations = |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 3199 | new (GetGraph()->GetArena()) LocationSummary(not_, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 3200 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3201 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | b55f835 | 2014-04-07 15:26:35 +0100 | [diff] [blame] | 3202 | } |
| 3203 | |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 3204 | void InstructionCodeGeneratorARM::VisitNot(HNot* not_) { |
| 3205 | LocationSummary* locations = not_->GetLocations(); |
| 3206 | Location out = locations->Out(); |
| 3207 | Location in = locations->InAt(0); |
Nicolas Geoffray | d8ef2e9 | 2015-02-24 16:02:06 +0000 | [diff] [blame] | 3208 | switch (not_->GetResultType()) { |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 3209 | case Primitive::kPrimInt: |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3210 | __ mvn(out.AsRegister<Register>(), ShifterOperand(in.AsRegister<Register>())); |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 3211 | break; |
| 3212 | |
| 3213 | case Primitive::kPrimLong: |
Roland Levillain | 7056643 | 2014-10-24 16:20:17 +0100 | [diff] [blame] | 3214 | __ mvn(out.AsRegisterPairLow<Register>(), |
| 3215 | ShifterOperand(in.AsRegisterPairLow<Register>())); |
| 3216 | __ mvn(out.AsRegisterPairHigh<Register>(), |
| 3217 | ShifterOperand(in.AsRegisterPairHigh<Register>())); |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 3218 | break; |
| 3219 | |
| 3220 | default: |
| 3221 | LOG(FATAL) << "Unimplemented type for not operation " << not_->GetResultType(); |
| 3222 | } |
Nicolas Geoffray | b55f835 | 2014-04-07 15:26:35 +0100 | [diff] [blame] | 3223 | } |
| 3224 | |
David Brazdil | 66d126e | 2015-04-03 16:02:44 +0100 | [diff] [blame] | 3225 | void LocationsBuilderARM::VisitBooleanNot(HBooleanNot* bool_not) { |
| 3226 | LocationSummary* locations = |
| 3227 | new (GetGraph()->GetArena()) LocationSummary(bool_not, LocationSummary::kNoCall); |
| 3228 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3229 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3230 | } |
| 3231 | |
| 3232 | void InstructionCodeGeneratorARM::VisitBooleanNot(HBooleanNot* bool_not) { |
David Brazdil | 66d126e | 2015-04-03 16:02:44 +0100 | [diff] [blame] | 3233 | LocationSummary* locations = bool_not->GetLocations(); |
| 3234 | Location out = locations->Out(); |
| 3235 | Location in = locations->InAt(0); |
| 3236 | __ eor(out.AsRegister<Register>(), in.AsRegister<Register>(), ShifterOperand(1)); |
| 3237 | } |
| 3238 | |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3239 | void LocationsBuilderARM::VisitCompare(HCompare* compare) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3240 | LocationSummary* locations = |
| 3241 | new (GetGraph()->GetArena()) LocationSummary(compare, LocationSummary::kNoCall); |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3242 | switch (compare->InputAt(0)->GetType()) { |
| 3243 | case Primitive::kPrimLong: { |
| 3244 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3245 | locations->SetInAt(1, Location::RequiresRegister()); |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 3246 | // Output overlaps because it is written before doing the low comparison. |
| 3247 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3248 | break; |
| 3249 | } |
| 3250 | case Primitive::kPrimFloat: |
| 3251 | case Primitive::kPrimDouble: { |
| 3252 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 3253 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 3254 | locations->SetOut(Location::RequiresRegister()); |
| 3255 | break; |
| 3256 | } |
| 3257 | default: |
| 3258 | LOG(FATAL) << "Unexpected type for compare operation " << compare->InputAt(0)->GetType(); |
| 3259 | } |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3260 | } |
| 3261 | |
| 3262 | void InstructionCodeGeneratorARM::VisitCompare(HCompare* compare) { |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3263 | LocationSummary* locations = compare->GetLocations(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3264 | Register out = locations->Out().AsRegister<Register>(); |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3265 | Location left = locations->InAt(0); |
| 3266 | Location right = locations->InAt(1); |
| 3267 | |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 3268 | Label less, greater, done; |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3269 | Primitive::Type type = compare->InputAt(0)->GetType(); |
| 3270 | switch (type) { |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3271 | case Primitive::kPrimLong: { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 3272 | __ cmp(left.AsRegisterPairHigh<Register>(), |
| 3273 | ShifterOperand(right.AsRegisterPairHigh<Register>())); // Signed compare. |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3274 | __ b(&less, LT); |
| 3275 | __ b(&greater, GT); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 3276 | // Do LoadImmediate before the last `cmp`, as LoadImmediate might affect the status flags. |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3277 | __ LoadImmediate(out, 0); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 3278 | __ cmp(left.AsRegisterPairLow<Register>(), |
| 3279 | ShifterOperand(right.AsRegisterPairLow<Register>())); // Unsigned compare. |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3280 | break; |
| 3281 | } |
| 3282 | case Primitive::kPrimFloat: |
| 3283 | case Primitive::kPrimDouble: { |
| 3284 | __ LoadImmediate(out, 0); |
| 3285 | if (type == Primitive::kPrimFloat) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3286 | __ vcmps(left.AsFpuRegister<SRegister>(), right.AsFpuRegister<SRegister>()); |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3287 | } else { |
| 3288 | __ vcmpd(FromLowSToD(left.AsFpuRegisterPairLow<SRegister>()), |
| 3289 | FromLowSToD(right.AsFpuRegisterPairLow<SRegister>())); |
| 3290 | } |
| 3291 | __ vmstat(); // transfer FP status register to ARM APSR. |
| 3292 | __ b(compare->IsGtBias() ? &greater : &less, VS); // VS for unordered. |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3293 | break; |
| 3294 | } |
| 3295 | default: |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3296 | LOG(FATAL) << "Unexpected compare type " << type; |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3297 | } |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3298 | __ b(&done, EQ); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 3299 | __ b(&less, LO); // LO is for both: unsigned compare for longs and 'less than' for floats. |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 3300 | |
| 3301 | __ Bind(&greater); |
| 3302 | __ LoadImmediate(out, 1); |
| 3303 | __ b(&done); |
| 3304 | |
| 3305 | __ Bind(&less); |
| 3306 | __ LoadImmediate(out, -1); |
| 3307 | |
| 3308 | __ Bind(&done); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 3309 | } |
| 3310 | |
Nicolas Geoffray | c32e770 | 2014-04-24 12:43:16 +0100 | [diff] [blame] | 3311 | void LocationsBuilderARM::VisitPhi(HPhi* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3312 | LocationSummary* locations = |
| 3313 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 31d76b4 | 2014-06-09 15:02:22 +0100 | [diff] [blame] | 3314 | for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { |
| 3315 | locations->SetInAt(i, Location::Any()); |
| 3316 | } |
| 3317 | locations->SetOut(Location::Any()); |
Nicolas Geoffray | c32e770 | 2014-04-24 12:43:16 +0100 | [diff] [blame] | 3318 | } |
| 3319 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 3320 | void InstructionCodeGeneratorARM::VisitPhi(HPhi* instruction ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 3321 | LOG(FATAL) << "Unreachable"; |
Nicolas Geoffray | c32e770 | 2014-04-24 12:43:16 +0100 | [diff] [blame] | 3322 | } |
| 3323 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3324 | void InstructionCodeGeneratorARM::GenerateMemoryBarrier(MemBarrierKind kind) { |
| 3325 | // TODO (ported from quick): revisit Arm barrier kinds |
Kenny Root | 1d8199d | 2015-06-02 11:01:10 -0700 | [diff] [blame] | 3326 | DmbOptions flavor = DmbOptions::ISH; // quiet c++ warnings |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3327 | switch (kind) { |
| 3328 | case MemBarrierKind::kAnyStore: |
| 3329 | case MemBarrierKind::kLoadAny: |
| 3330 | case MemBarrierKind::kAnyAny: { |
Kenny Root | 1d8199d | 2015-06-02 11:01:10 -0700 | [diff] [blame] | 3331 | flavor = DmbOptions::ISH; |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3332 | break; |
| 3333 | } |
| 3334 | case MemBarrierKind::kStoreStore: { |
Kenny Root | 1d8199d | 2015-06-02 11:01:10 -0700 | [diff] [blame] | 3335 | flavor = DmbOptions::ISHST; |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3336 | break; |
| 3337 | } |
| 3338 | default: |
| 3339 | LOG(FATAL) << "Unexpected memory barrier " << kind; |
| 3340 | } |
Kenny Root | 1d8199d | 2015-06-02 11:01:10 -0700 | [diff] [blame] | 3341 | __ dmb(flavor); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3342 | } |
| 3343 | |
| 3344 | void InstructionCodeGeneratorARM::GenerateWideAtomicLoad(Register addr, |
| 3345 | uint32_t offset, |
| 3346 | Register out_lo, |
| 3347 | Register out_hi) { |
| 3348 | if (offset != 0) { |
| 3349 | __ LoadImmediate(out_lo, offset); |
Nicolas Geoffray | bdcedd3 | 2015-01-09 08:48:29 +0000 | [diff] [blame] | 3350 | __ add(IP, addr, ShifterOperand(out_lo)); |
| 3351 | addr = IP; |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3352 | } |
| 3353 | __ ldrexd(out_lo, out_hi, addr); |
| 3354 | } |
| 3355 | |
| 3356 | void InstructionCodeGeneratorARM::GenerateWideAtomicStore(Register addr, |
| 3357 | uint32_t offset, |
| 3358 | Register value_lo, |
| 3359 | Register value_hi, |
| 3360 | Register temp1, |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3361 | Register temp2, |
| 3362 | HInstruction* instruction) { |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 3363 | Label fail; |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3364 | if (offset != 0) { |
| 3365 | __ LoadImmediate(temp1, offset); |
Nicolas Geoffray | bdcedd3 | 2015-01-09 08:48:29 +0000 | [diff] [blame] | 3366 | __ add(IP, addr, ShifterOperand(temp1)); |
| 3367 | addr = IP; |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3368 | } |
| 3369 | __ Bind(&fail); |
| 3370 | // We need a load followed by store. (The address used in a STREX instruction must |
| 3371 | // be the same as the address in the most recently executed LDREX instruction.) |
| 3372 | __ ldrexd(temp1, temp2, addr); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3373 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3374 | __ strexd(temp1, value_lo, value_hi, addr); |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 3375 | __ CompareAndBranchIfNonZero(temp1, &fail); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3376 | } |
| 3377 | |
| 3378 | void LocationsBuilderARM::HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info) { |
| 3379 | DCHECK(instruction->IsInstanceFieldSet() || instruction->IsStaticFieldSet()); |
| 3380 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3381 | LocationSummary* locations = |
| 3382 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 3383 | locations->SetInAt(0, Location::RequiresRegister()); |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3384 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3385 | Primitive::Type field_type = field_info.GetFieldType(); |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 3386 | if (Primitive::IsFloatingPointType(field_type)) { |
| 3387 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 3388 | } else { |
| 3389 | locations->SetInAt(1, Location::RequiresRegister()); |
| 3390 | } |
| 3391 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3392 | bool is_wide = field_type == Primitive::kPrimLong || field_type == Primitive::kPrimDouble; |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3393 | bool generate_volatile = field_info.IsVolatile() |
| 3394 | && is_wide |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3395 | && !codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd(); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3396 | bool needs_write_barrier = |
| 3397 | CodeGenerator::StoreNeedsWriteBarrier(field_type, instruction->InputAt(1)); |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 3398 | // Temporary registers for the write barrier. |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3399 | // TODO: consider renaming StoreNeedsWriteBarrier to StoreNeedsGCMark. |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3400 | if (needs_write_barrier) { |
| 3401 | locations->AddTemp(Location::RequiresRegister()); // Possibly used for reference poisoning too. |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 3402 | locations->AddTemp(Location::RequiresRegister()); |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3403 | } else if (generate_volatile) { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3404 | // Arm encoding have some additional constraints for ldrexd/strexd: |
| 3405 | // - registers need to be consecutive |
| 3406 | // - the first register should be even but not R14. |
| 3407 | // We don't test for Arm yet, and the assertion makes sure that we revisit this if we ever |
| 3408 | // enable Arm encoding. |
| 3409 | DCHECK_EQ(InstructionSet::kThumb2, codegen_->GetInstructionSet()); |
| 3410 | |
| 3411 | locations->AddTemp(Location::RequiresRegister()); |
| 3412 | locations->AddTemp(Location::RequiresRegister()); |
| 3413 | if (field_type == Primitive::kPrimDouble) { |
| 3414 | // For doubles we need two more registers to copy the value. |
| 3415 | locations->AddTemp(Location::RegisterLocation(R2)); |
| 3416 | locations->AddTemp(Location::RegisterLocation(R3)); |
| 3417 | } |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 3418 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3419 | } |
| 3420 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3421 | void InstructionCodeGeneratorARM::HandleFieldSet(HInstruction* instruction, |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 3422 | const FieldInfo& field_info, |
| 3423 | bool value_can_be_null) { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3424 | DCHECK(instruction->IsInstanceFieldSet() || instruction->IsStaticFieldSet()); |
| 3425 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3426 | LocationSummary* locations = instruction->GetLocations(); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3427 | Register base = locations->InAt(0).AsRegister<Register>(); |
| 3428 | Location value = locations->InAt(1); |
| 3429 | |
| 3430 | bool is_volatile = field_info.IsVolatile(); |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3431 | bool atomic_ldrd_strd = codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd(); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3432 | Primitive::Type field_type = field_info.GetFieldType(); |
| 3433 | uint32_t offset = field_info.GetFieldOffset().Uint32Value(); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3434 | bool needs_write_barrier = |
| 3435 | CodeGenerator::StoreNeedsWriteBarrier(field_type, instruction->InputAt(1)); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3436 | |
| 3437 | if (is_volatile) { |
| 3438 | GenerateMemoryBarrier(MemBarrierKind::kAnyStore); |
| 3439 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3440 | |
| 3441 | switch (field_type) { |
| 3442 | case Primitive::kPrimBoolean: |
| 3443 | case Primitive::kPrimByte: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3444 | __ StoreToOffset(kStoreByte, value.AsRegister<Register>(), base, offset); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3445 | break; |
| 3446 | } |
| 3447 | |
| 3448 | case Primitive::kPrimShort: |
| 3449 | case Primitive::kPrimChar: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3450 | __ StoreToOffset(kStoreHalfword, value.AsRegister<Register>(), base, offset); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3451 | break; |
| 3452 | } |
| 3453 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3454 | case Primitive::kPrimInt: |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3455 | case Primitive::kPrimNot: { |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3456 | if (kPoisonHeapReferences && needs_write_barrier) { |
| 3457 | // Note that in the case where `value` is a null reference, |
| 3458 | // we do not enter this block, as a null reference does not |
| 3459 | // need poisoning. |
| 3460 | DCHECK_EQ(field_type, Primitive::kPrimNot); |
| 3461 | Register temp = locations->GetTemp(0).AsRegister<Register>(); |
| 3462 | __ Mov(temp, value.AsRegister<Register>()); |
| 3463 | __ PoisonHeapReference(temp); |
| 3464 | __ StoreToOffset(kStoreWord, temp, base, offset); |
| 3465 | } else { |
| 3466 | __ StoreToOffset(kStoreWord, value.AsRegister<Register>(), base, offset); |
| 3467 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3468 | break; |
| 3469 | } |
| 3470 | |
| 3471 | case Primitive::kPrimLong: { |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3472 | if (is_volatile && !atomic_ldrd_strd) { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3473 | GenerateWideAtomicStore(base, offset, |
| 3474 | value.AsRegisterPairLow<Register>(), |
| 3475 | value.AsRegisterPairHigh<Register>(), |
| 3476 | locations->GetTemp(0).AsRegister<Register>(), |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3477 | locations->GetTemp(1).AsRegister<Register>(), |
| 3478 | instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3479 | } else { |
| 3480 | __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow<Register>(), base, offset); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3481 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3482 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3483 | break; |
| 3484 | } |
| 3485 | |
Nicolas Geoffray | 52e832b | 2014-11-06 15:15:31 +0000 | [diff] [blame] | 3486 | case Primitive::kPrimFloat: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3487 | __ StoreSToOffset(value.AsFpuRegister<SRegister>(), base, offset); |
Nicolas Geoffray | 52e832b | 2014-11-06 15:15:31 +0000 | [diff] [blame] | 3488 | break; |
| 3489 | } |
| 3490 | |
| 3491 | case Primitive::kPrimDouble: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3492 | DRegister value_reg = FromLowSToD(value.AsFpuRegisterPairLow<SRegister>()); |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3493 | if (is_volatile && !atomic_ldrd_strd) { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3494 | Register value_reg_lo = locations->GetTemp(0).AsRegister<Register>(); |
| 3495 | Register value_reg_hi = locations->GetTemp(1).AsRegister<Register>(); |
| 3496 | |
| 3497 | __ vmovrrd(value_reg_lo, value_reg_hi, value_reg); |
| 3498 | |
| 3499 | GenerateWideAtomicStore(base, offset, |
| 3500 | value_reg_lo, |
| 3501 | value_reg_hi, |
| 3502 | locations->GetTemp(2).AsRegister<Register>(), |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3503 | locations->GetTemp(3).AsRegister<Register>(), |
| 3504 | instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3505 | } else { |
| 3506 | __ StoreDToOffset(value_reg, base, offset); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3507 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3508 | } |
Nicolas Geoffray | 52e832b | 2014-11-06 15:15:31 +0000 | [diff] [blame] | 3509 | break; |
| 3510 | } |
| 3511 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3512 | case Primitive::kPrimVoid: |
| 3513 | LOG(FATAL) << "Unreachable type " << field_type; |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 3514 | UNREACHABLE(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3515 | } |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3516 | |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3517 | // Longs and doubles are handled in the switch. |
| 3518 | if (field_type != Primitive::kPrimLong && field_type != Primitive::kPrimDouble) { |
| 3519 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 3520 | } |
| 3521 | |
| 3522 | if (CodeGenerator::StoreNeedsWriteBarrier(field_type, instruction->InputAt(1))) { |
| 3523 | Register temp = locations->GetTemp(0).AsRegister<Register>(); |
| 3524 | Register card = locations->GetTemp(1).AsRegister<Register>(); |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 3525 | codegen_->MarkGCCard( |
| 3526 | temp, card, base, value.AsRegister<Register>(), value_can_be_null); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3527 | } |
| 3528 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3529 | if (is_volatile) { |
| 3530 | GenerateMemoryBarrier(MemBarrierKind::kAnyAny); |
| 3531 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3532 | } |
| 3533 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3534 | void LocationsBuilderARM::HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info) { |
| 3535 | DCHECK(instruction->IsInstanceFieldGet() || instruction->IsStaticFieldGet()); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3536 | LocationSummary* locations = |
| 3537 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 3538 | locations->SetInAt(0, Location::RequiresRegister()); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3539 | |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 3540 | bool volatile_for_double = field_info.IsVolatile() |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3541 | && (field_info.GetFieldType() == Primitive::kPrimDouble) |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3542 | && !codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd(); |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 3543 | bool overlap = field_info.IsVolatile() && (field_info.GetFieldType() == Primitive::kPrimLong); |
Nicolas Geoffray | acc0b8e | 2015-04-20 12:39:57 +0100 | [diff] [blame] | 3544 | |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 3545 | if (Primitive::IsFloatingPointType(instruction->GetType())) { |
| 3546 | locations->SetOut(Location::RequiresFpuRegister()); |
| 3547 | } else { |
| 3548 | locations->SetOut(Location::RequiresRegister(), |
| 3549 | (overlap ? Location::kOutputOverlap : Location::kNoOutputOverlap)); |
| 3550 | } |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 3551 | if (volatile_for_double) { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3552 | // Arm encoding have some additional constraints for ldrexd/strexd: |
| 3553 | // - registers need to be consecutive |
| 3554 | // - the first register should be even but not R14. |
| 3555 | // We don't test for Arm yet, and the assertion makes sure that we revisit this if we ever |
| 3556 | // enable Arm encoding. |
| 3557 | DCHECK_EQ(InstructionSet::kThumb2, codegen_->GetInstructionSet()); |
| 3558 | locations->AddTemp(Location::RequiresRegister()); |
| 3559 | locations->AddTemp(Location::RequiresRegister()); |
| 3560 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3561 | } |
| 3562 | |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 3563 | Location LocationsBuilderARM::ArmEncodableConstantOrRegister(HInstruction* constant, |
| 3564 | Opcode opcode) { |
| 3565 | DCHECK(!Primitive::IsFloatingPointType(constant->GetType())); |
| 3566 | if (constant->IsConstant() && |
| 3567 | CanEncodeConstantAsImmediate(constant->AsConstant(), opcode)) { |
| 3568 | return Location::ConstantLocation(constant->AsConstant()); |
| 3569 | } |
| 3570 | return Location::RequiresRegister(); |
| 3571 | } |
| 3572 | |
| 3573 | bool LocationsBuilderARM::CanEncodeConstantAsImmediate(HConstant* input_cst, |
| 3574 | Opcode opcode) { |
| 3575 | uint64_t value = static_cast<uint64_t>(Int64FromConstant(input_cst)); |
| 3576 | if (Primitive::Is64BitType(input_cst->GetType())) { |
| 3577 | return CanEncodeConstantAsImmediate(Low32Bits(value), opcode) && |
| 3578 | CanEncodeConstantAsImmediate(High32Bits(value), opcode); |
| 3579 | } else { |
| 3580 | return CanEncodeConstantAsImmediate(Low32Bits(value), opcode); |
| 3581 | } |
| 3582 | } |
| 3583 | |
| 3584 | bool LocationsBuilderARM::CanEncodeConstantAsImmediate(uint32_t value, Opcode opcode) { |
| 3585 | ShifterOperand so; |
| 3586 | ArmAssembler* assembler = codegen_->GetAssembler(); |
| 3587 | if (assembler->ShifterOperandCanHold(kNoRegister, kNoRegister, opcode, value, &so)) { |
| 3588 | return true; |
| 3589 | } |
| 3590 | Opcode neg_opcode = kNoOperand; |
| 3591 | switch (opcode) { |
| 3592 | case AND: |
| 3593 | neg_opcode = BIC; |
| 3594 | break; |
| 3595 | case ORR: |
| 3596 | neg_opcode = ORN; |
| 3597 | break; |
| 3598 | default: |
| 3599 | return false; |
| 3600 | } |
| 3601 | return assembler->ShifterOperandCanHold(kNoRegister, kNoRegister, neg_opcode, ~value, &so); |
| 3602 | } |
| 3603 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3604 | void InstructionCodeGeneratorARM::HandleFieldGet(HInstruction* instruction, |
| 3605 | const FieldInfo& field_info) { |
| 3606 | DCHECK(instruction->IsInstanceFieldGet() || instruction->IsStaticFieldGet()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3607 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3608 | LocationSummary* locations = instruction->GetLocations(); |
| 3609 | Register base = locations->InAt(0).AsRegister<Register>(); |
| 3610 | Location out = locations->Out(); |
| 3611 | bool is_volatile = field_info.IsVolatile(); |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3612 | bool atomic_ldrd_strd = codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd(); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3613 | Primitive::Type field_type = field_info.GetFieldType(); |
| 3614 | uint32_t offset = field_info.GetFieldOffset().Uint32Value(); |
| 3615 | |
| 3616 | switch (field_type) { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3617 | case Primitive::kPrimBoolean: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3618 | __ LoadFromOffset(kLoadUnsignedByte, out.AsRegister<Register>(), base, offset); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3619 | break; |
| 3620 | } |
| 3621 | |
| 3622 | case Primitive::kPrimByte: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3623 | __ LoadFromOffset(kLoadSignedByte, out.AsRegister<Register>(), base, offset); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3624 | break; |
| 3625 | } |
| 3626 | |
| 3627 | case Primitive::kPrimShort: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3628 | __ LoadFromOffset(kLoadSignedHalfword, out.AsRegister<Register>(), base, offset); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3629 | break; |
| 3630 | } |
| 3631 | |
| 3632 | case Primitive::kPrimChar: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3633 | __ LoadFromOffset(kLoadUnsignedHalfword, out.AsRegister<Register>(), base, offset); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3634 | break; |
| 3635 | } |
| 3636 | |
| 3637 | case Primitive::kPrimInt: |
| 3638 | case Primitive::kPrimNot: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3639 | __ LoadFromOffset(kLoadWord, out.AsRegister<Register>(), base, offset); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3640 | break; |
| 3641 | } |
| 3642 | |
| 3643 | case Primitive::kPrimLong: { |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3644 | if (is_volatile && !atomic_ldrd_strd) { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3645 | GenerateWideAtomicLoad(base, offset, |
| 3646 | out.AsRegisterPairLow<Register>(), |
| 3647 | out.AsRegisterPairHigh<Register>()); |
| 3648 | } else { |
| 3649 | __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow<Register>(), base, offset); |
| 3650 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3651 | break; |
| 3652 | } |
| 3653 | |
Nicolas Geoffray | 52e832b | 2014-11-06 15:15:31 +0000 | [diff] [blame] | 3654 | case Primitive::kPrimFloat: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3655 | __ LoadSFromOffset(out.AsFpuRegister<SRegister>(), base, offset); |
Nicolas Geoffray | 52e832b | 2014-11-06 15:15:31 +0000 | [diff] [blame] | 3656 | break; |
| 3657 | } |
| 3658 | |
| 3659 | case Primitive::kPrimDouble: { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3660 | DRegister out_reg = FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()); |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 3661 | if (is_volatile && !atomic_ldrd_strd) { |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3662 | Register lo = locations->GetTemp(0).AsRegister<Register>(); |
| 3663 | Register hi = locations->GetTemp(1).AsRegister<Register>(); |
| 3664 | GenerateWideAtomicLoad(base, offset, lo, hi); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3665 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3666 | __ vmovdrr(out_reg, lo, hi); |
| 3667 | } else { |
| 3668 | __ LoadDFromOffset(out_reg, base, offset); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3669 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3670 | } |
Nicolas Geoffray | 52e832b | 2014-11-06 15:15:31 +0000 | [diff] [blame] | 3671 | break; |
| 3672 | } |
| 3673 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3674 | case Primitive::kPrimVoid: |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3675 | LOG(FATAL) << "Unreachable type " << field_type; |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 3676 | UNREACHABLE(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3677 | } |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3678 | |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3679 | // Doubles are handled in the switch. |
| 3680 | if (field_type != Primitive::kPrimDouble) { |
| 3681 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 3682 | } |
| 3683 | |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3684 | if (is_volatile) { |
| 3685 | GenerateMemoryBarrier(MemBarrierKind::kLoadAny); |
| 3686 | } |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3687 | |
| 3688 | if (field_type == Primitive::kPrimNot) { |
| 3689 | __ MaybeUnpoisonHeapReference(out.AsRegister<Register>()); |
| 3690 | } |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3691 | } |
| 3692 | |
| 3693 | void LocationsBuilderARM::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
| 3694 | HandleFieldSet(instruction, instruction->GetFieldInfo()); |
| 3695 | } |
| 3696 | |
| 3697 | void InstructionCodeGeneratorARM::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 3698 | HandleFieldSet(instruction, instruction->GetFieldInfo(), instruction->GetValueCanBeNull()); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 3699 | } |
| 3700 | |
| 3701 | void LocationsBuilderARM::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
| 3702 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 3703 | } |
| 3704 | |
| 3705 | void InstructionCodeGeneratorARM::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
| 3706 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 3707 | } |
| 3708 | |
| 3709 | void LocationsBuilderARM::VisitStaticFieldGet(HStaticFieldGet* instruction) { |
| 3710 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 3711 | } |
| 3712 | |
| 3713 | void InstructionCodeGeneratorARM::VisitStaticFieldGet(HStaticFieldGet* instruction) { |
| 3714 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 3715 | } |
| 3716 | |
| 3717 | void LocationsBuilderARM::VisitStaticFieldSet(HStaticFieldSet* instruction) { |
| 3718 | HandleFieldSet(instruction, instruction->GetFieldInfo()); |
| 3719 | } |
| 3720 | |
| 3721 | void InstructionCodeGeneratorARM::VisitStaticFieldSet(HStaticFieldSet* instruction) { |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 3722 | HandleFieldSet(instruction, instruction->GetFieldInfo(), instruction->GetValueCanBeNull()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3723 | } |
| 3724 | |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 3725 | void LocationsBuilderARM::VisitUnresolvedInstanceFieldGet( |
| 3726 | HUnresolvedInstanceFieldGet* instruction) { |
| 3727 | FieldAccessCallingConventionARM calling_convention; |
| 3728 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3729 | instruction, instruction->GetFieldType(), calling_convention); |
| 3730 | } |
| 3731 | |
| 3732 | void InstructionCodeGeneratorARM::VisitUnresolvedInstanceFieldGet( |
| 3733 | HUnresolvedInstanceFieldGet* instruction) { |
| 3734 | FieldAccessCallingConventionARM calling_convention; |
| 3735 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3736 | instruction->GetFieldType(), |
| 3737 | instruction->GetFieldIndex(), |
| 3738 | instruction->GetDexPc(), |
| 3739 | calling_convention); |
| 3740 | } |
| 3741 | |
| 3742 | void LocationsBuilderARM::VisitUnresolvedInstanceFieldSet( |
| 3743 | HUnresolvedInstanceFieldSet* instruction) { |
| 3744 | FieldAccessCallingConventionARM calling_convention; |
| 3745 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3746 | instruction, instruction->GetFieldType(), calling_convention); |
| 3747 | } |
| 3748 | |
| 3749 | void InstructionCodeGeneratorARM::VisitUnresolvedInstanceFieldSet( |
| 3750 | HUnresolvedInstanceFieldSet* instruction) { |
| 3751 | FieldAccessCallingConventionARM calling_convention; |
| 3752 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3753 | instruction->GetFieldType(), |
| 3754 | instruction->GetFieldIndex(), |
| 3755 | instruction->GetDexPc(), |
| 3756 | calling_convention); |
| 3757 | } |
| 3758 | |
| 3759 | void LocationsBuilderARM::VisitUnresolvedStaticFieldGet( |
| 3760 | HUnresolvedStaticFieldGet* instruction) { |
| 3761 | FieldAccessCallingConventionARM calling_convention; |
| 3762 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3763 | instruction, instruction->GetFieldType(), calling_convention); |
| 3764 | } |
| 3765 | |
| 3766 | void InstructionCodeGeneratorARM::VisitUnresolvedStaticFieldGet( |
| 3767 | HUnresolvedStaticFieldGet* instruction) { |
| 3768 | FieldAccessCallingConventionARM calling_convention; |
| 3769 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3770 | instruction->GetFieldType(), |
| 3771 | instruction->GetFieldIndex(), |
| 3772 | instruction->GetDexPc(), |
| 3773 | calling_convention); |
| 3774 | } |
| 3775 | |
| 3776 | void LocationsBuilderARM::VisitUnresolvedStaticFieldSet( |
| 3777 | HUnresolvedStaticFieldSet* instruction) { |
| 3778 | FieldAccessCallingConventionARM calling_convention; |
| 3779 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3780 | instruction, instruction->GetFieldType(), calling_convention); |
| 3781 | } |
| 3782 | |
| 3783 | void InstructionCodeGeneratorARM::VisitUnresolvedStaticFieldSet( |
| 3784 | HUnresolvedStaticFieldSet* instruction) { |
| 3785 | FieldAccessCallingConventionARM calling_convention; |
| 3786 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3787 | instruction->GetFieldType(), |
| 3788 | instruction->GetFieldIndex(), |
| 3789 | instruction->GetDexPc(), |
| 3790 | calling_convention); |
| 3791 | } |
| 3792 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3793 | void LocationsBuilderARM::VisitNullCheck(HNullCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 3794 | LocationSummary::CallKind call_kind = instruction->CanThrowIntoCatchBlock() |
| 3795 | ? LocationSummary::kCallOnSlowPath |
| 3796 | : LocationSummary::kNoCall; |
| 3797 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3798 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 3799 | if (instruction->HasUses()) { |
| 3800 | locations->SetOut(Location::SameAsFirstInput()); |
| 3801 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3802 | } |
| 3803 | |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3804 | void InstructionCodeGeneratorARM::GenerateImplicitNullCheck(HNullCheck* instruction) { |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3805 | if (codegen_->CanMoveNullCheckToUser(instruction)) { |
| 3806 | return; |
| 3807 | } |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3808 | Location obj = instruction->GetLocations()->InAt(0); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3809 | |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3810 | __ LoadFromOffset(kLoadWord, IP, obj.AsRegister<Register>(), 0); |
| 3811 | codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); |
| 3812 | } |
| 3813 | |
| 3814 | void InstructionCodeGeneratorARM::GenerateExplicitNullCheck(HNullCheck* instruction) { |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 3815 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) NullCheckSlowPathARM(instruction); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3816 | codegen_->AddSlowPath(slow_path); |
| 3817 | |
| 3818 | LocationSummary* locations = instruction->GetLocations(); |
| 3819 | Location obj = locations->InAt(0); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3820 | |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 3821 | __ CompareAndBranchIfZero(obj.AsRegister<Register>(), slow_path->GetEntryLabel()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 3822 | } |
| 3823 | |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3824 | void InstructionCodeGeneratorARM::VisitNullCheck(HNullCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 3825 | if (codegen_->IsImplicitNullCheckAllowed(instruction)) { |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 3826 | GenerateImplicitNullCheck(instruction); |
| 3827 | } else { |
| 3828 | GenerateExplicitNullCheck(instruction); |
| 3829 | } |
| 3830 | } |
| 3831 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3832 | void LocationsBuilderARM::VisitArrayGet(HArrayGet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3833 | LocationSummary* locations = |
| 3834 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 3835 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3836 | locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1))); |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 3837 | if (Primitive::IsFloatingPointType(instruction->GetType())) { |
| 3838 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 3839 | } else { |
| 3840 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3841 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3842 | } |
| 3843 | |
| 3844 | void InstructionCodeGeneratorARM::VisitArrayGet(HArrayGet* instruction) { |
| 3845 | LocationSummary* locations = instruction->GetLocations(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3846 | Register obj = locations->InAt(0).AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3847 | Location index = locations->InAt(1); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3848 | Primitive::Type type = instruction->GetType(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3849 | |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3850 | switch (type) { |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3851 | case Primitive::kPrimBoolean: { |
| 3852 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3853 | Register out = locations->Out().AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3854 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 3855 | size_t offset = |
| 3856 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3857 | __ LoadFromOffset(kLoadUnsignedByte, out, obj, offset); |
| 3858 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3859 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>())); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3860 | __ LoadFromOffset(kLoadUnsignedByte, out, IP, data_offset); |
| 3861 | } |
| 3862 | break; |
| 3863 | } |
| 3864 | |
| 3865 | case Primitive::kPrimByte: { |
| 3866 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int8_t)).Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3867 | Register out = locations->Out().AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3868 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 3869 | size_t offset = |
| 3870 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3871 | __ LoadFromOffset(kLoadSignedByte, out, obj, offset); |
| 3872 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3873 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>())); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3874 | __ LoadFromOffset(kLoadSignedByte, out, IP, data_offset); |
| 3875 | } |
| 3876 | break; |
| 3877 | } |
| 3878 | |
| 3879 | case Primitive::kPrimShort: { |
| 3880 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int16_t)).Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3881 | Register out = locations->Out().AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3882 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 3883 | size_t offset = |
| 3884 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3885 | __ LoadFromOffset(kLoadSignedHalfword, out, obj, offset); |
| 3886 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3887 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_2)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3888 | __ LoadFromOffset(kLoadSignedHalfword, out, IP, data_offset); |
| 3889 | } |
| 3890 | break; |
| 3891 | } |
| 3892 | |
| 3893 | case Primitive::kPrimChar: { |
| 3894 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3895 | Register out = locations->Out().AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3896 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 3897 | size_t offset = |
| 3898 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3899 | __ LoadFromOffset(kLoadUnsignedHalfword, out, obj, offset); |
| 3900 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3901 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_2)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3902 | __ LoadFromOffset(kLoadUnsignedHalfword, out, IP, data_offset); |
| 3903 | } |
| 3904 | break; |
| 3905 | } |
| 3906 | |
| 3907 | case Primitive::kPrimInt: |
| 3908 | case Primitive::kPrimNot: { |
Roland Levillain | 33d6903 | 2015-06-18 18:20:59 +0100 | [diff] [blame] | 3909 | static_assert(sizeof(mirror::HeapReference<mirror::Object>) == sizeof(int32_t), |
| 3910 | "art::mirror::HeapReference<mirror::Object> and int32_t have different sizes."); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3911 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3912 | Register out = locations->Out().AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3913 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 3914 | size_t offset = |
| 3915 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3916 | __ LoadFromOffset(kLoadWord, out, obj, offset); |
| 3917 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3918 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_4)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3919 | __ LoadFromOffset(kLoadWord, out, IP, data_offset); |
| 3920 | } |
| 3921 | break; |
| 3922 | } |
| 3923 | |
| 3924 | case Primitive::kPrimLong: { |
| 3925 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 3926 | Location out = locations->Out(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3927 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 3928 | size_t offset = |
| 3929 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 3930 | __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow<Register>(), obj, offset); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3931 | } else { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 3932 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_8)); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 3933 | __ LoadFromOffset(kLoadWordPair, out.AsRegisterPairLow<Register>(), IP, data_offset); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3934 | } |
| 3935 | break; |
| 3936 | } |
| 3937 | |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 3938 | case Primitive::kPrimFloat: { |
| 3939 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(float)).Uint32Value(); |
| 3940 | Location out = locations->Out(); |
| 3941 | DCHECK(out.IsFpuRegister()); |
| 3942 | if (index.IsConstant()) { |
| 3943 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 3944 | __ LoadSFromOffset(out.AsFpuRegister<SRegister>(), obj, offset); |
| 3945 | } else { |
| 3946 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_4)); |
| 3947 | __ LoadSFromOffset(out.AsFpuRegister<SRegister>(), IP, data_offset); |
| 3948 | } |
| 3949 | break; |
| 3950 | } |
| 3951 | |
| 3952 | case Primitive::kPrimDouble: { |
| 3953 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(double)).Uint32Value(); |
| 3954 | Location out = locations->Out(); |
| 3955 | DCHECK(out.IsFpuRegisterPair()); |
| 3956 | if (index.IsConstant()) { |
| 3957 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 3958 | __ LoadDFromOffset(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), obj, offset); |
| 3959 | } else { |
| 3960 | __ add(IP, obj, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_8)); |
| 3961 | __ LoadDFromOffset(FromLowSToD(out.AsFpuRegisterPairLow<SRegister>()), IP, data_offset); |
| 3962 | } |
| 3963 | break; |
| 3964 | } |
| 3965 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3966 | case Primitive::kPrimVoid: |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3967 | LOG(FATAL) << "Unreachable type " << type; |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 3968 | UNREACHABLE(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3969 | } |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 3970 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 3971 | |
| 3972 | if (type == Primitive::kPrimNot) { |
| 3973 | Register out = locations->Out().AsRegister<Register>(); |
| 3974 | __ MaybeUnpoisonHeapReference(out); |
| 3975 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3976 | } |
| 3977 | |
| 3978 | void LocationsBuilderARM::VisitArraySet(HArraySet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3979 | Primitive::Type value_type = instruction->GetComponentType(); |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 3980 | |
| 3981 | bool needs_write_barrier = |
| 3982 | CodeGenerator::StoreNeedsWriteBarrier(value_type, instruction->GetValue()); |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 3983 | bool may_need_runtime_call = instruction->NeedsTypeCheck(); |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 3984 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 3985 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary( |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 3986 | instruction, |
| 3987 | may_need_runtime_call ? LocationSummary::kCallOnSlowPath : LocationSummary::kNoCall); |
| 3988 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3989 | locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 3990 | if (Primitive::IsFloatingPointType(value_type)) { |
| 3991 | locations->SetInAt(2, Location::RequiresFpuRegister()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 3992 | } else { |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 3993 | locations->SetInAt(2, Location::RequiresRegister()); |
| 3994 | } |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 3995 | |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 3996 | if (needs_write_barrier) { |
| 3997 | // Temporary registers for the write barrier. |
| 3998 | locations->AddTemp(Location::RequiresRegister()); // Possibly used for ref. poisoning too. |
| 3999 | locations->AddTemp(Location::RequiresRegister()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4000 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4001 | } |
| 4002 | |
| 4003 | void InstructionCodeGeneratorARM::VisitArraySet(HArraySet* instruction) { |
| 4004 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4005 | Register array = locations->InAt(0).AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4006 | Location index = locations->InAt(1); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 4007 | Primitive::Type value_type = instruction->GetComponentType(); |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4008 | bool may_need_runtime_call = locations->CanCall(); |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 4009 | bool needs_write_barrier = |
| 4010 | CodeGenerator::StoreNeedsWriteBarrier(value_type, instruction->GetValue()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4011 | |
| 4012 | switch (value_type) { |
| 4013 | case Primitive::kPrimBoolean: |
| 4014 | case Primitive::kPrimByte: { |
| 4015 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4016 | Register value = locations->InAt(2).AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4017 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 4018 | size_t offset = |
| 4019 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4020 | __ StoreToOffset(kStoreByte, value, array, offset); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4021 | } else { |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4022 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>())); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4023 | __ StoreToOffset(kStoreByte, value, IP, data_offset); |
| 4024 | } |
| 4025 | break; |
| 4026 | } |
| 4027 | |
| 4028 | case Primitive::kPrimShort: |
| 4029 | case Primitive::kPrimChar: { |
| 4030 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4031 | Register value = locations->InAt(2).AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4032 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 4033 | size_t offset = |
| 4034 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4035 | __ StoreToOffset(kStoreHalfword, value, array, offset); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4036 | } else { |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4037 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_2)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4038 | __ StoreToOffset(kStoreHalfword, value, IP, data_offset); |
| 4039 | } |
| 4040 | break; |
| 4041 | } |
| 4042 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4043 | case Primitive::kPrimNot: { |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4044 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
| 4045 | Register value = locations->InAt(2).AsRegister<Register>(); |
| 4046 | Register source = value; |
| 4047 | |
| 4048 | if (instruction->InputAt(2)->IsNullConstant()) { |
| 4049 | // Just setting null. |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 4050 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 4051 | size_t offset = |
| 4052 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4053 | __ StoreToOffset(kStoreWord, source, array, offset); |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 4054 | } else { |
| 4055 | DCHECK(index.IsRegister()) << index; |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4056 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_4)); |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 4057 | __ StoreToOffset(kStoreWord, source, IP, data_offset); |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 4058 | } |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4059 | break; |
Nicolas Geoffray | af07bc1 | 2014-11-12 18:08:09 +0000 | [diff] [blame] | 4060 | } |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4061 | |
| 4062 | DCHECK(needs_write_barrier); |
| 4063 | Register temp1 = locations->GetTemp(0).AsRegister<Register>(); |
| 4064 | Register temp2 = locations->GetTemp(1).AsRegister<Register>(); |
| 4065 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
| 4066 | uint32_t super_offset = mirror::Class::SuperClassOffset().Int32Value(); |
| 4067 | uint32_t component_offset = mirror::Class::ComponentTypeOffset().Int32Value(); |
| 4068 | Label done; |
| 4069 | SlowPathCode* slow_path = nullptr; |
| 4070 | |
| 4071 | if (may_need_runtime_call) { |
| 4072 | slow_path = new (GetGraph()->GetArena()) ArraySetSlowPathARM(instruction); |
| 4073 | codegen_->AddSlowPath(slow_path); |
| 4074 | if (instruction->GetValueCanBeNull()) { |
| 4075 | Label non_zero; |
| 4076 | __ CompareAndBranchIfNonZero(value, &non_zero); |
| 4077 | if (index.IsConstant()) { |
| 4078 | size_t offset = |
| 4079 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 4080 | __ StoreToOffset(kStoreWord, value, array, offset); |
| 4081 | } else { |
| 4082 | DCHECK(index.IsRegister()) << index; |
| 4083 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_4)); |
| 4084 | __ StoreToOffset(kStoreWord, value, IP, data_offset); |
| 4085 | } |
| 4086 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 4087 | __ b(&done); |
| 4088 | __ Bind(&non_zero); |
| 4089 | } |
| 4090 | |
| 4091 | __ LoadFromOffset(kLoadWord, temp1, array, class_offset); |
| 4092 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 4093 | __ MaybeUnpoisonHeapReference(temp1); |
| 4094 | __ LoadFromOffset(kLoadWord, temp1, temp1, component_offset); |
| 4095 | __ LoadFromOffset(kLoadWord, temp2, value, class_offset); |
| 4096 | // No need to poison/unpoison, we're comparing two poisoined references. |
| 4097 | __ cmp(temp1, ShifterOperand(temp2)); |
| 4098 | if (instruction->StaticTypeOfArrayIsObjectArray()) { |
| 4099 | Label do_put; |
| 4100 | __ b(&do_put, EQ); |
| 4101 | __ MaybeUnpoisonHeapReference(temp1); |
| 4102 | __ LoadFromOffset(kLoadWord, temp1, temp1, super_offset); |
| 4103 | // No need to poison/unpoison, we're comparing against null. |
| 4104 | __ CompareAndBranchIfNonZero(temp1, slow_path->GetEntryLabel()); |
| 4105 | __ Bind(&do_put); |
| 4106 | } else { |
| 4107 | __ b(slow_path->GetEntryLabel(), NE); |
| 4108 | } |
| 4109 | } |
| 4110 | |
| 4111 | if (kPoisonHeapReferences) { |
| 4112 | // Note that in the case where `value` is a null reference, |
| 4113 | // we do not enter this block, as a null reference does not |
| 4114 | // need poisoning. |
| 4115 | DCHECK_EQ(value_type, Primitive::kPrimNot); |
| 4116 | __ Mov(temp1, value); |
| 4117 | __ PoisonHeapReference(temp1); |
| 4118 | source = temp1; |
| 4119 | } |
| 4120 | |
| 4121 | if (index.IsConstant()) { |
| 4122 | size_t offset = |
| 4123 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 4124 | __ StoreToOffset(kStoreWord, source, array, offset); |
| 4125 | } else { |
| 4126 | DCHECK(index.IsRegister()) << index; |
| 4127 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_4)); |
| 4128 | __ StoreToOffset(kStoreWord, source, IP, data_offset); |
| 4129 | } |
| 4130 | |
| 4131 | if (!may_need_runtime_call) { |
| 4132 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 4133 | } |
| 4134 | |
| 4135 | codegen_->MarkGCCard(temp1, temp2, array, value, instruction->GetValueCanBeNull()); |
| 4136 | |
| 4137 | if (done.IsLinked()) { |
| 4138 | __ Bind(&done); |
| 4139 | } |
| 4140 | |
| 4141 | if (slow_path != nullptr) { |
| 4142 | __ Bind(slow_path->GetExitLabel()); |
| 4143 | } |
| 4144 | |
| 4145 | break; |
| 4146 | } |
| 4147 | |
| 4148 | case Primitive::kPrimInt: { |
| 4149 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
| 4150 | Register value = locations->InAt(2).AsRegister<Register>(); |
| 4151 | if (index.IsConstant()) { |
| 4152 | size_t offset = |
| 4153 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 4154 | __ StoreToOffset(kStoreWord, value, array, offset); |
| 4155 | } else { |
| 4156 | DCHECK(index.IsRegister()) << index; |
| 4157 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_4)); |
| 4158 | __ StoreToOffset(kStoreWord, value, IP, data_offset); |
| 4159 | } |
| 4160 | |
| 4161 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4162 | break; |
| 4163 | } |
| 4164 | |
| 4165 | case Primitive::kPrimLong: { |
| 4166 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 4167 | Location value = locations->InAt(2); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4168 | if (index.IsConstant()) { |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 4169 | size_t offset = |
| 4170 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4171 | __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow<Register>(), array, offset); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4172 | } else { |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4173 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_8)); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 4174 | __ StoreToOffset(kStoreWordPair, value.AsRegisterPairLow<Register>(), IP, data_offset); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4175 | } |
| 4176 | break; |
| 4177 | } |
| 4178 | |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4179 | case Primitive::kPrimFloat: { |
| 4180 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(float)).Uint32Value(); |
| 4181 | Location value = locations->InAt(2); |
| 4182 | DCHECK(value.IsFpuRegister()); |
| 4183 | if (index.IsConstant()) { |
| 4184 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4185 | __ StoreSToOffset(value.AsFpuRegister<SRegister>(), array, offset); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4186 | } else { |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4187 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_4)); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4188 | __ StoreSToOffset(value.AsFpuRegister<SRegister>(), IP, data_offset); |
| 4189 | } |
| 4190 | break; |
| 4191 | } |
| 4192 | |
| 4193 | case Primitive::kPrimDouble: { |
| 4194 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(double)).Uint32Value(); |
| 4195 | Location value = locations->InAt(2); |
| 4196 | DCHECK(value.IsFpuRegisterPair()); |
| 4197 | if (index.IsConstant()) { |
| 4198 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4199 | __ StoreDToOffset(FromLowSToD(value.AsFpuRegisterPairLow<SRegister>()), array, offset); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4200 | } else { |
Nicolas Geoffray | e0395dd | 2015-09-25 11:04:45 +0100 | [diff] [blame] | 4201 | __ add(IP, array, ShifterOperand(index.AsRegister<Register>(), LSL, TIMES_8)); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4202 | __ StoreDToOffset(FromLowSToD(value.AsFpuRegisterPairLow<SRegister>()), IP, data_offset); |
| 4203 | } |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 4204 | |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4205 | break; |
| 4206 | } |
| 4207 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4208 | case Primitive::kPrimVoid: |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4209 | LOG(FATAL) << "Unreachable type " << value_type; |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 4210 | UNREACHABLE(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4211 | } |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 4212 | |
| 4213 | // Ints and objects are handled in the switch. |
| 4214 | if (value_type != Primitive::kPrimInt && value_type != Primitive::kPrimNot) { |
| 4215 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 4216 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4217 | } |
| 4218 | |
| 4219 | void LocationsBuilderARM::VisitArrayLength(HArrayLength* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 4220 | LocationSummary* locations = |
| 4221 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 4222 | locations->SetInAt(0, Location::RequiresRegister()); |
| 4223 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4224 | } |
| 4225 | |
| 4226 | void InstructionCodeGeneratorARM::VisitArrayLength(HArrayLength* instruction) { |
| 4227 | LocationSummary* locations = instruction->GetLocations(); |
| 4228 | uint32_t offset = mirror::Array::LengthOffset().Uint32Value(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4229 | Register obj = locations->InAt(0).AsRegister<Register>(); |
| 4230 | Register out = locations->Out().AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4231 | __ LoadFromOffset(kLoadWord, out, obj, offset); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 4232 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4233 | } |
| 4234 | |
| 4235 | void LocationsBuilderARM::VisitBoundsCheck(HBoundsCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 4236 | LocationSummary::CallKind call_kind = instruction->CanThrowIntoCatchBlock() |
| 4237 | ? LocationSummary::kCallOnSlowPath |
| 4238 | : LocationSummary::kNoCall; |
| 4239 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4240 | locations->SetInAt(0, Location::RequiresRegister()); |
| 4241 | locations->SetInAt(1, Location::RequiresRegister()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 4242 | if (instruction->HasUses()) { |
| 4243 | locations->SetOut(Location::SameAsFirstInput()); |
| 4244 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4245 | } |
| 4246 | |
| 4247 | void InstructionCodeGeneratorARM::VisitBoundsCheck(HBoundsCheck* instruction) { |
| 4248 | LocationSummary* locations = instruction->GetLocations(); |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 4249 | SlowPathCode* slow_path = |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 4250 | new (GetGraph()->GetArena()) BoundsCheckSlowPathARM(instruction); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4251 | codegen_->AddSlowPath(slow_path); |
| 4252 | |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4253 | Register index = locations->InAt(0).AsRegister<Register>(); |
| 4254 | Register length = locations->InAt(1).AsRegister<Register>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4255 | |
| 4256 | __ cmp(index, ShifterOperand(length)); |
Roland Levillain | 4fa13f6 | 2015-07-06 18:11:54 +0100 | [diff] [blame] | 4257 | __ b(slow_path->GetEntryLabel(), HS); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4258 | } |
| 4259 | |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 4260 | void CodeGeneratorARM::MarkGCCard(Register temp, |
| 4261 | Register card, |
| 4262 | Register object, |
| 4263 | Register value, |
| 4264 | bool can_be_null) { |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 4265 | Label is_null; |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 4266 | if (can_be_null) { |
| 4267 | __ CompareAndBranchIfZero(value, &is_null); |
| 4268 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4269 | __ LoadFromOffset(kLoadWord, card, TR, Thread::CardTableOffset<kArmWordSize>().Int32Value()); |
| 4270 | __ Lsr(temp, object, gc::accounting::CardTable::kCardShift); |
| 4271 | __ strb(card, Address(card, temp)); |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 4272 | if (can_be_null) { |
| 4273 | __ Bind(&is_null); |
| 4274 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 4275 | } |
| 4276 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 4277 | void LocationsBuilderARM::VisitTemporary(HTemporary* temp) { |
| 4278 | temp->SetLocations(nullptr); |
| 4279 | } |
| 4280 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 4281 | void InstructionCodeGeneratorARM::VisitTemporary(HTemporary* temp ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 4282 | // Nothing to do, this is driven by the code generator. |
| 4283 | } |
| 4284 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 4285 | void LocationsBuilderARM::VisitParallelMove(HParallelMove* instruction ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4286 | LOG(FATAL) << "Unreachable"; |
Nicolas Geoffray | 4e3d23a | 2014-05-22 18:32:45 +0100 | [diff] [blame] | 4287 | } |
| 4288 | |
| 4289 | void InstructionCodeGeneratorARM::VisitParallelMove(HParallelMove* instruction) { |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4290 | codegen_->GetMoveResolver()->EmitNativeCode(instruction); |
| 4291 | } |
| 4292 | |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 4293 | void LocationsBuilderARM::VisitSuspendCheck(HSuspendCheck* instruction) { |
| 4294 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCallOnSlowPath); |
| 4295 | } |
| 4296 | |
| 4297 | void InstructionCodeGeneratorARM::VisitSuspendCheck(HSuspendCheck* instruction) { |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 4298 | HBasicBlock* block = instruction->GetBlock(); |
| 4299 | if (block->GetLoopInformation() != nullptr) { |
| 4300 | DCHECK(block->GetLoopInformation()->GetSuspendCheck() == instruction); |
| 4301 | // The back edge will generate the suspend check. |
| 4302 | return; |
| 4303 | } |
| 4304 | if (block->IsEntryBlock() && instruction->GetNext()->IsGoto()) { |
| 4305 | // The goto will generate the suspend check. |
| 4306 | return; |
| 4307 | } |
| 4308 | GenerateSuspendCheck(instruction, nullptr); |
| 4309 | } |
| 4310 | |
| 4311 | void InstructionCodeGeneratorARM::GenerateSuspendCheck(HSuspendCheck* instruction, |
| 4312 | HBasicBlock* successor) { |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 4313 | SuspendCheckSlowPathARM* slow_path = |
Nicolas Geoffray | db216f4 | 2015-05-05 17:02:20 +0100 | [diff] [blame] | 4314 | down_cast<SuspendCheckSlowPathARM*>(instruction->GetSlowPath()); |
| 4315 | if (slow_path == nullptr) { |
| 4316 | slow_path = new (GetGraph()->GetArena()) SuspendCheckSlowPathARM(instruction, successor); |
| 4317 | instruction->SetSlowPath(slow_path); |
| 4318 | codegen_->AddSlowPath(slow_path); |
| 4319 | if (successor != nullptr) { |
| 4320 | DCHECK(successor->IsLoopHeader()); |
| 4321 | codegen_->ClearSpillSlotsFromLoopPhisInStackMap(instruction); |
| 4322 | } |
| 4323 | } else { |
| 4324 | DCHECK_EQ(slow_path->GetSuccessor(), successor); |
| 4325 | } |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 4326 | |
Nicolas Geoffray | 44b819e | 2014-11-06 12:00:54 +0000 | [diff] [blame] | 4327 | __ LoadFromOffset( |
| 4328 | kLoadUnsignedHalfword, IP, TR, Thread::ThreadFlagsOffset<kArmWordSize>().Int32Value()); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 4329 | if (successor == nullptr) { |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 4330 | __ CompareAndBranchIfNonZero(IP, slow_path->GetEntryLabel()); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 4331 | __ Bind(slow_path->GetReturnLabel()); |
| 4332 | } else { |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 4333 | __ CompareAndBranchIfZero(IP, codegen_->GetLabelOf(successor)); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 4334 | __ b(slow_path->GetEntryLabel()); |
| 4335 | } |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 4336 | } |
| 4337 | |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4338 | ArmAssembler* ParallelMoveResolverARM::GetAssembler() const { |
| 4339 | return codegen_->GetAssembler(); |
| 4340 | } |
| 4341 | |
| 4342 | void ParallelMoveResolverARM::EmitMove(size_t index) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 4343 | MoveOperands* move = moves_[index]; |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4344 | Location source = move->GetSource(); |
| 4345 | Location destination = move->GetDestination(); |
| 4346 | |
| 4347 | if (source.IsRegister()) { |
| 4348 | if (destination.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4349 | __ Mov(destination.AsRegister<Register>(), source.AsRegister<Register>()); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4350 | } else { |
| 4351 | DCHECK(destination.IsStackSlot()); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4352 | __ StoreToOffset(kStoreWord, source.AsRegister<Register>(), |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4353 | SP, destination.GetStackIndex()); |
| 4354 | } |
| 4355 | } else if (source.IsStackSlot()) { |
| 4356 | if (destination.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4357 | __ LoadFromOffset(kLoadWord, destination.AsRegister<Register>(), |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4358 | SP, source.GetStackIndex()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4359 | } else if (destination.IsFpuRegister()) { |
| 4360 | __ LoadSFromOffset(destination.AsFpuRegister<SRegister>(), SP, source.GetStackIndex()); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4361 | } else { |
| 4362 | DCHECK(destination.IsStackSlot()); |
| 4363 | __ LoadFromOffset(kLoadWord, IP, SP, source.GetStackIndex()); |
| 4364 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex()); |
| 4365 | } |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4366 | } else if (source.IsFpuRegister()) { |
| 4367 | if (destination.IsFpuRegister()) { |
| 4368 | __ vmovs(destination.AsFpuRegister<SRegister>(), source.AsFpuRegister<SRegister>()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 4369 | } else { |
| 4370 | DCHECK(destination.IsStackSlot()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4371 | __ StoreSToOffset(source.AsFpuRegister<SRegister>(), SP, destination.GetStackIndex()); |
| 4372 | } |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4373 | } else if (source.IsDoubleStackSlot()) { |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4374 | if (destination.IsDoubleStackSlot()) { |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4375 | __ LoadDFromOffset(DTMP, SP, source.GetStackIndex()); |
| 4376 | __ StoreDToOffset(DTMP, SP, destination.GetStackIndex()); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4377 | } else if (destination.IsRegisterPair()) { |
| 4378 | DCHECK(ExpectedPairLayout(destination)); |
| 4379 | __ LoadFromOffset( |
| 4380 | kLoadWordPair, destination.AsRegisterPairLow<Register>(), SP, source.GetStackIndex()); |
| 4381 | } else { |
| 4382 | DCHECK(destination.IsFpuRegisterPair()) << destination; |
| 4383 | __ LoadDFromOffset(FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()), |
| 4384 | SP, |
| 4385 | source.GetStackIndex()); |
| 4386 | } |
| 4387 | } else if (source.IsRegisterPair()) { |
| 4388 | if (destination.IsRegisterPair()) { |
| 4389 | __ Mov(destination.AsRegisterPairLow<Register>(), source.AsRegisterPairLow<Register>()); |
| 4390 | __ Mov(destination.AsRegisterPairHigh<Register>(), source.AsRegisterPairHigh<Register>()); |
| 4391 | } else { |
| 4392 | DCHECK(destination.IsDoubleStackSlot()) << destination; |
| 4393 | DCHECK(ExpectedPairLayout(source)); |
| 4394 | __ StoreToOffset( |
| 4395 | kStoreWordPair, source.AsRegisterPairLow<Register>(), SP, destination.GetStackIndex()); |
| 4396 | } |
| 4397 | } else if (source.IsFpuRegisterPair()) { |
| 4398 | if (destination.IsFpuRegisterPair()) { |
| 4399 | __ vmovd(FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()), |
| 4400 | FromLowSToD(source.AsFpuRegisterPairLow<SRegister>())); |
| 4401 | } else { |
| 4402 | DCHECK(destination.IsDoubleStackSlot()) << destination; |
| 4403 | __ StoreDToOffset(FromLowSToD(source.AsFpuRegisterPairLow<SRegister>()), |
| 4404 | SP, |
| 4405 | destination.GetStackIndex()); |
| 4406 | } |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4407 | } else { |
| 4408 | DCHECK(source.IsConstant()) << source; |
Nicolas Geoffray | d6138ef | 2015-02-18 14:48:53 +0000 | [diff] [blame] | 4409 | HConstant* constant = source.GetConstant(); |
| 4410 | if (constant->IsIntConstant() || constant->IsNullConstant()) { |
| 4411 | int32_t value = CodeGenerator::GetInt32ValueOf(constant); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4412 | if (destination.IsRegister()) { |
| 4413 | __ LoadImmediate(destination.AsRegister<Register>(), value); |
| 4414 | } else { |
| 4415 | DCHECK(destination.IsStackSlot()); |
| 4416 | __ LoadImmediate(IP, value); |
| 4417 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex()); |
| 4418 | } |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 4419 | } else if (constant->IsLongConstant()) { |
| 4420 | int64_t value = constant->AsLongConstant()->GetValue(); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4421 | if (destination.IsRegisterPair()) { |
| 4422 | __ LoadImmediate(destination.AsRegisterPairLow<Register>(), Low32Bits(value)); |
| 4423 | __ LoadImmediate(destination.AsRegisterPairHigh<Register>(), High32Bits(value)); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 4424 | } else { |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4425 | DCHECK(destination.IsDoubleStackSlot()) << destination; |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 4426 | __ LoadImmediate(IP, Low32Bits(value)); |
| 4427 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex()); |
| 4428 | __ LoadImmediate(IP, High32Bits(value)); |
| 4429 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetHighStackIndex(kArmWordSize)); |
| 4430 | } |
| 4431 | } else if (constant->IsDoubleConstant()) { |
| 4432 | double value = constant->AsDoubleConstant()->GetValue(); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4433 | if (destination.IsFpuRegisterPair()) { |
| 4434 | __ LoadDImmediate(FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()), value); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 4435 | } else { |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4436 | DCHECK(destination.IsDoubleStackSlot()) << destination; |
| 4437 | uint64_t int_value = bit_cast<uint64_t, double>(value); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 4438 | __ LoadImmediate(IP, Low32Bits(int_value)); |
| 4439 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex()); |
| 4440 | __ LoadImmediate(IP, High32Bits(int_value)); |
| 4441 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetHighStackIndex(kArmWordSize)); |
| 4442 | } |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4443 | } else { |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 4444 | DCHECK(constant->IsFloatConstant()) << constant->DebugName(); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4445 | float value = constant->AsFloatConstant()->GetValue(); |
| 4446 | if (destination.IsFpuRegister()) { |
| 4447 | __ LoadSImmediate(destination.AsFpuRegister<SRegister>(), value); |
| 4448 | } else { |
| 4449 | DCHECK(destination.IsStackSlot()); |
| 4450 | __ LoadImmediate(IP, bit_cast<int32_t, float>(value)); |
| 4451 | __ StoreToOffset(kStoreWord, IP, SP, destination.GetStackIndex()); |
| 4452 | } |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 4453 | } |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4454 | } |
| 4455 | } |
| 4456 | |
| 4457 | void ParallelMoveResolverARM::Exchange(Register reg, int mem) { |
| 4458 | __ Mov(IP, reg); |
| 4459 | __ LoadFromOffset(kLoadWord, reg, SP, mem); |
| 4460 | __ StoreToOffset(kStoreWord, IP, SP, mem); |
| 4461 | } |
| 4462 | |
| 4463 | void ParallelMoveResolverARM::Exchange(int mem1, int mem2) { |
| 4464 | ScratchRegisterScope ensure_scratch(this, IP, R0, codegen_->GetNumberOfCoreRegisters()); |
| 4465 | int stack_offset = ensure_scratch.IsSpilled() ? kArmWordSize : 0; |
| 4466 | __ LoadFromOffset(kLoadWord, static_cast<Register>(ensure_scratch.GetRegister()), |
| 4467 | SP, mem1 + stack_offset); |
| 4468 | __ LoadFromOffset(kLoadWord, IP, SP, mem2 + stack_offset); |
| 4469 | __ StoreToOffset(kStoreWord, static_cast<Register>(ensure_scratch.GetRegister()), |
| 4470 | SP, mem2 + stack_offset); |
| 4471 | __ StoreToOffset(kStoreWord, IP, SP, mem1 + stack_offset); |
| 4472 | } |
| 4473 | |
| 4474 | void ParallelMoveResolverARM::EmitSwap(size_t index) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 4475 | MoveOperands* move = moves_[index]; |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4476 | Location source = move->GetSource(); |
| 4477 | Location destination = move->GetDestination(); |
| 4478 | |
| 4479 | if (source.IsRegister() && destination.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4480 | DCHECK_NE(source.AsRegister<Register>(), IP); |
| 4481 | DCHECK_NE(destination.AsRegister<Register>(), IP); |
| 4482 | __ Mov(IP, source.AsRegister<Register>()); |
| 4483 | __ Mov(source.AsRegister<Register>(), destination.AsRegister<Register>()); |
| 4484 | __ Mov(destination.AsRegister<Register>(), IP); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4485 | } else if (source.IsRegister() && destination.IsStackSlot()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4486 | Exchange(source.AsRegister<Register>(), destination.GetStackIndex()); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4487 | } else if (source.IsStackSlot() && destination.IsRegister()) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4488 | Exchange(destination.AsRegister<Register>(), source.GetStackIndex()); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4489 | } else if (source.IsStackSlot() && destination.IsStackSlot()) { |
| 4490 | Exchange(source.GetStackIndex(), destination.GetStackIndex()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4491 | } else if (source.IsFpuRegister() && destination.IsFpuRegister()) { |
Nicolas Geoffray | a8eef82 | 2015-01-16 11:14:27 +0000 | [diff] [blame] | 4492 | __ vmovrs(IP, source.AsFpuRegister<SRegister>()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4493 | __ vmovs(source.AsFpuRegister<SRegister>(), destination.AsFpuRegister<SRegister>()); |
Nicolas Geoffray | a8eef82 | 2015-01-16 11:14:27 +0000 | [diff] [blame] | 4494 | __ vmovsr(destination.AsFpuRegister<SRegister>(), IP); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4495 | } else if (source.IsRegisterPair() && destination.IsRegisterPair()) { |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4496 | __ vmovdrr(DTMP, source.AsRegisterPairLow<Register>(), source.AsRegisterPairHigh<Register>()); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4497 | __ Mov(source.AsRegisterPairLow<Register>(), destination.AsRegisterPairLow<Register>()); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4498 | __ Mov(source.AsRegisterPairHigh<Register>(), destination.AsRegisterPairHigh<Register>()); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4499 | __ vmovrrd(destination.AsRegisterPairLow<Register>(), |
| 4500 | destination.AsRegisterPairHigh<Register>(), |
| 4501 | DTMP); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4502 | } else if (source.IsRegisterPair() || destination.IsRegisterPair()) { |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4503 | Register low_reg = source.IsRegisterPair() |
| 4504 | ? source.AsRegisterPairLow<Register>() |
| 4505 | : destination.AsRegisterPairLow<Register>(); |
| 4506 | int mem = source.IsRegisterPair() |
| 4507 | ? destination.GetStackIndex() |
| 4508 | : source.GetStackIndex(); |
| 4509 | DCHECK(ExpectedPairLayout(source.IsRegisterPair() ? source : destination)); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4510 | __ vmovdrr(DTMP, low_reg, static_cast<Register>(low_reg + 1)); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4511 | __ LoadFromOffset(kLoadWordPair, low_reg, SP, mem); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4512 | __ StoreDToOffset(DTMP, SP, mem); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4513 | } else if (source.IsFpuRegisterPair() && destination.IsFpuRegisterPair()) { |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4514 | DRegister first = FromLowSToD(source.AsFpuRegisterPairLow<SRegister>()); |
| 4515 | DRegister second = FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4516 | __ vmovd(DTMP, first); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4517 | __ vmovd(first, second); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4518 | __ vmovd(second, DTMP); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4519 | } else if (source.IsFpuRegisterPair() || destination.IsFpuRegisterPair()) { |
| 4520 | DRegister reg = source.IsFpuRegisterPair() |
| 4521 | ? FromLowSToD(source.AsFpuRegisterPairLow<SRegister>()) |
| 4522 | : FromLowSToD(destination.AsFpuRegisterPairLow<SRegister>()); |
| 4523 | int mem = source.IsFpuRegisterPair() |
| 4524 | ? destination.GetStackIndex() |
| 4525 | : source.GetStackIndex(); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4526 | __ vmovd(DTMP, reg); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4527 | __ LoadDFromOffset(reg, SP, mem); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 4528 | __ StoreDToOffset(DTMP, SP, mem); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 4529 | } else if (source.IsFpuRegister() || destination.IsFpuRegister()) { |
| 4530 | SRegister reg = source.IsFpuRegister() ? source.AsFpuRegister<SRegister>() |
| 4531 | : destination.AsFpuRegister<SRegister>(); |
| 4532 | int mem = source.IsFpuRegister() |
| 4533 | ? destination.GetStackIndex() |
| 4534 | : source.GetStackIndex(); |
| 4535 | |
Nicolas Geoffray | a8eef82 | 2015-01-16 11:14:27 +0000 | [diff] [blame] | 4536 | __ vmovrs(IP, reg); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 4537 | __ LoadSFromOffset(reg, SP, mem); |
Nicolas Geoffray | a8eef82 | 2015-01-16 11:14:27 +0000 | [diff] [blame] | 4538 | __ StoreToOffset(kStoreWord, IP, SP, mem); |
Nicolas Geoffray | 53f1262 | 2015-01-13 18:04:41 +0000 | [diff] [blame] | 4539 | } else if (source.IsDoubleStackSlot() && destination.IsDoubleStackSlot()) { |
Nicolas Geoffray | 53f1262 | 2015-01-13 18:04:41 +0000 | [diff] [blame] | 4540 | Exchange(source.GetStackIndex(), destination.GetStackIndex()); |
| 4541 | Exchange(source.GetHighStackIndex(kArmWordSize), destination.GetHighStackIndex(kArmWordSize)); |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4542 | } else { |
Nicolas Geoffray | 53f1262 | 2015-01-13 18:04:41 +0000 | [diff] [blame] | 4543 | LOG(FATAL) << "Unimplemented" << source << " <-> " << destination; |
Nicolas Geoffray | e27f31a | 2014-06-12 17:53:14 +0100 | [diff] [blame] | 4544 | } |
| 4545 | } |
| 4546 | |
| 4547 | void ParallelMoveResolverARM::SpillScratch(int reg) { |
| 4548 | __ Push(static_cast<Register>(reg)); |
| 4549 | } |
| 4550 | |
| 4551 | void ParallelMoveResolverARM::RestoreScratch(int reg) { |
| 4552 | __ Pop(static_cast<Register>(reg)); |
Nicolas Geoffray | 4e3d23a | 2014-05-22 18:32:45 +0100 | [diff] [blame] | 4553 | } |
| 4554 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4555 | void LocationsBuilderARM::VisitLoadClass(HLoadClass* cls) { |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4556 | InvokeRuntimeCallingConvention calling_convention; |
| 4557 | CodeGenerator::CreateLoadClassLocationSummary( |
| 4558 | cls, |
| 4559 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), |
| 4560 | Location::RegisterLocation(R0)); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4561 | } |
| 4562 | |
| 4563 | void InstructionCodeGeneratorARM::VisitLoadClass(HLoadClass* cls) { |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 4564 | LocationSummary* locations = cls->GetLocations(); |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4565 | if (cls->NeedsAccessCheck()) { |
| 4566 | codegen_->MoveConstant(locations->GetTemp(0), cls->GetTypeIndex()); |
| 4567 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pInitializeTypeAndVerifyAccess), |
| 4568 | cls, |
| 4569 | cls->GetDexPc(), |
| 4570 | nullptr); |
Calin Juravle | 580b609 | 2015-10-06 17:35:58 +0100 | [diff] [blame] | 4571 | return; |
| 4572 | } |
| 4573 | |
| 4574 | Register out = locations->Out().AsRegister<Register>(); |
| 4575 | Register current_method = locations->InAt(0).AsRegister<Register>(); |
| 4576 | if (cls->IsReferrersClass()) { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4577 | DCHECK(!cls->CanCallRuntime()); |
| 4578 | DCHECK(!cls->MustGenerateClinitCheck()); |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 4579 | __ LoadFromOffset( |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 4580 | kLoadWord, out, current_method, ArtMethod::DeclaringClassOffset().Int32Value()); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4581 | } else { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4582 | DCHECK(cls->CanCallRuntime()); |
Nicolas Geoffray | 76b1e17 | 2015-05-27 17:18:33 +0100 | [diff] [blame] | 4583 | __ LoadFromOffset(kLoadWord, |
| 4584 | out, |
| 4585 | current_method, |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 4586 | ArtMethod::DexCacheResolvedTypesOffset(kArmPointerSize).Int32Value()); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4587 | __ LoadFromOffset(kLoadWord, out, out, CodeGenerator::GetCacheOffset(cls->GetTypeIndex())); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 4588 | // TODO: We will need a read barrier here. |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4589 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 4590 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathARM( |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4591 | cls, cls, cls->GetDexPc(), cls->MustGenerateClinitCheck()); |
| 4592 | codegen_->AddSlowPath(slow_path); |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 4593 | __ CompareAndBranchIfZero(out, slow_path->GetEntryLabel()); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4594 | if (cls->MustGenerateClinitCheck()) { |
| 4595 | GenerateClassInitializationCheck(slow_path, out); |
| 4596 | } else { |
| 4597 | __ Bind(slow_path->GetExitLabel()); |
| 4598 | } |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4599 | } |
| 4600 | } |
| 4601 | |
| 4602 | void LocationsBuilderARM::VisitClinitCheck(HClinitCheck* check) { |
| 4603 | LocationSummary* locations = |
| 4604 | new (GetGraph()->GetArena()) LocationSummary(check, LocationSummary::kCallOnSlowPath); |
| 4605 | locations->SetInAt(0, Location::RequiresRegister()); |
| 4606 | if (check->HasUses()) { |
| 4607 | locations->SetOut(Location::SameAsFirstInput()); |
| 4608 | } |
| 4609 | } |
| 4610 | |
| 4611 | void InstructionCodeGeneratorARM::VisitClinitCheck(HClinitCheck* check) { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4612 | // We assume the class is not null. |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 4613 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathARM( |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4614 | check->GetLoadClass(), check, check->GetDexPc(), true); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4615 | codegen_->AddSlowPath(slow_path); |
Roland Levillain | 199f336 | 2014-11-27 17:15:16 +0000 | [diff] [blame] | 4616 | GenerateClassInitializationCheck(slow_path, |
| 4617 | check->GetLocations()->InAt(0).AsRegister<Register>()); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4618 | } |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4619 | |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 4620 | void InstructionCodeGeneratorARM::GenerateClassInitializationCheck( |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 4621 | SlowPathCode* slow_path, Register class_reg) { |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 4622 | __ LoadFromOffset(kLoadWord, IP, class_reg, mirror::Class::StatusOffset().Int32Value()); |
| 4623 | __ cmp(IP, ShifterOperand(mirror::Class::kStatusInitialized)); |
| 4624 | __ b(slow_path->GetEntryLabel(), LT); |
| 4625 | // Even if the initialized flag is set, we may be in a situation where caches are not synced |
| 4626 | // properly. Therefore, we do a memory fence. |
| 4627 | __ dmb(ISH); |
| 4628 | __ Bind(slow_path->GetExitLabel()); |
| 4629 | } |
| 4630 | |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 4631 | void LocationsBuilderARM::VisitLoadString(HLoadString* load) { |
| 4632 | LocationSummary* locations = |
| 4633 | new (GetGraph()->GetArena()) LocationSummary(load, LocationSummary::kCallOnSlowPath); |
Nicolas Geoffray | fbdaa30 | 2015-05-29 12:06:56 +0100 | [diff] [blame] | 4634 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 4635 | locations->SetOut(Location::RequiresRegister()); |
| 4636 | } |
| 4637 | |
| 4638 | void InstructionCodeGeneratorARM::VisitLoadString(HLoadString* load) { |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 4639 | SlowPathCode* slow_path = new (GetGraph()->GetArena()) LoadStringSlowPathARM(load); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 4640 | codegen_->AddSlowPath(slow_path); |
| 4641 | |
Nicolas Geoffray | fbdaa30 | 2015-05-29 12:06:56 +0100 | [diff] [blame] | 4642 | LocationSummary* locations = load->GetLocations(); |
| 4643 | Register out = locations->Out().AsRegister<Register>(); |
| 4644 | Register current_method = locations->InAt(0).AsRegister<Register>(); |
| 4645 | __ LoadFromOffset( |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 4646 | kLoadWord, out, current_method, ArtMethod::DeclaringClassOffset().Int32Value()); |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 4647 | __ LoadFromOffset(kLoadWord, out, out, mirror::Class::DexCacheStringsOffset().Int32Value()); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 4648 | __ LoadFromOffset(kLoadWord, out, out, CodeGenerator::GetCacheOffset(load->GetStringIndex())); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 4649 | // TODO: We will need a read barrier here. |
Nicolas Geoffray | 2bcb431 | 2015-07-01 12:22:56 +0100 | [diff] [blame] | 4650 | __ CompareAndBranchIfZero(out, slow_path->GetEntryLabel()); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 4651 | __ Bind(slow_path->GetExitLabel()); |
| 4652 | } |
| 4653 | |
David Brazdil | cb1c055 | 2015-08-04 16:22:25 +0100 | [diff] [blame] | 4654 | static int32_t GetExceptionTlsOffset() { |
| 4655 | return Thread::ExceptionOffset<kArmWordSize>().Int32Value(); |
| 4656 | } |
| 4657 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 4658 | void LocationsBuilderARM::VisitLoadException(HLoadException* load) { |
| 4659 | LocationSummary* locations = |
| 4660 | new (GetGraph()->GetArena()) LocationSummary(load, LocationSummary::kNoCall); |
| 4661 | locations->SetOut(Location::RequiresRegister()); |
| 4662 | } |
| 4663 | |
| 4664 | void InstructionCodeGeneratorARM::VisitLoadException(HLoadException* load) { |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4665 | Register out = load->GetLocations()->Out().AsRegister<Register>(); |
David Brazdil | cb1c055 | 2015-08-04 16:22:25 +0100 | [diff] [blame] | 4666 | __ LoadFromOffset(kLoadWord, out, TR, GetExceptionTlsOffset()); |
| 4667 | } |
| 4668 | |
| 4669 | void LocationsBuilderARM::VisitClearException(HClearException* clear) { |
| 4670 | new (GetGraph()->GetArena()) LocationSummary(clear, LocationSummary::kNoCall); |
| 4671 | } |
| 4672 | |
| 4673 | void InstructionCodeGeneratorARM::VisitClearException(HClearException* clear ATTRIBUTE_UNUSED) { |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 4674 | __ LoadImmediate(IP, 0); |
David Brazdil | cb1c055 | 2015-08-04 16:22:25 +0100 | [diff] [blame] | 4675 | __ StoreToOffset(kStoreWord, IP, TR, GetExceptionTlsOffset()); |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 4676 | } |
| 4677 | |
| 4678 | void LocationsBuilderARM::VisitThrow(HThrow* instruction) { |
| 4679 | LocationSummary* locations = |
| 4680 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 4681 | InvokeRuntimeCallingConvention calling_convention; |
| 4682 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 4683 | } |
| 4684 | |
| 4685 | void InstructionCodeGeneratorARM::VisitThrow(HThrow* instruction) { |
| 4686 | codegen_->InvokeRuntime( |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 4687 | QUICK_ENTRY_POINT(pDeliverException), instruction, instruction->GetDexPc(), nullptr); |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 4688 | } |
| 4689 | |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4690 | void LocationsBuilderARM::VisitInstanceOf(HInstanceOf* instruction) { |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4691 | LocationSummary::CallKind call_kind = LocationSummary::kNoCall; |
| 4692 | switch (instruction->GetTypeCheckKind()) { |
| 4693 | case TypeCheckKind::kExactCheck: |
| 4694 | case TypeCheckKind::kAbstractClassCheck: |
| 4695 | case TypeCheckKind::kClassHierarchyCheck: |
| 4696 | case TypeCheckKind::kArrayObjectCheck: |
| 4697 | call_kind = LocationSummary::kNoCall; |
| 4698 | break; |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4699 | case TypeCheckKind::kUnresolvedCheck: |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4700 | case TypeCheckKind::kInterfaceCheck: |
| 4701 | call_kind = LocationSummary::kCall; |
| 4702 | break; |
| 4703 | case TypeCheckKind::kArrayCheck: |
| 4704 | call_kind = LocationSummary::kCallOnSlowPath; |
| 4705 | break; |
| 4706 | } |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4707 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4708 | if (call_kind != LocationSummary::kCall) { |
| 4709 | locations->SetInAt(0, Location::RequiresRegister()); |
| 4710 | locations->SetInAt(1, Location::RequiresRegister()); |
| 4711 | // The out register is used as a temporary, so it overlaps with the inputs. |
| 4712 | // Note that TypeCheckSlowPathARM uses this register too. |
| 4713 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
| 4714 | } else { |
| 4715 | InvokeRuntimeCallingConvention calling_convention; |
| 4716 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 4717 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 4718 | locations->SetOut(Location::RegisterLocation(R0)); |
| 4719 | } |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4720 | } |
| 4721 | |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4722 | void InstructionCodeGeneratorARM::VisitInstanceOf(HInstanceOf* instruction) { |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4723 | LocationSummary* locations = instruction->GetLocations(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4724 | Register obj = locations->InAt(0).AsRegister<Register>(); |
| 4725 | Register cls = locations->InAt(1).AsRegister<Register>(); |
| 4726 | Register out = locations->Out().AsRegister<Register>(); |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4727 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4728 | uint32_t super_offset = mirror::Class::SuperClassOffset().Int32Value(); |
| 4729 | uint32_t component_offset = mirror::Class::ComponentTypeOffset().Int32Value(); |
| 4730 | uint32_t primitive_offset = mirror::Class::PrimitiveTypeOffset().Int32Value(); |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 4731 | Label done, zero; |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 4732 | SlowPathCode* slow_path = nullptr; |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4733 | |
| 4734 | // Return 0 if `obj` is null. |
Guillaume "Vermeille" Sanchez | af88835 | 2015-04-20 14:41:30 +0100 | [diff] [blame] | 4735 | // avoid null check if we know obj is not null. |
| 4736 | if (instruction->MustDoNullCheck()) { |
Nicolas Geoffray | d56376c | 2015-05-21 12:32:34 +0000 | [diff] [blame] | 4737 | __ CompareAndBranchIfZero(obj, &zero); |
Guillaume "Vermeille" Sanchez | af88835 | 2015-04-20 14:41:30 +0100 | [diff] [blame] | 4738 | } |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4739 | |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4740 | // In case of an interface/unresolved check, we put the object class into the object register. |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4741 | // This is safe, as the register is caller-save, and the object must be in another |
| 4742 | // register if it survives the runtime call. |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4743 | Register target = (instruction->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) || |
| 4744 | (instruction->GetTypeCheckKind() == TypeCheckKind::kUnresolvedCheck) |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4745 | ? obj |
| 4746 | : out; |
| 4747 | __ LoadFromOffset(kLoadWord, target, obj, class_offset); |
| 4748 | __ MaybeUnpoisonHeapReference(target); |
| 4749 | |
| 4750 | switch (instruction->GetTypeCheckKind()) { |
| 4751 | case TypeCheckKind::kExactCheck: { |
| 4752 | __ cmp(out, ShifterOperand(cls)); |
| 4753 | // Classes must be equal for the instanceof to succeed. |
| 4754 | __ b(&zero, NE); |
| 4755 | __ LoadImmediate(out, 1); |
| 4756 | __ b(&done); |
| 4757 | break; |
| 4758 | } |
| 4759 | case TypeCheckKind::kAbstractClassCheck: { |
| 4760 | // If the class is abstract, we eagerly fetch the super class of the |
| 4761 | // object to avoid doing a comparison we know will fail. |
| 4762 | Label loop; |
| 4763 | __ Bind(&loop); |
| 4764 | __ LoadFromOffset(kLoadWord, out, out, super_offset); |
| 4765 | __ MaybeUnpoisonHeapReference(out); |
| 4766 | // If `out` is null, we use it for the result, and jump to `done`. |
| 4767 | __ CompareAndBranchIfZero(out, &done); |
| 4768 | __ cmp(out, ShifterOperand(cls)); |
| 4769 | __ b(&loop, NE); |
| 4770 | __ LoadImmediate(out, 1); |
| 4771 | if (zero.IsLinked()) { |
| 4772 | __ b(&done); |
| 4773 | } |
| 4774 | break; |
| 4775 | } |
| 4776 | case TypeCheckKind::kClassHierarchyCheck: { |
| 4777 | // Walk over the class hierarchy to find a match. |
| 4778 | Label loop, success; |
| 4779 | __ Bind(&loop); |
| 4780 | __ cmp(out, ShifterOperand(cls)); |
| 4781 | __ b(&success, EQ); |
| 4782 | __ LoadFromOffset(kLoadWord, out, out, super_offset); |
| 4783 | __ MaybeUnpoisonHeapReference(out); |
| 4784 | __ CompareAndBranchIfNonZero(out, &loop); |
| 4785 | // If `out` is null, we use it for the result, and jump to `done`. |
| 4786 | __ b(&done); |
| 4787 | __ Bind(&success); |
| 4788 | __ LoadImmediate(out, 1); |
| 4789 | if (zero.IsLinked()) { |
| 4790 | __ b(&done); |
| 4791 | } |
| 4792 | break; |
| 4793 | } |
| 4794 | case TypeCheckKind::kArrayObjectCheck: { |
Nicolas Geoffray | abfcf18 | 2015-09-21 18:41:21 +0100 | [diff] [blame] | 4795 | // Do an exact check. |
| 4796 | Label exact_check; |
| 4797 | __ cmp(out, ShifterOperand(cls)); |
| 4798 | __ b(&exact_check, EQ); |
| 4799 | // Otherwise, we need to check that the object's class is a non primitive array. |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4800 | __ LoadFromOffset(kLoadWord, out, out, component_offset); |
| 4801 | __ MaybeUnpoisonHeapReference(out); |
| 4802 | // If `out` is null, we use it for the result, and jump to `done`. |
| 4803 | __ CompareAndBranchIfZero(out, &done); |
| 4804 | __ LoadFromOffset(kLoadUnsignedHalfword, out, out, primitive_offset); |
| 4805 | static_assert(Primitive::kPrimNot == 0, "Expected 0 for kPrimNot"); |
| 4806 | __ CompareAndBranchIfNonZero(out, &zero); |
Nicolas Geoffray | abfcf18 | 2015-09-21 18:41:21 +0100 | [diff] [blame] | 4807 | __ Bind(&exact_check); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4808 | __ LoadImmediate(out, 1); |
| 4809 | __ b(&done); |
| 4810 | break; |
| 4811 | } |
| 4812 | case TypeCheckKind::kArrayCheck: { |
| 4813 | __ cmp(out, ShifterOperand(cls)); |
| 4814 | DCHECK(locations->OnlyCallsOnSlowPath()); |
| 4815 | slow_path = new (GetGraph()->GetArena()) TypeCheckSlowPathARM( |
| 4816 | instruction, /* is_fatal */ false); |
| 4817 | codegen_->AddSlowPath(slow_path); |
| 4818 | __ b(slow_path->GetEntryLabel(), NE); |
| 4819 | __ LoadImmediate(out, 1); |
| 4820 | if (zero.IsLinked()) { |
| 4821 | __ b(&done); |
| 4822 | } |
| 4823 | break; |
| 4824 | } |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4825 | case TypeCheckKind::kUnresolvedCheck: |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4826 | case TypeCheckKind::kInterfaceCheck: |
| 4827 | default: { |
| 4828 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pInstanceofNonTrivial), |
| 4829 | instruction, |
| 4830 | instruction->GetDexPc(), |
| 4831 | nullptr); |
| 4832 | if (zero.IsLinked()) { |
| 4833 | __ b(&done); |
| 4834 | } |
| 4835 | break; |
| 4836 | } |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4837 | } |
Guillaume "Vermeille" Sanchez | af88835 | 2015-04-20 14:41:30 +0100 | [diff] [blame] | 4838 | |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4839 | if (zero.IsLinked()) { |
Guillaume "Vermeille" Sanchez | af88835 | 2015-04-20 14:41:30 +0100 | [diff] [blame] | 4840 | __ Bind(&zero); |
| 4841 | __ LoadImmediate(out, 0); |
| 4842 | } |
| 4843 | |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4844 | if (done.IsLinked()) { |
| 4845 | __ Bind(&done); |
| 4846 | } |
| 4847 | |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4848 | if (slow_path != nullptr) { |
| 4849 | __ Bind(slow_path->GetExitLabel()); |
| 4850 | } |
Nicolas Geoffray | 6f5c41f | 2014-11-06 08:59:20 +0000 | [diff] [blame] | 4851 | } |
| 4852 | |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4853 | void LocationsBuilderARM::VisitCheckCast(HCheckCast* instruction) { |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4854 | LocationSummary::CallKind call_kind = LocationSummary::kNoCall; |
| 4855 | bool throws_into_catch = instruction->CanThrowIntoCatchBlock(); |
| 4856 | |
| 4857 | switch (instruction->GetTypeCheckKind()) { |
| 4858 | case TypeCheckKind::kExactCheck: |
| 4859 | case TypeCheckKind::kAbstractClassCheck: |
| 4860 | case TypeCheckKind::kClassHierarchyCheck: |
| 4861 | case TypeCheckKind::kArrayObjectCheck: |
| 4862 | call_kind = throws_into_catch |
| 4863 | ? LocationSummary::kCallOnSlowPath |
| 4864 | : LocationSummary::kNoCall; |
| 4865 | break; |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4866 | case TypeCheckKind::kUnresolvedCheck: |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4867 | case TypeCheckKind::kInterfaceCheck: |
| 4868 | call_kind = LocationSummary::kCall; |
| 4869 | break; |
| 4870 | case TypeCheckKind::kArrayCheck: |
| 4871 | call_kind = LocationSummary::kCallOnSlowPath; |
| 4872 | break; |
| 4873 | } |
| 4874 | |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4875 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary( |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4876 | instruction, call_kind); |
| 4877 | if (call_kind != LocationSummary::kCall) { |
| 4878 | locations->SetInAt(0, Location::RequiresRegister()); |
| 4879 | locations->SetInAt(1, Location::RequiresRegister()); |
| 4880 | // Note that TypeCheckSlowPathARM uses this register too. |
| 4881 | locations->AddTemp(Location::RequiresRegister()); |
| 4882 | } else { |
| 4883 | InvokeRuntimeCallingConvention calling_convention; |
| 4884 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 4885 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 4886 | } |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4887 | } |
| 4888 | |
| 4889 | void InstructionCodeGeneratorARM::VisitCheckCast(HCheckCast* instruction) { |
| 4890 | LocationSummary* locations = instruction->GetLocations(); |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 4891 | Register obj = locations->InAt(0).AsRegister<Register>(); |
| 4892 | Register cls = locations->InAt(1).AsRegister<Register>(); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4893 | Register temp = locations->WillCall() |
| 4894 | ? Register(kNoRegister) |
| 4895 | : locations->GetTemp(0).AsRegister<Register>(); |
| 4896 | |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4897 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4898 | uint32_t super_offset = mirror::Class::SuperClassOffset().Int32Value(); |
| 4899 | uint32_t component_offset = mirror::Class::ComponentTypeOffset().Int32Value(); |
| 4900 | uint32_t primitive_offset = mirror::Class::PrimitiveTypeOffset().Int32Value(); |
| 4901 | SlowPathCode* slow_path = nullptr; |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4902 | |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4903 | if (!locations->WillCall()) { |
| 4904 | slow_path = new (GetGraph()->GetArena()) TypeCheckSlowPathARM( |
| 4905 | instruction, !locations->CanCall()); |
| 4906 | codegen_->AddSlowPath(slow_path); |
Nicolas Geoffray | 64acf30 | 2015-09-14 22:20:29 +0100 | [diff] [blame] | 4907 | } |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4908 | |
| 4909 | Label done; |
| 4910 | // Avoid null check if we know obj is not null. |
| 4911 | if (instruction->MustDoNullCheck()) { |
| 4912 | __ CompareAndBranchIfZero(obj, &done); |
| 4913 | } |
| 4914 | |
| 4915 | if (locations->WillCall()) { |
| 4916 | __ LoadFromOffset(kLoadWord, obj, obj, class_offset); |
| 4917 | __ MaybeUnpoisonHeapReference(obj); |
| 4918 | } else { |
| 4919 | __ LoadFromOffset(kLoadWord, temp, obj, class_offset); |
| 4920 | __ MaybeUnpoisonHeapReference(temp); |
| 4921 | } |
| 4922 | |
| 4923 | switch (instruction->GetTypeCheckKind()) { |
| 4924 | case TypeCheckKind::kExactCheck: |
| 4925 | case TypeCheckKind::kArrayCheck: { |
| 4926 | __ cmp(temp, ShifterOperand(cls)); |
| 4927 | // Jump to slow path for throwing the exception or doing a |
| 4928 | // more involved array check. |
| 4929 | __ b(slow_path->GetEntryLabel(), NE); |
| 4930 | break; |
| 4931 | } |
| 4932 | case TypeCheckKind::kAbstractClassCheck: { |
| 4933 | // If the class is abstract, we eagerly fetch the super class of the |
| 4934 | // object to avoid doing a comparison we know will fail. |
| 4935 | Label loop; |
| 4936 | __ Bind(&loop); |
| 4937 | __ LoadFromOffset(kLoadWord, temp, temp, super_offset); |
| 4938 | __ MaybeUnpoisonHeapReference(temp); |
| 4939 | // Jump to the slow path to throw the exception. |
| 4940 | __ CompareAndBranchIfZero(temp, slow_path->GetEntryLabel()); |
| 4941 | __ cmp(temp, ShifterOperand(cls)); |
| 4942 | __ b(&loop, NE); |
| 4943 | break; |
| 4944 | } |
| 4945 | case TypeCheckKind::kClassHierarchyCheck: { |
| 4946 | // Walk over the class hierarchy to find a match. |
Nicolas Geoffray | abfcf18 | 2015-09-21 18:41:21 +0100 | [diff] [blame] | 4947 | Label loop; |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4948 | __ Bind(&loop); |
| 4949 | __ cmp(temp, ShifterOperand(cls)); |
Nicolas Geoffray | abfcf18 | 2015-09-21 18:41:21 +0100 | [diff] [blame] | 4950 | __ b(&done, EQ); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4951 | __ LoadFromOffset(kLoadWord, temp, temp, super_offset); |
| 4952 | __ MaybeUnpoisonHeapReference(temp); |
| 4953 | __ CompareAndBranchIfNonZero(temp, &loop); |
| 4954 | // Jump to the slow path to throw the exception. |
| 4955 | __ b(slow_path->GetEntryLabel()); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4956 | break; |
| 4957 | } |
| 4958 | case TypeCheckKind::kArrayObjectCheck: { |
Nicolas Geoffray | abfcf18 | 2015-09-21 18:41:21 +0100 | [diff] [blame] | 4959 | // Do an exact check. |
| 4960 | __ cmp(temp, ShifterOperand(cls)); |
| 4961 | __ b(&done, EQ); |
| 4962 | // Otherwise, we need to check that the object's class is a non primitive array. |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4963 | __ LoadFromOffset(kLoadWord, temp, temp, component_offset); |
| 4964 | __ MaybeUnpoisonHeapReference(temp); |
| 4965 | __ CompareAndBranchIfZero(temp, slow_path->GetEntryLabel()); |
| 4966 | __ LoadFromOffset(kLoadUnsignedHalfword, temp, temp, primitive_offset); |
| 4967 | static_assert(Primitive::kPrimNot == 0, "Expected 0 for kPrimNot"); |
| 4968 | __ CompareAndBranchIfNonZero(temp, slow_path->GetEntryLabel()); |
| 4969 | break; |
| 4970 | } |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 4971 | case TypeCheckKind::kUnresolvedCheck: |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 4972 | case TypeCheckKind::kInterfaceCheck: |
| 4973 | default: |
| 4974 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pCheckCast), |
| 4975 | instruction, |
| 4976 | instruction->GetDexPc(), |
| 4977 | nullptr); |
| 4978 | break; |
| 4979 | } |
| 4980 | __ Bind(&done); |
| 4981 | |
| 4982 | if (slow_path != nullptr) { |
| 4983 | __ Bind(slow_path->GetExitLabel()); |
| 4984 | } |
Nicolas Geoffray | 57a88d4 | 2014-11-10 15:09:21 +0000 | [diff] [blame] | 4985 | } |
| 4986 | |
Nicolas Geoffray | b7baf5c | 2014-11-11 16:29:44 +0000 | [diff] [blame] | 4987 | void LocationsBuilderARM::VisitMonitorOperation(HMonitorOperation* instruction) { |
| 4988 | LocationSummary* locations = |
| 4989 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 4990 | InvokeRuntimeCallingConvention calling_convention; |
| 4991 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 4992 | } |
| 4993 | |
| 4994 | void InstructionCodeGeneratorARM::VisitMonitorOperation(HMonitorOperation* instruction) { |
| 4995 | codegen_->InvokeRuntime(instruction->IsEnter() |
| 4996 | ? QUICK_ENTRY_POINT(pLockObject) : QUICK_ENTRY_POINT(pUnlockObject), |
| 4997 | instruction, |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 4998 | instruction->GetDexPc(), |
| 4999 | nullptr); |
Nicolas Geoffray | b7baf5c | 2014-11-11 16:29:44 +0000 | [diff] [blame] | 5000 | } |
| 5001 | |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5002 | void LocationsBuilderARM::VisitAnd(HAnd* instruction) { HandleBitwiseOperation(instruction, AND); } |
| 5003 | void LocationsBuilderARM::VisitOr(HOr* instruction) { HandleBitwiseOperation(instruction, ORR); } |
| 5004 | void LocationsBuilderARM::VisitXor(HXor* instruction) { HandleBitwiseOperation(instruction, EOR); } |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5005 | |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5006 | void LocationsBuilderARM::HandleBitwiseOperation(HBinaryOperation* instruction, Opcode opcode) { |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5007 | LocationSummary* locations = |
| 5008 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 5009 | DCHECK(instruction->GetResultType() == Primitive::kPrimInt |
| 5010 | || instruction->GetResultType() == Primitive::kPrimLong); |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5011 | // Note: GVN reorders commutative operations to have the constant on the right hand side. |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5012 | locations->SetInAt(0, Location::RequiresRegister()); |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5013 | locations->SetInAt(1, ArmEncodableConstantOrRegister(instruction->InputAt(1), opcode)); |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 5014 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5015 | } |
| 5016 | |
| 5017 | void InstructionCodeGeneratorARM::VisitAnd(HAnd* instruction) { |
| 5018 | HandleBitwiseOperation(instruction); |
| 5019 | } |
| 5020 | |
| 5021 | void InstructionCodeGeneratorARM::VisitOr(HOr* instruction) { |
| 5022 | HandleBitwiseOperation(instruction); |
| 5023 | } |
| 5024 | |
| 5025 | void InstructionCodeGeneratorARM::VisitXor(HXor* instruction) { |
| 5026 | HandleBitwiseOperation(instruction); |
| 5027 | } |
| 5028 | |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5029 | void InstructionCodeGeneratorARM::GenerateAndConst(Register out, Register first, uint32_t value) { |
| 5030 | // Optimize special cases for individual halfs of `and-long` (`and` is simplified earlier). |
| 5031 | if (value == 0xffffffffu) { |
| 5032 | if (out != first) { |
| 5033 | __ mov(out, ShifterOperand(first)); |
| 5034 | } |
| 5035 | return; |
| 5036 | } |
| 5037 | if (value == 0u) { |
| 5038 | __ mov(out, ShifterOperand(0)); |
| 5039 | return; |
| 5040 | } |
| 5041 | ShifterOperand so; |
| 5042 | if (__ ShifterOperandCanHold(kNoRegister, kNoRegister, AND, value, &so)) { |
| 5043 | __ and_(out, first, so); |
| 5044 | } else { |
| 5045 | DCHECK(__ ShifterOperandCanHold(kNoRegister, kNoRegister, BIC, ~value, &so)); |
| 5046 | __ bic(out, first, ShifterOperand(~value)); |
| 5047 | } |
| 5048 | } |
| 5049 | |
| 5050 | void InstructionCodeGeneratorARM::GenerateOrrConst(Register out, Register first, uint32_t value) { |
| 5051 | // Optimize special cases for individual halfs of `or-long` (`or` is simplified earlier). |
| 5052 | if (value == 0u) { |
| 5053 | if (out != first) { |
| 5054 | __ mov(out, ShifterOperand(first)); |
| 5055 | } |
| 5056 | return; |
| 5057 | } |
| 5058 | if (value == 0xffffffffu) { |
| 5059 | __ mvn(out, ShifterOperand(0)); |
| 5060 | return; |
| 5061 | } |
| 5062 | ShifterOperand so; |
| 5063 | if (__ ShifterOperandCanHold(kNoRegister, kNoRegister, ORR, value, &so)) { |
| 5064 | __ orr(out, first, so); |
| 5065 | } else { |
| 5066 | DCHECK(__ ShifterOperandCanHold(kNoRegister, kNoRegister, ORN, ~value, &so)); |
| 5067 | __ orn(out, first, ShifterOperand(~value)); |
| 5068 | } |
| 5069 | } |
| 5070 | |
| 5071 | void InstructionCodeGeneratorARM::GenerateEorConst(Register out, Register first, uint32_t value) { |
| 5072 | // Optimize special case for individual halfs of `xor-long` (`xor` is simplified earlier). |
| 5073 | if (value == 0u) { |
| 5074 | if (out != first) { |
| 5075 | __ mov(out, ShifterOperand(first)); |
| 5076 | } |
| 5077 | return; |
| 5078 | } |
| 5079 | __ eor(out, first, ShifterOperand(value)); |
| 5080 | } |
| 5081 | |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5082 | void InstructionCodeGeneratorARM::HandleBitwiseOperation(HBinaryOperation* instruction) { |
| 5083 | LocationSummary* locations = instruction->GetLocations(); |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5084 | Location first = locations->InAt(0); |
| 5085 | Location second = locations->InAt(1); |
| 5086 | Location out = locations->Out(); |
| 5087 | |
| 5088 | if (second.IsConstant()) { |
| 5089 | uint64_t value = static_cast<uint64_t>(Int64FromConstant(second.GetConstant())); |
| 5090 | uint32_t value_low = Low32Bits(value); |
| 5091 | if (instruction->GetResultType() == Primitive::kPrimInt) { |
| 5092 | Register first_reg = first.AsRegister<Register>(); |
| 5093 | Register out_reg = out.AsRegister<Register>(); |
| 5094 | if (instruction->IsAnd()) { |
| 5095 | GenerateAndConst(out_reg, first_reg, value_low); |
| 5096 | } else if (instruction->IsOr()) { |
| 5097 | GenerateOrrConst(out_reg, first_reg, value_low); |
| 5098 | } else { |
| 5099 | DCHECK(instruction->IsXor()); |
| 5100 | GenerateEorConst(out_reg, first_reg, value_low); |
| 5101 | } |
| 5102 | } else { |
| 5103 | DCHECK_EQ(instruction->GetResultType(), Primitive::kPrimLong); |
| 5104 | uint32_t value_high = High32Bits(value); |
| 5105 | Register first_low = first.AsRegisterPairLow<Register>(); |
| 5106 | Register first_high = first.AsRegisterPairHigh<Register>(); |
| 5107 | Register out_low = out.AsRegisterPairLow<Register>(); |
| 5108 | Register out_high = out.AsRegisterPairHigh<Register>(); |
| 5109 | if (instruction->IsAnd()) { |
| 5110 | GenerateAndConst(out_low, first_low, value_low); |
| 5111 | GenerateAndConst(out_high, first_high, value_high); |
| 5112 | } else if (instruction->IsOr()) { |
| 5113 | GenerateOrrConst(out_low, first_low, value_low); |
| 5114 | GenerateOrrConst(out_high, first_high, value_high); |
| 5115 | } else { |
| 5116 | DCHECK(instruction->IsXor()); |
| 5117 | GenerateEorConst(out_low, first_low, value_low); |
| 5118 | GenerateEorConst(out_high, first_high, value_high); |
| 5119 | } |
| 5120 | } |
| 5121 | return; |
| 5122 | } |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5123 | |
| 5124 | if (instruction->GetResultType() == Primitive::kPrimInt) { |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5125 | Register first_reg = first.AsRegister<Register>(); |
| 5126 | ShifterOperand second_reg(second.AsRegister<Register>()); |
| 5127 | Register out_reg = out.AsRegister<Register>(); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5128 | if (instruction->IsAnd()) { |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5129 | __ and_(out_reg, first_reg, second_reg); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5130 | } else if (instruction->IsOr()) { |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5131 | __ orr(out_reg, first_reg, second_reg); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5132 | } else { |
| 5133 | DCHECK(instruction->IsXor()); |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5134 | __ eor(out_reg, first_reg, second_reg); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5135 | } |
| 5136 | } else { |
| 5137 | DCHECK_EQ(instruction->GetResultType(), Primitive::kPrimLong); |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5138 | Register first_low = first.AsRegisterPairLow<Register>(); |
| 5139 | Register first_high = first.AsRegisterPairHigh<Register>(); |
| 5140 | ShifterOperand second_low(second.AsRegisterPairLow<Register>()); |
| 5141 | ShifterOperand second_high(second.AsRegisterPairHigh<Register>()); |
| 5142 | Register out_low = out.AsRegisterPairLow<Register>(); |
| 5143 | Register out_high = out.AsRegisterPairHigh<Register>(); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5144 | if (instruction->IsAnd()) { |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5145 | __ and_(out_low, first_low, second_low); |
| 5146 | __ and_(out_high, first_high, second_high); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5147 | } else if (instruction->IsOr()) { |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5148 | __ orr(out_low, first_low, second_low); |
| 5149 | __ orr(out_high, first_high, second_high); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5150 | } else { |
| 5151 | DCHECK(instruction->IsXor()); |
Vladimir Marko | d2b4ca2 | 2015-09-14 15:13:26 +0100 | [diff] [blame] | 5152 | __ eor(out_low, first_low, second_low); |
| 5153 | __ eor(out_high, first_high, second_high); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 5154 | } |
| 5155 | } |
| 5156 | } |
| 5157 | |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 5158 | HInvokeStaticOrDirect::DispatchInfo CodeGeneratorARM::GetSupportedInvokeStaticOrDirectDispatch( |
| 5159 | const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info, |
| 5160 | MethodReference target_method) { |
| 5161 | if (desired_dispatch_info.method_load_kind == |
| 5162 | HInvokeStaticOrDirect::MethodLoadKind::kDexCachePcRelative) { |
| 5163 | // TODO: Implement this type. For the moment, we fall back to kDexCacheViaMethod. |
| 5164 | return HInvokeStaticOrDirect::DispatchInfo { |
| 5165 | HInvokeStaticOrDirect::MethodLoadKind::kDexCacheViaMethod, |
| 5166 | HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod, |
| 5167 | 0u, |
| 5168 | 0u |
| 5169 | }; |
| 5170 | } |
| 5171 | if (desired_dispatch_info.code_ptr_location == |
| 5172 | HInvokeStaticOrDirect::CodePtrLocation::kCallPCRelative) { |
| 5173 | const DexFile& outer_dex_file = GetGraph()->GetDexFile(); |
| 5174 | if (&outer_dex_file != target_method.dex_file) { |
| 5175 | // Calls across dex files are more likely to exceed the available BL range, |
| 5176 | // so use absolute patch with fixup if available and kCallArtMethod otherwise. |
| 5177 | HInvokeStaticOrDirect::CodePtrLocation code_ptr_location = |
| 5178 | (desired_dispatch_info.method_load_kind == |
| 5179 | HInvokeStaticOrDirect::MethodLoadKind::kDirectAddressWithFixup) |
| 5180 | ? HInvokeStaticOrDirect::CodePtrLocation::kCallDirectWithFixup |
| 5181 | : HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod; |
| 5182 | return HInvokeStaticOrDirect::DispatchInfo { |
| 5183 | desired_dispatch_info.method_load_kind, |
| 5184 | code_ptr_location, |
| 5185 | desired_dispatch_info.method_load_data, |
| 5186 | 0u |
| 5187 | }; |
| 5188 | } |
| 5189 | } |
| 5190 | return desired_dispatch_info; |
| 5191 | } |
| 5192 | |
Nicolas Geoffray | 38207af | 2015-06-01 15:46:22 +0100 | [diff] [blame] | 5193 | void CodeGeneratorARM::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, Location temp) { |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5194 | // For better instruction scheduling we load the direct code pointer before the method pointer. |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5195 | switch (invoke->GetCodePtrLocation()) { |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5196 | case HInvokeStaticOrDirect::CodePtrLocation::kCallDirectWithFixup: |
| 5197 | // LR = code address from literal pool with link-time patch. |
| 5198 | __ LoadLiteral(LR, DeduplicateMethodCodeLiteral(invoke->GetTargetMethod())); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5199 | break; |
| 5200 | case HInvokeStaticOrDirect::CodePtrLocation::kCallDirect: |
| 5201 | // LR = invoke->GetDirectCodePtr(); |
| 5202 | __ LoadImmediate(LR, invoke->GetDirectCodePtr()); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5203 | break; |
| 5204 | default: |
| 5205 | break; |
| 5206 | } |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 5207 | |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5208 | Location callee_method = temp; // For all kinds except kRecursive, callee will be in temp. |
| 5209 | switch (invoke->GetMethodLoadKind()) { |
| 5210 | case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: |
| 5211 | // temp = thread->string_init_entrypoint |
| 5212 | __ LoadFromOffset(kLoadWord, temp.AsRegister<Register>(), TR, invoke->GetStringInitOffset()); |
| 5213 | break; |
| 5214 | case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: |
| 5215 | callee_method = invoke->GetLocations()->InAt(invoke->GetCurrentMethodInputIndex()); |
| 5216 | break; |
| 5217 | case HInvokeStaticOrDirect::MethodLoadKind::kDirectAddress: |
| 5218 | __ LoadImmediate(temp.AsRegister<Register>(), invoke->GetMethodAddress()); |
| 5219 | break; |
| 5220 | case HInvokeStaticOrDirect::MethodLoadKind::kDirectAddressWithFixup: |
| 5221 | __ LoadLiteral(temp.AsRegister<Register>(), |
| 5222 | DeduplicateMethodAddressLiteral(invoke->GetTargetMethod())); |
| 5223 | break; |
| 5224 | case HInvokeStaticOrDirect::MethodLoadKind::kDexCachePcRelative: |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 5225 | // TODO: Implement this type. |
| 5226 | // Currently filtered out by GetSupportedInvokeStaticOrDirectDispatch(). |
| 5227 | LOG(FATAL) << "Unsupported"; |
| 5228 | UNREACHABLE(); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5229 | case HInvokeStaticOrDirect::MethodLoadKind::kDexCacheViaMethod: { |
| 5230 | Location current_method = invoke->GetLocations()->InAt(invoke->GetCurrentMethodInputIndex()); |
| 5231 | Register method_reg; |
| 5232 | Register reg = temp.AsRegister<Register>(); |
| 5233 | if (current_method.IsRegister()) { |
| 5234 | method_reg = current_method.AsRegister<Register>(); |
| 5235 | } else { |
| 5236 | DCHECK(invoke->GetLocations()->Intrinsified()); |
| 5237 | DCHECK(!current_method.IsValid()); |
| 5238 | method_reg = reg; |
| 5239 | __ LoadFromOffset(kLoadWord, reg, SP, kCurrentMethodStackOffset); |
| 5240 | } |
| 5241 | // temp = current_method->dex_cache_resolved_methods_; |
| 5242 | __ LoadFromOffset( |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 5243 | kLoadWord, reg, method_reg, ArtMethod::DexCacheResolvedMethodsOffset( |
| 5244 | kArmPointerSize).Int32Value()); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5245 | // temp = temp[index_in_cache] |
| 5246 | uint32_t index_in_cache = invoke->GetTargetMethod().dex_method_index; |
| 5247 | __ LoadFromOffset(kLoadWord, reg, reg, CodeGenerator::GetCachePointerOffset(index_in_cache)); |
| 5248 | break; |
Nicolas Geoffray | ae71a05 | 2015-06-09 14:12:28 +0100 | [diff] [blame] | 5249 | } |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5250 | } |
| 5251 | |
| 5252 | switch (invoke->GetCodePtrLocation()) { |
| 5253 | case HInvokeStaticOrDirect::CodePtrLocation::kCallSelf: |
| 5254 | __ bl(GetFrameEntryLabel()); |
| 5255 | break; |
| 5256 | case HInvokeStaticOrDirect::CodePtrLocation::kCallPCRelative: |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 5257 | relative_call_patches_.emplace_back(invoke->GetTargetMethod()); |
| 5258 | __ Bind(&relative_call_patches_.back().label); |
| 5259 | // Arbitrarily branch to the BL itself, override at link time. |
| 5260 | __ bl(&relative_call_patches_.back().label); |
| 5261 | break; |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5262 | case HInvokeStaticOrDirect::CodePtrLocation::kCallDirectWithFixup: |
| 5263 | case HInvokeStaticOrDirect::CodePtrLocation::kCallDirect: |
| 5264 | // LR prepared above for better instruction scheduling. |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5265 | // LR() |
| 5266 | __ blx(LR); |
| 5267 | break; |
| 5268 | case HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod: |
| 5269 | // LR = callee_method->entry_point_from_quick_compiled_code_ |
| 5270 | __ LoadFromOffset( |
| 5271 | kLoadWord, LR, callee_method.AsRegister<Register>(), |
| 5272 | ArtMethod::EntryPointFromQuickCompiledCodeOffset(kArmWordSize).Int32Value()); |
| 5273 | // LR() |
| 5274 | __ blx(LR); |
| 5275 | break; |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 5276 | } |
| 5277 | |
Andreas Gampe | 2bcf9bf | 2015-01-29 09:56:07 -0800 | [diff] [blame] | 5278 | DCHECK(!IsLeafMethod()); |
| 5279 | } |
| 5280 | |
Andreas Gampe | bfb5ba9 | 2015-09-01 15:45:02 +0000 | [diff] [blame] | 5281 | void CodeGeneratorARM::GenerateVirtualCall(HInvokeVirtual* invoke, Location temp_location) { |
| 5282 | Register temp = temp_location.AsRegister<Register>(); |
| 5283 | uint32_t method_offset = mirror::Class::EmbeddedVTableEntryOffset( |
| 5284 | invoke->GetVTableIndex(), kArmPointerSize).Uint32Value(); |
| 5285 | LocationSummary* locations = invoke->GetLocations(); |
| 5286 | Location receiver = locations->InAt(0); |
| 5287 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
| 5288 | // temp = object->GetClass(); |
| 5289 | DCHECK(receiver.IsRegister()); |
| 5290 | __ LoadFromOffset(kLoadWord, temp, receiver.AsRegister<Register>(), class_offset); |
| 5291 | MaybeRecordImplicitNullCheck(invoke); |
| 5292 | __ MaybeUnpoisonHeapReference(temp); |
| 5293 | // temp = temp->GetMethodAt(method_offset); |
| 5294 | uint32_t entry_point = ArtMethod::EntryPointFromQuickCompiledCodeOffset( |
| 5295 | kArmWordSize).Int32Value(); |
| 5296 | __ LoadFromOffset(kLoadWord, temp, temp, method_offset); |
| 5297 | // LR = temp->GetEntryPoint(); |
| 5298 | __ LoadFromOffset(kLoadWord, LR, temp, entry_point); |
| 5299 | // LR(); |
| 5300 | __ blx(LR); |
| 5301 | } |
| 5302 | |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 5303 | void CodeGeneratorARM::EmitLinkerPatches(ArenaVector<LinkerPatch>* linker_patches) { |
| 5304 | DCHECK(linker_patches->empty()); |
| 5305 | size_t size = method_patches_.size() + call_patches_.size() + relative_call_patches_.size(); |
| 5306 | linker_patches->reserve(size); |
| 5307 | for (const auto& entry : method_patches_) { |
| 5308 | const MethodReference& target_method = entry.first; |
| 5309 | Literal* literal = entry.second; |
| 5310 | DCHECK(literal->GetLabel()->IsBound()); |
| 5311 | uint32_t literal_offset = literal->GetLabel()->Position(); |
| 5312 | linker_patches->push_back(LinkerPatch::MethodPatch(literal_offset, |
| 5313 | target_method.dex_file, |
| 5314 | target_method.dex_method_index)); |
| 5315 | } |
| 5316 | for (const auto& entry : call_patches_) { |
| 5317 | const MethodReference& target_method = entry.first; |
| 5318 | Literal* literal = entry.second; |
| 5319 | DCHECK(literal->GetLabel()->IsBound()); |
| 5320 | uint32_t literal_offset = literal->GetLabel()->Position(); |
| 5321 | linker_patches->push_back(LinkerPatch::CodePatch(literal_offset, |
| 5322 | target_method.dex_file, |
| 5323 | target_method.dex_method_index)); |
| 5324 | } |
| 5325 | for (const MethodPatchInfo<Label>& info : relative_call_patches_) { |
| 5326 | uint32_t literal_offset = info.label.Position(); |
| 5327 | linker_patches->push_back(LinkerPatch::RelativeCodePatch(literal_offset, |
| 5328 | info.target_method.dex_file, |
| 5329 | info.target_method.dex_method_index)); |
| 5330 | } |
| 5331 | } |
| 5332 | |
| 5333 | Literal* CodeGeneratorARM::DeduplicateMethodLiteral(MethodReference target_method, |
| 5334 | MethodToLiteralMap* map) { |
| 5335 | // Look up the literal for target_method. |
| 5336 | auto lb = map->lower_bound(target_method); |
| 5337 | if (lb != map->end() && !map->key_comp()(target_method, lb->first)) { |
| 5338 | return lb->second; |
| 5339 | } |
| 5340 | // We don't have a literal for this method yet, insert a new one. |
| 5341 | Literal* literal = __ NewLiteral<uint32_t>(0u); |
| 5342 | map->PutBefore(lb, target_method, literal); |
| 5343 | return literal; |
| 5344 | } |
| 5345 | |
| 5346 | Literal* CodeGeneratorARM::DeduplicateMethodAddressLiteral(MethodReference target_method) { |
| 5347 | return DeduplicateMethodLiteral(target_method, &method_patches_); |
| 5348 | } |
| 5349 | |
| 5350 | Literal* CodeGeneratorARM::DeduplicateMethodCodeLiteral(MethodReference target_method) { |
| 5351 | return DeduplicateMethodLiteral(target_method, &call_patches_); |
| 5352 | } |
| 5353 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 5354 | void LocationsBuilderARM::VisitBoundType(HBoundType* instruction ATTRIBUTE_UNUSED) { |
Calin Juravle | b1498f6 | 2015-02-16 13:13:29 +0000 | [diff] [blame] | 5355 | // Nothing to do, this should be removed during prepare for register allocator. |
Calin Juravle | b1498f6 | 2015-02-16 13:13:29 +0000 | [diff] [blame] | 5356 | LOG(FATAL) << "Unreachable"; |
| 5357 | } |
| 5358 | |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 5359 | void InstructionCodeGeneratorARM::VisitBoundType(HBoundType* instruction ATTRIBUTE_UNUSED) { |
Calin Juravle | b1498f6 | 2015-02-16 13:13:29 +0000 | [diff] [blame] | 5360 | // Nothing to do, this should be removed during prepare for register allocator. |
Calin Juravle | b1498f6 | 2015-02-16 13:13:29 +0000 | [diff] [blame] | 5361 | LOG(FATAL) << "Unreachable"; |
| 5362 | } |
| 5363 | |
Nicolas Geoffray | 2e7cd75 | 2015-07-10 11:38:52 +0100 | [diff] [blame] | 5364 | void LocationsBuilderARM::VisitFakeString(HFakeString* instruction) { |
| 5365 | DCHECK(codegen_->IsBaseline()); |
| 5366 | LocationSummary* locations = |
| 5367 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 5368 | locations->SetOut(Location::ConstantLocation(GetGraph()->GetNullConstant())); |
| 5369 | } |
| 5370 | |
| 5371 | void InstructionCodeGeneratorARM::VisitFakeString(HFakeString* instruction ATTRIBUTE_UNUSED) { |
| 5372 | DCHECK(codegen_->IsBaseline()); |
| 5373 | // Will be generated at use site. |
| 5374 | } |
| 5375 | |
Mark Mendell | fe57faa | 2015-09-18 09:26:15 -0400 | [diff] [blame] | 5376 | // Simple implementation of packed switch - generate cascaded compare/jumps. |
| 5377 | void LocationsBuilderARM::VisitPackedSwitch(HPackedSwitch* switch_instr) { |
| 5378 | LocationSummary* locations = |
| 5379 | new (GetGraph()->GetArena()) LocationSummary(switch_instr, LocationSummary::kNoCall); |
| 5380 | locations->SetInAt(0, Location::RequiresRegister()); |
| 5381 | } |
| 5382 | |
| 5383 | void InstructionCodeGeneratorARM::VisitPackedSwitch(HPackedSwitch* switch_instr) { |
| 5384 | int32_t lower_bound = switch_instr->GetStartValue(); |
| 5385 | int32_t num_entries = switch_instr->GetNumEntries(); |
| 5386 | LocationSummary* locations = switch_instr->GetLocations(); |
| 5387 | Register value_reg = locations->InAt(0).AsRegister<Register>(); |
| 5388 | HBasicBlock* default_block = switch_instr->GetDefaultBlock(); |
| 5389 | |
| 5390 | // Create a series of compare/jumps. |
| 5391 | const ArenaVector<HBasicBlock*>& successors = switch_instr->GetBlock()->GetSuccessors(); |
| 5392 | for (int32_t i = 0; i < num_entries; i++) { |
| 5393 | GenerateCompareWithImmediate(value_reg, lower_bound + i); |
Vladimir Marko | ec7802a | 2015-10-01 20:57:57 +0100 | [diff] [blame] | 5394 | __ b(codegen_->GetLabelOf(successors[i]), EQ); |
Mark Mendell | fe57faa | 2015-09-18 09:26:15 -0400 | [diff] [blame] | 5395 | } |
| 5396 | |
| 5397 | // And the default for any other value. |
| 5398 | if (!codegen_->GoesToNextBlock(switch_instr->GetBlock(), default_block)) { |
| 5399 | __ b(codegen_->GetLabelOf(default_block)); |
| 5400 | } |
| 5401 | } |
| 5402 | |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 5403 | void CodeGeneratorARM::MoveFromReturnRegister(Location trg, Primitive::Type type) { |
| 5404 | if (!trg.IsValid()) { |
| 5405 | DCHECK(type == Primitive::kPrimVoid); |
| 5406 | return; |
| 5407 | } |
| 5408 | |
| 5409 | DCHECK_NE(type, Primitive::kPrimVoid); |
| 5410 | |
| 5411 | Location return_loc = InvokeDexCallingConventionVisitorARM().GetReturnLocation(type); |
| 5412 | if (return_loc.Equals(trg)) { |
| 5413 | return; |
| 5414 | } |
| 5415 | |
| 5416 | // TODO: Consider pairs in the parallel move resolver, then this could be nicely merged |
| 5417 | // with the last branch. |
| 5418 | if (type == Primitive::kPrimLong) { |
| 5419 | HParallelMove parallel_move(GetGraph()->GetArena()); |
| 5420 | parallel_move.AddMove(return_loc.ToLow(), trg.ToLow(), Primitive::kPrimInt, nullptr); |
| 5421 | parallel_move.AddMove(return_loc.ToHigh(), trg.ToHigh(), Primitive::kPrimInt, nullptr); |
| 5422 | GetMoveResolver()->EmitNativeCode(¶llel_move); |
| 5423 | } else if (type == Primitive::kPrimDouble) { |
| 5424 | HParallelMove parallel_move(GetGraph()->GetArena()); |
| 5425 | parallel_move.AddMove(return_loc.ToLow(), trg.ToLow(), Primitive::kPrimFloat, nullptr); |
| 5426 | parallel_move.AddMove(return_loc.ToHigh(), trg.ToHigh(), Primitive::kPrimFloat, nullptr); |
| 5427 | GetMoveResolver()->EmitNativeCode(¶llel_move); |
| 5428 | } else { |
| 5429 | // Let the parallel move resolver take care of all of this. |
| 5430 | HParallelMove parallel_move(GetGraph()->GetArena()); |
| 5431 | parallel_move.AddMove(return_loc, trg, type, nullptr); |
| 5432 | GetMoveResolver()->EmitNativeCode(¶llel_move); |
| 5433 | } |
| 5434 | } |
| 5435 | |
Roland Levillain | 4d02711 | 2015-07-01 15:41:14 +0100 | [diff] [blame] | 5436 | #undef __ |
| 5437 | #undef QUICK_ENTRY_POINT |
| 5438 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 5439 | } // namespace arm |
| 5440 | } // namespace art |