Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Unified Diff: test/cctest/test-macro-assembler-mips64.cc

Issue 1747863002: MIPS: Tests for convert and truncate instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..86560ed53ee0ac8c673ca4c96540940d41d48d71 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);
+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,145 @@ TEST(Dlsa) {
}
}
+float run_Cvt_s_uw(uint32_t x) {
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope scope(isolate);
+ MacroAssembler assembler(isolate, nullptr, 0,
+ v8::internal::CodeObjectRequired::kYes);
+ MacroAssembler* masm = &assembler;
+
+ __ Cvt_s_uw(f0, a0);
+ __ jr(ra);
+ __ nop();
+
+ CodeDesc desc;
+ assembler.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ F2 f = FUNCTION_CAST<F2>(code->entry());
+
+ float res = CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0);
+
+ return res;
+}
+
+TEST(Cvt_s_uw) {
+ CcTest::InitializeVM();
+
+ struct TestCase {
+ uint32_t value;
+ float expected_res;
+ };
+
+ struct TestCase tc[] = {
akos.palfi.imgtec 2016/02/29 12:28:22 Rename this const array to uint32_test_values and
Ilija.Pavlovic1 2016/02/29 15:00:27 In all our test suites (test-assembler-mips*, test
Ilija.Pavlovic1 2016/03/04 08:02:52 Done.
+ // value, expected_res
+ {0x00000000, static_cast<float>(0x00000000)},
+ {0x00000001, static_cast<float>(0x00000001)},
+ {0x7fffffff, static_cast<float>(0x7fffffff)},
+ {0x80000000, static_cast<float>(0x80000000)},
+ {0x8fffffff, static_cast<float>(0x8fffffff)},
+ {0xffffffff, static_cast<float>(0xffffffff)},
+ };
+
+ size_t nr_test_cases = sizeof(tc) / sizeof(TestCase);
+ for (size_t i = 0; i < nr_test_cases; ++i) {
+ CHECK_EQ(tc[i].expected_res, run_Cvt_s_uw(tc[i].value));
+ }
+}
+
+float run_Cvt_s_ul(uint64_t x) {
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope scope(isolate);
+ MacroAssembler assembler(isolate, nullptr, 0,
+ v8::internal::CodeObjectRequired::kYes);
+ MacroAssembler* masm = &assembler;
+
+ __ Cvt_s_ul(f0, a0);
+ __ jr(ra);
+ __ nop();
+
+ CodeDesc desc;
+ assembler.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ F3 f = FUNCTION_CAST<F3>(code->entry());
+
+ float res = CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0);
+
+ return res;
+}
+
+TEST(Cvt_s_ul) {
+ CcTest::InitializeVM();
+
+ struct TestCase {
+ uint64_t value;
+ float expected_res;
+ };
+
+ struct TestCase tc[] = {
akos.palfi.imgtec 2016/02/29 12:28:22 Same here, call it uint64_test_values.
Ilija.Pavlovic1 2016/03/04 08:02:52 Done.
+ // value, expected_res
+ {0x0000000000000000, static_cast<float>(0x0000000000000000)},
+ {0x0000000000000001, static_cast<float>(0x0000000000000001)},
+ {0x7fffffffffffffff, static_cast<float>(0x7fffffffffffffff)},
+ {0x8000000000000000, static_cast<float>(0x8000000000000000)},
+ {0x8fffffffffffffff, static_cast<float>(0x8fffffffffffffff)},
+ {0xffffffffffffffff, static_cast<float>(0xffffffffffffffff)},
+ };
+
+ size_t nr_test_cases = sizeof(tc) / sizeof(TestCase);
+ for (size_t i = 0; i < nr_test_cases; ++i) {
+ CHECK_EQ(tc[i].expected_res, run_Cvt_s_ul(tc[i].value));
+ }
+}
+
+double run_Cvt_d_ul(uint64_t x) {
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope scope(isolate);
+ MacroAssembler assembler(isolate, nullptr, 0,
+ v8::internal::CodeObjectRequired::kYes);
+ MacroAssembler* masm = &assembler;
+
+ __ Cvt_d_ul(f0, a0);
+ __ jr(ra);
+ __ nop();
+
+ CodeDesc desc;
+ assembler.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ F4 f = FUNCTION_CAST<F4>(code->entry());
+
+ float res = CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0);
+
+ return res;
+}
+
+TEST(Cvt_d_ul) {
+ CcTest::InitializeVM();
+
+ struct TestCase {
+ uint64_t value;
+ double expected_res;
+ };
+
+ struct TestCase tc[] = {
akos.palfi.imgtec 2016/02/29 12:28:22 Same here.
Ilija.Pavlovic1 2016/03/04 08:02:52 Done.
+ // value, expected_res
+ {0x0000000000000000, static_cast<double>(0x0000000000000000)},
+ {0x0000000000000001, static_cast<double>(0x0000000000000001)},
+ {0x7fffffffffffffff, static_cast<double>(0x7fffffffffffffff)},
+ {0x8000000000000000, static_cast<double>(0x8000000000000000)},
+ {0x8fffffffffffffff, static_cast<double>(0x8fffffffffffffff)},
+ {0xffffffffffffffff, static_cast<double>(0xffffffffffffffff)},
+ };
+
+ size_t nr_test_cases = sizeof(tc) / sizeof(TestCase);
+ for (size_t i = 0; i < nr_test_cases; ++i) {
+ CHECK_EQ(tc[i].expected_res, run_Cvt_d_ul(tc[i].value));
+ }
+}
+
#undef __
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698