OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "test/cctest/cctest.h" | 39 #include "test/cctest/cctest.h" |
40 | 40 |
41 using namespace v8::internal; | 41 using namespace v8::internal; |
42 | 42 |
43 | 43 |
44 // Define these function prototypes to match JSEntryFunction in execution.cc. | 44 // Define these function prototypes to match JSEntryFunction in execution.cc. |
45 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); | 45 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); |
46 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); | 46 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); |
47 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); | 47 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); |
48 typedef Object* (*F4)(int64_t x, int64_t y, int64_t p2, int64_t p3, int64_t p4); | 48 typedef Object* (*F4)(int64_t x, int64_t y, int64_t p2, int64_t p3, int64_t p4); |
49 | 49 typedef Object* (*F5)(void* p0, void* p1, int p2, int p3, int p4); |
50 | 50 |
51 #define __ assm. | 51 #define __ assm. |
52 | 52 |
53 TEST(MIPS0) { | 53 TEST(MIPS0) { |
54 CcTest::InitializeVM(); | 54 CcTest::InitializeVM(); |
55 Isolate* isolate = CcTest::i_isolate(); | 55 Isolate* isolate = CcTest::i_isolate(); |
56 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
57 | 57 |
58 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 58 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
59 | 59 |
(...skipping 6049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6109 {0xABCD, 0xABC1ABC2ABC3ABC4, 32, 32, 0xABC3ABC40000ABCD}, | 6109 {0xABCD, 0xABC1ABC2ABC3ABC4, 32, 32, 0xABC3ABC40000ABCD}, |
6110 }; | 6110 }; |
6111 | 6111 |
6112 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDins); | 6112 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDins); |
6113 for (size_t i = 0; i < nr_test_cases; ++i) { | 6113 for (size_t i = 0; i < nr_test_cases; ++i) { |
6114 CHECK_EQ(tc[i].expected_res, | 6114 CHECK_EQ(tc[i].expected_res, |
6115 run_Dins(tc[i].imm, tc[i].source, tc[i].pos, tc[i].size)); | 6115 run_Dins(tc[i].imm, tc[i].source, tc[i].pos, tc[i].size)); |
6116 } | 6116 } |
6117 } | 6117 } |
6118 | 6118 |
| 6119 TEST(MSA_fill_copy) { |
| 6120 CcTest::InitializeVM(); |
| 6121 Isolate* isolate = CcTest::i_isolate(); |
| 6122 HandleScope scope(isolate); |
| 6123 |
| 6124 typedef struct { |
| 6125 uint64_t u8; |
| 6126 uint64_t u16; |
| 6127 uint64_t u32; |
| 6128 uint64_t s8; |
| 6129 uint64_t s16; |
| 6130 uint64_t s32; |
| 6131 uint64_t s64; |
| 6132 } T; |
| 6133 T t; |
| 6134 |
| 6135 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6136 if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) |
| 6137 return; |
| 6138 |
| 6139 { |
| 6140 CpuFeatureScope fscope(&assm, MIPS_SIMD); |
| 6141 |
| 6142 __ li(t0, 0x9e7689aca512b683); |
| 6143 |
| 6144 __ fill_b(w0, t0); |
| 6145 __ fill_h(w2, t0); |
| 6146 __ fill_w(w4, t0); |
| 6147 __ fill_d(w6, t0); |
| 6148 __ copy_u_b(t1, w0, 11); |
| 6149 __ sd(t1, MemOperand(a0, offsetof(T, u8))); |
| 6150 __ copy_u_h(t1, w2, 6); |
| 6151 __ sd(t1, MemOperand(a0, offsetof(T, u16))); |
| 6152 __ copy_u_w(t1, w4, 3); |
| 6153 __ sd(t1, MemOperand(a0, offsetof(T, u32))); |
| 6154 |
| 6155 __ copy_s_b(t1, w0, 8); |
| 6156 __ sd(t1, MemOperand(a0, offsetof(T, s8))); |
| 6157 __ copy_s_h(t1, w2, 5); |
| 6158 __ sd(t1, MemOperand(a0, offsetof(T, s16))); |
| 6159 __ copy_s_w(t1, w4, 1); |
| 6160 __ sd(t1, MemOperand(a0, offsetof(T, s32))); |
| 6161 __ copy_s_d(t1, w6, 0); |
| 6162 __ sd(t1, MemOperand(a0, offsetof(T, s64))); |
| 6163 |
| 6164 __ jr(ra); |
| 6165 __ nop(); |
| 6166 } |
| 6167 |
| 6168 CodeDesc desc; |
| 6169 assm.GetCode(&desc); |
| 6170 Handle<Code> code = isolate->factory()->NewCode( |
| 6171 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6172 #ifdef OBJECT_PRINT |
| 6173 code->Print(std::cout); |
| 6174 #endif |
| 6175 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 6176 |
| 6177 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); |
| 6178 USE(dummy); |
| 6179 |
| 6180 CHECK_EQ(0x83u, t.u8); |
| 6181 CHECK_EQ(0xb683u, t.u16); |
| 6182 CHECK_EQ(0xa512b683u, t.u32); |
| 6183 CHECK_EQ(0xffffffffffffff83u, t.s8); |
| 6184 CHECK_EQ(0xffffffffffffb683u, t.s16); |
| 6185 CHECK_EQ(0xffffffffa512b683u, t.s32); |
| 6186 CHECK_EQ(0x9e7689aca512b683u, t.s64); |
| 6187 } |
| 6188 |
| 6189 TEST(MSA_fill_copy_2) { |
| 6190 // Similar to MSA_fill_copy test, but also check overlaping between MSA and |
| 6191 // FPU registers with same numbers |
| 6192 CcTest::InitializeVM(); |
| 6193 Isolate* isolate = CcTest::i_isolate(); |
| 6194 HandleScope scope(isolate); |
| 6195 |
| 6196 typedef struct { |
| 6197 uint64_t d0; |
| 6198 uint64_t d1; |
| 6199 } T; |
| 6200 T t[2]; |
| 6201 |
| 6202 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6203 if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) |
| 6204 return; |
| 6205 |
| 6206 { |
| 6207 CpuFeatureScope fscope(&assm, MIPS_SIMD); |
| 6208 |
| 6209 __ li(t0, 0xaaaaaaaaaaaaaaaa); |
| 6210 __ li(t1, 0x5555555555555555); |
| 6211 |
| 6212 __ fill_d(w0, t0); |
| 6213 __ fill_d(w2, t0); |
| 6214 |
| 6215 __ Move(f0, t1); |
| 6216 __ Move(f2, t1); |
| 6217 |
| 6218 #define STORE_MSA_REG(w_reg, base, scratch) \ |
| 6219 __ copy_s_d(scratch, w_reg, 0); \ |
| 6220 __ sd(scratch, MemOperand(base, offsetof(T, d0))); \ |
| 6221 __ copy_s_d(scratch, w_reg, 1); \ |
| 6222 __ sd(scratch, MemOperand(base, offsetof(T, d1))); |
| 6223 |
| 6224 STORE_MSA_REG(w0, a0, t2) |
| 6225 STORE_MSA_REG(w2, a1, t2) |
| 6226 #undef STORE_MSA_REG |
| 6227 |
| 6228 __ jr(ra); |
| 6229 __ nop(); |
| 6230 } |
| 6231 |
| 6232 CodeDesc desc; |
| 6233 assm.GetCode(&desc); |
| 6234 Handle<Code> code = isolate->factory()->NewCode( |
| 6235 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6236 #ifdef OBJECT_PRINT |
| 6237 code->Print(std::cout); |
| 6238 #endif |
| 6239 F5 f = FUNCTION_CAST<F5>(code->entry()); |
| 6240 |
| 6241 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t[0], &t[1], 0, 0, 0); |
| 6242 USE(dummy); |
| 6243 |
| 6244 CHECK_EQ(0x5555555555555555, t[0].d0); |
| 6245 CHECK_EQ(0xaaaaaaaaaaaaaaaa, t[0].d1); |
| 6246 CHECK_EQ(0x5555555555555555, t[1].d0); |
| 6247 CHECK_EQ(0xaaaaaaaaaaaaaaaa, t[1].d1); |
| 6248 } |
| 6249 |
| 6250 TEST(MSA_fill_copy_3) { |
| 6251 // Similar to MSA_fill_copy test, but also check overlaping between MSA and |
| 6252 // FPU registers with same numbers |
| 6253 CcTest::InitializeVM(); |
| 6254 Isolate* isolate = CcTest::i_isolate(); |
| 6255 HandleScope scope(isolate); |
| 6256 |
| 6257 typedef struct { |
| 6258 uint64_t d0; |
| 6259 uint64_t d1; |
| 6260 } T; |
| 6261 T t[2]; |
| 6262 |
| 6263 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6264 if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) |
| 6265 return; |
| 6266 |
| 6267 { |
| 6268 CpuFeatureScope fscope(&assm, MIPS_SIMD); |
| 6269 |
| 6270 __ li(t0, 0xaaaaaaaaaaaaaaaa); |
| 6271 __ li(t1, 0x5555555555555555); |
| 6272 |
| 6273 __ Move(f0, t0); |
| 6274 __ Move(f2, t0); |
| 6275 |
| 6276 __ fill_d(w0, t1); |
| 6277 __ fill_d(w2, t1); |
| 6278 |
| 6279 __ Sdc1(f0, MemOperand(a0, offsetof(T, d0))); |
| 6280 __ Sdc1(f2, MemOperand(a1, offsetof(T, d0))); |
| 6281 |
| 6282 __ jr(ra); |
| 6283 __ nop(); |
| 6284 } |
| 6285 |
| 6286 CodeDesc desc; |
| 6287 assm.GetCode(&desc); |
| 6288 Handle<Code> code = isolate->factory()->NewCode( |
| 6289 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6290 #ifdef OBJECT_PRINT |
| 6291 code->Print(std::cout); |
| 6292 #endif |
| 6293 F5 f = FUNCTION_CAST<F5>(code->entry()); |
| 6294 |
| 6295 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t[0], &t[1], 0, 0, 0); |
| 6296 USE(dummy); |
| 6297 |
| 6298 CHECK_EQ(0x5555555555555555, t[0].d0); |
| 6299 CHECK_EQ(0x5555555555555555, t[1].d0); |
| 6300 } |
| 6301 |
6119 #undef __ | 6302 #undef __ |
OLD | NEW |