Merge remote-tracking branch 'origin/master' into wrangle-writer-buffering

This commit is contained in:
Andrew Kelley 2025-07-16 18:19:56 -07:00
commit 51ebebcea3
79 changed files with 3540 additions and 994 deletions

View File

@ -53,8 +53,7 @@ pub fn syscall1(number: usize, arg1: usize) usize {
// memory locations - not only the memory pointed to by a declared indirect // memory locations - not only the memory pointed to by a declared indirect
// output. In this example we list $rcx and $r11 because it is known the // output. In this example we list $rcx and $r11 because it is known the
// kernel syscall does not preserve these registers. // kernel syscall does not preserve these registers.
: "rcx", "r11" : .{ .rcx = true, .r11 = true });
);
} }
// syntax // syntax

View File

@ -15,8 +15,7 @@ pub fn syscall1(number: usize, arg1: usize) usize {
: [ret] "={rax}" (-> usize), : [ret] "={rax}" (-> usize),
: [number] "{rax}" (number), : [number] "{rax}" (number),
[arg1] "{rdi}" (arg1), [arg1] "{rdi}" (arg1),
: "rcx", "r11" : .{ .rcx = true, .r11 = true });
);
} }
pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{rdi}" (arg1), [arg1] "{rdi}" (arg1),
[arg2] "{rsi}" (arg2), [arg2] "{rsi}" (arg2),
[arg3] "{rdx}" (arg3), [arg3] "{rdx}" (arg3),
: "rcx", "r11" : .{ .rcx = true, .r11 = true });
);
} }
// exe=succeed // exe=succeed

View File

@ -28,8 +28,7 @@ fn __aarch64_cas1_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp1_relax() align(16) callconv(.naked) void { fn __aarch64_swp1_relax() align(16) callconv(.naked) void {
@ -48,8 +47,7 @@ fn __aarch64_swp1_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd1_relax() align(16) callconv(.naked) void { fn __aarch64_ldadd1_relax() align(16) callconv(.naked) void {
@ -69,8 +67,7 @@ fn __aarch64_ldadd1_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr1_relax() align(16) callconv(.naked) void { fn __aarch64_ldclr1_relax() align(16) callconv(.naked) void {
@ -90,8 +87,7 @@ fn __aarch64_ldclr1_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor1_relax() align(16) callconv(.naked) void { fn __aarch64_ldeor1_relax() align(16) callconv(.naked) void {
@ -111,8 +107,7 @@ fn __aarch64_ldeor1_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset1_relax() align(16) callconv(.naked) void { fn __aarch64_ldset1_relax() align(16) callconv(.naked) void {
@ -132,8 +127,7 @@ fn __aarch64_ldset1_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas1_acq() align(16) callconv(.naked) void { fn __aarch64_cas1_acq() align(16) callconv(.naked) void {
@ -154,8 +148,7 @@ fn __aarch64_cas1_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp1_acq() align(16) callconv(.naked) void { fn __aarch64_swp1_acq() align(16) callconv(.naked) void {
@ -174,8 +167,7 @@ fn __aarch64_swp1_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd1_acq() align(16) callconv(.naked) void { fn __aarch64_ldadd1_acq() align(16) callconv(.naked) void {
@ -195,8 +187,7 @@ fn __aarch64_ldadd1_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr1_acq() align(16) callconv(.naked) void { fn __aarch64_ldclr1_acq() align(16) callconv(.naked) void {
@ -216,8 +207,7 @@ fn __aarch64_ldclr1_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor1_acq() align(16) callconv(.naked) void { fn __aarch64_ldeor1_acq() align(16) callconv(.naked) void {
@ -237,8 +227,7 @@ fn __aarch64_ldeor1_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset1_acq() align(16) callconv(.naked) void { fn __aarch64_ldset1_acq() align(16) callconv(.naked) void {
@ -258,8 +247,7 @@ fn __aarch64_ldset1_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas1_rel() align(16) callconv(.naked) void { fn __aarch64_cas1_rel() align(16) callconv(.naked) void {
@ -280,8 +268,7 @@ fn __aarch64_cas1_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp1_rel() align(16) callconv(.naked) void { fn __aarch64_swp1_rel() align(16) callconv(.naked) void {
@ -300,8 +287,7 @@ fn __aarch64_swp1_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd1_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd1_rel() align(16) callconv(.naked) void {
@ -321,8 +307,7 @@ fn __aarch64_ldadd1_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr1_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr1_rel() align(16) callconv(.naked) void {
@ -342,8 +327,7 @@ fn __aarch64_ldclr1_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor1_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor1_rel() align(16) callconv(.naked) void {
@ -363,8 +347,7 @@ fn __aarch64_ldeor1_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset1_rel() align(16) callconv(.naked) void { fn __aarch64_ldset1_rel() align(16) callconv(.naked) void {
@ -384,8 +367,7 @@ fn __aarch64_ldset1_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas1_acq_rel() align(16) callconv(.naked) void { fn __aarch64_cas1_acq_rel() align(16) callconv(.naked) void {
@ -406,8 +388,7 @@ fn __aarch64_cas1_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp1_acq_rel() align(16) callconv(.naked) void { fn __aarch64_swp1_acq_rel() align(16) callconv(.naked) void {
@ -426,8 +407,7 @@ fn __aarch64_swp1_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd1_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd1_acq_rel() align(16) callconv(.naked) void {
@ -447,8 +427,7 @@ fn __aarch64_ldadd1_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr1_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr1_acq_rel() align(16) callconv(.naked) void {
@ -468,8 +447,7 @@ fn __aarch64_ldclr1_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor1_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor1_acq_rel() align(16) callconv(.naked) void {
@ -489,8 +467,7 @@ fn __aarch64_ldeor1_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset1_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldset1_acq_rel() align(16) callconv(.naked) void {
@ -510,8 +487,7 @@ fn __aarch64_ldset1_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas2_relax() align(16) callconv(.naked) void { fn __aarch64_cas2_relax() align(16) callconv(.naked) void {
@ -532,8 +508,7 @@ fn __aarch64_cas2_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp2_relax() align(16) callconv(.naked) void { fn __aarch64_swp2_relax() align(16) callconv(.naked) void {
@ -552,8 +527,7 @@ fn __aarch64_swp2_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd2_relax() align(16) callconv(.naked) void { fn __aarch64_ldadd2_relax() align(16) callconv(.naked) void {
@ -573,8 +547,7 @@ fn __aarch64_ldadd2_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr2_relax() align(16) callconv(.naked) void { fn __aarch64_ldclr2_relax() align(16) callconv(.naked) void {
@ -594,8 +567,7 @@ fn __aarch64_ldclr2_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor2_relax() align(16) callconv(.naked) void { fn __aarch64_ldeor2_relax() align(16) callconv(.naked) void {
@ -615,8 +587,7 @@ fn __aarch64_ldeor2_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset2_relax() align(16) callconv(.naked) void { fn __aarch64_ldset2_relax() align(16) callconv(.naked) void {
@ -636,8 +607,7 @@ fn __aarch64_ldset2_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas2_acq() align(16) callconv(.naked) void { fn __aarch64_cas2_acq() align(16) callconv(.naked) void {
@ -658,8 +628,7 @@ fn __aarch64_cas2_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp2_acq() align(16) callconv(.naked) void { fn __aarch64_swp2_acq() align(16) callconv(.naked) void {
@ -678,8 +647,7 @@ fn __aarch64_swp2_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd2_acq() align(16) callconv(.naked) void { fn __aarch64_ldadd2_acq() align(16) callconv(.naked) void {
@ -699,8 +667,7 @@ fn __aarch64_ldadd2_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr2_acq() align(16) callconv(.naked) void { fn __aarch64_ldclr2_acq() align(16) callconv(.naked) void {
@ -720,8 +687,7 @@ fn __aarch64_ldclr2_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor2_acq() align(16) callconv(.naked) void { fn __aarch64_ldeor2_acq() align(16) callconv(.naked) void {
@ -741,8 +707,7 @@ fn __aarch64_ldeor2_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset2_acq() align(16) callconv(.naked) void { fn __aarch64_ldset2_acq() align(16) callconv(.naked) void {
@ -762,8 +727,7 @@ fn __aarch64_ldset2_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas2_rel() align(16) callconv(.naked) void { fn __aarch64_cas2_rel() align(16) callconv(.naked) void {
@ -784,8 +748,7 @@ fn __aarch64_cas2_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp2_rel() align(16) callconv(.naked) void { fn __aarch64_swp2_rel() align(16) callconv(.naked) void {
@ -804,8 +767,7 @@ fn __aarch64_swp2_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd2_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd2_rel() align(16) callconv(.naked) void {
@ -825,8 +787,7 @@ fn __aarch64_ldadd2_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr2_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr2_rel() align(16) callconv(.naked) void {
@ -846,8 +807,7 @@ fn __aarch64_ldclr2_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor2_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor2_rel() align(16) callconv(.naked) void {
@ -867,8 +827,7 @@ fn __aarch64_ldeor2_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset2_rel() align(16) callconv(.naked) void { fn __aarch64_ldset2_rel() align(16) callconv(.naked) void {
@ -888,8 +847,7 @@ fn __aarch64_ldset2_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas2_acq_rel() align(16) callconv(.naked) void { fn __aarch64_cas2_acq_rel() align(16) callconv(.naked) void {
@ -910,8 +868,7 @@ fn __aarch64_cas2_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp2_acq_rel() align(16) callconv(.naked) void { fn __aarch64_swp2_acq_rel() align(16) callconv(.naked) void {
@ -930,8 +887,7 @@ fn __aarch64_swp2_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd2_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd2_acq_rel() align(16) callconv(.naked) void {
@ -951,8 +907,7 @@ fn __aarch64_ldadd2_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr2_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr2_acq_rel() align(16) callconv(.naked) void {
@ -972,8 +927,7 @@ fn __aarch64_ldclr2_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor2_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor2_acq_rel() align(16) callconv(.naked) void {
@ -993,8 +947,7 @@ fn __aarch64_ldeor2_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset2_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldset2_acq_rel() align(16) callconv(.naked) void {
@ -1014,8 +967,7 @@ fn __aarch64_ldset2_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas4_relax() align(16) callconv(.naked) void { fn __aarch64_cas4_relax() align(16) callconv(.naked) void {
@ -1036,8 +988,7 @@ fn __aarch64_cas4_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp4_relax() align(16) callconv(.naked) void { fn __aarch64_swp4_relax() align(16) callconv(.naked) void {
@ -1056,8 +1007,7 @@ fn __aarch64_swp4_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd4_relax() align(16) callconv(.naked) void { fn __aarch64_ldadd4_relax() align(16) callconv(.naked) void {
@ -1077,8 +1027,7 @@ fn __aarch64_ldadd4_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr4_relax() align(16) callconv(.naked) void { fn __aarch64_ldclr4_relax() align(16) callconv(.naked) void {
@ -1098,8 +1047,7 @@ fn __aarch64_ldclr4_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor4_relax() align(16) callconv(.naked) void { fn __aarch64_ldeor4_relax() align(16) callconv(.naked) void {
@ -1119,8 +1067,7 @@ fn __aarch64_ldeor4_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset4_relax() align(16) callconv(.naked) void { fn __aarch64_ldset4_relax() align(16) callconv(.naked) void {
@ -1140,8 +1087,7 @@ fn __aarch64_ldset4_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas4_acq() align(16) callconv(.naked) void { fn __aarch64_cas4_acq() align(16) callconv(.naked) void {
@ -1162,8 +1108,7 @@ fn __aarch64_cas4_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp4_acq() align(16) callconv(.naked) void { fn __aarch64_swp4_acq() align(16) callconv(.naked) void {
@ -1182,8 +1127,7 @@ fn __aarch64_swp4_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd4_acq() align(16) callconv(.naked) void { fn __aarch64_ldadd4_acq() align(16) callconv(.naked) void {
@ -1203,8 +1147,7 @@ fn __aarch64_ldadd4_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr4_acq() align(16) callconv(.naked) void { fn __aarch64_ldclr4_acq() align(16) callconv(.naked) void {
@ -1224,8 +1167,7 @@ fn __aarch64_ldclr4_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor4_acq() align(16) callconv(.naked) void { fn __aarch64_ldeor4_acq() align(16) callconv(.naked) void {
@ -1245,8 +1187,7 @@ fn __aarch64_ldeor4_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset4_acq() align(16) callconv(.naked) void { fn __aarch64_ldset4_acq() align(16) callconv(.naked) void {
@ -1266,8 +1207,7 @@ fn __aarch64_ldset4_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas4_rel() align(16) callconv(.naked) void { fn __aarch64_cas4_rel() align(16) callconv(.naked) void {
@ -1288,8 +1228,7 @@ fn __aarch64_cas4_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp4_rel() align(16) callconv(.naked) void { fn __aarch64_swp4_rel() align(16) callconv(.naked) void {
@ -1308,8 +1247,7 @@ fn __aarch64_swp4_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd4_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd4_rel() align(16) callconv(.naked) void {
@ -1329,8 +1267,7 @@ fn __aarch64_ldadd4_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr4_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr4_rel() align(16) callconv(.naked) void {
@ -1350,8 +1287,7 @@ fn __aarch64_ldclr4_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor4_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor4_rel() align(16) callconv(.naked) void {
@ -1371,8 +1307,7 @@ fn __aarch64_ldeor4_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset4_rel() align(16) callconv(.naked) void { fn __aarch64_ldset4_rel() align(16) callconv(.naked) void {
@ -1392,8 +1327,7 @@ fn __aarch64_ldset4_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas4_acq_rel() align(16) callconv(.naked) void { fn __aarch64_cas4_acq_rel() align(16) callconv(.naked) void {
@ -1414,8 +1348,7 @@ fn __aarch64_cas4_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp4_acq_rel() align(16) callconv(.naked) void { fn __aarch64_swp4_acq_rel() align(16) callconv(.naked) void {
@ -1434,8 +1367,7 @@ fn __aarch64_swp4_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd4_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd4_acq_rel() align(16) callconv(.naked) void {
@ -1455,8 +1387,7 @@ fn __aarch64_ldadd4_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr4_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr4_acq_rel() align(16) callconv(.naked) void {
@ -1476,8 +1407,7 @@ fn __aarch64_ldclr4_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor4_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor4_acq_rel() align(16) callconv(.naked) void {
@ -1497,8 +1427,7 @@ fn __aarch64_ldeor4_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset4_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldset4_acq_rel() align(16) callconv(.naked) void {
@ -1518,8 +1447,7 @@ fn __aarch64_ldset4_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas8_relax() align(16) callconv(.naked) void { fn __aarch64_cas8_relax() align(16) callconv(.naked) void {
@ -1540,8 +1468,7 @@ fn __aarch64_cas8_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp8_relax() align(16) callconv(.naked) void { fn __aarch64_swp8_relax() align(16) callconv(.naked) void {
@ -1560,8 +1487,7 @@ fn __aarch64_swp8_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd8_relax() align(16) callconv(.naked) void { fn __aarch64_ldadd8_relax() align(16) callconv(.naked) void {
@ -1581,8 +1507,7 @@ fn __aarch64_ldadd8_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr8_relax() align(16) callconv(.naked) void { fn __aarch64_ldclr8_relax() align(16) callconv(.naked) void {
@ -1602,8 +1527,7 @@ fn __aarch64_ldclr8_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor8_relax() align(16) callconv(.naked) void { fn __aarch64_ldeor8_relax() align(16) callconv(.naked) void {
@ -1623,8 +1547,7 @@ fn __aarch64_ldeor8_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset8_relax() align(16) callconv(.naked) void { fn __aarch64_ldset8_relax() align(16) callconv(.naked) void {
@ -1644,8 +1567,7 @@ fn __aarch64_ldset8_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas8_acq() align(16) callconv(.naked) void { fn __aarch64_cas8_acq() align(16) callconv(.naked) void {
@ -1666,8 +1588,7 @@ fn __aarch64_cas8_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp8_acq() align(16) callconv(.naked) void { fn __aarch64_swp8_acq() align(16) callconv(.naked) void {
@ -1686,8 +1607,7 @@ fn __aarch64_swp8_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd8_acq() align(16) callconv(.naked) void { fn __aarch64_ldadd8_acq() align(16) callconv(.naked) void {
@ -1707,8 +1627,7 @@ fn __aarch64_ldadd8_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr8_acq() align(16) callconv(.naked) void { fn __aarch64_ldclr8_acq() align(16) callconv(.naked) void {
@ -1728,8 +1647,7 @@ fn __aarch64_ldclr8_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor8_acq() align(16) callconv(.naked) void { fn __aarch64_ldeor8_acq() align(16) callconv(.naked) void {
@ -1749,8 +1667,7 @@ fn __aarch64_ldeor8_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset8_acq() align(16) callconv(.naked) void { fn __aarch64_ldset8_acq() align(16) callconv(.naked) void {
@ -1770,8 +1687,7 @@ fn __aarch64_ldset8_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas8_rel() align(16) callconv(.naked) void { fn __aarch64_cas8_rel() align(16) callconv(.naked) void {
@ -1792,8 +1708,7 @@ fn __aarch64_cas8_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp8_rel() align(16) callconv(.naked) void { fn __aarch64_swp8_rel() align(16) callconv(.naked) void {
@ -1812,8 +1727,7 @@ fn __aarch64_swp8_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd8_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd8_rel() align(16) callconv(.naked) void {
@ -1833,8 +1747,7 @@ fn __aarch64_ldadd8_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr8_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr8_rel() align(16) callconv(.naked) void {
@ -1854,8 +1767,7 @@ fn __aarch64_ldclr8_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor8_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor8_rel() align(16) callconv(.naked) void {
@ -1875,8 +1787,7 @@ fn __aarch64_ldeor8_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset8_rel() align(16) callconv(.naked) void { fn __aarch64_ldset8_rel() align(16) callconv(.naked) void {
@ -1896,8 +1807,7 @@ fn __aarch64_ldset8_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas8_acq_rel() align(16) callconv(.naked) void { fn __aarch64_cas8_acq_rel() align(16) callconv(.naked) void {
@ -1918,8 +1828,7 @@ fn __aarch64_cas8_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_swp8_acq_rel() align(16) callconv(.naked) void { fn __aarch64_swp8_acq_rel() align(16) callconv(.naked) void {
@ -1938,8 +1847,7 @@ fn __aarch64_swp8_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldadd8_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldadd8_acq_rel() align(16) callconv(.naked) void {
@ -1959,8 +1867,7 @@ fn __aarch64_ldadd8_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldclr8_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldclr8_acq_rel() align(16) callconv(.naked) void {
@ -1980,8 +1887,7 @@ fn __aarch64_ldclr8_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldeor8_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldeor8_acq_rel() align(16) callconv(.naked) void {
@ -2001,8 +1907,7 @@ fn __aarch64_ldeor8_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_ldset8_acq_rel() align(16) callconv(.naked) void { fn __aarch64_ldset8_acq_rel() align(16) callconv(.naked) void {
@ -2022,8 +1927,7 @@ fn __aarch64_ldset8_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas16_relax() align(16) callconv(.naked) void { fn __aarch64_cas16_relax() align(16) callconv(.naked) void {
@ -2046,8 +1950,7 @@ fn __aarch64_cas16_relax() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas16_acq() align(16) callconv(.naked) void { fn __aarch64_cas16_acq() align(16) callconv(.naked) void {
@ -2070,8 +1973,7 @@ fn __aarch64_cas16_acq() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas16_rel() align(16) callconv(.naked) void { fn __aarch64_cas16_rel() align(16) callconv(.naked) void {
@ -2094,8 +1996,7 @@ fn __aarch64_cas16_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }
fn __aarch64_cas16_acq_rel() align(16) callconv(.naked) void { fn __aarch64_cas16_acq_rel() align(16) callconv(.naked) void {
@ -2118,8 +2019,7 @@ fn __aarch64_cas16_acq_rel() align(16) callconv(.naked) void {
\\ ret \\ ret
: :
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics), : [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory" : .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
);
unreachable; unreachable;
} }

View File

@ -142,8 +142,7 @@ pub fn __aeabi_uidivmod() callconv(.naked) void {
\\ pop {pc} \\ pop {pc}
: :
: [__udivmodsi4] "X" (&__udivmodsi4), : [__udivmodsi4] "X" (&__udivmodsi4),
: "memory" : .{ .memory = true });
);
unreachable; unreachable;
} }
@ -162,8 +161,7 @@ pub fn __aeabi_uldivmod() callconv(.naked) void {
\\ pop {r4, pc} \\ pop {r4, pc}
: :
: [__udivmoddi4] "X" (&__udivmoddi4), : [__udivmoddi4] "X" (&__udivmoddi4),
: "memory" : .{ .memory = true });
);
unreachable; unreachable;
} }
@ -180,8 +178,7 @@ pub fn __aeabi_idivmod() callconv(.naked) void {
\\ pop {pc} \\ pop {pc}
: :
: [__divmodsi4] "X" (&__divmodsi4), : [__divmodsi4] "X" (&__divmodsi4),
: "memory" : .{ .memory = true });
);
unreachable; unreachable;
} }
@ -200,8 +197,7 @@ pub fn __aeabi_ldivmod() callconv(.naked) void {
\\ pop {r4, pc} \\ pop {r4, pc}
: :
: [__divmoddi4] "X" (&__divmoddi4), : [__divmoddi4] "X" (&__divmoddi4),
: "memory" : .{ .memory = true });
);
unreachable; unreachable;
} }

View File

@ -71,8 +71,7 @@ const SpinlockTable = struct {
break :flag asm volatile ("ldstub [%[addr]], %[flag]" break :flag asm volatile ("ldstub [%[addr]], %[flag]"
: [flag] "=r" (-> @TypeOf(self.v)), : [flag] "=r" (-> @TypeOf(self.v)),
: [addr] "r" (&self.v), : [addr] "r" (&self.v),
: "memory" : .{ .memory = true });
);
} else flag: { } else flag: {
break :flag @atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .acquire); break :flag @atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .acquire);
}; };
@ -88,8 +87,7 @@ const SpinlockTable = struct {
_ = asm volatile ("clrb [%[addr]]" _ = asm volatile ("clrb [%[addr]]"
: :
: [addr] "r" (&self.v), : [addr] "r" (&self.v),
: "memory" : .{ .memory = true });
);
} else { } else {
@atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .release); @atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .release);
} }

View File

@ -103,8 +103,7 @@ fn clear_cache(start: usize, end: usize) callconv(.c) void {
: [_] "{$2}" (165), // nr = SYS_sysarch : [_] "{$2}" (165), // nr = SYS_sysarch
[_] "{$4}" (0), // op = MIPS_CACHEFLUSH [_] "{$4}" (0), // op = MIPS_CACHEFLUSH
[_] "{$5}" (&cfa), // args = &cfa [_] "{$5}" (&cfa), // args = &cfa
: "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r2 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
exportIt(); exportIt();
} else if (mips and os == .openbsd) { } else if (mips and os == .openbsd) {
// TODO // TODO

View File

@ -793,6 +793,8 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
try expr(w, scope, parent_decl, full.ast.template); try expr(w, scope, parent_decl, full.ast.template);
}, },
.asm_legacy => {},
.builtin_call_two, .builtin_call_two,
.builtin_call_two_comma, .builtin_call_two_comma,
.builtin_call, .builtin_call,

View File

@ -16,10 +16,10 @@
License along with the GNU C Library; if not, see License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */ <https://www.gnu.org/licenses/>. */
// zig patch: sys/single_threaded.h header was added in glibc 2.35 // zig patch: sys/single_threaded.h header was added in glibc 2.32
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 35 #if __GLIBC__ == 2 && __GLIBC_MINOR__ < 32
#error "sys/single_threaded.h did not exist before glibc 2.35" #error "sys/single_threaded.h did not exist before glibc 2.32"
#endif /* error for glibc before 2.35 */ #endif /* error for glibc before 2.32 */
#ifndef _SYS_SINGLE_THREADED_H #ifndef _SYS_SINGLE_THREADED_H
#define _SYS_SINGLE_THREADED_H #define _SYS_SINGLE_THREADED_H

View File

@ -419,6 +419,7 @@ pub const Manifest = struct {
fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?fs.File, max_file_size: ?usize) usize { fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?fs.File, max_file_size: ?usize) usize {
const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{}); const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{});
if (gop.found_existing) { if (gop.found_existing) {
self.cache.gpa.free(prefixed_path.sub_path);
gop.key_ptr.updateMaxSize(max_file_size); gop.key_ptr.updateMaxSize(max_file_size);
gop.key_ptr.updateHandle(handle); gop.key_ptr.updateHandle(handle);
return gop.index; return gop.index;

View File

@ -464,32 +464,52 @@ pub fn writeVecAll(w: *Writer, data: [][]const u8) Error!void {
/// The `data` parameter is mutable because this function needs to mutate the /// The `data` parameter is mutable because this function needs to mutate the
/// fields in order to handle partial writes from `VTable.writeSplat`. /// fields in order to handle partial writes from `VTable.writeSplat`.
/// `data` will be restored to its original state before returning.
pub fn writeSplatAll(w: *Writer, data: [][]const u8, splat: usize) Error!void { pub fn writeSplatAll(w: *Writer, data: [][]const u8, splat: usize) Error!void {
var index: usize = 0; var index: usize = 0;
var truncate: usize = 0; var truncate: usize = 0;
var remaining_splat = splat;
while (index + 1 < data.len) { while (index + 1 < data.len) {
{ {
const untruncated = data[index]; const untruncated = data[index];
data[index] = untruncated[truncate..]; data[index] = untruncated[truncate..];
defer data[index] = untruncated; defer data[index] = untruncated;
truncate += try w.writeSplat(data[index..], remaining_splat); truncate += try w.writeSplat(data[index..], splat);
} }
while (truncate >= data[index].len) { while (truncate >= data[index].len and index + 1 < data.len) {
if (index + 1 < data.len) { truncate -= data[index].len;
truncate -= data[index].len; index += 1;
index += 1;
} else {
const last = data[data.len - 1];
remaining_splat -= @divExact(truncate, last.len);
while (remaining_splat > 0) {
const n = try w.writeSplat(data[data.len - 1 ..][0..1], remaining_splat);
remaining_splat -= @divExact(n, last.len);
}
return;
}
} }
} }
// Deal with any left over splats
if (data.len != 0 and truncate < data[index].len * splat) {
std.debug.assert(index == data.len - 1);
var remaining_splat = splat;
while (true) {
remaining_splat -= truncate / data[index].len;
truncate %= data[index].len;
if (remaining_splat == 0) break;
truncate += try w.writeSplat(&.{ data[index][truncate..], data[index] }, remaining_splat - 1);
}
}
}
test writeSplatAll {
var aw: Writer.Allocating = .init(testing.allocator);
defer aw.deinit();
var buffers = [_][]const u8{ "ba", "na" };
try aw.writer.writeSplatAll(&buffers, 2);
try testing.expectEqualStrings("banana", aw.writer.buffered());
}
test "writeSplatAll works with a single buffer" {
var aw: Writer.Allocating = .init(testing.allocator);
defer aw.deinit();
var message: [1][]const u8 = .{"hello"};
try aw.writer.writeSplatAll(&message, 3);
try testing.expectEqualStrings("hellohellohello", aw.writer.buffered());
} }
pub fn write(w: *Writer, bytes: []const u8) Error!usize { pub fn write(w: *Writer, bytes: []const u8) Error!usize {
@ -763,6 +783,14 @@ pub fn splatByteAll(w: *Writer, byte: u8, n: usize) Error!void {
while (remaining > 0) remaining -= try w.splatByte(byte, remaining); while (remaining > 0) remaining -= try w.splatByte(byte, remaining);
} }
test splatByteAll {
var aw: Writer.Allocating = .init(testing.allocator);
defer aw.deinit();
try aw.writer.splatByteAll('7', 45);
try testing.expectEqualStrings("7" ** 45, aw.writer.buffered());
}
/// Writes the same byte many times, allowing short writes. /// Writes the same byte many times, allowing short writes.
/// ///
/// Does maximum of one underlying `VTable.drain`. /// Does maximum of one underlying `VTable.drain`.
@ -778,13 +806,21 @@ pub fn splatBytesAll(w: *Writer, bytes: []const u8, splat: usize) Error!void {
while (remaining_bytes > 0) { while (remaining_bytes > 0) {
const leftover = remaining_bytes % bytes.len; const leftover = remaining_bytes % bytes.len;
const buffers: [2][]const u8 = .{ bytes[bytes.len - leftover ..], bytes }; const buffers: [2][]const u8 = .{ bytes[bytes.len - leftover ..], bytes };
remaining_bytes -= try w.splatBytes(&buffers, splat); remaining_bytes -= try w.writeSplat(&buffers, splat);
} }
} }
test splatBytesAll {
var aw: Writer.Allocating = .init(testing.allocator);
defer aw.deinit();
try aw.writer.splatBytesAll("hello", 3);
try testing.expectEqualStrings("hellohellohello", aw.writer.buffered());
}
/// Writes the same slice many times, allowing short writes. /// Writes the same slice many times, allowing short writes.
/// ///
/// Does maximum of one underlying `VTable.writeSplat`. /// Does maximum of one underlying `VTable.drain`.
pub fn splatBytes(w: *Writer, bytes: []const u8, n: usize) Error!usize { pub fn splatBytes(w: *Writer, bytes: []const u8, n: usize) Error!usize {
return writeSplat(w, &.{bytes}, n); return writeSplat(w, &.{bytes}, n);
} }

View File

@ -1199,8 +1199,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.x86_64 => asm volatile ( .x86_64 => asm volatile (
\\ movq $11, %%rax # SYS_munmap \\ movq $11, %%rax # SYS_munmap
\\ syscall \\ syscall
@ -1222,8 +1221,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.aarch64, .aarch64_be => asm volatile ( .aarch64, .aarch64_be => asm volatile (
\\ mov x8, #215 // SYS_munmap \\ mov x8, #215 // SYS_munmap
\\ mov x0, %[ptr] \\ mov x0, %[ptr]
@ -1235,8 +1233,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.hexagon => asm volatile ( .hexagon => asm volatile (
\\ r6 = #215 // SYS_munmap \\ r6 = #215 // SYS_munmap
\\ r0 = %[ptr] \\ r0 = %[ptr]
@ -1248,8 +1245,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
// We set `sp` to the address of the current function as a workaround for a Linux // We set `sp` to the address of the current function as a workaround for a Linux
// kernel bug that caused syscalls to return EFAULT if the stack pointer is invalid. // kernel bug that caused syscalls to return EFAULT if the stack pointer is invalid.
// The bug was introduced in 46e12c07b3b9603c60fc1d421ff18618241cb081 and fixed in // The bug was introduced in 46e12c07b3b9603c60fc1d421ff18618241cb081 and fixed in
@ -1266,8 +1262,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.mips64, .mips64el => asm volatile ( .mips64, .mips64el => asm volatile (
\\ li $2, 5011 # SYS_munmap \\ li $2, 5011 # SYS_munmap
\\ move $4, %[ptr] \\ move $4, %[ptr]
@ -1279,8 +1274,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.powerpc, .powerpcle, .powerpc64, .powerpc64le => asm volatile ( .powerpc, .powerpcle, .powerpc64, .powerpc64le => asm volatile (
\\ li 0, 91 # SYS_munmap \\ li 0, 91 # SYS_munmap
\\ mr 3, %[ptr] \\ mr 3, %[ptr]
@ -1293,8 +1287,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.riscv32, .riscv64 => asm volatile ( .riscv32, .riscv64 => asm volatile (
\\ li a7, 215 # SYS_munmap \\ li a7, 215 # SYS_munmap
\\ mv a0, %[ptr] \\ mv a0, %[ptr]
@ -1306,8 +1299,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.s390x => asm volatile ( .s390x => asm volatile (
\\ lgr %%r2, %[ptr] \\ lgr %%r2, %[ptr]
\\ lgr %%r3, %[len] \\ lgr %%r3, %[len]
@ -1317,8 +1309,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.sparc => asm volatile ( .sparc => asm volatile (
\\ # See sparc64 comments below. \\ # See sparc64 comments below.
\\ 1: \\ 1:
@ -1339,8 +1330,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.sparc64 => asm volatile ( .sparc64 => asm volatile (
\\ # SPARCs really don't like it when active stack frames \\ # SPARCs really don't like it when active stack frames
\\ # is unmapped (it will result in a segfault), so we \\ # is unmapped (it will result in a segfault), so we
@ -1366,8 +1356,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
.loongarch32, .loongarch64 => asm volatile ( .loongarch32, .loongarch64 => asm volatile (
\\ or $a0, $zero, %[ptr] \\ or $a0, $zero, %[ptr]
\\ or $a1, $zero, %[len] \\ or $a1, $zero, %[len]
@ -1379,8 +1368,7 @@ const LinuxThreadImpl = struct {
: :
: [ptr] "r" (@intFromPtr(self.mapped.ptr)), : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len), [len] "r" (self.mapped.len),
: "memory" : .{ .memory = true }),
),
else => |cpu_arch| @compileError("Unsupported linux arch: " ++ @tagName(cpu_arch)), else => |cpu_arch| @compileError("Unsupported linux arch: " ++ @tagName(cpu_arch)),
} }
unreachable; unreachable;

View File

@ -1,6 +1,10 @@
//! Types and values provided by the Zig language. //! Types and values provided by the Zig language.
const builtin = @import("builtin"); const builtin = @import("builtin");
const std = @import("std.zig");
const root = @import("root");
pub const assembly = @import("builtin/assembly.zig");
/// `explicit_subsystem` is missing when the subsystem is automatically detected, /// `explicit_subsystem` is missing when the subsystem is automatically detected,
/// so Zig standard library has the subsystem detection logic here. This should generally be /// so Zig standard library has the subsystem detection logic here. This should generally be
@ -1102,6 +1106,3 @@ pub noinline fn returnError() void {
st.instruction_addresses[st.index] = @returnAddress(); st.instruction_addresses[st.index] = @returnAddress();
st.index += 1; st.index += 1;
} }
const std = @import("std.zig");
const root = @import("root");

2205
lib/std/builtin/assembly.zig Normal file

File diff suppressed because it is too large Load Diff

View File

@ -235,8 +235,7 @@ fn Sha2x32(comptime iv: Iv32, digest_bits: comptime_int) type {
: [_] "0" (x), : [_] "0" (x),
[_] "1" (y), [_] "1" (y),
[w] "w" (w), [w] "w" (w),
: "v0" : .{ .v0 = true });
);
} }
d.s[0..4].* = x +% @as(V4u32, d.s[0..4].*); d.s[0..4].* = x +% @as(V4u32, d.s[0..4].*);

View File

@ -785,7 +785,7 @@ pub const StackIterator = struct {
"flushw" "flushw"
else else
"ta 3" // ST_FLUSH_WINDOWS "ta 3" // ST_FLUSH_WINDOWS
::: "memory"); ::: .{ .memory = true });
} }
return StackIterator{ return StackIterator{

View File

@ -1547,8 +1547,7 @@ pub inline fn stripInstructionPtrAuthCode(ptr: usize) usize {
\\mov x30, x16 \\mov x30, x16
: [ret] "={x15}" (-> usize), : [ret] "={x15}" (-> usize),
: [ptr] "{x15}" (ptr), : [ptr] "{x15}" (ptr),
: "x16" : .{ .x16 = true });
);
} }
return ptr; return ptr;

View File

@ -4497,8 +4497,7 @@ pub fn doNotOptimizeAway(val: anytype) void {
asm volatile ("" asm volatile (""
: :
: [val] "m" (val), : [val] "m" (val),
: "memory" : .{ .memory = true });
);
} }
}, },
.array => { .array => {

View File

@ -18,8 +18,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0" return asm volatile ("svc #0"
: [ret] "={x0}" (-> usize), : [ret] "={x0}" (-> usize),
: [number] "{x8}" (@intFromEnum(number)), : [number] "{x8}" (@intFromEnum(number)),
: "memory", "cc" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -27,8 +26,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={x0}" (-> usize), : [ret] "={x0}" (-> usize),
: [number] "{x8}" (@intFromEnum(number)), : [number] "{x8}" (@intFromEnum(number)),
[arg1] "{x0}" (arg1), [arg1] "{x0}" (arg1),
: "memory", "cc" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -37,8 +35,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{x8}" (@intFromEnum(number)), : [number] "{x8}" (@intFromEnum(number)),
[arg1] "{x0}" (arg1), [arg1] "{x0}" (arg1),
[arg2] "{x1}" (arg2), [arg2] "{x1}" (arg2),
: "memory", "cc" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -48,8 +45,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{x0}" (arg1), [arg1] "{x0}" (arg1),
[arg2] "{x1}" (arg2), [arg2] "{x1}" (arg2),
[arg3] "{x2}" (arg3), [arg3] "{x2}" (arg3),
: "memory", "cc" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -60,8 +56,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{x1}" (arg2), [arg2] "{x1}" (arg2),
[arg3] "{x2}" (arg3), [arg3] "{x2}" (arg3),
[arg4] "{x3}" (arg4), [arg4] "{x3}" (arg4),
: "memory", "cc" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -73,8 +68,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{x2}" (arg3), [arg3] "{x2}" (arg3),
[arg4] "{x3}" (arg4), [arg4] "{x3}" (arg4),
[arg5] "{x4}" (arg5), [arg5] "{x4}" (arg5),
: "memory", "cc" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -95,8 +89,7 @@ pub fn syscall6(
[arg4] "{x3}" (arg4), [arg4] "{x3}" (arg4),
[arg5] "{x4}" (arg5), [arg5] "{x4}" (arg5),
[arg6] "{x5}" (arg6), [arg6] "{x5}" (arg6),
: "memory", "cc" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -148,14 +141,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ svc #0 \\ svc #0
: :
: [number] "i" (@intFromEnum(SYS.rt_sigreturn)), : [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
: "memory", "cc" : .{ .memory = true }),
),
else => asm volatile ( else => asm volatile (
\\ svc #0 \\ svc #0
: :
: [number] "{x8}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{x8}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory", "cc" : .{ .memory = true }),
),
} }
} }

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0" return asm volatile ("svc #0"
: [ret] "={r0}" (-> usize), : [ret] "={r0}" (-> usize),
: [number] "{r7}" (@intFromEnum(number)), : [number] "{r7}" (@intFromEnum(number)),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r0}" (-> usize), : [ret] "={r0}" (-> usize),
: [number] "{r7}" (@intFromEnum(number)), : [number] "{r7}" (@intFromEnum(number)),
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -36,8 +34,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{r7}" (@intFromEnum(number)), : [number] "{r7}" (@intFromEnum(number)),
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -47,8 +44,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -59,8 +55,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -72,8 +67,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5), [arg5] "{r4}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -94,8 +88,7 @@ pub fn syscall6(
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5), [arg5] "{r4}" (arg5),
[arg6] "{r5}" (arg6), [arg6] "{r5}" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -141,14 +134,12 @@ pub fn restore() callconv(.naked) noreturn {
\\ svc #0 \\ svc #0
: :
: [number] "I" (@intFromEnum(SYS.sigreturn)), : [number] "I" (@intFromEnum(SYS.sigreturn)),
: "memory" : .{ .memory = true }),
),
else => asm volatile ( else => asm volatile (
\\ svc #0 \\ svc #0
: :
: [number] "{r7}" (@intFromEnum(SYS.sigreturn)), : [number] "{r7}" (@intFromEnum(SYS.sigreturn)),
: "memory" : .{ .memory = true }),
),
} }
} }
@ -159,14 +150,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ svc #0 \\ svc #0
: :
: [number] "I" (@intFromEnum(SYS.rt_sigreturn)), : [number] "I" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true }),
),
else => asm volatile ( else => asm volatile (
\\ svc #0 \\ svc #0
: :
: [number] "{r7}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{r7}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true }),
),
} }
} }

View File

@ -15,8 +15,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("trap0(#1)" return asm volatile ("trap0(#1)"
: [ret] "={r0}" (-> usize), : [ret] "={r0}" (-> usize),
: [number] "{r6}" (@intFromEnum(number)), : [number] "{r6}" (@intFromEnum(number)),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -24,8 +23,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r0}" (-> usize), : [ret] "={r0}" (-> usize),
: [number] "{r6}" (@intFromEnum(number)), : [number] "{r6}" (@intFromEnum(number)),
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -34,8 +32,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{r6}" (@intFromEnum(number)), : [number] "{r6}" (@intFromEnum(number)),
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -45,8 +42,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -57,8 +53,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -70,8 +65,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5), [arg5] "{r4}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -92,8 +86,7 @@ pub fn syscall6(
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5), [arg5] "{r4}" (arg5),
[arg6] "{r5}" (arg6), [arg6] "{r5}" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -142,8 +135,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ trap0(#0) \\ trap0(#0)
: :
: [number] "{r6}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{r6}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
\\ syscall 0 \\ syscall 0
: [ret] "={$r4}" (-> usize), : [ret] "={$r4}" (-> usize),
: [number] "{$r11}" (@intFromEnum(number)), : [number] "{$r11}" (@intFromEnum(number)),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -27,8 +26,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={$r4}" (-> usize), : [ret] "={$r4}" (-> usize),
: [number] "{$r11}" (@intFromEnum(number)), : [number] "{$r11}" (@intFromEnum(number)),
[arg1] "{$r4}" (arg1), [arg1] "{$r4}" (arg1),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -38,8 +36,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{$r11}" (@intFromEnum(number)), : [number] "{$r11}" (@intFromEnum(number)),
[arg1] "{$r4}" (arg1), [arg1] "{$r4}" (arg1),
[arg2] "{$r5}" (arg2), [arg2] "{$r5}" (arg2),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -50,8 +47,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{$r4}" (arg1), [arg1] "{$r4}" (arg1),
[arg2] "{$r5}" (arg2), [arg2] "{$r5}" (arg2),
[arg3] "{$r6}" (arg3), [arg3] "{$r6}" (arg3),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -63,8 +59,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{$r5}" (arg2), [arg2] "{$r5}" (arg2),
[arg3] "{$r6}" (arg3), [arg3] "{$r6}" (arg3),
[arg4] "{$r7}" (arg4), [arg4] "{$r7}" (arg4),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -77,8 +72,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{$r6}" (arg3), [arg3] "{$r6}" (arg3),
[arg4] "{$r7}" (arg4), [arg4] "{$r7}" (arg4),
[arg5] "{$r8}" (arg5), [arg5] "{$r8}" (arg5),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -100,8 +94,7 @@ pub fn syscall6(
[arg4] "{$r7}" (arg4), [arg4] "{$r7}" (arg4),
[arg5] "{$r8}" (arg5), [arg5] "{$r8}" (arg5),
[arg6] "{$r9}" (arg6), [arg6] "{$r9}" (arg6),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -150,8 +143,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall 0 \\ syscall 0
: :
: [number] "r" (@intFromEnum(SYS.rt_sigreturn)), : [number] "r" (@intFromEnum(SYS.rt_sigreturn)),
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory" : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true });
);
} }
pub const msghdr = extern struct { pub const msghdr = extern struct {

View File

@ -15,8 +15,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("trap #0" return asm volatile ("trap #0"
: [ret] "={d0}" (-> usize), : [ret] "={d0}" (-> usize),
: [number] "{d0}" (@intFromEnum(number)), : [number] "{d0}" (@intFromEnum(number)),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -24,8 +23,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={d0}" (-> usize), : [ret] "={d0}" (-> usize),
: [number] "{d0}" (@intFromEnum(number)), : [number] "{d0}" (@intFromEnum(number)),
[arg1] "{d1}" (arg1), [arg1] "{d1}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -34,8 +32,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{d0}" (@intFromEnum(number)), : [number] "{d0}" (@intFromEnum(number)),
[arg1] "{d1}" (arg1), [arg1] "{d1}" (arg1),
[arg2] "{d2}" (arg2), [arg2] "{d2}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -45,8 +42,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{d1}" (arg1), [arg1] "{d1}" (arg1),
[arg2] "{d2}" (arg2), [arg2] "{d2}" (arg2),
[arg3] "{d3}" (arg3), [arg3] "{d3}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -57,8 +53,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{d2}" (arg2), [arg2] "{d2}" (arg2),
[arg3] "{d3}" (arg3), [arg3] "{d3}" (arg3),
[arg4] "{d4}" (arg4), [arg4] "{d4}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -70,8 +65,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{d3}" (arg3), [arg3] "{d3}" (arg3),
[arg4] "{d4}" (arg4), [arg4] "{d4}" (arg4),
[arg5] "{d5}" (arg5), [arg5] "{d5}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -92,8 +86,7 @@ pub fn syscall6(
[arg4] "{d4}" (arg4), [arg4] "{d4}" (arg4),
[arg5] "{d5}" (arg5), [arg5] "{d5}" (arg5),
[arg6] "{a0}" (arg6), [arg6] "{a0}" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -155,8 +148,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
asm volatile ("trap #0" asm volatile ("trap #0"
: :
: [number] "{d0}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{d0}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -21,8 +21,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1: \\ 1:
: [ret] "={$2}" (-> usize), : [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(number)), : [number] "{$2}" (@intFromEnum(number)),
: "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall_pipe(fd: *[2]i32) usize { pub fn syscall_pipe(fd: *[2]i32) usize {
@ -41,8 +40,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
: [ret] "={$2}" (-> usize), : [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(SYS.pipe)), : [number] "{$2}" (@intFromEnum(SYS.pipe)),
[fd] "{$4}" (fd), [fd] "{$4}" (fd),
: "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -55,8 +53,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={$2}" (-> usize), : [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(number)), : [number] "{$2}" (@intFromEnum(number)),
[arg1] "{$4}" (arg1), [arg1] "{$4}" (arg1),
: "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -70,8 +67,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{$2}" (@intFromEnum(number)), : [number] "{$2}" (@intFromEnum(number)),
[arg1] "{$4}" (arg1), [arg1] "{$4}" (arg1),
[arg2] "{$5}" (arg2), [arg2] "{$5}" (arg2),
: "$1", "$3", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -86,8 +82,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{$4}" (arg1), [arg1] "{$4}" (arg1),
[arg2] "{$5}" (arg2), [arg2] "{$5}" (arg2),
[arg3] "{$6}" (arg3), [arg3] "{$6}" (arg3),
: "$1", "$3", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -103,8 +98,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{$5}" (arg2), [arg2] "{$5}" (arg2),
[arg3] "{$6}" (arg3), [arg3] "{$6}" (arg3),
[arg4] "{$7}" (arg4), [arg4] "{$7}" (arg4),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -125,8 +119,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{$6}" (arg3), [arg3] "{$6}" (arg3),
[arg4] "{$7}" (arg4), [arg4] "{$7}" (arg4),
[arg5] "r" (arg5), [arg5] "r" (arg5),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
// NOTE: The o32 calling convention requires the callee to reserve 16 bytes for // NOTE: The o32 calling convention requires the callee to reserve 16 bytes for
@ -160,8 +153,7 @@ pub fn syscall6(
[arg4] "{$7}" (arg4), [arg4] "{$7}" (arg4),
[arg5] "r" (arg5), [arg5] "r" (arg5),
[arg6] "r" (arg6), [arg6] "r" (arg6),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall7( pub fn syscall7(
@ -195,8 +187,7 @@ pub fn syscall7(
[arg5] "r" (arg5), [arg5] "r" (arg5),
[arg6] "r" (arg6), [arg6] "r" (arg6),
[arg7] "r" (arg7), [arg7] "r" (arg7),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -255,8 +246,7 @@ pub fn restore() callconv(.naked) noreturn {
\\ syscall \\ syscall
: :
: [number] "{$2}" (@intFromEnum(SYS.sigreturn)), : [number] "{$2}" (@intFromEnum(SYS.sigreturn)),
: "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn restore_rt() callconv(.naked) noreturn { pub fn restore_rt() callconv(.naked) noreturn {
@ -264,8 +254,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall \\ syscall
: :
: [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)),
: "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -21,8 +21,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1: \\ 1:
: [ret] "={$2}" (-> usize), : [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(number)), : [number] "{$2}" (@intFromEnum(number)),
: "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall_pipe(fd: *[2]i32) usize { pub fn syscall_pipe(fd: *[2]i32) usize {
@ -41,8 +40,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
: [ret] "={$2}" (-> usize), : [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(SYS.pipe)), : [number] "{$2}" (@intFromEnum(SYS.pipe)),
[fd] "{$4}" (fd), [fd] "{$4}" (fd),
: "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -56,8 +54,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={$2}" (-> usize), : [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(number)), : [number] "{$2}" (@intFromEnum(number)),
[arg1] "{$4}" (arg1), [arg1] "{$4}" (arg1),
: "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -71,8 +68,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{$2}" (@intFromEnum(number)), : [number] "{$2}" (@intFromEnum(number)),
[arg1] "{$4}" (arg1), [arg1] "{$4}" (arg1),
[arg2] "{$5}" (arg2), [arg2] "{$5}" (arg2),
: "$1", "$3", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -87,8 +83,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{$4}" (arg1), [arg1] "{$4}" (arg1),
[arg2] "{$5}" (arg2), [arg2] "{$5}" (arg2),
[arg3] "{$6}" (arg3), [arg3] "{$6}" (arg3),
: "$1", "$3", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -104,8 +99,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{$5}" (arg2), [arg2] "{$5}" (arg2),
[arg3] "{$6}" (arg3), [arg3] "{$6}" (arg3),
[arg4] "{$7}" (arg4), [arg4] "{$7}" (arg4),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -122,8 +116,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{$6}" (arg3), [arg3] "{$6}" (arg3),
[arg4] "{$7}" (arg4), [arg4] "{$7}" (arg4),
[arg5] "{$8}" (arg5), [arg5] "{$8}" (arg5),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -149,8 +142,7 @@ pub fn syscall6(
[arg4] "{$7}" (arg4), [arg4] "{$7}" (arg4),
[arg5] "{$8}" (arg5), [arg5] "{$8}" (arg5),
[arg6] "{$9}" (arg6), [arg6] "{$9}" (arg6),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn syscall7( pub fn syscall7(
@ -178,8 +170,7 @@ pub fn syscall7(
[arg5] "{$8}" (arg5), [arg5] "{$8}" (arg5),
[arg6] "{$9}" (arg6), [arg6] "{$9}" (arg6),
[arg7] "{$10}" (arg7), [arg7] "{$10}" (arg7),
: "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -234,8 +225,7 @@ pub fn restore() callconv(.naked) noreturn {
\\ syscall \\ syscall
: :
: [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)),
: "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub fn restore_rt() callconv(.naked) noreturn { pub fn restore_rt() callconv(.naked) noreturn {
@ -243,8 +233,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall \\ syscall
: :
: [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)),
: "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -22,8 +22,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1: \\ 1:
: [ret] "={r3}" (-> usize), : [ret] "={r3}" (-> usize),
: [number] "{r0}" (@intFromEnum(number)), : [number] "{r0}" (@intFromEnum(number)),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -35,8 +34,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r3}" (-> usize), : [ret] "={r3}" (-> usize),
: [number] "{r0}" (@intFromEnum(number)), : [number] "{r0}" (@intFromEnum(number)),
[arg1] "{r3}" (arg1), [arg1] "{r3}" (arg1),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -49,8 +47,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{r0}" (@intFromEnum(number)), : [number] "{r0}" (@intFromEnum(number)),
[arg1] "{r3}" (arg1), [arg1] "{r3}" (arg1),
[arg2] "{r4}" (arg2), [arg2] "{r4}" (arg2),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -64,8 +61,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r3}" (arg1), [arg1] "{r3}" (arg1),
[arg2] "{r4}" (arg2), [arg2] "{r4}" (arg2),
[arg3] "{r5}" (arg3), [arg3] "{r5}" (arg3),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -80,8 +76,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r4}" (arg2), [arg2] "{r4}" (arg2),
[arg3] "{r5}" (arg3), [arg3] "{r5}" (arg3),
[arg4] "{r6}" (arg4), [arg4] "{r6}" (arg4),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -97,8 +92,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r5}" (arg3), [arg3] "{r5}" (arg3),
[arg4] "{r6}" (arg4), [arg4] "{r6}" (arg4),
[arg5] "{r7}" (arg5), [arg5] "{r7}" (arg5),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -123,8 +117,7 @@ pub fn syscall6(
[arg4] "{r6}" (arg4), [arg4] "{r6}" (arg4),
[arg5] "{r7}" (arg5), [arg5] "{r7}" (arg5),
[arg6] "{r8}" (arg6), [arg6] "{r8}" (arg6),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -204,8 +197,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ sc \\ sc
: :
: [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -22,8 +22,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1: \\ 1:
: [ret] "={r3}" (-> usize), : [ret] "={r3}" (-> usize),
: [number] "{r0}" (@intFromEnum(number)), : [number] "{r0}" (@intFromEnum(number)),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -35,8 +34,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r3}" (-> usize), : [ret] "={r3}" (-> usize),
: [number] "{r0}" (@intFromEnum(number)), : [number] "{r0}" (@intFromEnum(number)),
[arg1] "{r3}" (arg1), [arg1] "{r3}" (arg1),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -49,8 +47,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{r0}" (@intFromEnum(number)), : [number] "{r0}" (@intFromEnum(number)),
[arg1] "{r3}" (arg1), [arg1] "{r3}" (arg1),
[arg2] "{r4}" (arg2), [arg2] "{r4}" (arg2),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -64,8 +61,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r3}" (arg1), [arg1] "{r3}" (arg1),
[arg2] "{r4}" (arg2), [arg2] "{r4}" (arg2),
[arg3] "{r5}" (arg3), [arg3] "{r5}" (arg3),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -80,8 +76,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r4}" (arg2), [arg2] "{r4}" (arg2),
[arg3] "{r5}" (arg3), [arg3] "{r5}" (arg3),
[arg4] "{r6}" (arg4), [arg4] "{r6}" (arg4),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -97,8 +92,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r5}" (arg3), [arg3] "{r5}" (arg3),
[arg4] "{r6}" (arg4), [arg4] "{r6}" (arg4),
[arg5] "{r7}" (arg5), [arg5] "{r7}" (arg5),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -123,8 +117,7 @@ pub fn syscall6(
[arg4] "{r6}" (arg4), [arg4] "{r6}" (arg4),
[arg5] "{r7}" (arg5), [arg5] "{r7}" (arg5),
[arg6] "{r8}" (arg6), [arg6] "{r8}" (arg6),
: "memory", "cr0", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -189,8 +182,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ sc \\ sc
: :
: [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : .{ .memory = true, .cr0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("ecall" return asm volatile ("ecall"
: [ret] "={x10}" (-> usize), : [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)), : [number] "{x17}" (@intFromEnum(number)),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={x10}" (-> usize), : [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)), : [number] "{x17}" (@intFromEnum(number)),
[arg1] "{x10}" (arg1), [arg1] "{x10}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -36,8 +34,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{x17}" (@intFromEnum(number)), : [number] "{x17}" (@intFromEnum(number)),
[arg1] "{x10}" (arg1), [arg1] "{x10}" (arg1),
[arg2] "{x11}" (arg2), [arg2] "{x11}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -47,8 +44,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{x10}" (arg1), [arg1] "{x10}" (arg1),
[arg2] "{x11}" (arg2), [arg2] "{x11}" (arg2),
[arg3] "{x12}" (arg3), [arg3] "{x12}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -59,8 +55,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{x11}" (arg2), [arg2] "{x11}" (arg2),
[arg3] "{x12}" (arg3), [arg3] "{x12}" (arg3),
[arg4] "{x13}" (arg4), [arg4] "{x13}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -72,8 +67,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{x12}" (arg3), [arg3] "{x12}" (arg3),
[arg4] "{x13}" (arg4), [arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5), [arg5] "{x14}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -94,8 +88,7 @@ pub fn syscall6(
[arg4] "{x13}" (arg4), [arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5), [arg5] "{x14}" (arg5),
[arg6] "{x15}" (arg6), [arg6] "{x15}" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -149,8 +142,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ ecall \\ ecall
: :
: [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("ecall" return asm volatile ("ecall"
: [ret] "={x10}" (-> usize), : [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)), : [number] "{x17}" (@intFromEnum(number)),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={x10}" (-> usize), : [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)), : [number] "{x17}" (@intFromEnum(number)),
[arg1] "{x10}" (arg1), [arg1] "{x10}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -36,8 +34,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{x17}" (@intFromEnum(number)), : [number] "{x17}" (@intFromEnum(number)),
[arg1] "{x10}" (arg1), [arg1] "{x10}" (arg1),
[arg2] "{x11}" (arg2), [arg2] "{x11}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -47,8 +44,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{x10}" (arg1), [arg1] "{x10}" (arg1),
[arg2] "{x11}" (arg2), [arg2] "{x11}" (arg2),
[arg3] "{x12}" (arg3), [arg3] "{x12}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -59,8 +55,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{x11}" (arg2), [arg2] "{x11}" (arg2),
[arg3] "{x12}" (arg3), [arg3] "{x12}" (arg3),
[arg4] "{x13}" (arg4), [arg4] "{x13}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -72,8 +67,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{x12}" (arg3), [arg3] "{x12}" (arg3),
[arg4] "{x13}" (arg4), [arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5), [arg5] "{x14}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -94,8 +88,7 @@ pub fn syscall6(
[arg4] "{x13}" (arg4), [arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5), [arg5] "{x14}" (arg5),
[arg6] "{x15}" (arg6), [arg6] "{x15}" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -149,8 +142,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ ecall \\ ecall
: :
: [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("svc 0" return asm volatile ("svc 0"
: [ret] "={r2}" (-> usize), : [ret] "={r2}" (-> usize),
: [number] "{r1}" (@intFromEnum(number)), : [number] "{r1}" (@intFromEnum(number)),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r2}" (-> usize), : [ret] "={r2}" (-> usize),
: [number] "{r1}" (@intFromEnum(number)), : [number] "{r1}" (@intFromEnum(number)),
[arg1] "{r2}" (arg1), [arg1] "{r2}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -36,8 +34,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{r1}" (@intFromEnum(number)), : [number] "{r1}" (@intFromEnum(number)),
[arg1] "{r2}" (arg1), [arg1] "{r2}" (arg1),
[arg2] "{r3}" (arg2), [arg2] "{r3}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -47,8 +44,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r2}" (arg1), [arg1] "{r2}" (arg1),
[arg2] "{r3}" (arg2), [arg2] "{r3}" (arg2),
[arg3] "{r4}" (arg3), [arg3] "{r4}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -59,8 +55,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r3}" (arg2), [arg2] "{r3}" (arg2),
[arg3] "{r4}" (arg3), [arg3] "{r4}" (arg3),
[arg4] "{r5}" (arg4), [arg4] "{r5}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -72,8 +67,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r4}" (arg3), [arg3] "{r4}" (arg3),
[arg4] "{r5}" (arg4), [arg4] "{r5}" (arg4),
[arg5] "{r6}" (arg5), [arg5] "{r6}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize, arg6: usize) usize { pub fn syscall6(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize, arg6: usize) usize {
@ -86,8 +80,7 @@ pub fn syscall6(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg4] "{r5}" (arg4), [arg4] "{r5}" (arg4),
[arg5] "{r6}" (arg5), [arg5] "{r6}" (arg5),
[arg6] "{r7}" (arg6), [arg6] "{r7}" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -161,8 +154,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\svc 0 \\svc 0
: :
: [number] "{r1}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{r1}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -32,8 +32,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
: [ret] "={o0}" (-> usize), : [ret] "={o0}" (-> usize),
: [number] "{g1}" (@intFromEnum(SYS.pipe)), : [number] "{g1}" (@intFromEnum(SYS.pipe)),
[arg] "r" (fd), [arg] "r" (fd),
: "memory", "g3" : .{ .memory = true, .g3 = true });
);
} }
pub fn syscall_fork() usize { pub fn syscall_fork() usize {
@ -55,8 +54,7 @@ pub fn syscall_fork() usize {
\\ 2: \\ 2:
: [ret] "={o0}" (-> usize), : [ret] "={o0}" (-> usize),
: [number] "{g1}" (@intFromEnum(SYS.fork)), : [number] "{g1}" (@intFromEnum(SYS.fork)),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn syscall0(number: SYS) usize { pub fn syscall0(number: SYS) usize {
@ -68,8 +66,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1: \\ 1:
: [ret] "={o0}" (-> usize), : [ret] "={o0}" (-> usize),
: [number] "{g1}" (@intFromEnum(number)), : [number] "{g1}" (@intFromEnum(number)),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -82,8 +79,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={o0}" (-> usize), : [ret] "={o0}" (-> usize),
: [number] "{g1}" (@intFromEnum(number)), : [number] "{g1}" (@intFromEnum(number)),
[arg1] "{o0}" (arg1), [arg1] "{o0}" (arg1),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -97,8 +93,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{g1}" (@intFromEnum(number)), : [number] "{g1}" (@intFromEnum(number)),
[arg1] "{o0}" (arg1), [arg1] "{o0}" (arg1),
[arg2] "{o1}" (arg2), [arg2] "{o1}" (arg2),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -113,8 +108,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{o0}" (arg1), [arg1] "{o0}" (arg1),
[arg2] "{o1}" (arg2), [arg2] "{o1}" (arg2),
[arg3] "{o2}" (arg3), [arg3] "{o2}" (arg3),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -130,8 +124,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{o1}" (arg2), [arg2] "{o1}" (arg2),
[arg3] "{o2}" (arg3), [arg3] "{o2}" (arg3),
[arg4] "{o3}" (arg4), [arg4] "{o3}" (arg4),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -148,8 +141,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{o2}" (arg3), [arg3] "{o2}" (arg3),
[arg4] "{o3}" (arg4), [arg4] "{o3}" (arg4),
[arg5] "{o4}" (arg5), [arg5] "{o4}" (arg5),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -175,8 +167,7 @@ pub fn syscall6(
[arg4] "{o3}" (arg4), [arg4] "{o3}" (arg4),
[arg5] "{o4}" (arg5), [arg5] "{o4}" (arg5),
[arg6] "{o5}" (arg6), [arg6] "{o5}" (arg6),
: "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -242,8 +233,7 @@ pub fn restore_rt() callconv(.c) void {
return asm volatile ("t 0x6d" return asm volatile ("t 0x6d"
: :
: [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7" : .{ .memory = true, .xcc = true, .o0 = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
);
} }
pub const F = struct { pub const F = struct {

View File

@ -18,8 +18,7 @@ pub fn syscall0(number: SYS) usize {
\\ ldr r7, [%[tmp], #4] \\ ldr r7, [%[tmp], #4]
: [ret] "={r0}" (-> usize), : [ret] "={r0}" (-> usize),
: [tmp] "{r1}" (&buf), : [tmp] "{r1}" (&buf),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -34,8 +33,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r0}" (-> usize), : [ret] "={r0}" (-> usize),
: [tmp] "{r1}" (&buf), : [tmp] "{r1}" (&buf),
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -51,8 +49,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [tmp] "{r2}" (&buf), : [tmp] "{r2}" (&buf),
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -69,8 +66,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r0}" (arg1), [arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -88,8 +84,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r1}" (arg2), [arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -108,8 +103,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r2}" (arg3), [arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5), [arg5] "{r4}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -137,8 +131,7 @@ pub fn syscall6(
[arg4] "{r3}" (arg4), [arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5), [arg5] "{r4}" (arg5),
[arg6] "{r5}" (arg6), [arg6] "{r5}" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub const clone = @import("arm.zig").clone; pub const clone = @import("arm.zig").clone;
@ -158,6 +151,5 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ svc #0 \\ svc #0
: :
: [number] "I" (@intFromEnum(SYS.rt_sigreturn)), : [number] "I" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true });
);
} }

View File

@ -308,8 +308,7 @@ pub fn setThreadPointer(addr: usize) void {
\\ sar %%a0, %%r0 \\ sar %%a0, %%r0
: :
: [addr] "r" (addr), : [addr] "r" (addr),
: "r0" : .{ .r0 = true });
);
}, },
.sparc, .sparc64 => { .sparc, .sparc64 => {
asm volatile ( asm volatile (

View File

@ -18,8 +18,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("int $0x80" return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize), : [ret] "={eax}" (-> usize),
: [number] "{eax}" (@intFromEnum(number)), : [number] "{eax}" (@intFromEnum(number)),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -27,8 +26,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={eax}" (-> usize), : [ret] "={eax}" (-> usize),
: [number] "{eax}" (@intFromEnum(number)), : [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1), [arg1] "{ebx}" (arg1),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -37,8 +35,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{eax}" (@intFromEnum(number)), : [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1), [arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2), [arg2] "{ecx}" (arg2),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -48,8 +45,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{ebx}" (arg1), [arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2), [arg2] "{ecx}" (arg2),
[arg3] "{edx}" (arg3), [arg3] "{edx}" (arg3),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -60,8 +56,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{ecx}" (arg2), [arg2] "{ecx}" (arg2),
[arg3] "{edx}" (arg3), [arg3] "{edx}" (arg3),
[arg4] "{esi}" (arg4), [arg4] "{esi}" (arg4),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -73,8 +68,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{edx}" (arg3), [arg3] "{edx}" (arg3),
[arg4] "{esi}" (arg4), [arg4] "{esi}" (arg4),
[arg5] "{edi}" (arg5), [arg5] "{edi}" (arg5),
: "memory" : .{ .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -108,8 +102,7 @@ pub fn syscall6(
[arg4] "{esi}" (arg4), [arg4] "{esi}" (arg4),
[arg5] "rm" (arg5), [arg5] "rm" (arg5),
[arg6] "rm" (arg6), [arg6] "rm" (arg6),
: "memory" : .{ .memory = true });
);
} }
pub fn socketcall(call: usize, args: [*]const usize) usize { pub fn socketcall(call: usize, args: [*]const usize) usize {
@ -118,8 +111,7 @@ pub fn socketcall(call: usize, args: [*]const usize) usize {
: [number] "{eax}" (@intFromEnum(SYS.socketcall)), : [number] "{eax}" (@intFromEnum(SYS.socketcall)),
[arg1] "{ebx}" (call), [arg1] "{ebx}" (call),
[arg2] "{ecx}" (@intFromPtr(args)), [arg2] "{ecx}" (@intFromPtr(args)),
: "memory" : .{ .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -179,14 +171,12 @@ pub fn restore() callconv(.naked) noreturn {
\\ int $0x80 \\ int $0x80
: :
: [number] "i" (@intFromEnum(SYS.sigreturn)), : [number] "i" (@intFromEnum(SYS.sigreturn)),
: "memory" : .{ .memory = true }),
),
else => asm volatile ( else => asm volatile (
\\ int $0x80 \\ int $0x80
: :
: [number] "{eax}" (@intFromEnum(SYS.sigreturn)), : [number] "{eax}" (@intFromEnum(SYS.sigreturn)),
: "memory" : .{ .memory = true }),
),
} }
} }
@ -197,14 +187,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ int $0x80 \\ int $0x80
: :
: [number] "i" (@intFromEnum(SYS.rt_sigreturn)), : [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true }),
),
else => asm volatile ( else => asm volatile (
\\ int $0x80 \\ int $0x80
: :
: [number] "{eax}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{eax}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory" : .{ .memory = true }),
),
} }
} }
@ -442,8 +430,7 @@ pub fn getContextInternal() callconv(.naked) usize {
[sigprocmask] "i" (@intFromEnum(linux.SYS.rt_sigprocmask)), [sigprocmask] "i" (@intFromEnum(linux.SYS.rt_sigprocmask)),
[sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")), [sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")),
[sigset_size] "i" (linux.NSIG / 8), [sigset_size] "i" (linux.NSIG / 8),
: "cc", "memory", "eax", "ecx", "edx" : .{ .cc = true, .memory = true, .eax = true, .ecx = true, .edx = true });
);
} }
pub inline fn getcontext(context: *ucontext_t) usize { pub inline fn getcontext(context: *ucontext_t) usize {
@ -457,6 +444,5 @@ pub inline fn getcontext(context: *ucontext_t) usize {
[_] "={edx}" (clobber_edx), [_] "={edx}" (clobber_edx),
: [_] "{edx}" (context), : [_] "{edx}" (context),
[getContextInternal] "X" (&getContextInternal), [getContextInternal] "X" (&getContextInternal),
: "cc", "memory", "ecx" : .{ .cc = true, .memory = true, .ecx = true });
);
} }

View File

@ -20,8 +20,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("syscall" return asm volatile ("syscall"
: [ret] "={rax}" (-> usize), : [ret] "={rax}" (-> usize),
: [number] "{rax}" (@intFromEnum(number)), : [number] "{rax}" (@intFromEnum(number)),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
} }
pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall1(number: SYS, arg1: usize) usize {
@ -29,8 +28,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={rax}" (-> usize), : [ret] "={rax}" (-> usize),
: [number] "{rax}" (@intFromEnum(number)), : [number] "{rax}" (@intFromEnum(number)),
[arg1] "{rdi}" (arg1), [arg1] "{rdi}" (arg1),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
} }
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
@ -39,8 +37,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{rax}" (@intFromEnum(number)), : [number] "{rax}" (@intFromEnum(number)),
[arg1] "{rdi}" (arg1), [arg1] "{rdi}" (arg1),
[arg2] "{rsi}" (arg2), [arg2] "{rsi}" (arg2),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
} }
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
@ -50,8 +47,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{rdi}" (arg1), [arg1] "{rdi}" (arg1),
[arg2] "{rsi}" (arg2), [arg2] "{rsi}" (arg2),
[arg3] "{rdx}" (arg3), [arg3] "{rdx}" (arg3),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
} }
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
@ -62,8 +58,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{rsi}" (arg2), [arg2] "{rsi}" (arg2),
[arg3] "{rdx}" (arg3), [arg3] "{rdx}" (arg3),
[arg4] "{r10}" (arg4), [arg4] "{r10}" (arg4),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
} }
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
@ -75,8 +70,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{rdx}" (arg3), [arg3] "{rdx}" (arg3),
[arg4] "{r10}" (arg4), [arg4] "{r10}" (arg4),
[arg5] "{r8}" (arg5), [arg5] "{r8}" (arg5),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
} }
pub fn syscall6( pub fn syscall6(
@ -97,8 +91,7 @@ pub fn syscall6(
[arg4] "{r10}" (arg4), [arg4] "{r10}" (arg4),
[arg5] "{r8}" (arg5), [arg5] "{r8}" (arg5),
[arg6] "{r9}" (arg6), [arg6] "{r9}" (arg6),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
} }
pub fn clone() callconv(.naked) usize { pub fn clone() callconv(.naked) usize {
@ -144,14 +137,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall \\ syscall
: :
: [number] "i" (@intFromEnum(SYS.rt_sigreturn)), : [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true }),
),
else => asm volatile ( else => asm volatile (
\\ syscall \\ syscall
: :
: [number] "{rax}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{rax}" (@intFromEnum(SYS.rt_sigreturn)),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true }),
),
} }
} }
@ -440,8 +431,7 @@ fn getContextInternal() callconv(.naked) usize {
[sigprocmask] "i" (@intFromEnum(linux.SYS.rt_sigprocmask)), [sigprocmask] "i" (@intFromEnum(linux.SYS.rt_sigprocmask)),
[sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")), [sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")),
[sigset_size] "i" (@sizeOf(sigset_t)), [sigset_size] "i" (@sizeOf(sigset_t)),
: "cc", "memory", "rax", "rcx", "rdx", "rdi", "rsi", "r8", "r10", "r11" : .{ .cc = true, .memory = true, .rax = true, .rcx = true, .rdx = true, .rdi = true, .rsi = true, .r8 = true, .r10 = true, .r11 = true });
);
} }
pub inline fn getcontext(context: *ucontext_t) usize { pub inline fn getcontext(context: *ucontext_t) usize {
@ -455,6 +445,5 @@ pub inline fn getcontext(context: *ucontext_t) usize {
[_] "={rdi}" (clobber_rdi), [_] "={rdi}" (clobber_rdi),
: [_] "{rdi}" (context), : [_] "{rdi}" (context),
[getContextInternal] "X" (&getContextInternal), [getContextInternal] "X" (&getContextInternal),
: "cc", "memory", "rcx", "rdx", "rsi", "r8", "r10", "r11" : .{ .cc = true, .memory = true, .rcx = true, .rdx = true, .rsi = true, .r8 = true, .r10 = true, .r11 = true });
);
} }

View File

@ -11,8 +11,7 @@ pub fn syscall1(sys: plan9.SYS, arg0: usize) usize {
: [ret] "={rax}" (-> usize), : [ret] "={rax}" (-> usize),
: [arg0] "{r8}" (arg0), : [arg0] "{r8}" (arg0),
[syscall_number] "{rbp}" (@intFromEnum(sys)), [syscall_number] "{rbp}" (@intFromEnum(sys)),
: "rcx", "rax", "rbp", "r11", "memory" : .{ .rcx = true, .rax = true, .rbp = true, .r11 = true, .memory = true });
);
} }
pub fn syscall2(sys: plan9.SYS, arg0: usize, arg1: usize) usize { pub fn syscall2(sys: plan9.SYS, arg0: usize, arg1: usize) usize {
return asm volatile ( return asm volatile (
@ -27,8 +26,7 @@ pub fn syscall2(sys: plan9.SYS, arg0: usize, arg1: usize) usize {
: [arg0] "{r8}" (arg0), : [arg0] "{r8}" (arg0),
[arg1] "{r9}" (arg1), [arg1] "{r9}" (arg1),
[syscall_number] "{rbp}" (@intFromEnum(sys)), [syscall_number] "{rbp}" (@intFromEnum(sys)),
: "rcx", "rax", "rbp", "r11", "memory" : .{ .rcx = true, .rax = true, .rbp = true, .r11 = true, .memory = true });
);
} }
pub fn syscall3(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize) usize { pub fn syscall3(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize) usize {
return asm volatile ( return asm volatile (
@ -46,8 +44,7 @@ pub fn syscall3(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize) usize {
[arg1] "{r9}" (arg1), [arg1] "{r9}" (arg1),
[arg2] "{r10}" (arg2), [arg2] "{r10}" (arg2),
[syscall_number] "{rbp}" (@intFromEnum(sys)), [syscall_number] "{rbp}" (@intFromEnum(sys)),
: "rcx", "rax", "rbp", "r11", "memory" : .{ .rcx = true, .rax = true, .rbp = true, .r11 = true, .memory = true });
);
} }
pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usize) usize {
return asm volatile ( return asm volatile (
@ -68,6 +65,5 @@ pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usi
[arg2] "{r10}" (arg2), [arg2] "{r10}" (arg2),
[arg3] "{r11}" (arg3), [arg3] "{r11}" (arg3),
[syscall_number] "{rbp}" (@intFromEnum(sys)), [syscall_number] "{rbp}" (@intFromEnum(sys)),
: "rcx", "rax", "rbp", "r11", "memory" : .{ .rcx = true, .rax = true, .rbp = true, .r11 = true, .memory = true });
);
} }

View File

@ -100,8 +100,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ %[ret] = add(r1, %[ret]) \\ %[ret] = add(r1, %[ret])
: [ret] "=r" (-> [*]const elf.Dyn), : [ret] "=r" (-> [*]const elf.Dyn),
: :
: "r1" : .{ .r1 = true }),
),
.loongarch32, .loongarch64 => asm volatile ( .loongarch32, .loongarch64 => asm volatile (
\\ .weak _DYNAMIC \\ .weak _DYNAMIC
\\ .hidden _DYNAMIC \\ .hidden _DYNAMIC
@ -127,8 +126,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ addu %[ret], %[ret], $gp \\ addu %[ret], %[ret], $gp
: [ret] "=r" (-> [*]const elf.Dyn), : [ret] "=r" (-> [*]const elf.Dyn),
: :
: "lr" : .{ .lr = true }),
),
.mips64, .mips64el => asm volatile ( .mips64, .mips64el => asm volatile (
\\ .weak _DYNAMIC \\ .weak _DYNAMIC
\\ .hidden _DYNAMIC \\ .hidden _DYNAMIC
@ -140,8 +138,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ daddu %[ret], %[ret], $gp \\ daddu %[ret], %[ret], $gp
: [ret] "=r" (-> [*]const elf.Dyn), : [ret] "=r" (-> [*]const elf.Dyn),
: :
: "lr" : .{ .lr = true }),
),
.powerpc, .powerpcle => asm volatile ( .powerpc, .powerpcle => asm volatile (
\\ .weak _DYNAMIC \\ .weak _DYNAMIC
\\ .hidden _DYNAMIC \\ .hidden _DYNAMIC
@ -153,8 +150,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ add %[ret], 4, %[ret] \\ add %[ret], 4, %[ret]
: [ret] "=r" (-> [*]const elf.Dyn), : [ret] "=r" (-> [*]const elf.Dyn),
: :
: "lr", "r4" : .{ .lr = true, .r4 = true }),
),
.powerpc64, .powerpc64le => asm volatile ( .powerpc64, .powerpc64le => asm volatile (
\\ .weak _DYNAMIC \\ .weak _DYNAMIC
\\ .hidden _DYNAMIC \\ .hidden _DYNAMIC
@ -166,8 +162,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ add %[ret], 4, %[ret] \\ add %[ret], 4, %[ret]
: [ret] "=r" (-> [*]const elf.Dyn), : [ret] "=r" (-> [*]const elf.Dyn),
: :
: "lr", "r4" : .{ .lr = true, .r4 = true }),
),
.riscv32, .riscv64 => asm volatile ( .riscv32, .riscv64 => asm volatile (
\\ .weak _DYNAMIC \\ .weak _DYNAMIC
\\ .hidden _DYNAMIC \\ .hidden _DYNAMIC

View File

@ -131,32 +131,28 @@ fn exit2(code: usize) noreturn {
: :
: [number] "{rax}" (231), : [number] "{rax}" (231),
[arg1] "{rdi}" (code), [arg1] "{rdi}" (code),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true });
);
}, },
.arm => { .arm => {
asm volatile ("svc #0" asm volatile ("svc #0"
: :
: [number] "{r7}" (1), : [number] "{r7}" (1),
[arg1] "{r0}" (code), [arg1] "{r0}" (code),
: "memory" : .{ .memory = true });
);
}, },
.aarch64 => { .aarch64 => {
asm volatile ("svc #0" asm volatile ("svc #0"
: :
: [number] "{x8}" (93), : [number] "{x8}" (93),
[arg1] "{x0}" (code), [arg1] "{x0}" (code),
: "memory", "cc" : .{ .memory = true });
);
}, },
.sparc64 => { .sparc64 => {
asm volatile ("ta 0x6d" asm volatile ("ta 0x6d"
: :
: [number] "{g1}" (1), : [number] "{g1}" (1),
[arg1] "{o0}" (code), [arg1] "{o0}" (code),
: "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory" : .{ .o0 = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o6 = true, .o7 = true, .memory = true });
);
}, },
else => @compileError("TODO"), else => @compileError("TODO"),
}, },

View File

@ -17,8 +17,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={r3}" (-> usize), : [_] "={r3}" (-> usize),
: [_] "{r4}" (args), : [_] "{r4}" (args),
[_] "{r3}" (default), [_] "{r3}" (default),
: "cc", "memory" : .{ .memory = true }),
),
.aarch64, .aarch64_be => asm volatile ( .aarch64, .aarch64_be => asm volatile (
\\ ror x12, x12, #3 ; ror x12, x12, #13 \\ ror x12, x12, #3 ; ror x12, x12, #13
\\ ror x12, x12, #51 ; ror x12, x12, #61 \\ ror x12, x12, #51 ; ror x12, x12, #61
@ -26,8 +25,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={x3}" (-> usize), : [_] "={x3}" (-> usize),
: [_] "{x4}" (args), : [_] "{x4}" (args),
[_] "{x3}" (default), [_] "{x3}" (default),
: "cc", "memory" : .{ .memory = true }),
),
.mips, .mipsel => asm volatile ( .mips, .mipsel => asm volatile (
\\ srl $0, $0, 13 \\ srl $0, $0, 13
\\ srl $0, $0, 29 \\ srl $0, $0, 29
@ -37,8 +35,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={$11}" (-> usize), : [_] "={$11}" (-> usize),
: [_] "{$12}" (args), : [_] "{$12}" (args),
[_] "{$11}" (default), [_] "{$11}" (default),
: "memory" : .{ .memory = true }),
),
.mips64, .mips64el => asm volatile ( .mips64, .mips64el => asm volatile (
\\ dsll $0, $0, 3 ; dsll $0, $0, 13 \\ dsll $0, $0, 3 ; dsll $0, $0, 13
\\ dsll $0, $0, 29 ; dsll $0, $0, 19 \\ dsll $0, $0, 29 ; dsll $0, $0, 19
@ -46,8 +43,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={$11}" (-> usize), : [_] "={$11}" (-> usize),
: [_] "{$12}" (args), : [_] "{$12}" (args),
[_] "{$11}" (default), [_] "{$11}" (default),
: "memory" : .{ .memory = true }),
),
.powerpc, .powerpcle => asm volatile ( .powerpc, .powerpcle => asm volatile (
\\ rlwinm 0, 0, 3, 0, 31 ; rlwinm 0, 0, 13, 0, 31 \\ rlwinm 0, 0, 3, 0, 31 ; rlwinm 0, 0, 13, 0, 31
\\ rlwinm 0, 0, 29, 0, 31 ; rlwinm 0, 0, 19, 0, 31 \\ rlwinm 0, 0, 29, 0, 31 ; rlwinm 0, 0, 19, 0, 31
@ -55,8 +51,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={r3}" (-> usize), : [_] "={r3}" (-> usize),
: [_] "{r4}" (args), : [_] "{r4}" (args),
[_] "{r3}" (default), [_] "{r3}" (default),
: "cc", "memory" : .{ .memory = true }),
),
.powerpc64, .powerpc64le => asm volatile ( .powerpc64, .powerpc64le => asm volatile (
\\ rotldi 0, 0, 3 ; rotldi 0, 0, 13 \\ rotldi 0, 0, 3 ; rotldi 0, 0, 13
\\ rotldi 0, 0, 61 ; rotldi 0, 0, 51 \\ rotldi 0, 0, 61 ; rotldi 0, 0, 51
@ -64,8 +59,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={r3}" (-> usize), : [_] "={r3}" (-> usize),
: [_] "{r4}" (args), : [_] "{r4}" (args),
[_] "{r3}" (default), [_] "{r3}" (default),
: "cc", "memory" : .{ .memory = true }),
),
.riscv64 => asm volatile ( .riscv64 => asm volatile (
\\ .option push \\ .option push
\\ .option norvc \\ .option norvc
@ -78,8 +72,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={a3}" (-> usize), : [_] "={a3}" (-> usize),
: [_] "{a4}" (args), : [_] "{a4}" (args),
[_] "{a3}" (default), [_] "{a3}" (default),
: "cc", "memory" : .{ .memory = true }),
),
.s390x => asm volatile ( .s390x => asm volatile (
\\ lr %%r15, %%r15 \\ lr %%r15, %%r15
\\ lr %%r1, %%r1 \\ lr %%r1, %%r1
@ -89,8 +82,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={r3}" (-> usize), : [_] "={r3}" (-> usize),
: [_] "{r2}" (args), : [_] "{r2}" (args),
[_] "{r3}" (default), [_] "{r3}" (default),
: "cc", "memory" : .{ .memory = true }),
),
.x86 => asm volatile ( .x86 => asm volatile (
\\ roll $3, %%edi ; roll $13, %%edi \\ roll $3, %%edi ; roll $13, %%edi
\\ roll $29, %%edi ; roll $19, %%edi \\ roll $29, %%edi ; roll $19, %%edi
@ -98,8 +90,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={edx}" (-> usize), : [_] "={edx}" (-> usize),
: [_] "{eax}" (args), : [_] "{eax}" (args),
[_] "{edx}" (default), [_] "{edx}" (default),
: "cc", "memory" : .{ .memory = true }),
),
.x86_64 => asm volatile ( .x86_64 => asm volatile (
\\ rolq $3, %%rdi ; rolq $13, %%rdi \\ rolq $3, %%rdi ; rolq $13, %%rdi
\\ rolq $61, %%rdi ; rolq $51, %%rdi \\ rolq $61, %%rdi ; rolq $51, %%rdi
@ -107,8 +98,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
: [_] "={rdx}" (-> usize), : [_] "={rdx}" (-> usize),
: [_] "{rax}" (args), : [_] "{rax}" (args),
[_] "{rdx}" (default), [_] "{rdx}" (default),
: "cc", "memory" : .{ .memory = true }),
),
else => default, else => default,
}; };
} }

View File

@ -732,6 +732,7 @@ pub const SimpleComptimeReason = enum(u32) {
generic_call_target, generic_call_target,
wasm_memory_index, wasm_memory_index,
work_group_dim_index, work_group_dim_index,
clobber,
// Evaluating at comptime because types must be comptime-known. // Evaluating at comptime because types must be comptime-known.
// Reasons other than `.type` are just more specific messages. // Reasons other than `.type` are just more specific messages.
@ -812,6 +813,7 @@ pub const SimpleComptimeReason = enum(u32) {
.generic_call_target => "generic function being called must be comptime-known", .generic_call_target => "generic function being called must be comptime-known",
.wasm_memory_index => "wasm memory index must be comptime-known", .wasm_memory_index => "wasm memory index must be comptime-known",
.work_group_dim_index => "work group dimension index must be comptime-known", .work_group_dim_index => "work group dimension index must be comptime-known",
.clobber => "clobber must be comptime-known",
.type => "types must be comptime-known", .type => "types must be comptime-known",
.array_sentinel => "array sentinel value must be comptime-known", .array_sentinel => "array sentinel value must be comptime-known",

View File

@ -636,6 +636,7 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
.@"nosuspend", .@"nosuspend",
.asm_simple, .asm_simple,
.@"asm", .@"asm",
.asm_legacy,
.array_type, .array_type,
.array_type_sentinel, .array_type_sentinel,
.error_value, .error_value,
@ -1049,6 +1050,11 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter
} }
}, },
.asm_legacy => {
_, const extra_index = tree.nodeData(n).node_and_extra;
const extra = tree.extraData(extra_index, Node.AsmLegacy);
return extra.rparen + end_offset;
},
.@"asm" => { .@"asm" => {
_, const extra_index = tree.nodeData(n).node_and_extra; _, const extra_index = tree.nodeData(n).node_and_extra;
const extra = tree.extraData(extra_index, Node.Asm); const extra = tree.extraData(extra_index, Node.Asm);
@ -1887,6 +1893,19 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm {
.template = template, .template = template,
.items = &.{}, .items = &.{},
.rparen = rparen, .rparen = rparen,
.clobbers = .none,
});
}
pub fn asmLegacy(tree: Ast, node: Node.Index) full.AsmLegacy {
const template, const extra_index = tree.nodeData(node).node_and_extra;
const extra = tree.extraData(extra_index, Node.AsmLegacy);
const items = tree.extraDataSlice(.{ .start = extra.items_start, .end = extra.items_end }, Node.Index);
return tree.legacyAsmComponents(.{
.asm_token = tree.nodeMainToken(node),
.template = template,
.items = items,
.rparen = extra.rparen,
}); });
} }
@ -1898,6 +1917,7 @@ pub fn asmFull(tree: Ast, node: Node.Index) full.Asm {
.asm_token = tree.nodeMainToken(node), .asm_token = tree.nodeMainToken(node),
.template = template, .template = template,
.items = items, .items = items,
.clobbers = extra.clobbers,
.rparen = extra.rparen, .rparen = extra.rparen,
}); });
} }
@ -2194,8 +2214,8 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N
return result; return result;
} }
fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm { fn legacyAsmComponents(tree: Ast, info: full.AsmLegacy.Components) full.AsmLegacy {
var result: full.Asm = .{ var result: full.AsmLegacy = .{
.ast = info, .ast = info,
.volatile_token = null, .volatile_token = null,
.inputs = &.{}, .inputs = &.{},
@ -2255,6 +2275,29 @@ fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm {
return result; return result;
} }
fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm {
var result: full.Asm = .{
.ast = info,
.volatile_token = null,
.inputs = &.{},
.outputs = &.{},
};
if (tree.tokenTag(info.asm_token + 1) == .keyword_volatile) {
result.volatile_token = info.asm_token + 1;
}
const outputs_end: usize = for (info.items, 0..) |item, i| {
switch (tree.nodeTag(item)) {
.asm_output => continue,
else => break i,
}
} else info.items.len;
result.outputs = info.items[0..outputs_end];
result.inputs = info.items[outputs_end..];
return result;
}
fn fullWhileComponents(tree: Ast, info: full.While.Components) full.While { fn fullWhileComponents(tree: Ast, info: full.While.Components) full.While {
var result: full.While = .{ var result: full.While = .{
.ast = info, .ast = info,
@ -2449,6 +2492,14 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm {
}; };
} }
/// To be deleted after 0.15.0 is tagged
pub fn legacyAsm(tree: Ast, node: Node.Index) ?full.AsmLegacy {
return switch (tree.nodeTag(node)) {
.asm_legacy => tree.asmLegacy(node),
else => null,
};
}
pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call { pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call {
return switch (tree.nodeTag(node)) { return switch (tree.nodeTag(node)) {
.call, .call_comma => tree.callFull(node), .call, .call_comma => tree.callFull(node),
@ -2829,6 +2880,21 @@ pub const full = struct {
}; };
pub const Asm = struct { pub const Asm = struct {
ast: Components,
volatile_token: ?TokenIndex,
outputs: []const Node.Index,
inputs: []const Node.Index,
pub const Components = struct {
asm_token: TokenIndex,
template: Node.Index,
items: []const Node.Index,
clobbers: Node.OptionalIndex,
rparen: TokenIndex,
};
};
pub const AsmLegacy = struct {
ast: Components, ast: Components,
volatile_token: ?TokenIndex, volatile_token: ?TokenIndex,
first_clobber: ?TokenIndex, first_clobber: ?TokenIndex,
@ -3835,15 +3901,22 @@ pub const Node = struct {
/// Same as `block` except there is known to be a trailing comma before /// Same as `block` except there is known to be a trailing comma before
/// the final rbrace. /// the final rbrace.
block_semicolon, block_semicolon,
/// `asm(lhs)`. /// `asm(a)`.
/// ///
/// rhs is a `Token.Index` to the `)` token.
/// The `main_token` field is the `asm` token. /// The `main_token` field is the `asm` token.
asm_simple, asm_simple,
/// `asm(lhs, a)`. /// `asm(lhs, a)`.
/// ///
/// The `data` field is a `.node_and_extra`: /// The `data` field is a `.node_and_extra`:
/// 1. a `Node.Index` to lhs. /// 1. a `Node.Index` to lhs.
/// 2. a `ExtraIndex` to `AsmLegacy`.
///
/// The `main_token` field is the `asm` token.
asm_legacy,
/// `asm(a, b)`.
///
/// The `data` field is a `.node_and_extra`:
/// 1. a `Node.Index` to a.
/// 2. a `ExtraIndex` to `Asm`. /// 2. a `ExtraIndex` to `Asm`.
/// ///
/// The `main_token` field is the `asm` token. /// The `main_token` field is the `asm` token.
@ -4016,9 +4089,18 @@ pub const Node = struct {
callconv_expr: OptionalIndex, callconv_expr: OptionalIndex,
}; };
/// To be removed after 0.15.0 is tagged
pub const AsmLegacy = struct {
items_start: ExtraIndex,
items_end: ExtraIndex,
/// Needed to make lastToken() work.
rparen: TokenIndex,
};
pub const Asm = struct { pub const Asm = struct {
items_start: ExtraIndex, items_start: ExtraIndex,
items_end: ExtraIndex, items_end: ExtraIndex,
clobbers: OptionalIndex,
/// Needed to make lastToken() work. /// Needed to make lastToken() work.
rparen: TokenIndex, rparen: TokenIndex,
}; };

View File

@ -855,6 +855,9 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
.@"asm", .@"asm",
=> return renderAsm(r, tree.fullAsm(node).?, space), => return renderAsm(r, tree.fullAsm(node).?, space),
// To be removed after 0.15.0 is tagged
.asm_legacy => return renderAsmLegacy(r, tree.legacyAsm(node).?, space),
.enum_literal => { .enum_literal => {
try renderToken(r, tree.nodeMainToken(node) - 1, .none); // . try renderToken(r, tree.nodeMainToken(node) - 1, .none); // .
return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name
@ -2368,9 +2371,9 @@ fn renderContainerDecl(
return renderToken(r, rbrace, space); // rbrace return renderToken(r, rbrace, space); // rbrace
} }
fn renderAsm( fn renderAsmLegacy(
r: *Render, r: *Render,
asm_node: Ast.full.Asm, asm_node: Ast.full.AsmLegacy,
space: Space, space: Space,
) Error!void { ) Error!void {
const tree = r.tree; const tree = r.tree;
@ -2396,17 +2399,24 @@ fn renderAsm(
try renderToken(r, first_clobber - 2, .none); try renderToken(r, first_clobber - 2, .none);
try renderToken(r, first_clobber - 1, .space); try renderToken(r, first_clobber - 1, .space);
try ais.writer().writeAll(".{ ");
var tok_i = first_clobber; var tok_i = first_clobber;
while (true) : (tok_i += 1) { while (true) : (tok_i += 1) {
try renderToken(r, tok_i, .none); try ais.writer().writeByte('.');
_ = try writeStringLiteralAsIdentifier(r, tok_i);
try ais.writer().writeAll(" = true");
tok_i += 1; tok_i += 1;
switch (tree.tokenTag(tok_i)) { switch (tree.tokenTag(tok_i)) {
.r_paren => { .r_paren => {
try ais.writer().writeAll(" }");
ais.popIndent(); ais.popIndent();
return renderToken(r, tok_i, space); return renderToken(r, tok_i, space);
}, },
.comma => { .comma => {
if (tree.tokenTag(tok_i + 1) == .r_paren) { if (tree.tokenTag(tok_i + 1) == .r_paren) {
try ais.writer().writeAll(" }");
ais.popIndent(); ais.popIndent();
return renderToken(r, tok_i + 1, space); return renderToken(r, tok_i + 1, space);
} else { } else {
@ -2417,10 +2427,7 @@ fn renderAsm(
} }
} }
} else { } else {
// asm ("foo") unreachable;
try renderExpression(r, asm_node.ast.template, .none);
ais.popIndent();
return renderToken(r, asm_node.ast.rparen, space); // rparen
} }
} }
@ -2504,13 +2511,17 @@ fn renderAsm(
}; };
try renderToken(r, colon3, .space); // : try renderToken(r, colon3, .space); // :
try ais.writer().writeAll(".{ ");
const first_clobber = asm_node.first_clobber.?; const first_clobber = asm_node.first_clobber.?;
var tok_i = first_clobber; var tok_i = first_clobber;
while (true) { while (true) {
switch (tree.tokenTag(tok_i + 1)) { switch (tree.tokenTag(tok_i + 1)) {
.r_paren => { .r_paren => {
ais.setIndentDelta(indent_delta); ais.setIndentDelta(indent_delta);
try renderToken(r, tok_i, .newline); try ais.writer().writeByte('.');
const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i);
try ais.writer().writeAll(" = true }");
try renderSpace(r, tok_i, lexeme_len, .newline);
ais.popIndent(); ais.popIndent();
return renderToken(r, tok_i + 1, space); return renderToken(r, tok_i + 1, space);
}, },
@ -2518,12 +2529,17 @@ fn renderAsm(
switch (tree.tokenTag(tok_i + 2)) { switch (tree.tokenTag(tok_i + 2)) {
.r_paren => { .r_paren => {
ais.setIndentDelta(indent_delta); ais.setIndentDelta(indent_delta);
try renderToken(r, tok_i, .newline); try ais.writer().writeByte('.');
const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i);
try ais.writer().writeAll(" = true }");
try renderSpace(r, tok_i, lexeme_len, .newline);
ais.popIndent(); ais.popIndent();
return renderToken(r, tok_i + 2, space); return renderToken(r, tok_i + 2, space);
}, },
else => { else => {
try renderToken(r, tok_i, .none); try ais.writer().writeByte('.');
_ = try writeStringLiteralAsIdentifier(r, tok_i);
try ais.writer().writeAll(" = true");
try renderToken(r, tok_i + 1, .space); try renderToken(r, tok_i + 1, .space);
tok_i += 2; tok_i += 2;
}, },
@ -2534,6 +2550,131 @@ fn renderAsm(
} }
} }
fn renderAsm(
r: *Render,
asm_node: Ast.full.Asm,
space: Space,
) Error!void {
const tree = r.tree;
const ais = r.ais;
try renderToken(r, asm_node.ast.asm_token, .space); // asm
if (asm_node.volatile_token) |volatile_token| {
try renderToken(r, volatile_token, .space); // volatile
try renderToken(r, volatile_token + 1, .none); // lparen
} else {
try renderToken(r, asm_node.ast.asm_token + 1, .none); // lparen
}
if (asm_node.ast.items.len == 0) {
try ais.forcePushIndent(.normal);
if (asm_node.ast.clobbers.unwrap()) |clobbers| {
// asm ("foo" ::: clobbers)
try renderExpression(r, asm_node.ast.template, .space);
// Render the three colons.
const first_clobber = tree.firstToken(clobbers);
try renderToken(r, first_clobber - 3, .none);
try renderToken(r, first_clobber - 2, .none);
try renderToken(r, first_clobber - 1, .space);
try renderExpression(r, clobbers, .none);
ais.popIndent();
return renderToken(r, asm_node.ast.rparen, space); // rparen
}
// asm ("foo")
try renderExpression(r, asm_node.ast.template, .none);
ais.popIndent();
return renderToken(r, asm_node.ast.rparen, space); // rparen
}
try ais.forcePushIndent(.normal);
try renderExpression(r, asm_node.ast.template, .newline);
ais.setIndentDelta(asm_indent_delta);
const colon1 = tree.lastToken(asm_node.ast.template) + 1;
const colon2 = if (asm_node.outputs.len == 0) colon2: {
try renderToken(r, colon1, .newline); // :
break :colon2 colon1 + 1;
} else colon2: {
try renderToken(r, colon1, .space); // :
try ais.forcePushIndent(.normal);
for (asm_node.outputs, 0..) |asm_output, i| {
if (i + 1 < asm_node.outputs.len) {
const next_asm_output = asm_node.outputs[i + 1];
try renderAsmOutput(r, asm_output, .none);
const comma = tree.firstToken(next_asm_output) - 1;
try renderToken(r, comma, .newline); // ,
try renderExtraNewlineToken(r, tree.firstToken(next_asm_output));
} else if (asm_node.inputs.len == 0 and asm_node.ast.clobbers == .none) {
try ais.pushSpace(.comma);
try renderAsmOutput(r, asm_output, .comma);
ais.popSpace();
ais.popIndent();
ais.setIndentDelta(indent_delta);
ais.popIndent();
return renderToken(r, asm_node.ast.rparen, space); // rparen
} else {
try ais.pushSpace(.comma);
try renderAsmOutput(r, asm_output, .comma);
ais.popSpace();
const comma_or_colon = tree.lastToken(asm_output) + 1;
ais.popIndent();
break :colon2 switch (tree.tokenTag(comma_or_colon)) {
.comma => comma_or_colon + 1,
else => comma_or_colon,
};
}
} else unreachable;
};
const colon3 = if (asm_node.inputs.len == 0) colon3: {
try renderToken(r, colon2, .newline); // :
break :colon3 colon2 + 1;
} else colon3: {
try renderToken(r, colon2, .space); // :
try ais.forcePushIndent(.normal);
for (asm_node.inputs, 0..) |asm_input, i| {
if (i + 1 < asm_node.inputs.len) {
const next_asm_input = asm_node.inputs[i + 1];
try renderAsmInput(r, asm_input, .none);
const first_token = tree.firstToken(next_asm_input);
try renderToken(r, first_token - 1, .newline); // ,
try renderExtraNewlineToken(r, first_token);
} else if (asm_node.ast.clobbers == .none) {
try ais.pushSpace(.comma);
try renderAsmInput(r, asm_input, .comma);
ais.popSpace();
ais.popIndent();
ais.setIndentDelta(indent_delta);
ais.popIndent();
return renderToken(r, asm_node.ast.rparen, space); // rparen
} else {
try ais.pushSpace(.comma);
try renderAsmInput(r, asm_input, .comma);
ais.popSpace();
const comma_or_colon = tree.lastToken(asm_input) + 1;
ais.popIndent();
break :colon3 switch (tree.tokenTag(comma_or_colon)) {
.comma => comma_or_colon + 1,
else => comma_or_colon,
};
}
}
unreachable;
};
try renderToken(r, colon3, .space); // :
const clobbers = asm_node.ast.clobbers.unwrap().?;
try renderExpression(r, clobbers, .none);
ais.setIndentDelta(indent_delta);
ais.popIndent();
return renderToken(r, asm_node.ast.rparen, space); // rparen
}
fn renderCall( fn renderCall(
r: *Render, r: *Render,
call: Ast.full.Call, call: Ast.full.Call,
@ -3094,6 +3235,22 @@ fn tokenSliceForRender(tree: Ast, token_index: Ast.TokenIndex) []const u8 {
return ret; return ret;
} }
fn writeStringLiteralAsIdentifier(r: *Render, token_index: Ast.TokenIndex) !usize {
const tree = r.tree;
const ais = r.ais;
assert(tree.tokenTag(token_index) == .string_literal);
const lexeme = tokenSliceForRender(tree, token_index);
const unquoted = lexeme[1..][0 .. lexeme.len - 2];
if (std.zig.isValidId(unquoted)) {
try ais.writer().writeAll(unquoted);
return unquoted.len;
} else {
try ais.writer().writeByte('@');
try ais.writer().writeAll(lexeme);
return lexeme.len + 1;
}
}
fn hasSameLineComment(tree: Ast, token_index: Ast.TokenIndex) bool { fn hasSameLineComment(tree: Ast, token_index: Ast.TokenIndex) bool {
const between_source = tree.source[tree.tokenStart(token_index)..tree.tokenStart(token_index + 1)]; const between_source = tree.source[tree.tokenStart(token_index)..tree.tokenStart(token_index + 1)];
for (between_source) |byte| switch (byte) { for (between_source) |byte| switch (byte) {

View File

@ -505,6 +505,7 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins
.bool_or, .bool_or,
.@"asm", .@"asm",
.asm_simple, .asm_simple,
.asm_legacy,
.string_literal, .string_literal,
.number_literal, .number_literal,
.call, .call,
@ -811,6 +812,12 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
.@"asm", .@"asm",
=> return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?), => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?),
.asm_legacy => {
return astgen.failNodeNotes(node, "legacy asm clobbers syntax", .{}, &[_]u32{
try astgen.errNoteNode(node, "use 'zig fmt' to auto-upgrade", .{}),
});
},
.string_literal => return stringLiteral(gz, ri, node), .string_literal => return stringLiteral(gz, ri, node),
.multiline_string_literal => return multilineStringLiteral(gz, ri, node), .multiline_string_literal => return multilineStringLiteral(gz, ri, node),
@ -8774,7 +8781,7 @@ fn asmExpr(
if (is_container_asm) { if (is_container_asm) {
if (full.volatile_token) |t| if (full.volatile_token) |t|
return astgen.failTok(t, "volatile is meaningless on global assembly", .{}); return astgen.failTok(t, "volatile is meaningless on global assembly", .{});
if (full.outputs.len != 0 or full.inputs.len != 0 or full.first_clobber != null) if (full.outputs.len != 0 or full.inputs.len != 0 or full.ast.clobbers != .none)
return astgen.failNode(node, "global assembly cannot have inputs, outputs, or clobbers", .{}); return astgen.failNode(node, "global assembly cannot have inputs, outputs, or clobbers", .{});
} else { } else {
if (full.outputs.len == 0 and full.volatile_token == null) { if (full.outputs.len == 0 and full.volatile_token == null) {
@ -8839,32 +8846,12 @@ fn asmExpr(
}; };
} }
var clobbers_buffer: [63]u32 = undefined; const clobbers: Zir.Inst.Ref = if (full.ast.clobbers.unwrap()) |clobbers_node|
var clobber_i: usize = 0; try comptimeExpr(gz, scope, .{ .rl = .{
if (full.first_clobber) |first_clobber| clobbers: { .coerced_ty = try gz.addBuiltinValue(clobbers_node, .clobbers),
// asm ("foo" ::: "a", "b") } }, clobbers_node, .clobber)
// asm ("foo" ::: "a", "b",) else
var tok_i = first_clobber; .none;
while (true) : (tok_i += 1) {
if (clobber_i >= clobbers_buffer.len) {
return astgen.failTok(tok_i, "too many asm clobbers", .{});
}
clobbers_buffer[clobber_i] = @intFromEnum((try astgen.strLitAsString(tok_i)).index);
clobber_i += 1;
tok_i += 1;
switch (tree.tokenTag(tok_i)) {
.r_paren => break :clobbers,
.comma => {
if (tree.tokenTag(tok_i + 1) == .r_paren) {
break :clobbers;
} else {
continue;
}
},
else => unreachable,
}
}
}
const result = try gz.addAsm(.{ const result = try gz.addAsm(.{
.tag = tag_and_tmpl.tag, .tag = tag_and_tmpl.tag,
@ -8874,7 +8861,7 @@ fn asmExpr(
.output_type_bits = output_type_bits, .output_type_bits = output_type_bits,
.outputs = outputs, .outputs = outputs,
.inputs = inputs, .inputs = inputs,
.clobbers = clobbers_buffer[0..clobber_i], .clobbers = clobbers,
}); });
return rvalue(gz, ri, result, node); return rvalue(gz, ri, result, node);
} }
@ -10332,6 +10319,7 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev
.@"asm", .@"asm",
.asm_simple, .asm_simple,
.asm_legacy,
.identifier, .identifier,
.field_access, .field_access,
.deref, .deref,
@ -10575,6 +10563,7 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In
.tagged_union_enum_tag_trailing, .tagged_union_enum_tag_trailing,
.@"asm", .@"asm",
.asm_simple, .asm_simple,
.asm_legacy,
.add, .add,
.add_wrap, .add_wrap,
.add_sat, .add_sat,
@ -10813,6 +10802,7 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool {
.tagged_union_enum_tag_trailing, .tagged_union_enum_tag_trailing,
.@"asm", .@"asm",
.asm_simple, .asm_simple,
.asm_legacy,
.add, .add,
.add_wrap, .add_wrap,
.add_sat, .add_sat,
@ -12811,7 +12801,7 @@ const GenZir = struct {
is_volatile: bool, is_volatile: bool,
outputs: []const Zir.Inst.Asm.Output, outputs: []const Zir.Inst.Asm.Output,
inputs: []const Zir.Inst.Asm.Input, inputs: []const Zir.Inst.Asm.Input,
clobbers: []const u32, clobbers: Zir.Inst.Ref,
}, },
) !Zir.Inst.Ref { ) !Zir.Inst.Ref {
const astgen = gz.astgen; const astgen = gz.astgen;
@ -12821,13 +12811,13 @@ const GenZir = struct {
try astgen.instructions.ensureUnusedCapacity(gpa, 1); try astgen.instructions.ensureUnusedCapacity(gpa, 1);
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".fields.len + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".fields.len +
args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".fields.len + args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".fields.len +
args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".fields.len + args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".fields.len);
args.clobbers.len);
const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{ const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{
.src_node = gz.nodeIndexToRelative(args.node), .src_node = gz.nodeIndexToRelative(args.node),
.asm_source = args.asm_source, .asm_source = args.asm_source,
.output_type_bits = args.output_type_bits, .output_type_bits = args.output_type_bits,
.clobbers = args.clobbers,
}); });
for (args.outputs) |output| { for (args.outputs) |output| {
_ = gz.astgen.addExtraAssumeCapacity(output); _ = gz.astgen.addExtraAssumeCapacity(output);
@ -12835,23 +12825,19 @@ const GenZir = struct {
for (args.inputs) |input| { for (args.inputs) |input| {
_ = gz.astgen.addExtraAssumeCapacity(input); _ = gz.astgen.addExtraAssumeCapacity(input);
} }
gz.astgen.extra.appendSliceAssumeCapacity(args.clobbers);
// * 0b00000000_0000XXXX - `outputs_len`. const small: Zir.Inst.Asm.Small = .{
// * 0b0000000X_XXXX0000 - `inputs_len`. .outputs_len = @intCast(args.outputs.len),
// * 0b0XXXXXX0_00000000 - `clobbers_len`. .inputs_len = @intCast(args.inputs.len),
// * 0bX0000000_00000000 - is volatile .is_volatile = args.is_volatile,
const small: u16 = @as(u16, @as(u4, @intCast(args.outputs.len))) << 0 | };
@as(u16, @as(u5, @intCast(args.inputs.len))) << 4 |
@as(u16, @as(u6, @intCast(args.clobbers.len))) << 9 |
@as(u16, @intFromBool(args.is_volatile)) << 15;
const new_index: Zir.Inst.Index = @enumFromInt(astgen.instructions.len); const new_index: Zir.Inst.Index = @enumFromInt(astgen.instructions.len);
astgen.instructions.appendAssumeCapacity(.{ astgen.instructions.appendAssumeCapacity(.{
.tag = .extended, .tag = .extended,
.data = .{ .extended = .{ .data = .{ .extended = .{
.opcode = args.tag, .opcode = args.tag,
.small = small, .small = @bitCast(small),
.operand = payload_index, .operand = payload_index,
} }, } },
}); });

View File

@ -310,6 +310,7 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI
.unreachable_literal, .unreachable_literal,
.asm_simple, .asm_simple,
.@"asm", .@"asm",
.asm_legacy,
.enum_literal, .enum_literal,
.error_value, .error_value,
.anyframe_literal, .anyframe_literal,

View File

@ -2801,7 +2801,7 @@ fn expectSwitchSuffix(p: *Parse, main_token: TokenIndex) !Node.Index {
/// ///
/// AsmInput <- COLON AsmInputList AsmClobbers? /// AsmInput <- COLON AsmInputList AsmClobbers?
/// ///
/// AsmClobbers <- COLON StringList /// AsmClobbers <- COLON Expr
/// ///
/// StringList <- (STRINGLITERAL COMMA)* STRINGLITERAL? /// StringList <- (STRINGLITERAL COMMA)* STRINGLITERAL?
/// ///
@ -2841,7 +2841,8 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
else => try p.warnExpected(.comma), else => try p.warnExpected(.comma),
} }
} }
if (p.eatToken(.colon)) |_| {
const clobbers: Node.OptionalIndex = if (p.eatToken(.colon)) |_| clobbers: {
while (true) { while (true) {
const input_item = try p.parseAsmInputItem() orelse break; const input_item = try p.parseAsmInputItem() orelse break;
try p.scratch.append(p.gpa, input_item); try p.scratch.append(p.gpa, input_item);
@ -2853,7 +2854,11 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
else => try p.warnExpected(.comma), else => try p.warnExpected(.comma),
} }
} }
if (p.eatToken(.colon)) |_| {
_ = p.eatToken(.colon) orelse break :clobbers .none;
// For automatic upgrades; delete after 0.15.0 released.
if (p.tokenTag(p.tok_i) == .string_literal) {
while (p.eatToken(.string_literal)) |_| { while (p.eatToken(.string_literal)) |_| {
switch (p.tokenTag(p.tok_i)) { switch (p.tokenTag(p.tok_i)) {
.comma => p.tok_i += 1, .comma => p.tok_i += 1,
@ -2862,8 +2867,25 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
else => try p.warnExpected(.comma), else => try p.warnExpected(.comma),
} }
} }
const rparen = try p.expectToken(.r_paren);
const span = try p.listToSpan(p.scratch.items[scratch_top..]);
return p.addNode(.{
.tag = .asm_legacy,
.main_token = asm_token,
.data = .{ .node_and_extra = .{
template,
try p.addExtra(Node.AsmLegacy{
.items_start = span.start,
.items_end = span.end,
.rparen = rparen,
}),
} },
});
} }
}
break :clobbers (try p.expectExpr()).toOptional();
} else .none;
const rparen = try p.expectToken(.r_paren); const rparen = try p.expectToken(.r_paren);
const span = try p.listToSpan(p.scratch.items[scratch_top..]); const span = try p.listToSpan(p.scratch.items[scratch_top..]);
return p.addNode(.{ return p.addNode(.{
@ -2874,6 +2896,7 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
try p.addExtra(Node.Asm{ try p.addExtra(Node.Asm{
.items_start = span.start, .items_start = span.start,
.items_end = span.end, .items_end = span.end,
.clobbers = clobbers,
.rparen = rparen, .rparen = rparen,
}), }),
} }, } },

View File

@ -1939,11 +1939,6 @@ pub const Inst = struct {
/// `operand` is payload index to `BinNode`. /// `operand` is payload index to `BinNode`.
builtin_extern, builtin_extern,
/// Inline assembly. /// Inline assembly.
/// `small`:
/// * 0b00000000_000XXXXX - `outputs_len`.
/// * 0b000000XX_XXX00000 - `inputs_len`.
/// * 0b0XXXXX00_00000000 - `clobbers_len`.
/// * 0bX0000000_00000000 - is volatile
/// `operand` is payload index to `Asm`. /// `operand` is payload index to `Asm`.
@"asm", @"asm",
/// Same as `asm` except the assembly template is not a string literal but a comptime /// Same as `asm` except the assembly template is not a string literal but a comptime
@ -2495,7 +2490,6 @@ pub const Inst = struct {
/// Trailing: /// Trailing:
/// 0. Output for every outputs_len /// 0. Output for every outputs_len
/// 1. Input for every inputs_len /// 1. Input for every inputs_len
/// 2. clobber: NullTerminatedString // index into string_bytes (null terminated) for every clobbers_len.
pub const Asm = struct { pub const Asm = struct {
src_node: Ast.Node.Offset, src_node: Ast.Node.Offset,
// null-terminated string index // null-terminated string index
@ -2505,6 +2499,13 @@ pub const Inst = struct {
/// 0b1 - operand is a type; asm expression has the output as the result. /// 0b1 - operand is a type; asm expression has the output as the result.
/// 0b0X is the first output, 0bX0 is the second, etc. /// 0b0X is the first output, 0bX0 is the second, etc.
output_type_bits: u32, output_type_bits: u32,
clobbers: Ref,
pub const Small = packed struct(u16) {
is_volatile: bool,
outputs_len: u7,
inputs_len: u8,
};
pub const Output = struct { pub const Output = struct {
/// index into string_bytes (null terminated) /// index into string_bytes (null terminated)
@ -3482,6 +3483,7 @@ pub const Inst = struct {
extern_options, extern_options,
type_info, type_info,
branch_hint, branch_hint,
clobbers,
// Values // Values
calling_convention_c, calling_convention_c,
calling_convention_inline, calling_convention_inline,

View File

@ -238,7 +238,7 @@ fn expr(zg: *ZonGen, node: Ast.Node.Index, dest_node: Zoir.Node.Index) Allocator
=> try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}), => try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}),
.@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}), .@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}),
.asm_simple, .@"asm" => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}), .asm_simple, .@"asm", .asm_legacy => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}),
.builtin_call_two, .builtin_call_two,
.builtin_call_two_comma, .builtin_call_two_comma,

View File

@ -32,7 +32,7 @@ test "zig fmt: tuple struct" {
} }
test "zig fmt: preserves clobbers in inline asm with stray comma" { test "zig fmt: preserves clobbers in inline asm with stray comma" {
try testCanonical( try testTransform(
\\fn foo() void { \\fn foo() void {
\\ asm volatile ("" \\ asm volatile (""
\\ : [_] "" (-> type), \\ : [_] "" (-> type),
@ -46,6 +46,20 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" {
\\ ); \\ );
\\} \\}
\\ \\
,
\\fn foo() void {
\\ asm volatile (""
\\ : [_] "" (-> type),
\\ :
\\ : .{ .clobber = true }
\\ );
\\ asm volatile (""
\\ :
\\ : [_] "" (type),
\\ : .{ .clobber = true }
\\ );
\\}
\\
); );
} }
@ -64,7 +78,7 @@ test "zig fmt: remove trailing comma at the end of assembly clobber" {
\\ asm volatile ("" \\ asm volatile (""
\\ : [_] "" (-> type), \\ : [_] "" (-> type),
\\ : \\ :
\\ : "clobber1", "clobber2" \\ : .{ .clobber1 = true, .clobber2 = true }
\\ ); \\ );
\\} \\}
\\ \\
@ -628,7 +642,7 @@ test "zig fmt: builtin call with trailing comma" {
} }
test "zig fmt: asm expression with comptime content" { test "zig fmt: asm expression with comptime content" {
try testCanonical( try testTransform(
\\comptime { \\comptime {
\\ asm ("foo" ++ "bar"); \\ asm ("foo" ++ "bar");
\\} \\}
@ -648,6 +662,26 @@ test "zig fmt: asm expression with comptime content" {
\\ ); \\ );
\\} \\}
\\ \\
,
\\comptime {
\\ asm ("foo" ++ "bar");
\\}
\\pub fn main() void {
\\ asm volatile ("foo" ++ "bar");
\\ asm volatile ("foo" ++ "bar"
\\ : [_] "" (x),
\\ );
\\ asm volatile ("foo" ++ "bar"
\\ : [_] "" (x),
\\ : [_] "" (y),
\\ );
\\ asm volatile ("foo" ++ "bar"
\\ : [_] "" (x),
\\ : [_] "" (y),
\\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true }
\\ );
\\}
\\
); );
} }
@ -2182,7 +2216,7 @@ test "zig fmt: simple asm" {
\\ : [a] "x" (-> i32), \\ : [a] "x" (-> i32),
\\ : [a] "x" (1), \\ : [a] "x" (1),
\\ ); \\ );
\\ asm ("still not real assembly" ::: "a", "b"); \\ asm ("still not real assembly" ::: .{ .a = true, .b = true });
\\} \\}
\\ \\
); );
@ -3907,7 +3941,7 @@ test "zig fmt: fn type" {
} }
test "zig fmt: inline asm" { test "zig fmt: inline asm" {
try testCanonical( try testTransform(
\\pub fn syscall1(number: usize, arg1: usize) usize { \\pub fn syscall1(number: usize, arg1: usize) usize {
\\ return asm volatile ("syscall" \\ return asm volatile ("syscall"
\\ : [ret] "={rax}" (-> usize), \\ : [ret] "={rax}" (-> usize),
@ -3917,6 +3951,16 @@ test "zig fmt: inline asm" {
\\ ); \\ );
\\} \\}
\\ \\
,
\\pub fn syscall1(number: usize, arg1: usize) usize {
\\ return asm volatile ("syscall"
\\ : [ret] "={rax}" (-> usize),
\\ : [number] "{rax}" (number),
\\ [arg1] "{rdi}" (arg1),
\\ : .{ .rcx = true, .r11 = true }
\\ );
\\}
\\
); );
} }
@ -3998,7 +4042,7 @@ test "zig fmt: inline asm parameter alignment" {
\\ asm volatile ( \\ asm volatile (
\\ \\ foo \\ \\ foo
\\ \\ bar \\ \\ bar
\\ ::: "", ""); \\ ::: .{ .a = true, .b = true });
\\ asm volatile ( \\ asm volatile (
\\ \\ foo \\ \\ foo
\\ \\ bar \\ \\ bar
@ -4006,8 +4050,7 @@ test "zig fmt: inline asm parameter alignment" {
\\ [_] "" (-> usize), \\ [_] "" (-> usize),
\\ : [_] "" (0), \\ : [_] "" (0),
\\ [_] "" (0), \\ [_] "" (0),
\\ : "", "" \\ : .{});
\\ );
\\} \\}
\\ \\
); );
@ -5325,7 +5368,7 @@ test "zig fmt: make single-line if no trailing comma, fmt: off" {
\\ asm ("not real assembly" \\ asm ("not real assembly"
\\ :[a] "x" (->i32),:[a] "x" (1),); \\ :[a] "x" (->i32),:[a] "x" (1),);
\\ asm volatile ("still not real assembly" \\ asm volatile ("still not real assembly"
\\ :::"a","b",); \\ :::.{.a = true,.b = true,});
\\ } \\ }
\\} \\}
); );
@ -5737,7 +5780,7 @@ test "zig fmt: canonicalize symbols (asm)" {
\\ [@"arg1"] "{rdi}" (arg), \\ [@"arg1"] "{rdi}" (arg),
\\ [arg2] "{rsi}" (arg), \\ [arg2] "{rsi}" (arg),
\\ [arg3] "{rdx}" (arg), \\ [arg3] "{rdx}" (arg),
\\ : "rcx", "r11" \\ : "rcx", "fn"
\\ ); \\ );
\\ \\
\\ const @"false": usize = 10; \\ const @"false": usize = 10;
@ -5759,7 +5802,7 @@ test "zig fmt: canonicalize symbols (asm)" {
\\ [arg1] "{rdi}" (arg), \\ [arg1] "{rdi}" (arg),
\\ [arg2] "{rsi}" (arg), \\ [arg2] "{rsi}" (arg),
\\ [arg3] "{rdx}" (arg), \\ [arg3] "{rdx}" (arg),
\\ : "rcx", "r11" \\ : .{ .rcx = true, .@"fn" = true }
\\ ); \\ );
\\ \\
\\ const @"false": usize = 10; \\ const @"false": usize = 10;

View File

@ -783,6 +783,5 @@ fn getXCR0() u32 {
\\ xgetbv \\ xgetbv
: [_] "={eax}" (-> u32), : [_] "={eax}" (-> u32),
: :
: "edx", "ecx" : .{ .edx = true, .ecx = true });
);
} }

View File

@ -1414,19 +1414,20 @@ pub const ShuffleTwoMask = enum(u32) {
/// terminated string. /// terminated string.
/// - name: memory at this position is reinterpreted as a null /// - name: memory at this position is reinterpreted as a null
/// terminated string. pad to the next u32 after the null byte. /// terminated string. pad to the next u32 after the null byte.
/// 4. for every clobbers_len /// 4. A number of u32 elements follow according to the equation `(source_len + 3) / 4`.
/// - clobber_name: memory at this position is reinterpreted as a null
/// terminated string. pad to the next u32 after the null byte.
/// 5. A number of u32 elements follow according to the equation `(source_len + 3) / 4`.
/// Memory starting at this position is reinterpreted as the source bytes. /// Memory starting at this position is reinterpreted as the source bytes.
pub const Asm = struct { pub const Asm = struct {
/// Length of the assembly source in bytes. /// Length of the assembly source in bytes.
source_len: u32, source_len: u32,
outputs_len: u32,
inputs_len: u32, inputs_len: u32,
/// The MSB is `is_volatile`. /// A comptime `std.builtin.assembly.Clobbers` value for the target architecture.
/// The rest of the bits are `clobbers_len`. clobbers: InternPool.Index,
flags: u32, flags: Flags,
pub const Flags = packed struct(u32) {
outputs_len: u31,
is_volatile: bool,
};
}; };
pub const Cmpxchg = struct { pub const Cmpxchg = struct {
@ -1750,7 +1751,7 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end
@field(result, field.name) = switch (field.type) { @field(result, field.name) = switch (field.type) {
u32 => air.extra.items[i], u32 => air.extra.items[i],
InternPool.Index, Inst.Ref => @enumFromInt(air.extra.items[i]), InternPool.Index, Inst.Ref => @enumFromInt(air.extra.items[i]),
i32, CondBr.BranchHints => @bitCast(air.extra.items[i]), i32, CondBr.BranchHints, Asm.Flags => @bitCast(air.extra.items[i]),
else => @compileError("bad field type: " ++ @typeName(field.type)), else => @compileError("bad field type: " ++ @typeName(field.type)),
}; };
i += 1; i += 1;

View File

@ -1209,8 +1209,9 @@ fn analyzeInst(
.assembly => { .assembly => {
const extra = a.air.extraData(Air.Asm, inst_datas[@intFromEnum(inst)].ty_pl.payload); const extra = a.air.extraData(Air.Asm, inst_datas[@intFromEnum(inst)].ty_pl.payload);
const outputs_len = extra.data.flags.outputs_len;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
const outputs = @as([]const Air.Inst.Ref, @ptrCast(a.air.extra.items[extra_i..][0..extra.data.outputs_len])); const outputs = @as([]const Air.Inst.Ref, @ptrCast(a.air.extra.items[extra_i..][0..outputs_len]));
extra_i += outputs.len; extra_i += outputs.len;
const inputs = @as([]const Air.Inst.Ref, @ptrCast(a.air.extra.items[extra_i..][0..extra.data.inputs_len])); const inputs = @as([]const Air.Inst.Ref, @ptrCast(a.air.extra.items[extra_i..][0..extra.data.inputs_len]));
extra_i += inputs.len; extra_i += inputs.len;

View File

@ -366,16 +366,11 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
.assembly => { .assembly => {
const ty_pl = data[@intFromEnum(inst)].ty_pl; const ty_pl = data[@intFromEnum(inst)].ty_pl;
const extra = self.air.extraData(Air.Asm, ty_pl.payload); const extra = self.air.extraData(Air.Asm, ty_pl.payload);
const outputs_len = extra.data.flags.outputs_len;
var extra_i = extra.end; var extra_i = extra.end;
const outputs = @as( const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..outputs_len]);
[]const Air.Inst.Ref,
@ptrCast(self.air.extra.items[extra_i..][0..extra.data.outputs_len]),
);
extra_i += outputs.len; extra_i += outputs.len;
const inputs = @as( const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]);
[]const Air.Inst.Ref,
@ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]),
);
extra_i += inputs.len; extra_i += inputs.len;
var bt = self.liveness.iterateBigTomb(inst); var bt = self.liveness.iterateBigTomb(inst);

View File

@ -1,5 +1,6 @@
const std = @import("std"); const std = @import("std");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const build_options = @import("build_options"); const build_options = @import("build_options");
const Zcu = @import("../Zcu.zig"); const Zcu = @import("../Zcu.zig");
@ -9,7 +10,7 @@ const Air = @import("../Air.zig");
const InternPool = @import("../InternPool.zig"); const InternPool = @import("../InternPool.zig");
pub fn write(air: Air, stream: *std.io.Writer, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { pub fn write(air: Air, stream: *std.io.Writer, pt: Zcu.PerThread, liveness: ?Air.Liveness) void {
comptime std.debug.assert(build_options.enable_debug_extensions); comptime assert(build_options.enable_debug_extensions);
const instruction_bytes = air.instructions.len * const instruction_bytes = air.instructions.len *
// Here we don't use @sizeOf(Air.Inst.Data) because it would include // Here we don't use @sizeOf(Air.Inst.Data) because it would include
// the debug safety tag but we want to measure release size. // the debug safety tag but we want to measure release size.
@ -59,7 +60,7 @@ pub fn writeInst(
pt: Zcu.PerThread, pt: Zcu.PerThread,
liveness: ?Air.Liveness, liveness: ?Air.Liveness,
) void { ) void {
comptime std.debug.assert(build_options.enable_debug_extensions); comptime assert(build_options.enable_debug_extensions);
var writer: Writer = .{ var writer: Writer = .{
.pt = pt, .pt = pt,
.gpa = pt.zcu.gpa, .gpa = pt.zcu.gpa,
@ -643,8 +644,8 @@ const Writer = struct {
fn writeAssembly(w: *Writer, s: *std.io.Writer, inst: Air.Inst.Index) Error!void { fn writeAssembly(w: *Writer, s: *std.io.Writer, inst: Air.Inst.Index) Error!void {
const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = w.air.extraData(Air.Asm, ty_pl.payload); const extra = w.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; const is_volatile = extra.data.flags.is_volatile;
const clobbers_len = @as(u31, @truncate(extra.data.flags)); const outputs_len = extra.data.flags.outputs_len;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
var op_index: usize = 0; var op_index: usize = 0;
@ -655,7 +656,7 @@ const Writer = struct {
try s.writeAll(", volatile"); try s.writeAll(", volatile");
} }
const outputs = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra_i..][0..extra.data.outputs_len])); const outputs = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra_i..][0..outputs_len]));
extra_i += outputs.len; extra_i += outputs.len;
const inputs = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra_i..][0..extra.data.inputs_len])); const inputs = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra_i..][0..extra.data.inputs_len]));
extra_i += inputs.len; extra_i += inputs.len;
@ -695,19 +696,35 @@ const Writer = struct {
try s.writeByte(')'); try s.writeByte(')');
} }
{ const zcu = w.pt.zcu;
var clobber_i: u32 = 0; const ip = &zcu.intern_pool;
while (clobber_i < clobbers_len) : (clobber_i += 1) { const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
const extra_bytes = std.mem.sliceAsBytes(w.air.extra.items[extra_i..]); const struct_type: Type = .fromInterned(aggregate.ty);
const clobber = std.mem.sliceTo(extra_bytes, 0); switch (aggregate.storage) {
// This equation accounts for the fact that even if we have exactly 4 bytes .elems => |elems| for (elems, 0..) |elem, i| {
// for the string, we still use the next u32 for the null terminator. switch (elem) {
extra_i += clobber.len / 4 + 1; .bool_true => {
const clobber = struct_type.structFieldName(i, zcu).toSlice(ip).?;
try s.writeAll(", ~{"); assert(clobber.len != 0);
try s.writeAll(clobber); try s.writeAll(", ~{");
try s.writeAll("}"); try s.writeAll(clobber);
} try s.writeAll("}");
},
.bool_false => continue,
else => unreachable,
}
},
.repeated_elem => |elem| {
try s.writeAll(", ");
try s.writeAll(switch (elem) {
.bool_true => "<all clobbers>",
.bool_false => "<no clobbers>",
else => unreachable,
});
},
.bytes => |bytes| {
try s.print(", {x}", .{bytes});
},
} }
const asm_source = std.mem.sliceAsBytes(w.air.extra.items[extra_i..])[0..extra.data.source_len]; const asm_source = std.mem.sliceAsBytes(w.air.extra.items[extra_i..])[0..extra.data.source_len];
try s.print(", \"{f}\"", .{std.zig.fmtString(asm_source)}); try s.print(", \"{f}\"", .{std.zig.fmtString(asm_source)});

View File

@ -416,8 +416,9 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
if (!checkType(data.ty_pl.ty.toType(), zcu)) return false; if (!checkType(data.ty_pl.ty.toType(), zcu)) return false;
// Luckily, we only care about the inputs and outputs, so we don't have to do // Luckily, we only care about the inputs and outputs, so we don't have to do
// the whole null-terminated string dance. // the whole null-terminated string dance.
const outputs: []const Air.Inst.Ref = @ptrCast(air.extra.items[extra.end..][0..extra.data.outputs_len]); const outputs_len = extra.data.flags.outputs_len;
const inputs: []const Air.Inst.Ref = @ptrCast(air.extra.items[extra.end + extra.data.outputs_len ..][0..extra.data.inputs_len]); const outputs: []const Air.Inst.Ref = @ptrCast(air.extra.items[extra.end..][0..outputs_len]);
const inputs: []const Air.Inst.Ref = @ptrCast(air.extra.items[extra.end + outputs_len ..][0..extra.data.inputs_len]);
for (outputs) |output| if (output != .none and !checkRef(output, zcu)) return false; for (outputs) |output| if (output != .none and !checkRef(output, zcu)) return false;
for (inputs) |input| if (input != .none and !checkRef(input, zcu)) return false; for (inputs) |input| if (input != .none and !checkRef(input, zcu)) return false;
}, },

View File

@ -54,6 +54,7 @@ namespace_name_deps: std.AutoArrayHashMapUnmanaged(NamespaceNameKey, DepEntry.In
memoized_state_main_deps: DepEntry.Index.Optional, memoized_state_main_deps: DepEntry.Index.Optional,
memoized_state_panic_deps: DepEntry.Index.Optional, memoized_state_panic_deps: DepEntry.Index.Optional,
memoized_state_va_list_deps: DepEntry.Index.Optional, memoized_state_va_list_deps: DepEntry.Index.Optional,
memoized_state_assembly_deps: DepEntry.Index.Optional,
/// Given a `Depender`, points to an entry in `dep_entries` whose `depender` /// Given a `Depender`, points to an entry in `dep_entries` whose `depender`
/// matches. The `next_dependee` field can be used to iterate all such entries /// matches. The `next_dependee` field can be used to iterate all such entries
@ -96,6 +97,7 @@ pub const empty: InternPool = .{
.memoized_state_main_deps = .none, .memoized_state_main_deps = .none,
.memoized_state_panic_deps = .none, .memoized_state_panic_deps = .none,
.memoized_state_va_list_deps = .none, .memoized_state_va_list_deps = .none,
.memoized_state_assembly_deps = .none,
.first_dependency = .empty, .first_dependency = .empty,
.dep_entries = .empty, .dep_entries = .empty,
.free_dep_entries = .empty, .free_dep_entries = .empty,
@ -458,6 +460,8 @@ pub const MemoizedStateStage = enum(u32) {
panic, panic,
/// Specifically `std.builtin.VaList`. See `Zcu.BuiltinDecl.stage`. /// Specifically `std.builtin.VaList`. See `Zcu.BuiltinDecl.stage`.
va_list, va_list,
/// Everything within `std.builtin.assembly`. See `Zcu.BuiltinDecl.stage`.
assembly,
}; };
pub const ComptimeUnit = extern struct { pub const ComptimeUnit = extern struct {
@ -880,6 +884,7 @@ pub fn dependencyIterator(ip: *const InternPool, dependee: Dependee) DependencyI
.main => ip.memoized_state_main_deps.unwrap(), .main => ip.memoized_state_main_deps.unwrap(),
.panic => ip.memoized_state_panic_deps.unwrap(), .panic => ip.memoized_state_panic_deps.unwrap(),
.va_list => ip.memoized_state_va_list_deps.unwrap(), .va_list => ip.memoized_state_va_list_deps.unwrap(),
.assembly => ip.memoized_state_assembly_deps.unwrap(),
}, },
} orelse return .{ } orelse return .{
.ip = ip, .ip = ip,
@ -915,6 +920,7 @@ pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, depend
.main => &ip.memoized_state_main_deps, .main => &ip.memoized_state_main_deps,
.panic => &ip.memoized_state_panic_deps, .panic => &ip.memoized_state_panic_deps,
.va_list => &ip.memoized_state_va_list_deps, .va_list => &ip.memoized_state_va_list_deps,
.assembly => &ip.memoized_state_assembly_deps,
}; };
if (deps.unwrap()) |first| { if (deps.unwrap()) |first| {

View File

@ -16413,10 +16413,10 @@ fn zirAsm(
const extra = sema.code.extraData(Zir.Inst.Asm, extended.operand); const extra = sema.code.extraData(Zir.Inst.Asm, extended.operand);
const src = block.nodeOffset(extra.data.src_node); const src = block.nodeOffset(extra.data.src_node);
const ret_ty_src = block.src(.{ .node_offset_asm_ret_ty = extra.data.src_node }); const ret_ty_src = block.src(.{ .node_offset_asm_ret_ty = extra.data.src_node });
const outputs_len: u4 = @truncate(extended.small); const small: Zir.Inst.Asm.Small = @bitCast(extended.small);
const inputs_len: u5 = @truncate(extended.small >> 4); const outputs_len = small.outputs_len;
const clobbers_len: u6 = @truncate(extended.small >> 9); const inputs_len = small.inputs_len;
const is_volatile = @as(u1, @truncate(extended.small >> 15)) != 0; const is_volatile = small.is_volatile;
const is_global_assembly = sema.func_index == .none; const is_global_assembly = sema.func_index == .none;
const zir_tags = sema.code.instructions.items(.tag); const zir_tags = sema.code.instructions.items(.tag);
@ -16432,7 +16432,7 @@ fn zirAsm(
if (inputs_len != 0) { if (inputs_len != 0) {
return sema.fail(block, src, "module-level assembly does not support inputs", .{}); return sema.fail(block, src, "module-level assembly does not support inputs", .{});
} }
if (clobbers_len != 0) { if (extra.data.clobbers != .none) {
return sema.fail(block, src, "module-level assembly does not support clobbers", .{}); return sema.fail(block, src, "module-level assembly does not support clobbers", .{});
} }
if (is_volatile) { if (is_volatile) {
@ -16506,15 +16506,11 @@ fn zirAsm(
inputs[arg_i] = .{ .c = constraint, .n = name }; inputs[arg_i] = .{ .c = constraint, .n = name };
} }
const clobbers = try sema.arena.alloc([]const u8, clobbers_len); const clobbers = if (extra.data.clobbers == .none) empty: {
for (clobbers) |*name| { const clobbers_ty = try sema.getBuiltinType(src, .@"assembly.Clobbers");
const name_index: Zir.NullTerminatedString = @enumFromInt(sema.code.extra[extra_i]); break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);
name.* = sema.code.nullTerminatedString(name_index); } else try sema.resolveInst(extra.data.clobbers); // Already coerced by AstGen.
extra_i += 1; const clobbers_val = try sema.resolveConstDefinedValue(block, src, clobbers, .{ .simple = .clobber });
needed_capacity += name.*.len / 4 + 1;
}
needed_capacity += (asm_source.len + 3) / 4; needed_capacity += (asm_source.len + 3) / 4;
const gpa = sema.gpa; const gpa = sema.gpa;
@ -16525,9 +16521,12 @@ fn zirAsm(
.ty = expr_ty, .ty = expr_ty,
.payload = sema.addExtraAssumeCapacity(Air.Asm{ .payload = sema.addExtraAssumeCapacity(Air.Asm{
.source_len = @intCast(asm_source.len), .source_len = @intCast(asm_source.len),
.outputs_len = outputs_len,
.inputs_len = @intCast(args.len), .inputs_len = @intCast(args.len),
.flags = (@as(u32, @intFromBool(is_volatile)) << 31) | @as(u32, @intCast(clobbers.len)), .clobbers = clobbers_val.toIntern(),
.flags = .{
.is_volatile = is_volatile,
.outputs_len = outputs_len,
},
}), }),
} }, } },
}); });
@ -16549,12 +16548,6 @@ fn zirAsm(
buffer[input.c.len + 1 + input.n.len] = 0; buffer[input.c.len + 1 + input.n.len] = 0;
sema.air_extra.items.len += (input.c.len + input.n.len + (2 + 3)) / 4; sema.air_extra.items.len += (input.c.len + input.n.len + (2 + 3)) / 4;
} }
for (clobbers) |clobber| {
const buffer = mem.sliceAsBytes(sema.air_extra.unusedCapacitySlice());
@memcpy(buffer[0..clobber.len], clobber);
buffer[clobber.len] = 0;
sema.air_extra.items.len += clobber.len / 4 + 1;
}
{ {
const buffer = mem.sliceAsBytes(sema.air_extra.unusedCapacitySlice()); const buffer = mem.sliceAsBytes(sema.air_extra.unusedCapacitySlice());
@memcpy(buffer[0..asm_source.len], asm_source); @memcpy(buffer[0..asm_source.len], asm_source);
@ -26197,6 +26190,7 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
.extern_options => try sema.getBuiltinType(src, .ExternOptions), .extern_options => try sema.getBuiltinType(src, .ExternOptions),
.type_info => try sema.getBuiltinType(src, .Type), .type_info => try sema.getBuiltinType(src, .Type),
.branch_hint => try sema.getBuiltinType(src, .BranchHint), .branch_hint => try sema.getBuiltinType(src, .BranchHint),
.clobbers => try sema.getBuiltinType(src, .@"assembly.Clobbers"),
// zig fmt: on // zig fmt: on
// Values are handled here. // Values are handled here.
@ -36546,7 +36540,7 @@ fn payloadToExtraItems(data: anytype) [@typeInfo(@TypeOf(data)).@"struct".fields
inline for (&result, fields) |*val, field| { inline for (&result, fields) |*val, field| {
val.* = switch (field.type) { val.* = switch (field.type) {
u32 => @field(data, field.name), u32 => @field(data, field.name),
i32, Air.CondBr.BranchHints => @bitCast(@field(data, field.name)), i32, Air.CondBr.BranchHints, Air.Asm.Flags => @bitCast(@field(data, field.name)),
Air.Inst.Ref, InternPool.Index => @intFromEnum(@field(data, field.name)), Air.Inst.Ref, InternPool.Index => @intFromEnum(@field(data, field.name)),
else => @compileError("bad field type: " ++ @typeName(field.type)), else => @compileError("bad field type: " ++ @typeName(field.type)),
}; };

View File

@ -460,6 +460,9 @@ pub const BuiltinDecl = enum {
VaList, VaList,
assembly,
@"assembly.Clobbers",
/// Determines what kind of validation will be done to the decl's value. /// Determines what kind of validation will be done to the decl's value.
pub fn kind(decl: BuiltinDecl) enum { type, func, string } { pub fn kind(decl: BuiltinDecl) enum { type, func, string } {
return switch (decl) { return switch (decl) {
@ -480,6 +483,8 @@ pub const BuiltinDecl = enum {
.ExportOptions, .ExportOptions,
.ExternOptions, .ExternOptions,
.BranchHint, .BranchHint,
.assembly,
.@"assembly.Clobbers",
=> .type, => .type,
.Type, .Type,
@ -540,6 +545,7 @@ pub const BuiltinDecl = enum {
/// Resolution of these values is done in three distinct stages: /// Resolution of these values is done in three distinct stages:
/// * Resolution of `std.builtin.Panic` and everything under it /// * Resolution of `std.builtin.Panic` and everything under it
/// * Resolution of `VaList` /// * Resolution of `VaList`
/// * Resolution of `assembly`
/// * Everything else /// * Everything else
/// ///
/// Panics are separated because they are provided by the user, so must be able to use /// Panics are separated because they are provided by the user, so must be able to use
@ -548,14 +554,20 @@ pub const BuiltinDecl = enum {
/// `VaList` is separate because its value depends on the target, so it needs some reflection /// `VaList` is separate because its value depends on the target, so it needs some reflection
/// machinery to work; additionally, it is `@compileError` on some targets, so must be referenced /// machinery to work; additionally, it is `@compileError` on some targets, so must be referenced
/// by itself. /// by itself.
///
/// `assembly` is separate because its value depends on the target.
pub fn stage(decl: BuiltinDecl) InternPool.MemoizedStateStage { pub fn stage(decl: BuiltinDecl) InternPool.MemoizedStateStage {
if (decl == .VaList) return .va_list; return switch (decl) {
.VaList => .va_list,
if (@intFromEnum(decl) <= @intFromEnum(BuiltinDecl.@"Type.Declaration")) { .assembly, .@"assembly.Clobbers" => .assembly,
return .main; else => {
} else { if (@intFromEnum(decl) <= @intFromEnum(BuiltinDecl.@"Type.Declaration")) {
return .panic; return .main;
} } else {
return .panic;
}
},
};
} }
/// Based on the tag name, determines how to access this decl; either as a direct child of the /// Based on the tag name, determines how to access this decl; either as a direct child of the

View File

@ -635,6 +635,7 @@ pub fn ensureMemoizedStateUpToDate(pt: Zcu.PerThread, stage: InternPool.Memoized
.main => .Type, .main => .Type,
.panic => .panic, .panic => .panic,
.va_list => .VaList, .va_list => .VaList,
.assembly => .assembly,
}; };
if (zcu.builtin_decl_values.get(to_check) != .none) return; if (zcu.builtin_decl_values.get(to_check) != .none) return;
} }

View File

@ -6048,10 +6048,10 @@ fn airBoolOp(func: *Func, inst: Air.Inst.Index) !void {
fn airAsm(func: *Func, inst: Air.Inst.Index) !void { fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = func.air.extraData(Air.Asm, ty_pl.payload); const extra = func.air.extraData(Air.Asm, ty_pl.payload);
const clobbers_len: u31 = @truncate(extra.data.flags); const outputs_len = extra.data.flags.outputs_len;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
const outputs: []const Air.Inst.Ref = const outputs: []const Air.Inst.Ref =
@ptrCast(func.air.extra.items[extra_i..][0..extra.data.outputs_len]); @ptrCast(func.air.extra.items[extra_i..][0..outputs_len]);
extra_i += outputs.len; extra_i += outputs.len;
const inputs: []const Air.Inst.Ref = @ptrCast(func.air.extra.items[extra_i..][0..extra.data.inputs_len]); const inputs: []const Air.Inst.Ref = @ptrCast(func.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len; extra_i += inputs.len;
@ -6162,21 +6162,33 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
args.appendAssumeCapacity(arg_mcv); args.appendAssumeCapacity(arg_mcv);
} }
{ const zcu = func.pt.zcu;
var clobber_i: u32 = 0; const ip = &zcu.intern_pool;
while (clobber_i < clobbers_len) : (clobber_i += 1) { const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
const clobber = std.mem.sliceTo(std.mem.sliceAsBytes(func.air.extra.items[extra_i..]), 0); const struct_type: Type = .fromInterned(aggregate.ty);
// This equation accounts for the fact that even if we have exactly 4 bytes switch (aggregate.storage) {
// for the string, we still use the next u32 for the null terminator. .elems => |elems| for (elems, 0..) |elem, i| {
extra_i += clobber.len / 4 + 1; switch (elem) {
.bool_true => {
if (std.mem.eql(u8, clobber, "") or std.mem.eql(u8, clobber, "memory")) { const clobber = struct_type.structFieldName(i, zcu).toSlice(ip).?;
// nothing really to do assert(clobber.len != 0);
} else { if (std.mem.eql(u8, clobber, "memory")) {
try func.register_manager.getReg(parseRegName(clobber) orelse // nothing really to do
return func.fail("invalid clobber: '{s}'", .{clobber}), null); } else {
try func.register_manager.getReg(parseRegName(clobber) orelse
return func.fail("invalid clobber: '{s}'", .{clobber}), null);
}
},
.bool_false => continue,
else => unreachable,
} }
} },
.repeated_elem => |elem| switch (elem) {
.bool_true => @panic("TODO"),
.bool_false => {},
else => unreachable,
},
.bytes => @panic("TODO"),
} }
const Label = struct { const Label = struct {

View File

@ -873,10 +873,10 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
fn airAsm(self: *Self, inst: Air.Inst.Index) !void { fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = self.air.extraData(Air.Asm, ty_pl.payload); const extra = self.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = (extra.data.flags & 0x80000000) != 0; const is_volatile = extra.data.flags.is_volatile;
const clobbers_len: u31 = @truncate(extra.data.flags); const outputs_len = extra.data.flags.outputs_len;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i .. extra_i + extra.data.outputs_len]); const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i .. extra_i + outputs_len]);
extra_i += outputs.len; extra_i += outputs.len;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i .. extra_i + extra.data.inputs_len]); const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i .. extra_i + extra.data.inputs_len]);
extra_i += inputs.len; extra_i += inputs.len;
@ -921,17 +921,8 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
try self.genSetReg(self.typeOf(input), reg, arg_mcv); try self.genSetReg(self.typeOf(input), reg, arg_mcv);
} }
{ // TODO honor the clobbers
var clobber_i: u32 = 0; _ = extra.data.clobbers;
while (clobber_i < clobbers_len) : (clobber_i += 1) {
const clobber = std.mem.sliceTo(std.mem.sliceAsBytes(self.air.extra.items[extra_i..]), 0);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += clobber.len / 4 + 1;
// TODO honor these
}
}
const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len]; const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len];

View File

@ -179788,9 +179788,9 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
const zcu = pt.zcu; const zcu = pt.zcu;
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = self.air.extraData(Air.Asm, ty_pl.payload); const extra = self.air.extraData(Air.Asm, ty_pl.payload);
const clobbers_len: u31 = @truncate(extra.data.flags); const outputs_len = extra.data.flags.outputs_len;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.outputs_len]); const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..outputs_len]);
extra_i += outputs.len; extra_i += outputs.len;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]); const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len; extra_i += inputs.len;
@ -179981,30 +179981,42 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
args.appendAssumeCapacity(arg_mcv); args.appendAssumeCapacity(arg_mcv);
} }
{ const ip = &zcu.intern_pool;
var clobber_i: u32 = 0; const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
while (clobber_i < clobbers_len) : (clobber_i += 1) { const struct_type: Type = .fromInterned(aggregate.ty);
const clobber = std.mem.sliceTo(std.mem.sliceAsBytes(self.air.extra.items[extra_i..]), 0); switch (aggregate.storage) {
// This equation accounts for the fact that even if we have exactly 4 bytes .elems => |elems| for (elems, 0..) |elem, i| switch (elem) {
// for the string, we still use the next u32 for the null terminator. .bool_true => {
extra_i += clobber.len / 4 + 1; const clobber = struct_type.structFieldName(i, zcu).toSlice(ip).?;
assert(clobber.len != 0);
if (std.mem.eql(u8, clobber, "") or std.mem.eql(u8, clobber, "memory") or if (std.mem.eql(u8, clobber, "memory") or
std.mem.eql(u8, clobber, "fpsr") or std.mem.eql(u8, clobber, "fpcr") or std.mem.eql(u8, clobber, "fpsr") or
std.mem.eql(u8, clobber, "mxcsr") or std.mem.eql(u8, clobber, "dirflag")) std.mem.eql(u8, clobber, "fpcr") or
{ std.mem.eql(u8, clobber, "mxcsr") or
// ok, sure std.mem.eql(u8, clobber, "dirflag"))
} else if (std.mem.eql(u8, clobber, "cc") or {
std.mem.eql(u8, clobber, "flags") or // ok, sure
std.mem.eql(u8, clobber, "eflags") or } else if (std.mem.eql(u8, clobber, "cc") or
std.mem.eql(u8, clobber, "rflags")) std.mem.eql(u8, clobber, "flags") or
{ std.mem.eql(u8, clobber, "eflags") or
try self.spillEflagsIfOccupied(); std.mem.eql(u8, clobber, "rflags"))
} else { {
try self.register_manager.getReg(parseRegName(clobber) orelse try self.spillEflagsIfOccupied();
return self.fail("invalid clobber: '{s}'", .{clobber}), null); } else {
} try self.register_manager.getReg(parseRegName(clobber) orelse
} return self.fail("invalid clobber: '{s}'", .{clobber}), null);
}
},
.bool_false => continue,
else => unreachable,
},
.repeated_elem => |elem| switch (elem) {
.bool_true => @panic("TODO"),
.bool_false => {},
else => unreachable,
},
.bytes => @panic("TODO"),
} }
const Label = struct { const Label = struct {

View File

@ -5545,11 +5545,11 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
const zcu = pt.zcu; const zcu = pt.zcu;
const ty_pl = f.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const ty_pl = f.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = f.air.extraData(Air.Asm, ty_pl.payload); const extra = f.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; const is_volatile = extra.data.flags.is_volatile;
const clobbers_len: u31 = @truncate(extra.data.flags); const outputs_len = extra.data.flags.outputs_len;
const gpa = f.object.dg.gpa; const gpa = f.object.dg.gpa;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
const outputs: []const Air.Inst.Ref = @ptrCast(f.air.extra.items[extra_i..][0..extra.data.outputs_len]); const outputs: []const Air.Inst.Ref = @ptrCast(f.air.extra.items[extra_i..][0..outputs_len]);
extra_i += outputs.len; extra_i += outputs.len;
const inputs: []const Air.Inst.Ref = @ptrCast(f.air.extra.items[extra_i..][0..extra.data.inputs_len]); const inputs: []const Air.Inst.Ref = @ptrCast(f.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len; extra_i += inputs.len;
@ -5645,12 +5645,6 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
try f.object.newline(); try f.object.newline();
} }
} }
for (0..clobbers_len) |_| {
const clobber = mem.sliceTo(mem.sliceAsBytes(f.air.extra.items[extra_i..]), 0);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += clobber.len / 4 + 1;
}
{ {
const asm_source = mem.sliceAsBytes(f.air.extra.items[extra_i..])[0..extra.data.source_len]; const asm_source = mem.sliceAsBytes(f.air.extra.items[extra_i..])[0..extra.data.source_len];
@ -5757,17 +5751,28 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
try w.writeByte(')'); try w.writeByte(')');
} }
try w.writeByte(':'); try w.writeByte(':');
for (0..clobbers_len) |clobber_i| { const ip = &zcu.intern_pool;
const clobber = mem.sliceTo(mem.sliceAsBytes(f.air.extra.items[extra_i..]), 0); const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
// This equation accounts for the fact that even if we have exactly 4 bytes const struct_type: Type = .fromInterned(aggregate.ty);
// for the string, we still use the next u32 for the null terminator. switch (aggregate.storage) {
extra_i += clobber.len / 4 + 1; .elems => |elems| for (elems, 0..) |elem, i| switch (elem) {
.bool_true => {
if (clobber.len == 0) continue; const name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
assert(name.len != 0);
if (clobber_i > 0) try w.writeByte(','); try w.print(" {f}", .{fmtStringLiteral(name, null)});
try w.print(" {f}", .{fmtStringLiteral(clobber, null)}); (try w.writableArray(1))[0] = ',';
},
.bool_false => continue,
else => unreachable,
},
.repeated_elem => |elem| switch (elem) {
.bool_true => @panic("TODO"),
.bool_false => {},
else => unreachable,
},
.bytes => @panic("TODO"),
} }
w.undo(1); // erase the last comma
try w.writeAll(");"); try w.writeAll(");");
try f.object.newline(); try f.object.newline();

View File

@ -7241,19 +7241,20 @@ pub const FuncGen = struct {
const o = self.ng.object; const o = self.ng.object;
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = self.air.extraData(Air.Asm, ty_pl.payload); const extra = self.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; const is_volatile = extra.data.flags.is_volatile;
const clobbers_len: u31 = @truncate(extra.data.flags); const outputs_len = extra.data.flags.outputs_len;
const gpa = self.gpa;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.outputs_len]); const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..outputs_len]);
extra_i += outputs.len; extra_i += outputs.len;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]); const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len; extra_i += inputs.len;
var llvm_constraints: std.ArrayListUnmanaged(u8) = .empty; var llvm_constraints: std.ArrayListUnmanaged(u8) = .empty;
defer llvm_constraints.deinit(self.gpa); defer llvm_constraints.deinit(gpa);
var arena_allocator = std.heap.ArenaAllocator.init(self.gpa); var arena_allocator = std.heap.ArenaAllocator.init(gpa);
defer arena_allocator.deinit(); defer arena_allocator.deinit();
const arena = arena_allocator.allocator(); const arena = arena_allocator.allocator();
@ -7276,7 +7277,7 @@ pub const FuncGen = struct {
var llvm_ret_i: usize = 0; var llvm_ret_i: usize = 0;
var llvm_param_i: usize = 0; var llvm_param_i: usize = 0;
var total_i: u16 = 0; var total_i: usize = 0;
var name_map: std.StringArrayHashMapUnmanaged(u16) = .empty; var name_map: std.StringArrayHashMapUnmanaged(u16) = .empty;
try name_map.ensureUnusedCapacity(arena, max_param_count); try name_map.ensureUnusedCapacity(arena, max_param_count);
@ -7290,7 +7291,7 @@ pub const FuncGen = struct {
// for the string, we still use the next u32 for the null terminator. // for the string, we still use the next u32 for the null terminator.
extra_i += (constraint.len + name.len + (2 + 3)) / 4; extra_i += (constraint.len + name.len + (2 + 3)) / 4;
try llvm_constraints.ensureUnusedCapacity(self.gpa, constraint.len + 3); try llvm_constraints.ensureUnusedCapacity(gpa, constraint.len + 3);
if (total_i != 0) { if (total_i != 0) {
llvm_constraints.appendAssumeCapacity(','); llvm_constraints.appendAssumeCapacity(',');
} }
@ -7358,7 +7359,7 @@ pub const FuncGen = struct {
if (!std.mem.eql(u8, name, "_")) { if (!std.mem.eql(u8, name, "_")) {
const gop = name_map.getOrPutAssumeCapacity(name); const gop = name_map.getOrPutAssumeCapacity(name);
if (gop.found_existing) return self.todo("duplicate asm output name '{s}'", .{name}); if (gop.found_existing) return self.todo("duplicate asm output name '{s}'", .{name});
gop.value_ptr.* = total_i; gop.value_ptr.* = @intCast(total_i);
} }
total_i += 1; total_i += 1;
} }
@ -7399,7 +7400,7 @@ pub const FuncGen = struct {
} }
} }
try llvm_constraints.ensureUnusedCapacity(self.gpa, constraint.len + 1); try llvm_constraints.ensureUnusedCapacity(gpa, constraint.len + 1);
if (total_i != 0) { if (total_i != 0) {
llvm_constraints.appendAssumeCapacity(','); llvm_constraints.appendAssumeCapacity(',');
} }
@ -7413,7 +7414,7 @@ pub const FuncGen = struct {
if (!std.mem.eql(u8, name, "_")) { if (!std.mem.eql(u8, name, "_")) {
const gop = name_map.getOrPutAssumeCapacity(name); const gop = name_map.getOrPutAssumeCapacity(name);
if (gop.found_existing) return self.todo("duplicate asm input name '{s}'", .{name}); if (gop.found_existing) return self.todo("duplicate asm input name '{s}'", .{name});
gop.value_ptr.* = total_i; gop.value_ptr.* = @intCast(total_i);
} }
// In the case of indirect inputs, LLVM requires the callsite to have // In the case of indirect inputs, LLVM requires the callsite to have
@ -7456,7 +7457,7 @@ pub const FuncGen = struct {
llvm_param_types[llvm_param_i] = llvm_elem_ty; llvm_param_types[llvm_param_i] = llvm_elem_ty;
} }
try llvm_constraints.print(self.gpa, ",{d}", .{output_index}); try llvm_constraints.print(gpa, ",{d}", .{output_index});
// In the case of indirect inputs, LLVM requires the callsite to have // In the case of indirect inputs, LLVM requires the callsite to have
// an elementtype(<ty>) attribute. // an elementtype(<ty>) attribute.
@ -7466,24 +7467,30 @@ pub const FuncGen = struct {
total_i += 1; total_i += 1;
} }
{ const ip = &zcu.intern_pool;
var clobber_i: u32 = 0; const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
while (clobber_i < clobbers_len) : (clobber_i += 1) { const struct_type: Type = .fromInterned(aggregate.ty);
const clobber = std.mem.sliceTo(std.mem.sliceAsBytes(self.air.extra.items[extra_i..]), 0); if (total_i != 0) try llvm_constraints.append(gpa, ',');
// This equation accounts for the fact that even if we have exactly 4 bytes switch (aggregate.storage) {
// for the string, we still use the next u32 for the null terminator. .elems => |elems| for (elems, 0..) |elem, i| {
extra_i += clobber.len / 4 + 1; switch (elem) {
.bool_true => {
try llvm_constraints.ensureUnusedCapacity(self.gpa, clobber.len + 4); const name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
if (total_i != 0) { total_i += try appendConstraints(gpa, &llvm_constraints, name, target);
llvm_constraints.appendAssumeCapacity(','); },
.bool_false => continue,
else => unreachable,
} }
llvm_constraints.appendSliceAssumeCapacity("~{"); },
llvm_constraints.appendSliceAssumeCapacity(clobber); .repeated_elem => |elem| switch (elem) {
llvm_constraints.appendSliceAssumeCapacity("}"); .bool_true => for (0..struct_type.structFieldCount(zcu)) |i| {
const name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
total_i += 1; total_i += try appendConstraints(gpa, &llvm_constraints, name, target);
} },
.bool_false => {},
else => unreachable,
},
.bytes => @panic("TODO"),
} }
// We have finished scanning through all inputs/outputs, so the number of // We have finished scanning through all inputs/outputs, so the number of
@ -7497,22 +7504,22 @@ pub const FuncGen = struct {
// to be buggy and regress often. // to be buggy and regress often.
switch (target.cpu.arch) { switch (target.cpu.arch) {
.x86_64, .x86 => { .x86_64, .x86 => {
if (total_i != 0) try llvm_constraints.append(self.gpa, ','); try llvm_constraints.appendSlice(gpa, "~{dirflag},~{fpsr},~{flags},");
try llvm_constraints.appendSlice(self.gpa, "~{dirflag},~{fpsr},~{flags}");
total_i += 3; total_i += 3;
}, },
.mips, .mipsel, .mips64, .mips64el => { .mips, .mipsel, .mips64, .mips64el => {
if (total_i != 0) try llvm_constraints.append(self.gpa, ','); try llvm_constraints.appendSlice(gpa, "~{$1},");
try llvm_constraints.appendSlice(self.gpa, "~{$1}");
total_i += 1; total_i += 1;
}, },
else => {}, else => {},
} }
if (std.mem.endsWith(u8, llvm_constraints.items, ",")) llvm_constraints.items.len -= 1;
const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len]; const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len];
// hackety hacks until stage2 has proper inline asm in the frontend. // hackety hacks until stage2 has proper inline asm in the frontend.
var rendered_template = std.ArrayList(u8).init(self.gpa); var rendered_template = std.ArrayList(u8).init(gpa);
defer rendered_template.deinit(); defer rendered_template.deinit();
const State = enum { start, percent, input, modifier }; const State = enum { start, percent, input, modifier };
@ -13188,3 +13195,257 @@ fn maxIntConst(b: *Builder, max_ty: Type, as_ty: Builder.Type, zcu: *const Zcu)
try res.setTwosCompIntLimit(.max, info.signedness, info.bits); try res.setTwosCompIntLimit(.max, info.signedness, info.bits);
return b.bigIntConst(as_ty, res.toConst()); return b.bigIntConst(as_ty, res.toConst());
} }
/// Appends zero or more LLVM constraints to `llvm_constraints`, returning how many were added.
fn appendConstraints(
gpa: Allocator,
llvm_constraints: *std.ArrayListUnmanaged(u8),
zig_name: []const u8,
target: *const std.Target,
) error{OutOfMemory}!usize {
switch (target.cpu.arch) {
.mips, .mipsel, .mips64, .mips64el => if (mips_clobber_overrides.get(zig_name)) |llvm_tag| {
const llvm_name = @tagName(llvm_tag);
try llvm_constraints.ensureUnusedCapacity(gpa, llvm_name.len + 4);
llvm_constraints.appendSliceAssumeCapacity("~{");
llvm_constraints.appendSliceAssumeCapacity(llvm_name);
llvm_constraints.appendSliceAssumeCapacity("},");
return 1;
},
else => {},
}
try llvm_constraints.ensureUnusedCapacity(gpa, zig_name.len + 4);
llvm_constraints.appendSliceAssumeCapacity("~{");
llvm_constraints.appendSliceAssumeCapacity(zig_name);
llvm_constraints.appendSliceAssumeCapacity("},");
return 1;
}
const mips_clobber_overrides = std.StaticStringMap(enum {
@"$msair",
@"$msacsr",
@"$msaaccess",
@"$msasave",
@"$msamodify",
@"$msarequest",
@"$msamap",
@"$msaunmap",
@"$f0",
@"$f1",
@"$f2",
@"$f3",
@"$f4",
@"$f5",
@"$f6",
@"$f7",
@"$f8",
@"$f9",
@"$f10",
@"$f11",
@"$f12",
@"$f13",
@"$f14",
@"$f15",
@"$f16",
@"$f17",
@"$f18",
@"$f19",
@"$f20",
@"$f21",
@"$f22",
@"$f23",
@"$f24",
@"$f25",
@"$f26",
@"$f27",
@"$f28",
@"$f29",
@"$f30",
@"$f31",
@"$fcc0",
@"$fcc1",
@"$fcc2",
@"$fcc3",
@"$fcc4",
@"$fcc5",
@"$fcc6",
@"$fcc7",
@"$w0",
@"$w1",
@"$w2",
@"$w3",
@"$w4",
@"$w5",
@"$w6",
@"$w7",
@"$w8",
@"$w9",
@"$w10",
@"$w11",
@"$w12",
@"$w13",
@"$w14",
@"$w15",
@"$w16",
@"$w17",
@"$w18",
@"$w19",
@"$w20",
@"$w21",
@"$w22",
@"$w23",
@"$w24",
@"$w25",
@"$w26",
@"$w27",
@"$w28",
@"$w29",
@"$w30",
@"$w31",
@"$0",
@"$1",
@"$2",
@"$3",
@"$4",
@"$5",
@"$6",
@"$7",
@"$8",
@"$9",
@"$10",
@"$11",
@"$12",
@"$13",
@"$14",
@"$15",
@"$16",
@"$17",
@"$18",
@"$19",
@"$20",
@"$21",
@"$22",
@"$23",
@"$24",
@"$25",
@"$26",
@"$27",
@"$28",
@"$29",
@"$30",
@"$31",
}).initComptime(.{
.{ "msa_ir", .@"$msair" },
.{ "msa_csr", .@"$msacsr" },
.{ "msa_access", .@"$msaaccess" },
.{ "msa_save", .@"$msasave" },
.{ "msa_modify", .@"$msamodify" },
.{ "msa_request", .@"$msarequest" },
.{ "msa_map", .@"$msamap" },
.{ "msa_unmap", .@"$msaunmap" },
.{ "f0", .@"$f0" },
.{ "f1", .@"$f1" },
.{ "f2", .@"$f2" },
.{ "f3", .@"$f3" },
.{ "f4", .@"$f4" },
.{ "f5", .@"$f5" },
.{ "f6", .@"$f6" },
.{ "f7", .@"$f7" },
.{ "f8", .@"$f8" },
.{ "f9", .@"$f9" },
.{ "f10", .@"$f10" },
.{ "f11", .@"$f11" },
.{ "f12", .@"$f12" },
.{ "f13", .@"$f13" },
.{ "f14", .@"$f14" },
.{ "f15", .@"$f15" },
.{ "f16", .@"$f16" },
.{ "f17", .@"$f17" },
.{ "f18", .@"$f18" },
.{ "f19", .@"$f19" },
.{ "f20", .@"$f20" },
.{ "f21", .@"$f21" },
.{ "f22", .@"$f22" },
.{ "f23", .@"$f23" },
.{ "f24", .@"$f24" },
.{ "f25", .@"$f25" },
.{ "f26", .@"$f26" },
.{ "f27", .@"$f27" },
.{ "f28", .@"$f28" },
.{ "f29", .@"$f29" },
.{ "f30", .@"$f30" },
.{ "f31", .@"$f31" },
.{ "fcc0", .@"$fcc0" },
.{ "fcc1", .@"$fcc1" },
.{ "fcc2", .@"$fcc2" },
.{ "fcc3", .@"$fcc3" },
.{ "fcc4", .@"$fcc4" },
.{ "fcc5", .@"$fcc5" },
.{ "fcc6", .@"$fcc6" },
.{ "fcc7", .@"$fcc7" },
.{ "w0", .@"$w0" },
.{ "w1", .@"$w1" },
.{ "w2", .@"$w2" },
.{ "w3", .@"$w3" },
.{ "w4", .@"$w4" },
.{ "w5", .@"$w5" },
.{ "w6", .@"$w6" },
.{ "w7", .@"$w7" },
.{ "w8", .@"$w8" },
.{ "w9", .@"$w9" },
.{ "w10", .@"$w10" },
.{ "w11", .@"$w11" },
.{ "w12", .@"$w12" },
.{ "w13", .@"$w13" },
.{ "w14", .@"$w14" },
.{ "w15", .@"$w15" },
.{ "w16", .@"$w16" },
.{ "w17", .@"$w17" },
.{ "w18", .@"$w18" },
.{ "w19", .@"$w19" },
.{ "w20", .@"$w20" },
.{ "w21", .@"$w21" },
.{ "w22", .@"$w22" },
.{ "w23", .@"$w23" },
.{ "w24", .@"$w24" },
.{ "w25", .@"$w25" },
.{ "w26", .@"$w26" },
.{ "w27", .@"$w27" },
.{ "w28", .@"$w28" },
.{ "w29", .@"$w29" },
.{ "w30", .@"$w30" },
.{ "w31", .@"$w31" },
.{ "r0", .@"$0" },
.{ "r1", .@"$1" },
.{ "r2", .@"$2" },
.{ "r3", .@"$3" },
.{ "r4", .@"$4" },
.{ "r5", .@"$5" },
.{ "r6", .@"$6" },
.{ "r7", .@"$7" },
.{ "r8", .@"$8" },
.{ "r9", .@"$9" },
.{ "r10", .@"$10" },
.{ "r11", .@"$11" },
.{ "r12", .@"$12" },
.{ "r13", .@"$13" },
.{ "r14", .@"$14" },
.{ "r15", .@"$15" },
.{ "r16", .@"$16" },
.{ "r17", .@"$17" },
.{ "r18", .@"$18" },
.{ "r19", .@"$19" },
.{ "r20", .@"$20" },
.{ "r21", .@"$21" },
.{ "r22", .@"$22" },
.{ "r23", .@"$23" },
.{ "r24", .@"$24" },
.{ "r25", .@"$25" },
.{ "r26", .@"$26" },
.{ "r27", .@"$27" },
.{ "r28", .@"$28" },
.{ "r29", .@"$29" },
.{ "r30", .@"$30" },
.{ "r31", .@"$31" },
});

View File

@ -6387,13 +6387,13 @@ const NavGen = struct {
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = self.air.extraData(Air.Asm, ty_pl.payload); const extra = self.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; const is_volatile = extra.data.flags.is_volatile;
const clobbers_len: u31 = @truncate(extra.data.flags); const outputs_len = extra.data.flags.outputs_len;
if (!is_volatile and self.liveness.isUnused(inst)) return null; if (!is_volatile and self.liveness.isUnused(inst)) return null;
var extra_i: usize = extra.end; var extra_i: usize = extra.end;
const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.outputs_len]); const outputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..outputs_len]);
extra_i += outputs.len; extra_i += outputs.len;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]); const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len; extra_i += inputs.len;
@ -6402,7 +6402,7 @@ const NavGen = struct {
return self.todo("implement inline asm with more than 1 output", .{}); return self.todo("implement inline asm with more than 1 output", .{});
} }
var as = SpvAssembler{ var as: SpvAssembler = .{
.gpa = self.gpa, .gpa = self.gpa,
.spv = self.spv, .spv = self.spv,
.func = &self.func, .func = &self.func,
@ -6486,14 +6486,8 @@ const NavGen = struct {
} }
} }
{ // TODO: do something with clobbers
var clobber_i: u32 = 0; _ = extra.data.clobbers;
while (clobber_i < clobbers_len) : (clobber_i += 1) {
const clobber = std.mem.sliceTo(std.mem.sliceAsBytes(self.air.extra.items[extra_i..]), 0);
extra_i += clobber.len / 4 + 1;
// TODO: Record clobber and use it somewhere.
}
}
const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len]; const asm_source = std.mem.sliceAsBytes(self.air.extra.items[extra_i..])[0..extra.data.source_len];

Binary file not shown.

View File

@ -55,13 +55,11 @@ test "output constraint modifiers" {
asm volatile ("" asm volatile (""
: [_] "=m,r" (a), : [_] "=m,r" (a),
: :
: "" : .{});
);
asm volatile ("" asm volatile (""
: [_] "=r,m" (a), : [_] "=r,m" (a),
: :
: "" : .{});
);
} }
test "alternative constraints" { test "alternative constraints" {
@ -79,7 +77,6 @@ test "alternative constraints" {
asm volatile ("" asm volatile (""
: [_] "=r,m" (a), : [_] "=r,m" (a),
: [_] "r,m" (a), : [_] "r,m" (a),
: ""
); );
} }
@ -96,42 +93,34 @@ test "sized integer/float in asm input" {
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(usize, 3)), : [_] "m" (@as(usize, 3)),
: ""
); );
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(i15, -3)), : [_] "m" (@as(i15, -3)),
: ""
); );
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(u3, 3)), : [_] "m" (@as(u3, 3)),
: ""
); );
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(i3, 3)), : [_] "m" (@as(i3, 3)),
: ""
); );
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(u121, 3)), : [_] "m" (@as(u121, 3)),
: ""
); );
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(i121, 3)), : [_] "m" (@as(i121, 3)),
: ""
); );
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(f32, 3.17)), : [_] "m" (@as(f32, 3.17)),
: ""
); );
asm volatile ("" asm volatile (""
: :
: [_] "m" (@as(f64, 3.17)), : [_] "m" (@as(f64, 3.17)),
: ""
); );
} }
@ -172,8 +161,7 @@ test "rw constraint (x86_64)" {
asm ("addl %[b], %[a]" asm ("addl %[b], %[a]"
: [a] "+r" (res), : [a] "+r" (res),
: [b] "r" (@as(i32, 13)), : [b] "r" (@as(i32, 13)),
: "flags" : .{ .flags = true });
);
try expectEqual(@as(i32, 18), res); try expectEqual(@as(i32, 18), res);
} }

View File

@ -9,7 +9,7 @@ fn setFs(value: c_ulong) void {
: [number] "{rax}" (158), : [number] "{rax}" (158),
[code] "{rdi}" (0x1002), [code] "{rdi}" (0x1002),
[val] "{rsi}" (value), [val] "{rsi}" (value),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true }
); );
} }
@ -21,7 +21,7 @@ fn getFs() c_ulong {
: [number] "{rax}" (158), : [number] "{rax}" (158),
[code] "{rdi}" (0x1003), [code] "{rdi}" (0x1003),
[ptr] "{rsi}" (@intFromPtr(&result)), [ptr] "{rsi}" (@intFromPtr(&result)),
: "rcx", "r11", "memory" : .{ .rcx = true, .r11 = true, .memory = true }
); );
return result; return result;
} }

View File

@ -38,20 +38,38 @@ pub fn build(b: *std.Build) void {
"../../tools/gen_spirv_spec.zig", "../../tools/gen_spirv_spec.zig",
"../../tools/gen_stubs.zig", "../../tools/gen_stubs.zig",
"../../tools/generate_c_size_and_align_checks.zig", "../../tools/generate_c_size_and_align_checks.zig",
"../../tools/generate_JSONTestSuite.zig",
"../../tools/generate_linux_syscalls.zig", "../../tools/generate_linux_syscalls.zig",
"../../tools/process_headers.zig", "../../tools/process_headers.zig",
"../../tools/migrate_langref.zig",
"../../tools/update-linux-headers.zig", "../../tools/update-linux-headers.zig",
"../../tools/update_clang_options.zig", "../../tools/update_clang_options.zig",
"../../tools/update_cpu_features.zig", "../../tools/update_cpu_features.zig",
"../../tools/update_crc_catalog.zig",
"../../tools/update_freebsd_libc.zig", "../../tools/update_freebsd_libc.zig",
"../../tools/update_glibc.zig", "../../tools/update_glibc.zig",
"../../tools/update_mingw.zig",
"../../tools/update_netbsd_libc.zig", "../../tools/update_netbsd_libc.zig",
}) |tool_src_path| {
if (std.mem.endsWith(u8, tool_src_path, "dump-cov.zig") and tools_target.result.os.tag == .windows) continue;
const tool = b.addExecutable(.{
.name = std.fs.path.stem(tool_src_path),
.root_module = b.createModule(.{
.root_source_file = b.path(tool_src_path),
.target = tools_target,
}),
});
tools_tests_step.dependOn(&tool.step);
}
for ([_][]const u8{
// Alphabetically sorted. Only ones with `test` blocks.
"../../tools/doctest.zig",
}) |tool_src_path| { }) |tool_src_path| {
const tool = b.addTest(.{ const tool = b.addTest(.{
.name = std.fs.path.stem(tool_src_path), .name = std.fs.path.stem(tool_src_path),
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.root_source_file = b.path(tool_src_path), .root_source_file = b.path(tool_src_path),
.optimize = .Debug,
.target = tools_target, .target = tools_target,
}), }),
}); });

View File

@ -31,7 +31,7 @@ noinline fn frame2(expected: *[4]usize, unwound: *[4]usize) void {
\\movl $7, %%edi \\movl $7, %%edi
\\movl $6, %%esi \\movl $6, %%esi
\\movl $5, %%ebp \\movl $5, %%ebp
::: "ebx", "ecx", "edx", "edi", "esi", "ebp"); ::: .{ .ebx = true, .ecx = true, .edx = true, .edi = true, .esi = true, .ebp = true });
} else { } else {
asm volatile ( asm volatile (
\\movl $3, %%ebx \\movl $3, %%ebx
@ -39,7 +39,7 @@ noinline fn frame2(expected: *[4]usize, unwound: *[4]usize) void {
\\movl $2, %%edx \\movl $2, %%edx
\\movl $7, %%edi \\movl $7, %%edi
\\movl $6, %%esi \\movl $6, %%esi
::: "ebx", "ecx", "edx", "edi", "esi"); ::: .{ .ebx = true, .ecx = true, .edx = true, .edi = true, .esi = true });
} }
}, },
.x86_64 => { .x86_64 => {
@ -51,7 +51,7 @@ noinline fn frame2(expected: *[4]usize, unwound: *[4]usize) void {
\\movq $14, %%r14 \\movq $14, %%r14
\\movq $15, %%r15 \\movq $15, %%r15
\\movq $6, %%rbp \\movq $6, %%rbp
::: "rbx", "r12", "r13", "r14", "r15", "rbp"); ::: .{ .rbx = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .rbp = true });
} else { } else {
asm volatile ( asm volatile (
\\movq $3, %%rbx \\movq $3, %%rbx
@ -59,7 +59,7 @@ noinline fn frame2(expected: *[4]usize, unwound: *[4]usize) void {
\\movq $13, %%r13 \\movq $13, %%r13
\\movq $14, %%r14 \\movq $14, %%r14
\\movq $15, %%r15 \\movq $15, %%r15
::: "rbx", "r12", "r13", "r14", "r15"); ::: .{ .rbx = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true });
} }
}, },
else => {}, else => {},

View File

@ -58,8 +58,7 @@ export fn _start() callconv(.c) noreturn {
\\syscall \\syscall
: :
: [missed] "{edi}" (missed), : [missed] "{edi}" (missed),
: "edi", "eax" : .{ .edi = true, .eax = true });
);
while (true) {} // unreached while (true) {} // unreached
} }

View File

@ -847,6 +847,7 @@ const test_targets = blk: {
.arch_os_abi = "riscv32-linux-none", .arch_os_abi = "riscv32-linux-none",
.cpu_features = "baseline-d-f", .cpu_features = "baseline-d-f",
}) catch unreachable, }) catch unreachable,
.extra_target = true,
}, },
.{ .{
.target = .{ .target = .{
@ -872,6 +873,7 @@ const test_targets = blk: {
.cpu_features = "baseline-d-f", .cpu_features = "baseline-d-f",
}) catch unreachable, }) catch unreachable,
.link_libc = true, .link_libc = true,
.extra_target = true,
}, },
.{ .{
.target = .{ .target = .{
@ -904,6 +906,7 @@ const test_targets = blk: {
.arch_os_abi = "riscv64-linux-none", .arch_os_abi = "riscv64-linux-none",
.cpu_features = "baseline-d-f", .cpu_features = "baseline-d-f",
}) catch unreachable, }) catch unreachable,
.extra_target = true,
}, },
.{ .{
.target = .{ .target = .{
@ -929,6 +932,7 @@ const test_targets = blk: {
.cpu_features = "baseline-d-f", .cpu_features = "baseline-d-f",
}) catch unreachable, }) catch unreachable,
.link_libc = true, .link_libc = true,
.extra_target = true,
}, },
.{ .{
.target = .{ .target = .{

View File

@ -87,7 +87,7 @@ pub fn main() anyerror!void {
const sysroot_path = sysroot orelse blk: { const sysroot_path = sysroot orelse blk: {
const target = try std.zig.system.resolveTargetQuery(.{}); const target = try std.zig.system.resolveTargetQuery(.{});
break :blk std.zig.system.darwin.getSdk(allocator, target) orelse break :blk std.zig.system.darwin.getSdk(allocator, &target) orelse
fatal("no SDK found; you can provide one explicitly with '--sysroot' flag", .{}); fatal("no SDK found; you can provide one explicitly with '--sysroot' flag", .{});
}; };
@ -112,7 +112,7 @@ pub fn main() anyerror!void {
15 => .sequoia, 15 => .sequoia,
else => unreachable, else => unreachable,
}; };
info("found SDK deployment target macOS {} aka '{s}'", .{ version, @tagName(os_ver) }); info("found SDK deployment target macOS {f} aka '{s}'", .{ version, @tagName(os_ver) });
var tmp = tmpDir(.{}); var tmp = tmpDir(.{});
defer tmp.cleanup(); defer tmp.cleanup();
@ -198,7 +198,7 @@ fn fetchTarget(
var dirs = std.StringHashMap(fs.Dir).init(arena); var dirs = std.StringHashMap(fs.Dir).init(arena);
try dirs.putNoClobber(".", dest_dir); try dirs.putNoClobber(".", dest_dir);
const headers_list_str = try headers_list_file.reader().readAllAlloc(arena, std.math.maxInt(usize)); const headers_list_str = try headers_list_file.deprecatedReader().readAllAlloc(arena, std.math.maxInt(usize));
const prefix = "/usr/include"; const prefix = "/usr/include";
var it = mem.splitScalar(u8, headers_list_str, '\n'); var it = mem.splitScalar(u8, headers_list_str, '\n');
@ -270,12 +270,8 @@ const Version = struct {
pub fn format( pub fn format(
v: Version, v: Version,
comptime unused_fmt_string: []const u8, writer: *std.Io.Writer,
options: std.fmt.FormatOptions, ) std.Io.Writer.Error!void {
writer: anytype,
) !void {
_ = unused_fmt_string;
_ = options;
try writer.print("{d}.{d}.{d}", .{ v.major, v.minor, v.patch }); try writer.print("{d}.{d}.{d}", .{ v.major, v.minor, v.patch });
} }
}; };

View File

@ -303,7 +303,7 @@ pub fn main() !void {
libc_so_path, libc_so_path,
100 * 1024 * 1024, 100 * 1024 * 1024,
1 * 1024 * 1024, 1 * 1024 * 1024,
@alignOf(elf.Elf64_Ehdr), .of(elf.Elf64_Ehdr),
null, null,
) catch |err| { ) catch |err| {
std.debug.panic("unable to read '{s}/{s}': {s}", .{ std.debug.panic("unable to read '{s}/{s}': {s}", .{

View File

@ -477,7 +477,7 @@ fn processPreprocessedFile(
const name = (getOverridenNameNew(value) orelse sys_name)["sys_".len..]; const name = (getOverridenNameNew(value) orelse sys_name)["sys_".len..];
const fixed_name = if (stdlib_renames_new.get(name)) |f| f else if (stdlib_renames.get(name)) |f| f else name; const fixed_name = if (stdlib_renames_new.get(name)) |f| f else if (stdlib_renames.get(name)) |f| f else name;
try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), value }); try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), value });
} }
} }
@ -510,7 +510,7 @@ fn processTableBasedArch(
} }
const fixed_name = if (filters.fixedName) |fixedNameFn| fixedNameFn(name) else name; const fixed_name = if (filters.fixedName) |fixedNameFn| fixedNameFn(name) else name;
try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
} }
} }
@ -543,7 +543,7 @@ fn processMipsBasedArch(
} }
const fixed_name = if (filters.fixedName) |fixedNameFn| fixedNameFn(name) else name; const fixed_name = if (filters.fixedName) |fixedNameFn| fixedNameFn(name) else name;
try writer.print(" {p} = linux_base + {s},\n", .{ zig.fmtId(fixed_name), number }); try writer.print(" {f} = linux_base + {s},\n", .{ zig.fmtId(fixed_name), number });
} }
} }
@ -568,12 +568,12 @@ fn processPowerPcBasedArch(
if (mem.eql(u8, abi, "spu")) { if (mem.eql(u8, abi, "spu")) {
continue; continue;
} else if (mem.eql(u8, abi, "32")) { } else if (mem.eql(u8, abi, "32")) {
try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
} else if (mem.eql(u8, abi, "64")) { } else if (mem.eql(u8, abi, "64")) {
try optional_writer.?.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); try optional_writer.?.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
} else { // common/nospu } else { // common/nospu
try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
try optional_writer.?.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); try optional_writer.?.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
} }
} }
} }

View File

@ -27,9 +27,9 @@ pub fn main() !void {
var out_dir = try fs.cwd().openDir(fs.path.dirname(output_file).?, .{}); var out_dir = try fs.cwd().openDir(fs.path.dirname(output_file).?, .{});
defer out_dir.close(); defer out_dir.close();
const input_file_bytes = try in_file.reader().readAllAlloc(arena, std.math.maxInt(u32)); const input_file_bytes = try in_file.deprecatedReader().readAllAlloc(arena, std.math.maxInt(u32));
var buffered_writer = io.bufferedWriter(out_file.writer()); var buffered_writer = io.bufferedWriter(out_file.deprecatedWriter());
var tokenizer = Tokenizer.init(input_file, input_file_bytes); var tokenizer = Tokenizer.init(input_file, input_file_bytes);
@ -388,39 +388,39 @@ fn walk(arena: Allocator, tokenizer: *Tokenizer, out_dir: std.fs.Dir, w: anytype
try file.writeAll("\n\n"); try file.writeAll("\n\n");
if (just_check_syntax) { if (just_check_syntax) {
try file.writer().print("// syntax\n", .{}); try file.deprecatedWriter().print("// syntax\n", .{});
} else switch (code_kind_id) { } else switch (code_kind_id) {
.@"test" => try file.writer().print("// test\n", .{}), .@"test" => try file.deprecatedWriter().print("// test\n", .{}),
.lib => try file.writer().print("// lib\n", .{}), .lib => try file.deprecatedWriter().print("// lib\n", .{}),
.test_error => |s| try file.writer().print("// test_error={s}\n", .{s}), .test_error => |s| try file.deprecatedWriter().print("// test_error={s}\n", .{s}),
.test_safety => |s| try file.writer().print("// test_safety={s}\n", .{s}), .test_safety => |s| try file.deprecatedWriter().print("// test_safety={s}\n", .{s}),
.exe => |s| try file.writer().print("// exe={s}\n", .{@tagName(s)}), .exe => |s| try file.deprecatedWriter().print("// exe={s}\n", .{@tagName(s)}),
.obj => |opt| if (opt) |s| { .obj => |opt| if (opt) |s| {
try file.writer().print("// obj={s}\n", .{s}); try file.deprecatedWriter().print("// obj={s}\n", .{s});
} else { } else {
try file.writer().print("// obj\n", .{}); try file.deprecatedWriter().print("// obj\n", .{});
}, },
} }
if (mode != .Debug) if (mode != .Debug)
try file.writer().print("// optimize={s}\n", .{@tagName(mode)}); try file.deprecatedWriter().print("// optimize={s}\n", .{@tagName(mode)});
for (link_objects.items) |link_object| { for (link_objects.items) |link_object| {
try file.writer().print("// link_object={s}\n", .{link_object}); try file.deprecatedWriter().print("// link_object={s}\n", .{link_object});
} }
if (target_str) |s| if (target_str) |s|
try file.writer().print("// target={s}\n", .{s}); try file.deprecatedWriter().print("// target={s}\n", .{s});
if (link_libc) try file.writer().print("// link_libc\n", .{}); if (link_libc) try file.deprecatedWriter().print("// link_libc\n", .{});
if (disable_cache) try file.writer().print("// disable_cache\n", .{}); if (disable_cache) try file.deprecatedWriter().print("// disable_cache\n", .{});
if (verbose_cimport) try file.writer().print("// verbose_cimport\n", .{}); if (verbose_cimport) try file.deprecatedWriter().print("// verbose_cimport\n", .{});
if (link_mode) |m| if (link_mode) |m|
try file.writer().print("// link_mode={s}\n", .{@tagName(m)}); try file.deprecatedWriter().print("// link_mode={s}\n", .{@tagName(m)});
for (additional_options.items) |o| { for (additional_options.items) |o| {
try file.writer().print("// additional_option={s}\n", .{o}); try file.deprecatedWriter().print("// additional_option={s}\n", .{o});
} }
try w.print("{{#code|{s}#}}\n", .{basename}); try w.print("{{#code|{s}#}}\n", .{basename});
} else { } else {

View File

@ -266,10 +266,10 @@ pub fn main() !void {
if (gop.found_existing) { if (gop.found_existing) {
max_bytes_saved += raw_bytes.len; max_bytes_saved += raw_bytes.len;
gop.value_ptr.hit_count += 1; gop.value_ptr.hit_count += 1;
std.debug.print("duplicate: {s} {s} ({:2})\n", .{ std.debug.print("duplicate: {s} {s} ({B})\n", .{
libc_dir, libc_dir,
rel_path, rel_path,
std.fmt.fmtIntSizeDec(raw_bytes.len), raw_bytes.len,
}); });
} else { } else {
gop.value_ptr.* = Contents{ gop.value_ptr.* = Contents{
@ -311,9 +311,9 @@ pub fn main() !void {
std.debug.print("warning: libc target not found: {s}\n", .{libc_dir}); std.debug.print("warning: libc target not found: {s}\n", .{libc_dir});
} }
} }
std.debug.print("summary: {:2} could be reduced to {:2}\n", .{ std.debug.print("summary: {B} could be reduced to {B}\n", .{
std.fmt.fmtIntSizeDec(total_bytes), total_bytes,
std.fmt.fmtIntSizeDec(total_bytes - max_bytes_saved), total_bytes - max_bytes_saved,
}); });
try std.fs.cwd().makePath(out_dir); try std.fs.cwd().makePath(out_dir);
@ -343,8 +343,8 @@ pub fn main() !void {
if (contender.hit_count > 1) { if (contender.hit_count > 1) {
const this_missed_bytes = contender.hit_count * contender.bytes.len; const this_missed_bytes = contender.hit_count * contender.bytes.len;
missed_opportunity_bytes += this_missed_bytes; missed_opportunity_bytes += this_missed_bytes;
std.debug.print("Missed opportunity ({:2}): {s}\n", .{ std.debug.print("Missed opportunity ({B}): {s}\n", .{
std.fmt.fmtIntSizeDec(this_missed_bytes), this_missed_bytes,
path_kv.key_ptr.*, path_kv.key_ptr.*,
}); });
} else break; } else break;

View File

@ -218,10 +218,10 @@ pub fn main() !void {
if (gop.found_existing) { if (gop.found_existing) {
max_bytes_saved += raw_bytes.len; max_bytes_saved += raw_bytes.len;
gop.value_ptr.hit_count += 1; gop.value_ptr.hit_count += 1;
std.debug.print("duplicate: {s} {s} ({:2})\n", .{ std.debug.print("duplicate: {s} {s} ({B})\n", .{
linux_target.name, linux_target.name,
rel_path, rel_path,
std.fmt.fmtIntSizeDec(raw_bytes.len), raw_bytes.len,
}); });
} else { } else {
gop.value_ptr.* = Contents{ gop.value_ptr.* = Contents{
@ -249,9 +249,9 @@ pub fn main() !void {
std.debug.print("warning: libc target not found: {s}\n", .{linux_target.name}); std.debug.print("warning: libc target not found: {s}\n", .{linux_target.name});
} }
} }
std.debug.print("summary: {:2} could be reduced to {:2}\n", .{ std.debug.print("summary: {B} could be reduced to {B}\n", .{
std.fmt.fmtIntSizeDec(total_bytes), total_bytes,
std.fmt.fmtIntSizeDec(total_bytes - max_bytes_saved), total_bytes - max_bytes_saved,
}); });
try std.fs.cwd().makePath(out_dir); try std.fs.cwd().makePath(out_dir);
@ -281,8 +281,8 @@ pub fn main() !void {
if (contender.hit_count > 1) { if (contender.hit_count > 1) {
const this_missed_bytes = contender.hit_count * contender.bytes.len; const this_missed_bytes = contender.hit_count * contender.bytes.len;
missed_opportunity_bytes += this_missed_bytes; missed_opportunity_bytes += this_missed_bytes;
std.debug.print("Missed opportunity ({:2}): {s}\n", .{ std.debug.print("Missed opportunity ({B}): {s}\n", .{
std.fmt.fmtIntSizeDec(this_missed_bytes), this_missed_bytes,
path_kv.key_ptr.*, path_kv.key_ptr.*,
}); });
} else break; } else break;

View File

@ -635,7 +635,7 @@ pub fn main() anyerror!void {
const args = try std.process.argsAlloc(allocator); const args = try std.process.argsAlloc(allocator);
var stdout_buffer: [4000]u8 = undefined; var stdout_buffer: [4000]u8 = undefined;
var stdout_writer = fs.stdout().writerStreaming(&stdout_buffer); var stdout_writer = fs.File.stdout().writerStreaming(&stdout_buffer);
const stdout = &stdout_writer.interface; const stdout = &stdout_writer.interface;
if (args.len <= 1) printUsageAndExit(args[0]); if (args.len <= 1) printUsageAndExit(args[0]);
@ -767,7 +767,7 @@ pub fn main() anyerror!void {
try stdout.print( try stdout.print(
\\.{{ \\.{{
\\ .name = "{s}", \\ .name = "{s}",
\\ .syntax = {s}, \\ .syntax = {f},
\\ .zig_equivalent = .{s}, \\ .zig_equivalent = .{s},
\\ .pd1 = {}, \\ .pd1 = {},
\\ .pd2 = {}, \\ .pd2 = {},
@ -797,7 +797,7 @@ pub fn main() anyerror!void {
try stdout.print( try stdout.print(
\\.{{ \\.{{
\\ .name = "{s}", \\ .name = "{s}",
\\ .syntax = {s}, \\ .syntax = {f},
\\ .zig_equivalent = .other, \\ .zig_equivalent = .other,
\\ .pd1 = {}, \\ .pd1 = {},
\\ .pd2 = {}, \\ .pd2 = {},
@ -845,14 +845,10 @@ const Syntax = union(enum) {
pub fn format( pub fn format(
self: Syntax, self: Syntax,
comptime fmt: []const u8, out_stream: *std.Io.Writer,
options: std.fmt.FormatOptions, ) std.Io.Writer.Error!void {
out_stream: anytype,
) !void {
_ = fmt;
_ = options;
switch (self) { switch (self) {
.multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }), .multi_arg => |n| return out_stream.print(".{{.{t}={d}}}", .{ self, n }),
else => return out_stream.print(".{s}", .{@tagName(self)}), else => return out_stream.print(".{s}", .{@tagName(self)}),
} }
} }

View File

@ -1906,7 +1906,7 @@ fn processOneTarget(job: Job) void {
var zig_code_file = try target_dir.createFile(zig_code_basename, .{}); var zig_code_file = try target_dir.createFile(zig_code_basename, .{});
defer zig_code_file.close(); defer zig_code_file.close();
var bw = std.io.bufferedWriter(zig_code_file.writer()); var bw = std.io.bufferedWriter(zig_code_file.deprecatedWriter());
const w = bw.writer(); const w = bw.writer();
try w.writeAll( try w.writeAll(
@ -1920,7 +1920,7 @@ fn processOneTarget(job: Job) void {
); );
for (all_features.items, 0..) |feature, i| { for (all_features.items, 0..) |feature, i| {
try w.print("\n {p},", .{std.zig.fmtId(feature.zig_name)}); try w.print("\n {f},", .{std.zig.fmtId(feature.zig_name)});
if (i == all_features.items.len - 1) try w.writeAll("\n"); if (i == all_features.items.len - 1) try w.writeAll("\n");
} }
@ -1949,27 +1949,27 @@ fn processOneTarget(job: Job) void {
for (all_features.items) |feature| { for (all_features.items) |feature| {
if (feature.llvm_name) |llvm_name| { if (feature.llvm_name) |llvm_name| {
try w.print( try w.print(
\\ result[@intFromEnum(Feature.{p_})] = .{{ \\ result[@intFromEnum(Feature.{f})] = .{{
\\ .llvm_name = "{}", \\ .llvm_name = "{f}",
\\ .description = "{}", \\ .description = "{f}",
\\ .dependencies = featureSet(&[_]Feature{{ \\ .dependencies = featureSet(&[_]Feature{{
, ,
.{ .{
std.zig.fmtId(feature.zig_name), std.zig.fmtIdPU(feature.zig_name),
std.zig.fmtEscapes(llvm_name), std.zig.fmtString(llvm_name),
std.zig.fmtEscapes(feature.desc), std.zig.fmtString(feature.desc),
}, },
); );
} else { } else {
try w.print( try w.print(
\\ result[@intFromEnum(Feature.{p_})] = .{{ \\ result[@intFromEnum(Feature.{f})] = .{{
\\ .llvm_name = null, \\ .llvm_name = null,
\\ .description = "{}", \\ .description = "{f}",
\\ .dependencies = featureSet(&[_]Feature{{ \\ .dependencies = featureSet(&[_]Feature{{
, ,
.{ .{
std.zig.fmtId(feature.zig_name), std.zig.fmtIdPU(feature.zig_name),
std.zig.fmtEscapes(feature.desc), std.zig.fmtString(feature.desc),
}, },
); );
} }
@ -1996,7 +1996,7 @@ fn processOneTarget(job: Job) void {
} else { } else {
try w.writeAll("\n"); try w.writeAll("\n");
for (dependencies.items) |dep| { for (dependencies.items) |dep| {
try w.print(" .{p_},\n", .{std.zig.fmtId(dep)}); try w.print(" .{f},\n", .{std.zig.fmtIdPU(dep)});
} }
try w.writeAll( try w.writeAll(
\\ }), \\ }),
@ -2033,24 +2033,24 @@ fn processOneTarget(job: Job) void {
mem.sort([]const u8, cpu_features.items, {}, asciiLessThan); mem.sort([]const u8, cpu_features.items, {}, asciiLessThan);
if (cpu.llvm_name) |llvm_name| { if (cpu.llvm_name) |llvm_name| {
try w.print( try w.print(
\\ pub const {}: CpuModel = .{{ \\ pub const {f}: CpuModel = .{{
\\ .name = "{}", \\ .name = "{f}",
\\ .llvm_name = "{}", \\ .llvm_name = "{f}",
\\ .features = featureSet(&[_]Feature{{ \\ .features = featureSet(&[_]Feature{{
, .{ , .{
std.zig.fmtId(cpu.zig_name), std.zig.fmtId(cpu.zig_name),
std.zig.fmtEscapes(cpu.zig_name), std.zig.fmtString(cpu.zig_name),
std.zig.fmtEscapes(llvm_name), std.zig.fmtString(llvm_name),
}); });
} else { } else {
try w.print( try w.print(
\\ pub const {}: CpuModel = .{{ \\ pub const {f}: CpuModel = .{{
\\ .name = "{}", \\ .name = "{f}",
\\ .llvm_name = null, \\ .llvm_name = null,
\\ .features = featureSet(&[_]Feature{{ \\ .features = featureSet(&[_]Feature{{
, .{ , .{
std.zig.fmtId(cpu.zig_name), std.zig.fmtId(cpu.zig_name),
std.zig.fmtEscapes(cpu.zig_name), std.zig.fmtString(cpu.zig_name),
}); });
} }
if (cpu_features.items.len == 0) { if (cpu_features.items.len == 0) {
@ -2062,7 +2062,7 @@ fn processOneTarget(job: Job) void {
} else { } else {
try w.writeAll("\n"); try w.writeAll("\n");
for (cpu_features.items) |feature_zig_name| { for (cpu_features.items) |feature_zig_name| {
try w.print(" .{p_},\n", .{std.zig.fmtId(feature_zig_name)}); try w.print(" .{f},\n", .{std.zig.fmtIdPU(feature_zig_name)});
} }
try w.writeAll( try w.writeAll(
\\ }), \\ }),

View File

@ -30,7 +30,7 @@ pub fn main() anyerror!void {
var zig_code_file = try hash_target_dir.createFile("crc.zig", .{}); var zig_code_file = try hash_target_dir.createFile("crc.zig", .{});
defer zig_code_file.close(); defer zig_code_file.close();
var cbw = std.io.bufferedWriter(zig_code_file.writer()); var cbw = std.io.bufferedWriter(zig_code_file.deprecatedWriter());
defer cbw.flush() catch unreachable; defer cbw.flush() catch unreachable;
const code_writer = cbw.writer(); const code_writer = cbw.writer();
@ -55,7 +55,7 @@ pub fn main() anyerror!void {
var zig_test_file = try crc_target_dir.createFile("test.zig", .{}); var zig_test_file = try crc_target_dir.createFile("test.zig", .{});
defer zig_test_file.close(); defer zig_test_file.close();
var tbw = std.io.bufferedWriter(zig_test_file.writer()); var tbw = std.io.bufferedWriter(zig_test_file.deprecatedWriter());
defer tbw.flush() catch unreachable; defer tbw.flush() catch unreachable;
const test_writer = tbw.writer(); const test_writer = tbw.writer();