Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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_mips64.h" |
| 18 | |
Alexey Frunze | c857c74 | 2015-09-23 15:12:39 -0700 | [diff] [blame] | 19 | #include "art_method.h" |
| 20 | #include "code_generator_utils.h" |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 21 | #include "entrypoints/quick/quick_entrypoints.h" |
| 22 | #include "entrypoints/quick/quick_entrypoints_enum.h" |
| 23 | #include "gc/accounting/card_table.h" |
| 24 | #include "intrinsics.h" |
Chris Larsen | 3039e38 | 2015-08-26 07:54:08 -0700 | [diff] [blame] | 25 | #include "intrinsics_mips64.h" |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 26 | #include "mirror/array-inl.h" |
| 27 | #include "mirror/class-inl.h" |
| 28 | #include "offsets.h" |
| 29 | #include "thread.h" |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 30 | #include "utils/assembler.h" |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 31 | #include "utils/mips64/assembler_mips64.h" |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 32 | #include "utils/stack_checks.h" |
| 33 | |
| 34 | namespace art { |
| 35 | namespace mips64 { |
| 36 | |
| 37 | static constexpr int kCurrentMethodStackOffset = 0; |
| 38 | static constexpr GpuRegister kMethodRegisterArgument = A0; |
| 39 | |
| 40 | // We need extra temporary/scratch registers (in addition to AT) in some cases. |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 41 | static constexpr FpuRegister FTMP = F8; |
| 42 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 43 | Location Mips64ReturnLocation(Primitive::Type return_type) { |
| 44 | switch (return_type) { |
| 45 | case Primitive::kPrimBoolean: |
| 46 | case Primitive::kPrimByte: |
| 47 | case Primitive::kPrimChar: |
| 48 | case Primitive::kPrimShort: |
| 49 | case Primitive::kPrimInt: |
| 50 | case Primitive::kPrimNot: |
| 51 | case Primitive::kPrimLong: |
| 52 | return Location::RegisterLocation(V0); |
| 53 | |
| 54 | case Primitive::kPrimFloat: |
| 55 | case Primitive::kPrimDouble: |
| 56 | return Location::FpuRegisterLocation(F0); |
| 57 | |
| 58 | case Primitive::kPrimVoid: |
| 59 | return Location(); |
| 60 | } |
| 61 | UNREACHABLE(); |
| 62 | } |
| 63 | |
| 64 | Location InvokeDexCallingConventionVisitorMIPS64::GetReturnLocation(Primitive::Type type) const { |
| 65 | return Mips64ReturnLocation(type); |
| 66 | } |
| 67 | |
| 68 | Location InvokeDexCallingConventionVisitorMIPS64::GetMethodLocation() const { |
| 69 | return Location::RegisterLocation(kMethodRegisterArgument); |
| 70 | } |
| 71 | |
| 72 | Location InvokeDexCallingConventionVisitorMIPS64::GetNextLocation(Primitive::Type type) { |
| 73 | Location next_location; |
| 74 | if (type == Primitive::kPrimVoid) { |
| 75 | LOG(FATAL) << "Unexpected parameter type " << type; |
| 76 | } |
| 77 | |
| 78 | if (Primitive::IsFloatingPointType(type) && |
| 79 | (float_index_ < calling_convention.GetNumberOfFpuRegisters())) { |
| 80 | next_location = Location::FpuRegisterLocation( |
| 81 | calling_convention.GetFpuRegisterAt(float_index_++)); |
| 82 | gp_index_++; |
| 83 | } else if (!Primitive::IsFloatingPointType(type) && |
| 84 | (gp_index_ < calling_convention.GetNumberOfRegisters())) { |
| 85 | next_location = Location::RegisterLocation(calling_convention.GetRegisterAt(gp_index_++)); |
| 86 | float_index_++; |
| 87 | } else { |
| 88 | size_t stack_offset = calling_convention.GetStackOffsetOf(stack_index_); |
| 89 | next_location = Primitive::Is64BitType(type) ? Location::DoubleStackSlot(stack_offset) |
| 90 | : Location::StackSlot(stack_offset); |
| 91 | } |
| 92 | |
| 93 | // Space on the stack is reserved for all arguments. |
| 94 | stack_index_ += Primitive::Is64BitType(type) ? 2 : 1; |
| 95 | |
| 96 | // TODO: review |
| 97 | |
| 98 | // TODO: shouldn't we use a whole machine word per argument on the stack? |
| 99 | // Implicit 4-byte method pointer (and such) will cause misalignment. |
| 100 | |
| 101 | return next_location; |
| 102 | } |
| 103 | |
| 104 | Location InvokeRuntimeCallingConvention::GetReturnLocation(Primitive::Type type) { |
| 105 | return Mips64ReturnLocation(type); |
| 106 | } |
| 107 | |
| 108 | #define __ down_cast<CodeGeneratorMIPS64*>(codegen)->GetAssembler()-> |
| 109 | #define QUICK_ENTRY_POINT(x) QUICK_ENTRYPOINT_OFFSET(kMips64WordSize, x).Int32Value() |
| 110 | |
| 111 | class BoundsCheckSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 112 | public: |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 113 | explicit BoundsCheckSlowPathMIPS64(HBoundsCheck* instruction) : instruction_(instruction) {} |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 114 | |
| 115 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 116 | LocationSummary* locations = instruction_->GetLocations(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 117 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 118 | __ Bind(GetEntryLabel()); |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 119 | if (instruction_->CanThrowIntoCatchBlock()) { |
| 120 | // Live registers will be restored in the catch block if caught. |
| 121 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 122 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 123 | // We're moving two locations to locations that could overlap, so we need a parallel |
| 124 | // move resolver. |
| 125 | InvokeRuntimeCallingConvention calling_convention; |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 126 | codegen->EmitParallelMoves(locations->InAt(0), |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 127 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), |
| 128 | Primitive::kPrimInt, |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 129 | locations->InAt(1), |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 130 | Location::RegisterLocation(calling_convention.GetRegisterAt(1)), |
| 131 | Primitive::kPrimInt); |
| 132 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pThrowArrayBounds), |
| 133 | instruction_, |
| 134 | instruction_->GetDexPc(), |
| 135 | this); |
| 136 | CheckEntrypointTypes<kQuickThrowArrayBounds, void, int32_t, int32_t>(); |
| 137 | } |
| 138 | |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 139 | bool IsFatal() const OVERRIDE { return true; } |
| 140 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 141 | const char* GetDescription() const OVERRIDE { return "BoundsCheckSlowPathMIPS64"; } |
| 142 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 143 | private: |
| 144 | HBoundsCheck* const instruction_; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 145 | |
| 146 | DISALLOW_COPY_AND_ASSIGN(BoundsCheckSlowPathMIPS64); |
| 147 | }; |
| 148 | |
| 149 | class DivZeroCheckSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 150 | public: |
| 151 | explicit DivZeroCheckSlowPathMIPS64(HDivZeroCheck* instruction) : instruction_(instruction) {} |
| 152 | |
| 153 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 154 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 155 | __ Bind(GetEntryLabel()); |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 156 | if (instruction_->CanThrowIntoCatchBlock()) { |
| 157 | // Live registers will be restored in the catch block if caught. |
| 158 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 159 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 160 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pThrowDivZero), |
| 161 | instruction_, |
| 162 | instruction_->GetDexPc(), |
| 163 | this); |
| 164 | CheckEntrypointTypes<kQuickThrowDivZero, void, void>(); |
| 165 | } |
| 166 | |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 167 | bool IsFatal() const OVERRIDE { return true; } |
| 168 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 169 | const char* GetDescription() const OVERRIDE { return "DivZeroCheckSlowPathMIPS64"; } |
| 170 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 171 | private: |
| 172 | HDivZeroCheck* const instruction_; |
| 173 | DISALLOW_COPY_AND_ASSIGN(DivZeroCheckSlowPathMIPS64); |
| 174 | }; |
| 175 | |
| 176 | class LoadClassSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 177 | public: |
| 178 | LoadClassSlowPathMIPS64(HLoadClass* cls, |
| 179 | HInstruction* at, |
| 180 | uint32_t dex_pc, |
| 181 | bool do_clinit) |
| 182 | : cls_(cls), at_(at), dex_pc_(dex_pc), do_clinit_(do_clinit) { |
| 183 | DCHECK(at->IsLoadClass() || at->IsClinitCheck()); |
| 184 | } |
| 185 | |
| 186 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 187 | LocationSummary* locations = at_->GetLocations(); |
| 188 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 189 | |
| 190 | __ Bind(GetEntryLabel()); |
| 191 | SaveLiveRegisters(codegen, locations); |
| 192 | |
| 193 | InvokeRuntimeCallingConvention calling_convention; |
| 194 | __ LoadConst32(calling_convention.GetRegisterAt(0), cls_->GetTypeIndex()); |
| 195 | int32_t entry_point_offset = do_clinit_ ? QUICK_ENTRY_POINT(pInitializeStaticStorage) |
| 196 | : QUICK_ENTRY_POINT(pInitializeType); |
| 197 | mips64_codegen->InvokeRuntime(entry_point_offset, at_, dex_pc_, this); |
| 198 | if (do_clinit_) { |
| 199 | CheckEntrypointTypes<kQuickInitializeStaticStorage, void*, uint32_t>(); |
| 200 | } else { |
| 201 | CheckEntrypointTypes<kQuickInitializeType, void*, uint32_t>(); |
| 202 | } |
| 203 | |
| 204 | // Move the class to the desired location. |
| 205 | Location out = locations->Out(); |
| 206 | if (out.IsValid()) { |
| 207 | DCHECK(out.IsRegister() && !locations->GetLiveRegisters()->ContainsCoreRegister(out.reg())); |
| 208 | Primitive::Type type = at_->GetType(); |
| 209 | mips64_codegen->MoveLocation(out, calling_convention.GetReturnLocation(type), type); |
| 210 | } |
| 211 | |
| 212 | RestoreLiveRegisters(codegen, locations); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 213 | __ Bc(GetExitLabel()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 214 | } |
| 215 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 216 | const char* GetDescription() const OVERRIDE { return "LoadClassSlowPathMIPS64"; } |
| 217 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 218 | private: |
| 219 | // The class this slow path will load. |
| 220 | HLoadClass* const cls_; |
| 221 | |
| 222 | // The instruction where this slow path is happening. |
| 223 | // (Might be the load class or an initialization check). |
| 224 | HInstruction* const at_; |
| 225 | |
| 226 | // The dex PC of `at_`. |
| 227 | const uint32_t dex_pc_; |
| 228 | |
| 229 | // Whether to initialize the class. |
| 230 | const bool do_clinit_; |
| 231 | |
| 232 | DISALLOW_COPY_AND_ASSIGN(LoadClassSlowPathMIPS64); |
| 233 | }; |
| 234 | |
| 235 | class LoadStringSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 236 | public: |
| 237 | explicit LoadStringSlowPathMIPS64(HLoadString* instruction) : instruction_(instruction) {} |
| 238 | |
| 239 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 240 | LocationSummary* locations = instruction_->GetLocations(); |
| 241 | DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg())); |
| 242 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 243 | |
| 244 | __ Bind(GetEntryLabel()); |
| 245 | SaveLiveRegisters(codegen, locations); |
| 246 | |
| 247 | InvokeRuntimeCallingConvention calling_convention; |
| 248 | __ LoadConst32(calling_convention.GetRegisterAt(0), instruction_->GetStringIndex()); |
| 249 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pResolveString), |
| 250 | instruction_, |
| 251 | instruction_->GetDexPc(), |
| 252 | this); |
| 253 | CheckEntrypointTypes<kQuickResolveString, void*, uint32_t>(); |
| 254 | Primitive::Type type = instruction_->GetType(); |
| 255 | mips64_codegen->MoveLocation(locations->Out(), |
| 256 | calling_convention.GetReturnLocation(type), |
| 257 | type); |
| 258 | |
| 259 | RestoreLiveRegisters(codegen, locations); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 260 | __ Bc(GetExitLabel()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 263 | const char* GetDescription() const OVERRIDE { return "LoadStringSlowPathMIPS64"; } |
| 264 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 265 | private: |
| 266 | HLoadString* const instruction_; |
| 267 | |
| 268 | DISALLOW_COPY_AND_ASSIGN(LoadStringSlowPathMIPS64); |
| 269 | }; |
| 270 | |
| 271 | class NullCheckSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 272 | public: |
| 273 | explicit NullCheckSlowPathMIPS64(HNullCheck* instr) : instruction_(instr) {} |
| 274 | |
| 275 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 276 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 277 | __ Bind(GetEntryLabel()); |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 278 | if (instruction_->CanThrowIntoCatchBlock()) { |
| 279 | // Live registers will be restored in the catch block if caught. |
| 280 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 281 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 282 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pThrowNullPointer), |
| 283 | instruction_, |
| 284 | instruction_->GetDexPc(), |
| 285 | this); |
| 286 | CheckEntrypointTypes<kQuickThrowNullPointer, void, void>(); |
| 287 | } |
| 288 | |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 289 | bool IsFatal() const OVERRIDE { return true; } |
| 290 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 291 | const char* GetDescription() const OVERRIDE { return "NullCheckSlowPathMIPS64"; } |
| 292 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 293 | private: |
| 294 | HNullCheck* const instruction_; |
| 295 | |
| 296 | DISALLOW_COPY_AND_ASSIGN(NullCheckSlowPathMIPS64); |
| 297 | }; |
| 298 | |
| 299 | class SuspendCheckSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 300 | public: |
Roland Levillain | 3887c46 | 2015-08-12 18:15:42 +0100 | [diff] [blame] | 301 | SuspendCheckSlowPathMIPS64(HSuspendCheck* instruction, HBasicBlock* successor) |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 302 | : instruction_(instruction), successor_(successor) {} |
| 303 | |
| 304 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 305 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 306 | __ Bind(GetEntryLabel()); |
| 307 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 308 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pTestSuspend), |
| 309 | instruction_, |
| 310 | instruction_->GetDexPc(), |
| 311 | this); |
| 312 | CheckEntrypointTypes<kQuickTestSuspend, void, void>(); |
| 313 | RestoreLiveRegisters(codegen, instruction_->GetLocations()); |
| 314 | if (successor_ == nullptr) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 315 | __ Bc(GetReturnLabel()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 316 | } else { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 317 | __ Bc(mips64_codegen->GetLabelOf(successor_)); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 318 | } |
| 319 | } |
| 320 | |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 321 | Mips64Label* GetReturnLabel() { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 322 | DCHECK(successor_ == nullptr); |
| 323 | return &return_label_; |
| 324 | } |
| 325 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 326 | const char* GetDescription() const OVERRIDE { return "SuspendCheckSlowPathMIPS64"; } |
| 327 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 328 | private: |
| 329 | HSuspendCheck* const instruction_; |
| 330 | // If not null, the block to branch to after the suspend check. |
| 331 | HBasicBlock* const successor_; |
| 332 | |
| 333 | // If `successor_` is null, the label to branch to after the suspend check. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 334 | Mips64Label return_label_; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 335 | |
| 336 | DISALLOW_COPY_AND_ASSIGN(SuspendCheckSlowPathMIPS64); |
| 337 | }; |
| 338 | |
| 339 | class TypeCheckSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 340 | public: |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 341 | explicit TypeCheckSlowPathMIPS64(HInstruction* instruction) : instruction_(instruction) {} |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 342 | |
| 343 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 344 | LocationSummary* locations = instruction_->GetLocations(); |
Goran Jakovljevic | f652cec | 2015-08-25 16:11:42 +0200 | [diff] [blame] | 345 | Location object_class = instruction_->IsCheckCast() ? locations->GetTemp(0) : locations->Out(); |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 346 | uint32_t dex_pc = instruction_->GetDexPc(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 347 | DCHECK(instruction_->IsCheckCast() |
| 348 | || !locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg())); |
| 349 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 350 | |
| 351 | __ Bind(GetEntryLabel()); |
| 352 | SaveLiveRegisters(codegen, locations); |
| 353 | |
| 354 | // We're moving two locations to locations that could overlap, so we need a parallel |
| 355 | // move resolver. |
| 356 | InvokeRuntimeCallingConvention calling_convention; |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 357 | codegen->EmitParallelMoves(locations->InAt(1), |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 358 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), |
| 359 | Primitive::kPrimNot, |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 360 | object_class, |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 361 | Location::RegisterLocation(calling_convention.GetRegisterAt(1)), |
| 362 | Primitive::kPrimNot); |
| 363 | |
| 364 | if (instruction_->IsInstanceOf()) { |
| 365 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pInstanceofNonTrivial), |
| 366 | instruction_, |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 367 | dex_pc, |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 368 | this); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 369 | CheckEntrypointTypes< |
| 370 | kQuickInstanceofNonTrivial, uint32_t, const mirror::Class*, const mirror::Class*>(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 371 | Primitive::Type ret_type = instruction_->GetType(); |
| 372 | Location ret_loc = calling_convention.GetReturnLocation(ret_type); |
| 373 | mips64_codegen->MoveLocation(locations->Out(), ret_loc, ret_type); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 374 | } else { |
| 375 | DCHECK(instruction_->IsCheckCast()); |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 376 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pCheckCast), instruction_, dex_pc, this); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 377 | CheckEntrypointTypes<kQuickCheckCast, void, const mirror::Class*, const mirror::Class*>(); |
| 378 | } |
| 379 | |
| 380 | RestoreLiveRegisters(codegen, locations); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 381 | __ Bc(GetExitLabel()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 382 | } |
| 383 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 384 | const char* GetDescription() const OVERRIDE { return "TypeCheckSlowPathMIPS64"; } |
| 385 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 386 | private: |
| 387 | HInstruction* const instruction_; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 388 | |
| 389 | DISALLOW_COPY_AND_ASSIGN(TypeCheckSlowPathMIPS64); |
| 390 | }; |
| 391 | |
| 392 | class DeoptimizationSlowPathMIPS64 : public SlowPathCodeMIPS64 { |
| 393 | public: |
| 394 | explicit DeoptimizationSlowPathMIPS64(HInstruction* instruction) |
| 395 | : instruction_(instruction) {} |
| 396 | |
| 397 | void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 398 | __ Bind(GetEntryLabel()); |
| 399 | SaveLiveRegisters(codegen, instruction_->GetLocations()); |
| 400 | DCHECK(instruction_->IsDeoptimize()); |
| 401 | HDeoptimize* deoptimize = instruction_->AsDeoptimize(); |
| 402 | uint32_t dex_pc = deoptimize->GetDexPc(); |
| 403 | CodeGeneratorMIPS64* mips64_codegen = down_cast<CodeGeneratorMIPS64*>(codegen); |
| 404 | mips64_codegen->InvokeRuntime(QUICK_ENTRY_POINT(pDeoptimize), instruction_, dex_pc, this); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 405 | CheckEntrypointTypes<kQuickDeoptimize, void, void>(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 406 | } |
| 407 | |
Roland Levillain | 4664889 | 2015-06-19 16:07:18 +0100 | [diff] [blame] | 408 | const char* GetDescription() const OVERRIDE { return "DeoptimizationSlowPathMIPS64"; } |
| 409 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 410 | private: |
| 411 | HInstruction* const instruction_; |
| 412 | DISALLOW_COPY_AND_ASSIGN(DeoptimizationSlowPathMIPS64); |
| 413 | }; |
| 414 | |
| 415 | CodeGeneratorMIPS64::CodeGeneratorMIPS64(HGraph* graph, |
| 416 | const Mips64InstructionSetFeatures& isa_features, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 417 | const CompilerOptions& compiler_options, |
| 418 | OptimizingCompilerStats* stats) |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 419 | : CodeGenerator(graph, |
| 420 | kNumberOfGpuRegisters, |
| 421 | kNumberOfFpuRegisters, |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 422 | /* number_of_register_pairs */ 0, |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 423 | ComputeRegisterMask(reinterpret_cast<const int*>(kCoreCalleeSaves), |
| 424 | arraysize(kCoreCalleeSaves)), |
| 425 | ComputeRegisterMask(reinterpret_cast<const int*>(kFpuCalleeSaves), |
| 426 | arraysize(kFpuCalleeSaves)), |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 427 | compiler_options, |
| 428 | stats), |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 429 | block_labels_(nullptr), |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 430 | location_builder_(graph, this), |
| 431 | instruction_visitor_(graph, this), |
| 432 | move_resolver_(graph->GetArena(), this), |
| 433 | isa_features_(isa_features) { |
| 434 | // Save RA (containing the return address) to mimic Quick. |
| 435 | AddAllocatedRegister(Location::RegisterLocation(RA)); |
| 436 | } |
| 437 | |
| 438 | #undef __ |
| 439 | #define __ down_cast<Mips64Assembler*>(GetAssembler())-> |
| 440 | #define QUICK_ENTRY_POINT(x) QUICK_ENTRYPOINT_OFFSET(kMips64WordSize, x).Int32Value() |
| 441 | |
| 442 | void CodeGeneratorMIPS64::Finalize(CodeAllocator* allocator) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 443 | // Ensure that we fix up branches. |
| 444 | __ FinalizeCode(); |
| 445 | |
| 446 | // Adjust native pc offsets in stack maps. |
| 447 | for (size_t i = 0, num = stack_map_stream_.GetNumberOfStackMaps(); i != num; ++i) { |
| 448 | uint32_t old_position = stack_map_stream_.GetStackMap(i).native_pc_offset; |
| 449 | uint32_t new_position = __ GetAdjustedPosition(old_position); |
| 450 | DCHECK_GE(new_position, old_position); |
| 451 | stack_map_stream_.SetStackMapNativePcOffset(i, new_position); |
| 452 | } |
| 453 | |
| 454 | // Adjust pc offsets for the disassembly information. |
| 455 | if (disasm_info_ != nullptr) { |
| 456 | GeneratedCodeInterval* frame_entry_interval = disasm_info_->GetFrameEntryInterval(); |
| 457 | frame_entry_interval->start = __ GetAdjustedPosition(frame_entry_interval->start); |
| 458 | frame_entry_interval->end = __ GetAdjustedPosition(frame_entry_interval->end); |
| 459 | for (auto& it : *disasm_info_->GetInstructionIntervals()) { |
| 460 | it.second.start = __ GetAdjustedPosition(it.second.start); |
| 461 | it.second.end = __ GetAdjustedPosition(it.second.end); |
| 462 | } |
| 463 | for (auto& it : *disasm_info_->GetSlowPathIntervals()) { |
| 464 | it.code_interval.start = __ GetAdjustedPosition(it.code_interval.start); |
| 465 | it.code_interval.end = __ GetAdjustedPosition(it.code_interval.end); |
| 466 | } |
| 467 | } |
| 468 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 469 | CodeGenerator::Finalize(allocator); |
| 470 | } |
| 471 | |
| 472 | Mips64Assembler* ParallelMoveResolverMIPS64::GetAssembler() const { |
| 473 | return codegen_->GetAssembler(); |
| 474 | } |
| 475 | |
| 476 | void ParallelMoveResolverMIPS64::EmitMove(size_t index) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 477 | MoveOperands* move = moves_[index]; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 478 | codegen_->MoveLocation(move->GetDestination(), move->GetSource(), move->GetType()); |
| 479 | } |
| 480 | |
| 481 | void ParallelMoveResolverMIPS64::EmitSwap(size_t index) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 482 | MoveOperands* move = moves_[index]; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 483 | codegen_->SwapLocations(move->GetDestination(), move->GetSource(), move->GetType()); |
| 484 | } |
| 485 | |
| 486 | void ParallelMoveResolverMIPS64::RestoreScratch(int reg) { |
| 487 | // Pop reg |
| 488 | __ Ld(GpuRegister(reg), SP, 0); |
| 489 | __ DecreaseFrameSize(kMips64WordSize); |
| 490 | } |
| 491 | |
| 492 | void ParallelMoveResolverMIPS64::SpillScratch(int reg) { |
| 493 | // Push reg |
| 494 | __ IncreaseFrameSize(kMips64WordSize); |
| 495 | __ Sd(GpuRegister(reg), SP, 0); |
| 496 | } |
| 497 | |
| 498 | void ParallelMoveResolverMIPS64::Exchange(int index1, int index2, bool double_slot) { |
| 499 | LoadOperandType load_type = double_slot ? kLoadDoubleword : kLoadWord; |
| 500 | StoreOperandType store_type = double_slot ? kStoreDoubleword : kStoreWord; |
| 501 | // Allocate a scratch register other than TMP, if available. |
| 502 | // Else, spill V0 (arbitrary choice) and use it as a scratch register (it will be |
| 503 | // automatically unspilled when the scratch scope object is destroyed). |
| 504 | ScratchRegisterScope ensure_scratch(this, TMP, V0, codegen_->GetNumberOfCoreRegisters()); |
| 505 | // If V0 spills onto the stack, SP-relative offsets need to be adjusted. |
| 506 | int stack_offset = ensure_scratch.IsSpilled() ? kMips64WordSize : 0; |
| 507 | __ LoadFromOffset(load_type, |
| 508 | GpuRegister(ensure_scratch.GetRegister()), |
| 509 | SP, |
| 510 | index1 + stack_offset); |
| 511 | __ LoadFromOffset(load_type, |
| 512 | TMP, |
| 513 | SP, |
| 514 | index2 + stack_offset); |
| 515 | __ StoreToOffset(store_type, |
| 516 | GpuRegister(ensure_scratch.GetRegister()), |
| 517 | SP, |
| 518 | index2 + stack_offset); |
| 519 | __ StoreToOffset(store_type, TMP, SP, index1 + stack_offset); |
| 520 | } |
| 521 | |
| 522 | static dwarf::Reg DWARFReg(GpuRegister reg) { |
| 523 | return dwarf::Reg::Mips64Core(static_cast<int>(reg)); |
| 524 | } |
| 525 | |
| 526 | // TODO: mapping of floating-point registers to DWARF |
| 527 | |
| 528 | void CodeGeneratorMIPS64::GenerateFrameEntry() { |
| 529 | __ Bind(&frame_entry_label_); |
| 530 | |
| 531 | bool do_overflow_check = FrameNeedsStackCheck(GetFrameSize(), kMips64) || !IsLeafMethod(); |
| 532 | |
| 533 | if (do_overflow_check) { |
| 534 | __ LoadFromOffset(kLoadWord, |
| 535 | ZERO, |
| 536 | SP, |
| 537 | -static_cast<int32_t>(GetStackOverflowReservedBytes(kMips64))); |
| 538 | RecordPcInfo(nullptr, 0); |
| 539 | } |
| 540 | |
| 541 | // TODO: anything related to T9/GP/GOT/PIC/.so's? |
| 542 | |
| 543 | if (HasEmptyFrame()) { |
| 544 | return; |
| 545 | } |
| 546 | |
| 547 | // Make sure the frame size isn't unreasonably large. Per the various APIs |
| 548 | // it looks like it should always be less than 2GB in size, which allows |
| 549 | // us using 32-bit signed offsets from the stack pointer. |
| 550 | if (GetFrameSize() > 0x7FFFFFFF) |
| 551 | LOG(FATAL) << "Stack frame larger than 2GB"; |
| 552 | |
| 553 | // Spill callee-saved registers. |
| 554 | // Note that their cumulative size is small and they can be indexed using |
| 555 | // 16-bit offsets. |
| 556 | |
| 557 | // TODO: increment/decrement SP in one step instead of two or remove this comment. |
| 558 | |
| 559 | uint32_t ofs = FrameEntrySpillSize(); |
| 560 | __ IncreaseFrameSize(ofs); |
| 561 | |
| 562 | for (int i = arraysize(kCoreCalleeSaves) - 1; i >= 0; --i) { |
| 563 | GpuRegister reg = kCoreCalleeSaves[i]; |
| 564 | if (allocated_registers_.ContainsCoreRegister(reg)) { |
| 565 | ofs -= kMips64WordSize; |
| 566 | __ Sd(reg, SP, ofs); |
| 567 | __ cfi().RelOffset(DWARFReg(reg), ofs); |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | for (int i = arraysize(kFpuCalleeSaves) - 1; i >= 0; --i) { |
| 572 | FpuRegister reg = kFpuCalleeSaves[i]; |
| 573 | if (allocated_registers_.ContainsFloatingPointRegister(reg)) { |
| 574 | ofs -= kMips64WordSize; |
| 575 | __ Sdc1(reg, SP, ofs); |
| 576 | // TODO: __ cfi().RelOffset(DWARFReg(reg), ofs); |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | // Allocate the rest of the frame and store the current method pointer |
| 581 | // at its end. |
| 582 | |
| 583 | __ IncreaseFrameSize(GetFrameSize() - FrameEntrySpillSize()); |
| 584 | |
| 585 | static_assert(IsInt<16>(kCurrentMethodStackOffset), |
| 586 | "kCurrentMethodStackOffset must fit into int16_t"); |
| 587 | __ Sd(kMethodRegisterArgument, SP, kCurrentMethodStackOffset); |
| 588 | } |
| 589 | |
| 590 | void CodeGeneratorMIPS64::GenerateFrameExit() { |
| 591 | __ cfi().RememberState(); |
| 592 | |
| 593 | // TODO: anything related to T9/GP/GOT/PIC/.so's? |
| 594 | |
| 595 | if (!HasEmptyFrame()) { |
| 596 | // Deallocate the rest of the frame. |
| 597 | |
| 598 | __ DecreaseFrameSize(GetFrameSize() - FrameEntrySpillSize()); |
| 599 | |
| 600 | // Restore callee-saved registers. |
| 601 | // Note that their cumulative size is small and they can be indexed using |
| 602 | // 16-bit offsets. |
| 603 | |
| 604 | // TODO: increment/decrement SP in one step instead of two or remove this comment. |
| 605 | |
| 606 | uint32_t ofs = 0; |
| 607 | |
| 608 | for (size_t i = 0; i < arraysize(kFpuCalleeSaves); ++i) { |
| 609 | FpuRegister reg = kFpuCalleeSaves[i]; |
| 610 | if (allocated_registers_.ContainsFloatingPointRegister(reg)) { |
| 611 | __ Ldc1(reg, SP, ofs); |
| 612 | ofs += kMips64WordSize; |
| 613 | // TODO: __ cfi().Restore(DWARFReg(reg)); |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | for (size_t i = 0; i < arraysize(kCoreCalleeSaves); ++i) { |
| 618 | GpuRegister reg = kCoreCalleeSaves[i]; |
| 619 | if (allocated_registers_.ContainsCoreRegister(reg)) { |
| 620 | __ Ld(reg, SP, ofs); |
| 621 | ofs += kMips64WordSize; |
| 622 | __ cfi().Restore(DWARFReg(reg)); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | DCHECK_EQ(ofs, FrameEntrySpillSize()); |
| 627 | __ DecreaseFrameSize(ofs); |
| 628 | } |
| 629 | |
| 630 | __ Jr(RA); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 631 | __ Nop(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 632 | |
| 633 | __ cfi().RestoreState(); |
| 634 | __ cfi().DefCFAOffset(GetFrameSize()); |
| 635 | } |
| 636 | |
| 637 | void CodeGeneratorMIPS64::Bind(HBasicBlock* block) { |
| 638 | __ Bind(GetLabelOf(block)); |
| 639 | } |
| 640 | |
| 641 | void CodeGeneratorMIPS64::MoveLocation(Location destination, |
| 642 | Location source, |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 643 | Primitive::Type dst_type) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 644 | if (source.Equals(destination)) { |
| 645 | return; |
| 646 | } |
| 647 | |
| 648 | // A valid move can always be inferred from the destination and source |
| 649 | // locations. When moving from and to a register, the argument type can be |
| 650 | // used to generate 32bit instead of 64bit moves. |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 651 | bool unspecified_type = (dst_type == Primitive::kPrimVoid); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 652 | DCHECK_EQ(unspecified_type, false); |
| 653 | |
| 654 | if (destination.IsRegister() || destination.IsFpuRegister()) { |
| 655 | if (unspecified_type) { |
| 656 | HConstant* src_cst = source.IsConstant() ? source.GetConstant() : nullptr; |
| 657 | if (source.IsStackSlot() || |
| 658 | (src_cst != nullptr && (src_cst->IsIntConstant() |
| 659 | || src_cst->IsFloatConstant() |
| 660 | || src_cst->IsNullConstant()))) { |
| 661 | // For stack slots and 32bit constants, a 64bit type is appropriate. |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 662 | dst_type = destination.IsRegister() ? Primitive::kPrimInt : Primitive::kPrimFloat; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 663 | } else { |
| 664 | // If the source is a double stack slot or a 64bit constant, a 64bit |
| 665 | // type is appropriate. Else the source is a register, and since the |
| 666 | // type has not been specified, we chose a 64bit type to force a 64bit |
| 667 | // move. |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 668 | dst_type = destination.IsRegister() ? Primitive::kPrimLong : Primitive::kPrimDouble; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 669 | } |
| 670 | } |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 671 | DCHECK((destination.IsFpuRegister() && Primitive::IsFloatingPointType(dst_type)) || |
| 672 | (destination.IsRegister() && !Primitive::IsFloatingPointType(dst_type))); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 673 | if (source.IsStackSlot() || source.IsDoubleStackSlot()) { |
| 674 | // Move to GPR/FPR from stack |
| 675 | LoadOperandType load_type = source.IsStackSlot() ? kLoadWord : kLoadDoubleword; |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 676 | if (Primitive::IsFloatingPointType(dst_type)) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 677 | __ LoadFpuFromOffset(load_type, |
| 678 | destination.AsFpuRegister<FpuRegister>(), |
| 679 | SP, |
| 680 | source.GetStackIndex()); |
| 681 | } else { |
| 682 | // TODO: use load_type = kLoadUnsignedWord when type == Primitive::kPrimNot. |
| 683 | __ LoadFromOffset(load_type, |
| 684 | destination.AsRegister<GpuRegister>(), |
| 685 | SP, |
| 686 | source.GetStackIndex()); |
| 687 | } |
| 688 | } else if (source.IsConstant()) { |
| 689 | // Move to GPR/FPR from constant |
| 690 | GpuRegister gpr = AT; |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 691 | if (!Primitive::IsFloatingPointType(dst_type)) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 692 | gpr = destination.AsRegister<GpuRegister>(); |
| 693 | } |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 694 | if (dst_type == Primitive::kPrimInt || dst_type == Primitive::kPrimFloat) { |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 695 | int32_t value = GetInt32ValueOf(source.GetConstant()->AsConstant()); |
| 696 | if (Primitive::IsFloatingPointType(dst_type) && value == 0) { |
| 697 | gpr = ZERO; |
| 698 | } else { |
| 699 | __ LoadConst32(gpr, value); |
| 700 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 701 | } else { |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 702 | int64_t value = GetInt64ValueOf(source.GetConstant()->AsConstant()); |
| 703 | if (Primitive::IsFloatingPointType(dst_type) && value == 0) { |
| 704 | gpr = ZERO; |
| 705 | } else { |
| 706 | __ LoadConst64(gpr, value); |
| 707 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 708 | } |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 709 | if (dst_type == Primitive::kPrimFloat) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 710 | __ Mtc1(gpr, destination.AsFpuRegister<FpuRegister>()); |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 711 | } else if (dst_type == Primitive::kPrimDouble) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 712 | __ Dmtc1(gpr, destination.AsFpuRegister<FpuRegister>()); |
| 713 | } |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 714 | } else if (source.IsRegister()) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 715 | if (destination.IsRegister()) { |
| 716 | // Move to GPR from GPR |
| 717 | __ Move(destination.AsRegister<GpuRegister>(), source.AsRegister<GpuRegister>()); |
| 718 | } else { |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 719 | DCHECK(destination.IsFpuRegister()); |
| 720 | if (Primitive::Is64BitType(dst_type)) { |
| 721 | __ Dmtc1(source.AsRegister<GpuRegister>(), destination.AsFpuRegister<FpuRegister>()); |
| 722 | } else { |
| 723 | __ Mtc1(source.AsRegister<GpuRegister>(), destination.AsFpuRegister<FpuRegister>()); |
| 724 | } |
| 725 | } |
| 726 | } else if (source.IsFpuRegister()) { |
| 727 | if (destination.IsFpuRegister()) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 728 | // Move to FPR from FPR |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 729 | if (dst_type == Primitive::kPrimFloat) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 730 | __ MovS(destination.AsFpuRegister<FpuRegister>(), source.AsFpuRegister<FpuRegister>()); |
| 731 | } else { |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 732 | DCHECK_EQ(dst_type, Primitive::kPrimDouble); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 733 | __ MovD(destination.AsFpuRegister<FpuRegister>(), source.AsFpuRegister<FpuRegister>()); |
| 734 | } |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 735 | } else { |
| 736 | DCHECK(destination.IsRegister()); |
| 737 | if (Primitive::Is64BitType(dst_type)) { |
| 738 | __ Dmfc1(destination.AsRegister<GpuRegister>(), source.AsFpuRegister<FpuRegister>()); |
| 739 | } else { |
| 740 | __ Mfc1(destination.AsRegister<GpuRegister>(), source.AsFpuRegister<FpuRegister>()); |
| 741 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 742 | } |
| 743 | } |
| 744 | } else { // The destination is not a register. It must be a stack slot. |
| 745 | DCHECK(destination.IsStackSlot() || destination.IsDoubleStackSlot()); |
| 746 | if (source.IsRegister() || source.IsFpuRegister()) { |
| 747 | if (unspecified_type) { |
| 748 | if (source.IsRegister()) { |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 749 | dst_type = destination.IsStackSlot() ? Primitive::kPrimInt : Primitive::kPrimLong; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 750 | } else { |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 751 | dst_type = destination.IsStackSlot() ? Primitive::kPrimFloat : Primitive::kPrimDouble; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 752 | } |
| 753 | } |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 754 | DCHECK((destination.IsDoubleStackSlot() == Primitive::Is64BitType(dst_type)) && |
| 755 | (source.IsFpuRegister() == Primitive::IsFloatingPointType(dst_type))); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 756 | // Move to stack from GPR/FPR |
| 757 | StoreOperandType store_type = destination.IsStackSlot() ? kStoreWord : kStoreDoubleword; |
| 758 | if (source.IsRegister()) { |
| 759 | __ StoreToOffset(store_type, |
| 760 | source.AsRegister<GpuRegister>(), |
| 761 | SP, |
| 762 | destination.GetStackIndex()); |
| 763 | } else { |
| 764 | __ StoreFpuToOffset(store_type, |
| 765 | source.AsFpuRegister<FpuRegister>(), |
| 766 | SP, |
| 767 | destination.GetStackIndex()); |
| 768 | } |
| 769 | } else if (source.IsConstant()) { |
| 770 | // Move to stack from constant |
| 771 | HConstant* src_cst = source.GetConstant(); |
| 772 | StoreOperandType store_type = destination.IsStackSlot() ? kStoreWord : kStoreDoubleword; |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 773 | GpuRegister gpr = ZERO; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 774 | if (destination.IsStackSlot()) { |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 775 | int32_t value = GetInt32ValueOf(src_cst->AsConstant()); |
| 776 | if (value != 0) { |
| 777 | gpr = TMP; |
| 778 | __ LoadConst32(gpr, value); |
| 779 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 780 | } else { |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 781 | DCHECK(destination.IsDoubleStackSlot()); |
| 782 | int64_t value = GetInt64ValueOf(src_cst->AsConstant()); |
| 783 | if (value != 0) { |
| 784 | gpr = TMP; |
| 785 | __ LoadConst64(gpr, value); |
| 786 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 787 | } |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 788 | __ StoreToOffset(store_type, gpr, SP, destination.GetStackIndex()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 789 | } else { |
| 790 | DCHECK(source.IsStackSlot() || source.IsDoubleStackSlot()); |
| 791 | DCHECK_EQ(source.IsDoubleStackSlot(), destination.IsDoubleStackSlot()); |
| 792 | // Move to stack from stack |
| 793 | if (destination.IsStackSlot()) { |
| 794 | __ LoadFromOffset(kLoadWord, TMP, SP, source.GetStackIndex()); |
| 795 | __ StoreToOffset(kStoreWord, TMP, SP, destination.GetStackIndex()); |
| 796 | } else { |
| 797 | __ LoadFromOffset(kLoadDoubleword, TMP, SP, source.GetStackIndex()); |
| 798 | __ StoreToOffset(kStoreDoubleword, TMP, SP, destination.GetStackIndex()); |
| 799 | } |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 804 | void CodeGeneratorMIPS64::SwapLocations(Location loc1, Location loc2, Primitive::Type type) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 805 | DCHECK(!loc1.IsConstant()); |
| 806 | DCHECK(!loc2.IsConstant()); |
| 807 | |
| 808 | if (loc1.Equals(loc2)) { |
| 809 | return; |
| 810 | } |
| 811 | |
| 812 | bool is_slot1 = loc1.IsStackSlot() || loc1.IsDoubleStackSlot(); |
| 813 | bool is_slot2 = loc2.IsStackSlot() || loc2.IsDoubleStackSlot(); |
| 814 | bool is_fp_reg1 = loc1.IsFpuRegister(); |
| 815 | bool is_fp_reg2 = loc2.IsFpuRegister(); |
| 816 | |
| 817 | if (loc2.IsRegister() && loc1.IsRegister()) { |
| 818 | // Swap 2 GPRs |
| 819 | GpuRegister r1 = loc1.AsRegister<GpuRegister>(); |
| 820 | GpuRegister r2 = loc2.AsRegister<GpuRegister>(); |
| 821 | __ Move(TMP, r2); |
| 822 | __ Move(r2, r1); |
| 823 | __ Move(r1, TMP); |
| 824 | } else if (is_fp_reg2 && is_fp_reg1) { |
| 825 | // Swap 2 FPRs |
| 826 | FpuRegister r1 = loc1.AsFpuRegister<FpuRegister>(); |
| 827 | FpuRegister r2 = loc2.AsFpuRegister<FpuRegister>(); |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 828 | if (type == Primitive::kPrimFloat) { |
| 829 | __ MovS(FTMP, r1); |
| 830 | __ MovS(r1, r2); |
| 831 | __ MovS(r2, FTMP); |
| 832 | } else { |
| 833 | DCHECK_EQ(type, Primitive::kPrimDouble); |
| 834 | __ MovD(FTMP, r1); |
| 835 | __ MovD(r1, r2); |
| 836 | __ MovD(r2, FTMP); |
| 837 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 838 | } else if (is_slot1 != is_slot2) { |
| 839 | // Swap GPR/FPR and stack slot |
| 840 | Location reg_loc = is_slot1 ? loc2 : loc1; |
| 841 | Location mem_loc = is_slot1 ? loc1 : loc2; |
| 842 | LoadOperandType load_type = mem_loc.IsStackSlot() ? kLoadWord : kLoadDoubleword; |
| 843 | StoreOperandType store_type = mem_loc.IsStackSlot() ? kStoreWord : kStoreDoubleword; |
| 844 | // TODO: use load_type = kLoadUnsignedWord when type == Primitive::kPrimNot. |
| 845 | __ LoadFromOffset(load_type, TMP, SP, mem_loc.GetStackIndex()); |
| 846 | if (reg_loc.IsFpuRegister()) { |
| 847 | __ StoreFpuToOffset(store_type, |
| 848 | reg_loc.AsFpuRegister<FpuRegister>(), |
| 849 | SP, |
| 850 | mem_loc.GetStackIndex()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 851 | if (mem_loc.IsStackSlot()) { |
| 852 | __ Mtc1(TMP, reg_loc.AsFpuRegister<FpuRegister>()); |
| 853 | } else { |
| 854 | DCHECK(mem_loc.IsDoubleStackSlot()); |
| 855 | __ Dmtc1(TMP, reg_loc.AsFpuRegister<FpuRegister>()); |
| 856 | } |
| 857 | } else { |
| 858 | __ StoreToOffset(store_type, reg_loc.AsRegister<GpuRegister>(), SP, mem_loc.GetStackIndex()); |
| 859 | __ Move(reg_loc.AsRegister<GpuRegister>(), TMP); |
| 860 | } |
| 861 | } else if (is_slot1 && is_slot2) { |
| 862 | move_resolver_.Exchange(loc1.GetStackIndex(), |
| 863 | loc2.GetStackIndex(), |
| 864 | loc1.IsDoubleStackSlot()); |
| 865 | } else { |
| 866 | LOG(FATAL) << "Unimplemented swap between locations " << loc1 << " and " << loc2; |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | void CodeGeneratorMIPS64::Move(HInstruction* instruction, |
| 871 | Location location, |
| 872 | HInstruction* move_for) { |
| 873 | LocationSummary* locations = instruction->GetLocations(); |
| 874 | Primitive::Type type = instruction->GetType(); |
| 875 | DCHECK_NE(type, Primitive::kPrimVoid); |
| 876 | |
| 877 | if (instruction->IsCurrentMethod()) { |
| 878 | MoveLocation(location, Location::DoubleStackSlot(kCurrentMethodStackOffset), type); |
| 879 | } else if (locations != nullptr && locations->Out().Equals(location)) { |
| 880 | return; |
| 881 | } else if (instruction->IsIntConstant() |
| 882 | || instruction->IsLongConstant() |
| 883 | || instruction->IsNullConstant()) { |
| 884 | if (location.IsRegister()) { |
| 885 | // Move to GPR from constant |
| 886 | GpuRegister dst = location.AsRegister<GpuRegister>(); |
| 887 | if (instruction->IsNullConstant() || instruction->IsIntConstant()) { |
| 888 | __ LoadConst32(dst, GetInt32ValueOf(instruction->AsConstant())); |
| 889 | } else { |
| 890 | __ LoadConst64(dst, instruction->AsLongConstant()->GetValue()); |
| 891 | } |
| 892 | } else { |
| 893 | DCHECK(location.IsStackSlot() || location.IsDoubleStackSlot()); |
| 894 | // Move to stack from constant |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 895 | GpuRegister gpr = ZERO; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 896 | if (location.IsStackSlot()) { |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 897 | int32_t value = GetInt32ValueOf(instruction->AsConstant()); |
| 898 | if (value != 0) { |
| 899 | gpr = TMP; |
| 900 | __ LoadConst32(gpr, value); |
| 901 | } |
| 902 | __ StoreToOffset(kStoreWord, gpr, SP, location.GetStackIndex()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 903 | } else { |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 904 | DCHECK(location.IsDoubleStackSlot()); |
| 905 | int64_t value = instruction->AsLongConstant()->GetValue(); |
| 906 | if (value != 0) { |
| 907 | gpr = TMP; |
| 908 | __ LoadConst64(gpr, value); |
| 909 | } |
| 910 | __ StoreToOffset(kStoreDoubleword, gpr, SP, location.GetStackIndex()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | } else if (instruction->IsTemporary()) { |
| 914 | Location temp_location = GetTemporaryLocation(instruction->AsTemporary()); |
| 915 | MoveLocation(location, temp_location, type); |
| 916 | } else if (instruction->IsLoadLocal()) { |
| 917 | uint32_t stack_slot = GetStackSlot(instruction->AsLoadLocal()->GetLocal()); |
| 918 | if (Primitive::Is64BitType(type)) { |
| 919 | MoveLocation(location, Location::DoubleStackSlot(stack_slot), type); |
| 920 | } else { |
| 921 | MoveLocation(location, Location::StackSlot(stack_slot), type); |
| 922 | } |
| 923 | } else { |
| 924 | DCHECK((instruction->GetNext() == move_for) || instruction->GetNext()->IsTemporary()); |
| 925 | MoveLocation(location, locations->Out(), type); |
| 926 | } |
| 927 | } |
| 928 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 929 | void CodeGeneratorMIPS64::MoveConstant(Location location, int32_t value) { |
| 930 | DCHECK(location.IsRegister()); |
| 931 | __ LoadConst32(location.AsRegister<GpuRegister>(), value); |
| 932 | } |
| 933 | |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 934 | void CodeGeneratorMIPS64::AddLocationAsTemp(Location location, LocationSummary* locations) { |
| 935 | if (location.IsRegister()) { |
| 936 | locations->AddTemp(location); |
| 937 | } else { |
| 938 | UNIMPLEMENTED(FATAL) << "AddLocationAsTemp not implemented for location " << location; |
| 939 | } |
| 940 | } |
| 941 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 942 | Location CodeGeneratorMIPS64::GetStackLocation(HLoadLocal* load) const { |
| 943 | Primitive::Type type = load->GetType(); |
| 944 | |
| 945 | switch (type) { |
| 946 | case Primitive::kPrimNot: |
| 947 | case Primitive::kPrimInt: |
| 948 | case Primitive::kPrimFloat: |
| 949 | return Location::StackSlot(GetStackSlot(load->GetLocal())); |
| 950 | |
| 951 | case Primitive::kPrimLong: |
| 952 | case Primitive::kPrimDouble: |
| 953 | return Location::DoubleStackSlot(GetStackSlot(load->GetLocal())); |
| 954 | |
| 955 | case Primitive::kPrimBoolean: |
| 956 | case Primitive::kPrimByte: |
| 957 | case Primitive::kPrimChar: |
| 958 | case Primitive::kPrimShort: |
| 959 | case Primitive::kPrimVoid: |
| 960 | LOG(FATAL) << "Unexpected type " << type; |
| 961 | } |
| 962 | |
| 963 | LOG(FATAL) << "Unreachable"; |
| 964 | return Location::NoLocation(); |
| 965 | } |
| 966 | |
| 967 | void CodeGeneratorMIPS64::MarkGCCard(GpuRegister object, GpuRegister value) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 968 | Mips64Label done; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 969 | GpuRegister card = AT; |
| 970 | GpuRegister temp = TMP; |
| 971 | __ Beqzc(value, &done); |
| 972 | __ LoadFromOffset(kLoadDoubleword, |
| 973 | card, |
| 974 | TR, |
| 975 | Thread::CardTableOffset<kMips64WordSize>().Int32Value()); |
| 976 | __ Dsrl(temp, object, gc::accounting::CardTable::kCardShift); |
| 977 | __ Daddu(temp, card, temp); |
| 978 | __ Sb(card, temp, 0); |
| 979 | __ Bind(&done); |
| 980 | } |
| 981 | |
| 982 | void CodeGeneratorMIPS64::SetupBlockedRegisters(bool is_baseline ATTRIBUTE_UNUSED) const { |
| 983 | // ZERO, K0, K1, GP, SP, RA are always reserved and can't be allocated. |
| 984 | blocked_core_registers_[ZERO] = true; |
| 985 | blocked_core_registers_[K0] = true; |
| 986 | blocked_core_registers_[K1] = true; |
| 987 | blocked_core_registers_[GP] = true; |
| 988 | blocked_core_registers_[SP] = true; |
| 989 | blocked_core_registers_[RA] = true; |
| 990 | |
| 991 | // AT and TMP(T8) are used as temporary/scratch registers |
| 992 | // (similar to how AT is used by MIPS assemblers). |
| 993 | blocked_core_registers_[AT] = true; |
| 994 | blocked_core_registers_[TMP] = true; |
| 995 | blocked_fpu_registers_[FTMP] = true; |
| 996 | |
| 997 | // Reserve suspend and thread registers. |
| 998 | blocked_core_registers_[S0] = true; |
| 999 | blocked_core_registers_[TR] = true; |
| 1000 | |
| 1001 | // Reserve T9 for function calls |
| 1002 | blocked_core_registers_[T9] = true; |
| 1003 | |
| 1004 | // TODO: review; anything else? |
| 1005 | |
| 1006 | // TODO: make these two for's conditional on is_baseline once |
| 1007 | // all the issues with register saving/restoring are sorted out. |
| 1008 | for (size_t i = 0; i < arraysize(kCoreCalleeSaves); ++i) { |
| 1009 | blocked_core_registers_[kCoreCalleeSaves[i]] = true; |
| 1010 | } |
| 1011 | |
| 1012 | for (size_t i = 0; i < arraysize(kFpuCalleeSaves); ++i) { |
| 1013 | blocked_fpu_registers_[kFpuCalleeSaves[i]] = true; |
| 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | Location CodeGeneratorMIPS64::AllocateFreeRegister(Primitive::Type type) const { |
| 1018 | if (type == Primitive::kPrimVoid) { |
| 1019 | LOG(FATAL) << "Unreachable type " << type; |
| 1020 | } |
| 1021 | |
| 1022 | if (Primitive::IsFloatingPointType(type)) { |
| 1023 | size_t reg = FindFreeEntry(blocked_fpu_registers_, kNumberOfFpuRegisters); |
| 1024 | return Location::FpuRegisterLocation(reg); |
| 1025 | } else { |
| 1026 | size_t reg = FindFreeEntry(blocked_core_registers_, kNumberOfGpuRegisters); |
| 1027 | return Location::RegisterLocation(reg); |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | size_t CodeGeneratorMIPS64::SaveCoreRegister(size_t stack_index, uint32_t reg_id) { |
| 1032 | __ StoreToOffset(kStoreDoubleword, GpuRegister(reg_id), SP, stack_index); |
| 1033 | return kMips64WordSize; |
| 1034 | } |
| 1035 | |
| 1036 | size_t CodeGeneratorMIPS64::RestoreCoreRegister(size_t stack_index, uint32_t reg_id) { |
| 1037 | __ LoadFromOffset(kLoadDoubleword, GpuRegister(reg_id), SP, stack_index); |
| 1038 | return kMips64WordSize; |
| 1039 | } |
| 1040 | |
| 1041 | size_t CodeGeneratorMIPS64::SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) { |
| 1042 | __ StoreFpuToOffset(kStoreDoubleword, FpuRegister(reg_id), SP, stack_index); |
| 1043 | return kMips64WordSize; |
| 1044 | } |
| 1045 | |
| 1046 | size_t CodeGeneratorMIPS64::RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) { |
| 1047 | __ LoadFpuFromOffset(kLoadDoubleword, FpuRegister(reg_id), SP, stack_index); |
| 1048 | return kMips64WordSize; |
| 1049 | } |
| 1050 | |
| 1051 | void CodeGeneratorMIPS64::DumpCoreRegister(std::ostream& stream, int reg) const { |
David Brazdil | 9f0dece | 2015-09-21 18:20:26 +0100 | [diff] [blame] | 1052 | stream << GpuRegister(reg); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | void CodeGeneratorMIPS64::DumpFloatingPointRegister(std::ostream& stream, int reg) const { |
David Brazdil | 9f0dece | 2015-09-21 18:20:26 +0100 | [diff] [blame] | 1056 | stream << FpuRegister(reg); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1057 | } |
| 1058 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 1059 | void CodeGeneratorMIPS64::InvokeRuntime(QuickEntrypointEnum entrypoint, |
| 1060 | HInstruction* instruction, |
| 1061 | uint32_t dex_pc, |
| 1062 | SlowPathCode* slow_path) { |
| 1063 | InvokeRuntime(GetThreadOffset<kMips64WordSize>(entrypoint).Int32Value(), |
| 1064 | instruction, |
| 1065 | dex_pc, |
| 1066 | slow_path); |
| 1067 | } |
| 1068 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1069 | void CodeGeneratorMIPS64::InvokeRuntime(int32_t entry_point_offset, |
| 1070 | HInstruction* instruction, |
| 1071 | uint32_t dex_pc, |
| 1072 | SlowPathCode* slow_path) { |
Alexandre Rames | 78e3ef6 | 2015-08-12 13:43:29 +0100 | [diff] [blame] | 1073 | ValidateInvokeRuntime(instruction, slow_path); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1074 | // TODO: anything related to T9/GP/GOT/PIC/.so's? |
| 1075 | __ LoadFromOffset(kLoadDoubleword, T9, TR, entry_point_offset); |
| 1076 | __ Jalr(T9); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 1077 | __ Nop(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1078 | RecordPcInfo(instruction, dex_pc, slow_path); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | void InstructionCodeGeneratorMIPS64::GenerateClassInitializationCheck(SlowPathCodeMIPS64* slow_path, |
| 1082 | GpuRegister class_reg) { |
| 1083 | __ LoadFromOffset(kLoadWord, TMP, class_reg, mirror::Class::StatusOffset().Int32Value()); |
| 1084 | __ LoadConst32(AT, mirror::Class::kStatusInitialized); |
| 1085 | __ Bltc(TMP, AT, slow_path->GetEntryLabel()); |
| 1086 | // TODO: barrier needed? |
| 1087 | __ Bind(slow_path->GetExitLabel()); |
| 1088 | } |
| 1089 | |
| 1090 | void InstructionCodeGeneratorMIPS64::GenerateMemoryBarrier(MemBarrierKind kind ATTRIBUTE_UNUSED) { |
| 1091 | __ Sync(0); // only stype 0 is supported |
| 1092 | } |
| 1093 | |
| 1094 | void InstructionCodeGeneratorMIPS64::GenerateSuspendCheck(HSuspendCheck* instruction, |
| 1095 | HBasicBlock* successor) { |
| 1096 | SuspendCheckSlowPathMIPS64* slow_path = |
| 1097 | new (GetGraph()->GetArena()) SuspendCheckSlowPathMIPS64(instruction, successor); |
| 1098 | codegen_->AddSlowPath(slow_path); |
| 1099 | |
| 1100 | __ LoadFromOffset(kLoadUnsignedHalfword, |
| 1101 | TMP, |
| 1102 | TR, |
| 1103 | Thread::ThreadFlagsOffset<kMips64WordSize>().Int32Value()); |
| 1104 | if (successor == nullptr) { |
| 1105 | __ Bnezc(TMP, slow_path->GetEntryLabel()); |
| 1106 | __ Bind(slow_path->GetReturnLabel()); |
| 1107 | } else { |
| 1108 | __ Beqzc(TMP, codegen_->GetLabelOf(successor)); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 1109 | __ Bc(slow_path->GetEntryLabel()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1110 | // slow_path will return to GetLabelOf(successor). |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | InstructionCodeGeneratorMIPS64::InstructionCodeGeneratorMIPS64(HGraph* graph, |
| 1115 | CodeGeneratorMIPS64* codegen) |
| 1116 | : HGraphVisitor(graph), |
| 1117 | assembler_(codegen->GetAssembler()), |
| 1118 | codegen_(codegen) {} |
| 1119 | |
| 1120 | void LocationsBuilderMIPS64::HandleBinaryOp(HBinaryOperation* instruction) { |
| 1121 | DCHECK_EQ(instruction->InputCount(), 2U); |
| 1122 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 1123 | Primitive::Type type = instruction->GetResultType(); |
| 1124 | switch (type) { |
| 1125 | case Primitive::kPrimInt: |
| 1126 | case Primitive::kPrimLong: { |
| 1127 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1128 | HInstruction* right = instruction->InputAt(1); |
| 1129 | bool can_use_imm = false; |
| 1130 | if (right->IsConstant()) { |
| 1131 | int64_t imm = CodeGenerator::GetInt64ValueOf(right->AsConstant()); |
| 1132 | if (instruction->IsAnd() || instruction->IsOr() || instruction->IsXor()) { |
| 1133 | can_use_imm = IsUint<16>(imm); |
| 1134 | } else if (instruction->IsAdd()) { |
| 1135 | can_use_imm = IsInt<16>(imm); |
| 1136 | } else { |
| 1137 | DCHECK(instruction->IsSub()); |
| 1138 | can_use_imm = IsInt<16>(-imm); |
| 1139 | } |
| 1140 | } |
| 1141 | if (can_use_imm) |
| 1142 | locations->SetInAt(1, Location::ConstantLocation(right->AsConstant())); |
| 1143 | else |
| 1144 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1145 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1146 | } |
| 1147 | break; |
| 1148 | |
| 1149 | case Primitive::kPrimFloat: |
| 1150 | case Primitive::kPrimDouble: |
| 1151 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1152 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 1153 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 1154 | break; |
| 1155 | |
| 1156 | default: |
| 1157 | LOG(FATAL) << "Unexpected " << instruction->DebugName() << " type " << type; |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | void InstructionCodeGeneratorMIPS64::HandleBinaryOp(HBinaryOperation* instruction) { |
| 1162 | Primitive::Type type = instruction->GetType(); |
| 1163 | LocationSummary* locations = instruction->GetLocations(); |
| 1164 | |
| 1165 | switch (type) { |
| 1166 | case Primitive::kPrimInt: |
| 1167 | case Primitive::kPrimLong: { |
| 1168 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 1169 | GpuRegister lhs = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1170 | Location rhs_location = locations->InAt(1); |
| 1171 | |
| 1172 | GpuRegister rhs_reg = ZERO; |
| 1173 | int64_t rhs_imm = 0; |
| 1174 | bool use_imm = rhs_location.IsConstant(); |
| 1175 | if (use_imm) { |
| 1176 | rhs_imm = CodeGenerator::GetInt64ValueOf(rhs_location.GetConstant()); |
| 1177 | } else { |
| 1178 | rhs_reg = rhs_location.AsRegister<GpuRegister>(); |
| 1179 | } |
| 1180 | |
| 1181 | if (instruction->IsAnd()) { |
| 1182 | if (use_imm) |
| 1183 | __ Andi(dst, lhs, rhs_imm); |
| 1184 | else |
| 1185 | __ And(dst, lhs, rhs_reg); |
| 1186 | } else if (instruction->IsOr()) { |
| 1187 | if (use_imm) |
| 1188 | __ Ori(dst, lhs, rhs_imm); |
| 1189 | else |
| 1190 | __ Or(dst, lhs, rhs_reg); |
| 1191 | } else if (instruction->IsXor()) { |
| 1192 | if (use_imm) |
| 1193 | __ Xori(dst, lhs, rhs_imm); |
| 1194 | else |
| 1195 | __ Xor(dst, lhs, rhs_reg); |
| 1196 | } else if (instruction->IsAdd()) { |
| 1197 | if (type == Primitive::kPrimInt) { |
| 1198 | if (use_imm) |
| 1199 | __ Addiu(dst, lhs, rhs_imm); |
| 1200 | else |
| 1201 | __ Addu(dst, lhs, rhs_reg); |
| 1202 | } else { |
| 1203 | if (use_imm) |
| 1204 | __ Daddiu(dst, lhs, rhs_imm); |
| 1205 | else |
| 1206 | __ Daddu(dst, lhs, rhs_reg); |
| 1207 | } |
| 1208 | } else { |
| 1209 | DCHECK(instruction->IsSub()); |
| 1210 | if (type == Primitive::kPrimInt) { |
| 1211 | if (use_imm) |
| 1212 | __ Addiu(dst, lhs, -rhs_imm); |
| 1213 | else |
| 1214 | __ Subu(dst, lhs, rhs_reg); |
| 1215 | } else { |
| 1216 | if (use_imm) |
| 1217 | __ Daddiu(dst, lhs, -rhs_imm); |
| 1218 | else |
| 1219 | __ Dsubu(dst, lhs, rhs_reg); |
| 1220 | } |
| 1221 | } |
| 1222 | break; |
| 1223 | } |
| 1224 | case Primitive::kPrimFloat: |
| 1225 | case Primitive::kPrimDouble: { |
| 1226 | FpuRegister dst = locations->Out().AsFpuRegister<FpuRegister>(); |
| 1227 | FpuRegister lhs = locations->InAt(0).AsFpuRegister<FpuRegister>(); |
| 1228 | FpuRegister rhs = locations->InAt(1).AsFpuRegister<FpuRegister>(); |
| 1229 | if (instruction->IsAdd()) { |
| 1230 | if (type == Primitive::kPrimFloat) |
| 1231 | __ AddS(dst, lhs, rhs); |
| 1232 | else |
| 1233 | __ AddD(dst, lhs, rhs); |
| 1234 | } else if (instruction->IsSub()) { |
| 1235 | if (type == Primitive::kPrimFloat) |
| 1236 | __ SubS(dst, lhs, rhs); |
| 1237 | else |
| 1238 | __ SubD(dst, lhs, rhs); |
| 1239 | } else { |
| 1240 | LOG(FATAL) << "Unexpected floating-point binary operation"; |
| 1241 | } |
| 1242 | break; |
| 1243 | } |
| 1244 | default: |
| 1245 | LOG(FATAL) << "Unexpected binary operation type " << type; |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | void LocationsBuilderMIPS64::HandleShift(HBinaryOperation* instr) { |
| 1250 | DCHECK(instr->IsShl() || instr->IsShr() || instr->IsUShr()); |
| 1251 | |
| 1252 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instr); |
| 1253 | Primitive::Type type = instr->GetResultType(); |
| 1254 | switch (type) { |
| 1255 | case Primitive::kPrimInt: |
| 1256 | case Primitive::kPrimLong: { |
| 1257 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1258 | locations->SetInAt(1, Location::RegisterOrConstant(instr->InputAt(1))); |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 1259 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1260 | break; |
| 1261 | } |
| 1262 | default: |
| 1263 | LOG(FATAL) << "Unexpected shift type " << type; |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | void InstructionCodeGeneratorMIPS64::HandleShift(HBinaryOperation* instr) { |
| 1268 | DCHECK(instr->IsShl() || instr->IsShr() || instr->IsUShr()); |
| 1269 | LocationSummary* locations = instr->GetLocations(); |
| 1270 | Primitive::Type type = instr->GetType(); |
| 1271 | |
| 1272 | switch (type) { |
| 1273 | case Primitive::kPrimInt: |
| 1274 | case Primitive::kPrimLong: { |
| 1275 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 1276 | GpuRegister lhs = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1277 | Location rhs_location = locations->InAt(1); |
| 1278 | |
| 1279 | GpuRegister rhs_reg = ZERO; |
| 1280 | int64_t rhs_imm = 0; |
| 1281 | bool use_imm = rhs_location.IsConstant(); |
| 1282 | if (use_imm) { |
| 1283 | rhs_imm = CodeGenerator::GetInt64ValueOf(rhs_location.GetConstant()); |
| 1284 | } else { |
| 1285 | rhs_reg = rhs_location.AsRegister<GpuRegister>(); |
| 1286 | } |
| 1287 | |
| 1288 | if (use_imm) { |
| 1289 | uint32_t shift_value = (type == Primitive::kPrimInt) |
| 1290 | ? static_cast<uint32_t>(rhs_imm & kMaxIntShiftValue) |
| 1291 | : static_cast<uint32_t>(rhs_imm & kMaxLongShiftValue); |
| 1292 | |
| 1293 | if (type == Primitive::kPrimInt) { |
| 1294 | if (instr->IsShl()) { |
| 1295 | __ Sll(dst, lhs, shift_value); |
| 1296 | } else if (instr->IsShr()) { |
| 1297 | __ Sra(dst, lhs, shift_value); |
| 1298 | } else { |
| 1299 | __ Srl(dst, lhs, shift_value); |
| 1300 | } |
| 1301 | } else { |
| 1302 | if (shift_value < 32) { |
| 1303 | if (instr->IsShl()) { |
| 1304 | __ Dsll(dst, lhs, shift_value); |
| 1305 | } else if (instr->IsShr()) { |
| 1306 | __ Dsra(dst, lhs, shift_value); |
| 1307 | } else { |
| 1308 | __ Dsrl(dst, lhs, shift_value); |
| 1309 | } |
| 1310 | } else { |
| 1311 | shift_value -= 32; |
| 1312 | if (instr->IsShl()) { |
| 1313 | __ Dsll32(dst, lhs, shift_value); |
| 1314 | } else if (instr->IsShr()) { |
| 1315 | __ Dsra32(dst, lhs, shift_value); |
| 1316 | } else { |
| 1317 | __ Dsrl32(dst, lhs, shift_value); |
| 1318 | } |
| 1319 | } |
| 1320 | } |
| 1321 | } else { |
| 1322 | if (type == Primitive::kPrimInt) { |
| 1323 | if (instr->IsShl()) { |
| 1324 | __ Sllv(dst, lhs, rhs_reg); |
| 1325 | } else if (instr->IsShr()) { |
| 1326 | __ Srav(dst, lhs, rhs_reg); |
| 1327 | } else { |
| 1328 | __ Srlv(dst, lhs, rhs_reg); |
| 1329 | } |
| 1330 | } else { |
| 1331 | if (instr->IsShl()) { |
| 1332 | __ Dsllv(dst, lhs, rhs_reg); |
| 1333 | } else if (instr->IsShr()) { |
| 1334 | __ Dsrav(dst, lhs, rhs_reg); |
| 1335 | } else { |
| 1336 | __ Dsrlv(dst, lhs, rhs_reg); |
| 1337 | } |
| 1338 | } |
| 1339 | } |
| 1340 | break; |
| 1341 | } |
| 1342 | default: |
| 1343 | LOG(FATAL) << "Unexpected shift operation type " << type; |
| 1344 | } |
| 1345 | } |
| 1346 | |
| 1347 | void LocationsBuilderMIPS64::VisitAdd(HAdd* instruction) { |
| 1348 | HandleBinaryOp(instruction); |
| 1349 | } |
| 1350 | |
| 1351 | void InstructionCodeGeneratorMIPS64::VisitAdd(HAdd* instruction) { |
| 1352 | HandleBinaryOp(instruction); |
| 1353 | } |
| 1354 | |
| 1355 | void LocationsBuilderMIPS64::VisitAnd(HAnd* instruction) { |
| 1356 | HandleBinaryOp(instruction); |
| 1357 | } |
| 1358 | |
| 1359 | void InstructionCodeGeneratorMIPS64::VisitAnd(HAnd* instruction) { |
| 1360 | HandleBinaryOp(instruction); |
| 1361 | } |
| 1362 | |
| 1363 | void LocationsBuilderMIPS64::VisitArrayGet(HArrayGet* instruction) { |
| 1364 | LocationSummary* locations = |
| 1365 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 1366 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1367 | locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 1368 | if (Primitive::IsFloatingPointType(instruction->GetType())) { |
| 1369 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 1370 | } else { |
| 1371 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1372 | } |
| 1373 | } |
| 1374 | |
| 1375 | void InstructionCodeGeneratorMIPS64::VisitArrayGet(HArrayGet* instruction) { |
| 1376 | LocationSummary* locations = instruction->GetLocations(); |
| 1377 | GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1378 | Location index = locations->InAt(1); |
| 1379 | Primitive::Type type = instruction->GetType(); |
| 1380 | |
| 1381 | switch (type) { |
| 1382 | case Primitive::kPrimBoolean: { |
| 1383 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
| 1384 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1385 | if (index.IsConstant()) { |
| 1386 | size_t offset = |
| 1387 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
| 1388 | __ LoadFromOffset(kLoadUnsignedByte, out, obj, offset); |
| 1389 | } else { |
| 1390 | __ Daddu(TMP, obj, index.AsRegister<GpuRegister>()); |
| 1391 | __ LoadFromOffset(kLoadUnsignedByte, out, TMP, data_offset); |
| 1392 | } |
| 1393 | break; |
| 1394 | } |
| 1395 | |
| 1396 | case Primitive::kPrimByte: { |
| 1397 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int8_t)).Uint32Value(); |
| 1398 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1399 | if (index.IsConstant()) { |
| 1400 | size_t offset = |
| 1401 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
| 1402 | __ LoadFromOffset(kLoadSignedByte, out, obj, offset); |
| 1403 | } else { |
| 1404 | __ Daddu(TMP, obj, index.AsRegister<GpuRegister>()); |
| 1405 | __ LoadFromOffset(kLoadSignedByte, out, TMP, data_offset); |
| 1406 | } |
| 1407 | break; |
| 1408 | } |
| 1409 | |
| 1410 | case Primitive::kPrimShort: { |
| 1411 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int16_t)).Uint32Value(); |
| 1412 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1413 | if (index.IsConstant()) { |
| 1414 | size_t offset = |
| 1415 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
| 1416 | __ LoadFromOffset(kLoadSignedHalfword, out, obj, offset); |
| 1417 | } else { |
| 1418 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_2); |
| 1419 | __ Daddu(TMP, obj, TMP); |
| 1420 | __ LoadFromOffset(kLoadSignedHalfword, out, TMP, data_offset); |
| 1421 | } |
| 1422 | break; |
| 1423 | } |
| 1424 | |
| 1425 | case Primitive::kPrimChar: { |
| 1426 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
| 1427 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1428 | if (index.IsConstant()) { |
| 1429 | size_t offset = |
| 1430 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
| 1431 | __ LoadFromOffset(kLoadUnsignedHalfword, out, obj, offset); |
| 1432 | } else { |
| 1433 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_2); |
| 1434 | __ Daddu(TMP, obj, TMP); |
| 1435 | __ LoadFromOffset(kLoadUnsignedHalfword, out, TMP, data_offset); |
| 1436 | } |
| 1437 | break; |
| 1438 | } |
| 1439 | |
| 1440 | case Primitive::kPrimInt: |
| 1441 | case Primitive::kPrimNot: { |
| 1442 | DCHECK_EQ(sizeof(mirror::HeapReference<mirror::Object>), sizeof(int32_t)); |
| 1443 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
| 1444 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1445 | LoadOperandType load_type = (type == Primitive::kPrimNot) ? kLoadUnsignedWord : kLoadWord; |
| 1446 | if (index.IsConstant()) { |
| 1447 | size_t offset = |
| 1448 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 1449 | __ LoadFromOffset(load_type, out, obj, offset); |
| 1450 | } else { |
| 1451 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_4); |
| 1452 | __ Daddu(TMP, obj, TMP); |
| 1453 | __ LoadFromOffset(load_type, out, TMP, data_offset); |
| 1454 | } |
| 1455 | break; |
| 1456 | } |
| 1457 | |
| 1458 | case Primitive::kPrimLong: { |
| 1459 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
| 1460 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1461 | if (index.IsConstant()) { |
| 1462 | size_t offset = |
| 1463 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 1464 | __ LoadFromOffset(kLoadDoubleword, out, obj, offset); |
| 1465 | } else { |
| 1466 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_8); |
| 1467 | __ Daddu(TMP, obj, TMP); |
| 1468 | __ LoadFromOffset(kLoadDoubleword, out, TMP, data_offset); |
| 1469 | } |
| 1470 | break; |
| 1471 | } |
| 1472 | |
| 1473 | case Primitive::kPrimFloat: { |
| 1474 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(float)).Uint32Value(); |
| 1475 | FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>(); |
| 1476 | if (index.IsConstant()) { |
| 1477 | size_t offset = |
| 1478 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 1479 | __ LoadFpuFromOffset(kLoadWord, out, obj, offset); |
| 1480 | } else { |
| 1481 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_4); |
| 1482 | __ Daddu(TMP, obj, TMP); |
| 1483 | __ LoadFpuFromOffset(kLoadWord, out, TMP, data_offset); |
| 1484 | } |
| 1485 | break; |
| 1486 | } |
| 1487 | |
| 1488 | case Primitive::kPrimDouble: { |
| 1489 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(double)).Uint32Value(); |
| 1490 | FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>(); |
| 1491 | if (index.IsConstant()) { |
| 1492 | size_t offset = |
| 1493 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 1494 | __ LoadFpuFromOffset(kLoadDoubleword, out, obj, offset); |
| 1495 | } else { |
| 1496 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_8); |
| 1497 | __ Daddu(TMP, obj, TMP); |
| 1498 | __ LoadFpuFromOffset(kLoadDoubleword, out, TMP, data_offset); |
| 1499 | } |
| 1500 | break; |
| 1501 | } |
| 1502 | |
| 1503 | case Primitive::kPrimVoid: |
| 1504 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
| 1505 | UNREACHABLE(); |
| 1506 | } |
| 1507 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 1508 | } |
| 1509 | |
| 1510 | void LocationsBuilderMIPS64::VisitArrayLength(HArrayLength* instruction) { |
| 1511 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 1512 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1513 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1514 | } |
| 1515 | |
| 1516 | void InstructionCodeGeneratorMIPS64::VisitArrayLength(HArrayLength* instruction) { |
| 1517 | LocationSummary* locations = instruction->GetLocations(); |
| 1518 | uint32_t offset = mirror::Array::LengthOffset().Uint32Value(); |
| 1519 | GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1520 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1521 | __ LoadFromOffset(kLoadWord, out, obj, offset); |
| 1522 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 1523 | } |
| 1524 | |
| 1525 | void LocationsBuilderMIPS64::VisitArraySet(HArraySet* instruction) { |
David Brazdil | bb3d505 | 2015-09-21 18:39:16 +0100 | [diff] [blame] | 1526 | bool needs_runtime_call = instruction->NeedsTypeCheck(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1527 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary( |
| 1528 | instruction, |
David Brazdil | bb3d505 | 2015-09-21 18:39:16 +0100 | [diff] [blame] | 1529 | needs_runtime_call ? LocationSummary::kCall : LocationSummary::kNoCall); |
| 1530 | if (needs_runtime_call) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1531 | InvokeRuntimeCallingConvention calling_convention; |
| 1532 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 1533 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 1534 | locations->SetInAt(2, Location::RegisterLocation(calling_convention.GetRegisterAt(2))); |
| 1535 | } else { |
| 1536 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1537 | locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 1538 | if (Primitive::IsFloatingPointType(instruction->InputAt(2)->GetType())) { |
| 1539 | locations->SetInAt(2, Location::RequiresFpuRegister()); |
| 1540 | } else { |
| 1541 | locations->SetInAt(2, Location::RequiresRegister()); |
| 1542 | } |
| 1543 | } |
| 1544 | } |
| 1545 | |
| 1546 | void InstructionCodeGeneratorMIPS64::VisitArraySet(HArraySet* instruction) { |
| 1547 | LocationSummary* locations = instruction->GetLocations(); |
| 1548 | GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1549 | Location index = locations->InAt(1); |
| 1550 | Primitive::Type value_type = instruction->GetComponentType(); |
| 1551 | bool needs_runtime_call = locations->WillCall(); |
| 1552 | bool needs_write_barrier = |
| 1553 | CodeGenerator::StoreNeedsWriteBarrier(value_type, instruction->GetValue()); |
| 1554 | |
| 1555 | switch (value_type) { |
| 1556 | case Primitive::kPrimBoolean: |
| 1557 | case Primitive::kPrimByte: { |
| 1558 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
| 1559 | GpuRegister value = locations->InAt(2).AsRegister<GpuRegister>(); |
| 1560 | if (index.IsConstant()) { |
| 1561 | size_t offset = |
| 1562 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
| 1563 | __ StoreToOffset(kStoreByte, value, obj, offset); |
| 1564 | } else { |
| 1565 | __ Daddu(TMP, obj, index.AsRegister<GpuRegister>()); |
| 1566 | __ StoreToOffset(kStoreByte, value, TMP, data_offset); |
| 1567 | } |
| 1568 | break; |
| 1569 | } |
| 1570 | |
| 1571 | case Primitive::kPrimShort: |
| 1572 | case Primitive::kPrimChar: { |
| 1573 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
| 1574 | GpuRegister value = locations->InAt(2).AsRegister<GpuRegister>(); |
| 1575 | if (index.IsConstant()) { |
| 1576 | size_t offset = |
| 1577 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
| 1578 | __ StoreToOffset(kStoreHalfword, value, obj, offset); |
| 1579 | } else { |
| 1580 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_2); |
| 1581 | __ Daddu(TMP, obj, TMP); |
| 1582 | __ StoreToOffset(kStoreHalfword, value, TMP, data_offset); |
| 1583 | } |
| 1584 | break; |
| 1585 | } |
| 1586 | |
| 1587 | case Primitive::kPrimInt: |
| 1588 | case Primitive::kPrimNot: { |
| 1589 | if (!needs_runtime_call) { |
| 1590 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
| 1591 | GpuRegister value = locations->InAt(2).AsRegister<GpuRegister>(); |
| 1592 | if (index.IsConstant()) { |
| 1593 | size_t offset = |
| 1594 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 1595 | __ StoreToOffset(kStoreWord, value, obj, offset); |
| 1596 | } else { |
| 1597 | DCHECK(index.IsRegister()) << index; |
| 1598 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_4); |
| 1599 | __ Daddu(TMP, obj, TMP); |
| 1600 | __ StoreToOffset(kStoreWord, value, TMP, data_offset); |
| 1601 | } |
| 1602 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 1603 | if (needs_write_barrier) { |
| 1604 | DCHECK_EQ(value_type, Primitive::kPrimNot); |
| 1605 | codegen_->MarkGCCard(obj, value); |
| 1606 | } |
| 1607 | } else { |
| 1608 | DCHECK_EQ(value_type, Primitive::kPrimNot); |
| 1609 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pAputObject), |
| 1610 | instruction, |
| 1611 | instruction->GetDexPc(), |
| 1612 | nullptr); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 1613 | CheckEntrypointTypes<kQuickAputObject, void, mirror::Array*, int32_t, mirror::Object*>(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1614 | } |
| 1615 | break; |
| 1616 | } |
| 1617 | |
| 1618 | case Primitive::kPrimLong: { |
| 1619 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
| 1620 | GpuRegister value = locations->InAt(2).AsRegister<GpuRegister>(); |
| 1621 | if (index.IsConstant()) { |
| 1622 | size_t offset = |
| 1623 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 1624 | __ StoreToOffset(kStoreDoubleword, value, obj, offset); |
| 1625 | } else { |
| 1626 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_8); |
| 1627 | __ Daddu(TMP, obj, TMP); |
| 1628 | __ StoreToOffset(kStoreDoubleword, value, TMP, data_offset); |
| 1629 | } |
| 1630 | break; |
| 1631 | } |
| 1632 | |
| 1633 | case Primitive::kPrimFloat: { |
| 1634 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(float)).Uint32Value(); |
| 1635 | FpuRegister value = locations->InAt(2).AsFpuRegister<FpuRegister>(); |
| 1636 | DCHECK(locations->InAt(2).IsFpuRegister()); |
| 1637 | if (index.IsConstant()) { |
| 1638 | size_t offset = |
| 1639 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 1640 | __ StoreFpuToOffset(kStoreWord, value, obj, offset); |
| 1641 | } else { |
| 1642 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_4); |
| 1643 | __ Daddu(TMP, obj, TMP); |
| 1644 | __ StoreFpuToOffset(kStoreWord, value, TMP, data_offset); |
| 1645 | } |
| 1646 | break; |
| 1647 | } |
| 1648 | |
| 1649 | case Primitive::kPrimDouble: { |
| 1650 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(double)).Uint32Value(); |
| 1651 | FpuRegister value = locations->InAt(2).AsFpuRegister<FpuRegister>(); |
| 1652 | DCHECK(locations->InAt(2).IsFpuRegister()); |
| 1653 | if (index.IsConstant()) { |
| 1654 | size_t offset = |
| 1655 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 1656 | __ StoreFpuToOffset(kStoreDoubleword, value, obj, offset); |
| 1657 | } else { |
| 1658 | __ Dsll(TMP, index.AsRegister<GpuRegister>(), TIMES_8); |
| 1659 | __ Daddu(TMP, obj, TMP); |
| 1660 | __ StoreFpuToOffset(kStoreDoubleword, value, TMP, data_offset); |
| 1661 | } |
| 1662 | break; |
| 1663 | } |
| 1664 | |
| 1665 | case Primitive::kPrimVoid: |
| 1666 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
| 1667 | UNREACHABLE(); |
| 1668 | } |
| 1669 | |
| 1670 | // Ints and objects are handled in the switch. |
| 1671 | if (value_type != Primitive::kPrimInt && value_type != Primitive::kPrimNot) { |
| 1672 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 1673 | } |
| 1674 | } |
| 1675 | |
| 1676 | void LocationsBuilderMIPS64::VisitBoundsCheck(HBoundsCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1677 | LocationSummary::CallKind call_kind = instruction->CanThrowIntoCatchBlock() |
| 1678 | ? LocationSummary::kCallOnSlowPath |
| 1679 | : LocationSummary::kNoCall; |
| 1680 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1681 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1682 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1683 | if (instruction->HasUses()) { |
| 1684 | locations->SetOut(Location::SameAsFirstInput()); |
| 1685 | } |
| 1686 | } |
| 1687 | |
| 1688 | void InstructionCodeGeneratorMIPS64::VisitBoundsCheck(HBoundsCheck* instruction) { |
| 1689 | LocationSummary* locations = instruction->GetLocations(); |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 1690 | BoundsCheckSlowPathMIPS64* slow_path = |
| 1691 | new (GetGraph()->GetArena()) BoundsCheckSlowPathMIPS64(instruction); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1692 | codegen_->AddSlowPath(slow_path); |
| 1693 | |
| 1694 | GpuRegister index = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1695 | GpuRegister length = locations->InAt(1).AsRegister<GpuRegister>(); |
| 1696 | |
| 1697 | // length is limited by the maximum positive signed 32-bit integer. |
| 1698 | // Unsigned comparison of length and index checks for index < 0 |
| 1699 | // and for length <= index simultaneously. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 1700 | __ Bgeuc(index, length, slow_path->GetEntryLabel()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1701 | } |
| 1702 | |
| 1703 | void LocationsBuilderMIPS64::VisitCheckCast(HCheckCast* instruction) { |
| 1704 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary( |
| 1705 | instruction, |
| 1706 | LocationSummary::kCallOnSlowPath); |
| 1707 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1708 | locations->SetInAt(1, Location::RequiresRegister()); |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 1709 | // Note that TypeCheckSlowPathMIPS64 uses this register too. |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1710 | locations->AddTemp(Location::RequiresRegister()); |
| 1711 | } |
| 1712 | |
| 1713 | void InstructionCodeGeneratorMIPS64::VisitCheckCast(HCheckCast* instruction) { |
| 1714 | LocationSummary* locations = instruction->GetLocations(); |
| 1715 | GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1716 | GpuRegister cls = locations->InAt(1).AsRegister<GpuRegister>(); |
| 1717 | GpuRegister obj_cls = locations->GetTemp(0).AsRegister<GpuRegister>(); |
| 1718 | |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 1719 | SlowPathCodeMIPS64* slow_path = |
| 1720 | new (GetGraph()->GetArena()) TypeCheckSlowPathMIPS64(instruction); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1721 | codegen_->AddSlowPath(slow_path); |
| 1722 | |
| 1723 | // TODO: avoid this check if we know obj is not null. |
| 1724 | __ Beqzc(obj, slow_path->GetExitLabel()); |
| 1725 | // Compare the class of `obj` with `cls`. |
| 1726 | __ LoadFromOffset(kLoadUnsignedWord, obj_cls, obj, mirror::Object::ClassOffset().Int32Value()); |
| 1727 | __ Bnec(obj_cls, cls, slow_path->GetEntryLabel()); |
| 1728 | __ Bind(slow_path->GetExitLabel()); |
| 1729 | } |
| 1730 | |
| 1731 | void LocationsBuilderMIPS64::VisitClinitCheck(HClinitCheck* check) { |
| 1732 | LocationSummary* locations = |
| 1733 | new (GetGraph()->GetArena()) LocationSummary(check, LocationSummary::kCallOnSlowPath); |
| 1734 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1735 | if (check->HasUses()) { |
| 1736 | locations->SetOut(Location::SameAsFirstInput()); |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | void InstructionCodeGeneratorMIPS64::VisitClinitCheck(HClinitCheck* check) { |
| 1741 | // We assume the class is not null. |
| 1742 | SlowPathCodeMIPS64* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathMIPS64( |
| 1743 | check->GetLoadClass(), |
| 1744 | check, |
| 1745 | check->GetDexPc(), |
| 1746 | true); |
| 1747 | codegen_->AddSlowPath(slow_path); |
| 1748 | GenerateClassInitializationCheck(slow_path, |
| 1749 | check->GetLocations()->InAt(0).AsRegister<GpuRegister>()); |
| 1750 | } |
| 1751 | |
| 1752 | void LocationsBuilderMIPS64::VisitCompare(HCompare* compare) { |
| 1753 | Primitive::Type in_type = compare->InputAt(0)->GetType(); |
| 1754 | |
| 1755 | LocationSummary::CallKind call_kind = Primitive::IsFloatingPointType(in_type) |
| 1756 | ? LocationSummary::kCall |
| 1757 | : LocationSummary::kNoCall; |
| 1758 | |
| 1759 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(compare, call_kind); |
| 1760 | |
| 1761 | switch (in_type) { |
| 1762 | case Primitive::kPrimLong: |
| 1763 | locations->SetInAt(0, Location::RequiresRegister()); |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 1764 | locations->SetInAt(1, Location::RegisterOrConstant(compare->InputAt(1))); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1765 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1766 | break; |
| 1767 | |
| 1768 | case Primitive::kPrimFloat: |
| 1769 | case Primitive::kPrimDouble: { |
| 1770 | InvokeRuntimeCallingConvention calling_convention; |
| 1771 | locations->SetInAt(0, Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(0))); |
| 1772 | locations->SetInAt(1, Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(1))); |
| 1773 | locations->SetOut(calling_convention.GetReturnLocation(Primitive::kPrimInt)); |
| 1774 | break; |
| 1775 | } |
| 1776 | |
| 1777 | default: |
| 1778 | LOG(FATAL) << "Unexpected type for compare operation " << in_type; |
| 1779 | } |
| 1780 | } |
| 1781 | |
| 1782 | void InstructionCodeGeneratorMIPS64::VisitCompare(HCompare* instruction) { |
| 1783 | LocationSummary* locations = instruction->GetLocations(); |
| 1784 | Primitive::Type in_type = instruction->InputAt(0)->GetType(); |
| 1785 | |
| 1786 | // 0 if: left == right |
| 1787 | // 1 if: left > right |
| 1788 | // -1 if: left < right |
| 1789 | switch (in_type) { |
| 1790 | case Primitive::kPrimLong: { |
| 1791 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 1792 | GpuRegister lhs = locations->InAt(0).AsRegister<GpuRegister>(); |
Alexey Frunze | 5c75ffa | 2015-09-24 14:41:59 -0700 | [diff] [blame] | 1793 | Location rhs_location = locations->InAt(1); |
| 1794 | bool use_imm = rhs_location.IsConstant(); |
| 1795 | GpuRegister rhs = ZERO; |
| 1796 | if (use_imm) { |
| 1797 | int64_t value = CodeGenerator::GetInt64ValueOf(rhs_location.GetConstant()->AsConstant()); |
| 1798 | if (value != 0) { |
| 1799 | rhs = AT; |
| 1800 | __ LoadConst64(rhs, value); |
| 1801 | } |
| 1802 | } else { |
| 1803 | rhs = rhs_location.AsRegister<GpuRegister>(); |
| 1804 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1805 | __ Slt(TMP, lhs, rhs); |
| 1806 | __ Slt(dst, rhs, lhs); |
| 1807 | __ Subu(dst, dst, TMP); |
| 1808 | break; |
| 1809 | } |
| 1810 | |
| 1811 | case Primitive::kPrimFloat: |
| 1812 | case Primitive::kPrimDouble: { |
| 1813 | int32_t entry_point_offset; |
| 1814 | if (in_type == Primitive::kPrimFloat) { |
| 1815 | entry_point_offset = instruction->IsGtBias() ? QUICK_ENTRY_POINT(pCmpgFloat) |
| 1816 | : QUICK_ENTRY_POINT(pCmplFloat); |
| 1817 | } else { |
| 1818 | entry_point_offset = instruction->IsGtBias() ? QUICK_ENTRY_POINT(pCmpgDouble) |
| 1819 | : QUICK_ENTRY_POINT(pCmplDouble); |
| 1820 | } |
| 1821 | codegen_->InvokeRuntime(entry_point_offset, instruction, instruction->GetDexPc(), nullptr); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 1822 | if (in_type == Primitive::kPrimFloat) { |
| 1823 | if (instruction->IsGtBias()) { |
| 1824 | CheckEntrypointTypes<kQuickCmpgFloat, int32_t, float, float>(); |
| 1825 | } else { |
| 1826 | CheckEntrypointTypes<kQuickCmplFloat, int32_t, float, float>(); |
| 1827 | } |
| 1828 | } else { |
| 1829 | if (instruction->IsGtBias()) { |
| 1830 | CheckEntrypointTypes<kQuickCmpgDouble, int32_t, double, double>(); |
| 1831 | } else { |
| 1832 | CheckEntrypointTypes<kQuickCmplDouble, int32_t, double, double>(); |
| 1833 | } |
| 1834 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1835 | break; |
| 1836 | } |
| 1837 | |
| 1838 | default: |
| 1839 | LOG(FATAL) << "Unimplemented compare type " << in_type; |
| 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | void LocationsBuilderMIPS64::VisitCondition(HCondition* instruction) { |
| 1844 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 1845 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1846 | locations->SetInAt(1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 1847 | if (instruction->NeedsMaterialization()) { |
| 1848 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1849 | } |
| 1850 | } |
| 1851 | |
| 1852 | void InstructionCodeGeneratorMIPS64::VisitCondition(HCondition* instruction) { |
| 1853 | if (!instruction->NeedsMaterialization()) { |
| 1854 | return; |
| 1855 | } |
| 1856 | |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1857 | // TODO: generalize to long |
| 1858 | DCHECK_NE(instruction->InputAt(0)->GetType(), Primitive::kPrimLong); |
| 1859 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1860 | LocationSummary* locations = instruction->GetLocations(); |
| 1861 | |
| 1862 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 1863 | GpuRegister lhs = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1864 | Location rhs_location = locations->InAt(1); |
| 1865 | |
| 1866 | GpuRegister rhs_reg = ZERO; |
| 1867 | int64_t rhs_imm = 0; |
| 1868 | bool use_imm = rhs_location.IsConstant(); |
| 1869 | if (use_imm) { |
| 1870 | rhs_imm = CodeGenerator::GetInt32ValueOf(rhs_location.GetConstant()); |
| 1871 | } else { |
| 1872 | rhs_reg = rhs_location.AsRegister<GpuRegister>(); |
| 1873 | } |
| 1874 | |
| 1875 | IfCondition if_cond = instruction->GetCondition(); |
| 1876 | |
| 1877 | switch (if_cond) { |
| 1878 | case kCondEQ: |
| 1879 | case kCondNE: |
| 1880 | if (use_imm && IsUint<16>(rhs_imm)) { |
| 1881 | __ Xori(dst, lhs, rhs_imm); |
| 1882 | } else { |
| 1883 | if (use_imm) { |
| 1884 | rhs_reg = TMP; |
| 1885 | __ LoadConst32(rhs_reg, rhs_imm); |
| 1886 | } |
| 1887 | __ Xor(dst, lhs, rhs_reg); |
| 1888 | } |
| 1889 | if (if_cond == kCondEQ) { |
| 1890 | __ Sltiu(dst, dst, 1); |
| 1891 | } else { |
| 1892 | __ Sltu(dst, ZERO, dst); |
| 1893 | } |
| 1894 | break; |
| 1895 | |
| 1896 | case kCondLT: |
| 1897 | case kCondGE: |
| 1898 | if (use_imm && IsInt<16>(rhs_imm)) { |
| 1899 | __ Slti(dst, lhs, rhs_imm); |
| 1900 | } else { |
| 1901 | if (use_imm) { |
| 1902 | rhs_reg = TMP; |
| 1903 | __ LoadConst32(rhs_reg, rhs_imm); |
| 1904 | } |
| 1905 | __ Slt(dst, lhs, rhs_reg); |
| 1906 | } |
| 1907 | if (if_cond == kCondGE) { |
| 1908 | // Simulate lhs >= rhs via !(lhs < rhs) since there's |
| 1909 | // only the slt instruction but no sge. |
| 1910 | __ Xori(dst, dst, 1); |
| 1911 | } |
| 1912 | break; |
| 1913 | |
| 1914 | case kCondLE: |
| 1915 | case kCondGT: |
| 1916 | if (use_imm && IsInt<16>(rhs_imm + 1)) { |
| 1917 | // Simulate lhs <= rhs via lhs < rhs + 1. |
| 1918 | __ Slti(dst, lhs, rhs_imm + 1); |
| 1919 | if (if_cond == kCondGT) { |
| 1920 | // Simulate lhs > rhs via !(lhs <= rhs) since there's |
| 1921 | // only the slti instruction but no sgti. |
| 1922 | __ Xori(dst, dst, 1); |
| 1923 | } |
| 1924 | } else { |
| 1925 | if (use_imm) { |
| 1926 | rhs_reg = TMP; |
| 1927 | __ LoadConst32(rhs_reg, rhs_imm); |
| 1928 | } |
| 1929 | __ Slt(dst, rhs_reg, lhs); |
| 1930 | if (if_cond == kCondLE) { |
| 1931 | // Simulate lhs <= rhs via !(rhs < lhs) since there's |
| 1932 | // only the slt instruction but no sle. |
| 1933 | __ Xori(dst, dst, 1); |
| 1934 | } |
| 1935 | } |
| 1936 | break; |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 1937 | |
| 1938 | case kCondB: |
| 1939 | case kCondAE: |
| 1940 | if (use_imm && 0 <= rhs_imm && rhs_imm <= 0x7fff) { |
| 1941 | __ Sltiu(dst, lhs, rhs_imm); |
| 1942 | } else { |
| 1943 | if (use_imm) { |
| 1944 | rhs_reg = TMP; |
| 1945 | __ LoadConst32(rhs_reg, rhs_imm); |
| 1946 | } |
| 1947 | __ Sltu(dst, lhs, rhs_reg); |
| 1948 | } |
| 1949 | if (if_cond == kCondAE) { |
| 1950 | // Simulate lhs >= rhs via !(lhs < rhs) since there's |
| 1951 | // only the sltu instruction but no sgeu. |
| 1952 | __ Xori(dst, dst, 1); |
| 1953 | } |
| 1954 | break; |
| 1955 | |
| 1956 | case kCondBE: |
| 1957 | case kCondA: |
| 1958 | if (use_imm && 0 <= rhs_imm && rhs_imm <= 0x7ffe) { |
| 1959 | // Simulate lhs <= rhs via lhs < rhs + 1. |
| 1960 | __ Sltiu(dst, lhs, rhs_imm + 1); |
| 1961 | if (if_cond == kCondA) { |
| 1962 | // Simulate lhs > rhs via !(lhs <= rhs) since there's |
| 1963 | // only the sltiu instruction but no sgtiu. |
| 1964 | __ Xori(dst, dst, 1); |
| 1965 | } |
| 1966 | } else { |
| 1967 | if (use_imm) { |
| 1968 | rhs_reg = TMP; |
| 1969 | __ LoadConst32(rhs_reg, rhs_imm); |
| 1970 | } |
| 1971 | __ Sltu(dst, rhs_reg, lhs); |
| 1972 | if (if_cond == kCondBE) { |
| 1973 | // Simulate lhs <= rhs via !(rhs < lhs) since there's |
| 1974 | // only the sltu instruction but no sleu. |
| 1975 | __ Xori(dst, dst, 1); |
| 1976 | } |
| 1977 | } |
| 1978 | break; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 1979 | } |
| 1980 | } |
| 1981 | |
Alexey Frunze | c857c74 | 2015-09-23 15:12:39 -0700 | [diff] [blame] | 1982 | void InstructionCodeGeneratorMIPS64::DivRemOneOrMinusOne(HBinaryOperation* instruction) { |
| 1983 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 1984 | Primitive::Type type = instruction->GetResultType(); |
| 1985 | |
| 1986 | LocationSummary* locations = instruction->GetLocations(); |
| 1987 | Location second = locations->InAt(1); |
| 1988 | DCHECK(second.IsConstant()); |
| 1989 | |
| 1990 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 1991 | GpuRegister dividend = locations->InAt(0).AsRegister<GpuRegister>(); |
| 1992 | int64_t imm = Int64FromConstant(second.GetConstant()); |
| 1993 | DCHECK(imm == 1 || imm == -1); |
| 1994 | |
| 1995 | if (instruction->IsRem()) { |
| 1996 | __ Move(out, ZERO); |
| 1997 | } else { |
| 1998 | if (imm == -1) { |
| 1999 | if (type == Primitive::kPrimInt) { |
| 2000 | __ Subu(out, ZERO, dividend); |
| 2001 | } else { |
| 2002 | DCHECK_EQ(type, Primitive::kPrimLong); |
| 2003 | __ Dsubu(out, ZERO, dividend); |
| 2004 | } |
| 2005 | } else if (out != dividend) { |
| 2006 | __ Move(out, dividend); |
| 2007 | } |
| 2008 | } |
| 2009 | } |
| 2010 | |
| 2011 | void InstructionCodeGeneratorMIPS64::DivRemByPowerOfTwo(HBinaryOperation* instruction) { |
| 2012 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 2013 | Primitive::Type type = instruction->GetResultType(); |
| 2014 | |
| 2015 | LocationSummary* locations = instruction->GetLocations(); |
| 2016 | Location second = locations->InAt(1); |
| 2017 | DCHECK(second.IsConstant()); |
| 2018 | |
| 2019 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 2020 | GpuRegister dividend = locations->InAt(0).AsRegister<GpuRegister>(); |
| 2021 | int64_t imm = Int64FromConstant(second.GetConstant()); |
| 2022 | uint64_t abs_imm = static_cast<uint64_t>(std::abs(imm)); |
| 2023 | DCHECK(IsPowerOfTwo(abs_imm)); |
| 2024 | int ctz_imm = CTZ(abs_imm); |
| 2025 | |
| 2026 | if (instruction->IsDiv()) { |
| 2027 | if (type == Primitive::kPrimInt) { |
| 2028 | if (ctz_imm == 1) { |
| 2029 | // Fast path for division by +/-2, which is very common. |
| 2030 | __ Srl(TMP, dividend, 31); |
| 2031 | } else { |
| 2032 | __ Sra(TMP, dividend, 31); |
| 2033 | __ Srl(TMP, TMP, 32 - ctz_imm); |
| 2034 | } |
| 2035 | __ Addu(out, dividend, TMP); |
| 2036 | __ Sra(out, out, ctz_imm); |
| 2037 | if (imm < 0) { |
| 2038 | __ Subu(out, ZERO, out); |
| 2039 | } |
| 2040 | } else { |
| 2041 | DCHECK_EQ(type, Primitive::kPrimLong); |
| 2042 | if (ctz_imm == 1) { |
| 2043 | // Fast path for division by +/-2, which is very common. |
| 2044 | __ Dsrl32(TMP, dividend, 31); |
| 2045 | } else { |
| 2046 | __ Dsra32(TMP, dividend, 31); |
| 2047 | if (ctz_imm > 32) { |
| 2048 | __ Dsrl(TMP, TMP, 64 - ctz_imm); |
| 2049 | } else { |
| 2050 | __ Dsrl32(TMP, TMP, 32 - ctz_imm); |
| 2051 | } |
| 2052 | } |
| 2053 | __ Daddu(out, dividend, TMP); |
| 2054 | if (ctz_imm < 32) { |
| 2055 | __ Dsra(out, out, ctz_imm); |
| 2056 | } else { |
| 2057 | __ Dsra32(out, out, ctz_imm - 32); |
| 2058 | } |
| 2059 | if (imm < 0) { |
| 2060 | __ Dsubu(out, ZERO, out); |
| 2061 | } |
| 2062 | } |
| 2063 | } else { |
| 2064 | if (type == Primitive::kPrimInt) { |
| 2065 | if (ctz_imm == 1) { |
| 2066 | // Fast path for modulo +/-2, which is very common. |
| 2067 | __ Sra(TMP, dividend, 31); |
| 2068 | __ Subu(out, dividend, TMP); |
| 2069 | __ Andi(out, out, 1); |
| 2070 | __ Addu(out, out, TMP); |
| 2071 | } else { |
| 2072 | __ Sra(TMP, dividend, 31); |
| 2073 | __ Srl(TMP, TMP, 32 - ctz_imm); |
| 2074 | __ Addu(out, dividend, TMP); |
| 2075 | if (IsUint<16>(abs_imm - 1)) { |
| 2076 | __ Andi(out, out, abs_imm - 1); |
| 2077 | } else { |
| 2078 | __ Sll(out, out, 32 - ctz_imm); |
| 2079 | __ Srl(out, out, 32 - ctz_imm); |
| 2080 | } |
| 2081 | __ Subu(out, out, TMP); |
| 2082 | } |
| 2083 | } else { |
| 2084 | DCHECK_EQ(type, Primitive::kPrimLong); |
| 2085 | if (ctz_imm == 1) { |
| 2086 | // Fast path for modulo +/-2, which is very common. |
| 2087 | __ Dsra32(TMP, dividend, 31); |
| 2088 | __ Dsubu(out, dividend, TMP); |
| 2089 | __ Andi(out, out, 1); |
| 2090 | __ Daddu(out, out, TMP); |
| 2091 | } else { |
| 2092 | __ Dsra32(TMP, dividend, 31); |
| 2093 | if (ctz_imm > 32) { |
| 2094 | __ Dsrl(TMP, TMP, 64 - ctz_imm); |
| 2095 | } else { |
| 2096 | __ Dsrl32(TMP, TMP, 32 - ctz_imm); |
| 2097 | } |
| 2098 | __ Daddu(out, dividend, TMP); |
| 2099 | if (IsUint<16>(abs_imm - 1)) { |
| 2100 | __ Andi(out, out, abs_imm - 1); |
| 2101 | } else { |
| 2102 | if (ctz_imm > 32) { |
| 2103 | __ Dsll(out, out, 64 - ctz_imm); |
| 2104 | __ Dsrl(out, out, 64 - ctz_imm); |
| 2105 | } else { |
| 2106 | __ Dsll32(out, out, 32 - ctz_imm); |
| 2107 | __ Dsrl32(out, out, 32 - ctz_imm); |
| 2108 | } |
| 2109 | } |
| 2110 | __ Dsubu(out, out, TMP); |
| 2111 | } |
| 2112 | } |
| 2113 | } |
| 2114 | } |
| 2115 | |
| 2116 | void InstructionCodeGeneratorMIPS64::GenerateDivRemWithAnyConstant(HBinaryOperation* instruction) { |
| 2117 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 2118 | |
| 2119 | LocationSummary* locations = instruction->GetLocations(); |
| 2120 | Location second = locations->InAt(1); |
| 2121 | DCHECK(second.IsConstant()); |
| 2122 | |
| 2123 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 2124 | GpuRegister dividend = locations->InAt(0).AsRegister<GpuRegister>(); |
| 2125 | int64_t imm = Int64FromConstant(second.GetConstant()); |
| 2126 | |
| 2127 | Primitive::Type type = instruction->GetResultType(); |
| 2128 | DCHECK(type == Primitive::kPrimInt || type == Primitive::kPrimLong) << type; |
| 2129 | |
| 2130 | int64_t magic; |
| 2131 | int shift; |
| 2132 | CalculateMagicAndShiftForDivRem(imm, |
| 2133 | (type == Primitive::kPrimLong), |
| 2134 | &magic, |
| 2135 | &shift); |
| 2136 | |
| 2137 | if (type == Primitive::kPrimInt) { |
| 2138 | __ LoadConst32(TMP, magic); |
| 2139 | __ MuhR6(TMP, dividend, TMP); |
| 2140 | |
| 2141 | if (imm > 0 && magic < 0) { |
| 2142 | __ Addu(TMP, TMP, dividend); |
| 2143 | } else if (imm < 0 && magic > 0) { |
| 2144 | __ Subu(TMP, TMP, dividend); |
| 2145 | } |
| 2146 | |
| 2147 | if (shift != 0) { |
| 2148 | __ Sra(TMP, TMP, shift); |
| 2149 | } |
| 2150 | |
| 2151 | if (instruction->IsDiv()) { |
| 2152 | __ Sra(out, TMP, 31); |
| 2153 | __ Subu(out, TMP, out); |
| 2154 | } else { |
| 2155 | __ Sra(AT, TMP, 31); |
| 2156 | __ Subu(AT, TMP, AT); |
| 2157 | __ LoadConst32(TMP, imm); |
| 2158 | __ MulR6(TMP, AT, TMP); |
| 2159 | __ Subu(out, dividend, TMP); |
| 2160 | } |
| 2161 | } else { |
| 2162 | __ LoadConst64(TMP, magic); |
| 2163 | __ Dmuh(TMP, dividend, TMP); |
| 2164 | |
| 2165 | if (imm > 0 && magic < 0) { |
| 2166 | __ Daddu(TMP, TMP, dividend); |
| 2167 | } else if (imm < 0 && magic > 0) { |
| 2168 | __ Dsubu(TMP, TMP, dividend); |
| 2169 | } |
| 2170 | |
| 2171 | if (shift >= 32) { |
| 2172 | __ Dsra32(TMP, TMP, shift - 32); |
| 2173 | } else if (shift > 0) { |
| 2174 | __ Dsra(TMP, TMP, shift); |
| 2175 | } |
| 2176 | |
| 2177 | if (instruction->IsDiv()) { |
| 2178 | __ Dsra32(out, TMP, 31); |
| 2179 | __ Dsubu(out, TMP, out); |
| 2180 | } else { |
| 2181 | __ Dsra32(AT, TMP, 31); |
| 2182 | __ Dsubu(AT, TMP, AT); |
| 2183 | __ LoadConst64(TMP, imm); |
| 2184 | __ Dmul(TMP, AT, TMP); |
| 2185 | __ Dsubu(out, dividend, TMP); |
| 2186 | } |
| 2187 | } |
| 2188 | } |
| 2189 | |
| 2190 | void InstructionCodeGeneratorMIPS64::GenerateDivRemIntegral(HBinaryOperation* instruction) { |
| 2191 | DCHECK(instruction->IsDiv() || instruction->IsRem()); |
| 2192 | Primitive::Type type = instruction->GetResultType(); |
| 2193 | DCHECK(type == Primitive::kPrimInt || type == Primitive::kPrimLong) << type; |
| 2194 | |
| 2195 | LocationSummary* locations = instruction->GetLocations(); |
| 2196 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 2197 | Location second = locations->InAt(1); |
| 2198 | |
| 2199 | if (second.IsConstant()) { |
| 2200 | int64_t imm = Int64FromConstant(second.GetConstant()); |
| 2201 | if (imm == 0) { |
| 2202 | // Do not generate anything. DivZeroCheck would prevent any code to be executed. |
| 2203 | } else if (imm == 1 || imm == -1) { |
| 2204 | DivRemOneOrMinusOne(instruction); |
| 2205 | } else if (IsPowerOfTwo(std::abs(imm))) { |
| 2206 | DivRemByPowerOfTwo(instruction); |
| 2207 | } else { |
| 2208 | DCHECK(imm <= -2 || imm >= 2); |
| 2209 | GenerateDivRemWithAnyConstant(instruction); |
| 2210 | } |
| 2211 | } else { |
| 2212 | GpuRegister dividend = locations->InAt(0).AsRegister<GpuRegister>(); |
| 2213 | GpuRegister divisor = second.AsRegister<GpuRegister>(); |
| 2214 | if (instruction->IsDiv()) { |
| 2215 | if (type == Primitive::kPrimInt) |
| 2216 | __ DivR6(out, dividend, divisor); |
| 2217 | else |
| 2218 | __ Ddiv(out, dividend, divisor); |
| 2219 | } else { |
| 2220 | if (type == Primitive::kPrimInt) |
| 2221 | __ ModR6(out, dividend, divisor); |
| 2222 | else |
| 2223 | __ Dmod(out, dividend, divisor); |
| 2224 | } |
| 2225 | } |
| 2226 | } |
| 2227 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2228 | void LocationsBuilderMIPS64::VisitDiv(HDiv* div) { |
| 2229 | LocationSummary* locations = |
| 2230 | new (GetGraph()->GetArena()) LocationSummary(div, LocationSummary::kNoCall); |
| 2231 | switch (div->GetResultType()) { |
| 2232 | case Primitive::kPrimInt: |
| 2233 | case Primitive::kPrimLong: |
| 2234 | locations->SetInAt(0, Location::RequiresRegister()); |
Alexey Frunze | c857c74 | 2015-09-23 15:12:39 -0700 | [diff] [blame] | 2235 | locations->SetInAt(1, Location::RegisterOrConstant(div->InputAt(1))); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2236 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2237 | break; |
| 2238 | |
| 2239 | case Primitive::kPrimFloat: |
| 2240 | case Primitive::kPrimDouble: |
| 2241 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 2242 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 2243 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 2244 | break; |
| 2245 | |
| 2246 | default: |
| 2247 | LOG(FATAL) << "Unexpected div type " << div->GetResultType(); |
| 2248 | } |
| 2249 | } |
| 2250 | |
| 2251 | void InstructionCodeGeneratorMIPS64::VisitDiv(HDiv* instruction) { |
| 2252 | Primitive::Type type = instruction->GetType(); |
| 2253 | LocationSummary* locations = instruction->GetLocations(); |
| 2254 | |
| 2255 | switch (type) { |
| 2256 | case Primitive::kPrimInt: |
Alexey Frunze | c857c74 | 2015-09-23 15:12:39 -0700 | [diff] [blame] | 2257 | case Primitive::kPrimLong: |
| 2258 | GenerateDivRemIntegral(instruction); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2259 | break; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2260 | case Primitive::kPrimFloat: |
| 2261 | case Primitive::kPrimDouble: { |
| 2262 | FpuRegister dst = locations->Out().AsFpuRegister<FpuRegister>(); |
| 2263 | FpuRegister lhs = locations->InAt(0).AsFpuRegister<FpuRegister>(); |
| 2264 | FpuRegister rhs = locations->InAt(1).AsFpuRegister<FpuRegister>(); |
| 2265 | if (type == Primitive::kPrimFloat) |
| 2266 | __ DivS(dst, lhs, rhs); |
| 2267 | else |
| 2268 | __ DivD(dst, lhs, rhs); |
| 2269 | break; |
| 2270 | } |
| 2271 | default: |
| 2272 | LOG(FATAL) << "Unexpected div type " << type; |
| 2273 | } |
| 2274 | } |
| 2275 | |
| 2276 | void LocationsBuilderMIPS64::VisitDivZeroCheck(HDivZeroCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 2277 | LocationSummary::CallKind call_kind = instruction->CanThrowIntoCatchBlock() |
| 2278 | ? LocationSummary::kCallOnSlowPath |
| 2279 | : LocationSummary::kNoCall; |
| 2280 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2281 | locations->SetInAt(0, Location::RegisterOrConstant(instruction->InputAt(0))); |
| 2282 | if (instruction->HasUses()) { |
| 2283 | locations->SetOut(Location::SameAsFirstInput()); |
| 2284 | } |
| 2285 | } |
| 2286 | |
| 2287 | void InstructionCodeGeneratorMIPS64::VisitDivZeroCheck(HDivZeroCheck* instruction) { |
| 2288 | SlowPathCodeMIPS64* slow_path = |
| 2289 | new (GetGraph()->GetArena()) DivZeroCheckSlowPathMIPS64(instruction); |
| 2290 | codegen_->AddSlowPath(slow_path); |
| 2291 | Location value = instruction->GetLocations()->InAt(0); |
| 2292 | |
| 2293 | Primitive::Type type = instruction->GetType(); |
| 2294 | |
Serguei Katkov | 8c0676c | 2015-08-03 13:55:33 +0600 | [diff] [blame] | 2295 | if ((type == Primitive::kPrimBoolean) || !Primitive::IsIntegralType(type)) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2296 | LOG(FATAL) << "Unexpected type " << type << " for DivZeroCheck."; |
Serguei Katkov | 8c0676c | 2015-08-03 13:55:33 +0600 | [diff] [blame] | 2297 | return; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | if (value.IsConstant()) { |
| 2301 | int64_t divisor = codegen_->GetInt64ValueOf(value.GetConstant()->AsConstant()); |
| 2302 | if (divisor == 0) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2303 | __ Bc(slow_path->GetEntryLabel()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2304 | } else { |
| 2305 | // A division by a non-null constant is valid. We don't need to perform |
| 2306 | // any check, so simply fall through. |
| 2307 | } |
| 2308 | } else { |
| 2309 | __ Beqzc(value.AsRegister<GpuRegister>(), slow_path->GetEntryLabel()); |
| 2310 | } |
| 2311 | } |
| 2312 | |
| 2313 | void LocationsBuilderMIPS64::VisitDoubleConstant(HDoubleConstant* constant) { |
| 2314 | LocationSummary* locations = |
| 2315 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
| 2316 | locations->SetOut(Location::ConstantLocation(constant)); |
| 2317 | } |
| 2318 | |
| 2319 | void InstructionCodeGeneratorMIPS64::VisitDoubleConstant(HDoubleConstant* cst ATTRIBUTE_UNUSED) { |
| 2320 | // Will be generated at use site. |
| 2321 | } |
| 2322 | |
| 2323 | void LocationsBuilderMIPS64::VisitExit(HExit* exit) { |
| 2324 | exit->SetLocations(nullptr); |
| 2325 | } |
| 2326 | |
| 2327 | void InstructionCodeGeneratorMIPS64::VisitExit(HExit* exit ATTRIBUTE_UNUSED) { |
| 2328 | } |
| 2329 | |
| 2330 | void LocationsBuilderMIPS64::VisitFloatConstant(HFloatConstant* constant) { |
| 2331 | LocationSummary* locations = |
| 2332 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
| 2333 | locations->SetOut(Location::ConstantLocation(constant)); |
| 2334 | } |
| 2335 | |
| 2336 | void InstructionCodeGeneratorMIPS64::VisitFloatConstant(HFloatConstant* constant ATTRIBUTE_UNUSED) { |
| 2337 | // Will be generated at use site. |
| 2338 | } |
| 2339 | |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 2340 | void InstructionCodeGeneratorMIPS64::HandleGoto(HInstruction* got, HBasicBlock* successor) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2341 | DCHECK(!successor->IsExitBlock()); |
| 2342 | HBasicBlock* block = got->GetBlock(); |
| 2343 | HInstruction* previous = got->GetPrevious(); |
| 2344 | HLoopInformation* info = block->GetLoopInformation(); |
| 2345 | |
| 2346 | if (info != nullptr && info->IsBackEdge(*block) && info->HasSuspendCheck()) { |
| 2347 | codegen_->ClearSpillSlotsFromLoopPhisInStackMap(info->GetSuspendCheck()); |
| 2348 | GenerateSuspendCheck(info->GetSuspendCheck(), successor); |
| 2349 | return; |
| 2350 | } |
| 2351 | if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) { |
| 2352 | GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr); |
| 2353 | } |
| 2354 | if (!codegen_->GoesToNextBlock(block, successor)) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2355 | __ Bc(codegen_->GetLabelOf(successor)); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2356 | } |
| 2357 | } |
| 2358 | |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 2359 | void LocationsBuilderMIPS64::VisitGoto(HGoto* got) { |
| 2360 | got->SetLocations(nullptr); |
| 2361 | } |
| 2362 | |
| 2363 | void InstructionCodeGeneratorMIPS64::VisitGoto(HGoto* got) { |
| 2364 | HandleGoto(got, got->GetSuccessor()); |
| 2365 | } |
| 2366 | |
| 2367 | void LocationsBuilderMIPS64::VisitTryBoundary(HTryBoundary* try_boundary) { |
| 2368 | try_boundary->SetLocations(nullptr); |
| 2369 | } |
| 2370 | |
| 2371 | void InstructionCodeGeneratorMIPS64::VisitTryBoundary(HTryBoundary* try_boundary) { |
| 2372 | HBasicBlock* successor = try_boundary->GetNormalFlowSuccessor(); |
| 2373 | if (!successor->IsExitBlock()) { |
| 2374 | HandleGoto(try_boundary, successor); |
| 2375 | } |
| 2376 | } |
| 2377 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2378 | void InstructionCodeGeneratorMIPS64::GenerateTestAndBranch(HInstruction* instruction, |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2379 | size_t condition_input_index, |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2380 | Mips64Label* true_target, |
| 2381 | Mips64Label* false_target) { |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2382 | HInstruction* cond = instruction->InputAt(condition_input_index); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2383 | |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2384 | if (true_target == nullptr && false_target == nullptr) { |
| 2385 | // Nothing to do. The code always falls through. |
| 2386 | return; |
| 2387 | } else if (cond->IsIntConstant()) { |
| 2388 | // Constant condition, statically compared against 1. |
| 2389 | if (cond->AsIntConstant()->IsOne()) { |
| 2390 | if (true_target != nullptr) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2391 | __ Bc(true_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2392 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2393 | } else { |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2394 | DCHECK(cond->AsIntConstant()->IsZero()); |
| 2395 | if (false_target != nullptr) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2396 | __ Bc(false_target); |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2397 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2398 | } |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2399 | return; |
| 2400 | } |
| 2401 | |
| 2402 | // The following code generates these patterns: |
| 2403 | // (1) true_target == nullptr && false_target != nullptr |
| 2404 | // - opposite condition true => branch to false_target |
| 2405 | // (2) true_target != nullptr && false_target == nullptr |
| 2406 | // - condition true => branch to true_target |
| 2407 | // (3) true_target != nullptr && false_target != nullptr |
| 2408 | // - condition true => branch to true_target |
| 2409 | // - branch to false_target |
| 2410 | if (IsBooleanValueOrMaterializedCondition(cond)) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2411 | // The condition instruction has been materialized, compare the output to 0. |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2412 | Location cond_val = instruction->GetLocations()->InAt(condition_input_index); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2413 | DCHECK(cond_val.IsRegister()); |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2414 | if (true_target == nullptr) { |
| 2415 | __ Beqzc(cond_val.AsRegister<GpuRegister>(), false_target); |
| 2416 | } else { |
| 2417 | __ Bnezc(cond_val.AsRegister<GpuRegister>(), true_target); |
| 2418 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2419 | } else { |
| 2420 | // The condition instruction has not been materialized, use its inputs as |
| 2421 | // the comparison and its condition as the branch condition. |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2422 | HCondition* condition = cond->AsCondition(); |
| 2423 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2424 | GpuRegister lhs = condition->GetLocations()->InAt(0).AsRegister<GpuRegister>(); |
| 2425 | Location rhs_location = condition->GetLocations()->InAt(1); |
| 2426 | GpuRegister rhs_reg = ZERO; |
| 2427 | int32_t rhs_imm = 0; |
| 2428 | bool use_imm = rhs_location.IsConstant(); |
| 2429 | if (use_imm) { |
| 2430 | rhs_imm = CodeGenerator::GetInt32ValueOf(rhs_location.GetConstant()); |
| 2431 | } else { |
| 2432 | rhs_reg = rhs_location.AsRegister<GpuRegister>(); |
| 2433 | } |
| 2434 | |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2435 | IfCondition if_cond; |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2436 | Mips64Label* non_fallthrough_target; |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2437 | if (true_target == nullptr) { |
| 2438 | if_cond = condition->GetOppositeCondition(); |
| 2439 | non_fallthrough_target = false_target; |
| 2440 | } else { |
| 2441 | if_cond = condition->GetCondition(); |
| 2442 | non_fallthrough_target = true_target; |
| 2443 | } |
| 2444 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2445 | if (use_imm && rhs_imm == 0) { |
| 2446 | switch (if_cond) { |
| 2447 | case kCondEQ: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2448 | __ Beqzc(lhs, non_fallthrough_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2449 | break; |
| 2450 | case kCondNE: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2451 | __ Bnezc(lhs, non_fallthrough_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2452 | break; |
| 2453 | case kCondLT: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2454 | __ Bltzc(lhs, non_fallthrough_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2455 | break; |
| 2456 | case kCondGE: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2457 | __ Bgezc(lhs, non_fallthrough_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2458 | break; |
| 2459 | case kCondLE: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2460 | __ Blezc(lhs, non_fallthrough_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2461 | break; |
| 2462 | case kCondGT: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2463 | __ Bgtzc(lhs, non_fallthrough_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2464 | break; |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 2465 | case kCondB: |
| 2466 | break; // always false |
| 2467 | case kCondBE: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2468 | __ Beqzc(lhs, non_fallthrough_target); // <= 0 if zero |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 2469 | break; |
| 2470 | case kCondA: |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2471 | __ Bnezc(lhs, non_fallthrough_target); // > 0 if non-zero |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 2472 | break; |
| 2473 | case kCondAE: |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2474 | __ Bc(non_fallthrough_target); // always true |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 2475 | break; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2476 | } |
| 2477 | } else { |
| 2478 | if (use_imm) { |
| 2479 | rhs_reg = TMP; |
| 2480 | __ LoadConst32(rhs_reg, rhs_imm); |
| 2481 | } |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2482 | switch (if_cond) { |
| 2483 | case kCondEQ: |
| 2484 | __ Beqc(lhs, rhs_reg, non_fallthrough_target); |
| 2485 | break; |
| 2486 | case kCondNE: |
| 2487 | __ Bnec(lhs, rhs_reg, non_fallthrough_target); |
| 2488 | break; |
| 2489 | case kCondLT: |
| 2490 | __ Bltc(lhs, rhs_reg, non_fallthrough_target); |
| 2491 | break; |
| 2492 | case kCondGE: |
| 2493 | __ Bgec(lhs, rhs_reg, non_fallthrough_target); |
| 2494 | break; |
| 2495 | case kCondLE: |
| 2496 | __ Bgec(rhs_reg, lhs, non_fallthrough_target); |
| 2497 | break; |
| 2498 | case kCondGT: |
| 2499 | __ Bltc(rhs_reg, lhs, non_fallthrough_target); |
| 2500 | break; |
| 2501 | case kCondB: |
| 2502 | __ Bltuc(lhs, rhs_reg, non_fallthrough_target); |
| 2503 | break; |
| 2504 | case kCondAE: |
| 2505 | __ Bgeuc(lhs, rhs_reg, non_fallthrough_target); |
| 2506 | break; |
| 2507 | case kCondBE: |
| 2508 | __ Bgeuc(rhs_reg, lhs, non_fallthrough_target); |
| 2509 | break; |
| 2510 | case kCondA: |
| 2511 | __ Bltuc(rhs_reg, lhs, non_fallthrough_target); |
| 2512 | break; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2513 | } |
| 2514 | } |
| 2515 | } |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2516 | |
| 2517 | // If neither branch falls through (case 3), the conditional branch to `true_target` |
| 2518 | // was already emitted (case 2) and we need to emit a jump to `false_target`. |
| 2519 | if (true_target != nullptr && false_target != nullptr) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2520 | __ Bc(false_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2521 | } |
| 2522 | } |
| 2523 | |
| 2524 | void LocationsBuilderMIPS64::VisitIf(HIf* if_instr) { |
| 2525 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(if_instr); |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2526 | if (IsBooleanValueOrMaterializedCondition(if_instr->InputAt(0))) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2527 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2528 | } |
| 2529 | } |
| 2530 | |
| 2531 | void InstructionCodeGeneratorMIPS64::VisitIf(HIf* if_instr) { |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2532 | HBasicBlock* true_successor = if_instr->IfTrueSuccessor(); |
| 2533 | HBasicBlock* false_successor = if_instr->IfFalseSuccessor(); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2534 | Mips64Label* true_target = codegen_->GoesToNextBlock(if_instr->GetBlock(), true_successor) ? |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2535 | nullptr : codegen_->GetLabelOf(true_successor); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2536 | Mips64Label* false_target = codegen_->GoesToNextBlock(if_instr->GetBlock(), false_successor) ? |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2537 | nullptr : codegen_->GetLabelOf(false_successor); |
| 2538 | GenerateTestAndBranch(if_instr, /* condition_input_index */ 0, true_target, false_target); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2539 | } |
| 2540 | |
| 2541 | void LocationsBuilderMIPS64::VisitDeoptimize(HDeoptimize* deoptimize) { |
| 2542 | LocationSummary* locations = new (GetGraph()->GetArena()) |
| 2543 | LocationSummary(deoptimize, LocationSummary::kCallOnSlowPath); |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2544 | if (IsBooleanValueOrMaterializedCondition(deoptimize->InputAt(0))) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2545 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2546 | } |
| 2547 | } |
| 2548 | |
| 2549 | void InstructionCodeGeneratorMIPS64::VisitDeoptimize(HDeoptimize* deoptimize) { |
| 2550 | SlowPathCodeMIPS64* slow_path = new (GetGraph()->GetArena()) |
| 2551 | DeoptimizationSlowPathMIPS64(deoptimize); |
| 2552 | codegen_->AddSlowPath(slow_path); |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 2553 | GenerateTestAndBranch(deoptimize, |
| 2554 | /* condition_input_index */ 0, |
| 2555 | slow_path->GetEntryLabel(), |
| 2556 | /* false_target */ nullptr); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2557 | } |
| 2558 | |
| 2559 | void LocationsBuilderMIPS64::HandleFieldGet(HInstruction* instruction, |
| 2560 | const FieldInfo& field_info ATTRIBUTE_UNUSED) { |
| 2561 | LocationSummary* locations = |
| 2562 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 2563 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2564 | if (Primitive::IsFloatingPointType(instruction->GetType())) { |
| 2565 | locations->SetOut(Location::RequiresFpuRegister()); |
| 2566 | } else { |
| 2567 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2568 | } |
| 2569 | } |
| 2570 | |
| 2571 | void InstructionCodeGeneratorMIPS64::HandleFieldGet(HInstruction* instruction, |
| 2572 | const FieldInfo& field_info) { |
| 2573 | Primitive::Type type = field_info.GetFieldType(); |
| 2574 | LocationSummary* locations = instruction->GetLocations(); |
| 2575 | GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); |
| 2576 | LoadOperandType load_type = kLoadUnsignedByte; |
| 2577 | switch (type) { |
| 2578 | case Primitive::kPrimBoolean: |
| 2579 | load_type = kLoadUnsignedByte; |
| 2580 | break; |
| 2581 | case Primitive::kPrimByte: |
| 2582 | load_type = kLoadSignedByte; |
| 2583 | break; |
| 2584 | case Primitive::kPrimShort: |
| 2585 | load_type = kLoadSignedHalfword; |
| 2586 | break; |
| 2587 | case Primitive::kPrimChar: |
| 2588 | load_type = kLoadUnsignedHalfword; |
| 2589 | break; |
| 2590 | case Primitive::kPrimInt: |
| 2591 | case Primitive::kPrimFloat: |
| 2592 | load_type = kLoadWord; |
| 2593 | break; |
| 2594 | case Primitive::kPrimLong: |
| 2595 | case Primitive::kPrimDouble: |
| 2596 | load_type = kLoadDoubleword; |
| 2597 | break; |
| 2598 | case Primitive::kPrimNot: |
| 2599 | load_type = kLoadUnsignedWord; |
| 2600 | break; |
| 2601 | case Primitive::kPrimVoid: |
| 2602 | LOG(FATAL) << "Unreachable type " << type; |
| 2603 | UNREACHABLE(); |
| 2604 | } |
| 2605 | if (!Primitive::IsFloatingPointType(type)) { |
| 2606 | DCHECK(locations->Out().IsRegister()); |
| 2607 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 2608 | __ LoadFromOffset(load_type, dst, obj, field_info.GetFieldOffset().Uint32Value()); |
| 2609 | } else { |
| 2610 | DCHECK(locations->Out().IsFpuRegister()); |
| 2611 | FpuRegister dst = locations->Out().AsFpuRegister<FpuRegister>(); |
| 2612 | __ LoadFpuFromOffset(load_type, dst, obj, field_info.GetFieldOffset().Uint32Value()); |
| 2613 | } |
| 2614 | |
| 2615 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 2616 | // TODO: memory barrier? |
| 2617 | } |
| 2618 | |
| 2619 | void LocationsBuilderMIPS64::HandleFieldSet(HInstruction* instruction, |
| 2620 | const FieldInfo& field_info ATTRIBUTE_UNUSED) { |
| 2621 | LocationSummary* locations = |
| 2622 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 2623 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2624 | if (Primitive::IsFloatingPointType(instruction->InputAt(1)->GetType())) { |
| 2625 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 2626 | } else { |
| 2627 | locations->SetInAt(1, Location::RequiresRegister()); |
| 2628 | } |
| 2629 | } |
| 2630 | |
| 2631 | void InstructionCodeGeneratorMIPS64::HandleFieldSet(HInstruction* instruction, |
| 2632 | const FieldInfo& field_info) { |
| 2633 | Primitive::Type type = field_info.GetFieldType(); |
| 2634 | LocationSummary* locations = instruction->GetLocations(); |
| 2635 | GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); |
| 2636 | StoreOperandType store_type = kStoreByte; |
| 2637 | switch (type) { |
| 2638 | case Primitive::kPrimBoolean: |
| 2639 | case Primitive::kPrimByte: |
| 2640 | store_type = kStoreByte; |
| 2641 | break; |
| 2642 | case Primitive::kPrimShort: |
| 2643 | case Primitive::kPrimChar: |
| 2644 | store_type = kStoreHalfword; |
| 2645 | break; |
| 2646 | case Primitive::kPrimInt: |
| 2647 | case Primitive::kPrimFloat: |
| 2648 | case Primitive::kPrimNot: |
| 2649 | store_type = kStoreWord; |
| 2650 | break; |
| 2651 | case Primitive::kPrimLong: |
| 2652 | case Primitive::kPrimDouble: |
| 2653 | store_type = kStoreDoubleword; |
| 2654 | break; |
| 2655 | case Primitive::kPrimVoid: |
| 2656 | LOG(FATAL) << "Unreachable type " << type; |
| 2657 | UNREACHABLE(); |
| 2658 | } |
| 2659 | if (!Primitive::IsFloatingPointType(type)) { |
| 2660 | DCHECK(locations->InAt(1).IsRegister()); |
| 2661 | GpuRegister src = locations->InAt(1).AsRegister<GpuRegister>(); |
| 2662 | __ StoreToOffset(store_type, src, obj, field_info.GetFieldOffset().Uint32Value()); |
| 2663 | } else { |
| 2664 | DCHECK(locations->InAt(1).IsFpuRegister()); |
| 2665 | FpuRegister src = locations->InAt(1).AsFpuRegister<FpuRegister>(); |
| 2666 | __ StoreFpuToOffset(store_type, src, obj, field_info.GetFieldOffset().Uint32Value()); |
| 2667 | } |
| 2668 | |
| 2669 | codegen_->MaybeRecordImplicitNullCheck(instruction); |
| 2670 | // TODO: memory barriers? |
| 2671 | if (CodeGenerator::StoreNeedsWriteBarrier(type, instruction->InputAt(1))) { |
| 2672 | DCHECK(locations->InAt(1).IsRegister()); |
| 2673 | GpuRegister src = locations->InAt(1).AsRegister<GpuRegister>(); |
| 2674 | codegen_->MarkGCCard(obj, src); |
| 2675 | } |
| 2676 | } |
| 2677 | |
| 2678 | void LocationsBuilderMIPS64::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
| 2679 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 2680 | } |
| 2681 | |
| 2682 | void InstructionCodeGeneratorMIPS64::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
| 2683 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 2684 | } |
| 2685 | |
| 2686 | void LocationsBuilderMIPS64::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
| 2687 | HandleFieldSet(instruction, instruction->GetFieldInfo()); |
| 2688 | } |
| 2689 | |
| 2690 | void InstructionCodeGeneratorMIPS64::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
| 2691 | HandleFieldSet(instruction, instruction->GetFieldInfo()); |
| 2692 | } |
| 2693 | |
| 2694 | void LocationsBuilderMIPS64::VisitInstanceOf(HInstanceOf* instruction) { |
| 2695 | LocationSummary::CallKind call_kind = |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 2696 | instruction->IsExactCheck() ? LocationSummary::kNoCall : LocationSummary::kCallOnSlowPath; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2697 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
| 2698 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2699 | locations->SetInAt(1, Location::RequiresRegister()); |
| 2700 | // The output does overlap inputs. |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 2701 | // Note that TypeCheckSlowPathMIPS64 uses this register too. |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2702 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
| 2703 | } |
| 2704 | |
| 2705 | void InstructionCodeGeneratorMIPS64::VisitInstanceOf(HInstanceOf* instruction) { |
| 2706 | LocationSummary* locations = instruction->GetLocations(); |
| 2707 | GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); |
| 2708 | GpuRegister cls = locations->InAt(1).AsRegister<GpuRegister>(); |
| 2709 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 2710 | |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2711 | Mips64Label done; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2712 | |
| 2713 | // Return 0 if `obj` is null. |
| 2714 | // TODO: Avoid this check if we know `obj` is not null. |
| 2715 | __ Move(out, ZERO); |
| 2716 | __ Beqzc(obj, &done); |
| 2717 | |
| 2718 | // Compare the class of `obj` with `cls`. |
| 2719 | __ LoadFromOffset(kLoadUnsignedWord, out, obj, mirror::Object::ClassOffset().Int32Value()); |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 2720 | if (instruction->IsExactCheck()) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2721 | // Classes must be equal for the instanceof to succeed. |
| 2722 | __ Xor(out, out, cls); |
| 2723 | __ Sltiu(out, out, 1); |
| 2724 | } else { |
| 2725 | // If the classes are not equal, we go into a slow path. |
| 2726 | DCHECK(locations->OnlyCallsOnSlowPath()); |
| 2727 | SlowPathCodeMIPS64* slow_path = |
Serban Constantinescu | 5a6cc49 | 2015-08-13 15:20:25 +0100 | [diff] [blame] | 2728 | new (GetGraph()->GetArena()) TypeCheckSlowPathMIPS64(instruction); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2729 | codegen_->AddSlowPath(slow_path); |
| 2730 | __ Bnec(out, cls, slow_path->GetEntryLabel()); |
| 2731 | __ LoadConst32(out, 1); |
| 2732 | __ Bind(slow_path->GetExitLabel()); |
| 2733 | } |
| 2734 | |
| 2735 | __ Bind(&done); |
| 2736 | } |
| 2737 | |
| 2738 | void LocationsBuilderMIPS64::VisitIntConstant(HIntConstant* constant) { |
| 2739 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(constant); |
| 2740 | locations->SetOut(Location::ConstantLocation(constant)); |
| 2741 | } |
| 2742 | |
| 2743 | void InstructionCodeGeneratorMIPS64::VisitIntConstant(HIntConstant* constant ATTRIBUTE_UNUSED) { |
| 2744 | // Will be generated at use site. |
| 2745 | } |
| 2746 | |
| 2747 | void LocationsBuilderMIPS64::VisitNullConstant(HNullConstant* constant) { |
| 2748 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(constant); |
| 2749 | locations->SetOut(Location::ConstantLocation(constant)); |
| 2750 | } |
| 2751 | |
| 2752 | void InstructionCodeGeneratorMIPS64::VisitNullConstant(HNullConstant* constant ATTRIBUTE_UNUSED) { |
| 2753 | // Will be generated at use site. |
| 2754 | } |
| 2755 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 2756 | void LocationsBuilderMIPS64::VisitInvokeUnresolved(HInvokeUnresolved* invoke) { |
| 2757 | // The trampoline uses the same calling convention as dex calling conventions, |
| 2758 | // except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
| 2759 | // the method_idx. |
| 2760 | HandleInvoke(invoke); |
| 2761 | } |
| 2762 | |
| 2763 | void InstructionCodeGeneratorMIPS64::VisitInvokeUnresolved(HInvokeUnresolved* invoke) { |
| 2764 | codegen_->GenerateInvokeUnresolvedRuntimeCall(invoke); |
| 2765 | } |
| 2766 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2767 | void LocationsBuilderMIPS64::HandleInvoke(HInvoke* invoke) { |
| 2768 | InvokeDexCallingConventionVisitorMIPS64 calling_convention_visitor; |
| 2769 | CodeGenerator::CreateCommonInvokeLocationSummary(invoke, &calling_convention_visitor); |
| 2770 | } |
| 2771 | |
| 2772 | void LocationsBuilderMIPS64::VisitInvokeInterface(HInvokeInterface* invoke) { |
| 2773 | HandleInvoke(invoke); |
| 2774 | // The register T0 is required to be used for the hidden argument in |
| 2775 | // art_quick_imt_conflict_trampoline, so add the hidden argument. |
| 2776 | invoke->GetLocations()->AddTemp(Location::RegisterLocation(T0)); |
| 2777 | } |
| 2778 | |
| 2779 | void InstructionCodeGeneratorMIPS64::VisitInvokeInterface(HInvokeInterface* invoke) { |
| 2780 | // TODO: b/18116999, our IMTs can miss an IncompatibleClassChangeError. |
| 2781 | GpuRegister temp = invoke->GetLocations()->GetTemp(0).AsRegister<GpuRegister>(); |
| 2782 | uint32_t method_offset = mirror::Class::EmbeddedImTableEntryOffset( |
| 2783 | invoke->GetImtIndex() % mirror::Class::kImtSize, kMips64PointerSize).Uint32Value(); |
| 2784 | Location receiver = invoke->GetLocations()->InAt(0); |
| 2785 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
| 2786 | Offset entry_point = ArtMethod::EntryPointFromQuickCompiledCodeOffset(kMips64WordSize); |
| 2787 | |
| 2788 | // Set the hidden argument. |
| 2789 | __ LoadConst32(invoke->GetLocations()->GetTemp(1).AsRegister<GpuRegister>(), |
| 2790 | invoke->GetDexMethodIndex()); |
| 2791 | |
| 2792 | // temp = object->GetClass(); |
| 2793 | if (receiver.IsStackSlot()) { |
| 2794 | __ LoadFromOffset(kLoadUnsignedWord, temp, SP, receiver.GetStackIndex()); |
| 2795 | __ LoadFromOffset(kLoadUnsignedWord, temp, temp, class_offset); |
| 2796 | } else { |
| 2797 | __ LoadFromOffset(kLoadUnsignedWord, temp, receiver.AsRegister<GpuRegister>(), class_offset); |
| 2798 | } |
| 2799 | codegen_->MaybeRecordImplicitNullCheck(invoke); |
| 2800 | // temp = temp->GetImtEntryAt(method_offset); |
| 2801 | __ LoadFromOffset(kLoadDoubleword, temp, temp, method_offset); |
| 2802 | // T9 = temp->GetEntryPoint(); |
| 2803 | __ LoadFromOffset(kLoadDoubleword, T9, temp, entry_point.Int32Value()); |
| 2804 | // T9(); |
| 2805 | __ Jalr(T9); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2806 | __ Nop(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2807 | DCHECK(!codegen_->IsLeafMethod()); |
| 2808 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
| 2809 | } |
| 2810 | |
| 2811 | void LocationsBuilderMIPS64::VisitInvokeVirtual(HInvokeVirtual* invoke) { |
Chris Larsen | 3039e38 | 2015-08-26 07:54:08 -0700 | [diff] [blame] | 2812 | IntrinsicLocationsBuilderMIPS64 intrinsic(codegen_); |
| 2813 | if (intrinsic.TryDispatch(invoke)) { |
| 2814 | return; |
| 2815 | } |
| 2816 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2817 | HandleInvoke(invoke); |
| 2818 | } |
| 2819 | |
| 2820 | void LocationsBuilderMIPS64::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) { |
| 2821 | // When we do not run baseline, explicit clinit checks triggered by static |
| 2822 | // invokes must have been pruned by art::PrepareForRegisterAllocation. |
| 2823 | DCHECK(codegen_->IsBaseline() || !invoke->IsStaticWithExplicitClinitCheck()); |
| 2824 | |
Chris Larsen | 3039e38 | 2015-08-26 07:54:08 -0700 | [diff] [blame] | 2825 | IntrinsicLocationsBuilderMIPS64 intrinsic(codegen_); |
| 2826 | if (intrinsic.TryDispatch(invoke)) { |
| 2827 | return; |
| 2828 | } |
| 2829 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2830 | HandleInvoke(invoke); |
| 2831 | |
| 2832 | // While SetupBlockedRegisters() blocks registers S2-S8 due to their |
| 2833 | // clobbering somewhere else, reduce further register pressure by avoiding |
| 2834 | // allocation of a register for the current method pointer like on x86 baseline. |
| 2835 | // TODO: remove this once all the issues with register saving/restoring are |
| 2836 | // sorted out. |
Vladimir Marko | 6f6f359 | 2015-11-09 12:54:16 +0000 | [diff] [blame] | 2837 | if (invoke->HasCurrentMethodInput()) { |
| 2838 | LocationSummary* locations = invoke->GetLocations(); |
Vladimir Marko | c53c079 | 2015-11-19 15:48:33 +0000 | [diff] [blame] | 2839 | Location location = locations->InAt(invoke->GetSpecialInputIndex()); |
Vladimir Marko | 6f6f359 | 2015-11-09 12:54:16 +0000 | [diff] [blame] | 2840 | if (location.IsUnallocated() && location.GetPolicy() == Location::kRequiresRegister) { |
Vladimir Marko | c53c079 | 2015-11-19 15:48:33 +0000 | [diff] [blame] | 2841 | locations->SetInAt(invoke->GetSpecialInputIndex(), Location::NoLocation()); |
Vladimir Marko | 6f6f359 | 2015-11-09 12:54:16 +0000 | [diff] [blame] | 2842 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2843 | } |
| 2844 | } |
| 2845 | |
Chris Larsen | 3039e38 | 2015-08-26 07:54:08 -0700 | [diff] [blame] | 2846 | static bool TryGenerateIntrinsicCode(HInvoke* invoke, CodeGeneratorMIPS64* codegen) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2847 | if (invoke->GetLocations()->Intrinsified()) { |
Chris Larsen | 3039e38 | 2015-08-26 07:54:08 -0700 | [diff] [blame] | 2848 | IntrinsicCodeGeneratorMIPS64 intrinsic(codegen); |
| 2849 | intrinsic.Dispatch(invoke); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2850 | return true; |
| 2851 | } |
| 2852 | return false; |
| 2853 | } |
| 2854 | |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 2855 | HInvokeStaticOrDirect::DispatchInfo CodeGeneratorMIPS64::GetSupportedInvokeStaticOrDirectDispatch( |
| 2856 | const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info, |
| 2857 | MethodReference target_method ATTRIBUTE_UNUSED) { |
| 2858 | switch (desired_dispatch_info.method_load_kind) { |
| 2859 | case HInvokeStaticOrDirect::MethodLoadKind::kDirectAddressWithFixup: |
| 2860 | case HInvokeStaticOrDirect::MethodLoadKind::kDexCachePcRelative: |
| 2861 | // TODO: Implement these types. For the moment, we fall back to kDexCacheViaMethod. |
| 2862 | return HInvokeStaticOrDirect::DispatchInfo { |
| 2863 | HInvokeStaticOrDirect::MethodLoadKind::kDexCacheViaMethod, |
| 2864 | HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod, |
| 2865 | 0u, |
| 2866 | 0u |
| 2867 | }; |
| 2868 | default: |
| 2869 | break; |
| 2870 | } |
| 2871 | switch (desired_dispatch_info.code_ptr_location) { |
| 2872 | case HInvokeStaticOrDirect::CodePtrLocation::kCallDirectWithFixup: |
| 2873 | case HInvokeStaticOrDirect::CodePtrLocation::kCallPCRelative: |
| 2874 | // TODO: Implement these types. For the moment, we fall back to kCallArtMethod. |
| 2875 | return HInvokeStaticOrDirect::DispatchInfo { |
| 2876 | desired_dispatch_info.method_load_kind, |
| 2877 | HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod, |
| 2878 | desired_dispatch_info.method_load_data, |
| 2879 | 0u |
| 2880 | }; |
| 2881 | default: |
| 2882 | return desired_dispatch_info; |
| 2883 | } |
| 2884 | } |
| 2885 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2886 | void CodeGeneratorMIPS64::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, Location temp) { |
| 2887 | // All registers are assumed to be correctly set up per the calling convention. |
| 2888 | |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2889 | Location callee_method = temp; // For all kinds except kRecursive, callee will be in temp. |
| 2890 | switch (invoke->GetMethodLoadKind()) { |
| 2891 | case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: |
| 2892 | // temp = thread->string_init_entrypoint |
| 2893 | __ LoadFromOffset(kLoadDoubleword, |
| 2894 | temp.AsRegister<GpuRegister>(), |
| 2895 | TR, |
| 2896 | invoke->GetStringInitOffset()); |
| 2897 | break; |
| 2898 | case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: |
Vladimir Marko | c53c079 | 2015-11-19 15:48:33 +0000 | [diff] [blame] | 2899 | callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2900 | break; |
| 2901 | case HInvokeStaticOrDirect::MethodLoadKind::kDirectAddress: |
| 2902 | __ LoadConst64(temp.AsRegister<GpuRegister>(), invoke->GetMethodAddress()); |
| 2903 | break; |
| 2904 | case HInvokeStaticOrDirect::MethodLoadKind::kDirectAddressWithFixup: |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2905 | case HInvokeStaticOrDirect::MethodLoadKind::kDexCachePcRelative: |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 2906 | // TODO: Implement these types. |
| 2907 | // Currently filtered out by GetSupportedInvokeStaticOrDirectDispatch(). |
| 2908 | LOG(FATAL) << "Unsupported"; |
| 2909 | UNREACHABLE(); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2910 | case HInvokeStaticOrDirect::MethodLoadKind::kDexCacheViaMethod: { |
Vladimir Marko | c53c079 | 2015-11-19 15:48:33 +0000 | [diff] [blame] | 2911 | Location current_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2912 | GpuRegister reg = temp.AsRegister<GpuRegister>(); |
| 2913 | GpuRegister method_reg; |
| 2914 | if (current_method.IsRegister()) { |
| 2915 | method_reg = current_method.AsRegister<GpuRegister>(); |
| 2916 | } else { |
| 2917 | // TODO: use the appropriate DCHECK() here if possible. |
| 2918 | // DCHECK(invoke->GetLocations()->Intrinsified()); |
| 2919 | DCHECK(!current_method.IsValid()); |
| 2920 | method_reg = reg; |
| 2921 | __ Ld(reg, SP, kCurrentMethodStackOffset); |
| 2922 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2923 | |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2924 | // temp = temp->dex_cache_resolved_methods_; |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 2925 | __ LoadFromOffset(kLoadDoubleword, |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2926 | reg, |
| 2927 | method_reg, |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 2928 | ArtMethod::DexCacheResolvedMethodsOffset(kMips64PointerSize).Int32Value()); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2929 | // temp = temp[index_in_cache] |
| 2930 | uint32_t index_in_cache = invoke->GetTargetMethod().dex_method_index; |
| 2931 | __ LoadFromOffset(kLoadDoubleword, |
| 2932 | reg, |
| 2933 | reg, |
| 2934 | CodeGenerator::GetCachePointerOffset(index_in_cache)); |
| 2935 | break; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2936 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2937 | } |
| 2938 | |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2939 | switch (invoke->GetCodePtrLocation()) { |
| 2940 | case HInvokeStaticOrDirect::CodePtrLocation::kCallSelf: |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2941 | __ Jialc(&frame_entry_label_, T9); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2942 | break; |
| 2943 | case HInvokeStaticOrDirect::CodePtrLocation::kCallDirect: |
| 2944 | // LR = invoke->GetDirectCodePtr(); |
| 2945 | __ LoadConst64(T9, invoke->GetDirectCodePtr()); |
| 2946 | // LR() |
| 2947 | __ Jalr(T9); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2948 | __ Nop(); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2949 | break; |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2950 | case HInvokeStaticOrDirect::CodePtrLocation::kCallDirectWithFixup: |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 2951 | case HInvokeStaticOrDirect::CodePtrLocation::kCallPCRelative: |
| 2952 | // TODO: Implement these types. |
| 2953 | // Currently filtered out by GetSupportedInvokeStaticOrDirectDispatch(). |
| 2954 | LOG(FATAL) << "Unsupported"; |
| 2955 | UNREACHABLE(); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2956 | case HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod: |
| 2957 | // T9 = callee_method->entry_point_from_quick_compiled_code_; |
| 2958 | __ LoadFromOffset(kLoadDoubleword, |
| 2959 | T9, |
| 2960 | callee_method.AsRegister<GpuRegister>(), |
| 2961 | ArtMethod::EntryPointFromQuickCompiledCodeOffset( |
| 2962 | kMips64WordSize).Int32Value()); |
| 2963 | // T9() |
| 2964 | __ Jalr(T9); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 2965 | __ Nop(); |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 2966 | break; |
| 2967 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2968 | DCHECK(!IsLeafMethod()); |
| 2969 | } |
| 2970 | |
| 2971 | void InstructionCodeGeneratorMIPS64::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) { |
| 2972 | // When we do not run baseline, explicit clinit checks triggered by static |
| 2973 | // invokes must have been pruned by art::PrepareForRegisterAllocation. |
| 2974 | DCHECK(codegen_->IsBaseline() || !invoke->IsStaticWithExplicitClinitCheck()); |
| 2975 | |
| 2976 | if (TryGenerateIntrinsicCode(invoke, codegen_)) { |
| 2977 | return; |
| 2978 | } |
| 2979 | |
| 2980 | LocationSummary* locations = invoke->GetLocations(); |
| 2981 | codegen_->GenerateStaticOrDirectCall(invoke, |
| 2982 | locations->HasTemps() |
| 2983 | ? locations->GetTemp(0) |
| 2984 | : Location::NoLocation()); |
| 2985 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
| 2986 | } |
| 2987 | |
Alexey Frunze | 53afca1 | 2015-11-05 16:34:23 -0800 | [diff] [blame] | 2988 | void CodeGeneratorMIPS64::GenerateVirtualCall(HInvokeVirtual* invoke, Location temp_location) { |
Nicolas Geoffray | e523423 | 2015-12-02 09:06:11 +0000 | [diff] [blame] | 2989 | // Use the calling convention instead of the location of the receiver, as |
| 2990 | // intrinsics may have put the receiver in a different register. In the intrinsics |
| 2991 | // slow path, the arguments have been moved to the right place, so here we are |
| 2992 | // guaranteed that the receiver is the first register of the calling convention. |
| 2993 | InvokeDexCallingConvention calling_convention; |
| 2994 | GpuRegister receiver = calling_convention.GetRegisterAt(0); |
| 2995 | |
Alexey Frunze | 53afca1 | 2015-11-05 16:34:23 -0800 | [diff] [blame] | 2996 | GpuRegister temp = temp_location.AsRegister<GpuRegister>(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 2997 | size_t method_offset = mirror::Class::EmbeddedVTableEntryOffset( |
| 2998 | invoke->GetVTableIndex(), kMips64PointerSize).SizeValue(); |
| 2999 | uint32_t class_offset = mirror::Object::ClassOffset().Int32Value(); |
| 3000 | Offset entry_point = ArtMethod::EntryPointFromQuickCompiledCodeOffset(kMips64WordSize); |
| 3001 | |
| 3002 | // temp = object->GetClass(); |
Nicolas Geoffray | e523423 | 2015-12-02 09:06:11 +0000 | [diff] [blame] | 3003 | __ LoadFromOffset(kLoadUnsignedWord, temp, receiver, class_offset); |
Alexey Frunze | 53afca1 | 2015-11-05 16:34:23 -0800 | [diff] [blame] | 3004 | MaybeRecordImplicitNullCheck(invoke); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3005 | // temp = temp->GetMethodAt(method_offset); |
| 3006 | __ LoadFromOffset(kLoadDoubleword, temp, temp, method_offset); |
| 3007 | // T9 = temp->GetEntryPoint(); |
| 3008 | __ LoadFromOffset(kLoadDoubleword, T9, temp, entry_point.Int32Value()); |
| 3009 | // T9(); |
| 3010 | __ Jalr(T9); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 3011 | __ Nop(); |
Alexey Frunze | 53afca1 | 2015-11-05 16:34:23 -0800 | [diff] [blame] | 3012 | } |
| 3013 | |
| 3014 | void InstructionCodeGeneratorMIPS64::VisitInvokeVirtual(HInvokeVirtual* invoke) { |
| 3015 | if (TryGenerateIntrinsicCode(invoke, codegen_)) { |
| 3016 | return; |
| 3017 | } |
| 3018 | |
| 3019 | codegen_->GenerateVirtualCall(invoke, invoke->GetLocations()->GetTemp(0)); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3020 | DCHECK(!codegen_->IsLeafMethod()); |
| 3021 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
| 3022 | } |
| 3023 | |
| 3024 | void LocationsBuilderMIPS64::VisitLoadClass(HLoadClass* cls) { |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 3025 | InvokeRuntimeCallingConvention calling_convention; |
| 3026 | CodeGenerator::CreateLoadClassLocationSummary( |
| 3027 | cls, |
| 3028 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), |
Alexey Frunze | 00580bd | 2015-11-11 13:31:12 -0800 | [diff] [blame] | 3029 | calling_convention.GetReturnLocation(cls->GetType())); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3030 | } |
| 3031 | |
| 3032 | void InstructionCodeGeneratorMIPS64::VisitLoadClass(HLoadClass* cls) { |
| 3033 | LocationSummary* locations = cls->GetLocations(); |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 3034 | if (cls->NeedsAccessCheck()) { |
| 3035 | codegen_->MoveConstant(locations->GetTemp(0), cls->GetTypeIndex()); |
| 3036 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pInitializeTypeAndVerifyAccess), |
| 3037 | cls, |
| 3038 | cls->GetDexPc(), |
| 3039 | nullptr); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 3040 | CheckEntrypointTypes<kQuickInitializeTypeAndVerifyAccess, void*, uint32_t>(); |
Calin Juravle | 580b609 | 2015-10-06 17:35:58 +0100 | [diff] [blame] | 3041 | return; |
| 3042 | } |
| 3043 | |
| 3044 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 3045 | GpuRegister current_method = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3046 | if (cls->IsReferrersClass()) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3047 | DCHECK(!cls->CanCallRuntime()); |
| 3048 | DCHECK(!cls->MustGenerateClinitCheck()); |
| 3049 | __ LoadFromOffset(kLoadUnsignedWord, out, current_method, |
| 3050 | ArtMethod::DeclaringClassOffset().Int32Value()); |
| 3051 | } else { |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 3052 | __ LoadFromOffset(kLoadDoubleword, out, current_method, |
| 3053 | ArtMethod::DexCacheResolvedTypesOffset(kMips64PointerSize).Int32Value()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3054 | __ LoadFromOffset(kLoadUnsignedWord, out, out, CodeGenerator::GetCacheOffset(cls->GetTypeIndex())); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 3055 | // TODO: We will need a read barrier here. |
Nicolas Geoffray | 42e372e | 2015-11-24 15:48:56 +0000 | [diff] [blame] | 3056 | if (!cls->IsInDexCache() || cls->MustGenerateClinitCheck()) { |
| 3057 | DCHECK(cls->CanCallRuntime()); |
| 3058 | SlowPathCodeMIPS64* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathMIPS64( |
| 3059 | cls, |
| 3060 | cls, |
| 3061 | cls->GetDexPc(), |
| 3062 | cls->MustGenerateClinitCheck()); |
| 3063 | codegen_->AddSlowPath(slow_path); |
| 3064 | if (!cls->IsInDexCache()) { |
| 3065 | __ Beqzc(out, slow_path->GetEntryLabel()); |
| 3066 | } |
| 3067 | if (cls->MustGenerateClinitCheck()) { |
| 3068 | GenerateClassInitializationCheck(slow_path, out); |
| 3069 | } else { |
| 3070 | __ Bind(slow_path->GetExitLabel()); |
| 3071 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3072 | } |
| 3073 | } |
| 3074 | } |
| 3075 | |
David Brazdil | cb1c055 | 2015-08-04 16:22:25 +0100 | [diff] [blame] | 3076 | static int32_t GetExceptionTlsOffset() { |
| 3077 | return Thread::ExceptionOffset<kMips64WordSize>().Int32Value(); |
| 3078 | } |
| 3079 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3080 | void LocationsBuilderMIPS64::VisitLoadException(HLoadException* load) { |
| 3081 | LocationSummary* locations = |
| 3082 | new (GetGraph()->GetArena()) LocationSummary(load, LocationSummary::kNoCall); |
| 3083 | locations->SetOut(Location::RequiresRegister()); |
| 3084 | } |
| 3085 | |
| 3086 | void InstructionCodeGeneratorMIPS64::VisitLoadException(HLoadException* load) { |
| 3087 | GpuRegister out = load->GetLocations()->Out().AsRegister<GpuRegister>(); |
David Brazdil | cb1c055 | 2015-08-04 16:22:25 +0100 | [diff] [blame] | 3088 | __ LoadFromOffset(kLoadUnsignedWord, out, TR, GetExceptionTlsOffset()); |
| 3089 | } |
| 3090 | |
| 3091 | void LocationsBuilderMIPS64::VisitClearException(HClearException* clear) { |
| 3092 | new (GetGraph()->GetArena()) LocationSummary(clear, LocationSummary::kNoCall); |
| 3093 | } |
| 3094 | |
| 3095 | void InstructionCodeGeneratorMIPS64::VisitClearException(HClearException* clear ATTRIBUTE_UNUSED) { |
| 3096 | __ StoreToOffset(kStoreWord, ZERO, TR, GetExceptionTlsOffset()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3097 | } |
| 3098 | |
| 3099 | void LocationsBuilderMIPS64::VisitLoadLocal(HLoadLocal* load) { |
| 3100 | load->SetLocations(nullptr); |
| 3101 | } |
| 3102 | |
| 3103 | void InstructionCodeGeneratorMIPS64::VisitLoadLocal(HLoadLocal* load ATTRIBUTE_UNUSED) { |
| 3104 | // Nothing to do, this is driven by the code generator. |
| 3105 | } |
| 3106 | |
| 3107 | void LocationsBuilderMIPS64::VisitLoadString(HLoadString* load) { |
Nicolas Geoffray | 917d016 | 2015-11-24 18:25:35 +0000 | [diff] [blame^] | 3108 | LocationSummary::CallKind call_kind = (!load->IsInDexCache() || kEmitCompilerReadBarrier) |
| 3109 | ? LocationSummary::kCallOnSlowPath |
| 3110 | : LocationSummary::kNoCall; |
| 3111 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(load, call_kind); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3112 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3113 | locations->SetOut(Location::RequiresRegister()); |
| 3114 | } |
| 3115 | |
| 3116 | void InstructionCodeGeneratorMIPS64::VisitLoadString(HLoadString* load) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3117 | LocationSummary* locations = load->GetLocations(); |
| 3118 | GpuRegister out = locations->Out().AsRegister<GpuRegister>(); |
| 3119 | GpuRegister current_method = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3120 | __ LoadFromOffset(kLoadUnsignedWord, out, current_method, |
| 3121 | ArtMethod::DeclaringClassOffset().Int32Value()); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 3122 | __ LoadFromOffset(kLoadDoubleword, out, out, mirror::Class::DexCacheStringsOffset().Int32Value()); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3123 | __ LoadFromOffset(kLoadUnsignedWord, out, out, CodeGenerator::GetCacheOffset(load->GetStringIndex())); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 3124 | // TODO: We will need a read barrier here. |
Nicolas Geoffray | 917d016 | 2015-11-24 18:25:35 +0000 | [diff] [blame^] | 3125 | |
| 3126 | if (!load->IsInDexCache()) { |
| 3127 | SlowPathCodeMIPS64* slow_path = new (GetGraph()->GetArena()) LoadStringSlowPathMIPS64(load); |
| 3128 | codegen_->AddSlowPath(slow_path); |
| 3129 | __ Beqzc(out, slow_path->GetEntryLabel()); |
| 3130 | __ Bind(slow_path->GetExitLabel()); |
| 3131 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3132 | } |
| 3133 | |
| 3134 | void LocationsBuilderMIPS64::VisitLocal(HLocal* local) { |
| 3135 | local->SetLocations(nullptr); |
| 3136 | } |
| 3137 | |
| 3138 | void InstructionCodeGeneratorMIPS64::VisitLocal(HLocal* local) { |
| 3139 | DCHECK_EQ(local->GetBlock(), GetGraph()->GetEntryBlock()); |
| 3140 | } |
| 3141 | |
| 3142 | void LocationsBuilderMIPS64::VisitLongConstant(HLongConstant* constant) { |
| 3143 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(constant); |
| 3144 | locations->SetOut(Location::ConstantLocation(constant)); |
| 3145 | } |
| 3146 | |
| 3147 | void InstructionCodeGeneratorMIPS64::VisitLongConstant(HLongConstant* constant ATTRIBUTE_UNUSED) { |
| 3148 | // Will be generated at use site. |
| 3149 | } |
| 3150 | |
| 3151 | void LocationsBuilderMIPS64::VisitMonitorOperation(HMonitorOperation* instruction) { |
| 3152 | LocationSummary* locations = |
| 3153 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 3154 | InvokeRuntimeCallingConvention calling_convention; |
| 3155 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 3156 | } |
| 3157 | |
| 3158 | void InstructionCodeGeneratorMIPS64::VisitMonitorOperation(HMonitorOperation* instruction) { |
| 3159 | codegen_->InvokeRuntime(instruction->IsEnter() |
| 3160 | ? QUICK_ENTRY_POINT(pLockObject) |
| 3161 | : QUICK_ENTRY_POINT(pUnlockObject), |
| 3162 | instruction, |
| 3163 | instruction->GetDexPc(), |
| 3164 | nullptr); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 3165 | if (instruction->IsEnter()) { |
| 3166 | CheckEntrypointTypes<kQuickLockObject, void, mirror::Object*>(); |
| 3167 | } else { |
| 3168 | CheckEntrypointTypes<kQuickUnlockObject, void, mirror::Object*>(); |
| 3169 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3170 | } |
| 3171 | |
| 3172 | void LocationsBuilderMIPS64::VisitMul(HMul* mul) { |
| 3173 | LocationSummary* locations = |
| 3174 | new (GetGraph()->GetArena()) LocationSummary(mul, LocationSummary::kNoCall); |
| 3175 | switch (mul->GetResultType()) { |
| 3176 | case Primitive::kPrimInt: |
| 3177 | case Primitive::kPrimLong: |
| 3178 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3179 | locations->SetInAt(1, Location::RequiresRegister()); |
| 3180 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3181 | break; |
| 3182 | |
| 3183 | case Primitive::kPrimFloat: |
| 3184 | case Primitive::kPrimDouble: |
| 3185 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 3186 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 3187 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 3188 | break; |
| 3189 | |
| 3190 | default: |
| 3191 | LOG(FATAL) << "Unexpected mul type " << mul->GetResultType(); |
| 3192 | } |
| 3193 | } |
| 3194 | |
| 3195 | void InstructionCodeGeneratorMIPS64::VisitMul(HMul* instruction) { |
| 3196 | Primitive::Type type = instruction->GetType(); |
| 3197 | LocationSummary* locations = instruction->GetLocations(); |
| 3198 | |
| 3199 | switch (type) { |
| 3200 | case Primitive::kPrimInt: |
| 3201 | case Primitive::kPrimLong: { |
| 3202 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 3203 | GpuRegister lhs = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3204 | GpuRegister rhs = locations->InAt(1).AsRegister<GpuRegister>(); |
| 3205 | if (type == Primitive::kPrimInt) |
| 3206 | __ MulR6(dst, lhs, rhs); |
| 3207 | else |
| 3208 | __ Dmul(dst, lhs, rhs); |
| 3209 | break; |
| 3210 | } |
| 3211 | case Primitive::kPrimFloat: |
| 3212 | case Primitive::kPrimDouble: { |
| 3213 | FpuRegister dst = locations->Out().AsFpuRegister<FpuRegister>(); |
| 3214 | FpuRegister lhs = locations->InAt(0).AsFpuRegister<FpuRegister>(); |
| 3215 | FpuRegister rhs = locations->InAt(1).AsFpuRegister<FpuRegister>(); |
| 3216 | if (type == Primitive::kPrimFloat) |
| 3217 | __ MulS(dst, lhs, rhs); |
| 3218 | else |
| 3219 | __ MulD(dst, lhs, rhs); |
| 3220 | break; |
| 3221 | } |
| 3222 | default: |
| 3223 | LOG(FATAL) << "Unexpected mul type " << type; |
| 3224 | } |
| 3225 | } |
| 3226 | |
| 3227 | void LocationsBuilderMIPS64::VisitNeg(HNeg* neg) { |
| 3228 | LocationSummary* locations = |
| 3229 | new (GetGraph()->GetArena()) LocationSummary(neg, LocationSummary::kNoCall); |
| 3230 | switch (neg->GetResultType()) { |
| 3231 | case Primitive::kPrimInt: |
| 3232 | case Primitive::kPrimLong: |
| 3233 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3234 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3235 | break; |
| 3236 | |
| 3237 | case Primitive::kPrimFloat: |
| 3238 | case Primitive::kPrimDouble: |
| 3239 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 3240 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 3241 | break; |
| 3242 | |
| 3243 | default: |
| 3244 | LOG(FATAL) << "Unexpected neg type " << neg->GetResultType(); |
| 3245 | } |
| 3246 | } |
| 3247 | |
| 3248 | void InstructionCodeGeneratorMIPS64::VisitNeg(HNeg* instruction) { |
| 3249 | Primitive::Type type = instruction->GetType(); |
| 3250 | LocationSummary* locations = instruction->GetLocations(); |
| 3251 | |
| 3252 | switch (type) { |
| 3253 | case Primitive::kPrimInt: |
| 3254 | case Primitive::kPrimLong: { |
| 3255 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 3256 | GpuRegister src = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3257 | if (type == Primitive::kPrimInt) |
| 3258 | __ Subu(dst, ZERO, src); |
| 3259 | else |
| 3260 | __ Dsubu(dst, ZERO, src); |
| 3261 | break; |
| 3262 | } |
| 3263 | case Primitive::kPrimFloat: |
| 3264 | case Primitive::kPrimDouble: { |
| 3265 | FpuRegister dst = locations->Out().AsFpuRegister<FpuRegister>(); |
| 3266 | FpuRegister src = locations->InAt(0).AsFpuRegister<FpuRegister>(); |
| 3267 | if (type == Primitive::kPrimFloat) |
| 3268 | __ NegS(dst, src); |
| 3269 | else |
| 3270 | __ NegD(dst, src); |
| 3271 | break; |
| 3272 | } |
| 3273 | default: |
| 3274 | LOG(FATAL) << "Unexpected neg type " << type; |
| 3275 | } |
| 3276 | } |
| 3277 | |
| 3278 | void LocationsBuilderMIPS64::VisitNewArray(HNewArray* instruction) { |
| 3279 | LocationSummary* locations = |
| 3280 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 3281 | InvokeRuntimeCallingConvention calling_convention; |
| 3282 | locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 3283 | locations->SetOut(calling_convention.GetReturnLocation(Primitive::kPrimNot)); |
| 3284 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 3285 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(2))); |
| 3286 | } |
| 3287 | |
| 3288 | void InstructionCodeGeneratorMIPS64::VisitNewArray(HNewArray* instruction) { |
| 3289 | LocationSummary* locations = instruction->GetLocations(); |
| 3290 | // Move an uint16_t value to a register. |
| 3291 | __ LoadConst32(locations->GetTemp(0).AsRegister<GpuRegister>(), instruction->GetTypeIndex()); |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 3292 | codegen_->InvokeRuntime(instruction->GetEntrypoint(), |
| 3293 | instruction, |
| 3294 | instruction->GetDexPc(), |
| 3295 | nullptr); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3296 | CheckEntrypointTypes<kQuickAllocArrayWithAccessCheck, void*, uint32_t, int32_t, ArtMethod*>(); |
| 3297 | } |
| 3298 | |
| 3299 | void LocationsBuilderMIPS64::VisitNewInstance(HNewInstance* instruction) { |
| 3300 | LocationSummary* locations = |
| 3301 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 3302 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 729645a | 2015-11-19 13:29:02 +0000 | [diff] [blame] | 3303 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 3304 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3305 | locations->SetOut(calling_convention.GetReturnLocation(Primitive::kPrimNot)); |
| 3306 | } |
| 3307 | |
| 3308 | void InstructionCodeGeneratorMIPS64::VisitNewInstance(HNewInstance* instruction) { |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 3309 | codegen_->InvokeRuntime(instruction->GetEntrypoint(), |
| 3310 | instruction, |
| 3311 | instruction->GetDexPc(), |
| 3312 | nullptr); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3313 | CheckEntrypointTypes<kQuickAllocObjectWithAccessCheck, void*, uint32_t, ArtMethod*>(); |
| 3314 | } |
| 3315 | |
| 3316 | void LocationsBuilderMIPS64::VisitNot(HNot* instruction) { |
| 3317 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 3318 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3319 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3320 | } |
| 3321 | |
| 3322 | void InstructionCodeGeneratorMIPS64::VisitNot(HNot* instruction) { |
| 3323 | Primitive::Type type = instruction->GetType(); |
| 3324 | LocationSummary* locations = instruction->GetLocations(); |
| 3325 | |
| 3326 | switch (type) { |
| 3327 | case Primitive::kPrimInt: |
| 3328 | case Primitive::kPrimLong: { |
| 3329 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 3330 | GpuRegister src = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3331 | __ Nor(dst, src, ZERO); |
| 3332 | break; |
| 3333 | } |
| 3334 | |
| 3335 | default: |
| 3336 | LOG(FATAL) << "Unexpected type for not operation " << instruction->GetResultType(); |
| 3337 | } |
| 3338 | } |
| 3339 | |
| 3340 | void LocationsBuilderMIPS64::VisitBooleanNot(HBooleanNot* instruction) { |
| 3341 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 3342 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3343 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3344 | } |
| 3345 | |
| 3346 | void InstructionCodeGeneratorMIPS64::VisitBooleanNot(HBooleanNot* instruction) { |
| 3347 | LocationSummary* locations = instruction->GetLocations(); |
| 3348 | __ Xori(locations->Out().AsRegister<GpuRegister>(), |
| 3349 | locations->InAt(0).AsRegister<GpuRegister>(), |
| 3350 | 1); |
| 3351 | } |
| 3352 | |
| 3353 | void LocationsBuilderMIPS64::VisitNullCheck(HNullCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 3354 | LocationSummary::CallKind call_kind = instruction->CanThrowIntoCatchBlock() |
| 3355 | ? LocationSummary::kCallOnSlowPath |
| 3356 | : LocationSummary::kNoCall; |
| 3357 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction, call_kind); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3358 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3359 | if (instruction->HasUses()) { |
| 3360 | locations->SetOut(Location::SameAsFirstInput()); |
| 3361 | } |
| 3362 | } |
| 3363 | |
| 3364 | void InstructionCodeGeneratorMIPS64::GenerateImplicitNullCheck(HNullCheck* instruction) { |
| 3365 | if (codegen_->CanMoveNullCheckToUser(instruction)) { |
| 3366 | return; |
| 3367 | } |
| 3368 | Location obj = instruction->GetLocations()->InAt(0); |
| 3369 | |
| 3370 | __ Lw(ZERO, obj.AsRegister<GpuRegister>(), 0); |
| 3371 | codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); |
| 3372 | } |
| 3373 | |
| 3374 | void InstructionCodeGeneratorMIPS64::GenerateExplicitNullCheck(HNullCheck* instruction) { |
| 3375 | SlowPathCodeMIPS64* slow_path = new (GetGraph()->GetArena()) NullCheckSlowPathMIPS64(instruction); |
| 3376 | codegen_->AddSlowPath(slow_path); |
| 3377 | |
| 3378 | Location obj = instruction->GetLocations()->InAt(0); |
| 3379 | |
| 3380 | __ Beqzc(obj.AsRegister<GpuRegister>(), slow_path->GetEntryLabel()); |
| 3381 | } |
| 3382 | |
| 3383 | void InstructionCodeGeneratorMIPS64::VisitNullCheck(HNullCheck* instruction) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 3384 | if (codegen_->IsImplicitNullCheckAllowed(instruction)) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3385 | GenerateImplicitNullCheck(instruction); |
| 3386 | } else { |
| 3387 | GenerateExplicitNullCheck(instruction); |
| 3388 | } |
| 3389 | } |
| 3390 | |
| 3391 | void LocationsBuilderMIPS64::VisitOr(HOr* instruction) { |
| 3392 | HandleBinaryOp(instruction); |
| 3393 | } |
| 3394 | |
| 3395 | void InstructionCodeGeneratorMIPS64::VisitOr(HOr* instruction) { |
| 3396 | HandleBinaryOp(instruction); |
| 3397 | } |
| 3398 | |
| 3399 | void LocationsBuilderMIPS64::VisitParallelMove(HParallelMove* instruction ATTRIBUTE_UNUSED) { |
| 3400 | LOG(FATAL) << "Unreachable"; |
| 3401 | } |
| 3402 | |
| 3403 | void InstructionCodeGeneratorMIPS64::VisitParallelMove(HParallelMove* instruction) { |
| 3404 | codegen_->GetMoveResolver()->EmitNativeCode(instruction); |
| 3405 | } |
| 3406 | |
| 3407 | void LocationsBuilderMIPS64::VisitParameterValue(HParameterValue* instruction) { |
| 3408 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 3409 | Location location = parameter_visitor_.GetNextLocation(instruction->GetType()); |
| 3410 | if (location.IsStackSlot()) { |
| 3411 | location = Location::StackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
| 3412 | } else if (location.IsDoubleStackSlot()) { |
| 3413 | location = Location::DoubleStackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
| 3414 | } |
| 3415 | locations->SetOut(location); |
| 3416 | } |
| 3417 | |
| 3418 | void InstructionCodeGeneratorMIPS64::VisitParameterValue(HParameterValue* instruction |
| 3419 | ATTRIBUTE_UNUSED) { |
| 3420 | // Nothing to do, the parameter is already at its location. |
| 3421 | } |
| 3422 | |
| 3423 | void LocationsBuilderMIPS64::VisitCurrentMethod(HCurrentMethod* instruction) { |
| 3424 | LocationSummary* locations = |
| 3425 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 3426 | locations->SetOut(Location::RegisterLocation(kMethodRegisterArgument)); |
| 3427 | } |
| 3428 | |
| 3429 | void InstructionCodeGeneratorMIPS64::VisitCurrentMethod(HCurrentMethod* instruction |
| 3430 | ATTRIBUTE_UNUSED) { |
| 3431 | // Nothing to do, the method is already at its location. |
| 3432 | } |
| 3433 | |
| 3434 | void LocationsBuilderMIPS64::VisitPhi(HPhi* instruction) { |
| 3435 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 3436 | for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { |
| 3437 | locations->SetInAt(i, Location::Any()); |
| 3438 | } |
| 3439 | locations->SetOut(Location::Any()); |
| 3440 | } |
| 3441 | |
| 3442 | void InstructionCodeGeneratorMIPS64::VisitPhi(HPhi* instruction ATTRIBUTE_UNUSED) { |
| 3443 | LOG(FATAL) << "Unreachable"; |
| 3444 | } |
| 3445 | |
| 3446 | void LocationsBuilderMIPS64::VisitRem(HRem* rem) { |
| 3447 | Primitive::Type type = rem->GetResultType(); |
| 3448 | LocationSummary::CallKind call_kind = |
| 3449 | Primitive::IsFloatingPointType(type) ? LocationSummary::kCall : LocationSummary::kNoCall; |
| 3450 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(rem, call_kind); |
| 3451 | |
| 3452 | switch (type) { |
| 3453 | case Primitive::kPrimInt: |
| 3454 | case Primitive::kPrimLong: |
| 3455 | locations->SetInAt(0, Location::RequiresRegister()); |
Alexey Frunze | c857c74 | 2015-09-23 15:12:39 -0700 | [diff] [blame] | 3456 | locations->SetInAt(1, Location::RegisterOrConstant(rem->InputAt(1))); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3457 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3458 | break; |
| 3459 | |
| 3460 | case Primitive::kPrimFloat: |
| 3461 | case Primitive::kPrimDouble: { |
| 3462 | InvokeRuntimeCallingConvention calling_convention; |
| 3463 | locations->SetInAt(0, Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(0))); |
| 3464 | locations->SetInAt(1, Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(1))); |
| 3465 | locations->SetOut(calling_convention.GetReturnLocation(type)); |
| 3466 | break; |
| 3467 | } |
| 3468 | |
| 3469 | default: |
| 3470 | LOG(FATAL) << "Unexpected rem type " << type; |
| 3471 | } |
| 3472 | } |
| 3473 | |
| 3474 | void InstructionCodeGeneratorMIPS64::VisitRem(HRem* instruction) { |
| 3475 | Primitive::Type type = instruction->GetType(); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3476 | |
| 3477 | switch (type) { |
| 3478 | case Primitive::kPrimInt: |
Alexey Frunze | c857c74 | 2015-09-23 15:12:39 -0700 | [diff] [blame] | 3479 | case Primitive::kPrimLong: |
| 3480 | GenerateDivRemIntegral(instruction); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3481 | break; |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3482 | |
| 3483 | case Primitive::kPrimFloat: |
| 3484 | case Primitive::kPrimDouble: { |
| 3485 | int32_t entry_offset = (type == Primitive::kPrimFloat) ? QUICK_ENTRY_POINT(pFmodf) |
| 3486 | : QUICK_ENTRY_POINT(pFmod); |
| 3487 | codegen_->InvokeRuntime(entry_offset, instruction, instruction->GetDexPc(), nullptr); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 3488 | if (type == Primitive::kPrimFloat) { |
| 3489 | CheckEntrypointTypes<kQuickFmodf, float, float, float>(); |
| 3490 | } else { |
| 3491 | CheckEntrypointTypes<kQuickFmod, double, double, double>(); |
| 3492 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3493 | break; |
| 3494 | } |
| 3495 | default: |
| 3496 | LOG(FATAL) << "Unexpected rem type " << type; |
| 3497 | } |
| 3498 | } |
| 3499 | |
| 3500 | void LocationsBuilderMIPS64::VisitMemoryBarrier(HMemoryBarrier* memory_barrier) { |
| 3501 | memory_barrier->SetLocations(nullptr); |
| 3502 | } |
| 3503 | |
| 3504 | void InstructionCodeGeneratorMIPS64::VisitMemoryBarrier(HMemoryBarrier* memory_barrier) { |
| 3505 | GenerateMemoryBarrier(memory_barrier->GetBarrierKind()); |
| 3506 | } |
| 3507 | |
| 3508 | void LocationsBuilderMIPS64::VisitReturn(HReturn* ret) { |
| 3509 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(ret); |
| 3510 | Primitive::Type return_type = ret->InputAt(0)->GetType(); |
| 3511 | locations->SetInAt(0, Mips64ReturnLocation(return_type)); |
| 3512 | } |
| 3513 | |
| 3514 | void InstructionCodeGeneratorMIPS64::VisitReturn(HReturn* ret ATTRIBUTE_UNUSED) { |
| 3515 | codegen_->GenerateFrameExit(); |
| 3516 | } |
| 3517 | |
| 3518 | void LocationsBuilderMIPS64::VisitReturnVoid(HReturnVoid* ret) { |
| 3519 | ret->SetLocations(nullptr); |
| 3520 | } |
| 3521 | |
| 3522 | void InstructionCodeGeneratorMIPS64::VisitReturnVoid(HReturnVoid* ret ATTRIBUTE_UNUSED) { |
| 3523 | codegen_->GenerateFrameExit(); |
| 3524 | } |
| 3525 | |
| 3526 | void LocationsBuilderMIPS64::VisitShl(HShl* shl) { |
| 3527 | HandleShift(shl); |
| 3528 | } |
| 3529 | |
| 3530 | void InstructionCodeGeneratorMIPS64::VisitShl(HShl* shl) { |
| 3531 | HandleShift(shl); |
| 3532 | } |
| 3533 | |
| 3534 | void LocationsBuilderMIPS64::VisitShr(HShr* shr) { |
| 3535 | HandleShift(shr); |
| 3536 | } |
| 3537 | |
| 3538 | void InstructionCodeGeneratorMIPS64::VisitShr(HShr* shr) { |
| 3539 | HandleShift(shr); |
| 3540 | } |
| 3541 | |
| 3542 | void LocationsBuilderMIPS64::VisitStoreLocal(HStoreLocal* store) { |
| 3543 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(store); |
| 3544 | Primitive::Type field_type = store->InputAt(1)->GetType(); |
| 3545 | switch (field_type) { |
| 3546 | case Primitive::kPrimNot: |
| 3547 | case Primitive::kPrimBoolean: |
| 3548 | case Primitive::kPrimByte: |
| 3549 | case Primitive::kPrimChar: |
| 3550 | case Primitive::kPrimShort: |
| 3551 | case Primitive::kPrimInt: |
| 3552 | case Primitive::kPrimFloat: |
| 3553 | locations->SetInAt(1, Location::StackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 3554 | break; |
| 3555 | |
| 3556 | case Primitive::kPrimLong: |
| 3557 | case Primitive::kPrimDouble: |
| 3558 | locations->SetInAt(1, Location::DoubleStackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 3559 | break; |
| 3560 | |
| 3561 | default: |
| 3562 | LOG(FATAL) << "Unimplemented local type " << field_type; |
| 3563 | } |
| 3564 | } |
| 3565 | |
| 3566 | void InstructionCodeGeneratorMIPS64::VisitStoreLocal(HStoreLocal* store ATTRIBUTE_UNUSED) { |
| 3567 | } |
| 3568 | |
| 3569 | void LocationsBuilderMIPS64::VisitSub(HSub* instruction) { |
| 3570 | HandleBinaryOp(instruction); |
| 3571 | } |
| 3572 | |
| 3573 | void InstructionCodeGeneratorMIPS64::VisitSub(HSub* instruction) { |
| 3574 | HandleBinaryOp(instruction); |
| 3575 | } |
| 3576 | |
| 3577 | void LocationsBuilderMIPS64::VisitStaticFieldGet(HStaticFieldGet* instruction) { |
| 3578 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 3579 | } |
| 3580 | |
| 3581 | void InstructionCodeGeneratorMIPS64::VisitStaticFieldGet(HStaticFieldGet* instruction) { |
| 3582 | HandleFieldGet(instruction, instruction->GetFieldInfo()); |
| 3583 | } |
| 3584 | |
| 3585 | void LocationsBuilderMIPS64::VisitStaticFieldSet(HStaticFieldSet* instruction) { |
| 3586 | HandleFieldSet(instruction, instruction->GetFieldInfo()); |
| 3587 | } |
| 3588 | |
| 3589 | void InstructionCodeGeneratorMIPS64::VisitStaticFieldSet(HStaticFieldSet* instruction) { |
| 3590 | HandleFieldSet(instruction, instruction->GetFieldInfo()); |
| 3591 | } |
| 3592 | |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 3593 | void LocationsBuilderMIPS64::VisitUnresolvedInstanceFieldGet( |
| 3594 | HUnresolvedInstanceFieldGet* instruction) { |
| 3595 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3596 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3597 | instruction, instruction->GetFieldType(), calling_convention); |
| 3598 | } |
| 3599 | |
| 3600 | void InstructionCodeGeneratorMIPS64::VisitUnresolvedInstanceFieldGet( |
| 3601 | HUnresolvedInstanceFieldGet* instruction) { |
| 3602 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3603 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3604 | instruction->GetFieldType(), |
| 3605 | instruction->GetFieldIndex(), |
| 3606 | instruction->GetDexPc(), |
| 3607 | calling_convention); |
| 3608 | } |
| 3609 | |
| 3610 | void LocationsBuilderMIPS64::VisitUnresolvedInstanceFieldSet( |
| 3611 | HUnresolvedInstanceFieldSet* instruction) { |
| 3612 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3613 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3614 | instruction, instruction->GetFieldType(), calling_convention); |
| 3615 | } |
| 3616 | |
| 3617 | void InstructionCodeGeneratorMIPS64::VisitUnresolvedInstanceFieldSet( |
| 3618 | HUnresolvedInstanceFieldSet* instruction) { |
| 3619 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3620 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3621 | instruction->GetFieldType(), |
| 3622 | instruction->GetFieldIndex(), |
| 3623 | instruction->GetDexPc(), |
| 3624 | calling_convention); |
| 3625 | } |
| 3626 | |
| 3627 | void LocationsBuilderMIPS64::VisitUnresolvedStaticFieldGet( |
| 3628 | HUnresolvedStaticFieldGet* instruction) { |
| 3629 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3630 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3631 | instruction, instruction->GetFieldType(), calling_convention); |
| 3632 | } |
| 3633 | |
| 3634 | void InstructionCodeGeneratorMIPS64::VisitUnresolvedStaticFieldGet( |
| 3635 | HUnresolvedStaticFieldGet* instruction) { |
| 3636 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3637 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3638 | instruction->GetFieldType(), |
| 3639 | instruction->GetFieldIndex(), |
| 3640 | instruction->GetDexPc(), |
| 3641 | calling_convention); |
| 3642 | } |
| 3643 | |
| 3644 | void LocationsBuilderMIPS64::VisitUnresolvedStaticFieldSet( |
| 3645 | HUnresolvedStaticFieldSet* instruction) { |
| 3646 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3647 | codegen_->CreateUnresolvedFieldLocationSummary( |
| 3648 | instruction, instruction->GetFieldType(), calling_convention); |
| 3649 | } |
| 3650 | |
| 3651 | void InstructionCodeGeneratorMIPS64::VisitUnresolvedStaticFieldSet( |
| 3652 | HUnresolvedStaticFieldSet* instruction) { |
| 3653 | FieldAccessCallingConventionMIPS64 calling_convention; |
| 3654 | codegen_->GenerateUnresolvedFieldAccess(instruction, |
| 3655 | instruction->GetFieldType(), |
| 3656 | instruction->GetFieldIndex(), |
| 3657 | instruction->GetDexPc(), |
| 3658 | calling_convention); |
| 3659 | } |
| 3660 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3661 | void LocationsBuilderMIPS64::VisitSuspendCheck(HSuspendCheck* instruction) { |
| 3662 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCallOnSlowPath); |
| 3663 | } |
| 3664 | |
| 3665 | void InstructionCodeGeneratorMIPS64::VisitSuspendCheck(HSuspendCheck* instruction) { |
| 3666 | HBasicBlock* block = instruction->GetBlock(); |
| 3667 | if (block->GetLoopInformation() != nullptr) { |
| 3668 | DCHECK(block->GetLoopInformation()->GetSuspendCheck() == instruction); |
| 3669 | // The back edge will generate the suspend check. |
| 3670 | return; |
| 3671 | } |
| 3672 | if (block->IsEntryBlock() && instruction->GetNext()->IsGoto()) { |
| 3673 | // The goto will generate the suspend check. |
| 3674 | return; |
| 3675 | } |
| 3676 | GenerateSuspendCheck(instruction, nullptr); |
| 3677 | } |
| 3678 | |
| 3679 | void LocationsBuilderMIPS64::VisitTemporary(HTemporary* temp) { |
| 3680 | temp->SetLocations(nullptr); |
| 3681 | } |
| 3682 | |
| 3683 | void InstructionCodeGeneratorMIPS64::VisitTemporary(HTemporary* temp ATTRIBUTE_UNUSED) { |
| 3684 | // Nothing to do, this is driven by the code generator. |
| 3685 | } |
| 3686 | |
| 3687 | void LocationsBuilderMIPS64::VisitThrow(HThrow* instruction) { |
| 3688 | LocationSummary* locations = |
| 3689 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 3690 | InvokeRuntimeCallingConvention calling_convention; |
| 3691 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 3692 | } |
| 3693 | |
| 3694 | void InstructionCodeGeneratorMIPS64::VisitThrow(HThrow* instruction) { |
| 3695 | codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pDeliverException), |
| 3696 | instruction, |
| 3697 | instruction->GetDexPc(), |
| 3698 | nullptr); |
| 3699 | CheckEntrypointTypes<kQuickDeliverException, void, mirror::Object*>(); |
| 3700 | } |
| 3701 | |
| 3702 | void LocationsBuilderMIPS64::VisitTypeConversion(HTypeConversion* conversion) { |
| 3703 | Primitive::Type input_type = conversion->GetInputType(); |
| 3704 | Primitive::Type result_type = conversion->GetResultType(); |
| 3705 | DCHECK_NE(input_type, result_type); |
| 3706 | |
| 3707 | if ((input_type == Primitive::kPrimNot) || (input_type == Primitive::kPrimVoid) || |
| 3708 | (result_type == Primitive::kPrimNot) || (result_type == Primitive::kPrimVoid)) { |
| 3709 | LOG(FATAL) << "Unexpected type conversion from " << input_type << " to " << result_type; |
| 3710 | } |
| 3711 | |
| 3712 | LocationSummary::CallKind call_kind = LocationSummary::kNoCall; |
| 3713 | if ((Primitive::IsFloatingPointType(result_type) && input_type == Primitive::kPrimLong) || |
| 3714 | (Primitive::IsIntegralType(result_type) && Primitive::IsFloatingPointType(input_type))) { |
| 3715 | call_kind = LocationSummary::kCall; |
| 3716 | } |
| 3717 | |
| 3718 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(conversion, call_kind); |
| 3719 | |
| 3720 | if (call_kind == LocationSummary::kNoCall) { |
| 3721 | if (Primitive::IsFloatingPointType(input_type)) { |
| 3722 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 3723 | } else { |
| 3724 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3725 | } |
| 3726 | |
| 3727 | if (Primitive::IsFloatingPointType(result_type)) { |
| 3728 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 3729 | } else { |
| 3730 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 3731 | } |
| 3732 | } else { |
| 3733 | InvokeRuntimeCallingConvention calling_convention; |
| 3734 | |
| 3735 | if (Primitive::IsFloatingPointType(input_type)) { |
| 3736 | locations->SetInAt(0, Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(0))); |
| 3737 | } else { |
| 3738 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 3739 | } |
| 3740 | |
| 3741 | locations->SetOut(calling_convention.GetReturnLocation(result_type)); |
| 3742 | } |
| 3743 | } |
| 3744 | |
| 3745 | void InstructionCodeGeneratorMIPS64::VisitTypeConversion(HTypeConversion* conversion) { |
| 3746 | LocationSummary* locations = conversion->GetLocations(); |
| 3747 | Primitive::Type result_type = conversion->GetResultType(); |
| 3748 | Primitive::Type input_type = conversion->GetInputType(); |
| 3749 | |
| 3750 | DCHECK_NE(input_type, result_type); |
| 3751 | |
| 3752 | if (Primitive::IsIntegralType(result_type) && Primitive::IsIntegralType(input_type)) { |
| 3753 | GpuRegister dst = locations->Out().AsRegister<GpuRegister>(); |
| 3754 | GpuRegister src = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3755 | |
| 3756 | switch (result_type) { |
| 3757 | case Primitive::kPrimChar: |
| 3758 | __ Andi(dst, src, 0xFFFF); |
| 3759 | break; |
| 3760 | case Primitive::kPrimByte: |
| 3761 | // long is never converted into types narrower than int directly, |
| 3762 | // so SEB and SEH can be used without ever causing unpredictable results |
| 3763 | // on 64-bit inputs |
| 3764 | DCHECK(input_type != Primitive::kPrimLong); |
| 3765 | __ Seb(dst, src); |
| 3766 | break; |
| 3767 | case Primitive::kPrimShort: |
| 3768 | // long is never converted into types narrower than int directly, |
| 3769 | // so SEB and SEH can be used without ever causing unpredictable results |
| 3770 | // on 64-bit inputs |
| 3771 | DCHECK(input_type != Primitive::kPrimLong); |
| 3772 | __ Seh(dst, src); |
| 3773 | break; |
| 3774 | case Primitive::kPrimInt: |
| 3775 | case Primitive::kPrimLong: |
| 3776 | // Sign-extend 32-bit int into bits 32 through 63 for |
| 3777 | // int-to-long and long-to-int conversions |
| 3778 | __ Sll(dst, src, 0); |
| 3779 | break; |
| 3780 | |
| 3781 | default: |
| 3782 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 3783 | << " to " << result_type; |
| 3784 | } |
| 3785 | } else if (Primitive::IsFloatingPointType(result_type) && Primitive::IsIntegralType(input_type)) { |
| 3786 | if (input_type != Primitive::kPrimLong) { |
| 3787 | FpuRegister dst = locations->Out().AsFpuRegister<FpuRegister>(); |
| 3788 | GpuRegister src = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3789 | __ Mtc1(src, FTMP); |
| 3790 | if (result_type == Primitive::kPrimFloat) { |
| 3791 | __ Cvtsw(dst, FTMP); |
| 3792 | } else { |
| 3793 | __ Cvtdw(dst, FTMP); |
| 3794 | } |
| 3795 | } else { |
| 3796 | int32_t entry_offset = (result_type == Primitive::kPrimFloat) ? QUICK_ENTRY_POINT(pL2f) |
| 3797 | : QUICK_ENTRY_POINT(pL2d); |
| 3798 | codegen_->InvokeRuntime(entry_offset, |
| 3799 | conversion, |
| 3800 | conversion->GetDexPc(), |
| 3801 | nullptr); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 3802 | if (result_type == Primitive::kPrimFloat) { |
| 3803 | CheckEntrypointTypes<kQuickL2f, float, int64_t>(); |
| 3804 | } else { |
| 3805 | CheckEntrypointTypes<kQuickL2d, double, int64_t>(); |
| 3806 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3807 | } |
| 3808 | } else if (Primitive::IsIntegralType(result_type) && Primitive::IsFloatingPointType(input_type)) { |
| 3809 | CHECK(result_type == Primitive::kPrimInt || result_type == Primitive::kPrimLong); |
| 3810 | int32_t entry_offset; |
| 3811 | if (result_type != Primitive::kPrimLong) { |
| 3812 | entry_offset = (input_type == Primitive::kPrimFloat) ? QUICK_ENTRY_POINT(pF2iz) |
| 3813 | : QUICK_ENTRY_POINT(pD2iz); |
| 3814 | } else { |
| 3815 | entry_offset = (input_type == Primitive::kPrimFloat) ? QUICK_ENTRY_POINT(pF2l) |
| 3816 | : QUICK_ENTRY_POINT(pD2l); |
| 3817 | } |
| 3818 | codegen_->InvokeRuntime(entry_offset, |
| 3819 | conversion, |
| 3820 | conversion->GetDexPc(), |
| 3821 | nullptr); |
Roland Levillain | 888d067 | 2015-11-23 18:53:50 +0000 | [diff] [blame] | 3822 | if (result_type != Primitive::kPrimLong) { |
| 3823 | if (input_type == Primitive::kPrimFloat) { |
| 3824 | CheckEntrypointTypes<kQuickF2iz, int32_t, float>(); |
| 3825 | } else { |
| 3826 | CheckEntrypointTypes<kQuickD2iz, int32_t, double>(); |
| 3827 | } |
| 3828 | } else { |
| 3829 | if (input_type == Primitive::kPrimFloat) { |
| 3830 | CheckEntrypointTypes<kQuickF2l, int64_t, float>(); |
| 3831 | } else { |
| 3832 | CheckEntrypointTypes<kQuickD2l, int64_t, double>(); |
| 3833 | } |
| 3834 | } |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 3835 | } else if (Primitive::IsFloatingPointType(result_type) && |
| 3836 | Primitive::IsFloatingPointType(input_type)) { |
| 3837 | FpuRegister dst = locations->Out().AsFpuRegister<FpuRegister>(); |
| 3838 | FpuRegister src = locations->InAt(0).AsFpuRegister<FpuRegister>(); |
| 3839 | if (result_type == Primitive::kPrimFloat) { |
| 3840 | __ Cvtsd(dst, src); |
| 3841 | } else { |
| 3842 | __ Cvtds(dst, src); |
| 3843 | } |
| 3844 | } else { |
| 3845 | LOG(FATAL) << "Unexpected or unimplemented type conversion from " << input_type |
| 3846 | << " to " << result_type; |
| 3847 | } |
| 3848 | } |
| 3849 | |
| 3850 | void LocationsBuilderMIPS64::VisitUShr(HUShr* ushr) { |
| 3851 | HandleShift(ushr); |
| 3852 | } |
| 3853 | |
| 3854 | void InstructionCodeGeneratorMIPS64::VisitUShr(HUShr* ushr) { |
| 3855 | HandleShift(ushr); |
| 3856 | } |
| 3857 | |
| 3858 | void LocationsBuilderMIPS64::VisitXor(HXor* instruction) { |
| 3859 | HandleBinaryOp(instruction); |
| 3860 | } |
| 3861 | |
| 3862 | void InstructionCodeGeneratorMIPS64::VisitXor(HXor* instruction) { |
| 3863 | HandleBinaryOp(instruction); |
| 3864 | } |
| 3865 | |
| 3866 | void LocationsBuilderMIPS64::VisitBoundType(HBoundType* instruction ATTRIBUTE_UNUSED) { |
| 3867 | // Nothing to do, this should be removed during prepare for register allocator. |
| 3868 | LOG(FATAL) << "Unreachable"; |
| 3869 | } |
| 3870 | |
| 3871 | void InstructionCodeGeneratorMIPS64::VisitBoundType(HBoundType* instruction ATTRIBUTE_UNUSED) { |
| 3872 | // Nothing to do, this should be removed during prepare for register allocator. |
| 3873 | LOG(FATAL) << "Unreachable"; |
| 3874 | } |
| 3875 | |
| 3876 | void LocationsBuilderMIPS64::VisitEqual(HEqual* comp) { |
| 3877 | VisitCondition(comp); |
| 3878 | } |
| 3879 | |
| 3880 | void InstructionCodeGeneratorMIPS64::VisitEqual(HEqual* comp) { |
| 3881 | VisitCondition(comp); |
| 3882 | } |
| 3883 | |
| 3884 | void LocationsBuilderMIPS64::VisitNotEqual(HNotEqual* comp) { |
| 3885 | VisitCondition(comp); |
| 3886 | } |
| 3887 | |
| 3888 | void InstructionCodeGeneratorMIPS64::VisitNotEqual(HNotEqual* comp) { |
| 3889 | VisitCondition(comp); |
| 3890 | } |
| 3891 | |
| 3892 | void LocationsBuilderMIPS64::VisitLessThan(HLessThan* comp) { |
| 3893 | VisitCondition(comp); |
| 3894 | } |
| 3895 | |
| 3896 | void InstructionCodeGeneratorMIPS64::VisitLessThan(HLessThan* comp) { |
| 3897 | VisitCondition(comp); |
| 3898 | } |
| 3899 | |
| 3900 | void LocationsBuilderMIPS64::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 3901 | VisitCondition(comp); |
| 3902 | } |
| 3903 | |
| 3904 | void InstructionCodeGeneratorMIPS64::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 3905 | VisitCondition(comp); |
| 3906 | } |
| 3907 | |
| 3908 | void LocationsBuilderMIPS64::VisitGreaterThan(HGreaterThan* comp) { |
| 3909 | VisitCondition(comp); |
| 3910 | } |
| 3911 | |
| 3912 | void InstructionCodeGeneratorMIPS64::VisitGreaterThan(HGreaterThan* comp) { |
| 3913 | VisitCondition(comp); |
| 3914 | } |
| 3915 | |
| 3916 | void LocationsBuilderMIPS64::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 3917 | VisitCondition(comp); |
| 3918 | } |
| 3919 | |
| 3920 | void InstructionCodeGeneratorMIPS64::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 3921 | VisitCondition(comp); |
| 3922 | } |
| 3923 | |
Aart Bik | e9f3760 | 2015-10-09 11:15:55 -0700 | [diff] [blame] | 3924 | void LocationsBuilderMIPS64::VisitBelow(HBelow* comp) { |
| 3925 | VisitCondition(comp); |
| 3926 | } |
| 3927 | |
| 3928 | void InstructionCodeGeneratorMIPS64::VisitBelow(HBelow* comp) { |
| 3929 | VisitCondition(comp); |
| 3930 | } |
| 3931 | |
| 3932 | void LocationsBuilderMIPS64::VisitBelowOrEqual(HBelowOrEqual* comp) { |
| 3933 | VisitCondition(comp); |
| 3934 | } |
| 3935 | |
| 3936 | void InstructionCodeGeneratorMIPS64::VisitBelowOrEqual(HBelowOrEqual* comp) { |
| 3937 | VisitCondition(comp); |
| 3938 | } |
| 3939 | |
| 3940 | void LocationsBuilderMIPS64::VisitAbove(HAbove* comp) { |
| 3941 | VisitCondition(comp); |
| 3942 | } |
| 3943 | |
| 3944 | void InstructionCodeGeneratorMIPS64::VisitAbove(HAbove* comp) { |
| 3945 | VisitCondition(comp); |
| 3946 | } |
| 3947 | |
| 3948 | void LocationsBuilderMIPS64::VisitAboveOrEqual(HAboveOrEqual* comp) { |
| 3949 | VisitCondition(comp); |
| 3950 | } |
| 3951 | |
| 3952 | void InstructionCodeGeneratorMIPS64::VisitAboveOrEqual(HAboveOrEqual* comp) { |
| 3953 | VisitCondition(comp); |
| 3954 | } |
| 3955 | |
Nicolas Geoffray | 2e7cd75 | 2015-07-10 11:38:52 +0100 | [diff] [blame] | 3956 | void LocationsBuilderMIPS64::VisitFakeString(HFakeString* instruction) { |
| 3957 | DCHECK(codegen_->IsBaseline()); |
| 3958 | LocationSummary* locations = |
| 3959 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 3960 | locations->SetOut(Location::ConstantLocation(GetGraph()->GetNullConstant())); |
| 3961 | } |
| 3962 | |
| 3963 | void InstructionCodeGeneratorMIPS64::VisitFakeString(HFakeString* instruction ATTRIBUTE_UNUSED) { |
| 3964 | DCHECK(codegen_->IsBaseline()); |
| 3965 | // Will be generated at use site. |
| 3966 | } |
| 3967 | |
Mark Mendell | fe57faa | 2015-09-18 09:26:15 -0400 | [diff] [blame] | 3968 | // Simple implementation of packed switch - generate cascaded compare/jumps. |
| 3969 | void LocationsBuilderMIPS64::VisitPackedSwitch(HPackedSwitch* switch_instr) { |
| 3970 | LocationSummary* locations = |
| 3971 | new (GetGraph()->GetArena()) LocationSummary(switch_instr, LocationSummary::kNoCall); |
| 3972 | locations->SetInAt(0, Location::RequiresRegister()); |
| 3973 | } |
| 3974 | |
| 3975 | void InstructionCodeGeneratorMIPS64::VisitPackedSwitch(HPackedSwitch* switch_instr) { |
| 3976 | int32_t lower_bound = switch_instr->GetStartValue(); |
| 3977 | int32_t num_entries = switch_instr->GetNumEntries(); |
| 3978 | LocationSummary* locations = switch_instr->GetLocations(); |
| 3979 | GpuRegister value_reg = locations->InAt(0).AsRegister<GpuRegister>(); |
| 3980 | HBasicBlock* default_block = switch_instr->GetDefaultBlock(); |
| 3981 | |
Zheng Xu | 59f054d | 2015-12-07 17:17:03 +0800 | [diff] [blame] | 3982 | // Create a set of compare/jumps. |
| 3983 | GpuRegister temp_reg = TMP; |
| 3984 | if (IsInt<16>(-lower_bound)) { |
| 3985 | __ Addiu(temp_reg, value_reg, -lower_bound); |
| 3986 | } else { |
| 3987 | __ LoadConst32(AT, -lower_bound); |
| 3988 | __ Addu(temp_reg, value_reg, AT); |
| 3989 | } |
| 3990 | // Jump to default if index is negative |
| 3991 | // Note: We don't check the case that index is positive while value < lower_bound, because in |
| 3992 | // this case, index >= num_entries must be true. So that we can save one branch instruction. |
| 3993 | __ Bltzc(temp_reg, codegen_->GetLabelOf(default_block)); |
| 3994 | |
Mark Mendell | fe57faa | 2015-09-18 09:26:15 -0400 | [diff] [blame] | 3995 | const ArenaVector<HBasicBlock*>& successors = switch_instr->GetBlock()->GetSuccessors(); |
Zheng Xu | 59f054d | 2015-12-07 17:17:03 +0800 | [diff] [blame] | 3996 | // Jump to successors[0] if value == lower_bound. |
| 3997 | __ Beqzc(temp_reg, codegen_->GetLabelOf(successors[0])); |
| 3998 | int32_t last_index = 0; |
| 3999 | for (; num_entries - last_index > 2; last_index += 2) { |
| 4000 | __ Addiu(temp_reg, temp_reg, -2); |
| 4001 | // Jump to successors[last_index + 1] if value < case_value[last_index + 2]. |
| 4002 | __ Bltzc(temp_reg, codegen_->GetLabelOf(successors[last_index + 1])); |
| 4003 | // Jump to successors[last_index + 2] if value == case_value[last_index + 2]. |
| 4004 | __ Beqzc(temp_reg, codegen_->GetLabelOf(successors[last_index + 2])); |
| 4005 | } |
| 4006 | if (num_entries - last_index == 2) { |
| 4007 | // The last missing case_value. |
| 4008 | __ Addiu(temp_reg, temp_reg, -1); |
| 4009 | __ Beqzc(temp_reg, codegen_->GetLabelOf(successors[last_index + 1])); |
Mark Mendell | fe57faa | 2015-09-18 09:26:15 -0400 | [diff] [blame] | 4010 | } |
| 4011 | |
| 4012 | // And the default for any other value. |
| 4013 | if (!codegen_->GoesToNextBlock(switch_instr->GetBlock(), default_block)) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 4014 | __ Bc(codegen_->GetLabelOf(default_block)); |
Mark Mendell | fe57faa | 2015-09-18 09:26:15 -0400 | [diff] [blame] | 4015 | } |
| 4016 | } |
| 4017 | |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 4018 | } // namespace mips64 |
| 4019 | } // namespace art |