Chris Larsen | 701566a | 2015-10-27 15:29:13 -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 "intrinsics_mips.h" |
| 18 | |
| 19 | #include "arch/mips/instruction_set_features_mips.h" |
| 20 | #include "art_method.h" |
| 21 | #include "code_generator_mips.h" |
| 22 | #include "entrypoints/quick/quick_entrypoints.h" |
| 23 | #include "intrinsics.h" |
| 24 | #include "mirror/array-inl.h" |
| 25 | #include "mirror/string.h" |
| 26 | #include "thread.h" |
| 27 | #include "utils/mips/assembler_mips.h" |
| 28 | #include "utils/mips/constants_mips.h" |
| 29 | |
| 30 | namespace art { |
| 31 | |
| 32 | namespace mips { |
| 33 | |
| 34 | IntrinsicLocationsBuilderMIPS::IntrinsicLocationsBuilderMIPS(CodeGeneratorMIPS* codegen) |
| 35 | : arena_(codegen->GetGraph()->GetArena()) { |
| 36 | } |
| 37 | |
| 38 | MipsAssembler* IntrinsicCodeGeneratorMIPS::GetAssembler() { |
| 39 | return reinterpret_cast<MipsAssembler*>(codegen_->GetAssembler()); |
| 40 | } |
| 41 | |
| 42 | ArenaAllocator* IntrinsicCodeGeneratorMIPS::GetAllocator() { |
| 43 | return codegen_->GetGraph()->GetArena(); |
| 44 | } |
| 45 | |
Alexey Frunze | bb9863a | 2016-01-11 15:51:16 -0800 | [diff] [blame] | 46 | inline bool IntrinsicCodeGeneratorMIPS::IsR2OrNewer() const { |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 47 | return codegen_->GetInstructionSetFeatures().IsMipsIsaRevGreaterThanEqual2(); |
| 48 | } |
| 49 | |
Alexey Frunze | bb9863a | 2016-01-11 15:51:16 -0800 | [diff] [blame] | 50 | inline bool IntrinsicCodeGeneratorMIPS::IsR6() const { |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 51 | return codegen_->GetInstructionSetFeatures().IsR6(); |
| 52 | } |
| 53 | |
Alexey Frunze | bb9863a | 2016-01-11 15:51:16 -0800 | [diff] [blame] | 54 | inline bool IntrinsicCodeGeneratorMIPS::Is32BitFPU() const { |
| 55 | return codegen_->GetInstructionSetFeatures().Is32BitFloatingPoint(); |
| 56 | } |
| 57 | |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 58 | #define __ codegen->GetAssembler()-> |
| 59 | |
| 60 | static void MoveFromReturnRegister(Location trg, |
| 61 | Primitive::Type type, |
| 62 | CodeGeneratorMIPS* codegen) { |
| 63 | if (!trg.IsValid()) { |
| 64 | DCHECK_EQ(type, Primitive::kPrimVoid); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | DCHECK_NE(type, Primitive::kPrimVoid); |
| 69 | |
| 70 | if (Primitive::IsIntegralType(type) || type == Primitive::kPrimNot) { |
| 71 | Register trg_reg = trg.AsRegister<Register>(); |
| 72 | if (trg_reg != V0) { |
| 73 | __ Move(V0, trg_reg); |
| 74 | } |
| 75 | } else { |
| 76 | FRegister trg_reg = trg.AsFpuRegister<FRegister>(); |
| 77 | if (trg_reg != F0) { |
| 78 | if (type == Primitive::kPrimFloat) { |
| 79 | __ MovS(F0, trg_reg); |
| 80 | } else { |
| 81 | __ MovD(F0, trg_reg); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | static void MoveArguments(HInvoke* invoke, CodeGeneratorMIPS* codegen) { |
| 88 | InvokeDexCallingConventionVisitorMIPS calling_convention_visitor; |
| 89 | IntrinsicVisitor::MoveArguments(invoke, codegen, &calling_convention_visitor); |
| 90 | } |
| 91 | |
| 92 | // Slow-path for fallback (calling the managed code to handle the |
| 93 | // intrinsic) in an intrinsified call. This will copy the arguments |
| 94 | // into the positions for a regular call. |
| 95 | // |
| 96 | // Note: The actual parameters are required to be in the locations |
| 97 | // given by the invoke's location summary. If an intrinsic |
| 98 | // modifies those locations before a slowpath call, they must be |
| 99 | // restored! |
| 100 | class IntrinsicSlowPathMIPS : public SlowPathCodeMIPS { |
| 101 | public: |
David Srbecky | 9cd6d37 | 2016-02-09 15:24:47 +0000 | [diff] [blame] | 102 | explicit IntrinsicSlowPathMIPS(HInvoke* invoke) : SlowPathCodeMIPS(invoke), invoke_(invoke) { } |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 103 | |
| 104 | void EmitNativeCode(CodeGenerator* codegen_in) OVERRIDE { |
| 105 | CodeGeneratorMIPS* codegen = down_cast<CodeGeneratorMIPS*>(codegen_in); |
| 106 | |
| 107 | __ Bind(GetEntryLabel()); |
| 108 | |
| 109 | SaveLiveRegisters(codegen, invoke_->GetLocations()); |
| 110 | |
| 111 | MoveArguments(invoke_, codegen); |
| 112 | |
| 113 | if (invoke_->IsInvokeStaticOrDirect()) { |
| 114 | codegen->GenerateStaticOrDirectCall(invoke_->AsInvokeStaticOrDirect(), |
| 115 | Location::RegisterLocation(A0)); |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 116 | } else { |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 117 | codegen->GenerateVirtualCall(invoke_->AsInvokeVirtual(), Location::RegisterLocation(A0)); |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 118 | } |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 119 | codegen->RecordPcInfo(invoke_, invoke_->GetDexPc(), this); |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 120 | |
| 121 | // Copy the result back to the expected output. |
| 122 | Location out = invoke_->GetLocations()->Out(); |
| 123 | if (out.IsValid()) { |
| 124 | DCHECK(out.IsRegister()); // TODO: Replace this when we support output in memory. |
| 125 | DCHECK(!invoke_->GetLocations()->GetLiveRegisters()->ContainsCoreRegister(out.reg())); |
| 126 | MoveFromReturnRegister(out, invoke_->GetType(), codegen); |
| 127 | } |
| 128 | |
| 129 | RestoreLiveRegisters(codegen, invoke_->GetLocations()); |
| 130 | __ B(GetExitLabel()); |
| 131 | } |
| 132 | |
| 133 | const char* GetDescription() const OVERRIDE { return "IntrinsicSlowPathMIPS"; } |
| 134 | |
| 135 | private: |
| 136 | // The instruction where this slow path is happening. |
| 137 | HInvoke* const invoke_; |
| 138 | |
| 139 | DISALLOW_COPY_AND_ASSIGN(IntrinsicSlowPathMIPS); |
| 140 | }; |
| 141 | |
| 142 | #undef __ |
| 143 | |
| 144 | bool IntrinsicLocationsBuilderMIPS::TryDispatch(HInvoke* invoke) { |
| 145 | Dispatch(invoke); |
| 146 | LocationSummary* res = invoke->GetLocations(); |
| 147 | return res != nullptr && res->Intrinsified(); |
| 148 | } |
| 149 | |
| 150 | #define __ assembler-> |
| 151 | |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 152 | static void CreateFPToIntLocations(ArenaAllocator* arena, HInvoke* invoke) { |
| 153 | LocationSummary* locations = new (arena) LocationSummary(invoke, |
| 154 | LocationSummary::kNoCall, |
| 155 | kIntrinsified); |
| 156 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 157 | locations->SetOut(Location::RequiresRegister()); |
| 158 | } |
| 159 | |
| 160 | static void MoveFPToInt(LocationSummary* locations, bool is64bit, MipsAssembler* assembler) { |
| 161 | FRegister in = locations->InAt(0).AsFpuRegister<FRegister>(); |
| 162 | |
| 163 | if (is64bit) { |
| 164 | Register out_lo = locations->Out().AsRegisterPairLow<Register>(); |
| 165 | Register out_hi = locations->Out().AsRegisterPairHigh<Register>(); |
| 166 | |
| 167 | __ Mfc1(out_lo, in); |
Alexey Frunze | bb9863a | 2016-01-11 15:51:16 -0800 | [diff] [blame] | 168 | __ MoveFromFpuHigh(out_hi, in); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 169 | } else { |
| 170 | Register out = locations->Out().AsRegister<Register>(); |
| 171 | |
| 172 | __ Mfc1(out, in); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // long java.lang.Double.doubleToRawLongBits(double) |
| 177 | void IntrinsicLocationsBuilderMIPS::VisitDoubleDoubleToRawLongBits(HInvoke* invoke) { |
| 178 | CreateFPToIntLocations(arena_, invoke); |
| 179 | } |
| 180 | |
| 181 | void IntrinsicCodeGeneratorMIPS::VisitDoubleDoubleToRawLongBits(HInvoke* invoke) { |
Roland Levillain | bf84a3d | 2015-12-04 14:33:02 +0000 | [diff] [blame] | 182 | MoveFPToInt(invoke->GetLocations(), /* is64bit */ true, GetAssembler()); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | // int java.lang.Float.floatToRawIntBits(float) |
| 186 | void IntrinsicLocationsBuilderMIPS::VisitFloatFloatToRawIntBits(HInvoke* invoke) { |
| 187 | CreateFPToIntLocations(arena_, invoke); |
| 188 | } |
| 189 | |
| 190 | void IntrinsicCodeGeneratorMIPS::VisitFloatFloatToRawIntBits(HInvoke* invoke) { |
Roland Levillain | bf84a3d | 2015-12-04 14:33:02 +0000 | [diff] [blame] | 191 | MoveFPToInt(invoke->GetLocations(), /* is64bit */ false, GetAssembler()); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | static void CreateIntToFPLocations(ArenaAllocator* arena, HInvoke* invoke) { |
| 195 | LocationSummary* locations = new (arena) LocationSummary(invoke, |
| 196 | LocationSummary::kNoCall, |
| 197 | kIntrinsified); |
| 198 | locations->SetInAt(0, Location::RequiresRegister()); |
| 199 | locations->SetOut(Location::RequiresFpuRegister()); |
| 200 | } |
| 201 | |
| 202 | static void MoveIntToFP(LocationSummary* locations, bool is64bit, MipsAssembler* assembler) { |
| 203 | FRegister out = locations->Out().AsFpuRegister<FRegister>(); |
| 204 | |
| 205 | if (is64bit) { |
| 206 | Register in_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 207 | Register in_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 208 | |
| 209 | __ Mtc1(in_lo, out); |
Alexey Frunze | bb9863a | 2016-01-11 15:51:16 -0800 | [diff] [blame] | 210 | __ MoveToFpuHigh(in_hi, out); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 211 | } else { |
| 212 | Register in = locations->InAt(0).AsRegister<Register>(); |
| 213 | |
| 214 | __ Mtc1(in, out); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // double java.lang.Double.longBitsToDouble(long) |
| 219 | void IntrinsicLocationsBuilderMIPS::VisitDoubleLongBitsToDouble(HInvoke* invoke) { |
| 220 | CreateIntToFPLocations(arena_, invoke); |
| 221 | } |
| 222 | |
| 223 | void IntrinsicCodeGeneratorMIPS::VisitDoubleLongBitsToDouble(HInvoke* invoke) { |
Roland Levillain | bf84a3d | 2015-12-04 14:33:02 +0000 | [diff] [blame] | 224 | MoveIntToFP(invoke->GetLocations(), /* is64bit */ true, GetAssembler()); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | // float java.lang.Float.intBitsToFloat(int) |
| 228 | void IntrinsicLocationsBuilderMIPS::VisitFloatIntBitsToFloat(HInvoke* invoke) { |
| 229 | CreateIntToFPLocations(arena_, invoke); |
| 230 | } |
| 231 | |
| 232 | void IntrinsicCodeGeneratorMIPS::VisitFloatIntBitsToFloat(HInvoke* invoke) { |
Roland Levillain | bf84a3d | 2015-12-04 14:33:02 +0000 | [diff] [blame] | 233 | MoveIntToFP(invoke->GetLocations(), /* is64bit */ false, GetAssembler()); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Chris Larsen | 8682960 | 2015-11-18 12:27:52 -0800 | [diff] [blame] | 236 | static void CreateIntToIntLocations(ArenaAllocator* arena, |
| 237 | HInvoke* invoke, |
| 238 | Location::OutputOverlap overlaps = Location::kNoOutputOverlap) { |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 239 | LocationSummary* locations = new (arena) LocationSummary(invoke, |
| 240 | LocationSummary::kNoCall, |
| 241 | kIntrinsified); |
| 242 | locations->SetInAt(0, Location::RequiresRegister()); |
Chris Larsen | 8682960 | 2015-11-18 12:27:52 -0800 | [diff] [blame] | 243 | locations->SetOut(Location::RequiresRegister(), overlaps); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 246 | static void GenReverse(LocationSummary* locations, |
| 247 | Primitive::Type type, |
| 248 | bool isR2OrNewer, |
| 249 | bool isR6, |
| 250 | bool reverseBits, |
| 251 | MipsAssembler* assembler) { |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 252 | DCHECK(type == Primitive::kPrimShort || |
| 253 | type == Primitive::kPrimInt || |
| 254 | type == Primitive::kPrimLong); |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 255 | DCHECK(type != Primitive::kPrimShort || !reverseBits); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 256 | |
| 257 | if (type == Primitive::kPrimShort) { |
| 258 | Register in = locations->InAt(0).AsRegister<Register>(); |
| 259 | Register out = locations->Out().AsRegister<Register>(); |
| 260 | |
| 261 | if (isR2OrNewer) { |
| 262 | __ Wsbh(out, in); |
| 263 | __ Seh(out, out); |
| 264 | } else { |
| 265 | __ Sll(TMP, in, 24); |
| 266 | __ Sra(TMP, TMP, 16); |
| 267 | __ Sll(out, in, 16); |
| 268 | __ Srl(out, out, 24); |
| 269 | __ Or(out, out, TMP); |
| 270 | } |
| 271 | } else if (type == Primitive::kPrimInt) { |
| 272 | Register in = locations->InAt(0).AsRegister<Register>(); |
| 273 | Register out = locations->Out().AsRegister<Register>(); |
| 274 | |
| 275 | if (isR2OrNewer) { |
| 276 | __ Rotr(out, in, 16); |
| 277 | __ Wsbh(out, out); |
| 278 | } else { |
| 279 | // MIPS32r1 |
| 280 | // __ Rotr(out, in, 16); |
| 281 | __ Sll(TMP, in, 16); |
| 282 | __ Srl(out, in, 16); |
| 283 | __ Or(out, out, TMP); |
| 284 | // __ Wsbh(out, out); |
| 285 | __ LoadConst32(AT, 0x00FF00FF); |
| 286 | __ And(TMP, out, AT); |
| 287 | __ Sll(TMP, TMP, 8); |
| 288 | __ Srl(out, out, 8); |
| 289 | __ And(out, out, AT); |
| 290 | __ Or(out, out, TMP); |
| 291 | } |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 292 | if (reverseBits) { |
| 293 | if (isR6) { |
| 294 | __ Bitswap(out, out); |
| 295 | } else { |
| 296 | __ LoadConst32(AT, 0x0F0F0F0F); |
| 297 | __ And(TMP, out, AT); |
| 298 | __ Sll(TMP, TMP, 4); |
| 299 | __ Srl(out, out, 4); |
| 300 | __ And(out, out, AT); |
| 301 | __ Or(out, TMP, out); |
| 302 | __ LoadConst32(AT, 0x33333333); |
| 303 | __ And(TMP, out, AT); |
| 304 | __ Sll(TMP, TMP, 2); |
| 305 | __ Srl(out, out, 2); |
| 306 | __ And(out, out, AT); |
| 307 | __ Or(out, TMP, out); |
| 308 | __ LoadConst32(AT, 0x55555555); |
| 309 | __ And(TMP, out, AT); |
| 310 | __ Sll(TMP, TMP, 1); |
| 311 | __ Srl(out, out, 1); |
| 312 | __ And(out, out, AT); |
| 313 | __ Or(out, TMP, out); |
| 314 | } |
| 315 | } |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 316 | } else if (type == Primitive::kPrimLong) { |
| 317 | Register in_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 318 | Register in_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 319 | Register out_lo = locations->Out().AsRegisterPairLow<Register>(); |
| 320 | Register out_hi = locations->Out().AsRegisterPairHigh<Register>(); |
| 321 | |
| 322 | if (isR2OrNewer) { |
| 323 | __ Rotr(AT, in_hi, 16); |
| 324 | __ Rotr(TMP, in_lo, 16); |
| 325 | __ Wsbh(out_lo, AT); |
| 326 | __ Wsbh(out_hi, TMP); |
| 327 | } else { |
| 328 | // When calling CreateIntToIntLocations() we promised that the |
| 329 | // use of the out_lo/out_hi wouldn't overlap with the use of |
| 330 | // in_lo/in_hi. Be very careful not to write to out_lo/out_hi |
| 331 | // until we're completely done reading from in_lo/in_hi. |
| 332 | // __ Rotr(TMP, in_lo, 16); |
| 333 | __ Sll(TMP, in_lo, 16); |
| 334 | __ Srl(AT, in_lo, 16); |
| 335 | __ Or(TMP, TMP, AT); // Hold in TMP until it's safe |
| 336 | // to write to out_hi. |
| 337 | // __ Rotr(out_lo, in_hi, 16); |
| 338 | __ Sll(AT, in_hi, 16); |
| 339 | __ Srl(out_lo, in_hi, 16); // Here we are finally done reading |
| 340 | // from in_lo/in_hi so it's okay to |
| 341 | // write to out_lo/out_hi. |
| 342 | __ Or(out_lo, out_lo, AT); |
| 343 | // __ Wsbh(out_hi, out_hi); |
| 344 | __ LoadConst32(AT, 0x00FF00FF); |
| 345 | __ And(out_hi, TMP, AT); |
| 346 | __ Sll(out_hi, out_hi, 8); |
| 347 | __ Srl(TMP, TMP, 8); |
| 348 | __ And(TMP, TMP, AT); |
| 349 | __ Or(out_hi, out_hi, TMP); |
| 350 | // __ Wsbh(out_lo, out_lo); |
| 351 | __ And(TMP, out_lo, AT); // AT already holds the correct mask value |
| 352 | __ Sll(TMP, TMP, 8); |
| 353 | __ Srl(out_lo, out_lo, 8); |
| 354 | __ And(out_lo, out_lo, AT); |
| 355 | __ Or(out_lo, out_lo, TMP); |
| 356 | } |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 357 | if (reverseBits) { |
| 358 | if (isR6) { |
| 359 | __ Bitswap(out_hi, out_hi); |
| 360 | __ Bitswap(out_lo, out_lo); |
| 361 | } else { |
| 362 | __ LoadConst32(AT, 0x0F0F0F0F); |
| 363 | __ And(TMP, out_hi, AT); |
| 364 | __ Sll(TMP, TMP, 4); |
| 365 | __ Srl(out_hi, out_hi, 4); |
| 366 | __ And(out_hi, out_hi, AT); |
| 367 | __ Or(out_hi, TMP, out_hi); |
| 368 | __ And(TMP, out_lo, AT); |
| 369 | __ Sll(TMP, TMP, 4); |
| 370 | __ Srl(out_lo, out_lo, 4); |
| 371 | __ And(out_lo, out_lo, AT); |
| 372 | __ Or(out_lo, TMP, out_lo); |
| 373 | __ LoadConst32(AT, 0x33333333); |
| 374 | __ And(TMP, out_hi, AT); |
| 375 | __ Sll(TMP, TMP, 2); |
| 376 | __ Srl(out_hi, out_hi, 2); |
| 377 | __ And(out_hi, out_hi, AT); |
| 378 | __ Or(out_hi, TMP, out_hi); |
| 379 | __ And(TMP, out_lo, AT); |
| 380 | __ Sll(TMP, TMP, 2); |
| 381 | __ Srl(out_lo, out_lo, 2); |
| 382 | __ And(out_lo, out_lo, AT); |
| 383 | __ Or(out_lo, TMP, out_lo); |
| 384 | __ LoadConst32(AT, 0x55555555); |
| 385 | __ And(TMP, out_hi, AT); |
| 386 | __ Sll(TMP, TMP, 1); |
| 387 | __ Srl(out_hi, out_hi, 1); |
| 388 | __ And(out_hi, out_hi, AT); |
| 389 | __ Or(out_hi, TMP, out_hi); |
| 390 | __ And(TMP, out_lo, AT); |
| 391 | __ Sll(TMP, TMP, 1); |
| 392 | __ Srl(out_lo, out_lo, 1); |
| 393 | __ And(out_lo, out_lo, AT); |
| 394 | __ Or(out_lo, TMP, out_lo); |
| 395 | } |
| 396 | } |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 397 | } |
| 398 | } |
| 399 | |
| 400 | // int java.lang.Integer.reverseBytes(int) |
| 401 | void IntrinsicLocationsBuilderMIPS::VisitIntegerReverseBytes(HInvoke* invoke) { |
| 402 | CreateIntToIntLocations(arena_, invoke); |
| 403 | } |
| 404 | |
| 405 | void IntrinsicCodeGeneratorMIPS::VisitIntegerReverseBytes(HInvoke* invoke) { |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 406 | GenReverse(invoke->GetLocations(), |
| 407 | Primitive::kPrimInt, |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 408 | IsR2OrNewer(), |
| 409 | IsR6(), |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 410 | /* reverseBits */ false, |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 411 | GetAssembler()); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | // long java.lang.Long.reverseBytes(long) |
| 415 | void IntrinsicLocationsBuilderMIPS::VisitLongReverseBytes(HInvoke* invoke) { |
| 416 | CreateIntToIntLocations(arena_, invoke); |
| 417 | } |
| 418 | |
| 419 | void IntrinsicCodeGeneratorMIPS::VisitLongReverseBytes(HInvoke* invoke) { |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 420 | GenReverse(invoke->GetLocations(), |
| 421 | Primitive::kPrimLong, |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 422 | IsR2OrNewer(), |
| 423 | IsR6(), |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 424 | /* reverseBits */ false, |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 425 | GetAssembler()); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // short java.lang.Short.reverseBytes(short) |
| 429 | void IntrinsicLocationsBuilderMIPS::VisitShortReverseBytes(HInvoke* invoke) { |
| 430 | CreateIntToIntLocations(arena_, invoke); |
| 431 | } |
| 432 | |
| 433 | void IntrinsicCodeGeneratorMIPS::VisitShortReverseBytes(HInvoke* invoke) { |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 434 | GenReverse(invoke->GetLocations(), |
| 435 | Primitive::kPrimShort, |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 436 | IsR2OrNewer(), |
| 437 | IsR6(), |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 438 | /* reverseBits */ false, |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 439 | GetAssembler()); |
| 440 | } |
| 441 | |
Chris Larsen | e384547 | 2015-11-18 12:27:15 -0800 | [diff] [blame] | 442 | static void GenNumberOfLeadingZeroes(LocationSummary* locations, |
| 443 | bool is64bit, |
| 444 | bool isR6, |
| 445 | MipsAssembler* assembler) { |
| 446 | Register out = locations->Out().AsRegister<Register>(); |
| 447 | if (is64bit) { |
| 448 | Register in_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 449 | Register in_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 450 | |
| 451 | if (isR6) { |
| 452 | __ ClzR6(AT, in_hi); |
| 453 | __ ClzR6(TMP, in_lo); |
| 454 | __ Seleqz(TMP, TMP, in_hi); |
| 455 | } else { |
| 456 | __ ClzR2(AT, in_hi); |
| 457 | __ ClzR2(TMP, in_lo); |
| 458 | __ Movn(TMP, ZERO, in_hi); |
| 459 | } |
| 460 | __ Addu(out, AT, TMP); |
| 461 | } else { |
| 462 | Register in = locations->InAt(0).AsRegister<Register>(); |
| 463 | |
| 464 | if (isR6) { |
| 465 | __ ClzR6(out, in); |
| 466 | } else { |
| 467 | __ ClzR2(out, in); |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | // int java.lang.Integer.numberOfLeadingZeros(int i) |
| 473 | void IntrinsicLocationsBuilderMIPS::VisitIntegerNumberOfLeadingZeros(HInvoke* invoke) { |
| 474 | CreateIntToIntLocations(arena_, invoke); |
| 475 | } |
| 476 | |
| 477 | void IntrinsicCodeGeneratorMIPS::VisitIntegerNumberOfLeadingZeros(HInvoke* invoke) { |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 478 | GenNumberOfLeadingZeroes(invoke->GetLocations(), /* is64bit */ false, IsR6(), GetAssembler()); |
Chris Larsen | e384547 | 2015-11-18 12:27:15 -0800 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | // int java.lang.Long.numberOfLeadingZeros(long i) |
| 482 | void IntrinsicLocationsBuilderMIPS::VisitLongNumberOfLeadingZeros(HInvoke* invoke) { |
| 483 | CreateIntToIntLocations(arena_, invoke); |
| 484 | } |
| 485 | |
| 486 | void IntrinsicCodeGeneratorMIPS::VisitLongNumberOfLeadingZeros(HInvoke* invoke) { |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 487 | GenNumberOfLeadingZeroes(invoke->GetLocations(), /* is64bit */ true, IsR6(), GetAssembler()); |
Chris Larsen | e384547 | 2015-11-18 12:27:15 -0800 | [diff] [blame] | 488 | } |
| 489 | |
Chris Larsen | 8682960 | 2015-11-18 12:27:52 -0800 | [diff] [blame] | 490 | static void GenNumberOfTrailingZeroes(LocationSummary* locations, |
| 491 | bool is64bit, |
| 492 | bool isR6, |
| 493 | bool isR2OrNewer, |
| 494 | MipsAssembler* assembler) { |
| 495 | Register out = locations->Out().AsRegister<Register>(); |
| 496 | Register in_lo; |
| 497 | Register in; |
| 498 | |
| 499 | if (is64bit) { |
Chris Larsen | 8682960 | 2015-11-18 12:27:52 -0800 | [diff] [blame] | 500 | Register in_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 501 | |
| 502 | in_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 503 | |
| 504 | // If in_lo is zero then count the number of trailing zeroes in in_hi; |
| 505 | // otherwise count the number of trailing zeroes in in_lo. |
| 506 | // AT = in_lo ? in_lo : in_hi; |
| 507 | if (isR6) { |
| 508 | __ Seleqz(out, in_hi, in_lo); |
| 509 | __ Selnez(TMP, in_lo, in_lo); |
| 510 | __ Or(out, out, TMP); |
| 511 | } else { |
| 512 | __ Movz(out, in_hi, in_lo); |
| 513 | __ Movn(out, in_lo, in_lo); |
| 514 | } |
| 515 | |
| 516 | in = out; |
| 517 | } else { |
| 518 | in = locations->InAt(0).AsRegister<Register>(); |
| 519 | // Give in_lo a dummy value to keep the compiler from complaining. |
| 520 | // Since we only get here in the 32-bit case, this value will never |
| 521 | // be used. |
| 522 | in_lo = in; |
| 523 | } |
| 524 | |
| 525 | // We don't have an instruction to count the number of trailing zeroes. |
| 526 | // Start by flipping the bits end-for-end so we can count the number of |
| 527 | // leading zeroes instead. |
| 528 | if (isR2OrNewer) { |
| 529 | __ Rotr(out, in, 16); |
| 530 | __ Wsbh(out, out); |
| 531 | } else { |
| 532 | // MIPS32r1 |
| 533 | // __ Rotr(out, in, 16); |
| 534 | __ Sll(TMP, in, 16); |
| 535 | __ Srl(out, in, 16); |
| 536 | __ Or(out, out, TMP); |
| 537 | // __ Wsbh(out, out); |
| 538 | __ LoadConst32(AT, 0x00FF00FF); |
| 539 | __ And(TMP, out, AT); |
| 540 | __ Sll(TMP, TMP, 8); |
| 541 | __ Srl(out, out, 8); |
| 542 | __ And(out, out, AT); |
| 543 | __ Or(out, out, TMP); |
| 544 | } |
| 545 | |
| 546 | if (isR6) { |
| 547 | __ Bitswap(out, out); |
| 548 | __ ClzR6(out, out); |
| 549 | } else { |
| 550 | __ LoadConst32(AT, 0x0F0F0F0F); |
| 551 | __ And(TMP, out, AT); |
| 552 | __ Sll(TMP, TMP, 4); |
| 553 | __ Srl(out, out, 4); |
| 554 | __ And(out, out, AT); |
| 555 | __ Or(out, TMP, out); |
| 556 | __ LoadConst32(AT, 0x33333333); |
| 557 | __ And(TMP, out, AT); |
| 558 | __ Sll(TMP, TMP, 2); |
| 559 | __ Srl(out, out, 2); |
| 560 | __ And(out, out, AT); |
| 561 | __ Or(out, TMP, out); |
| 562 | __ LoadConst32(AT, 0x55555555); |
| 563 | __ And(TMP, out, AT); |
| 564 | __ Sll(TMP, TMP, 1); |
| 565 | __ Srl(out, out, 1); |
| 566 | __ And(out, out, AT); |
| 567 | __ Or(out, TMP, out); |
| 568 | __ ClzR2(out, out); |
| 569 | } |
| 570 | |
| 571 | if (is64bit) { |
| 572 | // If in_lo is zero, then we counted the number of trailing zeroes in in_hi so we must add the |
| 573 | // number of trailing zeroes in in_lo (32) to get the correct final count |
| 574 | __ LoadConst32(TMP, 32); |
| 575 | if (isR6) { |
| 576 | __ Seleqz(TMP, TMP, in_lo); |
| 577 | } else { |
| 578 | __ Movn(TMP, ZERO, in_lo); |
| 579 | } |
| 580 | __ Addu(out, out, TMP); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | // int java.lang.Integer.numberOfTrailingZeros(int i) |
| 585 | void IntrinsicLocationsBuilderMIPS::VisitIntegerNumberOfTrailingZeros(HInvoke* invoke) { |
| 586 | CreateIntToIntLocations(arena_, invoke, Location::kOutputOverlap); |
| 587 | } |
| 588 | |
| 589 | void IntrinsicCodeGeneratorMIPS::VisitIntegerNumberOfTrailingZeros(HInvoke* invoke) { |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 590 | GenNumberOfTrailingZeroes(invoke->GetLocations(), |
| 591 | /* is64bit */ false, |
| 592 | IsR6(), |
| 593 | IsR2OrNewer(), |
| 594 | GetAssembler()); |
Chris Larsen | 8682960 | 2015-11-18 12:27:52 -0800 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | // int java.lang.Long.numberOfTrailingZeros(long i) |
| 598 | void IntrinsicLocationsBuilderMIPS::VisitLongNumberOfTrailingZeros(HInvoke* invoke) { |
| 599 | CreateIntToIntLocations(arena_, invoke, Location::kOutputOverlap); |
| 600 | } |
| 601 | |
| 602 | void IntrinsicCodeGeneratorMIPS::VisitLongNumberOfTrailingZeros(HInvoke* invoke) { |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 603 | GenNumberOfTrailingZeroes(invoke->GetLocations(), |
| 604 | /* is64bit */ true, |
| 605 | IsR6(), |
| 606 | IsR2OrNewer(), |
| 607 | GetAssembler()); |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | enum RotationDirection { |
| 611 | kRotateRight, |
| 612 | kRotateLeft, |
| 613 | }; |
| 614 | |
| 615 | static void GenRotate(HInvoke* invoke, |
| 616 | Primitive::Type type, |
| 617 | bool isR2OrNewer, |
| 618 | RotationDirection direction, |
| 619 | MipsAssembler* assembler) { |
| 620 | DCHECK(type == Primitive::kPrimInt || type == Primitive::kPrimLong); |
| 621 | |
| 622 | LocationSummary* locations = invoke->GetLocations(); |
| 623 | if (invoke->InputAt(1)->IsIntConstant()) { |
| 624 | int32_t shift = static_cast<int32_t>(invoke->InputAt(1)->AsIntConstant()->GetValue()); |
| 625 | if (type == Primitive::kPrimInt) { |
| 626 | Register in = locations->InAt(0).AsRegister<Register>(); |
| 627 | Register out = locations->Out().AsRegister<Register>(); |
| 628 | |
| 629 | shift &= 0x1f; |
| 630 | if (direction == kRotateLeft) { |
| 631 | shift = (32 - shift) & 0x1F; |
| 632 | } |
| 633 | |
| 634 | if (isR2OrNewer) { |
| 635 | if ((shift != 0) || (out != in)) { |
| 636 | __ Rotr(out, in, shift); |
| 637 | } |
| 638 | } else { |
| 639 | if (shift == 0) { |
| 640 | if (out != in) { |
| 641 | __ Move(out, in); |
| 642 | } |
| 643 | } else { |
| 644 | __ Srl(AT, in, shift); |
| 645 | __ Sll(out, in, 32 - shift); |
| 646 | __ Or(out, out, AT); |
| 647 | } |
| 648 | } |
| 649 | } else { // Primitive::kPrimLong |
| 650 | Register in_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 651 | Register in_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 652 | Register out_lo = locations->Out().AsRegisterPairLow<Register>(); |
| 653 | Register out_hi = locations->Out().AsRegisterPairHigh<Register>(); |
| 654 | |
| 655 | shift &= 0x3f; |
| 656 | if (direction == kRotateLeft) { |
| 657 | shift = (64 - shift) & 0x3F; |
| 658 | } |
| 659 | |
| 660 | if (shift == 0) { |
| 661 | __ Move(out_lo, in_lo); |
| 662 | __ Move(out_hi, in_hi); |
| 663 | } else if (shift == 32) { |
| 664 | __ Move(out_lo, in_hi); |
| 665 | __ Move(out_hi, in_lo); |
| 666 | } else if (shift < 32) { |
| 667 | __ Srl(AT, in_lo, shift); |
| 668 | __ Sll(out_lo, in_hi, 32 - shift); |
| 669 | __ Or(out_lo, out_lo, AT); |
| 670 | __ Srl(AT, in_hi, shift); |
| 671 | __ Sll(out_hi, in_lo, 32 - shift); |
| 672 | __ Or(out_hi, out_hi, AT); |
| 673 | } else { |
| 674 | __ Sll(AT, in_lo, 64 - shift); |
| 675 | __ Srl(out_lo, in_hi, shift - 32); |
| 676 | __ Or(out_lo, out_lo, AT); |
| 677 | __ Sll(AT, in_hi, 64 - shift); |
| 678 | __ Srl(out_hi, in_lo, shift - 32); |
| 679 | __ Or(out_hi, out_hi, AT); |
| 680 | } |
| 681 | } |
| 682 | } else { // !invoke->InputAt(1)->IsIntConstant() |
| 683 | Register shamt = locations->InAt(1).AsRegister<Register>(); |
| 684 | if (type == Primitive::kPrimInt) { |
| 685 | Register in = locations->InAt(0).AsRegister<Register>(); |
| 686 | Register out = locations->Out().AsRegister<Register>(); |
| 687 | |
| 688 | if (isR2OrNewer) { |
| 689 | if (direction == kRotateRight) { |
| 690 | __ Rotrv(out, in, shamt); |
| 691 | } else { |
| 692 | // negu tmp, shamt |
| 693 | __ Subu(TMP, ZERO, shamt); |
| 694 | __ Rotrv(out, in, TMP); |
| 695 | } |
| 696 | } else { |
| 697 | if (direction == kRotateRight) { |
| 698 | __ Srlv(AT, in, shamt); |
| 699 | __ Subu(TMP, ZERO, shamt); |
| 700 | __ Sllv(out, in, TMP); |
| 701 | __ Or(out, out, AT); |
| 702 | } else { |
| 703 | __ Sllv(AT, in, shamt); |
| 704 | __ Subu(TMP, ZERO, shamt); |
| 705 | __ Srlv(out, in, TMP); |
| 706 | __ Or(out, out, AT); |
| 707 | } |
| 708 | } |
| 709 | } else { // Primitive::kPrimLong |
| 710 | Register in_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 711 | Register in_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 712 | Register out_lo = locations->Out().AsRegisterPairLow<Register>(); |
| 713 | Register out_hi = locations->Out().AsRegisterPairHigh<Register>(); |
| 714 | |
| 715 | MipsLabel done; |
| 716 | |
| 717 | if (direction == kRotateRight) { |
| 718 | __ Nor(TMP, ZERO, shamt); |
| 719 | __ Srlv(AT, in_lo, shamt); |
| 720 | __ Sll(out_lo, in_hi, 1); |
| 721 | __ Sllv(out_lo, out_lo, TMP); |
| 722 | __ Or(out_lo, out_lo, AT); |
| 723 | __ Srlv(AT, in_hi, shamt); |
| 724 | __ Sll(out_hi, in_lo, 1); |
| 725 | __ Sllv(out_hi, out_hi, TMP); |
| 726 | __ Or(out_hi, out_hi, AT); |
| 727 | } else { |
| 728 | __ Nor(TMP, ZERO, shamt); |
| 729 | __ Sllv(AT, in_lo, shamt); |
| 730 | __ Srl(out_lo, in_hi, 1); |
| 731 | __ Srlv(out_lo, out_lo, TMP); |
| 732 | __ Or(out_lo, out_lo, AT); |
| 733 | __ Sllv(AT, in_hi, shamt); |
| 734 | __ Srl(out_hi, in_lo, 1); |
| 735 | __ Srlv(out_hi, out_hi, TMP); |
| 736 | __ Or(out_hi, out_hi, AT); |
| 737 | } |
| 738 | |
| 739 | __ Andi(TMP, shamt, 32); |
| 740 | __ Beqz(TMP, &done); |
| 741 | __ Move(TMP, out_hi); |
| 742 | __ Move(out_hi, out_lo); |
| 743 | __ Move(out_lo, TMP); |
| 744 | |
| 745 | __ Bind(&done); |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | // int java.lang.Integer.rotateRight(int i, int distance) |
| 751 | void IntrinsicLocationsBuilderMIPS::VisitIntegerRotateRight(HInvoke* invoke) { |
| 752 | LocationSummary* locations = new (arena_) LocationSummary(invoke, |
| 753 | LocationSummary::kNoCall, |
| 754 | kIntrinsified); |
| 755 | locations->SetInAt(0, Location::RequiresRegister()); |
| 756 | locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1))); |
| 757 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 758 | } |
| 759 | |
| 760 | void IntrinsicCodeGeneratorMIPS::VisitIntegerRotateRight(HInvoke* invoke) { |
| 761 | GenRotate(invoke, Primitive::kPrimInt, IsR2OrNewer(), kRotateRight, GetAssembler()); |
| 762 | } |
| 763 | |
| 764 | // long java.lang.Long.rotateRight(long i, int distance) |
| 765 | void IntrinsicLocationsBuilderMIPS::VisitLongRotateRight(HInvoke* invoke) { |
| 766 | LocationSummary* locations = new (arena_) LocationSummary(invoke, |
| 767 | LocationSummary::kNoCall, |
| 768 | kIntrinsified); |
| 769 | locations->SetInAt(0, Location::RequiresRegister()); |
| 770 | locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1))); |
| 771 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
| 772 | } |
| 773 | |
| 774 | void IntrinsicCodeGeneratorMIPS::VisitLongRotateRight(HInvoke* invoke) { |
| 775 | GenRotate(invoke, Primitive::kPrimLong, IsR2OrNewer(), kRotateRight, GetAssembler()); |
| 776 | } |
| 777 | |
| 778 | // int java.lang.Integer.rotateLeft(int i, int distance) |
| 779 | void IntrinsicLocationsBuilderMIPS::VisitIntegerRotateLeft(HInvoke* invoke) { |
| 780 | LocationSummary* locations = new (arena_) LocationSummary(invoke, |
| 781 | LocationSummary::kNoCall, |
| 782 | kIntrinsified); |
| 783 | locations->SetInAt(0, Location::RequiresRegister()); |
| 784 | locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1))); |
| 785 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 786 | } |
| 787 | |
| 788 | void IntrinsicCodeGeneratorMIPS::VisitIntegerRotateLeft(HInvoke* invoke) { |
| 789 | GenRotate(invoke, Primitive::kPrimInt, IsR2OrNewer(), kRotateLeft, GetAssembler()); |
| 790 | } |
| 791 | |
| 792 | // long java.lang.Long.rotateLeft(long i, int distance) |
| 793 | void IntrinsicLocationsBuilderMIPS::VisitLongRotateLeft(HInvoke* invoke) { |
| 794 | LocationSummary* locations = new (arena_) LocationSummary(invoke, |
| 795 | LocationSummary::kNoCall, |
| 796 | kIntrinsified); |
| 797 | locations->SetInAt(0, Location::RequiresRegister()); |
| 798 | locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1))); |
| 799 | locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap); |
| 800 | } |
| 801 | |
| 802 | void IntrinsicCodeGeneratorMIPS::VisitLongRotateLeft(HInvoke* invoke) { |
| 803 | GenRotate(invoke, Primitive::kPrimLong, IsR2OrNewer(), kRotateLeft, GetAssembler()); |
Chris Larsen | 8682960 | 2015-11-18 12:27:52 -0800 | [diff] [blame] | 804 | } |
| 805 | |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 806 | // int java.lang.Integer.reverse(int) |
| 807 | void IntrinsicLocationsBuilderMIPS::VisitIntegerReverse(HInvoke* invoke) { |
| 808 | CreateIntToIntLocations(arena_, invoke); |
| 809 | } |
| 810 | |
| 811 | void IntrinsicCodeGeneratorMIPS::VisitIntegerReverse(HInvoke* invoke) { |
| 812 | GenReverse(invoke->GetLocations(), |
| 813 | Primitive::kPrimInt, |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 814 | IsR2OrNewer(), |
| 815 | IsR6(), |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 816 | /* reverseBits */ true, |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 817 | GetAssembler()); |
| 818 | } |
| 819 | |
| 820 | // long java.lang.Long.reverse(long) |
| 821 | void IntrinsicLocationsBuilderMIPS::VisitLongReverse(HInvoke* invoke) { |
| 822 | CreateIntToIntLocations(arena_, invoke); |
| 823 | } |
| 824 | |
| 825 | void IntrinsicCodeGeneratorMIPS::VisitLongReverse(HInvoke* invoke) { |
| 826 | GenReverse(invoke->GetLocations(), |
| 827 | Primitive::kPrimLong, |
Chris Larsen | e16ce5a | 2015-11-18 12:30:20 -0800 | [diff] [blame] | 828 | IsR2OrNewer(), |
| 829 | IsR6(), |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 830 | /* reverseBits */ true, |
Chris Larsen | 70014c8 | 2015-11-18 12:26:08 -0800 | [diff] [blame] | 831 | GetAssembler()); |
Chris Larsen | 3f8bf65 | 2015-10-28 10:08:56 -0700 | [diff] [blame] | 832 | } |
| 833 | |
Chris Larsen | b74353a | 2015-11-20 09:07:09 -0800 | [diff] [blame] | 834 | static void CreateFPToFPLocations(ArenaAllocator* arena, HInvoke* invoke) { |
| 835 | LocationSummary* locations = new (arena) LocationSummary(invoke, |
| 836 | LocationSummary::kNoCall, |
| 837 | kIntrinsified); |
| 838 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 839 | locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); |
| 840 | } |
| 841 | |
| 842 | static void MathAbsFP(LocationSummary* locations, bool is64bit, MipsAssembler* assembler) { |
| 843 | FRegister in = locations->InAt(0).AsFpuRegister<FRegister>(); |
| 844 | FRegister out = locations->Out().AsFpuRegister<FRegister>(); |
| 845 | |
| 846 | if (is64bit) { |
| 847 | __ AbsD(out, in); |
| 848 | } else { |
| 849 | __ AbsS(out, in); |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | // double java.lang.Math.abs(double) |
| 854 | void IntrinsicLocationsBuilderMIPS::VisitMathAbsDouble(HInvoke* invoke) { |
| 855 | CreateFPToFPLocations(arena_, invoke); |
| 856 | } |
| 857 | |
| 858 | void IntrinsicCodeGeneratorMIPS::VisitMathAbsDouble(HInvoke* invoke) { |
| 859 | MathAbsFP(invoke->GetLocations(), /* is64bit */ true, GetAssembler()); |
| 860 | } |
| 861 | |
| 862 | // float java.lang.Math.abs(float) |
| 863 | void IntrinsicLocationsBuilderMIPS::VisitMathAbsFloat(HInvoke* invoke) { |
| 864 | CreateFPToFPLocations(arena_, invoke); |
| 865 | } |
| 866 | |
| 867 | void IntrinsicCodeGeneratorMIPS::VisitMathAbsFloat(HInvoke* invoke) { |
| 868 | MathAbsFP(invoke->GetLocations(), /* is64bit */ false, GetAssembler()); |
| 869 | } |
| 870 | |
| 871 | static void GenAbsInteger(LocationSummary* locations, bool is64bit, MipsAssembler* assembler) { |
| 872 | if (is64bit) { |
| 873 | Register in_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 874 | Register in_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 875 | Register out_lo = locations->Out().AsRegisterPairLow<Register>(); |
| 876 | Register out_hi = locations->Out().AsRegisterPairHigh<Register>(); |
| 877 | |
| 878 | // The comments in this section show the analogous operations which would |
| 879 | // be performed if we had 64-bit registers "in", and "out". |
| 880 | // __ Dsra32(AT, in, 31); |
| 881 | __ Sra(AT, in_hi, 31); |
| 882 | // __ Xor(out, in, AT); |
| 883 | __ Xor(TMP, in_lo, AT); |
| 884 | __ Xor(out_hi, in_hi, AT); |
| 885 | // __ Dsubu(out, out, AT); |
| 886 | __ Subu(out_lo, TMP, AT); |
| 887 | __ Sltu(TMP, out_lo, TMP); |
| 888 | __ Addu(out_hi, out_hi, TMP); |
| 889 | } else { |
| 890 | Register in = locations->InAt(0).AsRegister<Register>(); |
| 891 | Register out = locations->Out().AsRegister<Register>(); |
| 892 | |
| 893 | __ Sra(AT, in, 31); |
| 894 | __ Xor(out, in, AT); |
| 895 | __ Subu(out, out, AT); |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | // int java.lang.Math.abs(int) |
| 900 | void IntrinsicLocationsBuilderMIPS::VisitMathAbsInt(HInvoke* invoke) { |
| 901 | CreateIntToIntLocations(arena_, invoke); |
| 902 | } |
| 903 | |
| 904 | void IntrinsicCodeGeneratorMIPS::VisitMathAbsInt(HInvoke* invoke) { |
| 905 | GenAbsInteger(invoke->GetLocations(), /* is64bit */ false, GetAssembler()); |
| 906 | } |
| 907 | |
| 908 | // long java.lang.Math.abs(long) |
| 909 | void IntrinsicLocationsBuilderMIPS::VisitMathAbsLong(HInvoke* invoke) { |
| 910 | CreateIntToIntLocations(arena_, invoke); |
| 911 | } |
| 912 | |
| 913 | void IntrinsicCodeGeneratorMIPS::VisitMathAbsLong(HInvoke* invoke) { |
| 914 | GenAbsInteger(invoke->GetLocations(), /* is64bit */ true, GetAssembler()); |
| 915 | } |
| 916 | |
| 917 | static void GenMinMaxFP(LocationSummary* locations, |
| 918 | bool is_min, |
| 919 | Primitive::Type type, |
| 920 | bool is_R6, |
| 921 | MipsAssembler* assembler) { |
| 922 | FRegister out = locations->Out().AsFpuRegister<FRegister>(); |
| 923 | FRegister a = locations->InAt(0).AsFpuRegister<FRegister>(); |
| 924 | FRegister b = locations->InAt(1).AsFpuRegister<FRegister>(); |
| 925 | |
| 926 | if (is_R6) { |
| 927 | MipsLabel noNaNs; |
| 928 | MipsLabel done; |
| 929 | FRegister ftmp = ((out != a) && (out != b)) ? out : FTMP; |
| 930 | |
| 931 | // When Java computes min/max it prefers a NaN to a number; the |
| 932 | // behavior of MIPSR6 is to prefer numbers to NaNs, i.e., if one of |
| 933 | // the inputs is a NaN and the other is a valid number, the MIPS |
| 934 | // instruction will return the number; Java wants the NaN value |
| 935 | // returned. This is why there is extra logic preceding the use of |
| 936 | // the MIPS min.fmt/max.fmt instructions. If either a, or b holds a |
| 937 | // NaN, return the NaN, otherwise return the min/max. |
| 938 | if (type == Primitive::kPrimDouble) { |
| 939 | __ CmpUnD(FTMP, a, b); |
| 940 | __ Bc1eqz(FTMP, &noNaNs); |
| 941 | |
| 942 | // One of the inputs is a NaN |
| 943 | __ CmpEqD(ftmp, a, a); |
| 944 | // If a == a then b is the NaN, otherwise a is the NaN. |
| 945 | __ SelD(ftmp, a, b); |
| 946 | |
| 947 | if (ftmp != out) { |
| 948 | __ MovD(out, ftmp); |
| 949 | } |
| 950 | |
| 951 | __ B(&done); |
| 952 | |
| 953 | __ Bind(&noNaNs); |
| 954 | |
| 955 | if (is_min) { |
| 956 | __ MinD(out, a, b); |
| 957 | } else { |
| 958 | __ MaxD(out, a, b); |
| 959 | } |
| 960 | } else { |
| 961 | DCHECK_EQ(type, Primitive::kPrimFloat); |
| 962 | __ CmpUnS(FTMP, a, b); |
| 963 | __ Bc1eqz(FTMP, &noNaNs); |
| 964 | |
| 965 | // One of the inputs is a NaN |
| 966 | __ CmpEqS(ftmp, a, a); |
| 967 | // If a == a then b is the NaN, otherwise a is the NaN. |
| 968 | __ SelS(ftmp, a, b); |
| 969 | |
| 970 | if (ftmp != out) { |
| 971 | __ MovS(out, ftmp); |
| 972 | } |
| 973 | |
| 974 | __ B(&done); |
| 975 | |
| 976 | __ Bind(&noNaNs); |
| 977 | |
| 978 | if (is_min) { |
| 979 | __ MinS(out, a, b); |
| 980 | } else { |
| 981 | __ MaxS(out, a, b); |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | __ Bind(&done); |
| 986 | } else { |
| 987 | MipsLabel ordered; |
| 988 | MipsLabel compare; |
| 989 | MipsLabel select; |
| 990 | MipsLabel done; |
| 991 | |
| 992 | if (type == Primitive::kPrimDouble) { |
| 993 | __ CunD(a, b); |
| 994 | } else { |
| 995 | DCHECK_EQ(type, Primitive::kPrimFloat); |
| 996 | __ CunS(a, b); |
| 997 | } |
| 998 | __ Bc1f(&ordered); |
| 999 | |
| 1000 | // a or b (or both) is a NaN. Return one, which is a NaN. |
| 1001 | if (type == Primitive::kPrimDouble) { |
| 1002 | __ CeqD(b, b); |
| 1003 | } else { |
| 1004 | __ CeqS(b, b); |
| 1005 | } |
| 1006 | __ B(&select); |
| 1007 | |
| 1008 | __ Bind(&ordered); |
| 1009 | |
| 1010 | // Neither is a NaN. |
| 1011 | // a == b? (-0.0 compares equal with +0.0) |
| 1012 | // If equal, handle zeroes, else compare further. |
| 1013 | if (type == Primitive::kPrimDouble) { |
| 1014 | __ CeqD(a, b); |
| 1015 | } else { |
| 1016 | __ CeqS(a, b); |
| 1017 | } |
| 1018 | __ Bc1f(&compare); |
| 1019 | |
| 1020 | // a == b either bit for bit or one is -0.0 and the other is +0.0. |
| 1021 | if (type == Primitive::kPrimDouble) { |
| 1022 | __ MoveFromFpuHigh(TMP, a); |
| 1023 | __ MoveFromFpuHigh(AT, b); |
| 1024 | } else { |
| 1025 | __ Mfc1(TMP, a); |
| 1026 | __ Mfc1(AT, b); |
| 1027 | } |
| 1028 | |
| 1029 | if (is_min) { |
| 1030 | // -0.0 prevails over +0.0. |
| 1031 | __ Or(TMP, TMP, AT); |
| 1032 | } else { |
| 1033 | // +0.0 prevails over -0.0. |
| 1034 | __ And(TMP, TMP, AT); |
| 1035 | } |
| 1036 | |
| 1037 | if (type == Primitive::kPrimDouble) { |
| 1038 | __ Mfc1(AT, a); |
| 1039 | __ Mtc1(AT, out); |
| 1040 | __ MoveToFpuHigh(TMP, out); |
| 1041 | } else { |
| 1042 | __ Mtc1(TMP, out); |
| 1043 | } |
| 1044 | __ B(&done); |
| 1045 | |
| 1046 | __ Bind(&compare); |
| 1047 | |
| 1048 | if (type == Primitive::kPrimDouble) { |
| 1049 | if (is_min) { |
| 1050 | // return (a <= b) ? a : b; |
| 1051 | __ ColeD(a, b); |
| 1052 | } else { |
| 1053 | // return (a >= b) ? a : b; |
| 1054 | __ ColeD(b, a); // b <= a |
| 1055 | } |
| 1056 | } else { |
| 1057 | if (is_min) { |
| 1058 | // return (a <= b) ? a : b; |
| 1059 | __ ColeS(a, b); |
| 1060 | } else { |
| 1061 | // return (a >= b) ? a : b; |
| 1062 | __ ColeS(b, a); // b <= a |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | __ Bind(&select); |
| 1067 | |
| 1068 | if (type == Primitive::kPrimDouble) { |
| 1069 | __ MovtD(out, a); |
| 1070 | __ MovfD(out, b); |
| 1071 | } else { |
| 1072 | __ MovtS(out, a); |
| 1073 | __ MovfS(out, b); |
| 1074 | } |
| 1075 | |
| 1076 | __ Bind(&done); |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | static void CreateFPFPToFPLocations(ArenaAllocator* arena, HInvoke* invoke) { |
| 1081 | LocationSummary* locations = new (arena) LocationSummary(invoke, |
| 1082 | LocationSummary::kNoCall, |
| 1083 | kIntrinsified); |
| 1084 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1085 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 1086 | locations->SetOut(Location::RequiresFpuRegister(), Location::kOutputOverlap); |
| 1087 | } |
| 1088 | |
| 1089 | // double java.lang.Math.min(double, double) |
| 1090 | void IntrinsicLocationsBuilderMIPS::VisitMathMinDoubleDouble(HInvoke* invoke) { |
| 1091 | CreateFPFPToFPLocations(arena_, invoke); |
| 1092 | } |
| 1093 | |
| 1094 | void IntrinsicCodeGeneratorMIPS::VisitMathMinDoubleDouble(HInvoke* invoke) { |
| 1095 | GenMinMaxFP(invoke->GetLocations(), |
| 1096 | /* is_min */ true, |
| 1097 | Primitive::kPrimDouble, |
| 1098 | IsR6(), |
| 1099 | GetAssembler()); |
| 1100 | } |
| 1101 | |
| 1102 | // float java.lang.Math.min(float, float) |
| 1103 | void IntrinsicLocationsBuilderMIPS::VisitMathMinFloatFloat(HInvoke* invoke) { |
| 1104 | CreateFPFPToFPLocations(arena_, invoke); |
| 1105 | } |
| 1106 | |
| 1107 | void IntrinsicCodeGeneratorMIPS::VisitMathMinFloatFloat(HInvoke* invoke) { |
| 1108 | GenMinMaxFP(invoke->GetLocations(), |
| 1109 | /* is_min */ true, |
| 1110 | Primitive::kPrimFloat, |
| 1111 | IsR6(), |
| 1112 | GetAssembler()); |
| 1113 | } |
| 1114 | |
| 1115 | // double java.lang.Math.max(double, double) |
| 1116 | void IntrinsicLocationsBuilderMIPS::VisitMathMaxDoubleDouble(HInvoke* invoke) { |
| 1117 | CreateFPFPToFPLocations(arena_, invoke); |
| 1118 | } |
| 1119 | |
| 1120 | void IntrinsicCodeGeneratorMIPS::VisitMathMaxDoubleDouble(HInvoke* invoke) { |
| 1121 | GenMinMaxFP(invoke->GetLocations(), |
| 1122 | /* is_min */ false, |
| 1123 | Primitive::kPrimDouble, |
| 1124 | IsR6(), |
| 1125 | GetAssembler()); |
| 1126 | } |
| 1127 | |
| 1128 | // float java.lang.Math.max(float, float) |
| 1129 | void IntrinsicLocationsBuilderMIPS::VisitMathMaxFloatFloat(HInvoke* invoke) { |
| 1130 | CreateFPFPToFPLocations(arena_, invoke); |
| 1131 | } |
| 1132 | |
| 1133 | void IntrinsicCodeGeneratorMIPS::VisitMathMaxFloatFloat(HInvoke* invoke) { |
| 1134 | GenMinMaxFP(invoke->GetLocations(), |
| 1135 | /* is_min */ false, |
| 1136 | Primitive::kPrimFloat, |
| 1137 | IsR6(), |
| 1138 | GetAssembler()); |
| 1139 | } |
| 1140 | |
| 1141 | static void CreateIntIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) { |
| 1142 | LocationSummary* locations = new (arena) LocationSummary(invoke, |
| 1143 | LocationSummary::kNoCall, |
| 1144 | kIntrinsified); |
| 1145 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1146 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1147 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 1148 | } |
| 1149 | |
| 1150 | static void GenMinMax(LocationSummary* locations, |
| 1151 | bool is_min, |
| 1152 | Primitive::Type type, |
| 1153 | bool is_R6, |
| 1154 | MipsAssembler* assembler) { |
| 1155 | if (is_R6) { |
| 1156 | // Some architectures, such as ARM and MIPS (prior to r6), have a |
| 1157 | // conditional move instruction which only changes the target |
| 1158 | // (output) register if the condition is true (MIPS prior to r6 had |
| 1159 | // MOVF, MOVT, MOVN, and MOVZ). The SELEQZ and SELNEZ instructions |
| 1160 | // always change the target (output) register. If the condition is |
| 1161 | // true the output register gets the contents of the "rs" register; |
| 1162 | // otherwise, the output register is set to zero. One consequence |
| 1163 | // of this is that to implement something like "rd = c==0 ? rs : rt" |
| 1164 | // MIPS64r6 needs to use a pair of SELEQZ/SELNEZ instructions. |
| 1165 | // After executing this pair of instructions one of the output |
| 1166 | // registers from the pair will necessarily contain zero. Then the |
| 1167 | // code ORs the output registers from the SELEQZ/SELNEZ instructions |
| 1168 | // to get the final result. |
| 1169 | // |
| 1170 | // The initial test to see if the output register is same as the |
| 1171 | // first input register is needed to make sure that value in the |
| 1172 | // first input register isn't clobbered before we've finished |
| 1173 | // computing the output value. The logic in the corresponding else |
| 1174 | // clause performs the same task but makes sure the second input |
| 1175 | // register isn't clobbered in the event that it's the same register |
| 1176 | // as the output register; the else clause also handles the case |
| 1177 | // where the output register is distinct from both the first, and the |
| 1178 | // second input registers. |
| 1179 | if (type == Primitive::kPrimLong) { |
| 1180 | Register a_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 1181 | Register a_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 1182 | Register b_lo = locations->InAt(1).AsRegisterPairLow<Register>(); |
| 1183 | Register b_hi = locations->InAt(1).AsRegisterPairHigh<Register>(); |
| 1184 | Register out_lo = locations->Out().AsRegisterPairLow<Register>(); |
| 1185 | Register out_hi = locations->Out().AsRegisterPairHigh<Register>(); |
| 1186 | |
| 1187 | MipsLabel compare_done; |
| 1188 | |
| 1189 | if (a_lo == b_lo) { |
| 1190 | if (out_lo != a_lo) { |
| 1191 | __ Move(out_lo, a_lo); |
| 1192 | __ Move(out_hi, a_hi); |
| 1193 | } |
| 1194 | } else { |
| 1195 | __ Slt(TMP, b_hi, a_hi); |
| 1196 | __ Bne(b_hi, a_hi, &compare_done); |
| 1197 | |
| 1198 | __ Sltu(TMP, b_lo, a_lo); |
| 1199 | |
| 1200 | __ Bind(&compare_done); |
| 1201 | |
| 1202 | if (is_min) { |
| 1203 | __ Seleqz(AT, a_lo, TMP); |
| 1204 | __ Selnez(out_lo, b_lo, TMP); // Safe even if out_lo == a_lo/b_lo |
| 1205 | // because at this point we're |
| 1206 | // done using a_lo/b_lo. |
| 1207 | } else { |
| 1208 | __ Selnez(AT, a_lo, TMP); |
| 1209 | __ Seleqz(out_lo, b_lo, TMP); // ditto |
| 1210 | } |
| 1211 | __ Or(out_lo, out_lo, AT); |
| 1212 | if (is_min) { |
| 1213 | __ Seleqz(AT, a_hi, TMP); |
| 1214 | __ Selnez(out_hi, b_hi, TMP); // ditto but for out_hi & a_hi/b_hi |
| 1215 | } else { |
| 1216 | __ Selnez(AT, a_hi, TMP); |
| 1217 | __ Seleqz(out_hi, b_hi, TMP); // ditto but for out_hi & a_hi/b_hi |
| 1218 | } |
| 1219 | __ Or(out_hi, out_hi, AT); |
| 1220 | } |
| 1221 | } else { |
| 1222 | DCHECK_EQ(type, Primitive::kPrimInt); |
| 1223 | Register a = locations->InAt(0).AsRegister<Register>(); |
| 1224 | Register b = locations->InAt(1).AsRegister<Register>(); |
| 1225 | Register out = locations->Out().AsRegister<Register>(); |
| 1226 | |
| 1227 | if (a == b) { |
| 1228 | if (out != a) { |
| 1229 | __ Move(out, a); |
| 1230 | } |
| 1231 | } else { |
| 1232 | __ Slt(AT, b, a); |
| 1233 | if (is_min) { |
| 1234 | __ Seleqz(TMP, a, AT); |
| 1235 | __ Selnez(AT, b, AT); |
| 1236 | } else { |
| 1237 | __ Selnez(TMP, a, AT); |
| 1238 | __ Seleqz(AT, b, AT); |
| 1239 | } |
| 1240 | __ Or(out, TMP, AT); |
| 1241 | } |
| 1242 | } |
| 1243 | } else { |
| 1244 | if (type == Primitive::kPrimLong) { |
| 1245 | Register a_lo = locations->InAt(0).AsRegisterPairLow<Register>(); |
| 1246 | Register a_hi = locations->InAt(0).AsRegisterPairHigh<Register>(); |
| 1247 | Register b_lo = locations->InAt(1).AsRegisterPairLow<Register>(); |
| 1248 | Register b_hi = locations->InAt(1).AsRegisterPairHigh<Register>(); |
| 1249 | Register out_lo = locations->Out().AsRegisterPairLow<Register>(); |
| 1250 | Register out_hi = locations->Out().AsRegisterPairHigh<Register>(); |
| 1251 | |
| 1252 | MipsLabel compare_done; |
| 1253 | |
| 1254 | if (a_lo == b_lo) { |
| 1255 | if (out_lo != a_lo) { |
| 1256 | __ Move(out_lo, a_lo); |
| 1257 | __ Move(out_hi, a_hi); |
| 1258 | } |
| 1259 | } else { |
| 1260 | __ Slt(TMP, a_hi, b_hi); |
| 1261 | __ Bne(a_hi, b_hi, &compare_done); |
| 1262 | |
| 1263 | __ Sltu(TMP, a_lo, b_lo); |
| 1264 | |
| 1265 | __ Bind(&compare_done); |
| 1266 | |
| 1267 | if (is_min) { |
| 1268 | if (out_lo != a_lo) { |
| 1269 | __ Movn(out_hi, a_hi, TMP); |
| 1270 | __ Movn(out_lo, a_lo, TMP); |
| 1271 | } |
| 1272 | if (out_lo != b_lo) { |
| 1273 | __ Movz(out_hi, b_hi, TMP); |
| 1274 | __ Movz(out_lo, b_lo, TMP); |
| 1275 | } |
| 1276 | } else { |
| 1277 | if (out_lo != a_lo) { |
| 1278 | __ Movz(out_hi, a_hi, TMP); |
| 1279 | __ Movz(out_lo, a_lo, TMP); |
| 1280 | } |
| 1281 | if (out_lo != b_lo) { |
| 1282 | __ Movn(out_hi, b_hi, TMP); |
| 1283 | __ Movn(out_lo, b_lo, TMP); |
| 1284 | } |
| 1285 | } |
| 1286 | } |
| 1287 | } else { |
| 1288 | DCHECK_EQ(type, Primitive::kPrimInt); |
| 1289 | Register a = locations->InAt(0).AsRegister<Register>(); |
| 1290 | Register b = locations->InAt(1).AsRegister<Register>(); |
| 1291 | Register out = locations->Out().AsRegister<Register>(); |
| 1292 | |
| 1293 | if (a == b) { |
| 1294 | if (out != a) { |
| 1295 | __ Move(out, a); |
| 1296 | } |
| 1297 | } else { |
| 1298 | __ Slt(AT, a, b); |
| 1299 | if (is_min) { |
| 1300 | if (out != a) { |
| 1301 | __ Movn(out, a, AT); |
| 1302 | } |
| 1303 | if (out != b) { |
| 1304 | __ Movz(out, b, AT); |
| 1305 | } |
| 1306 | } else { |
| 1307 | if (out != a) { |
| 1308 | __ Movz(out, a, AT); |
| 1309 | } |
| 1310 | if (out != b) { |
| 1311 | __ Movn(out, b, AT); |
| 1312 | } |
| 1313 | } |
| 1314 | } |
| 1315 | } |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | // int java.lang.Math.min(int, int) |
| 1320 | void IntrinsicLocationsBuilderMIPS::VisitMathMinIntInt(HInvoke* invoke) { |
| 1321 | CreateIntIntToIntLocations(arena_, invoke); |
| 1322 | } |
| 1323 | |
| 1324 | void IntrinsicCodeGeneratorMIPS::VisitMathMinIntInt(HInvoke* invoke) { |
| 1325 | GenMinMax(invoke->GetLocations(), |
| 1326 | /* is_min */ true, |
| 1327 | Primitive::kPrimInt, |
| 1328 | IsR6(), |
| 1329 | GetAssembler()); |
| 1330 | } |
| 1331 | |
| 1332 | // long java.lang.Math.min(long, long) |
| 1333 | void IntrinsicLocationsBuilderMIPS::VisitMathMinLongLong(HInvoke* invoke) { |
| 1334 | CreateIntIntToIntLocations(arena_, invoke); |
| 1335 | } |
| 1336 | |
| 1337 | void IntrinsicCodeGeneratorMIPS::VisitMathMinLongLong(HInvoke* invoke) { |
| 1338 | GenMinMax(invoke->GetLocations(), |
| 1339 | /* is_min */ true, |
| 1340 | Primitive::kPrimLong, |
| 1341 | IsR6(), |
| 1342 | GetAssembler()); |
| 1343 | } |
| 1344 | |
| 1345 | // int java.lang.Math.max(int, int) |
| 1346 | void IntrinsicLocationsBuilderMIPS::VisitMathMaxIntInt(HInvoke* invoke) { |
| 1347 | CreateIntIntToIntLocations(arena_, invoke); |
| 1348 | } |
| 1349 | |
| 1350 | void IntrinsicCodeGeneratorMIPS::VisitMathMaxIntInt(HInvoke* invoke) { |
| 1351 | GenMinMax(invoke->GetLocations(), |
| 1352 | /* is_min */ false, |
| 1353 | Primitive::kPrimInt, |
| 1354 | IsR6(), |
| 1355 | GetAssembler()); |
| 1356 | } |
| 1357 | |
| 1358 | // long java.lang.Math.max(long, long) |
| 1359 | void IntrinsicLocationsBuilderMIPS::VisitMathMaxLongLong(HInvoke* invoke) { |
| 1360 | CreateIntIntToIntLocations(arena_, invoke); |
| 1361 | } |
| 1362 | |
| 1363 | void IntrinsicCodeGeneratorMIPS::VisitMathMaxLongLong(HInvoke* invoke) { |
| 1364 | GenMinMax(invoke->GetLocations(), |
| 1365 | /* is_min */ false, |
| 1366 | Primitive::kPrimLong, |
| 1367 | IsR6(), |
| 1368 | GetAssembler()); |
| 1369 | } |
| 1370 | |
| 1371 | // double java.lang.Math.sqrt(double) |
| 1372 | void IntrinsicLocationsBuilderMIPS::VisitMathSqrt(HInvoke* invoke) { |
| 1373 | CreateFPToFPLocations(arena_, invoke); |
| 1374 | } |
| 1375 | |
| 1376 | void IntrinsicCodeGeneratorMIPS::VisitMathSqrt(HInvoke* invoke) { |
| 1377 | LocationSummary* locations = invoke->GetLocations(); |
| 1378 | MipsAssembler* assembler = GetAssembler(); |
| 1379 | FRegister in = locations->InAt(0).AsFpuRegister<FRegister>(); |
| 1380 | FRegister out = locations->Out().AsFpuRegister<FRegister>(); |
| 1381 | |
| 1382 | __ SqrtD(out, in); |
| 1383 | } |
| 1384 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 1385 | // byte libcore.io.Memory.peekByte(long address) |
| 1386 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPeekByte(HInvoke* invoke) { |
| 1387 | CreateIntToIntLocations(arena_, invoke); |
| 1388 | } |
| 1389 | |
| 1390 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPeekByte(HInvoke* invoke) { |
| 1391 | MipsAssembler* assembler = GetAssembler(); |
| 1392 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1393 | Register out = invoke->GetLocations()->Out().AsRegister<Register>(); |
| 1394 | |
| 1395 | __ Lb(out, adr, 0); |
| 1396 | } |
| 1397 | |
| 1398 | // short libcore.io.Memory.peekShort(long address) |
| 1399 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPeekShortNative(HInvoke* invoke) { |
| 1400 | CreateIntToIntLocations(arena_, invoke); |
| 1401 | } |
| 1402 | |
| 1403 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPeekShortNative(HInvoke* invoke) { |
| 1404 | MipsAssembler* assembler = GetAssembler(); |
| 1405 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1406 | Register out = invoke->GetLocations()->Out().AsRegister<Register>(); |
| 1407 | |
| 1408 | if (IsR6()) { |
| 1409 | __ Lh(out, adr, 0); |
| 1410 | } else if (IsR2OrNewer()) { |
| 1411 | // Unlike for words, there are no lhl/lhr instructions to load |
| 1412 | // unaligned halfwords so the code loads individual bytes, in case |
| 1413 | // the address isn't halfword-aligned, and assembles them into a |
| 1414 | // signed halfword. |
| 1415 | __ Lb(AT, adr, 1); // This byte must be sign-extended. |
| 1416 | __ Lb(out, adr, 0); // This byte can be either sign-extended, or |
| 1417 | // zero-extended because the following |
| 1418 | // instruction overwrites the sign bits. |
| 1419 | __ Ins(out, AT, 8, 24); |
| 1420 | } else { |
| 1421 | __ Lbu(AT, adr, 0); // This byte must be zero-extended. If it's not |
| 1422 | // the "or" instruction below will destroy the upper |
| 1423 | // 24 bits of the final result. |
| 1424 | __ Lb(out, adr, 1); // This byte must be sign-extended. |
| 1425 | __ Sll(out, out, 8); |
| 1426 | __ Or(out, out, AT); |
| 1427 | } |
| 1428 | } |
| 1429 | |
| 1430 | // int libcore.io.Memory.peekInt(long address) |
| 1431 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPeekIntNative(HInvoke* invoke) { |
| 1432 | CreateIntToIntLocations(arena_, invoke, Location::kOutputOverlap); |
| 1433 | } |
| 1434 | |
| 1435 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPeekIntNative(HInvoke* invoke) { |
| 1436 | MipsAssembler* assembler = GetAssembler(); |
| 1437 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1438 | Register out = invoke->GetLocations()->Out().AsRegister<Register>(); |
| 1439 | |
| 1440 | if (IsR6()) { |
| 1441 | __ Lw(out, adr, 0); |
| 1442 | } else { |
| 1443 | __ Lwr(out, adr, 0); |
| 1444 | __ Lwl(out, adr, 3); |
| 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | // long libcore.io.Memory.peekLong(long address) |
| 1449 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPeekLongNative(HInvoke* invoke) { |
| 1450 | CreateIntToIntLocations(arena_, invoke, Location::kOutputOverlap); |
| 1451 | } |
| 1452 | |
| 1453 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPeekLongNative(HInvoke* invoke) { |
| 1454 | MipsAssembler* assembler = GetAssembler(); |
| 1455 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1456 | Register out_lo = invoke->GetLocations()->Out().AsRegisterPairLow<Register>(); |
| 1457 | Register out_hi = invoke->GetLocations()->Out().AsRegisterPairHigh<Register>(); |
| 1458 | |
| 1459 | if (IsR6()) { |
| 1460 | __ Lw(out_lo, adr, 0); |
| 1461 | __ Lw(out_hi, adr, 4); |
| 1462 | } else { |
| 1463 | __ Lwr(out_lo, adr, 0); |
| 1464 | __ Lwl(out_lo, adr, 3); |
| 1465 | __ Lwr(out_hi, adr, 4); |
| 1466 | __ Lwl(out_hi, adr, 7); |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | static void CreateIntIntToVoidLocations(ArenaAllocator* arena, HInvoke* invoke) { |
| 1471 | LocationSummary* locations = new (arena) LocationSummary(invoke, |
| 1472 | LocationSummary::kNoCall, |
| 1473 | kIntrinsified); |
| 1474 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1475 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1476 | } |
| 1477 | |
| 1478 | // void libcore.io.Memory.pokeByte(long address, byte value) |
| 1479 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPokeByte(HInvoke* invoke) { |
| 1480 | CreateIntIntToVoidLocations(arena_, invoke); |
| 1481 | } |
| 1482 | |
| 1483 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPokeByte(HInvoke* invoke) { |
| 1484 | MipsAssembler* assembler = GetAssembler(); |
| 1485 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1486 | Register val = invoke->GetLocations()->InAt(1).AsRegister<Register>(); |
| 1487 | |
| 1488 | __ Sb(val, adr, 0); |
| 1489 | } |
| 1490 | |
| 1491 | // void libcore.io.Memory.pokeShort(long address, short value) |
| 1492 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPokeShortNative(HInvoke* invoke) { |
| 1493 | CreateIntIntToVoidLocations(arena_, invoke); |
| 1494 | } |
| 1495 | |
| 1496 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPokeShortNative(HInvoke* invoke) { |
| 1497 | MipsAssembler* assembler = GetAssembler(); |
| 1498 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1499 | Register val = invoke->GetLocations()->InAt(1).AsRegister<Register>(); |
| 1500 | |
| 1501 | if (IsR6()) { |
| 1502 | __ Sh(val, adr, 0); |
| 1503 | } else { |
| 1504 | // Unlike for words, there are no shl/shr instructions to store |
| 1505 | // unaligned halfwords so the code stores individual bytes, in case |
| 1506 | // the address isn't halfword-aligned. |
| 1507 | __ Sb(val, adr, 0); |
| 1508 | __ Srl(AT, val, 8); |
| 1509 | __ Sb(AT, adr, 1); |
| 1510 | } |
| 1511 | } |
| 1512 | |
| 1513 | // void libcore.io.Memory.pokeInt(long address, int value) |
| 1514 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPokeIntNative(HInvoke* invoke) { |
| 1515 | CreateIntIntToVoidLocations(arena_, invoke); |
| 1516 | } |
| 1517 | |
| 1518 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPokeIntNative(HInvoke* invoke) { |
| 1519 | MipsAssembler* assembler = GetAssembler(); |
| 1520 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1521 | Register val = invoke->GetLocations()->InAt(1).AsRegister<Register>(); |
| 1522 | |
| 1523 | if (IsR6()) { |
| 1524 | __ Sw(val, adr, 0); |
| 1525 | } else { |
| 1526 | __ Swr(val, adr, 0); |
| 1527 | __ Swl(val, adr, 3); |
| 1528 | } |
| 1529 | } |
| 1530 | |
| 1531 | // void libcore.io.Memory.pokeLong(long address, long value) |
| 1532 | void IntrinsicLocationsBuilderMIPS::VisitMemoryPokeLongNative(HInvoke* invoke) { |
| 1533 | CreateIntIntToVoidLocations(arena_, invoke); |
| 1534 | } |
| 1535 | |
| 1536 | void IntrinsicCodeGeneratorMIPS::VisitMemoryPokeLongNative(HInvoke* invoke) { |
| 1537 | MipsAssembler* assembler = GetAssembler(); |
| 1538 | Register adr = invoke->GetLocations()->InAt(0).AsRegisterPairLow<Register>(); |
| 1539 | Register val_lo = invoke->GetLocations()->InAt(1).AsRegisterPairLow<Register>(); |
| 1540 | Register val_hi = invoke->GetLocations()->InAt(1).AsRegisterPairHigh<Register>(); |
| 1541 | |
| 1542 | if (IsR6()) { |
| 1543 | __ Sw(val_lo, adr, 0); |
| 1544 | __ Sw(val_hi, adr, 4); |
| 1545 | } else { |
| 1546 | __ Swr(val_lo, adr, 0); |
| 1547 | __ Swl(val_lo, adr, 3); |
| 1548 | __ Swr(val_hi, adr, 4); |
| 1549 | __ Swl(val_hi, adr, 7); |
| 1550 | } |
| 1551 | } |
| 1552 | |
| 1553 | // char java.lang.String.charAt(int index) |
| 1554 | void IntrinsicLocationsBuilderMIPS::VisitStringCharAt(HInvoke* invoke) { |
| 1555 | LocationSummary* locations = new (arena_) LocationSummary(invoke, |
| 1556 | LocationSummary::kCallOnSlowPath, |
| 1557 | kIntrinsified); |
| 1558 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1559 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1560 | locations->SetOut(Location::SameAsFirstInput()); |
| 1561 | } |
| 1562 | |
| 1563 | void IntrinsicCodeGeneratorMIPS::VisitStringCharAt(HInvoke* invoke) { |
| 1564 | LocationSummary* locations = invoke->GetLocations(); |
| 1565 | MipsAssembler* assembler = GetAssembler(); |
| 1566 | |
| 1567 | // Location of reference to data array |
| 1568 | const int32_t value_offset = mirror::String::ValueOffset().Int32Value(); |
| 1569 | // Location of count |
| 1570 | const int32_t count_offset = mirror::String::CountOffset().Int32Value(); |
| 1571 | |
| 1572 | Register obj = locations->InAt(0).AsRegister<Register>(); |
| 1573 | Register idx = locations->InAt(1).AsRegister<Register>(); |
| 1574 | Register out = locations->Out().AsRegister<Register>(); |
| 1575 | |
| 1576 | // TODO: Maybe we can support range check elimination. Overall, |
| 1577 | // though, I think it's not worth the cost. |
| 1578 | // TODO: For simplicity, the index parameter is requested in a |
| 1579 | // register, so different from Quick we will not optimize the |
| 1580 | // code for constants (which would save a register). |
| 1581 | |
| 1582 | SlowPathCodeMIPS* slow_path = new (GetAllocator()) IntrinsicSlowPathMIPS(invoke); |
| 1583 | codegen_->AddSlowPath(slow_path); |
| 1584 | |
| 1585 | // Load the string size |
| 1586 | __ Lw(TMP, obj, count_offset); |
| 1587 | codegen_->MaybeRecordImplicitNullCheck(invoke); |
| 1588 | // Revert to slow path if idx is too large, or negative |
| 1589 | __ Bgeu(idx, TMP, slow_path->GetEntryLabel()); |
| 1590 | |
| 1591 | // out = obj[2*idx]. |
| 1592 | __ Sll(TMP, idx, 1); // idx * 2 |
| 1593 | __ Addu(TMP, TMP, obj); // Address of char at location idx |
| 1594 | __ Lhu(out, TMP, value_offset); // Load char at location idx |
| 1595 | |
| 1596 | __ Bind(slow_path->GetExitLabel()); |
| 1597 | } |
| 1598 | |
Chris Larsen | 16ba2b4 | 2015-11-02 10:58:31 -0800 | [diff] [blame] | 1599 | // boolean java.lang.String.equals(Object anObject) |
| 1600 | void IntrinsicLocationsBuilderMIPS::VisitStringEquals(HInvoke* invoke) { |
| 1601 | LocationSummary* locations = new (arena_) LocationSummary(invoke, |
| 1602 | LocationSummary::kNoCall, |
| 1603 | kIntrinsified); |
| 1604 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1605 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1606 | locations->SetOut(Location::RequiresRegister()); |
| 1607 | |
| 1608 | // Temporary registers to store lengths of strings and for calculations. |
| 1609 | locations->AddTemp(Location::RequiresRegister()); |
| 1610 | locations->AddTemp(Location::RequiresRegister()); |
| 1611 | locations->AddTemp(Location::RequiresRegister()); |
| 1612 | } |
| 1613 | |
| 1614 | void IntrinsicCodeGeneratorMIPS::VisitStringEquals(HInvoke* invoke) { |
| 1615 | MipsAssembler* assembler = GetAssembler(); |
| 1616 | LocationSummary* locations = invoke->GetLocations(); |
| 1617 | |
| 1618 | Register str = locations->InAt(0).AsRegister<Register>(); |
| 1619 | Register arg = locations->InAt(1).AsRegister<Register>(); |
| 1620 | Register out = locations->Out().AsRegister<Register>(); |
| 1621 | |
| 1622 | Register temp1 = locations->GetTemp(0).AsRegister<Register>(); |
| 1623 | Register temp2 = locations->GetTemp(1).AsRegister<Register>(); |
| 1624 | Register temp3 = locations->GetTemp(2).AsRegister<Register>(); |
| 1625 | |
| 1626 | MipsLabel loop; |
| 1627 | MipsLabel end; |
| 1628 | MipsLabel return_true; |
| 1629 | MipsLabel return_false; |
| 1630 | |
| 1631 | // Get offsets of count, value, and class fields within a string object. |
| 1632 | const uint32_t count_offset = mirror::String::CountOffset().Uint32Value(); |
| 1633 | const uint32_t value_offset = mirror::String::ValueOffset().Uint32Value(); |
| 1634 | const uint32_t class_offset = mirror::Object::ClassOffset().Uint32Value(); |
| 1635 | |
| 1636 | // Note that the null check must have been done earlier. |
| 1637 | DCHECK(!invoke->CanDoImplicitNullCheckOn(invoke->InputAt(0))); |
| 1638 | |
| 1639 | // If the register containing the pointer to "this", and the register |
| 1640 | // containing the pointer to "anObject" are the same register then |
| 1641 | // "this", and "anObject" are the same object and we can |
| 1642 | // short-circuit the logic to a true result. |
| 1643 | if (str == arg) { |
| 1644 | __ LoadConst32(out, 1); |
| 1645 | return; |
| 1646 | } |
| 1647 | |
| 1648 | // Check if input is null, return false if it is. |
| 1649 | __ Beqz(arg, &return_false); |
| 1650 | |
| 1651 | // Reference equality check, return true if same reference. |
| 1652 | __ Beq(str, arg, &return_true); |
| 1653 | |
| 1654 | // Instanceof check for the argument by comparing class fields. |
| 1655 | // All string objects must have the same type since String cannot be subclassed. |
| 1656 | // Receiver must be a string object, so its class field is equal to all strings' class fields. |
| 1657 | // If the argument is a string object, its class field must be equal to receiver's class field. |
| 1658 | __ Lw(temp1, str, class_offset); |
| 1659 | __ Lw(temp2, arg, class_offset); |
| 1660 | __ Bne(temp1, temp2, &return_false); |
| 1661 | |
| 1662 | // Load lengths of this and argument strings. |
| 1663 | __ Lw(temp1, str, count_offset); |
| 1664 | __ Lw(temp2, arg, count_offset); |
| 1665 | // Check if lengths are equal, return false if they're not. |
| 1666 | __ Bne(temp1, temp2, &return_false); |
| 1667 | // Return true if both strings are empty. |
| 1668 | __ Beqz(temp1, &return_true); |
| 1669 | |
| 1670 | // Don't overwrite input registers |
| 1671 | __ Move(TMP, str); |
| 1672 | __ Move(temp3, arg); |
| 1673 | |
| 1674 | // Assertions that must hold in order to compare strings 2 characters at a time. |
| 1675 | DCHECK_ALIGNED(value_offset, 4); |
| 1676 | static_assert(IsAligned<4>(kObjectAlignment), "String of odd length is not zero padded"); |
| 1677 | |
| 1678 | // Loop to compare strings 2 characters at a time starting at the beginning of the string. |
| 1679 | // Ok to do this because strings are zero-padded. |
| 1680 | __ Bind(&loop); |
| 1681 | __ Lw(out, TMP, value_offset); |
| 1682 | __ Lw(temp2, temp3, value_offset); |
| 1683 | __ Bne(out, temp2, &return_false); |
| 1684 | __ Addiu(TMP, TMP, 4); |
| 1685 | __ Addiu(temp3, temp3, 4); |
| 1686 | __ Addiu(temp1, temp1, -2); |
| 1687 | __ Bgtz(temp1, &loop); |
| 1688 | |
| 1689 | // Return true and exit the function. |
| 1690 | // If loop does not result in returning false, we return true. |
| 1691 | __ Bind(&return_true); |
| 1692 | __ LoadConst32(out, 1); |
| 1693 | __ B(&end); |
| 1694 | |
| 1695 | // Return false and exit the function. |
| 1696 | __ Bind(&return_false); |
| 1697 | __ LoadConst32(out, 0); |
| 1698 | __ Bind(&end); |
| 1699 | } |
| 1700 | |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 1701 | // Unimplemented intrinsics. |
| 1702 | |
| 1703 | #define UNIMPLEMENTED_INTRINSIC(Name) \ |
| 1704 | void IntrinsicLocationsBuilderMIPS::Visit ## Name(HInvoke* invoke ATTRIBUTE_UNUSED) { \ |
| 1705 | } \ |
| 1706 | void IntrinsicCodeGeneratorMIPS::Visit ## Name(HInvoke* invoke ATTRIBUTE_UNUSED) { \ |
| 1707 | } |
| 1708 | |
Aart Bik | 3f67e69 | 2016-01-15 14:35:12 -0800 | [diff] [blame] | 1709 | UNIMPLEMENTED_INTRINSIC(IntegerBitCount) |
| 1710 | UNIMPLEMENTED_INTRINSIC(LongBitCount) |
| 1711 | |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 1712 | UNIMPLEMENTED_INTRINSIC(MathCeil) |
| 1713 | UNIMPLEMENTED_INTRINSIC(MathFloor) |
| 1714 | UNIMPLEMENTED_INTRINSIC(MathRint) |
| 1715 | UNIMPLEMENTED_INTRINSIC(MathRoundDouble) |
| 1716 | UNIMPLEMENTED_INTRINSIC(MathRoundFloat) |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 1717 | UNIMPLEMENTED_INTRINSIC(ThreadCurrentThread) |
| 1718 | UNIMPLEMENTED_INTRINSIC(UnsafeGet) |
| 1719 | UNIMPLEMENTED_INTRINSIC(UnsafeGetVolatile) |
| 1720 | UNIMPLEMENTED_INTRINSIC(UnsafeGetLong) |
| 1721 | UNIMPLEMENTED_INTRINSIC(UnsafeGetLongVolatile) |
| 1722 | UNIMPLEMENTED_INTRINSIC(UnsafeGetObject) |
| 1723 | UNIMPLEMENTED_INTRINSIC(UnsafeGetObjectVolatile) |
| 1724 | UNIMPLEMENTED_INTRINSIC(UnsafePut) |
| 1725 | UNIMPLEMENTED_INTRINSIC(UnsafePutOrdered) |
| 1726 | UNIMPLEMENTED_INTRINSIC(UnsafePutVolatile) |
| 1727 | UNIMPLEMENTED_INTRINSIC(UnsafePutObject) |
| 1728 | UNIMPLEMENTED_INTRINSIC(UnsafePutObjectOrdered) |
| 1729 | UNIMPLEMENTED_INTRINSIC(UnsafePutObjectVolatile) |
| 1730 | UNIMPLEMENTED_INTRINSIC(UnsafePutLong) |
| 1731 | UNIMPLEMENTED_INTRINSIC(UnsafePutLongOrdered) |
| 1732 | UNIMPLEMENTED_INTRINSIC(UnsafePutLongVolatile) |
| 1733 | UNIMPLEMENTED_INTRINSIC(UnsafeCASInt) |
| 1734 | UNIMPLEMENTED_INTRINSIC(UnsafeCASLong) |
| 1735 | UNIMPLEMENTED_INTRINSIC(UnsafeCASObject) |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 1736 | UNIMPLEMENTED_INTRINSIC(StringCompareTo) |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 1737 | UNIMPLEMENTED_INTRINSIC(StringIndexOf) |
| 1738 | UNIMPLEMENTED_INTRINSIC(StringIndexOfAfter) |
| 1739 | UNIMPLEMENTED_INTRINSIC(StringNewStringFromBytes) |
| 1740 | UNIMPLEMENTED_INTRINSIC(StringNewStringFromChars) |
| 1741 | UNIMPLEMENTED_INTRINSIC(StringNewStringFromString) |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 1742 | |
| 1743 | UNIMPLEMENTED_INTRINSIC(ReferenceGetReferent) |
| 1744 | UNIMPLEMENTED_INTRINSIC(StringGetCharsNoCheck) |
| 1745 | UNIMPLEMENTED_INTRINSIC(SystemArrayCopyChar) |
| 1746 | UNIMPLEMENTED_INTRINSIC(SystemArrayCopy) |
| 1747 | |
Mark Mendell | a4f1220 | 2015-08-06 15:23:34 -0400 | [diff] [blame] | 1748 | UNIMPLEMENTED_INTRINSIC(MathCos) |
| 1749 | UNIMPLEMENTED_INTRINSIC(MathSin) |
| 1750 | UNIMPLEMENTED_INTRINSIC(MathAcos) |
| 1751 | UNIMPLEMENTED_INTRINSIC(MathAsin) |
| 1752 | UNIMPLEMENTED_INTRINSIC(MathAtan) |
| 1753 | UNIMPLEMENTED_INTRINSIC(MathAtan2) |
| 1754 | UNIMPLEMENTED_INTRINSIC(MathCbrt) |
| 1755 | UNIMPLEMENTED_INTRINSIC(MathCosh) |
| 1756 | UNIMPLEMENTED_INTRINSIC(MathExp) |
| 1757 | UNIMPLEMENTED_INTRINSIC(MathExpm1) |
| 1758 | UNIMPLEMENTED_INTRINSIC(MathHypot) |
| 1759 | UNIMPLEMENTED_INTRINSIC(MathLog) |
| 1760 | UNIMPLEMENTED_INTRINSIC(MathLog10) |
| 1761 | UNIMPLEMENTED_INTRINSIC(MathNextAfter) |
| 1762 | UNIMPLEMENTED_INTRINSIC(MathSinh) |
| 1763 | UNIMPLEMENTED_INTRINSIC(MathTan) |
| 1764 | UNIMPLEMENTED_INTRINSIC(MathTanh) |
Aart Bik | 59c9454 | 2016-01-25 14:20:58 -0800 | [diff] [blame] | 1765 | |
| 1766 | UNIMPLEMENTED_INTRINSIC(FloatIsInfinite) |
| 1767 | UNIMPLEMENTED_INTRINSIC(DoubleIsInfinite) |
Aart Bik | 59c9454 | 2016-01-25 14:20:58 -0800 | [diff] [blame] | 1768 | |
Aart Bik | 59c9454 | 2016-01-25 14:20:58 -0800 | [diff] [blame] | 1769 | UNIMPLEMENTED_INTRINSIC(IntegerHighestOneBit) |
| 1770 | UNIMPLEMENTED_INTRINSIC(LongHighestOneBit) |
| 1771 | UNIMPLEMENTED_INTRINSIC(IntegerLowestOneBit) |
| 1772 | UNIMPLEMENTED_INTRINSIC(LongLowestOneBit) |
Aart Bik | a19616e | 2016-02-01 18:57:58 -0800 | [diff] [blame] | 1773 | |
| 1774 | // Handled as HIR instructions. |
Aart Bik | 2a6aad9 | 2016-02-25 11:32:32 -0800 | [diff] [blame] | 1775 | UNIMPLEMENTED_INTRINSIC(FloatFloatToIntBits) |
| 1776 | UNIMPLEMENTED_INTRINSIC(DoubleDoubleToLongBits) |
Aart Bik | 75a38b2 | 2016-02-17 10:41:50 -0800 | [diff] [blame] | 1777 | UNIMPLEMENTED_INTRINSIC(FloatIsNaN) |
| 1778 | UNIMPLEMENTED_INTRINSIC(DoubleIsNaN) |
Aart Bik | a19616e | 2016-02-01 18:57:58 -0800 | [diff] [blame] | 1779 | UNIMPLEMENTED_INTRINSIC(IntegerCompare) |
| 1780 | UNIMPLEMENTED_INTRINSIC(LongCompare) |
Aart Bik | 59c9454 | 2016-01-25 14:20:58 -0800 | [diff] [blame] | 1781 | UNIMPLEMENTED_INTRINSIC(IntegerSignum) |
| 1782 | UNIMPLEMENTED_INTRINSIC(LongSignum) |
| 1783 | |
Chris Larsen | 701566a | 2015-10-27 15:29:13 -0700 | [diff] [blame] | 1784 | #undef UNIMPLEMENTED_INTRINSIC |
| 1785 | |
| 1786 | #undef __ |
| 1787 | |
| 1788 | } // namespace mips |
| 1789 | } // namespace art |