2012-03-13 16:18:30 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2010-02-04 20:36:58 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2015-02-09 20:49:46 +00:00
|
|
|
#include <iostream> // NOLINT(readability/streams)
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/v8.h"
|
2010-02-04 20:36:58 +00:00
|
|
|
|
2015-04-21 10:21:50 +00:00
|
|
|
#include "src/base/utils/random-number-generator.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/disassembler.h"
|
|
|
|
#include "src/factory.h"
|
|
|
|
#include "src/macro-assembler.h"
|
|
|
|
#include "src/mips/macro-assembler-mips.h"
|
|
|
|
#include "src/mips/simulator-mips.h"
|
2010-02-04 20:36:58 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "test/cctest/cctest.h"
|
2010-02-04 20:36:58 +00:00
|
|
|
|
2015-02-09 20:49:46 +00:00
|
|
|
|
2010-02-04 20:36:58 +00:00
|
|
|
using namespace v8::internal;
|
|
|
|
|
|
|
|
|
|
|
|
// Define these function prototypes to match JSEntryFunction in execution.cc.
|
|
|
|
typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4);
|
|
|
|
typedef Object* (*F2)(int x, int y, int p2, int p3, int p4);
|
|
|
|
typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4);
|
2017-05-25 14:51:07 +00:00
|
|
|
typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4);
|
2010-02-04 20:36:58 +00:00
|
|
|
|
|
|
|
#define __ assm.
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2010-02-04 20:36:58 +00:00
|
|
|
TEST(MIPS0) {
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2010-02-04 20:36:58 +00:00
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2010-02-04 20:36:58 +00:00
|
|
|
|
|
|
|
// Addition.
|
|
|
|
__ addu(v0, a0, a1);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
2015-11-23 08:09:34 +00:00
|
|
|
int res = reinterpret_cast<int>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0xab0, 0xc, 0, 0, 0));
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0xabc), res);
|
2010-02-04 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS1) {
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2010-02-04 20:36:58 +00:00
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2010-02-04 20:36:58 +00:00
|
|
|
Label L, C;
|
|
|
|
|
|
|
|
__ mov(a1, a0);
|
|
|
|
__ li(v0, 0);
|
|
|
|
__ b(&C);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ bind(&L);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ addu(v0, v0, a1);
|
2010-02-04 20:36:58 +00:00
|
|
|
__ addiu(a1, a1, -1);
|
|
|
|
|
|
|
|
__ bind(&C);
|
|
|
|
__ xori(v1, a1, 0);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&L, ne, v1, Operand(0));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F1 f = FUNCTION_CAST<F1>(code->entry());
|
2015-11-23 08:09:34 +00:00
|
|
|
int res = reinterpret_cast<int>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 50, 0, 0, 0, 0));
|
2010-02-04 20:36:58 +00:00
|
|
|
CHECK_EQ(1275, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS2) {
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2010-02-04 20:36:58 +00:00
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2010-02-04 20:36:58 +00:00
|
|
|
|
|
|
|
Label exit, error;
|
|
|
|
|
|
|
|
// ----- Test all instructions.
|
|
|
|
|
|
|
|
// Test lui, ori, and addiu, used in the li pseudo-instruction.
|
|
|
|
// This way we can then safely load registers with chosen values.
|
|
|
|
|
|
|
|
__ ori(t0, zero_reg, 0);
|
|
|
|
__ lui(t0, 0x1234);
|
|
|
|
__ ori(t0, t0, 0);
|
|
|
|
__ ori(t0, t0, 0x0f0f);
|
|
|
|
__ ori(t0, t0, 0xf0f0);
|
|
|
|
__ addiu(t1, t0, 1);
|
|
|
|
__ addiu(t2, t1, -0x10);
|
|
|
|
|
|
|
|
// Load values in temporary registers.
|
|
|
|
__ li(t0, 0x00000004);
|
|
|
|
__ li(t1, 0x00001234);
|
|
|
|
__ li(t2, 0x12345678);
|
|
|
|
__ li(t3, 0x7fffffff);
|
|
|
|
__ li(t4, 0xfffffffc);
|
|
|
|
__ li(t5, 0xffffedcc);
|
|
|
|
__ li(t6, 0xedcba988);
|
|
|
|
__ li(t7, 0x80000000);
|
|
|
|
|
|
|
|
// SPECIAL class.
|
|
|
|
__ srl(v0, t2, 8); // 0x00123456
|
|
|
|
__ sll(v0, v0, 11); // 0x91a2b000
|
|
|
|
__ sra(v0, v0, 3); // 0xf2345600
|
|
|
|
__ srav(v0, v0, t0); // 0xff234560
|
|
|
|
__ sllv(v0, v0, t0); // 0xf2345600
|
|
|
|
__ srlv(v0, v0, t0); // 0x0f234560
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(0x0f234560));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
|
2011-03-28 13:05:36 +00:00
|
|
|
__ addu(v0, t0, t1); // 0x00001238
|
|
|
|
__ subu(v0, v0, t0); // 0x00001234
|
|
|
|
__ Branch(&error, ne, v0, Operand(0x00001234));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
__ addu(v1, t3, t0);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v1, Operand(0x80000003));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
__ subu(v1, t7, t0); // 0x7ffffffc
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v1, Operand(0x7ffffffc));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ and_(v0, t1, t2); // 0x00001230
|
|
|
|
__ or_(v0, v0, t1); // 0x00001234
|
|
|
|
__ xor_(v0, v0, t2); // 0x1234444c
|
|
|
|
__ nor(v0, v0, t2); // 0xedcba987
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(0xedcba983));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ slt(v0, t7, t3);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(0x1));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
__ sltu(v0, t7, t3);
|
2014-08-12 19:04:15 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(zero_reg));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
// End of SPECIAL class.
|
|
|
|
|
2011-03-28 13:05:36 +00:00
|
|
|
__ addiu(v0, zero_reg, 0x7421); // 0x00007421
|
|
|
|
__ addiu(v0, v0, -0x1); // 0x00007420
|
2010-02-04 20:36:58 +00:00
|
|
|
__ addiu(v0, v0, -0x20); // 0x00007400
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(0x00007400));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
__ addiu(v1, t3, 0x1); // 0x80000000
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v1, Operand(0x80000000));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ slti(v0, t1, 0x00002000); // 0x1
|
|
|
|
__ slti(v0, v0, 0xffff8000); // 0x0
|
2014-08-12 19:04:15 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(zero_reg));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
__ sltiu(v0, t1, 0x00002000); // 0x1
|
|
|
|
__ sltiu(v0, v0, 0x00008000); // 0x1
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(0x1));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ andi(v0, t1, 0xf0f0); // 0x00001030
|
|
|
|
__ ori(v0, v0, 0x8a00); // 0x00009a30
|
|
|
|
__ xori(v0, v0, 0x83cc); // 0x000019fc
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v0, Operand(0x000019fc));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
__ lui(v1, 0x8123); // 0x81230000
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, v1, Operand(0x81230000));
|
2010-02-04 20:36:58 +00:00
|
|
|
__ nop();
|
|
|
|
|
2011-03-28 13:05:36 +00:00
|
|
|
// Bit twiddling instructions & conditional moves.
|
|
|
|
// Uses t0-t7 as set above.
|
2012-03-13 16:18:30 +00:00
|
|
|
__ Clz(v0, t0); // 29
|
|
|
|
__ Clz(v1, t1); // 19
|
2011-03-28 13:05:36 +00:00
|
|
|
__ addu(v0, v0, v1); // 48
|
2012-03-13 16:18:30 +00:00
|
|
|
__ Clz(v1, t2); // 3
|
2011-03-28 13:05:36 +00:00
|
|
|
__ addu(v0, v0, v1); // 51
|
2012-03-13 16:18:30 +00:00
|
|
|
__ Clz(v1, t7); // 0
|
2011-03-28 13:05:36 +00:00
|
|
|
__ addu(v0, v0, v1); // 51
|
|
|
|
__ Branch(&error, ne, v0, Operand(51));
|
2012-03-13 16:18:30 +00:00
|
|
|
__ Movn(a0, t3, t0); // Move a0<-t3 (t0 is NOT 0).
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Ins(a0, t1, 12, 8); // 0x7ff34fff
|
|
|
|
__ Branch(&error, ne, a0, Operand(0x7ff34fff));
|
2012-03-13 16:18:30 +00:00
|
|
|
__ Movz(a0, t6, t7); // a0 not updated (t7 is NOT 0).
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Ext(a1, a0, 8, 12); // 0x34f
|
|
|
|
__ Branch(&error, ne, a1, Operand(0x34f));
|
2012-03-13 16:18:30 +00:00
|
|
|
__ Movz(a0, t6, v1); // a0<-t6, v0 is 0, from 8 instr back.
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&error, ne, a0, Operand(t6));
|
|
|
|
|
2010-02-04 20:36:58 +00:00
|
|
|
// Everything was correctly executed. Load the expected result.
|
|
|
|
__ li(v0, 0x31415926);
|
|
|
|
__ b(&exit);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ bind(&error);
|
|
|
|
// Got an error. Return a wrong result.
|
2011-03-28 13:05:36 +00:00
|
|
|
__ li(v0, 666);
|
2010-02-04 20:36:58 +00:00
|
|
|
|
|
|
|
__ bind(&exit);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
2015-11-23 08:09:34 +00:00
|
|
|
int res = reinterpret_cast<int>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0xab0, 0xc, 0, 0, 0));
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x31415926), res);
|
2010-02-04 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
TEST(MIPS3) {
|
|
|
|
// Test floating point instructions.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
double c;
|
|
|
|
double d;
|
|
|
|
double e;
|
|
|
|
double f;
|
|
|
|
double g;
|
2013-01-09 12:31:34 +00:00
|
|
|
double h;
|
|
|
|
double i;
|
2015-03-31 18:25:54 +00:00
|
|
|
float fa;
|
|
|
|
float fb;
|
|
|
|
float fc;
|
|
|
|
float fd;
|
|
|
|
float fe;
|
|
|
|
float ff;
|
|
|
|
float fg;
|
2011-03-28 13:05:36 +00:00
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
|
|
|
// Create a function that accepts &t, and loads, manipulates, and stores
|
|
|
|
// the doubles t.a ... t.f.
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
Label L, C;
|
|
|
|
|
2015-03-31 18:25:54 +00:00
|
|
|
// Double precision floating point instructions.
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, a)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(T, b)));
|
2013-04-16 11:33:02 +00:00
|
|
|
__ add_d(f8, f4, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f8, MemOperand(a0, offsetof(T, c))); // c = a + b.
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ mov_d(f10, f8); // c
|
|
|
|
__ neg_d(f12, f6); // -b
|
|
|
|
__ sub_d(f10, f10, f12);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(T, d))); // d = c - (-b).
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f4, MemOperand(a0, offsetof(T, b))); // b = a.
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ li(t0, 120);
|
|
|
|
__ mtc1(t0, f14);
|
|
|
|
__ cvt_d_w(f14, f14); // f14 = 120.0.
|
|
|
|
__ mul_d(f10, f10, f14);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(T, e))); // e = d * 120 = 1.8066e16.
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ div_d(f12, f10, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(T, f))); // f = e / a = 120.44.
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ sqrt_d(f14, f12);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f14, MemOperand(a0, offsetof(T, g)));
|
2013-04-16 11:33:02 +00:00
|
|
|
// g = sqrt(f) = 10.97451593465515908537
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2014-08-12 19:04:15 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r2)) {
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, h)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(T, i)));
|
2013-01-09 12:31:34 +00:00
|
|
|
__ madd_d(f14, f6, f4, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f14, MemOperand(a0, offsetof(T, h)));
|
2013-01-09 12:31:34 +00:00
|
|
|
}
|
|
|
|
|
2015-03-31 18:25:54 +00:00
|
|
|
// Single precision floating point instructions.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fa)) );
|
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(T, fb)) );
|
2015-03-31 18:25:54 +00:00
|
|
|
__ add_s(f8, f4, f6);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(T, fc)) ); // fc = fa + fb.
|
2015-03-31 18:25:54 +00:00
|
|
|
|
|
|
|
__ neg_s(f10, f6); // -fb
|
|
|
|
__ sub_s(f10, f8, f10);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(T, fd)) ); // fd = fc - (-fb).
|
2015-03-31 18:25:54 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f4, MemOperand(a0, offsetof(T, fb)) ); // fb = fa.
|
2015-03-31 18:25:54 +00:00
|
|
|
|
|
|
|
__ li(t0, 120);
|
|
|
|
__ mtc1(t0, f14);
|
|
|
|
__ cvt_s_w(f14, f14); // f14 = 120.0.
|
|
|
|
__ mul_s(f10, f10, f14);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(T, fe)) ); // fe = fd * 120
|
2015-03-31 18:25:54 +00:00
|
|
|
|
|
|
|
__ div_s(f12, f10, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(T, ff)) ); // ff = fe / fa
|
2015-03-31 18:25:54 +00:00
|
|
|
|
|
|
|
__ sqrt_s(f14, f12);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f14, MemOperand(a0, offsetof(T, fg)) );
|
2015-03-31 18:25:54 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-03-31 18:25:54 +00:00
|
|
|
// Double test values.
|
2013-04-16 11:33:02 +00:00
|
|
|
t.a = 1.5e14;
|
|
|
|
t.b = 2.75e11;
|
|
|
|
t.c = 0.0;
|
|
|
|
t.d = 0.0;
|
|
|
|
t.e = 0.0;
|
|
|
|
t.f = 0.0;
|
|
|
|
t.h = 1.5;
|
|
|
|
t.i = 2.75;
|
2015-03-31 18:25:54 +00:00
|
|
|
// Single test values.
|
|
|
|
t.fa = 1.5e6;
|
|
|
|
t.fb = 2.75e4;
|
|
|
|
t.fc = 0.0;
|
|
|
|
t.fd = 0.0;
|
|
|
|
t.fe = 0.0;
|
|
|
|
t.ff = 0.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2013-04-16 11:33:02 +00:00
|
|
|
USE(dummy);
|
2015-03-31 18:25:54 +00:00
|
|
|
// Expected double results.
|
2013-04-16 11:33:02 +00:00
|
|
|
CHECK_EQ(1.5e14, t.a);
|
|
|
|
CHECK_EQ(1.5e14, t.b);
|
|
|
|
CHECK_EQ(1.50275e14, t.c);
|
|
|
|
CHECK_EQ(1.50550e14, t.d);
|
|
|
|
CHECK_EQ(1.8066e16, t.e);
|
|
|
|
CHECK_EQ(120.44, t.f);
|
|
|
|
CHECK_EQ(10.97451593465515908537, t.g);
|
2014-08-12 19:04:15 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r2)) {
|
2013-06-19 17:15:21 +00:00
|
|
|
CHECK_EQ(6.875, t.h);
|
|
|
|
}
|
2015-03-31 18:25:54 +00:00
|
|
|
// Expected single results.
|
|
|
|
CHECK_EQ(1.5e6, t.fa);
|
|
|
|
CHECK_EQ(1.5e6, t.fb);
|
|
|
|
CHECK_EQ(1.5275e06, t.fc);
|
|
|
|
CHECK_EQ(1.5550e06, t.fd);
|
|
|
|
CHECK_EQ(1.866e08, t.fe);
|
|
|
|
CHECK_EQ(124.40000152587890625, t.ff);
|
|
|
|
CHECK_EQ(11.1534748077392578125, t.fg);
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS4) {
|
2016-02-08 09:43:58 +00:00
|
|
|
// Exchange between GP anf FP registers is done through memory
|
|
|
|
// on FPXX compiled binaries and architectures that do not support
|
|
|
|
// MTHC1 and MTFC1. If this is the case, skipping this test.
|
|
|
|
if (IsFpxxMode() &&
|
|
|
|
(IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-28 13:05:36 +00:00
|
|
|
// Test moves between floating point and integer registers.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
double c;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
Label L, C;
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, a)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(T, b)));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Swap f4 and f6, by using four integer registers, t0-t3.
|
2016-02-08 09:43:58 +00:00
|
|
|
if (IsFp32Mode()) {
|
2014-08-12 19:04:15 +00:00
|
|
|
__ mfc1(t0, f4);
|
|
|
|
__ mfc1(t1, f5);
|
|
|
|
__ mfc1(t2, f6);
|
|
|
|
__ mfc1(t3, f7);
|
|
|
|
|
|
|
|
__ mtc1(t0, f6);
|
|
|
|
__ mtc1(t1, f7);
|
|
|
|
__ mtc1(t2, f4);
|
|
|
|
__ mtc1(t3, f5);
|
|
|
|
} else {
|
2015-12-07 05:36:41 +00:00
|
|
|
CHECK(!IsMipsArchVariant(kMips32r1) && !IsMipsArchVariant(kLoongson));
|
2016-02-08 09:43:58 +00:00
|
|
|
DCHECK(IsFp64Mode() || IsFpxxMode());
|
2014-08-12 19:04:15 +00:00
|
|
|
__ mfc1(t0, f4);
|
|
|
|
__ mfhc1(t1, f4);
|
|
|
|
__ mfc1(t2, f6);
|
|
|
|
__ mfhc1(t3, f6);
|
|
|
|
|
|
|
|
__ mtc1(t0, f6);
|
|
|
|
__ mthc1(t1, f6);
|
|
|
|
__ mtc1(t2, f4);
|
|
|
|
__ mthc1(t3, f4);
|
|
|
|
}
|
2016-02-08 09:43:58 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Store the swapped f4 and f5 back to memory.
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f4, MemOperand(a0, offsetof(T, a)));
|
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, c)));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2013-04-16 11:33:02 +00:00
|
|
|
t.a = 1.5e22;
|
|
|
|
t.b = 2.75e11;
|
|
|
|
t.c = 17.17;
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2013-04-16 11:33:02 +00:00
|
|
|
USE(dummy);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CHECK_EQ(2.75e11, t.a);
|
|
|
|
CHECK_EQ(2.75e11, t.b);
|
|
|
|
CHECK_EQ(1.5e22, t.c);
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS5) {
|
|
|
|
// Test conversions between doubles and integers.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
Label L, C;
|
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Load all structure elements to registers.
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, a)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(T, b)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, i)) );
|
|
|
|
__ lw(t1, MemOperand(a0, offsetof(T, j)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Convert double in f4 to int in element i.
|
|
|
|
__ cvt_w_d(f8, f4);
|
|
|
|
__ mfc1(t2, f8);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, i)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Convert double in f6 to int in element j.
|
|
|
|
__ cvt_w_d(f10, f6);
|
|
|
|
__ mfc1(t3, f10);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, j)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Convert int in original i (t0) to double in a.
|
|
|
|
__ mtc1(t0, f12);
|
|
|
|
__ cvt_d_w(f0, f12);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f0, MemOperand(a0, offsetof(T, a)));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Convert int in original j (t1) to double in b.
|
|
|
|
__ mtc1(t1, f14);
|
|
|
|
__ cvt_d_w(f2, f14);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(T, b)));
|
2013-04-16 11:33:02 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2013-04-16 11:33:02 +00:00
|
|
|
t.a = 1.5e4;
|
|
|
|
t.b = 2.75e8;
|
|
|
|
t.i = 12345678;
|
|
|
|
t.j = -100000;
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2013-04-16 11:33:02 +00:00
|
|
|
USE(dummy);
|
|
|
|
|
|
|
|
CHECK_EQ(12345678.0, t.a);
|
|
|
|
CHECK_EQ(-100000.0, t.b);
|
|
|
|
CHECK_EQ(15000, t.i);
|
|
|
|
CHECK_EQ(275000000, t.j);
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS6) {
|
|
|
|
// Test simple memory loads and stores.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t ui;
|
|
|
|
int32_t si;
|
|
|
|
int32_t r1;
|
|
|
|
int32_t r2;
|
|
|
|
int32_t r3;
|
|
|
|
int32_t r4;
|
|
|
|
int32_t r5;
|
|
|
|
int32_t r6;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
2013-03-15 12:06:53 +00:00
|
|
|
Assembler assm(isolate, NULL, 0);
|
2011-03-28 13:05:36 +00:00
|
|
|
Label L, C;
|
|
|
|
|
|
|
|
// Basic word load/store.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, ui)) );
|
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, r1)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// lh with positive data.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lh(t1, MemOperand(a0, offsetof(T, ui)) );
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, r2)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// lh with negative data.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lh(t2, MemOperand(a0, offsetof(T, si)) );
|
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, r3)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// lhu with negative data.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lhu(t3, MemOperand(a0, offsetof(T, si)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, r4)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// lb with negative data.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lb(t4, MemOperand(a0, offsetof(T, si)) );
|
|
|
|
__ sw(t4, MemOperand(a0, offsetof(T, r5)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// sh writes only 1/2 of word.
|
|
|
|
__ lui(t5, 0x3333);
|
|
|
|
__ ori(t5, t5, 0x3333);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t5, MemOperand(a0, offsetof(T, r6)) );
|
|
|
|
__ lhu(t5, MemOperand(a0, offsetof(T, si)) );
|
|
|
|
__ sh(t5, MemOperand(a0, offsetof(T, r6)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2011-03-28 13:05:36 +00:00
|
|
|
t.ui = 0x11223344;
|
|
|
|
t.si = 0x99aabbcc;
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2011-03-28 13:05:36 +00:00
|
|
|
USE(dummy);
|
|
|
|
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x11223344), t.r1);
|
2014-04-15 16:39:21 +00:00
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x3344), t.r2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xffffbbcc), t.r3);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x0000bbcc), t.r4);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xffffffcc), t.r5);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x3333bbcc), t.r6);
|
2014-04-15 16:39:21 +00:00
|
|
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x1122), t.r2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xffff99aa), t.r3);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x000099aa), t.r4);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xffffff99), t.r5);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x99aa3333), t.r6);
|
2014-04-15 16:39:21 +00:00
|
|
|
#else
|
|
|
|
#error Unknown endianness
|
|
|
|
#endif
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS7) {
|
|
|
|
// Test floating point compare and branch instructions.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
double c;
|
|
|
|
double d;
|
|
|
|
double e;
|
|
|
|
double f;
|
|
|
|
int32_t result;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
|
|
|
// Create a function that accepts &t, and loads, manipulates, and stores
|
|
|
|
// the doubles t.a ... t.f.
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
Label neither_is_nan, less_than, outa_here;
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, a)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(T, b)));
|
2014-08-12 19:04:15 +00:00
|
|
|
if (!IsMipsArchVariant(kMips32r6)) {
|
2013-04-16 11:33:02 +00:00
|
|
|
__ c(UN, D, f4, f6);
|
|
|
|
__ bc1f(&neither_is_nan);
|
2014-08-12 19:04:15 +00:00
|
|
|
} else {
|
|
|
|
__ cmp(UN, L, f2, f4, f6);
|
|
|
|
__ bc1eqz(&neither_is_nan, f2);
|
|
|
|
}
|
2013-04-16 11:33:02 +00:00
|
|
|
__ nop();
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(zero_reg, MemOperand(a0, offsetof(T, result)) );
|
2013-04-16 11:33:02 +00:00
|
|
|
__ Branch(&outa_here);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ bind(&neither_is_nan);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2014-08-12 19:04:15 +00:00
|
|
|
if (IsMipsArchVariant(kLoongson)) {
|
2013-04-16 11:33:02 +00:00
|
|
|
__ c(OLT, D, f6, f4);
|
|
|
|
__ bc1t(&less_than);
|
2014-08-12 19:04:15 +00:00
|
|
|
} else if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
__ cmp(OLT, L, f2, f6, f4);
|
|
|
|
__ bc1nez(&less_than, f2);
|
2013-04-16 11:33:02 +00:00
|
|
|
} else {
|
|
|
|
__ c(OLT, D, f6, f4, 2);
|
|
|
|
__ bc1t(&less_than, 2);
|
|
|
|
}
|
2014-08-12 19:04:15 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ nop();
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(zero_reg, MemOperand(a0, offsetof(T, result)) );
|
2013-04-16 11:33:02 +00:00
|
|
|
__ Branch(&outa_here);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ bind(&less_than);
|
|
|
|
__ Addu(t0, zero_reg, Operand(1));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, result)) ); // Set true.
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// This test-case should have additional tests.
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ bind(&outa_here);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2013-04-16 11:33:02 +00:00
|
|
|
t.a = 1.5e14;
|
|
|
|
t.b = 2.75e11;
|
|
|
|
t.c = 2.0;
|
|
|
|
t.d = -4.0;
|
|
|
|
t.e = 0.0;
|
|
|
|
t.f = 0.0;
|
|
|
|
t.result = 0;
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2013-04-16 11:33:02 +00:00
|
|
|
USE(dummy);
|
|
|
|
CHECK_EQ(1.5e14, t.a);
|
|
|
|
CHECK_EQ(2.75e11, t.b);
|
|
|
|
CHECK_EQ(1, t.result);
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS8) {
|
|
|
|
// Test ROTR and ROTRV instructions.
|
2015-04-30 06:29:08 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r2)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-04-30 06:29:08 +00:00
|
|
|
typedef struct {
|
|
|
|
int32_t input;
|
|
|
|
int32_t result_rotr_4;
|
|
|
|
int32_t result_rotr_8;
|
|
|
|
int32_t result_rotr_12;
|
|
|
|
int32_t result_rotr_16;
|
|
|
|
int32_t result_rotr_20;
|
|
|
|
int32_t result_rotr_24;
|
|
|
|
int32_t result_rotr_28;
|
|
|
|
int32_t result_rotrv_4;
|
|
|
|
int32_t result_rotrv_8;
|
|
|
|
int32_t result_rotrv_12;
|
|
|
|
int32_t result_rotrv_16;
|
|
|
|
int32_t result_rotrv_20;
|
|
|
|
int32_t result_rotrv_24;
|
|
|
|
int32_t result_rotrv_28;
|
|
|
|
} T;
|
|
|
|
T t;
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-04-30 06:29:08 +00:00
|
|
|
// Basic word load.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, input)) );
|
2015-04-30 06:29:08 +00:00
|
|
|
|
|
|
|
// ROTR instruction (called through the Ror macro).
|
|
|
|
__ Ror(t1, t0, 0x0004);
|
|
|
|
__ Ror(t2, t0, 0x0008);
|
|
|
|
__ Ror(t3, t0, 0x000c);
|
|
|
|
__ Ror(t4, t0, 0x0010);
|
|
|
|
__ Ror(t5, t0, 0x0014);
|
|
|
|
__ Ror(t6, t0, 0x0018);
|
|
|
|
__ Ror(t7, t0, 0x001c);
|
|
|
|
|
|
|
|
// Basic word store.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, result_rotr_4)) );
|
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, result_rotr_8)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, result_rotr_12)) );
|
|
|
|
__ sw(t4, MemOperand(a0, offsetof(T, result_rotr_16)) );
|
|
|
|
__ sw(t5, MemOperand(a0, offsetof(T, result_rotr_20)) );
|
|
|
|
__ sw(t6, MemOperand(a0, offsetof(T, result_rotr_24)) );
|
|
|
|
__ sw(t7, MemOperand(a0, offsetof(T, result_rotr_28)) );
|
2015-04-30 06:29:08 +00:00
|
|
|
|
|
|
|
// ROTRV instruction (called through the Ror macro).
|
|
|
|
__ li(t7, 0x0004);
|
|
|
|
__ Ror(t1, t0, t7);
|
|
|
|
__ li(t7, 0x0008);
|
|
|
|
__ Ror(t2, t0, t7);
|
|
|
|
__ li(t7, 0x000C);
|
|
|
|
__ Ror(t3, t0, t7);
|
|
|
|
__ li(t7, 0x0010);
|
|
|
|
__ Ror(t4, t0, t7);
|
|
|
|
__ li(t7, 0x0014);
|
|
|
|
__ Ror(t5, t0, t7);
|
|
|
|
__ li(t7, 0x0018);
|
|
|
|
__ Ror(t6, t0, t7);
|
|
|
|
__ li(t7, 0x001C);
|
|
|
|
__ Ror(t7, t0, t7);
|
|
|
|
|
|
|
|
// Basic word store.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, result_rotrv_4)) );
|
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, result_rotrv_8)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, result_rotrv_12)) );
|
|
|
|
__ sw(t4, MemOperand(a0, offsetof(T, result_rotrv_16)) );
|
|
|
|
__ sw(t5, MemOperand(a0, offsetof(T, result_rotrv_20)) );
|
|
|
|
__ sw(t6, MemOperand(a0, offsetof(T, result_rotrv_24)) );
|
|
|
|
__ sw(t7, MemOperand(a0, offsetof(T, result_rotrv_28)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-04-30 06:29:08 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-04-30 06:29:08 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-04-30 06:29:08 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
t.input = 0x12345678;
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0x0, 0, 0, 0);
|
2015-04-30 06:29:08 +00:00
|
|
|
USE(dummy);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotr_4);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotr_8);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotr_12);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotr_16);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotr_20);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotr_24);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotr_28);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotrv_4);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotrv_8);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotrv_12);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotrv_16);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotrv_20);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotrv_24);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotrv_28);
|
|
|
|
}
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS9) {
|
|
|
|
// Test BRANCH improvements.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
Label exit, exit2, exit3;
|
|
|
|
|
2014-08-12 19:04:15 +00:00
|
|
|
__ Branch(&exit, ge, a0, Operand(zero_reg));
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Branch(&exit2, ge, a0, Operand(0x00001FFF));
|
|
|
|
__ Branch(&exit3, ge, a0, Operand(0x0001FFFF));
|
|
|
|
|
|
|
|
__ bind(&exit);
|
|
|
|
__ bind(&exit2);
|
|
|
|
__ bind(&exit3);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS10) {
|
2015-05-19 10:35:24 +00:00
|
|
|
// Test conversions between doubles and words.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
int32_t dbl_mant;
|
|
|
|
int32_t dbl_exp;
|
2014-02-04 14:05:46 +00:00
|
|
|
int32_t word;
|
|
|
|
int32_t b_word;
|
2011-03-28 13:05:36 +00:00
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
Label L, C;
|
|
|
|
|
2016-02-08 09:43:58 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)) return;
|
2014-08-12 19:04:15 +00:00
|
|
|
|
|
|
|
// Load all structure elements to registers.
|
2015-05-19 10:35:24 +00:00
|
|
|
// (f0, f1) = a (fp32), f0 = a (fp64)
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, a)));
|
2014-08-12 19:04:15 +00:00
|
|
|
|
2016-02-08 09:43:58 +00:00
|
|
|
__ mfc1(t0, f0); // t0 = f0(31..0)
|
|
|
|
__ mfhc1(t1, f0); // t1 = sign_extend(f0(63..32))
|
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, dbl_mant))); // dbl_mant = t0
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, dbl_exp))); // dbl_exp = t1
|
2014-08-12 19:04:15 +00:00
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
// Convert double in f0 to word, save hi/lo parts.
|
|
|
|
__ cvt_w_d(f0, f0); // a_word = (word)a
|
|
|
|
__ mfc1(t0, f0); // f0 has a 32-bits word. t0 = a_word
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, word))); // word = a_word
|
2014-08-12 19:04:15 +00:00
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
// Convert the b word to double b.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, b_word)));
|
2014-08-12 19:04:15 +00:00
|
|
|
__ mtc1(t0, f8); // f8 has a 32-bits word.
|
|
|
|
__ cvt_d_w(f10, f8);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(T, b)));
|
2014-08-12 19:04:15 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-08-12 19:04:15 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
t.a = 2.147483646e+09; // 0x7FFFFFFE -> 0xFF80000041DFFFFF as double.
|
|
|
|
t.b_word = 0x0ff00ff0; // 0x0FF00FF0 -> 0x as double.
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2014-08-12 19:04:15 +00:00
|
|
|
USE(dummy);
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x41DFFFFF), t.dbl_exp);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xFF800000), t.dbl_mant);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x7FFFFFFE), t.word);
|
2014-08-12 19:04:15 +00:00
|
|
|
// 0x0FF00FF0 -> 2.6739096+e08
|
|
|
|
CHECK_EQ(2.6739096e08, t.b);
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS11) {
|
2014-08-12 19:04:15 +00:00
|
|
|
// Do not run test on MIPS32r6, as these instructions are removed.
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) return;
|
2011-03-28 13:05:36 +00:00
|
|
|
// Test LWL, LWR, SWL and SWR instructions.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int32_t reg_init;
|
|
|
|
int32_t mem_init;
|
|
|
|
int32_t lwl_0;
|
|
|
|
int32_t lwl_1;
|
|
|
|
int32_t lwl_2;
|
|
|
|
int32_t lwl_3;
|
|
|
|
int32_t lwr_0;
|
|
|
|
int32_t lwr_1;
|
|
|
|
int32_t lwr_2;
|
|
|
|
int32_t lwr_3;
|
|
|
|
int32_t swl_0;
|
|
|
|
int32_t swl_1;
|
|
|
|
int32_t swl_2;
|
|
|
|
int32_t swl_3;
|
|
|
|
int32_t swr_0;
|
|
|
|
int32_t swr_1;
|
|
|
|
int32_t swr_2;
|
|
|
|
int32_t swr_3;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
2013-03-15 12:06:53 +00:00
|
|
|
Assembler assm(isolate, NULL, 0);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// Test all combinations of LWL and vAddr.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwl(t0, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, lwl_0)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t1, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwl(t1, MemOperand(a0, offsetof(T, mem_init) + 1) );
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, lwl_1)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t2, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwl(t2, MemOperand(a0, offsetof(T, mem_init) + 2) );
|
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, lwl_2)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t3, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwl(t3, MemOperand(a0, offsetof(T, mem_init) + 3) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, lwl_3)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// Test all combinations of LWR and vAddr.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwr(t0, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, lwr_0)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t1, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwr(t1, MemOperand(a0, offsetof(T, mem_init) + 1) );
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, lwr_1)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t2, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwr(t2, MemOperand(a0, offsetof(T, mem_init) + 2) );
|
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, lwr_2)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t3, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ lwr(t3, MemOperand(a0, offsetof(T, mem_init) + 3) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, lwr_3)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// Test all combinations of SWL and vAddr.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, swl_0)) );
|
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swl(t0, MemOperand(a0, offsetof(T, swl_0)) );
|
|
|
|
|
|
|
|
__ lw(t1, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, swl_1)) );
|
|
|
|
__ lw(t1, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swl(t1, MemOperand(a0, offsetof(T, swl_1) + 1) );
|
|
|
|
|
|
|
|
__ lw(t2, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, swl_2)) );
|
|
|
|
__ lw(t2, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swl(t2, MemOperand(a0, offsetof(T, swl_2) + 2) );
|
|
|
|
|
|
|
|
__ lw(t3, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, swl_3)) );
|
|
|
|
__ lw(t3, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swl(t3, MemOperand(a0, offsetof(T, swl_3) + 3) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
// Test all combinations of SWR and vAddr.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, swr_0)) );
|
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swr(t0, MemOperand(a0, offsetof(T, swr_0)) );
|
|
|
|
|
|
|
|
__ lw(t1, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, swr_1)) );
|
|
|
|
__ lw(t1, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swr(t1, MemOperand(a0, offsetof(T, swr_1) + 1) );
|
|
|
|
|
|
|
|
__ lw(t2, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t2, MemOperand(a0, offsetof(T, swr_2)) );
|
|
|
|
__ lw(t2, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swr(t2, MemOperand(a0, offsetof(T, swr_2) + 2) );
|
|
|
|
|
|
|
|
__ lw(t3, MemOperand(a0, offsetof(T, mem_init)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(T, swr_3)) );
|
|
|
|
__ lw(t3, MemOperand(a0, offsetof(T, reg_init)) );
|
|
|
|
__ swr(t3, MemOperand(a0, offsetof(T, swr_3) + 3) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2011-03-28 13:05:36 +00:00
|
|
|
t.reg_init = 0xaabbccdd;
|
|
|
|
t.mem_init = 0x11223344;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2011-03-28 13:05:36 +00:00
|
|
|
USE(dummy);
|
|
|
|
|
2014-04-15 16:39:21 +00:00
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x44bbccdd), t.lwl_0);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x3344ccdd), t.lwl_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x223344dd), t.lwl_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x11223344), t.lwl_3);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x11223344), t.lwr_0);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaa112233), t.lwr_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabb1122), t.lwr_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabbcc11), t.lwr_3);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x112233aa), t.swl_0);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x1122aabb), t.swl_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x11aabbcc), t.swl_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabbccdd), t.swl_3);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabbccdd), t.swr_0);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xbbccdd44), t.swr_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xccdd3344), t.swr_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xdd223344), t.swr_3);
|
2014-04-15 16:39:21 +00:00
|
|
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
2015-05-18 10:55:44 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x11223344), t.lwl_0);
|
2015-01-30 19:13:22 +00:00
|
|
|
CHECK_EQ(static_cast<int32_t>(0x223344dd), t.lwl_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x3344ccdd), t.lwl_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x44bbccdd), t.lwl_3);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabbcc11), t.lwr_0);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabb1122), t.lwr_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaa112233), t.lwr_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x11223344), t.lwr_3);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabbccdd), t.swl_0);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x11aabbcc), t.swl_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x1122aabb), t.swl_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x112233aa), t.swl_3);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xdd223344), t.swr_0);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xccdd3344), t.swr_1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xbbccdd44), t.swr_2);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xaabbccdd), t.swr_3);
|
2014-04-15 16:39:21 +00:00
|
|
|
#else
|
|
|
|
#error Unknown endianness
|
|
|
|
#endif
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS12) {
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int32_t x;
|
|
|
|
int32_t y;
|
|
|
|
int32_t y1;
|
|
|
|
int32_t y2;
|
|
|
|
int32_t y3;
|
|
|
|
int32_t y4;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
__ mov(t6, fp); // Save frame pointer.
|
|
|
|
__ mov(fp, a0); // Access struct T by fp.
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(T, y)) );
|
|
|
|
__ lw(t3, MemOperand(a0, offsetof(T, y4)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
__ addu(t1, t0, t3);
|
|
|
|
__ subu(t4, t0, t3);
|
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t0); // These instructions disappear after opt.
|
2011-03-28 13:05:36 +00:00
|
|
|
__ Pop();
|
|
|
|
__ addu(t0, t0, t0);
|
|
|
|
__ nop();
|
|
|
|
__ Pop(); // These instructions disappear after opt.
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t3);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t3); // These instructions disappear after opt.
|
|
|
|
__ pop(t3);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t3);
|
|
|
|
__ pop(t4);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t0, MemOperand(fp, offsetof(T, y)) );
|
|
|
|
__ lw(t0, MemOperand(fp, offsetof(T, y)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t0, MemOperand(fp, offsetof(T, y)) );
|
|
|
|
__ lw(t1, MemOperand(fp, offsetof(T, y)) );
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t1);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t1, MemOperand(fp, offsetof(T, y)) );
|
2011-05-09 14:28:09 +00:00
|
|
|
__ pop(t1);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t1);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t2, MemOperand(fp, offsetof(T, y)) );
|
2011-05-09 14:28:09 +00:00
|
|
|
__ pop(t1);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t1);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t2, MemOperand(fp, offsetof(T, y)) );
|
2011-05-09 14:28:09 +00:00
|
|
|
__ pop(t2);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t2);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t2, MemOperand(fp, offsetof(T, y)) );
|
2011-05-09 14:28:09 +00:00
|
|
|
__ pop(t1);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
2011-05-09 14:28:09 +00:00
|
|
|
__ push(t1);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t2, MemOperand(fp, offsetof(T, y)) );
|
2011-05-09 14:28:09 +00:00
|
|
|
__ pop(t3);
|
2011-03-28 13:05:36 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ mov(fp, t6);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2011-03-28 13:05:36 +00:00
|
|
|
t.x = 1;
|
|
|
|
t.y = 2;
|
|
|
|
t.y1 = 3;
|
|
|
|
t.y2 = 4;
|
|
|
|
t.y3 = 0XBABA;
|
|
|
|
t.y4 = 0xDEDA;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2011-03-28 13:05:36 +00:00
|
|
|
USE(dummy);
|
|
|
|
|
|
|
|
CHECK_EQ(3, t.y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS13) {
|
|
|
|
// Test Cvt_d_uw and Trunc_uw_d macros.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double cvt_big_out;
|
|
|
|
double cvt_small_out;
|
|
|
|
uint32_t trunc_big_out;
|
|
|
|
uint32_t trunc_small_out;
|
|
|
|
uint32_t cvt_big_in;
|
|
|
|
uint32_t cvt_small_in;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, cvt_small_in)));
|
2015-09-15 07:36:59 +00:00
|
|
|
__ Cvt_d_uw(f10, t0, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(T, cvt_small_out)));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-09-15 07:36:59 +00:00
|
|
|
__ Trunc_uw_d(f10, f10, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(T, trunc_small_out)));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, cvt_big_in)));
|
2015-09-15 07:36:59 +00:00
|
|
|
__ Cvt_d_uw(f8, t0, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f8, MemOperand(a0, offsetof(T, cvt_big_out)));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-09-15 07:36:59 +00:00
|
|
|
__ Trunc_uw_d(f8, f8, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(T, trunc_big_out)));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
t.cvt_big_in = 0xFFFFFFFF;
|
|
|
|
t.cvt_small_in = 333;
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2013-04-16 11:33:02 +00:00
|
|
|
USE(dummy);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CHECK_EQ(t.cvt_big_out, static_cast<double>(t.cvt_big_in));
|
|
|
|
CHECK_EQ(t.cvt_small_out, static_cast<double>(t.cvt_small_in));
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CHECK_EQ(static_cast<int>(t.trunc_big_out), static_cast<int>(t.cvt_big_in));
|
|
|
|
CHECK_EQ(static_cast<int>(t.trunc_small_out),
|
|
|
|
static_cast<int>(t.cvt_small_in));
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MIPS14) {
|
|
|
|
// Test round, floor, ceil, trunc, cvt.
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
|
|
|
#define ROUND_STRUCT_ELEMENT(x) \
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t x##_isNaN2008; \
|
2011-03-28 13:05:36 +00:00
|
|
|
int32_t x##_up_out; \
|
|
|
|
int32_t x##_down_out; \
|
|
|
|
int32_t neg_##x##_up_out; \
|
|
|
|
int32_t neg_##x##_down_out; \
|
2011-05-09 14:28:09 +00:00
|
|
|
uint32_t x##_err1_out; \
|
|
|
|
uint32_t x##_err2_out; \
|
|
|
|
uint32_t x##_err3_out; \
|
|
|
|
uint32_t x##_err4_out; \
|
2011-03-28 13:05:36 +00:00
|
|
|
int32_t x##_invalid_result;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double round_up_in;
|
|
|
|
double round_down_in;
|
|
|
|
double neg_round_up_in;
|
|
|
|
double neg_round_down_in;
|
|
|
|
double err1_in;
|
|
|
|
double err2_in;
|
|
|
|
double err3_in;
|
|
|
|
double err4_in;
|
|
|
|
|
|
|
|
ROUND_STRUCT_ELEMENT(round)
|
|
|
|
ROUND_STRUCT_ELEMENT(floor)
|
|
|
|
ROUND_STRUCT_ELEMENT(ceil)
|
|
|
|
ROUND_STRUCT_ELEMENT(trunc)
|
|
|
|
ROUND_STRUCT_ELEMENT(cvt)
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
|
|
|
#undef ROUND_STRUCT_ELEMENT
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
// Save FCSR.
|
|
|
|
__ cfc1(a1, FCSR);
|
|
|
|
// Disable FPU exceptions.
|
|
|
|
__ ctc1(zero_reg, FCSR);
|
2017-03-21 11:35:40 +00:00
|
|
|
#define RUN_ROUND_TEST(x) \
|
|
|
|
__ cfc1(t0, FCSR); \
|
|
|
|
__ sw(t0, MemOperand(a0, offsetof(T, x##_isNaN2008))); \
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, round_up_in))); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
|
|
|
__ swc1(f0, MemOperand(a0, offsetof(T, x##_up_out))); \
|
|
|
|
\
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, round_down_in))); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
|
|
|
__ swc1(f0, MemOperand(a0, offsetof(T, x##_down_out))); \
|
|
|
|
\
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, neg_round_up_in))); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
|
|
|
__ swc1(f0, MemOperand(a0, offsetof(T, neg_##x##_up_out))); \
|
|
|
|
\
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, neg_round_down_in))); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f0, MemOperand(a0, offsetof(T, neg_##x##_down_out))); \
|
2017-03-21 11:35:40 +00:00
|
|
|
\
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, err1_in))); \
|
|
|
|
__ ctc1(zero_reg, FCSR); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
|
|
|
__ cfc1(a2, FCSR); \
|
|
|
|
__ sw(a2, MemOperand(a0, offsetof(T, x##_err1_out))); \
|
|
|
|
\
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, err2_in))); \
|
|
|
|
__ ctc1(zero_reg, FCSR); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
|
|
|
__ cfc1(a2, FCSR); \
|
|
|
|
__ sw(a2, MemOperand(a0, offsetof(T, x##_err2_out))); \
|
|
|
|
\
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, err3_in))); \
|
|
|
|
__ ctc1(zero_reg, FCSR); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
|
|
|
__ cfc1(a2, FCSR); \
|
|
|
|
__ sw(a2, MemOperand(a0, offsetof(T, x##_err3_out))); \
|
|
|
|
\
|
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(T, err4_in))); \
|
|
|
|
__ ctc1(zero_reg, FCSR); \
|
|
|
|
__ x##_w_d(f0, f0); \
|
|
|
|
__ cfc1(a2, FCSR); \
|
|
|
|
__ sw(a2, MemOperand(a0, offsetof(T, x##_err4_out))); \
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f0, MemOperand(a0, offsetof(T, x##_invalid_result)));
|
2013-04-16 11:33:02 +00:00
|
|
|
|
|
|
|
RUN_ROUND_TEST(round)
|
|
|
|
RUN_ROUND_TEST(floor)
|
|
|
|
RUN_ROUND_TEST(ceil)
|
|
|
|
RUN_ROUND_TEST(trunc)
|
|
|
|
RUN_ROUND_TEST(cvt)
|
|
|
|
|
|
|
|
// Restore FCSR.
|
|
|
|
__ ctc1(a1, FCSR);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2014-04-16 11:38:56 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
t.round_up_in = 123.51;
|
|
|
|
t.round_down_in = 123.49;
|
|
|
|
t.neg_round_up_in = -123.5;
|
|
|
|
t.neg_round_down_in = -123.49;
|
|
|
|
t.err1_in = 123.51;
|
|
|
|
t.err2_in = 1;
|
|
|
|
t.err3_in = static_cast<double>(1) + 0xFFFFFFFF;
|
|
|
|
t.err4_in = NAN;
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2013-04-16 11:33:02 +00:00
|
|
|
USE(dummy);
|
2011-03-28 13:05:36 +00:00
|
|
|
|
2011-06-06 08:43:15 +00:00
|
|
|
#define GET_FPU_ERR(x) (static_cast<int>(x & kFCSRFlagMask))
|
2015-12-02 10:54:38 +00:00
|
|
|
#define CHECK_NAN2008(x) (x & kFCSRNaN2008FlagMask)
|
2015-01-30 19:13:22 +00:00
|
|
|
#define CHECK_ROUND_RESULT(type) \
|
|
|
|
CHECK(GET_FPU_ERR(t.type##_err1_out) & kFCSRInexactFlagMask); \
|
|
|
|
CHECK_EQ(0, GET_FPU_ERR(t.type##_err2_out)); \
|
2011-06-06 08:43:15 +00:00
|
|
|
CHECK(GET_FPU_ERR(t.type##_err3_out) & kFCSRInvalidOpFlagMask); \
|
|
|
|
CHECK(GET_FPU_ERR(t.type##_err4_out) & kFCSRInvalidOpFlagMask); \
|
2015-12-02 10:54:38 +00:00
|
|
|
if (CHECK_NAN2008(t.type##_isNaN2008) && kArchVariant == kMips32r6) {\
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0), t.type##_invalid_result);\
|
|
|
|
} else {\
|
|
|
|
CHECK_EQ(static_cast<int32_t>(kFPUInvalidResult), t.type##_invalid_result);\
|
|
|
|
}
|
|
|
|
|
2011-06-06 08:43:15 +00:00
|
|
|
|
2013-04-16 11:33:02 +00:00
|
|
|
CHECK_ROUND_RESULT(round);
|
|
|
|
CHECK_ROUND_RESULT(floor);
|
|
|
|
CHECK_ROUND_RESULT(ceil);
|
|
|
|
CHECK_ROUND_RESULT(cvt);
|
2011-03-28 13:05:36 +00:00
|
|
|
}
|
|
|
|
|
2011-08-30 07:36:31 +00:00
|
|
|
|
|
|
|
TEST(MIPS15) {
|
|
|
|
// Test chaining of label usages within instructions (issue 1644).
|
2013-04-10 08:29:39 +00:00
|
|
|
CcTest::InitializeVM();
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-03-15 12:06:53 +00:00
|
|
|
HandleScope scope(isolate);
|
|
|
|
Assembler assm(isolate, NULL, 0);
|
2011-08-30 07:36:31 +00:00
|
|
|
|
|
|
|
Label target;
|
|
|
|
__ beq(v0, v1, &target);
|
2011-08-31 09:42:28 +00:00
|
|
|
__ nop();
|
2011-08-30 07:36:31 +00:00
|
|
|
__ bne(v0, v1, &target);
|
2011-08-31 09:42:28 +00:00
|
|
|
__ nop();
|
2011-08-30 07:36:31 +00:00
|
|
|
__ bind(&target);
|
|
|
|
__ nop();
|
|
|
|
}
|
|
|
|
|
2015-02-09 20:49:46 +00:00
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
// ----------------------mips32r6 specific tests----------------------
|
|
|
|
TEST(seleqz_selnez) {
|
2015-03-31 22:39:49 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-03-31 22:39:49 +00:00
|
|
|
|
|
|
|
typedef struct test {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
int c;
|
|
|
|
int d;
|
|
|
|
double e;
|
|
|
|
double f;
|
|
|
|
double g;
|
|
|
|
double h;
|
2015-05-19 10:35:24 +00:00
|
|
|
float i;
|
|
|
|
float j;
|
|
|
|
float k;
|
|
|
|
float l;
|
2015-03-31 22:39:49 +00:00
|
|
|
} Test;
|
|
|
|
|
|
|
|
Test test;
|
|
|
|
// Integer part of test.
|
|
|
|
__ addiu(t1, zero_reg, 1); // t1 = 1
|
2015-04-06 11:54:38 +00:00
|
|
|
__ seleqz(t3, t1, zero_reg); // t3 = 1
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t3, MemOperand(a0, offsetof(Test, a))); // a = 1
|
2015-04-06 11:54:38 +00:00
|
|
|
__ seleqz(t2, t1, t1); // t2 = 0
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(Test, b))); // b = 0
|
2015-04-06 11:54:38 +00:00
|
|
|
__ selnez(t3, t1, zero_reg); // t3 = 1;
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t3, MemOperand(a0, offsetof(Test, c))); // c = 0
|
2015-04-06 11:54:38 +00:00
|
|
|
__ selnez(t3, t1, t1); // t3 = 1
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t3, MemOperand(a0, offsetof(Test, d))); // d = 1
|
2015-04-06 11:54:38 +00:00
|
|
|
// Floating point part of test.
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(Test, e))); // src
|
|
|
|
__ Ldc1(f2, MemOperand(a0, offsetof(Test, f))); // test
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f8, MemOperand(a0, offsetof(Test, i)) ); // src
|
|
|
|
__ lwc1(f10, MemOperand(a0, offsetof(Test, j)) ); // test
|
2015-05-19 10:35:24 +00:00
|
|
|
__ seleqz_d(f4, f0, f2);
|
|
|
|
__ selnez_d(f6, f0, f2);
|
|
|
|
__ seleqz_s(f12, f8, f10);
|
|
|
|
__ selnez_s(f14, f8, f10);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f4, MemOperand(a0, offsetof(Test, g))); // src
|
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(Test, h))); // src
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(Test, k)) ); // src
|
|
|
|
__ swc1(f14, MemOperand(a0, offsetof(Test, l)) ); // src
|
2015-03-31 22:39:49 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-03-31 22:39:49 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-03-31 22:39:49 +00:00
|
|
|
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(1, test.a);
|
|
|
|
CHECK_EQ(0, test.b);
|
|
|
|
CHECK_EQ(0, test.c);
|
|
|
|
CHECK_EQ(1, test.d);
|
2015-03-31 22:39:49 +00:00
|
|
|
|
2015-04-06 11:54:38 +00:00
|
|
|
const int test_size = 3;
|
|
|
|
const int input_size = 5;
|
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
double inputs_D[input_size] = {0.0, 65.2, -70.32,
|
2015-04-06 11:54:38 +00:00
|
|
|
18446744073709551621.0, -18446744073709551621.0};
|
2015-05-19 10:35:24 +00:00
|
|
|
double outputs_D[input_size] = {0.0, 65.2, -70.32,
|
2015-04-06 11:54:38 +00:00
|
|
|
18446744073709551621.0, -18446744073709551621.0};
|
2015-05-19 10:35:24 +00:00
|
|
|
double tests_D[test_size*2] = {2.8, 2.9, -2.8, -2.9,
|
2015-04-06 11:54:38 +00:00
|
|
|
18446744073709551616.0, 18446744073709555712.0};
|
2015-05-19 10:35:24 +00:00
|
|
|
float inputs_S[input_size] = {0.0, 65.2, -70.32,
|
|
|
|
18446744073709551621.0, -18446744073709551621.0};
|
|
|
|
float outputs_S[input_size] = {0.0, 65.2, -70.32,
|
|
|
|
18446744073709551621.0, -18446744073709551621.0};
|
|
|
|
float tests_S[test_size*2] = {2.9, 2.8, -2.9, -2.8,
|
|
|
|
18446744073709551616.0, 18446746272732807168.0};
|
2015-04-30 06:29:08 +00:00
|
|
|
for (int j=0; j < test_size; j+=2) {
|
|
|
|
for (int i=0; i < input_size; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.e = inputs_D[i];
|
|
|
|
test.f = tests_D[j];
|
|
|
|
test.i = inputs_S[i];
|
|
|
|
test.j = tests_S[j];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(outputs_D[i], test.g);
|
|
|
|
CHECK_EQ(0, test.h);
|
|
|
|
CHECK_EQ(outputs_S[i], test.k);
|
|
|
|
CHECK_EQ(0, test.l);
|
2015-04-06 11:54:38 +00:00
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
test.f = tests_D[j+1];
|
|
|
|
test.j = tests_S[j+1];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, test.g);
|
|
|
|
CHECK_EQ(outputs_D[i], test.h);
|
|
|
|
CHECK_EQ(0, test.k);
|
|
|
|
CHECK_EQ(outputs_S[i], test.l);
|
2015-04-06 11:54:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
TEST(min_max) {
|
2015-04-06 11:54:38 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2016-02-05 17:58:19 +00:00
|
|
|
MacroAssembler assm(isolate, nullptr, 0,
|
2015-11-25 14:23:37 +00:00
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-04-06 11:54:38 +00:00
|
|
|
|
2016-02-05 17:58:19 +00:00
|
|
|
struct TestFloat {
|
2015-04-06 11:54:38 +00:00
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
double c;
|
|
|
|
double d;
|
2015-05-19 10:35:24 +00:00
|
|
|
float e;
|
|
|
|
float f;
|
|
|
|
float g;
|
|
|
|
float h;
|
2016-02-05 17:58:19 +00:00
|
|
|
};
|
2015-04-06 11:54:38 +00:00
|
|
|
|
|
|
|
TestFloat test;
|
2016-02-05 17:58:19 +00:00
|
|
|
const double dnan = std::numeric_limits<double>::quiet_NaN();
|
|
|
|
const double dinf = std::numeric_limits<double>::infinity();
|
|
|
|
const double dminf = -std::numeric_limits<double>::infinity();
|
|
|
|
const float fnan = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
const float finf = std::numeric_limits<float>::infinity();
|
|
|
|
const float fminf = std::numeric_limits<float>::infinity();
|
|
|
|
const int kTableLength = 13;
|
|
|
|
double inputsa[kTableLength] = {2.0, 3.0, dnan, 3.0, -0.0, 0.0, dinf,
|
|
|
|
dnan, 42.0, dinf, dminf, dinf, dnan};
|
|
|
|
double inputsb[kTableLength] = {3.0, 2.0, 3.0, dnan, 0.0, -0.0, dnan,
|
|
|
|
dinf, dinf, 42.0, dinf, dminf, dnan};
|
|
|
|
double outputsdmin[kTableLength] = {2.0, 2.0, 3.0, 3.0, -0.0,
|
|
|
|
-0.0, dinf, dinf, 42.0, 42.0,
|
|
|
|
dminf, dminf, dnan};
|
|
|
|
double outputsdmax[kTableLength] = {3.0, 3.0, 3.0, 3.0, 0.0, 0.0, dinf,
|
|
|
|
dinf, dinf, dinf, dinf, dinf, dnan};
|
|
|
|
|
|
|
|
float inputse[kTableLength] = {2.0, 3.0, fnan, 3.0, -0.0, 0.0, finf,
|
|
|
|
fnan, 42.0, finf, fminf, finf, fnan};
|
2016-03-25 16:51:11 +00:00
|
|
|
float inputsf[kTableLength] = {3.0, 2.0, 3.0, fnan, 0.0, -0.0, fnan,
|
2016-02-05 17:58:19 +00:00
|
|
|
finf, finf, 42.0, finf, fminf, fnan};
|
|
|
|
float outputsfmin[kTableLength] = {2.0, 2.0, 3.0, 3.0, -0.0,
|
|
|
|
-0.0, finf, finf, 42.0, 42.0,
|
|
|
|
fminf, fminf, fnan};
|
|
|
|
float outputsfmax[kTableLength] = {3.0, 3.0, 3.0, 3.0, 0.0, 0.0, finf,
|
|
|
|
finf, finf, finf, finf, finf, fnan};
|
2015-04-06 11:54:38 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, a)));
|
|
|
|
__ Ldc1(f8, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f2, MemOperand(a0, offsetof(TestFloat, e)));
|
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(TestFloat, f)));
|
2015-04-30 16:43:00 +00:00
|
|
|
__ min_d(f10, f4, f8);
|
|
|
|
__ max_d(f12, f4, f8);
|
2015-05-19 10:35:24 +00:00
|
|
|
__ min_s(f14, f2, f6);
|
|
|
|
__ max_s(f16, f2, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, c)));
|
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(TestFloat, d)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f14, MemOperand(a0, offsetof(TestFloat, g)));
|
|
|
|
__ swc1(f16, MemOperand(a0, offsetof(TestFloat, h)));
|
2015-04-06 11:54:38 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
2015-03-31 22:39:49 +00:00
|
|
|
|
2015-04-06 11:54:38 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-04-06 11:54:38 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputsa[i];
|
|
|
|
test.b = inputsb[i];
|
|
|
|
test.e = inputse[i];
|
|
|
|
test.f = inputsf[i];
|
2015-05-14 18:44:46 +00:00
|
|
|
|
2016-03-25 16:51:11 +00:00
|
|
|
CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
CHECK_EQ(0, memcmp(&test.c, &outputsdmin[i], sizeof(test.c)));
|
|
|
|
CHECK_EQ(0, memcmp(&test.d, &outputsdmax[i], sizeof(test.d)));
|
|
|
|
CHECK_EQ(0, memcmp(&test.g, &outputsfmin[i], sizeof(test.g)));
|
|
|
|
CHECK_EQ(0, memcmp(&test.h, &outputsfmax[i], sizeof(test.h)));
|
2015-05-19 10:35:24 +00:00
|
|
|
}
|
2015-03-31 22:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
TEST(rint_d) {
|
2015-04-30 06:29:08 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 30;
|
2015-04-30 06:29:08 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-04-30 06:29:08 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
int fcsr;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs[kTableLength] = {18446744073709551617.0,
|
2015-04-30 06:29:08 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147,
|
|
|
|
1.7976931348623157E+308, 6.27463370218383111104242366943E-307,
|
|
|
|
309485009821345068724781056.89,
|
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RN[kTableLength] = {18446744073709551617.0,
|
2015-04-30 06:29:08 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147,
|
|
|
|
1.7976931348623157E308, 0,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
|
|
|
|
-2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RZ[kTableLength] = {18446744073709551617.0,
|
2015-04-30 06:29:08 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147,
|
|
|
|
1.7976931348623157E308, 0,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RP[kTableLength] = {18446744073709551617.0,
|
2015-04-30 06:29:08 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147,
|
|
|
|
1.7976931348623157E308, 1,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RM[kTableLength] = {18446744073709551617.0,
|
2015-04-30 06:29:08 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147,
|
|
|
|
1.7976931348623157E308, 0,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
|
|
|
int fcsr_inputs[4] =
|
|
|
|
{kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf};
|
|
|
|
double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM};
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(TestFloat, fcsr)) );
|
2015-04-30 06:29:08 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ ctc1(t0, FCSR);
|
|
|
|
__ rint_d(f8, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f8, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-04-30 06:29:08 +00:00
|
|
|
__ ctc1(t1, FCSR);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-04-30 06:29:08 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
test.fcsr = fcsr_inputs[j];
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-04-30 06:29:08 +00:00
|
|
|
test.a = inputs[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-04-30 06:29:08 +00:00
|
|
|
CHECK_EQ(test.b, outputs[j][i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
TEST(sel) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test {
|
|
|
|
double dd;
|
|
|
|
double ds;
|
|
|
|
double dt;
|
|
|
|
float fd;
|
|
|
|
float fs;
|
|
|
|
float ft;
|
|
|
|
} Test;
|
|
|
|
|
|
|
|
Test test;
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f0, MemOperand(a0, offsetof(Test, dd))); // test
|
|
|
|
__ Ldc1(f2, MemOperand(a0, offsetof(Test, ds))); // src1
|
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, dt))); // src2
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, fd)) ); // test
|
|
|
|
__ lwc1(f8, MemOperand(a0, offsetof(Test, fs)) ); // src1
|
|
|
|
__ lwc1(f10, MemOperand(a0, offsetof(Test, ft)) ); // src2
|
2015-05-19 10:35:24 +00:00
|
|
|
__ sel_d(f0, f2, f4);
|
|
|
|
__ sel_s(f6, f8, f10);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f0, MemOperand(a0, offsetof(Test, dd)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(Test, fd)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
const int test_size = 3;
|
|
|
|
const int input_size = 5;
|
|
|
|
|
|
|
|
double inputs_dt[input_size] = {0.0, 65.2, -70.32,
|
|
|
|
18446744073709551621.0, -18446744073709551621.0};
|
|
|
|
double inputs_ds[input_size] = {0.1, 69.88, -91.325,
|
|
|
|
18446744073709551625.0, -18446744073709551625.0};
|
|
|
|
float inputs_ft[input_size] = {0.0, 65.2, -70.32,
|
|
|
|
18446744073709551621.0, -18446744073709551621.0};
|
|
|
|
float inputs_fs[input_size] = {0.1, 69.88, -91.325,
|
|
|
|
18446744073709551625.0, -18446744073709551625.0};
|
|
|
|
double tests_D[test_size*2] = {2.8, 2.9, -2.8, -2.9,
|
|
|
|
18446744073709551616.0, 18446744073709555712.0};
|
|
|
|
float tests_S[test_size*2] = {2.9, 2.8, -2.9, -2.8,
|
|
|
|
18446744073709551616.0, 18446746272732807168.0};
|
|
|
|
for (int j=0; j < test_size; j+=2) {
|
|
|
|
for (int i=0; i < input_size; i++) {
|
|
|
|
test.dt = inputs_dt[i];
|
|
|
|
test.dd = tests_D[j];
|
|
|
|
test.ds = inputs_ds[i];
|
|
|
|
test.ft = inputs_ft[i];
|
|
|
|
test.fd = tests_S[j];
|
|
|
|
test.fs = inputs_fs[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.dd, inputs_ds[i]);
|
|
|
|
CHECK_EQ(test.fd, inputs_fs[i]);
|
|
|
|
|
|
|
|
test.dd = tests_D[j+1];
|
|
|
|
test.fd = tests_S[j+1];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.dd, inputs_dt[i]);
|
|
|
|
CHECK_EQ(test.fd, inputs_ft[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(rint_s) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 30;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
float a;
|
|
|
|
float b;
|
|
|
|
int fcsr;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs[kTableLength] = {18446744073709551617.0,
|
2015-05-19 10:35:24 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37,
|
|
|
|
1.7976931348623157E+38, 6.27463370218383111104242366943E-37,
|
|
|
|
309485009821345068724781056.89,
|
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_RN[kTableLength] = {18446744073709551617.0,
|
2015-05-19 10:35:24 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37,
|
|
|
|
1.7976931348623157E38, 0,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
|
|
|
|
-2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_RZ[kTableLength] = {18446744073709551617.0,
|
2015-05-19 10:35:24 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37,
|
|
|
|
1.7976931348623157E38, 0,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_RP[kTableLength] = {18446744073709551617.0,
|
2015-05-19 10:35:24 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37,
|
|
|
|
1.7976931348623157E38, 1,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_RM[kTableLength] = {18446744073709551617.0,
|
2015-05-19 10:35:24 +00:00
|
|
|
4503599627370496.0, -4503599627370496.0,
|
|
|
|
1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37,
|
|
|
|
1.7976931348623157E38, 0,
|
|
|
|
309485009821345068724781057.0,
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
|
|
|
|
37778931862957161709568.0, 37778931862957161709569.0,
|
|
|
|
37778931862957161709580.0, 37778931862957161709581.0,
|
|
|
|
37778931862957161709582.0, 37778931862957161709583.0,
|
|
|
|
37778931862957161709584.0, 37778931862957161709585.0,
|
|
|
|
37778931862957161709586.0, 37778931862957161709587.0};
|
|
|
|
int fcsr_inputs[4] =
|
|
|
|
{kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf};
|
|
|
|
float* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM};
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(TestFloat, a)) );
|
|
|
|
__ lw(t0, MemOperand(a0, offsetof(TestFloat, fcsr)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ ctc1(t0, FCSR);
|
|
|
|
__ rint_s(f8, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(TestFloat, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ ctc1(t1, FCSR);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
test.fcsr = fcsr_inputs[j];
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.b, outputs[j][i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-30 20:59:26 +00:00
|
|
|
TEST(Cvt_d_uw) {
|
2015-12-21 10:49:14 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-11-30 20:59:26 +00:00
|
|
|
|
2015-12-21 10:49:14 +00:00
|
|
|
typedef struct test_struct {
|
|
|
|
unsigned input;
|
|
|
|
uint64_t output;
|
|
|
|
} TestStruct;
|
2015-11-30 20:59:26 +00:00
|
|
|
|
2015-12-21 10:49:14 +00:00
|
|
|
unsigned inputs[] = {
|
|
|
|
0x0, 0xffffffff, 0x80000000, 0x7fffffff
|
|
|
|
};
|
2015-11-30 20:59:26 +00:00
|
|
|
|
2015-12-21 10:49:14 +00:00
|
|
|
uint64_t outputs[] = {
|
|
|
|
0x0, 0x41efffffffe00000,
|
|
|
|
0x41e0000000000000, 0x41dfffffffc00000
|
|
|
|
};
|
2015-11-30 20:59:26 +00:00
|
|
|
|
2015-12-21 10:49:14 +00:00
|
|
|
int kTableLength = sizeof(inputs)/sizeof(inputs[0]);
|
2015-11-30 20:59:26 +00:00
|
|
|
|
2015-12-21 10:49:14 +00:00
|
|
|
TestStruct test;
|
2015-11-30 20:59:26 +00:00
|
|
|
|
2015-12-21 10:49:14 +00:00
|
|
|
__ lw(t1, MemOperand(a0, offsetof(TestStruct, input)));
|
|
|
|
__ Cvt_d_uw(f4, t1, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f4, MemOperand(a0, offsetof(TestStruct, output)));
|
2015-12-21 10:49:14 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
2015-11-30 20:59:26 +00:00
|
|
|
|
2015-12-21 10:49:14 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-12-21 10:49:14 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
|
|
|
test.input = inputs[i];
|
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
|
|
|
// Check outputs
|
|
|
|
CHECK_EQ(test.output, outputs[i]);
|
2015-11-30 20:59:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
TEST(mina_maxa) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
2016-02-05 17:58:19 +00:00
|
|
|
const int kTableLength = 23;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2016-02-05 17:58:19 +00:00
|
|
|
MacroAssembler assm(isolate, nullptr, 0,
|
2015-11-25 14:23:37 +00:00
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2016-02-05 17:58:19 +00:00
|
|
|
const double dnan = std::numeric_limits<double>::quiet_NaN();
|
|
|
|
const double dinf = std::numeric_limits<double>::infinity();
|
|
|
|
const double dminf = -std::numeric_limits<double>::infinity();
|
|
|
|
const float fnan = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
const float finf = std::numeric_limits<float>::infinity();
|
|
|
|
const float fminf = std::numeric_limits<float>::infinity();
|
|
|
|
|
|
|
|
struct TestFloat {
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
double resd;
|
|
|
|
double resd1;
|
|
|
|
float c;
|
|
|
|
float d;
|
|
|
|
float resf;
|
|
|
|
float resf1;
|
2016-02-05 17:58:19 +00:00
|
|
|
};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputsa[kTableLength] = {
|
2016-02-05 17:58:19 +00:00
|
|
|
5.3, 4.8, 6.1, 9.8, 9.8, 9.8, -10.0, -8.9, -9.8, -10.0, -8.9, -9.8,
|
|
|
|
dnan, 3.0, -0.0, 0.0, dinf, dnan, 42.0, dinf, dminf, dinf, dnan};
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputsb[kTableLength] = {
|
2016-02-05 17:58:19 +00:00
|
|
|
4.8, 5.3, 6.1, -10.0, -8.9, -9.8, 9.8, 9.8, 9.8, -9.8, -11.2, -9.8,
|
|
|
|
3.0, dnan, 0.0, -0.0, dnan, dinf, dinf, 42.0, dinf, dminf, dnan};
|
2015-08-07 19:05:47 +00:00
|
|
|
double resd[kTableLength] = {
|
2016-02-05 17:58:19 +00:00
|
|
|
4.8, 4.8, 6.1, 9.8, -8.9, -9.8, 9.8, -8.9, -9.8, -9.8, -8.9, -9.8,
|
|
|
|
3.0, 3.0, -0.0, -0.0, dinf, dinf, 42.0, 42.0, dminf, dminf, dnan};
|
2015-08-07 19:05:47 +00:00
|
|
|
double resd1[kTableLength] = {
|
2016-02-05 17:58:19 +00:00
|
|
|
5.3, 5.3, 6.1, -10.0, 9.8, 9.8, -10.0, 9.8, 9.8, -10.0, -11.2, -9.8,
|
|
|
|
3.0, 3.0, 0.0, 0.0, dinf, dinf, dinf, dinf, dinf, dinf, dnan};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputsc[kTableLength] = {
|
2016-02-05 17:58:19 +00:00
|
|
|
5.3, 4.8, 6.1, 9.8, 9.8, 9.8, -10.0, -8.9, -9.8, -10.0, -8.9, -9.8,
|
|
|
|
fnan, 3.0, -0.0, 0.0, finf, fnan, 42.0, finf, fminf, finf, fnan};
|
|
|
|
float inputsd[kTableLength] = {4.8, 5.3, 6.1, -10.0, -8.9, -9.8,
|
|
|
|
9.8, 9.8, 9.8, -9.8, -11.2, -9.8,
|
|
|
|
3.0, fnan, -0.0, 0.0, fnan, finf,
|
|
|
|
finf, 42.0, finf, fminf, fnan};
|
2015-08-07 19:05:47 +00:00
|
|
|
float resf[kTableLength] = {
|
2016-02-05 17:58:19 +00:00
|
|
|
4.8, 4.8, 6.1, 9.8, -8.9, -9.8, 9.8, -8.9, -9.8, -9.8, -8.9, -9.8,
|
|
|
|
3.0, 3.0, -0.0, -0.0, finf, finf, 42.0, 42.0, fminf, fminf, fnan};
|
2015-08-07 19:05:47 +00:00
|
|
|
float resf1[kTableLength] = {
|
2016-02-05 17:58:19 +00:00
|
|
|
5.3, 5.3, 6.1, -10.0, 9.8, 9.8, -10.0, 9.8, 9.8, -10.0, -11.2, -9.8,
|
|
|
|
3.0, 3.0, 0.0, 0.0, finf, finf, finf, finf, finf, finf, fnan};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f2, MemOperand(a0, offsetof(TestFloat, a)));
|
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f8, MemOperand(a0, offsetof(TestFloat, c)) );
|
|
|
|
__ lwc1(f10, MemOperand(a0, offsetof(TestFloat, d)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ mina_d(f6, f2, f4);
|
|
|
|
__ mina_s(f12, f8, f10);
|
|
|
|
__ maxa_d(f14, f2, f4);
|
|
|
|
__ maxa_s(f16, f8, f10);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, resf)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(TestFloat, resd)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f16, MemOperand(a0, offsetof(TestFloat, resf1)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f14, MemOperand(a0, offsetof(TestFloat, resd1)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputsa[i];
|
|
|
|
test.b = inputsb[i];
|
|
|
|
test.c = inputsc[i];
|
|
|
|
test.d = inputsd[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-08-07 19:05:47 +00:00
|
|
|
if (i < kTableLength - 1) {
|
|
|
|
CHECK_EQ(test.resd, resd[i]);
|
|
|
|
CHECK_EQ(test.resf, resf[i]);
|
|
|
|
CHECK_EQ(test.resd1, resd1[i]);
|
|
|
|
CHECK_EQ(test.resf1, resf1[i]);
|
|
|
|
} else {
|
2015-12-07 05:36:41 +00:00
|
|
|
CHECK(std::isnan(test.resd));
|
|
|
|
CHECK(std::isnan(test.resf));
|
|
|
|
CHECK(std::isnan(test.resd1));
|
|
|
|
CHECK(std::isnan(test.resf1));
|
2015-08-07 19:05:47 +00:00
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------mips32r2 specific tests----------------------
|
|
|
|
TEST(trunc_l) {
|
|
|
|
if (IsMipsArchVariant(kMips32r2) && IsFp64Mode()) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int64_t c; // a trunc result
|
|
|
|
int64_t d; // b trunc result
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<double>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<float>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
2147483648.0, dFPU64InvalidResult,
|
2015-05-22 13:49:20 +00:00
|
|
|
dFPU64InvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
2147483648.0,
|
|
|
|
0,
|
|
|
|
dFPU64InvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ trunc_l_d(f8, f4);
|
|
|
|
__ trunc_l_s(f10, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f8, MemOperand(a0, offsetof(Test, c)));
|
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(Test, d)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) &&
|
|
|
|
kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(movz_movn) {
|
|
|
|
if (IsMipsArchVariant(kMips32r2)) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 4;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
2016-04-11 06:35:32 +00:00
|
|
|
int32_t rt;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
double bold;
|
|
|
|
double b1;
|
|
|
|
double bold1;
|
|
|
|
float c;
|
|
|
|
float d;
|
|
|
|
float dold;
|
|
|
|
float d1;
|
|
|
|
float dold1;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 5.3, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 4.8, -4.8, -0.29
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 4.8, -4.8, -0.29
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 5.3, -2.9
|
|
|
|
};
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f2, MemOperand(a0, offsetof(TestFloat, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(TestFloat, c)) );
|
|
|
|
__ lw(t0, MemOperand(a0, offsetof(TestFloat, rt)) );
|
2015-10-13 22:15:54 +00:00
|
|
|
__ Move(f12, 0.0);
|
|
|
|
__ Move(f10, 0.0);
|
|
|
|
__ Move(f16, 0.0);
|
|
|
|
__ Move(f14, 0.0);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(TestFloat, bold)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(TestFloat, dold)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f16, MemOperand(a0, offsetof(TestFloat, bold1)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f14, MemOperand(a0, offsetof(TestFloat, dold1)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ movz_s(f10, f6, t0);
|
|
|
|
__ movz_d(f12, f2, t0);
|
|
|
|
__ movn_s(f14, f6, t0);
|
|
|
|
__ movn_d(f16, f2, t0);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(TestFloat, d)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f14, MemOperand(a0, offsetof(TestFloat, d1)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f16, MemOperand(a0, offsetof(TestFloat, b1)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.c = inputs_S[i];
|
|
|
|
|
|
|
|
test.rt = 1;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.b, test.bold);
|
|
|
|
CHECK_EQ(test.d, test.dold);
|
|
|
|
CHECK_EQ(test.b1, outputs_D[i]);
|
|
|
|
CHECK_EQ(test.d1, outputs_S[i]);
|
|
|
|
|
|
|
|
test.rt = 0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.b, outputs_D[i]);
|
|
|
|
CHECK_EQ(test.d, outputs_S[i]);
|
|
|
|
CHECK_EQ(test.b1, test.bold1);
|
|
|
|
CHECK_EQ(test.d1, test.dold1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(movt_movd) {
|
|
|
|
if (IsMipsArchVariant(kMips32r2)) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 4;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
double srcd;
|
|
|
|
double dstd;
|
|
|
|
double dstdold;
|
|
|
|
double dstd1;
|
|
|
|
double dstdold1;
|
|
|
|
float srcf;
|
|
|
|
float dstf;
|
|
|
|
float dstfold;
|
|
|
|
float dstf1;
|
|
|
|
float dstfold1;
|
|
|
|
int32_t cc;
|
|
|
|
int32_t fcsr;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 20.8, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.88, 4.8, -4.8, -0.29
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.88, 4.8, -4.8, -0.29
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 20.8, -2.9
|
|
|
|
};
|
|
|
|
int condition_flags[8] = {0, 1, 2, 3, 4, 5, 6, 7};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.srcd = inputs_D[i];
|
|
|
|
test.srcf = inputs_S[i];
|
|
|
|
|
|
|
|
for (int j = 0; j< 8; j++) {
|
|
|
|
test.cc = condition_flags[j];
|
|
|
|
if (test.cc == 0) {
|
|
|
|
test.fcsr = 1 << 23;
|
|
|
|
} else {
|
|
|
|
test.fcsr = 1 << (24+condition_flags[j]);
|
|
|
|
}
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f2, MemOperand(a0, offsetof(TestFloat, srcd)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(TestFloat, srcf)) );
|
|
|
|
__ lw(t1, MemOperand(a0, offsetof(TestFloat, fcsr)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ cfc1(t0, FCSR);
|
|
|
|
__ ctc1(t1, FCSR);
|
|
|
|
__ li(t2, 0x0);
|
|
|
|
__ mtc1(t2, f12);
|
|
|
|
__ mtc1(t2, f10);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, dstdold)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, dstfold)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ movt_s(f12, f4, test.cc);
|
|
|
|
__ movt_d(f10, f2, test.cc);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, dstf)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, dstd)));
|
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, dstdold1)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, dstfold1)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ movf_s(f12, f4, test.cc);
|
|
|
|
__ movf_d(f10, f2, test.cc);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, dstf1)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, dstd1)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ ctc1(t0, FCSR);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.dstf, outputs_S[i]);
|
|
|
|
CHECK_EQ(test.dstd, outputs_D[i]);
|
|
|
|
CHECK_EQ(test.dstf1, test.dstfold1);
|
|
|
|
CHECK_EQ(test.dstd1, test.dstdold1);
|
|
|
|
test.fcsr = 0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.dstf, test.dstfold);
|
|
|
|
CHECK_EQ(test.dstd, test.dstdold);
|
|
|
|
CHECK_EQ(test.dstf1, outputs_S[i]);
|
|
|
|
CHECK_EQ(test.dstd1, outputs_D[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------tests for all archs--------------------------
|
|
|
|
TEST(cvt_w_d) {
|
2015-04-30 06:29:08 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-04-30 06:29:08 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
double a;
|
|
|
|
int32_t b;
|
|
|
|
int32_t fcsr;
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 24;
|
|
|
|
double inputs[kTableLength] = {
|
2015-04-30 06:29:08 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483637.0, 2147483638.0, 2147483639.0,
|
|
|
|
2147483640.0, 2147483641.0, 2147483642.0,
|
|
|
|
2147483643.0, 2147483644.0, 2147483645.0,
|
|
|
|
2147483646.0, 2147483647.0, 2147483653.0
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RN[kTableLength] = {
|
2015-04-30 06:29:08 +00:00
|
|
|
2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
|
|
|
|
-2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
|
|
|
|
2147483637.0, 2147483638.0, 2147483639.0,
|
|
|
|
2147483640.0, 2147483641.0, 2147483642.0,
|
|
|
|
2147483643.0, 2147483644.0, 2147483645.0,
|
|
|
|
2147483646.0, 2147483647.0, kFPUInvalidResult};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RZ[kTableLength] = {
|
2015-04-30 06:29:08 +00:00
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
2147483637.0, 2147483638.0, 2147483639.0,
|
|
|
|
2147483640.0, 2147483641.0, 2147483642.0,
|
|
|
|
2147483643.0, 2147483644.0, 2147483645.0,
|
|
|
|
2147483646.0, 2147483647.0, kFPUInvalidResult};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RP[kTableLength] = {
|
2015-04-30 06:29:08 +00:00
|
|
|
3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
2147483637.0, 2147483638.0, 2147483639.0,
|
|
|
|
2147483640.0, 2147483641.0, 2147483642.0,
|
|
|
|
2147483643.0, 2147483644.0, 2147483645.0,
|
|
|
|
2147483646.0, 2147483647.0, kFPUInvalidResult};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_RM[kTableLength] = {
|
2015-04-30 06:29:08 +00:00
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
|
|
|
|
2147483637.0, 2147483638.0, 2147483639.0,
|
|
|
|
2147483640.0, 2147483641.0, 2147483642.0,
|
|
|
|
2147483643.0, 2147483644.0, 2147483645.0,
|
|
|
|
2147483646.0, 2147483647.0, kFPUInvalidResult};
|
|
|
|
int fcsr_inputs[4] =
|
|
|
|
{kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf};
|
|
|
|
double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM};
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(t0, MemOperand(a0, offsetof(Test, fcsr)) );
|
2015-04-30 06:29:08 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ ctc1(t0, FCSR);
|
|
|
|
__ cvt_w_d(f8, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(Test, b)) );
|
2015-04-30 06:29:08 +00:00
|
|
|
__ ctc1(t1, FCSR);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-04-30 06:29:08 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
test.fcsr = fcsr_inputs[j];
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-04-30 06:29:08 +00:00
|
|
|
test.a = inputs[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-04-30 06:29:08 +00:00
|
|
|
CHECK_EQ(test.b, outputs[j][i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
TEST(trunc_w) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int32_t c; // a trunc result
|
|
|
|
int32_t d; // b trunc result
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
|
|
|
std::numeric_limits<double>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
|
|
|
std::numeric_limits<float>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
kFPUInvalidResult, kFPUInvalidResult,
|
|
|
|
kFPUInvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
kFPUInvalidResult,
|
|
|
|
0,
|
|
|
|
kFPUInvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ trunc_w_d(f8, f4);
|
|
|
|
__ trunc_w_s(f10, f6);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(Test, c)) );
|
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(Test, d)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(round_w) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int32_t c; // a trunc result
|
|
|
|
int32_t d; // b trunc result
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
|
|
|
std::numeric_limits<double>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
|
|
|
std::numeric_limits<float>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
|
|
|
|
-2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
|
|
|
|
kFPUInvalidResult, kFPUInvalidResult,
|
|
|
|
kFPUInvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
|
|
|
|
-2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
|
|
|
|
kFPUInvalidResult, 0,
|
|
|
|
kFPUInvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ round_w_d(f8, f4);
|
|
|
|
__ round_w_s(f10, f6);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(Test, c)) );
|
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(Test, d)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(round_l) {
|
|
|
|
if (IsFp64Mode()) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int64_t c;
|
|
|
|
int64_t d;
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<double>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<float>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
|
|
|
|
-2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
|
|
|
|
2147483648.0, dFPU64InvalidResult,
|
2015-05-22 13:49:20 +00:00
|
|
|
dFPU64InvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
|
|
|
|
-2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
|
|
|
|
2147483648.0,
|
|
|
|
0,
|
|
|
|
dFPU64InvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ round_l_d(f8, f4);
|
|
|
|
__ round_l_s(f10, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f8, MemOperand(a0, offsetof(Test, c)));
|
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(Test, d)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) &&
|
|
|
|
kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(sub) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 12;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
float a;
|
|
|
|
float b;
|
|
|
|
float resultS;
|
|
|
|
double c;
|
|
|
|
double d;
|
|
|
|
double resultD;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputfs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, 4.8, 2.9, -5.3, -4.8, -2.9,
|
|
|
|
5.3, 4.8, 2.9, -5.3, -4.8, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputft_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 5.3, 2.9, 4.8, 5.3, 2.9,
|
|
|
|
-4.8, -5.3, -2.9, -4.8, -5.3, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.5, -0.5, 0.0, -10.1, -10.1, -5.8,
|
|
|
|
10.1, 10.1, 5.8, -0.5, 0.5, 0.0
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputfs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, 4.8, 2.9, -5.3, -4.8, -2.9,
|
|
|
|
5.3, 4.8, 2.9, -5.3, -4.8, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputft_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 5.3, 2.9, 4.8, 5.3, 2.9,
|
|
|
|
-4.8, -5.3, -2.9, -4.8, -5.3, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.5, -0.5, 0.0, -10.1, -10.1, -5.8,
|
|
|
|
10.1, 10.1, 5.8, -0.5, 0.5, 0.0
|
|
|
|
};
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f2, MemOperand(a0, offsetof(TestFloat, a)) );
|
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(TestFloat, b)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f8, MemOperand(a0, offsetof(TestFloat, c)));
|
|
|
|
__ Ldc1(f10, MemOperand(a0, offsetof(TestFloat, d)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ sub_s(f6, f2, f4);
|
|
|
|
__ sub_d(f12, f8, f10);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(TestFloat, resultS)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(TestFloat, resultD)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputfs_S[i];
|
|
|
|
test.b = inputft_S[i];
|
|
|
|
test.c = inputfs_D[i];
|
|
|
|
test.d = inputft_D[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.resultS, outputs_S[i]);
|
|
|
|
CHECK_EQ(test.resultD, outputs_D[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(sqrt_rsqrt_recip) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 4;
|
2015-05-19 10:35:24 +00:00
|
|
|
const double deltaDouble = 2E-15;
|
|
|
|
const float deltaFloat = 2E-7;
|
|
|
|
const float sqrt2_s = sqrt(2);
|
|
|
|
const double sqrt2_d = sqrt(2);
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
float a;
|
|
|
|
float resultS;
|
|
|
|
float resultS1;
|
|
|
|
float resultS2;
|
|
|
|
double c;
|
|
|
|
double resultD;
|
|
|
|
double resultD1;
|
|
|
|
double resultD2;
|
|
|
|
}TestFloat;
|
|
|
|
TestFloat test;
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0L, 4.0L, 2.0L, 4e-28L
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0L, 2.0L, sqrt2_d, 2e-14L
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0, 4.0, 2.0, 4e-28
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0, 2.0, sqrt2_s, 2e-14
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f2, MemOperand(a0, offsetof(TestFloat, a)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f8, MemOperand(a0, offsetof(TestFloat, c)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ sqrt_s(f6, f2);
|
|
|
|
__ sqrt_d(f12, f8);
|
2015-07-01 16:15:34 +00:00
|
|
|
|
|
|
|
if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
|
|
|
|
__ rsqrt_d(f14, f8);
|
|
|
|
__ rsqrt_s(f16, f2);
|
|
|
|
__ recip_d(f18, f8);
|
2015-09-15 07:36:59 +00:00
|
|
|
__ recip_s(f4, f2);
|
2015-07-01 16:15:34 +00:00
|
|
|
}
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(TestFloat, resultS)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(TestFloat, resultD)));
|
2015-07-01 16:15:34 +00:00
|
|
|
|
|
|
|
if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
|
|
|
|
__ swc1(f16, MemOperand(a0, offsetof(TestFloat, resultS1)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f14, MemOperand(a0, offsetof(TestFloat, resultD1)));
|
2015-09-15 07:36:59 +00:00
|
|
|
__ swc1(f4, MemOperand(a0, offsetof(TestFloat, resultS2)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f18, MemOperand(a0, offsetof(TestFloat, resultD2)));
|
2015-07-01 16:15:34 +00:00
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
float f1;
|
|
|
|
double d1;
|
|
|
|
test.a = inputs_S[i];
|
|
|
|
test.c = inputs_D[i];
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
CHECK_EQ(test.resultS, outputs_S[i]);
|
|
|
|
CHECK_EQ(test.resultD, outputs_D[i]);
|
|
|
|
|
2015-07-01 16:15:34 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
|
|
|
|
if (i != 0) {
|
|
|
|
f1 = test.resultS1 - 1.0F/outputs_S[i];
|
|
|
|
f1 = (f1 < 0) ? f1 : -f1;
|
|
|
|
CHECK(f1 <= deltaFloat);
|
|
|
|
d1 = test.resultD1 - 1.0L/outputs_D[i];
|
|
|
|
d1 = (d1 < 0) ? d1 : -d1;
|
|
|
|
CHECK(d1 <= deltaDouble);
|
|
|
|
f1 = test.resultS2 - 1.0F/inputs_S[i];
|
|
|
|
f1 = (f1 < 0) ? f1 : -f1;
|
|
|
|
CHECK(f1 <= deltaFloat);
|
|
|
|
d1 = test.resultD2 - 1.0L/inputs_D[i];
|
|
|
|
d1 = (d1 < 0) ? d1 : -d1;
|
|
|
|
CHECK(d1 <= deltaDouble);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.resultS1, 1.0F/outputs_S[i]);
|
|
|
|
CHECK_EQ(test.resultD1, 1.0L/outputs_D[i]);
|
|
|
|
CHECK_EQ(test.resultS2, 1.0F/inputs_S[i]);
|
|
|
|
CHECK_EQ(test.resultD2, 1.0L/inputs_D[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(neg) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 3;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
float a;
|
|
|
|
float resultS;
|
|
|
|
double c;
|
|
|
|
double resultD;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0, 4.0, -2.0
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0, -4.0, 2.0
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0, 4.0, -2.0
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
0.0, -4.0, 2.0
|
|
|
|
};
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f2, MemOperand(a0, offsetof(TestFloat, a)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f8, MemOperand(a0, offsetof(TestFloat, c)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ neg_s(f6, f2);
|
|
|
|
__ neg_d(f12, f8);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(TestFloat, resultS)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(TestFloat, resultD)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_S[i];
|
|
|
|
test.c = inputs_D[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.resultS, outputs_S[i]);
|
|
|
|
CHECK_EQ(test.resultD, outputs_D[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(mul) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 4;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
float a;
|
|
|
|
float b;
|
|
|
|
float resultS;
|
|
|
|
double c;
|
|
|
|
double d;
|
|
|
|
double resultD;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputfs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 5.3, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputft_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 4.8, -4.8, -0.29
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputfs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 5.3, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputft_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 4.8, -4.8, -0.29
|
|
|
|
};
|
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f2, MemOperand(a0, offsetof(TestFloat, a)) );
|
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(TestFloat, b)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(TestFloat, c)));
|
|
|
|
__ Ldc1(f8, MemOperand(a0, offsetof(TestFloat, d)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ mul_s(f10, f2, f4);
|
|
|
|
__ mul_d(f12, f6, f8);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(TestFloat, resultS)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f12, MemOperand(a0, offsetof(TestFloat, resultD)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputfs_S[i];
|
|
|
|
test.b = inputft_S[i];
|
|
|
|
test.c = inputfs_D[i];
|
|
|
|
test.d = inputft_D[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.resultS, inputfs_S[i]*inputft_S[i]);
|
|
|
|
CHECK_EQ(test.resultD, inputfs_D[i]*inputft_D[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(mov) {
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 4;
|
2015-05-19 10:35:24 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
float c;
|
|
|
|
float d;
|
|
|
|
}TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 5.3, -2.9
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 4.8, -4.8, -0.29
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:05:47 +00:00
|
|
|
float outputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
4.8, 4.8, -4.8, -0.29
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
5.3, -5.3, 5.3, -2.9
|
|
|
|
};
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(TestFloat, c)) );
|
2015-09-15 07:36:59 +00:00
|
|
|
__ mov_s(f8, f6);
|
|
|
|
__ mov_d(f10, f4);
|
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(TestFloat, d)) );
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-09-15 07:36:59 +00:00
|
|
|
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.c = inputs_S[i];
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.b, outputs_D[i]);
|
|
|
|
CHECK_EQ(test.d, outputs_S[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(floor_w) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int32_t c; // a floor result
|
|
|
|
int32_t d; // b floor result
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
|
|
|
std::numeric_limits<double>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
|
|
|
std::numeric_limits<float>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
|
|
|
|
kFPUInvalidResult, kFPUInvalidResult,
|
|
|
|
kFPUInvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
|
|
|
|
kFPUInvalidResult,
|
|
|
|
0,
|
|
|
|
kFPUInvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ floor_w_d(f8, f4);
|
|
|
|
__ floor_w_s(f10, f6);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(Test, c)) );
|
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(Test, d)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(floor_l) {
|
|
|
|
if (IsFp64Mode()) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int64_t c;
|
|
|
|
int64_t d;
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<double>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<float>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
|
|
|
|
2147483648.0, dFPU64InvalidResult,
|
2015-05-22 13:49:20 +00:00
|
|
|
dFPU64InvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
|
|
|
|
-3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
|
|
|
|
2147483648.0,
|
|
|
|
0,
|
|
|
|
dFPU64InvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ floor_l_d(f8, f4);
|
|
|
|
__ floor_l_s(f10, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f8, MemOperand(a0, offsetof(Test, c)));
|
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(Test, d)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) &&
|
|
|
|
kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(ceil_w) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int32_t c; // a floor result
|
|
|
|
int32_t d; // b floor result
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
|
|
|
std::numeric_limits<double>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
|
|
|
std::numeric_limits<float>::infinity()
|
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
kFPUInvalidResult, kFPUInvalidResult,
|
|
|
|
kFPUInvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
kFPUInvalidResult,
|
|
|
|
0,
|
|
|
|
kFPUInvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ ceil_w_d(f8, f4);
|
|
|
|
__ ceil_w_s(f10, f6);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f8, MemOperand(a0, offsetof(Test, c)) );
|
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(Test, d)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(ceil_l) {
|
|
|
|
if (IsFp64Mode()) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-19 10:35:24 +00:00
|
|
|
const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
|
|
|
|
typedef struct test_float {
|
2015-12-02 10:54:38 +00:00
|
|
|
uint32_t isNaN2008;
|
2015-05-19 10:35:24 +00:00
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
int64_t c;
|
|
|
|
int64_t d;
|
|
|
|
}Test;
|
2015-08-07 19:05:47 +00:00
|
|
|
const int kTableLength = 15;
|
|
|
|
double inputs_D[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<double>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<double>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
float inputs_S[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
|
|
|
|
-2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
|
|
|
|
2147483648.0,
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
2015-05-22 13:49:20 +00:00
|
|
|
std::numeric_limits<float>::infinity()
|
2015-05-19 10:35:24 +00:00
|
|
|
};
|
2015-08-07 19:05:47 +00:00
|
|
|
double outputs[kTableLength] = {
|
2015-05-19 10:35:24 +00:00
|
|
|
3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
2147483648.0, dFPU64InvalidResult,
|
2015-05-22 13:49:20 +00:00
|
|
|
dFPU64InvalidResult};
|
2015-12-02 10:54:38 +00:00
|
|
|
double outputsNaN2008[kTableLength] = {
|
|
|
|
3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
|
|
|
|
-2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
|
|
|
|
2147483648.0,
|
|
|
|
0,
|
|
|
|
dFPU64InvalidResult};
|
2015-05-19 10:35:24 +00:00
|
|
|
|
2015-12-02 10:54:38 +00:00
|
|
|
__ cfc1(t1, FCSR);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008)));
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, a)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(Test, b)) );
|
2015-05-19 10:35:24 +00:00
|
|
|
__ ceil_l_d(f8, f4);
|
|
|
|
__ ceil_l_s(f10, f6);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f8, MemOperand(a0, offsetof(Test, c)));
|
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(Test, d)));
|
2015-05-19 10:35:24 +00:00
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
Test test;
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-19 10:35:24 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
2015-08-07 19:05:47 +00:00
|
|
|
for (int i = 0; i < kTableLength; i++) {
|
2015-05-19 10:35:24 +00:00
|
|
|
test.a = inputs_D[i];
|
|
|
|
test.b = inputs_S[i];
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-12-02 10:54:38 +00:00
|
|
|
if ((test.isNaN2008 & kFCSRNaN2008FlagMask) &&
|
|
|
|
kArchVariant == kMips32r6) {
|
|
|
|
CHECK_EQ(test.c, outputsNaN2008[i]);
|
|
|
|
} else {
|
|
|
|
CHECK_EQ(test.c, outputs[i]);
|
|
|
|
}
|
2015-05-19 10:35:24 +00:00
|
|
|
CHECK_EQ(test.d, test.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-09 20:49:46 +00:00
|
|
|
TEST(jump_tables1) {
|
|
|
|
// Test jump tables with forward jumps.
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
Assembler assm(isolate, nullptr, 0);
|
|
|
|
|
|
|
|
const int kNumCases = 512;
|
|
|
|
int values[kNumCases];
|
|
|
|
isolate->random_number_generator()->NextBytes(values, sizeof(values));
|
|
|
|
Label labels[kNumCases];
|
|
|
|
|
|
|
|
__ addiu(sp, sp, -4);
|
|
|
|
__ sw(ra, MemOperand(sp));
|
|
|
|
|
|
|
|
Label done;
|
|
|
|
{
|
2015-07-13 07:28:24 +00:00
|
|
|
__ BlockTrampolinePoolFor(kNumCases + 7);
|
2015-02-09 20:49:46 +00:00
|
|
|
PredictableCodeSizeScope predictable(
|
|
|
|
&assm, (kNumCases + 7) * Assembler::kInstrSize);
|
|
|
|
Label here;
|
|
|
|
|
|
|
|
__ bal(&here);
|
|
|
|
__ nop();
|
|
|
|
__ bind(&here);
|
|
|
|
__ sll(at, a0, 2);
|
|
|
|
__ addu(at, at, ra);
|
|
|
|
__ lw(at, MemOperand(at, 5 * Assembler::kInstrSize));
|
|
|
|
__ jr(at);
|
|
|
|
__ nop();
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
|
|
|
__ dd(&labels[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
|
|
|
__ bind(&labels[i]);
|
|
|
|
__ lui(v0, (values[i] >> 16) & 0xffff);
|
|
|
|
__ ori(v0, v0, values[i] & 0xffff);
|
|
|
|
__ b(&done);
|
|
|
|
__ nop();
|
|
|
|
}
|
|
|
|
|
|
|
|
__ bind(&done);
|
|
|
|
__ lw(ra, MemOperand(sp));
|
|
|
|
__ addiu(sp, sp, 4);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, assm.UnboundLabelsCount());
|
2016-04-28 10:58:41 +00:00
|
|
|
|
2015-02-09 20:49:46 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-02-09 20:49:46 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F1 f = FUNCTION_CAST<F1>(code->entry());
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
2015-11-23 08:09:34 +00:00
|
|
|
int res = reinterpret_cast<int>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
|
2015-02-09 20:49:46 +00:00
|
|
|
::printf("f(%d) = %d\n", i, res);
|
|
|
|
CHECK_EQ(values[i], res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(jump_tables2) {
|
|
|
|
// Test jump tables with backward jumps.
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
Assembler assm(isolate, nullptr, 0);
|
|
|
|
|
|
|
|
const int kNumCases = 512;
|
|
|
|
int values[kNumCases];
|
|
|
|
isolate->random_number_generator()->NextBytes(values, sizeof(values));
|
|
|
|
Label labels[kNumCases];
|
|
|
|
|
|
|
|
__ addiu(sp, sp, -4);
|
|
|
|
__ sw(ra, MemOperand(sp));
|
|
|
|
|
|
|
|
Label done, dispatch;
|
|
|
|
__ b(&dispatch);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
|
|
|
__ bind(&labels[i]);
|
|
|
|
__ lui(v0, (values[i] >> 16) & 0xffff);
|
|
|
|
__ ori(v0, v0, values[i] & 0xffff);
|
|
|
|
__ b(&done);
|
|
|
|
__ nop();
|
|
|
|
}
|
|
|
|
|
|
|
|
__ bind(&dispatch);
|
|
|
|
{
|
2015-07-13 07:28:24 +00:00
|
|
|
__ BlockTrampolinePoolFor(kNumCases + 7);
|
2015-02-09 20:49:46 +00:00
|
|
|
PredictableCodeSizeScope predictable(
|
|
|
|
&assm, (kNumCases + 7) * Assembler::kInstrSize);
|
|
|
|
Label here;
|
|
|
|
|
|
|
|
__ bal(&here);
|
|
|
|
__ nop();
|
|
|
|
__ bind(&here);
|
|
|
|
__ sll(at, a0, 2);
|
|
|
|
__ addu(at, at, ra);
|
|
|
|
__ lw(at, MemOperand(at, 5 * Assembler::kInstrSize));
|
|
|
|
__ jr(at);
|
|
|
|
__ nop();
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
|
|
|
__ dd(&labels[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
__ bind(&done);
|
|
|
|
__ lw(ra, MemOperand(sp));
|
|
|
|
__ addiu(sp, sp, 4);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-02-09 20:49:46 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F1 f = FUNCTION_CAST<F1>(code->entry());
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
2015-11-23 08:09:34 +00:00
|
|
|
int res = reinterpret_cast<int>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
|
2015-02-09 20:49:46 +00:00
|
|
|
::printf("f(%d) = %d\n", i, res);
|
|
|
|
CHECK_EQ(values[i], res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(jump_tables3) {
|
|
|
|
// Test jump tables with backward jumps and embedded heap objects.
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
Assembler assm(isolate, nullptr, 0);
|
|
|
|
|
|
|
|
const int kNumCases = 256;
|
|
|
|
Handle<Object> values[kNumCases];
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
|
|
|
double value = isolate->random_number_generator()->NextDouble();
|
|
|
|
values[i] = isolate->factory()->NewHeapNumber(value, IMMUTABLE, TENURED);
|
|
|
|
}
|
|
|
|
Label labels[kNumCases];
|
|
|
|
Object* obj;
|
|
|
|
int32_t imm32;
|
|
|
|
|
|
|
|
__ addiu(sp, sp, -4);
|
|
|
|
__ sw(ra, MemOperand(sp));
|
|
|
|
|
|
|
|
Label done, dispatch;
|
|
|
|
__ b(&dispatch);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
|
|
|
__ bind(&labels[i]);
|
|
|
|
obj = *values[i];
|
|
|
|
imm32 = reinterpret_cast<intptr_t>(obj);
|
|
|
|
__ lui(v0, (imm32 >> 16) & 0xffff);
|
|
|
|
__ ori(v0, v0, imm32 & 0xffff);
|
|
|
|
__ b(&done);
|
|
|
|
__ nop();
|
|
|
|
}
|
|
|
|
|
|
|
|
__ bind(&dispatch);
|
|
|
|
{
|
2015-07-13 07:28:24 +00:00
|
|
|
__ BlockTrampolinePoolFor(kNumCases + 7);
|
2015-02-09 20:49:46 +00:00
|
|
|
PredictableCodeSizeScope predictable(
|
|
|
|
&assm, (kNumCases + 7) * Assembler::kInstrSize);
|
|
|
|
Label here;
|
|
|
|
|
|
|
|
__ bal(&here);
|
|
|
|
__ nop();
|
|
|
|
__ bind(&here);
|
|
|
|
__ sll(at, a0, 2);
|
|
|
|
__ addu(at, at, ra);
|
|
|
|
__ lw(at, MemOperand(at, 5 * Assembler::kInstrSize));
|
|
|
|
__ jr(at);
|
|
|
|
__ nop();
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
|
|
|
__ dd(&labels[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
__ bind(&done);
|
|
|
|
__ lw(ra, MemOperand(sp));
|
|
|
|
__ addiu(sp, sp, 4);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-02-09 20:49:46 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F1 f = FUNCTION_CAST<F1>(code->entry());
|
|
|
|
for (int i = 0; i < kNumCases; ++i) {
|
2015-11-23 08:09:34 +00:00
|
|
|
Handle<Object> result(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0), isolate);
|
2015-02-09 20:49:46 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
::printf("f(%d) = ", i);
|
|
|
|
result->Print(std::cout);
|
|
|
|
::printf("\n");
|
|
|
|
#endif
|
|
|
|
CHECK(values[i].is_identical_to(result));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-22 13:49:20 +00:00
|
|
|
TEST(BITSWAP) {
|
|
|
|
// Test BITSWAP
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int32_t r1;
|
|
|
|
int32_t r2;
|
|
|
|
int32_t r3;
|
|
|
|
int32_t r4;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
|
|
|
Assembler assm(isolate, NULL, 0);
|
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(a2, MemOperand(a0, offsetof(T, r1)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ nop();
|
|
|
|
__ bitswap(a1, a2);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(a1, MemOperand(a0, offsetof(T, r1)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lw(a2, MemOperand(a0, offsetof(T, r2)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ nop();
|
|
|
|
__ bitswap(a1, a2);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(a1, MemOperand(a0, offsetof(T, r2)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
t.r1 = 0x781A15C3;
|
|
|
|
t.r2 = 0x8B71FCDE;
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2015-05-22 13:49:20 +00:00
|
|
|
USE(dummy);
|
|
|
|
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0x1E58A8C3), t.r1);
|
|
|
|
CHECK_EQ(static_cast<int32_t>(0xD18E3F7B), t.r2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(class_fmt) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
// Test CLASS.fmt instruction.
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double dSignalingNan;
|
|
|
|
double dQuietNan;
|
|
|
|
double dNegInf;
|
|
|
|
double dNegNorm;
|
|
|
|
double dNegSubnorm;
|
|
|
|
double dNegZero;
|
|
|
|
double dPosInf;
|
|
|
|
double dPosNorm;
|
|
|
|
double dPosSubnorm;
|
|
|
|
double dPosZero;
|
|
|
|
float fSignalingNan;
|
|
|
|
float fQuietNan;
|
|
|
|
float fNegInf;
|
|
|
|
float fNegNorm;
|
|
|
|
float fNegSubnorm;
|
|
|
|
float fNegZero;
|
|
|
|
float fPosInf;
|
|
|
|
float fPosNorm;
|
|
|
|
float fPosSubnorm;
|
|
|
|
float fPosZero; } T;
|
|
|
|
T t;
|
|
|
|
|
|
|
|
// Create a function that accepts &t, and loads, manipulates, and stores
|
|
|
|
// the doubles t.a ... t.f.
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dSignalingNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dSignalingNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dQuietNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dQuietNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dNegInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dNegInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dNegNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dNegNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dNegSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dNegSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dNegZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dNegZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dPosInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dPosInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dPosNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dPosNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dPosSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dPosSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(T, dPosZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_d(f6, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(T, dPosZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
// Testing instruction CLASS.S
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fSignalingNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fSignalingNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fQuietNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fQuietNan)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fNegInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fNegInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fNegNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fNegNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fNegSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fNegSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fNegZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fNegZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fPosInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fPosInf)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fPosNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fPosNorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fPosSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fPosSubnorm)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(T, fPosZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ class_s(f6, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(T, fPosZero)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
t.dSignalingNan = std::numeric_limits<double>::signaling_NaN();
|
|
|
|
t.dQuietNan = std::numeric_limits<double>::quiet_NaN();
|
|
|
|
t.dNegInf = -1.0 / 0.0;
|
|
|
|
t.dNegNorm = -5.0;
|
|
|
|
t.dNegSubnorm = -DBL_MIN / 2.0;
|
|
|
|
t.dNegZero = -0.0;
|
|
|
|
t.dPosInf = 2.0 / 0.0;
|
|
|
|
t.dPosNorm = 275.35;
|
|
|
|
t.dPosSubnorm = DBL_MIN / 2.0;
|
|
|
|
t.dPosZero = +0.0;
|
|
|
|
// Float test values
|
|
|
|
|
|
|
|
t.fSignalingNan = std::numeric_limits<float>::signaling_NaN();
|
|
|
|
t.fQuietNan = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
t.fNegInf = -0.5/0.0;
|
|
|
|
t.fNegNorm = -FLT_MIN;
|
|
|
|
t.fNegSubnorm = -FLT_MIN / 1.5;
|
|
|
|
t.fNegZero = -0.0;
|
|
|
|
t.fPosInf = 100000.0 / 0.0;
|
|
|
|
t.fPosNorm = FLT_MAX;
|
|
|
|
t.fPosSubnorm = FLT_MIN / 20.0;
|
|
|
|
t.fPosZero = +0.0;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
2015-05-22 13:49:20 +00:00
|
|
|
USE(dummy);
|
|
|
|
// Expected double results.
|
2015-06-04 11:45:08 +00:00
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dSignalingNan), 0x001);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dQuietNan), 0x002);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dNegInf), 0x004);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dNegNorm), 0x008);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dNegSubnorm), 0x010);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dNegZero), 0x020);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dPosInf), 0x040);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dPosNorm), 0x080);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dPosSubnorm), 0x100);
|
|
|
|
CHECK_EQ(bit_cast<int64_t>(t.dPosZero), 0x200);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
// Expected float results.
|
2015-06-04 11:45:08 +00:00
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fSignalingNan), 0x001);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fQuietNan), 0x002);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fNegInf), 0x004);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fNegNorm), 0x008);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fNegSubnorm), 0x010);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fNegZero), 0x020);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fPosInf), 0x040);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fPosNorm), 0x080);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fPosSubnorm), 0x100);
|
|
|
|
CHECK_EQ(bit_cast<int32_t>(t.fPosZero), 0x200);
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(ABS) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
int64_t fir;
|
|
|
|
double a;
|
|
|
|
float b;
|
|
|
|
double fcsr;
|
|
|
|
} TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
|
|
|
|
|
|
|
// Save FIR.
|
|
|
|
__ cfc1(a1, FCSR);
|
|
|
|
// Disable FPU exceptions.
|
|
|
|
__ ctc1(zero_reg, FCSR);
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, a)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ abs_d(f10, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, a)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ abs_s(f10, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
// Restore FCSR.
|
|
|
|
__ ctc1(a1, FCSR);
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
test.a = -2.0;
|
|
|
|
test.b = -2.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.a, 2.0);
|
|
|
|
CHECK_EQ(test.b, 2.0);
|
|
|
|
|
|
|
|
test.a = 2.0;
|
|
|
|
test.b = 2.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.a, 2.0);
|
|
|
|
CHECK_EQ(test.b, 2.0);
|
|
|
|
|
|
|
|
// Testing biggest positive number
|
|
|
|
test.a = std::numeric_limits<double>::max();
|
|
|
|
test.b = std::numeric_limits<float>::max();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.a, std::numeric_limits<double>::max());
|
|
|
|
CHECK_EQ(test.b, std::numeric_limits<float>::max());
|
|
|
|
|
|
|
|
// Testing smallest negative number
|
2015-06-10 15:45:07 +00:00
|
|
|
test.a = -std::numeric_limits<double>::max(); // lowest()
|
|
|
|
test.b = -std::numeric_limits<float>::max(); // lowest()
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.a, std::numeric_limits<double>::max());
|
|
|
|
CHECK_EQ(test.b, std::numeric_limits<float>::max());
|
|
|
|
|
|
|
|
// Testing smallest positive number
|
|
|
|
test.a = -std::numeric_limits<double>::min();
|
|
|
|
test.b = -std::numeric_limits<float>::min();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.a, std::numeric_limits<double>::min());
|
|
|
|
CHECK_EQ(test.b, std::numeric_limits<float>::min());
|
|
|
|
|
|
|
|
// Testing infinity
|
|
|
|
test.a = -std::numeric_limits<double>::max()
|
|
|
|
/ std::numeric_limits<double>::min();
|
|
|
|
test.b = -std::numeric_limits<float>::max()
|
|
|
|
/ std::numeric_limits<float>::min();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.a, std::numeric_limits<double>::max()
|
|
|
|
/ std::numeric_limits<double>::min());
|
|
|
|
CHECK_EQ(test.b, std::numeric_limits<float>::max()
|
|
|
|
/ std::numeric_limits<float>::min());
|
|
|
|
|
|
|
|
test.a = std::numeric_limits<double>::quiet_NaN();
|
|
|
|
test.b = std::numeric_limits<float>::quiet_NaN();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK(std::isnan(test.a));
|
|
|
|
CHECK(std::isnan(test.b));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.a = std::numeric_limits<double>::signaling_NaN();
|
|
|
|
test.b = std::numeric_limits<float>::signaling_NaN();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK(std::isnan(test.a));
|
|
|
|
CHECK(std::isnan(test.b));
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(ADD_FMT) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
double a;
|
|
|
|
double b;
|
|
|
|
double c;
|
|
|
|
float fa;
|
|
|
|
float fb;
|
|
|
|
float fc;
|
|
|
|
} TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, a)));
|
|
|
|
__ Ldc1(f8, MemOperand(a0, offsetof(TestFloat, b)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ add_d(f10, f8, f4);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, c)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(TestFloat, fa)));
|
|
|
|
__ lwc1(f8, MemOperand(a0, offsetof(TestFloat, fb)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ add_s(f10, f8, f4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(TestFloat, fc)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
test.a = 2.0;
|
|
|
|
test.b = 3.0;
|
|
|
|
test.fa = 2.0;
|
|
|
|
test.fb = 3.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.c, 5.0);
|
|
|
|
CHECK_EQ(test.fc, 5.0);
|
|
|
|
|
|
|
|
test.a = std::numeric_limits<double>::max();
|
2015-06-10 15:45:07 +00:00
|
|
|
test.b = -std::numeric_limits<double>::max(); // lowest()
|
2015-05-22 13:49:20 +00:00
|
|
|
test.fa = std::numeric_limits<float>::max();
|
2015-06-10 15:45:07 +00:00
|
|
|
test.fb = -std::numeric_limits<float>::max(); // lowest()
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.c, 0.0);
|
|
|
|
CHECK_EQ(test.fc, 0.0);
|
|
|
|
|
|
|
|
test.a = std::numeric_limits<double>::max();
|
|
|
|
test.b = std::numeric_limits<double>::max();
|
|
|
|
test.fa = std::numeric_limits<float>::max();
|
|
|
|
test.fb = std::numeric_limits<float>::max();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK(!std::isfinite(test.c));
|
|
|
|
CHECK(!std::isfinite(test.fc));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.a = 5.0;
|
|
|
|
test.b = std::numeric_limits<double>::signaling_NaN();
|
|
|
|
test.fa = 5.0;
|
|
|
|
test.fb = std::numeric_limits<float>::signaling_NaN();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK(std::isnan(test.c));
|
|
|
|
CHECK(std::isnan(test.fc));
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(C_COND_FMT) {
|
|
|
|
if ((IsMipsArchVariant(kMips32r1)) || (IsMipsArchVariant(kMips32r2))) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
double dOp1;
|
|
|
|
double dOp2;
|
|
|
|
uint32_t dF;
|
|
|
|
uint32_t dUn;
|
|
|
|
uint32_t dEq;
|
|
|
|
uint32_t dUeq;
|
|
|
|
uint32_t dOlt;
|
|
|
|
uint32_t dUlt;
|
|
|
|
uint32_t dOle;
|
|
|
|
uint32_t dUle;
|
|
|
|
float fOp1;
|
|
|
|
float fOp2;
|
|
|
|
uint32_t fF;
|
|
|
|
uint32_t fUn;
|
|
|
|
uint32_t fEq;
|
|
|
|
uint32_t fUeq;
|
|
|
|
uint32_t fOlt;
|
|
|
|
uint32_t fUlt;
|
|
|
|
uint32_t fOle;
|
|
|
|
uint32_t fUle;
|
|
|
|
} TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
|
|
|
|
|
|
|
__ li(t1, 1);
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, dOp1)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(TestFloat, dOp2)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f14, MemOperand(a0, offsetof(TestFloat, fOp1)));
|
|
|
|
__ lwc1(f16, MemOperand(a0, offsetof(TestFloat, fOp2)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(F, f4, f6, 0);
|
|
|
|
__ c_s(F, f14, f16, 2);
|
|
|
|
__ movt(t2, t1, 0);
|
|
|
|
__ movt(t3, t1, 2);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dF)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fF)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(UN, f4, f6, 2);
|
|
|
|
__ c_s(UN, f14, f16, 4);
|
|
|
|
__ movt(t2, t1, 2);
|
|
|
|
__ movt(t3, t1, 4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dUn)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fUn)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(EQ, f4, f6, 4);
|
|
|
|
__ c_s(EQ, f14, f16, 6);
|
|
|
|
__ movt(t2, t1, 4);
|
|
|
|
__ movt(t3, t1, 6);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dEq)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fEq)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(UEQ, f4, f6, 6);
|
|
|
|
__ c_s(UEQ, f14, f16, 0);
|
|
|
|
__ movt(t2, t1, 6);
|
|
|
|
__ movt(t3, t1, 0);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dUeq)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fUeq)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(OLT, f4, f6, 0);
|
|
|
|
__ c_s(OLT, f14, f16, 2);
|
|
|
|
__ movt(t2, t1, 0);
|
|
|
|
__ movt(t3, t1, 2);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dOlt)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fOlt)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(ULT, f4, f6, 2);
|
|
|
|
__ c_s(ULT, f14, f16, 4);
|
|
|
|
__ movt(t2, t1, 2);
|
|
|
|
__ movt(t3, t1, 4);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dUlt)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fUlt)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(OLE, f4, f6, 4);
|
|
|
|
__ c_s(OLE, f14, f16, 6);
|
|
|
|
__ movt(t2, t1, 4);
|
|
|
|
__ movt(t3, t1, 6);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dOle)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fOle)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ mov(t2, zero_reg);
|
|
|
|
__ mov(t3, zero_reg);
|
|
|
|
__ c_d(ULE, f4, f6, 6);
|
|
|
|
__ c_s(ULE, f14, f16, 0);
|
|
|
|
__ movt(t2, t1, 6);
|
|
|
|
__ movt(t3, t1, 0);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ sw(t2, MemOperand(a0, offsetof(TestFloat, dUle)) );
|
|
|
|
__ sw(t3, MemOperand(a0, offsetof(TestFloat, fUle)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
test.dOp1 = 2.0;
|
|
|
|
test.dOp2 = 3.0;
|
|
|
|
test.fOp1 = 2.0;
|
|
|
|
test.fOp2 = 3.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-06-04 11:45:08 +00:00
|
|
|
CHECK_EQ(test.dF, 0U);
|
|
|
|
CHECK_EQ(test.dUn, 0U);
|
|
|
|
CHECK_EQ(test.dEq, 0U);
|
|
|
|
CHECK_EQ(test.dUeq, 0U);
|
|
|
|
CHECK_EQ(test.dOlt, 1U);
|
|
|
|
CHECK_EQ(test.dUlt, 1U);
|
|
|
|
CHECK_EQ(test.dOle, 1U);
|
|
|
|
CHECK_EQ(test.dUle, 1U);
|
|
|
|
CHECK_EQ(test.fF, 0U);
|
|
|
|
CHECK_EQ(test.fUn, 0U);
|
|
|
|
CHECK_EQ(test.fEq, 0U);
|
|
|
|
CHECK_EQ(test.fUeq, 0U);
|
|
|
|
CHECK_EQ(test.fOlt, 1U);
|
|
|
|
CHECK_EQ(test.fUlt, 1U);
|
|
|
|
CHECK_EQ(test.fOle, 1U);
|
|
|
|
CHECK_EQ(test.fUle, 1U);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.dOp1 = std::numeric_limits<double>::max();
|
|
|
|
test.dOp2 = std::numeric_limits<double>::min();
|
|
|
|
test.fOp1 = std::numeric_limits<float>::min();
|
2015-06-10 15:45:07 +00:00
|
|
|
test.fOp2 = -std::numeric_limits<float>::max(); // lowest()
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-06-04 11:45:08 +00:00
|
|
|
CHECK_EQ(test.dF, 0U);
|
|
|
|
CHECK_EQ(test.dUn, 0U);
|
|
|
|
CHECK_EQ(test.dEq, 0U);
|
|
|
|
CHECK_EQ(test.dUeq, 0U);
|
|
|
|
CHECK_EQ(test.dOlt, 0U);
|
|
|
|
CHECK_EQ(test.dUlt, 0U);
|
|
|
|
CHECK_EQ(test.dOle, 0U);
|
|
|
|
CHECK_EQ(test.dUle, 0U);
|
|
|
|
CHECK_EQ(test.fF, 0U);
|
|
|
|
CHECK_EQ(test.fUn, 0U);
|
|
|
|
CHECK_EQ(test.fEq, 0U);
|
|
|
|
CHECK_EQ(test.fUeq, 0U);
|
|
|
|
CHECK_EQ(test.fOlt, 0U);
|
|
|
|
CHECK_EQ(test.fUlt, 0U);
|
|
|
|
CHECK_EQ(test.fOle, 0U);
|
|
|
|
CHECK_EQ(test.fUle, 0U);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-10 15:45:07 +00:00
|
|
|
test.dOp1 = -std::numeric_limits<double>::max(); // lowest()
|
|
|
|
test.dOp2 = -std::numeric_limits<double>::max(); // lowest()
|
2015-05-22 13:49:20 +00:00
|
|
|
test.fOp1 = std::numeric_limits<float>::max();
|
|
|
|
test.fOp2 = std::numeric_limits<float>::max();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-06-04 11:45:08 +00:00
|
|
|
CHECK_EQ(test.dF, 0U);
|
|
|
|
CHECK_EQ(test.dUn, 0U);
|
|
|
|
CHECK_EQ(test.dEq, 1U);
|
|
|
|
CHECK_EQ(test.dUeq, 1U);
|
|
|
|
CHECK_EQ(test.dOlt, 0U);
|
|
|
|
CHECK_EQ(test.dUlt, 0U);
|
|
|
|
CHECK_EQ(test.dOle, 1U);
|
|
|
|
CHECK_EQ(test.dUle, 1U);
|
|
|
|
CHECK_EQ(test.fF, 0U);
|
|
|
|
CHECK_EQ(test.fUn, 0U);
|
|
|
|
CHECK_EQ(test.fEq, 1U);
|
|
|
|
CHECK_EQ(test.fUeq, 1U);
|
|
|
|
CHECK_EQ(test.fOlt, 0U);
|
|
|
|
CHECK_EQ(test.fUlt, 0U);
|
|
|
|
CHECK_EQ(test.fOle, 1U);
|
|
|
|
CHECK_EQ(test.fUle, 1U);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.dOp1 = std::numeric_limits<double>::quiet_NaN();
|
|
|
|
test.dOp2 = 0.0;
|
|
|
|
test.fOp1 = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
test.fOp2 = 0.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-06-04 11:45:08 +00:00
|
|
|
CHECK_EQ(test.dF, 0U);
|
|
|
|
CHECK_EQ(test.dUn, 1U);
|
|
|
|
CHECK_EQ(test.dEq, 0U);
|
|
|
|
CHECK_EQ(test.dUeq, 1U);
|
|
|
|
CHECK_EQ(test.dOlt, 0U);
|
|
|
|
CHECK_EQ(test.dUlt, 1U);
|
|
|
|
CHECK_EQ(test.dOle, 0U);
|
|
|
|
CHECK_EQ(test.dUle, 1U);
|
|
|
|
CHECK_EQ(test.fF, 0U);
|
|
|
|
CHECK_EQ(test.fUn, 1U);
|
|
|
|
CHECK_EQ(test.fEq, 0U);
|
|
|
|
CHECK_EQ(test.fUeq, 1U);
|
|
|
|
CHECK_EQ(test.fOlt, 0U);
|
|
|
|
CHECK_EQ(test.fUlt, 1U);
|
|
|
|
CHECK_EQ(test.fOle, 0U);
|
|
|
|
CHECK_EQ(test.fUle, 1U);
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(CMP_COND_FMT) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
double dOp1;
|
|
|
|
double dOp2;
|
|
|
|
double dF;
|
|
|
|
double dUn;
|
|
|
|
double dEq;
|
|
|
|
double dUeq;
|
|
|
|
double dOlt;
|
|
|
|
double dUlt;
|
|
|
|
double dOle;
|
|
|
|
double dUle;
|
|
|
|
double dOr;
|
|
|
|
double dUne;
|
|
|
|
double dNe;
|
|
|
|
float fOp1;
|
|
|
|
float fOp2;
|
|
|
|
float fF;
|
|
|
|
float fUn;
|
|
|
|
float fEq;
|
|
|
|
float fUeq;
|
|
|
|
float fOlt;
|
|
|
|
float fUlt;
|
|
|
|
float fOle;
|
|
|
|
float fUle;
|
|
|
|
float fOr;
|
|
|
|
float fUne;
|
|
|
|
float fNe;
|
|
|
|
} TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
|
|
|
|
|
|
|
__ li(t1, 1);
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestFloat, dOp1)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(TestFloat, dOp2)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f14, MemOperand(a0, offsetof(TestFloat, fOp1)));
|
|
|
|
__ lwc1(f16, MemOperand(a0, offsetof(TestFloat, fOp2)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(F, f2, f4, f6);
|
|
|
|
__ cmp_s(F, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dF)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fF)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(UN, f2, f4, f6);
|
|
|
|
__ cmp_s(UN, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dUn)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fUn)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(EQ, f2, f4, f6);
|
|
|
|
__ cmp_s(EQ, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dEq)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fEq)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(UEQ, f2, f4, f6);
|
|
|
|
__ cmp_s(UEQ, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dUeq)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fUeq)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(LT, f2, f4, f6);
|
|
|
|
__ cmp_s(LT, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dOlt)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fOlt)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(ULT, f2, f4, f6);
|
|
|
|
__ cmp_s(ULT, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dUlt)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fUlt)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(LE, f2, f4, f6);
|
|
|
|
__ cmp_s(LE, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dOle)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fOle)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(ULE, f2, f4, f6);
|
|
|
|
__ cmp_s(ULE, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dUle)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fUle)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(ORD, f2, f4, f6);
|
|
|
|
__ cmp_s(ORD, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dOr)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fOr)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(UNE, f2, f4, f6);
|
|
|
|
__ cmp_s(UNE, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dUne)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fUne)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ cmp_d(NE, f2, f4, f6);
|
|
|
|
__ cmp_s(NE, f12, f14, f16);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f2, MemOperand(a0, offsetof(TestFloat, dNe)));
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f12, MemOperand(a0, offsetof(TestFloat, fNe)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
uint64_t dTrue = 0xFFFFFFFFFFFFFFFF;
|
|
|
|
uint64_t dFalse = 0x0000000000000000;
|
|
|
|
uint32_t fTrue = 0xFFFFFFFF;
|
|
|
|
uint32_t fFalse = 0x00000000;
|
|
|
|
|
|
|
|
test.dOp1 = 2.0;
|
|
|
|
test.dOp2 = 3.0;
|
|
|
|
test.fOp1 = 2.0;
|
|
|
|
test.fOp2 = 3.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUn), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dEq), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOle), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUle), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOr), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUne), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dNe), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUn), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fEq), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOle), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUle), fTrue);
|
|
|
|
|
|
|
|
test.dOp1 = std::numeric_limits<double>::max();
|
|
|
|
test.dOp2 = std::numeric_limits<double>::min();
|
|
|
|
test.fOp1 = std::numeric_limits<float>::min();
|
2015-06-10 15:45:07 +00:00
|
|
|
test.fOp2 = -std::numeric_limits<float>::max(); // lowest()
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUn), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dEq), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOle), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUle), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOr), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUne), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dNe), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUn), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fEq), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOle), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUle), fFalse);
|
|
|
|
|
2015-06-10 15:45:07 +00:00
|
|
|
test.dOp1 = -std::numeric_limits<double>::max(); // lowest()
|
|
|
|
test.dOp2 = -std::numeric_limits<double>::max(); // lowest()
|
2015-05-22 13:49:20 +00:00
|
|
|
test.fOp1 = std::numeric_limits<float>::max();
|
|
|
|
test.fOp2 = std::numeric_limits<float>::max();
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUn), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dEq), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOle), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUle), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOr), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUne), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dNe), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUn), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fEq), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOle), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUle), fTrue);
|
|
|
|
|
|
|
|
test.dOp1 = std::numeric_limits<double>::quiet_NaN();
|
|
|
|
test.dOp2 = 0.0;
|
|
|
|
test.fOp1 = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
test.fOp2 = 0.0;
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUn), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dEq), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOle), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUle), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dOr), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dUne), dTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint64_t>(test.dNe), dFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUn), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fEq), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fTrue);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fOle), fFalse);
|
|
|
|
CHECK_EQ(bit_cast<uint32_t>(test.fUle), fTrue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(CVT) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
typedef struct test_float {
|
|
|
|
float cvt_d_s_in;
|
|
|
|
double cvt_d_s_out;
|
|
|
|
int32_t cvt_d_w_in;
|
|
|
|
double cvt_d_w_out;
|
|
|
|
int64_t cvt_d_l_in;
|
|
|
|
double cvt_d_l_out;
|
|
|
|
|
|
|
|
float cvt_l_s_in;
|
|
|
|
int64_t cvt_l_s_out;
|
|
|
|
double cvt_l_d_in;
|
|
|
|
int64_t cvt_l_d_out;
|
|
|
|
|
|
|
|
double cvt_s_d_in;
|
|
|
|
float cvt_s_d_out;
|
|
|
|
int32_t cvt_s_w_in;
|
|
|
|
float cvt_s_w_out;
|
|
|
|
int64_t cvt_s_l_in;
|
|
|
|
float cvt_s_l_out;
|
|
|
|
|
|
|
|
float cvt_w_s_in;
|
|
|
|
int32_t cvt_w_s_out;
|
|
|
|
double cvt_w_d_in;
|
|
|
|
int32_t cvt_w_d_out;
|
|
|
|
} TestFloat;
|
|
|
|
|
|
|
|
TestFloat test;
|
|
|
|
|
|
|
|
// Save FCSR.
|
|
|
|
__ cfc1(a1, FCSR);
|
|
|
|
// Disable FPU exceptions.
|
|
|
|
__ ctc1(zero_reg, FCSR);
|
|
|
|
|
|
|
|
#define GENERATE_CVT_TEST(x, y, z) \
|
2015-06-17 09:06:44 +00:00
|
|
|
__ y##c1(f0, MemOperand(a0, offsetof(TestFloat, x##_in))); \
|
2015-05-22 13:49:20 +00:00
|
|
|
__ x(f0, f0); \
|
|
|
|
__ nop(); \
|
2015-06-17 09:06:44 +00:00
|
|
|
__ z##c1(f0, MemOperand(a0, offsetof(TestFloat, x##_out)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
GENERATE_CVT_TEST(cvt_d_s, lw, Sd)
|
|
|
|
GENERATE_CVT_TEST(cvt_d_w, lw, Sd)
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2017-03-21 11:35:40 +00:00
|
|
|
GENERATE_CVT_TEST(cvt_d_l, Ld, Sd)
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsFp64Mode()) {
|
2017-03-21 11:35:40 +00:00
|
|
|
GENERATE_CVT_TEST(cvt_l_s, lw, Sd)
|
|
|
|
GENERATE_CVT_TEST(cvt_l_d, Ld, Sd)
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
GENERATE_CVT_TEST(cvt_s_d, Ld, sw)
|
2015-05-22 13:49:20 +00:00
|
|
|
GENERATE_CVT_TEST(cvt_s_w, lw, sw)
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2017-03-21 11:35:40 +00:00
|
|
|
GENERATE_CVT_TEST(cvt_s_l, Ld, sw)
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GENERATE_CVT_TEST(cvt_w_s, lw, sw)
|
2017-03-21 11:35:40 +00:00
|
|
|
GENERATE_CVT_TEST(cvt_w_d, Ld, sw)
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
// Restore FCSR.
|
|
|
|
__ ctc1(a1, FCSR);
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
test.cvt_d_s_in = -0.51;
|
|
|
|
test.cvt_d_w_in = -1;
|
|
|
|
test.cvt_d_l_in = -1;
|
|
|
|
test.cvt_l_s_in = -0.51;
|
|
|
|
test.cvt_l_d_in = -0.51;
|
|
|
|
test.cvt_s_d_in = -0.51;
|
|
|
|
test.cvt_s_w_in = -1;
|
|
|
|
test.cvt_s_l_in = -1;
|
|
|
|
test.cvt_w_s_in = -0.51;
|
|
|
|
test.cvt_w_d_in = -0.51;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
|
|
|
|
CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
|
|
|
|
}
|
|
|
|
if (IsFp64Mode()) {
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(-1, test.cvt_l_s_out);
|
|
|
|
CHECK_EQ(-1, test.cvt_l_d_out);
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
|
|
|
|
CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
|
|
|
|
}
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(-1, test.cvt_w_s_out);
|
|
|
|
CHECK_EQ(-1, test.cvt_w_d_out);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.cvt_d_s_in = 0.49;
|
|
|
|
test.cvt_d_w_in = 1;
|
|
|
|
test.cvt_d_l_in = 1;
|
|
|
|
test.cvt_l_s_in = 0.49;
|
|
|
|
test.cvt_l_d_in = 0.49;
|
|
|
|
test.cvt_s_d_in = 0.49;
|
|
|
|
test.cvt_s_w_in = 1;
|
|
|
|
test.cvt_s_l_in = 1;
|
|
|
|
test.cvt_w_s_in = 0.49;
|
|
|
|
test.cvt_w_d_in = 0.49;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
|
|
|
|
CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
|
|
|
|
}
|
|
|
|
if (IsFp64Mode()) {
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, test.cvt_l_s_out);
|
|
|
|
CHECK_EQ(0, test.cvt_l_d_out);
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
|
|
|
|
CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
|
|
|
|
}
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, test.cvt_w_s_out);
|
|
|
|
CHECK_EQ(0, test.cvt_w_d_out);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.cvt_d_s_in = std::numeric_limits<float>::max();
|
|
|
|
test.cvt_d_w_in = std::numeric_limits<int32_t>::max();
|
|
|
|
test.cvt_d_l_in = std::numeric_limits<int64_t>::max();
|
|
|
|
test.cvt_l_s_in = std::numeric_limits<float>::max();
|
|
|
|
test.cvt_l_d_in = std::numeric_limits<double>::max();
|
|
|
|
test.cvt_s_d_in = std::numeric_limits<double>::max();
|
|
|
|
test.cvt_s_w_in = std::numeric_limits<int32_t>::max();
|
|
|
|
test.cvt_s_l_in = std::numeric_limits<int64_t>::max();
|
|
|
|
test.cvt_w_s_in = std::numeric_limits<float>::max();
|
|
|
|
test.cvt_w_d_in = std::numeric_limits<double>::max();
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
|
|
|
|
CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
|
|
|
|
}
|
|
|
|
if (IsFp64Mode()) {
|
|
|
|
CHECK_EQ(test.cvt_l_s_out, std::numeric_limits<int64_t>::max());
|
|
|
|
CHECK_EQ(test.cvt_l_d_out, std::numeric_limits<int64_t>::max());
|
|
|
|
}
|
|
|
|
CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
|
|
|
|
CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
|
|
|
|
}
|
|
|
|
CHECK_EQ(test.cvt_w_s_out, std::numeric_limits<int32_t>::max());
|
|
|
|
CHECK_EQ(test.cvt_w_d_out, std::numeric_limits<int32_t>::max());
|
|
|
|
|
|
|
|
|
2015-06-10 15:45:07 +00:00
|
|
|
test.cvt_d_s_in = -std::numeric_limits<float>::max(); // lowest()
|
|
|
|
test.cvt_d_w_in = std::numeric_limits<int32_t>::min(); // lowest()
|
|
|
|
test.cvt_d_l_in = std::numeric_limits<int64_t>::min(); // lowest()
|
|
|
|
test.cvt_l_s_in = -std::numeric_limits<float>::max(); // lowest()
|
|
|
|
test.cvt_l_d_in = -std::numeric_limits<double>::max(); // lowest()
|
|
|
|
test.cvt_s_d_in = -std::numeric_limits<double>::max(); // lowest()
|
|
|
|
test.cvt_s_w_in = std::numeric_limits<int32_t>::min(); // lowest()
|
|
|
|
test.cvt_s_l_in = std::numeric_limits<int64_t>::min(); // lowest()
|
|
|
|
test.cvt_w_s_in = -std::numeric_limits<float>::max(); // lowest()
|
|
|
|
test.cvt_w_d_in = -std::numeric_limits<double>::max(); // lowest()
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
|
|
|
|
CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
|
|
|
|
}
|
|
|
|
// The returned value when converting from fixed-point to float-point
|
|
|
|
// is not consistent between board, simulator and specification
|
|
|
|
// in this test case, therefore modifying the test
|
|
|
|
if (IsFp64Mode()) {
|
|
|
|
CHECK(test.cvt_l_s_out == std::numeric_limits<int64_t>::min() ||
|
|
|
|
test.cvt_l_s_out == std::numeric_limits<int64_t>::max());
|
|
|
|
CHECK(test.cvt_l_d_out == std::numeric_limits<int64_t>::min() ||
|
|
|
|
test.cvt_l_d_out == std::numeric_limits<int64_t>::max());
|
|
|
|
}
|
|
|
|
CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
|
|
|
|
CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
|
|
|
|
}
|
|
|
|
CHECK(test.cvt_w_s_out == std::numeric_limits<int32_t>::min() ||
|
|
|
|
test.cvt_w_s_out == std::numeric_limits<int32_t>::max());
|
|
|
|
CHECK(test.cvt_w_d_out == std::numeric_limits<int32_t>::min() ||
|
|
|
|
test.cvt_w_d_out == std::numeric_limits<int32_t>::max());
|
|
|
|
|
|
|
|
|
|
|
|
test.cvt_d_s_in = std::numeric_limits<float>::min();
|
|
|
|
test.cvt_d_w_in = std::numeric_limits<int32_t>::min();
|
|
|
|
test.cvt_d_l_in = std::numeric_limits<int64_t>::min();
|
|
|
|
test.cvt_l_s_in = std::numeric_limits<float>::min();
|
|
|
|
test.cvt_l_d_in = std::numeric_limits<double>::min();
|
|
|
|
test.cvt_s_d_in = std::numeric_limits<double>::min();
|
|
|
|
test.cvt_s_w_in = std::numeric_limits<int32_t>::min();
|
|
|
|
test.cvt_s_l_in = std::numeric_limits<int64_t>::min();
|
|
|
|
test.cvt_w_s_in = std::numeric_limits<float>::min();
|
|
|
|
test.cvt_w_d_in = std::numeric_limits<double>::min();
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
|
|
|
|
CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
|
|
|
|
}
|
|
|
|
if (IsFp64Mode()) {
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, test.cvt_l_s_out);
|
|
|
|
CHECK_EQ(0, test.cvt_l_d_out);
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
|
|
|
|
CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
|
2015-11-19 16:39:10 +00:00
|
|
|
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
|
|
|
|
IsFp64Mode()) {
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
|
|
|
|
}
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, test.cvt_w_s_out);
|
|
|
|
CHECK_EQ(0, test.cvt_w_d_out);
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(DIV_FMT) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
typedef struct test {
|
|
|
|
double dOp1;
|
|
|
|
double dOp2;
|
|
|
|
double dRes;
|
|
|
|
float fOp1;
|
|
|
|
float fOp2;
|
|
|
|
float fRes;
|
|
|
|
} Test;
|
|
|
|
|
|
|
|
Test test;
|
|
|
|
|
|
|
|
// Save FCSR.
|
|
|
|
__ cfc1(a1, FCSR);
|
|
|
|
// Disable FPU exceptions.
|
|
|
|
__ ctc1(zero_reg, FCSR);
|
|
|
|
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(Test, dOp1)));
|
|
|
|
__ Ldc1(f2, MemOperand(a0, offsetof(Test, dOp2)));
|
2015-05-22 13:49:20 +00:00
|
|
|
__ nop();
|
|
|
|
__ div_d(f6, f4, f2);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f6, MemOperand(a0, offsetof(Test, dRes)));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
2015-06-17 09:06:44 +00:00
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(Test, fOp1)) );
|
|
|
|
__ lwc1(f2, MemOperand(a0, offsetof(Test, fOp2)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
__ nop();
|
|
|
|
__ div_s(f6, f4, f2);
|
2015-06-17 09:06:44 +00:00
|
|
|
__ swc1(f6, MemOperand(a0, offsetof(Test, fRes)) );
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
// Restore FCSR.
|
|
|
|
__ ctc1(a1, FCSR);
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
2015-05-22 13:49:20 +00:00
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-05-22 13:49:20 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
2015-05-22 13:49:20 +00:00
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
const int test_size = 3;
|
|
|
|
|
|
|
|
double dOp1[test_size] = {
|
|
|
|
5.0,
|
|
|
|
DBL_MAX,
|
|
|
|
DBL_MAX,
|
|
|
|
};
|
|
|
|
double dOp2[test_size] = {
|
|
|
|
2.0,
|
|
|
|
2.0,
|
|
|
|
-DBL_MAX,
|
|
|
|
};
|
|
|
|
double dRes[test_size] = {
|
|
|
|
2.5,
|
|
|
|
DBL_MAX / 2.0,
|
|
|
|
-1.0,
|
|
|
|
};
|
|
|
|
float fOp1[test_size] = {
|
|
|
|
5.0,
|
|
|
|
FLT_MAX,
|
|
|
|
FLT_MAX,
|
|
|
|
};
|
|
|
|
float fOp2[test_size] = {
|
|
|
|
2.0,
|
|
|
|
2.0,
|
|
|
|
-FLT_MAX,
|
|
|
|
};
|
|
|
|
float fRes[test_size] = {
|
|
|
|
2.5,
|
|
|
|
FLT_MAX / 2.0,
|
|
|
|
-1.0,
|
|
|
|
};
|
|
|
|
|
|
|
|
for (int i = 0; i < test_size; i++) {
|
|
|
|
test.dOp1 = dOp1[i];
|
|
|
|
test.dOp2 = dOp2[i];
|
|
|
|
test.fOp1 = fOp1[i];
|
|
|
|
test.fOp2 = fOp2[i];
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2015-05-22 13:49:20 +00:00
|
|
|
CHECK_EQ(test.dRes, dRes[i]);
|
|
|
|
CHECK_EQ(test.fRes, fRes[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
test.dOp1 = DBL_MAX;
|
|
|
|
test.dOp2 = -0.0;
|
|
|
|
test.fOp1 = FLT_MAX;
|
|
|
|
test.fOp2 = -0.0;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK(!std::isfinite(test.dRes));
|
|
|
|
CHECK(!std::isfinite(test.fRes));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.dOp1 = 0.0;
|
|
|
|
test.dOp2 = -0.0;
|
|
|
|
test.fOp1 = 0.0;
|
|
|
|
test.fOp2 = -0.0;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK(std::isnan(test.dRes));
|
|
|
|
CHECK(std::isnan(test.fRes));
|
2015-05-22 13:49:20 +00:00
|
|
|
|
|
|
|
test.dOp1 = std::numeric_limits<double>::quiet_NaN();
|
|
|
|
test.dOp2 = -5.0;
|
|
|
|
test.fOp1 = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
test.fOp2 = -5.0;
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
(CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK(std::isnan(test.dRes));
|
|
|
|
CHECK(std::isnan(test.fRes));
|
2015-05-22 13:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
uint32_t run_align(uint32_t rs_value, uint32_t rt_value, uint8_t bp) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
__ align(v0, a0, a1, bp);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(CALL_GENERATED_CODE(
|
|
|
|
isolate, f, rs_value, rt_value, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_align) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseAlign {
|
|
|
|
uint32_t rs_value;
|
|
|
|
uint32_t rt_value;
|
|
|
|
uint8_t bp;
|
|
|
|
uint32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseAlign tc[] = {
|
|
|
|
// rs_value, rt_value, bp, expected_res
|
|
|
|
{ 0x11223344, 0xaabbccdd, 0, 0xaabbccdd },
|
|
|
|
{ 0x11223344, 0xaabbccdd, 1, 0xbbccdd11 },
|
|
|
|
{ 0x11223344, 0xaabbccdd, 2, 0xccdd1122 },
|
|
|
|
{ 0x11223344, 0xaabbccdd, 3, 0xdd112233 },
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseAlign);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
CHECK_EQ(tc[i].expected_res, run_align(tc[i].rs_value,
|
|
|
|
tc[i].rt_value, tc[i].bp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t PC; // The program counter.
|
|
|
|
|
|
|
|
uint32_t run_aluipc(int16_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
__ aluipc(v0, offset);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
PC = (uint32_t) f; // Set the program counter.
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_aluipc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseAluipc {
|
|
|
|
int16_t offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseAluipc tc[] = {
|
|
|
|
// offset
|
|
|
|
{ -32768 }, // 0x8000
|
|
|
|
{ -1 }, // 0xFFFF
|
|
|
|
{ 0 },
|
|
|
|
{ 1 },
|
|
|
|
{ 32767 }, // 0x7FFF
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseAluipc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
PC = 0;
|
|
|
|
uint32_t res = run_aluipc(tc[i].offset);
|
|
|
|
// Now, the program_counter (PC) is set.
|
|
|
|
uint32_t expected_res = ~0x0FFFF & (PC + (tc[i].offset << 16));
|
|
|
|
CHECK_EQ(expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t run_auipc(int16_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
__ auipc(v0, offset);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
PC = (uint32_t) f; // Set the program counter.
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_auipc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseAuipc {
|
|
|
|
int16_t offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseAuipc tc[] = {
|
|
|
|
// offset
|
|
|
|
{ -32768 }, // 0x8000
|
|
|
|
{ -1 }, // 0xFFFF
|
|
|
|
{ 0 },
|
|
|
|
{ 1 },
|
|
|
|
{ 32767 }, // 0x7FFF
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseAuipc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
PC = 0;
|
|
|
|
uint32_t res = run_auipc(tc[i].offset);
|
|
|
|
// Now, the program_counter (PC) is set.
|
|
|
|
uint32_t expected_res = PC + (tc[i].offset << 16);
|
|
|
|
CHECK_EQ(expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t run_lwpc(int offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
// 256k instructions; 2^8k
|
|
|
|
// addiu t7, t0, 0xffff; (0x250fffff)
|
|
|
|
// ...
|
|
|
|
// addiu t4, t0, 0x0000; (0x250c0000)
|
|
|
|
uint32_t addiu_start_1 = 0x25000000;
|
|
|
|
for (int32_t i = 0xfffff; i >= 0xc0000; --i) {
|
|
|
|
uint32_t addiu_new = addiu_start_1 + i;
|
|
|
|
__ dd(addiu_new);
|
|
|
|
}
|
|
|
|
|
|
|
|
__ lwpc(t8, offset); // offset 0; 0xef080000 (t8 register)
|
|
|
|
__ mov(v0, t8);
|
|
|
|
|
|
|
|
// 256k instructions; 2^8k
|
|
|
|
// addiu t0, t0, 0x0000; (0x25080000)
|
|
|
|
// ...
|
|
|
|
// addiu t3, t0, 0xffff; (0x250bffff)
|
|
|
|
uint32_t addiu_start_2 = 0x25000000;
|
|
|
|
for (int32_t i = 0x80000; i <= 0xbffff; ++i) {
|
|
|
|
uint32_t addiu_new = addiu_start_2 + i;
|
|
|
|
__ dd(addiu_new);
|
|
|
|
}
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_lwpc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseLwpc {
|
|
|
|
int offset;
|
|
|
|
uint32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseLwpc tc[] = {
|
|
|
|
// offset, expected_res
|
|
|
|
{ -262144, 0x250fffff }, // offset 0x40000
|
|
|
|
{ -4, 0x250c0003 },
|
|
|
|
{ -1, 0x250c0000 },
|
|
|
|
{ 0, 0xef080000 },
|
|
|
|
{ 1, 0x03001025 }, // mov(v0, t8)
|
|
|
|
{ 2, 0x25080000 },
|
|
|
|
{ 4, 0x25080002 },
|
|
|
|
{ 262143, 0x250bfffd }, // offset 0x3ffff
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLwpc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
uint32_t res = run_lwpc(tc[i].offset);
|
|
|
|
CHECK_EQ(tc[i].expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t run_jic(int16_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
Label get_program_counter, stop_execution;
|
|
|
|
__ push(ra);
|
|
|
|
__ li(v0, 0);
|
|
|
|
__ li(t1, 0x66);
|
|
|
|
|
|
|
|
__ addiu(v0, v0, 0x1); // <-- offset = -32
|
|
|
|
__ addiu(v0, v0, 0x2);
|
|
|
|
__ addiu(v0, v0, 0x10);
|
|
|
|
__ addiu(v0, v0, 0x20);
|
|
|
|
__ beq(v0, t1, &stop_execution);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ bal(&get_program_counter); // t0 <- program counter
|
|
|
|
__ nop();
|
|
|
|
__ jic(t0, offset);
|
|
|
|
|
|
|
|
__ addiu(v0, v0, 0x100);
|
|
|
|
__ addiu(v0, v0, 0x200);
|
|
|
|
__ addiu(v0, v0, 0x1000);
|
|
|
|
__ addiu(v0, v0, 0x2000); // <--- offset = 16
|
|
|
|
__ pop(ra);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ bind(&get_program_counter);
|
|
|
|
__ mov(t0, ra);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ bind(&stop_execution);
|
|
|
|
__ pop(ra);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_jic) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseJic {
|
|
|
|
// As rt will be used t0 register which will have value of
|
|
|
|
// the program counter for the jic instruction.
|
|
|
|
int16_t offset;
|
|
|
|
uint32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseJic tc[] = {
|
|
|
|
// offset, expected_result
|
|
|
|
{ 16, 0x2033 },
|
|
|
|
{ 4, 0x3333 },
|
|
|
|
{ -32, 0x66 },
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseJic);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
uint32_t res = run_jic(tc[i].offset);
|
|
|
|
CHECK_EQ(tc[i].expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t run_beqzc(int32_t value, int32_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
Label stop_execution;
|
|
|
|
__ li(v0, 0);
|
|
|
|
__ li(t1, 0x66);
|
|
|
|
|
|
|
|
__ addiu(v0, v0, 0x1); // <-- offset = -32
|
|
|
|
__ addiu(v0, v0, 0x2);
|
|
|
|
__ addiu(v0, v0, 0x10);
|
|
|
|
__ addiu(v0, v0, 0x20);
|
|
|
|
__ beq(v0, t1, &stop_execution);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ beqzc(a0, offset); // BEQZC rs, offset
|
|
|
|
|
|
|
|
__ addiu(v0, v0, 0x1);
|
|
|
|
__ addiu(v0, v0, 0x100);
|
|
|
|
__ addiu(v0, v0, 0x200);
|
|
|
|
__ addiu(v0, v0, 0x1000);
|
|
|
|
__ addiu(v0, v0, 0x2000); // <--- offset = 16
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ bind(&stop_execution);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, value, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_beqzc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseBeqzc {
|
|
|
|
uint32_t value;
|
|
|
|
int32_t offset;
|
|
|
|
uint32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseBeqzc tc[] = {
|
|
|
|
// value, offset, expected_res
|
|
|
|
{ 0x0, -8, 0x66 },
|
|
|
|
{ 0x0, 0, 0x3334 },
|
|
|
|
{ 0x0, 1, 0x3333 },
|
|
|
|
{ 0xabc, 1, 0x3334 },
|
|
|
|
{ 0x0, 4, 0x2033 },
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBeqzc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
uint32_t res = run_beqzc(tc[i].value, tc[i].offset);
|
|
|
|
CHECK_EQ(tc[i].expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t run_jialc(int16_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
Label main_block, get_program_counter;
|
|
|
|
__ push(ra);
|
|
|
|
__ li(v0, 0);
|
|
|
|
__ beq(v0, v0, &main_block);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
// Block 1
|
|
|
|
__ addiu(v0, v0, 0x1); // <-- offset = -40
|
|
|
|
__ addiu(v0, v0, 0x2);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
// Block 2
|
|
|
|
__ addiu(v0, v0, 0x10); // <-- offset = -24
|
|
|
|
__ addiu(v0, v0, 0x20);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
// Block 3 (Main)
|
|
|
|
__ bind(&main_block);
|
|
|
|
__ bal(&get_program_counter); // t0 <- program counter
|
|
|
|
__ nop();
|
|
|
|
__ jialc(t0, offset);
|
|
|
|
__ addiu(v0, v0, 0x4);
|
|
|
|
__ pop(ra);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
// Block 4
|
|
|
|
__ addiu(v0, v0, 0x100); // <-- offset = 20
|
|
|
|
__ addiu(v0, v0, 0x200);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
// Block 5
|
|
|
|
__ addiu(v0, v0, 0x1000); // <--- offset = 36
|
|
|
|
__ addiu(v0, v0, 0x2000);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ bind(&get_program_counter);
|
|
|
|
__ mov(t0, ra);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_jialc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseJialc {
|
|
|
|
int16_t offset;
|
|
|
|
uint32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseJialc tc[] = {
|
|
|
|
// offset, expected_res
|
|
|
|
{ -40, 0x7 },
|
|
|
|
{ -24, 0x34 },
|
|
|
|
{ 20, 0x304 },
|
|
|
|
{ 36, 0x3004 }
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseJialc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
uint32_t res = run_jialc(tc[i].offset);
|
|
|
|
CHECK_EQ(tc[i].expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-03 13:30:57 +00:00
|
|
|
static uint32_t run_addiupc(int32_t imm19) {
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
__ addiupc(v0, imm19);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
PC = (uint32_t) f; // Set the program counter.
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t rs = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, imm19, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return rs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_addiupc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseAddiupc {
|
|
|
|
int32_t imm19;
|
|
|
|
};
|
|
|
|
|
2016-02-03 13:30:57 +00:00
|
|
|
TestCaseAddiupc tc[] = {
|
|
|
|
// imm19
|
|
|
|
{-262144}, // 0x40000
|
|
|
|
{-1}, // 0x7FFFF
|
|
|
|
{0},
|
|
|
|
{1}, // 0x00001
|
|
|
|
{262143} // 0x3FFFF
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseAddiupc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
PC = 0;
|
|
|
|
uint32_t res = run_addiupc(tc[i].imm19);
|
|
|
|
// Now, the program_counter (PC) is set.
|
|
|
|
uint32_t expected_res = PC + (tc[i].imm19 << 2);
|
|
|
|
CHECK_EQ(expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t run_bc(int32_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
Label continue_1, stop_execution;
|
|
|
|
__ push(ra);
|
|
|
|
__ li(v0, 0);
|
|
|
|
__ li(t8, 0);
|
|
|
|
__ li(t9, 2); // A condition for stopping execution.
|
|
|
|
|
|
|
|
for (int32_t i = -100; i <= -11; ++i) {
|
2016-01-12 19:48:51 +00:00
|
|
|
__ addiu(v0, v0, 1);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__ addiu(t8, t8, 1); // -10
|
|
|
|
|
|
|
|
__ beq(t8, t9, &stop_execution); // -9
|
|
|
|
__ nop(); // -8
|
|
|
|
__ beq(t8, t8, &continue_1); // -7
|
|
|
|
__ nop(); // -6
|
|
|
|
|
|
|
|
__ bind(&stop_execution);
|
|
|
|
__ pop(ra); // -5, -4
|
|
|
|
__ jr(ra); // -3
|
|
|
|
__ nop(); // -2
|
|
|
|
|
|
|
|
__ bind(&continue_1);
|
|
|
|
__ bc(offset); // -1
|
|
|
|
|
|
|
|
for (int32_t i = 0; i <= 99; ++i) {
|
2016-01-12 19:48:51 +00:00
|
|
|
__ addiu(v0, v0, 1);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__ pop(ra);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
int32_t res = reinterpret_cast<int32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_bc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseBc {
|
|
|
|
int32_t offset;
|
|
|
|
int32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseBc tc[] = {
|
|
|
|
// offset, expected_result
|
|
|
|
{ -100, (abs(-100) - 10) * 2 },
|
|
|
|
{ -11, (abs(-100) - 10 + 1) },
|
|
|
|
{ 0, (abs(-100) - 10 + 1 + 99) },
|
|
|
|
{ 1, (abs(-100) - 10 + 99) },
|
|
|
|
{ 99, (abs(-100) - 10 + 1) },
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
int32_t res = run_bc(tc[i].offset);
|
|
|
|
CHECK_EQ(tc[i].expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t run_balc(int32_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
Label continue_1, stop_execution;
|
|
|
|
__ push(ra);
|
|
|
|
__ li(v0, 0);
|
|
|
|
__ li(t8, 0);
|
|
|
|
__ li(t9, 2); // A condition for stopping execution.
|
|
|
|
|
|
|
|
__ beq(t8, t8, &continue_1);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
uint32_t instruction_addiu = 0x24420001; // addiu v0, v0, 1
|
|
|
|
for (int32_t i = -117; i <= -57; ++i) {
|
|
|
|
__ dd(instruction_addiu);
|
|
|
|
}
|
|
|
|
__ jr(ra); // -56
|
|
|
|
__ nop(); // -55
|
|
|
|
|
|
|
|
for (int32_t i = -54; i <= -4; ++i) {
|
|
|
|
__ dd(instruction_addiu);
|
|
|
|
}
|
|
|
|
__ jr(ra); // -3
|
|
|
|
__ nop(); // -2
|
|
|
|
|
|
|
|
__ bind(&continue_1);
|
|
|
|
__ balc(offset); // -1
|
|
|
|
|
|
|
|
__ pop(ra); // 0, 1
|
|
|
|
__ jr(ra); // 2
|
|
|
|
__ nop(); // 3
|
|
|
|
|
|
|
|
for (int32_t i = 4; i <= 44; ++i) {
|
|
|
|
__ dd(instruction_addiu);
|
|
|
|
}
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
int32_t res = reinterpret_cast<int32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-30 20:30:04 +00:00
|
|
|
uint32_t run_aui(uint32_t rs, uint16_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
|
|
|
|
__ li(t0, rs);
|
|
|
|
__ aui(v0, t0, offset);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-11-30 20:30:04 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
|
|
|
uint32_t res =
|
|
|
|
reinterpret_cast<uint32_t>
|
|
|
|
(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(r6_aui) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseAui {
|
|
|
|
uint32_t rs;
|
|
|
|
uint16_t offset;
|
|
|
|
uint32_t ref_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseAui tc[] = {
|
|
|
|
// input, offset, result
|
|
|
|
{0xfffeffff, 1, 0xffffffff},
|
|
|
|
{0xffffffff, 0, 0xffffffff},
|
|
|
|
{0, 0xffff, 0xffff0000},
|
|
|
|
{0x0008ffff, 0xfff7, 0xffffffff},
|
|
|
|
{32767, 32767, 0x7fff7fff},
|
|
|
|
// overflow cases
|
|
|
|
{0xffffffff, 0x1, 0x0000ffff},
|
|
|
|
{0xffffffff, 0xffff, 0xfffeffff},
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseAui);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
PC = 0;
|
|
|
|
uint32_t res = run_aui(tc[i].rs, tc[i].offset);
|
|
|
|
CHECK_EQ(tc[i].ref_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
MIPS: Implemented PC-relative instructions for R6.
Added: JIC, BEQZC, JIALC, LDPC, LWPC, ALUIPC, ADDIUPC, ALIGN/DAILGN, LWUPC,
AUIPC, BC, BALC. Additional fixed compact branch offset.
TEST=test-assembler-mips[64]/r6_align, r6_dalign, r6_aluipc, r6_lwpc, r6_jic,
r6_beqzc, r6_jialc, r6_addiupc, r6_ldpc, r6_lwupc,
r6_auipc, r6_bc, r6_balc
BUG=
Review URL: https://codereview.chromium.org/1195793002
Cr-Commit-Position: refs/heads/master@{#29143}
2015-06-19 11:05:59 +00:00
|
|
|
TEST(r6_balc) {
|
|
|
|
if (IsMipsArchVariant(kMips32r6)) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseBalc {
|
|
|
|
int32_t offset;
|
|
|
|
int32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseBalc tc[] = {
|
|
|
|
// offset, expected_result
|
|
|
|
{ -117, 61 },
|
|
|
|
{ -54, 51 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 4, 41 },
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBalc);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
int32_t res = run_balc(tc[i].offset);
|
|
|
|
CHECK_EQ(tc[i].expected_res, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-23 07:29:57 +00:00
|
|
|
uint32_t run_bal(int16_t offset) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
2015-07-23 07:29:57 +00:00
|
|
|
|
|
|
|
__ mov(t0, ra);
|
|
|
|
__ bal(offset); // Equivalent for "BGEZAL zero_reg, offset".
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ mov(ra, t0);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ li(v0, 1);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-07-23 07:29:57 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
2015-07-23 07:29:57 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(bal) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseBal {
|
|
|
|
int16_t offset;
|
|
|
|
uint32_t expected_res;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseBal tc[] = {
|
|
|
|
// offset, expected_res
|
|
|
|
{ 4, 1 },
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBal);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
CHECK_EQ(tc[i].expected_res, run_bal(tc[i].offset));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-18 17:43:03 +00:00
|
|
|
TEST(Trampoline) {
|
|
|
|
// Private member of Assembler class.
|
|
|
|
static const int kMaxBranchOffset = (1 << (18 - 1)) - 1;
|
|
|
|
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
MacroAssembler assm(isolate, nullptr, 0,
|
|
|
|
v8::internal::CodeObjectRequired::kYes);
|
2015-11-18 17:43:03 +00:00
|
|
|
Label done;
|
|
|
|
size_t nr_calls = kMaxBranchOffset / (2 * Instruction::kInstrSize) + 2;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < nr_calls; ++i) {
|
|
|
|
__ BranchShort(&done, eq, a0, Operand(a1));
|
|
|
|
}
|
|
|
|
__ bind(&done);
|
|
|
|
__ Ret(USE_DELAY_SLOT);
|
|
|
|
__ mov(v0, zero_reg);
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2015-11-18 17:43:03 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
2015-11-23 08:09:34 +00:00
|
|
|
int32_t res = reinterpret_cast<int32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, res);
|
2015-11-18 17:43:03 +00:00
|
|
|
}
|
|
|
|
|
2016-09-14 11:36:29 +00:00
|
|
|
template <class T>
|
|
|
|
struct TestCaseMaddMsub {
|
|
|
|
T fr, fs, ft, fd_add, fd_sub;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename F>
|
|
|
|
void helper_madd_msub_maddf_msubf(F func) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
|
|
|
|
T x = std::sqrt(static_cast<T>(2.0));
|
|
|
|
T y = std::sqrt(static_cast<T>(3.0));
|
|
|
|
T z = std::sqrt(static_cast<T>(5.0));
|
|
|
|
T x2 = 11.11, y2 = 22.22, z2 = 33.33;
|
|
|
|
TestCaseMaddMsub<T> test_cases[] = {
|
|
|
|
{x, y, z, 0.0, 0.0},
|
|
|
|
{x, y, -z, 0.0, 0.0},
|
|
|
|
{x, -y, z, 0.0, 0.0},
|
|
|
|
{x, -y, -z, 0.0, 0.0},
|
|
|
|
{-x, y, z, 0.0, 0.0},
|
|
|
|
{-x, y, -z, 0.0, 0.0},
|
|
|
|
{-x, -y, z, 0.0, 0.0},
|
|
|
|
{-x, -y, -z, 0.0, 0.0},
|
|
|
|
{-3.14, 0.2345, -123.000056, 0.0, 0.0},
|
|
|
|
{7.3, -23.257, -357.1357, 0.0, 0.0},
|
|
|
|
{x2, y2, z2, 0.0, 0.0},
|
|
|
|
{x2, y2, -z2, 0.0, 0.0},
|
|
|
|
{x2, -y2, z2, 0.0, 0.0},
|
|
|
|
{x2, -y2, -z2, 0.0, 0.0},
|
|
|
|
{-x2, y2, z2, 0.0, 0.0},
|
|
|
|
{-x2, y2, -z2, 0.0, 0.0},
|
|
|
|
{-x2, -y2, z2, 0.0, 0.0},
|
|
|
|
{-x2, -y2, -z2, 0.0, 0.0},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (std::is_same<T, float>::value) {
|
|
|
|
__ lwc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
|
|
|
|
__ lwc1(f6, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fs)));
|
|
|
|
__ lwc1(f8, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, ft)));
|
|
|
|
__ lwc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
|
|
|
|
} else if (std::is_same<T, double>::value) {
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Ldc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
|
|
|
|
__ Ldc1(f6, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fs)));
|
|
|
|
__ Ldc1(f8, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, ft)));
|
|
|
|
__ Ldc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
|
2016-09-14 11:36:29 +00:00
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
func(assm);
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2016-09-14 11:36:29 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
const size_t kTableLength = sizeof(test_cases) / sizeof(TestCaseMaddMsub<T>);
|
|
|
|
TestCaseMaddMsub<T> tc;
|
|
|
|
for (size_t i = 0; i < kTableLength; i++) {
|
|
|
|
tc.fr = test_cases[i].fr;
|
|
|
|
tc.fs = test_cases[i].fs;
|
|
|
|
tc.ft = test_cases[i].ft;
|
|
|
|
|
|
|
|
(CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0));
|
|
|
|
|
2016-12-02 09:11:47 +00:00
|
|
|
T res_add = 0;
|
2016-09-23 13:23:35 +00:00
|
|
|
T res_sub = 0;
|
2016-09-14 11:36:29 +00:00
|
|
|
if (IsMipsArchVariant(kMips32r2)) {
|
2016-12-02 09:11:47 +00:00
|
|
|
res_add = (tc.fs * tc.ft) + tc.fr;
|
2016-09-14 11:36:29 +00:00
|
|
|
res_sub = (tc.fs * tc.ft) - tc.fr;
|
|
|
|
} else if (IsMipsArchVariant(kMips32r6)) {
|
2016-12-02 09:11:47 +00:00
|
|
|
res_add = std::fma(tc.fs, tc.ft, tc.fr);
|
|
|
|
res_sub = std::fma(-tc.fs, tc.ft, tc.fr);
|
2016-09-23 13:23:35 +00:00
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
2016-09-14 11:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_EQ(tc.fd_add, res_add);
|
|
|
|
CHECK_EQ(tc.fd_sub, res_sub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(madd_msub_s) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r2)) return;
|
|
|
|
helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
|
|
|
|
__ madd_s(f10, f4, f6, f8);
|
|
|
|
__ swc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
|
|
|
|
__ msub_s(f16, f4, f6, f8);
|
|
|
|
__ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(madd_msub_d) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r2)) return;
|
|
|
|
helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
|
|
|
|
__ madd_d(f10, f4, f6, f8);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
|
2016-09-14 11:36:29 +00:00
|
|
|
__ msub_d(f16, f4, f6, f8);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
|
2016-09-14 11:36:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(maddf_msubf_s) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r6)) return;
|
|
|
|
helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
|
|
|
|
__ maddf_s(f4, f6, f8);
|
|
|
|
__ swc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
|
|
|
|
__ msubf_s(f16, f6, f8);
|
|
|
|
__ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(maddf_msubf_d) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r6)) return;
|
|
|
|
helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
|
|
|
|
__ maddf_d(f4, f6, f8);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
|
2016-09-14 11:36:29 +00:00
|
|
|
__ msubf_d(f16, f6, f8);
|
2017-03-21 11:35:40 +00:00
|
|
|
__ Sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
|
2016-09-14 11:36:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-04-27 12:56:50 +00:00
|
|
|
uint32_t run_Subu(uint32_t imm, int32_t num_instr) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
|
|
|
|
Label code_start;
|
|
|
|
__ bind(&code_start);
|
|
|
|
__ Subu(v0, zero_reg, imm);
|
|
|
|
CHECK_EQ(assm.SizeOfCodeGeneratedSince(&code_start),
|
|
|
|
num_instr * Assembler::kInstrSize);
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2017-04-27 12:56:50 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
F2 f = FUNCTION_CAST<F2>(code->entry());
|
|
|
|
|
|
|
|
uint32_t res = reinterpret_cast<uint32_t>(
|
|
|
|
CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Subu) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
// Test Subu macro-instruction for min_int16 and max_int16 border cases.
|
|
|
|
// For subtracting int16 immediate values we use addiu.
|
|
|
|
|
|
|
|
struct TestCaseSubu {
|
|
|
|
uint32_t imm;
|
|
|
|
uint32_t expected_res;
|
|
|
|
int32_t num_instr;
|
|
|
|
};
|
|
|
|
|
|
|
|
// We call Subu(v0, zero_reg, imm) to test cases listed below.
|
|
|
|
// 0 - imm = expected_res
|
|
|
|
struct TestCaseSubu tc[] = {
|
|
|
|
// imm, expected_res, num_instr
|
2017-05-23 16:01:41 +00:00
|
|
|
{0xffff8000, 0x8000, 2}, // min_int16
|
2017-04-27 12:56:50 +00:00
|
|
|
// Generates ori + addu
|
|
|
|
// We can't have just addiu because -min_int16 > max_int16 so use
|
|
|
|
// register. We can load min_int16 to at register with addiu and then
|
|
|
|
// subtract at with subu, but now we use ori + addu because -min_int16 can
|
|
|
|
// be loaded using ori.
|
|
|
|
{0x8000, 0xffff8000, 1}, // max_int16 + 1
|
|
|
|
// Generates addiu
|
|
|
|
// max_int16 + 1 is not int16 but -(max_int16 + 1) is, just use addiu.
|
|
|
|
{0xffff7fff, 0x8001, 2}, // min_int16 - 1
|
|
|
|
// Generates ori + addu
|
|
|
|
// To load this value to at we need two instructions and another one to
|
|
|
|
// subtract, lui + ori + subu. But we can load -value to at using just
|
|
|
|
// ori and then add at register with addu.
|
|
|
|
{0x8001, 0xffff7fff, 2}, // max_int16 + 2
|
|
|
|
// Generates ori + subu
|
|
|
|
// Not int16 but is uint16, load value to at with ori and subtract with
|
|
|
|
// subu.
|
|
|
|
{0x00010000, 0xffff0000, 2},
|
|
|
|
// Generates lui + subu
|
|
|
|
// Load value using lui to at and subtract with subu.
|
|
|
|
{0x00010001, 0xfffeffff, 3},
|
|
|
|
// Generates lui + ori + subu
|
|
|
|
// We have to generate three instructions in this case.
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseSubu);
|
|
|
|
for (size_t i = 0; i < nr_test_cases; ++i) {
|
|
|
|
CHECK_EQ(tc[i].expected_res, run_Subu(tc[i].imm, tc[i].num_instr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:51:07 +00:00
|
|
|
TEST(MSA_fill_copy) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t u8;
|
|
|
|
uint32_t u16;
|
|
|
|
uint32_t u32;
|
|
|
|
uint32_t s8;
|
|
|
|
uint32_t s16;
|
|
|
|
uint32_t s32;
|
|
|
|
} T;
|
|
|
|
T t;
|
|
|
|
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD))
|
|
|
|
return;
|
|
|
|
|
|
|
|
{
|
|
|
|
CpuFeatureScope fscope(&assm, MIPS_SIMD);
|
|
|
|
|
|
|
|
__ li(t0, 0xa512b683);
|
|
|
|
|
|
|
|
__ fill_b(w0, t0);
|
|
|
|
__ fill_h(w2, t0);
|
|
|
|
__ fill_w(w4, t0);
|
|
|
|
__ copy_u_b(t1, w0, 11);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, u8)));
|
|
|
|
__ copy_u_h(t1, w2, 6);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, u16)));
|
|
|
|
__ copy_u_w(t1, w4, 3);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, u32)));
|
|
|
|
|
|
|
|
__ copy_s_b(t1, w0, 8);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, s8)));
|
|
|
|
__ copy_s_h(t1, w2, 5);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, s16)));
|
|
|
|
__ copy_s_w(t1, w4, 1);
|
|
|
|
__ sw(t1, MemOperand(a0, offsetof(T, s32)));
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2017-05-25 14:51:07 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
|
|
|
USE(dummy);
|
|
|
|
|
|
|
|
CHECK_EQ(0x83u, t.u8);
|
|
|
|
CHECK_EQ(0xb683u, t.u16);
|
|
|
|
CHECK_EQ(0xa512b683u, t.u32);
|
|
|
|
CHECK_EQ(0xffffff83u, t.s8);
|
|
|
|
CHECK_EQ(0xffffb683u, t.s16);
|
|
|
|
CHECK_EQ(0xa512b683u, t.s32);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MSA_fill_copy_2) {
|
|
|
|
// Similar to MSA_fill_copy test, but also check overlaping between MSA and
|
|
|
|
// FPU registers with same numbers
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t w0;
|
|
|
|
uint32_t w1;
|
|
|
|
uint32_t w2;
|
|
|
|
uint32_t w3;
|
|
|
|
} T;
|
|
|
|
T t[2];
|
|
|
|
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD))
|
|
|
|
return;
|
|
|
|
|
|
|
|
{
|
|
|
|
CpuFeatureScope fscope(&assm, MIPS_SIMD);
|
|
|
|
|
|
|
|
__ li(t0, 0xaaaaaaaa);
|
|
|
|
__ li(t1, 0x55555555);
|
|
|
|
|
|
|
|
__ fill_w(w0, t0);
|
|
|
|
__ fill_w(w2, t0);
|
|
|
|
|
|
|
|
__ FmoveLow(f0, t1);
|
|
|
|
__ FmoveHigh(f2, t1);
|
|
|
|
|
|
|
|
#define STORE_MSA_REG(w_reg, base, scratch) \
|
|
|
|
__ copy_u_w(scratch, w_reg, 0); \
|
|
|
|
__ sw(scratch, MemOperand(base, offsetof(T, w0))); \
|
|
|
|
__ copy_u_w(scratch, w_reg, 1); \
|
|
|
|
__ sw(scratch, MemOperand(base, offsetof(T, w1))); \
|
|
|
|
__ copy_u_w(scratch, w_reg, 2); \
|
|
|
|
__ sw(scratch, MemOperand(base, offsetof(T, w2))); \
|
|
|
|
__ copy_u_w(scratch, w_reg, 3); \
|
|
|
|
__ sw(scratch, MemOperand(base, offsetof(T, w3)));
|
|
|
|
|
|
|
|
STORE_MSA_REG(w0, a0, t2)
|
|
|
|
STORE_MSA_REG(w2, a1, t2)
|
|
|
|
#undef STORE_MSA_REG
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2017-05-25 14:51:07 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F4 f = FUNCTION_CAST<F4>(code->entry());
|
|
|
|
|
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t[0], &t[1], 0, 0, 0);
|
|
|
|
USE(dummy);
|
|
|
|
|
|
|
|
CHECK_EQ(0x55555555, t[0].w0);
|
|
|
|
CHECK_EQ(0xaaaaaaaa, t[0].w1);
|
|
|
|
CHECK_EQ(0xaaaaaaaa, t[0].w2);
|
|
|
|
CHECK_EQ(0xaaaaaaaa, t[0].w3);
|
|
|
|
CHECK_EQ(0xaaaaaaaa, t[1].w0);
|
|
|
|
CHECK_EQ(0x55555555, t[1].w1);
|
|
|
|
CHECK_EQ(0xaaaaaaaa, t[1].w2);
|
|
|
|
CHECK_EQ(0xaaaaaaaa, t[1].w3);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MSA_fill_copy_3) {
|
|
|
|
// Similar to MSA_fill_copy test, but also check overlaping between MSA and
|
|
|
|
// FPU registers with same numbers
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint64_t d0;
|
|
|
|
uint64_t d1;
|
|
|
|
} T;
|
|
|
|
T t[2];
|
|
|
|
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD))
|
|
|
|
return;
|
|
|
|
|
|
|
|
{
|
|
|
|
CpuFeatureScope fscope(&assm, MIPS_SIMD);
|
|
|
|
|
|
|
|
__ li(t0, 0xaaaaaaaa);
|
|
|
|
__ li(t1, 0x55555555);
|
|
|
|
|
|
|
|
__ Move(f0, t0, t0);
|
|
|
|
__ Move(f2, t0, t0);
|
|
|
|
|
|
|
|
__ fill_w(w0, t1);
|
|
|
|
__ fill_w(w2, t1);
|
|
|
|
|
|
|
|
__ Sdc1(f0, MemOperand(a0, offsetof(T, d0)));
|
|
|
|
__ Sdc1(f2, MemOperand(a1, offsetof(T, d0)));
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2017-05-25 14:51:07 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F4 f = FUNCTION_CAST<F4>(code->entry());
|
|
|
|
|
|
|
|
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t[0], &t[1], 0, 0, 0);
|
|
|
|
USE(dummy);
|
|
|
|
|
|
|
|
CHECK_EQ(0x5555555555555555, t[0].d0);
|
|
|
|
CHECK_EQ(0x5555555555555555, t[1].d0);
|
|
|
|
}
|
|
|
|
|
2017-05-31 09:34:46 +00:00
|
|
|
typedef union {
|
|
|
|
uint8_t b[16];
|
|
|
|
uint16_t h[8];
|
|
|
|
uint32_t w[4];
|
|
|
|
uint64_t d[2];
|
|
|
|
} msa_reg_t;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void run_msa_insert(int32_t rs_value, int n, msa_reg_t* w) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
CpuFeatureScope fscope(&assm, MIPS_SIMD);
|
|
|
|
|
|
|
|
__ li(t0, -1);
|
|
|
|
__ li(t1, rs_value);
|
|
|
|
__ fill_w(w0, t0);
|
|
|
|
|
|
|
|
if (std::is_same<T, int8_t>::value) {
|
|
|
|
DCHECK(n < 16);
|
|
|
|
__ insert_b(w0, n, t1);
|
|
|
|
} else if (std::is_same<T, int16_t>::value) {
|
|
|
|
DCHECK(n < 8);
|
|
|
|
__ insert_h(w0, n, t1);
|
|
|
|
} else if (std::is_same<T, int32_t>::value) {
|
|
|
|
DCHECK(n < 4);
|
|
|
|
__ insert_w(w0, n, t1);
|
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
__ copy_u_w(t2, w0, 0);
|
|
|
|
__ sw(t2, MemOperand(a0, 0));
|
|
|
|
__ copy_u_w(t2, w0, 1);
|
|
|
|
__ sw(t2, MemOperand(a0, 4));
|
|
|
|
__ copy_u_w(t2, w0, 2);
|
|
|
|
__ sw(t2, MemOperand(a0, 8));
|
|
|
|
__ copy_u_w(t2, w0, 3);
|
|
|
|
__ sw(t2, MemOperand(a0, 12));
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2017-05-31 09:34:46 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
(CALL_GENERATED_CODE(isolate, f, w, 0, 0, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MSA_insert) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseInsert {
|
|
|
|
uint32_t input;
|
|
|
|
int n;
|
|
|
|
uint64_t exp_res_lo;
|
|
|
|
uint64_t exp_res_hi;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCaseInsert tc_b[] = {
|
|
|
|
// input, n, exp_res_lo, exp_res_hi
|
|
|
|
{0xa2, 13, 0xffffffffffffffffu, 0xffffa2ffffffffffu},
|
|
|
|
{0x73, 10, 0xffffffffffffffffu, 0xffffffffff73ffffu},
|
|
|
|
{0x3494, 5, 0xffff94ffffffffffu, 0xffffffffffffffffu},
|
|
|
|
{0xa6b8, 1, 0xffffffffffffb8ffu, 0xffffffffffffffffu}};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(tc_b) / sizeof(TestCaseInsert); ++i) {
|
|
|
|
msa_reg_t res;
|
|
|
|
run_msa_insert<int8_t>(tc_b[i].input, tc_b[i].n, &res);
|
|
|
|
CHECK_EQ(tc_b[i].exp_res_lo, res.d[0]);
|
|
|
|
CHECK_EQ(tc_b[i].exp_res_hi, res.d[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestCaseInsert tc_h[] = {
|
|
|
|
// input, n, exp_res_lo, exp_res_hi
|
|
|
|
{0x85a2, 7, 0xffffffffffffffffu, 0x85a2ffffffffffffu},
|
|
|
|
{0xe873, 5, 0xffffffffffffffffu, 0xffffffffe873ffffu},
|
|
|
|
{0x3494, 3, 0x3494ffffffffffffu, 0xffffffffffffffffu},
|
|
|
|
{0xa6b8, 1, 0xffffffffa6b8ffffu, 0xffffffffffffffffu}};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(tc_h) / sizeof(TestCaseInsert); ++i) {
|
|
|
|
msa_reg_t res;
|
|
|
|
run_msa_insert<int16_t>(tc_h[i].input, tc_h[i].n, &res);
|
|
|
|
CHECK_EQ(tc_h[i].exp_res_lo, res.d[0]);
|
|
|
|
CHECK_EQ(tc_h[i].exp_res_hi, res.d[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestCaseInsert tc_w[] = {
|
|
|
|
// input, n, exp_res_lo, exp_res_hi
|
|
|
|
{0xd2f085a2u, 3, 0xffffffffffffffffu, 0xd2f085a2ffffffffu},
|
|
|
|
{0x4567e873u, 2, 0xffffffffffffffffu, 0xffffffff4567e873u},
|
|
|
|
{0xacdb3494u, 1, 0xacdb3494ffffffffu, 0xffffffffffffffffu},
|
|
|
|
{0x89aba6b8u, 0, 0xffffffff89aba6b8u, 0xffffffffffffffffu}};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(tc_w) / sizeof(TestCaseInsert); ++i) {
|
|
|
|
msa_reg_t res;
|
|
|
|
run_msa_insert<int32_t>(tc_w[i].input, tc_w[i].n, &res);
|
|
|
|
CHECK_EQ(tc_w[i].exp_res_lo, res.d[0]);
|
|
|
|
CHECK_EQ(tc_w[i].exp_res_hi, res.d[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ExpResShf {
|
|
|
|
uint8_t i8;
|
|
|
|
uint64_t lo;
|
|
|
|
uint64_t hi;
|
|
|
|
};
|
|
|
|
|
|
|
|
void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi,
|
|
|
|
uint8_t i8) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
|
|
|
|
MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
|
|
|
|
CpuFeatureScope fscope(&assm, MIPS_SIMD);
|
|
|
|
msa_reg_t res;
|
|
|
|
uint64_t wd_lo = 0xf35862e13e38f8b0;
|
|
|
|
uint64_t wd_hi = 0x4f41ffdef2bfe636;
|
|
|
|
|
|
|
|
#define LOAD_W_REG(lo, hi, w_reg) \
|
|
|
|
__ li(t0, static_cast<uint32_t>(lo & 0xffffffff)); \
|
|
|
|
__ li(t1, static_cast<uint32_t>((lo >> 32) & 0xffffffff)); \
|
|
|
|
__ insert_w(w_reg, 0, t0); \
|
|
|
|
__ insert_w(w_reg, 1, t1); \
|
|
|
|
__ li(t0, static_cast<uint32_t>(hi & 0xffffffff)); \
|
|
|
|
__ li(t1, static_cast<uint32_t>((hi >> 32) & 0xffffffff)); \
|
|
|
|
__ insert_w(w_reg, 2, t0); \
|
|
|
|
__ insert_w(w_reg, 3, t1);
|
|
|
|
|
|
|
|
LOAD_W_REG(ws_lo, ws_hi, w0)
|
|
|
|
|
|
|
|
switch (opcode) {
|
|
|
|
case ANDI_B:
|
|
|
|
__ andi_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case ORI_B:
|
|
|
|
__ ori_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case NORI_B:
|
|
|
|
__ nori_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case XORI_B:
|
|
|
|
__ xori_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case BMNZI_B:
|
|
|
|
LOAD_W_REG(wd_lo, wd_hi, w2);
|
|
|
|
__ bmnzi_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case BMZI_B:
|
|
|
|
LOAD_W_REG(wd_lo, wd_hi, w2);
|
|
|
|
__ bmzi_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case BSELI_B:
|
|
|
|
LOAD_W_REG(wd_lo, wd_hi, w2);
|
|
|
|
__ bseli_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case SHF_B:
|
|
|
|
__ shf_b(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case SHF_H:
|
|
|
|
__ shf_h(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
case SHF_W:
|
|
|
|
__ shf_w(w2, w0, i8);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
__ copy_u_w(t2, w2, 0);
|
|
|
|
__ sw(t2, MemOperand(a0, 0));
|
|
|
|
__ copy_u_w(t2, w2, 1);
|
|
|
|
__ sw(t2, MemOperand(a0, 4));
|
|
|
|
__ copy_u_w(t2, w2, 2);
|
|
|
|
__ sw(t2, MemOperand(a0, 8));
|
|
|
|
__ copy_u_w(t2, w2, 3);
|
|
|
|
__ sw(t2, MemOperand(a0, 12));
|
|
|
|
|
|
|
|
__ jr(ra);
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
#undef LOAD_W_REG
|
|
|
|
|
|
|
|
CodeDesc desc;
|
2017-05-31 14:00:11 +00:00
|
|
|
assm.GetCode(isolate, &desc);
|
2017-05-31 09:34:46 +00:00
|
|
|
Handle<Code> code = isolate->factory()->NewCode(
|
|
|
|
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
code->Print(std::cout);
|
|
|
|
#endif
|
|
|
|
F3 f = FUNCTION_CAST<F3>(code->entry());
|
|
|
|
|
|
|
|
(CALL_GENERATED_CODE(isolate, f, &res, 0, 0, 0, 0));
|
|
|
|
|
|
|
|
uint64_t mask = i8 * 0x0101010101010101ull;
|
|
|
|
switch (opcode) {
|
|
|
|
case ANDI_B:
|
|
|
|
CHECK_EQ(ws_lo & mask, res.d[0]);
|
|
|
|
CHECK_EQ(ws_hi & mask, res.d[1]);
|
|
|
|
break;
|
|
|
|
case ORI_B:
|
|
|
|
CHECK_EQ(ws_lo | mask, res.d[0]);
|
|
|
|
CHECK_EQ(ws_hi | mask, res.d[1]);
|
|
|
|
break;
|
|
|
|
case NORI_B:
|
|
|
|
CHECK_EQ(~(ws_lo | mask), res.d[0]);
|
|
|
|
CHECK_EQ(~(ws_hi | mask), res.d[1]);
|
|
|
|
break;
|
|
|
|
case XORI_B:
|
|
|
|
CHECK_EQ(ws_lo ^ mask, res.d[0]);
|
|
|
|
CHECK_EQ(ws_hi ^ mask, res.d[1]);
|
|
|
|
break;
|
|
|
|
case BMNZI_B:
|
|
|
|
CHECK_EQ((ws_lo & mask) | (wd_lo & ~mask), res.d[0]);
|
|
|
|
CHECK_EQ((ws_hi & mask) | (wd_hi & ~mask), res.d[1]);
|
|
|
|
break;
|
|
|
|
case BMZI_B:
|
|
|
|
CHECK_EQ((ws_lo & ~mask) | (wd_lo & mask), res.d[0]);
|
|
|
|
CHECK_EQ((ws_hi & ~mask) | (wd_hi & mask), res.d[1]);
|
|
|
|
break;
|
|
|
|
case BSELI_B:
|
|
|
|
CHECK_EQ((ws_lo & ~wd_lo) | (mask & wd_lo), res.d[0]);
|
|
|
|
CHECK_EQ((ws_hi & ~wd_hi) | (mask & wd_hi), res.d[1]);
|
|
|
|
break;
|
|
|
|
case SHF_B: {
|
|
|
|
struct ExpResShf exp_b[] = {
|
|
|
|
// i8, exp_lo, exp_hi
|
|
|
|
{0xffu, 0x11111111b9b9b9b9, 0xf7f7f7f7c8c8c8c8},
|
|
|
|
{0x0u, 0x62626262dfdfdfdf, 0xd6d6d6d6c8c8c8c8},
|
|
|
|
{0xe4u, 0xf35862e13e38f8b0, 0x4f41ffdef2bfe636},
|
|
|
|
{0x1bu, 0x1b756911c3d9a7b9, 0xae94a5f79c8aefc8},
|
|
|
|
{0xb1u, 0x662b6253e8c4df12, 0x0d3ad6803f8bc88b},
|
|
|
|
{0x4eu, 0x62e1f358f8b03e38, 0xffde4f41e636f2bf},
|
|
|
|
{0x27u, 0x1b697511c3a7d9b9, 0xaea594f79cef8ac8}};
|
|
|
|
for (size_t i = 0; i < sizeof(exp_b) / sizeof(ExpResShf); ++i) {
|
|
|
|
if (exp_b[i].i8 == i8) {
|
|
|
|
CHECK_EQ(exp_b[i].lo, res.d[0]);
|
|
|
|
CHECK_EQ(exp_b[i].hi, res.d[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case SHF_H: {
|
|
|
|
struct ExpResShf exp_h[] = {
|
|
|
|
// i8, exp_lo, exp_hi
|
|
|
|
{0xffu, 0x1169116911691169, 0xf7a5f7a5f7a5f7a5},
|
|
|
|
{0x0u, 0x12df12df12df12df, 0x8bc88bc88bc88bc8},
|
|
|
|
{0xe4u, 0xf35862e13e38f8b0, 0x4f41ffdef2bfe636},
|
|
|
|
{0x1bu, 0xd9c3b9a7751b1169, 0x8a9cc8ef94aef7a5},
|
|
|
|
{0xb1u, 0x53622b6612dfc4e8, 0x80d63a0d8bc88b3f},
|
|
|
|
{0x4eu, 0x3e38f8b0f35862e1, 0xf2bfe6364f41ffde},
|
|
|
|
{0x27u, 0xd9c3751bb9a71169, 0x8a9c94aec8eff7a5}};
|
|
|
|
for (size_t i = 0; i < sizeof(exp_h) / sizeof(ExpResShf); ++i) {
|
|
|
|
if (exp_h[i].i8 == i8) {
|
|
|
|
CHECK_EQ(exp_h[i].lo, res.d[0]);
|
|
|
|
CHECK_EQ(exp_h[i].hi, res.d[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case SHF_W: {
|
|
|
|
struct ExpResShf exp_w[] = {
|
|
|
|
// i8, exp_lo, exp_hi
|
|
|
|
{0xffu, 0xf7a594aef7a594ae, 0xf7a594aef7a594ae},
|
|
|
|
{0x0u, 0xc4e812dfc4e812df, 0xc4e812dfc4e812df},
|
|
|
|
{0xe4u, 0xf35862e13e38f8b0, 0x4f41ffdef2bfe636},
|
|
|
|
{0x1bu, 0xc8ef8a9cf7a594ae, 0xb9a7d9c31169751b},
|
|
|
|
{0xb1u, 0xc4e812df2b665362, 0x8b3f8bc83a0d80d6},
|
|
|
|
{0x4eu, 0x4f41ffdef2bfe636, 0xf35862e13e38f8b0},
|
|
|
|
{0x27u, 0x1169751bf7a594ae, 0xb9a7d9c3c8ef8a9c}};
|
|
|
|
for (size_t i = 0; i < sizeof(exp_w) / sizeof(ExpResShf); ++i) {
|
|
|
|
if (exp_w[i].i8 == i8) {
|
|
|
|
CHECK_EQ(exp_w[i].lo, res.d[0]);
|
|
|
|
CHECK_EQ(exp_w[i].hi, res.d[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestCaseMsaI8 {
|
|
|
|
uint64_t input_lo;
|
|
|
|
uint64_t input_hi;
|
|
|
|
uint8_t i8;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST(MSA_andi_ori_nori_xori) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseMsaI8 tc[] = {// input_lo, input_hi, i8
|
|
|
|
{0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0xffu},
|
|
|
|
{0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0x0u},
|
|
|
|
{0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x3bu},
|
|
|
|
{0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0xd9u}};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(tc) / sizeof(TestCaseMsaI8); ++i) {
|
|
|
|
run_msa_i8(ANDI_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
run_msa_i8(ORI_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
run_msa_i8(NORI_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
run_msa_i8(XORI_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MSA_bmnzi_bmzi_bseli) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseMsaI8 tc[] = {// input_lo, input_hi, i8
|
|
|
|
{0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0xffu},
|
|
|
|
{0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0x0u},
|
|
|
|
{0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x3bu},
|
|
|
|
{0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0xd9u}};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(tc) / sizeof(TestCaseMsaI8); ++i) {
|
|
|
|
run_msa_i8(BMNZI_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
run_msa_i8(BMZI_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
run_msa_i8(BSELI_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MSA_shf) {
|
|
|
|
if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
|
|
|
|
struct TestCaseMsaI8 tc[] = {
|
|
|
|
// input_lo, input_hi, i8
|
|
|
|
{0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0xffu}, // 3333
|
|
|
|
{0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0x0u}, // 0000
|
|
|
|
{0xf35862e13e38f8b0, 0x4f41ffdef2bfe636, 0xe4u}, // 3210
|
|
|
|
{0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x1bu}, // 0123
|
|
|
|
{0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0xb1u}, // 2301
|
|
|
|
{0xf35862e13e38f8b0, 0x4f41ffdef2bfe636, 0x4eu}, // 1032
|
|
|
|
{0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x27u} // 0213
|
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(tc) / sizeof(TestCaseMsaI8); ++i) {
|
|
|
|
run_msa_i8(SHF_B, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
run_msa_i8(SHF_H, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
run_msa_i8(SHF_W, tc[i].input_lo, tc[i].input_hi, tc[i].i8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-04 20:36:58 +00:00
|
|
|
#undef __
|