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