authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-24 20:58:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-24 20:58:38-07:00
log12d18a36e5eed4b0898e93df2fd13b56061049b3
tree8ef105a3cbedc2bdfa962acb553cd6d0cab2856c
parent01bfd835bb9613d21f09c0c4f5b905b077b3d5f9

stage2: enable passing tests


1 files changed, 185 insertions(+), 185 deletions(-)

test/stage2/test.zig+185-185
......@@ -622,197 +622,197 @@ pub fn addCases(ctx: *TestContext) !void {
622622 );
623623
624624 // Labeled blocks (no conditional branch)
625 //case.addCompareOutput(
626 // \\export fn _start() noreturn {
627 // \\ assert(add(3, 4) == 20);
628 // \\
629 // \\ exit();
630 // \\}
631 // \\
632 // \\fn add(a: u32, b: u32) u32 {
633 // \\ const x: u32 = blk: {
634 // \\ const c = a + b; // 7
635 // \\ const d = a + c; // 10
636 // \\ const e = d + b; // 14
637 // \\ break :blk e;
638 // \\ };
639 // \\ const y = x + a; // 17
640 // \\ const z = y + a; // 20
641 // \\ return z;
642 // \\}
643 // \\
644 // \\pub fn assert(ok: bool) void {
645 // \\ if (!ok) unreachable; // assertion failure
646 // \\}
647 // \\
648 // \\fn exit() noreturn {
649 // \\ asm volatile ("syscall"
650 // \\ :
651 // \\ : [number] "{rax}" (231),
652 // \\ [arg1] "{rdi}" (0)
653 // \\ : "rcx", "r11", "memory"
654 // \\ );
655 // \\ unreachable;
656 // \\}
657 //,
658 // "",
659 //);
625 case.addCompareOutput(
626 \\export fn _start() noreturn {
627 \\ assert(add(3, 4) == 20);
628 \\
629 \\ exit();
630 \\}
631 \\
632 \\fn add(a: u32, b: u32) u32 {
633 \\ const x: u32 = blk: {
634 \\ const c = a + b; // 7
635 \\ const d = a + c; // 10
636 \\ const e = d + b; // 14
637 \\ break :blk e;
638 \\ };
639 \\ const y = x + a; // 17
640 \\ const z = y + a; // 20
641 \\ return z;
642 \\}
643 \\
644 \\pub fn assert(ok: bool) void {
645 \\ if (!ok) unreachable; // assertion failure
646 \\}
647 \\
648 \\fn exit() noreturn {
649 \\ asm volatile ("syscall"
650 \\ :
651 \\ : [number] "{rax}" (231),
652 \\ [arg1] "{rdi}" (0)
653 \\ : "rcx", "r11", "memory"
654 \\ );
655 \\ unreachable;
656 \\}
657 ,
658 "",
659 );
660660
661661 // This catches a possible bug in the logic for re-using dying operands.
662 //case.addCompareOutput(
663 // \\export fn _start() noreturn {
664 // \\ assert(add(3, 4) == 116);
665 // \\
666 // \\ exit();
667 // \\}
668 // \\
669 // \\fn add(a: u32, b: u32) u32 {
670 // \\ const x: u32 = blk: {
671 // \\ const c = a + b; // 7
672 // \\ const d = a + c; // 10
673 // \\ const e = d + b; // 14
674 // \\ const f = d + e; // 24
675 // \\ const g = e + f; // 38
676 // \\ const h = f + g; // 62
677 // \\ const i = g + h; // 100
678 // \\ const j = i + d; // 110
679 // \\ break :blk j;
680 // \\ };
681 // \\ const y = x + a; // 113
682 // \\ const z = y + a; // 116
683 // \\ return z;
684 // \\}
685 // \\
686 // \\pub fn assert(ok: bool) void {
687 // \\ if (!ok) unreachable; // assertion failure
688 // \\}
689 // \\
690 // \\fn exit() noreturn {
691 // \\ asm volatile ("syscall"
692 // \\ :
693 // \\ : [number] "{rax}" (231),
694 // \\ [arg1] "{rdi}" (0)
695 // \\ : "rcx", "r11", "memory"
696 // \\ );
697 // \\ unreachable;
698 // \\}
699 //,
700 // "",
701 //);
662 case.addCompareOutput(
663 \\export fn _start() noreturn {
664 \\ assert(add(3, 4) == 116);
665 \\
666 \\ exit();
667 \\}
668 \\
669 \\fn add(a: u32, b: u32) u32 {
670 \\ const x: u32 = blk: {
671 \\ const c = a + b; // 7
672 \\ const d = a + c; // 10
673 \\ const e = d + b; // 14
674 \\ const f = d + e; // 24
675 \\ const g = e + f; // 38
676 \\ const h = f + g; // 62
677 \\ const i = g + h; // 100
678 \\ const j = i + d; // 110
679 \\ break :blk j;
680 \\ };
681 \\ const y = x + a; // 113
682 \\ const z = y + a; // 116
683 \\ return z;
684 \\}
685 \\
686 \\pub fn assert(ok: bool) void {
687 \\ if (!ok) unreachable; // assertion failure
688 \\}
689 \\
690 \\fn exit() noreturn {
691 \\ asm volatile ("syscall"
692 \\ :
693 \\ : [number] "{rax}" (231),
694 \\ [arg1] "{rdi}" (0)
695 \\ : "rcx", "r11", "memory"
696 \\ );
697 \\ unreachable;
698 \\}
699 ,
700 "",
701 );
702702
703703 // Spilling registers to the stack.
704 //case.addCompareOutput(
705 // \\export fn _start() noreturn {
706 // \\ assert(add(3, 4) == 791);
707 // \\
708 // \\ exit();
709 // \\}
710 // \\
711 // \\fn add(a: u32, b: u32) u32 {
712 // \\ const x: u32 = blk: {
713 // \\ const c = a + b; // 7
714 // \\ const d = a + c; // 10
715 // \\ const e = d + b; // 14
716 // \\ const f = d + e; // 24
717 // \\ const g = e + f; // 38
718 // \\ const h = f + g; // 62
719 // \\ const i = g + h; // 100
720 // \\ const j = i + d; // 110
721 // \\ const k = i + j; // 210
722 // \\ const l = k + c; // 217
723 // \\ const m = l + d; // 227
724 // \\ const n = m + e; // 241
725 // \\ const o = n + f; // 265
726 // \\ const p = o + g; // 303
727 // \\ const q = p + h; // 365
728 // \\ const r = q + i; // 465
729 // \\ const s = r + j; // 575
730 // \\ const t = s + k; // 785
731 // \\ break :blk t;
732 // \\ };
733 // \\ const y = x + a; // 788
734 // \\ const z = y + a; // 791
735 // \\ return z;
736 // \\}
737 // \\
738 // \\pub fn assert(ok: bool) void {
739 // \\ if (!ok) unreachable; // assertion failure
740 // \\}
741 // \\
742 // \\fn exit() noreturn {
743 // \\ asm volatile ("syscall"
744 // \\ :
745 // \\ : [number] "{rax}" (231),
746 // \\ [arg1] "{rdi}" (0)
747 // \\ : "rcx", "r11", "memory"
748 // \\ );
749 // \\ unreachable;
750 // \\}
751 //,
752 // "",
753 //);
704 case.addCompareOutput(
705 \\export fn _start() noreturn {
706 \\ assert(add(3, 4) == 791);
707 \\
708 \\ exit();
709 \\}
710 \\
711 \\fn add(a: u32, b: u32) u32 {
712 \\ const x: u32 = blk: {
713 \\ const c = a + b; // 7
714 \\ const d = a + c; // 10
715 \\ const e = d + b; // 14
716 \\ const f = d + e; // 24
717 \\ const g = e + f; // 38
718 \\ const h = f + g; // 62
719 \\ const i = g + h; // 100
720 \\ const j = i + d; // 110
721 \\ const k = i + j; // 210
722 \\ const l = k + c; // 217
723 \\ const m = l + d; // 227
724 \\ const n = m + e; // 241
725 \\ const o = n + f; // 265
726 \\ const p = o + g; // 303
727 \\ const q = p + h; // 365
728 \\ const r = q + i; // 465
729 \\ const s = r + j; // 575
730 \\ const t = s + k; // 785
731 \\ break :blk t;
732 \\ };
733 \\ const y = x + a; // 788
734 \\ const z = y + a; // 791
735 \\ return z;
736 \\}
737 \\
738 \\pub fn assert(ok: bool) void {
739 \\ if (!ok) unreachable; // assertion failure
740 \\}
741 \\
742 \\fn exit() noreturn {
743 \\ asm volatile ("syscall"
744 \\ :
745 \\ : [number] "{rax}" (231),
746 \\ [arg1] "{rdi}" (0)
747 \\ : "rcx", "r11", "memory"
748 \\ );
749 \\ unreachable;
750 \\}
751 ,
752 "",
753 );
754754
755755 // Reusing the registers of dead operands playing nicely with conditional branching.
756 //case.addCompareOutput(
757 // \\export fn _start() noreturn {
758 // \\ assert(add(3, 4) == 791);
759 // \\ assert(add(4, 3) == 79);
760 // \\
761 // \\ exit();
762 // \\}
763 // \\
764 // \\fn add(a: u32, b: u32) u32 {
765 // \\ const x: u32 = if (a < b) blk: {
766 // \\ const c = a + b; // 7
767 // \\ const d = a + c; // 10
768 // \\ const e = d + b; // 14
769 // \\ const f = d + e; // 24
770 // \\ const g = e + f; // 38
771 // \\ const h = f + g; // 62
772 // \\ const i = g + h; // 100
773 // \\ const j = i + d; // 110
774 // \\ const k = i + j; // 210
775 // \\ const l = k + c; // 217
776 // \\ const m = l + d; // 227
777 // \\ const n = m + e; // 241
778 // \\ const o = n + f; // 265
779 // \\ const p = o + g; // 303
780 // \\ const q = p + h; // 365
781 // \\ const r = q + i; // 465
782 // \\ const s = r + j; // 575
783 // \\ const t = s + k; // 785
784 // \\ break :blk t;
785 // \\ } else blk: {
786 // \\ const t = b + b + a; // 10
787 // \\ const c = a + t; // 14
788 // \\ const d = c + t; // 24
789 // \\ const e = d + t; // 34
790 // \\ const f = e + t; // 44
791 // \\ const g = f + t; // 54
792 // \\ const h = c + g; // 68
793 // \\ break :blk h + b; // 71
794 // \\ };
795 // \\ const y = x + a; // 788, 75
796 // \\ const z = y + a; // 791, 79
797 // \\ return z;
798 // \\}
799 // \\
800 // \\pub fn assert(ok: bool) void {
801 // \\ if (!ok) unreachable; // assertion failure
802 // \\}
803 // \\
804 // \\fn exit() noreturn {
805 // \\ asm volatile ("syscall"
806 // \\ :
807 // \\ : [number] "{rax}" (231),
808 // \\ [arg1] "{rdi}" (0)
809 // \\ : "rcx", "r11", "memory"
810 // \\ );
811 // \\ unreachable;
812 // \\}
813 //,
814 // "",
815 //);
756 case.addCompareOutput(
757 \\export fn _start() noreturn {
758 \\ assert(add(3, 4) == 791);
759 \\ assert(add(4, 3) == 79);
760 \\
761 \\ exit();
762 \\}
763 \\
764 \\fn add(a: u32, b: u32) u32 {
765 \\ const x: u32 = if (a < b) blk: {
766 \\ const c = a + b; // 7
767 \\ const d = a + c; // 10
768 \\ const e = d + b; // 14
769 \\ const f = d + e; // 24
770 \\ const g = e + f; // 38
771 \\ const h = f + g; // 62
772 \\ const i = g + h; // 100
773 \\ const j = i + d; // 110
774 \\ const k = i + j; // 210
775 \\ const l = k + c; // 217
776 \\ const m = l + d; // 227
777 \\ const n = m + e; // 241
778 \\ const o = n + f; // 265
779 \\ const p = o + g; // 303
780 \\ const q = p + h; // 365
781 \\ const r = q + i; // 465
782 \\ const s = r + j; // 575
783 \\ const t = s + k; // 785
784 \\ break :blk t;
785 \\ } else blk: {
786 \\ const t = b + b + a; // 10
787 \\ const c = a + t; // 14
788 \\ const d = c + t; // 24
789 \\ const e = d + t; // 34
790 \\ const f = e + t; // 44
791 \\ const g = f + t; // 54
792 \\ const h = c + g; // 68
793 \\ break :blk h + b; // 71
794 \\ };
795 \\ const y = x + a; // 788, 75
796 \\ const z = y + a; // 791, 79
797 \\ return z;
798 \\}
799 \\
800 \\pub fn assert(ok: bool) void {
801 \\ if (!ok) unreachable; // assertion failure
802 \\}
803 \\
804 \\fn exit() noreturn {
805 \\ asm volatile ("syscall"
806 \\ :
807 \\ : [number] "{rax}" (231),
808 \\ [arg1] "{rdi}" (0)
809 \\ : "rcx", "r11", "memory"
810 \\ );
811 \\ unreachable;
812 \\}
813 ,
814 "",
815 );
816816
817817 // Character literals and multiline strings.
818818 case.addCompareOutput(