|
|
fa3bfd |
From ed26260ce20cd6c05e8c8526bd2bd9fadfee8d19 Mon Sep 17 00:00:00 2001
|
|
|
fa3bfd |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
fa3bfd |
Date: Thu, 27 Jul 2017 10:53:59 +0200
|
|
|
fa3bfd |
Subject: [PATCH 08/10] S390: Use cu42 instruction for converting from utf32 to
|
|
|
fa3bfd |
utf16.
|
|
|
fa3bfd |
|
|
|
fa3bfd |
upstream-commit 593e4da186906525e2a0bdc4d87601bd0c2625eb
|
|
|
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 |
cu42 instruction.
|
|
|
fa3bfd |
|
|
|
fa3bfd |
ChangeLog:
|
|
|
fa3bfd |
|
|
|
fa3bfd |
* sysdeps/s390/utf16-utf32-z9.c (__to_utf16_loop_vx_cu):
|
|
|
fa3bfd |
Use vector and cu42 instruction.
|
|
|
fa3bfd |
* sysdeps/s390/multiarch/utf16-utf32-z9.c:
|
|
|
fa3bfd |
Add __to_utf16_loop_vx_cu in ifunc resolver.
|
|
|
fa3bfd |
---
|
|
|
fa3bfd |
sysdeps/s390/multiarch/utf16-utf32-z9.c | 8 ++-
|
|
|
fa3bfd |
sysdeps/s390/utf16-utf32-z9.c | 107 +++++++++++++++++++++++++++++++-
|
|
|
fa3bfd |
2 files changed, 111 insertions(+), 4 deletions(-)
|
|
|
fa3bfd |
|
|
|
fa3bfd |
diff --git a/sysdeps/s390/multiarch/utf16-utf32-z9.c b/sysdeps/s390/multiarch/utf16-utf32-z9.c
|
|
|
fa3bfd |
index 6e64169..ded3cc2 100644
|
|
|
fa3bfd |
--- a/sysdeps/s390/multiarch/utf16-utf32-z9.c
|
|
|
fa3bfd |
+++ b/sysdeps/s390/multiarch/utf16-utf32-z9.c
|
|
|
fa3bfd |
@@ -37,8 +37,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/utf16-utf32-z9.c b/sysdeps/s390/utf16-utf32-z9.c
|
|
|
fa3bfd |
index 5a39d5d..b1728d6 100644
|
|
|
fa3bfd |
--- a/sysdeps/s390/utf16-utf32-z9.c
|
|
|
fa3bfd |
+++ b/sysdeps/s390/utf16-utf32-z9.c
|
|
|
fa3bfd |
@@ -40,9 +40,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 |
@@ -471,7 +473,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
fa3bfd |
" vlm %%v30,%%v31,0(%[R_TMP])\n\t" \
|
|
|
fa3bfd |
CONVERT_32BIT_SIZE_T ([R_INLEN]) \
|
|
|
fa3bfd |
CONVERT_32BIT_SIZE_T ([R_OUTLEN]) \
|
|
|
fa3bfd |
- /* Loop which handles UTF-16 chars \
|
|
|
fa3bfd |
+ /* Loop which handles UTF-32 chars \
|
|
|
fa3bfd |
ch < 0xd800 || (ch > 0xdfff && ch < 0x10000). */ \
|
|
|
fa3bfd |
"0: clgijl %[R_INLEN],32,2f\n\t" \
|
|
|
fa3bfd |
" clgijl %[R_OUTLEN],16,2f\n\t" \
|
|
|
fa3bfd |
@@ -595,6 +597,109 @@ 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, tmp3; \
|
|
|
fa3bfd |
+ asm volatile (".machine push\n\t" \
|
|
|
fa3bfd |
+ ".machine \"z13\"\n\t" \
|
|
|
fa3bfd |
+ ".machinemode \"zarch_nohighgprs\"\n\t" \
|
|
|
fa3bfd |
+ /* Setup to check for surrogates. */ \
|
|
|
fa3bfd |
+ " larl %[R_TMP],9f\n\t" \
|
|
|
fa3bfd |
+ " vlm %%v30,%%v31,0(%[R_TMP])\n\t" \
|
|
|
fa3bfd |
+ CONVERT_32BIT_SIZE_T ([R_INLEN]) \
|
|
|
fa3bfd |
+ CONVERT_32BIT_SIZE_T ([R_OUTLEN]) \
|
|
|
fa3bfd |
+ /* Loop which handles UTF-32 chars \
|
|
|
fa3bfd |
+ ch < 0xd800 || (ch > 0xdfff && ch < 0x10000). */ \
|
|
|
fa3bfd |
+ "0: clgijl %[R_INLEN],32,20f\n\t" \
|
|
|
fa3bfd |
+ " clgijl %[R_OUTLEN],16,20f\n\t" \
|
|
|
fa3bfd |
+ "1: vlm %%v16,%%v17,0(%[R_IN])\n\t" \
|
|
|
fa3bfd |
+ " lghi %[R_TMP2],0\n\t" \
|
|
|
fa3bfd |
+ /* Shorten to UTF-16. */ \
|
|
|
fa3bfd |
+ " vpkf %%v18,%%v16,%%v17\n\t" \
|
|
|
fa3bfd |
+ /* Check for surrogate chars. */ \
|
|
|
fa3bfd |
+ " vstrcfs %%v19,%%v16,%%v30,%%v31\n\t" \
|
|
|
fa3bfd |
+ " jno 10f\n\t" \
|
|
|
fa3bfd |
+ " vstrcfs %%v19,%%v17,%%v30,%%v31\n\t" \
|
|
|
fa3bfd |
+ " jno 11f\n\t" \
|
|
|
fa3bfd |
+ /* Store 16 bytes to buf_out. */ \
|
|
|
fa3bfd |
+ " vst %%v18,0(%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ " la %[R_IN],32(%[R_IN])\n\t" \
|
|
|
fa3bfd |
+ " aghi %[R_INLEN],-32\n\t" \
|
|
|
fa3bfd |
+ " aghi %[R_OUTLEN],-16\n\t" \
|
|
|
fa3bfd |
+ " la %[R_OUT],16(%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ " clgijl %[R_INLEN],32,20f\n\t" \
|
|
|
fa3bfd |
+ " clgijl %[R_OUTLEN],16,20f\n\t" \
|
|
|
fa3bfd |
+ " j 1b\n\t" \
|
|
|
fa3bfd |
+ /* Setup to check for ch >= 0xd800 && ch <= 0xdfff \
|
|
|
fa3bfd |
+ and check for ch >= 0x10000. (v30, v31) */ \
|
|
|
fa3bfd |
+ "9: .long 0xd800,0xdfff,0x10000,0x10000\n\t" \
|
|
|
fa3bfd |
+ " .long 0xa0000000,0xc0000000, 0xa0000000,0xa0000000\n\t" \
|
|
|
fa3bfd |
+ /* At least one UTF32 char is in range of surrogates. \
|
|
|
fa3bfd |
+ Store the preceding characters. */ \
|
|
|
fa3bfd |
+ "11: ahi %[R_TMP2],16\n\t" \
|
|
|
fa3bfd |
+ "10: vlgvb %[R_TMP],%%v19,7\n\t" \
|
|
|
fa3bfd |
+ " agr %[R_TMP],%[R_TMP2]\n\t" \
|
|
|
fa3bfd |
+ " srlg %[R_TMP3],%[R_TMP],1\n\t" /* Number of out bytes. */ \
|
|
|
fa3bfd |
+ " ahik %[R_TMP2],%[R_TMP3],-1\n\t" /* Highest index to store. */ \
|
|
|
fa3bfd |
+ " jl 20f\n\t" \
|
|
|
fa3bfd |
+ " vstl %%v18,%[R_TMP2],0(%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ /* Update pointers. */ \
|
|
|
fa3bfd |
+ " la %[R_IN],0(%[R_TMP],%[R_IN])\n\t" \
|
|
|
fa3bfd |
+ " slgr %[R_INLEN],%[R_TMP]\n\t" \
|
|
|
fa3bfd |
+ " la %[R_OUT],0(%[R_TMP3],%[R_OUT])\n\t" \
|
|
|
fa3bfd |
+ " slgr %[R_OUTLEN],%[R_TMP3]\n\t" \
|
|
|
fa3bfd |
+ /* Handles UTF16 surrogates with convert instruction. */ \
|
|
|
fa3bfd |
+ "20: cu42 %[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] "=a" (tmp) \
|
|
|
fa3bfd |
+ , [R_TMP2] "=d" (tmp2), [R_TMP3] "=a" (tmp3) \
|
|
|
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 ("v30") ASM_CLOBBER_VR ("v31") \
|
|
|
fa3bfd |
+ ); \
|
|
|
fa3bfd |
+ inptr = pInput; \
|
|
|
fa3bfd |
+ outptr = pOutput; \
|
|
|
fa3bfd |
+ \
|
|
|
fa3bfd |
+ if (__glibc_likely (inlen == 0) \
|
|
|
fa3bfd |
+ || result == __GCONV_FULL_OUTPUT) \
|
|
|
fa3bfd |
+ break; \
|
|
|
fa3bfd |
+ if (inlen < 4) \
|
|
|
fa3bfd |
+ { \
|
|
|
fa3bfd |
+ result = __GCONV_INCOMPLETE_INPUT; \
|
|
|
fa3bfd |
+ break; \
|
|
|
fa3bfd |
+ } \
|
|
|
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_utf16_loop_vx_cu
|
|
|
fa3bfd |
+# define LOOPFCT TO_LOOP_VX_CU
|
|
|
fa3bfd |
+# define LOOP_NEED_FLAGS
|
|
|
fa3bfd |
+# define BODY BODY_TO_VX_CU
|
|
|
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 |
|