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

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

Issue 235363005: Adds comparisons, labels, branches to arm64 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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_arm64.cc ('k') | runtime/vm/constants_arm64.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_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 __ eon(R0, R1, Operand(R2)); 484 __ eon(R0, R1, Operand(R2));
485 __ ret(); 485 __ ret();
486 } 486 }
487 487
488 488
489 ASSEMBLER_TEST_RUN(EonRegs, test) { 489 ASSEMBLER_TEST_RUN(EonRegs, test) {
490 typedef int (*SimpleCode)(); 490 typedef int (*SimpleCode)();
491 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); 491 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
492 } 492 }
493 493
494 // TODO(zra): ands and bics after branches are implemented.
495
496 494
497 // Logical immediate operations. 495 // Logical immediate operations.
498 ASSEMBLER_TEST_GENERATE(AndImm, assembler) { 496 ASSEMBLER_TEST_GENERATE(AndImm, assembler) {
499 __ movz(R1, 42, 0); 497 __ movz(R1, 42, 0);
500 __ andi(R0, R1, 0xaaaaaaaaaaaaaaaaULL); 498 __ andi(R0, R1, 0xaaaaaaaaaaaaaaaaULL);
501 __ ret(); 499 __ ret();
502 } 500 }
503 501
504 502
505 ASSEMBLER_TEST_RUN(AndImm, test) { 503 ASSEMBLER_TEST_RUN(AndImm, test) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 __ and_(R0, R0, Operand(R1)); 544 __ and_(R0, R0, Operand(R1));
547 __ ret(); 545 __ ret();
548 } 546 }
549 547
550 548
551 ASSEMBLER_TEST_RUN(EorImm, test) { 549 ASSEMBLER_TEST_RUN(EorImm, test) {
552 typedef int (*SimpleCode)(); 550 typedef int (*SimpleCode)();
553 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); 551 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
554 } 552 }
555 553
556 // TODO(zra): andis after branches are implemented. 554
555 // Comparisons, branching.
556 ASSEMBLER_TEST_GENERATE(BranchALForward, assembler) {
557 Label l;
558 __ movz(R0, 42, 0);
559 __ b(&l, AL);
560 __ movz(R0, 0, 0);
561 __ Bind(&l);
562 __ ret();
563 }
564
565
566 ASSEMBLER_TEST_RUN(BranchALForward, test) {
567 typedef int (*SimpleCode)();
568 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
569 }
570
571
572 ASSEMBLER_TEST_GENERATE(BranchALBackwards, assembler) {
573 Label l, leave;
574 __ movz(R0, 42, 0);
575 __ b(&l, AL);
576
577 __ movz(R0, 0, 0);
578 __ Bind(&leave);
579 __ ret();
580 __ movz(R0, 0, 0);
581
582 __ Bind(&l);
583 __ b(&leave, AL);
584 __ movz(R0, 0, 0);
585 __ ret();
586 }
587
588
589 ASSEMBLER_TEST_RUN(BranchALBackwards, test) {
590 typedef int (*SimpleCode)();
591 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
592 }
593
594
595 ASSEMBLER_TEST_GENERATE(CmpEqBranch, assembler) {
596 Label l;
597
598 __ movz(R0, 42, 0);
599 __ movz(R1, 234, 0);
600 __ movz(R2, 234, 0);
601
602 __ cmp(R1, Operand(R2));
603 __ b(&l, EQ);
604 __ movz(R0, 0, 0);
605 __ Bind(&l);
606 __ ret();
607 }
608
609
610 ASSEMBLER_TEST_RUN(CmpEqBranch, test) {
611 typedef int (*SimpleCode)();
612 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
613 }
614
615
616 ASSEMBLER_TEST_GENERATE(CmpEqBranchNotTaken, assembler) {
617 Label l;
618
619 __ movz(R0, 0, 0);
620 __ movz(R1, 233, 0);
621 __ movz(R2, 234, 0);
622
623 __ cmp(R1, Operand(R2));
624 __ b(&l, EQ);
625 __ movz(R0, 42, 0);
626 __ Bind(&l);
627 __ ret();
628 }
629
630
631 ASSEMBLER_TEST_RUN(CmpEqBranchNotTaken, test) {
632 typedef int (*SimpleCode)();
633 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
634 }
635
636
637 ASSEMBLER_TEST_GENERATE(CmpEq1Branch, assembler) {
638 Label l;
639
640 __ movz(R0, 42, 0);
641 __ movz(R1, 1, 0);
642
643 __ cmp(R1, Operand(1));
644 __ b(&l, EQ);
645 __ movz(R0, 0, 0);
646 __ Bind(&l);
647 __ ret();
648 }
649
650
651 ASSEMBLER_TEST_RUN(CmpEq1Branch, test) {
652 typedef int (*SimpleCode)();
653 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
654 }
655
656
657 ASSEMBLER_TEST_GENERATE(CmnEq1Branch, assembler) {
658 Label l;
659
660 __ movz(R0, 42, 0);
661 __ movn(R1, 0, 0); // R1 <- -1
662
663 __ cmn(R1, Operand(1));
664 __ b(&l, EQ);
665 __ movz(R0, 0, 0);
666 __ Bind(&l);
667 __ ret();
668 }
669
670
671 ASSEMBLER_TEST_RUN(CmnEq1Branch, test) {
672 typedef int (*SimpleCode)();
673 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
674 }
675
676
677 ASSEMBLER_TEST_GENERATE(CmpLtBranch, assembler) {
678 Label l;
679
680 __ movz(R0, 42, 0);
681 __ movz(R1, 233, 0);
682 __ movz(R2, 234, 0);
683
684 __ cmp(R1, Operand(R2));
685 __ b(&l, LT);
686 __ movz(R0, 0, 0);
687 __ Bind(&l);
688 __ ret();
689 }
690
691
692 ASSEMBLER_TEST_RUN(CmpLtBranch, test) {
693 typedef int (*SimpleCode)();
694 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
695 }
696
697
698 ASSEMBLER_TEST_GENERATE(CmpLtBranchNotTaken, assembler) {
699 Label l;
700
701 __ movz(R0, 0, 0);
702 __ movz(R1, 235, 0);
703 __ movz(R2, 234, 0);
704
705 __ cmp(R1, Operand(R2));
706 __ b(&l, LT);
707 __ movz(R0, 42, 0);
708 __ Bind(&l);
709 __ ret();
710 }
711
712
713 ASSEMBLER_TEST_RUN(CmpLtBranchNotTaken, test) {
714 typedef int (*SimpleCode)();
715 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
716 }
717
718
719 ASSEMBLER_TEST_GENERATE(AndsBranch, assembler) {
720 Label l;
721
722 __ movz(R0, 42, 0);
723 __ movz(R1, 2, 0);
724 __ movz(R2, 1, 0);
725
726 __ ands(R3, R1, Operand(R2));
727 __ b(&l, EQ);
728 __ movz(R0, 0, 0);
729 __ Bind(&l);
730 __ ret();
731 }
732
733
734 ASSEMBLER_TEST_RUN(AndsBranch, test) {
735 typedef int (*SimpleCode)();
736 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
737 }
738
739
740 ASSEMBLER_TEST_GENERATE(AndsBranchNotTaken, assembler) {
741 Label l;
742
743 __ movz(R0, 0, 0);
744 __ movz(R1, 2, 0);
745 __ movz(R2, 2, 0);
746
747 __ ands(R3, R1, Operand(R2));
748 __ b(&l, EQ);
749 __ movz(R0, 42, 0);
750 __ Bind(&l);
751 __ ret();
752 }
753
754
755 ASSEMBLER_TEST_RUN(AndsBranchNotTaken, test) {
756 typedef int (*SimpleCode)();
757 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
758 }
759
760
761 ASSEMBLER_TEST_GENERATE(BicsBranch, assembler) {
762 Label l;
763
764 __ movz(R0, 42, 0);
765 __ movz(R1, 2, 0);
766 __ movz(R2, 2, 0);
767
768 __ bics(R3, R1, Operand(R2));
769 __ b(&l, EQ);
770 __ movz(R0, 0, 0);
771 __ Bind(&l);
772 __ ret();
773 }
774
775
776 ASSEMBLER_TEST_RUN(BicsBranch, test) {
777 typedef int (*SimpleCode)();
778 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
779 }
780
781
782 ASSEMBLER_TEST_GENERATE(BicsBranchNotTaken, assembler) {
783 Label l;
784
785 __ movz(R0, 0, 0);
786 __ movz(R1, 2, 0);
787 __ movz(R2, 1, 0);
788
789 __ bics(R3, R1, Operand(R2));
790 __ b(&l, EQ);
791 __ movz(R0, 42, 0);
792 __ Bind(&l);
793 __ ret();
794 }
795
796
797 ASSEMBLER_TEST_RUN(BicsBranchNotTaken, test) {
798 typedef int (*SimpleCode)();
799 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
800 }
801
802
803 ASSEMBLER_TEST_GENERATE(AndisBranch, assembler) {
804 Label l;
805
806 __ movz(R0, 42, 0);
807 __ movz(R1, 2, 0);
808
809 __ andis(R3, R1, 1);
810 __ b(&l, EQ);
811 __ movz(R0, 0, 0);
812 __ Bind(&l);
813 __ ret();
814 }
815
816
817 ASSEMBLER_TEST_RUN(AndisBranch, test) {
818 typedef int (*SimpleCode)();
819 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
820 }
821
822
823 ASSEMBLER_TEST_GENERATE(AndisBranchNotTaken, assembler) {
824 Label l;
825
826 __ movz(R0, 0, 0);
827 __ movz(R1, 2, 0);
828
829 __ andis(R3, R1, 2);
830 __ b(&l, EQ);
831 __ movz(R0, 42, 0);
832 __ Bind(&l);
833 __ ret();
834 }
835
836
837 ASSEMBLER_TEST_RUN(AndisBranchNotTaken, test) {
838 typedef int (*SimpleCode)();
839 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
840 }
841
842
843 // Address of PC-rel offset, br, blr.
844 ASSEMBLER_TEST_GENERATE(AdrBr, assembler) {
845 __ movz(R0, 123, 0);
846 __ adr(R1, 3 * Instr::kInstrSize); // R1 <- PC + 3*Instr::kInstrSize
847 __ br(R1);
848 __ ret();
849
850 // br goes here.
851 __ movz(R0, 42, 0);
852 __ ret();
853 }
854
855
856 ASSEMBLER_TEST_RUN(AdrBr, test) {
857 typedef int (*SimpleCode)();
858 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
859 }
860
861
862 ASSEMBLER_TEST_GENERATE(AdrBlr, assembler) {
863 __ movz(R0, 123, 0);
864 __ add(R3, ZR, Operand(LR)); // Save LR.
865 __ adr(R1, 4 * Instr::kInstrSize); // R1 <- PC + 4*Instr::kInstrSize
866 __ blr(R1);
867 __ add(LR, ZR, Operand(R3));
868 __ ret();
869
870 // blr goes here.
871 __ movz(R0, 42, 0);
872 __ ret();
873 }
874
875
876 ASSEMBLER_TEST_RUN(AdrBlr, test) {
877 typedef int (*SimpleCode)();
878 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
879 }
557 880
558 } // namespace dart 881 } // namespace dart
559 882
560 #endif // defined(TARGET_ARCH_ARM64) 883 #endif // defined(TARGET_ARCH_ARM64)
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm64.cc ('k') | runtime/vm/constants_arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698