UNSPEC_VSBOX
UNSPEC_VSHASIGMA
UNSPEC_VPERMXOR
- UNSPEC_VPMSUM])
+ UNSPEC_VPMSUM
+ UNSPEC_XXAESENCP
+ UNSPEC_XXAES128ENCP
+ UNSPEC_XXAES192ENCP
+ UNSPEC_XXAES256ENCP
+ UNSPEC_XXAESDECP
+ UNSPEC_XXAES128DECP
+ UNSPEC_XXAES192DECP
+ UNSPEC_XXAES256DECP
+ UNSPEC_XXAESGENLKP
+ UNSPEC_XXAES128GENLKP
+ UNSPEC_XXAES192GENLKP
+ UNSPEC_XXAES256GENLKP
+ UNSPEC_XXGFMUL128
+ UNSPEC_XXGFMUL128GCM
+ UNSPEC_XXGFMUL128XTS])
;; Iterator for VPMSUM/VPERMXOR
(define_mode_iterator CR_mode [V16QI V8HI V4SI V2DI])
(UNSPEC_VCIPHERLAST "vcipherlast")
(UNSPEC_VNCIPHERLAST "vncipherlast")])
+;; Iterator and attribute for AES encrypt/decrypt
+(define_int_iterator AESACC_base_code [UNSPEC_XXAESENCP
+ UNSPEC_XXAESDECP])
+(define_int_attr AESACC_base_insn [(UNSPEC_XXAESENCP "xxaesencp")
+ (UNSPEC_XXAESDECP "xxaesdecp")])
+
+;; Iterator and attribute for AES encrypt/decrypt extended mnemonics
+(define_int_iterator AESACC_code [UNSPEC_XXAES128ENCP
+ UNSPEC_XXAES192ENCP
+ UNSPEC_XXAES256ENCP
+ UNSPEC_XXAES128DECP
+ UNSPEC_XXAES192DECP
+ UNSPEC_XXAES256DECP])
+(define_int_attr AESACC_insn [(UNSPEC_XXAES128ENCP "xxaes128encp")
+ (UNSPEC_XXAES192ENCP "xxaes192encp")
+ (UNSPEC_XXAES256ENCP "xxaes256encp")
+ (UNSPEC_XXAES128DECP "xxaes128decp")
+ (UNSPEC_XXAES192DECP "xxaes192decp")
+ (UNSPEC_XXAES256DECP "xxaes256decp")])
+
+;; Iterator and attribute for AES gen last key extended mnemonics
+(define_int_iterator AESGENLKP_code [UNSPEC_XXAES128GENLKP
+ UNSPEC_XXAES192GENLKP
+ UNSPEC_XXAES256GENLKP])
+(define_int_attr AESGENLKP_insn [(UNSPEC_XXAES128GENLKP "xxaes128genlkp")
+ (UNSPEC_XXAES192GENLKP "xxaes192genlkp")
+ (UNSPEC_XXAES256GENLKP "xxaes256genlkp")])
+
+;; Iterator and attribute for AES galois field mult extended mnemonics
+(define_int_iterator AESGF_code [UNSPEC_XXGFMUL128GCM
+ UNSPEC_XXGFMUL128XTS])
+(define_int_attr AESGF_insn [(UNSPEC_XXGFMUL128GCM "xxgfmul128gcm")
+ (UNSPEC_XXGFMUL128XTS "xxgfmul128xts")])
+
;; 2 operand crypto instructions
(define_insn "crypto_<CR_insn>_<mode>"
[(set (match_operand:CR_vqdi 0 "register_operand" "=v")
"TARGET_CRYPTO"
"vshasigma<CR_char> %0,%1,%2,%3"
[(set_attr "type" "vecsimple")])
+
+;; AES acceleration instructions
+
+(define_insn "<AESACC_base_insn>"
+ [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+ (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")
+ (match_operand:OO 2 "vsx_register_operand" "wa")
+ (match_operand:SI 3 "const_0_to_3_operand" "n")]
+ AESACC_base_code))]
+ "TARGET_FUTURE"
+ "<AESACC_base_insn> %x0,%x1,%x2,%3")
+
+(define_insn "<AESACC_insn>"
+ [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+ (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")
+ (match_operand:OO 2 "vsx_register_operand" "wa")]
+ AESACC_code))]
+ "TARGET_FUTURE"
+ "<AESACC_insn> %x0,%x1,%x2")
+
+(define_insn "xxaesgenlkp"
+ [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+ (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")
+ (match_operand:SI 2 "const_0_to_3_operand" "n")]
+ UNSPEC_XXAESGENLKP))]
+ "TARGET_FUTURE"
+ "xxaesgenlkp %x0,%x1,%2")
+
+(define_insn "<AESGENLKP_insn>"
+ [(set (match_operand:OO 0 "vsx_register_operand" "=wa")
+ (unspec:OO [(match_operand:OO 1 "vsx_register_operand" "wa")]
+ AESGENLKP_code))]
+ "TARGET_FUTURE"
+ "<AESGENLKP_insn> %x0,%x1")
+
+(define_insn "xxgfmul128"
+ [(set (match_operand:V16QI 0 "vsx_register_operand" "=wa")
+ (unspec:V16QI [(match_operand:V16QI 1 "vsx_register_operand" "wa")
+ (match_operand:V16QI 2 "vsx_register_operand" "wa")
+ (match_operand:SI 3 "const_0_to_1_operand" "n")]
+ UNSPEC_XXGFMUL128))]
+ "TARGET_FUTURE"
+ "xxgfmul128 %x0,%x1,%x2,%3")
+
+(define_insn "<AESGF_insn>"
+ [(set (match_operand:V16QI 0 "vsx_register_operand" "=wa")
+ (unspec:V16QI [(match_operand:V16QI 1 "vsx_register_operand" "wa")
+ (match_operand:V16QI 2 "vsx_register_operand" "wa")]
+ AESGF_code))]
+ "TARGET_FUTURE"
+ "<AESGF_insn> %x0,%x1,%x2")
void __builtin_vsx_stxvp (v256, unsigned long, const v256 *);
STXVP nothing {mma,pair}
+
+[future]
+ const v256 __builtin_aes_encrypt_paired (v256, v256, const int<2>);
+ XXAESENCP xxaesencp {}
+
+ const v256 __builtin_aes128_encrypt_paired (v256, v256);
+ XXAES128ENCP xxaes128encp {}
+
+ const v256 __builtin_aes192_encrypt_paired (v256, v256);
+ XXAES192ENCP xxaes192encp {}
+
+ const v256 __builtin_aes256_encrypt_paired (v256, v256);
+ XXAES256ENCP xxaes256encp {}
+
+ const v256 __builtin_aes_decrypt_paired (v256, v256, const int<2>);
+ XXAESDECP xxaesdecp {}
+
+ const v256 __builtin_aes128_decrypt_paired (v256, v256);
+ XXAES128DECP xxaes128decp {}
+
+ const v256 __builtin_aes192_decrypt_paired (v256, v256);
+ XXAES192DECP xxaes192decp {}
+
+ const v256 __builtin_aes256_decrypt_paired (v256, v256);
+ XXAES256DECP xxaes256decp {}
+
+ const v256 __builtin_aes_genlastkey_paired (v256, const int<2>);
+ XXAESGENLKP xxaesgenlkp {}
+
+ const v256 __builtin_aes128_genlastkey_paired (v256);
+ XXAES128GENLKP xxaes128genlkp {}
+
+ const v256 __builtin_aes192_genlastkey_paired (v256);
+ XXAES192GENLKP xxaes192genlkp {}
+
+ const v256 __builtin_aes256_genlastkey_paired (v256);
+ XXAES256GENLKP xxaes256genlkp {}
+
+ const vuc __builtin_galois_field_mult (vuc, vuc, const int<1>);
+ XXGFMUL128 xxgfmul128 {}
+
+ const vuc __builtin_galois_field_mult_gcm (vuc, vuc);
+ XXGFMUL128GCM xxgfmul128gcm {}
+
+ const vuc __builtin_galois_field_mult_xts (vuc, vuc);
+ XXGFMUL128XTS xxgfmul128xts {}
* PowerPC AltiVec Built-in Functions Available on ISA 2.07::
* PowerPC AltiVec Built-in Functions Available on ISA 3.0::
* PowerPC AltiVec Built-in Functions Available on ISA 3.1::
+* PowerPC AltiVec/VSX Built-in Functions Available on Future ISA::
@end menu
@node PowerPC AltiVec Built-in Functions on ISA 2.05
vector unsigned char);
@end smallexample
+@node PowerPC AltiVec/VSX Built-in Functions Available on Future ISA
+@subsubsection PowerPC AltiVec/VSX Built-in Functions Available on Future ISA
+
+The following additional built-in functions are available for the
+PowerPC family of processors, starting with Future ISA.
+
+Future ISA of the PowerPC may add new instructions for accelerating AES
+algorithm. GCC provides support for these new instructions through the
+following built-in functions. The third argument to
+@var{__builtin_aes_encrypt_paired} and @var{__builtin_aes_decrypt_paired} must
+be a constant integer that is 0, 1 or 2. The values correspond to 128, 192 and
+256 bit AES encryption/decryption respectively. The third argument to
+@var{__builtin_galois_field_mult} must be a constant integer that is 0 or 1.
+The values correspond to gcm and xts variant respectively.
+
+@smallexample
+__vector_pair __builtin_aes_encrypt_paired (__vector_pair, __vector_pair,
+ int);
+
+__vector_pair __builtin_aes128_encrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair __builtin_aes192_encrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair __builtin_aes256_encrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair __builtin_aes_decrypt_paired (__vector_pair, __vector_pair,
+ int);
+
+__vector_pair __builtin_aes128_decrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair __builtin_aes192_decrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair __builtin_aes256_decrypt_paired (__vector_pair, __vector_pair);
+
+__vector_pair __builtin_aes_genlastkey_paired (__vector_pair, int);
+
+__vector_pair __builtin_aes128_genlastkey_paired (__vector_pair);
+
+__vector_pair __builtin_aes192_genlastkey_paired (__vector_pair);
+
+__vector_pair __builtin_aes256_genlastkey_paired (__vector_pair);
+
+vec_t __builtin_galois_field_mult (vec_t, vec_t, int);
+
+vec_t __builtin_galois_field_mult_gcm (vec_t, vec_t);
+
+vec_t __builtin_galois_field_mult_xts (vec_t, vec_t);
+@end smallexample
+
+
@node PowerPC Hardware Transactional Memory Built-in Functions
@subsection PowerPC Hardware Transactional Memory Built-in Functions
GCC provides two interfaces for accessing the Hardware Transactional
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+void
+aes_enc_pair_0 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_encrypt_paired (t, k, 0);
+ *res = c;
+}
+void
+aes_enc_pair_1 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_encrypt_paired (t, k, 1);
+ *res = c;
+}
+void
+aes_enc_pair_2 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_encrypt_paired (t, k, 2);
+ *res = c;
+}
+void
+aes_enc_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes128_encrypt_paired (t, k);
+ *res = c;
+}
+void
+aes_enc_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes192_encrypt_paired (t, k);
+ *res = c;
+}
+void
+aes_enc_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes256_encrypt_paired (t, k);
+ *res = c;
+}
+void
+aes_dec_pair_0 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_decrypt_paired (t, k, 0);
+ *res = c;
+}
+void
+aes_dec_pair_1 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_decrypt_paired (t, k, 1);
+ *res = c;
+}
+void
+aes_dec_pair_2 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_decrypt_paired (t, k, 2);
+ *res = c;
+}
+void
+aes_dec_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes128_decrypt_paired (t, k);
+ *res = c;
+}
+void
+aes_dec_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes192_decrypt_paired (t, k);
+ *res = c;
+}
+void
+aes_dec_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes256_decrypt_paired (t, k);
+ *res = c;
+}
+void
+aes_genlastkey_paired_0 (__vector_pair *key, __vector_pair *res)
+{
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_genlastkey_paired (k, 0);
+ *res = c;
+}
+void
+aes_genlastkey_paired_1 (__vector_pair *key, __vector_pair *res)
+{
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_genlastkey_paired (k, 1);
+ *res = c;
+}
+void
+aes_genlastkey_paired_2 (__vector_pair *key, __vector_pair *res)
+{
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes_genlastkey_paired (k, 2);
+ *res = c;
+}
+void
+aes_genlastkey_paired_128 (__vector_pair *key, __vector_pair *res)
+{
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes128_genlastkey_paired (k);
+ *res = c;
+}
+void
+aes_genlastkey_paired_192 (__vector_pair *key, __vector_pair *res)
+{
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes192_genlastkey_paired (k);
+ *res = c;
+}
+void
+aes_genlastkey_paired_256 (__vector_pair *key, __vector_pair *res)
+{
+ __vector_pair k = *key;
+ __vector_pair c = __builtin_aes256_genlastkey_paired (k);
+ *res = c;
+}
+
+
+/* { dg-final { scan-assembler-times {\mxxaesencp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128encp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192encp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256encp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaesdecp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaesgenlkp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256genlkp\M} 1 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+typedef unsigned char vec_t __attribute__((vector_size(16)));
+
+void
+gfmul (vec_t *a, vec_t *b, vec_t *res)
+{
+ vec_t A = *a;
+ vec_t B = *b;
+ vec_t R = __builtin_galois_field_mult (A, B, 0);
+ R = __builtin_galois_field_mult (R, B, 1);
+ *res = R;
+}
+void
+gfmul_gcm (vec_t *a, vec_t *b, vec_t *res)
+{
+ vec_t A = *a;
+ vec_t B = *b;
+ vec_t R = __builtin_galois_field_mult_gcm (A, B);
+ *res = R;
+}
+void
+gfmul_xts (vec_t *a, vec_t *b, vec_t *res)
+{
+ vec_t A = *a;
+ vec_t B = *b;
+ vec_t R = __builtin_galois_field_mult_xts (A, B);
+ *res = R;
+}
+
+/* { dg-final { scan-assembler-times {\mxxgfmul128\M} 2 } } */
+/* { dg-final { scan-assembler-times {\mxxgfmul128gcm\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxgfmul128xts\M} 1 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+void
+aes_dec_pair (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair lk = __builtin_aes_genlastkey_paired (k, 0);
+ __vector_pair c = __builtin_aes_decrypt_paired (t, lk, 0);
+ lk = __builtin_aes_genlastkey_paired (k, 1);
+ c = __builtin_aes_decrypt_paired (c, lk, 1);
+ lk = __builtin_aes_genlastkey_paired (k, 2);
+ c = __builtin_aes_decrypt_paired (c, lk, 2);
+ *res = c;
+}
+void
+aes_dec_pair_128 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair lk = __builtin_aes128_genlastkey_paired (k);
+ __vector_pair c = __builtin_aes128_decrypt_paired (t, lk);
+ *res = c;
+}
+void
+aes_dec_pair_192 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair lk = __builtin_aes192_genlastkey_paired (k);
+ __vector_pair c = __builtin_aes192_decrypt_paired (t, lk);
+ *res = c;
+}
+void
+aes_dec_pair_256 (__vector_pair *text, __vector_pair *key, __vector_pair *res)
+{
+ __vector_pair t = *text;
+ __vector_pair k = *key;
+ __vector_pair lk = __builtin_aes256_genlastkey_paired (k);
+ __vector_pair c = __builtin_aes256_decrypt_paired (t, lk);
+ *res = c;
+}
+
+/* { dg-final { scan-assembler-times {\mxxaesdecp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256decp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaesgenlkp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxaes128genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes192genlkp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxxaes256genlkp\M} 1 } } */
\ No newline at end of file