xref: /freebsd/contrib/llvm-project/clang/lib/Headers/hresetintrin.h (revision d5b0e70f7e04d971691517ce1304d86a1e367e2e)
1 /*===---------------- hresetintrin.h - HRESET intrinsics -------------------===
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 #ifndef __X86GPRINTRIN_H
10 #error "Never use <hresetintrin.h> directly; include <x86gprintrin.h> instead."
11 #endif
12 
13 #ifndef __HRESETINTRIN_H
14 #define __HRESETINTRIN_H
15 
16 #if __has_extension(gnu_asm)
17 
18 /* Define the default attributes for the functions in this file. */
19 #define __DEFAULT_FN_ATTRS \
20   __attribute__((__always_inline__, __nodebug__, __target__("hreset")))
21 
22 /// Provides a hint to the processor to selectively reset the prediction
23 ///    history of the current logical processor specified by a 32-bit integer
24 ///    value \a __eax.
25 ///
26 /// This intrinsic corresponds to the <c> HRESET </c> instruction.
27 ///
28 /// \operation
29 ///    IF __eax == 0
30 ///      // nop
31 ///    ELSE
32 ///      FOR i := 0 to 31
33 ///        IF __eax[i]
34 ///          ResetPredictionFeature(i)
35 ///        FI
36 ///      ENDFOR
37 ///    FI
38 /// \endoperation
39 static __inline void __DEFAULT_FN_ATTRS
40 _hreset(int __eax)
41 {
42   __asm__ ("hreset $0" :: "a"(__eax));
43 }
44 
45 #undef __DEFAULT_FN_ATTRS
46 
47 #endif /* __has_extension(gnu_asm) */
48 
49 #endif /* __HRESETINTRIN_H */
50