Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1416 bool have_div = CPUFeatures::integer_division_supported(); | 1416 bool have_div = CPUFeatures::integer_division_supported(); |
| 1417 int32_t r = EXECUTE_TEST_CODE_INT32(Tst, test->entry()); | 1417 int32_t r = EXECUTE_TEST_CODE_INT32(Tst, test->entry()); |
| 1418 if (have_div) { | 1418 if (have_div) { |
| 1419 EXPECT_LT(0, r); | 1419 EXPECT_LT(0, r); |
| 1420 } else { | 1420 } else { |
| 1421 EXPECT_EQ(0, r); | 1421 EXPECT_EQ(0, r); |
| 1422 } | 1422 } |
| 1423 } | 1423 } |
| 1424 | 1424 |
| 1425 | 1425 |
| 1426 ASSEMBLER_TEST_GENERATE(Udiv, assembler) { | |
| 1427 __ mov(R0, ShifterOperand(27)); | |
| 1428 __ mov(R1, ShifterOperand(9)); | |
| 1429 __ udiv(R2, R0, R1); | |
| 1430 __ Mov(R0, R2); | |
| 1431 __ mov(PC, ShifterOperand(LR)); | |
| 1432 } | |
| 1433 | |
| 1434 | |
| 1435 ASSEMBLER_TEST_RUN(Udiv, test) { | |
| 1436 EXPECT(test != NULL); | |
| 1437 typedef int (*Tst)(); | |
| 1438 EXPECT_EQ(3, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); | |
| 1439 } | |
| 1440 | |
| 1441 | |
| 1442 ASSEMBLER_TEST_GENERATE(Sdiv, assembler) { | |
| 1443 __ mov(R0, ShifterOperand(27)); | |
| 1444 __ LoadImmediate(R1, -9); | |
| 1445 __ sdiv(R2, R0, R1); | |
| 1446 __ Mov(R0, R2); | |
| 1447 __ mov(PC, ShifterOperand(LR)); | |
| 1448 } | |
| 1449 | |
| 1450 | |
| 1451 ASSEMBLER_TEST_RUN(Sdiv, test) { | |
| 1452 EXPECT(test != NULL); | |
| 1453 typedef int (*Tst)(); | |
| 1454 EXPECT_EQ(-3, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); | |
| 1455 } | |
| 1456 | |
| 1457 | |
| 1458 ASSEMBLER_TEST_GENERATE(Muls, assembler) { | |
| 1459 __ mov(R0, ShifterOperand(3)); | |
| 1460 __ LoadImmediate(R1, -9); | |
| 1461 __ muls(R2, R0, R1); | |
| 1462 __ mov(R0, ShifterOperand(42), MI); | |
| 1463 __ mov(PC, ShifterOperand(LR)); | |
| 1464 } | |
| 1465 | |
| 1466 | |
| 1467 ASSEMBLER_TEST_RUN(Muls, test) { | |
| 1468 EXPECT(test != NULL); | |
| 1469 typedef int (*Tst)(); | |
| 1470 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); | |
| 1471 } | |
|
regis
2013/03/05 19:11:34
I would add tests for division by zero as well as
| |
| 1472 | |
| 1473 | |
| 1426 } // namespace dart | 1474 } // namespace dart |
| 1427 | 1475 |
| 1428 #endif // defined TARGET_ARCH_ARM | 1476 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |