From patchwork Mon May 18 14:57:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 473415 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 C0F0914016A for ; Tue, 19 May 2015 00:57:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ODMQPYK6; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=hxbV0NofJf5bFwURpv2wecWebjoACtFRwxYPX+WPMPk M47G6+JhYbbAHu1i4JXicFiyeN5VKwlPpoRVlULSAW7WmsBoftk8A3JSHv8Sms5k VE7QG//V5f1oUV9LB4lElyRx79otCRVQxh60/8igm7iRqnbDDPNW1m1oFrbnWQes = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=/eMVuBvue+MtnrNsBSe9dCKGxC8=; b=ODMQPYK6VJJRVMsaD Z12XDFmtHYDuWD5WSFJpNUQIKpXZadT8pBn9I0vShs33UpQu981Nf/KSmhuwmjaJ x8MVkN23dv2w0X8MslUTWPRdEplroK8rFo8qq41kmenKRN1rLxZxXzBP6AjaEoNl ue3c83pUvAIXMNPKnS8ETZbG3o= Received: (qmail 115386 invoked by alias); 18 May 2015 14:57: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 115306 invoked by uid 89); 18 May 2015 14:57:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 May 2015 14:57:36 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-18.uk.mimecast.lan; Mon, 18 May 2015 15:57:31 +0100 Received: from [10.2.206.56] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 18 May 2015 15:57:30 +0100 Message-ID: <5559FDDA.5060902@arm.com> Date: Mon, 18 May 2015 15:57:30 +0100 From: Szabolcs Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Marcus Shawcroft , Ramana Radhakrishnan Subject: [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk X-MC-Unique: WlgKMqorQGu9nsDDZ0KByA-1 X-IsSubscribed: yes Rewrote the generator script in awk, to avoid dealing with sed portability issues. gcc/Changelog: 2015-05-18 Szabolcs Nagy PR target/66136 * config/aarch64/geniterators.sh: Rewrite in awk. diff --git a/gcc/config/aarch64/geniterators.sh b/gcc/config/aarch64/geniterators.sh index f908e89..5a51d29 100644 --- a/gcc/config/aarch64/geniterators.sh +++ b/gcc/config/aarch64/geniterators.sh @@ -22,25 +22,52 @@ # Generate aarch64-builtin-iterators.h, a file containing a series of # BUILTIN_ macros, which expand to VAR Macros covering the # same set of modes as the iterator in iterators.md - -echo "/* -*- buffer-read-only: t -*- */" -echo "/* Generated automatically by geniterators.sh from iterators.md. */" -echo "#ifndef GCC_AARCH64_ITERATORS_H" -echo "#define GCC_AARCH64_ITERATORS_H" - -# Strip newlines, create records marked ITERATOR, and strip junk (anything -# which does not have a matching brace because it contains characters we +# +# Find the definitions (may span several lines), skip the ones +# which does not have a simple format because it contains characters we # don't want to or can't handle (e.g P, PTR iterators change depending on # Pmode and ptr_mode). -export LC_ALL=C -cat $1 | tr "\n" " " \ - | sed 's/(define_mode_iterator \([A-Za-z0-9_]*\) \([]\[A-Z0-9 \t]*\)/\n#define BUILTIN_\1(T, N, MAP) \\ \2\n/g' \ - | grep '#define [A-Z0-9_(), \\]* \[[A-Z0-9[:space:]]*]' \ - | sed 's/\t//g' \ - | sed 's/ */ /g' \ - | sed 's/ \[\([A-Z0-9 ]*\)]/\n\1/' \ - | awk ' BEGIN { FS = " " ; OFS = ", "} \ - /#/ { print } \ - ! /#/ { $1 = $1 ; printf " VAR%d (T, N, MAP, %s)\n", NF, tolower($0) }' - -echo "#endif /* GCC_AARCH64_ITERATORS_H */" +LC_ALL=C awk ' +BEGIN { + print "/* -*- buffer-read-only: t -*- */" + print "/* Generated automatically by geniterators.sh from iterators.md. */" + print "#ifndef GCC_AARCH64_ITERATORS_H" + print "#define GCC_AARCH64_ITERATORS_H" +} + +{ + sub(/;.*/, "") +} + +iterdef { + s = s " " $0 +} + +!iterdef && /\(define_mode_iterator/ { + iterdef = 1 + s = $0 + sub(/.*\(define_mode_iterator/, "", s) +} + +iterdef && s ~ /\)/ { + iterdef = 0 + + gsub(/[ \t]+/, " ", s) + sub(/ *\).*/, "", s) + sub(/^ /, "", s) + if (s !~ /^[A-Za-z0-9_]+ \[[A-Z0-9 ]*\]$/) + next + sub(/\[ */, "", s) + sub(/ *\]/, "", s) + + n = split(s, a) + printf "#define BUILTIN_" a[1] "(T, N, MAP) \\\n" + printf " VAR" (n-1) " (T, N, MAP" + for (i = 2; i <= n; i++) + printf ", " tolower(a[i]) + printf ")\n" +} + +END { + print "#endif /* GCC_AARCH64_ITERATORS_H */" +}' $1