Updated --with-cpu patch, v9
Daniel Jacobowitz
drow@mvista.com
Wed May 14 14:46:00 GMT 2003
On Mon, May 12, 2003 at 06:57:27PM -0400, Daniel Jacobowitz wrote:
> This is an update to the --with-cpu patch I posted some months ago. It's
> evolved and simplified quite a lot, and I think the result is much nicer
> than any previous version.
Here's an update, based on Richard Earnshaw's, Richard Sandiford's, and
Alexandre Oliva's suggestions. --with-tune is now overridden by -mcpu
on ARM, but not by -march; the value of --with-abi is checked on MIPS;
and we use %(VALUE) instead of just VALUE. I still do it by string
substitution rather than faking up a spec named VALUE.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-05-12 Daniel Jacobowitz <drow@mvista.com>
* config.gcc: Reorganize --with-cpu logic. Set
configure_default_options according to the default CPU, --with-cpu,
--with-arch, --with-tune, --with-schedule, --with-abi, and
--with-float. Check for legal values of various options.
* configure.in: Define configure_default_options in configargs.h.
* configure: Regenerated.
* config/mips/mips.h (TARGET_DEFAULT_ARCH_P)
(TARGET_DEFAULT_FLOAT_P): New macros.
* gcc.c (do_option_spec): New function.
(struct default_spec, option_default_specs): New.
(main): Call do_option_spec.
* config/alpha/alpha.h, config/arm/arm.h, config/i386/i386.h,
config/mips/mips.h, config/pa/pa.h, config/rs6000/rs6000.h,
config/sparc/sparc.h (OPTION_DEFAULT_SPECS): Define.
* doc/install.texi: Update --with-cpu documentation. Mention
--with-arch, --with-schedule, --with-tune, --with-abi, and
--with-float.
* doc/tm.texi (Driver): Document OPTION_DEFAULT_SPECS.
Index: gcc/config.gcc
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config.gcc,v
retrieving revision 1.299
diff -u -p -r1.299 config.gcc
--- gcc/config.gcc 10 May 2003 12:07:00 -0000 1.299
+++ gcc/config.gcc 13 May 2003 16:07:17 -0000
@@ -160,6 +160,9 @@
# determines the underlying integral type for
# HOST_WIDE_INT cannot see the definition of
# MAX_LONG_TYPE_SIZE.)
+# configure_default_options
+# Set to an initializer for configure_default_options
+# in configargs.h, based on --with-cpu et cetera.
# The following variables are used in each case-construct to build up the
# outgoing variables:
@@ -2651,262 +2654,469 @@ 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-*|winchip_c6-*|winchip2-*|c3-*)
- target_cpu_default2=TARGET_CPU_DEFAULT_pentium_mmx
- ;;
- *)
- target_cpu_default2=TARGET_CPU_DEFAULT_pentium
- ;;
- esac
- ;;
-i686-*-* | i786-*-*)
- case $target_alias in
- k8-*)
- target_cpu_default2=TARGET_CPU_DEFAULT_k8
- ;;
- 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_k8
- ;;
-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"
+
+ # If there is no $with_cpu option, try to infer one from ${machine}.
+ # This block sets nothing except for with_cpu.
+ if test x$with_cpu = x
+ then
+ case $machine in
+ ep9312-*-*)
+ # A Cirrus ARM variant.
+ with_cpu="ep9312"
+ ;;
+ 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-*|winchip_c6-*|winchip2-*|c3-*)
+ with_cpu=pentium-mmx
+ ;;
+ *)
+ with_cpu=pentium
+ ;;
+ esac
+ ;;
+ i686-*-* | i786-*-*)
+ case $target_alias in
+ k8-*)
+ with_cpu=k8
+ ;;
+ 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=k8
+ ;;
+ 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
;;
- alphaev56*)
- target_cpu_default2="MASK_CPU_EV5|MASK_BWX"
+ sparc*-*-*)
+ with_cpu="`echo $machine | sed 's/-.*$//'`"
;;
- alphaev5*)
- target_cpu_default2="MASK_CPU_EV5"
+ esac
+ fi
+
+ # Similarly for --with-schedule.
+ if test x$with_schedule = x; then
+ case $machine in
+ hppa1* | parisc1*)
+ # Override default PA8000 scheduling model.
+ with_schedule=7100LC
;;
- esac
+ esac
+ fi
- if test x$gas = xyes
- then
- if test "$target_cpu_default2" = ""
+
+ # Set some miscellaneous flags for particular targets.
+ case "$machine" in
+ alpha*-*-*)
+ if test x$gas = xyes
then
target_cpu_default2="MASK_GAS"
- else
- target_cpu_default2="${target_cpu_default2}|MASK_GAS"
fi
- fi
- ;;
-arm*-*-*)
- case "x$with_cpu" in
- x)
- # The most generic
+ ;;
+ arm*-*-*)
+ if test "x$with_cpu" = "x"
+ then
target_cpu_default2="TARGET_CPU_generic"
- ;;
-
- # Distinguish cores, and major variants
- # arm7m doesn't exist, but D & I don't affect code
- xarm[236789] | xarm250 | xarm[67][01]0 \
- | xarm7m | xarm7dm | xarm7dmi | xarm[79]tdmi \
- | xarm7100 | xarm7500 | xarm7500fe | xarm810 \
- | xxscale \
- | xep9312 \
- | xstrongarm | xstrongarm110 | xstrongarm1100)
+ else
target_cpu_default2="TARGET_CPU_$with_cpu"
- ;;
+ fi
+ ;;
- xyes | xno)
- echo "--with-cpu must be passed a value" 1>&2
- exit 1
- ;;
+ hppa*-*-* | parisc*-*-*)
+ if test x$gas = xyes
+ then
+ target_cpu_default2="MASK_GAS|MASK_JUMP_IN_DELAY"
+ fi
+ ;;
- *)
- if test x$pass2done = xyes
+ 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
- case $machine in
- 9ep9312-*-*)
- target_cpu_default2="TARGET_CPU_9ep9312"
- ;;
- 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
+ ;;
+ esac
+ case $machine in
+ mips*el-*-*)
+ tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
+ ;;
+ esac
+ case $tm_file in
+ *mips/elf.h* | *mips/elf64.h*)
+ tm_defines="OBJECT_FORMAT_ELF $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
;;
- mips*-*-*)
- if test x$gas = xyes
+ powerpc*-*-* | rs6000-*-*)
+ if test x$enable_altivec = xyes
then
- target_cpu_default2="MASK_GAS"
+ tm_file="$tm_file rs6000/altivec-defs.h"
fi
+ out_file=rs6000/rs6000.c
+ c_target_objs="${c_target_objs} rs6000-c.o"
+ cxx_target_objs="${cxx_target_objs} rs6000-c.o"
+ tmake_file="rs6000/t-rs6000 ${tmake_file}"
+
+ # FIXME: The PowerPC port uses the value set at compile time,
+ # although it's only cosmetic.
+ target_cpu_default2="\\\"$with_cpu\\\""
+ ;;
+ sparc*-*-*)
+ # Some standard aliases.
+ case x$with_cpu in
+ xsparc)
+ with_cpu=v7
+ ;;
+ xsparc86x)
+ with_cpu=sparclite86x
+ ;;
+ xsparcv9 | xsparc64)
+ with_cpu=v9
+ ;;
+ esac
+
+ # The Sparc port checks this value at compile-time.
+ target_cpu_default2="TARGET_CPU_$with_cpu"
;;
- esac
- case $machine in
- mips*el-*-*)
- tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
+ v850*-*-*)
+ # FIXME: The v850 is "special" in that it does not support
+ # runtime CPU selection, only --with-cpu.
+ case "x$with_cpu" in
+ xv850e)
+ target_cpu_default2="TARGET_CPU_$with_cpu"
;;
+ esac
+ ;;
esac
- case $tm_file in
- *mips/elf.h* | *mips/elf64.h*)
- tm_defines="OBJECT_FORMAT_ELF $tm_defines"
+
+ supported_defaults=
+
+ # Validate and mark as valid any --with options supported
+ # by this target. In order to use a particular --with option
+ # you must list it in supported_defaults; validating the value
+ # is optional. This case statement should set nothing besides
+ # supported_defaults.
+
+ case "$machine" in
+ alpha*-*-*)
+ supported_defaults="cpu tune"
+ case "x$with_tune" in
+ x \
+ | xev4 | xev45 | x21064 | xev5 | x21164 | xev56 | x21164a \
+ | xpca56 | x21164PC | x21164pc | xev6 | x21264 | xev67 \
+ | x21264a)
;;
- 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
- x)
+ *)
+ echo "Unknown CPU used in --with-tune=$with_tune" 1>&2
+ exit 1
;;
+ esac
+ case "x$with_cpu" in
+ x \
+ | xev4 | xev45 | x21064 | xev5 | x21164 | xev56 | x21164a \
+ | xpca56 | x21164PC | x21164pc | xev6 | x21264 | xev67 \
+ | x21264a)
+ ;;
+ *)
+ echo "Unknown CPU used in --with-cpu=$with_cpu" 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
- xcommon | xpowerpc | xpowerpc64 \
- | xpower | xpower2 | xpower3 | xpower4 \
- | xrios | xrios1 | xrios2 | xrsc | xrsc1 | xrs64a \
- | x601 | x602 | x603 | x603e | x604 | x604e | x620 | x630 \
- | x740 | x750 | x7400 | x7450 | x505)
- target_cpu_default2="\\\"$with_cpu\\\""
+ arm*-*-*)
+ supported_defaults="arch cpu float tune"
+ for which in cpu tune; do
+ eval "val=\$with_$which"
+ case "x$val" in
+ x \
+ | xarm[236789] | xarm250 | xarm[67][01]0 \
+ | xarm60 | xarm620 | xarm7d | xarm7di \
+ | xarm7m | xarm7dm | xarm7dmi | xarm[79]tdmi \
+ | xarm70 | xarm700i | xarm710t | xarm720 \
+ | xarm720t | xarm740t | xarm710c | xarm920 \
+ | xarm920t | xarm940t | xarm9e | xarm10tdmi \
+ | xarm7100 | xarm7500 | xarm7500fe | xarm810 \
+ | xarm1020t \
+ | xxscale \
+ | xep9312 \
+ | xstrongarm | xstrongarm110 | xstrongarm11[01]0)
+ # OK
+ ;;
+ *)
+ echo "Unknown cpu used in --with-$which=$val" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+
+ case "x$with_arch" in
+ x \
+ | xarmv[2345] | xarmv2a | xarmv3m | xarmv4t | xarmv5t \
+ | xarmv5te | ep9312)
+ # OK
;;
+ *)
+ echo "Unknown arch used in --with-arch=$with_arch" 1>&2
+ exit 1
+ ;;
+ esac
- x401 | x403 | x405 | xec603e | x801 | x821 | x823 | x860)
- target_cpu_default2="\\\"$with_cpu\\\""
+ case "x$with_float" in
+ x \
+ | xsoft | xhard)
+ # OK
;;
+ *)
+ echo "Unknown floating point type used in --with-float=$with_float" 1>&2
+ exit 1
+ ;;
+ esac
- xyes | xno)
- echo "--with-cpu must be passed a value" 1>&2
+ if test "x$with_arch" != x && test "x$with_cpu" != x; then
+ echo "Warning: --with-arch overrides --with-cpu" 1>&2
+ fi
+ ;;
+
+ hppa*-*-* | parisc*-*-*)
+ supported_defaults="arch schedule"
+
+ case "x$with_arch" in
+ x | x1.0 | x1.1 | x2.0)
+ # OK
+ ;;
+ *)
+ echo "Unknown architecture used in --with-arch=$with_arch" 1>&2
exit 1
;;
+ esac
+ case "x$with_schedule" in
+ x | x700 | x7100 | x7100LC | x7200 | x7300 | x8000)
+ # OK
+ ;;
*)
- if test x$pass2done = xyes
- then
- echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
- exit 1
- fi
+ echo "Unknown processor used in --with-schedule=$with_schedule" 1>&2
+ exit 1
;;
- esac
- out_file=rs6000/rs6000.c
- c_target_objs="${c_target_objs} rs6000-c.o"
- cxx_target_objs="${cxx_target_objs} rs6000-c.o"
- tmake_file="rs6000/t-rs6000 ${tmake_file}"
- ;;
-sparc*-*-*)
- case ".$with_cpu" in
- .)
- target_cpu_default2=TARGET_CPU_"`echo $machine | sed 's/-.*$//'`"
+ esac
+ ;;
+
+ i[34567]86-*-*)
+ supported_defaults="arch cpu tune"
+ ;;
+
+ mips*-*-*)
+ supported_defaults="abi arch float tune"
+
+ case "x$with_float" in
+ x \
+ | xsoft | xhard)
+ # OK
;;
- .supersparc | .hypersparc | .ultrasparc | .v7 | .v8 | .v9)
- target_cpu_default2="TARGET_CPU_$with_cpu"
+ *)
+ echo "Unknown floating point type used in --with-float=$with_float" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case "x$with_abi" in
+ x \
+ | x32 | xo64 | xn32 | x64 | xeabi)
+ # OK
;;
*)
- if test x$pass2done = xyes
- then
- echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
+ echo "Unknown ABI used in --with-abi=$with_abi" 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
+
+ powerpc*-*-* | rs6000-*-*)
+ supported_defaults="cpu float tune"
+
+ for which in cpu tune; do
+ eval "val=\$with_$which"
+ case "x$val" in
+ x \
+ | xcommon \
+ | xpower | xpower2 | xpower3 | xpower4 \
+ | xpowerpc | xpowerpc64 \
+ | xrios | xrios1 | xrios2 | xrsc | xrsc1 | xrs64a \
+ | x401 | x403 | x405 | x405fp | x440 | x440fp | x505 \
+ | x601 | x602 | x603 | x603e | xec603e | x604 \
+ | x604e | x620 | x630 | x740 | x750 | x7400 | x7450 \
+ | x8540 | x801 | x821 | x823 | x860)
+ # OK
+ ;;
+ *)
+ echo "Unknown cpu used in --with-$which=$val" 1>&2
exit 1
- fi
+ ;;
+ esac
+ done
+ ;;
+
+ sparc*-*-*)
+ supported_defaults="cpu float tune"
+
+ for which in cpu tune; do
+ eval "val=\$with_$which"
+ case x$val in
+ x \
+ | xv7 | xcypress | xv8 | xsupersparc | xsparclite | xf930 \
+ | xf934 | xhypersparc | xsparclite86x | xsparclet | tsc701 \
+ | xv9 | xultrasparc | xultrasparc3)
+ # OK
+ ;;
+ *)
+ echo "Unknown cpu used in --with-$which=$val" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+
+ case "x$with_float" in
+ x \
+ | xsoft | xhard)
+ # OK
;;
- esac
- ;;
-v850*-*-*)
- case "x$with_cpu" in
- x)
+ *)
+ echo "Unknown floating point type used in --with-float=$with_float" 1>&2
+ exit 1
;;
- xv850e)
- target_cpu_default2="TARGET_CPU_$with_cpu"
+ esac
+ ;;
+
+ v850*-*-*)
+ supported_defaults=cpu
+ case "x$with_cpu" in
+ x | xv850e)
+ # OK
;;
*)
- if test x$pass2done = xyes
- then
- echo "Unknown cpu used with --with-cpu=$with_cpu" 1>&2
- exit 1
- fi
+ echo "Unknown cpu used in --with-cpu=$with_cpu" 1>&2
+ exit 1
;;
+ esac
+ ;;
+
+ x86_64-*-*)
+ supported_defaults="arch cpu tune"
+ ;;
esac
- ;;
-esac
-if test "$target_cpu_default2" != ""
-then
- if test "$target_cpu_default" != ""
+ t=
+ all_defaults="abi cpu arch tune schedule float"
+ for option in $all_defaults
+ do
+ eval "val=\$with_$option"
+ if test -n "$val"; then
+ case " $supported_defaults " in
+ *" $option "*)
+ ;;
+ *)
+ echo "This target does not support --with-$option." 2>&1
+ exit 1
+ ;;
+ esac
+
+ if test "x$t" = x
+ then
+ t="{ \"$option\", \"$val\" }"
+ else
+ t="${t}, { \"$option\", \"$val\" }"
+ fi
+ fi
+ done
+ configure_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: gcc/configure.in
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/configure.in,v
retrieving revision 1.668
diff -u -p -r1.668 configure.in
--- gcc/configure.in 12 May 2003 22:30:24 -0000 1.668
+++ gcc/configure.in 14 May 2003 14:10:26 -0000
@@ -1213,6 +1213,10 @@ cat > configargs.h <<EOF
/* Generated automatically. */
static const char configuration_arguments[] = "$gcc_config_arguments";
static const char thread_model[] = "$thread_file";
+
+static const struct {
+ const char *name, *value;
+} configure_default_options[] = $configure_default_options;
EOF
changequote([,])dnl
Index: gcc/gcc.c
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/gcc.c,v
retrieving revision 1.374
diff -u -p -r1.374 gcc.c
--- gcc/gcc.c 7 May 2003 06:10:49 -0000 1.374
+++ gcc/gcc.c 14 May 2003 14:23:24 -0000
@@ -325,6 +325,7 @@ static char *save_string PARAMS ((const
static void set_collect_gcc_options PARAMS ((void));
static int do_spec_1 PARAMS ((const char *, int, const char *));
static int do_spec_2 PARAMS ((const char *));
+static void do_option_spec PARAMS ((const char *, const char *));
static void do_self_spec PARAMS ((const char *));
static const char *find_file PARAMS ((const char *));
static int is_directory PARAMS ((const char *, const char *, int));
@@ -803,6 +804,19 @@ static const char *const multilib_defaul
static const char *const driver_self_specs[] = { DRIVER_SELF_SPECS };
+#ifndef OPTION_DEFAULT_SPECS
+#define OPTION_DEFAULT_SPECS
+#endif
+
+struct default_spec
+{
+ const char *name;
+ const char *spec;
+};
+
+static const struct default_spec
+ option_default_specs[] = { OPTION_DEFAULT_SPECS };
+
struct user_specs
{
struct user_specs *next;
@@ -4254,6 +4268,53 @@ do_spec_2 (spec)
of the switches/n_switches array. */
static void
+do_option_spec (name, spec)
+ const char *name;
+ const char *spec;
+{
+ unsigned int i, value_count, value_len;
+ const char *p, *q, *value;
+ char *tmp_spec, *tmp_spec_p;
+
+ for (i = 0; i < ARRAY_SIZE (configure_default_options); i++)
+ if (strcmp (configure_default_options[i].name, name) == 0)
+ break;
+ if (i == ARRAY_SIZE (configure_default_options))
+ return;
+ value = configure_default_options[i].value;
+ value_len = strlen (value);
+
+ /* Compute the size of the final spec. */
+ value_count = 0;
+ p = spec;
+ while ((p = strstr (p, "%(VALUE)")) != NULL)
+ {
+ p ++;
+ value_count ++;
+ }
+
+ /* Replace each %(VALUE) by the specified value. */
+ tmp_spec = alloca (strlen (spec) + 1
+ + value_count * (value_len - strlen ("%(VALUE)"));
+ tmp_spec_p = tmp_spec;
+ q = spec;
+ while ((p = strstr (q, "%(VALUE)")) != NULL)
+ {
+ memcpy (tmp_spec_p, q, p - q);
+ tmp_spec_p = tmp_spec_p + (p - q);
+ memcpy (tmp_spec_p, value, value_len);
+ tmp_spec_p += value_len;
+ q = p + strlen ("%(VALUE)");
+ }
+ strcpy (tmp_spec_p, q);
+
+ do_self_spec (tmp_spec);
+}
+
+/* Process the given spec string and add any new options to the end
+ of the switches/n_switches array. */
+
+static void
do_self_spec (spec)
const char *spec;
{
@@ -6193,6 +6254,12 @@ main (argc, argv)
strcat (specs_file, "specs");
if (access (specs_file, R_OK) == 0)
read_specs (specs_file, TRUE);
+
+ /* Process any configure-time defaults specified for the command line
+ options, via OPTION_DEFAULT_SPECS. */
+ for (i = 0; i < ARRAY_SIZE (option_default_specs); i++)
+ do_option_spec (option_default_specs[i].name,
+ option_default_specs[i].spec);
/* Process DRIVER_SELF_SPECS, adding any new options to the end
of the command line. */
Index: gcc/config/alpha/alpha.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config/alpha/alpha.h,v
retrieving revision 1.196
diff -u -p -r1.196 alpha.h
--- gcc/config/alpha/alpha.h 12 May 2003 09:51:19 -0000 1.196
+++ gcc/config/alpha/alpha.h 14 May 2003 14:26:27 -0000
@@ -365,6 +365,13 @@ extern const char *alpha_tls_size_string
N_("Specify bit size of immediate TLS offsets"), 0}, \
}
+/* Support for a compile-time default CPU, et cetera. The rules are:
+ --with-cpu is ignored if -mcpu is specified.
+ --with-tune is ignored if -mtune is specified. */
+#define OPTION_DEFAULT_SPECS \
+ {"cpu", "%{!mcpu=*:-mcpu=%(VALUE)}" }, \
+ {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }
+
/* This macro defines names of additional specifications to put in the
specs that can be used in various specifications like CC1_SPEC. Its
definition is an initializer with a subgrouping for each command option.
Index: gcc/config/arm/arm.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.189
diff -u -p -r1.189 arm.h
--- gcc/config/arm/arm.h 23 Apr 2003 16:39:30 -0000 1.189
+++ gcc/config/arm/arm.h 14 May 2003 14:25:53 -0000
@@ -525,6 +525,20 @@ Unrecognized value in TARGET_CPU_DEFAULT
N_("Specify the register to be used for PIC addressing"), 0} \
}
+/* Support for a compile-time default CPU, et cetera. The rules are:
+ --with-arch is ignored if -march or -mcpu are specified.
+ --with-cpu is ignored if -march or -mcpu are specified, and is overridden
+ by --with-arch.
+ --with-tune is ignored if -mtune or -mcpu are specified (but not affected
+ by -march).
+ --with-float is ignored if -mhard-float or -msoft-float are
+ specified. */
+#define OPTION_DEFAULT_SPECS \
+ {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
+ {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \
+ {"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }
+
struct arm_cpu_select
{
const char * string;
Index: gcc/config/i386/i386.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.335
diff -u -p -r1.335 i386.h
--- gcc/config/i386/i386.h 10 May 2003 19:38:02 -0000 1.335
+++ gcc/config/i386/i386.h 14 May 2003 14:26:18 -0000
@@ -483,6 +483,12 @@ extern int x86_prefetch_sse;
#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) \
optimization_options ((LEVEL), (SIZE))
+/* Support for configure-time defaults of some command line options. */
+#define OPTION_DEFAULT_SPECS \
+ {"arch", "%{!march=*:-march=%(VALUE)}"}, \
+ {"tune", "%{!mtune=*:%{!mcpu=*:-mtune=%(VALUE)}}" }, \
+ {"cpu", "%{!mtune=*:%{!mcpu=*:-mtune=%(VALUE)}}" }
+
/* Specs for the compiler proper */
#ifndef CC1_CPU_SPEC
Index: gcc/config/mips/mips.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.249
diff -u -p -r1.249 mips.h
--- gcc/config/mips/mips.h 12 May 2003 13:59:14 -0000 1.249
+++ gcc/config/mips/mips.h 14 May 2003 14:25:45 -0000
@@ -807,6 +807,20 @@ extern void sbss_section PARAMS ((void)
/* This is meant to be redefined in the host dependent files. */
#define SUBTARGET_TARGET_OPTIONS
+/* Support for a compile-time default CPU, et cetera. The rules are:
+ --with-arch is ignored if -march is specified or a -mips is specified
+ (other than -mips16).
+ --with-tune is ignored if -mtune is specified.
+ --with-abi is ignored if -mabi is specified.
+ --with-float is ignored if -mhard-float or -msoft-float are
+ specified. */
+#define OPTION_DEFAULT_SPECS \
+ {"arch", "%{!march=*:%{mips16:-march=%(VALUE)}%{!mips*:-march=%(VALUE)}}" }, \
+ {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
+ {"abi", "%{!mabi=*:-mabi=%(VALUE)}" }, \
+ {"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }
+
+
#define GENERATE_BRANCHLIKELY (TARGET_BRANCHLIKELY \
&& !TARGET_SR71K \
&& !TARGET_MIPS16)
Index: gcc/config/pa/pa.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config/pa/pa.h,v
retrieving revision 1.190
diff -u -p -r1.190 pa.h
--- gcc/config/pa/pa.h 12 May 2003 09:51:33 -0000 1.190
+++ gcc/config/pa/pa.h 14 May 2003 14:26:10 -0000
@@ -312,6 +312,13 @@ extern int target_flags;
N_("Specify architecture for code generation. Values are 1.0, 1.1, and 2.0. 2.0 requires gas snapshot 19990413 or later."), 0}\
}
+/* Support for a compile-time default CPU, et cetera. The rules are:
+ --with-schedule is ignored if -mschedule is specified.
+ --with-arch is ignored if -march is specified. */
+#define OPTION_DEFAULT_SPECS \
+ {"arch", "%{!march=*:-march=%(VALUE)}" }, \
+ {"schedule", "%{!mschedule=*:-mschedule=%(VALUE)}" }
+
/* 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: gcc/config/rs6000/rs6000.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.272
diff -u -p -r1.272 rs6000.h
--- gcc/config/rs6000/rs6000.h 12 May 2003 22:30:30 -0000 1.272
+++ gcc/config/rs6000/rs6000.h 14 May 2003 14:25:33 -0000
@@ -405,6 +405,16 @@ extern enum processor_type rs6000_cpu;
SUBTARGET_OPTIONS \
}
+/* Support for a compile-time default CPU, et cetera. The rules are:
+ --with-cpu is ignored if -mcpu is specified.
+ --with-tune is ignored if -mtune is specified.
+ --with-float is ignored if -mhard-float or -msoft-float are
+ specified. */
+#define OPTION_DEFAULT_SPECS \
+ {"cpu", "%{!mcpu=*:-mcpu=%(VALUE)}" }, \
+ {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
+ {"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }
+
/* rs6000_select[0] is reserved for the default cpu defined via --with-cpu */
struct rs6000_cpu_select
{
Index: gcc/config/sparc/sparc.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/config/sparc/sparc.h,v
retrieving revision 1.223
diff -u -p -r1.223 sparc.h
--- gcc/config/sparc/sparc.h 12 May 2003 09:51:35 -0000 1.223
+++ gcc/config/sparc/sparc.h 14 May 2003 14:26:04 -0000
@@ -643,6 +643,16 @@ extern enum processor_type sparc_cpu;
/* This is meant to be redefined in target specific files. */
#define SUBTARGET_OPTIONS
+/* Support for a compile-time default CPU, et cetera. The rules are:
+ --with-cpu is ignored if -mcpu is specified.
+ --with-tune is ignored if -mtune is specified.
+ --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
+ are specified. */
+#define OPTION_DEFAULT_SPECS \
+ {"cpu", "%{!mcpu=*:-mcpu=%(VALUE)}" }, \
+ {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
+ {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
+
/* sparc_select[0] is reserved for the default cpu. */
struct sparc_cpu_select
{
Index: gcc/doc/install.texi
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/doc/install.texi,v
retrieving revision 1.189
diff -u -p -r1.189 install.texi
--- gcc/doc/install.texi 6 May 2003 23:17:59 -0000 1.189
+++ gcc/doc/install.texi 12 May 2003 22:43:22 -0000
@@ -721,12 +721,21 @@ Microsoft Win32 API thread support.
@end table
@item --with-cpu=@var{cpu}
-Specify which cpu variant the
-compiler should generate code for by default. This is currently
-only supported on 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
-@file{gcc/config.gcc} script for a complete list of supported models.
+Specify which cpu variant the 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 targets, including ARM, i386, PowerPC,
+and SPARC@.
+
+@item --with-schedule=@var{cpu}
+@itemx --with-arch=@var{cpu}
+@itemx --with-tune=@var{cpu}
+@itemx --with-abi=@var{abi}
+@itemx --with-float=@var{type}
+These configure options provide default values for the @code{-mschedule=},
+@code{-march=}, @code{-mtune=}, and @code{-mabi=} options and for
+@code{-mhard-float} or @code{-msoft-float}. As with @code{--with-cpu},
+which switches will be accepted and acceptable values of the arguments depend
+on the target.
@item --enable-altivec
Specify that the target supports AltiVec vector enhancements. This
Index: gcc/doc/tm.texi
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/doc/tm.texi,v
retrieving revision 1.217
diff -u -p -r1.217 tm.texi
--- gcc/doc/tm.texi 10 May 2003 22:59:04 -0000 1.217
+++ gcc/doc/tm.texi 14 May 2003 14:34:10 -0000
@@ -181,6 +181,25 @@ that the other specs are easier to write
Do not define this macro if it does not need to do anything.
+@findex OPTION_DEFAULT_SPECS
+@item OPTION_DEFAULT_SPECS
+A list of specs used to support configure-time default options (i.e.@:
+@code{--with} options) in the driver. It should be a suitable initializer
+for an array of structures, each containing two strings, without the
+outermost pair of surrounding braces.
+
+The first item in the pair is the name of the default. This must match
+the code in @file{config.gcc} for the target. The second item is a spec
+to apply if a default with this name was specified. The string
+@samp{%(VALUE)} in the spec will be replaced by the value of the default
+everywhere it occurs.
+
+The driver will apply these specs to its own command line between loading
+default @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using
+the same mechanism as @code{DRIVER_SELF_SPECS}.
+
+Do not define this macro if it does not need to do anything.
+
@findex CPP_SPEC
@item CPP_SPEC
A C string constant that tells the GCC driver program options to
More information about the Gcc-patches
mailing list