summaryrefslogtreecommitdiff
path: root/neozip/arch/loongarch/loongarch_features.c
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
commit7fb132859fda54aa96bc9dd46d302b343eeb5a02 (patch)
treeb43ae77d7451fb470a260c03349a1caf2846c5e5 /neozip/arch/loongarch/loongarch_features.c
parentb1e34e861b5d732afe828d58aad2c638135061fd (diff)
parentc2712b8a345191f6ed79558c089777df94590087 (diff)
downloadProject-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.tar.gz
Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.zip
Add 'neozip/' from commit 'c2712b8a345191f6ed79558c089777df94590087'
git-subtree-dir: neozip git-subtree-mainline: b1e34e861b5d732afe828d58aad2c638135061fd git-subtree-split: c2712b8a345191f6ed79558c089777df94590087
Diffstat (limited to 'neozip/arch/loongarch/loongarch_features.c')
-rw-r--r--neozip/arch/loongarch/loongarch_features.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/neozip/arch/loongarch/loongarch_features.c b/neozip/arch/loongarch/loongarch_features.c
new file mode 100644
index 0000000000..bedf8499f7
--- /dev/null
+++ b/neozip/arch/loongarch/loongarch_features.c
@@ -0,0 +1,31 @@
+/* loongarch_features.c -- check for LoongArch features.
+ *
+ * Copyright (C) 2025 Vladislav Shchapov <vladislav@shchapov.ru>
+ *
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifdef LOONGARCH_FEATURES
+
+#include "zbuild.h"
+#include "loongarch_features.h"
+
+#include <larchintrin.h>
+
+/*
+ * https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html
+ *
+ * Word number Bit number Annotation Implication
+ * 0x1 25 CRC 1 indicates support for CRC instruction
+ * 0x1 6 LSX 1 indicates support for 128-bit vector extension
+ * 0x1 7 LASX 1 indicates support for 256-bit vector expansion
+ */
+
+void Z_INTERNAL loongarch_check_features(struct loongarch_cpu_features *features) {
+ unsigned int w1 = __cpucfg(0x1);
+ features->has_crc = w1 & 0x2000000;
+ features->has_lsx = w1 & 0x40;
+ features->has_lasx = w1 & 0x80;
+}
+
+#endif