1 /*===---- lwpintrin.h - LWP intrinsics -------------------------------------===
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
7 *===-----------------------------------------------------------------------===
11 #error "Never use <lwpintrin.h> directly; include <x86intrin.h> instead."
17 /* Define the default attributes for the functions in this file. */
18 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("lwp")))
20 /// Parses the LWPCB at the specified address and enables
21 /// profiling if valid.
23 /// \headerfile <x86intrin.h>
25 /// This intrinsic corresponds to the <c> LLWPCB </c> instruction.
28 /// Address to the new Lightweight Profiling Control Block (LWPCB). If the
29 /// LWPCB is valid, writes the address into the LWP_CBADDR MSR and enables
30 /// Lightweight Profiling.
31 static __inline__
void __DEFAULT_FN_ATTRS
32 __llwpcb (void *__addr
)
34 __builtin_ia32_llwpcb(__addr
);
37 /// Flushes the LWP state to memory and returns the address of the LWPCB.
39 /// \headerfile <x86intrin.h>
41 /// This intrinsic corresponds to the <c> SLWPCB </c> instruction.
44 /// Address to the current Lightweight Profiling Control Block (LWPCB).
45 /// If LWP is not currently enabled, returns NULL.
46 static __inline__
void* __DEFAULT_FN_ATTRS
49 return __builtin_ia32_slwpcb();
52 /// Inserts programmed event record into the LWP event ring buffer
53 /// and advances the ring buffer pointer.
55 /// \headerfile <x86intrin.h>
57 /// This intrinsic corresponds to the <c> LWPINS </c> instruction.
60 /// A 32-bit value is zero-extended and inserted into the 64-bit Data2 field.
62 /// A 32-bit value is inserted into the 32-bit Data1 field.
64 /// A 32-bit immediate value is inserted into the 32-bit Flags field.
65 /// \returns If the ring buffer is full and LWP is running in Synchronized Mode,
66 /// the event record overwrites the last record in the buffer, the MissedEvents
67 /// counter in the LWPCB is incremented, the head pointer is not advanced, and
68 /// 1 is returned. Otherwise 0 is returned.
69 #define __lwpins32(DATA2, DATA1, FLAGS) \
70 (__builtin_ia32_lwpins32((unsigned int) (DATA2), (unsigned int) (DATA1), \
71 (unsigned int) (FLAGS)))
73 /// Decrements the LWP programmed value sample event counter. If the result is
74 /// negative, inserts an event record into the LWP event ring buffer in memory
75 /// and advances the ring buffer pointer.
77 /// \headerfile <x86intrin.h>
79 /// This intrinsic corresponds to the <c> LWPVAL </c> instruction.
82 /// A 32-bit value is zero-extended and inserted into the 64-bit Data2 field.
84 /// A 32-bit value is inserted into the 32-bit Data1 field.
86 /// A 32-bit immediate value is inserted into the 32-bit Flags field.
87 #define __lwpval32(DATA2, DATA1, FLAGS) \
88 (__builtin_ia32_lwpval32((unsigned int) (DATA2), (unsigned int) (DATA1), \
89 (unsigned int) (FLAGS)))
93 /// Inserts programmed event record into the LWP event ring buffer
94 /// and advances the ring buffer pointer.
96 /// \headerfile <x86intrin.h>
98 /// This intrinsic corresponds to the <c> LWPINS </c> instruction.
101 /// A 64-bit value is inserted into the 64-bit Data2 field.
103 /// A 32-bit value is inserted into the 32-bit Data1 field.
105 /// A 32-bit immediate value is inserted into the 32-bit Flags field.
106 /// \returns If the ring buffer is full and LWP is running in Synchronized Mode,
107 /// the event record overwrites the last record in the buffer, the MissedEvents
108 /// counter in the LWPCB is incremented, the head pointer is not advanced, and
109 /// 1 is returned. Otherwise 0 is returned.
110 #define __lwpins64(DATA2, DATA1, FLAGS) \
111 (__builtin_ia32_lwpins64((unsigned long long) (DATA2), (unsigned int) (DATA1), \
112 (unsigned int) (FLAGS)))
114 /// Decrements the LWP programmed value sample event counter. If the result is
115 /// negative, inserts an event record into the LWP event ring buffer in memory
116 /// and advances the ring buffer pointer.
118 /// \headerfile <x86intrin.h>
120 /// This intrinsic corresponds to the <c> LWPVAL </c> instruction.
123 /// A 64-bit value is and inserted into the 64-bit Data2 field.
125 /// A 32-bit value is inserted into the 32-bit Data1 field.
127 /// A 32-bit immediate value is inserted into the 32-bit Flags field.
128 #define __lwpval64(DATA2, DATA1, FLAGS) \
129 (__builtin_ia32_lwpval64((unsigned long long) (DATA2), (unsigned int) (DATA1), \
130 (unsigned int) (FLAGS)))
134 #undef __DEFAULT_FN_ATTRS
136 #endif /* __LWPINTRIN_H */