+2018-05-14 Sebastian Peryt <sebastian.peryt@intel.com>
+
+ * common/config/i386/i386-common.c (OPTION_MASK_ISA_CLDEMOTE_SET,
+ OPTION_MASK_ISA_CLDEMOTE_UNSET): New defines.
+ (ix86_handle_option): Handle -mcldemote.
+ * config.gcc: New header.
+ * config/i386/cldemoteintrin.h: New file.
+ * config/i386/cpuid.h (bit_CLDEMOTE): New bit.
+ * config/i386/driver-i386.c (host_detect_local_cpu): Detect
+ -mcldemote.
+ * config/i386/i386-c.c (ix86_target_macros_internal): Handle
+ OPTION_MASK_ISA_CLDEMOTE.
+ * config/i386/i386.c (ix86_target_string): Add -mcldemote.
+ (ix86_valid_target_attribute_inner_p): Ditto.
+ (enum ix86_builtins): Add IX86_BUILTIN_CLDEMOTE.
+ (ix86_init_mmx_sse_builtins): Define __builtin_ia32_cldemote.
+ (ix86_expand_builtin): Expand IX86_BUILTIN_CLDEMOTE.
+ * config/i386/i386.h (TARGET_CLDEMOTE, TARGET_CLDEMOTE_P): New.
+ * config/i386/i386.md (UNSPECV_CLDEMOTE): New.
+ (cldemote): New.
+ * config/i386/i386.opt: Add -mcldemote.
+ * config/i386/x86intrin.h: New header.
+ * doc/invoke.texi: Add -mcldemote.
+
2018-05-14 Richard Biener <rguenther@suse.de>
* doc/match-and-simplify.texi: Adjust :s documentation.
#define OPTION_MASK_ISA_MOVDIRI_SET OPTION_MASK_ISA_MOVDIRI
#define OPTION_MASK_ISA_MOVDIR64B_SET OPTION_MASK_ISA_MOVDIR64B
#define OPTION_MASK_ISA_WAITPKG_SET OPTION_MASK_ISA_WAITPKG
+#define OPTION_MASK_ISA_CLDEMOTE_SET OPTION_MASK_ISA_CLDEMOTE
/* Define a set of ISAs which aren't available when a given ISA is
disabled. MMX and SSE ISAs are handled separately. */
#define OPTION_MASK_ISA_MOVDIRI_UNSET OPTION_MASK_ISA_MOVDIRI
#define OPTION_MASK_ISA_MOVDIR64B_UNSET OPTION_MASK_ISA_MOVDIR64B
#define OPTION_MASK_ISA_WAITPKG_UNSET OPTION_MASK_ISA_WAITPKG
+#define OPTION_MASK_ISA_CLDEMOTE_UNSET OPTION_MASK_ISA_CLDEMOTE
/* SSE4 includes both SSE4.1 and SSE4.2. -mno-sse4 should the same
as -mno-sse4.1. */
opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA_MOVDIR64B_UNSET;
opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA_MOVDIR64B_UNSET;
}
+ return true;
+
+ case OPT_mcldemote:
+ if (value)
+ {
+ opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_CLDEMOTE_SET;
+ opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA_CLDEMOTE_SET;
+ }
+ else
+ {
+ opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA_CLDEMOTE_UNSET;
+ opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA_CLDEMOTE_UNSET;
+ }
return true;
case OPT_mwaitpkg:
avx512vnnivlintrin.h vaesintrin.h vpclmulqdqintrin.h
avx512vpopcntdqvlintrin.h avx512bitalgintrin.h
pconfigintrin.h wbnoinvdintrin.h movdirintrin.h
- waitpkgintrin.h"
+ waitpkgintrin.h cldemoteintrin.h"
;;
x86_64-*-*)
cpu_type=i386
avx512vnnivlintrin.h vaesintrin.h vpclmulqdqintrin.h
avx512vpopcntdqvlintrin.h avx512bitalgintrin.h
pconfigintrin.h wbnoinvdintrin.h movdirintrin.h
- waitpkgintrin.h"
+ waitpkgintrin.h cldemoteintrin.h"
;;
ia64-*-*)
extra_headers=ia64intrin.h
--- /dev/null
+/* Copyright (C) 2018 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GCC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if !defined _X86INTRIN_H_INCLUDED
+# error "Never use <cldemoteintrin.h> directly; include <x86intrin.h> instead."
+#endif
+
+#ifndef _CLDEMOTE_H_INCLUDED
+#define _CLDEMOTE_H_INCLUDED
+
+#ifndef __CLDEMOTE__
+#pragma GCC push_options
+#pragma GCC target("cldemote")
+#define __DISABLE_CLDEMOTE__
+#endif /* __CLDEMOTE__ */
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_cldemote (void *__A)
+{
+ __builtin_ia32_cldemote (__A);
+}
+#ifdef __DISABLE_CLDEMOTE__
+#undef __DISABLE_CLDEMOTE__
+#pragma GCC pop_options
+#endif /* __DISABLE_CLDEMOTE__ */
+
+#endif /* _CLDEMOTE_H_INCLUDED */
#define bit_RDPID (1 << 22)
#define bit_MOVDIRI (1 << 27)
#define bit_MOVDIR64B (1 << 28)
+#define bit_CLDEMOTE (1 << 25)
/* %edx */
#define bit_AVX5124VNNIW (1 << 2)
unsigned int has_vpclmulqdq = 0;
unsigned int has_movdiri = 0, has_movdir64b = 0;
unsigned int has_waitpkg = 0;
+ unsigned int has_cldemote = 0;
bool arch;
has_avx512bitalg = ecx & bit_AVX512BITALG;
has_movdiri = ecx & bit_MOVDIRI;
has_movdir64b = ecx & bit_MOVDIR64B;
+ has_cldemote = ecx & bit_CLDEMOTE;
has_avx5124vnniw = edx & bit_AVX5124VNNIW;
has_avx5124fmaps = edx & bit_AVX5124FMAPS;
const char *movdiri = has_movdiri ? " -mmovdiri" : " -mno-movdiri";
const char *movdir64b = has_movdir64b ? " -mmovdir64b" : " -mno-movdir64b";
const char *waitpkg = has_waitpkg ? " -mwaitpkg" : " -mno-waitpkg";
+ const char *cldemote = has_cldemote ? " -mcldemote" : " -mno-cldemote";
options = concat (options, mmx, mmx3dnow, sse, sse2, sse3, ssse3,
sse4a, cx16, sahf, movbe, aes, sha, pclmul,
popcnt, abm, lwp, fma, fma4, xop, bmi, sgx, bmi2,
avx512ifma, avx512vbmi, avx5124fmaps, avx5124vnniw,
clwb, mwaitx, clzero, pku, rdpid, gfni, shstk,
avx512vbmi2, avx512vnni, vaes, vpclmulqdq,
- avx512bitalg, movdiri, movdir64b, waitpkg, NULL);
+ avx512bitalg, movdiri, movdir64b, waitpkg, cldemote,
+ NULL);
}
done:
def_or_undef (parse_in, "__MOVDIR64B__");
if (isa_flag2 & OPTION_MASK_ISA_WAITPKG)
def_or_undef (parse_in, "__WAITPKG__");
+ if (isa_flag2 & OPTION_MASK_ISA_CLDEMOTE)
+ def_or_undef (parse_in, "__CLDEMOTE__");
if (TARGET_IAMCU)
{
def_or_undef (parse_in, "__iamcu");
{ "-mclzero", OPTION_MASK_ISA_CLZERO },
{ "-mmwaitx", OPTION_MASK_ISA_MWAITX },
{ "-mmovdir64b", OPTION_MASK_ISA_MOVDIR64B },
- { "-mwaitpkg", OPTION_MASK_ISA_WAITPKG }
+ { "-mwaitpkg", OPTION_MASK_ISA_WAITPKG },
+ { "-mcldemote", OPTION_MASK_ISA_CLDEMOTE }
};
static struct ix86_target_opts isa_opts[] =
{
IX86_ATTR_ISA ("movdiri", OPT_mmovdiri),
IX86_ATTR_ISA ("movdir64b", OPT_mmovdir64b),
IX86_ATTR_ISA ("waitpkg", OPT_mwaitpkg),
+ IX86_ATTR_ISA ("cldemote", OPT_mcldemote),
/* enum options */
IX86_ATTR_ENUM ("fpmath=", OPT_mfpmath_),
IX86_BUILTIN_UMWAIT,
IX86_BUILTIN_TPAUSE,
IX86_BUILTIN_CLZERO,
+ IX86_BUILTIN_CLDEMOTE,
IX86_BUILTIN_VEC_INIT_V2SI,
IX86_BUILTIN_VEC_INIT_V4HI,
IX86_BUILTIN_VEC_INIT_V8QI,
def_builtin2 (OPTION_MASK_ISA_WAITPKG, "__builtin_ia32_tpause",
UINT8_FTYPE_UNSIGNED_UINT64, IX86_BUILTIN_TPAUSE);
+ /* CLDEMOTE. */
+ def_builtin2 (OPTION_MASK_ISA_CLDEMOTE, "__builtin_ia32_cldemote",
+ VOID_FTYPE_PCVOID, IX86_BUILTIN_CLDEMOTE);
+
/* Add FMA4 multi-arg argument instructions */
for (i = 0, d = bdesc_multi_arg; i < ARRAY_SIZE (bdesc_multi_arg); i++, d++)
{
emit_insn (ix86_gen_clzero (op0));
return 0;
+ case IX86_BUILTIN_CLDEMOTE:
+ arg0 = CALL_EXPR_ARG (exp, 0);
+ op0 = expand_normal (arg0);
+ icode = CODE_FOR_cldemote;
+ if (!insn_data[icode].operand[0].predicate (op0, Pmode))
+ op0 = ix86_zero_extend_to_Pmode (op0);
+
+ emit_insn (gen_cldemote (op0));
+ return 0;
+
case IX86_BUILTIN_VEC_INIT_V2SI:
case IX86_BUILTIN_VEC_INIT_V4HI:
case IX86_BUILTIN_VEC_INIT_V8QI:
#define TARGET_MOVDIR64B_P(x) TARGET_ISA_MOVDIR64B_P(x)
#define TARGET_WAITPKG TARGET_ISA_WAITPKG
#define TARGET_WAITPKG_P(x) TARGET_ISA_WAITPKG_P(x)
+#define TARGET_CLDEMOTE TARGET_ISA_CLDEMOTE
+#define TARGET_CLDEMOTE_P(x) TARGET_ISA_CLDEMOTE_P(x)
#define TARGET_LP64 TARGET_ABI_64
#define TARGET_LP64_P(x) TARGET_ABI_64_P(x)
UNSPECV_UMWAIT
UNSPECV_UMONITOR
UNSPECV_TPAUSE
+
+ ;; For CLDEMOTE support
+ UNSPECV_CLDEMOTE
])
;; Constants to represent rounding modes in the ROUND instruction
"tpause\t%0"
[(set_attr "length" "3")])
+(define_insn "cldemote"
+ [(unspec_volatile[(match_operand 0 "address_operand" "p")]
+ UNSPECV_CLDEMOTE)]
+ "TARGET_CLDEMOTE"
+ "cldemote\t%a0"
+ [(set_attr "type" "other")
+ (set_attr "memory" "unknown")])
+
(include "mmx.md")
(include "sse.md")
(include "sync.md")
mwaitpkg
Target Report Mask(ISA_WAITPKG) Var(ix86_isa_flags2) Save
Support WAITPKG built-in functions and code generation.
+
+mcldemote
+Target Report Mask(ISA_CLDEMOTE) Var(ix86_isa_flags2) Save
+Support CLDEMOTE built-in functions and code generation.
#include <waitpkgintrin.h>
+#include <cldemoteintrin.h>
+
#endif /* __iamcu__ */
#endif /* _X86INTRIN_H_INCLUDED */
-mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mlwp -mmpx @gol
-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
-mshstk -mforce-indirect-call -mavx512vbmi2 @gol
--mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
+-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
+-mcldemote @gol
-mms-bitfields -mno-align-stringops -minline-all-stringops @gol
-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
@need 200
@itemx -mavx512vpopcntdq
@opindex mavx512vpopcntdq
+@need 200
+@itemx -mcldemote
+@opindex mcldemote
These switches enable the use of instructions in the MMX, SSE,
SSE2, SSE3, SSSE3, SSE4.1, AVX, AVX2, AVX512F, AVX512PF, AVX512ER, AVX512CD,
SHA, AES, PCLMUL, FSGSBASE, RDRND, F16C, FMA, SSE4A, FMA4, XOP, LWP, ABM,
AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, BMI, BMI2, VAES, WAITPKG,
FXSR, XSAVE, XSAVEOPT, LZCNT, RTM, MPX, MWAITX, PKU, IBT, SHSTK, AVX512VBMI2,
GFNI, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B,
-AVX512VPOPCNTDQ3DNow!@: or enhanced 3DNow!@: extended instruction sets.
-Each has a corresponding @option{-mno-} option to disable use of these
+AVX512VPOPCNTDQ, CLDEMOTE, 3DNow!@: or enhanced 3DNow!@: extended instruction
+sets. Each has a corresponding @option{-mno-} option to disable use of these
instructions.
These extensions are also available as built-in functions: see
+2018-05-14 Sebastian Peryt <sebastian.peryt@intel.com>
+
+ * gcc.target/i386/cldemote-1.c: New test.
+
2018-05-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/85742
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcldemote" } */
+/* { dg-final { scan-assembler "cldemote\[ \\t\]" } } */
+
+#include "x86intrin.h"
+
+void
+test_cldemote (void *__A)
+{
+ _cldemote (__A);
+}