summaryrefslogtreecommitdiff
path: root/neozip/arch/power/power_intrins.h
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/power/power_intrins.h
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/power/power_intrins.h')
-rw-r--r--neozip/arch/power/power_intrins.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/neozip/arch/power/power_intrins.h b/neozip/arch/power/power_intrins.h
new file mode 100644
index 0000000000..3efcfb9722
--- /dev/null
+++ b/neozip/arch/power/power_intrins.h
@@ -0,0 +1,61 @@
+/* Helper functions to work around issues with clang builtins
+ * Copyright (C) 2021 IBM Corporation
+ *
+ * Authors:
+ * Daniel Black <daniel@linux.vnet.ibm.com>
+ * Rogerio Alves <rogealve@br.ibm.com>
+ * Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
+ *
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef POWER_INTRINS_H
+#define POWER_INTRINS_H
+
+#include <altivec.h>
+
+#if defined (__clang__)
+/*
+ * These stubs fix clang incompatibilities with GCC builtins.
+ */
+
+#ifndef __builtin_crypto_vpmsumw
+#define __builtin_crypto_vpmsumw __builtin_crypto_vpmsumb
+#endif
+#ifndef __builtin_crypto_vpmsumd
+#define __builtin_crypto_vpmsumd __builtin_crypto_vpmsumb
+#endif
+
+#ifdef __VSX__
+static inline __vector unsigned long long __attribute__((overloadable))
+vec_ld(int __a, const __vector unsigned long long* __b) {
+ return (__vector unsigned long long)__builtin_altivec_lvx(__a, __b);
+}
+#endif
+
+#endif
+
+/* There's no version of this that operates over unsigned and if casted, it does
+ * sign extension. Let's write an endian independent version and hope the compiler
+ * eliminates creating another zero idiom for the zero value if one exists locally */
+static inline vector unsigned short vec_unpackl(vector unsigned char a) {
+ vector unsigned char zero = vec_splat_u8(0);
+
+#if BYTE_ORDER == BIG_ENDIAN
+ return (vector unsigned short)vec_mergel(zero, a);
+#else
+ return (vector unsigned short)vec_mergel(a, zero);
+#endif
+}
+
+static inline vector unsigned short vec_unpackh(vector unsigned char a) {
+ vector unsigned char zero = vec_splat_u8(0);
+
+#if BYTE_ORDER == BIG_ENDIAN
+ return (vector unsigned short)vec_mergeh(zero, a);
+#else
+ return (vector unsigned short)vec_mergeh(a, zero);
+#endif
+}
+
+#endif