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

Side by Side Diff: runtime/vm/assembler_mips_test.cc

Issue 2452453002: Support unaligned integer loads on ARM and MIPS. (Closed)
Patch Set: review Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/assembler_mips.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 __ jr(RA); 313 __ jr(RA);
314 } 314 }
315 315
316 316
317 ASSEMBLER_TEST_RUN(Lw, test) { 317 ASSEMBLER_TEST_RUN(Lw, test) {
318 typedef int (*SimpleCode)() DART_UNUSED; 318 typedef int (*SimpleCode)() DART_UNUSED;
319 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 319 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
320 } 320 }
321 321
322 322
323 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnaligned, assembler) {
324 __ LoadHalfWordUnaligned(V0, A0, TMP);
325 __ jr(RA);
326 }
327
328
329 ASSEMBLER_TEST_RUN(LoadHalfWordUnaligned, test) {
330 EXPECT(test != NULL);
331 typedef intptr_t (*LoadHalfWordUnaligned)(intptr_t) DART_UNUSED;
332 uint8_t buffer[4] = {
333 0x89, 0xAB, 0xCD, 0xEF,
334 };
335
336 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xAB89)),
337 EXECUTE_TEST_CODE_INTPTR_INTPTR(
338 LoadHalfWordUnaligned,
339 test->entry(),
340 reinterpret_cast<intptr_t>(&buffer[0])));
341 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xCDAB)),
342 EXECUTE_TEST_CODE_INTPTR_INTPTR(
343 LoadHalfWordUnaligned,
344 test->entry(),
345 reinterpret_cast<intptr_t>(&buffer[1])));
346 }
347
348
349 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnsignedUnaligned, assembler) {
350 __ LoadHalfWordUnsignedUnaligned(V0, A0, TMP);
351 __ jr(RA);
352 }
353
354
355 ASSEMBLER_TEST_RUN(LoadHalfWordUnsignedUnaligned, test) {
356 EXPECT(test != NULL);
357 typedef intptr_t (*LoadHalfWordUnsignedUnaligned)(intptr_t) DART_UNUSED;
358 uint8_t buffer[4] = {
359 0x89, 0xAB, 0xCD, 0xEF,
360 };
361
362 EXPECT_EQ(0xAB89,
363 EXECUTE_TEST_CODE_INTPTR_INTPTR(
364 LoadHalfWordUnsignedUnaligned,
365 test->entry(),
366 reinterpret_cast<intptr_t>(&buffer[0])));
367 EXPECT_EQ(0xCDAB,
368 EXECUTE_TEST_CODE_INTPTR_INTPTR(
369 LoadHalfWordUnsignedUnaligned,
370 test->entry(),
371 reinterpret_cast<intptr_t>(&buffer[1])));
372 }
373
374
375 ASSEMBLER_TEST_GENERATE(StoreHalfWordUnaligned, assembler) {
376 __ LoadImmediate(A1, 0xABCD);
377 __ StoreWordUnaligned(A1, A0, TMP);
378 __ mov(V0, A1);
379 __ jr(RA);
380 }
381
382
383 ASSEMBLER_TEST_RUN(StoreHalfWordUnaligned, test) {
384 EXPECT(test != NULL);
385 typedef intptr_t (*StoreHalfWordUnaligned)(intptr_t) DART_UNUSED;
386 uint8_t buffer[4] = {
387 0, 0, 0, 0,
388 };
389
390 EXPECT_EQ(0xABCD,
391 EXECUTE_TEST_CODE_INTPTR_INTPTR(
392 StoreHalfWordUnaligned,
393 test->entry(),
394 reinterpret_cast<intptr_t>(&buffer[0])));
395 EXPECT_EQ(0xCD, buffer[0]);
396 EXPECT_EQ(0xAB, buffer[1]);
397 EXPECT_EQ(0, buffer[2]);
398
399 EXPECT_EQ(0xABCD,
400 EXECUTE_TEST_CODE_INTPTR_INTPTR(
401 StoreHalfWordUnaligned,
402 test->entry(),
403 reinterpret_cast<intptr_t>(&buffer[1])));
404 EXPECT_EQ(0xCD, buffer[1]);
405 EXPECT_EQ(0xAB, buffer[2]);
406 EXPECT_EQ(0, buffer[3]);
407 }
408
409
410 ASSEMBLER_TEST_GENERATE(LoadWordUnaligned, assembler) {
411 __ LoadWordUnaligned(V0, A0, TMP);
412 __ jr(RA);
413 }
414
415
416 ASSEMBLER_TEST_RUN(LoadWordUnaligned, test) {
417 EXPECT(test != NULL);
418 typedef intptr_t (*LoadWordUnaligned)(intptr_t) DART_UNUSED;
419 uint8_t buffer[8] = {
420 0x12, 0x34, 0x56, 0x78,
421 0x9A, 0xBC, 0xDE, 0xF0
422 };
423
424 EXPECT_EQ(0x78563412,
425 EXECUTE_TEST_CODE_INTPTR_INTPTR(
426 LoadWordUnaligned,
427 test->entry(),
428 reinterpret_cast<intptr_t>(&buffer[0])));
429 EXPECT_EQ(0x9A785634,
430 EXECUTE_TEST_CODE_INTPTR_INTPTR(
431 LoadWordUnaligned,
432 test->entry(),
433 reinterpret_cast<intptr_t>(&buffer[1])));
434 EXPECT_EQ(0xBC9A7856,
435 EXECUTE_TEST_CODE_INTPTR_INTPTR(
436 LoadWordUnaligned,
437 test->entry(),
438 reinterpret_cast<intptr_t>(&buffer[2])));
439 EXPECT_EQ(0xDEBC9A78,
440 EXECUTE_TEST_CODE_INTPTR_INTPTR(
441 LoadWordUnaligned,
442 test->entry(),
443 reinterpret_cast<intptr_t>(&buffer[3])));
444 }
445
446
447 ASSEMBLER_TEST_GENERATE(StoreWordUnaligned, assembler) {
448 __ LoadImmediate(A1, 0x12345678);
449 __ StoreWordUnaligned(A1, A0, TMP);
450 __ mov(V0, A1);
451 __ jr(RA);
452 }
453
454
455 ASSEMBLER_TEST_RUN(StoreWordUnaligned, test) {
456 EXPECT(test != NULL);
457 typedef intptr_t (*StoreWordUnaligned)(intptr_t) DART_UNUSED;
458 uint8_t buffer[8] = {
459 0, 0, 0, 0,
460 0, 0, 0, 0
461 };
462
463 EXPECT_EQ(0x12345678,
464 EXECUTE_TEST_CODE_INTPTR_INTPTR(
465 StoreWordUnaligned,
466 test->entry(),
467 reinterpret_cast<intptr_t>(&buffer[0])));
468 EXPECT_EQ(0x78, buffer[0]);
469 EXPECT_EQ(0x56, buffer[1]);
470 EXPECT_EQ(0x34, buffer[2]);
471 EXPECT_EQ(0x12, buffer[3]);
472
473 EXPECT_EQ(0x12345678,
474 EXECUTE_TEST_CODE_INTPTR_INTPTR(
475 StoreWordUnaligned,
476 test->entry(),
477 reinterpret_cast<intptr_t>(&buffer[1])));
478 EXPECT_EQ(0x78, buffer[1]);
479 EXPECT_EQ(0x56, buffer[2]);
480 EXPECT_EQ(0x34, buffer[3]);
481 EXPECT_EQ(0x12, buffer[4]);
482
483 EXPECT_EQ(0x12345678,
484 EXECUTE_TEST_CODE_INTPTR_INTPTR(
485 StoreWordUnaligned,
486 test->entry(),
487 reinterpret_cast<intptr_t>(&buffer[2])));
488 EXPECT_EQ(0x78, buffer[2]);
489 EXPECT_EQ(0x56, buffer[3]);
490 EXPECT_EQ(0x34, buffer[4]);
491 EXPECT_EQ(0x12, buffer[5]);
492
493 EXPECT_EQ(0x12345678,
494 EXECUTE_TEST_CODE_INTPTR_INTPTR(
495 StoreWordUnaligned,
496 test->entry(),
497 reinterpret_cast<intptr_t>(&buffer[3])));
498 EXPECT_EQ(0x78, buffer[3]);
499 EXPECT_EQ(0x56, buffer[4]);
500 EXPECT_EQ(0x34, buffer[5]);
501 EXPECT_EQ(0x12, buffer[6]);
502 }
503
504
323 ASSEMBLER_TEST_GENERATE(Lui, assembler) { 505 ASSEMBLER_TEST_GENERATE(Lui, assembler) {
324 __ lui(V0, Immediate(42)); 506 __ lui(V0, Immediate(42));
325 __ jr(RA); 507 __ jr(RA);
326 } 508 }
327 509
328 510
329 ASSEMBLER_TEST_RUN(Lui, test) { 511 ASSEMBLER_TEST_RUN(Lui, test) {
330 typedef int (*SimpleCode)() DART_UNUSED; 512 typedef int (*SimpleCode)() DART_UNUSED;
331 EXPECT_EQ(42 << 16, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 513 EXPECT_EQ(42 << 16, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
332 } 514 }
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 ASSEMBLER_TEST_RUN(Semaphore, test) { 2343 ASSEMBLER_TEST_RUN(Semaphore, test) {
2162 EXPECT(test != NULL); 2344 EXPECT(test != NULL);
2163 typedef int (*Semaphore)() DART_UNUSED; 2345 typedef int (*Semaphore)() DART_UNUSED;
2164 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Semaphore, test->entry())); 2346 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Semaphore, test->entry()));
2165 } 2347 }
2166 2348
2167 2349
2168 } // namespace dart 2350 } // namespace dart
2169 2351
2170 #endif // defined TARGET_ARCH_MIPS 2352 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/assembler_mips.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698