Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loongarch: add __clear_cache builtin implementation #21008

Merged
merged 8 commits into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/compiler_rt/clear_cache.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
.aarch64, .aarch64_be => true,
else => false,
};
const loongarch64 = switch (arch) {
.loongarch64 => true,
else => false,
};
const mips = switch (arch) {
.mips, .mipsel, .mips64, .mips64el => true,
else => false,
Expand Down Expand Up @@ -159,6 +163,12 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
// On Darwin, sys_icache_invalidate() provides this functionality
sys_icache_invalidate(start, end - start);
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();
}
}

Expand Down