|
|
fa3bfd |
From 9b9fd1ec26b5386072fa967bac0771df5e86a284 Mon Sep 17 00:00:00 2001
|
|
|
fa3bfd |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
fa3bfd |
Date: Thu, 27 Jul 2017 10:53:58 +0200
|
|
|
fa3bfd |
Subject: [PATCH 07/10] S390: Use cu41 instruction for converting from utf32 to
|
|
|
fa3bfd |
utf8.
|
|
|
fa3bfd |
|
|
|
fa3bfd |
upstream-commit 23ea69a9d6e9ab28c66a232b767a800b04eaa938
|
|
|
fa3bfd |
|
|
|
fa3bfd |
This patch adds an ifunc variant to use the cu instruction on arch12 CPUs.
|
|
|
fa3bfd |
This new ifunc variant can be built if binutils support z13 vector
|
|
|
fa3bfd |
instructions. At runtime, HWCAP_S390_VXE decides if we can use the
|
|
|
fa3bfd |
cu41 instruction.
|
|
|
fa3bfd |
|
|
|
fa3bfd |
ChangeLog:
|
|
|
fa3bfd |
|
|
|
fa3bfd |
* sysdeps/s390/utf8-utf32-z9.c (__to_utf8_loop_vx_cu):
|
|
|
fa3bfd |
Use vector and cu41 instruction.
|
|
|
fa3bfd |
* sysdeps/s390/multiarch/utf8-utf32-z9.c: Add __to_utf8_loop_vx_cu
|
|
|
fa3bfd |
in ifunc resolver.
|
|
|
fa3bfd |
---
|
|
|
fa3bfd |
sysdeps/s390/multiarch/utf8-utf32-z9.c | 8 ++-
|
|
|
fa3bfd |
sysdeps/s390/utf8-utf32-z9.c | 112 +++++++++++++++++++++++++++++++++
|
|
|
fa3bfd |
2 files changed, 117 insertions(+), 3 deletions(-)
|
|
|
fa3bfd |
|
|
|
fa3bfd |
diff --git a/sysdeps/s390/multiarch/utf8-utf32-z9.c b/sysdeps/s390/multiarch/utf8-utf32-z9.c
|
|
|
fa3bfd |
index faf1f46..0c6d9e9 100644
|
|
|
fa3bfd |
--- a/sysdeps/s390/multiarch/utf8-utf32-z9.c
|
|
|
fa3bfd |
+++ b/sysdeps/s390/multiarch/utf8-utf32-z9.c
|
|
|
fa3bfd |
@@ -41,8 +41,10 @@ s390_libc_ifunc_expr (FROM_LOOP_DEFAULT, FROM_LOOP,
|
|
|
fa3bfd |
: FROM_LOOP_DEFAULT);
|
|
|
fa3bfd |
|
|
|
fa3bfd |
s390_libc_ifunc_expr (TO_LOOP_DEFAULT, TO_LOOP,
|
|
|
fa3bfd |
- (HAVE_TO_VX && (hwcap & HWCAP_S390_VX))
|
|
|
fa3bfd |
- ? TO_LOOP_VX
|
|
|
fa3bfd |
- : TO_LOOP_DEFAULT);
|
|
|
fa3bfd |
+ (HAVE_TO_VX_CU && (hwcap & HWCAP_S390_VXE))
|
|
|
fa3bfd |
+ ? TO_LOOP_VX_CU
|
|
|
fa3bfd |
+ : (HAVE_TO_VX && (hwcap & HWCAP_S390_VX))
|
|
|
fa3bfd |
+ ? TO_LOOP_VX
|
|
|
fa3bfd |
+ : TO_LOOP_DEFAULT);
|
|
|
fa3bfd |
|
|
|
fa3bfd |
#include <iconv/skeleton.c>
|
|
|
fa3bfd |
diff --git a/sysdeps/s390/utf8-utf32-z9.c b/sysdeps/s390/utf8-utf32-z9.c
|
|
|
fa3bfd |
index e06d11e..e4f2e0c 100644
|
|
|
fa3bfd |
--- a/sysdeps/s390/utf8-utf32-z9.c
|
|
|
fa3bfd |
+++ b/sysdeps/s390/utf8-utf32-z9.c
|
|
|
fa3bfd |
@@ -52,9 +52,11 @@
|
|
|
fa3bfd |
#if defined HAVE_S390_VX_ASM_SUPPORT && defined USE_MULTIARCH
|
|
|
fa3bfd |
# define HAVE_FROM_VX 1
|
|
|
fa3bfd |
# define HAVE_TO_VX 1
|
|
|
fa3bfd |
+# define HAVE_TO_VX_CU 1
|
|
|
fa3bfd |
#else
|
|
|
fa3bfd |
# define HAVE_FROM_VX 0
|
|
|
fa3bfd |
# define HAVE_TO_VX 0
|
|
|
fa3bfd |
+# define HAVE_TO_VX_CU 0
|
|
|
fa3bfd |
#endif
|
|
|
fa3bfd |
|
|
|
fa3bfd |
#if defined HAVE_S390_VX_GCC_SUPPORT
|
|
|
fa3bfd |
@@ -863,6 +865,116 @@ gconv_end (struct __gconv_step *data)
|
|
|
fa3bfd |
# define TO_LOOP_VX NULL
|
|
|
fa3bfd |
#endif /* HAVE_TO_VX != 1 */
|
|
|
fa3bfd |
|
|
|
fa3bfd |
+#if HAVE_TO_VX_CU == 1
|
|
|
fa3bfd |
+#define BODY_TO_VX_CU \
|
|
|
fa3bfd |
+ { \
|
|
|
fa3bfd |
+ register const unsigned char* pInput asm ("8") = inptr; \
|
|
|
fa3bfd |
+ register size_t inlen asm ("9") = inend - inptr; \
|
|
|
fa3bfd |
+ register unsigned char* pOutput asm ("10") = outptr; \
|
|
|
fa3bfd |
+ register size_t outlen asm ("11") = outend - outptr; \
|
|
|
fa3bfd |
+ unsigned long tmp, tmp2; \
|
|
|
fa3bfd |
+ asm volatile (".machine push\n\t" \
|
|
|
fa3bfd |
+ ".machine \"z13\"\n\t" \
|
|
|
fa3bfd |
+ ".machinemode \"zarch_nohighgprs\"\n\t" \
|
|
|
fa3bfd |
+ " vleif %%v20,127,0\n\t" /* element 0: 127 */ \
|
|
|
fa3bfd |
+ " vzero %%v21\n\t" \
|
|
|
fa3bfd |
+ " vleih %%v21,8192,0\n\t" /* element 0: > */ \
|
|
|
fa3bfd |
+ " vleih %%v21,-8192,2\n\t" /* element 1: =<> */ \
|
|
|
fa3bfd |
+ CONVERT_32BIT_SIZE_T ([R_INLEN]) \
|
|
|
fa3bfd |
+ CONVERT_32BIT_SIZE_T ([R_OUTLEN]) \
|
|
|
fa3bfd |
+ /* Loop which handles UTF-32 chars <= 0x7f. */ \
|
|
|
fa3bfd |
+ "0: clgijl %[R_INLEN],64,20f\n\t" \
|
|
|
fa3bfd |
+ " clgijl %[R_OUTLEN],16,20f\n\t" \
|
|
|
fa3bfd |
+ "1: vlm %%v16,%%v19,0(%[R_IN])\n\t" \
|
|
|
fa3bfd |
+ " lghi %[R_TMP],0\n\t" \
|
|
|
fa3bfd |
+ /* Shorten to byte values. */ \
|
|
|
fa3bfd |
+ " vpkf %%v23,%%v16,%%v17\n\t" \
|
|
|
fa3bfd |
+ " vpkf %%v24,%%v18,%%v19\n\t" \
|
|
|
fa3bfd |
+ " vpkh %%v23,%%v23,%%v24\n\t" \
|
|
|
fa3bfd |
+ /* Checking for values > 0x7f. */ \
|
|
|
fa3bfd |
+ " vstrcfs %%v22,%%v16,%%v20,%%v21\n\t" \
|
|
|
fa3bfd |
+ " jno 10f\n\t" \
|
|
|
fa3bfd |
+ " vstrcfs %%v22,%%v17,%%v20,%%v21\n\t" \
|
|
|
fa3bfd |
+ " jno 11f\n\t" \
|
|
|
fa3bfd |
+ " vstrcfs %%v22,%%v18,%%v20,%%v21\n\t" \
|
|
|
fa3bfd |
+ " jno 12f\n\t" \
|
|
|
fa3bfd |
+ " vstrcfs %%v22,%%v19,%%v20,%%v21\n\t" \
|
|
|
fa3bfd |
+ " jno 13f\n\t" \
|
|
|
fa3bfd |
+ /* Store 16bytes to outptr. */ \
|
|
|
fa3bfd |
+ " vst %%v23,0(%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ " aghi %[R_INLEN],-64\n\t" \
|
|
|
fa3bfd |
+ " aghi %[R_OUTLEN],-16\n\t" \
|
|
|
fa3bfd |
+ " la %[R_IN],64(%[R_IN])\n\t" \
|
|
|
fa3bfd |
+ " la %[R_OUT],16(%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ " clgijl %[R_INLEN],64,20f\n\t" \
|
|
|
fa3bfd |
+ " clgijl %[R_OUTLEN],16,20f\n\t" \
|
|
|
fa3bfd |
+ " j 1b\n\t" \
|
|
|
fa3bfd |
+ /* Found a value > 0x7f. */ \
|
|
|
fa3bfd |
+ "13: ahi %[R_TMP],4\n\t" \
|
|
|
fa3bfd |
+ "12: ahi %[R_TMP],4\n\t" \
|
|
|
fa3bfd |
+ "11: ahi %[R_TMP],4\n\t" \
|
|
|
fa3bfd |
+ "10: vlgvb %[R_I],%%v22,7\n\t" \
|
|
|
fa3bfd |
+ " srlg %[R_I],%[R_I],2\n\t" \
|
|
|
fa3bfd |
+ " agr %[R_I],%[R_TMP]\n\t" \
|
|
|
fa3bfd |
+ " je 20f\n\t" \
|
|
|
fa3bfd |
+ /* Store characters before invalid one... */ \
|
|
|
fa3bfd |
+ " slgr %[R_OUTLEN],%[R_I]\n\t" \
|
|
|
fa3bfd |
+ "15: aghi %[R_I],-1\n\t" \
|
|
|
fa3bfd |
+ " vstl %%v23,%[R_I],0(%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ /* ... and update pointers. */ \
|
|
|
fa3bfd |
+ " aghi %[R_I],1\n\t" \
|
|
|
fa3bfd |
+ " la %[R_OUT],0(%[R_I],%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ " sllg %[R_I],%[R_I],2\n\t" \
|
|
|
fa3bfd |
+ " la %[R_IN],0(%[R_I],%[R_IN])\n\t" \
|
|
|
fa3bfd |
+ " slgr %[R_INLEN],%[R_I]\n\t" \
|
|
|
fa3bfd |
+ /* Handle multibyte utf8-char with convert instruction. */ \
|
|
|
fa3bfd |
+ "20: cu41 %[R_OUT],%[R_IN]\n\t" \
|
|
|
fa3bfd |
+ " jo 0b\n\t" /* Try vector implemenation again. */ \
|
|
|
fa3bfd |
+ " lochil %[R_RES],%[RES_OUT_FULL]\n\t" /* cc == 1. */ \
|
|
|
fa3bfd |
+ " lochih %[R_RES],%[RES_IN_ILL]\n\t" /* cc == 2. */ \
|
|
|
fa3bfd |
+ ".machine pop" \
|
|
|
fa3bfd |
+ : /* outputs */ [R_IN] "+a" (pInput) \
|
|
|
fa3bfd |
+ , [R_INLEN] "+d" (inlen), [R_OUT] "+a" (pOutput) \
|
|
|
fa3bfd |
+ , [R_OUTLEN] "+d" (outlen), [R_TMP] "=d" (tmp) \
|
|
|
fa3bfd |
+ , [R_I] "=a" (tmp2) \
|
|
|
fa3bfd |
+ , [R_RES] "+d" (result) \
|
|
|
fa3bfd |
+ : /* inputs */ \
|
|
|
fa3bfd |
+ [RES_OUT_FULL] "i" (__GCONV_FULL_OUTPUT) \
|
|
|
fa3bfd |
+ , [RES_IN_ILL] "i" (__GCONV_ILLEGAL_INPUT) \
|
|
|
fa3bfd |
+ : /* clobber list */ "memory", "cc" \
|
|
|
fa3bfd |
+ ASM_CLOBBER_VR ("v16") ASM_CLOBBER_VR ("v17") \
|
|
|
fa3bfd |
+ ASM_CLOBBER_VR ("v18") ASM_CLOBBER_VR ("v19") \
|
|
|
fa3bfd |
+ ASM_CLOBBER_VR ("v20") ASM_CLOBBER_VR ("v21") \
|
|
|
fa3bfd |
+ ASM_CLOBBER_VR ("v22") ASM_CLOBBER_VR ("v23") \
|
|
|
fa3bfd |
+ ASM_CLOBBER_VR ("v24") \
|
|
|
fa3bfd |
+ ); \
|
|
|
fa3bfd |
+ inptr = pInput; \
|
|
|
fa3bfd |
+ outptr = pOutput; \
|
|
|
fa3bfd |
+ \
|
|
|
fa3bfd |
+ if (__glibc_likely (inptr == inend) \
|
|
|
fa3bfd |
+ || result == __GCONV_FULL_OUTPUT) \
|
|
|
fa3bfd |
+ break; \
|
|
|
fa3bfd |
+ if (inptr + 4 > inend) \
|
|
|
fa3bfd |
+ { \
|
|
|
fa3bfd |
+ result = __GCONV_INCOMPLETE_INPUT; \
|
|
|
fa3bfd |
+ break; \
|
|
|
fa3bfd |
+ } \
|
|
|
fa3bfd |
+ STANDARD_TO_LOOP_ERR_HANDLER (4); \
|
|
|
fa3bfd |
+ }
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+/* Generate loop-function with hardware vector and utf-convert instructions. */
|
|
|
fa3bfd |
+# define MIN_NEEDED_INPUT MIN_NEEDED_TO
|
|
|
fa3bfd |
+# define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
|
|
|
fa3bfd |
+# define MAX_NEEDED_OUTPUT MAX_NEEDED_FROM
|
|
|
fa3bfd |
+# define TO_LOOP_VX_CU __to_utf8_loop_vx_cu
|
|
|
fa3bfd |
+# define LOOPFCT TO_LOOP_VX_CU
|
|
|
fa3bfd |
+# define BODY BODY_TO_VX_CU
|
|
|
fa3bfd |
+# define LOOP_NEED_FLAGS
|
|
|
fa3bfd |
+# include <iconv/loop.c>
|
|
|
fa3bfd |
+#else
|
|
|
fa3bfd |
+# define TO_LOOP_VX_CU NULL
|
|
|
fa3bfd |
+#endif /* HAVE_TO_VX_CU != 1 */
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
/* This file also exists in sysdeps/s390/multiarch/ which
|
|
|
fa3bfd |
generates ifunc resolvers for FROM/TO_LOOP functions
|
|
|
fa3bfd |
and includes iconv/skeleton.c afterwards. */
|
|
|
fa3bfd |
--
|
|
|
fa3bfd |
1.8.3.1
|
|
|
fa3bfd |
|