13043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor/*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------===
23043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor *
33043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * Permission is hereby granted, free of charge, to any person obtaining a copy
43043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * of this software and associated documentation files (the "Software"), to deal
53043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * in the Software without restriction, including without limitation the rights
63043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
73043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * copies of the Software, and to permit persons to whom the Software is
83043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * furnished to do so, subject to the following conditions:
93043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor *
103043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * The above copyright notice and this permission notice shall be included in
113043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * all copies or substantial portions of the Software.
123043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor *
133043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
143043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
153043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
163043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
173043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
183043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
193043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor * THE SOFTWARE.
203043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor *
213043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor *===-----------------------------------------------------------------------===
223043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor */
233043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#ifndef _WMMINTRIN_AES_H
243043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#define _WMMINTRIN_AES_H
253043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
263043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#include <emmintrin.h>
273043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
283043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#if !defined (__AES__)
293043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#  error "AES instructions not enabled"
303043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#else
313043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
323043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregorstatic __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
333043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor_mm_aesenc_si128(__m128i __V, __m128i __R)
343043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor{
353043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor  return (__m128i)__builtin_ia32_aesenc128(__V, __R);
363043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor}
373043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
383043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregorstatic __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
393043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor_mm_aesenclast_si128(__m128i __V, __m128i __R)
403043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor{
413043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor  return (__m128i)__builtin_ia32_aesenclast128(__V, __R);
423043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor}
433043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
443043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregorstatic __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
453043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor_mm_aesdec_si128(__m128i __V, __m128i __R)
463043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor{
473043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor  return (__m128i)__builtin_ia32_aesdec128(__V, __R);
483043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor}
493043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
503043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregorstatic __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
513043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor_mm_aesdeclast_si128(__m128i __V, __m128i __R)
523043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor{
533043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor  return (__m128i)__builtin_ia32_aesdeclast128(__V, __R);
543043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor}
553043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
563043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregorstatic __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
573043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor_mm_aesimc_si128(__m128i __V)
583043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor{
593043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor  return (__m128i)__builtin_ia32_aesimc128(__V);
603043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor}
613043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
623043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#define _mm_aeskeygenassist_si128(C, R) \
633043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor  __builtin_ia32_aeskeygenassist128((C), (R))
643043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
653043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#endif
663043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor
673043175274899e086c8664fe64c8fb4b9eacb733Douglas Gregor#endif  /* _WMMINTRIN_AES_H */
68