| ... | ... | @@ -32,7 +32,7 @@ test "zig fmt: tuple struct" { |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | test "zig fmt: preserves clobbers in inline asm with stray comma" { |
| 35 | | try testCanonical( |
| 35 | try testTransform( |
| 36 | 36 | \\fn foo() void { |
| 37 | 37 | \\ asm volatile ("" |
| 38 | 38 | \\ : [_] "" (-> type), |
| ... | ... | @@ -46,6 +46,20 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" { |
| 46 | 46 | \\ ); |
| 47 | 47 | \\} |
| 48 | 48 | \\ |
| 49 | , |
| 50 | \\fn foo() void { |
| 51 | \\ asm volatile ("" |
| 52 | \\ : [_] "" (-> type), |
| 53 | \\ : |
| 54 | \\ : .{ .clobber = true } |
| 55 | \\ ); |
| 56 | \\ asm volatile ("" |
| 57 | \\ : |
| 58 | \\ : [_] "" (type), |
| 59 | \\ : .{ .clobber = true } |
| 60 | \\ ); |
| 61 | \\} |
| 62 | \\ |
| 49 | 63 | ); |
| 50 | 64 | } |
| 51 | 65 | |
| ... | ... | @@ -64,7 +78,7 @@ test "zig fmt: remove trailing comma at the end of assembly clobber" { |
| 64 | 78 | \\ asm volatile ("" |
| 65 | 79 | \\ : [_] "" (-> type), |
| 66 | 80 | \\ : |
| 67 | | \\ : "clobber1", "clobber2" |
| 81 | \\ : .{ .clobber1 = true, .clobber2 = true } |
| 68 | 82 | \\ ); |
| 69 | 83 | \\} |
| 70 | 84 | \\ |
| ... | ... | @@ -628,7 +642,7 @@ test "zig fmt: builtin call with trailing comma" { |
| 628 | 642 | } |
| 629 | 643 | |
| 630 | 644 | test "zig fmt: asm expression with comptime content" { |
| 631 | | try testCanonical( |
| 645 | try testTransform( |
| 632 | 646 | \\comptime { |
| 633 | 647 | \\ asm ("foo" ++ "bar"); |
| 634 | 648 | \\} |
| ... | ... | @@ -648,6 +662,26 @@ test "zig fmt: asm expression with comptime content" { |
| 648 | 662 | \\ ); |
| 649 | 663 | \\} |
| 650 | 664 | \\ |
| 665 | , |
| 666 | \\comptime { |
| 667 | \\ asm ("foo" ++ "bar"); |
| 668 | \\} |
| 669 | \\pub fn main() void { |
| 670 | \\ asm volatile ("foo" ++ "bar"); |
| 671 | \\ asm volatile ("foo" ++ "bar" |
| 672 | \\ : [_] "" (x), |
| 673 | \\ ); |
| 674 | \\ asm volatile ("foo" ++ "bar" |
| 675 | \\ : [_] "" (x), |
| 676 | \\ : [_] "" (y), |
| 677 | \\ ); |
| 678 | \\ asm volatile ("foo" ++ "bar" |
| 679 | \\ : [_] "" (x), |
| 680 | \\ : [_] "" (y), |
| 681 | \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true } |
| 682 | \\ ); |
| 683 | \\} |
| 684 | \\ |
| 651 | 685 | ); |
| 652 | 686 | } |
| 653 | 687 | |
| ... | ... | @@ -2182,7 +2216,7 @@ test "zig fmt: simple asm" { |
| 2182 | 2216 | \\ : [a] "x" (-> i32), |
| 2183 | 2217 | \\ : [a] "x" (1), |
| 2184 | 2218 | \\ ); |
| 2185 | | \\ asm ("still not real assembly" ::: "a", "b"); |
| 2219 | \\ asm ("still not real assembly" ::: .{ .a = true, .b = true }); |
| 2186 | 2220 | \\} |
| 2187 | 2221 | \\ |
| 2188 | 2222 | ); |
| ... | ... | @@ -3907,7 +3941,7 @@ test "zig fmt: fn type" { |
| 3907 | 3941 | } |
| 3908 | 3942 | |
| 3909 | 3943 | test "zig fmt: inline asm" { |
| 3910 | | try testCanonical( |
| 3944 | try testTransform( |
| 3911 | 3945 | \\pub fn syscall1(number: usize, arg1: usize) usize { |
| 3912 | 3946 | \\ return asm volatile ("syscall" |
| 3913 | 3947 | \\ : [ret] "={rax}" (-> usize), |
| ... | ... | @@ -3917,6 +3951,16 @@ test "zig fmt: inline asm" { |
| 3917 | 3951 | \\ ); |
| 3918 | 3952 | \\} |
| 3919 | 3953 | \\ |
| 3954 | , |
| 3955 | \\pub fn syscall1(number: usize, arg1: usize) usize { |
| 3956 | \\ return asm volatile ("syscall" |
| 3957 | \\ : [ret] "={rax}" (-> usize), |
| 3958 | \\ : [number] "{rax}" (number), |
| 3959 | \\ [arg1] "{rdi}" (arg1), |
| 3960 | \\ : .{ .rcx = true, .r11 = true } |
| 3961 | \\ ); |
| 3962 | \\} |
| 3963 | \\ |
| 3920 | 3964 | ); |
| 3921 | 3965 | } |
| 3922 | 3966 | |
| ... | ... | @@ -3998,7 +4042,7 @@ test "zig fmt: inline asm parameter alignment" { |
| 3998 | 4042 | \\ asm volatile ( |
| 3999 | 4043 | \\ \\ foo |
| 4000 | 4044 | \\ \\ bar |
| 4001 | | \\ ::: "", ""); |
| 4045 | \\ ::: .{ .a = true, .b = true }); |
| 4002 | 4046 | \\ asm volatile ( |
| 4003 | 4047 | \\ \\ foo |
| 4004 | 4048 | \\ \\ bar |
| ... | ... | @@ -4006,8 +4050,7 @@ test "zig fmt: inline asm parameter alignment" { |
| 4006 | 4050 | \\ [_] "" (-> usize), |
| 4007 | 4051 | \\ : [_] "" (0), |
| 4008 | 4052 | \\ [_] "" (0), |
| 4009 | | \\ : "", "" |
| 4010 | | \\ ); |
| 4053 | \\ : .{}); |
| 4011 | 4054 | \\} |
| 4012 | 4055 | \\ |
| 4013 | 4056 | ); |
| ... | ... | @@ -5325,7 +5368,7 @@ test "zig fmt: make single-line if no trailing comma, fmt: off" { |
| 5325 | 5368 | \\ asm ("not real assembly" |
| 5326 | 5369 | \\ :[a] "x" (->i32),:[a] "x" (1),); |
| 5327 | 5370 | \\ asm volatile ("still not real assembly" |
| 5328 | | \\ :::"a","b",); |
| 5371 | \\ :::.{.a = true,.b = true,}); |
| 5329 | 5372 | \\ } |
| 5330 | 5373 | \\} |
| 5331 | 5374 | ); |
| ... | ... | @@ -5737,7 +5780,7 @@ test "zig fmt: canonicalize symbols (asm)" { |
| 5737 | 5780 | \\ [@"arg1"] "{rdi}" (arg), |
| 5738 | 5781 | \\ [arg2] "{rsi}" (arg), |
| 5739 | 5782 | \\ [arg3] "{rdx}" (arg), |
| 5740 | | \\ : "rcx", "r11" |
| 5783 | \\ : "rcx", "fn" |
| 5741 | 5784 | \\ ); |
| 5742 | 5785 | \\ |
| 5743 | 5786 | \\ const @"false": usize = 10; |
| ... | ... | @@ -5759,7 +5802,7 @@ test "zig fmt: canonicalize symbols (asm)" { |
| 5759 | 5802 | \\ [arg1] "{rdi}" (arg), |
| 5760 | 5803 | \\ [arg2] "{rsi}" (arg), |
| 5761 | 5804 | \\ [arg3] "{rdx}" (arg), |
| 5762 | | \\ : "rcx", "r11" |
| 5805 | \\ : .{ .rcx = true, .@"fn" = true } |
| 5763 | 5806 | \\ ); |
| 5764 | 5807 | \\ |
| 5765 | 5808 | \\ const @"false": usize = 10; |