public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: RFC: New approach to --with-cpu
@ 2002-07-30 18:54 John David Anglin
  2002-07-30 23:03 ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: John David Anglin @ 2002-07-30 18:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: drow

From a PA standpoint, the main objection that I have to this approach
is that there seems to be a slight loss of flexibility.  You use "with_cpu"
to set the default scheduling model.  However, I was also planning to set
the default arch based on the target machine when a linker bug in handling
PA2.0 code is fixed.  I view these options as independent although the
configure defaults would both be based on the target triplet.  Thus,
it would be necessary to introduce a new configure option to handle
the arch default.  In the future, I can see other default code generation
options being set-table.

I must admit that I don't really like the multilib concept and find
it a rather  idea to build libraries for all scheduling models,
archs, etc.  Thus, I don't find this justification attractive.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: RFC: New approach to --with-cpu
  2002-07-30 18:54 RFC: New approach to --with-cpu John David Anglin
@ 2002-07-30 23:03 ` Daniel Jacobowitz
  2002-07-31  7:53   ` John David Anglin
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-30 23:03 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc-patches

On Tue, Jul 30, 2002 at 09:31:41PM -0400, John David Anglin wrote:
> >From a PA standpoint, the main objection that I have to this approach
> is that there seems to be a slight loss of flexibility.  You use "with_cpu"
> to set the default scheduling model.  However, I was also planning to set
> the default arch based on the target machine when a linker bug in handling
> PA2.0 code is fixed.  I view these options as independent although the
> configure defaults would both be based on the target triplet.  Thus,
> it would be necessary to introduce a new configure option to handle
> the arch default.  In the future, I can see other default code generation
> options being set-table.

Well, that's no problem.  A first cut of this patch offered defaults
for -march= and -mtune= separately on MIPS.  I could do the same for
PA easily.

> I must admit that I don't really like the multilib concept and find
> it a rather  idea to build libraries for all scheduling models,
> archs, etc.  Thus, I don't find this justification attractive.

I don't like multilibs either.  Eric mentioned some concerns that this
would interfere with them when I discussed it with him, which is why I
brought it up.

The real advantage of my approach is getting anything specs-based
correct.  For instance, the preprocessor flags related to -msoft-float
are set correctly if you use --with-float=soft.

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

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

* Re: RFC: New approach to --with-cpu
  2002-07-30 23:03 ` Daniel Jacobowitz
@ 2002-07-31  7:53   ` John David Anglin
  2002-07-31  8:09     ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: John David Anglin @ 2002-07-31  7:53 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gcc-patches

> Well, that's no problem.  A first cut of this patch offered defaults
> for -march= and -mtune= separately on MIPS.  I could do the same for
> PA easily.

I would be happy if the configure option for setting the default
scheduling was "--with-schedule" rather than "--with-cpu".  This
will set the default for -mschedule=.  Similarly, when an option
is introduced to set the default arch, then I would like to use
"--with-arch".

Using the same suffix in the configure and gcc options makes the
relationship between the two options clearer.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  7:53   ` John David Anglin
@ 2002-07-31  8:09     ` Daniel Jacobowitz
  2002-07-31  8:30       ` Richard Earnshaw
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-31  8:09 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc-patches

On Wed, Jul 31, 2002 at 10:46:50AM -0400, John David Anglin wrote:
> > Well, that's no problem.  A first cut of this patch offered defaults
> > for -march= and -mtune= separately on MIPS.  I could do the same for
> > PA easily.
> 
> I would be happy if the configure option for setting the default
> scheduling was "--with-schedule" rather than "--with-cpu".  This
> will set the default for -mschedule=.  Similarly, when an option
> is introduced to set the default arch, then I would like to use
> "--with-arch".
> 
> Using the same suffix in the configure and gcc options makes the
> relationship between the two options clearer.

I was actually debating this.  The advantage of using --with-cpu for
all targets is consistency across architectures.  The advantage of
saying --with-schedule, --with-arch, --with-tune is flexibility.  I
lean towards consistency, but I could be persuaded either way - does
anyone else have an opinion?

I suppose using --with-schedule on PA would also mean we could have
--with-arch, which is nice.

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

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  8:09     ` Daniel Jacobowitz
@ 2002-07-31  8:30       ` Richard Earnshaw
  2002-07-31  9:02         ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Earnshaw @ 2002-07-31  8:30 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: John David Anglin, gcc-patches, Richard.Earnshaw

> On Wed, Jul 31, 2002 at 10:46:50AM -0400, John David Anglin wrote:
> > > Well, that's no problem.  A first cut of this patch offered defaults
> > > for -march= and -mtune= separately on MIPS.  I could do the same for
> > > PA easily.
> > 
> > I would be happy if the configure option for setting the default
> > scheduling was "--with-schedule" rather than "--with-cpu".  This
> > will set the default for -mschedule=.  Similarly, when an option
> > is introduced to set the default arch, then I would like to use
> > "--with-arch".
> > 
> > Using the same suffix in the configure and gcc options makes the
> > relationship between the two options clearer.
> 
> I was actually debating this.  The advantage of using --with-cpu for
> all targets is consistency across architectures.  The advantage of
> saying --with-schedule, --with-arch, --with-tune is flexibility.  I
> lean towards consistency, but I could be persuaded either way - does
> anyone else have an opinion?
> 
> I suppose using --with-schedule on PA would also mean we could have
> --with-arch, which is nice.
> 

In what way is --with-schedule different from --with-tune?  Are they 
synonyms?

I can understand the split --with-arch --with-tune and --with-cpu (with 
the latter meaning -with-arch=<arch-of-cpu> --with-tune=cpu), but I'm not 
sure of the distinction between schedule and tune.

R.

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  8:30       ` Richard Earnshaw
@ 2002-07-31  9:02         ` Daniel Jacobowitz
  2002-07-31 10:34           ` John David Anglin
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-31  9:02 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: John David Anglin, gcc-patches

On Wed, Jul 31, 2002 at 04:17:10PM +0100, Richard Earnshaw wrote:
> > On Wed, Jul 31, 2002 at 10:46:50AM -0400, John David Anglin wrote:
> > > > Well, that's no problem.  A first cut of this patch offered defaults
> > > > for -march= and -mtune= separately on MIPS.  I could do the same for
> > > > PA easily.
> > > 
> > > I would be happy if the configure option for setting the default
> > > scheduling was "--with-schedule" rather than "--with-cpu".  This
> > > will set the default for -mschedule=.  Similarly, when an option
> > > is introduced to set the default arch, then I would like to use
> > > "--with-arch".
> > > 
> > > Using the same suffix in the configure and gcc options makes the
> > > relationship between the two options clearer.
> > 
> > I was actually debating this.  The advantage of using --with-cpu for
> > all targets is consistency across architectures.  The advantage of
> > saying --with-schedule, --with-arch, --with-tune is flexibility.  I
> > lean towards consistency, but I could be persuaded either way - does
> > anyone else have an opinion?
> > 
> > I suppose using --with-schedule on PA would also mean we could have
> > --with-arch, which is nice.
> > 
> 
> In what way is --with-schedule different from --with-tune?  Are they 
> synonyms?
> 
> I can understand the split --with-arch --with-tune and --with-cpu (with 
> the latter meaning -with-arch=<arch-of-cpu> --with-tune=cpu), but I'm not 
> sure of the distinction between schedule and tune.

Historical inconsistency.  PA appears to define -mschedule but not
-mtune; the meaning appears to be about the same.  One thing I will
_not_ do is allow --with-tune to set -mschedule, though; I'd rather add
-mtune to PA and then use --with-tune.

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

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  9:02         ` Daniel Jacobowitz
@ 2002-07-31 10:34           ` John David Anglin
  2002-07-31 13:27             ` Daniel Jacobowitz
  2002-08-01  6:30             ` Richard Earnshaw
  0 siblings, 2 replies; 26+ messages in thread
From: John David Anglin @ 2002-07-31 10:34 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Richard.Earnshaw, gcc-patches

> Historical inconsistency.  PA appears to define -mschedule but not
> -mtune; the meaning appears to be about the same.  One thing I will
> _not_ do is allow --with-tune to set -mschedule, though; I'd rather add
> -mtune to PA and then use --with-tune.

My preference would be to leave things as they are and use --with-schedule.
-mschedule relates directly to the scheduling model.  The option value is PA
specific anyway.  We also have a whole bunch of other oddball -m options
which affect bits in the target flags.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: RFC: New approach to --with-cpu
  2002-07-31 10:34           ` John David Anglin
@ 2002-07-31 13:27             ` Daniel Jacobowitz
  2002-08-01  3:31               ` Richard Sandiford
  2002-08-01  8:15               ` John David Anglin
  2002-08-01  6:30             ` Richard Earnshaw
  1 sibling, 2 replies; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-31 13:27 UTC (permalink / raw)
  To: John David Anglin; +Cc: Richard.Earnshaw, gcc-patches

On Wed, Jul 31, 2002 at 12:52:24PM -0400, John David Anglin wrote:
> > Historical inconsistency.  PA appears to define -mschedule but not
> > -mtune; the meaning appears to be about the same.  One thing I will
> > _not_ do is allow --with-tune to set -mschedule, though; I'd rather add
> > -mtune to PA and then use --with-tune.
> 
> My preference would be to leave things as they are and use --with-schedule.
> -mschedule relates directly to the scheduling model.  The option value is PA
> specific anyway.  We also have a whole bunch of other oddball -m options
> which affect bits in the target flags.

Take 3.  Is this about what you had in mind?

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

2002-07-31  Daniel Jacobowitz  <drow@mvista.com>

	* Makefile.in (DRIVER_DEFINES): Add @target_default_options@
	* configure.in: Add @target_default_options@.  Document --with-cpu,
	--with-arch, --with-tune, --with-schedule, and --with-float.
	* config.gcc: Reorganize $with_cpu logic.  Set
	target_default_options according to the default CPU, $with_cpu,
	$with_arch, $with_tune, $with_schedule, and $with_float.
	* config/mips/mips.h (TARGET_DEFAULT_ARCH_P)
	(TARGET_DEFAULT_FLOAT_P): New macros.
	* gcc.c (default_options, add_option, option_present): New
	functions.
	(process_command): Call default_options.
	* doc/install.texi: Update --with-cpu documentation.  Mention
	--with-arch, --with-schedule, --with-tune, and --with-float.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.919
diff -u -p -r1.919 Makefile.in
--- Makefile.in	29 Jul 2002 19:31:23 -0000	1.919
+++ Makefile.in	31 Jul 2002 19:43:30 -0000
@@ -1251,6 +1251,7 @@ c-dump.o : c-dump.c $(CONFIG_H) $(SYSTEM
 # Language-independent files.
 
 DRIVER_DEFINES = \
+  @target_default_options@ \
   -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc-lib/\" \
   -DDEFAULT_TARGET_VERSION=\"$(version)\" \
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.229
diff -u -p -r1.229 config.gcc
--- config.gcc	29 Jul 2002 22:21:40 -0000	1.229
+++ config.gcc	31 Jul 2002 19:43:32 -0000
@@ -2770,173 +2770,178 @@ case $machine in
 	;;
 esac
 
-# Distinguish i[34567]86
-# Also, do not run mips-tfile on MIPS if using gas.
-# Process --with-cpu= for PowerPC/rs6000
-target_cpu_default2=
-case $machine in
-i486-*-*)
-	target_cpu_default2=TARGET_CPU_DEFAULT_i486
-	;;
-i586-*-*)
-	case $target_alias in
-		k6_2-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6_2
-			;;
-		k6_3-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6_3
-			;;
-		k6-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6
-			;;
-		pentium_mmx-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium_mmx
-			;;
-		*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium
-			;;
-	esac
-	;;
-i686-*-* | i786-*-*)
-	case $target_alias in
-		athlon_xp-*|athlon_mp-*|athlon_4-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
-			;;
-		athlon_tbird-*|athlon-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_athlon
-			;;
-		pentium2-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium2
-			;;
-		pentium3-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium3
-			;;
-		pentium4-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium4
-			;;
-		*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentiumpro
+if test x$pass2done = xyes
+then
+	case "x$with_cpu" in
+		xyes | xno)
+			echo "--with-cpu must be passed a value" 1>&2
+			exit 1
 			;;
 	esac
-	;;
-x86_64-*-*)
-	# We should have hammer chip here, but it does not exist yet and
-	# thus it is not supported.  Athlon_SSE is probably equivalent feature
-	# wise to hammer from our point of view except for 64bit mode.
-	target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
-	;;
-alpha*-*-*)
-	case $machine in
-		alphaev6[78]*)
-			target_cpu_default2="MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX|MASK_CIX"
-			;;
-		alphaev6*)
-			target_cpu_default2="MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX"
-			;;
-		alphapca56*)
-			target_cpu_default2="MASK_CPU_EV5|MASK_BWX|MASK_MAX"
-			;;
-		alphaev56*)
-			target_cpu_default2="MASK_CPU_EV5|MASK_BWX"
+
+	# If there is no $with_cpu option, try to infer one from ${machine}.
+	if test x$with_cpu = x
+	then
+		case $machine in
+		i486-*-*)
+			with_cpu=i486
+			;;
+		i586-*-*)
+			case $target_alias in
+			k6_2-*)
+				with_cpu=k6-2
+				;;
+			k6_3-*)
+				with_cpu=k6-3
+				;;
+			k6-*)
+				with_cpu=k6
+				;;
+			pentium_mmx-*)
+				with_cpu=pentium-mmx
+				;;
+			*)
+				with_cpu=pentium
+				;;
+			esac
+			;;
+		i686-*-* | i786-*-*)
+			case $target_alias in
+			athlon_xp-*|athlon_mp-*|athlon_4-*)
+				with_cpu=athlon-4
+				;;
+			athlon_tbird-*|athlon-*)
+				with_cpu=athlon
+				;;
+			pentium2-*)
+				with_cpu=pentium2
+				;;
+			pentium3-*)
+				with_cpu=pentium3
+				;;
+			pentium4-*)
+				with_cpu=pentium4
+				;;
+			*)
+				with_cpu=pentiumpro
+				;;
+			esac
+			;;
+		x86_64-*-*)
+			# We should have hammer chip here, but it does not
+			# exist yet and thus it is not supported.  Athlon_SSE
+			# is probably equivalent feature wise to hammer from
+			# our point of view except for 64bit mode.
+			with_cpu=athlon-sse
+			;;
+		alpha*-*-*)
+			case $machine in
+			alphaev6[78]*)
+				with_cpu=ev67
+				;;
+			alphaev6*)
+				with_cpu=ev6
+				;;
+			alphapca56*)
+				with_cpu=pca56
+				;;
+			alphaev56*)
+				with_cpu=ev56
+				;;
+			alphaev5*)
+				with_cpu=ev5
+				;;
+			esac
 			;;
-		alphaev5*)
-			target_cpu_default2="MASK_CPU_EV5"
+		sparc*-*-*)
+			with_cpu="`echo $machine | sed 's/-.*$//'`"
 			;;
-	esac
+		esac
+	fi
 
-	if test x$gas = xyes
-	then
-		if test "$target_cpu_default2" = ""
+	case "$machine" in
+	alpha*-*-*)
+		if test x$gas = xyes
 		then
-			target_cpu_default2="MASK_GAS"
-		else
-			target_cpu_default2="${target_cpu_default2}|MASK_GAS"
+			if test "$target_cpu_default2" = ""
+			then
+				target_cpu_default2="MASK_GAS"
+			else
+				target_cpu_default2="${target_cpu_default2}|MASK_GAS"
+			fi
 		fi
-	fi
-	;;
-arm*-*-*)
-	case "x$with_cpu" in
-		x)
-			# The most generic
-			target_cpu_default2="TARGET_CPU_generic"
-			;;
-
+		;;
+	arm*-*-*)
+		# Start with the most generic.
+		target_cpu_default2="TARGET_CPU_generic"
 		# Distinguish cores, and major variants
 		# arm7m doesn't exist, but D & I don't affect code
+		case "x$with_cpu" in
 		xarm[236789] | xarm250 | xarm[67][01]0 \
 		| xarm7m | xarm7dm | xarm7dmi | xarm[79]tdmi \
 		| xarm7100 | xarm7500 | xarm7500fe | xarm810 \
 		| xxscale \
 		| xstrongarm | xstrongarm110 | xstrongarm1100)
-			target_cpu_default2="TARGET_CPU_$with_cpu"
+			# OK
 			;;
 
-		xyes | xno)
-			echo "--with-cpu must be passed a value" 1>&2
+		*)
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
 			exit 1
 			;;
-
-		*)
-			if test x$pass2done = xyes
+		esac
+		;;
+	hppa*-*-* | parisc*-*-*)
+		if test x$gas = xyes
+		then
+			target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
+		fi
+		case $machine in
+			hppa1* | parisc1*)
+				with_cpu=7100LC
+				;;
+		esac
+		;;
+	mips*-*-*)
+		case $machine in
+		mips*-*-ecoff* | mips*-*-elf*)
+			if test x$gas = xyes
 			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
+				if test x$gnu_ld = xyes
+				then
+					target_cpu_default2="MASK_GAS|MASK_SPLIT_ADDR"
+				else
+					target_cpu_default2="MASK_GAS"
+				fi
 			fi
 			;;
-	esac
-	;;
-
-hppa*-*-* | parisc*-*-*)
-	if test x$gas = xyes
-	then
-		target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
-	fi
-	case $machine in
-		hppa1* | parisc1*)
-			tm_defines="TARGET_SCHED_DEFAULT=\\\"7100LC\\\""
-			;;
-	esac
-	;;
-mips*-*-*)
-	case $machine in
-	mips*-*-ecoff* | mips*-*-elf*)
-		if test x$gas = xyes
-		then
-			if test x$gnu_ld = xyes
+		mips*-*-*)
+			if test x$gas = xyes
 			then
-				target_cpu_default2="MASK_GAS|MASK_SPLIT_ADDR"
-			else
 				target_cpu_default2="MASK_GAS"
 			fi
-		fi
-		;;
-	mips*-*-*)
-		if test x$gas = xyes
+			;;
+		esac
+		case $machine in
+			mips*el-*-*)
+				tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
+				;;
+		esac
+		if test "x$enable_gofast" = xyes
 		then
-			target_cpu_default2="MASK_GAS"
+			tm_defines="INIT_SUBTARGET_OPTABS=INIT_GOFAST_OPTABS $tm_defines"
+			tm_file="gofast.h $tm_file"
+			tmake_file="mips/t-gofast $tmake_file"
+		else
+			tmake_file="mips/t-mips $tmake_file"
 		fi
 		;;
-	esac
-	case $machine in
-		mips*el-*-*)
-			tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
-			;;
-	esac
-	if test "x$enable_gofast" = xyes
-	then
-		tm_defines="INIT_SUBTARGET_OPTABS=INIT_GOFAST_OPTABS $tm_defines"
-		tm_file="gofast.h $tm_file"
-		tmake_file="mips/t-gofast $tmake_file"
-	else
-		tmake_file="mips/t-mips $tmake_file"
-	fi
-	;;
-powerpc*-*-* | rs6000-*-*)
-        if test x$enable_altivec = xyes
-        then
-                tm_file="$tm_file rs6000/altivec-defs.h"
-        fi
-	case "x$with_cpu" in
+	powerpc*-*-* | rs6000-*-*)
+        	if test x$enable_altivec = xyes
+	        then
+        	        tm_file="$tm_file rs6000/altivec-defs.h"
+	        fi
+		case "x$with_cpu" in
 		x)
 			;;
 
@@ -2951,49 +2956,48 @@ powerpc*-*-* | rs6000-*-*)
 			target_cpu_default2="\\\"$with_cpu\\\""
 			;;
 
-		xyes | xno)
-			echo "--with-cpu must be passed a value" 1>&2
-			exit 1
-			;;
-
 		*)
-			if test x$pass2done = xyes
-			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
-			fi
-			;;
-	esac
-	c_target_objs="${c_target_objs} rs6000-c.o"
-	cxx_target_objs="${cxx_target_objs} rs6000-c.o"
-	tmake_file="${tmake_file} rs6000/t-rs6000-c-rule"
-	;;
-sparc*-*-*)
-	case ".$with_cpu" in
-		.)
-			target_cpu_default2=TARGET_CPU_"`echo $machine | sed 's/-.*$//'`"
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
+			exit 1
 			;;
+		esac
+		c_target_objs="${c_target_objs} rs6000-c.o"
+		cxx_target_objs="${cxx_target_objs} rs6000-c.o"
+		tmake_file="${tmake_file} rs6000/t-rs6000-c-rule"
+		;;
+	sparc*-*-*)
+		case .$with_cpu in
 		.supersparc | .hypersparc | .ultrasparc | .v7 | .v8 | .v9)
 			target_cpu_default2="TARGET_CPU_$with_cpu"
 			;;
 		*)
-			if test x$pass2done = xyes
-			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
-			fi
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
+			exit 1
 			;;
+		esac
+		;;
 	esac
-	;;
-esac
 
-if test "$target_cpu_default2" != ""
-then
-	if test "$target_cpu_default" != ""
+	t=
+	for option in cpu arch tune schedule float
+	do
+		val=`eval 'echo $with_'$option`
+		if test -n "$val"; then
+			upper=`echo $option | tr '[a-z]' '[A-Z]'`
+			option="TARGET_DEFAULT_OPTION_$upper"
+			t="${t} -D${option}=\"${val}\""
+		fi
+	done
+	target_default_options="${t}"
+
+	if test "$target_cpu_default2" != ""
 	then
-		target_cpu_default="(${target_cpu_default}|${target_cpu_default2})"
-	else
-		target_cpu_default=$target_cpu_default2
+		if test "$target_cpu_default" != ""
+		then
+			target_cpu_default="(${target_cpu_default}|${target_cpu_default2})"
+		else
+			target_cpu_default=$target_cpu_default2
+		fi
 	fi
 fi
 
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.612
diff -u -p -r1.612 configure.in
--- configure.in	29 Jul 2002 22:07:27 -0000	1.612
+++ configure.in	31 Jul 2002 19:43:40 -0000
@@ -136,6 +136,20 @@ AC_ARG_WITH(elf,
 elf="$with_elf",
 elf=no)
 
+# With a particular CPU
+AC_ARG_WITH(cpu,
+[  --with-cpu              default to -mcpu=CPU],,)
+AC_ARG_WITH(arch,
+[  --with-arch             default to -march=CPU],,)
+AC_ARG_WITH(schedule,
+[  --with-schedule         default to -mschedule=CPU],,)
+AC_ARG_WITH(tune,
+[  --with-tune             default to -mtune=CPU],,)
+
+# Default floating-point setting
+AC_ARG_WITH(float,
+[  --with-float            default to the specified type of floating point],,)
+
 # Specify the local prefix
 local_prefix=
 AC_ARG_WITH(local-prefix,
@@ -2694,6 +2708,7 @@ AC_SUBST(target_alias)
 AC_SUBST(c_target_objs)
 AC_SUBST(cxx_target_objs)
 AC_SUBST(target_cpu_default)
+AC_SUBST(target_default_options)
 
 AC_SUBST_FILE(target_overrides)
 AC_SUBST_FILE(host_overrides)
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.332
diff -u -p -r1.332 gcc.c
--- gcc.c	30 Jul 2002 20:40:14 -0000	1.332
+++ gcc.c	31 Jul 2002 19:43:45 -0000
@@ -990,6 +990,112 @@ static const struct option_map option_ma
  };
 \f
 
+static int option_present PARAMS ((int, const char *const *, const char *));
+static void add_option PARAMS ((int *, const char *const **, const char *));
+static void default_options PARAMS ((int *, const char *const **));
+
+static int
+option_present (argc, argv, option)
+     int argc;
+     const char *const *argv;
+     const char *option;
+{
+  int i;
+  int len;
+
+  len = strlen (option);
+
+  for (i = 0; i < argc; i++)
+    if (option[len - 1] == '=')
+      {
+	if (strncmp (argv[i], option, len) == 0)
+	  return 1;
+      }
+    else
+      {
+	if (strcmp (argv[i], option) == 0)
+	  return 1;
+      }
+
+  return 0;
+}
+
+static void
+add_option (argcp, argvp, option)
+     int *argcp;
+     const char *const **argvp;
+     const char *option;
+{
+  const char **newargv = (const char **) xmalloc ((*argcp + 2) * sizeof (char *));
+  int i;
+
+  newargv[0] = (*argvp)[0];
+  newargv[1] = option;
+  for (i = 1; i < *argcp; i++)
+    newargv[i + 1] = (*argvp)[i];
+  newargv[i + 1] = NULL;
+
+  *argvp = newargv;
+  (*argcp)++;
+}
+
+#ifndef TARGET_DEFAULT_ARCH_P
+#define TARGET_DEFAULT_ARCH_P() (! option_present (*argcp, *argvp, "-march="))
+#endif
+
+#ifndef TARGET_DEFAULT_CPU_P
+#define TARGET_DEFAULT_CPU_P() (! option_present (*argcp, *argvp, "-mcpu="))
+#endif
+
+#ifndef TARGET_DEFAULT_SCHEDULE_P
+#define TARGET_DEFAULT_SCHEDULE_P() (! option_present (*argcp, *argvp, \
+						       "-mschedule="))
+#endif
+
+#ifndef TARGET_DEFAULT_TUNE_P
+#define TARGET_DEFAULT_TUNE_P() (! option_present (*argcp, *argvp, "-mtune="))
+#endif
+
+#ifndef TARGET_DEFAULT_FLOAT_P
+#define TARGET_DEFAULT_FLOAT_P() (! option_present (*argcp, *argvp, \
+						    "-msoft-float") \
+				  && ! option_present (*argcp, *argvp, \
+						       "-mhard-float"))
+#endif
+
+static void
+default_options (argcp, argvp)
+     int *argcp ATTRIBUTE_UNUSED;
+     const char *const **argvp ATTRIBUTE_UNUSED;
+{
+#ifdef TARGET_DEFAULT_OPTION_ARCH
+  if (TARGET_DEFAULT_ARCH_P ())
+    add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_CPU
+  if (TARGET_DEFAULT_CPU_P ())
+    add_option (argcp, argvp, "-mcpu=" XSTRING (TARGET_DEFAULT_OPTION_CPU));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_SCHEDULE
+  if (TARGET_DEFAULT_SCHEDULE_P ())
+    add_option (argcp, argvp,
+		"-mschedule=" XSTRING (TARGET_DEFAULT_OPTION_SCHEDULE));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_TUNE
+  if (TARGET_DEFAULT_TUNE_P ())
+    add_option (argcp, argvp, "-mtune=" XSTRING (TARGET_DEFAULT_OPTION_TUNE));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_FLOAT
+  if (TARGET_DEFAULT_FLOAT_P ())
+    add_option (argcp, argvp, "-m" XSTRING (TARGET_DEFAULT_OPTION_FLOAT) "-float");
+#endif
+}
+\f
+
 #ifdef TARGET_OPTION_TRANSLATE_TABLE
 static const struct {
   const char *const option_found;
@@ -3374,6 +3480,9 @@ process_command (argc, argv)
 
   /* Convert new-style -- options to old-style.  */
   translate_options (&argc, &argv);
+
+  /* Add any default options.  */
+  default_options (&argc, &argv);
 
   /* Do language-specific adjustment/addition of flags.  */
   lang_specific_driver (&argc, &argv, &added_libraries);
Index: config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.206
diff -u -p -r1.206 mips.h
--- config/mips/mips.h	31 Jul 2002 02:13:31 -0000	1.206
+++ config/mips/mips.h	31 Jul 2002 19:43:52 -0000
@@ -737,6 +737,20 @@ extern void		sbss_section PARAMS ((void)
       N_("Specify cache flush function")},				\
 }
 
+/* This is not quite correct, because -mips16 will override a default
+   architecture.  This is an unfortunate consequence of -mips16 being
+   completely orthogonal to the other -mipsN switches, yet sometimes
+   overriding them on the command line.  */
+#define TARGET_DEFAULT_ARCH_P() \
+  (! option_present (*argcp, *argvp, "-march=") \
+   && (! option_present (*argcp, *argvp, "-mips") \
+       || option_present (*argcp, *argvp, "-mips16")))
+
+#define TARGET_DEFAULT_FLOAT_P() \
+  (! option_present (*argcp, *argvp, "-msoft-float") \
+   && ! option_present (*argcp, *argvp, "-mhard-float") \
+   && ! option_present (*argcp, *argvp, "-msingle-float"))
+
 /* This is meant to be redefined in the host dependent files.  */
 #define SUBTARGET_TARGET_OPTIONS
 
Index: doc/install.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/install.texi,v
retrieving revision 1.128
diff -u -p -r1.128 install.texi
--- doc/install.texi	30 Jun 2002 19:27:48 -0000	1.128
+++ doc/install.texi	31 Jul 2002 19:43:58 -0000
@@ -671,11 +671,24 @@ Microsoft Win32 API thread support.
 
 @item --with-cpu=@var{cpu}
 Specify which cpu variant the
-compiler should generate code for by default.  This is currently
-only supported on the some ports, specifically arm, powerpc, and
-SPARC@.  If configure does not recognize the model name (e.g.@: arm700,
-603e, or ultrasparc) you provide, please check the configure script
-for a complete list of supported models.
+compiler should generate code for by default.  @var{cpu}
+will be used as the default value of the @code{-mcpu=} switch.
+This option is only supported on some ports, including arm, i386, powerpc,
+and SPARC@.
+
+@item --with-schedule=@var{cpu}
+@itemx --with-arch=@var{cpu}
+@itemx --with-tune=@var{cpu}
+These configure options provide default values for the @code{-mschedule=},
+@code{-march=}, and @code{-mtune=} options, respectively.  As with
+@code{--with-cpu} the legal values of @var{CPU} depend on the port; these
+options are not valid for all ports, only those which accept the respective
+options.
+
+@item --with-float=@var{type}
+Specify the default form of floating point.  The normal choices are ``hard''
+and ``soft''.  Which (if any) choices are recognized depends on the port;
+for instance, MIPS also recognizes ``single''.
 
 @item --enable-altivec
 Specify that the target supports AltiVec vector enhancements.  This

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

* Re: RFC: New approach to --with-cpu
  2002-07-31 13:27             ` Daniel Jacobowitz
@ 2002-08-01  3:31               ` Richard Sandiford
  2002-08-01  3:57                 ` Richard Earnshaw
  2002-08-01  8:15               ` John David Anglin
  1 sibling, 1 reply; 26+ messages in thread
From: Richard Sandiford @ 2002-08-01  3:31 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: John David Anglin, Richard.Earnshaw, gcc-patches

Daniel Jacobowitz <drow@mvista.com> writes:
> +#ifdef TARGET_DEFAULT_OPTION_CPU
> +  if (TARGET_DEFAULT_CPU_P ())
> +    add_option (argcp, argvp, "-mcpu=" XSTRING (TARGET_DEFAULT_OPTION_CPU));
> +#endif

Sorry, didn't notice first time.  Is it OK to use string
concatenation in gcc.c?

Richard

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

* Re: RFC: New approach to --with-cpu
  2002-08-01  3:31               ` Richard Sandiford
@ 2002-08-01  3:57                 ` Richard Earnshaw
  0 siblings, 0 replies; 26+ messages in thread
From: Richard Earnshaw @ 2002-08-01  3:57 UTC (permalink / raw)
  To: Richard Sandiford
  Cc: Daniel Jacobowitz, John David Anglin, Richard.Earnshaw, gcc-patches

> Daniel Jacobowitz <drow@mvista.com> writes:
> > +#ifdef TARGET_DEFAULT_OPTION_CPU
> > +  if (TARGET_DEFAULT_CPU_P ())
> > +    add_option (argcp, argvp, "-mcpu=" XSTRING (TARGET_DEFAULT_OPTION_CPU));
> > +#endif
> 
> Sorry, didn't notice first time.  Is it OK to use string
> concatenation in gcc.c?

No, I don't think so. It isn't available (that way) in K+R C.

R.

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

* Re: RFC: New approach to --with-cpu
  2002-07-31 10:34           ` John David Anglin
  2002-07-31 13:27             ` Daniel Jacobowitz
@ 2002-08-01  6:30             ` Richard Earnshaw
  2002-08-01  7:41               ` John David Anglin
  1 sibling, 1 reply; 26+ messages in thread
From: Richard Earnshaw @ 2002-08-01  6:30 UTC (permalink / raw)
  To: John David Anglin; +Cc: Daniel Jacobowitz, Richard.Earnshaw, gcc-patches


> My preference would be to leave things as they are and use --with-schedule.
> -mschedule relates directly to the scheduling model.  The option value is PA
> specific anyway.  We also have a whole bunch of other oddball -m options
> which affect bits in the target flags.

But why would a *user* of the compiler want to use a different set of 
'cost' metrics in another part of the compiler from the 'cost' metrics 
used by the scheduler?

R.

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

* Re: RFC: New approach to --with-cpu
  2002-08-01  6:30             ` Richard Earnshaw
@ 2002-08-01  7:41               ` John David Anglin
  0 siblings, 0 replies; 26+ messages in thread
From: John David Anglin @ 2002-08-01  7:41 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: drow, gcc-patches

> But why would a *user* of the compiler want to use a different set of 
> 'cost' metrics in another part of the compiler from the 'cost' metrics 
> used by the scheduler?

The scheduler supports generation of code using several different
scheduling models.  This allows testing of the models without having
to have a different compiler for each.  Where binaries are being
distributed, the compiler may be running on the latest PA gizmo
but a more portable arch and scheduling model may be desired for
the code being distributed.

The HP ansi compiler supports options to select the target architecture,
data model, apptype, OS, and scheduler model (tuning).

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: RFC: New approach to --with-cpu
  2002-07-31 13:27             ` Daniel Jacobowitz
  2002-08-01  3:31               ` Richard Sandiford
@ 2002-08-01  8:15               ` John David Anglin
  2002-08-01  8:23                 ` Daniel Jacobowitz
  1 sibling, 1 reply; 26+ messages in thread
From: John David Anglin @ 2002-08-01  8:15 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Richard.Earnshaw, gcc-patches

> +	hppa*-*-* | parisc*-*-*)
> +		if test x$gas = xyes
> +		then
> +			target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
> +		fi
> +		case $machine in
> +			hppa1* | parisc1*)
> +				with_cpu=7100LC
                                ^^^^^^^^

I believe that this should be "with_schedule".  I was also wondering
if a comment should be added to indicate that the default scheduling
model is "8000".

I am going to give the patch a try.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: RFC: New approach to --with-cpu
  2002-08-01  8:15               ` John David Anglin
@ 2002-08-01  8:23                 ` Daniel Jacobowitz
  2002-08-01 11:40                   ` John David Anglin
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-08-01  8:23 UTC (permalink / raw)
  To: John David Anglin; +Cc: Richard.Earnshaw, gcc-patches

On Thu, Aug 01, 2002 at 11:15:10AM -0400, John David Anglin wrote:
> > +	hppa*-*-* | parisc*-*-*)
> > +		if test x$gas = xyes
> > +		then
> > +			target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
> > +		fi
> > +		case $machine in
> > +			hppa1* | parisc1*)
> > +				with_cpu=7100LC
>                                 ^^^^^^^^
> 
> I believe that this should be "with_schedule".  I was also wondering
> if a comment should be added to indicate that the default scheduling
> model is "8000".

And you're completely correct on both counts.  I've added that to my
working copy.

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

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

* Re: RFC: New approach to --with-cpu
  2002-08-01  8:23                 ` Daniel Jacobowitz
@ 2002-08-01 11:40                   ` John David Anglin
  0 siblings, 0 replies; 26+ messages in thread
From: John David Anglin @ 2002-08-01 11:40 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Richard.Earnshaw, gcc-patches

> On Thu, Aug 01, 2002 at 11:15:10AM -0400, John David Anglin wrote:
> > > +	hppa*-*-* | parisc*-*-*)
> > > +		if test x$gas = xyes
> > > +		then
> > > +			target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
> > > +		fi
> > > +		case $machine in
> > > +			hppa1* | parisc1*)
> > > +				with_cpu=7100LC
> >                                 ^^^^^^^^
> > 
> > I believe that this should be "with_schedule".  I was also wondering
> > if a comment should be added to indicate that the default scheduling
> > model is "8000".
> 
> And you're completely correct on both counts.  I've added that to my
> working copy.

I enclose below an update to above code.  I have attempted to
bullet proof it so that it handles error conditions gracefully
and only overrides the PA8000 default based on the target
cpu when the user doesn't specify --with-schedule.

I have run through partial builds checking most of the option
permutations and the patch seems to be working well.  I like
the ease with which the scheduling model can now be specified.

The only additional wish is for an easy way to print the target
defaults.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

--- config.gcc.orig	2002-08-01 09:36:20.000000000 -0700
+++ config.gcc	2002-08-01 11:19:24.000000000 -0700
@@ -2908,9 +2908,21 @@
 		then
 			target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
 		fi
-		case $machine in
-			hppa1* | parisc1*)
-				with_cpu=7100LC
+		case ".$with_schedule" in
+			.700 | .7100 | .7100LC | .7200 | .7300 | .8000)
+				;;
+			.)
+				case $machine in
+					hppa1* | parisc1*)
+						# Override default PA8000
+						# scheduling model.
+						with_schedule=7100LC
+						;;
+				esac
+				;;
+			*)
+				echo "Unknown cpu used with --with-schedule=$with_schedule" 1>&2
+				exit 1
 				;;
 		esac
 		;;

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

* Re: RFC: New approach to --with-cpu
  2002-08-01  6:04 ` Richard Earnshaw
@ 2002-08-01  6:25   ` Daniel Jacobowitz
  0 siblings, 0 replies; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-08-01  6:25 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: Richard Sandiford, John David Anglin, gcc-patches

On Thu, Aug 01, 2002 at 02:03:26PM +0100, Richard Earnshaw wrote:
> > On Thu, Aug 01, 2002 at 11:56:17AM +0100, Richard Earnshaw wrote:
> > > > Daniel Jacobowitz <drow@mvista.com> writes:
> > > > > +#ifdef TARGET_DEFAULT_OPTION_CPU
> > > > > +  if (TARGET_DEFAULT_CPU_P ())
> > > > > +    add_option (argcp, argvp, "-mcpu=" XSTRING (TARGET_DEFAULT_OPTION_CPU));
> > > > > +#endif
> > > > 
> > > > Sorry, didn't notice first time.  Is it OK to use string
> > > > concatenation in gcc.c?
> > > 
> > > No, I don't think so. It isn't available (that way) in K+R C.
> > 
> > You're right, I should be using concat().  Before I fix that, does
> > anyone know whether XSTRING() works in K&R C, or whether I need to do
> > this with some extra quoting from configure?
> 
> I would have said that XSTRING was OK.  It would be a rather perverse K+R 
> compiler that didn't support either
> 
> #define STRINGX(s) "s"
> or 
> #define STRINGX(s) #s
> 
> to get stringification.

I know that STRINGX works; I'm just not sure how K&R compilers handle
the extra level of indirection in XSTRING.  Don't have one to test
with, and README.Portability is silent.

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

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

* Re: RFC: New approach to --with-cpu
       [not found] <20020801125224.GA5374@nevyn.them.org>
@ 2002-08-01  6:04 ` Richard Earnshaw
  2002-08-01  6:25   ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Earnshaw @ 2002-08-01  6:04 UTC (permalink / raw)
  To: Daniel Jacobowitz
  Cc: Richard.Earnshaw, Richard Sandiford, John David Anglin, gcc-patches

> On Thu, Aug 01, 2002 at 11:56:17AM +0100, Richard Earnshaw wrote:
> > > Daniel Jacobowitz <drow@mvista.com> writes:
> > > > +#ifdef TARGET_DEFAULT_OPTION_CPU
> > > > +  if (TARGET_DEFAULT_CPU_P ())
> > > > +    add_option (argcp, argvp, "-mcpu=" XSTRING (TARGET_DEFAULT_OPTION_CPU));
> > > > +#endif
> > > 
> > > Sorry, didn't notice first time.  Is it OK to use string
> > > concatenation in gcc.c?
> > 
> > No, I don't think so. It isn't available (that way) in K+R C.
> 
> You're right, I should be using concat().  Before I fix that, does
> anyone know whether XSTRING() works in K&R C, or whether I need to do
> this with some extra quoting from configure?

I would have said that XSTRING was OK.  It would be a rather perverse K+R 
compiler that didn't support either

#define STRINGX(s) "s"
or 
#define STRINGX(s) #s

to get stringification.

R.

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  7:50             ` Richard Sandiford
@ 2002-07-31  8:04               ` Daniel Jacobowitz
  0 siblings, 0 replies; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-31  8:04 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches, echristo

On Wed, Jul 31, 2002 at 03:45:52PM +0100, Richard Sandiford wrote:
> Daniel Jacobowitz <drow@mvista.com> writes:
> > Well, the best I can do given the -mipsN situation... how does this
> > revision look to you?
> 
> The new macro looks good.  I still think there should be some -mips16
> exemption, though.  Specifying -mips16 and some other -mipsN option
> isn't supported, so if -mips16 does occur on the command line, I think
> we should assume the user wants the default architecture.

That sounds reasonable, I've updated my copy:
#define TARGET_HANDLE_DEFAULT_CPU(CPU) do { \
  if (! option_present (*argcp, *argvp, "-march=") \
      && (! option_present (*argcp, *argvp, "-mips") \   
          || option_present (*argcp, *argvp, "-mips16"))) \
    add_option (argcp, argvp, "-march=" XSTRING (CPU)); \
  if (! option_present (*argcp, *argvp, "-mtune=")) \
    add_option (argcp, argvp, "-mtune=" XSTRING (CPU)); \
} while (0)
  


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

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  7:46           ` Daniel Jacobowitz
@ 2002-07-31  7:50             ` Richard Sandiford
  2002-07-31  8:04               ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Sandiford @ 2002-07-31  7:50 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gcc-patches, echristo

Daniel Jacobowitz <drow@mvista.com> writes:
> Well, the best I can do given the -mipsN situation... how does this
> revision look to you?

The new macro looks good.  I still think there should be some -mips16
exemption, though.  Specifying -mips16 and some other -mipsN option
isn't supported, so if -mips16 does occur on the command line, I think
we should assume the user wants the default architecture.

Richard

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  7:36         ` Richard Sandiford
@ 2002-07-31  7:46           ` Daniel Jacobowitz
  2002-07-31  7:50             ` Richard Sandiford
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-31  7:46 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches, echristo

On Wed, Jul 31, 2002 at 02:54:07PM +0100, Richard Sandiford wrote:
> Daniel Jacobowitz <drow@mvista.com> writes:
> > if the user configures --with-cpu=<blah>, and then runs the compiler
> > with -mips3, what _should_ happen and what _will_ happen?  The result
> > will be both -march= and -mips3 being specified on the command line;
> > will the -mips3 be ignored or have some effect?
> 
> Well, -march overrides -mipsN (N != 16).  gcc will accept -mipsN
> alongside a MIPS N -march (e.g. -march=r4000 -mips3) otherwise you'll
> get an error.
> 
> I guess what should happen depends on what you want --with-cpu to mean.
> If it gives a default argument for -march, then the original patch is
> OK, and an incompatible -mipsN would be an error.  If (more generally)
> you want --with-cpu to specify a default architecture, then I guess
> -mips3 should override the default.

Well, the best I can do given the -mipsN situation... how does this
revision look to you?  Configure only sets TARGET_DEFAULT_OPTION_CPU,
and the backend can do with it as it pleases.

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

2002-07-31  Daniel Jacobowitz  <drow@mvista.com>

	* Makefile.in (DRIVER_DEFINES): Add @target_default_options@
	* configure.in: Add @target_default_options@.  Document --with-cpu
	and --with-float.
	* config.gcc: Reorganize $with_cpu logic.  Set
	target_default_options according to the default CPU, $with_cpu,
	and $with_float.
	* config/mips/mips.h (TARGET_HANDLE_DEFAULT_CPU)
	(TARGET_HANDLE_DEFAULT_FLOAT): New macros.
	* config/pa/pa.h (TARGET_HANDLE_DEFAULT_CPU): New macro.
	* gcc.c (default_options, add_option, option_present): New
	functions.
	(process_command): Call default_options.
	* doc/install.texi: Update --with-cpu documentation.  Mention
	--with-float.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.919
diff -u -p -r1.919 Makefile.in
--- Makefile.in	29 Jul 2002 19:31:23 -0000	1.919
+++ Makefile.in	31 Jul 2002 14:32:04 -0000
@@ -1251,6 +1251,7 @@ c-dump.o : c-dump.c $(CONFIG_H) $(SYSTEM
 # Language-independent files.
 
 DRIVER_DEFINES = \
+  @target_default_options@ \
   -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc-lib/\" \
   -DDEFAULT_TARGET_VERSION=\"$(version)\" \
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.229
diff -u -p -r1.229 config.gcc
--- config.gcc	29 Jul 2002 22:21:40 -0000	1.229
+++ config.gcc	31 Jul 2002 14:32:06 -0000
@@ -2770,173 +2770,178 @@ case $machine in
 	;;
 esac
 
-# Distinguish i[34567]86
-# Also, do not run mips-tfile on MIPS if using gas.
-# Process --with-cpu= for PowerPC/rs6000
-target_cpu_default2=
-case $machine in
-i486-*-*)
-	target_cpu_default2=TARGET_CPU_DEFAULT_i486
-	;;
-i586-*-*)
-	case $target_alias in
-		k6_2-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6_2
-			;;
-		k6_3-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6_3
-			;;
-		k6-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6
-			;;
-		pentium_mmx-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium_mmx
-			;;
-		*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium
-			;;
-	esac
-	;;
-i686-*-* | i786-*-*)
-	case $target_alias in
-		athlon_xp-*|athlon_mp-*|athlon_4-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
-			;;
-		athlon_tbird-*|athlon-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_athlon
-			;;
-		pentium2-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium2
-			;;
-		pentium3-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium3
-			;;
-		pentium4-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium4
-			;;
-		*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentiumpro
+if test x$pass2done = xyes
+then
+	case "x$with_cpu" in
+		xyes | xno)
+			echo "--with-cpu must be passed a value" 1>&2
+			exit 1
 			;;
 	esac
-	;;
-x86_64-*-*)
-	# We should have hammer chip here, but it does not exist yet and
-	# thus it is not supported.  Athlon_SSE is probably equivalent feature
-	# wise to hammer from our point of view except for 64bit mode.
-	target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
-	;;
-alpha*-*-*)
-	case $machine in
-		alphaev6[78]*)
-			target_cpu_default2="MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX|MASK_CIX"
-			;;
-		alphaev6*)
-			target_cpu_default2="MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX"
-			;;
-		alphapca56*)
-			target_cpu_default2="MASK_CPU_EV5|MASK_BWX|MASK_MAX"
-			;;
-		alphaev56*)
-			target_cpu_default2="MASK_CPU_EV5|MASK_BWX"
+
+	# If there is no $with_cpu option, try to infer one from ${machine}.
+	if test x$with_cpu = x
+	then
+		case $machine in
+		i486-*-*)
+			with_cpu=i486
+			;;
+		i586-*-*)
+			case $target_alias in
+			k6_2-*)
+				with_cpu=k6-2
+				;;
+			k6_3-*)
+				with_cpu=k6-3
+				;;
+			k6-*)
+				with_cpu=k6
+				;;
+			pentium_mmx-*)
+				with_cpu=pentium-mmx
+				;;
+			*)
+				with_cpu=pentium
+				;;
+			esac
+			;;
+		i686-*-* | i786-*-*)
+			case $target_alias in
+			athlon_xp-*|athlon_mp-*|athlon_4-*)
+				with_cpu=athlon-4
+				;;
+			athlon_tbird-*|athlon-*)
+				with_cpu=athlon
+				;;
+			pentium2-*)
+				with_cpu=pentium2
+				;;
+			pentium3-*)
+				with_cpu=pentium3
+				;;
+			pentium4-*)
+				with_cpu=pentium4
+				;;
+			*)
+				with_cpu=pentiumpro
+				;;
+			esac
+			;;
+		x86_64-*-*)
+			# We should have hammer chip here, but it does not
+			# exist yet and thus it is not supported.  Athlon_SSE
+			# is probably equivalent feature wise to hammer from
+			# our point of view except for 64bit mode.
+			with_cpu=athlon-sse
+			;;
+		alpha*-*-*)
+			case $machine in
+			alphaev6[78]*)
+				with_cpu=ev67
+				;;
+			alphaev6*)
+				with_cpu=ev6
+				;;
+			alphapca56*)
+				with_cpu=pca56
+				;;
+			alphaev56*)
+				with_cpu=ev56
+				;;
+			alphaev5*)
+				with_cpu=ev5
+				;;
+			esac
 			;;
-		alphaev5*)
-			target_cpu_default2="MASK_CPU_EV5"
+		sparc*-*-*)
+			with_cpu="`echo $machine | sed 's/-.*$//'`"
 			;;
-	esac
+		esac
+	fi
 
-	if test x$gas = xyes
-	then
-		if test "$target_cpu_default2" = ""
+	case "$machine" in
+	alpha*-*-*)
+		if test x$gas = xyes
 		then
-			target_cpu_default2="MASK_GAS"
-		else
-			target_cpu_default2="${target_cpu_default2}|MASK_GAS"
+			if test "$target_cpu_default2" = ""
+			then
+				target_cpu_default2="MASK_GAS"
+			else
+				target_cpu_default2="${target_cpu_default2}|MASK_GAS"
+			fi
 		fi
-	fi
-	;;
-arm*-*-*)
-	case "x$with_cpu" in
-		x)
-			# The most generic
-			target_cpu_default2="TARGET_CPU_generic"
-			;;
-
+		;;
+	arm*-*-*)
+		# Start with the most generic.
+		target_cpu_default2="TARGET_CPU_generic"
 		# Distinguish cores, and major variants
 		# arm7m doesn't exist, but D & I don't affect code
+		case "x$with_cpu" in
 		xarm[236789] | xarm250 | xarm[67][01]0 \
 		| xarm7m | xarm7dm | xarm7dmi | xarm[79]tdmi \
 		| xarm7100 | xarm7500 | xarm7500fe | xarm810 \
 		| xxscale \
 		| xstrongarm | xstrongarm110 | xstrongarm1100)
-			target_cpu_default2="TARGET_CPU_$with_cpu"
+			# OK
 			;;
 
-		xyes | xno)
-			echo "--with-cpu must be passed a value" 1>&2
+		*)
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
 			exit 1
 			;;
-
-		*)
-			if test x$pass2done = xyes
+		esac
+		;;
+	hppa*-*-* | parisc*-*-*)
+		if test x$gas = xyes
+		then
+			target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
+		fi
+		case $machine in
+			hppa1* | parisc1*)
+				with_cpu=7100LC
+				;;
+		esac
+		;;
+	mips*-*-*)
+		case $machine in
+		mips*-*-ecoff* | mips*-*-elf*)
+			if test x$gas = xyes
 			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
+				if test x$gnu_ld = xyes
+				then
+					target_cpu_default2="MASK_GAS|MASK_SPLIT_ADDR"
+				else
+					target_cpu_default2="MASK_GAS"
+				fi
 			fi
 			;;
-	esac
-	;;
-
-hppa*-*-* | parisc*-*-*)
-	if test x$gas = xyes
-	then
-		target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
-	fi
-	case $machine in
-		hppa1* | parisc1*)
-			tm_defines="TARGET_SCHED_DEFAULT=\\\"7100LC\\\""
-			;;
-	esac
-	;;
-mips*-*-*)
-	case $machine in
-	mips*-*-ecoff* | mips*-*-elf*)
-		if test x$gas = xyes
-		then
-			if test x$gnu_ld = xyes
+		mips*-*-*)
+			if test x$gas = xyes
 			then
-				target_cpu_default2="MASK_GAS|MASK_SPLIT_ADDR"
-			else
 				target_cpu_default2="MASK_GAS"
 			fi
-		fi
-		;;
-	mips*-*-*)
-		if test x$gas = xyes
+			;;
+		esac
+		case $machine in
+			mips*el-*-*)
+				tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
+				;;
+		esac
+		if test "x$enable_gofast" = xyes
 		then
-			target_cpu_default2="MASK_GAS"
+			tm_defines="INIT_SUBTARGET_OPTABS=INIT_GOFAST_OPTABS $tm_defines"
+			tm_file="gofast.h $tm_file"
+			tmake_file="mips/t-gofast $tmake_file"
+		else
+			tmake_file="mips/t-mips $tmake_file"
 		fi
 		;;
-	esac
-	case $machine in
-		mips*el-*-*)
-			tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
-			;;
-	esac
-	if test "x$enable_gofast" = xyes
-	then
-		tm_defines="INIT_SUBTARGET_OPTABS=INIT_GOFAST_OPTABS $tm_defines"
-		tm_file="gofast.h $tm_file"
-		tmake_file="mips/t-gofast $tmake_file"
-	else
-		tmake_file="mips/t-mips $tmake_file"
-	fi
-	;;
-powerpc*-*-* | rs6000-*-*)
-        if test x$enable_altivec = xyes
-        then
-                tm_file="$tm_file rs6000/altivec-defs.h"
-        fi
-	case "x$with_cpu" in
+	powerpc*-*-* | rs6000-*-*)
+        	if test x$enable_altivec = xyes
+	        then
+        	        tm_file="$tm_file rs6000/altivec-defs.h"
+	        fi
+		case "x$with_cpu" in
 		x)
 			;;
 
@@ -2951,49 +2956,46 @@ powerpc*-*-* | rs6000-*-*)
 			target_cpu_default2="\\\"$with_cpu\\\""
 			;;
 
-		xyes | xno)
-			echo "--with-cpu must be passed a value" 1>&2
-			exit 1
-			;;
-
 		*)
-			if test x$pass2done = xyes
-			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
-			fi
-			;;
-	esac
-	c_target_objs="${c_target_objs} rs6000-c.o"
-	cxx_target_objs="${cxx_target_objs} rs6000-c.o"
-	tmake_file="${tmake_file} rs6000/t-rs6000-c-rule"
-	;;
-sparc*-*-*)
-	case ".$with_cpu" in
-		.)
-			target_cpu_default2=TARGET_CPU_"`echo $machine | sed 's/-.*$//'`"
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
+			exit 1
 			;;
+		esac
+		c_target_objs="${c_target_objs} rs6000-c.o"
+		cxx_target_objs="${cxx_target_objs} rs6000-c.o"
+		tmake_file="${tmake_file} rs6000/t-rs6000-c-rule"
+		;;
+	sparc*-*-*)
+		case .$with_cpu in
 		.supersparc | .hypersparc | .ultrasparc | .v7 | .v8 | .v9)
 			target_cpu_default2="TARGET_CPU_$with_cpu"
 			;;
 		*)
-			if test x$pass2done = xyes
-			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
-			fi
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
+			exit 1
 			;;
+		esac
+		;;
 	esac
-	;;
-esac
 
-if test "$target_cpu_default2" != ""
-then
-	if test "$target_cpu_default" != ""
+	if test x$with_cpu != x
+	then
+		target_default_options="-DTARGET_DEFAULT_OPTION_CPU=$with_cpu"
+	fi
+
+	if test -n "$with_float"
 	then
-		target_cpu_default="(${target_cpu_default}|${target_cpu_default2})"
-	else
-		target_cpu_default=$target_cpu_default2
+		target_default_options="${target_default_options} -DTARGET_DEFAULT_OPTION_FLOAT=\"$with_float\""
+	fi
+
+	if test "$target_cpu_default2" != ""
+	then
+		if test "$target_cpu_default" != ""
+		then
+			target_cpu_default="(${target_cpu_default}|${target_cpu_default2})"
+		else
+			target_cpu_default=$target_cpu_default2
+		fi
 	fi
 fi
 
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.612
diff -u -p -r1.612 configure.in
--- configure.in	29 Jul 2002 22:07:27 -0000	1.612
+++ configure.in	31 Jul 2002 14:32:15 -0000
@@ -136,6 +136,14 @@ AC_ARG_WITH(elf,
 elf="$with_elf",
 elf=no)
 
+# With a particular CPU
+AC_ARG_WITH(cpu,
+[  --with-cpu              default to the specified CPU],,)
+
+# Default floating-point setting
+AC_ARG_WITH(float,
+[  --with-float            default to the specified type of floating point],,)
+
 # Specify the local prefix
 local_prefix=
 AC_ARG_WITH(local-prefix,
@@ -2694,6 +2702,7 @@ AC_SUBST(target_alias)
 AC_SUBST(c_target_objs)
 AC_SUBST(cxx_target_objs)
 AC_SUBST(target_cpu_default)
+AC_SUBST(target_default_options)
 
 AC_SUBST_FILE(target_overrides)
 AC_SUBST_FILE(host_overrides)
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.331
diff -u -p -r1.331 gcc.c
--- gcc.c	25 Jul 2002 18:48:42 -0000	1.331
+++ gcc.c	31 Jul 2002 14:32:21 -0000
@@ -990,6 +990,82 @@ static const struct option_map option_ma
  };
 \f
 
+static int option_present PARAMS ((int, const char *const *, const char *));
+static void add_option PARAMS ((int *, const char *const **, const char *));
+static void default_options PARAMS ((int *, const char *const **));
+
+static int
+option_present (argc, argv, option)
+     int argc;
+     const char *const *argv;
+     const char *option;
+{
+  int i;
+  int len;
+
+  len = strlen (option);
+
+  for (i = 0; i < argc; i++)
+    if (option[len - 1] == '=')
+      {
+	if (strncmp (argv[i], option, len) == 0)
+	  return 1;
+      }
+    else
+      {
+	if (strcmp (argv[i], option) == 0)
+	  return 1;
+      }
+
+  return 0;
+}
+
+static void
+add_option (argcp, argvp, option)
+     int *argcp;
+     const char *const **argvp;
+     const char *option;
+{
+  const char **newargv = (const char **) xmalloc ((*argcp + 2) * sizeof (char *));
+  int i;
+
+  newargv[0] = (*argvp)[0];
+  newargv[1] = option;
+  for (i = 1; i < *argcp; i++)
+    newargv[i + 1] = (*argvp)[i];
+  newargv[i + 1] = NULL;
+
+  *argvp = newargv;
+  (*argcp)++;
+}
+
+static void
+default_options (argcp, argvp)
+     int *argcp ATTRIBUTE_UNUSED;
+     const char *const **argvp ATTRIBUTE_UNUSED;
+{
+#ifdef TARGET_DEFAULT_OPTION_CPU
+# ifdef TARGET_HANDLE_DEFAULT_CPU
+  TARGET_HANDLE_DEFAULT_CPU (TARGET_DEFAULT_OPTION_CPU);
+# else
+  if (! option_present (*argcp, *argvp, "-mcpu="))
+    add_option (argcp, argvp, "-mcpu=" XSTRING (TARGET_DEFAULT_OPTION_CPU));
+# endif
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_FLOAT
+# ifdef TARGET_HANDLE_DEFAULT_CPU
+  TARGET_HANDLE_DEFAULT_FLOAT (TARGET_DEFAULT_OPTION_FLOAT);
+# else
+  /* Add other mutually exclusive floating point options as necessary.  */
+  if (! option_present (*argcp, *argvp, "-msoft-float")
+      && ! option_present (*argcp, *argvp, "-mhard-float"))
+    add_option (argcp, argvp, "-m" XSTRING (TARGET_DEFAULT_OPTION_FLOAT) "-float");
+# endif
+#endif
+}
+\f
+
 #ifdef TARGET_OPTION_TRANSLATE_TABLE
 static const struct {
   const char *const option_found;
@@ -3374,6 +3450,9 @@ process_command (argc, argv)
 
   /* Convert new-style -- options to old-style.  */
   translate_options (&argc, &argv);
+
+  /* Add any default options.  */
+  default_options (&argc, &argv);
 
   /* Do language-specific adjustment/addition of flags.  */
   lang_specific_driver (&argc, &argv, &added_libraries);
Index: config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.205
diff -u -p -r1.205 mips.h
--- config/mips/mips.h	30 Jul 2002 19:08:23 -0000	1.205
+++ config/mips/mips.h	31 Jul 2002 14:32:37 -0000
@@ -737,6 +737,25 @@ extern void		sbss_section PARAMS ((void)
       N_("Specify cache flush function")},				\
 }
 
+/* This is not quite correct, because -mips16 will override a default
+   architecture.  This is an unfortunate consequence of -mips16 being
+   completely orthogonal to the other -mipsN switches, yet sometimes
+   overriding them on the command line.  */
+#define TARGET_HANDLE_DEFAULT_CPU(CPU) do { \
+  if (! option_present (*argcp, *argvp, "-march=") \
+      && ! option_present (*argcp, *argvp, "-mips")) \
+    add_option (argcp, argvp, "-march=" XSTRING (CPU)); \
+  if (! option_present (*argcp, *argvp, "-mtune=")) \
+    add_option (argcp, argvp, "-mtune=" XSTRING (CPU)); \
+} while (0)
+  
+#define TARGET_HANDLE_DEFAULT_FLOAT(FLOAT) do { \
+  if (! option_present (*argcp, *argvp, "-msoft-float") \
+      && ! option_present (*argcp, *argvp, "-mhard-float") \
+      && ! option_present (*argcp, *argvp, "-msingle-float")) \
+    add_option (argcp, argvp, "-m" XSTRING (FLOAT) "-float"); \
+} while (0)  
+
 /* This is meant to be redefined in the host dependent files.  */
 #define SUBTARGET_TARGET_OPTIONS
 
Index: config/pa/pa.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.h,v
retrieving revision 1.165
diff -u -p -r1.165 pa.h
--- config/pa/pa.h	18 Jul 2002 18:18:26 -0000	1.165
+++ config/pa/pa.h	31 Jul 2002 14:32:39 -0000
@@ -218,6 +218,11 @@ extern int target_flags;
   { "arch=",		&pa_arch_string, "Specify architecture for code generation.  Values are 1.0, 1.1, and 2.0.  2.0 requires gas snapshot 19990413 or later." }\
 }
 
+#define TARGET_HANDLE_DEFAULT_CPU(CPU) do { \
+  if (! option_present (*argcp, *argvp, "-mschedule=")) \
+    add_option (argcp, argvp, "-mschedule=" XSTRING (CPU)); \
+} while (0)
+
 /* Specify the dialect of assembler to use.  New mnemonics is dialect one
    and the old mnemonics are dialect zero.  */
 #define ASSEMBLER_DIALECT (TARGET_PA_20 ? 1 : 0)
Index: doc/install.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/install.texi,v
retrieving revision 1.128
diff -u -p -r1.128 install.texi
--- doc/install.texi	30 Jun 2002 19:27:48 -0000	1.128
+++ doc/install.texi	31 Jul 2002 14:32:42 -0000
@@ -672,10 +672,15 @@ Microsoft Win32 API thread support.
 @item --with-cpu=@var{cpu}
 Specify which cpu variant the
 compiler should generate code for by default.  This is currently
-only supported on the some ports, specifically arm, powerpc, and
+only supported on some ports, including arm, i386, powerpc, MIPS, PA, and
 SPARC@.  If configure does not recognize the model name (e.g.@: arm700,
 603e, or ultrasparc) you provide, please check the configure script
 for a complete list of supported models.
+
+@item --with-float=@var{type}
+Specify the default form of floating point.  The normal choices are ``hard''
+and ``soft''.  Which (if any) choices are recognized depends on the port;
+for instance, MIPS also recognizes ``single''.
 
 @item --enable-altivec
 Specify that the target supports AltiVec vector enhancements.  This

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  7:28       ` Daniel Jacobowitz
@ 2002-07-31  7:36         ` Richard Sandiford
  2002-07-31  7:46           ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Sandiford @ 2002-07-31  7:36 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gcc-patches, echristo

Daniel Jacobowitz <drow@mvista.com> writes:
> if the user configures --with-cpu=<blah>, and then runs the compiler
> with -mips3, what _should_ happen and what _will_ happen?  The result
> will be both -march= and -mips3 being specified on the command line;
> will the -mips3 be ignored or have some effect?

Well, -march overrides -mipsN (N != 16).  gcc will accept -mipsN
alongside a MIPS N -march (e.g. -march=r4000 -mips3) otherwise you'll
get an error.

I guess what should happen depends on what you want --with-cpu to mean.
If it gives a default argument for -march, then the original patch is
OK, and an incompatible -mipsN would be an error.  If (more generally)
you want --with-cpu to specify a default architecture, then I guess
-mips3 should override the default.

Richard

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  6:54     ` Richard Sandiford
@ 2002-07-31  7:28       ` Daniel Jacobowitz
  2002-07-31  7:36         ` Richard Sandiford
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-31  7:28 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches, echristo

On Wed, Jul 31, 2002 at 02:35:21PM +0100, Richard Sandiford wrote:
> Daniel Jacobowitz <drow@mvista.com> writes:
> > > I suppose you could have:
> > > 
> > >   if (!option_present (*argcp, *argvp, "-march=")
> > >       && (!option_present (*argcp, *argvp, "-mips")
> > >           || option_present (*argcp, *argvp, "-mips16")))
> > >     add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));
> > > 
> > > (since -mips16 shouldn't change the default arch) but maybe
> > > there needs to be some sort of target macro?
> > 
> > That doesn't do quite the right thing, if you think about the logic. 
> > It'd have to be "-mips1" or "-mips2" or "-mips3" or "-mips4" or
> > "-mips5" (?) or "-mips32" or "-mips64".
> 
> Well, all -mips* options are handled by one entry in TARGET_SWITCHES, so
> -mips16 overrides a previous -mips3, silly as that might be.  I guess to
> be fully correct, you need to see if the last -mips option is -mips16, in
> which case you keep the default, or something else, in which case you
> don't.  (half ;-)

Wait, wait a second here.  I forgot to re-ask the basic question: if
the user configures --with-cpu=<blah>, and then runs the compiler with
-mips3, what _should_ happen and what _will_ happen?  The result will
be both -march= and -mips3 being specified on the command line; will
the -mips3 be ignored or have some effect?  You're much more familiar
with this code than I am...

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

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  6:41   ` Daniel Jacobowitz
@ 2002-07-31  6:54     ` Richard Sandiford
  2002-07-31  7:28       ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Sandiford @ 2002-07-31  6:54 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gcc-patches, echristo

Daniel Jacobowitz <drow@mvista.com> writes:
> > I suppose you could have:
> > 
> >   if (!option_present (*argcp, *argvp, "-march=")
> >       && (!option_present (*argcp, *argvp, "-mips")
> >           || option_present (*argcp, *argvp, "-mips16")))
> >     add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));
> > 
> > (since -mips16 shouldn't change the default arch) but maybe
> > there needs to be some sort of target macro?
> 
> That doesn't do quite the right thing, if you think about the logic. 
> It'd have to be "-mips1" or "-mips2" or "-mips3" or "-mips4" or
> "-mips5" (?) or "-mips32" or "-mips64".

Well, all -mips* options are handled by one entry in TARGET_SWITCHES, so
-mips16 overrides a previous -mips3, silly as that might be.  I guess to
be fully correct, you need to see if the last -mips option is -mips16, in
which case you keep the default, or something else, in which case you
don't.  (half ;-)

Richard

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

* Re: RFC: New approach to --with-cpu
  2002-07-31  6:35 ` Richard Sandiford
@ 2002-07-31  6:41   ` Daniel Jacobowitz
  2002-07-31  6:54     ` Richard Sandiford
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-31  6:41 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches, echristo

On Wed, Jul 31, 2002 at 02:15:53PM +0100, Richard Sandiford wrote:
> Daniel Jacobowitz <drow@mvista.com> writes:
> > +#ifdef TARGET_DEFAULT_OPTION_ARCH
> > +  if (! option_present (*argcp, *argvp, "-march="))
> > +    add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));
> > +#endif
> 
> On mips, what should happen if you give -mips3 on the command line?
> Should it override the default -march?  Seems like the default would
> win as things stand.
> 
> I suppose you could have:
> 
>   if (!option_present (*argcp, *argvp, "-march=")
>       && (!option_present (*argcp, *argvp, "-mips")
>           || option_present (*argcp, *argvp, "-mips16")))
>     add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));
> 
> (since -mips16 shouldn't change the default arch) but maybe
> there needs to be some sort of target macro?

That doesn't do quite the right thing, if you think about the logic. 
It'd have to be "-mips1" or "-mips2" or "-mips3" or "-mips4" or
"-mips5" (?) or "-mips32" or "-mips64".  At this point there should
obviously be a target macro, which I was hoping to avoid, but at least
it can be a bit simpler.

Blast it, I knew the maze of twisty MIPS command line options was going
to bite me.  I'll resubmit the patch with a target macro for this,
then.

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

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

* Re: RFC: New approach to --with-cpu
  2002-07-30 15:27 Daniel Jacobowitz
@ 2002-07-31  6:35 ` Richard Sandiford
  2002-07-31  6:41   ` Daniel Jacobowitz
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Sandiford @ 2002-07-31  6:35 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gcc-patches, echristo

Daniel Jacobowitz <drow@mvista.com> writes:
> +#ifdef TARGET_DEFAULT_OPTION_ARCH
> +  if (! option_present (*argcp, *argvp, "-march="))
> +    add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));
> +#endif

On mips, what should happen if you give -mips3 on the command line?
Should it override the default -march?  Seems like the default would
win as things stand.

I suppose you could have:

  if (!option_present (*argcp, *argvp, "-march=")
      && (!option_present (*argcp, *argvp, "-mips")
          || option_present (*argcp, *argvp, "-mips16")))
    add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));

(since -mips16 shouldn't change the default arch) but maybe
there needs to be some sort of target macro?

Richard

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

* RFC: New approach to --with-cpu
@ 2002-07-30 15:27 Daniel Jacobowitz
  2002-07-31  6:35 ` Richard Sandiford
  0 siblings, 1 reply; 26+ messages in thread
From: Daniel Jacobowitz @ 2002-07-30 15:27 UTC (permalink / raw)
  To: gcc-patches, echristo

This patch changes the way --with-cpu is implemented, mostly implements it
for more targets, and adds --with-float.  Instead of being controlled by
defining flags in the backend, the driver synthesizes -mcpu (or -mschedule
for HPPA, or -march/-mtune for MIPS) onto the command line.  This improves
behavior with multilibs, predefined macros, and anything else that
conditionalizes based on the processor option.  My goal was to make
--with-cpu= no different from -mcpu= (or the appropriate option).

While I was in there, I did the same thing with
-msoft-float/-mhard-float/-msingle-float and added
--with-float=[hard,soft,single].  Targets with a different range of
floating point options can easily add more.

It still behaves a little oddly with multilibs (because it changes how
multilibs which do not specify a float type or a cpu type are built)
but it should interact with them adequately well.  I think.  Configuring
with --with-cpu makes the "right" behavior of multilibs a bit less obvious.

I've built xgcc and cc1 and verified the option-passing behavior on
hppa1.1-proelf, hppa2.0-linux, strongarm-elf, i386-linux, and mips-elf.
I'm pretty sure I didn't break any target, but of course more eyes are
welcome.

Any comments?  Is this OK?  Anyone have a better idea on how to do this?

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

2002-07-30  Daniel Jacobowitz  <drow@mvista.com>

	* Makefile.in (DRIVER_DEFINES): Add @target_default_options@
	* configure.in: Add @target_default_options@.  Document --with-cpu
	and --with-float.
	* config.gcc: Reorganize $with_cpu logic.  Set
	target_default_options according to the default CPU, $with_cpu,
	and $with_float.
	* gcc.c (default_options, add_option, option_present): New
	functions.
	(process_command): Call default_options.
	* doc/install.texi: Update --with-cpu documentation.  Mention
	--with-float.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.919
diff -u -p -r1.919 Makefile.in
--- Makefile.in	29 Jul 2002 19:31:23 -0000	1.919
+++ Makefile.in	30 Jul 2002 21:36:00 -0000
@@ -1251,6 +1251,7 @@ c-dump.o : c-dump.c $(CONFIG_H) $(SYSTEM
 # Language-independent files.
 
 DRIVER_DEFINES = \
+  @target_default_options@ \
   -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc-lib/\" \
   -DDEFAULT_TARGET_VERSION=\"$(version)\" \
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.229
diff -u -p -r1.229 config.gcc
--- config.gcc	29 Jul 2002 22:21:40 -0000	1.229
+++ config.gcc	30 Jul 2002 21:36:02 -0000
@@ -2770,173 +2770,178 @@ case $machine in
 	;;
 esac
 
-# Distinguish i[34567]86
-# Also, do not run mips-tfile on MIPS if using gas.
-# Process --with-cpu= for PowerPC/rs6000
-target_cpu_default2=
-case $machine in
-i486-*-*)
-	target_cpu_default2=TARGET_CPU_DEFAULT_i486
-	;;
-i586-*-*)
-	case $target_alias in
-		k6_2-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6_2
-			;;
-		k6_3-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6_3
-			;;
-		k6-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_k6
-			;;
-		pentium_mmx-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium_mmx
-			;;
-		*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium
-			;;
-	esac
-	;;
-i686-*-* | i786-*-*)
-	case $target_alias in
-		athlon_xp-*|athlon_mp-*|athlon_4-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
-			;;
-		athlon_tbird-*|athlon-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_athlon
-			;;
-		pentium2-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium2
-			;;
-		pentium3-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium3
-			;;
-		pentium4-*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentium4
-			;;
-		*)
-			target_cpu_default2=TARGET_CPU_DEFAULT_pentiumpro
+if test x$pass2done = xyes
+then
+	case "x$with_cpu" in
+		xyes | xno)
+			echo "--with-cpu must be passed a value" 1>&2
+			exit 1
 			;;
 	esac
-	;;
-x86_64-*-*)
-	# We should have hammer chip here, but it does not exist yet and
-	# thus it is not supported.  Athlon_SSE is probably equivalent feature
-	# wise to hammer from our point of view except for 64bit mode.
-	target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
-	;;
-alpha*-*-*)
-	case $machine in
-		alphaev6[78]*)
-			target_cpu_default2="MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX|MASK_CIX"
-			;;
-		alphaev6*)
-			target_cpu_default2="MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX"
-			;;
-		alphapca56*)
-			target_cpu_default2="MASK_CPU_EV5|MASK_BWX|MASK_MAX"
-			;;
-		alphaev56*)
-			target_cpu_default2="MASK_CPU_EV5|MASK_BWX"
+
+	# If there is no $with_cpu option, try to infer one from ${machine}.
+	if test x$with_cpu = x
+	then
+		case $machine in
+		i486-*-*)
+			with_cpu=i486
+			;;
+		i586-*-*)
+			case $target_alias in
+			k6_2-*)
+				with_cpu=k6-2
+				;;
+			k6_3-*)
+				with_cpu=k6-3
+				;;
+			k6-*)
+				with_cpu=k6
+				;;
+			pentium_mmx-*)
+				with_cpu=pentium-mmx
+				;;
+			*)
+				with_cpu=pentium
+				;;
+			esac
+			;;
+		i686-*-* | i786-*-*)
+			case $target_alias in
+			athlon_xp-*|athlon_mp-*|athlon_4-*)
+				with_cpu=athlon-4
+				;;
+			athlon_tbird-*|athlon-*)
+				with_cpu=athlon
+				;;
+			pentium2-*)
+				with_cpu=pentium2
+				;;
+			pentium3-*)
+				with_cpu=pentium3
+				;;
+			pentium4-*)
+				with_cpu=pentium4
+				;;
+			*)
+				with_cpu=pentiumpro
+				;;
+			esac
+			;;
+		x86_64-*-*)
+			# We should have hammer chip here, but it does not
+			# exist yet and thus it is not supported.  Athlon_SSE
+			# is probably equivalent feature wise to hammer from
+			# our point of view except for 64bit mode.
+			with_cpu=athlon-sse
+			;;
+		alpha*-*-*)
+			case $machine in
+			alphaev6[78]*)
+				with_cpu=ev67
+				;;
+			alphaev6*)
+				with_cpu=ev6
+				;;
+			alphapca56*)
+				with_cpu=pca56
+				;;
+			alphaev56*)
+				with_cpu=ev56
+				;;
+			alphaev5*)
+				with_cpu=ev5
+				;;
+			esac
 			;;
-		alphaev5*)
-			target_cpu_default2="MASK_CPU_EV5"
+		sparc*-*-*)
+			with_cpu="`echo $machine | sed 's/-.*$//'`"
 			;;
-	esac
+		esac
+	fi
 
-	if test x$gas = xyes
-	then
-		if test "$target_cpu_default2" = ""
+	case "$machine" in
+	alpha*-*-*)
+		if test x$gas = xyes
 		then
-			target_cpu_default2="MASK_GAS"
-		else
-			target_cpu_default2="${target_cpu_default2}|MASK_GAS"
+			if test "$target_cpu_default2" = ""
+			then
+				target_cpu_default2="MASK_GAS"
+			else
+				target_cpu_default2="${target_cpu_default2}|MASK_GAS"
+			fi
 		fi
-	fi
-	;;
-arm*-*-*)
-	case "x$with_cpu" in
-		x)
-			# The most generic
-			target_cpu_default2="TARGET_CPU_generic"
-			;;
-
+		;;
+	arm*-*-*)
+		# Start with the most generic.
+		target_cpu_default2="TARGET_CPU_generic"
 		# Distinguish cores, and major variants
 		# arm7m doesn't exist, but D & I don't affect code
+		case "x$with_cpu" in
 		xarm[236789] | xarm250 | xarm[67][01]0 \
 		| xarm7m | xarm7dm | xarm7dmi | xarm[79]tdmi \
 		| xarm7100 | xarm7500 | xarm7500fe | xarm810 \
 		| xxscale \
 		| xstrongarm | xstrongarm110 | xstrongarm1100)
-			target_cpu_default2="TARGET_CPU_$with_cpu"
+			# OK
 			;;
 
-		xyes | xno)
-			echo "--with-cpu must be passed a value" 1>&2
+		*)
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
 			exit 1
 			;;
-
-		*)
-			if test x$pass2done = xyes
+		esac
+		;;
+	hppa*-*-* | parisc*-*-*)
+		if test x$gas = xyes
+		then
+			target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
+		fi
+		case $machine in
+			hppa1* | parisc1*)
+				with_cpu=7100LC
+				;;
+		esac
+		;;
+	mips*-*-*)
+		case $machine in
+		mips*-*-ecoff* | mips*-*-elf*)
+			if test x$gas = xyes
 			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
+				if test x$gnu_ld = xyes
+				then
+					target_cpu_default2="MASK_GAS|MASK_SPLIT_ADDR"
+				else
+					target_cpu_default2="MASK_GAS"
+				fi
 			fi
 			;;
-	esac
-	;;
-
-hppa*-*-* | parisc*-*-*)
-	if test x$gas = xyes
-	then
-		target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
-	fi
-	case $machine in
-		hppa1* | parisc1*)
-			tm_defines="TARGET_SCHED_DEFAULT=\\\"7100LC\\\""
-			;;
-	esac
-	;;
-mips*-*-*)
-	case $machine in
-	mips*-*-ecoff* | mips*-*-elf*)
-		if test x$gas = xyes
-		then
-			if test x$gnu_ld = xyes
+		mips*-*-*)
+			if test x$gas = xyes
 			then
-				target_cpu_default2="MASK_GAS|MASK_SPLIT_ADDR"
-			else
 				target_cpu_default2="MASK_GAS"
 			fi
-		fi
-		;;
-	mips*-*-*)
-		if test x$gas = xyes
+			;;
+		esac
+		case $machine in
+			mips*el-*-*)
+				tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
+				;;
+		esac
+		if test "x$enable_gofast" = xyes
 		then
-			target_cpu_default2="MASK_GAS"
+			tm_defines="INIT_SUBTARGET_OPTABS=INIT_GOFAST_OPTABS $tm_defines"
+			tm_file="gofast.h $tm_file"
+			tmake_file="mips/t-gofast $tmake_file"
+		else
+			tmake_file="mips/t-mips $tmake_file"
 		fi
 		;;
-	esac
-	case $machine in
-		mips*el-*-*)
-			tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
-			;;
-	esac
-	if test "x$enable_gofast" = xyes
-	then
-		tm_defines="INIT_SUBTARGET_OPTABS=INIT_GOFAST_OPTABS $tm_defines"
-		tm_file="gofast.h $tm_file"
-		tmake_file="mips/t-gofast $tmake_file"
-	else
-		tmake_file="mips/t-mips $tmake_file"
-	fi
-	;;
-powerpc*-*-* | rs6000-*-*)
-        if test x$enable_altivec = xyes
-        then
-                tm_file="$tm_file rs6000/altivec-defs.h"
-        fi
-	case "x$with_cpu" in
+	powerpc*-*-* | rs6000-*-*)
+        	if test x$enable_altivec = xyes
+	        then
+        	        tm_file="$tm_file rs6000/altivec-defs.h"
+	        fi
+		case "x$with_cpu" in
 		x)
 			;;
 
@@ -2951,49 +2956,56 @@ powerpc*-*-* | rs6000-*-*)
 			target_cpu_default2="\\\"$with_cpu\\\""
 			;;
 
-		xyes | xno)
-			echo "--with-cpu must be passed a value" 1>&2
+		*)
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
 			exit 1
 			;;
-
+		esac
+		c_target_objs="${c_target_objs} rs6000-c.o"
+		cxx_target_objs="${cxx_target_objs} rs6000-c.o"
+		tmake_file="${tmake_file} rs6000/t-rs6000-c-rule"
+		;;
+	sparc*-*-*)
+		case .$with_cpu in
+		.supersparc | .hypersparc | .ultrasparc | .v7 | .v8 | .v9)
+			target_cpu_default2="TARGET_CPU_$with_cpu"
+			;;
 		*)
-			if test x$pass2done = xyes
-			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
-			fi
+			echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
+			exit 1
 			;;
+		esac
+		;;
 	esac
-	c_target_objs="${c_target_objs} rs6000-c.o"
-	cxx_target_objs="${cxx_target_objs} rs6000-c.o"
-	tmake_file="${tmake_file} rs6000/t-rs6000-c-rule"
-	;;
-sparc*-*-*)
-	case ".$with_cpu" in
-		.)
-			target_cpu_default2=TARGET_CPU_"`echo $machine | sed 's/-.*$//'`"
+
+	if test x$with_cpu != x
+	then
+		case "$machine" in
+		hppa*-*-* | parisc*-*-*)
+			target_default_options="-DTARGET_DEFAULT_OPTION_SCHEDULE=$with_cpu"
 			;;
-		.supersparc | .hypersparc | .ultrasparc | .v7 | .v8 | .v9)
-			target_cpu_default2="TARGET_CPU_$with_cpu"
+		mips*-*-*)
+			target_default_options="-DTARGET_DEFAULT_OPTION_ARCH=$with_cpu -DTARGET_DEFAULT_OPTION_TUNE=$with_tune"
 			;;
 		*)
-			if test x$pass2done = xyes
-			then
-				echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
-				exit 1
-			fi
+			target_default_options="-DTARGET_DEFAULT_OPTION_CPU=$with_cpu"
 			;;
-	esac
-	;;
-esac
+		esac
+	fi
 
-if test "$target_cpu_default2" != ""
-then
-	if test "$target_cpu_default" != ""
+	if test -n "$with_float"
 	then
-		target_cpu_default="(${target_cpu_default}|${target_cpu_default2})"
-	else
-		target_cpu_default=$target_cpu_default2
+		target_default_options="${target_default_options} -DTARGET_DEFAULT_OPTION_FLOAT=\"$with_float\""
+	fi
+
+	if test "$target_cpu_default2" != ""
+	then
+		if test "$target_cpu_default" != ""
+		then
+			target_cpu_default="(${target_cpu_default}|${target_cpu_default2})"
+		else
+			target_cpu_default=$target_cpu_default2
+		fi
 	fi
 fi
 
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.612
diff -u -p -r1.612 configure.in
--- configure.in	29 Jul 2002 22:07:27 -0000	1.612
+++ configure.in	30 Jul 2002 21:36:10 -0000
@@ -136,6 +136,14 @@ AC_ARG_WITH(elf,
 elf="$with_elf",
 elf=no)
 
+# With a particular CPU
+AC_ARG_WITH(cpu,
+[  --with-cpu              default to the specified CPU],,)
+
+# Default floating-point setting
+AC_ARG_WITH(float,
+[  --with-float            default to the specified type of floating point],,)
+
 # Specify the local prefix
 local_prefix=
 AC_ARG_WITH(local-prefix,
@@ -2694,6 +2702,7 @@ AC_SUBST(target_alias)
 AC_SUBST(c_target_objs)
 AC_SUBST(cxx_target_objs)
 AC_SUBST(target_cpu_default)
+AC_SUBST(target_default_options)
 
 AC_SUBST_FILE(target_overrides)
 AC_SUBST_FILE(host_overrides)
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.331
diff -u -p -r1.331 gcc.c
--- gcc.c	25 Jul 2002 18:48:42 -0000	1.331
+++ gcc.c	30 Jul 2002 21:36:15 -0000
@@ -990,6 +990,90 @@ static const struct option_map option_ma
  };
 \f
 
+static int option_present PARAMS ((int, const char *const *, const char *));
+static void add_option PARAMS ((int *, const char *const **, const char *));
+static void default_options PARAMS ((int *, const char *const **));
+
+static int
+option_present (argc, argv, option)
+     int argc;
+     const char *const *argv;
+     const char *option;
+{
+  int i;
+  int len;
+
+  len = strlen (option);
+
+  for (i = 0; i < argc; i++)
+    if (option[len - 1] == '=')
+      {
+	if (strncmp (argv[i], option, len) == 0)
+	  return 1;
+      }
+    else
+      {
+	if (strcmp (argv[i], option) == 0)
+	  return 1;
+      }
+
+  return 0;
+}
+
+static void
+add_option (argcp, argvp, option)
+     int *argcp;
+     const char *const **argvp;
+     const char *option;
+{
+  const char **newargv = (const char **) xmalloc ((*argcp + 2) * sizeof (char *));
+  int i;
+
+  newargv[0] = (*argvp)[0];
+  newargv[1] = option;
+  for (i = 1; i < *argcp; i++)
+    newargv[i + 1] = (*argvp)[i];
+  newargv[i + 1] = NULL;
+
+  *argvp = newargv;
+  (*argcp)++;
+}
+
+static void
+default_options (argcp, argvp)
+     int *argcp ATTRIBUTE_UNUSED;
+     const char *const **argvp ATTRIBUTE_UNUSED;
+{
+#ifdef TARGET_DEFAULT_OPTION_CPU
+  if (! option_present (*argcp, *argvp, "-mcpu="))
+    add_option (argcp, argvp, "-mcpu=" XSTRING (TARGET_DEFAULT_OPTION_CPU));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_ARCH
+  if (! option_present (*argcp, *argvp, "-march="))
+    add_option (argcp, argvp, "-march=" XSTRING (TARGET_DEFAULT_OPTION_ARCH));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_TUNE
+  if (! option_present (*argcp, *argvp, "-mtune="))
+    add_option (argcp, argvp, "-mtune=" XSTRING (TARGET_DEFAULT_OPTION_TUNE));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_SCHEDULE
+  if (! option_present (*argcp, *argvp, "-mschedule="))
+    add_option (argcp, argvp, "-mschedule=" XSTRING (TARGET_DEFAULT_OPTION_SCHEDULE));
+#endif
+
+#ifdef TARGET_DEFAULT_OPTION_FLOAT
+  /* Add other mutually exclusive floating point options as necessary.  */
+  if (! option_present (*argcp, *argvp, "-msoft-float")
+      && ! option_present (*argcp, *argvp, "-mhard-float")
+      && ! option_present (*argcp, *argvp, "-msingle-float"))
+    add_option (argcp, argvp, "-m" XSTRING (TARGET_DEFAULT_OPTION_FLOAT) "-float");
+#endif
+}
+\f
+
 #ifdef TARGET_OPTION_TRANSLATE_TABLE
 static const struct {
   const char *const option_found;
@@ -3374,6 +3458,9 @@ process_command (argc, argv)
 
   /* Convert new-style -- options to old-style.  */
   translate_options (&argc, &argv);
+
+  /* Add any default options.  */
+  default_options (&argc, &argv);
 
   /* Do language-specific adjustment/addition of flags.  */
   lang_specific_driver (&argc, &argv, &added_libraries);
Index: doc/install.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/install.texi,v
retrieving revision 1.128
diff -u -p -r1.128 install.texi
--- doc/install.texi	30 Jun 2002 19:27:48 -0000	1.128
+++ doc/install.texi	30 Jul 2002 21:49:18 -0000
@@ -672,10 +672,15 @@ Microsoft Win32 API thread support.
 @item --with-cpu=@var{cpu}
 Specify which cpu variant the
 compiler should generate code for by default.  This is currently
-only supported on the some ports, specifically arm, powerpc, and
+only supported on some ports, including arm, i386, powerpc, MIPS, PA, and
 SPARC@.  If configure does not recognize the model name (e.g.@: arm700,
 603e, or ultrasparc) you provide, please check the configure script
 for a complete list of supported models.
+
+@item --with-float=@var{type}
+Specify the default form of floating point.  The choices are hard, soft,
+and single.  Which (if any) choices are recognized depends on the port
+you configure for.
 
 @item --enable-altivec
 Specify that the target supports AltiVec vector enhancements.  This

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

end of thread, other threads:[~2002-08-01 18:40 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-30 18:54 RFC: New approach to --with-cpu John David Anglin
2002-07-30 23:03 ` Daniel Jacobowitz
2002-07-31  7:53   ` John David Anglin
2002-07-31  8:09     ` Daniel Jacobowitz
2002-07-31  8:30       ` Richard Earnshaw
2002-07-31  9:02         ` Daniel Jacobowitz
2002-07-31 10:34           ` John David Anglin
2002-07-31 13:27             ` Daniel Jacobowitz
2002-08-01  3:31               ` Richard Sandiford
2002-08-01  3:57                 ` Richard Earnshaw
2002-08-01  8:15               ` John David Anglin
2002-08-01  8:23                 ` Daniel Jacobowitz
2002-08-01 11:40                   ` John David Anglin
2002-08-01  6:30             ` Richard Earnshaw
2002-08-01  7:41               ` John David Anglin
     [not found] <20020801125224.GA5374@nevyn.them.org>
2002-08-01  6:04 ` Richard Earnshaw
2002-08-01  6:25   ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2002-07-30 15:27 Daniel Jacobowitz
2002-07-31  6:35 ` Richard Sandiford
2002-07-31  6:41   ` Daniel Jacobowitz
2002-07-31  6:54     ` Richard Sandiford
2002-07-31  7:28       ` Daniel Jacobowitz
2002-07-31  7:36         ` Richard Sandiford
2002-07-31  7:46           ` Daniel Jacobowitz
2002-07-31  7:50             ` Richard Sandiford
2002-07-31  8:04               ` Daniel Jacobowitz

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