xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Headers/hresetintrin.h (revision e038c9c4676b0f19b1b7dd08a940c6ed64a6d5ae)
1*e038c9c4Sjoerg /*===---------------- hresetintrin.h - HRESET intrinsics -------------------===
2*e038c9c4Sjoerg  *
3*e038c9c4Sjoerg  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*e038c9c4Sjoerg  * See https://llvm.org/LICENSE.txt for license information.
5*e038c9c4Sjoerg  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*e038c9c4Sjoerg  *
7*e038c9c4Sjoerg  *===-----------------------------------------------------------------------===
8*e038c9c4Sjoerg  */
9*e038c9c4Sjoerg #ifndef __X86GPRINTRIN_H
10*e038c9c4Sjoerg #error "Never use <hresetintrin.h> directly; include <x86gprintrin.h> instead."
11*e038c9c4Sjoerg #endif
12*e038c9c4Sjoerg 
13*e038c9c4Sjoerg #ifndef __HRESETINTRIN_H
14*e038c9c4Sjoerg #define __HRESETINTRIN_H
15*e038c9c4Sjoerg 
16*e038c9c4Sjoerg #if __has_extension(gnu_asm)
17*e038c9c4Sjoerg 
18*e038c9c4Sjoerg /* Define the default attributes for the functions in this file. */
19*e038c9c4Sjoerg #define __DEFAULT_FN_ATTRS \
20*e038c9c4Sjoerg   __attribute__((__always_inline__, __nodebug__, __target__("hreset")))
21*e038c9c4Sjoerg 
22*e038c9c4Sjoerg /// Provides a hint to the processor to selectively reset the prediction
23*e038c9c4Sjoerg ///    history of the current logical processor specified by a 32-bit integer
24*e038c9c4Sjoerg ///    value \a __eax.
25*e038c9c4Sjoerg ///
26*e038c9c4Sjoerg /// This intrinsic corresponds to the <c> HRESET </c> instruction.
27*e038c9c4Sjoerg ///
28*e038c9c4Sjoerg /// \operation
29*e038c9c4Sjoerg ///    IF __eax == 0
30*e038c9c4Sjoerg ///      // nop
31*e038c9c4Sjoerg ///    ELSE
32*e038c9c4Sjoerg ///      FOR i := 0 to 31
33*e038c9c4Sjoerg ///        IF __eax[i]
34*e038c9c4Sjoerg ///          ResetPredictionFeature(i)
35*e038c9c4Sjoerg ///        FI
36*e038c9c4Sjoerg ///      ENDFOR
37*e038c9c4Sjoerg ///    FI
38*e038c9c4Sjoerg /// \endoperation
39*e038c9c4Sjoerg static __inline void __DEFAULT_FN_ATTRS
_hreset(int __eax)40*e038c9c4Sjoerg _hreset(int __eax)
41*e038c9c4Sjoerg {
42*e038c9c4Sjoerg   __asm__ ("hreset $0" :: "a"(__eax));
43*e038c9c4Sjoerg }
44*e038c9c4Sjoerg 
45*e038c9c4Sjoerg #undef __DEFAULT_FN_ATTRS
46*e038c9c4Sjoerg 
47*e038c9c4Sjoerg #endif /* __has_extension(gnu_asm) */
48*e038c9c4Sjoerg 
49*e038c9c4Sjoerg #endif /* __HRESETINTRIN_H */
50