r269907 - Add new intrinsic support for MONITORX and MWAITX instructions
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu May 19 14:13:08 PDT 2016
The modules buildbot has been broken since this commit landed:
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/15761/steps/compile.llvm.stage2/logs/stdio
Please fix or revert.
On Wed, May 18, 2016 at 4:56 AM, Ashutosh Nema via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: ashutosh
> Date: Wed May 18 06:56:23 2016
> New Revision: 269907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269907&view=rev
> Log:
> Add new intrinsic support for MONITORX and MWAITX instructions
>
> Summary:
> MONITORX/MWAITX instructions provide similar capability to the
> MONITOR/MWAIT
> pair while adding a timer function, such that another termination of the
> MWAITX
> instruction occurs when the timer expires. The presence of the MONITORX and
> MWAITX instructions is indicated by CPUID 8000_0001, ECX, bit 29.
>
> The MONITORX and MWAITX instructions are intercepted by the same bits that
> intercept MONITOR and MWAIT. MONITORX instruction establishes a range to be
> monitored. MWAITX instruction causes the processor to stop instruction
> execution and enter an implementation-dependent optimized state until
> occurrence of a class of events.
>
> Opcode of MONITORX instruction is "0F 01 FA". Opcode of MWAITX instruction
> is
> "0F 01 FB". These opcode information is used in adding tests for the
> disassembler.
>
> These instructions are enabled for AMD's bdver4 architecture.
>
> Patch by Ganesh Gopalasubramanian!
>
> Reviewers: echristo, craig.topper
>
> Subscribers: RKSimon, joker.eph, llvm-commits, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D19796
>
> Added:
> cfe/trunk/lib/Headers/mwaitxintrin.h
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Headers/CMakeLists.txt
> cfe/trunk/lib/Headers/module.modulemap
> cfe/trunk/lib/Headers/x86intrin.h
> cfe/trunk/test/CodeGen/builtins-x86.c
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=269907&r1=269906&r2=269907&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed May 18 06:56:23 2016
> @@ -2272,5 +2272,9 @@ TARGET_BUILTIN(__builtin_ia32_cvtusi2sd6
> TARGET_BUILTIN(__builtin_ia32_cvtusi2ss32, "V4fV4fUiIi","","avx512f")
> TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fULLiIi","","avx512f")
>
> +// MONITORX/MWAITX
> +TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
> +TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
> +
> #undef BUILTIN
> #undef TARGET_BUILTIN
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269907&r1=269906&r2=269907&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed May 18 06:56:23 2016
> @@ -1425,6 +1425,7 @@ def mno_xsave : Flag<["-"], "mno-xsave">
> def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">,
> Group<m_x86_Features_Group>;
> def mno_xsavec : Flag<["-"], "mno-xsavec">, Group<m_x86_Features_Group>;
> def mno_xsaves : Flag<["-"], "mno-xsaves">, Group<m_x86_Features_Group>;
> +def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group<m_x86_Features_Group>;
> def mno_pku : Flag<["-"], "mno-pku">, Group<m_x86_Features_Group>;
>
> def munaligned_access : Flag<["-"], "munaligned-access">,
> Group<m_arm_Features_Group>,
> @@ -1610,6 +1611,7 @@ def mxsave : Flag<["-"], "mxsave">, Grou
> def mxsaveopt : Flag<["-"], "mxsaveopt">, Group<m_x86_Features_Group>;
> def mxsavec : Flag<["-"], "mxsavec">, Group<m_x86_Features_Group>;
> def mxsaves : Flag<["-"], "mxsaves">, Group<m_x86_Features_Group>;
> +def mmwaitx : Flag<["-"], "mmwaitx">, Group<m_x86_Features_Group>;
> def mips16 : Flag<["-"], "mips16">, Group<m_Group>;
> def mno_mips16 : Flag<["-"], "mno-mips16">, Group<m_Group>;
> def mmicromips : Flag<["-"], "mmicromips">, Group<m_Group>;
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=269907&r1=269906&r2=269907&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed May 18 06:56:23 2016
> @@ -2273,6 +2273,7 @@ class X86TargetInfo : public TargetInfo
> bool HasXSAVEOPT = false;
> bool HasXSAVEC = false;
> bool HasXSAVES = false;
> + bool HasMWAITX = false;
> bool HasPKU = false;
> bool HasCLFLUSHOPT = false;
> bool HasPCOMMIT = false;
> @@ -2947,6 +2948,7 @@ bool X86TargetInfo::initFeatureMap(
> case CK_BDVER4:
> setFeatureEnabledImpl(Features, "avx2", true);
> setFeatureEnabledImpl(Features, "bmi2", true);
> + setFeatureEnabledImpl(Features, "mwaitx", true);
> // FALLTHROUGH
> case CK_BDVER3:
> setFeatureEnabledImpl(Features, "fsgsbase", true);
> @@ -3266,6 +3268,8 @@ bool X86TargetInfo::handleTargetFeatures
> HasXSAVEC = true;
> } else if (Feature == "+xsaves") {
> HasXSAVES = true;
> + } else if (Feature == "+mwaitx") {
> + HasMWAITX = true;
> } else if (Feature == "+pku") {
> HasPKU = true;
> } else if (Feature == "+clflushopt") {
> @@ -3538,6 +3542,9 @@ void X86TargetInfo::getTargetDefines(con
> if (HasTBM)
> Builder.defineMacro("__TBM__");
>
> + if (HasMWAITX)
> + Builder.defineMacro("__MWAITX__");
> +
> switch (XOPLevel) {
> case XOP:
> Builder.defineMacro("__XOP__");
>
> Modified: cfe/trunk/lib/Headers/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=269907&r1=269906&r2=269907&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Headers/CMakeLists.txt (original)
> +++ cfe/trunk/lib/Headers/CMakeLists.txt Wed May 18 06:56:23 2016
> @@ -78,6 +78,7 @@ set(files
> xsaveoptintrin.h
> xsavecintrin.h
> xsavesintrin.h
> + mwaitxintrin.h
> xtestintrin.h
> avx512ifmaintrin.h
> avx512ifmavlintrin.h
>
> Modified: cfe/trunk/lib/Headers/module.modulemap
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=269907&r1=269906&r2=269907&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Headers/module.modulemap (original)
> +++ cfe/trunk/lib/Headers/module.modulemap Wed May 18 06:56:23 2016
> @@ -125,6 +125,10 @@ module _Builtin_intrinsics [system] [ext
> export pclmul
> }
>
> + explicit module mwaitx {
> + header "mwaitxintrin.h"
> + }
> +
> explicit module aes {
> header "__wmmintrin_aes.h"
> }
>
> Added: cfe/trunk/lib/Headers/mwaitxintrin.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/mwaitxintrin.h?rev=269907&view=auto
>
> ==============================================================================
> --- cfe/trunk/lib/Headers/mwaitxintrin.h (added)
> +++ cfe/trunk/lib/Headers/mwaitxintrin.h Wed May 18 06:56:23 2016
> @@ -0,0 +1,47 @@
> +/*===---- mwaitxintrin.h - MONITORX/MWAITX intrinsics
> ----------------------===
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining
> a copy
> + * of this software and associated documentation files (the "Software"),
> to deal
> + * in the Software without restriction, including without limitation the
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
> sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
> SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> IN
> + * THE SOFTWARE.
> + *
> +
> *===-----------------------------------------------------------------------===
> + */
> +
> +#ifndef __X86INTRIN_H
> +#error "Never use <mwaitxintrin.h> directly; include <x86intrin.h>
> instead."
> +#endif
> +
> +#ifndef _MWAITXINTRIN_H
> +#define _MWAITXINTRIN_H
> +
> +/* Define the default attributes for the functions in this file. */
> +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__,
> __nodebug__, __target__("mwaitx")))
> +static __inline__ void __DEFAULT_FN_ATTRS
> +_mm_monitorx(void const * __p, unsigned __extensions, unsigned __hints)
> +{
> + __builtin_ia32_monitorx((void *)__p, __extensions, __hints);
> +}
> +
> +static __inline__ void __DEFAULT_FN_ATTRS
> +_mm_mwaitx(unsigned __extensions, unsigned __hints, unsigned __clock)
> +{
> + __builtin_ia32_mwaitx(__extensions, __hints, __clock);
> +}
> +
> +#undef __DEFAULT_FN_ATTRS
> +
> +#endif /* _MWAITXINTRIN_H */
>
> Modified: cfe/trunk/lib/Headers/x86intrin.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/x86intrin.h?rev=269907&r1=269906&r2=269907&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Headers/x86intrin.h (original)
> +++ cfe/trunk/lib/Headers/x86intrin.h Wed May 18 06:56:23 2016
> @@ -76,6 +76,10 @@
> #include <f16cintrin.h>
> #endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__MWAITX__)
> +#include <mwaitxintrin.h>
> +#endif
> +
> /* FIXME: LWP */
>
> #endif /* __X86INTRIN_H */
>
> Modified: cfe/trunk/test/CodeGen/builtins-x86.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=269907&r1=269906&r2=269907&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/builtins-x86.c (original)
> +++ cfe/trunk/test/CodeGen/builtins-x86.c Wed May 18 06:56:23 2016
> @@ -1,5 +1,5 @@
> -// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown
> -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt
> -target-feature +xsaves -target-feature +xsavec -emit-llvm -o %t %s
> -// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown
> -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt
> -target-feature +xsaves -target-feature +xsavec -fsyntax-only -o %t %s
> +// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown
> -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt
> -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx
> -emit-llvm -o %t %s
> +// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown
> -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt
> -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx
> -fsyntax-only -o %t %s
>
> #ifdef USE_ALL
> #define USE_3DNOW
> @@ -281,6 +281,9 @@ void f0() {
> (void)__builtin_ia32_xsaves(tmp_vp, tmp_ULLi);
> (void)__builtin_ia32_xsaves64(tmp_vp, tmp_ULLi);
>
> + (void) __builtin_ia32_monitorx(tmp_vp, tmp_Ui, tmp_Ui);
> + (void) __builtin_ia32_mwaitx(tmp_Ui, tmp_Ui, tmp_Ui);
> +
> tmp_V4f = __builtin_ia32_cvtpi2ps(tmp_V4f, tmp_V2i);
> tmp_V2i = __builtin_ia32_cvtps2pi(tmp_V4f);
> tmp_i = __builtin_ia32_cvtss2si(tmp_V4f);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160519/9d773ccf/attachment-0001.html>
More information about the cfe-commits
mailing list