Merge pull request #24419 from ziglang/asm-clobbers

inline assembly: use types for clobbers
This commit is contained in:
Andrew Kelley 2025-07-17 02:14:18 +02:00 committed by GitHub
commit 680358767e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
65 changed files with 3384 additions and 889 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
// output. In this example we list $rcx and $r11 because it is known the
// kernel syscall does not preserve these registers.
: "rcx", "r11"
);
: .{ .rcx = true, .r11 = true });
}
// syntax

View File

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

View File

@ -28,8 +28,7 @@ fn __aarch64_cas1_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp1_relax() align(16) callconv(.naked) void {
@ -48,8 +47,7 @@ fn __aarch64_swp1_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd1_relax() align(16) callconv(.naked) void {
@ -69,8 +67,7 @@ fn __aarch64_ldadd1_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr1_relax() align(16) callconv(.naked) void {
@ -90,8 +87,7 @@ fn __aarch64_ldclr1_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor1_relax() align(16) callconv(.naked) void {
@ -111,8 +107,7 @@ fn __aarch64_ldeor1_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset1_relax() align(16) callconv(.naked) void {
@ -132,8 +127,7 @@ fn __aarch64_ldset1_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas1_acq() align(16) callconv(.naked) void {
@ -154,8 +148,7 @@ fn __aarch64_cas1_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp1_acq() align(16) callconv(.naked) void {
@ -174,8 +167,7 @@ fn __aarch64_swp1_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd1_acq() align(16) callconv(.naked) void {
@ -195,8 +187,7 @@ fn __aarch64_ldadd1_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr1_acq() align(16) callconv(.naked) void {
@ -216,8 +207,7 @@ fn __aarch64_ldclr1_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor1_acq() align(16) callconv(.naked) void {
@ -237,8 +227,7 @@ fn __aarch64_ldeor1_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset1_acq() align(16) callconv(.naked) void {
@ -258,8 +247,7 @@ fn __aarch64_ldset1_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas1_rel() align(16) callconv(.naked) void {
@ -280,8 +268,7 @@ fn __aarch64_cas1_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp1_rel() align(16) callconv(.naked) void {
@ -300,8 +287,7 @@ fn __aarch64_swp1_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd1_rel() align(16) callconv(.naked) void {
@ -321,8 +307,7 @@ fn __aarch64_ldadd1_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr1_rel() align(16) callconv(.naked) void {
@ -342,8 +327,7 @@ fn __aarch64_ldclr1_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor1_rel() align(16) callconv(.naked) void {
@ -363,8 +347,7 @@ fn __aarch64_ldeor1_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset1_rel() align(16) callconv(.naked) void {
@ -384,8 +367,7 @@ fn __aarch64_ldset1_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas2_relax() align(16) callconv(.naked) void {
@ -532,8 +508,7 @@ fn __aarch64_cas2_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp2_relax() align(16) callconv(.naked) void {
@ -552,8 +527,7 @@ fn __aarch64_swp2_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd2_relax() align(16) callconv(.naked) void {
@ -573,8 +547,7 @@ fn __aarch64_ldadd2_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr2_relax() align(16) callconv(.naked) void {
@ -594,8 +567,7 @@ fn __aarch64_ldclr2_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor2_relax() align(16) callconv(.naked) void {
@ -615,8 +587,7 @@ fn __aarch64_ldeor2_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset2_relax() align(16) callconv(.naked) void {
@ -636,8 +607,7 @@ fn __aarch64_ldset2_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas2_acq() align(16) callconv(.naked) void {
@ -658,8 +628,7 @@ fn __aarch64_cas2_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp2_acq() align(16) callconv(.naked) void {
@ -678,8 +647,7 @@ fn __aarch64_swp2_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd2_acq() align(16) callconv(.naked) void {
@ -699,8 +667,7 @@ fn __aarch64_ldadd2_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr2_acq() align(16) callconv(.naked) void {
@ -720,8 +687,7 @@ fn __aarch64_ldclr2_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor2_acq() align(16) callconv(.naked) void {
@ -741,8 +707,7 @@ fn __aarch64_ldeor2_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset2_acq() align(16) callconv(.naked) void {
@ -762,8 +727,7 @@ fn __aarch64_ldset2_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas2_rel() align(16) callconv(.naked) void {
@ -784,8 +748,7 @@ fn __aarch64_cas2_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp2_rel() align(16) callconv(.naked) void {
@ -804,8 +767,7 @@ fn __aarch64_swp2_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd2_rel() align(16) callconv(.naked) void {
@ -825,8 +787,7 @@ fn __aarch64_ldadd2_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr2_rel() align(16) callconv(.naked) void {
@ -846,8 +807,7 @@ fn __aarch64_ldclr2_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor2_rel() align(16) callconv(.naked) void {
@ -867,8 +827,7 @@ fn __aarch64_ldeor2_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset2_rel() align(16) callconv(.naked) void {
@ -888,8 +847,7 @@ fn __aarch64_ldset2_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas4_relax() align(16) callconv(.naked) void {
@ -1036,8 +988,7 @@ fn __aarch64_cas4_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp4_relax() align(16) callconv(.naked) void {
@ -1056,8 +1007,7 @@ fn __aarch64_swp4_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd4_relax() align(16) callconv(.naked) void {
@ -1077,8 +1027,7 @@ fn __aarch64_ldadd4_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr4_relax() align(16) callconv(.naked) void {
@ -1098,8 +1047,7 @@ fn __aarch64_ldclr4_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor4_relax() align(16) callconv(.naked) void {
@ -1119,8 +1067,7 @@ fn __aarch64_ldeor4_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset4_relax() align(16) callconv(.naked) void {
@ -1140,8 +1087,7 @@ fn __aarch64_ldset4_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas4_acq() align(16) callconv(.naked) void {
@ -1162,8 +1108,7 @@ fn __aarch64_cas4_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp4_acq() align(16) callconv(.naked) void {
@ -1182,8 +1127,7 @@ fn __aarch64_swp4_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd4_acq() align(16) callconv(.naked) void {
@ -1203,8 +1147,7 @@ fn __aarch64_ldadd4_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr4_acq() align(16) callconv(.naked) void {
@ -1224,8 +1167,7 @@ fn __aarch64_ldclr4_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor4_acq() align(16) callconv(.naked) void {
@ -1245,8 +1187,7 @@ fn __aarch64_ldeor4_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset4_acq() align(16) callconv(.naked) void {
@ -1266,8 +1207,7 @@ fn __aarch64_ldset4_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas4_rel() align(16) callconv(.naked) void {
@ -1288,8 +1228,7 @@ fn __aarch64_cas4_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp4_rel() align(16) callconv(.naked) void {
@ -1308,8 +1247,7 @@ fn __aarch64_swp4_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd4_rel() align(16) callconv(.naked) void {
@ -1329,8 +1267,7 @@ fn __aarch64_ldadd4_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr4_rel() align(16) callconv(.naked) void {
@ -1350,8 +1287,7 @@ fn __aarch64_ldclr4_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor4_rel() align(16) callconv(.naked) void {
@ -1371,8 +1307,7 @@ fn __aarch64_ldeor4_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset4_rel() align(16) callconv(.naked) void {
@ -1392,8 +1327,7 @@ fn __aarch64_ldset4_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas8_relax() align(16) callconv(.naked) void {
@ -1540,8 +1468,7 @@ fn __aarch64_cas8_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp8_relax() align(16) callconv(.naked) void {
@ -1560,8 +1487,7 @@ fn __aarch64_swp8_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd8_relax() align(16) callconv(.naked) void {
@ -1581,8 +1507,7 @@ fn __aarch64_ldadd8_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr8_relax() align(16) callconv(.naked) void {
@ -1602,8 +1527,7 @@ fn __aarch64_ldclr8_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor8_relax() align(16) callconv(.naked) void {
@ -1623,8 +1547,7 @@ fn __aarch64_ldeor8_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset8_relax() align(16) callconv(.naked) void {
@ -1644,8 +1567,7 @@ fn __aarch64_ldset8_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas8_acq() align(16) callconv(.naked) void {
@ -1666,8 +1588,7 @@ fn __aarch64_cas8_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp8_acq() align(16) callconv(.naked) void {
@ -1686,8 +1607,7 @@ fn __aarch64_swp8_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd8_acq() align(16) callconv(.naked) void {
@ -1707,8 +1627,7 @@ fn __aarch64_ldadd8_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr8_acq() align(16) callconv(.naked) void {
@ -1728,8 +1647,7 @@ fn __aarch64_ldclr8_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor8_acq() align(16) callconv(.naked) void {
@ -1749,8 +1667,7 @@ fn __aarch64_ldeor8_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset8_acq() align(16) callconv(.naked) void {
@ -1770,8 +1687,7 @@ fn __aarch64_ldset8_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas8_rel() align(16) callconv(.naked) void {
@ -1792,8 +1708,7 @@ fn __aarch64_cas8_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_swp8_rel() align(16) callconv(.naked) void {
@ -1812,8 +1727,7 @@ fn __aarch64_swp8_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldadd8_rel() align(16) callconv(.naked) void {
@ -1833,8 +1747,7 @@ fn __aarch64_ldadd8_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldclr8_rel() align(16) callconv(.naked) void {
@ -1854,8 +1767,7 @@ fn __aarch64_ldclr8_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldeor8_rel() align(16) callconv(.naked) void {
@ -1875,8 +1787,7 @@ fn __aarch64_ldeor8_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_ldset8_rel() align(16) callconv(.naked) void {
@ -1896,8 +1807,7 @@ fn __aarch64_ldset8_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas16_relax() align(16) callconv(.naked) void {
@ -2046,8 +1950,7 @@ fn __aarch64_cas16_relax() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas16_acq() align(16) callconv(.naked) void {
@ -2070,8 +1973,7 @@ fn __aarch64_cas16_acq() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
fn __aarch64_cas16_rel() align(16) callconv(.naked) void {
@ -2094,8 +1996,7 @@ fn __aarch64_cas16_rel() align(16) callconv(.naked) void {
\\ ret
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}
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
:
: [__aarch64_have_lse_atomics] "{w16}" (__aarch64_have_lse_atomics),
: "w15", "w16", "w17", "memory"
);
: .{ .w15 = true, .w16 = true, .w17 = true, .memory = true });
unreachable;
}

View File

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

View File

@ -71,8 +71,7 @@ const SpinlockTable = struct {
break :flag asm volatile ("ldstub [%[addr]], %[flag]"
: [flag] "=r" (-> @TypeOf(self.v)),
: [addr] "r" (&self.v),
: "memory"
);
: .{ .memory = true });
} else flag: {
break :flag @atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .acquire);
};
@ -88,8 +87,7 @@ const SpinlockTable = struct {
_ = asm volatile ("clrb [%[addr]]"
:
: [addr] "r" (&self.v),
: "memory"
);
: .{ .memory = true });
} else {
@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
[_] "{$4}" (0), // op = MIPS_CACHEFLUSH
[_] "{$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();
} else if (mips and os == .openbsd) {
// TODO

View File

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

View File

@ -1198,8 +1198,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.x86_64 => asm volatile (
\\ movq $11, %%rax # SYS_munmap
\\ syscall
@ -1221,8 +1220,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.aarch64, .aarch64_be => asm volatile (
\\ mov x8, #215 // SYS_munmap
\\ mov x0, %[ptr]
@ -1234,8 +1232,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.hexagon => asm volatile (
\\ r6 = #215 // SYS_munmap
\\ r0 = %[ptr]
@ -1247,8 +1244,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
// 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.
// The bug was introduced in 46e12c07b3b9603c60fc1d421ff18618241cb081 and fixed in
@ -1265,8 +1261,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.mips64, .mips64el => asm volatile (
\\ li $2, 5011 # SYS_munmap
\\ move $4, %[ptr]
@ -1278,8 +1273,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.powerpc, .powerpcle, .powerpc64, .powerpc64le => asm volatile (
\\ li 0, 91 # SYS_munmap
\\ mr 3, %[ptr]
@ -1292,8 +1286,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.riscv32, .riscv64 => asm volatile (
\\ li a7, 215 # SYS_munmap
\\ mv a0, %[ptr]
@ -1305,8 +1298,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.s390x => asm volatile (
\\ lgr %%r2, %[ptr]
\\ lgr %%r3, %[len]
@ -1316,8 +1308,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.sparc => asm volatile (
\\ # See sparc64 comments below.
\\ 1:
@ -1338,8 +1329,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.sparc64 => asm volatile (
\\ # SPARCs really don't like it when active stack frames
\\ # is unmapped (it will result in a segfault), so we
@ -1365,8 +1355,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
.loongarch32, .loongarch64 => asm volatile (
\\ or $a0, $zero, %[ptr]
\\ or $a1, $zero, %[len]
@ -1378,8 +1367,7 @@ const LinuxThreadImpl = struct {
:
: [ptr] "r" (@intFromPtr(self.mapped.ptr)),
[len] "r" (self.mapped.len),
: "memory"
),
: .{ .memory = true }),
else => |cpu_arch| @compileError("Unsupported linux arch: " ++ @tagName(cpu_arch)),
}
unreachable;

View File

@ -1,6 +1,10 @@
//! Types and values provided by the Zig language.
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,
/// so Zig standard library has the subsystem detection logic here. This should generally be
@ -1100,6 +1104,3 @@ pub noinline fn returnError() void {
st.instruction_addresses[st.index] = @returnAddress();
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

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

View File

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

View File

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

View File

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

View File

@ -18,8 +18,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0"
: [ret] "={x0}" (-> usize),
: [number] "{x8}" (@intFromEnum(number)),
: "memory", "cc"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -27,8 +26,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={x0}" (-> usize),
: [number] "{x8}" (@intFromEnum(number)),
[arg1] "{x0}" (arg1),
: "memory", "cc"
);
: .{ .memory = true });
}
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)),
[arg1] "{x0}" (arg1),
[arg2] "{x1}" (arg2),
: "memory", "cc"
);
: .{ .memory = true });
}
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),
[arg2] "{x1}" (arg2),
[arg3] "{x2}" (arg3),
: "memory", "cc"
);
: .{ .memory = true });
}
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),
[arg3] "{x2}" (arg3),
[arg4] "{x3}" (arg4),
: "memory", "cc"
);
: .{ .memory = true });
}
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),
[arg4] "{x3}" (arg4),
[arg5] "{x4}" (arg5),
: "memory", "cc"
);
: .{ .memory = true });
}
pub fn syscall6(
@ -95,8 +89,7 @@ pub fn syscall6(
[arg4] "{x3}" (arg4),
[arg5] "{x4}" (arg5),
[arg6] "{x5}" (arg6),
: "memory", "cc"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -148,14 +141,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ svc #0
:
: [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
: "memory", "cc"
),
: .{ .memory = true }),
else => asm volatile (
\\ svc #0
:
: [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"
: [ret] "={r0}" (-> usize),
: [number] "{r7}" (@intFromEnum(number)),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r0}" (-> usize),
: [number] "{r7}" (@intFromEnum(number)),
[arg1] "{r0}" (arg1),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2),
: "memory"
);
: .{ .memory = true });
}
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),
[arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3),
: "memory"
);
: .{ .memory = true });
}
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),
[arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4),
: "memory"
);
: .{ .memory = true });
}
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),
[arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall6(
@ -94,8 +88,7 @@ pub fn syscall6(
[arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5),
[arg6] "{r5}" (arg6),
: "memory"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -141,14 +134,12 @@ pub fn restore() callconv(.naked) noreturn {
\\ svc #0
:
: [number] "I" (@intFromEnum(SYS.sigreturn)),
: "memory"
),
: .{ .memory = true }),
else => asm volatile (
\\ svc #0
:
: [number] "{r7}" (@intFromEnum(SYS.sigreturn)),
: "memory"
),
: .{ .memory = true }),
}
}
@ -159,14 +150,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ svc #0
:
: [number] "I" (@intFromEnum(SYS.rt_sigreturn)),
: "memory"
),
: .{ .memory = true }),
else => asm volatile (
\\ svc #0
:
: [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)"
: [ret] "={r0}" (-> usize),
: [number] "{r6}" (@intFromEnum(number)),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -24,8 +23,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r0}" (-> usize),
: [number] "{r6}" (@intFromEnum(number)),
[arg1] "{r0}" (arg1),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{r0}" (arg1),
[arg2] "{r1}" (arg2),
: "memory"
);
: .{ .memory = true });
}
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),
[arg2] "{r1}" (arg2),
[arg3] "{r2}" (arg3),
: "memory"
);
: .{ .memory = true });
}
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),
[arg3] "{r2}" (arg3),
[arg4] "{r3}" (arg4),
: "memory"
);
: .{ .memory = true });
}
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),
[arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall6(
@ -92,8 +86,7 @@ pub fn syscall6(
[arg4] "{r3}" (arg4),
[arg5] "{r4}" (arg5),
[arg6] "{r5}" (arg6),
: "memory"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -142,8 +135,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ trap0(#0)
:
: [number] "{r6}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory"
);
: .{ .memory = true });
}
pub const F = struct {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
\\ syscall 0
: [ret] "={$r4}" (-> usize),
: [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 {
@ -27,8 +26,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={$r4}" (-> usize),
: [number] "{$r11}" (@intFromEnum(number)),
[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 {
@ -38,8 +36,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{$r11}" (@intFromEnum(number)),
[arg1] "{$r4}" (arg1),
[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 {
@ -50,8 +47,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{$r4}" (arg1),
[arg2] "{$r5}" (arg2),
[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 {
@ -63,8 +59,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{$r5}" (arg2),
[arg3] "{$r6}" (arg3),
[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 {
@ -77,8 +72,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{$r6}" (arg3),
[arg4] "{$r7}" (arg4),
[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(
@ -100,8 +94,7 @@ pub fn syscall6(
[arg4] "{$r7}" (arg4),
[arg5] "{$r8}" (arg5),
[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 {
@ -150,8 +143,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall 0
:
: [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 {

View File

@ -15,8 +15,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("trap #0"
: [ret] "={d0}" (-> usize),
: [number] "{d0}" (@intFromEnum(number)),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -24,8 +23,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={d0}" (-> usize),
: [number] "{d0}" (@intFromEnum(number)),
[arg1] "{d1}" (arg1),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{d1}" (arg1),
[arg2] "{d2}" (arg2),
: "memory"
);
: .{ .memory = true });
}
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),
[arg2] "{d2}" (arg2),
[arg3] "{d3}" (arg3),
: "memory"
);
: .{ .memory = true });
}
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),
[arg3] "{d3}" (arg3),
[arg4] "{d4}" (arg4),
: "memory"
);
: .{ .memory = true });
}
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),
[arg4] "{d4}" (arg4),
[arg5] "{d5}" (arg5),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall6(
@ -92,8 +86,7 @@ pub fn syscall6(
[arg4] "{d4}" (arg4),
[arg5] "{d5}" (arg5),
[arg6] "{a0}" (arg6),
: "memory"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -155,8 +148,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
asm volatile ("trap #0"
:
: [number] "{d0}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory"
);
: .{ .memory = true });
}
pub const F = struct {

View File

@ -21,8 +21,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1:
: [ret] "={$2}" (-> usize),
: [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 {
@ -41,8 +40,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
: [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(SYS.pipe)),
[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 {
@ -55,8 +53,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(number)),
[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 {
@ -70,8 +67,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{$2}" (@intFromEnum(number)),
[arg1] "{$4}" (arg1),
[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 {
@ -86,8 +82,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{$4}" (arg1),
[arg2] "{$5}" (arg2),
[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 {
@ -103,8 +98,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{$5}" (arg2),
[arg3] "{$6}" (arg3),
[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 {
@ -125,8 +119,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{$6}" (arg3),
[arg4] "{$7}" (arg4),
[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
@ -160,8 +153,7 @@ pub fn syscall6(
[arg4] "{$7}" (arg4),
[arg5] "r" (arg5),
[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(
@ -195,8 +187,7 @@ pub fn syscall7(
[arg5] "r" (arg5),
[arg6] "r" (arg6),
[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 {
@ -255,8 +246,7 @@ pub fn restore() callconv(.naked) noreturn {
\\ syscall
:
: [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 {
@ -264,8 +254,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall
:
: [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 {

View File

@ -21,8 +21,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1:
: [ret] "={$2}" (-> usize),
: [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 {
@ -41,8 +40,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
: [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(SYS.pipe)),
[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 {
@ -56,8 +54,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={$2}" (-> usize),
: [number] "{$2}" (@intFromEnum(number)),
[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 {
@ -71,8 +68,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{$2}" (@intFromEnum(number)),
[arg1] "{$4}" (arg1),
[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 {
@ -87,8 +83,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{$4}" (arg1),
[arg2] "{$5}" (arg2),
[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 {
@ -104,8 +99,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{$5}" (arg2),
[arg3] "{$6}" (arg3),
[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 {
@ -122,8 +116,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{$6}" (arg3),
[arg4] "{$7}" (arg4),
[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(
@ -149,8 +142,7 @@ pub fn syscall6(
[arg4] "{$7}" (arg4),
[arg5] "{$8}" (arg5),
[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(
@ -178,8 +170,7 @@ pub fn syscall7(
[arg5] "{$8}" (arg5),
[arg6] "{$9}" (arg6),
[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 {
@ -234,8 +225,7 @@ pub fn restore() callconv(.naked) noreturn {
\\ syscall
:
: [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 {
@ -243,8 +233,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall
:
: [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 {

View File

@ -22,8 +22,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1:
: [ret] "={r3}" (-> usize),
: [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 {
@ -35,8 +34,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r3}" (-> usize),
: [number] "{r0}" (@intFromEnum(number)),
[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 {
@ -49,8 +47,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{r0}" (@intFromEnum(number)),
[arg1] "{r3}" (arg1),
[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 {
@ -64,8 +61,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r3}" (arg1),
[arg2] "{r4}" (arg2),
[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 {
@ -80,8 +76,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r4}" (arg2),
[arg3] "{r5}" (arg3),
[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 {
@ -97,8 +92,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r5}" (arg3),
[arg4] "{r6}" (arg4),
[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(
@ -123,8 +117,7 @@ pub fn syscall6(
[arg4] "{r6}" (arg4),
[arg5] "{r7}" (arg5),
[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 {
@ -204,8 +197,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ sc
:
: [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 {

View File

@ -22,8 +22,7 @@ pub fn syscall0(number: SYS) usize {
\\ 1:
: [ret] "={r3}" (-> usize),
: [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 {
@ -35,8 +34,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r3}" (-> usize),
: [number] "{r0}" (@intFromEnum(number)),
[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 {
@ -49,8 +47,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
: [number] "{r0}" (@intFromEnum(number)),
[arg1] "{r3}" (arg1),
[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 {
@ -64,8 +61,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
[arg1] "{r3}" (arg1),
[arg2] "{r4}" (arg2),
[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 {
@ -80,8 +76,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{r4}" (arg2),
[arg3] "{r5}" (arg3),
[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 {
@ -97,8 +92,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{r5}" (arg3),
[arg4] "{r6}" (arg4),
[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(
@ -123,8 +117,7 @@ pub fn syscall6(
[arg4] "{r6}" (arg4),
[arg5] "{r7}" (arg5),
[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 {
@ -189,8 +182,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ sc
:
: [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 {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("ecall"
: [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)),
[arg1] "{x10}" (arg1),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{x10}" (arg1),
[arg2] "{x11}" (arg2),
: "memory"
);
: .{ .memory = true });
}
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),
[arg2] "{x11}" (arg2),
[arg3] "{x12}" (arg3),
: "memory"
);
: .{ .memory = true });
}
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),
[arg3] "{x12}" (arg3),
[arg4] "{x13}" (arg4),
: "memory"
);
: .{ .memory = true });
}
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),
[arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall6(
@ -94,8 +88,7 @@ pub fn syscall6(
[arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5),
[arg6] "{x15}" (arg6),
: "memory"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -149,8 +142,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ ecall
:
: [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory"
);
: .{ .memory = true });
}
pub const F = struct {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("ecall"
: [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={x10}" (-> usize),
: [number] "{x17}" (@intFromEnum(number)),
[arg1] "{x10}" (arg1),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{x10}" (arg1),
[arg2] "{x11}" (arg2),
: "memory"
);
: .{ .memory = true });
}
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),
[arg2] "{x11}" (arg2),
[arg3] "{x12}" (arg3),
: "memory"
);
: .{ .memory = true });
}
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),
[arg3] "{x12}" (arg3),
[arg4] "{x13}" (arg4),
: "memory"
);
: .{ .memory = true });
}
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),
[arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall6(
@ -94,8 +88,7 @@ pub fn syscall6(
[arg4] "{x13}" (arg4),
[arg5] "{x14}" (arg5),
[arg6] "{x15}" (arg6),
: "memory"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -149,8 +142,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ ecall
:
: [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory"
);
: .{ .memory = true });
}
pub const F = struct {

View File

@ -17,8 +17,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("svc 0"
: [ret] "={r2}" (-> usize),
: [number] "{r1}" (@intFromEnum(number)),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -26,8 +25,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={r2}" (-> usize),
: [number] "{r1}" (@intFromEnum(number)),
[arg1] "{r2}" (arg1),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{r2}" (arg1),
[arg2] "{r3}" (arg2),
: "memory"
);
: .{ .memory = true });
}
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),
[arg2] "{r3}" (arg2),
[arg3] "{r4}" (arg3),
: "memory"
);
: .{ .memory = true });
}
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),
[arg3] "{r4}" (arg3),
[arg4] "{r5}" (arg4),
: "memory"
);
: .{ .memory = true });
}
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),
[arg4] "{r5}" (arg4),
[arg5] "{r6}" (arg5),
: "memory"
);
: .{ .memory = true });
}
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),
[arg5] "{r6}" (arg5),
[arg6] "{r7}" (arg6),
: "memory"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -161,8 +154,7 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\svc 0
:
: [number] "{r1}" (@intFromEnum(SYS.rt_sigreturn)),
: "memory"
);
: .{ .memory = true });
}
pub const F = struct {

View File

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

View File

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

View File

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

View File

@ -18,8 +18,7 @@ pub fn syscall0(number: SYS) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@intFromEnum(number)),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -27,8 +26,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
: "memory"
);
: .{ .memory = true });
}
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),
[arg2] "{ecx}" (arg2),
[arg3] "{edx}" (arg3),
: "memory"
);
: .{ .memory = true });
}
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),
[arg3] "{edx}" (arg3),
[arg4] "{esi}" (arg4),
: "memory"
);
: .{ .memory = true });
}
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),
[arg4] "{esi}" (arg4),
[arg5] "{edi}" (arg5),
: "memory"
);
: .{ .memory = true });
}
pub fn syscall6(
@ -108,8 +102,7 @@ pub fn syscall6(
[arg4] "{esi}" (arg4),
[arg5] "rm" (arg5),
[arg6] "rm" (arg6),
: "memory"
);
: .{ .memory = true });
}
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)),
[arg1] "{ebx}" (call),
[arg2] "{ecx}" (@intFromPtr(args)),
: "memory"
);
: .{ .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -179,14 +171,12 @@ pub fn restore() callconv(.naked) noreturn {
\\ int $0x80
:
: [number] "i" (@intFromEnum(SYS.sigreturn)),
: "memory"
),
: .{ .memory = true }),
else => asm volatile (
\\ int $0x80
:
: [number] "{eax}" (@intFromEnum(SYS.sigreturn)),
: "memory"
),
: .{ .memory = true }),
}
}
@ -197,14 +187,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ int $0x80
:
: [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
: "memory"
),
: .{ .memory = true }),
else => asm volatile (
\\ int $0x80
:
: [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)),
[sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")),
[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 {
@ -457,6 +444,5 @@ pub inline fn getcontext(context: *ucontext_t) usize {
[_] "={edx}" (clobber_edx),
: [_] "{edx}" (context),
[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"
: [ret] "={rax}" (-> usize),
: [number] "{rax}" (@intFromEnum(number)),
: "rcx", "r11", "memory"
);
: .{ .rcx = true, .r11 = true, .memory = true });
}
pub fn syscall1(number: SYS, arg1: usize) usize {
@ -29,8 +28,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
: [ret] "={rax}" (-> usize),
: [number] "{rax}" (@intFromEnum(number)),
[arg1] "{rdi}" (arg1),
: "rcx", "r11", "memory"
);
: .{ .rcx = true, .r11 = true, .memory = true });
}
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)),
[arg1] "{rdi}" (arg1),
[arg2] "{rsi}" (arg2),
: "rcx", "r11", "memory"
);
: .{ .rcx = true, .r11 = true, .memory = true });
}
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),
[arg2] "{rsi}" (arg2),
[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 {
@ -62,8 +58,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
[arg2] "{rsi}" (arg2),
[arg3] "{rdx}" (arg3),
[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 {
@ -75,8 +70,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
[arg3] "{rdx}" (arg3),
[arg4] "{r10}" (arg4),
[arg5] "{r8}" (arg5),
: "rcx", "r11", "memory"
);
: .{ .rcx = true, .r11 = true, .memory = true });
}
pub fn syscall6(
@ -97,8 +91,7 @@ pub fn syscall6(
[arg4] "{r10}" (arg4),
[arg5] "{r8}" (arg5),
[arg6] "{r9}" (arg6),
: "rcx", "r11", "memory"
);
: .{ .rcx = true, .r11 = true, .memory = true });
}
pub fn clone() callconv(.naked) usize {
@ -144,14 +137,12 @@ pub fn restore_rt() callconv(.naked) noreturn {
\\ syscall
:
: [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
: "rcx", "r11", "memory"
),
: .{ .rcx = true, .r11 = true, .memory = true }),
else => asm volatile (
\\ syscall
:
: [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)),
[sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")),
[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 {
@ -455,6 +445,5 @@ pub inline fn getcontext(context: *ucontext_t) usize {
[_] "={rdi}" (clobber_rdi),
: [_] "{rdi}" (context),
[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),
: [arg0] "{r8}" (arg0),
[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 {
return asm volatile (
@ -27,8 +26,7 @@ pub fn syscall2(sys: plan9.SYS, arg0: usize, arg1: usize) usize {
: [arg0] "{r8}" (arg0),
[arg1] "{r9}" (arg1),
[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 {
return asm volatile (
@ -46,8 +44,7 @@ pub fn syscall3(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize) usize {
[arg1] "{r9}" (arg1),
[arg2] "{r10}" (arg2),
[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 {
return asm volatile (
@ -68,6 +65,5 @@ pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usi
[arg2] "{r10}" (arg2),
[arg3] "{r11}" (arg3),
[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] "=r" (-> [*]const elf.Dyn),
:
: "r1"
),
: .{ .r1 = true }),
.loongarch32, .loongarch64 => asm volatile (
\\ .weak _DYNAMIC
\\ .hidden _DYNAMIC
@ -127,8 +126,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ addu %[ret], %[ret], $gp
: [ret] "=r" (-> [*]const elf.Dyn),
:
: "lr"
),
: .{ .lr = true }),
.mips64, .mips64el => asm volatile (
\\ .weak _DYNAMIC
\\ .hidden _DYNAMIC
@ -140,8 +138,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ daddu %[ret], %[ret], $gp
: [ret] "=r" (-> [*]const elf.Dyn),
:
: "lr"
),
: .{ .lr = true }),
.powerpc, .powerpcle => asm volatile (
\\ .weak _DYNAMIC
\\ .hidden _DYNAMIC
@ -153,8 +150,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ add %[ret], 4, %[ret]
: [ret] "=r" (-> [*]const elf.Dyn),
:
: "lr", "r4"
),
: .{ .lr = true, .r4 = true }),
.powerpc64, .powerpc64le => asm volatile (
\\ .weak _DYNAMIC
\\ .hidden _DYNAMIC
@ -166,8 +162,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
\\ add %[ret], 4, %[ret]
: [ret] "=r" (-> [*]const elf.Dyn),
:
: "lr", "r4"
),
: .{ .lr = true, .r4 = true }),
.riscv32, .riscv64 => asm volatile (
\\ .weak _DYNAMIC
\\ .hidden _DYNAMIC

View File

@ -131,32 +131,28 @@ fn exit2(code: usize) noreturn {
:
: [number] "{rax}" (231),
[arg1] "{rdi}" (code),
: "rcx", "r11", "memory"
);
: .{ .rcx = true, .r11 = true, .memory = true });
},
.arm => {
asm volatile ("svc #0"
:
: [number] "{r7}" (1),
[arg1] "{r0}" (code),
: "memory"
);
: .{ .memory = true });
},
.aarch64 => {
asm volatile ("svc #0"
:
: [number] "{x8}" (93),
[arg1] "{x0}" (code),
: "memory", "cc"
);
: .{ .memory = true });
},
.sparc64 => {
asm volatile ("ta 0x6d"
:
: [number] "{g1}" (1),
[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"),
},

View File

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

View File

@ -740,6 +740,7 @@ pub const SimpleComptimeReason = enum(u32) {
generic_call_target,
wasm_memory_index,
work_group_dim_index,
clobber,
// Evaluating at comptime because types must be comptime-known.
// Reasons other than `.type` are just more specific messages.
@ -820,6 +821,7 @@ pub const SimpleComptimeReason = enum(u32) {
.generic_call_target => "generic function being called 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",
.clobber => "clobber must be comptime-known",
.type => "types must be comptime-known",
.array_sentinel => "array sentinel value must be comptime-known",

View File

@ -634,6 +634,7 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
.@"nosuspend",
.asm_simple,
.@"asm",
.asm_legacy,
.array_type,
.array_type_sentinel,
.error_value,
@ -1047,6 +1048,11 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
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" => {
_, const extra_index = tree.nodeData(n).node_and_extra;
const extra = tree.extraData(extra_index, Node.Asm);
@ -1885,6 +1891,19 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm {
.template = template,
.items = &.{},
.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,
});
}
@ -1896,6 +1915,7 @@ pub fn asmFull(tree: Ast, node: Node.Index) full.Asm {
.asm_token = tree.nodeMainToken(node),
.template = template,
.items = items,
.clobbers = extra.clobbers,
.rparen = extra.rparen,
});
}
@ -2192,8 +2212,8 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N
return result;
}
fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm {
var result: full.Asm = .{
fn legacyAsmComponents(tree: Ast, info: full.AsmLegacy.Components) full.AsmLegacy {
var result: full.AsmLegacy = .{
.ast = info,
.volatile_token = null,
.inputs = &.{},
@ -2253,6 +2273,29 @@ fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm {
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 {
var result: full.While = .{
.ast = info,
@ -2447,6 +2490,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 {
return switch (tree.nodeTag(node)) {
.call, .call_comma => tree.callFull(node),
@ -2827,6 +2878,21 @@ pub const full = 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,
volatile_token: ?TokenIndex,
first_clobber: ?TokenIndex,
@ -3833,15 +3899,22 @@ pub const Node = struct {
/// Same as `block` except there is known to be a trailing comma before
/// the final rbrace.
block_semicolon,
/// `asm(lhs)`.
/// `asm(a)`.
///
/// rhs is a `Token.Index` to the `)` token.
/// The `main_token` field is the `asm` token.
asm_simple,
/// `asm(lhs, a)`.
///
/// The `data` field is a `.node_and_extra`:
/// 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`.
///
/// The `main_token` field is the `asm` token.
@ -4014,9 +4087,18 @@ pub const Node = struct {
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 {
items_start: ExtraIndex,
items_end: ExtraIndex,
clobbers: OptionalIndex,
/// Needed to make lastToken() work.
rparen: TokenIndex,
};

View File

@ -505,6 +505,7 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins
.bool_or,
.@"asm",
.asm_simple,
.asm_legacy,
.string_literal,
.number_literal,
.call,
@ -811,6 +812,12 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
.@"asm",
=> 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),
.multiline_string_literal => return multilineStringLiteral(gz, ri, node),
@ -8774,7 +8781,7 @@ fn asmExpr(
if (is_container_asm) {
if (full.volatile_token) |t|
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", .{});
} else {
if (full.outputs.len == 0 and full.volatile_token == null) {
@ -8839,32 +8846,12 @@ fn asmExpr(
};
}
var clobbers_buffer: [63]u32 = undefined;
var clobber_i: usize = 0;
if (full.first_clobber) |first_clobber| clobbers: {
// asm ("foo" ::: "a", "b")
// asm ("foo" ::: "a", "b",)
var tok_i = first_clobber;
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 clobbers: Zir.Inst.Ref = if (full.ast.clobbers.unwrap()) |clobbers_node|
try comptimeExpr(gz, scope, .{ .rl = .{
.coerced_ty = try gz.addBuiltinValue(clobbers_node, .clobbers),
} }, clobbers_node, .clobber)
else
.none;
const result = try gz.addAsm(.{
.tag = tag_and_tmpl.tag,
@ -8874,7 +8861,7 @@ fn asmExpr(
.output_type_bits = output_type_bits,
.outputs = outputs,
.inputs = inputs,
.clobbers = clobbers_buffer[0..clobber_i],
.clobbers = clobbers,
});
return rvalue(gz, ri, result, node);
}
@ -10332,6 +10319,7 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev
.@"asm",
.asm_simple,
.asm_legacy,
.identifier,
.field_access,
.deref,
@ -10575,6 +10563,7 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In
.tagged_union_enum_tag_trailing,
.@"asm",
.asm_simple,
.asm_legacy,
.add,
.add_wrap,
.add_sat,
@ -10813,6 +10802,7 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool {
.tagged_union_enum_tag_trailing,
.@"asm",
.asm_simple,
.asm_legacy,
.add,
.add_wrap,
.add_sat,
@ -12806,7 +12796,7 @@ const GenZir = struct {
is_volatile: bool,
outputs: []const Zir.Inst.Asm.Output,
inputs: []const Zir.Inst.Asm.Input,
clobbers: []const u32,
clobbers: Zir.Inst.Ref,
},
) !Zir.Inst.Ref {
const astgen = gz.astgen;
@ -12816,13 +12806,13 @@ const GenZir = struct {
try astgen.instructions.ensureUnusedCapacity(gpa, 1);
try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"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.clobbers.len);
args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".fields.len);
const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{
.src_node = gz.nodeIndexToRelative(args.node),
.asm_source = args.asm_source,
.output_type_bits = args.output_type_bits,
.clobbers = args.clobbers,
});
for (args.outputs) |output| {
_ = gz.astgen.addExtraAssumeCapacity(output);
@ -12830,23 +12820,19 @@ const GenZir = struct {
for (args.inputs) |input| {
_ = gz.astgen.addExtraAssumeCapacity(input);
}
gz.astgen.extra.appendSliceAssumeCapacity(args.clobbers);
// * 0b00000000_0000XXXX - `outputs_len`.
// * 0b0000000X_XXXX0000 - `inputs_len`.
// * 0b0XXXXXX0_00000000 - `clobbers_len`.
// * 0bX0000000_00000000 - 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 small: Zir.Inst.Asm.Small = .{
.outputs_len = @intCast(args.outputs.len),
.inputs_len = @intCast(args.inputs.len),
.is_volatile = args.is_volatile,
};
const new_index: Zir.Inst.Index = @enumFromInt(astgen.instructions.len);
astgen.instructions.appendAssumeCapacity(.{
.tag = .extended,
.data = .{ .extended = .{
.opcode = args.tag,
.small = small,
.small = @bitCast(small),
.operand = payload_index,
} },
});

View File

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

View File

@ -2801,7 +2801,7 @@ fn expectSwitchSuffix(p: *Parse, main_token: TokenIndex) !Node.Index {
///
/// AsmInput <- COLON AsmInputList AsmClobbers?
///
/// AsmClobbers <- COLON StringList
/// AsmClobbers <- COLON Expr
///
/// StringList <- (STRINGLITERAL COMMA)* STRINGLITERAL?
///
@ -2841,7 +2841,8 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
else => try p.warnExpected(.comma),
}
}
if (p.eatToken(.colon)) |_| {
const clobbers: Node.OptionalIndex = if (p.eatToken(.colon)) |_| clobbers: {
while (true) {
const input_item = try p.parseAsmInputItem() orelse break;
try p.scratch.append(p.gpa, input_item);
@ -2853,7 +2854,11 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
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)) |_| {
switch (p.tokenTag(p.tok_i)) {
.comma => p.tok_i += 1,
@ -2862,8 +2867,25 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
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 span = try p.listToSpan(p.scratch.items[scratch_top..]);
return p.addNode(.{
@ -2874,6 +2896,7 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
try p.addExtra(Node.Asm{
.items_start = span.start,
.items_end = span.end,
.clobbers = clobbers,
.rparen = rparen,
}),
} },

View File

@ -1939,11 +1939,6 @@ pub const Inst = struct {
/// `operand` is payload index to `BinNode`.
builtin_extern,
/// 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`.
@"asm",
/// Same as `asm` except the assembly template is not a string literal but a comptime
@ -2495,7 +2490,6 @@ pub const Inst = struct {
/// Trailing:
/// 0. Output for every outputs_len
/// 1. Input for every inputs_len
/// 2. clobber: NullTerminatedString // index into string_bytes (null terminated) for every clobbers_len.
pub const Asm = struct {
src_node: Ast.Node.Offset,
// 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.
/// 0b0X is the first output, 0bX0 is the second, etc.
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 {
/// index into string_bytes (null terminated)
@ -3482,6 +3483,7 @@ pub const Inst = struct {
extern_options,
type_info,
branch_hint,
clobbers,
// Values
calling_convention_c,
calling_convention_inline,

View File

@ -227,7 +227,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", .{}),
.@"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_comma,

View File

@ -32,7 +32,7 @@ test "zig fmt: tuple struct" {
}
test "zig fmt: preserves clobbers in inline asm with stray comma" {
try testCanonical(
try testTransform(
\\fn foo() void {
\\ asm volatile (""
\\ : [_] "" (-> 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 (""
\\ : [_] "" (-> 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" {
try testCanonical(
try testTransform(
\\comptime {
\\ 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" (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" {
try testCanonical(
try testTransform(
\\pub fn syscall1(number: usize, arg1: usize) usize {
\\ return asm volatile ("syscall"
\\ : [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 (
\\ \\ foo
\\ \\ bar
\\ ::: "", "");
\\ ::: .{ .a = true, .b = true });
\\ asm volatile (
\\ \\ foo
\\ \\ bar
@ -4006,8 +4050,7 @@ test "zig fmt: inline asm parameter alignment" {
\\ [_] "" (-> usize),
\\ : [_] "" (0),
\\ [_] "" (0),
\\ : "", ""
\\ );
\\ : .{});
\\}
\\
);
@ -5325,7 +5368,7 @@ test "zig fmt: make single-line if no trailing comma, fmt: off" {
\\ asm ("not real assembly"
\\ :[a] "x" (->i32),:[a] "x" (1),);
\\ 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),
\\ [arg2] "{rsi}" (arg),
\\ [arg3] "{rdx}" (arg),
\\ : "rcx", "r11"
\\ : "rcx", "fn"
\\ );
\\
\\ const @"false": usize = 10;
@ -5759,7 +5802,7 @@ test "zig fmt: canonicalize symbols (asm)" {
\\ [arg1] "{rdi}" (arg),
\\ [arg2] "{rsi}" (arg),
\\ [arg3] "{rdx}" (arg),
\\ : "rcx", "r11"
\\ : .{ .rcx = true, .@"fn" = true }
\\ );
\\
\\ const @"false": usize = 10;

View File

@ -852,6 +852,9 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
.@"asm",
=> 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 => {
try renderToken(r, tree.nodeMainToken(node) - 1, .none); // .
return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name
@ -2363,9 +2366,9 @@ fn renderContainerDecl(
return renderToken(r, rbrace, space); // rbrace
}
fn renderAsm(
fn renderAsmLegacy(
r: *Render,
asm_node: Ast.full.Asm,
asm_node: Ast.full.AsmLegacy,
space: Space,
) Error!void {
const tree = r.tree;
@ -2391,17 +2394,24 @@ fn renderAsm(
try renderToken(r, first_clobber - 2, .none);
try renderToken(r, first_clobber - 1, .space);
try ais.writer().writeAll(".{ ");
var tok_i = first_clobber;
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;
switch (tree.tokenTag(tok_i)) {
.r_paren => {
try ais.writer().writeAll(" }");
ais.popIndent();
return renderToken(r, tok_i, space);
},
.comma => {
if (tree.tokenTag(tok_i + 1) == .r_paren) {
try ais.writer().writeAll(" }");
ais.popIndent();
return renderToken(r, tok_i + 1, space);
} else {
@ -2412,10 +2422,7 @@ fn renderAsm(
}
}
} else {
// asm ("foo")
try renderExpression(r, asm_node.ast.template, .none);
ais.popIndent();
return renderToken(r, asm_node.ast.rparen, space); // rparen
unreachable;
}
}
@ -2499,13 +2506,17 @@ fn renderAsm(
};
try renderToken(r, colon3, .space); // :
try ais.writer().writeAll(".{ ");
const first_clobber = asm_node.first_clobber.?;
var tok_i = first_clobber;
while (true) {
switch (tree.tokenTag(tok_i + 1)) {
.r_paren => {
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();
return renderToken(r, tok_i + 1, space);
},
@ -2513,12 +2524,17 @@ fn renderAsm(
switch (tree.tokenTag(tok_i + 2)) {
.r_paren => {
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();
return renderToken(r, tok_i + 2, space);
},
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);
tok_i += 2;
},
@ -2529,6 +2545,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(
r: *Render,
call: Ast.full.Call,
@ -3090,6 +3231,22 @@ fn tokenSliceForRender(tree: Ast, token_index: Ast.TokenIndex) []const u8 {
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 {
const between_source = tree.source[tree.tokenStart(token_index)..tree.tokenStart(token_index + 1)];
for (between_source) |byte| switch (byte) {

View File

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

View File

@ -1413,19 +1413,20 @@ pub const ShuffleTwoMask = enum(u32) {
/// terminated string.
/// - name: memory at this position is reinterpreted as a null
/// terminated string. pad to the next u32 after the null byte.
/// 4. for every clobbers_len
/// - 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`.
/// 4. 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.
pub const Asm = struct {
/// Length of the assembly source in bytes.
source_len: u32,
outputs_len: u32,
inputs_len: u32,
/// The MSB is `is_volatile`.
/// The rest of the bits are `clobbers_len`.
flags: u32,
/// A comptime `std.builtin.assembly.Clobbers` value for the target architecture.
clobbers: InternPool.Index,
flags: Flags,
pub const Flags = packed struct(u32) {
outputs_len: u31,
is_volatile: bool,
};
};
pub const Cmpxchg = struct {
@ -1749,7 +1750,7 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end
@field(result, field.name) = switch (field.type) {
u32 => 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)),
};
i += 1;

View File

@ -1208,8 +1208,9 @@ fn analyzeInst(
.assembly => {
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;
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;
const inputs = @as([]const Air.Inst.Ref, @ptrCast(a.air.extra.items[extra_i..][0..extra.data.inputs_len]));
extra_i += inputs.len;

View File

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

View File

@ -1,5 +1,6 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const build_options = @import("build_options");
const Zcu = @import("../Zcu.zig");
@ -9,7 +10,7 @@ const Air = @import("../Air.zig");
const InternPool = @import("../InternPool.zig");
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 *
// Here we don't use @sizeOf(Air.Inst.Data) because it would include
// the debug safety tag but we want to measure release size.
@ -59,7 +60,7 @@ pub fn writeInst(
pt: Zcu.PerThread,
liveness: ?Air.Liveness,
) void {
comptime std.debug.assert(build_options.enable_debug_extensions);
comptime assert(build_options.enable_debug_extensions);
var writer: Writer = .{
.pt = pt,
.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 {
const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = w.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;
const clobbers_len = @as(u31, @truncate(extra.data.flags));
const is_volatile = extra.data.flags.is_volatile;
const outputs_len = extra.data.flags.outputs_len;
var extra_i: usize = extra.end;
var op_index: usize = 0;
@ -655,7 +656,7 @@ const Writer = struct {
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;
const inputs = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra_i..][0..extra.data.inputs_len]));
extra_i += inputs.len;
@ -695,19 +696,35 @@ const Writer = struct {
try s.writeByte(')');
}
{
var clobber_i: u32 = 0;
while (clobber_i < clobbers_len) : (clobber_i += 1) {
const extra_bytes = std.mem.sliceAsBytes(w.air.extra.items[extra_i..]);
const clobber = std.mem.sliceTo(extra_bytes, 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;
try s.writeAll(", ~{");
try s.writeAll(clobber);
try s.writeAll("}");
}
const zcu = w.pt.zcu;
const ip = &zcu.intern_pool;
const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
const struct_type: Type = .fromInterned(aggregate.ty);
switch (aggregate.storage) {
.elems => |elems| for (elems, 0..) |elem, i| {
switch (elem) {
.bool_true => {
const clobber = struct_type.structFieldName(i, zcu).toSlice(ip).?;
assert(clobber.len != 0);
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];
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;
// Luckily, we only care about the inputs and outputs, so we don't have to do
// the whole null-terminated string dance.
const outputs: []const Air.Inst.Ref = @ptrCast(air.extra.items[extra.end..][0..extra.data.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_len = extra.data.flags.outputs_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 (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_panic_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`
/// 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_panic_deps = .none,
.memoized_state_va_list_deps = .none,
.memoized_state_assembly_deps = .none,
.first_dependency = .empty,
.dep_entries = .empty,
.free_dep_entries = .empty,
@ -458,6 +460,8 @@ pub const MemoizedStateStage = enum(u32) {
panic,
/// Specifically `std.builtin.VaList`. See `Zcu.BuiltinDecl.stage`.
va_list,
/// Everything within `std.builtin.assembly`. See `Zcu.BuiltinDecl.stage`.
assembly,
};
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(),
.panic => ip.memoized_state_panic_deps.unwrap(),
.va_list => ip.memoized_state_va_list_deps.unwrap(),
.assembly => ip.memoized_state_assembly_deps.unwrap(),
},
} orelse return .{
.ip = ip,
@ -915,6 +920,7 @@ pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, depend
.main => &ip.memoized_state_main_deps,
.panic => &ip.memoized_state_panic_deps,
.va_list => &ip.memoized_state_va_list_deps,
.assembly => &ip.memoized_state_assembly_deps,
};
if (deps.unwrap()) |first| {

View File

@ -16413,10 +16413,10 @@ fn zirAsm(
const extra = sema.code.extraData(Zir.Inst.Asm, extended.operand);
const src = block.nodeOffset(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 inputs_len: u5 = @truncate(extended.small >> 4);
const clobbers_len: u6 = @truncate(extended.small >> 9);
const is_volatile = @as(u1, @truncate(extended.small >> 15)) != 0;
const small: Zir.Inst.Asm.Small = @bitCast(extended.small);
const outputs_len = small.outputs_len;
const inputs_len = small.inputs_len;
const is_volatile = small.is_volatile;
const is_global_assembly = sema.func_index == .none;
const zir_tags = sema.code.instructions.items(.tag);
@ -16432,7 +16432,7 @@ fn zirAsm(
if (inputs_len != 0) {
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", .{});
}
if (is_volatile) {
@ -16506,15 +16506,11 @@ fn zirAsm(
inputs[arg_i] = .{ .c = constraint, .n = name };
}
const clobbers = try sema.arena.alloc([]const u8, clobbers_len);
for (clobbers) |*name| {
const name_index: Zir.NullTerminatedString = @enumFromInt(sema.code.extra[extra_i]);
name.* = sema.code.nullTerminatedString(name_index);
extra_i += 1;
needed_capacity += name.*.len / 4 + 1;
}
const clobbers = if (extra.data.clobbers == .none) empty: {
const clobbers_ty = try sema.getBuiltinType(src, .@"assembly.Clobbers");
break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);
} else try sema.resolveInst(extra.data.clobbers); // Already coerced by AstGen.
const clobbers_val = try sema.resolveConstDefinedValue(block, src, clobbers, .{ .simple = .clobber });
needed_capacity += (asm_source.len + 3) / 4;
const gpa = sema.gpa;
@ -16525,9 +16521,12 @@ fn zirAsm(
.ty = expr_ty,
.payload = sema.addExtraAssumeCapacity(Air.Asm{
.source_len = @intCast(asm_source.len),
.outputs_len = outputs_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;
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());
@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),
.type_info => try sema.getBuiltinType(src, .Type),
.branch_hint => try sema.getBuiltinType(src, .BranchHint),
.clobbers => try sema.getBuiltinType(src, .@"assembly.Clobbers"),
// zig fmt: on
// Values are handled here.
@ -36546,7 +36540,7 @@ fn payloadToExtraItems(data: anytype) [@typeInfo(@TypeOf(data)).@"struct".fields
inline for (&result, fields) |*val, field| {
val.* = switch (field.type) {
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)),
else => @compileError("bad field type: " ++ @typeName(field.type)),
};

View File

@ -460,6 +460,9 @@ pub const BuiltinDecl = enum {
VaList,
assembly,
@"assembly.Clobbers",
/// Determines what kind of validation will be done to the decl's value.
pub fn kind(decl: BuiltinDecl) enum { type, func, string } {
return switch (decl) {
@ -480,6 +483,8 @@ pub const BuiltinDecl = enum {
.ExportOptions,
.ExternOptions,
.BranchHint,
.assembly,
.@"assembly.Clobbers",
=> .type,
.Type,
@ -540,6 +545,7 @@ pub const BuiltinDecl = enum {
/// Resolution of these values is done in three distinct stages:
/// * Resolution of `std.builtin.Panic` and everything under it
/// * Resolution of `VaList`
/// * Resolution of `assembly`
/// * Everything else
///
/// 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
/// machinery to work; additionally, it is `@compileError` on some targets, so must be referenced
/// by itself.
///
/// `assembly` is separate because its value depends on the target.
pub fn stage(decl: BuiltinDecl) InternPool.MemoizedStateStage {
if (decl == .VaList) return .va_list;
if (@intFromEnum(decl) <= @intFromEnum(BuiltinDecl.@"Type.Declaration")) {
return .main;
} else {
return .panic;
}
return switch (decl) {
.VaList => .va_list,
.assembly, .@"assembly.Clobbers" => .assembly,
else => {
if (@intFromEnum(decl) <= @intFromEnum(BuiltinDecl.@"Type.Declaration")) {
return .main;
} else {
return .panic;
}
},
};
}
/// 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,
.panic => .panic,
.va_list => .VaList,
.assembly => .assembly,
};
if (zcu.builtin_decl_values.get(to_check) != .none) return;
}

View File

@ -6047,10 +6047,10 @@ fn airBoolOp(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 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;
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;
const inputs: []const Air.Inst.Ref = @ptrCast(func.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len;
@ -6161,21 +6161,33 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
args.appendAssumeCapacity(arg_mcv);
}
{
var clobber_i: u32 = 0;
while (clobber_i < clobbers_len) : (clobber_i += 1) {
const clobber = std.mem.sliceTo(std.mem.sliceAsBytes(func.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;
if (std.mem.eql(u8, clobber, "") or std.mem.eql(u8, clobber, "memory")) {
// nothing really to do
} else {
try func.register_manager.getReg(parseRegName(clobber) orelse
return func.fail("invalid clobber: '{s}'", .{clobber}), null);
const zcu = func.pt.zcu;
const ip = &zcu.intern_pool;
const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
const struct_type: Type = .fromInterned(aggregate.ty);
switch (aggregate.storage) {
.elems => |elems| for (elems, 0..) |elem, i| {
switch (elem) {
.bool_true => {
const clobber = struct_type.structFieldName(i, zcu).toSlice(ip).?;
assert(clobber.len != 0);
if (std.mem.eql(u8, clobber, "memory")) {
// nothing really to do
} 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 {

View File

@ -873,10 +873,10 @@ fn airArrayToSlice(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 extra = self.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = (extra.data.flags & 0x80000000) != 0;
const clobbers_len: u31 = @truncate(extra.data.flags);
const is_volatile = extra.data.flags.is_volatile;
const outputs_len = extra.data.flags.outputs_len;
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;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i .. extra_i + extra.data.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);
}
{
var clobber_i: u32 = 0;
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
}
}
// TODO honor the clobbers
_ = extra.data.clobbers;
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 ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
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;
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;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len;
@ -179981,30 +179981,42 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
args.appendAssumeCapacity(arg_mcv);
}
{
var clobber_i: u32 = 0;
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;
const ip = &zcu.intern_pool;
const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
const struct_type: Type = .fromInterned(aggregate.ty);
switch (aggregate.storage) {
.elems => |elems| for (elems, 0..) |elem, i| switch (elem) {
.bool_true => {
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
std.mem.eql(u8, clobber, "fpsr") or std.mem.eql(u8, clobber, "fpcr") or
std.mem.eql(u8, clobber, "mxcsr") or std.mem.eql(u8, clobber, "dirflag"))
{
// ok, sure
} else if (std.mem.eql(u8, clobber, "cc") or
std.mem.eql(u8, clobber, "flags") or
std.mem.eql(u8, clobber, "eflags") or
std.mem.eql(u8, clobber, "rflags"))
{
try self.spillEflagsIfOccupied();
} else {
try self.register_manager.getReg(parseRegName(clobber) orelse
return self.fail("invalid clobber: '{s}'", .{clobber}), null);
}
}
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, "mxcsr") or
std.mem.eql(u8, clobber, "dirflag"))
{
// ok, sure
} else if (std.mem.eql(u8, clobber, "cc") or
std.mem.eql(u8, clobber, "flags") or
std.mem.eql(u8, clobber, "eflags") or
std.mem.eql(u8, clobber, "rflags"))
{
try self.spillEflagsIfOccupied();
} 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 {

View File

@ -5545,11 +5545,11 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
const zcu = pt.zcu;
const ty_pl = f.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = f.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;
const clobbers_len: u31 = @truncate(extra.data.flags);
const is_volatile = extra.data.flags.is_volatile;
const outputs_len = extra.data.flags.outputs_len;
const gpa = f.object.dg.gpa;
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;
const inputs: []const Air.Inst.Ref = @ptrCast(f.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len;
@ -5645,12 +5645,6 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
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];
@ -5757,17 +5751,28 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
try w.writeByte(')');
}
try w.writeByte(':');
for (0..clobbers_len) |clobber_i| {
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;
if (clobber.len == 0) continue;
if (clobber_i > 0) try w.writeByte(',');
try w.print(" {f}", .{fmtStringLiteral(clobber, null)});
const ip = &zcu.intern_pool;
const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
const struct_type: Type = .fromInterned(aggregate.ty);
switch (aggregate.storage) {
.elems => |elems| for (elems, 0..) |elem, i| switch (elem) {
.bool_true => {
const name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
assert(name.len != 0);
try w.print(" {f}", .{fmtStringLiteral(name, 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 f.object.newline();

View File

@ -7241,19 +7241,20 @@ pub const FuncGen = struct {
const o = self.ng.object;
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = self.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;
const clobbers_len: u31 = @truncate(extra.data.flags);
const is_volatile = extra.data.flags.is_volatile;
const outputs_len = extra.data.flags.outputs_len;
const gpa = self.gpa;
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;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len;
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();
const arena = arena_allocator.allocator();
@ -7276,7 +7277,7 @@ pub const FuncGen = struct {
var llvm_ret_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;
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.
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) {
llvm_constraints.appendAssumeCapacity(',');
}
@ -7358,7 +7359,7 @@ pub const FuncGen = struct {
if (!std.mem.eql(u8, name, "_")) {
const gop = name_map.getOrPutAssumeCapacity(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;
}
@ -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) {
llvm_constraints.appendAssumeCapacity(',');
}
@ -7413,7 +7414,7 @@ pub const FuncGen = struct {
if (!std.mem.eql(u8, name, "_")) {
const gop = name_map.getOrPutAssumeCapacity(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
@ -7456,7 +7457,7 @@ pub const FuncGen = struct {
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
// an elementtype(<ty>) attribute.
@ -7466,24 +7467,30 @@ pub const FuncGen = struct {
total_i += 1;
}
{
var clobber_i: u32 = 0;
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;
try llvm_constraints.ensureUnusedCapacity(self.gpa, clobber.len + 4);
if (total_i != 0) {
llvm_constraints.appendAssumeCapacity(',');
const ip = &zcu.intern_pool;
const aggregate = ip.indexToKey(extra.data.clobbers).aggregate;
const struct_type: Type = .fromInterned(aggregate.ty);
if (total_i != 0) try llvm_constraints.append(gpa, ',');
switch (aggregate.storage) {
.elems => |elems| for (elems, 0..) |elem, i| {
switch (elem) {
.bool_true => {
const name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
total_i += try appendConstraints(gpa, &llvm_constraints, name, target);
},
.bool_false => continue,
else => unreachable,
}
llvm_constraints.appendSliceAssumeCapacity("~{");
llvm_constraints.appendSliceAssumeCapacity(clobber);
llvm_constraints.appendSliceAssumeCapacity("}");
total_i += 1;
}
},
.repeated_elem => |elem| switch (elem) {
.bool_true => for (0..struct_type.structFieldCount(zcu)) |i| {
const name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
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
@ -7497,22 +7504,22 @@ pub const FuncGen = struct {
// to be buggy and regress often.
switch (target.cpu.arch) {
.x86_64, .x86 => {
if (total_i != 0) try llvm_constraints.append(self.gpa, ',');
try llvm_constraints.appendSlice(self.gpa, "~{dirflag},~{fpsr},~{flags}");
try llvm_constraints.appendSlice(gpa, "~{dirflag},~{fpsr},~{flags},");
total_i += 3;
},
.mips, .mipsel, .mips64, .mips64el => {
if (total_i != 0) try llvm_constraints.append(self.gpa, ',');
try llvm_constraints.appendSlice(self.gpa, "~{$1}");
try llvm_constraints.appendSlice(gpa, "~{$1},");
total_i += 1;
},
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];
// 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();
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);
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 extra = self.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;
const clobbers_len: u31 = @truncate(extra.data.flags);
const is_volatile = extra.data.flags.is_volatile;
const outputs_len = extra.data.flags.outputs_len;
if (!is_volatile and self.liveness.isUnused(inst)) return null;
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;
const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra.items[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len;
@ -6402,7 +6402,7 @@ const NavGen = struct {
return self.todo("implement inline asm with more than 1 output", .{});
}
var as = SpvAssembler{
var as: SpvAssembler = .{
.gpa = self.gpa,
.spv = self.spv,
.func = &self.func,
@ -6486,14 +6486,8 @@ const NavGen = struct {
}
}
{
var clobber_i: u32 = 0;
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.
}
}
// TODO: do something with clobbers
_ = extra.data.clobbers;
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 (""
: [_] "=m,r" (a),
:
: ""
);
: .{});
asm volatile (""
: [_] "=r,m" (a),
:
: ""
);
: .{});
}
test "alternative constraints" {
@ -79,7 +77,6 @@ test "alternative constraints" {
asm volatile (""
: [_] "=r,m" (a),
: [_] "r,m" (a),
: ""
);
}
@ -96,42 +93,34 @@ test "sized integer/float in asm input" {
asm volatile (""
:
: [_] "m" (@as(usize, 3)),
: ""
);
asm volatile (""
:
: [_] "m" (@as(i15, -3)),
: ""
);
asm volatile (""
:
: [_] "m" (@as(u3, 3)),
: ""
);
asm volatile (""
:
: [_] "m" (@as(i3, 3)),
: ""
);
asm volatile (""
:
: [_] "m" (@as(u121, 3)),
: ""
);
asm volatile (""
:
: [_] "m" (@as(i121, 3)),
: ""
);
asm volatile (""
:
: [_] "m" (@as(f32, 3.17)),
: ""
);
asm volatile (""
:
: [_] "m" (@as(f64, 3.17)),
: ""
);
}
@ -172,8 +161,7 @@ test "rw constraint (x86_64)" {
asm ("addl %[b], %[a]"
: [a] "+r" (res),
: [b] "r" (@as(i32, 13)),
: "flags"
);
: .{ .flags = true });
try expectEqual(@as(i32, 18), res);
}

View File

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

View File

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

View File

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