diff options
author | Vladimir Makarov <vmakarov@redhat.com> | 2002-05-14 16:16:18 +0000 |
---|---|---|
committer | Vladimir Makarov <vmakarov@gcc.gnu.org> | 2002-05-14 16:16:18 +0000 |
commit | 317638a8098ccaf5e154f2e73c79fd14d30a25b5 (patch) | |
tree | bcfeec35ae7c00f88d62fd26a76fea60f5913f8e | |
parent | db80834f53cdd93d8ba1af287b7459058a246fbf (diff) | |
download | gcc-317638a8098ccaf5e154f2e73c79fd14d30a25b5.zip gcc-317638a8098ccaf5e154f2e73c79fd14d30a25b5.tar.gz gcc-317638a8098ccaf5e154f2e73c79fd14d30a25b5.tar.bz2 |
genautomata.c (transform_3): Add code for transformation `(A,B,...)+C -> A+C,B,...'.
2002-05-14 Vladimir Makarov <vmakarov@redhat.com>
* genautomata.c (transform_3): Add code for transformation
`(A,B,...)+C -> A+C,B,...'.
From-SVN: r53459
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/genautomata.c | 46 |
2 files changed, 48 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c98fac1..8ff7135 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-05-14 Vladimir Makarov <vmakarov@redhat.com> + + * genautomata.c (transform_3): Add code for transformation + `(A,B,...)+C -> A+C,B,...'. + Tue May 14 12:48:22 CEST 2002 Jan Hubicka <jh@suse.cz> * final.c (end_final): Do not output profile_arcs constructor, when diff --git a/gcc/genautomata.c b/gcc/genautomata.c index 783d50e..2c7c883 100644 --- a/gcc/genautomata.c +++ b/gcc/genautomata.c @@ -4637,7 +4637,8 @@ transform_2 (regexp) /* The function makes transformations ...,A|B|...,C,... -> (...,A,C,...)|(...,B,C,...)|... - ...+(A|B|...)+C+... -> (...+A+C+...)|(...+B+C+...)|... */ + ...+(A|B|...)+C+... -> (...+A+C+...)|(...+B+C+...)|... + ...+(A,B,...)+C+... -> (...+A+C+...),B,... */ static regexp_t transform_3 (regexp) regexp_t regexp; @@ -4693,8 +4694,8 @@ transform_3 (regexp) } else if (regexp->mode == rm_allof) { - regexp_t oneof; - int oneof_index; + regexp_t oneof, seq; + int oneof_index, seq_index; regexp_t result; regexp_t allof; int i, j; @@ -4739,6 +4740,45 @@ transform_3 (regexp) regexp_transformed_p = 1; regexp = result; } + for (i = 0; i < regexp->regexp.allof.regexps_num; i++) + if (regexp->regexp.allof.regexps [i]->mode == rm_sequence) + { + seq_index = i; + seq = regexp->regexp.allof.regexps [i]; + break; + } + if (i < regexp->regexp.allof.regexps_num) + { + if (seq->regexp.sequence.regexps_num <= 1 + || regexp->regexp.allof.regexps_num <= 1) + abort (); + result = create_node (sizeof (struct regexp) + + sizeof (regexp_t) + * (seq->regexp.sequence.regexps_num - 1)); + result->mode = rm_sequence; + result->pos = regexp->pos; + result->regexp.sequence.regexps_num + = seq->regexp.sequence.regexps_num; + allof = create_node (sizeof (struct regexp) + + sizeof (regexp_t) + * (regexp->regexp.allof.regexps_num - 1)); + allof->mode = rm_allof; + allof->pos = regexp->pos; + allof->regexp.allof.regexps_num = regexp->regexp.allof.regexps_num; + result->regexp.sequence.regexps [0] = allof; + for (j = 0; j < allof->regexp.allof.regexps_num; j++) + if (j != seq_index) + allof->regexp.allof.regexps [j] + = copy_insn_regexp (regexp->regexp.allof.regexps [j]); + else + allof->regexp.allof.regexps [j] + = copy_insn_regexp (seq->regexp.sequence.regexps [0]); + for (i = 1; i < result->regexp.sequence.regexps_num; i++) + result->regexp.sequence.regexps [i] + = copy_insn_regexp (seq->regexp.sequence.regexps [i]); + regexp_transformed_p = 1; + regexp = result; + } } return regexp; } |