Skip to content

Commit

Permalink
[Headers][doc] Add/revise MONITOR/MWAIT descriptions
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D148653
  • Loading branch information
pogo59 committed Apr 19, 2023
1 parent 864cb2a commit 5ddcef2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
29 changes: 29 additions & 0 deletions clang/lib/Headers/mwaitxintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,41 @@

/* Define the default attributes for the functions in this file. */
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("mwaitx")))

/// Establishes a linear address memory range to be monitored and puts
/// the processor in the monitor event pending state. Data stored in the
/// monitored address range causes the processor to exit the pending state.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c MONITORX instruction.
///
/// \param __p
/// The memory range to be monitored. The size of the range is determined by
/// CPUID function 0000_0005h.
/// \param __extensions
/// Optional extensions for the monitoring state.
/// \param __hints
/// Optional hints for the monitoring state.
static __inline__ void __DEFAULT_FN_ATTRS
_mm_monitorx(void * __p, unsigned __extensions, unsigned __hints)
{
__builtin_ia32_monitorx(__p, __extensions, __hints);
}

/// Used with the \c MONITORX instruction to wait while the processor is in
/// the monitor event pending state. Data stored in the monitored address
/// range causes the processor to exit the pending state.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c MWAITX instruction.
///
/// \param __extensions
/// Optional extensions for the monitoring state, which can vary by
/// processor.
/// \param __hints
/// Optional hints for the monitoring state, which can vary by processor.
static __inline__ void __DEFAULT_FN_ATTRS
_mm_mwaitx(unsigned __extensions, unsigned __hints, unsigned __clock)
{
Expand Down
16 changes: 11 additions & 5 deletions clang/lib/Headers/pmmintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ _mm_movedup_pd(__m128d __a)
/// the processor in the monitor event pending state. Data stored in the
/// monitored address range causes the processor to exit the pending state.
///
/// The \c MONITOR instruction can be used in kernel mode, and in other modes
/// if MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the <c> MONITOR </c> instruction.
/// This intrinsic corresponds to the \c MONITOR instruction.
///
/// \param __p
/// The memory range to be monitored. The size of the range is determined by
Expand All @@ -270,19 +273,22 @@ _mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
__builtin_ia32_monitor(__p, __extensions, __hints);
}

/// Used with the MONITOR instruction to wait while the processor is in
/// Used with the \c MONITOR instruction to wait while the processor is in
/// the monitor event pending state. Data stored in the monitored address
/// range causes the processor to exit the pending state.
///
/// The \c MWAIT instruction can be used in kernel mode, and in other modes if
/// MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the <c> MWAIT </c> instruction.
/// This intrinsic corresponds to the \c MWAIT instruction.
///
/// \param __extensions
/// Optional extensions for the monitoring state, which may vary by
/// Optional extensions for the monitoring state, which can vary by
/// processor.
/// \param __hints
/// Optional hints for the monitoring state, which may vary by processor.
/// Optional hints for the monitoring state, which can vary by processor.
static __inline__ void __DEFAULT_FN_ATTRS
_mm_mwait(unsigned __extensions, unsigned __hints)
{
Expand Down

0 comments on commit 5ddcef2

Please sign in to comment.