Patchwork Avoid global state in m68k_handle_option

login
register
mail settings
Submitter Joseph S. Myers
Date April 28, 2011, 11:57 p.m.
Message ID <Pine.LNX.4.64.1104282356360.4451@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/93353/
State New
Headers show

Comments

Joseph S. Myers - April 28, 2011, 11:57 p.m.
This patch stops m68k_handle_option from using global state.  The
general approach is similar to that used for ARM: new .def files are
added for the -march= and -mtune= arguments, to go along with the
existing one for -mcpu= arguments, and as well as initializing arrays
in m68k.c these are used to generate a .opt file with the relevant
Enum entries.  Thus gcc_options fields are set automatically from the
arguments to these three options, and m68k_option_override then sets
the resulting pointers (some of which could actually become local
variables in m68k_option_override because they are not used
elsewhere).

The enum uarch_type enumeration now gets its contents from
m68k-microarchs.def; enum target_device already got its contents from
m68k-devices.def.  (Note that the ucfv5 value does not correspond to
any entry in any of the tables, so the code using it is in fact dead.)
The isa_* enum values do not have a one-to-one correspondence with
entries in m68k-isas.def, so that enum still has its values defined
manually and the option uses int values as indices into the table.

Tested building cc1 and xgcc for cross to m68k-elf.  Will commit to
trunk in the absence of target maintainer objections.

contrib:
2011-04-28  Joseph Myers  <joseph@codesourcery.com>

	* gcc_update (gcc/config/m68k/m68k-tables.opt): New dependencies.

gcc:
2011-04-28  Joseph Myers  <joseph@codesourcery.com>

	* config/m68k/genopt.sh, config/m68k/m68k-isas.def,
	config/m68k/m68k-microarchs.def, config/m68k/m68k-opts.h,
	config/m68k/t-opts: New files.
	* config/m68k/m68k-tables.opt: New file (generated).
	* config.gcc (fido-*-*, m68k-*-*): Add m68k/m68k-tables.opt to
	extra_options and m68k/t-opts to tmake_file.
	* config/m68k/m68k.c (m68k_library_id_string): More to m68k.opt.
	(all_isas): Initialize using m68k-isas.def.
	(all_microarchs): Initialize using m68k-microarchs.def.
	(m68k_find_selection): Remove.
	(m68k_handle_option): Don't assert that global structures are in
	use.  Use error_at.  Access variables via opts pointer.  Don't
	handle -march=, -mcpu= and -mtune= here.  Set gcc_options fields
	directly for -m68020-40 and -m68020-60.
	(m68k_option_override): Set m68k_arch_entry, m68k_cpu_entry and
	m68k_tune_entry here.
	* config/m68k/m68k.h (enum uarch_type, enum target_device): Move
	to m68k-opts.h.
	(m68k_library_id_string): Remove declaration.
	* config/m68k/m68k.opt (config/m68k/m68k-opts.h): New
	HeaderInclude.
	(m68k_library_id_string): New Variable.
	(march=, mcpu=, mtune=): Use Enum and Var.

Patch

Index: contrib/gcc_update
===================================================================
--- contrib/gcc_update	(revision 173046)
+++ contrib/gcc_update	(working copy)
@@ -81,6 +81,7 @@  gcc/config.in: gcc/cstamp-h.in
 gcc/fixinc/fixincl.x: gcc/fixinc/fixincl.tpl gcc/fixinc/inclhack.def
 gcc/config/arm/arm-tune.md: gcc/config/arm/arm-cores.def gcc/config/arm/gentune.sh
 gcc/config/arm/arm-tables.opt: gcc/config/arm/arm-arches.def gcc/config/arm/arm-cores.def gcc/config/arm/genopt.sh
+gcc/config/m68k/m68k-tables.opt: gcc/config/m68k/m68k-devices.def gcc/config/m68k/m68k-isas.def gcc/config/m68k/m68k-microarchs.def gcc/config/m68k/genopt.sh
 # And then, language-specific files
 gcc/cp/cfns.h: gcc/cp/cfns.gperf
 gcc/java/keyword.h: gcc/java/keyword.gperf
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 173046)
+++ gcc/config.gcc	(working copy)
@@ -317,6 +317,7 @@  moxie*)	cpu_type=moxie
 fido-*-*)
 	cpu_type=m68k
 	extra_headers=math-68881.h
+	extra_options="${extra_options} m68k/m68k-tables.opt"
         ;;
 i[34567]86-*-*)
 	cpu_type=i386
@@ -360,6 +361,7 @@  m32r*-*-*)
         ;;
 m68k-*-*)
 	extra_headers=math-68881.h
+	extra_options="${extra_options} m68k/m68k-tables.opt"
 	;;
 microblaze*-*-*)
         cpu_type=microblaze
@@ -3524,6 +3526,7 @@  case ${target} in
 
 	fido*-*-* | m68k*-*-*)
 		target_cpu_default2=$m68k_cpu_ident
+		tmake_file="m68k/t-opts $tmake_file"
 		if [ x"$m68k_arch_family" != x ]; then
 		        tmake_file="m68k/t-$m68k_arch_family $tmake_file"
 		fi
Index: gcc/config/m68k/m68k-isas.def
===================================================================
--- gcc/config/m68k/m68k-isas.def	(revision 0)
+++ gcc/config/m68k/m68k-isas.def	(revision 0)
@@ -0,0 +1,43 @@ 
+/* m68k ISA names.
+   Copyright (C) 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Define ISAs for the -march option, used both in m68k.c and to
+   generate m68k-tables.opt.  Before including this file, define a
+   macro:
+
+   M68K_ISA (NAME, DEVICE, MICROARCH, ISA, FLAGS)
+
+   where NAME is the name for use with -march=, DEVICE is the value in
+   the target_device enumeration of a representative device, FLAGS is
+   the set of FL_* flags that apply to this ISA and the other
+   arguments are as for M68K_DEVICE in m68k-devices.def.  */
+
+M68K_ISA ("68000",    m68000,     68000, isa_00,    FL_FOR_isa_00)
+M68K_ISA ("68010",    m68010,     68010, isa_10,    FL_FOR_isa_10)
+M68K_ISA ("68020",    m68020,     68020, isa_20,    FL_FOR_isa_20)
+M68K_ISA ("68030",    m68030,     68030, isa_20,    FL_FOR_isa_20)
+M68K_ISA ("68040",    m68040,     68040, isa_40,    FL_FOR_isa_40)
+M68K_ISA ("68060",    m68060,     68060, isa_40,    FL_FOR_isa_40)
+M68K_ISA ("cpu32",    cpu32,      cpu32, isa_20,    FL_FOR_isa_cpu32)
+M68K_ISA ("isaa",     mcf5206e,   cfv2,  isa_a,     FL_FOR_isa_a | FL_CF_HWDIV)
+M68K_ISA ("isaaplus", mcf5271,    cfv2,  isa_aplus, FL_FOR_isa_aplus | FL_CF_HWDIV)
+M68K_ISA ("isab",     mcf5407,    cfv4,  isa_b,     FL_FOR_isa_b)
+M68K_ISA ("isac",     unk_device, cfv4,  isa_c,     FL_FOR_isa_c | FL_CF_HWDIV)
Index: gcc/config/m68k/t-opts
===================================================================
--- gcc/config/m68k/t-opts	(revision 0)
+++ gcc/config/m68k/t-opts	(revision 0)
@@ -0,0 +1,5 @@ 
+$(srcdir)/config/m68k/m68k-tables.opt: $(srcdir)/config/m68k/genopt.sh \
+  $(srcdir)/config/m68k/m68k-devices.def $(srcdir)/config/m68k/m68k-isas.def \
+  $(srcdir)/config/m68k/m68k-microarchs.def
+	$(SHELL) $(srcdir)/config/m68k/genopt.sh $(srcdir)/config/m68k > \
+		$(srcdir)/config/m68k/m68k-tables.opt
Index: gcc/config/m68k/m68k-opts.h
===================================================================
--- gcc/config/m68k/m68k-opts.h	(revision 0)
+++ gcc/config/m68k/m68k-opts.h	(revision 0)
@@ -0,0 +1,46 @@ 
+/* Definitions for option handling for Motorola 680x0/ColdFire.
+   Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef M68K_OPTS_H
+#define M68K_OPTS_H
+
+/* Values used in the MICROARCH argument to M68K_DEVICE.  */
+enum uarch_type
+{
+#define M68K_MICROARCH(NAME,DEVICE,MICROARCH,ISA,FLAGS) \
+  u##MICROARCH,
+#include "m68k-microarchs.def"
+#undef M68K_MICROARCH
+  ucfv5,
+  unk_arch
+};
+
+/* An enumeration of all supported target devices.  */
+enum target_device
+{
+#define M68K_DEVICE(NAME,ENUM_VALUE,FAMILY,MULTILIB,MICROARCH,ISA,FLAGS) \
+  ENUM_VALUE,
+#include "m68k-devices.def"
+#undef M68K_DEVICE
+  unk_device
+};
+
+#endif
Index: gcc/config/m68k/m68k-microarchs.def
===================================================================
--- gcc/config/m68k/m68k-microarchs.def	(revision 0)
+++ gcc/config/m68k/m68k-microarchs.def	(revision 0)
@@ -0,0 +1,46 @@ 
+/* m68k microarchitecture names.
+   Copyright (C) 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Define microarchitectures for the -mtune option, used both in
+   m68k.c and to generate m68k-tables.opt.  Before including this
+   file, define a macro:
+
+   M68K_MICROARCH (NAME, DEVICE, MICROARCH, ISA, FLAGS)
+
+   where NAME is the name for use with -mtune=, DEVICE is the value in
+   the target_device enumeration of a representative device, FLAGS is
+   the set of FL_* flags that apply to this ISA and the other
+   arguments are as for M68K_DEVICE in m68k-devices.def.  */
+
+M68K_MICROARCH ("68000",    m68000,  68000,    isa_00,  FL_FOR_isa_00)
+M68K_MICROARCH ("68010",    m68010,  68010,    isa_10,  FL_FOR_isa_10)
+M68K_MICROARCH ("68020",    m68020,  68020,    isa_20,  FL_FOR_isa_20)
+M68K_MICROARCH ("68020-40", m68020,  68020_40, isa_20,  FL_FOR_isa_20)
+M68K_MICROARCH ("68020-60", m68020,  68020_60, isa_20,  FL_FOR_isa_20)
+M68K_MICROARCH ("68030",    m68030,  68030,    isa_20,  FL_FOR_isa_20)
+M68K_MICROARCH ("68040",    m68040,  68040,    isa_40,  FL_FOR_isa_40)
+M68K_MICROARCH ("68060",    m68060,  68060,    isa_40,  FL_FOR_isa_40)
+M68K_MICROARCH ("cpu32",    cpu32,   cpu32,    isa_20,  FL_FOR_isa_cpu32)
+M68K_MICROARCH ("cfv1",     mcf51qe, cfv1,     isa_c,   FL_FOR_isa_c)
+M68K_MICROARCH ("cfv2",     mcf5206, cfv2,     isa_a,   FL_FOR_isa_a)
+M68K_MICROARCH ("cfv3",     mcf5307, cfv3,     isa_a,   FL_FOR_isa_a | FL_CF_HWDIV)
+M68K_MICROARCH ("cfv4",     mcf5407, cfv4,     isa_b,   FL_FOR_isa_b)
+M68K_MICROARCH ("cfv4e",    mcf547x, cfv4e,    isa_b,   FL_FOR_isa_b | FL_CF_USP| FL_CF_EMAC | FL_CF_FPU)
Index: gcc/config/m68k/m68k.opt
===================================================================
--- gcc/config/m68k/m68k.opt	(revision 173046)
+++ gcc/config/m68k/m68k.opt	(working copy)
@@ -19,6 +19,13 @@ 
 ; along with GCC; see the file COPYING3.  If not see
 ; <http://www.gnu.org/licenses/>.
 
+HeaderInclude
+config/m68k/m68k-opts.h
+
+; Specify the identification number of the library being built.
+Variable
+const char *m68k_library_id_string = "_current_shared_library_a5_offset_"
+
 m5200
 Target RejectNegative Alias(mcpu=, 5206)
 Generate code for a 520X
@@ -93,7 +100,7 @@  Target Report Mask(ALIGN_INT)
 Align variables on a 32-bit boundary
 
 march=
-Target RejectNegative Joined
+Target RejectNegative Joined Enum(m68k_isa) Var(m68k_arch_option)
 Specify the name of the target architecture
 
 mbitfield
@@ -113,7 +120,7 @@  Target RejectNegative Alias(mcpu=, 547x)
 Generate code for a ColdFire v4e
 
 mcpu=
-Target RejectNegative Joined
+Target RejectNegative Joined Enum(target_device) Var(m68k_cpu_option) Init(unk_device)
 Specify the target CPU
 
 mcpu32
@@ -177,7 +184,7 @@  Target Report Mask(STRICT_ALIGNMENT)
 Do not use unaligned memory references
 
 mtune=
-Target RejectNegative Joined
+Target RejectNegative Joined Enum(uarch_type) Var(m68k_tune_option) Init(unk_arch)
 Tune for the specified target CPU or architecture
 
 mxgot
Index: gcc/config/m68k/m68k-tables.opt
===================================================================
--- gcc/config/m68k/m68k-tables.opt	(revision 0)
+++ gcc/config/m68k/m68k-tables.opt	(revision 0)
@@ -0,0 +1,427 @@ 
+; -*- buffer-read-only: t -*-
+; Generated automatically by genopt.sh from m68k-devices.def,
+; m68k-isas.def and m68k-microarchs.def.
+
+; Copyright (C) 2011 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Enum
+Name(target_device) Type(enum target_device)
+Known M68K CPUs (for use with the -mcpu= option):
+
+EnumValue
+Enum(target_device) String(68000) Value(m68000)
+
+EnumValue
+Enum(target_device) String(68010) Value(m68010)
+
+EnumValue
+Enum(target_device) String(68020) Value(m68020)
+
+EnumValue
+Enum(target_device) String(68030) Value(m68030)
+
+EnumValue
+Enum(target_device) String(68040) Value(m68040)
+
+EnumValue
+Enum(target_device) String(68060) Value(m68060)
+
+EnumValue
+Enum(target_device) String(68302) Value(m68302)
+
+EnumValue
+Enum(target_device) String(68332) Value(m68332)
+
+EnumValue
+Enum(target_device) String(cpu32) Value(cpu32)
+
+EnumValue
+Enum(target_device) String(51) Value(mcf51)
+
+EnumValue
+Enum(target_device) String(51ac) Value(mcf51ac)
+
+EnumValue
+Enum(target_device) String(51cn) Value(mcf51cn)
+
+EnumValue
+Enum(target_device) String(51em) Value(mcf51em)
+
+EnumValue
+Enum(target_device) String(51jm) Value(mcf51jm)
+
+EnumValue
+Enum(target_device) String(51qe) Value(mcf51qe)
+
+EnumValue
+Enum(target_device) String(5202) Value(mcf5202)
+
+EnumValue
+Enum(target_device) String(5204) Value(mcf5204)
+
+EnumValue
+Enum(target_device) String(5206) Value(mcf5206)
+
+EnumValue
+Enum(target_device) String(5206e) Value(mcf5206e)
+
+EnumValue
+Enum(target_device) String(5207) Value(mcf5207)
+
+EnumValue
+Enum(target_device) String(5208) Value(mcf5208)
+
+EnumValue
+Enum(target_device) String(5210a) Value(mcf5210a)
+
+EnumValue
+Enum(target_device) String(5211a) Value(mcf5211a)
+
+EnumValue
+Enum(target_device) String(5211) Value(mcf5211)
+
+EnumValue
+Enum(target_device) String(5212) Value(mcf5212)
+
+EnumValue
+Enum(target_device) String(5213) Value(mcf5213)
+
+EnumValue
+Enum(target_device) String(5214) Value(mcf5214)
+
+EnumValue
+Enum(target_device) String(5216) Value(mcf5216)
+
+EnumValue
+Enum(target_device) String(5221x) Value(mcf5221x)
+
+EnumValue
+Enum(target_device) String(52221) Value(mcf52221)
+
+EnumValue
+Enum(target_device) String(52223) Value(mcf52223)
+
+EnumValue
+Enum(target_device) String(52230) Value(mcf52230)
+
+EnumValue
+Enum(target_device) String(52231) Value(mcf52231)
+
+EnumValue
+Enum(target_device) String(52232) Value(mcf52232)
+
+EnumValue
+Enum(target_device) String(52233) Value(mcf52233)
+
+EnumValue
+Enum(target_device) String(52234) Value(mcf52234)
+
+EnumValue
+Enum(target_device) String(52235) Value(mcf52235)
+
+EnumValue
+Enum(target_device) String(5224) Value(mcf5224)
+
+EnumValue
+Enum(target_device) String(5225) Value(mcf5225)
+
+EnumValue
+Enum(target_device) String(52252) Value(mcf52252)
+
+EnumValue
+Enum(target_device) String(52254) Value(mcf52254)
+
+EnumValue
+Enum(target_device) String(52255) Value(mcf52255)
+
+EnumValue
+Enum(target_device) String(52256) Value(mcf52256)
+
+EnumValue
+Enum(target_device) String(52258) Value(mcf52258)
+
+EnumValue
+Enum(target_device) String(52259) Value(mcf52259)
+
+EnumValue
+Enum(target_device) String(52274) Value(mcf52274)
+
+EnumValue
+Enum(target_device) String(52277) Value(mcf52277)
+
+EnumValue
+Enum(target_device) String(5232) Value(mcf5232)
+
+EnumValue
+Enum(target_device) String(5233) Value(mcf5233)
+
+EnumValue
+Enum(target_device) String(5234) Value(mcf5234)
+
+EnumValue
+Enum(target_device) String(5235) Value(mcf5235)
+
+EnumValue
+Enum(target_device) String(523x) Value(mcf523x)
+
+EnumValue
+Enum(target_device) String(5249) Value(mcf5249)
+
+EnumValue
+Enum(target_device) String(5250) Value(mcf5250)
+
+EnumValue
+Enum(target_device) String(5253) Value(mcf5253)
+
+EnumValue
+Enum(target_device) String(5270) Value(mcf5270)
+
+EnumValue
+Enum(target_device) String(5271) Value(mcf5271)
+
+EnumValue
+Enum(target_device) String(5272) Value(mcf5272)
+
+EnumValue
+Enum(target_device) String(5274) Value(mcf5274)
+
+EnumValue
+Enum(target_device) String(5275) Value(mcf5275)
+
+EnumValue
+Enum(target_device) String(5280) Value(mcf5280)
+
+EnumValue
+Enum(target_device) String(5281) Value(mcf5281)
+
+EnumValue
+Enum(target_device) String(5282) Value(mcf5282)
+
+EnumValue
+Enum(target_device) String(528x) Value(mcf528x)
+
+EnumValue
+Enum(target_device) String(53011) Value(mcf53011)
+
+EnumValue
+Enum(target_device) String(53012) Value(mcf53012)
+
+EnumValue
+Enum(target_device) String(53013) Value(mcf53013)
+
+EnumValue
+Enum(target_device) String(53014) Value(mcf53014)
+
+EnumValue
+Enum(target_device) String(53015) Value(mcf53015)
+
+EnumValue
+Enum(target_device) String(53016) Value(mcf53016)
+
+EnumValue
+Enum(target_device) String(53017) Value(mcf53017)
+
+EnumValue
+Enum(target_device) String(5307) Value(mcf5307)
+
+EnumValue
+Enum(target_device) String(5327) Value(mcf5327)
+
+EnumValue
+Enum(target_device) String(5328) Value(mcf5328)
+
+EnumValue
+Enum(target_device) String(5329) Value(mcf5329)
+
+EnumValue
+Enum(target_device) String(532x) Value(mcf532x)
+
+EnumValue
+Enum(target_device) String(5372) Value(mcf5372)
+
+EnumValue
+Enum(target_device) String(5373) Value(mcf5373)
+
+EnumValue
+Enum(target_device) String(537x) Value(mcf537x)
+
+EnumValue
+Enum(target_device) String(5407) Value(mcf5407)
+
+EnumValue
+Enum(target_device) String(54410) Value(mcf54410)
+
+EnumValue
+Enum(target_device) String(54415) Value(mcf54415)
+
+EnumValue
+Enum(target_device) String(54416) Value(mcf54416)
+
+EnumValue
+Enum(target_device) String(54417) Value(mcf54417)
+
+EnumValue
+Enum(target_device) String(54418) Value(mcf54418)
+
+EnumValue
+Enum(target_device) String(54450) Value(mcf54450)
+
+EnumValue
+Enum(target_device) String(54451) Value(mcf54451)
+
+EnumValue
+Enum(target_device) String(54452) Value(mcf54452)
+
+EnumValue
+Enum(target_device) String(54453) Value(mcf54453)
+
+EnumValue
+Enum(target_device) String(54454) Value(mcf54454)
+
+EnumValue
+Enum(target_device) String(54455) Value(mcf54455)
+
+EnumValue
+Enum(target_device) String(5470) Value(mcf5470)
+
+EnumValue
+Enum(target_device) String(5471) Value(mcf5471)
+
+EnumValue
+Enum(target_device) String(5472) Value(mcf5472)
+
+EnumValue
+Enum(target_device) String(5473) Value(mcf5473)
+
+EnumValue
+Enum(target_device) String(5474) Value(mcf5474)
+
+EnumValue
+Enum(target_device) String(5475) Value(mcf5475)
+
+EnumValue
+Enum(target_device) String(547x) Value(mcf547x)
+
+EnumValue
+Enum(target_device) String(5480) Value(mcf5480)
+
+EnumValue
+Enum(target_device) String(5481) Value(mcf5481)
+
+EnumValue
+Enum(target_device) String(5482) Value(mcf5482)
+
+EnumValue
+Enum(target_device) String(5483) Value(mcf5483)
+
+EnumValue
+Enum(target_device) String(5484) Value(mcf5484)
+
+EnumValue
+Enum(target_device) String(5485) Value(mcf5485)
+
+EnumValue
+Enum(target_device) String(548x) Value(mcf548x)
+
+EnumValue
+Enum(target_device) String(fidoa) Value(fidoa)
+
+Enum
+Name(uarch_type) Type(enum uarch_type)
+Known M68K microarchitectures (for use with the -mtune= option):
+
+EnumValue
+Enum(uarch_type) String(68000) Value(u68000)
+
+EnumValue
+Enum(uarch_type) String(68010) Value(u68010)
+
+EnumValue
+Enum(uarch_type) String(68020) Value(u68020)
+
+EnumValue
+Enum(uarch_type) String(68020-40) Value(u68020_40)
+
+EnumValue
+Enum(uarch_type) String(68020-60) Value(u68020_60)
+
+EnumValue
+Enum(uarch_type) String(68030) Value(u68030)
+
+EnumValue
+Enum(uarch_type) String(68040) Value(u68040)
+
+EnumValue
+Enum(uarch_type) String(68060) Value(u68060)
+
+EnumValue
+Enum(uarch_type) String(cpu32) Value(ucpu32)
+
+EnumValue
+Enum(uarch_type) String(cfv1) Value(ucfv1)
+
+EnumValue
+Enum(uarch_type) String(cfv2) Value(ucfv2)
+
+EnumValue
+Enum(uarch_type) String(cfv3) Value(ucfv3)
+
+EnumValue
+Enum(uarch_type) String(cfv4) Value(ucfv4)
+
+EnumValue
+Enum(uarch_type) String(cfv4e) Value(ucfv4e)
+
+Enum
+Name(m68k_isa) Type(int)
+Known M68K ISAs (for use with the -march= option):
+
+EnumValue
+Enum(m68k_isa) String(68000) Value(0)
+
+EnumValue
+Enum(m68k_isa) String(68010) Value(1)
+
+EnumValue
+Enum(m68k_isa) String(68020) Value(2)
+
+EnumValue
+Enum(m68k_isa) String(68030) Value(3)
+
+EnumValue
+Enum(m68k_isa) String(68040) Value(4)
+
+EnumValue
+Enum(m68k_isa) String(68060) Value(5)
+
+EnumValue
+Enum(m68k_isa) String(cpu32) Value(6)
+
+EnumValue
+Enum(m68k_isa) String(isaa) Value(7)
+
+EnumValue
+Enum(m68k_isa) String(isaaplus) Value(8)
+
+EnumValue
+Enum(m68k_isa) String(isab) Value(9)
+
+EnumValue
+Enum(m68k_isa) String(isac) Value(10)
+
Index: gcc/config/m68k/genopt.sh
===================================================================
--- gcc/config/m68k/genopt.sh	(revision 0)
+++ gcc/config/m68k/genopt.sh	(revision 0)
@@ -0,0 +1,92 @@ 
+#!/bin/sh
+# Generate m68k-tables.opt from the lists in *.def.
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+cat <<EOF
+; -*- buffer-read-only: t -*-
+; Generated automatically by genopt.sh from m68k-devices.def,
+; m68k-isas.def and m68k-microarchs.def.
+
+; Copyright (C) 2011 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Enum
+Name(target_device) Type(enum target_device)
+Known M68K CPUs (for use with the -mcpu= option):
+
+EOF
+
+awk -F'[(, 	]+' '/^M68K_DEVICE/ {
+    name = $2
+    enum = $3
+    gsub("\"", "", name)
+    print "EnumValue"
+    print "Enum(target_device) String(" name ") Value(" enum ")"
+    print ""
+}' $1/m68k-devices.def
+
+cat <<EOF
+Enum
+Name(uarch_type) Type(enum uarch_type)
+Known M68K microarchitectures (for use with the -mtune= option):
+
+EOF
+
+awk -F'[(, 	]+' '/^M68K_MICROARCH/ {
+    name = $2
+    enum = $4
+    gsub("\"", "", name)
+    print "EnumValue"
+    print "Enum(uarch_type) String(" name ") Value(u" enum ")"
+    print ""
+}' $1/m68k-microarchs.def
+
+cat <<EOF
+Enum
+Name(m68k_isa) Type(int)
+Known M68K ISAs (for use with the -march= option):
+
+EOF
+
+awk -F'[(, 	]+' 'BEGIN {
+    value = 0
+}
+/^M68K_ISA/ {
+    name = $2
+    gsub("\"", "", name)
+    print "EnumValue"
+    print "Enum(m68k_isa) String(" name ") Value(" value ")"
+    print ""
+    value++
+}' $1/m68k-isas.def

Property changes on: gcc/config/m68k/genopt.sh
___________________________________________________________________
Added: svn:executable
   + *

Index: gcc/config/m68k/m68k.c
===================================================================
--- gcc/config/m68k/m68k.c	(revision 173046)
+++ gcc/config/m68k/m68k.c	(working copy)
@@ -165,10 +165,6 @@  static rtx m68k_function_arg (CUMULATIVE
 			      const_tree, bool);
 static bool m68k_cannot_force_const_mem (enum machine_mode mode, rtx x);
 
-
-/* Specify the identification number of the library being built */
-const char *m68k_library_id_string = "_current_shared_library_a5_offset_";
-
 /* Initialize the GCC target structure.  */
 
 #if INT_OP_GROUP == INT_OP_DOT_WORD
@@ -385,20 +381,10 @@  static const struct m68k_target_selectio
    Used for -march selection.  */
 static const struct m68k_target_selection all_isas[] =
 {
-  { "68000",    m68000,     NULL,  u68000,   isa_00,    FL_FOR_isa_00 },
-  { "68010",    m68010,     NULL,  u68010,   isa_10,    FL_FOR_isa_10 },
-  { "68020",    m68020,     NULL,  u68020,   isa_20,    FL_FOR_isa_20 },
-  { "68030",    m68030,     NULL,  u68030,   isa_20,    FL_FOR_isa_20 },
-  { "68040",    m68040,     NULL,  u68040,   isa_40,    FL_FOR_isa_40 },
-  { "68060",    m68060,     NULL,  u68060,   isa_40,    FL_FOR_isa_40 },
-  { "cpu32",    cpu32,      NULL,  ucpu32,   isa_20,    FL_FOR_isa_cpu32 },
-  { "isaa",     mcf5206e,   NULL,  ucfv2,    isa_a,     (FL_FOR_isa_a
-							 | FL_CF_HWDIV) },
-  { "isaaplus", mcf5271,    NULL,  ucfv2,    isa_aplus, (FL_FOR_isa_aplus
-							 | FL_CF_HWDIV) },
-  { "isab",     mcf5407,    NULL,  ucfv4,    isa_b,     FL_FOR_isa_b },
-  { "isac",     unk_device, NULL,  ucfv4,    isa_c,     (FL_FOR_isa_c
-							 | FL_CF_HWDIV) },
+#define M68K_ISA(NAME,DEVICE,MICROARCH,ISA,FLAGS) \
+  { NAME, DEVICE, NULL, u##MICROARCH, ISA, FLAGS },
+#include "m68k-isas.def"
+#undef M68K_ISA
   { NULL,       unk_device, NULL,  unk_arch, isa_max,   0 }
 };
 
@@ -406,24 +392,10 @@  static const struct m68k_target_selectio
    device.  Used for -mtune selection.  */
 static const struct m68k_target_selection all_microarchs[] =
 {
-  { "68000",    m68000,     NULL,  u68000,    isa_00,  FL_FOR_isa_00 },
-  { "68010",    m68010,     NULL,  u68010,    isa_10,  FL_FOR_isa_10 },
-  { "68020",    m68020,     NULL,  u68020,    isa_20,  FL_FOR_isa_20 },
-  { "68020-40", m68020,     NULL,  u68020_40, isa_20,  FL_FOR_isa_20 },
-  { "68020-60", m68020,     NULL,  u68020_60, isa_20,  FL_FOR_isa_20 },
-  { "68030",    m68030,     NULL,  u68030,    isa_20,  FL_FOR_isa_20 },
-  { "68040",    m68040,     NULL,  u68040,    isa_40,  FL_FOR_isa_40 },
-  { "68060",    m68060,     NULL,  u68060,    isa_40,  FL_FOR_isa_40 },
-  { "cpu32",    cpu32,      NULL,  ucpu32,    isa_20,  FL_FOR_isa_cpu32 },
-  { "cfv1",     mcf51qe,    NULL,  ucfv1,     isa_c,   FL_FOR_isa_c },
-  { "cfv2",     mcf5206,    NULL,  ucfv2,     isa_a,   FL_FOR_isa_a },
-  { "cfv3",     mcf5307,    NULL,  ucfv3,     isa_a,   (FL_FOR_isa_a
-							| FL_CF_HWDIV) },
-  { "cfv4",     mcf5407,    NULL,  ucfv4,     isa_b,   FL_FOR_isa_b },
-  { "cfv4e",    mcf547x,    NULL,  ucfv4e,    isa_b,   (FL_FOR_isa_b
-							| FL_CF_USP
-							| FL_CF_EMAC
-							| FL_CF_FPU) },
+#define M68K_MICROARCH(NAME,DEVICE,MICROARCH,ISA,FLAGS) \
+  { NAME, DEVICE, NULL, u##MICROARCH, ISA, FLAGS },
+#include "m68k-microarchs.def"
+#undef M68K_MICROARCH
   { NULL,       unk_device, NULL,  unk_arch,  isa_max, 0 }
 };
 
@@ -458,70 +430,39 @@  const char *m68k_symbolic_jump;
 enum M68K_SYMBOLIC_CALL m68k_symbolic_call_var;
 
 
-/* See whether TABLE has an entry with name NAME.  Return true and
-   store the entry in *ENTRY if so, otherwise return false and
-   leave *ENTRY alone.  */
-
-static bool
-m68k_find_selection (const struct m68k_target_selection **entry,
-		     const struct m68k_target_selection *table,
-		     const char *name)
-{
-  size_t i;
-
-  for (i = 0; table[i].name; i++)
-    if (strcmp (table[i].name, name) == 0)
-      {
-	*entry = table + i;
-	return true;
-      }
-  return false;
-}
-
 /* Implement TARGET_HANDLE_OPTION.  */
 
 static bool
-m68k_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
+m68k_handle_option (struct gcc_options *opts,
+		    struct gcc_options *opts_set ATTRIBUTE_UNUSED,
 		    const struct cl_decoded_option *decoded,
-		    location_t loc ATTRIBUTE_UNUSED)
+		    location_t loc)
 {
   size_t code = decoded->opt_index;
   const char *arg = decoded->arg;
   int value = decoded->value;
 
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
-
   switch (code)
     {
-    case OPT_march_:
-      return m68k_find_selection (&m68k_arch_entry, all_isas, arg);
-
-    case OPT_mcpu_:
-      return m68k_find_selection (&m68k_cpu_entry, all_devices, arg);
-
-    case OPT_mtune_:
-      return m68k_find_selection (&m68k_tune_entry, all_microarchs, arg);
-
     case OPT_m68020_40:
-      return (m68k_find_selection (&m68k_tune_entry, all_microarchs,
-				   "68020-40")
-	      && m68k_find_selection (&m68k_cpu_entry, all_devices, "68020"));
+      opts->x_m68k_tune_option = u68020_40;
+      opts->x_m68k_cpu_option = m68020;
+      return true;
 
     case OPT_m68020_60:
-      return (m68k_find_selection (&m68k_tune_entry, all_microarchs,
-				   "68020-60")
-	      && m68k_find_selection (&m68k_cpu_entry, all_devices, "68020"));
+      opts->x_m68k_tune_option = u68020_60;
+      opts->x_m68k_cpu_option = m68020;
+      return true;
 
     case OPT_mshared_library_id_:
       if (value > MAX_LIBRARY_ID)
-	error ("-mshared-library-id=%s is not between 0 and %d",
-	       arg, MAX_LIBRARY_ID);
+	error_at (loc, "-mshared-library-id=%s is not between 0 and %d",
+		  arg, MAX_LIBRARY_ID);
       else
         {
 	  char *tmp;
 	  asprintf (&tmp, "%d", (value * -4) - 4);
-	  m68k_library_id_string = tmp;
+	  opts->x_m68k_library_id_string = tmp;
 	}
       return true;
 
@@ -538,6 +479,15 @@  m68k_option_override (void)
   const struct m68k_target_selection *entry;
   unsigned long target_mask;
 
+  if (global_options_set.x_m68k_arch_option)
+    m68k_arch_entry = &all_isas[m68k_arch_option];
+
+  if (global_options_set.x_m68k_cpu_option)
+    m68k_cpu_entry = &all_devices[(int) m68k_cpu_option];
+
+  if (global_options_set.x_m68k_tune_option)
+    m68k_tune_entry = &all_microarchs[(int) m68k_tune_option];
+
   /* User can choose:
 
      -mcpu=
Index: gcc/config/m68k/m68k.h
===================================================================
--- gcc/config/m68k/m68k.h	(revision 173046)
+++ gcc/config/m68k/m68k.h	(working copy)
@@ -941,36 +941,7 @@  do {							\
     goto FAIL;						\
 } while (0);
 
-/* Values used in the MICROARCH argument to M68K_DEVICE.  */
-enum uarch_type
-{
-  u68000,
-  u68010,
-  u68020,
-  u68020_40,
-  u68020_60,
-  u68030,
-  u68040,
-  u68060,
-  ucpu32,
-  ucfv1,
-  ucfv2,
-  ucfv3,
-  ucfv4,
-  ucfv4e,
-  ucfv5,
-  unk_arch
-};
-
-/* An enumeration of all supported target devices.  */
-enum target_device
-{
-#define M68K_DEVICE(NAME,ENUM_VALUE,FAMILY,MULTILIB,MICROARCH,ISA,FLAGS) \
-  ENUM_VALUE,
-#include "m68k-devices.def"
-#undef M68K_DEVICE
-  unk_device
-};
+#include "config/m68k/m68k-opts.h"
 
 enum fpu_type
 {
@@ -987,7 +958,6 @@  enum m68k_function_kind
 };
 
 /* Variables in m68k.c; see there for details.  */
-extern const char *m68k_library_id_string;
 extern enum target_device m68k_cpu;
 extern enum uarch_type m68k_tune;
 extern enum fpu_type m68k_fpu;