From patchwork Wed Jun 27 11:49:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 935424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480550-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="KKVmyJ55"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="lJZtf1Gj"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41G1Rh2pXyz9s1B for ; Wed, 27 Jun 2018 21:49:49 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=e8tplKKr2sO9u+hmJ TToEJrSxtdPfss6fxTGmoZtnMqWuDO5B6DZwTyBUgykBHcxByH4UgRdgBwNzRyYO JfPbjsRkhsZUNZpWrEDr6tESe+lUeOJkVAnpeXF7rR2vM9ca/KLdVibeNRBPMQ02 x97rLRF3X6T5B/dw8lnlAaBmEw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=1Agn6edkmrDL/DnbFSwePYX WZFo=; b=KKVmyJ55zw1HDMlGZEwPD16mj21FmISuypyEsX/vNrHktbFeuBS4wfP P12ZVi/mPWB22/+/PgvDbz/bqxUTag3Mw5hUJ6skpzKqxi+ybDtfqm5+HA0+xQI/ k83ZYJSLngu/REsqc4rNy3hXBgGL4PuXK4ai1F7ZgKWDjBtVF3qE= Received: (qmail 26898 invoked by alias); 27 Jun 2018 11:49:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 26882 invoked by uid 89); 27 Jun 2018 11:49:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?iso-8859-1?q?No=2C_score=3D-24=2E1_required=3D5=2E?= =?iso-8859-1?q?0_tests=3DAWL=2CBAYES_00=2CGIT_PATCH_0=2CGIT_PATCH_?= =?iso-8859-1?q?1=2CGIT_PATCH_2=2CGIT_PATCH_3=2CRCVD_IN_DNSWL_NONE?= =?iso-8859-1?q?=2CSPF_PASS_autolearn=3Dham_version=3D3=2E3=2E2_spa?= =?iso-8859-1?q?mmy=3D8=3Ali=2C_8=3A=B4=2C_H*r=3Ask=3At6-v6so=2C_Te?= =?iso-8859-1?q?ll?= X-HELO: mail-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 11:49:27 +0000 Received: by mail-wr0-f176.google.com with SMTP id t6-v6so1715690wrq.13 for ; Wed, 27 Jun 2018 04:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=7ir3FDXBux+QH0vPe8gkNWVfRvznvXJK0GuY5O3b7ho=; b=lJZtf1GjKYRPleIPn7ui2plz8hksW9V2MoPyNSVoP181c3xoGE5q0UeXWeRw7GgQjf 2jHooQGX2H3TGQc1Jg2v17zTEmJzRHsow8gy3/bLfw0GcXmR5dtbIim9kVjeDHh9oImG oHmu2/ANkNIPlYgytpjxAHK0g0BnXkqBxhqqzGmu1FfuibrFBpVc3ZUtXa0zuXd29neG tml+rrACLaGNJ8P+XeupTB+FmOb0IK2f4CpQCpfvQ25ocoKFSjs+tbujRJQ5Sp/Tm10E RvoP2bCCbv0quUW4gj5BpblO3I6+ubo4Bf55GxyuZDAatUyh4ukxfSrwVCjJs0Cg8+iz 4oWg== Received: from [192.168.1.136] (host81-159-214-6.range81-159.btcentralplus.com. [81.159.214.6]) by smtp.gmail.com with ESMTPSA id d4-v6sm5606989wrp.51.2018.06.27.04.49.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 04:49:24 -0700 (PDT) Subject: [PATCH 1/4] [MSP430] Consolidate hard-coded MCU data To: gcc-patches@gcc.gnu.org Cc: DJ Delorie , Nick Clifton References: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> From: Jozef Lawrynowicz Message-ID: Date: Wed, 27 Jun 2018 12:49:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> X-IsSubscribed: yes > 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? From 751a5b4f32a91d697b56fa94ca8426fa6679c5fa Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz 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 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 From patchwork Wed Jun 27 11:52:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 935426 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480551-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="afUggTTK"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="Q2tTwJjO"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41G1WL2GrLz9s1B for ; Wed, 27 Jun 2018 21:53:02 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=JoeJI5JpH84+JvEul ZGrkECe77YYhRpWEG2FVDJGft9oNU7N39mAvIyPFCCjEzY/5jtJnVeoUlQxNNGDg bv6wnZ+xMUs3QibfgUhrNSXgI93+2zhvd0qG0K5DiPz3W0B7uYUDzOkxATIBp2zw f6KZ7PQG1fozkLz57OWqlCiJgQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=vrcZ+hQ379k3FN2saJu8qQG 2Arg=; b=afUggTTKoWWjnG/09EfZMGFRzXpzjN3uY8fg8x6GshrmI+JbenPVwPV LwqLaS7BM3JfIhQMpjN/KKX39WL3QxN1X500auvcrLW5u5wCPUy/L3PKMYKs4wht E16f40a8EcD+Btob+RkbXU8VsBCg7r4qGET44tPEazktXOrLbkl4= Received: (qmail 31203 invoked by alias); 27 Jun 2018 11:52:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31193 invoked by uid 89); 27 Jun 2018 11:52:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3057 X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 11:52:52 +0000 Received: by mail-wm0-f53.google.com with SMTP id 69-v6so5145235wmf.3 for ; Wed, 27 Jun 2018 04:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=nPyEpfXXZ2okLFOryY7PeFmed5Bl7MdTKOsma0/ZeIg=; b=Q2tTwJjOsgmb8oIJgO+294ATWGajbi8ZgrrZEoV8ziqOfHrVzR1j8BB2zvJyHiBzW7 +mjyFnP75n7WanL13DUD3ILBTaerW1xl/KPPKnMi1H7eTNOLiP6z15+0I5dYUETlzMHN ajiV0+8An3H3OOcEyd8MlIytoim4/UrtbhPvaRfDLyuiOl7iyQUYPofuwU8QwU7XCrtC wgDTgboY5yoYZmc03x1hTIGlO0ntl7cKnTVR0TEqnIr18t/LlUezCTzhXPzR7puhmNni 7ldIo+PK2nKvR+akqDibCL7a4GUSF1b+GK6Q3nPE4r5rZD5HDTO78RnH8zdlSfVdS/Vc 0pGw== Received: from [192.168.1.136] (host81-159-214-6.range81-159.btcentralplus.com. [81.159.214.6]) by smtp.gmail.com with ESMTPSA id j131-v6sm5648874wmb.25.2018.06.27.04.52.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 04:52:49 -0700 (PDT) Subject: [PATCH 2/4] [MSP430] Update hard-coded MCU data To: gcc-patches@gcc.gnu.org Cc: DJ Delorie , Nick Clifton References: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> From: Jozef Lawrynowicz Message-ID: <08f52326-1fe1-abfe-8d1e-67dd0ba432fd@mittosystems.com> Date: Wed, 27 Jun 2018 12:52:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> X-IsSubscribed: yes > The second patch updates the hard-coded MCU data to the latest version. From 7da6e1edcffc1fa1a93dde5e23c87f9653132768 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Mon, 25 Jun 2018 19:56:53 +0100 Subject: [PATCH 2/4] MSP430 - Devices 1.1 Update hard-coded MCU data 2018-06-27 Jozef Lawrynowicz gcc/config/msp430/ * msp430-devices.c (hard_msp430_mcu_data): Add new devices. --- gcc/config/msp430/msp430-devices.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/gcc/config/msp430/msp430-devices.c b/gcc/config/msp430/msp430-devices.c index f20b379..fff5554 100644 --- a/gcc/config/msp430/msp430-devices.c +++ b/gcc/config/msp430/msp430-devices.c @@ -13,7 +13,7 @@ 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]; +extern struct t_msp430_mcu_data hard_msp430_mcu_data[626]; /* This function only needs to be executed once, but it can be first called from a number of different locations. */ @@ -60,10 +60,9 @@ msp430_extract_mcu_data (const char * mcu_name) } } -/* 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] = +/* The data in this structure has been extracted from version 1.205 of the + devices.csv file released by TI in April 2018. */ +struct t_msp430_mcu_data hard_msp430_mcu_data[626] = { { "cc430f5123",2,8 }, { "cc430f5125",2,8 }, @@ -479,13 +478,22 @@ struct t_msp430_mcu_data hard_msp430_mcu_data[605] = { "msp430fg6426",2,8 }, { "msp430fg6625",2,8 }, { "msp430fg6626",2,8 }, + { "msp430fr2000",2,0 }, { "msp430fr2032",2,0 }, { "msp430fr2033",2,0 }, + { "msp430fr2100",2,0 }, { "msp430fr2110",2,0 }, { "msp430fr2111",2,0 }, + { "msp430fr2153",2,8 }, + { "msp430fr2155",2,8 }, { "msp430fr2310",2,0 }, { "msp430fr2311",2,0 }, + { "msp430fr2353",2,8 }, + { "msp430fr2355",2,8 }, + { "msp430fr2422",2,8 }, { "msp430fr2433",2,8 }, + { "msp430fr2512",2,8 }, + { "msp430fr2522",2,8 }, { "msp430fr2532",2,8 }, { "msp430fr2533",2,8 }, { "msp430fr2632",2,8 }, @@ -494,6 +502,9 @@ struct t_msp430_mcu_data hard_msp430_mcu_data[605] = { "msp430fr4131",2,0 }, { "msp430fr4132",2,0 }, { "msp430fr4133",2,0 }, + { "msp430fr5041",2,8 }, + { "msp430fr5043",2,8 }, + { "msp430fr50431",2,8 }, { "msp430fr5720",2,8 }, { "msp430fr5721",2,8 }, { "msp430fr5722",2,8 }, @@ -560,6 +571,15 @@ struct t_msp430_mcu_data hard_msp430_mcu_data[605] = { "msp430fr5994",2,8 }, { "msp430fr59941",2,8 }, { "msp430fr5xx_6xxgeneric",2,8 }, + { "msp430fr6035",2,8 }, + { "msp430fr6037",2,8 }, + { "msp430fr60371",2,8 }, + { "msp430fr6041",2,8 }, + { "msp430fr6043",2,8 }, + { "msp430fr60431",2,8 }, + { "msp430fr6045",2,8 }, + { "msp430fr6047",2,8 }, + { "msp430fr60471",2,8 }, { "msp430fr6820",2,8 }, { "msp430fr6822",2,8 }, { "msp430fr68221",2,8 }, -- 2.7.4 From patchwork Wed Jun 27 11:55:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 935435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480552-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="aLifJdTr"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="PJ/pcGU3"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41G1ZL6mLqz9s2L for ; Wed, 27 Jun 2018 21:55:37 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=vRXpfqE3W75L+KcZf Hge6sQx2J5PBZArt06BVDd9M8XAsetkqG7FL6tg75fKLZsqBYcS8RFB8gkQnOdtZ wQJkSJBVyXqJGbpCwv4IuiFq0j4eIkf9wcQmN3BXlNMQTFqOs4Y6tvQiPlupuNRe q3S5pGETTCbyYFtTtSCfLHerUY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=RO0k+yhBOJyrv2YDIgzgggy zhbU=; b=aLifJdTrSSSyr6IknUldBBNvLe5Pm7Xyh4C0XIS6SqY1nxBW8l9iWmQ NorYUhjlEOwe0FN7q/p0+/txaM/Y/1ZfxtAZstyYM9WSnzUA1kOo74jFFD3flQol f3B0O2wK2hl+aYgLhSGudI08o3YAQVhjnUXi5JhZV4FUcCs7XXVc= Received: (qmail 127408 invoked by alias); 27 Jun 2018 11:55:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 125124 invoked by uid 89); 27 Jun 2018 11:55:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=silicon, heading X-HELO: mail-wm0-f54.google.com Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 11:55:23 +0000 Received: by mail-wm0-f54.google.com with SMTP id z13-v6so5180356wma.5 for ; Wed, 27 Jun 2018 04:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=MpJZD+0RWSuwm+4el3hLXbfFWZOZpWT9LRD6i4MQgAI=; b=PJ/pcGU38WaTWCqcLioRtNyzu1EeB/+JNlCwM5LxQ69Q5NhI9Vy6400xW09ae6LE1M 8YNUxx1P/9Dy1Ap6YUQ5jGkCN6uspDk7QqTWWGL7nKhM3yyMtSwAuKBsSMytkZ34YuNM ppYIL+BtvC0cM/2xPDtuD1IN1SmRZZ9pExczCFHeSCCrsTsTKPV7mzbvS+gILhsOmJtE wlkjuYV4p7BON6PLtG0vP3pAGDl2zt9FVw6LRX9djYQTTYrG6Q++MJneQDCkvB0YWcE1 M9AX16p60V00ACH5grFCIV5NL+SBO8FY/dKYU9JLbZN0TR6fk+3t1sBftkRz5bssy1bK pV+A== Received: from [192.168.1.136] (host81-159-214-6.range81-159.btcentralplus.com. [81.159.214.6]) by smtp.gmail.com with ESMTPSA id r123-v6sm6372876wmb.21.2018.06.27.04.55.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 04:55:20 -0700 (PDT) Subject: [PATCH 3/4] [MSP430] Search for MCU data file on include paths To: gcc-patches@gcc.gnu.org Cc: DJ Delorie , Nick Clifton References: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> From: Jozef Lawrynowicz Message-ID: <5863caab-cbe6-71d5-432b-11d1417c1ff0@mittosystems.com> Date: Wed, 27 Jun 2018 12:55:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> X-IsSubscribed: yes > The third patch adds functionality to search the include paths > specified with > -I for "devices.csv". If the file is found, and a device name has been > passed > to the -mmcu option, then devices.csv is parsed, and the MCU data for > the given > device is extracted. From 7e24ade1d4d16d71dca3f4d7d3e66a784d2563fd Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Tue, 26 Jun 2018 12:21:09 +0100 Subject: [PATCH 3/4] MSP430 - Devices 2 - Add functionality to read device data from CSV file 2018-06-27 Jozef Lawrynowicz gcc/config/msp430/ * msp430-devices.c (msp430_check_path_for_devices): New. (devices_csv_warning): New. (parse_devices_csv_1): New. (parse_devices_csv): New. (msp430_extract_mcu_data): Add argument to choose if devices.csv warnings should be surpressed. * msp430.c (msp430_mcu_name): Update invocation of msp430_extract_mcu_data. (msp430_option_override): Likewise. (msp430_use_f5_series_hwmult): Likewise. (use_32bit_hwmult): Likewise. (msp430_no_hwmult): Likewise. * msp430-devices.h (msp430_extract_mcu_data): Add argument to choose if devices.csv warnings should be surpressed. * msp430.h (EXTRA_SPEC_FUNCTIONS): Add msp430_check_path_for_devices. (DRIVER_SELF_SPECS): Likewise. * msp430.opt: Add -mdevices-csv-loc= and -mdisable-device-warnings options. * driver-msp430.c (msp430_select_cpu): Update invocation of msp430_extract_mcu_data. (msp430_select_hwmult_lib): Likewise. gcc/doc/ * invoke.texi: Document that MCU data for the -mmcu option value can be loaded from an external file. Document -mdisable-device-warnings. gcc/testsuite/gcc.target/msp430/ * devices/csv_msp430_{0,1,2}{0,1,2,4,8}.c: New. * devices/csv_msp430f5529.c: New. * devices/csv_msp430fr5969.c: New. * devices/devices.csv: New. * devices/msp430.h: New. * msp430.exp (msp430_get_multidir): Extend so MCU data is loaded from devices.csv for csv_* tests. (dg-msp-options): Update invocation to msp430_get_multidir. (msp430_get_supported_opts): Likewise. (msp430_device_permutations_runtest): Extend to handle csv_* tests. --- gcc/config/msp430/driver-msp430.c | 5 +- gcc/config/msp430/msp430-devices.c | 203 ++++++++++++++++++++- gcc/config/msp430/msp430-devices.h | 2 +- gcc/config/msp430/msp430.c | 10 +- gcc/config/msp430/msp430.h | 7 +- gcc/config/msp430/msp430.opt | 9 + gcc/doc/invoke.texi | 10 +- .../gcc.target/msp430/devices/csv_msp430_00.c | 6 + .../gcc.target/msp430/devices/csv_msp430_01.c | 6 + .../gcc.target/msp430/devices/csv_msp430_02.c | 6 + .../gcc.target/msp430/devices/csv_msp430_04.c | 6 + .../gcc.target/msp430/devices/csv_msp430_08.c | 6 + .../gcc.target/msp430/devices/csv_msp430_10.c | 6 + .../gcc.target/msp430/devices/csv_msp430_11.c | 6 + .../gcc.target/msp430/devices/csv_msp430_12.c | 6 + .../gcc.target/msp430/devices/csv_msp430_14.c | 6 + .../gcc.target/msp430/devices/csv_msp430_18.c | 6 + .../gcc.target/msp430/devices/csv_msp430_20.c | 6 + .../gcc.target/msp430/devices/csv_msp430_21.c | 6 + .../gcc.target/msp430/devices/csv_msp430_22.c | 6 + .../gcc.target/msp430/devices/csv_msp430_24.c | 6 + .../gcc.target/msp430/devices/csv_msp430_28.c | 6 + .../gcc.target/msp430/devices/csv_msp430f5529.c | 8 + .../gcc.target/msp430/devices/csv_msp430fr5969.c | 10 + .../gcc.target/msp430/devices/devices.csv | 17 ++ gcc/testsuite/gcc.target/msp430/devices/msp430.h | 3 + gcc/testsuite/gcc.target/msp430/msp430.exp | 35 +++- 27 files changed, 386 insertions(+), 23 deletions(-) create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_00.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_01.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_02.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_04.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_08.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_10.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_11.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_12.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_14.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_18.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_20.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_21.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_22.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_24.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430_28.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430f5529.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_msp430fr5969.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/devices.csv create mode 100644 gcc/testsuite/gcc.target/msp430/devices/msp430.h diff --git a/gcc/config/msp430/driver-msp430.c b/gcc/config/msp430/driver-msp430.c index e83c20f..4242274 100644 --- a/gcc/config/msp430/driver-msp430.c +++ b/gcc/config/msp430/driver-msp430.c @@ -27,13 +27,12 @@ #include "tm.h" #include "msp430-devices.h" - const char * msp430_select_cpu (int argc, const char ** argv) { if (argc == 0) return NULL; - msp430_extract_mcu_data (argv[0]); + msp430_extract_mcu_data (argv[0], true); /* 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) @@ -91,7 +90,7 @@ msp430_select_hwmult_lib (int argc ATTRIBUTE_UNUSED, const char ** argv ATTRIBUT } else if (strcasecmp (argv[0], "mcu") == 0) { - msp430_extract_mcu_data (argv[argc - 1]); + msp430_extract_mcu_data (argv[argc - 1], true); if (extracted_mcu_data.name != NULL) { switch (extracted_mcu_data.hwmpy) diff --git a/gcc/config/msp430/msp430-devices.c b/gcc/config/msp430/msp430-devices.c index fff5554..a87a439 100644 --- a/gcc/config/msp430/msp430-devices.c +++ b/gcc/config/msp430/msp430-devices.c @@ -12,19 +12,218 @@ #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[626]; +static const char * advice_string += "Checking the hard-coded device data..."; + +char * derived_devices_csv_loc = NULL; +/* Set to true by msp430_extract_mcu_data if called from the driver. */ +bool surpress_devices_warn = false; + +const char * +msp430_check_path_for_devices (int argc, const char **argv) +{ + /* devices_csv_loc is set by -mdevices-csv-loc. */ + if (devices_csv_loc) + return NULL; + else if (derived_devices_csv_loc) + return concat ("-mdevices-csv-loc=", derived_devices_csv_loc, NULL); + const char dirsep[2] = { DIR_SEPARATOR, 0 }; + FILE * devices_csv = NULL; + char * local_devices_csv_loc = NULL; + int i; + for (i = 0; i < argc; i++) + { + char *inc_path = ASTRDUP (argv[i]); + if (!IS_DIR_SEPARATOR (inc_path[strlen (inc_path) - 1])) + inc_path = concat (inc_path, dirsep, NULL); + local_devices_csv_loc = concat (inc_path, "devices.csv", NULL); + devices_csv = fopen (local_devices_csv_loc, "r"); + if (devices_csv != NULL) + { + fclose (devices_csv); + derived_devices_csv_loc = local_devices_csv_loc; + return concat ("-mdevices-csv-loc=", local_devices_csv_loc, NULL); + } + } + return NULL; +} + +static void +devices_csv_warning (const char * str, const char * mcu_name) +{ + if (TARGET_DISABLE_DEVICE_WARN || surpress_devices_warn) + return; + warning (0, str, mcu_name); + inform ((location_t)0, "%s", advice_string); +} + +/* Return 1 if MCU data wasn't loaded into extracted_mcu_data. */ +static int +parse_devices_csv_1 (const char * real_devices_csv_loc, const char * mcu_name) +{ + FILE * devices_csv = fopen (real_devices_csv_loc, "r"); + /* Some devices have a large number of errata, which means that MPY_TYPE + isn't found until the ~100th character in the line. line_buf_siz set to + 200 to be safe and hopefully future proof. */ + const int line_buf_siz = 200; + char line[line_buf_siz]; + const char comma[2] = ","; + char * res; + bool found_headings = false; + bool found_mcu = false; + int cpu_type = -1; + int mpy_type = -1; + int cpu_type_column = -1; + int mpy_type_column = -1; + const char * device_name_heading = "# Device Name"; + const char * cpu_type_heading = "CPU_TYPE"; + const char * mpy_type_heading = "MPY_TYPE"; + /* devices_csv should never be NULL at this stage. */ + if (devices_csv == NULL) + { + devices_csv_warning ("Unexpected error opening devices.csv.", NULL); + return 1; + } + while (1) + { + res = fgets (line, line_buf_siz, devices_csv); + if (res == NULL) + { + devices_csv_warning ("Device %s not found in devices.csv.", mcu_name); + goto end; + } + else if (strncmp (line, device_name_heading, + strlen (device_name_heading)) == 0) + { + found_headings = true; + int curr_column = 0; + char * heading = strtok (line, comma); + while (heading != NULL) + { + if (strncmp (heading, cpu_type_heading, + strlen (cpu_type_heading)) == 0) + cpu_type_column = curr_column; + else if (strncmp (heading, mpy_type_heading, + strlen (mpy_type_heading)) == 0) + mpy_type_column = curr_column; + heading = strtok (NULL, comma); + curr_column++; + } + if (curr_column < cpu_type_column || curr_column < mpy_type_column) + { + devices_csv_warning ("Couldn't read the required data from " + "devices.csv into a buffer. There may be " + "too many CPU_Bugs in the row for %s. Try " + "removing these so CPU_TYPE and MPY_TYPE " + "fit in the buffer.", mcu_name); + goto end; + } + else if (cpu_type_column == -1 || mpy_type_column == -1) + { + devices_csv_warning ("CPU_TYPE and/or MPY_TYPE headings not " + "present in devices.csv, or format not " + "as expected.", NULL); + goto end; + } + } + else if (strncasecmp (line, mcu_name, strlen (mcu_name)) == 0) + { + if (!found_headings) + { + devices_csv_warning ("Column headings format of devices.csv " + "not as expected.", NULL); + goto end; + } + extracted_mcu_data.name = mcu_name; + char * val = strtok (line, comma); + int final_col_num = (cpu_type_column < mpy_type_column) + ? mpy_type_column : cpu_type_column; + int curr_col; + bool found_cpu = false; + bool found_mpy = false; + for (curr_col = 0; curr_col < final_col_num + 1; curr_col++) + { + if (curr_col == cpu_type_column) + { + cpu_type = atoi (val); + if (strlen (val) != 1 || (cpu_type == 0 && val[0] != '0') + || cpu_type > 2 || cpu_type < 0) + { + devices_csv_warning ("Invalid CPU_TYPE read from " + "devices.csv.", NULL); + goto end; + } + extracted_mcu_data.revision = cpu_type; + found_cpu = true; + } + else if (curr_col == mpy_type_column) + { + mpy_type = atoi (val); + if ((mpy_type == 0 && val[0] != '0') + || !(mpy_type == 0 + || mpy_type == 1 + || mpy_type == 2 + || mpy_type == 4 + || mpy_type == 8)) + { + devices_csv_warning ("Invalid MPY_TYPE read from " + "devices.csv.", NULL); + goto end; + } + extracted_mcu_data.hwmpy = mpy_type; + found_mpy = true; + } + if (found_cpu && found_mpy) + { + found_mcu = true; + goto end; + } + val = strtok (NULL, comma); + } + if (cpu_type == -1 || mpy_type == -1) + devices_csv_warning ("Unknown error reading CPU_TYPE and/or " + "MPY_TYPE from devices.csv.", NULL); + goto end; + } + } + end: + fclose (devices_csv); + if (!found_mcu) + return 1; + return 0; +} + +static int +parse_devices_csv (const char * mcu_name) +{ + /* First check if the path to devices.csv was set by -mdevices-csv-loc. */ + if (devices_csv_loc != NULL) + return parse_devices_csv_1 (devices_csv_loc, mcu_name); + /* Otherwise check if the path to devices.csv was found another way. */ + else if (derived_devices_csv_loc != NULL) + return parse_devices_csv_1 (derived_devices_csv_loc, mcu_name); + return 1; +} + /* This function only needs to be executed once, but it can be first called - from a number of different locations. */ + from a number of different functions. */ void -msp430_extract_mcu_data (const char * mcu_name) +msp430_extract_mcu_data (const char * mcu_name, bool surpress_warn) { static int executed = 0; unsigned int i; + surpress_devices_warn = surpress_warn; if (mcu_name == NULL || executed == 1) return; executed = 1; + /* If parse_devices_csv returns non-zero we need to use the + hard-coded data. */ + if (!parse_devices_csv (mcu_name)) + return; /* 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) diff --git a/gcc/config/msp430/msp430-devices.h b/gcc/config/msp430/msp430-devices.h index 2d6c1ed..9500115 100644 --- a/gcc/config/msp430/msp430-devices.h +++ b/gcc/config/msp430/msp430-devices.h @@ -8,4 +8,4 @@ struct t_msp430_mcu_data extern struct t_msp430_mcu_data extracted_mcu_data; -void msp430_extract_mcu_data (const char * mcu_name); +void msp430_extract_mcu_data (const char * mcu_name, bool surpress_warn); diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 02b47df..13b8c0d 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -104,7 +104,7 @@ msp430_mcu_name (void) { if (target_mcu) { - msp430_extract_mcu_data (target_mcu); + msp430_extract_mcu_data (target_mcu, false); unsigned int i; unsigned int start_upper; unsigned int end_upper; @@ -167,7 +167,7 @@ msp430_option_override (void) if (target_mcu) { - msp430_extract_mcu_data (target_mcu); + msp430_extract_mcu_data (target_mcu, false); int i; if (extracted_mcu_data.name != NULL) @@ -2705,7 +2705,7 @@ msp430_use_f5_series_hwmult (void) if (strncasecmp (target_mcu, "msp430f6", 8) == 0) return cached_result = true; - msp430_extract_mcu_data (target_mcu); + msp430_extract_mcu_data (target_mcu, false); if (extracted_mcu_data.name != NULL) return cached_result = extracted_mcu_data.hwmpy == 8; @@ -2733,7 +2733,7 @@ use_32bit_hwmult (void) cached_match = target_mcu; - msp430_extract_mcu_data (target_mcu); + msp430_extract_mcu_data (target_mcu, false); if (extracted_mcu_data.name != NULL) return cached_result = extracted_mcu_data.hwmpy == 4; @@ -2764,7 +2764,7 @@ msp430_no_hwmult (void) cached_match = target_mcu; - msp430_extract_mcu_data (target_mcu); + msp430_extract_mcu_data (target_mcu, false); if (extracted_mcu_data.name != NULL) return cached_result = extracted_mcu_data.hwmpy == 0; diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h index acc8d16..a8daf3f 100644 --- a/gcc/config/msp430/msp430.h +++ b/gcc/config/msp430/msp430.h @@ -46,10 +46,12 @@ extern bool msp430x; extern const char * msp430_select_hwmult_lib (int, const char **); extern const char * msp430_select_cpu (int, const char **); +extern const char * msp430_check_path_for_devices (int, const char **); # define EXTRA_SPEC_FUNCTIONS \ { "msp430_hwmult_lib", msp430_select_hwmult_lib }, \ - { "msp430_select_cpu", msp430_select_cpu }, + { "msp430_select_cpu", msp430_select_cpu }, \ + { "msp430_check_path_for_devices", msp430_check_path_for_devices }, #undef STARTFILE_SPEC #define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{minrt:crt0-minrt.o%s}%{!minrt:crt0.o%s}} %{!minrt:crtbegin.o%s}" @@ -75,7 +77,8 @@ extern const char * msp430_select_cpu (int, const char **); "%{mcode-region=*:--code-region=%*} %{mdata-region=*:--data-region=%*}" #define DRIVER_SELF_SPECS \ - "%{!mcpu=*:%{mmcu=*:%:msp430_select_cpu(%{mmcu=*:%*})}}" + " %{I*:%:msp430_check_path_for_devices(%{I*:%*})}" \ + " %{!mcpu=*:%{mmcu=*:%:msp430_select_cpu(%{mmcu=*:%*})}}" /* Specify the libraries to include on the linker command line. diff --git a/gcc/config/msp430/msp430.opt b/gcc/config/msp430/msp430.opt index c027201..99195ae 100644 --- a/gcc/config/msp430/msp430.opt +++ b/gcc/config/msp430/msp430.opt @@ -92,3 +92,12 @@ Passes on a request to the assembler to enable fixes for various silicon errata. msilicon-errata-warn= Target Joined RejectNegative Report ToLower Passes on a request to the assembler to warn about various silicon errata. + +mdevices-csv-loc= +Target Joined Var(devices_csv_loc) RejectNegative Report +The path to devices.csv. The GCC driver can normally locate devices.csv itself +and pass this option to the compiler, so the user shouldn't need to pass this. + +mdisable-device-warnings +Target RejectNegative Mask(DISABLE_DEVICE_WARN) Report +Suppress warnings regarding devices.csv not being found on an include path. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d48f9b4..d0be9b5 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -21379,7 +21379,12 @@ command line. The script's name is the name of the MCU with command line defines the C preprocessor symbol @code{__XXX__} and cause the linker to search for a script called @file{xxx.ld}. -This option is also passed on to the assembler. +The ISA and hardware multiply supported for the different MCUs is hard-coded +into GCC. However, an external @samp{devices.csv} file can be used to +extend device support beyond those that have been hard-coded. + +GCC searches for the @samp{devices.csv} file on the include paths specified +with @code{-I}. @item -mwarn-mcu @itemx -mno-warn-mcu @@ -21468,6 +21473,9 @@ the named silicon errata. This option passes on a request to the assembler to enable warning messages when a silicon errata might need to be applied. +@item -mdisable-device-warnings +Suppress warnings regarding the @samp{devices.csv} file not being found. + @end table @node NDS32 Options diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_00.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_00.c new file mode 100644 index 0000000..eb95ee6 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_00.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */ +/* { dg-msp-options "-mmcu=msp430_00" } */ +/* { dg-warning "does not have hardware multiply" "" { target msp430_hwmul_not_none } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_01.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_01.c new file mode 100644 index 0000000..746d952 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_01.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */ +/* { dg-msp-options "-mmcu=msp430_01" } */ +/* { dg-warning "supports 16bit hardware multiply" "" { target msp430_hwmul_not_16bit } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_02.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_02.c new file mode 100644 index 0000000..84ad95d --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_02.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */ +/* { dg-msp-options "-mmcu=msp430_02" } */ +/* { dg-warning "supports 16bit hardware multiply" "" { target msp430_hwmul_not_16bit } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_04.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_04.c new file mode 100644 index 0000000..b692277 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_04.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */ +/* { dg-msp-options "-mmcu=msp430_04" } */ +/* { dg-warning "supports 32bit hardware multiply" "" { target msp430_hwmul_not_32bit } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_08.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_08.c new file mode 100644 index 0000000..8489ea8 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_08.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */ +/* { dg-msp-options "-mmcu=msp430_08" } */ +/* { dg-warning "supports f5series hardware multiply" "" { target msp430_hwmul_not_f5 } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_10.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_10.c new file mode 100644 index 0000000..2c88c97 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_10.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_10" } */ +/* { dg-warning "does not have hardware multiply" "" { target msp430_hwmul_not_none } 0 } */ +/* { dg-warning "supports 430X ISA but -mcpu option is set to 430" "" { target 430_selected } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_11.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_11.c new file mode 100644 index 0000000..161c8ac --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_11.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_11" } */ +/* { 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 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_12.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_12.c new file mode 100644 index 0000000..68b675e --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_12.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_12" } */ +/* { 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 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_14.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_14.c new file mode 100644 index 0000000..ebc77e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_14.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_14" } */ +/* { dg-warning "supports 430X ISA but -mcpu option is set to 430" "" { target 430_selected } 0 } */ +/* { dg-warning "supports 32bit hardware multiply" "" { target msp430_hwmul_not_32bit } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_18.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_18.c new file mode 100644 index 0000000..ad02e90 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_18.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_18" } */ +/* { 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 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_20.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_20.c new file mode 100644 index 0000000..6940975 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_20.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_20" } */ +/* { dg-warning "does not have hardware multiply" "" { target msp430_hwmul_not_none } 0 } */ +/* { dg-warning "supports 430X ISA but -mcpu option is set to 430" "" { target 430_selected } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_21.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_21.c new file mode 100644 index 0000000..62e3f2a --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_21.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_21" } */ +/* { 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 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_22.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_22.c new file mode 100644 index 0000000..bc79f0c --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_22.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_22" } */ +/* { 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 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_24.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_24.c new file mode 100644 index 0000000..f83390e --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_24.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_24" } */ +/* { dg-warning "supports 430X ISA but -mcpu option is set to 430" "" { target 430_selected } 0 } */ +/* { dg-warning "supports 32bit hardware multiply" "" { target msp430_hwmul_not_32bit } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_28.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_28.c new file mode 100644 index 0000000..1e0a2be --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430_28.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_28" } */ +/* { 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 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430f5529.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430f5529.c new file mode 100644 index 0000000..8a42cb8 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430f5529.c @@ -0,0 +1,8 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430f5529" } */ +/* { 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 } */ +/* { dg-warning "Device msp430f5529 not found in devices.csv" "" { target msp430-*-* } 0 } */ +/* { dg-message "hard-coded device data" "" { target msp430-*-* } 0 } */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_msp430fr5969.c b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430fr5969.c new file mode 100644 index 0000000..3994892 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_msp430fr5969.c @@ -0,0 +1,10 @@ +/* { dg-do link } */ +/* { dg-skip-if "MCU supports 430 ISA only" { *-*-* } { "-mlarge" "-mcpu=msp430x*" } { "" } } */ +/* { dg-msp-options "-mmcu=msp430fr5969" } */ +/* MSP430FR5969 has msp430x ISA and f5series hwmult in the hard-coded data, + check that the different values for this device in devices.csv override it. + */ +/* { dg-warning "does not have hardware multiply" "" { target msp430_hwmul_not_none } 0 } */ + + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/devices.csv b/gcc/testsuite/gcc.target/msp430/devices/devices.csv new file mode 100644 index 0000000..23b38e1 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/devices.csv @@ -0,0 +1,17 @@ +# Device Name,CPU_TYPE,MPY_TYPE +msp430_00,0,0 +msp430_01,0,1 +msp430_02,0,2 +msp430_04,0,4 +msp430_08,0,8 +msp430_10,1,0 +msp430_11,1,1 +msp430_12,1,2 +msp430_14,1,4 +msp430_18,1,8 +msp430_20,2,0 +msp430_21,2,1 +msp430_22,2,2 +msp430_24,2,4 +msp430_28,2,8 +msp430fr5969,0,0 diff --git a/gcc/testsuite/gcc.target/msp430/devices/msp430.h b/gcc/testsuite/gcc.target/msp430/devices/msp430.h new file mode 100644 index 0000000..1a1c7a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/msp430.h @@ -0,0 +1,3 @@ +#ifndef __MSP430__ +#error "__MSP430__ not defined" +#endif diff --git a/gcc/testsuite/gcc.target/msp430/msp430.exp b/gcc/testsuite/gcc.target/msp430/msp430.exp index a0de3d1..2cdf436 100644 --- a/gcc/testsuite/gcc.target/msp430/msp430.exp +++ b/gcc/testsuite/gcc.target/msp430/msp430.exp @@ -46,7 +46,10 @@ proc msp430_reset_board_info_ldflags { } { # Return the name of the mulilib directory GCC uses when invoked with 'cmd_opts' # as arguments. -proc msp430_get_multidir { cmd_opts } { +proc msp430_get_multidir { cmd_opts test_file } { + if { [string match "csv_*" [file tail $test_file]] } { + append cmd_opts " -I[file dirname $test_file] -mdisable-device-warnings" + } set cmd "[board_info [target_info name] compiler] $cmd_opts \ --print-multi-dir" set tmp [remote_exec host $cmd] @@ -114,6 +117,7 @@ proc dg-msp-options { args } { } global board_info upvar tool_flags test_tool_flags + upvar prog test_file set opts [lindex $args 1] if { [board_info [target_info name] exists ldflags] } { msp430_reset_board_info_ldflags @@ -123,7 +127,8 @@ proc dg-msp-options { args } { 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 multidir [msp430_get_multidir "$opts $test_tool_flags" \ + $test_file] set newmultitop $multitop set default_multidir_regex "/\.($|/$)" set large_multidir_regex "/large($|/$)" @@ -169,7 +174,6 @@ proc dg-msp-options { args } { # 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 @@ -196,7 +200,7 @@ proc msp430_get_supported_opts { test_file } { 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 "." } { + if { [msp430_get_multidir "-mmcu=$mcu_name" $test_file] eq "." } { lappend supported_opts -mcpu=msp430x -mcpu=msp430xv2 -mlarge } return $supported_opts @@ -204,11 +208,22 @@ proc msp430_get_supported_opts { test_file } { # 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 +proc msp430_device_permutations_runtest { tests default_cflags } { + # The specific tests being run + global runtests foreach { test_file } $tests { + if { ![runtest_file_p $runtests $test_file] } { + continue + } foreach { mcu_flags } [msp430_get_supported_opts $test_file] { - dg-runtest $test_file "$mcu_flags" "$MSP430_DEFAULT_CFLAGS" + if { [string match "csv_*" [file tail $test_file]] } { + dg-runtest $test_file "$mcu_flags" "-I[file dirname $test_file] $default_cflags" + } else { + # If not testing using devices.csv, then don't test if include + # paths are set up properly, by defining TESTING_HARD_DATA to + # remove the inclusion of msp430.h in devices-main.c. + dg-runtest $test_file "$mcu_flags" "-DTESTING_HARD_DATA $default_cflags" + } } } } @@ -234,9 +249,11 @@ 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\]]] +msp430_device_permutations_runtest \ + [lsort [glob -nocomplain $srcdir/$subdir/devices/*.\[cCS\]]] \ + "$MSP430_DEFAULT_CFLAGS" # Reset any possibly changed ldflags by dg-msp-options msp430_reset_board_info_ldflags -- 2.7.4 From patchwork Wed Jun 27 11:57:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 935440 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480553-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NBN4ghSQ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="T7k/rmpM"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41G1cf1nvsz9s1B for ; Wed, 27 Jun 2018 21:57:38 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=ZFJ7ZdG47wyCdbsXI 3v9HpLD8sBGfuXF3c14ergGfWUBgOVS6pFhxbQ1C9jBSBvLjKU1hCh7RJ0X/SoWC KaC+bgFBw0kD3bfwftGFJipbVKFIx2nO73DBdvbT9l7mjwBBBL65QQXMxz1OSQct 2eckCspnyw3r7EHKwr/G2oZMtg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=FTJ6Sw/OpOcYeow96DRpm5P BT8I=; b=NBN4ghSQOmpMWz7WKRJyouhOWWfO9NJNxv67zF1MW1NTIDrwP8ibH4B VqKPMGLn4BIw74FAvpSH+d1VQMhc6zldtCpSfFMnzhqc8tKGY1ukeT6eZ/N/euw4 /P5UFwNiGSBFZHz/fCZjym0uAfFC3k+InGICAOgFmCqo5aYL+klo= Received: (qmail 125807 invoked by alias); 27 Jun 2018 11:57:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 124855 invoked by uid 89); 27 Jun 2018 11:57:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=locating X-HELO: mail-wr0-f182.google.com Received: from mail-wr0-f182.google.com (HELO mail-wr0-f182.google.com) (209.85.128.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 11:57:26 +0000 Received: by mail-wr0-f182.google.com with SMTP id f16-v6so1758514wrm.3 for ; Wed, 27 Jun 2018 04:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=iuPh5ObmjoPYfDkzbx8or+b1AYtG6jWUt9qvxY2rJEk=; b=T7k/rmpMs6YKLgkWTnvB6UGRhQDL15Y2cJbRFY8KlcQGlRG+CMHe7ACiPxeg0UlXtO lK431iQJP26D+iuAEl5RRHqk9GCg/TGwm2/1IiZ14U77nR4yJYZ3hZVEWGFcNIi0B2q8 WAP96H+Iw7lB7wBTftMNkXX0C9kNqsBTFco/QLApNN/e8k/zSuH4SGzVpxm5jhWQFWpG cno165Q+exbyTp4FqVuVx5DX9OTkotuUDeOp3B4sSAxd6NUtvF/rxFLWysaZ2Wnxk5wu 3KdRFjFpbJ4hBG608UrOc+fgwngvaDQivG5Bbl41h78DnnbL1e50LXehJodhrYyl1zHk O83g== Received: from [192.168.1.136] (host81-159-214-6.range81-159.btcentralplus.com. [81.159.214.6]) by smtp.gmail.com with ESMTPSA id q140-v6sm2187119wmb.35.2018.06.27.04.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 04:57:23 -0700 (PDT) Subject: [PATCH 4/4] [MSP430] Search for MCU data file using environment variable and in a toolchain subdirectory To: gcc-patches@gcc.gnu.org Cc: DJ Delorie , Nick Clifton References: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> From: Jozef Lawrynowicz Message-ID: Date: Wed, 27 Jun 2018 12:57:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1f624927-f6c6-dced-6169-a31175a21965@mittosystems.com> X-IsSubscribed: yes > The fourth and final patch adds functionality to search for > devices.csv in both > the path specified by the environment variable > "MSP430_GCC_INCLUDE_DIR", and > the directory "msp430-elf/include/devices" from the toolchain root. These > locations are searched if devices.csv is not found on an include path. > If devices.csv is found using one of these methods, the directory > containing > devices.csv is also registered as an include path and linker library > path. > From 43a9106e71a8b7545f894b4c1c495288b6144876 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Tue, 26 Jun 2018 15:02:58 +0100 Subject: [PATCH 4/4] MSP430 - Devices 3 - Add functionality to read devices.csv path from env var 2018-06-27 Jozef Lawrynowicz gcc/config/msp430/ * driver-msp430.c (msp430_select_hwmult_lib): Fix formatting. (msp430_get_linker_devices_include_path): New. * msp430-devices.c (msp430_dirname): New. (canonicalize_path_dirsep): New. (process_collect_gcc_into_devices_dir): New. (msp430_check_env_var_for_devices): New. (parse_devices_csv): Call msp430_check_env_var_for_devices after trying other methods. * msp430-devices.h (msp430_check_env_var_for_devices): New. (msp430_dirname): New. * msp430.c (msp430_register_pre_includes): New. * msp430.h (EXTRA_SPEC_FUNCTIONS): Add msp430_get_linker_devices_include_path. (LINK_SPEC): Likewise. Define TARGET_EXTRA_PRE_INCLUDES to msp430_register_pre_includes. gcc/doc/ * invoke.texi: Document that devices.csv is searched for using an environment variable and in a subdirectory of the toolchain installation. gcc/testsuite/gcc.target/msp430/ * devices/csv_using_env_var.c: New. * devices/csv_using_installed.c: New. * devices/csv_using_option.c: New. * msp430.exp (msp430_device_permutations_runtest): Prepare for csv_using_* tests as appropriate. (get_installed_device_data_path): New. (msp430_hide_installed_devices_data): New. (msp430_restore_installed_devices_data): New. (msp430_test_installed_device_data): New. --- gcc/config/msp430/driver-msp430.c | 13 +++- gcc/config/msp430/msp430-devices.c | 87 +++++++++++++++++++++- gcc/config/msp430/msp430-devices.h | 2 + gcc/config/msp430/msp430.c | 16 ++++ gcc/config/msp430/msp430.h | 12 ++- gcc/doc/invoke.texi | 28 ++++++- .../gcc.target/msp430/devices/csv_using_env_var.c | 10 +++ .../msp430/devices/csv_using_installed.c | 11 +++ .../gcc.target/msp430/devices/csv_using_option.c | 12 +++ gcc/testsuite/gcc.target/msp430/msp430.exp | 70 ++++++++++++++++- 10 files changed, 254 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_using_env_var.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_using_installed.c create mode 100644 gcc/testsuite/gcc.target/msp430/devices/csv_using_option.c diff --git a/gcc/config/msp430/driver-msp430.c b/gcc/config/msp430/driver-msp430.c index 4242274..3facdc2 100644 --- a/gcc/config/msp430/driver-msp430.c +++ b/gcc/config/msp430/driver-msp430.c @@ -52,7 +52,8 @@ msp430_select_cpu (int argc, const char ** argv) /* Implement spec function `msp430_hwmult_libĀ“. */ const char * -msp430_select_hwmult_lib (int argc ATTRIBUTE_UNUSED, const char ** argv ATTRIBUTE_UNUSED) +msp430_select_hwmult_lib (int argc ATTRIBUTE_UNUSED, + const char ** argv ATTRIBUTE_UNUSED) { int i; @@ -116,3 +117,13 @@ msp430_select_hwmult_lib (int argc ATTRIBUTE_UNUSED, const char ** argv ATTRIBUT return "-lmul_none"; } + +const char * +msp430_get_linker_devices_include_path (int argc ATTRIBUTE_UNUSED, + const char **argv ATTRIBUTE_UNUSED) +{ + char *devices_csv_path; + if (msp430_check_env_var_for_devices (&devices_csv_path)) + return NULL; + return concat ("-L", msp430_dirname (devices_csv_path), NULL); +} diff --git a/gcc/config/msp430/msp430-devices.c b/gcc/config/msp430/msp430-devices.c index a87a439..597568c 100644 --- a/gcc/config/msp430/msp430-devices.c +++ b/gcc/config/msp430/msp430-devices.c @@ -23,6 +23,88 @@ char * derived_devices_csv_loc = NULL; /* Set to true by msp430_extract_mcu_data if called from the driver. */ bool surpress_devices_warn = false; +/* This modifies the string pointed to by path. */ +char * +msp430_dirname (char *path) +{ + int last_elem = strlen (path) - 1; + int i = last_elem - (IS_DIR_SEPARATOR (path[last_elem]) ? 1 : 0); + for (; i >= 0; i--) + { + if (IS_DIR_SEPARATOR (path[i])) + { + path[i] = '\0'; + return path; + } + } + return path; +} + +/* This is to canonicalize the path. On Windows we can have a mix of forward + and backslashes which leads to issues following paths. */ +static void +canonicalize_path_dirsep (char **path) +{ + char *t_path = *path; + unsigned int i; + for (i = 0; i < strlen (t_path); i++) + if (IS_DIR_SEPARATOR (t_path[i])) + t_path[i] = DIR_SEPARATOR; +} + +static void +process_collect_gcc_into_devices_dir (char **devices_loc) +{ + const char rest_of_devices_path[] = "/msp430-elf/include/devices/"; + char *t_devices_loc = *devices_loc; + /* Go up a directory to the toolchain root. */ + t_devices_loc = msp430_dirname (msp430_dirname (t_devices_loc)); + t_devices_loc = concat (t_devices_loc, rest_of_devices_path, NULL); + *devices_loc = t_devices_loc; +} + +int +msp430_check_env_var_for_devices (char **local_devices_csv_loc) +{ + const int num_vars = 2; + const char dirsep[2] = { DIR_SEPARATOR, 0 }; + /* Use the COLLECT_GCC environment variable to find toolchain root directory. + */ + const char *env_vars[num_vars] = { "MSP430_GCC_INCLUDE_DIR", "COLLECT_GCC" }; + FILE *devices_csv_file = NULL; + unsigned int i; + + for (i = 0; i < num_vars; i++) + { + char *t_devices_loc; + char *val = getenv (env_vars[i]); + if (val == NULL) + continue; + t_devices_loc = ASTRDUP (val); + + /* MSP430_GCC_INCLUDE_DIR. */ + if (i == 0) + { + if (!IS_DIR_SEPARATOR (t_devices_loc[strlen (t_devices_loc) - 1])) + t_devices_loc = concat (t_devices_loc, dirsep, NULL); + } + /* COLLECT_GCC. */ + else if (i == 1) + process_collect_gcc_into_devices_dir (&t_devices_loc); + + t_devices_loc = concat (t_devices_loc, "devices.csv", NULL); + devices_csv_file = fopen (t_devices_loc, "r"); + if (devices_csv_file != NULL) + { + fclose (devices_csv_file); + *local_devices_csv_loc = t_devices_loc; + canonicalize_path_dirsep (local_devices_csv_loc); + return 0; + } + } + return 1; +} + const char * msp430_check_path_for_devices (int argc, const char **argv) { @@ -206,7 +288,10 @@ parse_devices_csv (const char * mcu_name) /* Otherwise check if the path to devices.csv was found another way. */ else if (derived_devices_csv_loc != NULL) return parse_devices_csv_1 (derived_devices_csv_loc, mcu_name); - return 1; + /* Otherwise we need to use environment variables to try and find it. */ + else + return msp430_check_env_var_for_devices (&derived_devices_csv_loc) + || parse_devices_csv_1 (derived_devices_csv_loc, mcu_name); } /* This function only needs to be executed once, but it can be first called diff --git a/gcc/config/msp430/msp430-devices.h b/gcc/config/msp430/msp430-devices.h index 9500115..e92927a 100644 --- a/gcc/config/msp430/msp430-devices.h +++ b/gcc/config/msp430/msp430-devices.h @@ -9,3 +9,5 @@ struct t_msp430_mcu_data extern struct t_msp430_mcu_data extracted_mcu_data; void msp430_extract_mcu_data (const char * mcu_name, bool surpress_warn); +int msp430_check_env_var_for_devices (char **local_devices_csv_loc); +char * msp430_dirname (char *path); diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 13b8c0d..1ea2ecc 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -46,6 +46,8 @@ #include "builtins.h" #include "intl.h" #include "msp430-devices.h" +#include "incpath.h" +#include "prefix.h" /* This file should be included last. */ #include "target-def.h" @@ -3252,6 +3254,20 @@ msp430_can_change_mode_class (machine_mode from, machine_mode to, reg_class_t) return false; return true; } + +void +msp430_register_pre_includes (const char *sysroot ATTRIBUTE_UNUSED, + const char *iprefix ATTRIBUTE_UNUSED, + int stdinc ATTRIBUTE_UNUSED) +{ + char *include_dir; + if (msp430_check_env_var_for_devices (&include_dir)) + return; + include_dir = msp430_dirname (include_dir); + + include_dir = update_path (include_dir, ""); + add_path (include_dir, INC_SYSTEM, false, false); +} struct gcc_target targetm = TARGET_INITIALIZER; diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h index a8daf3f..ce94116 100644 --- a/gcc/config/msp430/msp430.h +++ b/gcc/config/msp430/msp430.h @@ -47,11 +47,14 @@ extern bool msp430x; extern const char * msp430_select_hwmult_lib (int, const char **); extern const char * msp430_select_cpu (int, const char **); extern const char * msp430_check_path_for_devices (int, const char **); +extern const char * msp430_get_linker_devices_include_path (int, const char **); # define EXTRA_SPEC_FUNCTIONS \ { "msp430_hwmult_lib", msp430_select_hwmult_lib }, \ { "msp430_select_cpu", msp430_select_cpu }, \ - { "msp430_check_path_for_devices", msp430_check_path_for_devices }, + { "msp430_check_path_for_devices", msp430_check_path_for_devices }, \ + { "msp430_get_linker_devices_include_path", \ + msp430_get_linker_devices_include_path }, #undef STARTFILE_SPEC #define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{minrt:crt0-minrt.o%s}%{!minrt:crt0.o%s}} %{!minrt:crtbegin.o%s}" @@ -74,7 +77,8 @@ extern const char * msp430_check_path_for_devices (int, const char **); are creating a relocatable binary (gc does not work) or debugging is enabled (the GDB testsuite relies upon unused entities not being deleted). */ #define LINK_SPEC "%{mrelax:--relax} %{mlarge:%{!r:%{!g:--gc-sections}}} " \ - "%{mcode-region=*:--code-region=%*} %{mdata-region=*:--data-region=%*}" + "%{mcode-region=*:--code-region=%*} %{mdata-region=*:--data-region=%*} " \ + "%:msp430_get_linker_devices_include_path(%{L*:%*})" #define DRIVER_SELF_SPECS \ " %{I*:%:msp430_check_path_for_devices(%{I*:%*})}" \ @@ -424,5 +428,9 @@ typedef struct #undef USE_SELECT_SECTION_FOR_FUNCTIONS #define USE_SELECT_SECTION_FOR_FUNCTIONS 1 +void msp430_register_pre_includes (const char *sysroot, const char *iprefix, + int stdinc); +#define TARGET_EXTRA_PRE_INCLUDES msp430_register_pre_includes + #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \ msp430_output_aligned_decl_common ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d0be9b5..b8e2286 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -21383,8 +21383,32 @@ The ISA and hardware multiply supported for the different MCUs is hard-coded into GCC. However, an external @samp{devices.csv} file can be used to extend device support beyond those that have been hard-coded. -GCC searches for the @samp{devices.csv} file on the include paths specified -with @code{-I}. +GCC searches for the @samp{devices.csv} file using the following methods in the +given precedence order, where the first method takes precendence over the +second which takes precedence over the third. + +@table @asis +@item Include path specified with @code{-I} +@samp{devices.csv} will be searched for in each of the directories specified by +include paths. +@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR} +Define the value of the global environment variable +@samp{MSP430_GCC_INCLUDE_DIR} +to the full path to the directory containing devices.csv, and GCC will search +this directory for devices.csv. If devices.csv is found, this directory will +also be registered as an include path, and linker library path. Header files +and linker scripts in this directory can therefore be used without manually +specifying @code{-I} and @code{-L} on the command line. +@item The @samp{msp430-elf/include/devices} directory +Finally, GCC will examine @samp{msp430-elf/include/devices} from the +toolchain root directory. This directory does not exist in a default +installation, but if the user has created it and copied @samp{devices.csv} +there, then the MCU data will be read. As above, this directory will +also be registered as an include path, and linker library path. + +@end table +If none of the above search methods find @samp{devices.csv}, then the +hard-coded MCU data is used. @item -mwarn-mcu @itemx -mno-warn-mcu diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_using_env_var.c b/gcc/testsuite/gcc.target/msp430/devices/csv_using_env_var.c new file mode 100644 index 0000000..506ae74 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_using_env_var.c @@ -0,0 +1,10 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_28" } */ +/* { 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 } */ + +/* This tests that the environment variable MSP430_GCC_INCLUDE_DIR can be used + to specify the path to the directory containing devices.csv. + The variable is set in msp430.exp. */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_using_installed.c b/gcc/testsuite/gcc.target/msp430/devices/csv_using_installed.c new file mode 100644 index 0000000..f5d7806 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_using_installed.c @@ -0,0 +1,11 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_28" } */ +/* { 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 } */ + +/* This tests that the devices.csv can be installed into the + "$TOOLCHAIN_ROOT/msp430-elf/include/devices/" and used to read device data. + msp430.exp will mark this test unsupported if the above directory does not + exist. */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv_using_option.c b/gcc/testsuite/gcc.target/msp430/devices/csv_using_option.c new file mode 100644 index 0000000..c8d7f6d --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/devices/csv_using_option.c @@ -0,0 +1,12 @@ +/* { dg-do link } */ +/* { dg-msp-options "-mmcu=msp430_28" } */ +/* { 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 } */ + +/* This tests that the -mdevices-csv-loc option can be used to specify the path + to devices.csv. + The option is passed in msp430.exp, rather than in the dg-msp-options + directive above, as the full path to devices.csv is not known at this + point. */ + +#include "../devices-main.c" diff --git a/gcc/testsuite/gcc.target/msp430/msp430.exp b/gcc/testsuite/gcc.target/msp430/msp430.exp index 2cdf436..fe57469 100644 --- a/gcc/testsuite/gcc.target/msp430/msp430.exp +++ b/gcc/testsuite/gcc.target/msp430/msp430.exp @@ -215,6 +215,29 @@ proc msp430_device_permutations_runtest { tests default_cflags } { if { ![runtest_file_p $runtests $test_file] } { continue } + # Don't run torture style tests on every method of locating devices.csv + # The device name passed to -mmcu in the csv_using_* tests do not exist + # in the hard-coded data, so to ensure the test fails if method can't + # find the device data. + if { [file tail $test_file] eq "csv_using_installed.c" } { + msp430_test_installed_device_data $test_file $default_cflags + continue + # The path passed to -mdevices-csv-loc is not used to infer an + # include dir to find msp430.h, so define TESTING_HARD_DATA to prevent + # msp430.h being included. + } elseif { [file tail $test_file] eq "csv_using_option.c" } { + dg-runtest $test_file \ + "-mdevices-csv-loc=[file dirname $test_file]/devices.csv" \ + "-DTESTING_HARD_DATA $default_cflags" + continue + } elseif { [file tail $test_file] eq "csv_using_env_var.c" } { + setenv MSP430_GCC_INCLUDE_DIR [file dirname $test_file] + verbose -log "MSP430_GCC_INCLUDE_DIR=[file dirname $test_file]" + dg-runtest $test_file "" "$default_cflags" + setenv MSP430_GCC_INCLUDE_DIR "" + verbose -log "MSP430_GCC_INCLUDE_DIR=\"\"" + continue + } foreach { mcu_flags } [msp430_get_supported_opts $test_file] { if { [string match "csv_*" [file tail $test_file]] } { dg-runtest $test_file "$mcu_flags" "-I[file dirname $test_file] $default_cflags" @@ -228,6 +251,48 @@ proc msp430_device_permutations_runtest { tests default_cflags } { } } +# Return $TOOLCHAIN_ROOT/msp430-elf/include/devices/ +proc get_installed_device_data_path { } { + set compiler [lindex [regexp -all -inline {\S+} \ + [board_info [target_info name] compiler]] 0] + # $compiler is actually a file, but normalize will still get us the desired + # result. + return [file normalize \ + "$compiler/../../msp430-elf/include/devices/devices.csv"] +} + +# If the devices.csv is installed in +# $TOOLCHAIN_ROOT/msp430-elf/include/devices/, rename it so it doesn't +# interfere with the hard-coded device data tests. +proc msp430_hide_installed_devices_data { } { + set devices_path [get_installed_device_data_path] + if { [file exists $devices_path] } { + file rename $devices_path "$devices_path.bak" + } +} + +# Restore devices.csv if renamed by msp430_hide_installed_devices_data. +proc msp430_restore_installed_devices_data { } { + set devices_path [get_installed_device_data_path] + if { [file exists "$devices_path.bak"] } { + file rename "$devices_path.bak" $devices_path + } +} + +proc msp430_test_installed_device_data { name default_cflags } { + global subdir + msp430_restore_installed_devices_data + set devices_path [get_installed_device_data_path] + if { [file exists $devices_path] } { + dg-runtest $name "" "$default_cflags" + } else { + set shorter_name "$subdir/[file tail $name]" + verbose -log "$shorter_name not supported, $devices_path doesn't exist." + unsupported $shorter_name + } + msp430_hide_installed_devices_data +} + # Load support procs. load_lib gcc-dg.exp @@ -245,18 +310,21 @@ if [info exists DEFAULT_CFLAGS] then { # Initialize `dg'. dg-init -msp430_set_old_board_info_ldflags +msp430_hide_installed_devices_data # Main loop. dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ "" "$MSP430_DEFAULT_CFLAGS" +msp430_set_old_board_info_ldflags + msp430_device_permutations_runtest \ [lsort [glob -nocomplain $srcdir/$subdir/devices/*.\[cCS\]]] \ "$MSP430_DEFAULT_CFLAGS" # Reset any possibly changed ldflags by dg-msp-options msp430_reset_board_info_ldflags +msp430_restore_installed_devices_data # All done. dg-finish -- 2.7.4