1336815Sdim/*===---- sgxintrin.h - X86 SGX intrinsics configuration -------------------=== 2336815Sdim * 3353358Sdim * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim * See https://llvm.org/LICENSE.txt for license information. 5353358Sdim * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6336815Sdim * 7336815Sdim *===-----------------------------------------------------------------------=== 8336815Sdim */ 9336815Sdim 10336815Sdim#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H 11336815Sdim#error "Never use <sgxintrin.h> directly; include <x86intrin.h> instead." 12336815Sdim#endif 13336815Sdim 14336815Sdim#ifndef __SGXINTRIN_H 15336815Sdim#define __SGXINTRIN_H 16336815Sdim 17353358Sdim#if __has_extension(gnu_asm) 18353358Sdim 19336815Sdim/* Define the default attributes for the functions in this file. */ 20336815Sdim#define __DEFAULT_FN_ATTRS \ 21336815Sdim __attribute__((__always_inline__, __nodebug__, __target__("sgx"))) 22336815Sdim 23336815Sdimstatic __inline unsigned int __DEFAULT_FN_ATTRS 24336815Sdim_enclu_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) 25336815Sdim{ 26336815Sdim unsigned int __result; 27336815Sdim __asm__ ("enclu" 28336815Sdim : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) 29336815Sdim : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) 30336815Sdim : "cc"); 31336815Sdim return __result; 32336815Sdim} 33336815Sdim 34336815Sdimstatic __inline unsigned int __DEFAULT_FN_ATTRS 35336815Sdim_encls_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) 36336815Sdim{ 37336815Sdim unsigned int __result; 38336815Sdim __asm__ ("encls" 39336815Sdim : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) 40336815Sdim : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) 41336815Sdim : "cc"); 42336815Sdim return __result; 43336815Sdim} 44336815Sdim 45336815Sdimstatic __inline unsigned int __DEFAULT_FN_ATTRS 46336815Sdim_enclv_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) 47336815Sdim{ 48336815Sdim unsigned int __result; 49336815Sdim __asm__ ("enclv" 50336815Sdim : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) 51336815Sdim : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) 52336815Sdim : "cc"); 53336815Sdim return __result; 54336815Sdim} 55336815Sdim 56336815Sdim#undef __DEFAULT_FN_ATTRS 57336815Sdim 58353358Sdim#endif /* __has_extension(gnu_asm) */ 59353358Sdim 60336815Sdim#endif 61