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

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

Issue 12634030: Adds branch instructions and labels to the MIPS simulator, assembler, disassembler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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_mips.cc ('k') | runtime/vm/constants_mips.h » ('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/os.h" 9 #include "vm/os.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 __ delay_slot()->ori(V0, ZR, Immediate(42)); 639 __ delay_slot()->ori(V0, ZR, Immediate(42));
640 } 640 }
641 641
642 642
643 ASSEMBLER_TEST_RUN(Jr_delay, test) { 643 ASSEMBLER_TEST_RUN(Jr_delay, test) {
644 typedef int (*SimpleCode)(); 644 typedef int (*SimpleCode)();
645 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 645 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
646 } 646 }
647 647
648 648
649 ASSEMBLER_TEST_GENERATE(Beq_backward, assembler) {
650 Label l;
651
652 __ LoadImmediate(R1, 0);
653 __ LoadImmediate(R2, 1);
654 __ Bind(&l);
655 __ addiu(R1, R1, Immediate(1));
656 __ beq(R1, R2, &l);
657 __ ori(V0, R1, Immediate(0));
658 __ jr(RA);
659 }
660
661
662 ASSEMBLER_TEST_RUN(Beq_backward, test) {
663 typedef int (*SimpleCode)();
664 EXPECT_EQ(2, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
665 }
666
667
668 ASSEMBLER_TEST_GENERATE(Beq_backward_delay, assembler) {
669 Label l;
670
671 __ LoadImmediate(R1, 0);
672 __ LoadImmediate(R2, 1);
673 __ Bind(&l);
674 __ addiu(R1, R1, Immediate(1));
675 __ beq(R1, R2, &l);
676 __ delay_slot()->addiu(R1, R1, Immediate(1));
677 __ ori(V0, R1, Immediate(0));
678 __ jr(RA);
679 }
680
681
682 ASSEMBLER_TEST_RUN(Beq_backward_delay, test) {
683 typedef int (*SimpleCode)();
684 EXPECT_EQ(4, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
685 }
686
687
688 ASSEMBLER_TEST_GENERATE(Beq_forward_taken, assembler) {
689 Label l;
690
691 __ LoadImmediate(R5, 1);
692 __ LoadImmediate(R6, 1);
693
694 __ LoadImmediate(V0, 42);
695 __ beq(R5, R6, &l);
696 __ LoadImmediate(V0, 0);
697 __ Bind(&l);
698 __ jr(RA);
699 }
700
701
702 ASSEMBLER_TEST_RUN(Beq_forward_taken, test) {
703 typedef int (*SimpleCode)();
704 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
705 }
706
707
708 ASSEMBLER_TEST_GENERATE(Beq_forward_not_taken, assembler) {
709 Label l;
710
711 __ LoadImmediate(R5, 0);
712 __ LoadImmediate(R6, 1);
713
714 __ LoadImmediate(V0, 42);
715 __ beq(R5, R6, &l);
716 __ LoadImmediate(V0, 0);
717 __ Bind(&l);
718 __ jr(RA);
719 }
720
721
722 ASSEMBLER_TEST_RUN(Beq_forward_not_taken, test) {
723 typedef int (*SimpleCode)();
724 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
725 }
726
727
728 ASSEMBLER_TEST_GENERATE(Beq_forward_taken2, assembler) {
729 Label l;
730
731 __ LoadImmediate(R5, 1);
732 __ LoadImmediate(R6, 1);
733
734 __ LoadImmediate(V0, 42);
735 __ beq(R5, R6, &l);
736 __ nop();
737 __ nop();
738 __ LoadImmediate(V0, 0);
739 __ Bind(&l);
740 __ jr(RA);
741 }
742
743
744 ASSEMBLER_TEST_RUN(Beq_forward_taken2, test) {
745 typedef int (*SimpleCode)();
746 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
747 }
748
749
750 ASSEMBLER_TEST_GENERATE(Beq_forward_taken_delay, assembler) {
751 Label l;
752
753 __ LoadImmediate(R5, 1);
754 __ LoadImmediate(R6, 1);
755
756 __ LoadImmediate(V0, 42);
757 __ beq(R5, R6, &l);
758 __ delay_slot()->ori(V0, V0, Immediate(1));
759 __ LoadImmediate(V0, 0);
760 __ Bind(&l);
761 __ jr(RA);
762 }
763
764
765 ASSEMBLER_TEST_RUN(Beq_forward_taken_delay, test) {
766 typedef int (*SimpleCode)();
767 EXPECT_EQ(43, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
768 }
769
770
771 ASSEMBLER_TEST_GENERATE(Beq_forward_not_taken_delay, assembler) {
772 Label l;
773
774 __ LoadImmediate(R5, 0);
775 __ LoadImmediate(R6, 1);
776
777 __ LoadImmediate(V0, 42);
778 __ beq(R5, R6, &l);
779 __ delay_slot()->ori(V0, V0, Immediate(1));
780 __ addiu(V0, V0, Immediate(1));
781 __ Bind(&l);
782 __ jr(RA);
783 }
784
785
786 ASSEMBLER_TEST_RUN(Beq_forward_not_taken_delay, test) {
787 typedef int (*SimpleCode)();
788 EXPECT_EQ(44, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
789 }
790
791
792 ASSEMBLER_TEST_GENERATE(Beql_backward_delay, assembler) {
793 Label l;
794
795 __ LoadImmediate(R5, 0);
796 __ LoadImmediate(R6, 1);
797 __ Bind(&l);
798 __ addiu(R5, R5, Immediate(1));
799 __ beql(R5, R6, &l);
800 __ delay_slot()->addiu(R5, R5, Immediate(1));
801 __ ori(V0, R5, Immediate(0));
802 __ jr(RA);
803 }
804
805
806 ASSEMBLER_TEST_RUN(Beql_backward_delay, test) {
807 typedef int (*SimpleCode)();
808 EXPECT_EQ(3, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
809 }
810
811
812 ASSEMBLER_TEST_GENERATE(Bgez, assembler) {
813 Label l;
814
815 __ LoadImmediate(R5, 3);
816 __ Bind(&l);
817 __ bgez(R5, &l);
818 __ delay_slot()->addiu(R5, R5, Immediate(-1));
819 __ ori(V0, R5, Immediate(0));
820 __ jr(RA);
821 }
822
823
824 ASSEMBLER_TEST_RUN(Bgez, test) {
825 typedef int (*SimpleCode)();
826 EXPECT_EQ(-2, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
827 }
828
829
830 ASSEMBLER_TEST_GENERATE(Bgezl, assembler) {
831 Label l;
832
833 __ LoadImmediate(R5, 3);
834 __ Bind(&l);
835 __ bgezl(R5, &l);
836 __ delay_slot()->addiu(R5, R5, Immediate(-1));
837 __ ori(V0, R5, Immediate(0));
838 __ jr(RA);
839 }
840
841
842 ASSEMBLER_TEST_RUN(Bgezl, test) {
843 typedef int (*SimpleCode)();
844 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
845 }
846
847
848 ASSEMBLER_TEST_GENERATE(Blez, assembler) {
849 Label l;
850
851 __ LoadImmediate(R5, -3);
852 __ Bind(&l);
853 __ blez(R5, &l);
854 __ delay_slot()->addiu(R5, R5, Immediate(1));
855 __ ori(V0, R5, Immediate(0));
856 __ jr(RA);
857 }
858
859
860 ASSEMBLER_TEST_RUN(Blez, test) {
861 typedef int (*SimpleCode)();
862 EXPECT_EQ(2, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
863 }
864
865
866 ASSEMBLER_TEST_GENERATE(Blezl, assembler) {
867 Label l;
868
869 __ LoadImmediate(R5, -3);
870 __ Bind(&l);
871 __ blezl(R5, &l);
872 __ delay_slot()->addiu(R5, R5, Immediate(1));
873 __ ori(V0, R5, Immediate(0));
874 __ jr(RA);
875 }
876
877
878 ASSEMBLER_TEST_RUN(Blezl, test) {
879 typedef int (*SimpleCode)();
880 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
881 }
882
883
884 ASSEMBLER_TEST_GENERATE(Bgtz, assembler) {
885 Label l;
886
887 __ LoadImmediate(R5, 3);
888 __ Bind(&l);
889 __ bgtz(R5, &l);
890 __ delay_slot()->addiu(R5, R5, Immediate(-1));
891 __ ori(V0, R5, Immediate(0));
892 __ jr(RA);
893 }
894
895
896 ASSEMBLER_TEST_RUN(Bgtz, test) {
897 typedef int (*SimpleCode)();
898 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
899 }
900
901
902 ASSEMBLER_TEST_GENERATE(Bgtzl, assembler) {
903 Label l;
904
905 __ LoadImmediate(R5, 3);
906 __ Bind(&l);
907 __ bgtzl(R5, &l);
908 __ delay_slot()->addiu(R5, R5, Immediate(-1));
909 __ ori(V0, R5, Immediate(0));
910 __ jr(RA);
911 }
912
913
914 ASSEMBLER_TEST_RUN(Bgtzl, test) {
915 typedef int (*SimpleCode)();
916 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
917 }
918
919
920 ASSEMBLER_TEST_GENERATE(Bltz, assembler) {
921 Label l;
922
923 __ LoadImmediate(R5, -3);
924 __ Bind(&l);
925 __ bltz(R5, &l);
926 __ delay_slot()->addiu(R5, R5, Immediate(1));
927 __ ori(V0, R5, Immediate(0));
928 __ jr(RA);
929 }
930
931
932 ASSEMBLER_TEST_RUN(Bltz, test) {
933 typedef int (*SimpleCode)();
934 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
935 }
936
937
938 ASSEMBLER_TEST_GENERATE(Bltzl, assembler) {
939 Label l;
940
941 __ LoadImmediate(R5, -3);
942 __ Bind(&l);
943 __ bltzl(R5, &l);
944 __ delay_slot()->addiu(R5, R5, Immediate(1));
945 __ ori(V0, R5, Immediate(0));
946 __ jr(RA);
947 }
948
949
950 ASSEMBLER_TEST_RUN(Bltzl, test) {
951 typedef int (*SimpleCode)();
952 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
953 }
954
955
956 ASSEMBLER_TEST_GENERATE(Bne, assembler) {
957 Label l;
958
959 __ LoadImmediate(R5, 3);
960 __ Bind(&l);
961 __ bne(R5, R0, &l);
962 __ delay_slot()->addiu(R5, R5, Immediate(-1));
963 __ ori(V0, R5, Immediate(0));
964 __ jr(RA);
965 }
966
967
968 ASSEMBLER_TEST_RUN(Bne, test) {
969 typedef int (*SimpleCode)();
970 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
971 }
972
973
974 ASSEMBLER_TEST_GENERATE(Bnel, assembler) {
975 Label l;
976
977 __ LoadImmediate(R5, 3);
978 __ Bind(&l);
979 __ bnel(R5, R0, &l);
980 __ delay_slot()->addiu(R5, R5, Immediate(-1));
981 __ ori(V0, R5, Immediate(0));
982 __ jr(RA);
983 }
984
985
986 ASSEMBLER_TEST_RUN(Bnel, test) {
987 typedef int (*SimpleCode)();
988 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
989 }
990
991
649 ASSEMBLER_TEST_GENERATE(Jalr_delay, assembler) { 992 ASSEMBLER_TEST_GENERATE(Jalr_delay, assembler) {
650 __ Move(R2, RA); 993 __ mov(R2, RA);
651 __ jalr(R2, RA); 994 __ jalr(R2, RA);
652 __ delay_slot()->ori(V0, ZR, Immediate(42)); 995 __ delay_slot()->ori(V0, ZR, Immediate(42));
653 } 996 }
654 997
655 998
656 ASSEMBLER_TEST_RUN(Jalr_delay, test) { 999 ASSEMBLER_TEST_RUN(Jalr_delay, test) {
657 typedef int (*SimpleCode)(); 1000 typedef int (*SimpleCode)();
658 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 1001 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
659 } 1002 }
660 1003
661 } // namespace dart 1004 } // namespace dart
662 1005
663 #endif // defined TARGET_ARCH_MIPS 1006 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/assembler_mips.cc ('k') | runtime/vm/constants_mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698