On Thu, Jun 11, 2015 at 11:49 AM, Kumar, Venkataramanan
<venkataramanan.ku...@amd.com> wrote:
> Hi Maintainers,
>
> This patch adds support for new MONITORX and MWAITX instructions and also 
> enables them via builtins.
> The ISA is enabled by new -mmwaitx option  and is available for AMD bdver4 
> target (-march=bdver4).
>
> MONITORX and MWAITX implements same functionality as old MONITOR and MWAIT.
> In addition MWAITX can enable a timer and is accepted as third argument (in 
> %ebx).
>
>
> Testing status.
>
> * Bootstrapped and retested.
> (Snip)
> ## /bin/sh ./gcc-fsf-trunk/contrib/compare_tests  /tmp/gxx-sum1.9548 
> /tmp/gxx-sum2.9548
> New tests that PASS:
>
> gcc.target/i386/monitorx.c (test for excess errors)
> (Snip)
>
> * On bdver4 machine ISA gets detected via -march=native.
> * Also tested with assembler patch available at
>  https://sourceware.org/ml/binutils/2015-06/msg00106.html
>
>
> gcc/ChangeLog
>
> 2015-06-11  Venkataramanan Kumar  <venkataramanan.ku...@amd.com>
>
>         * common/config/i386/i386-common.c
>         (OPTION_MASK_ISA_MWAITX_SET): New.
>         (ix86_handle_option): Handle mwaitx.
>        * config.gcc (i[34567]86-*-*): Add mwaitxintrin.h,
>         (x86_64-*-*): Likewise.
>         * config/i386/mwaitxintrin.h: New header.
>         * config/i386/cpuid.h (bit_MWAITX):  Define.
>         * config/i386/driver-i386.c (host_detect_local_cpu): Detect
>         MWAITX support.
>        * config/i386/i386.opt (mwaitx): New.
>        * config/i386/i386-builtin-types.def
>         (VOID_FTYPE_UNSIGNED_ UNSIGNED_UNSIGNED): New function type.
>         * config/i386/i386-c.c: Define __MWAITX__ if needed.
>         * config/i386/i386.c (ix86_target_string): Define -mmwaitx option.
>         (PTA_MWAITX): New.
>         (ix86_option_override_internal): Handle new option.
>         (processor_alias_table): Added PTA_MWAITX.
>         (ix86_valid_target_attribute_inner_p): Add OPT_mmwaitx.
>         (ix86_builtins): Add IX86_BUILTIN_MWAITX, IX86_BUILTIN_MONITORX.
>         (ix86_expand_builtin): Handle IX86_BUILTIN_MWAITX  and
>         IX86_BUILTIN_MONITORX  built-ins.
>         * config/i386/i386.h (TARGET_MWAITX):  New.
>         * config/i386/i386.md (unspecv): Add UNSPEC_ MWAITX and UNSPEC_ 
> MONITORX.
>         (mwaitx):  New pattern.
>         (monitorx_<mode>): New pattern.
>         * config/i386/x86intrin.h: Include mwaitxintrin.h.
>        * doc/extend.texi: Document monitorx and mwaitx builtins.
>        * doc/invoke.texi: Document -mmwaitx option.
>
> gcc/testsuite/ChangeLog:
>
> 2015-06-11  Venkataramanan Kumar  <venkataramanan.ku...@amd.com>
>
>         * gcc.target/i386/monitorx.c: New.
>         * gcc.target/i386/sse-12.c: Add -mmwaitx.
>         * gcc.target/i386/sse-13.c: Ditto.
>         * gcc.target/i386/sse-14.c: Ditto.
>         * gcc.target/i386/sse-22.c: Ditto.
>         * gcc.target/i386/sse-23.c: Ditto.
>         * g++.dg/other/i386-2.C: Ditto.
>         * g++.dg/other/i386-3.C: Ditto.
>
> Ok for trunk ?

OK for mainline with a small improvement below.

+    case IX86_BUILTIN_MONITORX:
+      arg0 = CALL_EXPR_ARG (exp, 0);
+      arg1 = CALL_EXPR_ARG (exp, 1);
+      arg2 = CALL_EXPR_ARG (exp, 2);
+      op0 = expand_normal (arg0);
+      op1 = expand_normal (arg1);
+      op2 = expand_normal (arg2);
+      if (!REG_P (op0))
+ op0 = ix86_zero_extend_to_Pmode (op0);
+      if (!REG_P (op1))
+ op1 = copy_to_mode_reg (SImode, op1);
+      if (!REG_P (op2))
+ op2 = copy_to_mode_reg (SImode, op2);
+      emit_insn (ix86_gen_monitorx (op0, op1, op2));
+      return 0;

Please merge the above with existing IX86_BUILTIN_MONITOR. You can use
emit_insn (fcode == IX86_BUILTIN_MONITOR
  ? ix86_gen_monitor (...)
  : ix86_gen_monitorx (...));

Thanks,
Uros.

Reply via email to