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

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

Issue 10696183: Add some missing x64 instruction variations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/intrinsifier_x64.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_X64) 6 #if defined(TARGET_ARCH_X64)
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 EXPECT_EQ(8000, reinterpret_cast<SignedMultiply>(entry)()); 344 EXPECT_EQ(8000, reinterpret_cast<SignedMultiply>(entry)());
345 } 345 }
346 346
347 347
348 ASSEMBLER_TEST_GENERATE(SignedMultiply64, assembler) { 348 ASSEMBLER_TEST_GENERATE(SignedMultiply64, assembler) {
349 __ movq(RAX, Immediate(2)); 349 __ movq(RAX, Immediate(2));
350 __ movq(RCX, Immediate(4)); 350 __ movq(RCX, Immediate(4));
351 __ imulq(RAX, RCX); 351 __ imulq(RAX, RCX);
352 __ movq(R8, Immediate(2)); 352 __ movq(R8, Immediate(2));
353 __ movq(R9, Immediate(4)); 353 __ movq(R9, Immediate(4));
354 __ imulq(R8, R9); 354 __ pushq(R9);
355 __ imulq(R8, Address(RSP, 0));
356 __ popq(R9);
355 __ addq(RAX, R8); 357 __ addq(RAX, R8);
356 __ ret(); 358 __ ret();
357 } 359 }
358 360
359 361
360 ASSEMBLER_TEST_RUN(SignedMultiply64, entry) { 362 ASSEMBLER_TEST_RUN(SignedMultiply64, entry) {
361 typedef int64_t (*SignedMultiply64)(); 363 typedef int64_t (*SignedMultiply64)();
362 EXPECT_EQ(16, reinterpret_cast<SignedMultiply64>(entry)()); 364 EXPECT_EQ(16, reinterpret_cast<SignedMultiply64>(entry)());
363 } 365 }
364 366
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 __ ret(); 515 __ ret();
514 } 516 }
515 517
516 518
517 ASSEMBLER_TEST_RUN(Bitwise, entry) { 519 ASSEMBLER_TEST_RUN(Bitwise, entry) {
518 typedef int (*Bitwise)(); 520 typedef int (*Bitwise)();
519 EXPECT_EQ(256 + 1, reinterpret_cast<Bitwise>(entry)()); 521 EXPECT_EQ(256 + 1, reinterpret_cast<Bitwise>(entry)());
520 } 522 }
521 523
522 524
525 ASSEMBLER_TEST_GENERATE(Bitwise64, assembler) {
526 Label error;
527 __ movq(RAX, Immediate(42));
528 __ pushq(RAX);
529 __ xorq(RAX, Address(RSP, 0));
530 __ popq(RCX);
531 __ cmpq(RAX, Immediate(0));
532 __ j(NOT_EQUAL, &error);
533 __ xorq(RCX, RCX);
534 __ orq(RCX, Immediate(256));
535 __ movq(RAX, Immediate(4));
536 __ orq(RCX, RAX);
537 __ movq(RAX, Immediate(0xfff0));
538 __ andq(RCX, RAX);
539 __ movq(RAX, Immediate(1));
540 __ pushq(RAX);
541 __ orq(RCX, Address(RSP, 0));
542 __ popq(RAX);
543 __ movq(RAX, RCX);
544 __ ret();
545 __ Bind(&error);
546 __ movq(RAX, Immediate(-1));
547 __ ret();
548 }
549
550
551 ASSEMBLER_TEST_RUN(Bitwise64, entry) {
552 typedef int (*Bitwise64)();
553 EXPECT_EQ(256 + 1, reinterpret_cast<Bitwise64>(entry)());
554 }
555
556
523 ASSEMBLER_TEST_GENERATE(LogicalOps, assembler) { 557 ASSEMBLER_TEST_GENERATE(LogicalOps, assembler) {
524 Label donetest1; 558 Label donetest1;
525 __ movl(RAX, Immediate(4)); 559 __ movl(RAX, Immediate(4));
526 __ andl(RAX, Immediate(2)); 560 __ andl(RAX, Immediate(2));
527 __ cmpl(RAX, Immediate(0)); 561 __ cmpl(RAX, Immediate(0));
528 __ j(EQUAL, &donetest1); 562 __ j(EQUAL, &donetest1);
529 // Be sure to skip this crashing code. 563 // Be sure to skip this crashing code.
530 __ movl(RAX, Immediate(0)); 564 __ movl(RAX, Immediate(0));
531 __ movl(Address(RAX, 0), RAX); 565 __ movl(Address(RAX, 0), RAX);
532 __ Bind(&donetest1); 566 __ Bind(&donetest1);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 __ ret(); 749 __ ret();
716 } 750 }
717 751
718 752
719 ASSEMBLER_TEST_RUN(LogicalOps, entry) { 753 ASSEMBLER_TEST_RUN(LogicalOps, entry) {
720 typedef int (*LogicalOpsCode)(); 754 typedef int (*LogicalOpsCode)();
721 EXPECT_EQ(0, reinterpret_cast<LogicalOpsCode>(entry)()); 755 EXPECT_EQ(0, reinterpret_cast<LogicalOpsCode>(entry)());
722 } 756 }
723 757
724 758
759 ASSEMBLER_TEST_GENERATE(LogicalOps64, assembler) {
760 Label donetest1;
761 __ movq(RAX, Immediate(4));
762 __ andq(RAX, Immediate(2));
763 __ cmpq(RAX, Immediate(0));
764 __ j(EQUAL, &donetest1);
765 // Be sure to skip this crashing code.
766 __ movq(RAX, Immediate(0));
767 __ movq(Address(RAX, 0), RAX);
768 __ Bind(&donetest1);
769
770 Label donetest2;
771 __ movq(RCX, Immediate(4));
772 __ pushq(RCX);
773 __ andq(RCX, Address(RSP, 0));
774 __ popq(RAX);
775 __ cmpq(RCX, Immediate(0));
776 __ j(NOT_EQUAL, &donetest2);
777 // Be sure to skip this crashing code.
778 __ movq(RAX, Immediate(0));
779 __ movq(Address(RAX, 0), RAX);
780 __ Bind(&donetest2);
781
782 Label donetest3;
783 __ movq(RAX, Immediate(0));
784 __ orq(RAX, Immediate(0));
785 __ cmpq(RAX, Immediate(0));
786 __ j(EQUAL, &donetest3);
787 // Be sure to skip this crashing code.
788 __ movq(RAX, Immediate(0));
789 __ movq(Address(RAX, 0), RAX);
790 __ Bind(&donetest3);
791
792 Label donetest4;
793 __ movq(RAX, Immediate(4));
794 __ orq(RAX, Immediate(0));
795 __ cmpq(RAX, Immediate(0));
796 __ j(NOT_EQUAL, &donetest4);
797 // Be sure to skip this crashing code.
798 __ movq(RAX, Immediate(0));
799 __ movq(Address(RAX, 0), RAX);
800 __ Bind(&donetest4);
801
802 Label donetest5;
803 __ pushq(RAX);
804 __ movq(RAX, Immediate(0xff));
805 __ movq(Address(RSP, 0), RAX);
806 __ cmpq(Address(RSP, 0), Immediate(0xff));
807 __ j(EQUAL, &donetest5);
808 // Be sure to skip this crashing code.
809 __ movq(RAX, Immediate(0));
810 __ movq(Address(RAX, 0), RAX);
811 __ Bind(&donetest5);
812 __ popq(RAX);
813
814 Label donetest6;
815 __ movq(RAX, Immediate(1));
816 __ shlq(RAX, Immediate(3));
817 __ cmpq(RAX, Immediate(8));
818 __ j(EQUAL, &donetest6);
819 // Be sure to skip this crashing code.
820 __ movq(RAX, Immediate(0));
821 __ movq(Address(RAX, 0), RAX);
822 __ Bind(&donetest6);
823
824 Label donetest7;
825 __ movq(RAX, Immediate(2));
826 __ shrq(RAX, Immediate(1));
827 __ cmpq(RAX, Immediate(1));
828 __ j(EQUAL, &donetest7);
829 // Be sure to skip this crashing code.
830 __ movq(RAX, Immediate(0));
831 __ movq(Address(RAX, 0), RAX);
832 __ Bind(&donetest7);
833
834 Label donetest8;
835 __ movq(RAX, Immediate(8));
836 __ shrq(RAX, Immediate(3));
837 __ cmpq(RAX, Immediate(1));
838 __ j(EQUAL, &donetest8);
839 // Be sure to skip this crashing code.
840 __ movq(RAX, Immediate(0));
841 __ movq(Address(RAX, 0), RAX);
842 __ Bind(&donetest8);
843
844 Label donetest9;
845 __ movq(RAX, Immediate(1));
846 __ movq(RCX, Immediate(3));
847 __ shlq(RAX, RCX);
848 __ cmpq(RAX, Immediate(8));
849 __ j(EQUAL, &donetest9);
850 // Be sure to skip this crashing code.
851 __ movq(RAX, Immediate(0));
852 __ movq(Address(RAX, 0), RAX);
853 __ Bind(&donetest9);
854
855 Label donetest10;
856 __ movq(RAX, Immediate(8));
857 __ movq(RCX, Immediate(3));
858 __ shrq(RAX, RCX);
859 __ cmpq(RAX, Immediate(1));
860 __ j(EQUAL, &donetest10);
861 // Be sure to skip this crashing code.
862 __ movq(RAX, Immediate(0));
863 __ movq(Address(RAX, 0), RAX);
864 __ Bind(&donetest10);
865
866 Label donetest6a;
867 __ movq(RAX, Immediate(1));
868 __ shlq(RAX, Immediate(3));
869 __ cmpq(RAX, Immediate(8));
870 __ j(EQUAL, &donetest6a);
871 // Be sure to skip this crashing code.
872 __ movq(RAX, Immediate(0));
873 __ movq(Address(RAX, 0), RAX);
874 __ Bind(&donetest6a);
875
876 Label donetest7a;
877 __ movq(RAX, Immediate(2));
878 __ shrq(RAX, Immediate(1));
879 __ cmpq(RAX, Immediate(1));
880 __ j(EQUAL, &donetest7a);
881 // Be sure to skip this crashing code.
882 __ movq(RAX, Immediate(0));
883 __ movq(Address(RAX, 0), RAX);
884 __ Bind(&donetest7a);
885
886 Label donetest8a;
887 __ movq(RAX, Immediate(8));
888 __ shrq(RAX, Immediate(3));
889 __ cmpq(RAX, Immediate(1));
890 __ j(EQUAL, &donetest8a);
891 // Be sure to skip this crashing code.
892 __ movq(RAX, Immediate(0));
893 __ movq(Address(RAX, 0), RAX);
894 __ Bind(&donetest8a);
895
896 Label donetest9a;
897 __ movq(RAX, Immediate(1));
898 __ movq(RCX, Immediate(3));
899 __ shlq(RAX, RCX);
900 __ cmpq(RAX, Immediate(8));
901 __ j(EQUAL, &donetest9a);
902 // Be sure to skip this crashing code.
903 __ movq(RAX, Immediate(0));
904 __ movq(Address(RAX, 0), RAX);
905 __ Bind(&donetest9a);
906
907 Label donetest10a;
908 __ movq(RAX, Immediate(8));
909 __ movq(RCX, Immediate(3));
910 __ shrq(RAX, RCX);
911 __ cmpq(RAX, Immediate(1));
912 __ j(EQUAL, &donetest10a);
913 // Be sure to skip this crashing code.
914 __ movq(RAX, Immediate(0));
915 __ movq(Address(RAX, 0), RAX);
916 __ Bind(&donetest10a);
917
918 Label donetest11a;
919 __ movq(RAX, Immediate(1));
920 __ shlq(RAX, Immediate(31));
921 __ shrq(RAX, Immediate(3));
922 __ cmpq(RAX, Immediate(0x10000000));
923 __ j(EQUAL, &donetest11a);
924 // Be sure to skip this crashing code.
925 __ movq(RAX, Immediate(0));
926 __ movq(Address(RAX, 0), RAX);
927 __ Bind(&donetest11a);
928
929 Label donetest12a;
930 __ movq(RAX, Immediate(1));
931 __ shlq(RAX, Immediate(63));
932 __ sarq(RAX, Immediate(3));
933 __ cmpq(RAX, Immediate(0xf000000000000000));
934 __ j(EQUAL, &donetest12a);
935 // Be sure to skip this crashing code.
936 __ movq(RAX, Immediate(0));
937 __ movq(Address(RAX, 0), RAX);
938 __ Bind(&donetest12a);
939
940 Label donetest13a;
941 __ movq(RAX, Immediate(1));
942 __ movq(RCX, Immediate(3));
943 __ shlq(RAX, Immediate(63));
944 __ sarq(RAX, RCX);
945 __ cmpq(RAX, Immediate(0xf000000000000000));
946 __ j(EQUAL, &donetest13a);
947 // Be sure to skip this crashing code.
948 __ movq(RAX, Immediate(0));
949 __ movq(Address(RAX, 0), RAX);
950 __ Bind(&donetest13a);
951
952 __ movq(RAX, Immediate(0));
953 __ ret();
954 }
955
956
957 ASSEMBLER_TEST_RUN(LogicalOps64, entry) {
958 typedef int (*LogicalOpsCode)();
959 EXPECT_EQ(0, reinterpret_cast<LogicalOpsCode>(entry)());
960 }
961
962
725 ASSEMBLER_TEST_GENERATE(LogicalTestL, assembler) { 963 ASSEMBLER_TEST_GENERATE(LogicalTestL, assembler) {
726 Label donetest1; 964 Label donetest1;
727 __ movl(RAX, Immediate(4)); 965 __ movl(RAX, Immediate(4));
728 __ movl(RCX, Immediate(2)); 966 __ movl(RCX, Immediate(2));
729 __ testl(RAX, RCX); 967 __ testl(RAX, RCX);
730 __ j(EQUAL, &donetest1); 968 __ j(EQUAL, &donetest1);
731 // Be sure to skip this crashing code. 969 // Be sure to skip this crashing code.
732 __ movl(RAX, Immediate(0)); 970 __ movl(RAX, Immediate(0));
733 __ movl(Address(RAX, 0), RAX); 971 __ movl(Address(RAX, 0), RAX);
734 __ Bind(&donetest1); 972 __ Bind(&donetest1);
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 ASSEMBLER_TEST_GENERATE(TestAdds, assembler) { 1481 ASSEMBLER_TEST_GENERATE(TestAdds, assembler) {
1244 __ movq(RAX, Immediate(4)); 1482 __ movq(RAX, Immediate(4));
1245 __ pushq(RAX); 1483 __ pushq(RAX);
1246 __ addq(Address(RSP, 0), Immediate(5)); 1484 __ addq(Address(RSP, 0), Immediate(5));
1247 // TOS: 9 1485 // TOS: 9
1248 __ addq(Address(RSP, 0), Immediate(-2)); 1486 __ addq(Address(RSP, 0), Immediate(-2));
1249 // TOS: 7 1487 // TOS: 7
1250 __ movq(RCX, Immediate(3)); 1488 __ movq(RCX, Immediate(3));
1251 __ addq(Address(RSP, 0), RCX); 1489 __ addq(Address(RSP, 0), RCX);
1252 // TOS: 10 1490 // TOS: 10
1253 __ popq(RAX); 1491 __ movq(RAX, Immediate(10));
1492 __ addq(RAX, Address(RSP, 0));
1493 // RAX: 20
1494 __ popq(RCX);
1254 __ ret(); 1495 __ ret();
1255 } 1496 }
1256 1497
1257 1498
1258 ASSEMBLER_TEST_RUN(TestAdds, entry) { 1499 ASSEMBLER_TEST_RUN(TestAdds, entry) {
1259 typedef int (*TestAdds)(); 1500 typedef int (*TestAdds)();
1260 int res = reinterpret_cast<TestAdds>(entry)(); 1501 int res = reinterpret_cast<TestAdds>(entry)();
1261 EXPECT_EQ(10, res); 1502 EXPECT_EQ(20, res);
1262 } 1503 }
1263 1504
1264 1505
1265 ASSEMBLER_TEST_GENERATE(TestNot, assembler) { 1506 ASSEMBLER_TEST_GENERATE(TestNot, assembler) {
1266 __ movq(RAX, Immediate(0xFFFFFFFF00000000)); 1507 __ movq(RAX, Immediate(0xFFFFFFFF00000000));
1267 __ notq(RAX); 1508 __ notq(RAX);
1268 __ ret(); 1509 __ ret();
1269 } 1510 }
1270 1511
1271 1512
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 EXPECT_EQ(0, res); 1674 EXPECT_EQ(0, res);
1434 res = reinterpret_cast<ExtractSignBits>(entry)(-1.0); 1675 res = reinterpret_cast<ExtractSignBits>(entry)(-1.0);
1435 EXPECT_EQ(1, res); 1676 EXPECT_EQ(1, res);
1436 res = reinterpret_cast<ExtractSignBits>(entry)(-0.0); 1677 res = reinterpret_cast<ExtractSignBits>(entry)(-0.0);
1437 EXPECT_EQ(1, res); 1678 EXPECT_EQ(1, res);
1438 } 1679 }
1439 1680
1440 } // namespace dart 1681 } // namespace dart
1441 1682
1442 #endif // defined TARGET_ARCH_X64 1683 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698