mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 22:04:21 +00:00
loongarch: add __clear_cache builtin implementation (#21008)
This commit is contained in:
parent
54151428e5
commit
6d54f20c47
1 changed files with 10 additions and 0 deletions
|
|
@ -28,6 +28,10 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
|
||||||
.aarch64, .aarch64_be => true,
|
.aarch64, .aarch64_be => true,
|
||||||
else => false,
|
else => false,
|
||||||
};
|
};
|
||||||
|
const loongarch64 = switch (arch) {
|
||||||
|
.loongarch64 => true,
|
||||||
|
else => false,
|
||||||
|
};
|
||||||
const mips = switch (arch) {
|
const mips = switch (arch) {
|
||||||
.mips, .mipsel, .mips64, .mips64el => true,
|
.mips, .mipsel, .mips64, .mips64el => true,
|
||||||
else => false,
|
else => false,
|
||||||
|
|
@ -159,6 +163,12 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
|
||||||
// On Darwin, sys_icache_invalidate() provides this functionality
|
// On Darwin, sys_icache_invalidate() provides this functionality
|
||||||
sys_icache_invalidate(start, end - start);
|
sys_icache_invalidate(start, end - start);
|
||||||
exportIt();
|
exportIt();
|
||||||
|
} else if (os == .linux and loongarch64) {
|
||||||
|
// See: https://github.com/llvm/llvm-project/blob/cf54cae26b65fc3201eff7200ffb9b0c9e8f9a13/compiler-rt/lib/builtins/clear_cache.c#L94-L95
|
||||||
|
asm volatile (
|
||||||
|
\\ ibar 0
|
||||||
|
);
|
||||||
|
exportIt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue