[1/4,MSP430] Consolidate hard-coded MCU data

Message ID d6c4846d-6eda-5902-d4e6-69b345888e36@mittosystems.com
State Superseded
Headers show
Series
  • Add methods to extract MCU data from file
Related show

Commit Message

Jozef Lawrynowicz June 27, 2018, 11:49 a.m.
> The first patch keeps the hard-coded data as the only way of reading 

> MCU data,

> but consolidates it in a single file. Extensions to the spec handling in

> msp430.h mean that the hard-coded data is no longer needed in 

> 't-msp430' for

> multilib selection, or in the assembler. This is achieved by the 

> driver which

> places the corresponding mcpu value for the MCU on its command line.

>

Ok for trunk?

Patch

From 751a5b4f32a91d697b56fa94ca8426fa6679c5fa Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Thu, 7 Jun 2018 14:44:10 +0100
Subject: [PATCH 1/4] MSP430 - Devices 1 - Handle device tasks in separate file

2018-06-27  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

gcc/
	* config.gcc (msp430*-*-*): Add msp430-devices.o to extra_objs and
	extra_gcc_objs.

gcc/config/msp430/

	* msp430-devices.c: New.
	* msp430-devices.h: New.
	* driver-msp430.c (msp430_select_cpu): New spec function to return
	-mcpu value for given mcu.
	(msp430_select_hwmult_lib): Call msp430_extract_mcu_data to get MCU
	data.
	(msp430_mcu_data): Remove.
	* msp430.c (msp430_mcu_data): Remove.
	(msp430_mcu_name): Call msp430_extract_mcu_data to get MCU data.
	(msp430_option_override): Likewise.
	(msp430_use_f5_series_hwmult): Likewise.
	(use_32bit_hwmult): Likewise.
	(msp430_no_hwmult): Likewise.
	* msp430.h (EXTRA_SPEC_FUNCTIONS): Add msp430_select_cpu.
	(DRIVER_SELF_SPECS): Define.
	(ASM_SPEC): Don't pass mmcu option to assembler.
	* t-msp430: Add makefile rule for msp430-devices.o.
	Remove MULTILIB_MATCHES containing MCU names.

gcc/testsuite/gcc.target/msp430/

	* devices-main.c: New generic test source file.
	* msp430.exp (msp430_set_old_board_info_ldflags): New.
	(msp430_reset_board_info_ldflags): New.
	(msp430_get_multidir): New.
	(check_effective_target_430_selected): New.
	(check_effective_target_msp430_hwmul_not_none): New.
	(check_effective_target_msp430_hwmul_not_16bit): New.
	(check_effective_target_msp430_hwmul_not_32bit): New.
	(check_effective_target_msp430_hwmul_not_f5): New.
	(msp430_get_supported_opts): New.
	(msp430_device_permutations_runtest): New.
	(dg-msp-options): New dg-directive for MSP430.
	* devices/README
	* devices/hard_cc430f5123.c
	* devices/hard_foo.c
	* devices/hard_msp430afe253.c
	* devices/hard_msp430cg4616.c
	* devices/hard_msp430f4783.c
	* devices/hard_rf430frl154h_rom.c
---
 gcc/config.gcc                                     |   3 +-
 gcc/config/msp430/driver-msp430.c                  | 667 +------------------
 gcc/config/msp430/msp430-devices.c                 | 673 +++++++++++++++++++
 gcc/config/msp430/msp430-devices.h                 |  11 +
 gcc/config/msp430/msp430.c                         | 732 ++-------------------
 gcc/config/msp430/msp430.h                         |  14 +-
 gcc/config/msp430/t-msp430                         | 237 +------
 gcc/testsuite/gcc.target/msp430/devices-main.c     |   5 +
 gcc/testsuite/gcc.target/msp430/devices/README     |  15 +
 .../gcc.target/msp430/devices/hard_cc430f5123.c    |   7 +
 gcc/testsuite/gcc.target/msp430/devices/hard_foo.c |   5 +
 .../gcc.target/msp430/devices/hard_msp430afe253.c  |   7 +
 .../gcc.target/msp430/devices/hard_msp430cg4616.c  |   7 +
 .../gcc.target/msp430/devices/hard_msp430f4783.c   |   7 +
 .../msp430/devices/hard_rf430frl154h_rom.c         |   7 +
 gcc/testsuite/gcc.target/msp430/msp430.exp         | 207 +++++-
 16 files changed, 1057 insertions(+), 1547 deletions(-)
 create mode 100644 gcc/config/msp430/msp430-devices.c
 create mode 100644 gcc/config/msp430/msp430-devices.h
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices-main.c
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices/README
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices/hard_cc430f5123.c
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices/hard_foo.c
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices/hard_msp430afe253.c
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices/hard_msp430cg4616.c
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices/hard_msp430f4783.c
 create mode 100644 gcc/testsuite/gcc.target/msp430/devices/hard_rf430frl154h_rom.c

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 63162aa..0ba941f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2340,7 +2340,8 @@  msp430*-*-*)
 	c_target_objs="msp430-c.o"
 	cxx_target_objs="msp430-c.o"
 	tmake_file="${tmake_file} msp430/t-msp430"
-	extra_gcc_objs="driver-msp430.o"
+	extra_objs="${extra_objs} msp430-devices.o"
+	extra_gcc_objs="driver-msp430.o msp430-devices.o"
 	;;
 nds32*-*-*)
 	target_cpu_default="0"
diff --git a/gcc/config/msp430/driver-msp430.c b/gcc/config/msp430/driver-msp430.c
index 09b4b9c..e83c20f 100644
--- a/gcc/config/msp430/driver-msp430.c
+++ b/gcc/config/msp430/driver-msp430.c
@@ -25,627 +25,30 @@ 
 #include "coretypes.h"
 #include "diagnostic.h"
 #include "tm.h"
+#include "msp430-devices.h"
 
-/* This is a copy of the same data structure found in gas/config/tc-msp430.c
-   Also another (sort-of) copy can be found in gcc/config/msp430/msp430.c
-   Keep these three structures in sync.
-   The data in this structure has been extracted from version 1.194 of the
-   devices.csv file released by TI in September 2016.  */
 
-struct msp430_mcu_data
+const char *
+msp430_select_cpu (int argc, const char ** argv)
 {
-  const char * name;
-  unsigned int revision; /* 0=> MSP430, 1=>MSP430X, 2=> MSP430Xv2.  */
-  unsigned int hwmpy;    /* 0=>none, 1=>16-bit, 2=>16-bit w/sign extend, 4=>32-bit, 8=> 32-bit (5xx).  */
+  if (argc == 0)
+    return NULL;
+  msp430_extract_mcu_data (argv[0]);
+  /* Do not add an mcpu option onto the command line if the mcu isn't found,
+     in case the user manually specified one.  */
+  if (extracted_mcu_data.name != NULL)
+    {
+      switch (extracted_mcu_data.revision)
+	{
+	case 0: return "-mcpu=msp430";
+	case 1: return "-mcpu=msp430x";
+	case 2: return "-mcpu=msp430xv2";
+	default:
+		gcc_unreachable ();
+	}
+    }
+  return NULL;
 }
-msp430_mcu_data [] =
-{
-  { "cc430f5123",2,8 },
-  { "cc430f5125",2,8 },
-  { "cc430f5133",2,8 },
-  { "cc430f5135",2,8 },
-  { "cc430f5137",2,8 },
-  { "cc430f5143",2,8 },
-  { "cc430f5145",2,8 },
-  { "cc430f5147",2,8 },
-  { "cc430f6125",2,8 },
-  { "cc430f6126",2,8 },
-  { "cc430f6127",2,8 },
-  { "cc430f6135",2,8 },
-  { "cc430f6137",2,8 },
-  { "cc430f6143",2,8 },
-  { "cc430f6145",2,8 },
-  { "cc430f6147",2,8 },
-  { "msp430afe221",0,2 },
-  { "msp430afe222",0,2 },
-  { "msp430afe223",0,2 },
-  { "msp430afe231",0,2 },
-  { "msp430afe232",0,2 },
-  { "msp430afe233",0,2 },
-  { "msp430afe251",0,2 },
-  { "msp430afe252",0,2 },
-  { "msp430afe253",0,2 },
-  { "msp430bt5190",2,8 },
-  { "msp430c091",0,0 },
-  { "msp430c092",0,0 },
-  { "msp430c111",0,0 },
-  { "msp430c1111",0,0 },
-  { "msp430c112",0,0 },
-  { "msp430c1121",0,0 },
-  { "msp430c1331",0,0 },
-  { "msp430c1351",0,0 },
-  { "msp430c311s",0,0 },
-  { "msp430c312",0,0 },
-  { "msp430c313",0,0 },
-  { "msp430c314",0,0 },
-  { "msp430c315",0,0 },
-  { "msp430c323",0,0 },
-  { "msp430c325",0,0 },
-  { "msp430c336",0,1 },
-  { "msp430c337",0,1 },
-  { "msp430c412",0,0 },
-  { "msp430c413",0,0 },
-  { "msp430cg4616",1,1 },
-  { "msp430cg4617",1,1 },
-  { "msp430cg4618",1,1 },
-  { "msp430cg4619",1,1 },
-  { "msp430e112",0,0 },
-  { "msp430e313",0,0 },
-  { "msp430e315",0,0 },
-  { "msp430e325",0,0 },
-  { "msp430e337",0,1 },
-  { "msp430f110",0,0 },
-  { "msp430f1101",0,0 },
-  { "msp430f1101a",0,0 },
-  { "msp430f1111",0,0 },
-  { "msp430f1111a",0,0 },
-  { "msp430f112",0,0 },
-  { "msp430f1121",0,0 },
-  { "msp430f1121a",0,0 },
-  { "msp430f1122",0,0 },
-  { "msp430f1132",0,0 },
-  { "msp430f122",0,0 },
-  { "msp430f1222",0,0 },
-  { "msp430f123",0,0 },
-  { "msp430f1232",0,0 },
-  { "msp430f133",0,0 },
-  { "msp430f135",0,0 },
-  { "msp430f147",0,1 },
-  { "msp430f1471",0,1 },
-  { "msp430f148",0,1 },
-  { "msp430f1481",0,1 },
-  { "msp430f149",0,1 },
-  { "msp430f1491",0,1 },
-  { "msp430f155",0,0 },
-  { "msp430f156",0,0 },
-  { "msp430f157",0,0 },
-  { "msp430f1610",0,1 },
-  { "msp430f1611",0,1 },
-  { "msp430f1612",0,1 },
-  { "msp430f167",0,1 },
-  { "msp430f168",0,1 },
-  { "msp430f169",0,1 },
-  { "msp430f2001",0,0 },
-  { "msp430f2002",0,0 },
-  { "msp430f2003",0,0 },
-  { "msp430f2011",0,0 },
-  { "msp430f2012",0,0 },
-  { "msp430f2013",0,0 },
-  { "msp430f2101",0,0 },
-  { "msp430f2111",0,0 },
-  { "msp430f2112",0,0 },
-  { "msp430f2121",0,0 },
-  { "msp430f2122",0,0 },
-  { "msp430f2131",0,0 },
-  { "msp430f2132",0,0 },
-  { "msp430f2232",0,0 },
-  { "msp430f2234",0,0 },
-  { "msp430f2252",0,0 },
-  { "msp430f2254",0,0 },
-  { "msp430f2272",0,0 },
-  { "msp430f2274",0,0 },
-  { "msp430f233",0,2 },
-  { "msp430f2330",0,2 },
-  { "msp430f235",0,2 },
-  { "msp430f2350",0,2 },
-  { "msp430f2370",0,2 },
-  { "msp430f2410",0,2 },
-  { "msp430f2416",1,2 },
-  { "msp430f2417",1,2 },
-  { "msp430f2418",1,2 },
-  { "msp430f2419",1,2 },
-  { "msp430f247",0,2 },
-  { "msp430f2471",0,2 },
-  { "msp430f248",0,2 },
-  { "msp430f2481",0,2 },
-  { "msp430f249",0,2 },
-  { "msp430f2491",0,2 },
-  { "msp430f2616",1,2 },
-  { "msp430f2617",1,2 },
-  { "msp430f2618",1,2 },
-  { "msp430f2619",1,2 },
-  { "msp430f412",0,0 },
-  { "msp430f413",0,0 },
-  { "msp430f4132",0,0 },
-  { "msp430f415",0,0 },
-  { "msp430f4152",0,0 },
-  { "msp430f417",0,0 },
-  { "msp430f423",0,1 },
-  { "msp430f423a",0,1 },
-  { "msp430f425",0,1 },
-  { "msp430f4250",0,0 },
-  { "msp430f425a",0,1 },
-  { "msp430f4260",0,0 },
-  { "msp430f427",0,1 },
-  { "msp430f4270",0,0 },
-  { "msp430f427a",0,1 },
-  { "msp430f435",0,0 },
-  { "msp430f4351",0,0 },
-  { "msp430f436",0,0 },
-  { "msp430f4361",0,0 },
-  { "msp430f437",0,0 },
-  { "msp430f4371",0,0 },
-  { "msp430f438",0,0 },
-  { "msp430f439",0,0 },
-  { "msp430f447",0,1 },
-  { "msp430f448",0,1 },
-  { "msp430f4481",0,1 },
-  { "msp430f449",0,1 },
-  { "msp430f4491",0,1 },
-  { "msp430f4616",1,1 },
-  { "msp430f46161",1,1 },
-  { "msp430f4617",1,1 },
-  { "msp430f46171",1,1 },
-  { "msp430f4618",1,1 },
-  { "msp430f46181",1,1 },
-  { "msp430f4619",1,1 },
-  { "msp430f46191",1,1 },
-  { "msp430f47126",1,4 },
-  { "msp430f47127",1,4 },
-  { "msp430f47163",1,4 },
-  { "msp430f47166",1,4 },
-  { "msp430f47167",1,4 },
-  { "msp430f47173",1,4 },
-  { "msp430f47176",1,4 },
-  { "msp430f47177",1,4 },
-  { "msp430f47183",1,4 },
-  { "msp430f47186",1,4 },
-  { "msp430f47187",1,4 },
-  { "msp430f47193",1,4 },
-  { "msp430f47196",1,4 },
-  { "msp430f47197",1,4 },
-  { "msp430f477",0,0 },
-  { "msp430f478",0,0 },
-  { "msp430f4783",0,4 },
-  { "msp430f4784",0,4 },
-  { "msp430f479",0,0 },
-  { "msp430f4793",0,4 },
-  { "msp430f4794",0,4 },
-  { "msp430f5131",2,8 },
-  { "msp430f5132",2,8 },
-  { "msp430f5151",2,8 },
-  { "msp430f5152",2,8 },
-  { "msp430f5171",2,8 },
-  { "msp430f5172",2,8 },
-  { "msp430f5212",2,8 },
-  { "msp430f5213",2,8 },
-  { "msp430f5214",2,8 },
-  { "msp430f5217",2,8 },
-  { "msp430f5218",2,8 },
-  { "msp430f5219",2,8 },
-  { "msp430f5222",2,8 },
-  { "msp430f5223",2,8 },
-  { "msp430f5224",2,8 },
-  { "msp430f5227",2,8 },
-  { "msp430f5228",2,8 },
-  { "msp430f5229",2,8 },
-  { "msp430f5232",2,8 },
-  { "msp430f5234",2,8 },
-  { "msp430f5237",2,8 },
-  { "msp430f5239",2,8 },
-  { "msp430f5242",2,8 },
-  { "msp430f5244",2,8 },
-  { "msp430f5247",2,8 },
-  { "msp430f5249",2,8 },
-  { "msp430f5252",2,8 },
-  { "msp430f5253",2,8 },
-  { "msp430f5254",2,8 },
-  { "msp430f5255",2,8 },
-  { "msp430f5256",2,8 },
-  { "msp430f5257",2,8 },
-  { "msp430f5258",2,8 },
-  { "msp430f5259",2,8 },
-  { "msp430f5304",2,8 },
-  { "msp430f5308",2,8 },
-  { "msp430f5309",2,8 },
-  { "msp430f5310",2,8 },
-  { "msp430f5324",2,8 },
-  { "msp430f5325",2,8 },
-  { "msp430f5326",2,8 },
-  { "msp430f5327",2,8 },
-  { "msp430f5328",2,8 },
-  { "msp430f5329",2,8 },
-  { "msp430f5333",2,8 },
-  { "msp430f5335",2,8 },
-  { "msp430f5336",2,8 },
-  { "msp430f5338",2,8 },
-  { "msp430f5340",2,8 },
-  { "msp430f5341",2,8 },
-  { "msp430f5342",2,8 },
-  { "msp430f5358",2,8 },
-  { "msp430f5359",2,8 },
-  { "msp430f5418",2,8 },
-  { "msp430f5418a",2,8 },
-  { "msp430f5419",2,8 },
-  { "msp430f5419a",2,8 },
-  { "msp430f5435",2,8 },
-  { "msp430f5435a",2,8 },
-  { "msp430f5436",2,8 },
-  { "msp430f5436a",2,8 },
-  { "msp430f5437",2,8 },
-  { "msp430f5437a",2,8 },
-  { "msp430f5438",2,8 },
-  { "msp430f5438a",2,8 },
-  { "msp430f5500",2,8 },
-  { "msp430f5501",2,8 },
-  { "msp430f5502",2,8 },
-  { "msp430f5503",2,8 },
-  { "msp430f5504",2,8 },
-  { "msp430f5505",2,8 },
-  { "msp430f5506",2,8 },
-  { "msp430f5507",2,8 },
-  { "msp430f5508",2,8 },
-  { "msp430f5509",2,8 },
-  { "msp430f5510",2,8 },
-  { "msp430f5513",2,8 },
-  { "msp430f5514",2,8 },
-  { "msp430f5515",2,8 },
-  { "msp430f5517",2,8 },
-  { "msp430f5519",2,8 },
-  { "msp430f5521",2,8 },
-  { "msp430f5522",2,8 },
-  { "msp430f5524",2,8 },
-  { "msp430f5525",2,8 },
-  { "msp430f5526",2,8 },
-  { "msp430f5527",2,8 },
-  { "msp430f5528",2,8 },
-  { "msp430f5529",2,8 },
-  { "msp430f5630",2,8 },
-  { "msp430f5631",2,8 },
-  { "msp430f5632",2,8 },
-  { "msp430f5633",2,8 },
-  { "msp430f5634",2,8 },
-  { "msp430f5635",2,8 },
-  { "msp430f5636",2,8 },
-  { "msp430f5637",2,8 },
-  { "msp430f5638",2,8 },
-  { "msp430f5658",2,8 },
-  { "msp430f5659",2,8 },
-  { "msp430f5xx_6xxgeneric",2,8 },
-  { "msp430f6433",2,8 },
-  { "msp430f6435",2,8 },
-  { "msp430f6436",2,8 },
-  { "msp430f6438",2,8 },
-  { "msp430f6458",2,8 },
-  { "msp430f6459",2,8 },
-  { "msp430f6630",2,8 },
-  { "msp430f6631",2,8 },
-  { "msp430f6632",2,8 },
-  { "msp430f6633",2,8 },
-  { "msp430f6634",2,8 },
-  { "msp430f6635",2,8 },
-  { "msp430f6636",2,8 },
-  { "msp430f6637",2,8 },
-  { "msp430f6638",2,8 },
-  { "msp430f6658",2,8 },
-  { "msp430f6659",2,8 },
-  { "msp430f6720",2,8 },
-  { "msp430f6720a",2,8 },
-  { "msp430f6721",2,8 },
-  { "msp430f6721a",2,8 },
-  { "msp430f6723",2,8 },
-  { "msp430f6723a",2,8 },
-  { "msp430f6724",2,8 },
-  { "msp430f6724a",2,8 },
-  { "msp430f6725",2,8 },
-  { "msp430f6725a",2,8 },
-  { "msp430f6726",2,8 },
-  { "msp430f6726a",2,8 },
-  { "msp430f6730",2,8 },
-  { "msp430f6730a",2,8 },
-  { "msp430f6731",2,8 },
-  { "msp430f6731a",2,8 },
-  { "msp430f6733",2,8 },
-  { "msp430f6733a",2,8 },
-  { "msp430f6734",2,8 },
-  { "msp430f6734a",2,8 },
-  { "msp430f6735",2,8 },
-  { "msp430f6735a",2,8 },
-  { "msp430f6736",2,8 },
-  { "msp430f6736a",2,8 },
-  { "msp430f6745",2,8 },
-  { "msp430f67451",2,8 },
-  { "msp430f67451a",2,8 },
-  { "msp430f6745a",2,8 },
-  { "msp430f6746",2,8 },
-  { "msp430f67461",2,8 },
-  { "msp430f67461a",2,8 },
-  { "msp430f6746a",2,8 },
-  { "msp430f6747",2,8 },
-  { "msp430f67471",2,8 },
-  { "msp430f67471a",2,8 },
-  { "msp430f6747a",2,8 },
-  { "msp430f6748",2,8 },
-  { "msp430f67481",2,8 },
-  { "msp430f67481a",2,8 },
-  { "msp430f6748a",2,8 },
-  { "msp430f6749",2,8 },
-  { "msp430f67491",2,8 },
-  { "msp430f67491a",2,8 },
-  { "msp430f6749a",2,8 },
-  { "msp430f67621",2,8 },
-  { "msp430f67621a",2,8 },
-  { "msp430f67641",2,8 },
-  { "msp430f67641a",2,8 },
-  { "msp430f6765",2,8 },
-  { "msp430f67651",2,8 },
-  { "msp430f67651a",2,8 },
-  { "msp430f6765a",2,8 },
-  { "msp430f6766",2,8 },
-  { "msp430f67661",2,8 },
-  { "msp430f67661a",2,8 },
-  { "msp430f6766a",2,8 },
-  { "msp430f6767",2,8 },
-  { "msp430f67671",2,8 },
-  { "msp430f67671a",2,8 },
-  { "msp430f6767a",2,8 },
-  { "msp430f6768",2,8 },
-  { "msp430f67681",2,8 },
-  { "msp430f67681a",2,8 },
-  { "msp430f6768a",2,8 },
-  { "msp430f6769",2,8 },
-  { "msp430f67691",2,8 },
-  { "msp430f67691a",2,8 },
-  { "msp430f6769a",2,8 },
-  { "msp430f6775",2,8 },
-  { "msp430f67751",2,8 },
-  { "msp430f67751a",2,8 },
-  { "msp430f6775a",2,8 },
-  { "msp430f6776",2,8 },
-  { "msp430f67761",2,8 },
-  { "msp430f67761a",2,8 },
-  { "msp430f6776a",2,8 },
-  { "msp430f6777",2,8 },
-  { "msp430f67771",2,8 },
-  { "msp430f67771a",2,8 },
-  { "msp430f6777a",2,8 },
-  { "msp430f6778",2,8 },
-  { "msp430f67781",2,8 },
-  { "msp430f67781a",2,8 },
-  { "msp430f6778a",2,8 },
-  { "msp430f6779",2,8 },
-  { "msp430f67791",2,8 },
-  { "msp430f67791a",2,8 },
-  { "msp430f6779a",2,8 },
-  { "msp430fe423",0,0 },
-  { "msp430fe4232",0,0 },
-  { "msp430fe423a",0,0 },
-  { "msp430fe4242",0,0 },
-  { "msp430fe425",0,0 },
-  { "msp430fe4252",0,0 },
-  { "msp430fe425a",0,0 },
-  { "msp430fe427",0,0 },
-  { "msp430fe4272",0,0 },
-  { "msp430fe427a",0,0 },
-  { "msp430fg4250",0,0 },
-  { "msp430fg4260",0,0 },
-  { "msp430fg4270",0,0 },
-  { "msp430fg437",0,0 },
-  { "msp430fg438",0,0 },
-  { "msp430fg439",0,0 },
-  { "msp430fg4616",1,1 },
-  { "msp430fg4617",1,1 },
-  { "msp430fg4618",1,1 },
-  { "msp430fg4619",1,1 },
-  { "msp430fg477",0,0 },
-  { "msp430fg478",0,0 },
-  { "msp430fg479",0,0 },
-  { "msp430fg6425",2,8 },
-  { "msp430fg6426",2,8 },
-  { "msp430fg6625",2,8 },
-  { "msp430fg6626",2,8 },
-  { "msp430fr2032",2,0 },
-  { "msp430fr2033",2,0 },
-  { "msp430fr2110",2,0 },
-  { "msp430fr2111",2,0 },
-  { "msp430fr2310",2,0 },
-  { "msp430fr2311",2,0 },
-  { "msp430fr2433",2,8 },
-  { "msp430fr2532",2,8 },
-  { "msp430fr2533",2,8 },
-  { "msp430fr2632",2,8 },
-  { "msp430fr2633",2,8 },
-  { "msp430fr2xx_4xxgeneric",2,8 },
-  { "msp430fr4131",2,0 },
-  { "msp430fr4132",2,0 },
-  { "msp430fr4133",2,0 },
-  { "msp430fr5720",2,8 },
-  { "msp430fr5721",2,8 },
-  { "msp430fr5722",2,8 },
-  { "msp430fr5723",2,8 },
-  { "msp430fr5724",2,8 },
-  { "msp430fr5725",2,8 },
-  { "msp430fr5726",2,8 },
-  { "msp430fr5727",2,8 },
-  { "msp430fr5728",2,8 },
-  { "msp430fr5729",2,8 },
-  { "msp430fr5730",2,8 },
-  { "msp430fr5731",2,8 },
-  { "msp430fr5732",2,8 },
-  { "msp430fr5733",2,8 },
-  { "msp430fr5734",2,8 },
-  { "msp430fr5735",2,8 },
-  { "msp430fr5736",2,8 },
-  { "msp430fr5737",2,8 },
-  { "msp430fr5738",2,8 },
-  { "msp430fr5739",2,8 },
-  { "msp430fr57xxgeneric",2,8 },
-  { "msp430fr5847",2,8 },
-  { "msp430fr58471",2,8 },
-  { "msp430fr5848",2,8 },
-  { "msp430fr5849",2,8 },
-  { "msp430fr5857",2,8 },
-  { "msp430fr5858",2,8 },
-  { "msp430fr5859",2,8 },
-  { "msp430fr5867",2,8 },
-  { "msp430fr58671",2,8 },
-  { "msp430fr5868",2,8 },
-  { "msp430fr5869",2,8 },
-  { "msp430fr5870",2,8 },
-  { "msp430fr5872",2,8 },
-  { "msp430fr58721",2,8 },
-  { "msp430fr5887",2,8 },
-  { "msp430fr5888",2,8 },
-  { "msp430fr5889",2,8 },
-  { "msp430fr58891",2,8 },
-  { "msp430fr5922",2,8 },
-  { "msp430fr59221",2,8 },
-  { "msp430fr5947",2,8 },
-  { "msp430fr59471",2,8 },
-  { "msp430fr5948",2,8 },
-  { "msp430fr5949",2,8 },
-  { "msp430fr5957",2,8 },
-  { "msp430fr5958",2,8 },
-  { "msp430fr5959",2,8 },
-  { "msp430fr5962",2,8 },
-  { "msp430fr5964",2,8 },
-  { "msp430fr5967",2,8 },
-  { "msp430fr5968",2,8 },
-  { "msp430fr5969",2,8 },
-  { "msp430fr59691",2,8 },
-  { "msp430fr5970",2,8 },
-  { "msp430fr5972",2,8 },
-  { "msp430fr59721",2,8 },
-  { "msp430fr5986",2,8 },
-  { "msp430fr5987",2,8 },
-  { "msp430fr5988",2,8 },
-  { "msp430fr5989",2,8 },
-  { "msp430fr59891",2,8 },
-  { "msp430fr5992",2,8 },
-  { "msp430fr5994",2,8 },
-  { "msp430fr59941",2,8 },
-  { "msp430fr5xx_6xxgeneric",2,8 },
-  { "msp430fr6820",2,8 },
-  { "msp430fr6822",2,8 },
-  { "msp430fr68221",2,8 },
-  { "msp430fr6870",2,8 },
-  { "msp430fr6872",2,8 },
-  { "msp430fr68721",2,8 },
-  { "msp430fr6877",2,8 },
-  { "msp430fr6879",2,8 },
-  { "msp430fr68791",2,8 },
-  { "msp430fr6887",2,8 },
-  { "msp430fr6888",2,8 },
-  { "msp430fr6889",2,8 },
-  { "msp430fr68891",2,8 },
-  { "msp430fr6920",2,8 },
-  { "msp430fr6922",2,8 },
-  { "msp430fr69221",2,8 },
-  { "msp430fr6927",2,8 },
-  { "msp430fr69271",2,8 },
-  { "msp430fr6928",2,8 },
-  { "msp430fr6970",2,8 },
-  { "msp430fr6972",2,8 },
-  { "msp430fr69721",2,8 },
-  { "msp430fr6977",2,8 },
-  { "msp430fr6979",2,8 },
-  { "msp430fr69791",2,8 },
-  { "msp430fr6987",2,8 },
-  { "msp430fr6988",2,8 },
-  { "msp430fr6989",2,8 },
-  { "msp430fr69891",2,8 },
-  { "msp430fw423",0,0 },
-  { "msp430fw425",0,0 },
-  { "msp430fw427",0,0 },
-  { "msp430fw428",0,0 },
-  { "msp430fw429",0,0 },
-  { "msp430g2001",0,0 },
-  { "msp430g2101",0,0 },
-  { "msp430g2102",0,0 },
-  { "msp430g2111",0,0 },
-  { "msp430g2112",0,0 },
-  { "msp430g2113",0,0 },
-  { "msp430g2121",0,0 },
-  { "msp430g2131",0,0 },
-  { "msp430g2132",0,0 },
-  { "msp430g2152",0,0 },
-  { "msp430g2153",0,0 },
-  { "msp430g2201",0,0 },
-  { "msp430g2202",0,0 },
-  { "msp430g2203",0,0 },
-  { "msp430g2210",0,0 },
-  { "msp430g2211",0,0 },
-  { "msp430g2212",0,0 },
-  { "msp430g2213",0,0 },
-  { "msp430g2221",0,0 },
-  { "msp430g2230",0,0 },
-  { "msp430g2231",0,0 },
-  { "msp430g2232",0,0 },
-  { "msp430g2233",0,0 },
-  { "msp430g2252",0,0 },
-  { "msp430g2253",0,0 },
-  { "msp430g2302",0,0 },
-  { "msp430g2303",0,0 },
-  { "msp430g2312",0,0 },
-  { "msp430g2313",0,0 },
-  { "msp430g2332",0,0 },
-  { "msp430g2333",0,0 },
-  { "msp430g2352",0,0 },
-  { "msp430g2353",0,0 },
-  { "msp430g2402",0,0 },
-  { "msp430g2403",0,0 },
-  { "msp430g2412",0,0 },
-  { "msp430g2413",0,0 },
-  { "msp430g2432",0,0 },
-  { "msp430g2433",0,0 },
-  { "msp430g2444",0,0 },
-  { "msp430g2452",0,0 },
-  { "msp430g2453",0,0 },
-  { "msp430g2513",0,0 },
-  { "msp430g2533",0,0 },
-  { "msp430g2544",0,0 },
-  { "msp430g2553",0,0 },
-  { "msp430g2744",0,0 },
-  { "msp430g2755",0,0 },
-  { "msp430g2855",0,0 },
-  { "msp430g2955",0,0 },
-  { "msp430i2020",0,2 },
-  { "msp430i2021",0,2 },
-  { "msp430i2030",0,2 },
-  { "msp430i2031",0,2 },
-  { "msp430i2040",0,2 },
-  { "msp430i2041",0,2 },
-  { "msp430i2xxgeneric",0,2 },
-  { "msp430l092",0,0 },
-  { "msp430p112",0,0 },
-  { "msp430p313",0,0 },
-  { "msp430p315",0,0 },
-  { "msp430p315s",0,0 },
-  { "msp430p325",0,0 },
-  { "msp430p337",0,1 },
-  { "msp430sl5438a",2,8 },
-  { "msp430tch5e",0,0 },
-  { "msp430xgeneric",2,8 },
-  { "rf430f5144",2,8 },
-  { "rf430f5155",2,8 },
-  { "rf430f5175",2,8 },
-  { "rf430frl152h",0,0 },
-  { "rf430frl152h_rom",0,0 },
-  { "rf430frl153h",0,0 },
-  { "rf430frl153h_rom",0,0 },
-  { "rf430frl154h",0,0 },
-  { "rf430frl154h_rom",0,0 }
-};  
 
 /* Implement spec function `msp430_hwmult_libĀ“.  */
 
@@ -688,22 +91,20 @@  msp430_select_hwmult_lib (int argc ATTRIBUTE_UNUSED, const char ** argv ATTRIBUT
       }
     else if (strcasecmp (argv[0], "mcu") == 0)
       {
-	for (i = ARRAY_SIZE (msp430_mcu_data); i--;)
-	  if (strcasecmp (argv[argc - 1], msp430_mcu_data[i].name) == 0)
-	    {
-	      switch (msp430_mcu_data[i].hwmpy)
-		{
-		case 0: return "-lmul_none";
-		case 2:
-		case 1: return "-lmul_16";
-		case 4: return "-lmul_32";
-		case 8: return "-lmul_f5";
-		default:
-		  error ("unrecognized hwpy field in msp430_mcu_data[%d]: %d",
-			 i, msp430_mcu_data[i].hwmpy);
-		  break;
-		}
-	    }
+	msp430_extract_mcu_data (argv[argc - 1]);
+	if (extracted_mcu_data.name != NULL)
+	  {
+	    switch (extracted_mcu_data.hwmpy)
+	      {
+	      case 0: return "-lmul_none";
+	      case 2:
+	      case 1: return "-lmul_16";
+	      case 4: return "-lmul_32";
+	      case 8: return "-lmul_f5";
+	      default:
+		      gcc_unreachable ();
+	      }
+	  }
       }
     else
       error ("unexpected first argument to msp430_select_hwmult_lib: %s", argv[0]);
diff --git a/gcc/config/msp430/msp430-devices.c b/gcc/config/msp430/msp430-devices.c
new file mode 100644
index 0000000..f20b379
--- /dev/null
+++ b/gcc/config/msp430/msp430-devices.c
@@ -0,0 +1,673 @@ 
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "target.h"
+#include "tree.h"
+#include "memmodel.h"
+#include "diagnostic-core.h"
+#include "langhooks.h"
+#include "builtins.h"
+#include "intl.h"
+#include "msp430-devices.h"
+
+struct t_msp430_mcu_data extracted_mcu_data;
+/* Initialized at the bottom for improved readability.  */
+extern struct t_msp430_mcu_data hard_msp430_mcu_data[605];
+
+/* This function only needs to be executed once, but it can be first called
+   from a number of different locations.  */
+void
+msp430_extract_mcu_data (const char * mcu_name)
+{
+  static int executed = 0;
+  unsigned int i;
+  if (mcu_name == NULL || executed == 1)
+    return;
+  executed = 1;
+  /* FIXME: This array is alpha sorted - we could use a binary search.  */
+  for (i = ARRAY_SIZE (hard_msp430_mcu_data); i--;)
+    if (strcasecmp (mcu_name, hard_msp430_mcu_data[i].name) == 0)
+      {
+	extracted_mcu_data = hard_msp430_mcu_data[i];
+	break;
+      }
+  /* Validation checks.  */
+  if (extracted_mcu_data.name != NULL)
+    {
+      switch (extracted_mcu_data.hwmpy)
+	{
+	case 0:
+	case 2:
+	case 1:
+	case 4:
+	case 8: break;
+	default:
+		error ("unrecognized hwmpy field in hard_msp430_mcu_data[%d]: "
+		       "%d", i, hard_msp430_mcu_data[i].hwmpy);
+		break;
+	}
+      switch (extracted_mcu_data.revision)
+	{
+	case 0:
+	case 1:
+	case 2: break;
+	default:
+		error ("unrecognized revision field in "
+		       "hard_msp430_mcu_data[%d]: %d", i,
+		       hard_msp430_mcu_data[i].revision);
+	}
+    }
+}
+
+/* The data in this structure has been extracted from version 1.194 of the
+   devices.csv file released by TI in September 2016.  */
+
+struct t_msp430_mcu_data hard_msp430_mcu_data[605] =
+{
+  { "cc430f5123",2,8 },
+  { "cc430f5125",2,8 },
+  { "cc430f5133",2,8 },
+  { "cc430f5135",2,8 },
+  { "cc430f5137",2,8 },
+  { "cc430f5143",2,8 },
+  { "cc430f5145",2,8 },
+  { "cc430f5147",2,8 },
+  { "cc430f6125",2,8 },
+  { "cc430f6126",2,8 },
+  { "cc430f6127",2,8 },
+  { "cc430f6135",2,8 },
+  { "cc430f6137",2,8 },
+  { "cc430f6143",2,8 },
+  { "cc430f6145",2,8 },
+  { "cc430f6147",2,8 },
+  { "msp430afe221",0,2 },
+  { "msp430afe222",0,2 },
+  { "msp430afe223",0,2 },
+  { "msp430afe231",0,2 },
+  { "msp430afe232",0,2 },
+  { "msp430afe233",0,2 },
+  { "msp430afe251",0,2 },
+  { "msp430afe252",0,2 },
+  { "msp430afe253",0,2 },
+  { "msp430bt5190",2,8 },
+  { "msp430c091",0,0 },
+  { "msp430c092",0,0 },
+  { "msp430c111",0,0 },
+  { "msp430c1111",0,0 },
+  { "msp430c112",0,0 },
+  { "msp430c1121",0,0 },
+  { "msp430c1331",0,0 },
+  { "msp430c1351",0,0 },
+  { "msp430c311s",0,0 },
+  { "msp430c312",0,0 },
+  { "msp430c313",0,0 },
+  { "msp430c314",0,0 },
+  { "msp430c315",0,0 },
+  { "msp430c323",0,0 },
+  { "msp430c325",0,0 },
+  { "msp430c336",0,1 },
+  { "msp430c337",0,1 },
+  { "msp430c412",0,0 },
+  { "msp430c413",0,0 },
+  { "msp430cg4616",1,1 },
+  { "msp430cg4617",1,1 },
+  { "msp430cg4618",1,1 },
+  { "msp430cg4619",1,1 },
+  { "msp430e112",0,0 },
+  { "msp430e313",0,0 },
+  { "msp430e315",0,0 },
+  { "msp430e325",0,0 },
+  { "msp430e337",0,1 },
+  { "msp430f110",0,0 },
+  { "msp430f1101",0,0 },
+  { "msp430f1101a",0,0 },
+  { "msp430f1111",0,0 },
+  { "msp430f1111a",0,0 },
+  { "msp430f112",0,0 },
+  { "msp430f1121",0,0 },
+  { "msp430f1121a",0,0 },
+  { "msp430f1122",0,0 },
+  { "msp430f1132",0,0 },
+  { "msp430f122",0,0 },
+  { "msp430f1222",0,0 },
+  { "msp430f123",0,0 },
+  { "msp430f1232",0,0 },
+  { "msp430f133",0,0 },
+  { "msp430f135",0,0 },
+  { "msp430f147",0,1 },
+  { "msp430f1471",0,1 },
+  { "msp430f148",0,1 },
+  { "msp430f1481",0,1 },
+  { "msp430f149",0,1 },
+  { "msp430f1491",0,1 },
+  { "msp430f155",0,0 },
+  { "msp430f156",0,0 },
+  { "msp430f157",0,0 },
+  { "msp430f1610",0,1 },
+  { "msp430f1611",0,1 },
+  { "msp430f1612",0,1 },
+  { "msp430f167",0,1 },
+  { "msp430f168",0,1 },
+  { "msp430f169",0,1 },
+  { "msp430f2001",0,0 },
+  { "msp430f2002",0,0 },
+  { "msp430f2003",0,0 },
+  { "msp430f2011",0,0 },
+  { "msp430f2012",0,0 },
+  { "msp430f2013",0,0 },
+  { "msp430f2101",0,0 },
+  { "msp430f2111",0,0 },
+  { "msp430f2112",0,0 },
+  { "msp430f2121",0,0 },
+  { "msp430f2122",0,0 },
+  { "msp430f2131",0,0 },
+  { "msp430f2132",0,0 },
+  { "msp430f2232",0,0 },
+  { "msp430f2234",0,0 },
+  { "msp430f2252",0,0 },
+  { "msp430f2254",0,0 },
+  { "msp430f2272",0,0 },
+  { "msp430f2274",0,0 },
+  { "msp430f233",0,2 },
+  { "msp430f2330",0,2 },
+  { "msp430f235",0,2 },
+  { "msp430f2350",0,2 },
+  { "msp430f2370",0,2 },
+  { "msp430f2410",0,2 },
+  { "msp430f2416",1,2 },
+  { "msp430f2417",1,2 },
+  { "msp430f2418",1,2 },
+  { "msp430f2419",1,2 },
+  { "msp430f247",0,2 },
+  { "msp430f2471",0,2 },
+  { "msp430f248",0,2 },
+  { "msp430f2481",0,2 },
+  { "msp430f249",0,2 },
+  { "msp430f2491",0,2 },
+  { "msp430f2616",1,2 },
+  { "msp430f2617",1,2 },
+  { "msp430f2618",1,2 },
+  { "msp430f2619",1,2 },
+  { "msp430f412",0,0 },
+  { "msp430f413",0,0 },
+  { "msp430f4132",0,0 },
+  { "msp430f415",0,0 },
+  { "msp430f4152",0,0 },
+  { "msp430f417",0,0 },
+  { "msp430f423",0,1 },
+  { "msp430f423a",0,1 },
+  { "msp430f425",0,1 },
+  { "msp430f4250",0,0 },
+  { "msp430f425a",0,1 },
+  { "msp430f4260",0,0 },
+  { "msp430f427",0,1 },
+  { "msp430f4270",0,0 },
+  { "msp430f427a",0,1 },
+  { "msp430f435",0,0 },
+  { "msp430f4351",0,0 },
+  { "msp430f436",0,0 },
+  { "msp430f4361",0,0 },
+  { "msp430f437",0,0 },
+  { "msp430f4371",0,0 },
+  { "msp430f438",0,0 },
+  { "msp430f439",0,0 },
+  { "msp430f447",0,1 },
+  { "msp430f448",0,1 },
+  { "msp430f4481",0,1 },
+  { "msp430f449",0,1 },
+  { "msp430f4491",0,1 },
+  { "msp430f4616",1,1 },
+  { "msp430f46161",1,1 },
+  { "msp430f4617",1,1 },
+  { "msp430f46171",1,1 },
+  { "msp430f4618",1,1 },
+  { "msp430f46181",1,1 },
+  { "msp430f4619",1,1 },
+  { "msp430f46191",1,1 },
+  { "msp430f47126",1,4 },
+  { "msp430f47127",1,4 },
+  { "msp430f47163",1,4 },
+  { "msp430f47166",1,4 },
+  { "msp430f47167",1,4 },
+  { "msp430f47173",1,4 },
+  { "msp430f47176",1,4 },
+  { "msp430f47177",1,4 },
+  { "msp430f47183",1,4 },
+  { "msp430f47186",1,4 },
+  { "msp430f47187",1,4 },
+  { "msp430f47193",1,4 },
+  { "msp430f47196",1,4 },
+  { "msp430f47197",1,4 },
+  { "msp430f477",0,0 },
+  { "msp430f478",0,0 },
+  { "msp430f4783",0,4 },
+  { "msp430f4784",0,4 },
+  { "msp430f479",0,0 },
+  { "msp430f4793",0,4 },
+  { "msp430f4794",0,4 },
+  { "msp430f5131",2,8 },
+  { "msp430f5132",2,8 },
+  { "msp430f5151",2,8 },
+  { "msp430f5152",2,8 },
+  { "msp430f5171",2,8 },
+  { "msp430f5172",2,8 },
+  { "msp430f5212",2,8 },
+  { "msp430f5213",2,8 },
+  { "msp430f5214",2,8 },
+  { "msp430f5217",2,8 },
+  { "msp430f5218",2,8 },
+  { "msp430f5219",2,8 },
+  { "msp430f5222",2,8 },
+  { "msp430f5223",2,8 },
+  { "msp430f5224",2,8 },
+  { "msp430f5227",2,8 },
+  { "msp430f5228",2,8 },
+  { "msp430f5229",2,8 },
+  { "msp430f5232",2,8 },
+  { "msp430f5234",2,8 },
+  { "msp430f5237",2,8 },
+  { "msp430f5239",2,8 },
+  { "msp430f5242",2,8 },
+  { "msp430f5244",2,8 },
+  { "msp430f5247",2,8 },
+  { "msp430f5249",2,8 },
+  { "msp430f5252",2,8 },
+  { "msp430f5253",2,8 },
+  { "msp430f5254",2,8 },
+  { "msp430f5255",2,8 },
+  { "msp430f5256",2,8 },
+  { "msp430f5257",2,8 },
+  { "msp430f5258",2,8 },
+  { "msp430f5259",2,8 },
+  { "msp430f5304",2,8 },
+  { "msp430f5308",2,8 },
+  { "msp430f5309",2,8 },
+  { "msp430f5310",2,8 },
+  { "msp430f5324",2,8 },
+  { "msp430f5325",2,8 },
+  { "msp430f5326",2,8 },
+  { "msp430f5327",2,8 },
+  { "msp430f5328",2,8 },
+  { "msp430f5329",2,8 },
+  { "msp430f5333",2,8 },
+  { "msp430f5335",2,8 },
+  { "msp430f5336",2,8 },
+  { "msp430f5338",2,8 },
+  { "msp430f5340",2,8 },
+  { "msp430f5341",2,8 },
+  { "msp430f5342",2,8 },
+  { "msp430f5358",2,8 },
+  { "msp430f5359",2,8 },
+  { "msp430f5418",2,8 },
+  { "msp430f5418a",2,8 },
+  { "msp430f5419",2,8 },
+  { "msp430f5419a",2,8 },
+  { "msp430f5435",2,8 },
+  { "msp430f5435a",2,8 },
+  { "msp430f5436",2,8 },
+  { "msp430f5436a",2,8 },
+  { "msp430f5437",2,8 },
+  { "msp430f5437a",2,8 },
+  { "msp430f5438",2,8 },
+  { "msp430f5438a",2,8 },
+  { "msp430f5500",2,8 },
+  { "msp430f5501",2,8 },
+  { "msp430f5502",2,8 },
+  { "msp430f5503",2,8 },
+  { "msp430f5504",2,8 },
+  { "msp430f5505",2,8 },
+  { "msp430f5506",2,8 },
+  { "msp430f5507",2,8 },
+  { "msp430f5508",2,8 },
+  { "msp430f5509",2,8 },
+  { "msp430f5510",2,8 },
+  { "msp430f5513",2,8 },
+  { "msp430f5514",2,8 },
+  { "msp430f5515",2,8 },
+  { "msp430f5517",2,8 },
+  { "msp430f5519",2,8 },
+  { "msp430f5521",2,8 },
+  { "msp430f5522",2,8 },
+  { "msp430f5524",2,8 },
+  { "msp430f5525",2,8 },
+  { "msp430f5526",2,8 },
+  { "msp430f5527",2,8 },
+  { "msp430f5528",2,8 },
+  { "msp430f5529",2,8 },
+  { "msp430f5630",2,8 },
+  { "msp430f5631",2,8 },
+  { "msp430f5632",2,8 },
+  { "msp430f5633",2,8 },
+  { "msp430f5634",2,8 },
+  { "msp430f5635",2,8 },
+  { "msp430f5636",2,8 },
+  { "msp430f5637",2,8 },
+  { "msp430f5638",2,8 },
+  { "msp430f5658",2,8 },
+  { "msp430f5659",2,8 },
+  { "msp430f5xx_6xxgeneric",2,8 },
+  { "msp430f6433",2,8 },
+  { "msp430f6435",2,8 },
+  { "msp430f6436",2,8 },
+  { "msp430f6438",2,8 },
+  { "msp430f6458",2,8 },
+  { "msp430f6459",2,8 },
+  { "msp430f6630",2,8 },
+  { "msp430f6631",2,8 },
+  { "msp430f6632",2,8 },
+  { "msp430f6633",2,8 },
+  { "msp430f6634",2,8 },
+  { "msp430f6635",2,8 },
+  { "msp430f6636",2,8 },
+  { "msp430f6637",2,8 },
+  { "msp430f6638",2,8 },
+  { "msp430f6658",2,8 },
+  { "msp430f6659",2,8 },
+  { "msp430f6720",2,8 },
+  { "msp430f6720a",2,8 },
+  { "msp430f6721",2,8 },
+  { "msp430f6721a",2,8 },
+  { "msp430f6723",2,8 },
+  { "msp430f6723a",2,8 },
+  { "msp430f6724",2,8 },
+  { "msp430f6724a",2,8 },
+  { "msp430f6725",2,8 },
+  { "msp430f6725a",2,8 },
+  { "msp430f6726",2,8 },
+  { "msp430f6726a",2,8 },
+  { "msp430f6730",2,8 },
+  { "msp430f6730a",2,8 },
+  { "msp430f6731",2,8 },
+  { "msp430f6731a",2,8 },
+  { "msp430f6733",2,8 },
+  { "msp430f6733a",2,8 },
+  { "msp430f6734",2,8 },
+  { "msp430f6734a",2,8 },
+  { "msp430f6735",2,8 },
+  { "msp430f6735a",2,8 },
+  { "msp430f6736",2,8 },
+  { "msp430f6736a",2,8 },
+  { "msp430f6745",2,8 },
+  { "msp430f67451",2,8 },
+  { "msp430f67451a",2,8 },
+  { "msp430f6745a",2,8 },
+  { "msp430f6746",2,8 },
+  { "msp430f67461",2,8 },
+  { "msp430f67461a",2,8 },
+  { "msp430f6746a",2,8 },
+  { "msp430f6747",2,8 },
+  { "msp430f67471",2,8 },
+  { "msp430f67471a",2,8 },
+  { "msp430f6747a",2,8 },
+  { "msp430f6748",2,8 },
+  { "msp430f67481",2,8 },
+  { "msp430f67481a",2,8 },
+  { "msp430f6748a",2,8 },
+  { "msp430f6749",2,8 },
+  { "msp430f67491",2,8 },
+  { "msp430f67491a",2,8 },
+  { "msp430f6749a",2,8 },
+  { "msp430f67621",2,8 },
+  { "msp430f67621a",2,8 },
+  { "msp430f67641",2,8 },
+  { "msp430f67641a",2,8 },
+  { "msp430f6765",2,8 },
+  { "msp430f67651",2,8 },
+  { "msp430f67651a",2,8 },
+  { "msp430f6765a",2,8 },
+  { "msp430f6766",2,8 },
+  { "msp430f67661",2,8 },
+  { "msp430f67661a",2,8 },
+  { "msp430f6766a",2,8 },
+  { "msp430f6767",2,8 },
+  { "msp430f67671",2,8 },
+  { "msp430f67671a",2,8 },
+  { "msp430f6767a",2,8 },
+  { "msp430f6768",2,8 },
+  { "msp430f67681",2,8 },
+  { "msp430f67681a",2,8 },
+  { "msp430f6768a",2,8 },
+  { "msp430f6769",2,8 },
+  { "msp430f67691",2,8 },
+  { "msp430f67691a",2,8 },
+  { "msp430f6769a",2,8 },
+  { "msp430f6775",2,8 },
+  { "msp430f67751",2,8 },
+  { "msp430f67751a",2,8 },
+  { "msp430f6775a",2,8 },
+  { "msp430f6776",2,8 },
+  { "msp430f67761",2,8 },
+  { "msp430f67761a",2,8 },
+  { "msp430f6776a",2,8 },
+  { "msp430f6777",2,8 },
+  { "msp430f67771",2,8 },
+  { "msp430f67771a",2,8 },
+  { "msp430f6777a",2,8 },
+  { "msp430f6778",2,8 },
+  { "msp430f67781",2,8 },
+  { "msp430f67781a",2,8 },
+  { "msp430f6778a",2,8 },
+  { "msp430f6779",2,8 },
+  { "msp430f67791",2,8 },
+  { "msp430f67791a",2,8 },
+  { "msp430f6779a",2,8 },
+  { "msp430fe423",0,0 },
+  { "msp430fe4232",0,0 },
+  { "msp430fe423a",0,0 },
+  { "msp430fe4242",0,0 },
+  { "msp430fe425",0,0 },
+  { "msp430fe4252",0,0 },
+  { "msp430fe425a",0,0 },
+  { "msp430fe427",0,0 },
+  { "msp430fe4272",0,0 },
+  { "msp430fe427a",0,0 },
+  { "msp430fg4250",0,0 },
+  { "msp430fg4260",0,0 },
+  { "msp430fg4270",0,0 },
+  { "msp430fg437",0,0 },
+  { "msp430fg438",0,0 },
+  { "msp430fg439",0,0 },
+  { "msp430fg4616",1,1 },
+  { "msp430fg4617",1,1 },
+  { "msp430fg4618",1,1 },
+  { "msp430fg4619",1,1 },
+  { "msp430fg477",0,0 },
+  { "msp430fg478",0,0 },
+  { "msp430fg479",0,0 },
+  { "msp430fg6425",2,8 },
+  { "msp430fg6426",2,8 },
+  { "msp430fg6625",2,8 },
+  { "msp430fg6626",2,8 },
+  { "msp430fr2032",2,0 },
+  { "msp430fr2033",2,0 },
+  { "msp430fr2110",2,0 },
+  { "msp430fr2111",2,0 },
+  { "msp430fr2310",2,0 },
+  { "msp430fr2311",2,0 },
+  { "msp430fr2433",2,8 },
+  { "msp430fr2532",2,8 },
+  { "msp430fr2533",2,8 },
+  { "msp430fr2632",2,8 },
+  { "msp430fr2633",2,8 },
+  { "msp430fr2xx_4xxgeneric",2,8 },
+  { "msp430fr4131",2,0 },
+  { "msp430fr4132",2,0 },
+  { "msp430fr4133",2,0 },
+  { "msp430fr5720",2,8 },
+  { "msp430fr5721",2,8 },
+  { "msp430fr5722",2,8 },
+  { "msp430fr5723",2,8 },
+  { "msp430fr5724",2,8 },
+  { "msp430fr5725",2,8 },
+  { "msp430fr5726",2,8 },
+  { "msp430fr5727",2,8 },
+  { "msp430fr5728",2,8 },
+  { "msp430fr5729",2,8 },
+  { "msp430fr5730",2,8 },
+  { "msp430fr5731",2,8 },
+  { "msp430fr5732",2,8 },
+  { "msp430fr5733",2,8 },
+  { "msp430fr5734",2,8 },
+  { "msp430fr5735",2,8 },
+  { "msp430fr5736",2,8 },
+  { "msp430fr5737",2,8 },
+  { "msp430fr5738",2,8 },
+  { "msp430fr5739",2,8 },
+  { "msp430fr57xxgeneric",2,8 },
+  { "msp430fr5847",2,8 },
+  { "msp430fr58471",2,8 },
+  { "msp430fr5848",2,8 },
+  { "msp430fr5849",2,8 },
+  { "msp430fr5857",2,8 },
+  { "msp430fr5858",2,8 },
+  { "msp430fr5859",2,8 },
+  { "msp430fr5867",2,8 },
+  { "msp430fr58671",2,8 },
+  { "msp430fr5868",2,8 },
+  { "msp430fr5869",2,8 },
+  { "msp430fr5870",2,8 },
+  { "msp430fr5872",2,8 },
+  { "msp430fr58721",2,8 },
+  { "msp430fr5887",2,8 },
+  { "msp430fr5888",2,8 },
+  { "msp430fr5889",2,8 },
+  { "msp430fr58891",2,8 },
+  { "msp430fr5922",2,8 },
+  { "msp430fr59221",2,8 },
+  { "msp430fr5947",2,8 },
+  { "msp430fr59471",2,8 },
+  { "msp430fr5948",2,8 },
+  { "msp430fr5949",2,8 },
+  { "msp430fr5957",2,8 },
+  { "msp430fr5958",2,8 },
+  { "msp430fr5959",2,8 },
+  { "msp430fr5962",2,8 },
+  { "msp430fr5964",2,8 },
+  { "msp430fr5967",2,8 },
+  { "msp430fr5968",2,8 },
+  { "msp430fr5969",2,8 },
+  { "msp430fr59691",2,8 },
+  { "msp430fr5970",2,8 },
+  { "msp430fr5972",2,8 },
+  { "msp430fr59721",2,8 },
+  { "msp430fr5986",2,8 },
+  { "msp430fr5987",2,8 },
+  { "msp430fr5988",2,8 },
+  { "msp430fr5989",2,8 },
+  { "msp430fr59891",2,8 },
+  { "msp430fr5992",2,8 },
+  { "msp430fr5994",2,8 },
+  { "msp430fr59941",2,8 },
+  { "msp430fr5xx_6xxgeneric",2,8 },
+  { "msp430fr6820",2,8 },
+  { "msp430fr6822",2,8 },
+  { "msp430fr68221",2,8 },
+  { "msp430fr6870",2,8 },
+  { "msp430fr6872",2,8 },
+  { "msp430fr68721",2,8 },
+  { "msp430fr6877",2,8 },
+  { "msp430fr6879",2,8 },
+  { "msp430fr68791",2,8 },
+  { "msp430fr6887",2,8 },
+  { "msp430fr6888",2,8 },
+  { "msp430fr6889",2,8 },
+  { "msp430fr68891",2,8 },
+  { "msp430fr6920",2,8 },
+  { "msp430fr6922",2,8 },
+  { "msp430fr69221",2,8 },
+  { "msp430fr6927",2,8 },
+  { "msp430fr69271",2,8 },
+  { "msp430fr6928",2,8 },
+  { "msp430fr6970",2,8 },
+  { "msp430fr6972",2,8 },
+  { "msp430fr69721",2,8 },
+  { "msp430fr6977",2,8 },
+  { "msp430fr6979",2,8 },
+  { "msp430fr69791",2,8 },
+  { "msp430fr6987",2,8 },
+  { "msp430fr6988",2,8 },
+  { "msp430fr6989",2,8 },
+  { "msp430fr69891",2,8 },
+  { "msp430fw423",0,0 },
+  { "msp430fw425",0,0 },
+  { "msp430fw427",0,0 },
+  { "msp430fw428",0,0 },
+  { "msp430fw429",0,0 },
+  { "msp430g2001",0,0 },
+  { "msp430g2101",0,0 },
+  { "msp430g2102",0,0 },
+  { "msp430g2111",0,0 },
+  { "msp430g2112",0,0 },
+  { "msp430g2113",0,0 },
+  { "msp430g2121",0,0 },
+  { "msp430g2131",0,0 },
+  { "msp430g2132",0,0 },
+  { "msp430g2152",0,0 },
+  { "msp430g2153",0,0 },
+  { "msp430g2201",0,0 },
+  { "msp430g2202",0,0 },
+  { "msp430g2203",0,0 },
+  { "msp430g2210",0,0 },
+  { "msp430g2211",0,0 },
+  { "msp430g2212",0,0 },
+  { "msp430g2213",0,0 },
+  { "msp430g2221",0,0 },
+  { "msp430g2230",0,0 },
+  { "msp430g2231",0,0 },
+  { "msp430g2232",0,0 },
+  { "msp430g2233",0,0 },
+  { "msp430g2252",0,0 },
+  { "msp430g2253",0,0 },
+  { "msp430g2302",0,0 },
+  { "msp430g2303",0,0 },
+  { "msp430g2312",0,0 },
+  { "msp430g2313",0,0 },
+  { "msp430g2332",0,0 },
+  { "msp430g2333",0,0 },
+  { "msp430g2352",0,0 },
+  { "msp430g2353",0,0 },
+  { "msp430g2402",0,0 },
+  { "msp430g2403",0,0 },
+  { "msp430g2412",0,0 },
+  { "msp430g2413",0,0 },
+  { "msp430g2432",0,0 },
+  { "msp430g2433",0,0 },
+  { "msp430g2444",0,0 },
+  { "msp430g2452",0,0 },
+  { "msp430g2453",0,0 },
+  { "msp430g2513",0,0 },
+  { "msp430g2533",0,0 },
+  { "msp430g2544",0,0 },
+  { "msp430g2553",0,0 },
+  { "msp430g2744",0,0 },
+  { "msp430g2755",0,0 },
+  { "msp430g2855",0,0 },
+  { "msp430g2955",0,0 },
+  { "msp430i2020",0,2 },
+  { "msp430i2021",0,2 },
+  { "msp430i2030",0,2 },
+  { "msp430i2031",0,2 },
+  { "msp430i2040",0,2 },
+  { "msp430i2041",0,2 },
+  { "msp430i2xxgeneric",0,2 },
+  { "msp430l092",0,0 },
+  { "msp430p112",0,0 },
+  { "msp430p313",0,0 },
+  { "msp430p315",0,0 },
+  { "msp430p315s",0,0 },
+  { "msp430p325",0,0 },
+  { "msp430p337",0,1 },
+  { "msp430sl5438a",2,8 },
+  { "msp430tch5e",0,0 },
+  { "msp430xgeneric",2,8 },
+  { "rf430f5144",2,8 },
+  { "rf430f5155",2,8 },
+  { "rf430f5175",2,8 },
+  { "rf430frl152h",0,0 },
+  { "rf430frl152h_rom",0,0 },
+  { "rf430frl153h",0,0 },
+  { "rf430frl153h_rom",0,0 },
+  { "rf430frl154h",0,0 },
+  { "rf430frl154h_rom",0,0 }
+};
diff --git a/gcc/config/msp430/msp430-devices.h b/gcc/config/msp430/msp430-devices.h
new file mode 100644
index 0000000..2d6c1ed
--- /dev/null
+++ b/gcc/config/msp430/msp430-devices.h
@@ -0,0 +1,11 @@ 
+struct t_msp430_mcu_data
+{
+  const char * name;
+  unsigned int revision; /* 0=> MSP430, 1=>MSP430X, 2=> MSP430Xv2.  */
+  unsigned int hwmpy;    /* 0=>none, 1=>16-bit, 2=>16-bit w/sign extend.  */
+			 /* 4=>32-bit, 8=> 32-bit (5xx).  */
+};
+
+extern struct t_msp430_mcu_data extracted_mcu_data;
+
+void msp430_extract_mcu_data (const char * mcu_name);
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index 685bdc8..02b47df 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -45,6 +45,7 @@ 
 #include "langhooks.h"
 #include "builtins.h"
 #include "intl.h"
+#include "msp430-devices.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -95,627 +96,6 @@  msp430_init_machine_status (void)
 #undef  TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE		msp430_option_override
 
-/* This is a copy of the same data structure found in gas/config/tc-msp430.c
-   Also another (sort-of) copy can be found in gcc/config/msp430/t-msp430
-   Keep these three structures in sync.
-   The data in this structure has been extracted from version 1.194 of the
-   devices.csv file released by TI in September 2016.  */
-
-struct msp430_mcu_data
-{
-  const char * name;
-  unsigned int revision; /* 0=> MSP430, 1=>MSP430X, 2=> MSP430Xv2.  */
-  unsigned int hwmpy;    /* 0=>none, 1=>16-bit, 2=>16-bit w/sign extend, 4=>32-bit, 8=> 32-bit (5xx).  */
-}
-msp430_mcu_data [] =
-{
-  { "cc430f5123",2,8 },
-  { "cc430f5125",2,8 },
-  { "cc430f5133",2,8 },
-  { "cc430f5135",2,8 },
-  { "cc430f5137",2,8 },
-  { "cc430f5143",2,8 },
-  { "cc430f5145",2,8 },
-  { "cc430f5147",2,8 },
-  { "cc430f6125",2,8 },
-  { "cc430f6126",2,8 },
-  { "cc430f6127",2,8 },
-  { "cc430f6135",2,8 },
-  { "cc430f6137",2,8 },
-  { "cc430f6143",2,8 },
-  { "cc430f6145",2,8 },
-  { "cc430f6147",2,8 },
-  { "msp430afe221",0,2 },
-  { "msp430afe222",0,2 },
-  { "msp430afe223",0,2 },
-  { "msp430afe231",0,2 },
-  { "msp430afe232",0,2 },
-  { "msp430afe233",0,2 },
-  { "msp430afe251",0,2 },
-  { "msp430afe252",0,2 },
-  { "msp430afe253",0,2 },
-  { "msp430bt5190",2,8 },
-  { "msp430c091",0,0 },
-  { "msp430c092",0,0 },
-  { "msp430c111",0,0 },
-  { "msp430c1111",0,0 },
-  { "msp430c112",0,0 },
-  { "msp430c1121",0,0 },
-  { "msp430c1331",0,0 },
-  { "msp430c1351",0,0 },
-  { "msp430c311s",0,0 },
-  { "msp430c312",0,0 },
-  { "msp430c313",0,0 },
-  { "msp430c314",0,0 },
-  { "msp430c315",0,0 },
-  { "msp430c323",0,0 },
-  { "msp430c325",0,0 },
-  { "msp430c336",0,1 },
-  { "msp430c337",0,1 },
-  { "msp430c412",0,0 },
-  { "msp430c413",0,0 },
-  { "msp430cg4616",1,1 },
-  { "msp430cg4617",1,1 },
-  { "msp430cg4618",1,1 },
-  { "msp430cg4619",1,1 },
-  { "msp430e112",0,0 },
-  { "msp430e313",0,0 },
-  { "msp430e315",0,0 },
-  { "msp430e325",0,0 },
-  { "msp430e337",0,1 },
-  { "msp430f110",0,0 },
-  { "msp430f1101",0,0 },
-  { "msp430f1101a",0,0 },
-  { "msp430f1111",0,0 },
-  { "msp430f1111a",0,0 },
-  { "msp430f112",0,0 },
-  { "msp430f1121",0,0 },
-  { "msp430f1121a",0,0 },
-  { "msp430f1122",0,0 },
-  { "msp430f1132",0,0 },
-  { "msp430f122",0,0 },
-  { "msp430f1222",0,0 },
-  { "msp430f123",0,0 },
-  { "msp430f1232",0,0 },
-  { "msp430f133",0,0 },
-  { "msp430f135",0,0 },
-  { "msp430f147",0,1 },
-  { "msp430f1471",0,1 },
-  { "msp430f148",0,1 },
-  { "msp430f1481",0,1 },
-  { "msp430f149",0,1 },
-  { "msp430f1491",0,1 },
-  { "msp430f155",0,0 },
-  { "msp430f156",0,0 },
-  { "msp430f157",0,0 },
-  { "msp430f1610",0,1 },
-  { "msp430f1611",0,1 },
-  { "msp430f1612",0,1 },
-  { "msp430f167",0,1 },
-  { "msp430f168",0,1 },
-  { "msp430f169",0,1 },
-  { "msp430f2001",0,0 },
-  { "msp430f2002",0,0 },
-  { "msp430f2003",0,0 },
-  { "msp430f2011",0,0 },
-  { "msp430f2012",0,0 },
-  { "msp430f2013",0,0 },
-  { "msp430f2101",0,0 },
-  { "msp430f2111",0,0 },
-  { "msp430f2112",0,0 },
-  { "msp430f2121",0,0 },
-  { "msp430f2122",0,0 },
-  { "msp430f2131",0,0 },
-  { "msp430f2132",0,0 },
-  { "msp430f2232",0,0 },
-  { "msp430f2234",0,0 },
-  { "msp430f2252",0,0 },
-  { "msp430f2254",0,0 },
-  { "msp430f2272",0,0 },
-  { "msp430f2274",0,0 },
-  { "msp430f233",0,2 },
-  { "msp430f2330",0,2 },
-  { "msp430f235",0,2 },
-  { "msp430f2350",0,2 },
-  { "msp430f2370",0,2 },
-  { "msp430f2410",0,2 },
-  { "msp430f2416",1,2 },
-  { "msp430f2417",1,2 },
-  { "msp430f2418",1,2 },
-  { "msp430f2419",1,2 },
-  { "msp430f247",0,2 },
-  { "msp430f2471",0,2 },
-  { "msp430f248",0,2 },
-  { "msp430f2481",0,2 },
-  { "msp430f249",0,2 },
-  { "msp430f2491",0,2 },
-  { "msp430f2616",1,2 },
-  { "msp430f2617",1,2 },
-  { "msp430f2618",1,2 },
-  { "msp430f2619",1,2 },
-  { "msp430f412",0,0 },
-  { "msp430f413",0,0 },
-  { "msp430f4132",0,0 },
-  { "msp430f415",0,0 },
-  { "msp430f4152",0,0 },
-  { "msp430f417",0,0 },
-  { "msp430f423",0,1 },
-  { "msp430f423a",0,1 },
-  { "msp430f425",0,1 },
-  { "msp430f4250",0,0 },
-  { "msp430f425a",0,1 },
-  { "msp430f4260",0,0 },
-  { "msp430f427",0,1 },
-  { "msp430f4270",0,0 },
-  { "msp430f427a",0,1 },
-  { "msp430f435",0,0 },
-  { "msp430f4351",0,0 },
-  { "msp430f436",0,0 },
-  { "msp430f4361",0,0 },
-  { "msp430f437",0,0 },
-  { "msp430f4371",0,0 },
-  { "msp430f438",0,0 },
-  { "msp430f439",0,0 },
-  { "msp430f447",0,1 },
-  { "msp430f448",0,1 },
-  { "msp430f4481",0,1 },
-  { "msp430f449",0,1 },
-  { "msp430f4491",0,1 },
-  { "msp430f4616",1,1 },
-  { "msp430f46161",1,1 },
-  { "msp430f4617",1,1 },
-  { "msp430f46171",1,1 },
-  { "msp430f4618",1,1 },
-  { "msp430f46181",1,1 },
-  { "msp430f4619",1,1 },
-  { "msp430f46191",1,1 },
-  { "msp430f47126",1,4 },
-  { "msp430f47127",1,4 },
-  { "msp430f47163",1,4 },
-  { "msp430f47166",1,4 },
-  { "msp430f47167",1,4 },
-  { "msp430f47173",1,4 },
-  { "msp430f47176",1,4 },
-  { "msp430f47177",1,4 },
-  { "msp430f47183",1,4 },
-  { "msp430f47186",1,4 },
-  { "msp430f47187",1,4 },
-  { "msp430f47193",1,4 },
-  { "msp430f47196",1,4 },
-  { "msp430f47197",1,4 },
-  { "msp430f477",0,0 },
-  { "msp430f478",0,0 },
-  { "msp430f4783",0,4 },
-  { "msp430f4784",0,4 },
-  { "msp430f479",0,0 },
-  { "msp430f4793",0,4 },
-  { "msp430f4794",0,4 },
-  { "msp430f5131",2,8 },
-  { "msp430f5132",2,8 },
-  { "msp430f5151",2,8 },
-  { "msp430f5152",2,8 },
-  { "msp430f5171",2,8 },
-  { "msp430f5172",2,8 },
-  { "msp430f5212",2,8 },
-  { "msp430f5213",2,8 },
-  { "msp430f5214",2,8 },
-  { "msp430f5217",2,8 },
-  { "msp430f5218",2,8 },
-  { "msp430f5219",2,8 },
-  { "msp430f5222",2,8 },
-  { "msp430f5223",2,8 },
-  { "msp430f5224",2,8 },
-  { "msp430f5227",2,8 },
-  { "msp430f5228",2,8 },
-  { "msp430f5229",2,8 },
-  { "msp430f5232",2,8 },
-  { "msp430f5234",2,8 },
-  { "msp430f5237",2,8 },
-  { "msp430f5239",2,8 },
-  { "msp430f5242",2,8 },
-  { "msp430f5244",2,8 },
-  { "msp430f5247",2,8 },
-  { "msp430f5249",2,8 },
-  { "msp430f5252",2,8 },
-  { "msp430f5253",2,8 },
-  { "msp430f5254",2,8 },
-  { "msp430f5255",2,8 },
-  { "msp430f5256",2,8 },
-  { "msp430f5257",2,8 },
-  { "msp430f5258",2,8 },
-  { "msp430f5259",2,8 },
-  { "msp430f5304",2,8 },
-  { "msp430f5308",2,8 },
-  { "msp430f5309",2,8 },
-  { "msp430f5310",2,8 },
-  { "msp430f5324",2,8 },
-  { "msp430f5325",2,8 },
-  { "msp430f5326",2,8 },
-  { "msp430f5327",2,8 },
-  { "msp430f5328",2,8 },
-  { "msp430f5329",2,8 },
-  { "msp430f5333",2,8 },
-  { "msp430f5335",2,8 },
-  { "msp430f5336",2,8 },
-  { "msp430f5338",2,8 },
-  { "msp430f5340",2,8 },
-  { "msp430f5341",2,8 },
-  { "msp430f5342",2,8 },
-  { "msp430f5358",2,8 },
-  { "msp430f5359",2,8 },
-  { "msp430f5418",2,8 },
-  { "msp430f5418a",2,8 },
-  { "msp430f5419",2,8 },
-  { "msp430f5419a",2,8 },
-  { "msp430f5435",2,8 },
-  { "msp430f5435a",2,8 },
-  { "msp430f5436",2,8 },
-  { "msp430f5436a",2,8 },
-  { "msp430f5437",2,8 },
-  { "msp430f5437a",2,8 },
-  { "msp430f5438",2,8 },
-  { "msp430f5438a",2,8 },
-  { "msp430f5500",2,8 },
-  { "msp430f5501",2,8 },
-  { "msp430f5502",2,8 },
-  { "msp430f5503",2,8 },
-  { "msp430f5504",2,8 },
-  { "msp430f5505",2,8 },
-  { "msp430f5506",2,8 },
-  { "msp430f5507",2,8 },
-  { "msp430f5508",2,8 },
-  { "msp430f5509",2,8 },
-  { "msp430f5510",2,8 },
-  { "msp430f5513",2,8 },
-  { "msp430f5514",2,8 },
-  { "msp430f5515",2,8 },
-  { "msp430f5517",2,8 },
-  { "msp430f5519",2,8 },
-  { "msp430f5521",2,8 },
-  { "msp430f5522",2,8 },
-  { "msp430f5524",2,8 },
-  { "msp430f5525",2,8 },
-  { "msp430f5526",2,8 },
-  { "msp430f5527",2,8 },
-  { "msp430f5528",2,8 },
-  { "msp430f5529",2,8 },
-  { "msp430f5630",2,8 },
-  { "msp430f5631",2,8 },
-  { "msp430f5632",2,8 },
-  { "msp430f5633",2,8 },
-  { "msp430f5634",2,8 },
-  { "msp430f5635",2,8 },
-  { "msp430f5636",2,8 },
-  { "msp430f5637",2,8 },
-  { "msp430f5638",2,8 },
-  { "msp430f5658",2,8 },
-  { "msp430f5659",2,8 },
-  { "msp430f5xx_6xxgeneric",2,8 },
-  { "msp430f6433",2,8 },
-  { "msp430f6435",2,8 },
-  { "msp430f6436",2,8 },
-  { "msp430f6438",2,8 },
-  { "msp430f6458",2,8 },
-  { "msp430f6459",2,8 },
-  { "msp430f6630",2,8 },
-  { "msp430f6631",2,8 },
-  { "msp430f6632",2,8 },
-  { "msp430f6633",2,8 },
-  { "msp430f6634",2,8 },
-  { "msp430f6635",2,8 },
-  { "msp430f6636",2,8 },
-  { "msp430f6637",2,8 },
-  { "msp430f6638",2,8 },
-  { "msp430f6658",2,8 },
-  { "msp430f6659",2,8 },
-  { "msp430f6720",2,8 },
-  { "msp430f6720a",2,8 },
-  { "msp430f6721",2,8 },
-  { "msp430f6721a",2,8 },
-  { "msp430f6723",2,8 },
-  { "msp430f6723a",2,8 },
-  { "msp430f6724",2,8 },
-  { "msp430f6724a",2,8 },
-  { "msp430f6725",2,8 },
-  { "msp430f6725a",2,8 },
-  { "msp430f6726",2,8 },
-  { "msp430f6726a",2,8 },
-  { "msp430f6730",2,8 },
-  { "msp430f6730a",2,8 },
-  { "msp430f6731",2,8 },
-  { "msp430f6731a",2,8 },
-  { "msp430f6733",2,8 },
-  { "msp430f6733a",2,8 },
-  { "msp430f6734",2,8 },
-  { "msp430f6734a",2,8 },
-  { "msp430f6735",2,8 },
-  { "msp430f6735a",2,8 },
-  { "msp430f6736",2,8 },
-  { "msp430f6736a",2,8 },
-  { "msp430f6745",2,8 },
-  { "msp430f67451",2,8 },
-  { "msp430f67451a",2,8 },
-  { "msp430f6745a",2,8 },
-  { "msp430f6746",2,8 },
-  { "msp430f67461",2,8 },
-  { "msp430f67461a",2,8 },
-  { "msp430f6746a",2,8 },
-  { "msp430f6747",2,8 },
-  { "msp430f67471",2,8 },
-  { "msp430f67471a",2,8 },
-  { "msp430f6747a",2,8 },
-  { "msp430f6748",2,8 },
-  { "msp430f67481",2,8 },
-  { "msp430f67481a",2,8 },
-  { "msp430f6748a",2,8 },
-  { "msp430f6749",2,8 },
-  { "msp430f67491",2,8 },
-  { "msp430f67491a",2,8 },
-  { "msp430f6749a",2,8 },
-  { "msp430f67621",2,8 },
-  { "msp430f67621a",2,8 },
-  { "msp430f67641",2,8 },
-  { "msp430f67641a",2,8 },
-  { "msp430f6765",2,8 },
-  { "msp430f67651",2,8 },
-  { "msp430f67651a",2,8 },
-  { "msp430f6765a",2,8 },
-  { "msp430f6766",2,8 },
-  { "msp430f67661",2,8 },
-  { "msp430f67661a",2,8 },
-  { "msp430f6766a",2,8 },
-  { "msp430f6767",2,8 },
-  { "msp430f67671",2,8 },
-  { "msp430f67671a",2,8 },
-  { "msp430f6767a",2,8 },
-  { "msp430f6768",2,8 },
-  { "msp430f67681",2,8 },
-  { "msp430f67681a",2,8 },
-  { "msp430f6768a",2,8 },
-  { "msp430f6769",2,8 },
-  { "msp430f67691",2,8 },
-  { "msp430f67691a",2,8 },
-  { "msp430f6769a",2,8 },
-  { "msp430f6775",2,8 },
-  { "msp430f67751",2,8 },
-  { "msp430f67751a",2,8 },
-  { "msp430f6775a",2,8 },
-  { "msp430f6776",2,8 },
-  { "msp430f67761",2,8 },
-  { "msp430f67761a",2,8 },
-  { "msp430f6776a",2,8 },
-  { "msp430f6777",2,8 },
-  { "msp430f67771",2,8 },
-  { "msp430f67771a",2,8 },
-  { "msp430f6777a",2,8 },
-  { "msp430f6778",2,8 },
-  { "msp430f67781",2,8 },
-  { "msp430f67781a",2,8 },
-  { "msp430f6778a",2,8 },
-  { "msp430f6779",2,8 },
-  { "msp430f67791",2,8 },
-  { "msp430f67791a",2,8 },
-  { "msp430f6779a",2,8 },
-  { "msp430fe423",0,0 },
-  { "msp430fe4232",0,0 },
-  { "msp430fe423a",0,0 },
-  { "msp430fe4242",0,0 },
-  { "msp430fe425",0,0 },
-  { "msp430fe4252",0,0 },
-  { "msp430fe425a",0,0 },
-  { "msp430fe427",0,0 },
-  { "msp430fe4272",0,0 },
-  { "msp430fe427a",0,0 },
-  { "msp430fg4250",0,0 },
-  { "msp430fg4260",0,0 },
-  { "msp430fg4270",0,0 },
-  { "msp430fg437",0,0 },
-  { "msp430fg438",0,0 },
-  { "msp430fg439",0,0 },
-  { "msp430fg4616",1,1 },
-  { "msp430fg4617",1,1 },
-  { "msp430fg4618",1,1 },
-  { "msp430fg4619",1,1 },
-  { "msp430fg477",0,0 },
-  { "msp430fg478",0,0 },
-  { "msp430fg479",0,0 },
-  { "msp430fg6425",2,8 },
-  { "msp430fg6426",2,8 },
-  { "msp430fg6625",2,8 },
-  { "msp430fg6626",2,8 },
-  { "msp430fr2032",2,0 },
-  { "msp430fr2033",2,0 },
-  { "msp430fr2110",2,0 },
-  { "msp430fr2111",2,0 },
-  { "msp430fr2310",2,0 },
-  { "msp430fr2311",2,0 },
-  { "msp430fr2433",2,8 },
-  { "msp430fr2532",2,8 },
-  { "msp430fr2533",2,8 },
-  { "msp430fr2632",2,8 },
-  { "msp430fr2633",2,8 },
-  { "msp430fr2xx_4xxgeneric",2,8 },
-  { "msp430fr4131",2,0 },
-  { "msp430fr4132",2,0 },
-  { "msp430fr4133",2,0 },
-  { "msp430fr5720",2,8 },
-  { "msp430fr5721",2,8 },
-  { "msp430fr5722",2,8 },
-  { "msp430fr5723",2,8 },
-  { "msp430fr5724",2,8 },
-  { "msp430fr5725",2,8 },
-  { "msp430fr5726",2,8 },
-  { "msp430fr5727",2,8 },
-  { "msp430fr5728",2,8 },
-  { "msp430fr5729",2,8 },
-  { "msp430fr5730",2,8 },
-  { "msp430fr5731",2,8 },
-  { "msp430fr5732",2,8 },
-  { "msp430fr5733",2,8 },
-  { "msp430fr5734",2,8 },
-  { "msp430fr5735",2,8 },
-  { "msp430fr5736",2,8 },
-  { "msp430fr5737",2,8 },
-  { "msp430fr5738",2,8 },
-  { "msp430fr5739",2,8 },
-  { "msp430fr57xxgeneric",2,8 },
-  { "msp430fr5847",2,8 },
-  { "msp430fr58471",2,8 },
-  { "msp430fr5848",2,8 },
-  { "msp430fr5849",2,8 },
-  { "msp430fr5857",2,8 },
-  { "msp430fr5858",2,8 },
-  { "msp430fr5859",2,8 },
-  { "msp430fr5867",2,8 },
-  { "msp430fr58671",2,8 },
-  { "msp430fr5868",2,8 },
-  { "msp430fr5869",2,8 },
-  { "msp430fr5870",2,8 },
-  { "msp430fr5872",2,8 },
-  { "msp430fr58721",2,8 },
-  { "msp430fr5887",2,8 },
-  { "msp430fr5888",2,8 },
-  { "msp430fr5889",2,8 },
-  { "msp430fr58891",2,8 },
-  { "msp430fr5922",2,8 },
-  { "msp430fr59221",2,8 },
-  { "msp430fr5947",2,8 },
-  { "msp430fr59471",2,8 },
-  { "msp430fr5948",2,8 },
-  { "msp430fr5949",2,8 },
-  { "msp430fr5957",2,8 },
-  { "msp430fr5958",2,8 },
-  { "msp430fr5959",2,8 },
-  { "msp430fr5962",2,8 },
-  { "msp430fr5964",2,8 },
-  { "msp430fr5967",2,8 },
-  { "msp430fr5968",2,8 },
-  { "msp430fr5969",2,8 },
-  { "msp430fr59691",2,8 },
-  { "msp430fr5970",2,8 },
-  { "msp430fr5972",2,8 },
-  { "msp430fr59721",2,8 },
-  { "msp430fr5986",2,8 },
-  { "msp430fr5987",2,8 },
-  { "msp430fr5988",2,8 },
-  { "msp430fr5989",2,8 },
-  { "msp430fr59891",2,8 },
-  { "msp430fr5992",2,8 },
-  { "msp430fr5994",2,8 },
-  { "msp430fr59941",2,8 },
-  { "msp430fr5xx_6xxgeneric",2,8 },
-  { "msp430fr6820",2,8 },
-  { "msp430fr6822",2,8 },
-  { "msp430fr68221",2,8 },
-  { "msp430fr6870",2,8 },
-  { "msp430fr6872",2,8 },
-  { "msp430fr68721",2,8 },
-  { "msp430fr6877",2,8 },
-  { "msp430fr6879",2,8 },
-  { "msp430fr68791",2,8 },
-  { "msp430fr6887",2,8 },
-  { "msp430fr6888",2,8 },
-  { "msp430fr6889",2,8 },
-  { "msp430fr68891",2,8 },
-  { "msp430fr6920",2,8 },
-  { "msp430fr6922",2,8 },
-  { "msp430fr69221",2,8 },
-  { "msp430fr6927",2,8 },
-  { "msp430fr69271",2,8 },
-  { "msp430fr6928",2,8 },
-  { "msp430fr6970",2,8 },
-  { "msp430fr6972",2,8 },
-  { "msp430fr69721",2,8 },
-  { "msp430fr6977",2,8 },
-  { "msp430fr6979",2,8 },
-  { "msp430fr69791",2,8 },
-  { "msp430fr6987",2,8 },
-  { "msp430fr6988",2,8 },
-  { "msp430fr6989",2,8 },
-  { "msp430fr69891",2,8 },
-  { "msp430fw423",0,0 },
-  { "msp430fw425",0,0 },
-  { "msp430fw427",0,0 },
-  { "msp430fw428",0,0 },
-  { "msp430fw429",0,0 },
-  { "msp430g2001",0,0 },
-  { "msp430g2101",0,0 },
-  { "msp430g2102",0,0 },
-  { "msp430g2111",0,0 },
-  { "msp430g2112",0,0 },
-  { "msp430g2113",0,0 },
-  { "msp430g2121",0,0 },
-  { "msp430g2131",0,0 },
-  { "msp430g2132",0,0 },
-  { "msp430g2152",0,0 },
-  { "msp430g2153",0,0 },
-  { "msp430g2201",0,0 },
-  { "msp430g2202",0,0 },
-  { "msp430g2203",0,0 },
-  { "msp430g2210",0,0 },
-  { "msp430g2211",0,0 },
-  { "msp430g2212",0,0 },
-  { "msp430g2213",0,0 },
-  { "msp430g2221",0,0 },
-  { "msp430g2230",0,0 },
-  { "msp430g2231",0,0 },
-  { "msp430g2232",0,0 },
-  { "msp430g2233",0,0 },
-  { "msp430g2252",0,0 },
-  { "msp430g2253",0,0 },
-  { "msp430g2302",0,0 },
-  { "msp430g2303",0,0 },
-  { "msp430g2312",0,0 },
-  { "msp430g2313",0,0 },
-  { "msp430g2332",0,0 },
-  { "msp430g2333",0,0 },
-  { "msp430g2352",0,0 },
-  { "msp430g2353",0,0 },
-  { "msp430g2402",0,0 },
-  { "msp430g2403",0,0 },
-  { "msp430g2412",0,0 },
-  { "msp430g2413",0,0 },
-  { "msp430g2432",0,0 },
-  { "msp430g2433",0,0 },
-  { "msp430g2444",0,0 },
-  { "msp430g2452",0,0 },
-  { "msp430g2453",0,0 },
-  { "msp430g2513",0,0 },
-  { "msp430g2533",0,0 },
-  { "msp430g2544",0,0 },
-  { "msp430g2553",0,0 },
-  { "msp430g2744",0,0 },
-  { "msp430g2755",0,0 },
-  { "msp430g2855",0,0 },
-  { "msp430g2955",0,0 },
-  { "msp430i2020",0,2 },
-  { "msp430i2021",0,2 },
-  { "msp430i2030",0,2 },
-  { "msp430i2031",0,2 },
-  { "msp430i2040",0,2 },
-  { "msp430i2041",0,2 },
-  { "msp430i2xxgeneric",0,2 },
-  { "msp430l092",0,0 },
-  { "msp430p112",0,0 },
-  { "msp430p313",0,0 },
-  { "msp430p315",0,0 },
-  { "msp430p315s",0,0 },
-  { "msp430p325",0,0 },
-  { "msp430p337",0,1 },
-  { "msp430sl5438a",2,8 },
-  { "msp430tch5e",0,0 },
-  { "msp430xgeneric",2,8 },
-  { "rf430f5144",2,8 },
-  { "rf430f5155",2,8 },
-  { "rf430f5175",2,8 },
-  { "rf430frl152h",0,0 },
-  { "rf430frl152h_rom",0,0 },
-  { "rf430frl153h",0,0 },
-  { "rf430frl153h_rom",0,0 },
-  { "rf430frl154h",0,0 },
-  { "rf430frl154h_rom",0,0 }
-};  
-
 /* Generate a C preprocessor symbol based upon the MCU selected by the user.
    If a specific MCU has not been selected then return a generic symbol instead.  */
 
@@ -724,6 +104,7 @@  msp430_mcu_name (void)
 {
   if (target_mcu)
     {
+      msp430_extract_mcu_data (target_mcu);
       unsigned int i;
       unsigned int start_upper;
       unsigned int end_upper;
@@ -757,10 +138,10 @@  hwmult_name (unsigned int val)
   switch (val)
     {
     case 0: return "none";
-    case 1: return "16-bit";
-    case 2: return "16-bit";
-    case 4: return "32-bit";
-    case 8: return "32-bit (5xx)";
+    case 2:
+    case 1: return "16bit";
+    case 4: return "32bit";
+    case 8: return "f5series";
     default: gcc_unreachable ();
     }
 }
@@ -786,45 +167,50 @@  msp430_option_override (void)
 
   if (target_mcu)
     {
+      msp430_extract_mcu_data (target_mcu);
       int i;
 
-      /* FIXME: If the array were alpha sorted, we could use a binary search.  */
-      for (i = ARRAY_SIZE (msp430_mcu_data); i--;)
-	if (strcasecmp (msp430_mcu_data[i].name, target_mcu) == 0)
-	  {
-	    bool xisa = msp430_mcu_data[i].revision >= 1; 
-
-	    if (msp430_warn_mcu)
-	      {
-		if (target_cpu&& msp430x != xisa)
-		  warning (0, "MCU '%s' supports %s ISA but -mcpu option is set to %s",
-			   target_mcu, xisa ? "430X" : "430", msp430x ? "430X" : "430");
-
-		if (msp430_mcu_data[i].hwmpy == 0
-		    && msp430_hwmult_type != MSP430_HWMULT_AUTO
-		    && msp430_hwmult_type != MSP430_HWMULT_NONE)
-		  warning (0, "MCU '%s' does not have hardware multiply support, but -mhwmult is set to %s",
-			   target_mcu,
-			   msp430_hwmult_type == MSP430_HWMULT_SMALL ? "16-bit"
-			   : msp430_hwmult_type == MSP430_HWMULT_LARGE ? "32-bit" : "f5series");
-		else if (msp430_hwmult_type == MSP430_HWMULT_SMALL
-		    && msp430_mcu_data[i].hwmpy != 1
-		    && msp430_mcu_data[i].hwmpy != 2 )
-		  warning (0, "MCU '%s' supports %s hardware multiply, but -mhwmult is set to 16-bit",
-			   target_mcu, hwmult_name (msp430_mcu_data[i].hwmpy));
-		else if (msp430_hwmult_type == MSP430_HWMULT_LARGE && msp430_mcu_data[i].hwmpy != 4)
-		  warning (0, "MCU '%s' supports %s hardware multiply, but -mhwmult is set to 32-bit",
-			   target_mcu, hwmult_name (msp430_mcu_data[i].hwmpy));
-		else if (msp430_hwmult_type == MSP430_HWMULT_F5SERIES && msp430_mcu_data[i].hwmpy != 8)
-		  warning (0, "MCU '%s' supports %s hardware multiply, but -mhwmult is set to f5series",
-			   target_mcu, hwmult_name (msp430_mcu_data[i].hwmpy));
-	      }
+      if (extracted_mcu_data.name != NULL)
+	{
+	  bool xisa = extracted_mcu_data.revision >= 1;
 
-	    msp430x = xisa;
-	    break;
-	  }
+	  if (msp430_warn_mcu)
+	    {
+	      if (target_cpu && msp430x != xisa)
+		warning (0, "MCU '%s' supports %s ISA but -mcpu option is set "
+			 "to %s", target_mcu, xisa ? "430X" : "430",
+			 msp430x ? "430X" : "430");
+
+	      if (extracted_mcu_data.hwmpy == 0
+		  && msp430_hwmult_type != MSP430_HWMULT_AUTO
+		  && msp430_hwmult_type != MSP430_HWMULT_NONE)
+		warning (0, "MCU '%s' does not have hardware multiply support, "
+			 "but -mhwmult is set to %s",
+			 target_mcu,
+			 msp430_hwmult_type == MSP430_HWMULT_SMALL ? "16bit"
+			 : msp430_hwmult_type == MSP430_HWMULT_LARGE ? "32bit"
+			 : "f5series");
+	      else if (msp430_hwmult_type == MSP430_HWMULT_SMALL
+		       && extracted_mcu_data.hwmpy != 1
+		       && extracted_mcu_data.hwmpy != 2)
+		warning (0, "MCU '%s' supports %s hardware multiply, "
+			 "but -mhwmult is set to 16bit",
+			 target_mcu, hwmult_name (extracted_mcu_data.hwmpy));
+	      else if (msp430_hwmult_type == MSP430_HWMULT_LARGE
+		       && extracted_mcu_data.hwmpy != 4)
+		warning (0, "MCU '%s' supports %s hardware multiply, "
+			 "but -mhwmult is set to 32bit",
+			 target_mcu, hwmult_name (extracted_mcu_data.hwmpy));
+	      else if (msp430_hwmult_type == MSP430_HWMULT_F5SERIES
+		       && extracted_mcu_data.hwmpy != 8)
+		warning (0, "MCU '%s' supports %s hardware multiply, "
+			 "but -mhwmult is set to f5series",
+			 target_mcu, hwmult_name (extracted_mcu_data.hwmpy));
+	    }
 
-      if (i < 0)
+	  msp430x = xisa;
+	}
+      else
 	{
 	  if (msp430_hwmult_type == MSP430_HWMULT_AUTO)
 	    {
@@ -864,7 +250,8 @@  msp430_option_override (void)
     }
 
   /* The F5 series are all able to support the 430X ISA.  */
-  if (target_cpu == NULL && target_mcu == NULL && msp430_hwmult_type == MSP430_HWMULT_F5SERIES)
+  if (target_cpu == NULL && target_mcu == NULL
+      && msp430_hwmult_type == MSP430_HWMULT_F5SERIES)
     msp430x = true;
 
   if (TARGET_LARGE && !msp430x)
@@ -3318,12 +2705,10 @@  msp430_use_f5_series_hwmult (void)
   if (strncasecmp (target_mcu, "msp430f6", 8) == 0)
     return cached_result = true;
 
-  int i;
+  msp430_extract_mcu_data (target_mcu);
 
-  /* FIXME: This array is alpha sorted - we could use a binary search.  */
-  for (i = ARRAY_SIZE (msp430_mcu_data); i--;)
-    if (strcasecmp (target_mcu, msp430_mcu_data[i].name) == 0)
-      return cached_result = msp430_mcu_data[i].hwmpy == 8;
+  if (extracted_mcu_data.name != NULL)
+    return cached_result = extracted_mcu_data.hwmpy == 8;
 
   return cached_result = false;
 }
@@ -3336,7 +2721,6 @@  use_32bit_hwmult (void)
 {
   static const char * cached_match = NULL;
   static bool         cached_result;
-  int i;
 
   if (msp430_hwmult_type == MSP430_HWMULT_LARGE)
     return true;
@@ -3349,10 +2733,9 @@  use_32bit_hwmult (void)
 
   cached_match = target_mcu;
 
-  /* FIXME: This array is alpha sorted - we could use a binary search.  */
-  for (i = ARRAY_SIZE (msp430_mcu_data); i--;)
-    if (strcasecmp (target_mcu, msp430_mcu_data[i].name) == 0)
-      return cached_result = msp430_mcu_data[i].hwmpy == 4;
+  msp430_extract_mcu_data (target_mcu);
+  if (extracted_mcu_data.name != NULL)
+    return cached_result = extracted_mcu_data.hwmpy == 4;
 
   return cached_result = false;
 }
@@ -3381,10 +2764,9 @@  msp430_no_hwmult (void)
 
   cached_match = target_mcu;
 
-  /* FIXME: This array is alpha sorted - we could use a binary search.  */
-  for (i = ARRAY_SIZE (msp430_mcu_data); i--;)
-    if (strcasecmp (target_mcu, msp430_mcu_data[i].name) == 0)
-      return cached_result = msp430_mcu_data[i].hwmpy == 0;
+  msp430_extract_mcu_data (target_mcu);
+  if (extracted_mcu_data.name != NULL)
+    return cached_result = extracted_mcu_data.hwmpy == 0;
 
   /* If we do not recognise the MCU name, we assume that it does not support
      any kind of hardware multiply - this is the safest assumption to make.  */
diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h
index 6bfe28c..acc8d16 100644
--- a/gcc/config/msp430/msp430.h
+++ b/gcc/config/msp430/msp430.h
@@ -44,6 +44,13 @@  extern bool msp430x;
     }                                           \
   while (0)
 
+extern const char * msp430_select_hwmult_lib (int, const char **);
+extern const char * msp430_select_cpu (int, const char **);
+
+# define EXTRA_SPEC_FUNCTIONS				\
+  { "msp430_hwmult_lib", msp430_select_hwmult_lib }, \
+  { "msp430_select_cpu", msp430_select_cpu },
+
 #undef  STARTFILE_SPEC
 #define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{minrt:crt0-minrt.o%s}%{!minrt:crt0.o%s}} %{!minrt:crtbegin.o%s}"
 
@@ -52,7 +59,7 @@  extern bool msp430x;
 #define ENDFILE_SPEC "%{!minrt:crtend.o%s} %{minrt:crtn-minrt.o%s}%{!minrt:crtn.o%s} -lgcc"
 
 #define ASM_SPEC "-mP " /* Enable polymorphic instructions.  */ \
-  "%{mcpu=*:-mcpu=%*}%{!mcpu=*:%{mmcu=*:-mmcu=%*}} " /* Pass the CPU type on to the assembler.  */ \
+  "%{mcpu=*:-mcpu=%*} " /* Pass the CPU type on to the assembler.  */ \
   "%{mrelax=-mQ} " /* Pass the relax option on to the assembler.  */ \
   "%{mlarge:-ml} " /* Tell the assembler if we are building for the LARGE pointer model.  */ \
   "%{!msim:-md} %{msim:%{mlarge:-md}} " /* Copy data from ROM to RAM if necessary.  */ \
@@ -67,9 +74,8 @@  extern bool msp430x;
 #define LINK_SPEC "%{mrelax:--relax} %{mlarge:%{!r:%{!g:--gc-sections}}} " \
   "%{mcode-region=*:--code-region=%*} %{mdata-region=*:--data-region=%*}"
 
-extern const char * msp430_select_hwmult_lib (int, const char **);
-# define EXTRA_SPEC_FUNCTIONS				\
-  { "msp430_hwmult_lib", msp430_select_hwmult_lib },
+#define DRIVER_SELF_SPECS \
+  "%{!mcpu=*:%{mmcu=*:%:msp430_select_cpu(%{mmcu=*:%*})}}"
 
 /* Specify the libraries to include on the linker command line.
 
diff --git a/gcc/config/msp430/t-msp430 b/gcc/config/msp430/t-msp430
index af9d5e6..97042d9 100644
--- a/gcc/config/msp430/t-msp430
+++ b/gcc/config/msp430/t-msp430
@@ -22,6 +22,10 @@  driver-msp430.o: $(srcdir)/config/msp430/driver-msp430.c \
   $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
 
+msp430-devices.o: $(srcdir)/config/msp430/msp430-devices.c \
+  $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+
 # Enable multilibs:
 
 MULTILIB_OPTIONS    = mcpu=msp430 mlarge 
@@ -30,239 +34,12 @@  MULTILIB_DIRNAMES   = 430          large
 # Match -mcpu=430
 MULTILIB_MATCHES    = mcpu?msp430=mcpu?430
 
-# Match the known 430 ISA mcu names.
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c091
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c092
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c111
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c1111
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c112
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c1121
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c1331
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c1351
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c311s
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c312
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c313
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c314
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c315
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c323
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c325
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c412
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c413
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430e112
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430e313
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430e315
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430e325
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f110
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1101
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1101a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1111
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1111a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f112
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1121
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1121a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1122
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1132
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f122
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1222
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f123
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1232
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f133
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f135
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f155
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f156
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f157
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2001
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2002
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2003
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2011
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2012
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2013
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2101
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2111
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2112
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2121
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2122
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2131
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2132
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2232
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2234
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2252
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2254
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2272
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2274
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f412
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f413
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4132
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f415
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4152
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f417
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4250
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4260
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4270
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f435
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4351
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f436
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4361
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f437
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4371
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f438
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f439
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f477
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f478
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f479
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe423
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe4232
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe423a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe4242
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe425
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe4252
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe425a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe427
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe4272
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fe427a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg4250
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg4260
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg4270
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg437
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg438
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg439
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg477
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg478
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fg479
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fw423
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fw425
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fw427
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fw428
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430fw429
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2001
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2101
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2102
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2111
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2112
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2113
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2121
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2131
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2132
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2152
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2153
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2201
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2202
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2203
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2210
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2211
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2212
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2213
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2221
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2230
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2231
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2232
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2233
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2252
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2253
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2302
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2303
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2312
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2313
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2332
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2333
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2352
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2353
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2402
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2403
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2412
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2413
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2432
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2433
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2444
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2452
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2453
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2513
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2533
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2544
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2553
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2744
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2755
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2855
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430g2955
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430l092
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430p112
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430p313
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430p315
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430p315s
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430p325
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430tch5e
-MULTILIB_MATCHES += mcpu?msp430=mmcu?rf430frl152h
-MULTILIB_MATCHES += mcpu?msp430=mmcu?rf430frl152h_rom
-MULTILIB_MATCHES += mcpu?msp430=mmcu?rf430frl153h
-MULTILIB_MATCHES += mcpu?msp430=mmcu?rf430frl153h_rom
-MULTILIB_MATCHES += mcpu?msp430=mmcu?rf430frl154h
-MULTILIB_MATCHES += mcpu?msp430=mmcu?rf430frl154h_rom
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c336
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430c337
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430e337
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f147
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1471
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f148
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1481
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f149
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1491
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1610
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1611
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f1612
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f167
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f168
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f169
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f423
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f423a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f425
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f425a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f427
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f427a
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f447
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f448
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4481
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f449
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4491
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430p337
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe221
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe222
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe223
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe231
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe232
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe233
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe251
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe252
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430afe253
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f233
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2330
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f235
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2350
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2370
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2410
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f247
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2471
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f248
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2481
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f249
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f2491
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430i2020
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430i2021
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430i2030
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430i2031
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430i2040
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430i2041
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430i2xxgeneric
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4783
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4784
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4793
-MULTILIB_MATCHES += mcpu?msp430=mmcu?msp430f4794
-
-# Add additional MCU matches like this:
-# MULTILIB_MATCHES += mcpu?msp430x=mmcu?xxxxxxxxxx
+# The correct multilib for a given mmcu is selected without the need for
+# hard-coded data here, because DRIVER_SELF_SPECS will place the correct
+# -mcpu option for a given mcu onto the command line.
 
 MULTILIB_EXCEPTIONS = mcpu=msp430/mlarge
 
-
 MULTILIB_EXTRA_OPTS =
 
 msp430-c.o: $(srcdir)/config/msp430/msp430-c.c $(RTL_H) $(TREE_H) $(CONFIG_H) $(TM_H)
diff --git a/gcc/testsuite/gcc.target/msp430/devices-main.c b/gcc/testsuite/gcc.target/msp430/devices-main.c
new file mode 100644
index 0000000..b72eacd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices-main.c
@@ -0,0 +1,5 @@ 
+int main (void)
+{
+  while (1);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/msp430/devices/README b/gcc/testsuite/gcc.target/msp430/devices/README
new file mode 100644
index 0000000..b940b5e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/README
@@ -0,0 +1,15 @@ 
+Some tests in this directory are run in a msp430-specific "torture" style,
+where all target specific options (that change code generation) that are
+expected to produce an executable for the given MCU without error are each used
+on each test source file in turn.
+
+The criteria for this torture style of testing is:
+  - The source file has a .c suffix
+  - The source file is in this "devices" subdirectory of the msp430 tests
+  - Somewhere in the test file name matches the regex:
+    [a-z0-9]+430[a-z0-9_]+(?=\.c).
+    The non-capturing part of this regex will be used as the MCU name, to
+    ascertain which multilib this device supports.
+
+Some of the options used to run the tests will produce warnings for the mcus,
+so ensure the test has dg-warning directives as appropriate.
diff --git a/gcc/testsuite/gcc.target/msp430/devices/hard_cc430f5123.c b/gcc/testsuite/gcc.target/msp430/devices/hard_cc430f5123.c
new file mode 100644
index 0000000..240ff4f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/hard_cc430f5123.c
@@ -0,0 +1,7 @@ 
+/* { dg-do link } */
+/* { dg-msp-options "-mmcu=cc430f5123" } */
+/* { dg-warning "supports 430X ISA but -mcpu option is set to 430" "" { target 430_selected } 0 } */
+/* { dg-warning "supports f5series hardware multiply" "" { target msp430_hwmul_not_f5 } 0 } */
+
+/* revision=2, hwmpy=8 */
+#include "../devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/hard_foo.c b/gcc/testsuite/gcc.target/msp430/devices/hard_foo.c
new file mode 100644
index 0000000..40a0d2e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/hard_foo.c
@@ -0,0 +1,5 @@ 
+/* { dg-do link } */
+/* { dg-msp-options "-mmcu=msp430foo" } */
+/* { dg-warning "Unrecognized MCU name 'msp430foo'.*\n.*Use the" "" { target *-*-* } 0 } */
+
+#include "../devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/hard_msp430afe253.c b/gcc/testsuite/gcc.target/msp430/devices/hard_msp430afe253.c
new file mode 100644
index 0000000..6b5d97d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/hard_msp430afe253.c
@@ -0,0 +1,7 @@ 
+/* { dg-do link } */
+/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */
+/* { dg-msp-options "-mmcu=msp430afe253" } */
+/* { dg-warning "supports 16bit hardware multiply" "" { target msp430_hwmul_not_16bit } 0 } */
+
+/* revision=0, hwmpy=2  */
+#include "../devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/hard_msp430cg4616.c b/gcc/testsuite/gcc.target/msp430/devices/hard_msp430cg4616.c
new file mode 100644
index 0000000..ae9389c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/hard_msp430cg4616.c
@@ -0,0 +1,7 @@ 
+/* { dg-do link } */
+/* { dg-msp-options "-mmcu=msp430cg4616" } */
+/* { dg-warning "supports 430X ISA but -mcpu option is set to 430" "" { target 430_selected } 0 } */
+/* { dg-warning "supports 16bit hardware multiply" "" { target msp430_hwmul_not_16bit } 0 } */
+
+/* revision=1, hwmpy=1 */
+#include "../devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/hard_msp430f4783.c b/gcc/testsuite/gcc.target/msp430/devices/hard_msp430f4783.c
new file mode 100644
index 0000000..3ac74b3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/hard_msp430f4783.c
@@ -0,0 +1,7 @@ 
+/* { dg-do link } */
+/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */
+/* { dg-msp-options "-mmcu=msp430f4783" } */
+/* { dg-warning "supports 32bit hardware multiply" "" { target msp430_hwmul_not_32bit } 0 } */
+
+/* revision=0, hwmpy=4  */
+#include "../devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/hard_rf430frl154h_rom.c b/gcc/testsuite/gcc.target/msp430/devices/hard_rf430frl154h_rom.c
new file mode 100644
index 0000000..9d608168
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/hard_rf430frl154h_rom.c
@@ -0,0 +1,7 @@ 
+/* { dg-do link } */
+/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */
+/* { dg-msp-options "-mmcu=rf430frl154h_rom" } */
+/* { dg-warning "does not have hardware multiply" "" { target msp430_hwmul_not_none } 0 } */
+
+/* revision=0, hwmpy=0  */
+#include "../devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/msp430.exp b/gcc/testsuite/gcc.target/msp430/msp430.exp
index 0bd42c2..a0de3d1 100644
--- a/gcc/testsuite/gcc.target/msp430/msp430.exp
+++ b/gcc/testsuite/gcc.target/msp430/msp430.exp
@@ -18,7 +18,199 @@ 
 
 # Exit immediately if this isn't the right target.
 if { ![istarget msp430-*-*] } then {
-  return
+    return
+}
+
+# Save the value of the global board_info->ldflags variable, so we can reset it
+# before exiting in case it gets changed during these tests.
+proc msp430_set_old_board_info_ldflags { } {
+    global msp430_old_board_ldflags
+    global board_info
+    if { [board_info [target_info name] exists ldflags] } {
+	set msp430_old_board_ldflags "[board_info [target_info name] ldflags]"
+    }
+}
+
+# This resets the value of the global board_info->ldflags variable to whatever
+# it was first saved as by the msp430_set_old_board_info_ldflags proc.
+proc msp430_reset_board_info_ldflags { } {
+    global msp430_old_board_ldflags
+    global board_info
+    if { ![info exists msp430_old_board_ldflags] } {
+	error "msp430_old_board_ldflags does not exist.
+	Ensure 'msp430_set_old_board_info_ldflags' is called before\
+	'msp430_reset_board_info_ldflags'."
+    }
+    set board_info([target_info name],ldflags) $msp430_old_board_ldflags
+}
+
+# Return the name of the mulilib directory GCC uses when invoked with 'cmd_opts'
+# as arguments.
+proc msp430_get_multidir { cmd_opts } {
+    set cmd "[board_info [target_info name] compiler] $cmd_opts \
+	--print-multi-dir"
+    set tmp [remote_exec host $cmd]
+    set retval [lindex $tmp 0]
+    set multidir [lindex $tmp 1]
+    if { $retval == 0 } {
+	if { [lsearch {430 . large} \
+	    [set multidir [string trim $multidir]]]  == -1 } {
+	    error "Unexpected multidir found: $multidir"
+	}
+	return $multidir
+    } else {
+	error "Error executing $cmd"
+    }
+}
+
+proc check_effective_target_430_selected { } {
+    return [check-flags [list "" { *-*-* } { "-mcpu=msp430" } { "" } ]]
+}
+
+proc check_effective_target_msp430_hwmul_not_none { } {
+    return [check-flags [list "" { *-*-* } \
+    { "-mhwmult=16bit" "-mhwmult=32bit" "-mhwmult=f5series" } { "" } ]]
+}
+
+proc check_effective_target_msp430_hwmul_not_16bit { } {
+    return [check-flags [list "" { *-*-* } \
+    { "-mhwmult=f5series" "-mhwmult=32bit" } { "" } ]]
+}
+
+proc check_effective_target_msp430_hwmul_not_32bit { } {
+    return [check-flags [list "" { *-*-* } \
+    { "-mhwmult=16bit" "-mhwmult=f5series" } { "" } ]]
+}
+
+proc check_effective_target_msp430_hwmul_not_f5 { } {
+    return [check-flags [list "" { *-*-* } \
+    { "-mhwmult=16bit" "-mhwmult=32bit" } { "" } ]]
+}
+
+# When tests are run using "make check", ldflags are polluted with -B and -L
+# options specific to a multilib. Link tests requiring a different multilib
+# would normally fail.
+#
+# In this situation, the linker does find and select the libgcc objects from
+# the correct multilib, however libgloss objects from the default multilib ("."
+# i.e msp430x) are always used. This causes issues if we want to run link tests
+# for -mcpu=msp430 or -mlarge.
+#
+# By extracting the multilib dir GCC thinks is needed for this test and set of
+# options, we can fix up the paths passed to -B and -L so the libgloss objects
+# from the correct multilib are selected.
+#
+# This directive should only be used if this behaviour is explicitly required,
+# as otherwise this proc has less functionality than the default "dg-options"
+# directive.
+#
+# The regex string from dg.exp to grep for dg-* directives does not account for
+# numbers, so if the proc name was dg-msp430-options it would never get called.
+proc dg-msp-options { args } {
+    if { [llength $args] != 2 } {
+	error "dg-msp-options only supports a single argument, use regular \
+	dg-options directive if a target needs to be selected."
+	return
+    }
+    global board_info
+    upvar tool_flags test_tool_flags
+    set opts [lindex $args 1]
+    if { [board_info [target_info name] exists ldflags] } {
+	msp430_reset_board_info_ldflags
+	set ldflags "[board_info [target_info name] ldflags]"
+	# This tests whether we might need to correct the multilib dir for
+	# libgloss objects such as crt0.o.
+	if { [regexp {\-B\S+libgloss} $ldflags] } {
+	    if { [board_info [target_info name] exists multitop] } {
+		set multitop "[board_info [target_info name] multitop]"
+		set multidir [msp430_get_multidir "$opts $test_tool_flags"]
+		set newmultitop $multitop
+		set default_multidir_regex "/\.($|/$)"
+		set large_multidir_regex "/large($|/$)"
+		set fourthirty_multidir_regex "/430($|/$)"
+		if { ![regexp $default_multidir_regex $multitop] 
+		    && ![regexp $large_multidir_regex $multitop]
+		    && ![regexp $fourthirty_multidir_regex $multitop] } {
+		    error "The board_info->multitop value of '$multitop'\
+		    is not caught by the any of the following regex strings:
+		    '$default_multidir_regex'
+		    '$large_multidir_regex'
+		    '$fourthirty_multidir_regex'.
+		    If this multitop value is valid then the regex needs\
+		    to be extended."
+		}
+		if { $multidir eq "430" } {
+		    set newmultitop "[regsub $default_multidir_regex \
+			$multitop {/430}]"
+		} elseif { $multidir eq "large" } {
+		    set newmultitop "[regsub $default_multidir_regex \
+			$multitop {/large}]"
+		}
+		if { $newmultitop != $multitop } {
+		    set board_info([target_info name],ldflags) \
+		    [string map "$multitop $newmultitop" "$ldflags"]
+		    # No need to set board_info->multitop, as the ldflags
+		    # change is only temporary, and multitop is not used
+		    # when building the test.
+		}
+	    } else {
+		# FIXME extract the multilib dir from ldflags -B value
+		error "board_info->multitop does not exist"
+	    }
+	}
+    }
+    upvar dg-extra-tool-flags extra-tool-flags
+    append extra-tool-flags $opts
+}
+
+# Return a list of msp430-specific options we can run the test with.
+# The mcu name is extracted from the file name, not from the -mmcu option
+# specified in the test file.
+# An alternative would be to check the
+# -mmcu option in the test file, but this is simpler and gives some finer
+# control over which tests make use of this functionality.
+
+proc msp430_get_supported_opts { test_file } {
+    global board_info
+    # If the mcu name is not recognized, run the test as normal without
+    # additional options.
+    if { ![regexp {[a-z0-9]+430[a-z0-9_]+(?=\.c)} $test_file mcu_name] } {
+	return { "" }
+    }
+    # If the testsuite has been invoked with specific MSP430 options, don't run
+    # in this torture style.
+    set multi_flags [board_info [target_info name] multilib_flags]
+    if { [string match "*mlarge*" $multi_flags]
+	|| [string match "*msmall*" $multi_flags]
+	|| [string match "*mcpu*" $multi_flags]
+	|| [string match "*mmcu*" $multi_flags]
+	|| [string match "*mhwmult*" $multi_flags] } {
+	return { "" }
+    }
+    # All mcus will compile all mhwmult options without error, but the compiler
+    # will warn, so ensure dg-warning directives are set up in the test sources.
+    set supported_opts {"" -mhwmult=none -mhwmult=16bit -mhwmult=32bit -mhwmult=f5series}
+    # Don't run -mcpu=msp430 tests if the mlarge multilib is being tested
+    if { ![string match "*mlarge*" [board_info [target_info name] \
+	multilib_flags]] } {
+	lappend supported_opts -mcpu=msp430 
+    }
+    # Default multilib supported by the MCU i.e. its ISA is msp430x
+    if { [msp430_get_multidir "-mmcu=$mcu_name"] eq "." } {
+	lappend supported_opts -mcpu=msp430x -mcpu=msp430xv2 -mlarge
+    }
+    return $supported_opts
+}
+
+# Run each test file in 'tests' with every supported msp430 specific option for
+# the mcu specified by the test.
+proc msp430_device_permutations_runtest { tests } {
+    global MSP430_DEFAULT_CFLAGS
+    foreach { test_file } $tests {
+	foreach { mcu_flags } [msp430_get_supported_opts $test_file] {
+	    dg-runtest $test_file "$mcu_flags" "$MSP430_DEFAULT_CFLAGS"
+	}
+    }
 }
 
 # Load support procs.
@@ -30,17 +222,24 @@  load_lib gcc-dg.exp
 global DEFAULT_CFLAGS
 if [info exists DEFAULT_CFLAGS] then {
     set MSP430_DEFAULT_CFLAGS \
-      [ string map { "-pedantic-errors" "" } $DEFAULT_CFLAGS ]
+	[string map { "-pedantic-errors" "" } $DEFAULT_CFLAGS]
 } else {
-   set MSP430_DEFAULT_CFLAGS ""
+    set MSP430_DEFAULT_CFLAGS ""
 }
 
 # Initialize `dg'.
 dg-init
 
+msp430_set_old_board_info_ldflags
+
 # Main loop.
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
-	"" $MSP430_DEFAULT_CFLAGS
+    "" $MSP430_DEFAULT_CFLAGS
+
+msp430_device_permutations_runtest [lsort [glob -nocomplain $srcdir/$subdir/devices/*.\[cCS\]]]
+
+# Reset any possibly changed ldflags by dg-msp-options
+msp430_reset_board_info_ldflags
 
 # All done.
 dg-finish
-- 
2.7.4