15f757f3fSDimitry Andric /*===--------------- usermsrintrin.h - USERMSR intrinsics -----------------===
25f757f3fSDimitry Andric  *
35f757f3fSDimitry Andric  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f757f3fSDimitry Andric  * See https://llvm.org/LICENSE.txt for license information.
55f757f3fSDimitry Andric  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65f757f3fSDimitry Andric  *
75f757f3fSDimitry Andric  *===-----------------------------------------------------------------------===
85f757f3fSDimitry Andric  */
95f757f3fSDimitry Andric #ifndef __X86GPRINTRIN_H
105f757f3fSDimitry Andric #error "Never use <usermsrintrin.h> directly; include <x86gprintrin.h> instead."
115f757f3fSDimitry Andric #endif // __X86GPRINTRIN_H
125f757f3fSDimitry Andric 
135f757f3fSDimitry Andric #ifndef __USERMSRINTRIN_H
145f757f3fSDimitry Andric #define __USERMSRINTRIN_H
155f757f3fSDimitry Andric #ifdef __x86_64__
165f757f3fSDimitry Andric 
17*647cbc5dSDimitry Andric /// Reads the contents of a 64-bit MSR specified in \a __A into \a dst.
18*647cbc5dSDimitry Andric ///
19*647cbc5dSDimitry Andric /// This intrinsic corresponds to the <c> URDMSR </c> instruction.
20*647cbc5dSDimitry Andric /// \param __A
21*647cbc5dSDimitry Andric ///    An unsigned long long.
22*647cbc5dSDimitry Andric ///
23*647cbc5dSDimitry Andric /// \code{.operation}
24*647cbc5dSDimitry Andric ///    DEST := MSR[__A]
25*647cbc5dSDimitry Andric /// \endcode
265f757f3fSDimitry Andric static __inline__ unsigned long long
275f757f3fSDimitry Andric     __attribute__((__always_inline__, __nodebug__, __target__("usermsr")))
_urdmsr(unsigned long long __A)285f757f3fSDimitry Andric     _urdmsr(unsigned long long __A) {
295f757f3fSDimitry Andric   return __builtin_ia32_urdmsr(__A);
305f757f3fSDimitry Andric }
315f757f3fSDimitry Andric 
32*647cbc5dSDimitry Andric /// Writes the contents of \a __B into the 64-bit MSR specified in \a __A.
33*647cbc5dSDimitry Andric ///
34*647cbc5dSDimitry Andric /// This intrinsic corresponds to the <c> UWRMSR </c> instruction.
35*647cbc5dSDimitry Andric ///
36*647cbc5dSDimitry Andric /// \param __A
37*647cbc5dSDimitry Andric ///    An unsigned long long.
38*647cbc5dSDimitry Andric /// \param __B
39*647cbc5dSDimitry Andric ///    An unsigned long long.
40*647cbc5dSDimitry Andric ///
41*647cbc5dSDimitry Andric /// \code{.operation}
42*647cbc5dSDimitry Andric ///    MSR[__A] := __B
43*647cbc5dSDimitry Andric /// \endcode
445f757f3fSDimitry Andric static __inline__ void
455f757f3fSDimitry Andric     __attribute__((__always_inline__, __nodebug__, __target__("usermsr")))
_uwrmsr(unsigned long long __A,unsigned long long __B)465f757f3fSDimitry Andric     _uwrmsr(unsigned long long __A, unsigned long long __B) {
475f757f3fSDimitry Andric   return __builtin_ia32_uwrmsr(__A, __B);
485f757f3fSDimitry Andric }
495f757f3fSDimitry Andric 
505f757f3fSDimitry Andric #endif // __x86_64__
515f757f3fSDimitry Andric #endif // __USERMSRINTRIN_H
52