public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Should gcc configurted for CPU to generate code for CPU by default?
@ 2002-07-19 11:15 H. J. Lu
  2002-07-19 11:36 ` Philip Blundell
  2002-07-19 12:56 ` Richard Earnshaw
  0 siblings, 2 replies; 14+ messages in thread
From: H. J. Lu @ 2002-07-19 11:15 UTC (permalink / raw)
  To: gcc

When I configure gcc for i686 with

.../configure --target=i686-xxxxx

I'd like to be able to make gcc generate code for i686 by default. It
is also useful for MIPS. I am thinking adding

--with-default-ARCH=cpu

or

--with-default-CPU=cpu

or

--with-default-ISA=cpu

Any comments?


H.J.

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

* Re: Should gcc configurted for CPU to generate code for CPU by default?
  2002-07-19 11:15 Should gcc configurted for CPU to generate code for CPU by default? H. J. Lu
@ 2002-07-19 11:36 ` Philip Blundell
  2002-07-19 12:56 ` Richard Earnshaw
  1 sibling, 0 replies; 14+ messages in thread
From: Philip Blundell @ 2002-07-19 11:36 UTC (permalink / raw)
  To: H. J. Lu; +Cc: gcc

On Fri, 2002-07-19 at 16:14, H. J. Lu wrote:
> When I configure gcc for i686 with
> 
> .../configure --target=i686-xxxxx
> 
> I'd like to be able to make gcc generate code for i686 by default. It
> is also useful for MIPS. I am thinking adding
> 
> --with-default-CPU=cpu

FYI, the arm port already has a "--with-cpu=CPU" configure option that
does pretty much this.  Having gcc automatically take the cpu name from
the target tuple (ie --target=i686-linux implying 686 code) is probably
not desirable.

p.


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

* Re: Should gcc configurted for CPU to generate code for CPU by  default?
  2002-07-19 11:15 Should gcc configurted for CPU to generate code for CPU by default? H. J. Lu
  2002-07-19 11:36 ` Philip Blundell
@ 2002-07-19 12:56 ` Richard Earnshaw
  2002-07-19 12:56   ` H. J. Lu
  1 sibling, 1 reply; 14+ messages in thread
From: Richard Earnshaw @ 2002-07-19 12:56 UTC (permalink / raw)
  To: H. J. Lu; +Cc: gcc, Richard.Earnshaw

> When I configure gcc for i686 with
> 
> .../configure --target=i686-xxxxx
> 
> I'd like to be able to make gcc generate code for i686 by default. It
> is also useful for MIPS. I am thinking adding
> 
> --with-default-ARCH=cpu
> 
> or
> 
> --with-default-CPU=cpu
> 
> or
> 
> --with-default-ISA=cpu
> 
> Any comments?
> 

What's wrong with the existing --with-cpu=... already supported by 
configure?

R.

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

* Re: Should gcc configurted for CPU to generate code for CPU by default?
  2002-07-19 12:56 ` Richard Earnshaw
@ 2002-07-19 12:56   ` H. J. Lu
  2002-07-19 15:26     ` PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?) H. J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: H. J. Lu @ 2002-07-19 12:56 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: gcc

On Fri, Jul 19, 2002 at 04:25:00PM +0100, Richard Earnshaw wrote:
> > When I configure gcc for i686 with
> > 
> > .../configure --target=i686-xxxxx
> > 
> > I'd like to be able to make gcc generate code for i686 by default. It
> > is also useful for MIPS. I am thinking adding
> > 
> > --with-default-ARCH=cpu
> > 
> > or
> > 
> > --with-default-CPU=cpu
> > 
> > or
> > 
> > --with-default-ISA=cpu
> > 
> > Any comments?
> > 
> 
> What's wrong with the existing --with-cpu=... already supported by 
> configure?
> 

Correct me if I am wrong. At least for x86, --with-cpu=i686 is no
different from --target=i686-xxxxx, as far as the default code
generation is concerned. For x86, there are -mcpu=xxx and -march=xxx.
-with-cpu=xxx sets the default -mcpu=xxx. I want something to set
the default -march=xxx. Looking at install.texi. --with-cpu should
be used to set -march=xxx for x86. But for x86, TARGET_CPU_DEFAULT
is for -mcpu=... I am looking for TARGET_ARCH_DEFAULT. --with-arch=...
will work for me.


H.J.

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

* PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-19 12:56   ` H. J. Lu
@ 2002-07-19 15:26     ` H. J. Lu
  2002-07-19 15:35       ` Daniel Jacobowitz
  0 siblings, 1 reply; 14+ messages in thread
From: H. J. Lu @ 2002-07-19 15:26 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: gcc, gcc-patches

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

On Fri, Jul 19, 2002 at 09:02:07AM -0700, H. J. Lu wrote:
> On Fri, Jul 19, 2002 at 04:25:00PM +0100, Richard Earnshaw wrote:
> > > When I configure gcc for i686 with
> > > 
> > > .../configure --target=i686-xxxxx
> > > 
> > > I'd like to be able to make gcc generate code for i686 by default. It
> > > is also useful for MIPS. I am thinking adding
> > > 
> > > --with-default-ARCH=cpu
> > > 
> > > or
> > > 
> > > --with-default-CPU=cpu
> > > 
> > > or
> > > 
> > > --with-default-ISA=cpu
> > > 
> > > Any comments?
> > > 
> > 
> > What's wrong with the existing --with-cpu=... already supported by 
> > configure?
> > 
> 
> Correct me if I am wrong. At least for x86, --with-cpu=i686 is no
> different from --target=i686-xxxxx, as far as the default code
> generation is concerned. For x86, there are -mcpu=xxx and -march=xxx.
> -with-cpu=xxx sets the default -mcpu=xxx. I want something to set
> the default -march=xxx. Looking at install.texi. --with-cpu should
> be used to set -march=xxx for x86. But for x86, TARGET_CPU_DEFAULT
> is for -mcpu=... I am looking for TARGET_ARCH_DEFAULT. --with-arch=...
> will work for me.
> 
> 

Here is a patch to add --with-arch=cpu.


H.J.

[-- Attachment #2: gcc-arch.patch --]
[-- Type: text/plain, Size: 5955 bytes --]

2002-07-19  H.J. Lu <hjl@gnu.org>

	* Makefile.in (target_arch_default): New.
	(cs-config.h): Add TARGET_ARCH_DEFAULT="$(target_arch_default)".
	(cs-hconfig.h): Likewise.
	(cs-tconfig.h): Add TARGET_ARCH_DEFAULT="".
	(cs-tm_p.h): Likewise.

	* config.gcc (target_arch_default): New.
	Support --with-arch=cpu for i[34567]86-*-* and x86_64-*-*.

	* config/i386/i386.c (override_options): Set ix86_arch_string
	to cpu_names [TARGET_ARCH_DEFAULT].

	* configure.in: Substitute target_arch_default.
	* configure: Regenerated.

	* doc/install.texi: Document --with-arch=cpu.

--- gcc/Makefile.in.arch	Fri Jul 19 08:39:57 2002
+++ gcc/Makefile.in	Fri Jul 19 09:20:49 2002
@@ -277,6 +277,7 @@ lang_specs_files=@lang_specs_files@
 lang_options_files=@lang_options_files@
 lang_tree_files=@lang_tree_files@
 target_cpu_default=@target_cpu_default@
+target_arch_default=@target_arch_default@
 GCC_THREAD_FILE=@thread_file@
 OBJC_BOEHM_GC=@objc_boehm_gc@
 GTHREAD_FLAGS=@gthread_flags@
@@ -856,23 +857,28 @@ cs-config.h: Makefile
 	TM_DEFINES="$(tm_defines)" \
 	HEADERS="$(host_xm_file)" XM_DEFINES="$(host_xm_defines)" \
 	TARGET_CPU_DEFAULT="$(target_cpu_default)" \
+	TARGET_ARCH_DEFAULT="$(target_arch_default)" \
 	$(SHELL) $(srcdir)/mkconfig.sh config.h
 
 cs-hconfig.h: Makefile
 	TM_DEFINES="$(tm_defines)" \
 	HEADERS="$(build_xm_file)" XM_DEFINES="$(build_xm_defines)" \
 	TARGET_CPU_DEFAULT="$(target_cpu_default)" \
+	TARGET_ARCH_DEFAULT="$(target_arch_default)" \
 	$(SHELL) $(srcdir)/mkconfig.sh hconfig.h
 
 cs-tconfig.h: Makefile
 	TM_DEFINES="$(tm_defines)" \
 	HEADERS="$(xm_file)" XM_DEFINES="$(xm_defines)" \
 	TARGET_CPU_DEFAULT="" \
+	TARGET_ARCH_DEFAULT="" \
 	$(SHELL) $(srcdir)/mkconfig.sh tconfig.h
 
 cs-tm_p.h: Makefile
 	TM_DEFINES="" \
-	HEADERS="$(tm_p_file)" XM_DEFINES="" TARGET_CPU_DEFAULT="" \
+	HEADERS="$(tm_p_file)" XM_DEFINES="" \
+	TARGET_CPU_DEFAULT="" \
+	TARGET_ARCH_DEFAULT="" \
 	$(SHELL) $(srcdir)/mkconfig.sh tm_p.h
 
 # Don't automatically run autoconf, since configure.in might be accidentally
--- gcc/config.gcc.arch	Fri Jul 19 08:39:59 2002
+++ gcc/config.gcc	Fri Jul 19 10:15:37 2002
@@ -133,6 +133,8 @@
 #
 #  target_cpu_default	Set to override the default target model.
 #
+#  target_arch_default	Set to override the default arch model.
+#
 #  build_install_headers_dir
 #			Target to use when installing header files.
 #
@@ -197,6 +199,8 @@ float_format=
 use_collect2=
 # Set this to override the default target model.
 target_cpu_default=
+# Set this to override the default arch model.
+target_arch_default=
 # Set this to control how the header file directory is installed.
 install_headers_dir=install-headers-tar
 # Set this if directory names should be truncated to 14 characters.
@@ -252,13 +256,40 @@ arm*-*-*)
 xscale-*-*)
 	cpu_type=arm
 	;;
-i[34567]86-*-*)
-	cpu_type=i386
-	extra_headers="mmintrin.h xmmintrin.h"
-	;;
-x86_64-*-*)
+i[34567]86-*-* | x86_64-*-*)
 	cpu_type=i386
 	extra_headers="mmintrin.h xmmintrin.h"
+	case $machine in
+	x86_64-*-*)
+		target_arch_default=TARGET_CPU_DEFAULT_athlon_sse
+		;;
+	*)
+		target_arch_default=TARGET_CPU_DEFAULT_i386
+		;;
+	esac
+	case x"$with_arch" in
+	x)
+		;;
+	xi586)
+		target_arch_default="TARGET_CPU_DEFAULT_pentium"
+		;;
+	xi686 | xi786)
+		target_arch_default="TARGET_CPU_DEFAULT_pentiumpro"
+		;;
+	xi386 | xi486 | xpentium | xpentium-mmx | xpentiumpro \
+	| xpentium2 | xpentium3 | xpentium4 | xk6 | xk6-2 | xk6-3 \
+	| xathlon | xathlon-4)
+		target_arch_default="TARGET_CPU_DEFAULT_$with_arch"
+		;;
+	xyes | xno)
+		echo "--with-arch must be passed a value" 1>&2
+		exit 1
+		;;
+	*)
+		echo "Unknown arch used with --with-arch=$with_arch" 1>&2
+		exit 1
+		;;
+	esac
 	;;
 ia64-*-*)
 	extra_headers=ia64intrin.h
--- gcc/config/i386/i386.c.arch	Thu Jul 18 12:54:03 2002
+++ gcc/config/i386/i386.c	Fri Jul 19 09:20:55 2002
@@ -944,7 +944,7 @@ override_options ()
   if (!ix86_cpu_string)
     ix86_cpu_string = cpu_names [TARGET_CPU_DEFAULT];
   if (!ix86_arch_string)
-    ix86_arch_string = TARGET_64BIT ? "athlon-4" : "i386";
+    ix86_arch_string = cpu_names [TARGET_ARCH_DEFAULT];
 
   if (ix86_cmodel_string != 0)
     {
--- gcc/configure.in.arch	Fri Jul 19 08:39:59 2002
+++ gcc/configure.in	Fri Jul 19 09:22:23 2002
@@ -2691,6 +2691,7 @@ AC_SUBST(target_alias)
 AC_SUBST(c_target_objs)
 AC_SUBST(cxx_target_objs)
 AC_SUBST(target_cpu_default)
+AC_SUBST(target_arch_default)
 
 AC_SUBST_FILE(target_overrides)
 AC_SUBST_FILE(host_overrides)
--- gcc/doc/install.texi.arch	Sun Jun 30 23:23:28 2002
+++ gcc/doc/install.texi	Fri Jul 19 10:34:34 2002
@@ -677,6 +677,14 @@ SPARC@.  If configure does not recognize
 603e, or ultrasparc) you provide, please check the configure script
 for a complete list of supported models.
 
+@item --with-arch=@var{cpu}
+Also specify which cpu variant the compiler should generate code for
+by default.  For some processors, like the i386 family,
+@option{--with-cpu-@var{cpu}} will only schedule things appropriately
+for @var{cpu}. the compiler will not generate any code that
+does not run on the i386 without @option{--with-arch-@var{cpu}}.
+This is currently only supported on the i386 family of processors.
+
 @item --enable-altivec
 Specify that the target supports AltiVec vector enhancements.  This
 option will adjust the ABI for AltiVec enhancements, as well as generate
--- gcc/mkconfig.sh.arch	Sun Jun 23 08:33:42 2002
+++ gcc/mkconfig.sh	Fri Jul 19 09:21:50 2002
@@ -19,6 +19,12 @@ if [ "$TARGET_CPU_DEFAULT" != "" ]; then
     echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T
 fi
 
+# Define TARGET_ARCH_DEFAULT if the system wants one.
+# This substitutes for lots of *.h files.
+if [ "$TARGET_ARCH_DEFAULT" != "" ]; then
+    echo "#define TARGET_ARCH_DEFAULT ($TARGET_ARCH_DEFAULT)" >> ${output}T
+fi
+
 # Provide defines for other target machine macros to be used everywhere.
 for def in $TM_DEFINES; do
     echo "#ifndef $def" | sed 's/=.*//' >> ${output}T

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-19 15:26     ` PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?) H. J. Lu
@ 2002-07-19 15:35       ` Daniel Jacobowitz
  2002-07-19 16:35         ` H. J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2002-07-19 15:35 UTC (permalink / raw)
  To: gcc, gcc-patches

On Fri, Jul 19, 2002 at 10:40:08AM -0700, H. J. Lu wrote:
> On Fri, Jul 19, 2002 at 09:02:07AM -0700, H. J. Lu wrote:
> > On Fri, Jul 19, 2002 at 04:25:00PM +0100, Richard Earnshaw wrote:
> > > > When I configure gcc for i686 with
> > > > 
> > > > .../configure --target=i686-xxxxx
> > > > 
> > > > I'd like to be able to make gcc generate code for i686 by default. It
> > > > is also useful for MIPS. I am thinking adding
> > > > 
> > > > --with-default-ARCH=cpu
> > > > 
> > > > or
> > > > 
> > > > --with-default-CPU=cpu
> > > > 
> > > > or
> > > > 
> > > > --with-default-ISA=cpu
> > > > 
> > > > Any comments?
> > > > 
> > > 
> > > What's wrong with the existing --with-cpu=... already supported by 
> > > configure?
> > > 
> > 
> > Correct me if I am wrong. At least for x86, --with-cpu=i686 is no
> > different from --target=i686-xxxxx, as far as the default code
> > generation is concerned. For x86, there are -mcpu=xxx and -march=xxx.
> > -with-cpu=xxx sets the default -mcpu=xxx. I want something to set
> > the default -march=xxx. Looking at install.texi. --with-cpu should
> > be used to set -march=xxx for x86. But for x86, TARGET_CPU_DEFAULT
> > is for -mcpu=... I am looking for TARGET_ARCH_DEFAULT. --with-arch=...
> > will work for me.
> > 
> > 
> 
> Here is a patch to add --with-arch=cpu.
> 
> 
> H.J.

Can't this be done at the driver level?  We have different handling of
--with-cpu for every architecture already; I'd much rather not
proliferate that.


-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-19 15:35       ` Daniel Jacobowitz
@ 2002-07-19 16:35         ` H. J. Lu
  2002-07-19 17:03           ` Daniel Jacobowitz
  0 siblings, 1 reply; 14+ messages in thread
From: H. J. Lu @ 2002-07-19 16:35 UTC (permalink / raw)
  To: gcc, gcc-patches

On Fri, Jul 19, 2002 at 01:43:14PM -0400, Daniel Jacobowitz wrote:
> > > 
> > > Correct me if I am wrong. At least for x86, --with-cpu=i686 is no
> > > different from --target=i686-xxxxx, as far as the default code
> > > generation is concerned. For x86, there are -mcpu=xxx and -march=xxx.
> > > -with-cpu=xxx sets the default -mcpu=xxx. I want something to set
> > > the default -march=xxx. Looking at install.texi. --with-cpu should
> > > be used to set -march=xxx for x86. But for x86, TARGET_CPU_DEFAULT
> > > is for -mcpu=... I am looking for TARGET_ARCH_DEFAULT. --with-arch=...
> > > will work for me.
> > > 
> > > 
> > 
> > Here is a patch to add --with-arch=cpu.
> > 
> > 
> > H.J.
> 
> Can't this be done at the driver level?  We have different handling of
> 

What do you mean by that?


H.J.

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-19 16:35         ` H. J. Lu
@ 2002-07-19 17:03           ` Daniel Jacobowitz
  2002-07-19 18:46             ` H. J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2002-07-19 17:03 UTC (permalink / raw)
  To: H. J. Lu; +Cc: gcc

On Fri, Jul 19, 2002 at 10:46:23AM -0700, H. J. Lu wrote:
> On Fri, Jul 19, 2002 at 01:43:14PM -0400, Daniel Jacobowitz wrote:
> > > > 
> > > > Correct me if I am wrong. At least for x86, --with-cpu=i686 is no
> > > > different from --target=i686-xxxxx, as far as the default code
> > > > generation is concerned. For x86, there are -mcpu=xxx and -march=xxx.
> > > > -with-cpu=xxx sets the default -mcpu=xxx. I want something to set
> > > > the default -march=xxx. Looking at install.texi. --with-cpu should
> > > > be used to set -march=xxx for x86. But for x86, TARGET_CPU_DEFAULT
> > > > is for -mcpu=... I am looking for TARGET_ARCH_DEFAULT. --with-arch=...
> > > > will work for me.
> > > > 
> > > > 
> > > 
> > > Here is a patch to add --with-arch=cpu.
> > > 
> > > 
> > > H.J.
> > 
> > Can't this be done at the driver level?  We have different handling of
> > 
> 
> What do you mean by that?

I.E. make the GCC driver supply a default value of -mcpu if none is
specified on the command line, the same way sane programs set defaults.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-19 17:03           ` Daniel Jacobowitz
@ 2002-07-19 18:46             ` H. J. Lu
  2002-07-20  6:05               ` Daniel Jacobowitz
  0 siblings, 1 reply; 14+ messages in thread
From: H. J. Lu @ 2002-07-19 18:46 UTC (permalink / raw)
  To: gcc

On Fri, Jul 19, 2002 at 01:49:52PM -0400, Daniel Jacobowitz wrote:
> > > 
> > > Can't this be done at the driver level?  We have different handling of
> > > 
> > 
> > What do you mean by that?
> 
> I.E. make the GCC driver supply a default value of -mcpu if none is
> specified on the command line, the same way sane programs set defaults.
> 

That is exactly what the gcc driver is doing today. My patch provides
a way to choose a different default value for -march at the configure
time. Without my change, the default value for -march is i386 for all
ia32 processors and it is fixed.


H.J.

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-19 18:46             ` H. J. Lu
@ 2002-07-20  6:05               ` Daniel Jacobowitz
  2002-07-20  7:10                 ` H. J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2002-07-20  6:05 UTC (permalink / raw)
  To: H. J. Lu; +Cc: gcc

On Fri, Jul 19, 2002 at 10:55:47AM -0700, H. J. Lu wrote:
> On Fri, Jul 19, 2002 at 01:49:52PM -0400, Daniel Jacobowitz wrote:
> > > > 
> > > > Can't this be done at the driver level?  We have different handling of
> > > > 
> > > 
> > > What do you mean by that?
> > 
> > I.E. make the GCC driver supply a default value of -mcpu if none is
> > specified on the command line, the same way sane programs set defaults.
> > 
> 
> That is exactly what the gcc driver is doing today. My patch provides
> a way to choose a different default value for -march at the configure
> time. Without my change, the default value for -march is i386 for all
> ia32 processors and it is fixed.

No, that's not what the driver does today.  I mean that if the driver
was built with --with-arch=, and the driver does not see an -march=,
then the driver should supply one.  Then we won't need any changes to
backends.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-20  6:05               ` Daniel Jacobowitz
@ 2002-07-20  7:10                 ` H. J. Lu
  2002-07-20  7:52                   ` Daniel Jacobowitz
  0 siblings, 1 reply; 14+ messages in thread
From: H. J. Lu @ 2002-07-20  7:10 UTC (permalink / raw)
  To: gcc

On Fri, Jul 19, 2002 at 02:03:29PM -0400, Daniel Jacobowitz wrote:
> On Fri, Jul 19, 2002 at 10:55:47AM -0700, H. J. Lu wrote:
> > On Fri, Jul 19, 2002 at 01:49:52PM -0400, Daniel Jacobowitz wrote:
> > > > > 
> > > > > Can't this be done at the driver level?  We have different handling of
> > > > > 
> > > > 
> > > > What do you mean by that?
> > > 
> > > I.E. make the GCC driver supply a default value of -mcpu if none is
> > > specified on the command line, the same way sane programs set defaults.
> > > 
> > 
> > That is exactly what the gcc driver is doing today. My patch provides
> > a way to choose a different default value for -march at the configure
> > time. Without my change, the default value for -march is i386 for all
> > ia32 processors and it is fixed.
> 
> No, that's not what the driver does today.  I mean that if the driver
> was built with --with-arch=, and the driver does not see an -march=,
> then the driver should supply one.  Then we won't need any changes to
> backends.

I am really confused here. To me, my patch does exactly what you said
above. Wait, did you mean gcc.c should handle -march=, not i386.c?
I have an impresssion that most, if not all, "-mxxx" switches are 
handled in the backend. I don't see why my patch should change that.

FWIW, "-mxxx" switches are backend dependent by definition. Did I miss
something here?


H.J.

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-20  7:10                 ` H. J. Lu
@ 2002-07-20  7:52                   ` Daniel Jacobowitz
  2002-07-20 11:24                     ` H. J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2002-07-20  7:52 UTC (permalink / raw)
  To: H. J. Lu; +Cc: gcc

On Fri, Jul 19, 2002 at 11:10:53AM -0700, H. J. Lu wrote:
> On Fri, Jul 19, 2002 at 02:03:29PM -0400, Daniel Jacobowitz wrote:
> > On Fri, Jul 19, 2002 at 10:55:47AM -0700, H. J. Lu wrote:
> > > On Fri, Jul 19, 2002 at 01:49:52PM -0400, Daniel Jacobowitz wrote:
> > > > > > 
> > > > > > Can't this be done at the driver level?  We have different handling of
> > > > > > 
> > > > > 
> > > > > What do you mean by that?
> > > > 
> > > > I.E. make the GCC driver supply a default value of -mcpu if none is
> > > > specified on the command line, the same way sane programs set defaults.
> > > > 
> > > 
> > > That is exactly what the gcc driver is doing today. My patch provides
> > > a way to choose a different default value for -march at the configure
> > > time. Without my change, the default value for -march is i386 for all
> > > ia32 processors and it is fixed.
> > 
> > No, that's not what the driver does today.  I mean that if the driver
> > was built with --with-arch=, and the driver does not see an -march=,
> > then the driver should supply one.  Then we won't need any changes to
> > backends.
> 
> I am really confused here. To me, my patch does exactly what you said
> above. Wait, did you mean gcc.c should handle -march=, not i386.c?
> I have an impresssion that most, if not all, "-mxxx" switches are 
> handled in the backend. I don't see why my patch should change that.
> 
> FWIW, "-mxxx" switches are backend dependent by definition. Did I miss
> something here?

Right now, we have a handful of architectures that support --with-cpu=. 
They all do it in different ways.  Most don't recognize it at all. 
What I am suggesting is that the driver (gcc.c) should recognize
-march= and -mcpu= if TARGET_{ARCH,CPU}_DEFAULT are defined.  The only
thing it should do with them is supply one if none is present.  The
backend handles the rest, as before.

That way we don't keep having to do this for different platforms.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?)
  2002-07-20  7:52                   ` Daniel Jacobowitz
@ 2002-07-20 11:24                     ` H. J. Lu
  2002-07-25  4:24                       ` Michael Eager
  0 siblings, 1 reply; 14+ messages in thread
From: H. J. Lu @ 2002-07-20 11:24 UTC (permalink / raw)
  To: gcc

On Fri, Jul 19, 2002 at 02:15:49PM -0400, Daniel Jacobowitz wrote:
> 
> Right now, we have a handful of architectures that support --with-cpu=. 
> They all do it in different ways.  Most don't recognize it at all. 
> What I am suggesting is that the driver (gcc.c) should recognize
> -march= and -mcpu= if TARGET_{ARCH,CPU}_DEFAULT are defined.  The only
> thing it should do with them is supply one if none is present.  The
> backend handles the rest, as before.
 

I agree it is not a bad idea. However, different platforms have
different treatments for TARGET_{ARCH,CPU}_DEFAULT. Some of them treat
them as bit masks, while others treat them as indexes. Unify them or
not belongs to a different discussion.

While we are on this topic, we have -march, -mcpu and -mtune for
different backends. They may not have the same meaning even when the
option name is the same. It is particularly true for -mcpu. I don't
see if we can unify them without breaking backward compatibility.


H.J.

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

* Re: PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to  generate code for CPU by default?)
  2002-07-20 11:24                     ` H. J. Lu
@ 2002-07-25  4:24                       ` Michael Eager
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Eager @ 2002-07-25  4:24 UTC (permalink / raw)
  To: H. J. Lu, gcc

"H. J. Lu" wrote:
> 
> On Fri, Jul 19, 2002 at 02:15:49PM -0400, Daniel Jacobowitz wrote:
> >
> > Right now, we have a handful of architectures that support --with-cpu=.
> > They all do it in different ways.  Most don't recognize it at all.
> > What I am suggesting is that the driver (gcc.c) should recognize
> > -march= and -mcpu= if TARGET_{ARCH,CPU}_DEFAULT are defined.  The only
> > thing it should do with them is supply one if none is present.  The
> > backend handles the rest, as before.
> 
> 
> I agree it is not a bad idea. However, different platforms have
> different treatments for TARGET_{ARCH,CPU}_DEFAULT. Some of them treat
> them as bit masks, while others treat them as indexes. Unify them or
> not belongs to a different discussion.
> 
> While we are on this topic, we have -march, -mcpu and -mtune for
> different backends. They may not have the same meaning even when the
> option name is the same. It is particularly true for -mcpu. I don't
> see if we can unify them without breaking backward compatibility.


Let me jump in here, even if a bit late.

Most of the architecture/cpu processing in config.gcc is pretty inconsistent
and jumbled.  As you point out the interpretation of the -march, -mcpu, and 
-mtune is not consistent across all architectures.   

I don't think that the way to address this inconsistency is to add yet 
another option.  The architecture of is the first component of a target 
triple/quad.  If --target=i586-montavista-linux, there is no 
need to also specify --with-arch=i586.

The interpretation of --with-cpu, for most architectures, is to specify
a specific processor model within an architecture.  Not all architectures
accept this option.  Worse, not all architectures use the same set of
flags to pass this information into the compiler.  For example, MIPS uses
target_cpu_default to indicate whether or not gas is being used, not 
which processor is the default.

[As a small bit of background, some time ago I developed a patch for 
gcc-2.95.3 for MIPS which accepted --with-cpu, separated the gas flags from 
the default cpu type, and correctly configured the default processor.  
Unfortunately,  I never got around to porting it to the CVS head.]

Daniel's suggestion that the driver, not cc1, handle the --with-cpu option
is interesting.  This would also address another problem.  Although cc1 
knows the default cpu, the driver doesn't.  This means that this cannot
be passed on to as.   This is needed in the cases either when the assembler
should generate different op codes for different processor variants, or 
flag instructions which are not valid on the target processor.  This works
if the user specifies --mcpu= on the command line, but it doesn't work if
gcc is configured with --with-cpu=.

So, with some trepidation, let me suggest the following:

1)  target_cpu_flags be created to capture options, like --gas=yes.
2)  target_cpu_default have the processor flags.
3)  target_cpu_name is the name of the processor specified in --with-cpu.
4)  export each of these names to config.h so that they can be used 
    either by cc1 or gcc
5)  add a specs file option to generate the target_cpu_name so that
    this info can be passed either to cc1, as or other components,
    as needed.

Comments?  Suggestions?



--
Michael Eager     eager@mvista.com	408-328-8426	
MontaVista Software, Inc. 1237 E. Arques Ave., Sunnyvale, CA  94085

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

end of thread, other threads:[~2002-07-24 23:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-19 11:15 Should gcc configurted for CPU to generate code for CPU by default? H. J. Lu
2002-07-19 11:36 ` Philip Blundell
2002-07-19 12:56 ` Richard Earnshaw
2002-07-19 12:56   ` H. J. Lu
2002-07-19 15:26     ` PATCH: Add --with-arch=cpu (Re: Should gcc configurted for CPU to generate code for CPU by default?) H. J. Lu
2002-07-19 15:35       ` Daniel Jacobowitz
2002-07-19 16:35         ` H. J. Lu
2002-07-19 17:03           ` Daniel Jacobowitz
2002-07-19 18:46             ` H. J. Lu
2002-07-20  6:05               ` Daniel Jacobowitz
2002-07-20  7:10                 ` H. J. Lu
2002-07-20  7:52                   ` Daniel Jacobowitz
2002-07-20 11:24                     ` H. J. Lu
2002-07-25  4:24                       ` Michael Eager

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).