This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to use Power8 vcipher with 8-bit types?


I'm having trouble using Power8's vcipher instruction. I want to use
'__vcipher' because it takes and returns an unsigned char array. Also
see https://www.ibm.com/support/knowledgecenter/en/SSGH3R_13.1.3/com.ibm.xlcpp1313.aix.doc/compiler_ref/bif_crypto_aes_vcipher.html.

So far I've only been able to use __builtin_crypto_vcipher, and that
requires casts to/from 64-bit types. For example, the following does
not compile:

    typedef vector unsigned char uint8x16_p8;
    typedef vector unsigned long uint64x2_p8;

    uint8x16_p8 block = (uint8x16_p8)vec_vsx_ld(0, inBlock);
    block = __builtin_crypto_vcipher(block, (uint8x16_p8)vec_ld( 16,
(const byte*)subkeys));
    block = __builtin_crypto_vcipher(block, (uint8x16_p8)vec_ld( 32,
(const byte*)subkeys));
    ...

it results in:

rijndael-test.cpp:23:95: error: cannot convert 'uint8x16_p8 {aka
__vector(16) unsigned char}' to '__vector(2) long unsigned int' for
argument '1' to '__vector(2) long unsigned int
__builtin_crypto_vcipher(__vector(2) long unsigned int, __vector(2)
long unsigned int)'

If I cast to a 64-bit type to get past the compile errors, then I
cannot arrive at the correct result. (I may not arrive at the correct
result with the 8-bit type, but that's what I am trying to discover).

I found  a couple of mailing lists posts that talk about Power8 endian
swaps when using types other than 8-bit. That's why I want to avoid
the 64-bit type. Also see
https://gcc.gnu.org/ml/gcc/2015-03/msg00143.html.

How can I use Power8 vcipher with 8-bit types?

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]