public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk
@ 2015-05-18 15:01 Szabolcs Nagy
  2015-06-01 12:13 ` Szabolcs Nagy
  2015-06-01 12:55 ` Marcus Shawcroft
  0 siblings, 2 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2015-05-18 15:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: Marcus Shawcroft, Ramana Radhakrishnan

[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

Rewrote the generator script in awk, to avoid dealing with
sed portability issues.

gcc/Changelog:

2015-05-18  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	PR target/66136
	* config/aarch64/geniterators.sh: Rewrite in awk.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: geniter2.diff --]
[-- Type: text/x-patch; name=geniter2.diff, Size: 2484 bytes --]

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_<ITERATOR> macros, which expand to VAR<N> 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 <ITERATOR> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk
  2015-05-18 15:01 [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk Szabolcs Nagy
@ 2015-06-01 12:13 ` Szabolcs Nagy
  2015-06-01 12:55 ` Marcus Shawcroft
  1 sibling, 0 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2015-06-01 12:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Marcus Shawcroft, Ramana Radhakrishnan, James Greenhalgh

On 18/05/15 15:57, Szabolcs Nagy wrote:
> Rewrote the generator script in awk, to avoid dealing with
> sed portability issues.
> 

Ping.

it was confirmed to fix the build on freebsd:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66136

> gcc/Changelog:
> 
> 2015-05-18  Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
> 	PR target/66136
> 	* config/aarch64/geniterators.sh: Rewrite in awk.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk
  2015-05-18 15:01 [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk Szabolcs Nagy
  2015-06-01 12:13 ` Szabolcs Nagy
@ 2015-06-01 12:55 ` Marcus Shawcroft
  2015-06-02 17:17   ` Szabolcs Nagy
  1 sibling, 1 reply; 5+ messages in thread
From: Marcus Shawcroft @ 2015-06-01 12:55 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Marcus Shawcroft, Ramana Radhakrishnan

On 18 May 2015 at 15:57, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> Rewrote the generator script in awk, to avoid dealing with
> sed portability issues.
>
> gcc/Changelog:
>
> 2015-05-18  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
>         PR target/66136
>         * config/aarch64/geniterators.sh: Rewrite in awk.

OK provide you have checked the generated output is identical before
and after this patch.  Ask for an account on sourceware here
https://sourceware.org/cgi-bin/pdw/ps_form.cgi you want write on
approval for gcc.

/Marcus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk
  2015-06-01 12:55 ` Marcus Shawcroft
@ 2015-06-02 17:17   ` Szabolcs Nagy
  2015-06-30 10:27     ` Szabolcs Nagy
  0 siblings, 1 reply; 5+ messages in thread
From: Szabolcs Nagy @ 2015-06-02 17:17 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: gcc-patches, Marcus Shawcroft, Ramana Radhakrishnan

[-- Attachment #1: Type: text/plain, Size: 701 bytes --]

On 01/06/15 13:55, Marcus Shawcroft wrote:
> On 18 May 2015 at 15:57, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>> Rewrote the generator script in awk, to avoid dealing with
>> sed portability issues.
>>
>> gcc/Changelog:
>>
>> 2015-05-18  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>>         PR target/66136
>>         * config/aarch64/geniterators.sh: Rewrite in awk.
> 
> OK provide you have checked the generated output is identical before
> and after this patch.  Ask for an account on sourceware here
> https://sourceware.org/cgi-bin/pdw/ps_form.cgi you want write on
> approval for gcc.
> 
> /Marcus
> 

commited in r224031.

and added myself to write after approval.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: a.diff --]
[-- Type: text/x-patch; name=a.diff, Size: 881 bytes --]

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 224031)
+++ ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2015-06-02  Szabolcs Nagy  <szabolcs.nagy@arm.com>
+
+	* MAINTAINERS (Write After Approval): Add myself.
+
 2015-05-28  Mike Frysinger  <vapier@gentoo.org>
 
 	* configure.ac (--vtable-verify): Use AS_HELP_STRING for help.
Index: MAINTAINERS
===================================================================
--- MAINTAINERS	(revision 224031)
+++ MAINTAINERS	(working copy)
@@ -500,6 +500,7 @@
 Brooks Moses					<bmoses@google.com>
 Dirk Mueller					<dmueller@suse.de>
 Phil Muldoon					<pmuldoon@redhat.com>
+Szabolcs Nagy					<szabolcs.nagy@arm.com>
 Quentin Neill					<quentin.neill.gnu@gmail.com>
 Adam Nemet					<adambnemet@gmail.com>
 Thomas Neumann					<tneumann@users.sourceforge.net>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk
  2015-06-02 17:17   ` Szabolcs Nagy
@ 2015-06-30 10:27     ` Szabolcs Nagy
  0 siblings, 0 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2015-06-30 10:27 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: gcc-patches, Marcus Shawcroft, Ramana Radhakrishnan



On 02/06/15 18:01, Szabolcs Nagy wrote:
> On 01/06/15 13:55, Marcus Shawcroft wrote:
>> On 18 May 2015 at 15:57, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>> Rewrote the generator script in awk, to avoid dealing with
>>> sed portability issues.
>>>
>>> gcc/Changelog:
>>>
>>> 2015-05-18  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>>
>>>         PR target/66136
>>>         * config/aarch64/geniterators.sh: Rewrite in awk.
>>
>> OK provide you have checked the generated output is identical before
>> and after this patch.  Ask for an account on sourceware here
>> https://sourceware.org/cgi-bin/pdw/ps_form.cgi you want write on
>> approval for gcc.
>>
>> /Marcus
>>
> 
> commited in r224031.
> 

backported to gcc-5-branch in r225170.

as requested in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66136

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-30 10:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-18 15:01 [PATCH][AArch64][PR 66136] rewrite geniterators.sh in awk Szabolcs Nagy
2015-06-01 12:13 ` Szabolcs Nagy
2015-06-01 12:55 ` Marcus Shawcroft
2015-06-02 17:17   ` Szabolcs Nagy
2015-06-30 10:27     ` Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).