[clang] 6c6cd5f - [X86] Consolidate wide Key Locker intrinsics into the same header as the other Key Locker intrinsics.
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 4 12:10:27 PDT 2020
Author: Craig Topper
Date: 2020-10-04T12:09:21-07:00
New Revision: 6c6cd5f8a9750865800ce26bdeacd84533335db3
URL: https://github.com/llvm/llvm-project/commit/6c6cd5f8a9750865800ce26bdeacd84533335db3
DIFF: https://github.com/llvm/llvm-project/commit/6c6cd5f8a9750865800ce26bdeacd84533335db3.diff
LOG: [X86] Consolidate wide Key Locker intrinsics into the same header as the other Key Locker intrinsics.
Added:
Modified:
clang/lib/Headers/CMakeLists.txt
clang/lib/Headers/immintrin.h
clang/lib/Headers/keylockerintrin.h
Removed:
clang/lib/Headers/keylocker_wide_intrin.h
################################################################################
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index 8c12d5ab935d..95047e7069e7 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -73,7 +73,6 @@ set(files
invpcidintrin.h
iso646.h
keylockerintrin.h
- keylocker_wide_intrin.h
limits.h
lwpintrin.h
lzcntintrin.h
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 1beade1be248..8fb5447a5919 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -472,15 +472,10 @@ _storebe_i64(void * __P, long long __D) {
#endif
#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
- defined(__KL__)
+ defined(__KL__) || defined(__WIDEKL__)
#include <keylockerintrin.h>
#endif
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
- defined(__WIDEKL__)
-#include <keylocker_wide_intrin.h>
-#endif
-
#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
defined(__AMXTILE__) || defined(__AMXINT8__) || defined(__AMXBF16__)
#include <amxintrin.h>
diff --git a/clang/lib/Headers/keylocker_wide_intrin.h b/clang/lib/Headers/keylocker_wide_intrin.h
deleted file mode 100644
index 9b6c9ccab811..000000000000
--- a/clang/lib/Headers/keylocker_wide_intrin.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/*===-------------- keylocker_wide_intrin.h - KL_WIDE Intrinsics ------------===
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *===-----------------------------------------------------------------------===
- */
-
-#ifndef __IMMINTRIN_H
-#error "Never use <keylocker_wide_intrin.h> directly; include <immintrin.h> instead."
-#endif
-
-#ifndef _KEYLOCKERINTRIN_WIDE_H
-#define _KEYLOCKERINTRIN_WIDE_H
-
-/* Define the default attributes for the functions in this file. */
-#define __DEFAULT_FN_ATTRS \
- __attribute__((__always_inline__, __nodebug__, __target__("kl,widekl"),\
- __min_vector_width__(128)))
-
-/// Encrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle
-/// at __h and store each resultant block back from __odata to __odata+7. And
-/// return the affected ZF flag status.
-///
-/// \headerfile <x86intrin.h>
-///
-/// This intrinsic corresponds to the <c> AESENCWIDE128KL </c> instructions.
-///
-/// \operation
-/// Handle := MEM[__h+383:__h]
-/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
-/// (Handle[127:0] AND (CPL > 0)) ||
-/// Handle[255:128] ||
-/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128 )
-/// IF (IllegalHandle)
-/// ZF := 1
-/// ELSE
-/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
-/// IF Authentic == 0
-/// ZF := 1
-/// ELSE
-/// FOR i := 0 to 7
-/// __odata[i] := AES128Encrypt (__idata[i], UnwrappedKey)
-/// ENDFOR
-/// ZF := 0
-/// FI
-/// FI
-/// dst := ZF
-/// OF := 0
-/// SF := 0
-/// AF := 0
-/// PF := 0
-/// CF := 0
-/// \endoperation
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_mm_aesencwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
- return __builtin_ia32_aesencwide128kl(__h,
- __odata,
- __odata + 1,
- __odata + 2,
- __odata + 3,
- __odata + 4,
- __odata + 5,
- __odata + 6,
- __odata + 7,
- __idata[0],
- __idata[1],
- __idata[2],
- __idata[3],
- __idata[4],
- __idata[5],
- __idata[6],
- __idata[7]);
-}
-
-/// Encrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle
-/// at __h and store each resultant block back from __odata to __odata+7. And
-/// return the affected ZF flag status.
-///
-/// \headerfile <x86intrin.h>
-///
-/// This intrinsic corresponds to the <c> AESENCWIDE256KL </c> instructions.
-///
-/// \operation
-/// Handle[511:0] := MEM[__h+511:__h]
-/// IllegalHandle := ( HandleReservedBitSet (Handle[511:0]) ||
-/// (Handle[127:0] AND (CPL > 0)) ||
-/// Handle[255:128] ||
-/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES512 )
-/// IF (IllegalHandle)
-/// ZF := 1
-/// ELSE
-/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
-/// IF Authentic == 0
-/// ZF := 1
-/// ELSE
-/// FOR i := 0 to 7
-/// __odata[i] := AES256Encrypt (__idata[i], UnwrappedKey)
-/// ENDFOR
-/// ZF := 0
-/// FI
-/// FI
-/// dst := ZF
-/// OF := 0
-/// SF := 0
-/// AF := 0
-/// PF := 0
-/// CF := 0
-/// \endoperation
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_mm_aesencwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
- return __builtin_ia32_aesencwide256kl(__h,
- __odata,
- __odata + 1,
- __odata + 2,
- __odata + 3,
- __odata + 4,
- __odata + 5,
- __odata + 6,
- __odata + 7,
- __idata[0],
- __idata[1],
- __idata[2],
- __idata[3],
- __idata[4],
- __idata[5],
- __idata[6],
- __idata[7]);
-}
-
-/// Decrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle
-/// at __h and store each resultant block back from __odata to __odata+7. And
-/// return the affected ZF flag status.
-///
-/// \headerfile <x86intrin.h>
-///
-/// This intrinsic corresponds to the <c> AESDECWIDE128KL </c> instructions.
-///
-/// \operation
-/// Handle[383:0] := MEM[__h+383:__h]
-/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
-/// (Handle[127:0] AND (CPL > 0)) ||
-/// Handle[255:128] ||
-/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES128 )
-/// IF (IllegalHandle)
-/// ZF := 1
-/// ELSE
-/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
-/// IF Authentic == 0
-/// ZF := 1
-/// ELSE
-/// FOR i := 0 to 7
-/// __odata[i] := AES128Decrypt (__idata[i], UnwrappedKey)
-/// ENDFOR
-/// ZF := 0
-/// FI
-/// FI
-/// dst := ZF
-/// OF := 0
-/// SF := 0
-/// AF := 0
-/// PF := 0
-/// CF := 0
-/// \endoperation
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_mm_aesdecwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
- return __builtin_ia32_aesdecwide128kl(__h,
- __odata,
- __odata + 1,
- __odata + 2,
- __odata + 3,
- __odata + 4,
- __odata + 5,
- __odata + 6,
- __odata + 7,
- __idata[0],
- __idata[1],
- __idata[2],
- __idata[3],
- __idata[4],
- __idata[5],
- __idata[6],
- __idata[7]);
-}
-
-/// Decrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle
-/// at __h and store each resultant block back from __odata to __odata+7. And
-/// return the affected ZF flag status.
-///
-/// \headerfile <x86intrin.h>
-///
-/// This intrinsic corresponds to the <c> AESDECWIDE256KL </c> instructions.
-///
-/// \operation
-/// Handle[511:0] := MEM[__h+511:__h]
-/// IllegalHandle = ( HandleReservedBitSet (Handle[511:0]) ||
-/// (Handle[127:0] AND (CPL > 0)) ||
-/// Handle[255:128] ||
-/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES512 )
-/// If (IllegalHandle)
-/// ZF := 1
-/// ELSE
-/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
-/// IF Authentic == 0
-/// ZF := 1
-/// ELSE
-/// FOR i := 0 to 7
-/// __odata[i] := AES256Decrypt (__idata[i], UnwrappedKey)
-/// ENDFOR
-/// ZF := 0
-/// FI
-/// FI
-/// dst := ZF
-/// OF := 0
-/// SF := 0
-/// AF := 0
-/// PF := 0
-/// CF := 0
-/// \endoperation
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_mm_aesdecwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
- return __builtin_ia32_aesdecwide256kl(__h,
- __odata,
- __odata + 1,
- __odata + 2,
- __odata + 3,
- __odata + 4,
- __odata + 5,
- __odata + 6,
- __odata + 7,
- __idata[0],
- __idata[1],
- __idata[2],
- __idata[3],
- __idata[4],
- __idata[5],
- __idata[6],
- __idata[7]);
-}
-
-
-#undef __DEFAULT_FN_ATTRS
-
-#endif /* _KEYLOCKERINTRIN_WIDE_H */
diff --git a/clang/lib/Headers/keylockerintrin.h b/clang/lib/Headers/keylockerintrin.h
index 5bd4fe59c6be..2d6a1ca5851f 100644
--- a/clang/lib/Headers/keylockerintrin.h
+++ b/clang/lib/Headers/keylockerintrin.h
@@ -28,6 +28,9 @@
#ifndef _KEYLOCKERINTRIN_H
#define _KEYLOCKERINTRIN_H
+#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
+ defined(__KL__)
+
/* Define the default attributes for the functions in this file. */
#define __DEFAULT_FN_ATTRS \
__attribute__((__always_inline__, __nodebug__, __target__("kl"),\
@@ -340,4 +343,240 @@ _mm_aesdec256kl_u8(__m128i* __odata, __m128i __idata, const void *__h) {
#undef __DEFAULT_FN_ATTRS
+#endif /* !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) \
+ || defined(__KL__) */
+
+#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
+ defined(__WIDEKL__)
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS \
+ __attribute__((__always_inline__, __nodebug__, __target__("kl,widekl"),\
+ __min_vector_width__(128)))
+
+/// Encrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle
+/// at __h and store each resultant block back from __odata to __odata+7. And
+/// return the affected ZF flag status.
+///
+/// \headerfile <x86intrin.h>
+///
+/// This intrinsic corresponds to the <c> AESENCWIDE128KL </c> instructions.
+///
+/// \operation
+/// Handle := MEM[__h+383:__h]
+/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
+/// (Handle[127:0] AND (CPL > 0)) ||
+/// Handle[255:128] ||
+/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128 )
+/// IF (IllegalHandle)
+/// ZF := 1
+/// ELSE
+/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
+/// IF Authentic == 0
+/// ZF := 1
+/// ELSE
+/// FOR i := 0 to 7
+/// __odata[i] := AES128Encrypt (__idata[i], UnwrappedKey)
+/// ENDFOR
+/// ZF := 0
+/// FI
+/// FI
+/// dst := ZF
+/// OF := 0
+/// SF := 0
+/// AF := 0
+/// PF := 0
+/// CF := 0
+/// \endoperation
+static __inline__ unsigned char __DEFAULT_FN_ATTRS
+_mm_aesencwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
+ return __builtin_ia32_aesencwide128kl(__h,
+ __odata,
+ __odata + 1,
+ __odata + 2,
+ __odata + 3,
+ __odata + 4,
+ __odata + 5,
+ __odata + 6,
+ __odata + 7,
+ __idata[0],
+ __idata[1],
+ __idata[2],
+ __idata[3],
+ __idata[4],
+ __idata[5],
+ __idata[6],
+ __idata[7]);
+}
+
+/// Encrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle
+/// at __h and store each resultant block back from __odata to __odata+7. And
+/// return the affected ZF flag status.
+///
+/// \headerfile <x86intrin.h>
+///
+/// This intrinsic corresponds to the <c> AESENCWIDE256KL </c> instructions.
+///
+/// \operation
+/// Handle[511:0] := MEM[__h+511:__h]
+/// IllegalHandle := ( HandleReservedBitSet (Handle[511:0]) ||
+/// (Handle[127:0] AND (CPL > 0)) ||
+/// Handle[255:128] ||
+/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES512 )
+/// IF (IllegalHandle)
+/// ZF := 1
+/// ELSE
+/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
+/// IF Authentic == 0
+/// ZF := 1
+/// ELSE
+/// FOR i := 0 to 7
+/// __odata[i] := AES256Encrypt (__idata[i], UnwrappedKey)
+/// ENDFOR
+/// ZF := 0
+/// FI
+/// FI
+/// dst := ZF
+/// OF := 0
+/// SF := 0
+/// AF := 0
+/// PF := 0
+/// CF := 0
+/// \endoperation
+static __inline__ unsigned char __DEFAULT_FN_ATTRS
+_mm_aesencwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
+ return __builtin_ia32_aesencwide256kl(__h,
+ __odata,
+ __odata + 1,
+ __odata + 2,
+ __odata + 3,
+ __odata + 4,
+ __odata + 5,
+ __odata + 6,
+ __odata + 7,
+ __idata[0],
+ __idata[1],
+ __idata[2],
+ __idata[3],
+ __idata[4],
+ __idata[5],
+ __idata[6],
+ __idata[7]);
+}
+
+/// Decrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle
+/// at __h and store each resultant block back from __odata to __odata+7. And
+/// return the affected ZF flag status.
+///
+/// \headerfile <x86intrin.h>
+///
+/// This intrinsic corresponds to the <c> AESDECWIDE128KL </c> instructions.
+///
+/// \operation
+/// Handle[383:0] := MEM[__h+383:__h]
+/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
+/// (Handle[127:0] AND (CPL > 0)) ||
+/// Handle[255:128] ||
+/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES128 )
+/// IF (IllegalHandle)
+/// ZF := 1
+/// ELSE
+/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
+/// IF Authentic == 0
+/// ZF := 1
+/// ELSE
+/// FOR i := 0 to 7
+/// __odata[i] := AES128Decrypt (__idata[i], UnwrappedKey)
+/// ENDFOR
+/// ZF := 0
+/// FI
+/// FI
+/// dst := ZF
+/// OF := 0
+/// SF := 0
+/// AF := 0
+/// PF := 0
+/// CF := 0
+/// \endoperation
+static __inline__ unsigned char __DEFAULT_FN_ATTRS
+_mm_aesdecwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
+ return __builtin_ia32_aesdecwide128kl(__h,
+ __odata,
+ __odata + 1,
+ __odata + 2,
+ __odata + 3,
+ __odata + 4,
+ __odata + 5,
+ __odata + 6,
+ __odata + 7,
+ __idata[0],
+ __idata[1],
+ __idata[2],
+ __idata[3],
+ __idata[4],
+ __idata[5],
+ __idata[6],
+ __idata[7]);
+}
+
+/// Decrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle
+/// at __h and store each resultant block back from __odata to __odata+7. And
+/// return the affected ZF flag status.
+///
+/// \headerfile <x86intrin.h>
+///
+/// This intrinsic corresponds to the <c> AESDECWIDE256KL </c> instructions.
+///
+/// \operation
+/// Handle[511:0] := MEM[__h+511:__h]
+/// IllegalHandle = ( HandleReservedBitSet (Handle[511:0]) ||
+/// (Handle[127:0] AND (CPL > 0)) ||
+/// Handle[255:128] ||
+/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES512 )
+/// If (IllegalHandle)
+/// ZF := 1
+/// ELSE
+/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
+/// IF Authentic == 0
+/// ZF := 1
+/// ELSE
+/// FOR i := 0 to 7
+/// __odata[i] := AES256Decrypt (__idata[i], UnwrappedKey)
+/// ENDFOR
+/// ZF := 0
+/// FI
+/// FI
+/// dst := ZF
+/// OF := 0
+/// SF := 0
+/// AF := 0
+/// PF := 0
+/// CF := 0
+/// \endoperation
+static __inline__ unsigned char __DEFAULT_FN_ATTRS
+_mm_aesdecwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
+ return __builtin_ia32_aesdecwide256kl(__h,
+ __odata,
+ __odata + 1,
+ __odata + 2,
+ __odata + 3,
+ __odata + 4,
+ __odata + 5,
+ __odata + 6,
+ __odata + 7,
+ __idata[0],
+ __idata[1],
+ __idata[2],
+ __idata[3],
+ __idata[4],
+ __idata[5],
+ __idata[6],
+ __idata[7]);
+}
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif /* !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) \
+ || defined(__WIDEKL__) */
+
#endif /* _KEYLOCKERINTRIN_H */
More information about the cfe-commits
mailing list