xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Headers/sgxintrin.h (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1*7330f729Sjoerg /*===---- sgxintrin.h - X86 SGX intrinsics configuration -------------------===
2*7330f729Sjoerg  *
3*7330f729Sjoerg  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7330f729Sjoerg  * See https://llvm.org/LICENSE.txt for license information.
5*7330f729Sjoerg  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7330f729Sjoerg  *
7*7330f729Sjoerg  *===-----------------------------------------------------------------------===
8*7330f729Sjoerg  */
9*7330f729Sjoerg 
10*7330f729Sjoerg #if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
11*7330f729Sjoerg #error "Never use <sgxintrin.h> directly; include <x86intrin.h> instead."
12*7330f729Sjoerg #endif
13*7330f729Sjoerg 
14*7330f729Sjoerg #ifndef __SGXINTRIN_H
15*7330f729Sjoerg #define __SGXINTRIN_H
16*7330f729Sjoerg 
17*7330f729Sjoerg #if __has_extension(gnu_asm)
18*7330f729Sjoerg 
19*7330f729Sjoerg /* Define the default attributes for the functions in this file. */
20*7330f729Sjoerg #define __DEFAULT_FN_ATTRS \
21*7330f729Sjoerg   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
22*7330f729Sjoerg 
23*7330f729Sjoerg static __inline unsigned int __DEFAULT_FN_ATTRS
_enclu_u32(unsigned int __leaf,__SIZE_TYPE__ __d[])24*7330f729Sjoerg _enclu_u32(unsigned int __leaf, __SIZE_TYPE__ __d[])
25*7330f729Sjoerg {
26*7330f729Sjoerg   unsigned int __result;
27*7330f729Sjoerg   __asm__ ("enclu"
28*7330f729Sjoerg            : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
29*7330f729Sjoerg            : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2])
30*7330f729Sjoerg            : "cc");
31*7330f729Sjoerg   return __result;
32*7330f729Sjoerg }
33*7330f729Sjoerg 
34*7330f729Sjoerg static __inline unsigned int __DEFAULT_FN_ATTRS
_encls_u32(unsigned int __leaf,__SIZE_TYPE__ __d[])35*7330f729Sjoerg _encls_u32(unsigned int __leaf, __SIZE_TYPE__ __d[])
36*7330f729Sjoerg {
37*7330f729Sjoerg   unsigned int __result;
38*7330f729Sjoerg   __asm__ ("encls"
39*7330f729Sjoerg            : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
40*7330f729Sjoerg            : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2])
41*7330f729Sjoerg            : "cc");
42*7330f729Sjoerg   return __result;
43*7330f729Sjoerg }
44*7330f729Sjoerg 
45*7330f729Sjoerg static __inline unsigned int __DEFAULT_FN_ATTRS
_enclv_u32(unsigned int __leaf,__SIZE_TYPE__ __d[])46*7330f729Sjoerg _enclv_u32(unsigned int __leaf, __SIZE_TYPE__ __d[])
47*7330f729Sjoerg {
48*7330f729Sjoerg   unsigned int __result;
49*7330f729Sjoerg   __asm__ ("enclv"
50*7330f729Sjoerg            : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
51*7330f729Sjoerg            : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2])
52*7330f729Sjoerg            : "cc");
53*7330f729Sjoerg   return __result;
54*7330f729Sjoerg }
55*7330f729Sjoerg 
56*7330f729Sjoerg #undef __DEFAULT_FN_ATTRS
57*7330f729Sjoerg 
58*7330f729Sjoerg #endif /* __has_extension(gnu_asm) */
59*7330f729Sjoerg 
60*7330f729Sjoerg #endif
61