Re: [PATCH] rs6000: Add support for the vec_sbox_be, vec_cipher_be etc. builtins.

2019-02-19 Thread Segher Boessenkool
On Tue, Feb 12, 2019 at 02:00:38PM +0800, Xiong Hu Luo wrote:
> On 2019/1/26 AM1:43, Segher Boessenkool wrote:
> >On Wed, Jan 23, 2019 at 03:57:28AM -0600, luo...@linux.vnet.ibm.com wrote:
> >>The 5 new builtins vec_sbox_be, vec_cipher_be, vec_cipherlast_be, 
> >>vec_ncipher_be
> >>and vec_ncipherlast_be only support vector unsigned char type parameters.
> >>Add new instruction crypto_vsbox_ and crypto__ to 
> >>handle
> >>them accordingly, where the new mode CR_vqdi can be expanded to vector 
> >>unsigned
> >>long long for none _be postfix builtins or vector unsigned char for _be 
> >>postfix
> >>builtins.
> >
> >Hrm, can't you use the existing CR_mode iterator here?
> >
> >>2019-01-23  Xiong Hu Luo  
> >>
> >>* gcc/testsuite/gcc.target/powerpc/crypto-builtin-1.c
> >>(crpyto1_be, crpyto2_be, crpyto3_be, crpyto4_be, crpyto5_be):
> >> New testcases.
> >
> >Typoes ("crypto").  And that last line is indented incorrectly.
> >
> >With those things fixed, okay for trunk, with the new iterator if CR_mode
> >isn't usable here.  Thanks!
> 
> Thanks, I will fix the typos and indent.
> CR_mode support all the 4 types(v16qi, v8hi, v4si and v2di), so we 
> define the new mode CR_vqdi to represent only 2 types(v16qi and v2di) we 
> need, means that these two modes cannot be reused.
> BTW, does this patch need back port to gcc-7 and gcc-8?

[ Sorry, I think I forgot to reply to this. ]

They probably should be backported, yes.  Okay to backport after 8.3 has
been released.  Thanks!


Segher


Re: [PATCH] rs6000: Add support for the vec_sbox_be, vec_cipher_be etc. builtins.

2019-02-11 Thread Xiong Hu Luo

Hi Segher,

On 2019/1/26 AM1:43, Segher Boessenkool wrote:

Hi!

On Wed, Jan 23, 2019 at 03:57:28AM -0600, luo...@linux.vnet.ibm.com wrote:

The 5 new builtins vec_sbox_be, vec_cipher_be, vec_cipherlast_be, vec_ncipher_be
and vec_ncipherlast_be only support vector unsigned char type parameters.
Add new instruction crypto_vsbox_ and crypto__ to handle
them accordingly, where the new mode CR_vqdi can be expanded to vector unsigned
long long for none _be postfix builtins or vector unsigned char for _be postfix
builtins.


Hrm, can't you use the existing CR_mode iterator here?


2019-01-23  Xiong Hu Luo  

* gcc/testsuite/gcc.target/powerpc/crypto-builtin-1.c
(crpyto1_be, crpyto2_be, crpyto3_be, crpyto4_be, crpyto5_be):
 New testcases.


Typoes ("crypto").  And that last line is indented incorrectly.

With those things fixed, okay for trunk, with the new iterator if CR_mode
isn't usable here.  Thanks!


Segher



Thanks, I will fix the typos and indent.
CR_mode support all the 4 types(v16qi, v8hi, v4si and v2di), so we 
define the new mode CR_vqdi to represent only 2 types(v16qi and v2di) we 
need, means that these two modes cannot be reused.

BTW, does this patch need back port to gcc-7 and gcc-8?

Xionghu







Re: [PATCH] rs6000: Add support for the vec_sbox_be, vec_cipher_be etc. builtins.

2019-01-25 Thread Segher Boessenkool
Hi!

On Wed, Jan 23, 2019 at 03:57:28AM -0600, luo...@linux.vnet.ibm.com wrote:
> The 5 new builtins vec_sbox_be, vec_cipher_be, vec_cipherlast_be, 
> vec_ncipher_be
> and vec_ncipherlast_be only support vector unsigned char type parameters.
> Add new instruction crypto_vsbox_ and crypto__ to handle
> them accordingly, where the new mode CR_vqdi can be expanded to vector 
> unsigned
> long long for none _be postfix builtins or vector unsigned char for _be 
> postfix
> builtins.

Hrm, can't you use the existing CR_mode iterator here?

> 2019-01-23  Xiong Hu Luo  
> 
>   * gcc/testsuite/gcc.target/powerpc/crypto-builtin-1.c
>   (crpyto1_be, crpyto2_be, crpyto3_be, crpyto4_be, crpyto5_be):
> New testcases.

Typoes ("crypto").  And that last line is indented incorrectly.

With those things fixed, okay for trunk, with the new iterator if CR_mode
isn't usable here.  Thanks!


Segher


[PATCH] rs6000: Add support for the vec_sbox_be, vec_cipher_be etc. builtins.

2019-01-23 Thread luoxhu
From: Xiong Hu Luo 

The 5 new builtins vec_sbox_be, vec_cipher_be, vec_cipherlast_be, vec_ncipher_be
and vec_ncipherlast_be only support vector unsigned char type parameters.
Add new instruction crypto_vsbox_ and crypto__ to handle
them accordingly, where the new mode CR_vqdi can be expanded to vector unsigned
long long for none _be postfix builtins or vector unsigned char for _be postfix
builtins.

---
gcc/ChangeLog

2019-01-23  Xiong Hu Luo  

* gcc/config/rs6000/altivec.h (vec_sbox_be, vec_cipher_be,
vec_cipherlast_be, vec_ncipher_be, vec_ncipherlast_be): New #defines.
* gcc/config/rs6000/crypto.md (CR_vqdi): New define_mode_iterator.
(crypto_vsbox_, crypto__): New define_insns.
* gcc/config/rs6000/rs6000-builtin.def (VSBOX_BE): New BU_CRYPTO_1.
(VCIPHER_BE, VCIPHERLAST_BE, VNCIPHER_BE, VNCIPHERLAST_BE):
New BU_CRYPTO_2.
* gcc/config/rs6000/rs6000.c (builtin_function_type)
: New switch options.
* gcc/doc/extend.texi (vec_sbox_be, vec_cipher_be, vec_cipherlast_be,
vec_ncipher_be, vec_ncipherlast_be): New builtin functions.

gcc/testsuite/ChangeLog

2019-01-23  Xiong Hu Luo  

* gcc/testsuite/gcc.target/powerpc/crypto-builtin-1.c
(crpyto1_be, crpyto2_be, crpyto3_be, crpyto4_be, crpyto5_be):
New testcases.
---
 gcc/config/rs6000/altivec.h|  5 +++
 gcc/config/rs6000/crypto.md| 17 +-
 gcc/config/rs6000/rs6000-builtin.def   | 19 +---
 gcc/config/rs6000/rs6000.c |  5 +++
 gcc/doc/extend.texi| 13 
 .../gcc.target/powerpc/crypto-builtin-1.c  | 36 +++---
 6 files changed, 78 insertions(+), 17 deletions(-)

diff --git a/gcc/config/rs6000/altivec.h b/gcc/config/rs6000/altivec.h
index bf29d46..d66ae7c 100644
--- a/gcc/config/rs6000/altivec.h
+++ b/gcc/config/rs6000/altivec.h
@@ -418,6 +418,11 @@
 #define vec_vupkhsw __builtin_vec_vupkhsw
 #define vec_vupklsw __builtin_vec_vupklsw
 #define vec_revb __builtin_vec_revb
+#define vec_sbox_be __builtin_crypto_vsbox_be
+#define vec_cipher_be __builtin_crypto_vcipher_be
+#define vec_cipherlast_be __builtin_crypto_vcipherlast_be
+#define vec_ncipher_be __builtin_crypto_vncipher_be
+#define vec_ncipherlast_be __builtin_crypto_vncipherlast_be
 #endif
 
 #ifdef __POWER9_VECTOR__
diff --git a/gcc/config/rs6000/crypto.md b/gcc/config/rs6000/crypto.md
index 2ee3e3a..b9917b0 100644
--- a/gcc/config/rs6000/crypto.md
+++ b/gcc/config/rs6000/crypto.md
@@ -48,6 +48,9 @@
 ;; Iterator for VSHASIGMAD/VSHASIGMAW
 (define_mode_iterator CR_hash [V4SI V2DI])
 
+;; Iterator for VSBOX/VCIPHER/VNCIPHER/VCIPHERLAST/VNCIPHERLAST
+(define_mode_iterator CR_vqdi [V16QI V2DI])
+
 ;; Iterator for the other crypto functions
 (define_int_iterator CR_code   [UNSPEC_VCIPHER
UNSPEC_VNCIPHER
@@ -60,10 +63,10 @@
  (UNSPEC_VNCIPHERLAST "vncipherlast")])
 
 ;; 2 operand crypto instructions
-(define_insn "crypto_"
-  [(set (match_operand:V2DI 0 "register_operand" "=v")
-   (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "v")
- (match_operand:V2DI 2 "register_operand" "v")]
+(define_insn "crypto__"
+  [(set (match_operand:CR_vqdi 0 "register_operand" "=v")
+   (unspec:CR_vqdi [(match_operand:CR_vqdi 1 "register_operand" "v")
+ (match_operand:CR_vqdi 2 "register_operand" "v")]
 CR_code))]
   "TARGET_CRYPTO"
   " %0,%1,%2"
@@ -90,9 +93,9 @@
   [(set_attr "type" "vecperm")])
 
 ;; 1 operand crypto instruction
-(define_insn "crypto_vsbox"
-  [(set (match_operand:V2DI 0 "register_operand" "=v")
-   (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "v")]
+(define_insn "crypto_vsbox_"
+  [(set (match_operand:CR_vqdi 0 "register_operand" "=v")
+   (unspec:CR_vqdi [(match_operand:CR_vqdi 1 "register_operand" "v")]
 UNSPEC_VSBOX))]
   "TARGET_CRYPTO"
   "vsbox %0,%1"
diff --git a/gcc/config/rs6000/rs6000-builtin.def 
b/gcc/config/rs6000/rs6000-builtin.def
index 60b3bd0..0a2bdb7 100644
--- a/gcc/config/rs6000/rs6000-builtin.def
+++ b/gcc/config/rs6000/rs6000-builtin.def
@@ -2418,13 +2418,22 @@ BU_P9_OVERLOAD_2 (CMPRB2,   "byte_in_either_range")
 BU_P9_OVERLOAD_2 (CMPEQB,  "byte_in_set")
 
 /* 1 argument crypto functions.  */
-BU_CRYPTO_1 (VSBOX,"vsbox",  CONST, crypto_vsbox)
+BU_CRYPTO_1 (VSBOX,"vsbox",  CONST, crypto_vsbox_v2di)
+BU_CRYPTO_1 (VSBOX_BE, "vsbox_be",   CONST, crypto_vsbox_v16qi)
 
 /* 2 argument crypto functions.  */
-BU_CRYPTO_2 (VCIPHER,  "vcipher",CONST, crypto_vcipher)
-BU_CRYPTO_2 (VCIPHERLAST,  "vcipherlast",CONST, crypto_vcipherlast)
-BU_CRYPTO_2 (VNCIPHER, "vncipher",   CONST, crypto_vncipher)
-BU_CRYPTO_2 (VNCIPHERLAST, "vncipherlast",   CONST, crypto_vncipherlast)