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