public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] S390: SUpport -mtune=native and -march=native.
@ 2015-05-19  6:16 Dominik Vogt
  2015-05-26 11:56 ` [PATCH] S390: Support " Dominik Vogt
  0 siblings, 1 reply; 7+ messages in thread
From: Dominik Vogt @ 2015-05-19  6:16 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 257 bytes --]

The attached patch activates the -mtune=native and -march=native
command line options on S390 and System z.  Most of the code is a
modified copy of gcc/config/mips/driver-native.c.  ChangeLog
attached.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: ChangeLog --]
[-- Type: text/plain, Size: 479 bytes --]

gcc/ChangeLog:

2015-05-05  Dominik Vogt  <vogt@linux.vnet.ibm.com>

	* config/s390/driver-native.c: New file.
	* config/s390/x-native: New file.
	* config.host: Add new files for s390.
	* config/s390/s390.h (DRIVER_SELF_SPECS): Add support for -mtune=native
	and -march=native
	* config/s390/s390.opt (march): Likewise; add PROCESSOR_NATIVE
	* config/s390/s390-opts.h (enum processor_type): Ditto.
	* config/s390/s390.c (s390_option_override): Catch unhandled
	PROCESSOR_NATIVE

[-- Attachment #3: 0001-S390-Support-mtune-native-and-march-native.patch --]
[-- Type: text/x-diff, Size: 7106 bytes --]

From 591c2a1e6c82caee681386b8e18b5814d0a2116e Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 5 May 2015 12:49:23 +0100
Subject: [PATCH] S390: Support -mtune=native and -march=native.

---
 gcc/config.host                 |  4 ++
 gcc/config/s390/driver-native.c | 91 +++++++++++++++++++++++++++++++++++++++++
 gcc/config/s390/s390-opts.h     |  1 +
 gcc/config/s390/s390.c          |  2 +
 gcc/config/s390/s390.h          | 14 ++++++-
 gcc/config/s390/s390.opt        |  3 ++
 gcc/config/s390/x-native        |  3 ++
 7 files changed, 116 insertions(+), 2 deletions(-)
 create mode 100644 gcc/config/s390/driver-native.c
 create mode 100644 gcc/config/s390/x-native

diff --git a/gcc/config.host b/gcc/config.host
index a8896d1..4e456a1 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -172,6 +172,10 @@ case ${host} in
 	;;
     esac
     ;;
+  s390-*-* | s390x-*-*)
+    host_extra_gcc_objs="driver-native.o"
+    host_xmake_file="${host_xmake_file} s390/x-native"
+    ;;
   sparc*-*-solaris2*)
     case ${target} in
       sparc*-*-solaris2*)
diff --git a/gcc/config/s390/driver-native.c b/gcc/config/s390/driver-native.c
new file mode 100644
index 0000000..88c76bd
--- /dev/null
+++ b/gcc/config/s390/driver-native.c
@@ -0,0 +1,91 @@
+/* Subroutines for the gcc driver.
+   Copyright (C) 2015 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.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+
+/* This will be called by the spec parser in gcc.c when it sees
+   a %:local_cpu_detect(args) construct.  Currently it will be called
+   with either "arch" or "tune" as argument depending on if -march=native
+   or -mtune=native is to be substituted.
+
+   It returns a string containing new command line parameters to be
+   put at the place of the above two options, depending on what CPU
+   this is executed.  E.g. "-march=zEC12" on a zEC12 for -march=native.
+   If the routine can't detect a known processor, the -march or -mtune
+   option is discarded.
+
+   ARGC and ARGV are set depending on the actual arguments given
+   in the spec.  */
+const char *
+s390_host_detect_local_cpu (int argc, const char **argv)
+{
+  const char *cpu = NULL;
+  char buf[256];
+  FILE *f;
+  bool arch;
+
+  if (argc < 1)
+    return NULL;
+
+  arch = strcmp (argv[0], "arch") == 0;
+  if (!arch && strcmp (argv[0], "tune"))
+    return NULL;
+
+  f = fopen ("/proc/cpuinfo", "r");
+  if (f == NULL)
+    return NULL;
+
+  while (fgets (buf, sizeof (buf), f) != NULL)
+    if (strncmp (buf, "processor", sizeof ("processor") - 1) == 0)
+      {
+	if (strstr (buf, "machine = 9672") != NULL)
+	  cpu = "g5";
+	else if (strstr (buf, "machine = 2064") != NULL
+		 || strstr (buf, "machine = 2066") != NULL)
+	  cpu = "z900";
+	else if (strstr (buf, "machine = 2084") != NULL
+		 || strstr (buf, "machine = 2086") != NULL)
+	  cpu = "z990";
+	else if (strstr (buf, "machine = 2094") != NULL
+		 || strstr (buf, "machine = 2096") != NULL)
+	  cpu = "z9-109";
+	else if (strstr (buf, "machine = 2097") != NULL
+		 || strstr (buf, "machine = 2098") != NULL)
+	  cpu = "z10";
+	else if (strstr (buf, "machine = 2817") != NULL
+		 || strstr (buf, "machine = 2818") != NULL)
+	  cpu = "z196";
+	else if (strstr (buf, "machine = 2827") != NULL
+		 || strstr (buf, "machine = 2828") != NULL)
+	  cpu = "zEC12";
+	else if (strstr (buf, "machine = 2964") != NULL)
+	  cpu = "z13";
+	break;
+      }
+
+  fclose (f);
+
+  if (cpu == NULL)
+    return NULL;
+
+  return concat ("-m", argv[0], "=", cpu, NULL);
+}
diff --git a/gcc/config/s390/s390-opts.h b/gcc/config/s390/s390-opts.h
index cb9ebc7..cf49d35 100644
--- a/gcc/config/s390/s390-opts.h
+++ b/gcc/config/s390/s390-opts.h
@@ -35,6 +35,7 @@ enum processor_type
   PROCESSOR_2097_Z10,
   PROCESSOR_2817_Z196,
   PROCESSOR_2827_ZEC12,
+  PROCESSOR_NATIVE,
   PROCESSOR_max
 };
 
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 7d16048..fb1a0ce 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -11981,6 +11981,8 @@ s390_option_override (void)
     }
 
   /* Sanity checks.  */
+  if (s390_arch == PROCESSOR_NATIVE || s390_tune == PROCESSOR_NATIVE)
+    gcc_unreachable ();
   if (TARGET_ZARCH && !TARGET_CPU_ZARCH)
     error ("z/Architecture mode not supported on %s", s390_arch_string);
   if (TARGET_64BIT && !TARGET_ZARCH)
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index f887409..e972b4d 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -126,17 +126,27 @@ enum processor_flags
   { "arch", "%{!march=*:-march=%(VALUE)}" },			\
   { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
 
+extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
+# define EXTRA_SPEC_FUNCTIONS \
+  { "local_cpu_detect", s390_host_detect_local_cpu },
+
+# define MARCH_MTUNE_NATIVE_SPECS				\
+  " %{march=native:%<march=native %:local_cpu_detect(arch)}"	\
+  " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
+
 /* Defaulting rules.  */
 #ifdef DEFAULT_TARGET_64BIT
 #define DRIVER_SELF_SPECS					\
   "%{!m31:%{!m64:-m64}}",					\
   "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}",		\
-  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
+  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}",		\
+  MARCH_MTUNE_NATIVE_SPECS
 #else
 #define DRIVER_SELF_SPECS					\
   "%{!m31:%{!m64:-m31}}",					\
   "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}",		\
-  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
+  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}",		\
+  MARCH_MTUNE_NATIVE_SPECS
 #endif
 
 /* Constants needed to control the TEST DATA CLASS (TDC) instruction.  */
diff --git a/gcc/config/s390/s390.opt b/gcc/config/s390/s390.opt
index 22f1ff5..3c05419 100644
--- a/gcc/config/s390/s390.opt
+++ b/gcc/config/s390/s390.opt
@@ -76,6 +76,9 @@ Enum(processor_type) String(z196) Value(PROCESSOR_2817_Z196)
 EnumValue
 Enum(processor_type) String(zEC12) Value(PROCESSOR_2827_ZEC12)
 
+EnumValue
+Enum(processor_type) String(native) Value(PROCESSOR_NATIVE) DriverOnly
+
 mbackchain
 Target Report Mask(BACKCHAIN)
 Maintain backchain pointer
diff --git a/gcc/config/s390/x-native b/gcc/config/s390/x-native
new file mode 100644
index 0000000..b33c8b6
--- /dev/null
+++ b/gcc/config/s390/x-native
@@ -0,0 +1,3 @@
+driver-native.o : $(srcdir)/config/s390/driver-native.c \
+  $(CONFIG_H) $(SYSTEM_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
-- 
2.3.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] S390: Support -mtune=native and -march=native.
  2015-05-19  6:16 [PATCH] S390: SUpport -mtune=native and -march=native Dominik Vogt
@ 2015-05-26 11:56 ` Dominik Vogt
  2015-06-01 11:50   ` Jakub Jelinek
  2015-07-08 20:18   ` DJ Delorie
  0 siblings, 2 replies; 7+ messages in thread
From: Dominik Vogt @ 2015-05-26 11:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

On Tue, May 19, 2015 at 07:05:14AM +0100, Dominik Vogt wrote:
> The attached patch activates the -mtune=native and -march=native
> command line options on S390 and System z.  Most of the code is a
> modified copy of gcc/config/mips/driver-native.c.  ChangeLog
> attached.

Version 2 of the patch to enable the configure options
--with-arch=native and --with-tune=native.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: ChangeLog --]
[-- Type: text/plain, Size: 503 bytes --]

gcc/ChangeLog

2015-05-21  Dominik Vogt  <vogt@linux.vnet.ibm.com>

	* config/s390/driver-native.c: New file.
	* config/s390/x-native: New file.
	* config.host: Add new files for s390.
	* config/s390/s390.h (DRIVER_SELF_SPECS): Add support for -mtune=native
	and -march=native
	* config.gcc: Likewise.
	* config/s390/s390.opt (march): Likewise; add PROCESSOR_NATIVE
	* config/s390/s390-opts.h (enum processor_type): Ditto.
	* config/s390/s390.c (s390_option_override): Catch unhandled
	PROCESSOR_NATIVE

[-- Attachment #3: 0001-v2-S390-Support-mtune-native-and-march-native.patch --]
[-- Type: text/x-diff, Size: 7568 bytes --]

From 3cc593974d299bf2f2c7f5f47fa6ff3524115e04 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 5 May 2015 12:49:23 +0100
Subject: [PATCH] S390: Support -mtune=native and -march=native.

---
 gcc/config.gcc                  |  2 +-
 gcc/config.host                 |  4 ++
 gcc/config/s390/driver-native.c | 91 +++++++++++++++++++++++++++++++++++++++++
 gcc/config/s390/s390-opts.h     |  1 +
 gcc/config/s390/s390.c          |  2 +
 gcc/config/s390/s390.h          | 14 ++++++-
 gcc/config/s390/s390.opt        |  3 ++
 gcc/config/s390/x-native        |  3 ++
 8 files changed, 117 insertions(+), 3 deletions(-)
 create mode 100644 gcc/config/s390/driver-native.c
 create mode 100644 gcc/config/s390/x-native

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 1fcc290..e23a34c 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4099,7 +4099,7 @@ case "${target}" in
 		for which in arch tune; do
 			eval "val=\$with_$which"
 			case ${val} in
-			"" | g5 | g6 | z900 | z990 | z9-109 | z9-ec | z10 | z196 | zEC12 | z13)
+			"" | native | g5 | g6 | z900 | z990 | z9-109 | z9-ec | z10 | z196 | zEC12 | z13)
 				# OK
 				;;
 			*)
diff --git a/gcc/config.host b/gcc/config.host
index a8896d1..4e456a1 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -172,6 +172,10 @@ case ${host} in
 	;;
     esac
     ;;
+  s390-*-* | s390x-*-*)
+    host_extra_gcc_objs="driver-native.o"
+    host_xmake_file="${host_xmake_file} s390/x-native"
+    ;;
   sparc*-*-solaris2*)
     case ${target} in
       sparc*-*-solaris2*)
diff --git a/gcc/config/s390/driver-native.c b/gcc/config/s390/driver-native.c
new file mode 100644
index 0000000..88c76bd
--- /dev/null
+++ b/gcc/config/s390/driver-native.c
@@ -0,0 +1,91 @@
+/* Subroutines for the gcc driver.
+   Copyright (C) 2015 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.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+
+/* This will be called by the spec parser in gcc.c when it sees
+   a %:local_cpu_detect(args) construct.  Currently it will be called
+   with either "arch" or "tune" as argument depending on if -march=native
+   or -mtune=native is to be substituted.
+
+   It returns a string containing new command line parameters to be
+   put at the place of the above two options, depending on what CPU
+   this is executed.  E.g. "-march=zEC12" on a zEC12 for -march=native.
+   If the routine can't detect a known processor, the -march or -mtune
+   option is discarded.
+
+   ARGC and ARGV are set depending on the actual arguments given
+   in the spec.  */
+const char *
+s390_host_detect_local_cpu (int argc, const char **argv)
+{
+  const char *cpu = NULL;
+  char buf[256];
+  FILE *f;
+  bool arch;
+
+  if (argc < 1)
+    return NULL;
+
+  arch = strcmp (argv[0], "arch") == 0;
+  if (!arch && strcmp (argv[0], "tune"))
+    return NULL;
+
+  f = fopen ("/proc/cpuinfo", "r");
+  if (f == NULL)
+    return NULL;
+
+  while (fgets (buf, sizeof (buf), f) != NULL)
+    if (strncmp (buf, "processor", sizeof ("processor") - 1) == 0)
+      {
+	if (strstr (buf, "machine = 9672") != NULL)
+	  cpu = "g5";
+	else if (strstr (buf, "machine = 2064") != NULL
+		 || strstr (buf, "machine = 2066") != NULL)
+	  cpu = "z900";
+	else if (strstr (buf, "machine = 2084") != NULL
+		 || strstr (buf, "machine = 2086") != NULL)
+	  cpu = "z990";
+	else if (strstr (buf, "machine = 2094") != NULL
+		 || strstr (buf, "machine = 2096") != NULL)
+	  cpu = "z9-109";
+	else if (strstr (buf, "machine = 2097") != NULL
+		 || strstr (buf, "machine = 2098") != NULL)
+	  cpu = "z10";
+	else if (strstr (buf, "machine = 2817") != NULL
+		 || strstr (buf, "machine = 2818") != NULL)
+	  cpu = "z196";
+	else if (strstr (buf, "machine = 2827") != NULL
+		 || strstr (buf, "machine = 2828") != NULL)
+	  cpu = "zEC12";
+	else if (strstr (buf, "machine = 2964") != NULL)
+	  cpu = "z13";
+	break;
+      }
+
+  fclose (f);
+
+  if (cpu == NULL)
+    return NULL;
+
+  return concat ("-m", argv[0], "=", cpu, NULL);
+}
diff --git a/gcc/config/s390/s390-opts.h b/gcc/config/s390/s390-opts.h
index 5bde333..f0ea532 100644
--- a/gcc/config/s390/s390-opts.h
+++ b/gcc/config/s390/s390-opts.h
@@ -36,6 +36,7 @@ enum processor_type
   PROCESSOR_2817_Z196,
   PROCESSOR_2827_ZEC12,
   PROCESSOR_2964_Z13,
+  PROCESSOR_NATIVE,
   PROCESSOR_max
 };
 
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 6648597..dfca516 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -13339,6 +13339,8 @@ s390_option_override (void)
     }
 
   /* Sanity checks.  */
+  if (s390_arch == PROCESSOR_NATIVE || s390_tune == PROCESSOR_NATIVE)
+    gcc_unreachable ();
   if (TARGET_ZARCH && !TARGET_CPU_ZARCH)
     error ("z/Architecture mode not supported on %s", s390_arch_string);
   if (TARGET_64BIT && !TARGET_ZARCH)
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index 6ddd8aa..82ec3d0 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -126,17 +126,27 @@ enum processor_flags
   { "arch", "%{!march=*:-march=%(VALUE)}" },			\
   { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
 
+extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
+# define EXTRA_SPEC_FUNCTIONS \
+  { "local_cpu_detect", s390_host_detect_local_cpu },
+
+# define MARCH_MTUNE_NATIVE_SPECS				\
+  " %{march=native:%<march=native %:local_cpu_detect(arch)}"	\
+  " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
+
 /* Defaulting rules.  */
 #ifdef DEFAULT_TARGET_64BIT
 #define DRIVER_SELF_SPECS					\
   "%{!m31:%{!m64:-m64}}",					\
   "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}",		\
-  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
+  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}",		\
+  MARCH_MTUNE_NATIVE_SPECS
 #else
 #define DRIVER_SELF_SPECS					\
   "%{!m31:%{!m64:-m31}}",					\
   "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}",		\
-  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
+  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}",		\
+  MARCH_MTUNE_NATIVE_SPECS
 #endif
 
 /* Constants needed to control the TEST DATA CLASS (TDC) instruction.  */
diff --git a/gcc/config/s390/s390.opt b/gcc/config/s390/s390.opt
index b841c4d..b21dc36 100644
--- a/gcc/config/s390/s390.opt
+++ b/gcc/config/s390/s390.opt
@@ -79,6 +79,9 @@ Enum(processor_type) String(zEC12) Value(PROCESSOR_2827_ZEC12)
 EnumValue
 Enum(processor_type) String(z13) Value(PROCESSOR_2964_Z13)
 
+EnumValue
+Enum(processor_type) String(native) Value(PROCESSOR_NATIVE) DriverOnly
+
 mbackchain
 Target Report Mask(BACKCHAIN)
 Maintain backchain pointer
diff --git a/gcc/config/s390/x-native b/gcc/config/s390/x-native
new file mode 100644
index 0000000..b33c8b6
--- /dev/null
+++ b/gcc/config/s390/x-native
@@ -0,0 +1,3 @@
+driver-native.o : $(srcdir)/config/s390/driver-native.c \
+  $(CONFIG_H) $(SYSTEM_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
-- 
2.3.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] S390: Support -mtune=native and -march=native.
  2015-05-26 11:56 ` [PATCH] S390: Support " Dominik Vogt
@ 2015-06-01 11:50   ` Jakub Jelinek
  2015-07-08 20:18   ` DJ Delorie
  1 sibling, 0 replies; 7+ messages in thread
From: Jakub Jelinek @ 2015-06-01 11:50 UTC (permalink / raw)
  To: gcc-patches, Andreas Krebbel

On Tue, May 26, 2015 at 12:06:51PM +0100, Dominik Vogt wrote:
> +  f = fopen ("/proc/cpuinfo", "r");
> +  if (f == NULL)
> +    return NULL;
> +
> +  while (fgets (buf, sizeof (buf), f) != NULL)
> +    if (strncmp (buf, "processor", sizeof ("processor") - 1) == 0)
> +      {
> +	if (strstr (buf, "machine = 9672") != NULL)
> +	  cpu = "g5";
> +	else if (strstr (buf, "machine = 2064") != NULL
> +		 || strstr (buf, "machine = 2066") != NULL)
> +	  cpu = "z900";
> +	else if (strstr (buf, "machine = 2084") != NULL
> +		 || strstr (buf, "machine = 2086") != NULL)
> +	  cpu = "z990";
> +	else if (strstr (buf, "machine = 2094") != NULL
> +		 || strstr (buf, "machine = 2096") != NULL)
> +	  cpu = "z9-109";
> +	else if (strstr (buf, "machine = 2097") != NULL
> +		 || strstr (buf, "machine = 2098") != NULL)
> +	  cpu = "z10";
> +	else if (strstr (buf, "machine = 2817") != NULL
> +		 || strstr (buf, "machine = 2818") != NULL)
> +	  cpu = "z196";
> +	else if (strstr (buf, "machine = 2827") != NULL
> +		 || strstr (buf, "machine = 2828") != NULL)
> +	  cpu = "zEC12";
> +	else if (strstr (buf, "machine = 2964") != NULL)
> +	  cpu = "z13";

Wouldn't it be better to just use const char *p = strstr (buf, "machine = ");
and then either strtoul the number after it and switch on it, or strcmp
it, rather than using up to 13 strstr calls that all need to skip
over the "processor" (you could even start after the matched keyword),
version and identification stuff?

	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] S390: Support -mtune=native and -march=native.
  2015-05-26 11:56 ` [PATCH] S390: Support " Dominik Vogt
  2015-06-01 11:50   ` Jakub Jelinek
@ 2015-07-08 20:18   ` DJ Delorie
  2015-07-09  6:44     ` Dominik Vogt
  1 sibling, 1 reply; 7+ messages in thread
From: DJ Delorie @ 2015-07-08 20:18 UTC (permalink / raw)
  To: vogt; +Cc: gcc-patches, krebbel


> Version 2 of the patch to enable the configure options
> --with-arch=native and --with-tune=native.

This patch broke cross-compiling with --target=s390-*

s390_host_detect_local_cpu is only defined if the --host is s390-*

but EXTRA_SPEC_FUNCTIONS refers to it when --target is s390-*

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] S390: Support -mtune=native and -march=native.
  2015-07-08 20:18   ` DJ Delorie
@ 2015-07-09  6:44     ` Dominik Vogt
  2015-07-09  7:23       ` DJ Delorie
  2015-07-17 14:36       ` Jan-Benedict Glaw
  0 siblings, 2 replies; 7+ messages in thread
From: Dominik Vogt @ 2015-07-09  6:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: krebbel, DJ Delorie

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

On Wed, Jul 08, 2015 at 04:18:47PM -0400, DJ Delorie wrote:
> 
> > Version 2 of the patch to enable the configure options
> > --with-arch=native and --with-tune=native.
> 
> This patch broke cross-compiling with --target=s390-*
> 
> s390_host_detect_local_cpu is only defined if the --host is s390-*
> 
> but EXTRA_SPEC_FUNCTIONS refers to it when --target is s390-*

Sorry about that.  Does the attached Patch fix the problem?

gcc/ChangeLog:
--------------
2015-07-09  Dominik Vogt  <vogt@linux.vnet.ibm.com>

	* config/s390/s390.h: S390: Do not define EXTRA_SPEC_FUNCTIONS when
	cross compiling.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-S390-Do-not-define-EXTRA_SPEC_FUNCTIONS-when-cross-c.patch --]
[-- Type: text/x-diff, Size: 1708 bytes --]

From 86e02035d8011fa158125a541cde5cc55a21c1ea Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Thu, 9 Jul 2015 07:31:42 +0100
Subject: [PATCH] S390: Do not define EXTRA_SPEC_FUNCTIONS when cross
 compiling.

---
 gcc/config/s390/s390.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index 85a0d1a..362e3d4 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -126,26 +126,30 @@ enum processor_flags
   { "arch", "%{!march=*:-march=%(VALUE)}" },			\
   { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
 
+#ifdef __s390__
 extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
 # define EXTRA_SPEC_FUNCTIONS \
   { "local_cpu_detect", s390_host_detect_local_cpu },
 
 # define MARCH_MTUNE_NATIVE_SPECS				\
-  " %{march=native:%<march=native %:local_cpu_detect(arch)}"	\
+  , " %{march=native:%<march=native %:local_cpu_detect(arch)}"	\
   " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
+#else
+# define MARCH_MTUNE_NATIVE_SPECS
+#endif
 
 /* Defaulting rules.  */
 #ifdef DEFAULT_TARGET_64BIT
 #define DRIVER_SELF_SPECS					\
   "%{!m31:%{!m64:-m64}}",					\
   "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}",		\
-  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}",		\
+  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"		\
   MARCH_MTUNE_NATIVE_SPECS
 #else
 #define DRIVER_SELF_SPECS					\
   "%{!m31:%{!m64:-m31}}",					\
   "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}",		\
-  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}",		\
+  "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"		\
   MARCH_MTUNE_NATIVE_SPECS
 #endif
 
-- 
2.3.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] S390: Support -mtune=native and -march=native.
  2015-07-09  6:44     ` Dominik Vogt
@ 2015-07-09  7:23       ` DJ Delorie
  2015-07-17 14:36       ` Jan-Benedict Glaw
  1 sibling, 0 replies; 7+ messages in thread
From: DJ Delorie @ 2015-07-09  7:23 UTC (permalink / raw)
  To: vogt; +Cc: gcc-patches, krebbel


> Sorry about that.  Does the attached Patch fix the problem?

Yup.  Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] S390: Support -mtune=native and -march=native.
  2015-07-09  6:44     ` Dominik Vogt
  2015-07-09  7:23       ` DJ Delorie
@ 2015-07-17 14:36       ` Jan-Benedict Glaw
  1 sibling, 0 replies; 7+ messages in thread
From: Jan-Benedict Glaw @ 2015-07-17 14:36 UTC (permalink / raw)
  To: krebbel; +Cc: DJ Delorie, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]

On Thu, 2015-07-09 07:44:09 +0100, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> On Wed, Jul 08, 2015 at 04:18:47PM -0400, DJ Delorie wrote:
> > 
> > > Version 2 of the patch to enable the configure options
> > > --with-arch=native and --with-tune=native.
> > 
> > This patch broke cross-compiling with --target=s390-*
> > 
> > s390_host_detect_local_cpu is only defined if the --host is s390-*
> > 
> > but EXTRA_SPEC_FUNCTIONS refers to it when --target is s390-*
> 
> Sorry about that.  Does the attached Patch fix the problem?

I haven't checked the patch, but others reported it to fix
cross-building. It seems to be not yet committed and my Build
Robot still complains about the initial issue:

http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=455156

  It would be nice if you'd commit it.

Thanks,
  Jan-Benedict

-- 
      Jan-Benedict Glaw      jbglaw@lug-owl.de              +49-172-7608481
Signature of:  The course of history shows that as a government grows, liberty
the second  : decreases."  (Thomas Jefferson)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-17 14:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19  6:16 [PATCH] S390: SUpport -mtune=native and -march=native Dominik Vogt
2015-05-26 11:56 ` [PATCH] S390: Support " Dominik Vogt
2015-06-01 11:50   ` Jakub Jelinek
2015-07-08 20:18   ` DJ Delorie
2015-07-09  6:44     ` Dominik Vogt
2015-07-09  7:23       ` DJ Delorie
2015-07-17 14:36       ` Jan-Benedict Glaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).