RE: [PATCH] [X86_64]: Add support for MONITORX and MWAITX ISA

2015-06-18 Thread Kumar, Venkataramanan
Hi Uros

After bootstrap testing and regression testing on bdver4 machine.  I committed 
the back port on GCC 5 branch  at 

https://gcc.gnu.org/viewcvs/gcc?view=revisionrevision=224603

Checked with Richard as well before proceeding.

Regards,
Venkat.

 -Original Message-
 From: Uros Bizjak [mailto:ubiz...@gmail.com]
 Sent: Friday, June 12, 2015 4:02 PM
 To: Kumar, Venkataramanan
 Cc: gcc-patches@gcc.gnu.org
 Subject: Re: [PATCH] [X86_64]: Add support for MONITORX and MWAITX ISA
 
 On Fri, Jun 12, 2015 at 12:27 PM, Kumar, Venkataramanan
 venkataramanan.ku...@amd.com wrote:
 
   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.
 
  Thank you. I committed the patch along with your suggestion.
  Ref: https://gcc.gnu.org/viewcvs/gcc?view=revisionrevision=224414
 
  We would like to get this ISA support into next release compiler based on
 GCC 5.
 
  Is this ok for gcc-5-branch?
 
 Should be OK (the branch has not diverged too much from the trunk yet),
 but please wait a week to see if any problem arises in the trunk, and to give
 some time for release managers to eventually object.
 
 Thanks,
 Uros.


Re: [PATCH] [X86_64]: Add support for MONITORX and MWAITX ISA

2015-06-12 Thread Uros Bizjak
On Fri, Jun 12, 2015 at 12:27 PM, Kumar, Venkataramanan
venkataramanan.ku...@amd.com wrote:

  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.

 Thank you. I committed the patch along with your suggestion.
 Ref: https://gcc.gnu.org/viewcvs/gcc?view=revisionrevision=224414

 We would like to get this ISA support into next release compiler based on GCC 
 5.

 Is this ok for gcc-5-branch?

Should be OK (the branch has not diverged too much from the trunk
yet), but please wait a week to see if any problem arises in the
trunk, and to give some time for release managers to eventually
object.

Thanks,
Uros.


RE: [PATCH] [X86_64]: Add support for MONITORX and MWAITX ISA

2015-06-12 Thread Kumar, Venkataramanan
Hi Uros, 

 -Original Message-
 From: Uros Bizjak [mailto:ubiz...@gmail.com]
 Sent: Thursday, June 11, 2015 3:50 PM
 To: Kumar, Venkataramanan
 Cc: gcc-patches@gcc.gnu.org
 Subject: Re: [PATCH] [X86_64]: Add support for MONITORX and MWAITX ISA
 
 On Thu, Jun 11, 2015 at 11:49 AM, Kumar, Venkataramanan
 venkataramanan.ku...@amd.com wrote:
  Hi Maintainers,
 
  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.
 
Thank you. I committed the patch along with your suggestion.
Ref: https://gcc.gnu.org/viewcvs/gcc?view=revisionrevision=224414

We would like to get this ISA support into next release compiler based on GCC 5.

Is this ok for gcc-5-branch?

Regards,
Venkat.


Re: [PATCH] [X86_64]: Add support for MONITORX and MWAITX ISA

2015-06-11 Thread Uros Bizjak
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.