brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · d8ab0db Raw
137 lines · c
1/*===---- lwpintrin.h - LWP 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-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10#ifndef __X86INTRIN_H11#error "Never use <lwpintrin.h> directly; include <x86intrin.h> instead."12#endif13 14#ifndef __LWPINTRIN_H15#define __LWPINTRIN_H16 17/* Define the default attributes for the functions in this file. */18#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("lwp")))19 20/// Parses the LWPCB at the specified address and enables21///        profiling if valid.22///23/// \headerfile <x86intrin.h>24///25/// This intrinsic corresponds to the <c> LLWPCB </c> instruction.26///27/// \param __addr28///    Address to the new Lightweight Profiling Control Block (LWPCB). If the29///    LWPCB is valid, writes the address into the LWP_CBADDR MSR and enables30///    Lightweight Profiling.31static __inline__ void __DEFAULT_FN_ATTRS32__llwpcb (void *__addr)33{34  __builtin_ia32_llwpcb(__addr);35}36 37/// Flushes the LWP state to memory and returns the address of the LWPCB.38///39/// \headerfile <x86intrin.h>40///41/// This intrinsic corresponds to the <c> SLWPCB </c> instruction.42///43/// \return44///    Address to the current Lightweight Profiling Control Block (LWPCB).45///    If LWP is not currently enabled, returns NULL.46static __inline__ void* __DEFAULT_FN_ATTRS47__slwpcb (void)48{49  return __builtin_ia32_slwpcb();50}51 52/// Inserts programmed event record into the LWP event ring buffer53///        and advances the ring buffer pointer.54///55/// \headerfile <x86intrin.h>56///57/// This intrinsic corresponds to the <c> LWPINS </c> instruction.58///59/// \param DATA260///    A 32-bit value is zero-extended and inserted into the 64-bit Data2 field.61/// \param DATA162///    A 32-bit value is inserted into the 32-bit Data1 field.63/// \param FLAGS64///    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 MissedEvents67///    counter in the LWPCB is incremented, the head pointer is not advanced, and68///    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)))72 73/// Decrements the LWP programmed value sample event counter. If the result is74///        negative, inserts an event record into the LWP event ring buffer in memory75///        and advances the ring buffer pointer.76///77/// \headerfile <x86intrin.h>78///79/// This intrinsic corresponds to the <c> LWPVAL </c> instruction.80///81/// \param DATA282///    A 32-bit value is zero-extended and inserted into the 64-bit Data2 field.83/// \param DATA184///    A 32-bit value is inserted into the 32-bit Data1 field.85/// \param FLAGS86///    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)))90 91#ifdef __x86_64__92 93/// Inserts programmed event record into the LWP event ring buffer94///        and advances the ring buffer pointer.95///96/// \headerfile <x86intrin.h>97///98/// This intrinsic corresponds to the <c> LWPINS </c> instruction.99///100/// \param DATA2101///    A 64-bit value is inserted into the 64-bit Data2 field.102/// \param DATA1103///    A 32-bit value is inserted into the 32-bit Data1 field.104/// \param FLAGS105///    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 MissedEvents108///    counter in the LWPCB is incremented, the head pointer is not advanced, and109///    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)))113 114/// Decrements the LWP programmed value sample event counter. If the result is115///        negative, inserts an event record into the LWP event ring buffer in memory116///        and advances the ring buffer pointer.117///118/// \headerfile <x86intrin.h>119///120/// This intrinsic corresponds to the <c> LWPVAL </c> instruction.121///122/// \param DATA2123///    A 64-bit value is and inserted into the 64-bit Data2 field.124/// \param DATA1125///    A 32-bit value is inserted into the 32-bit Data1 field.126/// \param FLAGS127///    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)))131 132#endif133 134#undef __DEFAULT_FN_ATTRS135 136#endif /* __LWPINTRIN_H */137