Path: blob/master/tools/android-sdk/renderscript/clang-include/__wmmintrin_aes.h
496 views
/*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------===1*2* Permission is hereby granted, free of charge, to any person obtaining a copy3* of this software and associated documentation files (the "Software"), to deal4* in the Software without restriction, including without limitation the rights5* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell6* copies of the Software, and to permit persons to whom the Software is7* furnished to do so, subject to the following conditions:8*9* The above copyright notice and this permission notice shall be included in10* all copies or substantial portions of the Software.11*12* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR13* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE15* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER16* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,17* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN18* THE SOFTWARE.19*20*===-----------------------------------------------------------------------===21*/22#ifndef _WMMINTRIN_AES_H23#define _WMMINTRIN_AES_H2425#include <emmintrin.h>2627/* Define the default attributes for the functions in this file. */28#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes")))2930/// \brief Performs a single round of AES encryption using the Equivalent31/// Inverse Cipher, transforming the state value from the first source32/// operand using a 128-bit round key value contained in the second source33/// operand, and writes the result to the destination.34///35/// \headerfile <x86intrin.h>36///37/// This intrinsic corresponds to the \c VAESENC instruction.38///39/// \param __V40/// A 128-bit integer vector containing the state value.41/// \param __R42/// A 128-bit integer vector containing the round key value.43/// \returns A 128-bit integer vector containing the encrypted value.44static __inline__ __m128i __DEFAULT_FN_ATTRS45_mm_aesenc_si128(__m128i __V, __m128i __R)46{47return (__m128i)__builtin_ia32_aesenc128((__v2di)__V, (__v2di)__R);48}4950/// \brief Performs the final round of AES encryption using the Equivalent51/// Inverse Cipher, transforming the state value from the first source52/// operand using a 128-bit round key value contained in the second source53/// operand, and writes the result to the destination.54///55/// \headerfile <x86intrin.h>56///57/// This intrinsic corresponds to the \c VAESENCLAST instruction.58///59/// \param __V60/// A 128-bit integer vector containing the state value.61/// \param __R62/// A 128-bit integer vector containing the round key value.63/// \returns A 128-bit integer vector containing the encrypted value.64static __inline__ __m128i __DEFAULT_FN_ATTRS65_mm_aesenclast_si128(__m128i __V, __m128i __R)66{67return (__m128i)__builtin_ia32_aesenclast128((__v2di)__V, (__v2di)__R);68}6970/// \brief Performs a single round of AES decryption using the Equivalent71/// Inverse Cipher, transforming the state value from the first source72/// operand using a 128-bit round key value contained in the second source73/// operand, and writes the result to the destination.74///75/// \headerfile <x86intrin.h>76///77/// This intrinsic corresponds to the \c VAESDEC instruction.78///79/// \param __V80/// A 128-bit integer vector containing the state value.81/// \param __R82/// A 128-bit integer vector containing the round key value.83/// \returns A 128-bit integer vector containing the decrypted value.84static __inline__ __m128i __DEFAULT_FN_ATTRS85_mm_aesdec_si128(__m128i __V, __m128i __R)86{87return (__m128i)__builtin_ia32_aesdec128((__v2di)__V, (__v2di)__R);88}8990/// \brief Performs the final round of AES decryption using the Equivalent91/// Inverse Cipher, transforming the state value from the first source92/// operand using a 128-bit round key value contained in the second source93/// operand, and writes the result to the destination.94///95/// \headerfile <x86intrin.h>96///97/// This intrinsic corresponds to the \c VAESDECLAST instruction.98///99/// \param __V100/// A 128-bit integer vector containing the state value.101/// \param __R102/// A 128-bit integer vector containing the round key value.103/// \returns A 128-bit integer vector containing the decrypted value.104static __inline__ __m128i __DEFAULT_FN_ATTRS105_mm_aesdeclast_si128(__m128i __V, __m128i __R)106{107return (__m128i)__builtin_ia32_aesdeclast128((__v2di)__V, (__v2di)__R);108}109110/// \brief Applies the AES InvMixColumns() transformation to an expanded key111/// contained in the source operand, and writes the result to the112/// destination.113///114/// \headerfile <x86intrin.h>115///116/// This intrinsic corresponds to the \c VAESIMC instruction.117///118/// \param __V119/// A 128-bit integer vector containing the expanded key.120/// \returns A 128-bit integer vector containing the transformed value.121static __inline__ __m128i __DEFAULT_FN_ATTRS122_mm_aesimc_si128(__m128i __V)123{124return (__m128i)__builtin_ia32_aesimc128((__v2di)__V);125}126127/// \brief Generates a round key for AES encyption, operating on 128-bit data128/// specified in the first source operand and using an 8-bit round constant129/// specified by the second source operand, and writes the result to the130/// destination.131///132/// \headerfile <x86intrin.h>133///134/// \code135/// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R);136/// \endcode137///138/// This intrinsic corresponds to the \c AESKEYGENASSIST instruction.139///140/// \param C141/// A 128-bit integer vector that is used to generate the AES encryption key.142/// \param R143/// An 8-bit round constant used to generate the AES encryption key.144/// \returns A 128-bit round key for AES encryption.145#define _mm_aeskeygenassist_si128(C, R) \146(__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R))147148#undef __DEFAULT_FN_ATTRS149150#endif /* _WMMINTRIN_AES_H */151152153