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