blob: e29f9e599ac5db5e83115ed103a50682c25a655e [file] [log] [blame]
Chris Larsen3039e382015-08-26 07:54:08 -07001/*
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_mips64.h"
18
19#include "arch/mips64/instruction_set_features_mips64.h"
20#include "art_method.h"
21#include "code_generator_mips64.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/mips64/assembler_mips64.h"
28#include "utils/mips64/constants_mips64.h"
29
30namespace art {
31
32namespace mips64 {
33
34IntrinsicLocationsBuilderMIPS64::IntrinsicLocationsBuilderMIPS64(CodeGeneratorMIPS64* codegen)
35 : arena_(codegen->GetGraph()->GetArena()) {
36}
37
38Mips64Assembler* IntrinsicCodeGeneratorMIPS64::GetAssembler() {
39 return reinterpret_cast<Mips64Assembler*>(codegen_->GetAssembler());
40}
41
42ArenaAllocator* IntrinsicCodeGeneratorMIPS64::GetAllocator() {
43 return codegen_->GetGraph()->GetArena();
44}
45
Chris Larsen9701c2e2015-09-04 17:22:47 -070046#define __ codegen->GetAssembler()->
47
48static void MoveFromReturnRegister(Location trg,
49 Primitive::Type type,
50 CodeGeneratorMIPS64* codegen) {
51 if (!trg.IsValid()) {
52 DCHECK_EQ(type, Primitive::kPrimVoid);
53 return;
54 }
55
56 DCHECK_NE(type, Primitive::kPrimVoid);
57
58 if (Primitive::IsIntegralType(type) || type == Primitive::kPrimNot) {
59 GpuRegister trg_reg = trg.AsRegister<GpuRegister>();
60 if (trg_reg != V0) {
61 __ Move(V0, trg_reg);
62 }
63 } else {
64 FpuRegister trg_reg = trg.AsFpuRegister<FpuRegister>();
65 if (trg_reg != F0) {
66 if (type == Primitive::kPrimFloat) {
67 __ MovS(F0, trg_reg);
68 } else {
69 __ MovD(F0, trg_reg);
70 }
71 }
72 }
73}
74
75static void MoveArguments(HInvoke* invoke, CodeGeneratorMIPS64* codegen) {
76 InvokeDexCallingConventionVisitorMIPS64 calling_convention_visitor;
77 IntrinsicVisitor::MoveArguments(invoke, codegen, &calling_convention_visitor);
78}
79
80// Slow-path for fallback (calling the managed code to handle the
81// intrinsic) in an intrinsified call. This will copy the arguments
82// into the positions for a regular call.
83//
84// Note: The actual parameters are required to be in the locations
85// given by the invoke's location summary. If an intrinsic
86// modifies those locations before a slowpath call, they must be
87// restored!
88class IntrinsicSlowPathMIPS64 : public SlowPathCodeMIPS64 {
89 public:
90 explicit IntrinsicSlowPathMIPS64(HInvoke* invoke) : invoke_(invoke) { }
91
92 void EmitNativeCode(CodeGenerator* codegen_in) OVERRIDE {
93 CodeGeneratorMIPS64* codegen = down_cast<CodeGeneratorMIPS64*>(codegen_in);
94
95 __ Bind(GetEntryLabel());
96
97 SaveLiveRegisters(codegen, invoke_->GetLocations());
98
99 MoveArguments(invoke_, codegen);
100
101 if (invoke_->IsInvokeStaticOrDirect()) {
102 codegen->GenerateStaticOrDirectCall(invoke_->AsInvokeStaticOrDirect(),
103 Location::RegisterLocation(A0));
Chris Larsen9701c2e2015-09-04 17:22:47 -0700104 } else {
Alexey Frunze53afca12015-11-05 16:34:23 -0800105 codegen->GenerateVirtualCall(invoke_->AsInvokeVirtual(), Location::RegisterLocation(A0));
Chris Larsen9701c2e2015-09-04 17:22:47 -0700106 }
Alexey Frunze53afca12015-11-05 16:34:23 -0800107 codegen->RecordPcInfo(invoke_, invoke_->GetDexPc(), this);
Chris Larsen9701c2e2015-09-04 17:22:47 -0700108
109 // Copy the result back to the expected output.
110 Location out = invoke_->GetLocations()->Out();
111 if (out.IsValid()) {
112 DCHECK(out.IsRegister()); // TODO: Replace this when we support output in memory.
113 DCHECK(!invoke_->GetLocations()->GetLiveRegisters()->ContainsCoreRegister(out.reg()));
114 MoveFromReturnRegister(out, invoke_->GetType(), codegen);
115 }
116
117 RestoreLiveRegisters(codegen, invoke_->GetLocations());
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700118 __ Bc(GetExitLabel());
Chris Larsen9701c2e2015-09-04 17:22:47 -0700119 }
120
121 const char* GetDescription() const OVERRIDE { return "IntrinsicSlowPathMIPS64"; }
122
123 private:
124 // The instruction where this slow path is happening.
125 HInvoke* const invoke_;
126
127 DISALLOW_COPY_AND_ASSIGN(IntrinsicSlowPathMIPS64);
128};
129
130#undef __
131
Chris Larsen3039e382015-08-26 07:54:08 -0700132bool IntrinsicLocationsBuilderMIPS64::TryDispatch(HInvoke* invoke) {
133 Dispatch(invoke);
134 LocationSummary* res = invoke->GetLocations();
135 return res != nullptr && res->Intrinsified();
136}
137
138#define __ assembler->
139
140static void CreateFPToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
141 LocationSummary* locations = new (arena) LocationSummary(invoke,
142 LocationSummary::kNoCall,
143 kIntrinsified);
144 locations->SetInAt(0, Location::RequiresFpuRegister());
145 locations->SetOut(Location::RequiresRegister());
146}
147
148static void MoveFPToInt(LocationSummary* locations, bool is64bit, Mips64Assembler* assembler) {
149 FpuRegister in = locations->InAt(0).AsFpuRegister<FpuRegister>();
150 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
151
152 if (is64bit) {
153 __ Dmfc1(out, in);
154 } else {
155 __ Mfc1(out, in);
156 }
157}
158
159// long java.lang.Double.doubleToRawLongBits(double)
160void IntrinsicLocationsBuilderMIPS64::VisitDoubleDoubleToRawLongBits(HInvoke* invoke) {
161 CreateFPToIntLocations(arena_, invoke);
162}
163
164void IntrinsicCodeGeneratorMIPS64::VisitDoubleDoubleToRawLongBits(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000165 MoveFPToInt(invoke->GetLocations(), /* is64bit */ true, GetAssembler());
Chris Larsen3039e382015-08-26 07:54:08 -0700166}
167
168// int java.lang.Float.floatToRawIntBits(float)
169void IntrinsicLocationsBuilderMIPS64::VisitFloatFloatToRawIntBits(HInvoke* invoke) {
170 CreateFPToIntLocations(arena_, invoke);
171}
172
173void IntrinsicCodeGeneratorMIPS64::VisitFloatFloatToRawIntBits(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000174 MoveFPToInt(invoke->GetLocations(), /* is64bit */ false, GetAssembler());
Chris Larsen3039e382015-08-26 07:54:08 -0700175}
176
177static void CreateIntToFPLocations(ArenaAllocator* arena, HInvoke* invoke) {
178 LocationSummary* locations = new (arena) LocationSummary(invoke,
179 LocationSummary::kNoCall,
180 kIntrinsified);
181 locations->SetInAt(0, Location::RequiresRegister());
182 locations->SetOut(Location::RequiresFpuRegister());
183}
184
185static void MoveIntToFP(LocationSummary* locations, bool is64bit, Mips64Assembler* assembler) {
186 GpuRegister in = locations->InAt(0).AsRegister<GpuRegister>();
187 FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>();
188
189 if (is64bit) {
190 __ Dmtc1(in, out);
191 } else {
192 __ Mtc1(in, out);
193 }
194}
195
196// double java.lang.Double.longBitsToDouble(long)
197void IntrinsicLocationsBuilderMIPS64::VisitDoubleLongBitsToDouble(HInvoke* invoke) {
198 CreateIntToFPLocations(arena_, invoke);
199}
200
201void IntrinsicCodeGeneratorMIPS64::VisitDoubleLongBitsToDouble(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000202 MoveIntToFP(invoke->GetLocations(), /* is64bit */ true, GetAssembler());
Chris Larsen3039e382015-08-26 07:54:08 -0700203}
204
205// float java.lang.Float.intBitsToFloat(int)
206void IntrinsicLocationsBuilderMIPS64::VisitFloatIntBitsToFloat(HInvoke* invoke) {
207 CreateIntToFPLocations(arena_, invoke);
208}
209
210void IntrinsicCodeGeneratorMIPS64::VisitFloatIntBitsToFloat(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000211 MoveIntToFP(invoke->GetLocations(), /* is64bit */ false, GetAssembler());
Chris Larsen3039e382015-08-26 07:54:08 -0700212}
213
214static void CreateIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
215 LocationSummary* locations = new (arena) LocationSummary(invoke,
216 LocationSummary::kNoCall,
217 kIntrinsified);
218 locations->SetInAt(0, Location::RequiresRegister());
219 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
220}
221
222static void GenReverseBytes(LocationSummary* locations,
223 Primitive::Type type,
224 Mips64Assembler* assembler) {
225 GpuRegister in = locations->InAt(0).AsRegister<GpuRegister>();
226 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
227
228 switch (type) {
229 case Primitive::kPrimShort:
230 __ Dsbh(out, in);
231 __ Seh(out, out);
232 break;
233 case Primitive::kPrimInt:
234 __ Rotr(out, in, 16);
235 __ Wsbh(out, out);
236 break;
237 case Primitive::kPrimLong:
238 __ Dsbh(out, in);
239 __ Dshd(out, out);
240 break;
241 default:
242 LOG(FATAL) << "Unexpected size for reverse-bytes: " << type;
243 UNREACHABLE();
244 }
245}
246
247// int java.lang.Integer.reverseBytes(int)
248void IntrinsicLocationsBuilderMIPS64::VisitIntegerReverseBytes(HInvoke* invoke) {
249 CreateIntToIntLocations(arena_, invoke);
250}
251
252void IntrinsicCodeGeneratorMIPS64::VisitIntegerReverseBytes(HInvoke* invoke) {
253 GenReverseBytes(invoke->GetLocations(), Primitive::kPrimInt, GetAssembler());
254}
255
256// long java.lang.Long.reverseBytes(long)
257void IntrinsicLocationsBuilderMIPS64::VisitLongReverseBytes(HInvoke* invoke) {
258 CreateIntToIntLocations(arena_, invoke);
259}
260
261void IntrinsicCodeGeneratorMIPS64::VisitLongReverseBytes(HInvoke* invoke) {
262 GenReverseBytes(invoke->GetLocations(), Primitive::kPrimLong, GetAssembler());
263}
264
265// short java.lang.Short.reverseBytes(short)
266void IntrinsicLocationsBuilderMIPS64::VisitShortReverseBytes(HInvoke* invoke) {
267 CreateIntToIntLocations(arena_, invoke);
268}
269
270void IntrinsicCodeGeneratorMIPS64::VisitShortReverseBytes(HInvoke* invoke) {
271 GenReverseBytes(invoke->GetLocations(), Primitive::kPrimShort, GetAssembler());
272}
273
Chris Larsen81284372015-10-21 15:28:53 -0700274static void GenNumberOfLeadingZeroes(LocationSummary* locations,
275 bool is64bit,
276 Mips64Assembler* assembler) {
Chris Larsen3039e382015-08-26 07:54:08 -0700277 GpuRegister in = locations->InAt(0).AsRegister<GpuRegister>();
278 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
279
280 if (is64bit) {
281 __ Dclz(out, in);
282 } else {
283 __ Clz(out, in);
284 }
285}
286
287// int java.lang.Integer.numberOfLeadingZeros(int i)
288void IntrinsicLocationsBuilderMIPS64::VisitIntegerNumberOfLeadingZeros(HInvoke* invoke) {
289 CreateIntToIntLocations(arena_, invoke);
290}
291
292void IntrinsicCodeGeneratorMIPS64::VisitIntegerNumberOfLeadingZeros(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000293 GenNumberOfLeadingZeroes(invoke->GetLocations(), /* is64bit */ false, GetAssembler());
Chris Larsen3039e382015-08-26 07:54:08 -0700294}
295
296// int java.lang.Long.numberOfLeadingZeros(long i)
297void IntrinsicLocationsBuilderMIPS64::VisitLongNumberOfLeadingZeros(HInvoke* invoke) {
298 CreateIntToIntLocations(arena_, invoke);
299}
300
301void IntrinsicCodeGeneratorMIPS64::VisitLongNumberOfLeadingZeros(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000302 GenNumberOfLeadingZeroes(invoke->GetLocations(), /* is64bit */ true, GetAssembler());
Chris Larsen0646da72015-09-22 16:02:40 -0700303}
304
Chris Larsen81284372015-10-21 15:28:53 -0700305static void GenNumberOfTrailingZeroes(LocationSummary* locations,
306 bool is64bit,
307 Mips64Assembler* assembler) {
Chris Larsen0646da72015-09-22 16:02:40 -0700308 Location in = locations->InAt(0);
309 Location out = locations->Out();
310
311 if (is64bit) {
312 __ Dsbh(out.AsRegister<GpuRegister>(), in.AsRegister<GpuRegister>());
313 __ Dshd(out.AsRegister<GpuRegister>(), out.AsRegister<GpuRegister>());
314 __ Dbitswap(out.AsRegister<GpuRegister>(), out.AsRegister<GpuRegister>());
315 __ Dclz(out.AsRegister<GpuRegister>(), out.AsRegister<GpuRegister>());
316 } else {
317 __ Rotr(out.AsRegister<GpuRegister>(), in.AsRegister<GpuRegister>(), 16);
318 __ Wsbh(out.AsRegister<GpuRegister>(), out.AsRegister<GpuRegister>());
319 __ Bitswap(out.AsRegister<GpuRegister>(), out.AsRegister<GpuRegister>());
320 __ Clz(out.AsRegister<GpuRegister>(), out.AsRegister<GpuRegister>());
321 }
322}
323
324// int java.lang.Integer.numberOfTrailingZeros(int i)
325void IntrinsicLocationsBuilderMIPS64::VisitIntegerNumberOfTrailingZeros(HInvoke* invoke) {
326 CreateIntToIntLocations(arena_, invoke);
327}
328
329void IntrinsicCodeGeneratorMIPS64::VisitIntegerNumberOfTrailingZeros(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000330 GenNumberOfTrailingZeroes(invoke->GetLocations(), /* is64bit */ false, GetAssembler());
Chris Larsen0646da72015-09-22 16:02:40 -0700331}
332
333// int java.lang.Long.numberOfTrailingZeros(long i)
334void IntrinsicLocationsBuilderMIPS64::VisitLongNumberOfTrailingZeros(HInvoke* invoke) {
335 CreateIntToIntLocations(arena_, invoke);
336}
337
338void IntrinsicCodeGeneratorMIPS64::VisitLongNumberOfTrailingZeros(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000339 GenNumberOfTrailingZeroes(invoke->GetLocations(), /* is64bit */ true, GetAssembler());
Chris Larsen3039e382015-08-26 07:54:08 -0700340}
341
Chris Larsen9aebff22015-09-22 17:54:15 -0700342static void GenRotateRight(HInvoke* invoke,
343 Primitive::Type type,
344 Mips64Assembler* assembler) {
345 DCHECK(type == Primitive::kPrimInt || type == Primitive::kPrimLong);
346
347 LocationSummary* locations = invoke->GetLocations();
348 GpuRegister in = locations->InAt(0).AsRegister<GpuRegister>();
349 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
350
351 if (invoke->InputAt(1)->IsIntConstant()) {
352 uint32_t shift = static_cast<uint32_t>(invoke->InputAt(1)->AsIntConstant()->GetValue());
353 if (type == Primitive::kPrimInt) {
354 shift &= 0x1f;
355 __ Rotr(out, in, shift);
356 } else {
357 shift &= 0x3f;
358 if (shift < 32) {
359 __ Drotr(out, in, shift);
360 } else {
361 shift &= 0x1f;
362 __ Drotr32(out, in, shift);
363 }
364 }
365 } else {
366 GpuRegister shamt = locations->InAt(1).AsRegister<GpuRegister>();
367 if (type == Primitive::kPrimInt) {
368 __ Rotrv(out, in, shamt);
369 } else {
370 __ Drotrv(out, in, shamt);
371 }
372 }
373}
374
375// int java.lang.Integer.rotateRight(int i, int distance)
376void IntrinsicLocationsBuilderMIPS64::VisitIntegerRotateRight(HInvoke* invoke) {
377 LocationSummary* locations = new (arena_) LocationSummary(invoke,
378 LocationSummary::kNoCall,
379 kIntrinsified);
380 locations->SetInAt(0, Location::RequiresRegister());
381 locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1)));
382 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
383}
384
385void IntrinsicCodeGeneratorMIPS64::VisitIntegerRotateRight(HInvoke* invoke) {
386 GenRotateRight(invoke, Primitive::kPrimInt, GetAssembler());
387}
388
Chris Larsen81284372015-10-21 15:28:53 -0700389// long java.lang.Long.rotateRight(long i, int distance)
Chris Larsen9aebff22015-09-22 17:54:15 -0700390void IntrinsicLocationsBuilderMIPS64::VisitLongRotateRight(HInvoke* invoke) {
391 LocationSummary* locations = new (arena_) LocationSummary(invoke,
392 LocationSummary::kNoCall,
393 kIntrinsified);
394 locations->SetInAt(0, Location::RequiresRegister());
395 locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1)));
396 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
397}
398
399void IntrinsicCodeGeneratorMIPS64::VisitLongRotateRight(HInvoke* invoke) {
400 GenRotateRight(invoke, Primitive::kPrimLong, GetAssembler());
401}
402
Chris Larsen0f8f8642015-10-02 17:25:58 -0700403static void GenRotateLeft(HInvoke* invoke,
404 Primitive::Type type,
405 Mips64Assembler* assembler) {
406 DCHECK(type == Primitive::kPrimInt || type == Primitive::kPrimLong);
407
408 LocationSummary* locations = invoke->GetLocations();
409 GpuRegister in = locations->InAt(0).AsRegister<GpuRegister>();
410 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
411
412 if (invoke->InputAt(1)->IsIntConstant()) {
413 int32_t shift = -static_cast<int32_t>(invoke->InputAt(1)->AsIntConstant()->GetValue());
414 if (type == Primitive::kPrimInt) {
415 shift &= 0x1f;
416 __ Rotr(out, in, shift);
417 } else {
418 shift &= 0x3f;
419 if (shift < 32) {
420 __ Drotr(out, in, shift);
421 } else {
422 shift &= 0x1f;
423 __ Drotr32(out, in, shift);
424 }
425 }
426 } else {
427 GpuRegister shamt = locations->InAt(1).AsRegister<GpuRegister>();
428 if (type == Primitive::kPrimInt) {
429 __ Subu(TMP, ZERO, shamt);
430 __ Rotrv(out, in, TMP);
431 } else {
432 __ Dsubu(TMP, ZERO, shamt);
433 __ Drotrv(out, in, TMP);
434 }
435 }
436}
437
438// int java.lang.Integer.rotateLeft(int i, int distance)
439void IntrinsicLocationsBuilderMIPS64::VisitIntegerRotateLeft(HInvoke* invoke) {
440 LocationSummary* locations = new (arena_) LocationSummary(invoke,
441 LocationSummary::kNoCall,
442 kIntrinsified);
443 locations->SetInAt(0, Location::RequiresRegister());
444 locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1)));
445 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
446}
447
448void IntrinsicCodeGeneratorMIPS64::VisitIntegerRotateLeft(HInvoke* invoke) {
449 GenRotateLeft(invoke, Primitive::kPrimInt, GetAssembler());
450}
451
Chris Larsen81284372015-10-21 15:28:53 -0700452// long java.lang.Long.rotateLeft(long i, int distance)
Chris Larsen0f8f8642015-10-02 17:25:58 -0700453void IntrinsicLocationsBuilderMIPS64::VisitLongRotateLeft(HInvoke* invoke) {
454 LocationSummary* locations = new (arena_) LocationSummary(invoke,
455 LocationSummary::kNoCall,
456 kIntrinsified);
457 locations->SetInAt(0, Location::RequiresRegister());
458 locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1)));
459 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
460}
461
462void IntrinsicCodeGeneratorMIPS64::VisitLongRotateLeft(HInvoke* invoke) {
463 GenRotateLeft(invoke, Primitive::kPrimLong, GetAssembler());
464}
465
Chris Larsen3039e382015-08-26 07:54:08 -0700466static void GenReverse(LocationSummary* locations,
467 Primitive::Type type,
468 Mips64Assembler* assembler) {
469 DCHECK(type == Primitive::kPrimInt || type == Primitive::kPrimLong);
470
471 GpuRegister in = locations->InAt(0).AsRegister<GpuRegister>();
472 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
473
474 if (type == Primitive::kPrimInt) {
475 __ Rotr(out, in, 16);
476 __ Wsbh(out, out);
477 __ Bitswap(out, out);
478 } else {
479 __ Dsbh(out, in);
480 __ Dshd(out, out);
481 __ Dbitswap(out, out);
482 }
483}
484
485// int java.lang.Integer.reverse(int)
486void IntrinsicLocationsBuilderMIPS64::VisitIntegerReverse(HInvoke* invoke) {
487 CreateIntToIntLocations(arena_, invoke);
488}
489
490void IntrinsicCodeGeneratorMIPS64::VisitIntegerReverse(HInvoke* invoke) {
491 GenReverse(invoke->GetLocations(), Primitive::kPrimInt, GetAssembler());
492}
493
494// long java.lang.Long.reverse(long)
495void IntrinsicLocationsBuilderMIPS64::VisitLongReverse(HInvoke* invoke) {
496 CreateIntToIntLocations(arena_, invoke);
497}
498
499void IntrinsicCodeGeneratorMIPS64::VisitLongReverse(HInvoke* invoke) {
500 GenReverse(invoke->GetLocations(), Primitive::kPrimLong, GetAssembler());
501}
502
Chris Larsen0b7ac982015-09-04 12:54:28 -0700503static void CreateFPToFPLocations(ArenaAllocator* arena, HInvoke* invoke) {
504 LocationSummary* locations = new (arena) LocationSummary(invoke,
505 LocationSummary::kNoCall,
506 kIntrinsified);
507 locations->SetInAt(0, Location::RequiresFpuRegister());
508 locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
509}
510
511static void MathAbsFP(LocationSummary* locations, bool is64bit, Mips64Assembler* assembler) {
512 FpuRegister in = locations->InAt(0).AsFpuRegister<FpuRegister>();
513 FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>();
514
515 if (is64bit) {
516 __ AbsD(out, in);
517 } else {
518 __ AbsS(out, in);
519 }
520}
521
522// double java.lang.Math.abs(double)
523void IntrinsicLocationsBuilderMIPS64::VisitMathAbsDouble(HInvoke* invoke) {
524 CreateFPToFPLocations(arena_, invoke);
525}
526
527void IntrinsicCodeGeneratorMIPS64::VisitMathAbsDouble(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000528 MathAbsFP(invoke->GetLocations(), /* is64bit */ true, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700529}
530
531// float java.lang.Math.abs(float)
532void IntrinsicLocationsBuilderMIPS64::VisitMathAbsFloat(HInvoke* invoke) {
533 CreateFPToFPLocations(arena_, invoke);
534}
535
536void IntrinsicCodeGeneratorMIPS64::VisitMathAbsFloat(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000537 MathAbsFP(invoke->GetLocations(), /* is64bit */ false, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700538}
539
540static void CreateIntToInt(ArenaAllocator* arena, HInvoke* invoke) {
541 LocationSummary* locations = new (arena) LocationSummary(invoke,
542 LocationSummary::kNoCall,
543 kIntrinsified);
544 locations->SetInAt(0, Location::RequiresRegister());
545 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
546}
547
548static void GenAbsInteger(LocationSummary* locations, bool is64bit, Mips64Assembler* assembler) {
549 GpuRegister in = locations->InAt(0).AsRegister<GpuRegister>();
550 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
551
552 if (is64bit) {
553 __ Dsra32(AT, in, 31);
554 __ Xor(out, in, AT);
555 __ Dsubu(out, out, AT);
556 } else {
557 __ Sra(AT, in, 31);
558 __ Xor(out, in, AT);
559 __ Subu(out, out, AT);
560 }
561}
562
563// int java.lang.Math.abs(int)
564void IntrinsicLocationsBuilderMIPS64::VisitMathAbsInt(HInvoke* invoke) {
565 CreateIntToInt(arena_, invoke);
566}
567
568void IntrinsicCodeGeneratorMIPS64::VisitMathAbsInt(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000569 GenAbsInteger(invoke->GetLocations(), /* is64bit */ false, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700570}
571
572// long java.lang.Math.abs(long)
573void IntrinsicLocationsBuilderMIPS64::VisitMathAbsLong(HInvoke* invoke) {
574 CreateIntToInt(arena_, invoke);
575}
576
577void IntrinsicCodeGeneratorMIPS64::VisitMathAbsLong(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000578 GenAbsInteger(invoke->GetLocations(), /* is64bit */ true, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700579}
580
581static void GenMinMaxFP(LocationSummary* locations,
582 bool is_min,
Chris Larsenb74353a2015-11-20 09:07:09 -0800583 Primitive::Type type,
Chris Larsen0b7ac982015-09-04 12:54:28 -0700584 Mips64Assembler* assembler) {
Chris Larsenb74353a2015-11-20 09:07:09 -0800585 FpuRegister a = locations->InAt(0).AsFpuRegister<FpuRegister>();
586 FpuRegister b = locations->InAt(1).AsFpuRegister<FpuRegister>();
Chris Larsen0b7ac982015-09-04 12:54:28 -0700587 FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>();
588
Chris Larsenb74353a2015-11-20 09:07:09 -0800589 Mips64Label noNaNs;
590 Mips64Label done;
591 FpuRegister ftmp = ((out != a) && (out != b)) ? out : FTMP;
592
593 // When Java computes min/max it prefers a NaN to a number; the
594 // behavior of MIPSR6 is to prefer numbers to NaNs, i.e., if one of
595 // the inputs is a NaN and the other is a valid number, the MIPS
596 // instruction will return the number; Java wants the NaN value
597 // returned. This is why there is extra logic preceding the use of
598 // the MIPS min.fmt/max.fmt instructions. If either a, or b holds a
599 // NaN, return the NaN, otherwise return the min/max.
600 if (type == Primitive::kPrimDouble) {
601 __ CmpUnD(FTMP, a, b);
602 __ Bc1eqz(FTMP, &noNaNs);
603
604 // One of the inputs is a NaN
605 __ CmpEqD(ftmp, a, a);
606 // If a == a then b is the NaN, otherwise a is the NaN.
607 __ SelD(ftmp, a, b);
608
609 if (ftmp != out) {
610 __ MovD(out, ftmp);
611 }
612
613 __ Bc(&done);
614
615 __ Bind(&noNaNs);
616
Chris Larsen0b7ac982015-09-04 12:54:28 -0700617 if (is_min) {
Chris Larsenb74353a2015-11-20 09:07:09 -0800618 __ MinD(out, a, b);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700619 } else {
Chris Larsenb74353a2015-11-20 09:07:09 -0800620 __ MaxD(out, a, b);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700621 }
622 } else {
Chris Larsenb74353a2015-11-20 09:07:09 -0800623 DCHECK_EQ(type, Primitive::kPrimFloat);
624 __ CmpUnS(FTMP, a, b);
625 __ Bc1eqz(FTMP, &noNaNs);
626
627 // One of the inputs is a NaN
628 __ CmpEqS(ftmp, a, a);
629 // If a == a then b is the NaN, otherwise a is the NaN.
630 __ SelS(ftmp, a, b);
631
632 if (ftmp != out) {
633 __ MovS(out, ftmp);
634 }
635
636 __ Bc(&done);
637
638 __ Bind(&noNaNs);
639
Chris Larsen0b7ac982015-09-04 12:54:28 -0700640 if (is_min) {
Chris Larsenb74353a2015-11-20 09:07:09 -0800641 __ MinS(out, a, b);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700642 } else {
Chris Larsenb74353a2015-11-20 09:07:09 -0800643 __ MaxS(out, a, b);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700644 }
645 }
Chris Larsenb74353a2015-11-20 09:07:09 -0800646
647 __ Bind(&done);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700648}
649
650static void CreateFPFPToFPLocations(ArenaAllocator* arena, HInvoke* invoke) {
651 LocationSummary* locations = new (arena) LocationSummary(invoke,
652 LocationSummary::kNoCall,
653 kIntrinsified);
654 locations->SetInAt(0, Location::RequiresFpuRegister());
655 locations->SetInAt(1, Location::RequiresFpuRegister());
656 locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
657}
658
659// double java.lang.Math.min(double, double)
660void IntrinsicLocationsBuilderMIPS64::VisitMathMinDoubleDouble(HInvoke* invoke) {
661 CreateFPFPToFPLocations(arena_, invoke);
662}
663
664void IntrinsicCodeGeneratorMIPS64::VisitMathMinDoubleDouble(HInvoke* invoke) {
Chris Larsenb74353a2015-11-20 09:07:09 -0800665 GenMinMaxFP(invoke->GetLocations(), /* is_min */ true, Primitive::kPrimDouble, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700666}
667
668// float java.lang.Math.min(float, float)
669void IntrinsicLocationsBuilderMIPS64::VisitMathMinFloatFloat(HInvoke* invoke) {
670 CreateFPFPToFPLocations(arena_, invoke);
671}
672
673void IntrinsicCodeGeneratorMIPS64::VisitMathMinFloatFloat(HInvoke* invoke) {
Chris Larsenb74353a2015-11-20 09:07:09 -0800674 GenMinMaxFP(invoke->GetLocations(), /* is_min */ true, Primitive::kPrimFloat, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700675}
676
677// double java.lang.Math.max(double, double)
678void IntrinsicLocationsBuilderMIPS64::VisitMathMaxDoubleDouble(HInvoke* invoke) {
679 CreateFPFPToFPLocations(arena_, invoke);
680}
681
682void IntrinsicCodeGeneratorMIPS64::VisitMathMaxDoubleDouble(HInvoke* invoke) {
Chris Larsenb74353a2015-11-20 09:07:09 -0800683 GenMinMaxFP(invoke->GetLocations(), /* is_min */ false, Primitive::kPrimDouble, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700684}
685
686// float java.lang.Math.max(float, float)
687void IntrinsicLocationsBuilderMIPS64::VisitMathMaxFloatFloat(HInvoke* invoke) {
688 CreateFPFPToFPLocations(arena_, invoke);
689}
690
691void IntrinsicCodeGeneratorMIPS64::VisitMathMaxFloatFloat(HInvoke* invoke) {
Chris Larsenb74353a2015-11-20 09:07:09 -0800692 GenMinMaxFP(invoke->GetLocations(), /* is_min */ false, Primitive::kPrimFloat, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700693}
694
695static void GenMinMax(LocationSummary* locations,
696 bool is_min,
697 Mips64Assembler* assembler) {
698 GpuRegister lhs = locations->InAt(0).AsRegister<GpuRegister>();
699 GpuRegister rhs = locations->InAt(1).AsRegister<GpuRegister>();
700 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
701
Chris Larsenb74353a2015-11-20 09:07:09 -0800702 if (lhs == rhs) {
703 if (out != lhs) {
704 __ Move(out, lhs);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700705 }
706 } else {
Chris Larsenb74353a2015-11-20 09:07:09 -0800707 // Some architectures, such as ARM and MIPS (prior to r6), have a
708 // conditional move instruction which only changes the target
709 // (output) register if the condition is true (MIPS prior to r6 had
710 // MOVF, MOVT, and MOVZ). The SELEQZ and SELNEZ instructions always
711 // change the target (output) register. If the condition is true the
712 // output register gets the contents of the "rs" register; otherwise,
713 // the output register is set to zero. One consequence of this is
714 // that to implement something like "rd = c==0 ? rs : rt" MIPS64r6
715 // needs to use a pair of SELEQZ/SELNEZ instructions. After
716 // executing this pair of instructions one of the output registers
717 // from the pair will necessarily contain zero. Then the code ORs the
718 // output registers from the SELEQZ/SELNEZ instructions to get the
719 // final result.
720 //
721 // The initial test to see if the output register is same as the
722 // first input register is needed to make sure that value in the
723 // first input register isn't clobbered before we've finished
724 // computing the output value. The logic in the corresponding else
725 // clause performs the same task but makes sure the second input
726 // register isn't clobbered in the event that it's the same register
727 // as the output register; the else clause also handles the case
728 // where the output register is distinct from both the first, and the
729 // second input registers.
730 if (out == lhs) {
731 __ Slt(AT, rhs, lhs);
732 if (is_min) {
733 __ Seleqz(out, lhs, AT);
734 __ Selnez(AT, rhs, AT);
735 } else {
736 __ Selnez(out, lhs, AT);
737 __ Seleqz(AT, rhs, AT);
738 }
Chris Larsen0b7ac982015-09-04 12:54:28 -0700739 } else {
Chris Larsenb74353a2015-11-20 09:07:09 -0800740 __ Slt(AT, lhs, rhs);
741 if (is_min) {
742 __ Seleqz(out, rhs, AT);
743 __ Selnez(AT, lhs, AT);
744 } else {
745 __ Selnez(out, rhs, AT);
746 __ Seleqz(AT, lhs, AT);
747 }
Chris Larsen0b7ac982015-09-04 12:54:28 -0700748 }
Chris Larsenb74353a2015-11-20 09:07:09 -0800749 __ Or(out, out, AT);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700750 }
Chris Larsen0b7ac982015-09-04 12:54:28 -0700751}
752
753static void CreateIntIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
754 LocationSummary* locations = new (arena) LocationSummary(invoke,
755 LocationSummary::kNoCall,
756 kIntrinsified);
757 locations->SetInAt(0, Location::RequiresRegister());
758 locations->SetInAt(1, Location::RequiresRegister());
759 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
760}
761
762// int java.lang.Math.min(int, int)
763void IntrinsicLocationsBuilderMIPS64::VisitMathMinIntInt(HInvoke* invoke) {
764 CreateIntIntToIntLocations(arena_, invoke);
765}
766
767void IntrinsicCodeGeneratorMIPS64::VisitMathMinIntInt(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000768 GenMinMax(invoke->GetLocations(), /* is_min */ true, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700769}
770
771// long java.lang.Math.min(long, long)
772void IntrinsicLocationsBuilderMIPS64::VisitMathMinLongLong(HInvoke* invoke) {
773 CreateIntIntToIntLocations(arena_, invoke);
774}
775
776void IntrinsicCodeGeneratorMIPS64::VisitMathMinLongLong(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000777 GenMinMax(invoke->GetLocations(), /* is_min */ true, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700778}
779
780// int java.lang.Math.max(int, int)
781void IntrinsicLocationsBuilderMIPS64::VisitMathMaxIntInt(HInvoke* invoke) {
782 CreateIntIntToIntLocations(arena_, invoke);
783}
784
785void IntrinsicCodeGeneratorMIPS64::VisitMathMaxIntInt(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000786 GenMinMax(invoke->GetLocations(), /* is_min */ false, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700787}
788
789// long java.lang.Math.max(long, long)
790void IntrinsicLocationsBuilderMIPS64::VisitMathMaxLongLong(HInvoke* invoke) {
791 CreateIntIntToIntLocations(arena_, invoke);
792}
793
794void IntrinsicCodeGeneratorMIPS64::VisitMathMaxLongLong(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +0000795 GenMinMax(invoke->GetLocations(), /* is_min */ false, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700796}
797
798// double java.lang.Math.sqrt(double)
799void IntrinsicLocationsBuilderMIPS64::VisitMathSqrt(HInvoke* invoke) {
800 CreateFPToFPLocations(arena_, invoke);
801}
802
803void IntrinsicCodeGeneratorMIPS64::VisitMathSqrt(HInvoke* invoke) {
804 LocationSummary* locations = invoke->GetLocations();
805 Mips64Assembler* assembler = GetAssembler();
806 FpuRegister in = locations->InAt(0).AsFpuRegister<FpuRegister>();
807 FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>();
808
809 __ SqrtD(out, in);
810}
811
Chris Larsen81284372015-10-21 15:28:53 -0700812static void CreateFPToFP(ArenaAllocator* arena,
813 HInvoke* invoke,
814 Location::OutputOverlap overlaps = Location::kOutputOverlap) {
Chris Larsen0b7ac982015-09-04 12:54:28 -0700815 LocationSummary* locations = new (arena) LocationSummary(invoke,
816 LocationSummary::kNoCall,
817 kIntrinsified);
818 locations->SetInAt(0, Location::RequiresFpuRegister());
Chris Larsen81284372015-10-21 15:28:53 -0700819 locations->SetOut(Location::RequiresFpuRegister(), overlaps);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700820}
821
822// double java.lang.Math.rint(double)
823void IntrinsicLocationsBuilderMIPS64::VisitMathRint(HInvoke* invoke) {
Chris Larsen81284372015-10-21 15:28:53 -0700824 CreateFPToFP(arena_, invoke, Location::kNoOutputOverlap);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700825}
826
827void IntrinsicCodeGeneratorMIPS64::VisitMathRint(HInvoke* invoke) {
828 LocationSummary* locations = invoke->GetLocations();
829 Mips64Assembler* assembler = GetAssembler();
830 FpuRegister in = locations->InAt(0).AsFpuRegister<FpuRegister>();
831 FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>();
832
833 __ RintD(out, in);
834}
835
836// double java.lang.Math.floor(double)
837void IntrinsicLocationsBuilderMIPS64::VisitMathFloor(HInvoke* invoke) {
838 CreateFPToFP(arena_, invoke);
839}
840
Chris Larsen14500822015-10-01 11:35:18 -0700841const constexpr uint16_t kFPLeaveUnchanged = kPositiveZero |
842 kPositiveInfinity |
843 kNegativeZero |
844 kNegativeInfinity |
845 kQuietNaN |
846 kSignalingNaN;
Chris Larsen0b7ac982015-09-04 12:54:28 -0700847
Chris Larsen81284372015-10-21 15:28:53 -0700848enum FloatRoundingMode {
849 kFloor,
850 kCeil,
851};
852
853static void GenRoundingMode(LocationSummary* locations,
854 FloatRoundingMode mode,
855 Mips64Assembler* assembler) {
Chris Larsen0b7ac982015-09-04 12:54:28 -0700856 FpuRegister in = locations->InAt(0).AsFpuRegister<FpuRegister>();
857 FpuRegister out = locations->Out().AsFpuRegister<FpuRegister>();
858
Chris Larsen81284372015-10-21 15:28:53 -0700859 DCHECK_NE(in, out);
860
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700861 Mips64Label done;
Chris Larsen0b7ac982015-09-04 12:54:28 -0700862
Chris Larsen81284372015-10-21 15:28:53 -0700863 // double floor/ceil(double in) {
Chris Larsen0b7ac982015-09-04 12:54:28 -0700864 // if in.isNaN || in.isInfinite || in.isZero {
865 // return in;
866 // }
867 __ ClassD(out, in);
868 __ Dmfc1(AT, out);
Chris Larsen14500822015-10-01 11:35:18 -0700869 __ Andi(AT, AT, kFPLeaveUnchanged); // +0.0 | +Inf | -0.0 | -Inf | qNaN | sNaN
Chris Larsen0b7ac982015-09-04 12:54:28 -0700870 __ MovD(out, in);
871 __ Bnezc(AT, &done);
872
Chris Larsen81284372015-10-21 15:28:53 -0700873 // Long outLong = floor/ceil(in);
Chris Larsen0b7ac982015-09-04 12:54:28 -0700874 // if outLong == Long.MAX_VALUE {
Chris Larsen81284372015-10-21 15:28:53 -0700875 // // floor()/ceil() has almost certainly returned a value
876 // // which can't be successfully represented as a signed
877 // // 64-bit number. Java expects that the input value will
878 // // be returned in these cases.
879 // // There is also a small probability that floor(in)/ceil(in)
880 // // correctly truncates/rounds up the input value to
881 // // Long.MAX_VALUE. In that case, this exception handling
882 // // code still does the correct thing.
Chris Larsen0b7ac982015-09-04 12:54:28 -0700883 // return in;
884 // }
Chris Larsen81284372015-10-21 15:28:53 -0700885 if (mode == kFloor) {
886 __ FloorLD(out, in);
887 } else if (mode == kCeil) {
888 __ CeilLD(out, in);
889 }
Chris Larsen0b7ac982015-09-04 12:54:28 -0700890 __ Dmfc1(AT, out);
891 __ MovD(out, in);
892 __ LoadConst64(TMP, kPrimLongMax);
893 __ Beqc(AT, TMP, &done);
894
895 // double out = outLong;
896 // return out;
897 __ Dmtc1(AT, out);
898 __ Cvtdl(out, out);
899 __ Bind(&done);
900 // }
901}
902
Chris Larsen81284372015-10-21 15:28:53 -0700903void IntrinsicCodeGeneratorMIPS64::VisitMathFloor(HInvoke* invoke) {
904 GenRoundingMode(invoke->GetLocations(), kFloor, GetAssembler());
905}
906
Chris Larsen0b7ac982015-09-04 12:54:28 -0700907// double java.lang.Math.ceil(double)
908void IntrinsicLocationsBuilderMIPS64::VisitMathCeil(HInvoke* invoke) {
909 CreateFPToFP(arena_, invoke);
910}
911
912void IntrinsicCodeGeneratorMIPS64::VisitMathCeil(HInvoke* invoke) {
Chris Larsen81284372015-10-21 15:28:53 -0700913 GenRoundingMode(invoke->GetLocations(), kCeil, GetAssembler());
Chris Larsen0b7ac982015-09-04 12:54:28 -0700914}
915
Chris Larsen70fb1f42015-09-04 10:15:27 -0700916// byte libcore.io.Memory.peekByte(long address)
917void IntrinsicLocationsBuilderMIPS64::VisitMemoryPeekByte(HInvoke* invoke) {
918 CreateIntToIntLocations(arena_, invoke);
919}
920
921void IntrinsicCodeGeneratorMIPS64::VisitMemoryPeekByte(HInvoke* invoke) {
922 Mips64Assembler* assembler = GetAssembler();
923 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
924 GpuRegister out = invoke->GetLocations()->Out().AsRegister<GpuRegister>();
925
926 __ Lb(out, adr, 0);
927}
928
929// short libcore.io.Memory.peekShort(long address)
930void IntrinsicLocationsBuilderMIPS64::VisitMemoryPeekShortNative(HInvoke* invoke) {
931 CreateIntToIntLocations(arena_, invoke);
932}
933
934void IntrinsicCodeGeneratorMIPS64::VisitMemoryPeekShortNative(HInvoke* invoke) {
935 Mips64Assembler* assembler = GetAssembler();
936 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
937 GpuRegister out = invoke->GetLocations()->Out().AsRegister<GpuRegister>();
938
939 __ Lh(out, adr, 0);
940}
941
942// int libcore.io.Memory.peekInt(long address)
943void IntrinsicLocationsBuilderMIPS64::VisitMemoryPeekIntNative(HInvoke* invoke) {
944 CreateIntToIntLocations(arena_, invoke);
945}
946
947void IntrinsicCodeGeneratorMIPS64::VisitMemoryPeekIntNative(HInvoke* invoke) {
948 Mips64Assembler* assembler = GetAssembler();
949 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
950 GpuRegister out = invoke->GetLocations()->Out().AsRegister<GpuRegister>();
951
952 __ Lw(out, adr, 0);
953}
954
955// long libcore.io.Memory.peekLong(long address)
956void IntrinsicLocationsBuilderMIPS64::VisitMemoryPeekLongNative(HInvoke* invoke) {
957 CreateIntToIntLocations(arena_, invoke);
958}
959
960void IntrinsicCodeGeneratorMIPS64::VisitMemoryPeekLongNative(HInvoke* invoke) {
961 Mips64Assembler* assembler = GetAssembler();
962 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
963 GpuRegister out = invoke->GetLocations()->Out().AsRegister<GpuRegister>();
964
965 __ Ld(out, adr, 0);
966}
967
968static void CreateIntIntToVoidLocations(ArenaAllocator* arena, HInvoke* invoke) {
969 LocationSummary* locations = new (arena) LocationSummary(invoke,
970 LocationSummary::kNoCall,
971 kIntrinsified);
972 locations->SetInAt(0, Location::RequiresRegister());
973 locations->SetInAt(1, Location::RequiresRegister());
974}
975
976// void libcore.io.Memory.pokeByte(long address, byte value)
977void IntrinsicLocationsBuilderMIPS64::VisitMemoryPokeByte(HInvoke* invoke) {
978 CreateIntIntToVoidLocations(arena_, invoke);
979}
980
981void IntrinsicCodeGeneratorMIPS64::VisitMemoryPokeByte(HInvoke* invoke) {
982 Mips64Assembler* assembler = GetAssembler();
983 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
984 GpuRegister val = invoke->GetLocations()->InAt(1).AsRegister<GpuRegister>();
985
986 __ Sb(val, adr, 0);
987}
988
989// void libcore.io.Memory.pokeShort(long address, short value)
990void IntrinsicLocationsBuilderMIPS64::VisitMemoryPokeShortNative(HInvoke* invoke) {
991 CreateIntIntToVoidLocations(arena_, invoke);
992}
993
994void IntrinsicCodeGeneratorMIPS64::VisitMemoryPokeShortNative(HInvoke* invoke) {
995 Mips64Assembler* assembler = GetAssembler();
996 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
997 GpuRegister val = invoke->GetLocations()->InAt(1).AsRegister<GpuRegister>();
998
999 __ Sh(val, adr, 0);
1000}
1001
1002// void libcore.io.Memory.pokeInt(long address, int value)
1003void IntrinsicLocationsBuilderMIPS64::VisitMemoryPokeIntNative(HInvoke* invoke) {
1004 CreateIntIntToVoidLocations(arena_, invoke);
1005}
1006
1007void IntrinsicCodeGeneratorMIPS64::VisitMemoryPokeIntNative(HInvoke* invoke) {
1008 Mips64Assembler* assembler = GetAssembler();
1009 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
1010 GpuRegister val = invoke->GetLocations()->InAt(1).AsRegister<GpuRegister>();
1011
1012 __ Sw(val, adr, 00);
1013}
1014
1015// void libcore.io.Memory.pokeLong(long address, long value)
1016void IntrinsicLocationsBuilderMIPS64::VisitMemoryPokeLongNative(HInvoke* invoke) {
1017 CreateIntIntToVoidLocations(arena_, invoke);
1018}
1019
1020void IntrinsicCodeGeneratorMIPS64::VisitMemoryPokeLongNative(HInvoke* invoke) {
1021 Mips64Assembler* assembler = GetAssembler();
1022 GpuRegister adr = invoke->GetLocations()->InAt(0).AsRegister<GpuRegister>();
1023 GpuRegister val = invoke->GetLocations()->InAt(1).AsRegister<GpuRegister>();
1024
1025 __ Sd(val, adr, 0);
1026}
1027
Chris Larsen49e55392015-09-04 16:04:03 -07001028// Thread java.lang.Thread.currentThread()
1029void IntrinsicLocationsBuilderMIPS64::VisitThreadCurrentThread(HInvoke* invoke) {
1030 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1031 LocationSummary::kNoCall,
1032 kIntrinsified);
1033 locations->SetOut(Location::RequiresRegister());
1034}
1035
1036void IntrinsicCodeGeneratorMIPS64::VisitThreadCurrentThread(HInvoke* invoke) {
1037 Mips64Assembler* assembler = GetAssembler();
1038 GpuRegister out = invoke->GetLocations()->Out().AsRegister<GpuRegister>();
1039
1040 __ LoadFromOffset(kLoadUnsignedWord,
1041 out,
1042 TR,
1043 Thread::PeerOffset<kMips64PointerSize>().Int32Value());
1044}
1045
Chris Larsen1360ada2015-09-04 23:38:16 -07001046static void CreateIntIntIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
1047 LocationSummary* locations = new (arena) LocationSummary(invoke,
1048 LocationSummary::kNoCall,
1049 kIntrinsified);
1050 locations->SetInAt(0, Location::NoLocation()); // Unused receiver.
1051 locations->SetInAt(1, Location::RequiresRegister());
1052 locations->SetInAt(2, Location::RequiresRegister());
1053 locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
1054}
1055
1056static void GenUnsafeGet(HInvoke* invoke,
1057 Primitive::Type type,
1058 bool is_volatile,
1059 CodeGeneratorMIPS64* codegen) {
1060 LocationSummary* locations = invoke->GetLocations();
1061 DCHECK((type == Primitive::kPrimInt) ||
1062 (type == Primitive::kPrimLong) ||
1063 (type == Primitive::kPrimNot));
1064 Mips64Assembler* assembler = codegen->GetAssembler();
1065 // Object pointer.
1066 GpuRegister base = locations->InAt(1).AsRegister<GpuRegister>();
1067 // Long offset.
1068 GpuRegister offset = locations->InAt(2).AsRegister<GpuRegister>();
1069 GpuRegister trg = locations->Out().AsRegister<GpuRegister>();
1070
1071 __ Daddu(TMP, base, offset);
1072 if (is_volatile) {
1073 __ Sync(0);
1074 }
1075 switch (type) {
1076 case Primitive::kPrimInt:
1077 __ Lw(trg, TMP, 0);
1078 break;
1079
1080 case Primitive::kPrimNot:
1081 __ Lwu(trg, TMP, 0);
1082 break;
1083
1084 case Primitive::kPrimLong:
1085 __ Ld(trg, TMP, 0);
1086 break;
1087
1088 default:
1089 LOG(FATAL) << "Unsupported op size " << type;
1090 UNREACHABLE();
1091 }
1092}
1093
1094// int sun.misc.Unsafe.getInt(Object o, long offset)
1095void IntrinsicLocationsBuilderMIPS64::VisitUnsafeGet(HInvoke* invoke) {
1096 CreateIntIntIntToIntLocations(arena_, invoke);
1097}
1098
1099void IntrinsicCodeGeneratorMIPS64::VisitUnsafeGet(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001100 GenUnsafeGet(invoke, Primitive::kPrimInt, /* is_volatile */ false, codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001101}
1102
1103// int sun.misc.Unsafe.getIntVolatile(Object o, long offset)
1104void IntrinsicLocationsBuilderMIPS64::VisitUnsafeGetVolatile(HInvoke* invoke) {
1105 CreateIntIntIntToIntLocations(arena_, invoke);
1106}
1107
1108void IntrinsicCodeGeneratorMIPS64::VisitUnsafeGetVolatile(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001109 GenUnsafeGet(invoke, Primitive::kPrimInt, /* is_volatile */ true, codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001110}
1111
1112// long sun.misc.Unsafe.getLong(Object o, long offset)
1113void IntrinsicLocationsBuilderMIPS64::VisitUnsafeGetLong(HInvoke* invoke) {
1114 CreateIntIntIntToIntLocations(arena_, invoke);
1115}
1116
1117void IntrinsicCodeGeneratorMIPS64::VisitUnsafeGetLong(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001118 GenUnsafeGet(invoke, Primitive::kPrimLong, /* is_volatile */ false, codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001119}
1120
1121// long sun.misc.Unsafe.getLongVolatile(Object o, long offset)
1122void IntrinsicLocationsBuilderMIPS64::VisitUnsafeGetLongVolatile(HInvoke* invoke) {
1123 CreateIntIntIntToIntLocations(arena_, invoke);
1124}
1125
1126void IntrinsicCodeGeneratorMIPS64::VisitUnsafeGetLongVolatile(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001127 GenUnsafeGet(invoke, Primitive::kPrimLong, /* is_volatile */ true, codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001128}
1129
1130// Object sun.misc.Unsafe.getObject(Object o, long offset)
1131void IntrinsicLocationsBuilderMIPS64::VisitUnsafeGetObject(HInvoke* invoke) {
1132 CreateIntIntIntToIntLocations(arena_, invoke);
1133}
1134
1135void IntrinsicCodeGeneratorMIPS64::VisitUnsafeGetObject(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001136 GenUnsafeGet(invoke, Primitive::kPrimNot, /* is_volatile */ false, codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001137}
1138
1139// Object sun.misc.Unsafe.getObjectVolatile(Object o, long offset)
1140void IntrinsicLocationsBuilderMIPS64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
1141 CreateIntIntIntToIntLocations(arena_, invoke);
1142}
1143
1144void IntrinsicCodeGeneratorMIPS64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001145 GenUnsafeGet(invoke, Primitive::kPrimNot, /* is_volatile */ true, codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001146}
1147
1148static void CreateIntIntIntIntToVoid(ArenaAllocator* arena, HInvoke* invoke) {
1149 LocationSummary* locations = new (arena) LocationSummary(invoke,
1150 LocationSummary::kNoCall,
1151 kIntrinsified);
1152 locations->SetInAt(0, Location::NoLocation()); // Unused receiver.
1153 locations->SetInAt(1, Location::RequiresRegister());
1154 locations->SetInAt(2, Location::RequiresRegister());
1155 locations->SetInAt(3, Location::RequiresRegister());
1156}
1157
1158static void GenUnsafePut(LocationSummary* locations,
1159 Primitive::Type type,
1160 bool is_volatile,
1161 bool is_ordered,
1162 CodeGeneratorMIPS64* codegen) {
1163 DCHECK((type == Primitive::kPrimInt) ||
1164 (type == Primitive::kPrimLong) ||
1165 (type == Primitive::kPrimNot));
1166 Mips64Assembler* assembler = codegen->GetAssembler();
1167 // Object pointer.
1168 GpuRegister base = locations->InAt(1).AsRegister<GpuRegister>();
1169 // Long offset.
1170 GpuRegister offset = locations->InAt(2).AsRegister<GpuRegister>();
1171 GpuRegister value = locations->InAt(3).AsRegister<GpuRegister>();
1172
1173 __ Daddu(TMP, base, offset);
1174 if (is_volatile || is_ordered) {
1175 __ Sync(0);
1176 }
1177 switch (type) {
1178 case Primitive::kPrimInt:
1179 case Primitive::kPrimNot:
1180 __ Sw(value, TMP, 0);
1181 break;
1182
1183 case Primitive::kPrimLong:
1184 __ Sd(value, TMP, 0);
1185 break;
1186
1187 default:
1188 LOG(FATAL) << "Unsupported op size " << type;
1189 UNREACHABLE();
1190 }
1191 if (is_volatile) {
1192 __ Sync(0);
1193 }
1194
1195 if (type == Primitive::kPrimNot) {
Goran Jakovljevic8ed18262016-01-22 13:01:00 +01001196 bool value_can_be_null = true; // TODO: Worth finding out this information?
1197 codegen->MarkGCCard(base, value, value_can_be_null);
Chris Larsen1360ada2015-09-04 23:38:16 -07001198 }
1199}
1200
1201// void sun.misc.Unsafe.putInt(Object o, long offset, int x)
1202void IntrinsicLocationsBuilderMIPS64::VisitUnsafePut(HInvoke* invoke) {
1203 CreateIntIntIntIntToVoid(arena_, invoke);
1204}
1205
1206void IntrinsicCodeGeneratorMIPS64::VisitUnsafePut(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001207 GenUnsafePut(invoke->GetLocations(),
1208 Primitive::kPrimInt,
1209 /* is_volatile */ false,
1210 /* is_ordered */ false,
1211 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001212}
1213
1214// void sun.misc.Unsafe.putOrderedInt(Object o, long offset, int x)
1215void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutOrdered(HInvoke* invoke) {
1216 CreateIntIntIntIntToVoid(arena_, invoke);
1217}
1218
1219void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutOrdered(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001220 GenUnsafePut(invoke->GetLocations(),
1221 Primitive::kPrimInt,
1222 /* is_volatile */ false,
1223 /* is_ordered */ true,
1224 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001225}
1226
1227// void sun.misc.Unsafe.putIntVolatile(Object o, long offset, int x)
1228void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutVolatile(HInvoke* invoke) {
1229 CreateIntIntIntIntToVoid(arena_, invoke);
1230}
1231
1232void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutVolatile(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001233 GenUnsafePut(invoke->GetLocations(),
1234 Primitive::kPrimInt,
1235 /* is_volatile */ true,
1236 /* is_ordered */ false,
1237 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001238}
1239
1240// void sun.misc.Unsafe.putObject(Object o, long offset, Object x)
1241void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutObject(HInvoke* invoke) {
1242 CreateIntIntIntIntToVoid(arena_, invoke);
1243}
1244
1245void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutObject(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001246 GenUnsafePut(invoke->GetLocations(),
1247 Primitive::kPrimNot,
1248 /* is_volatile */ false,
1249 /* is_ordered */ false,
1250 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001251}
1252
1253// void sun.misc.Unsafe.putOrderedObject(Object o, long offset, Object x)
1254void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutObjectOrdered(HInvoke* invoke) {
1255 CreateIntIntIntIntToVoid(arena_, invoke);
1256}
1257
1258void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutObjectOrdered(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001259 GenUnsafePut(invoke->GetLocations(),
1260 Primitive::kPrimNot,
1261 /* is_volatile */ false,
1262 /* is_ordered */ true,
1263 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001264}
1265
1266// void sun.misc.Unsafe.putObjectVolatile(Object o, long offset, Object x)
1267void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutObjectVolatile(HInvoke* invoke) {
1268 CreateIntIntIntIntToVoid(arena_, invoke);
1269}
1270
1271void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutObjectVolatile(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001272 GenUnsafePut(invoke->GetLocations(),
1273 Primitive::kPrimNot,
1274 /* is_volatile */ true,
1275 /* is_ordered */ false,
1276 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001277}
1278
1279// void sun.misc.Unsafe.putLong(Object o, long offset, long x)
1280void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutLong(HInvoke* invoke) {
1281 CreateIntIntIntIntToVoid(arena_, invoke);
1282}
1283
1284void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutLong(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001285 GenUnsafePut(invoke->GetLocations(),
1286 Primitive::kPrimLong,
1287 /* is_volatile */ false,
1288 /* is_ordered */ false,
1289 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001290}
1291
1292// void sun.misc.Unsafe.putOrderedLong(Object o, long offset, long x)
1293void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutLongOrdered(HInvoke* invoke) {
1294 CreateIntIntIntIntToVoid(arena_, invoke);
1295}
1296
1297void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutLongOrdered(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001298 GenUnsafePut(invoke->GetLocations(),
1299 Primitive::kPrimLong,
1300 /* is_volatile */ false,
1301 /* is_ordered */ true,
1302 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001303}
1304
1305// void sun.misc.Unsafe.putLongVolatile(Object o, long offset, long x)
1306void IntrinsicLocationsBuilderMIPS64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
1307 CreateIntIntIntIntToVoid(arena_, invoke);
1308}
1309
1310void IntrinsicCodeGeneratorMIPS64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001311 GenUnsafePut(invoke->GetLocations(),
1312 Primitive::kPrimLong,
1313 /* is_volatile */ true,
1314 /* is_ordered */ false,
1315 codegen_);
Chris Larsen1360ada2015-09-04 23:38:16 -07001316}
1317
Chris Larsen36427492015-10-23 02:19:38 -07001318static void CreateIntIntIntIntIntToInt(ArenaAllocator* arena, HInvoke* invoke) {
1319 LocationSummary* locations = new (arena) LocationSummary(invoke,
1320 LocationSummary::kNoCall,
1321 kIntrinsified);
1322 locations->SetInAt(0, Location::NoLocation()); // Unused receiver.
1323 locations->SetInAt(1, Location::RequiresRegister());
1324 locations->SetInAt(2, Location::RequiresRegister());
1325 locations->SetInAt(3, Location::RequiresRegister());
1326 locations->SetInAt(4, Location::RequiresRegister());
1327
1328 locations->SetOut(Location::RequiresRegister());
1329}
1330
1331static void GenCas(LocationSummary* locations, Primitive::Type type, CodeGeneratorMIPS64* codegen) {
1332 Mips64Assembler* assembler = codegen->GetAssembler();
1333 GpuRegister base = locations->InAt(1).AsRegister<GpuRegister>();
1334 GpuRegister offset = locations->InAt(2).AsRegister<GpuRegister>();
1335 GpuRegister expected = locations->InAt(3).AsRegister<GpuRegister>();
1336 GpuRegister value = locations->InAt(4).AsRegister<GpuRegister>();
1337 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
1338
1339 DCHECK_NE(base, out);
1340 DCHECK_NE(offset, out);
1341 DCHECK_NE(expected, out);
1342
Goran Jakovljevic8ed18262016-01-22 13:01:00 +01001343 if (type == Primitive::kPrimNot) {
1344 // Mark card for object assuming new value is stored.
1345 bool value_can_be_null = true; // TODO: Worth finding out this information?
1346 codegen->MarkGCCard(base, value, value_can_be_null);
1347 }
1348
Chris Larsen36427492015-10-23 02:19:38 -07001349 // do {
1350 // tmp_value = [tmp_ptr] - expected;
1351 // } while (tmp_value == 0 && failure([tmp_ptr] <- r_new_value));
1352 // result = tmp_value != 0;
1353
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001354 Mips64Label loop_head, exit_loop;
Chris Larsen36427492015-10-23 02:19:38 -07001355 __ Daddu(TMP, base, offset);
1356 __ Sync(0);
1357 __ Bind(&loop_head);
1358 if (type == Primitive::kPrimLong) {
1359 __ Lld(out, TMP);
1360 } else {
Roland Levillain391b8662015-12-18 11:43:38 +00001361 // Note: We will need a read barrier here, when read barrier
1362 // support is added to the MIPS64 back end.
Chris Larsen36427492015-10-23 02:19:38 -07001363 __ Ll(out, TMP);
1364 }
1365 __ Dsubu(out, out, expected); // If we didn't get the 'expected'
1366 __ Sltiu(out, out, 1); // value, set 'out' to false, and
1367 __ Beqzc(out, &exit_loop); // return.
1368 __ Move(out, value); // Use 'out' for the 'store conditional' instruction.
1369 // If we use 'value' directly, we would lose 'value'
1370 // in the case that the store fails. Whether the
1371 // store succeeds, or fails, it will load the
1372 // correct boolean value into the 'out' register.
1373 if (type == Primitive::kPrimLong) {
1374 __ Scd(out, TMP);
1375 } else {
1376 __ Sc(out, TMP);
1377 }
1378 __ Beqzc(out, &loop_head); // If we couldn't do the read-modify-write
1379 // cycle atomically then retry.
1380 __ Bind(&exit_loop);
1381 __ Sync(0);
1382}
1383
1384// boolean sun.misc.Unsafe.compareAndSwapInt(Object o, long offset, int expected, int x)
1385void IntrinsicLocationsBuilderMIPS64::VisitUnsafeCASInt(HInvoke* invoke) {
1386 CreateIntIntIntIntIntToInt(arena_, invoke);
1387}
1388
1389void IntrinsicCodeGeneratorMIPS64::VisitUnsafeCASInt(HInvoke* invoke) {
1390 GenCas(invoke->GetLocations(), Primitive::kPrimInt, codegen_);
1391}
1392
1393// boolean sun.misc.Unsafe.compareAndSwapLong(Object o, long offset, long expected, long x)
1394void IntrinsicLocationsBuilderMIPS64::VisitUnsafeCASLong(HInvoke* invoke) {
1395 CreateIntIntIntIntIntToInt(arena_, invoke);
1396}
1397
1398void IntrinsicCodeGeneratorMIPS64::VisitUnsafeCASLong(HInvoke* invoke) {
1399 GenCas(invoke->GetLocations(), Primitive::kPrimLong, codegen_);
1400}
1401
1402// boolean sun.misc.Unsafe.compareAndSwapObject(Object o, long offset, Object expected, Object x)
1403void IntrinsicLocationsBuilderMIPS64::VisitUnsafeCASObject(HInvoke* invoke) {
1404 CreateIntIntIntIntIntToInt(arena_, invoke);
1405}
1406
1407void IntrinsicCodeGeneratorMIPS64::VisitUnsafeCASObject(HInvoke* invoke) {
1408 GenCas(invoke->GetLocations(), Primitive::kPrimNot, codegen_);
1409}
1410
Chris Larsen9701c2e2015-09-04 17:22:47 -07001411// char java.lang.String.charAt(int index)
1412void IntrinsicLocationsBuilderMIPS64::VisitStringCharAt(HInvoke* invoke) {
1413 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1414 LocationSummary::kCallOnSlowPath,
1415 kIntrinsified);
1416 locations->SetInAt(0, Location::RequiresRegister());
1417 locations->SetInAt(1, Location::RequiresRegister());
1418 locations->SetOut(Location::SameAsFirstInput());
1419}
1420
1421void IntrinsicCodeGeneratorMIPS64::VisitStringCharAt(HInvoke* invoke) {
1422 LocationSummary* locations = invoke->GetLocations();
1423 Mips64Assembler* assembler = GetAssembler();
1424
1425 // Location of reference to data array
1426 const int32_t value_offset = mirror::String::ValueOffset().Int32Value();
1427 // Location of count
1428 const int32_t count_offset = mirror::String::CountOffset().Int32Value();
1429
1430 GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>();
1431 GpuRegister idx = locations->InAt(1).AsRegister<GpuRegister>();
1432 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
1433
1434 // TODO: Maybe we can support range check elimination. Overall,
1435 // though, I think it's not worth the cost.
1436 // TODO: For simplicity, the index parameter is requested in a
1437 // register, so different from Quick we will not optimize the
1438 // code for constants (which would save a register).
1439
1440 SlowPathCodeMIPS64* slow_path = new (GetAllocator()) IntrinsicSlowPathMIPS64(invoke);
1441 codegen_->AddSlowPath(slow_path);
1442
1443 // Load the string size
1444 __ Lw(TMP, obj, count_offset);
1445 codegen_->MaybeRecordImplicitNullCheck(invoke);
1446 // Revert to slow path if idx is too large, or negative
1447 __ Bgeuc(idx, TMP, slow_path->GetEntryLabel());
1448
1449 // out = obj[2*idx].
1450 __ Sll(TMP, idx, 1); // idx * 2
1451 __ Daddu(TMP, TMP, obj); // Address of char at location idx
1452 __ Lhu(out, TMP, value_offset); // Load char at location idx
1453
1454 __ Bind(slow_path->GetExitLabel());
1455}
1456
1457// int java.lang.String.compareTo(String anotherString)
1458void IntrinsicLocationsBuilderMIPS64::VisitStringCompareTo(HInvoke* invoke) {
1459 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1460 LocationSummary::kCall,
1461 kIntrinsified);
1462 InvokeRuntimeCallingConvention calling_convention;
1463 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1464 locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1465 Location outLocation = calling_convention.GetReturnLocation(Primitive::kPrimInt);
1466 locations->SetOut(Location::RegisterLocation(outLocation.AsRegister<GpuRegister>()));
1467}
1468
1469void IntrinsicCodeGeneratorMIPS64::VisitStringCompareTo(HInvoke* invoke) {
1470 Mips64Assembler* assembler = GetAssembler();
1471 LocationSummary* locations = invoke->GetLocations();
1472
1473 // Note that the null check must have been done earlier.
1474 DCHECK(!invoke->CanDoImplicitNullCheckOn(invoke->InputAt(0)));
1475
1476 GpuRegister argument = locations->InAt(1).AsRegister<GpuRegister>();
1477 SlowPathCodeMIPS64* slow_path = new (GetAllocator()) IntrinsicSlowPathMIPS64(invoke);
1478 codegen_->AddSlowPath(slow_path);
1479 __ Beqzc(argument, slow_path->GetEntryLabel());
1480
1481 __ LoadFromOffset(kLoadDoubleword,
1482 TMP,
1483 TR,
Lazar Trsicd9672662015-09-03 17:33:01 +02001484 QUICK_ENTRYPOINT_OFFSET(kMips64DoublewordSize, pStringCompareTo).Int32Value());
Chris Larsen9701c2e2015-09-04 17:22:47 -07001485 __ Jalr(TMP);
1486 __ Nop();
1487 __ Bind(slow_path->GetExitLabel());
1488}
1489
Chris Larsen972d6d72015-10-20 11:29:12 -07001490// boolean java.lang.String.equals(Object anObject)
1491void IntrinsicLocationsBuilderMIPS64::VisitStringEquals(HInvoke* invoke) {
1492 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1493 LocationSummary::kNoCall,
1494 kIntrinsified);
1495 locations->SetInAt(0, Location::RequiresRegister());
1496 locations->SetInAt(1, Location::RequiresRegister());
1497 locations->SetOut(Location::RequiresRegister());
1498
1499 // Temporary registers to store lengths of strings and for calculations.
1500 locations->AddTemp(Location::RequiresRegister());
1501 locations->AddTemp(Location::RequiresRegister());
1502 locations->AddTemp(Location::RequiresRegister());
1503}
1504
1505void IntrinsicCodeGeneratorMIPS64::VisitStringEquals(HInvoke* invoke) {
1506 Mips64Assembler* assembler = GetAssembler();
1507 LocationSummary* locations = invoke->GetLocations();
1508
1509 GpuRegister str = locations->InAt(0).AsRegister<GpuRegister>();
1510 GpuRegister arg = locations->InAt(1).AsRegister<GpuRegister>();
1511 GpuRegister out = locations->Out().AsRegister<GpuRegister>();
1512
1513 GpuRegister temp1 = locations->GetTemp(0).AsRegister<GpuRegister>();
1514 GpuRegister temp2 = locations->GetTemp(1).AsRegister<GpuRegister>();
1515 GpuRegister temp3 = locations->GetTemp(2).AsRegister<GpuRegister>();
1516
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001517 Mips64Label loop;
1518 Mips64Label end;
1519 Mips64Label return_true;
1520 Mips64Label return_false;
Chris Larsen972d6d72015-10-20 11:29:12 -07001521
1522 // Get offsets of count, value, and class fields within a string object.
1523 const int32_t count_offset = mirror::String::CountOffset().Int32Value();
1524 const int32_t value_offset = mirror::String::ValueOffset().Int32Value();
1525 const int32_t class_offset = mirror::Object::ClassOffset().Int32Value();
1526
1527 // Note that the null check must have been done earlier.
1528 DCHECK(!invoke->CanDoImplicitNullCheckOn(invoke->InputAt(0)));
1529
1530 // If the register containing the pointer to "this", and the register
1531 // containing the pointer to "anObject" are the same register then
1532 // "this", and "anObject" are the same object and we can
1533 // short-circuit the logic to a true result.
1534 if (str == arg) {
1535 __ LoadConst64(out, 1);
1536 return;
1537 }
1538
1539 // Check if input is null, return false if it is.
1540 __ Beqzc(arg, &return_false);
1541
1542 // Reference equality check, return true if same reference.
1543 __ Beqc(str, arg, &return_true);
1544
1545 // Instanceof check for the argument by comparing class fields.
1546 // All string objects must have the same type since String cannot be subclassed.
1547 // Receiver must be a string object, so its class field is equal to all strings' class fields.
1548 // If the argument is a string object, its class field must be equal to receiver's class field.
1549 __ Lw(temp1, str, class_offset);
1550 __ Lw(temp2, arg, class_offset);
1551 __ Bnec(temp1, temp2, &return_false);
1552
1553 // Load lengths of this and argument strings.
1554 __ Lw(temp1, str, count_offset);
1555 __ Lw(temp2, arg, count_offset);
1556 // Check if lengths are equal, return false if they're not.
1557 __ Bnec(temp1, temp2, &return_false);
1558 // Return true if both strings are empty.
1559 __ Beqzc(temp1, &return_true);
1560
1561 // Don't overwrite input registers
1562 __ Move(TMP, str);
1563 __ Move(temp3, arg);
1564
1565 // Assertions that must hold in order to compare strings 4 characters at a time.
1566 DCHECK_ALIGNED(value_offset, 8);
1567 static_assert(IsAligned<8>(kObjectAlignment), "String of odd length is not zero padded");
1568
1569 // Loop to compare strings 4 characters at a time starting at the beginning of the string.
1570 // Ok to do this because strings are zero-padded to be 8-byte aligned.
1571 __ Bind(&loop);
1572 __ Ld(out, TMP, value_offset);
1573 __ Ld(temp2, temp3, value_offset);
1574 __ Bnec(out, temp2, &return_false);
1575 __ Daddiu(TMP, TMP, 8);
1576 __ Daddiu(temp3, temp3, 8);
1577 __ Addiu(temp1, temp1, -4);
1578 __ Bgtzc(temp1, &loop);
1579
1580 // Return true and exit the function.
1581 // If loop does not result in returning false, we return true.
1582 __ Bind(&return_true);
1583 __ LoadConst64(out, 1);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001584 __ Bc(&end);
Chris Larsen972d6d72015-10-20 11:29:12 -07001585
1586 // Return false and exit the function.
1587 __ Bind(&return_false);
1588 __ LoadConst64(out, 0);
1589 __ Bind(&end);
1590}
1591
Chris Larsen9701c2e2015-09-04 17:22:47 -07001592static void GenerateStringIndexOf(HInvoke* invoke,
1593 Mips64Assembler* assembler,
1594 CodeGeneratorMIPS64* codegen,
1595 ArenaAllocator* allocator,
1596 bool start_at_zero) {
1597 LocationSummary* locations = invoke->GetLocations();
1598 GpuRegister tmp_reg = start_at_zero ? locations->GetTemp(0).AsRegister<GpuRegister>() : TMP;
1599
1600 // Note that the null check must have been done earlier.
1601 DCHECK(!invoke->CanDoImplicitNullCheckOn(invoke->InputAt(0)));
1602
1603 // Check for code points > 0xFFFF. Either a slow-path check when we
1604 // don't know statically, or directly dispatch if we have a constant.
1605 SlowPathCodeMIPS64* slow_path = nullptr;
1606 if (invoke->InputAt(1)->IsIntConstant()) {
1607 if (!IsUint<16>(invoke->InputAt(1)->AsIntConstant()->GetValue())) {
1608 // Always needs the slow-path. We could directly dispatch to it,
1609 // but this case should be rare, so for simplicity just put the
1610 // full slow-path down and branch unconditionally.
1611 slow_path = new (allocator) IntrinsicSlowPathMIPS64(invoke);
1612 codegen->AddSlowPath(slow_path);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001613 __ Bc(slow_path->GetEntryLabel());
Chris Larsen9701c2e2015-09-04 17:22:47 -07001614 __ Bind(slow_path->GetExitLabel());
1615 return;
1616 }
1617 } else {
1618 GpuRegister char_reg = locations->InAt(1).AsRegister<GpuRegister>();
1619 __ LoadConst32(tmp_reg, std::numeric_limits<uint16_t>::max());
1620 slow_path = new (allocator) IntrinsicSlowPathMIPS64(invoke);
1621 codegen->AddSlowPath(slow_path);
1622 __ Bltuc(tmp_reg, char_reg, slow_path->GetEntryLabel()); // UTF-16 required
1623 }
1624
1625 if (start_at_zero) {
1626 DCHECK_EQ(tmp_reg, A2);
1627 // Start-index = 0.
1628 __ Clear(tmp_reg);
1629 } else {
1630 __ Slt(TMP, A2, ZERO); // if fromIndex < 0
1631 __ Seleqz(A2, A2, TMP); // fromIndex = 0
1632 }
1633
1634 __ LoadFromOffset(kLoadDoubleword,
1635 TMP,
1636 TR,
Lazar Trsicd9672662015-09-03 17:33:01 +02001637 QUICK_ENTRYPOINT_OFFSET(kMips64DoublewordSize, pIndexOf).Int32Value());
Chris Larsen9701c2e2015-09-04 17:22:47 -07001638 __ Jalr(TMP);
1639 __ Nop();
1640
1641 if (slow_path != nullptr) {
1642 __ Bind(slow_path->GetExitLabel());
1643 }
1644}
1645
1646// int java.lang.String.indexOf(int ch)
1647void IntrinsicLocationsBuilderMIPS64::VisitStringIndexOf(HInvoke* invoke) {
1648 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1649 LocationSummary::kCall,
1650 kIntrinsified);
1651 // We have a hand-crafted assembly stub that follows the runtime
1652 // calling convention. So it's best to align the inputs accordingly.
1653 InvokeRuntimeCallingConvention calling_convention;
1654 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1655 locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1656 Location outLocation = calling_convention.GetReturnLocation(Primitive::kPrimInt);
1657 locations->SetOut(Location::RegisterLocation(outLocation.AsRegister<GpuRegister>()));
1658
1659 // Need a temp for slow-path codepoint compare, and need to send start-index=0.
1660 locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(2)));
1661}
1662
1663void IntrinsicCodeGeneratorMIPS64::VisitStringIndexOf(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001664 GenerateStringIndexOf(invoke, GetAssembler(), codegen_, GetAllocator(), /* start_at_zero */ true);
Chris Larsen9701c2e2015-09-04 17:22:47 -07001665}
1666
1667// int java.lang.String.indexOf(int ch, int fromIndex)
1668void IntrinsicLocationsBuilderMIPS64::VisitStringIndexOfAfter(HInvoke* invoke) {
1669 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1670 LocationSummary::kCall,
1671 kIntrinsified);
1672 // We have a hand-crafted assembly stub that follows the runtime
1673 // calling convention. So it's best to align the inputs accordingly.
1674 InvokeRuntimeCallingConvention calling_convention;
1675 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1676 locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1677 locations->SetInAt(2, Location::RegisterLocation(calling_convention.GetRegisterAt(2)));
1678 Location outLocation = calling_convention.GetReturnLocation(Primitive::kPrimInt);
1679 locations->SetOut(Location::RegisterLocation(outLocation.AsRegister<GpuRegister>()));
1680}
1681
1682void IntrinsicCodeGeneratorMIPS64::VisitStringIndexOfAfter(HInvoke* invoke) {
Roland Levillainbf84a3d2015-12-04 14:33:02 +00001683 GenerateStringIndexOf(
1684 invoke, GetAssembler(), codegen_, GetAllocator(), /* start_at_zero */ false);
Chris Larsen9701c2e2015-09-04 17:22:47 -07001685}
1686
1687// java.lang.String.String(byte[] bytes)
1688void IntrinsicLocationsBuilderMIPS64::VisitStringNewStringFromBytes(HInvoke* invoke) {
1689 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1690 LocationSummary::kCall,
1691 kIntrinsified);
1692 InvokeRuntimeCallingConvention calling_convention;
1693 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1694 locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1695 locations->SetInAt(2, Location::RegisterLocation(calling_convention.GetRegisterAt(2)));
1696 locations->SetInAt(3, Location::RegisterLocation(calling_convention.GetRegisterAt(3)));
1697 Location outLocation = calling_convention.GetReturnLocation(Primitive::kPrimInt);
1698 locations->SetOut(Location::RegisterLocation(outLocation.AsRegister<GpuRegister>()));
1699}
1700
1701void IntrinsicCodeGeneratorMIPS64::VisitStringNewStringFromBytes(HInvoke* invoke) {
1702 Mips64Assembler* assembler = GetAssembler();
1703 LocationSummary* locations = invoke->GetLocations();
1704
1705 GpuRegister byte_array = locations->InAt(0).AsRegister<GpuRegister>();
1706 SlowPathCodeMIPS64* slow_path = new (GetAllocator()) IntrinsicSlowPathMIPS64(invoke);
1707 codegen_->AddSlowPath(slow_path);
1708 __ Beqzc(byte_array, slow_path->GetEntryLabel());
1709
1710 __ LoadFromOffset(kLoadDoubleword,
1711 TMP,
1712 TR,
Lazar Trsicd9672662015-09-03 17:33:01 +02001713 QUICK_ENTRYPOINT_OFFSET(kMips64DoublewordSize,
1714 pAllocStringFromBytes).Int32Value());
Chris Larsen9701c2e2015-09-04 17:22:47 -07001715 codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
1716 __ Jalr(TMP);
1717 __ Nop();
1718 __ Bind(slow_path->GetExitLabel());
1719}
1720
1721// java.lang.String.String(char[] value)
1722void IntrinsicLocationsBuilderMIPS64::VisitStringNewStringFromChars(HInvoke* invoke) {
1723 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1724 LocationSummary::kCall,
1725 kIntrinsified);
1726 InvokeRuntimeCallingConvention calling_convention;
1727 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1728 locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1729 locations->SetInAt(2, Location::RegisterLocation(calling_convention.GetRegisterAt(2)));
1730 Location outLocation = calling_convention.GetReturnLocation(Primitive::kPrimInt);
1731 locations->SetOut(Location::RegisterLocation(outLocation.AsRegister<GpuRegister>()));
1732}
1733
1734void IntrinsicCodeGeneratorMIPS64::VisitStringNewStringFromChars(HInvoke* invoke) {
1735 Mips64Assembler* assembler = GetAssembler();
1736
1737 __ LoadFromOffset(kLoadDoubleword,
1738 TMP,
1739 TR,
Lazar Trsicd9672662015-09-03 17:33:01 +02001740 QUICK_ENTRYPOINT_OFFSET(kMips64DoublewordSize,
1741 pAllocStringFromChars).Int32Value());
Chris Larsen9701c2e2015-09-04 17:22:47 -07001742 codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
1743 __ Jalr(TMP);
1744 __ Nop();
1745}
1746
1747// java.lang.String.String(String original)
1748void IntrinsicLocationsBuilderMIPS64::VisitStringNewStringFromString(HInvoke* invoke) {
1749 LocationSummary* locations = new (arena_) LocationSummary(invoke,
1750 LocationSummary::kCall,
1751 kIntrinsified);
1752 InvokeRuntimeCallingConvention calling_convention;
1753 locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0)));
1754 locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1)));
1755 locations->SetInAt(2, Location::RegisterLocation(calling_convention.GetRegisterAt(2)));
1756 Location outLocation = calling_convention.GetReturnLocation(Primitive::kPrimInt);
1757 locations->SetOut(Location::RegisterLocation(outLocation.AsRegister<GpuRegister>()));
1758}
1759
1760void IntrinsicCodeGeneratorMIPS64::VisitStringNewStringFromString(HInvoke* invoke) {
1761 Mips64Assembler* assembler = GetAssembler();
1762 LocationSummary* locations = invoke->GetLocations();
1763
1764 GpuRegister string_to_copy = locations->InAt(0).AsRegister<GpuRegister>();
1765 SlowPathCodeMIPS64* slow_path = new (GetAllocator()) IntrinsicSlowPathMIPS64(invoke);
1766 codegen_->AddSlowPath(slow_path);
1767 __ Beqzc(string_to_copy, slow_path->GetEntryLabel());
1768
1769 __ LoadFromOffset(kLoadDoubleword,
1770 TMP,
1771 TR,
Lazar Trsicd9672662015-09-03 17:33:01 +02001772 QUICK_ENTRYPOINT_OFFSET(kMips64DoublewordSize,
1773 pAllocStringFromString).Int32Value());
Chris Larsen9701c2e2015-09-04 17:22:47 -07001774 codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
1775 __ Jalr(TMP);
1776 __ Nop();
1777 __ Bind(slow_path->GetExitLabel());
1778}
1779
Chris Larsen3039e382015-08-26 07:54:08 -07001780// Unimplemented intrinsics.
1781
1782#define UNIMPLEMENTED_INTRINSIC(Name) \
1783void IntrinsicLocationsBuilderMIPS64::Visit ## Name(HInvoke* invoke ATTRIBUTE_UNUSED) { \
1784} \
1785void IntrinsicCodeGeneratorMIPS64::Visit ## Name(HInvoke* invoke ATTRIBUTE_UNUSED) { \
1786}
1787
Aart Bik3f67e692016-01-15 14:35:12 -08001788UNIMPLEMENTED_INTRINSIC(IntegerBitCount)
1789UNIMPLEMENTED_INTRINSIC(LongBitCount)
1790
Chris Larsen3039e382015-08-26 07:54:08 -07001791UNIMPLEMENTED_INTRINSIC(MathRoundDouble)
1792UNIMPLEMENTED_INTRINSIC(MathRoundFloat)
Chris Larsen0b7ac982015-09-04 12:54:28 -07001793
Chris Larsen3039e382015-08-26 07:54:08 -07001794UNIMPLEMENTED_INTRINSIC(ReferenceGetReferent)
1795UNIMPLEMENTED_INTRINSIC(StringGetCharsNoCheck)
1796UNIMPLEMENTED_INTRINSIC(SystemArrayCopyChar)
Nicolas Geoffrayee3cf072015-10-06 11:45:02 +01001797UNIMPLEMENTED_INTRINSIC(SystemArrayCopy)
Chris Larsen3039e382015-08-26 07:54:08 -07001798
Mark Mendella4f12202015-08-06 15:23:34 -04001799UNIMPLEMENTED_INTRINSIC(MathCos)
1800UNIMPLEMENTED_INTRINSIC(MathSin)
1801UNIMPLEMENTED_INTRINSIC(MathAcos)
1802UNIMPLEMENTED_INTRINSIC(MathAsin)
1803UNIMPLEMENTED_INTRINSIC(MathAtan)
1804UNIMPLEMENTED_INTRINSIC(MathAtan2)
1805UNIMPLEMENTED_INTRINSIC(MathCbrt)
1806UNIMPLEMENTED_INTRINSIC(MathCosh)
1807UNIMPLEMENTED_INTRINSIC(MathExp)
1808UNIMPLEMENTED_INTRINSIC(MathExpm1)
1809UNIMPLEMENTED_INTRINSIC(MathHypot)
1810UNIMPLEMENTED_INTRINSIC(MathLog)
1811UNIMPLEMENTED_INTRINSIC(MathLog10)
1812UNIMPLEMENTED_INTRINSIC(MathNextAfter)
1813UNIMPLEMENTED_INTRINSIC(MathSinh)
1814UNIMPLEMENTED_INTRINSIC(MathTan)
1815UNIMPLEMENTED_INTRINSIC(MathTanh)
1816
Aart Bik59c94542016-01-25 14:20:58 -08001817UNIMPLEMENTED_INTRINSIC(FloatIsInfinite)
1818UNIMPLEMENTED_INTRINSIC(DoubleIsInfinite)
Aart Bik59c94542016-01-25 14:20:58 -08001819
Aart Bik59c94542016-01-25 14:20:58 -08001820UNIMPLEMENTED_INTRINSIC(IntegerHighestOneBit)
1821UNIMPLEMENTED_INTRINSIC(LongHighestOneBit)
1822UNIMPLEMENTED_INTRINSIC(IntegerLowestOneBit)
1823UNIMPLEMENTED_INTRINSIC(LongLowestOneBit)
Aart Bika19616e2016-02-01 18:57:58 -08001824
1825// Handled as HIR instructions.
Aart Bik75a38b22016-02-17 10:41:50 -08001826UNIMPLEMENTED_INTRINSIC(FloatIsNaN)
1827UNIMPLEMENTED_INTRINSIC(DoubleIsNaN)
Aart Bika19616e2016-02-01 18:57:58 -08001828UNIMPLEMENTED_INTRINSIC(IntegerCompare)
1829UNIMPLEMENTED_INTRINSIC(LongCompare)
Aart Bik59c94542016-01-25 14:20:58 -08001830UNIMPLEMENTED_INTRINSIC(IntegerSignum)
1831UNIMPLEMENTED_INTRINSIC(LongSignum)
1832
Chris Larsen3039e382015-08-26 07:54:08 -07001833#undef UNIMPLEMENTED_INTRINSIC
1834
1835#undef __
1836
1837} // namespace mips64
1838} // namespace art