Index: test/cctest/test-macro-assembler-mips64.cc |
diff --git a/test/cctest/test-macro-assembler-mips64.cc b/test/cctest/test-macro-assembler-mips64.cc |
index e74703b8f80c248aca3abf7a88e9bbe0972b9022..ccac993e53b8fdf8ddbc051a827ff3bb7e250745 100644 |
--- a/test/cctest/test-macro-assembler-mips64.cc |
+++ b/test/cctest/test-macro-assembler-mips64.cc |
@@ -41,6 +41,9 @@ using namespace v8::internal; |
typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4); |
typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); |
+typedef float (*F2)(uint32_t x0, int x1, int x2, int x3, int x4); |
akos.palfi.imgtec
2016/03/04 09:02:07
Nit: These defs are not necessary anymore.
Ilija.Pavlovic1
2016/03/04 09:11:09
Done.
|
+typedef float (*F3)(uint64_t x0, int x1, int x2, int x3, int x4); |
+typedef double (*F4)(uint64_t x0, int x1, int x2, int x3, int x4); |
#define __ masm-> |
@@ -522,4 +525,82 @@ TEST(Dlsa) { |
} |
} |
+static const std::vector<uint32_t> uint32_test_values() { |
+ static const uint32_t kValues[] = {0x00000000, 0x00000001, 0x00ffff00, |
+ 0x7fffffff, 0x80000000, 0x80000001, |
+ 0x80ffff00, 0x8fffffff, 0xffffffff}; |
+ return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]); |
+} |
+ |
+static const std::vector<uint64_t> uint64_test_values() { |
+ static const uint64_t kValues[] = { |
+ 0x0000000000000000, 0x0000000000000001, 0x0000ffffffff0000, |
+ 0x7fffffffffffffff, 0x8000000000000000, 0x8000000000000001, |
+ 0x8000ffffffff0000, 0x8fffffffffffffff, 0xffffffffffffffff}; |
+ return std::vector<uint64_t>(&kValues[0], &kValues[arraysize(kValues)]); |
+} |
+ |
+// Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... } |
+#define FOR_INPUTS(ctype, itype, var) \ |
+ std::vector<ctype> var##_vec = itype##_test_values(); \ |
+ for (std::vector<ctype>::iterator var = var##_vec.begin(); \ |
+ var != var##_vec.end(); ++var) |
+ |
+#define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var) |
+#define FOR_UINT64_INPUTS(var) FOR_INPUTS(uint64_t, uint64, var) |
+ |
+template <typename RET_TYPE, typename IN_TYPE, typename Func> |
+RET_TYPE run_Cvt(IN_TYPE x, Func GenerateConvertInstructionFunc) { |
+ typedef RET_TYPE (*F_CVT)(IN_TYPE x0, int x1, int x2, int x3, int x4); |
+ |
+ Isolate* isolate = CcTest::i_isolate(); |
+ HandleScope scope(isolate); |
+ MacroAssembler assm(isolate, nullptr, 0, |
+ v8::internal::CodeObjectRequired::kYes); |
+ MacroAssembler* masm = &assm; |
+ |
+ GenerateConvertInstructionFunc(masm); |
+ __ jr(ra); |
+ __ nop(); |
+ |
+ CodeDesc desc; |
+ assm.GetCode(&desc); |
+ Handle<Code> code = isolate->factory()->NewCode( |
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
+ |
+ F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); |
+ |
+ return CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0); |
+} |
+ |
+TEST(Cvt_s_uw) { |
+ CcTest::InitializeVM(); |
+ FOR_UINT32_INPUTS(i) { |
+ uint32_t input = *i; |
+ CHECK_EQ(static_cast<float>(input), |
+ run_Cvt<float>( |
+ input, [](MacroAssembler* masm) { masm->Cvt_s_uw(f0, a0); })); |
+ } |
+} |
+ |
+TEST(Cvt_s_ul) { |
+ CcTest::InitializeVM(); |
+ FOR_UINT64_INPUTS(i) { |
+ uint64_t input = *i; |
+ CHECK_EQ(static_cast<float>(input), |
+ run_Cvt<float>( |
+ input, [](MacroAssembler* masm) { masm->Cvt_s_ul(f0, a0); })); |
+ } |
+} |
+ |
+TEST(Cvt_d_ul) { |
+ CcTest::InitializeVM(); |
+ FOR_UINT64_INPUTS(i) { |
+ uint64_t input = *i; |
+ CHECK_EQ(static_cast<double>(input), |
+ run_Cvt<double>( |
+ input, [](MacroAssembler* masm) { masm->Cvt_d_ul(f0, a0); })); |
+ } |
+} |
+ |
#undef __ |