From patchwork Thu Nov 22 13:43:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1001785 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-490720-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tThKPIHd"; 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 4310yr4fNNz9s8J for ; Fri, 23 Nov 2018 00:43:48 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=vkzlQfgsDvbQ9mi0iCi9/mmjp8Phi9b7TbvjnTgWw/aZMzHDjB fT+QWefyD10gy2fMrB0v5sMKujy1T2S+6PyyU+5fVlUovtSLzMyNs64EjE1aBmH6 SDXCMCRKb21K8DUmzh5WyEUFgp2L7aLYje9+m2iOhxkMNIW3c5+Bq+FwY= 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:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=nvgW6o2HRlvXVPgDoxNhTVyEP50=; b=tThKPIHdYGYwGARJ3YuJ 95Z0bXIYXdtBIhwzuZYfa69JGgREnIfFrC9bu8/WNi5qwW2eE8760Ry3sqevg392 XiEiBitYHWD8rmReM5Nia5CInMVskbsObrQ+oqX/q/eEuj8Cm2MQ7jyYN2ETiWNb k4UZn25SzVaj5Kz/2IqiVck= Received: (qmail 44251 invoked by alias); 22 Nov 2018 13:43:41 -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 44192 invoked by uid 89); 22 Nov 2018 13:43:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=Guarantee, feasible, diverge X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Nov 2018 13:43:39 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D2669AD36; Thu, 22 Nov 2018 13:43:36 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Fix option values for -march. To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak , Jan Hubicka Message-ID: <0c782751-8793-08ab-2ae7-d0ac15f502ab@suse.cz> Date: Thu, 22 Nov 2018 14:43:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi. The patch makes clear we'll not diverge number of elements in processor_names and the corresponding enum. Plus I fixed -march=znver2 native as valid options that were not listed. Patch survives tests and bootstrap on x86_64-linux-gnu. Ready for trunk? Martin gcc/ChangeLog: 2018-11-22 Martin Liska * common/config/i386/i386-common.c (processor_names): Add static assert and add missing "znver2". (ix86_get_valid_option_values): Add checking assert for null values and add "native" value if feasible. * config/i386/i386.h: Do not declare size of processor_names. --- gcc/common/config/i386/i386-common.c | 26 ++++++++++++++++++++++---- gcc/config/i386/i386.h | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c index 1017147599c..3deac94a879 100644 --- a/gcc/common/config/i386/i386-common.c +++ b/gcc/common/config/i386/i386-common.c @@ -1478,7 +1478,7 @@ i386_except_unwind_info (struct gcc_options *opts) #define TARGET_SUPPORTS_SPLIT_STACK ix86_supports_split_stack /* This table must be in sync with enum processor_type in i386.h. */ -const char *const processor_names[PROCESSOR_max] = +const char *const processor_names[] = { "generic", "i386", @@ -1516,9 +1516,14 @@ const char *const processor_names[PROCESSOR_max] = "bdver4", "btver1", "btver2", - "znver1" + "znver1", + "znver2" }; +/* Guarantee that the array is aligned with henum processor_type. */ +STATIC_ASSERT ((sizeof (processor_names) / sizeof (processor_names[0]) + == PROCESSOR_max)); + const pta processor_alias_table[] = { {"i386", PROCESSOR_I386, CPU_NONE, 0}, @@ -1734,11 +1739,24 @@ ix86_get_valid_option_values (int option_code, { case OPT_march_: for (unsigned i = 0; i < pta_size; i++) - v.safe_push (processor_alias_table[i].name); + { + const char *name = processor_alias_table[i].name; + gcc_checking_assert (name != NULL); + v.safe_push (name); + } +#ifdef HAVE_LOCAL_CPU_DETECT + /* Add also "native" as possible value. */ + v.safe_push ("native"); +#endif + break; case OPT_mtune_: for (unsigned i = 0; i < PROCESSOR_max; i++) - v.safe_push (processor_names[i]); + { + const char *name = processor_names[i]; + gcc_checking_assert (name != NULL); + v.safe_push (name); + } break; default: break; diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 813c86dbdfa..b9e726e3d24 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2279,7 +2279,7 @@ enum processor_type }; #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS) -extern const char *const processor_names[PROCESSOR_max]; +extern const char *const processor_names[]; #include "wide-int-bitmask.h"