|
|
147e83 |
From 832572eac8a661d25efe0f2bcc6a861e2c29c3b8 Mon Sep 17 00:00:00 2001
|
|
|
147e83 |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
147e83 |
Date: Mon, 7 Nov 2016 15:50:46 +0100
|
|
|
147e83 |
Subject: [PATCH 05/17] S390: Optimize iso-8859-1 to ibm037 iconv-module.
|
|
|
147e83 |
|
|
|
147e83 |
Upstream commit 81c6380887c6d62c56e5f0f85a241f759f58b2fd
|
|
|
147e83 |
|
|
|
147e83 |
This patch reworks the s390 specific module which used the z900
|
|
|
147e83 |
translate one to one instruction. Now the g5 translate instruction is used,
|
|
|
147e83 |
because it outperforms the troo instruction.
|
|
|
147e83 |
|
|
|
147e83 |
ChangeLog:
|
|
|
147e83 |
|
|
|
147e83 |
* sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c (TROO_LOOP):
|
|
|
147e83 |
Rename to TR_LOOP and usage of tr instead of troo instruction.
|
|
|
147e83 |
---
|
|
|
147e83 |
sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c | 95 +++++++++++++++++-----------
|
|
|
147e83 |
1 file changed, 57 insertions(+), 38 deletions(-)
|
|
|
147e83 |
|
|
|
147e83 |
diff --git a/sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c b/sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c
|
|
|
147e83 |
index 58641f5..3b63e6a 100644
|
|
|
147e83 |
--- a/sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c
|
|
|
147e83 |
+++ b/sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c
|
|
|
147e83 |
@@ -1,8 +1,7 @@
|
|
|
147e83 |
/* Conversion between ISO 8859-1 and IBM037.
|
|
|
147e83 |
|
|
|
147e83 |
- This module uses the Z900 variant of the Translate One To One
|
|
|
147e83 |
- instruction.
|
|
|
147e83 |
- Copyright (C) 1997-2009 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This module uses the translate instruction.
|
|
|
147e83 |
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
|
|
|
147e83 |
|
|
|
147e83 |
Author: Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
|
|
|
147e83 |
Based on the work by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
|
|
147e83 |
@@ -176,50 +175,70 @@ __attribute__ ((aligned (8))) =
|
|
|
147e83 |
#define MIN_NEEDED_FROM 1
|
|
|
147e83 |
#define MIN_NEEDED_TO 1
|
|
|
147e83 |
|
|
|
147e83 |
-/* The Z900 variant of troo forces us to always specify a test
|
|
|
147e83 |
- character which ends the translation. So if we run into the
|
|
|
147e83 |
- situation where the translation has been interrupted due to the
|
|
|
147e83 |
- test character we translate the character by hand and jump back
|
|
|
147e83 |
- into the instruction. */
|
|
|
147e83 |
-
|
|
|
147e83 |
-#define TROO_LOOP(TABLE) \
|
|
|
147e83 |
+#define TR_LOOP(TABLE) \
|
|
|
147e83 |
{ \
|
|
|
147e83 |
- register const unsigned char test asm ("0") = 0; \
|
|
|
147e83 |
- register const unsigned char *pTable asm ("1") = TABLE; \
|
|
|
147e83 |
- register unsigned char *pOutput asm ("2") = outptr; \
|
|
|
147e83 |
- register uint64_t length asm ("3"); \
|
|
|
147e83 |
- const unsigned char* pInput = inptr; \
|
|
|
147e83 |
- uint64_t tmp; \
|
|
|
147e83 |
- \
|
|
|
147e83 |
- length = (inend - inptr < outend - outptr \
|
|
|
147e83 |
- ? inend - inptr : outend - outptr); \
|
|
|
147e83 |
+ size_t length = (inend - inptr < outend - outptr \
|
|
|
147e83 |
+ ? inend - inptr : outend - outptr); \
|
|
|
147e83 |
\
|
|
|
147e83 |
- asm volatile ("0: \n\t" \
|
|
|
147e83 |
- " troo %0,%1 \n\t" \
|
|
|
147e83 |
- " jz 1f \n\t" \
|
|
|
147e83 |
- " jo 0b \n\t" \
|
|
|
147e83 |
- " llgc %3,0(%1) \n\t" \
|
|
|
147e83 |
- " la %3,0(%3,%4) \n\t" \
|
|
|
147e83 |
- " mvc 0(1,%0),0(%3) \n\t" \
|
|
|
147e83 |
- " aghi %1,1 \n\t" \
|
|
|
147e83 |
- " aghi %0,1 \n\t" \
|
|
|
147e83 |
- " aghi %2,-1 \n\t" \
|
|
|
147e83 |
- " j 0b \n\t" \
|
|
|
147e83 |
- "1: \n" \
|
|
|
147e83 |
+ /* Process in 256 byte blocks. */ \
|
|
|
147e83 |
+ if (__builtin_expect (length >= 256, 0)) \
|
|
|
147e83 |
+ { \
|
|
|
147e83 |
+ size_t blocks = length / 256; \
|
|
|
147e83 |
+ __asm__ __volatile__("0: mvc 0(256,%[R_OUT]),0(%[R_IN])\n\t" \
|
|
|
147e83 |
+ " tr 0(256,%[R_OUT]),0(%[R_TBL])\n\t" \
|
|
|
147e83 |
+ " la %[R_IN],256(%[R_IN])\n\t" \
|
|
|
147e83 |
+ " la %[R_OUT],256(%[R_OUT])\n\t" \
|
|
|
147e83 |
+ " brctg %[R_LI],0b\n\t" \
|
|
|
147e83 |
+ : /* outputs */ [R_IN] "+a" (inptr) \
|
|
|
147e83 |
+ , [R_OUT] "+a" (outptr), [R_LI] "+d" (blocks) \
|
|
|
147e83 |
+ : /* inputs */ [R_TBL] "a" (TABLE) \
|
|
|
147e83 |
+ : /* clobber list */ "memory" \
|
|
|
147e83 |
+ ); \
|
|
|
147e83 |
+ length = length % 256; \
|
|
|
147e83 |
+ } \
|
|
|
147e83 |
\
|
|
|
147e83 |
- : "+a" (pOutput), "+a" (pInput), "+d" (length), "=&a" (tmp) \
|
|
|
147e83 |
- : "a" (pTable), "d" (test) \
|
|
|
147e83 |
- : "cc"); \
|
|
|
147e83 |
+ /* Process remaining 0...248 bytes in 8byte blocks. */ \
|
|
|
147e83 |
+ if (length >= 8) \
|
|
|
147e83 |
+ { \
|
|
|
147e83 |
+ size_t blocks = length / 8; \
|
|
|
147e83 |
+ for (int i = 0; i < blocks; i++) \
|
|
|
147e83 |
+ { \
|
|
|
147e83 |
+ outptr[0] = TABLE[inptr[0]]; \
|
|
|
147e83 |
+ outptr[1] = TABLE[inptr[1]]; \
|
|
|
147e83 |
+ outptr[2] = TABLE[inptr[2]]; \
|
|
|
147e83 |
+ outptr[3] = TABLE[inptr[3]]; \
|
|
|
147e83 |
+ outptr[4] = TABLE[inptr[4]]; \
|
|
|
147e83 |
+ outptr[5] = TABLE[inptr[5]]; \
|
|
|
147e83 |
+ outptr[6] = TABLE[inptr[6]]; \
|
|
|
147e83 |
+ outptr[7] = TABLE[inptr[7]]; \
|
|
|
147e83 |
+ inptr += 8; \
|
|
|
147e83 |
+ outptr += 8; \
|
|
|
147e83 |
+ } \
|
|
|
147e83 |
+ length = length % 8; \
|
|
|
147e83 |
+ } \
|
|
|
147e83 |
\
|
|
|
147e83 |
- inptr = pInput; \
|
|
|
147e83 |
- outptr = pOutput; \
|
|
|
147e83 |
+ /* Process remaining 0...7 bytes. */ \
|
|
|
147e83 |
+ switch (length) \
|
|
|
147e83 |
+ { \
|
|
|
147e83 |
+ case 7: outptr[6] = TABLE[inptr[6]]; \
|
|
|
147e83 |
+ case 6: outptr[5] = TABLE[inptr[5]]; \
|
|
|
147e83 |
+ case 5: outptr[4] = TABLE[inptr[4]]; \
|
|
|
147e83 |
+ case 4: outptr[3] = TABLE[inptr[3]]; \
|
|
|
147e83 |
+ case 3: outptr[2] = TABLE[inptr[2]]; \
|
|
|
147e83 |
+ case 2: outptr[1] = TABLE[inptr[1]]; \
|
|
|
147e83 |
+ case 1: outptr[0] = TABLE[inptr[0]]; \
|
|
|
147e83 |
+ case 0: break; \
|
|
|
147e83 |
+ } \
|
|
|
147e83 |
+ inptr += length; \
|
|
|
147e83 |
+ outptr += length; \
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
+
|
|
|
147e83 |
/* First define the conversion function from ISO 8859-1 to CP037. */
|
|
|
147e83 |
#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
|
|
|
147e83 |
#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
|
|
|
147e83 |
#define LOOPFCT FROM_LOOP
|
|
|
147e83 |
-#define BODY TROO_LOOP (table_iso8859_1_to_cp037)
|
|
|
147e83 |
+#define BODY TR_LOOP (table_iso8859_1_to_cp037)
|
|
|
147e83 |
|
|
|
147e83 |
#include <iconv/loop.c>
|
|
|
147e83 |
|
|
|
147e83 |
@@ -228,7 +247,7 @@ __attribute__ ((aligned (8))) =
|
|
|
147e83 |
#define MIN_NEEDED_INPUT MIN_NEEDED_TO
|
|
|
147e83 |
#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
|
|
|
147e83 |
#define LOOPFCT TO_LOOP
|
|
|
147e83 |
-#define BODY TROO_LOOP (table_cp037_iso8859_1);
|
|
|
147e83 |
+#define BODY TR_LOOP (table_cp037_iso8859_1);
|
|
|
147e83 |
|
|
|
147e83 |
#include <iconv/loop.c>
|
|
|
147e83 |
|
|
|
147e83 |
--
|
|
|
147e83 |
1.8.3.1
|
|
|
147e83 |
|