From patchwork Mon Oct 4 15:11:18 2021 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: 45790 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F3E6385843C for ; Mon, 4 Oct 2021 15:11:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id EFD703858D28 for ; Mon, 4 Oct 2021 15:11:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EFD703858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E24CA2230E; Mon, 4 Oct 2021 15:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1633360278; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b/ksBUfryg7tEdugDb5SF/y3OZ6JtE4X8jfjT6v5FsQ=; b=0gdaurO0IQ7yBhiiEzVwaqRqzpM1/Z3eY+VP541ECj3Z0yO+JZMjJiHZITEpjXI/7oDrAC 55i94rFrDQ8JqLjmyw6NzB9bDpLNUnNHNU8MELpIPnC8dIK/9zImR57AJsuFnOT5MZF1QI qGiXqLeDJkCV0kjqgeX5p9aCxFtwwBw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1633360278; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b/ksBUfryg7tEdugDb5SF/y3OZ6JtE4X8jfjT6v5FsQ=; b=1fKkNS9jYXkhEU6y+NIKwOtfDS2fzsMKVAwPcIkKNe9V+5gKqy/7T+N4FOddFclVmJ9WxH ta+0wNSlM91cxBAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C20A512FC5; Mon, 4 Oct 2021 15:11:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xRhYLpYZW2GHEAAAMHmgww (envelope-from ); Mon, 04 Oct 2021 15:11:18 +0000 Message-ID: Date: Mon, 4 Oct 2021 17:11:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH][i386] target: support spaces in target attribute. To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hello. The patch is about supporting target attribute values like "no-avx, sse2 ". I'm planning doing the same change for aarch64 and other archs as well once this one is accepted. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR target/102374 gcc/ChangeLog: * config/i386/i386-options.c (ix86_valid_target_attribute_inner_p): * system.h (strip_spaces): gcc/testsuite/ChangeLog: * gcc.target/i386/pr102374.c: New test. --- gcc/config/i386/i386-options.c | 2 ++ gcc/system.h | 21 +++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr102374.c | 3 +++ 3 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr102374.c diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c index e7a3bd4aaea..c88bc77b04d 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -1146,6 +1146,8 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[], next_optstr = NULL; } + p = strip_spaces (p, &len); + /* Recognize no-xxx. */ if (len > 3 && p[0] == 'n' && p[1] == 'o' && p[2] == '-') { diff --git a/gcc/system.h b/gcc/system.h index adde3e264b6..35b15203a96 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -1305,4 +1305,25 @@ startswith (const char *str, const char *prefix) return strncmp (str, prefix, strlen (prefix)) == 0; } +/* Strip spaces from STRING with LEN length. + A stripped string is returned and LEN is updated accordingly. */ + +static inline char * +strip_spaces (char *string, size_t *len) +{ + while (string[0] == ' ') + { + --(*len); + ++string; + } + + while (string[*len - 1] == ' ') + { + string[*len - 1] = '\0'; + --(*len); + } + + return string; +} + #endif /* ! GCC_SYSTEM_H */ diff --git a/gcc/testsuite/gcc.target/i386/pr102374.c b/gcc/testsuite/gcc.target/i386/pr102374.c new file mode 100644 index 00000000000..db84aeed9a5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr102374.c @@ -0,0 +1,3 @@ +/* PR target/102374 */ + +void calculate_sse(void) __attribute__ ((__target__ ("no-avx, sse2 ")));