Path: blob/main/contrib/llvm-project/clang/lib/Headers/__wmmintrin_aes.h
35233 views
/*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------===1*2* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3* See https://llvm.org/LICENSE.txt for license information.4* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5*6*===-----------------------------------------------------------------------===7*/89#ifndef __WMMINTRIN_H10#error "Never use <__wmmintrin_aes.h> directly; include <wmmintrin.h> instead."11#endif1213#ifndef __WMMINTRIN_AES_H14#define __WMMINTRIN_AES_H1516/* Define the default attributes for the functions in this file. */17#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes"), __min_vector_width__(128)))1819/// Performs a single round of AES encryption using the Equivalent20/// Inverse Cipher, transforming the state value from the first source21/// operand using a 128-bit round key value contained in the second source22/// operand, and writes the result to the destination.23///24/// \headerfile <x86intrin.h>25///26/// This intrinsic corresponds to the <c> VAESENC </c> instruction.27///28/// \param __V29/// A 128-bit integer vector containing the state value.30/// \param __R31/// A 128-bit integer vector containing the round key value.32/// \returns A 128-bit integer vector containing the encrypted value.33static __inline__ __m128i __DEFAULT_FN_ATTRS34_mm_aesenc_si128(__m128i __V, __m128i __R)35{36return (__m128i)__builtin_ia32_aesenc128((__v2di)__V, (__v2di)__R);37}3839/// Performs the final round of AES encryption using the Equivalent40/// Inverse Cipher, transforming the state value from the first source41/// operand using a 128-bit round key value contained in the second source42/// operand, and writes the result to the destination.43///44/// \headerfile <x86intrin.h>45///46/// This intrinsic corresponds to the <c> VAESENCLAST </c> instruction.47///48/// \param __V49/// A 128-bit integer vector containing the state value.50/// \param __R51/// A 128-bit integer vector containing the round key value.52/// \returns A 128-bit integer vector containing the encrypted value.53static __inline__ __m128i __DEFAULT_FN_ATTRS54_mm_aesenclast_si128(__m128i __V, __m128i __R)55{56return (__m128i)__builtin_ia32_aesenclast128((__v2di)__V, (__v2di)__R);57}5859/// Performs a single round of AES decryption using the Equivalent60/// Inverse Cipher, transforming the state value from the first source61/// operand using a 128-bit round key value contained in the second source62/// operand, and writes the result to the destination.63///64/// \headerfile <x86intrin.h>65///66/// This intrinsic corresponds to the <c> VAESDEC </c> instruction.67///68/// \param __V69/// A 128-bit integer vector containing the state value.70/// \param __R71/// A 128-bit integer vector containing the round key value.72/// \returns A 128-bit integer vector containing the decrypted value.73static __inline__ __m128i __DEFAULT_FN_ATTRS74_mm_aesdec_si128(__m128i __V, __m128i __R)75{76return (__m128i)__builtin_ia32_aesdec128((__v2di)__V, (__v2di)__R);77}7879/// Performs the final round of AES decryption using the Equivalent80/// Inverse Cipher, transforming the state value from the first source81/// operand using a 128-bit round key value contained in the second source82/// operand, and writes the result to the destination.83///84/// \headerfile <x86intrin.h>85///86/// This intrinsic corresponds to the <c> VAESDECLAST </c> instruction.87///88/// \param __V89/// A 128-bit integer vector containing the state value.90/// \param __R91/// A 128-bit integer vector containing the round key value.92/// \returns A 128-bit integer vector containing the decrypted value.93static __inline__ __m128i __DEFAULT_FN_ATTRS94_mm_aesdeclast_si128(__m128i __V, __m128i __R)95{96return (__m128i)__builtin_ia32_aesdeclast128((__v2di)__V, (__v2di)__R);97}9899/// Applies the AES InvMixColumns() transformation to an expanded key100/// contained in the source operand, and writes the result to the101/// destination.102///103/// \headerfile <x86intrin.h>104///105/// This intrinsic corresponds to the <c> VAESIMC </c> instruction.106///107/// \param __V108/// A 128-bit integer vector containing the expanded key.109/// \returns A 128-bit integer vector containing the transformed value.110static __inline__ __m128i __DEFAULT_FN_ATTRS111_mm_aesimc_si128(__m128i __V)112{113return (__m128i)__builtin_ia32_aesimc128((__v2di)__V);114}115116/// Generates a round key for AES encryption, operating on 128-bit data117/// specified in the first source operand and using an 8-bit round constant118/// specified by the second source operand, and writes the result to the119/// destination.120///121/// \headerfile <x86intrin.h>122///123/// \code124/// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R);125/// \endcode126///127/// This intrinsic corresponds to the <c> AESKEYGENASSIST </c> instruction.128///129/// \param C130/// A 128-bit integer vector that is used to generate the AES encryption key.131/// \param R132/// An 8-bit round constant used to generate the AES encryption key.133/// \returns A 128-bit round key for AES encryption.134#define _mm_aeskeygenassist_si128(C, R) \135((__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R)))136137#undef __DEFAULT_FN_ATTRS138139#endif /* __WMMINTRIN_AES_H */140141142