Skip to content

Instantly share code, notes, and snippets.

View xen0n's full-sized avatar

WÁNG Xuěruì xen0n

View GitHub Profile
@xen0n
xen0n / check-new-world.tiny.s
Last active April 24, 2025 06:24
Tiny helper checking for LoongArch new world UAPI
# SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#
# how to build this:
#
# $ as -o check-new-world.tiny.o check-new-world.tiny.s
# $ ld check-new-world.tiny.o -o check-new-world.tiny.tmp
# $ objcopy -O binary --only-section=.blob ./check-new-world.tiny.tmp ./check-new-world.tiny
.section ".blob", "aw", @progbits
@xen0n
xen0n / linux-xor-simd-test.c
Created July 21, 2023 12:57
Sketching LoongArch SIMD acceleration for Linux XOR ops
// SPDX-License-Identifier: GPL-2.0-or-later
/*
$ gcc -O3 -o linux-xor-simd-test linux-xor-simd-test.c
$ ./linux-xor-simd-test
ref (size=4096 ) passed 16383 times: 0.005044150 s total, 0.000000307 s per pass, 12687.191 MiB/s
lsx_32b (size=4096 ) passed 16383 times: 0.002663250 s total, 0.000000162 s per pass, 24029.323 MiB/s
lsx_64b (size=4096 ) passed 16383 times: 0.002517970 s total, 0.000000153 s per pass, 25415.749 MiB/s
lsx_128b (size=4096 ) passed 16383 times: 0.002517590 s total, 0.000000153 s per pass, 25419.585 MiB/s
lasx_32b (size=4096 ) passed 16383 times: 0.001935550 s total, 0.000000118 s per pass, 33063.519 MiB/s
@xen0n
xen0n / test-page-delta.cc
Created July 25, 2023 12:11
The verification code behind LLD's getLoongArchPageDelta
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Ever wondered how the wicked logic in https://github.com/llvm/llvm-project/blob/6084ee742064cf8/lld/ELF/Arch/LoongArch.cpp#L86-L169
// got discovered? This is the experiment I've done...
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <unistd.h>