From: Ulya Trofimovich Date: Wed, 26 Oct 2016 14:17:34 +0000 (+0100) Subject: Minor tweak in tag version allocation; updated tests. X-Git-Tag: 1.0~39^2~248 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d13e22ec10f01a8efd9d17350f7c1b414302633;p=re2c Minor tweak in tag version allocation; updated tests. The previous commit 394fec90c1d7a66f2e13c658c5cc28e0d38c5678 "Use tag versions to implement fallback tags." added copy coalescing and introduced serious changes to allocation algorithm. It simulated the order of allocation used by previous algorithm to preserve test results. Now we drop this simulation and keep to the natural order: it is easy to see that changes in test results are caused by different order of tag version allocation. --- diff --git a/re2c/src/ir/dfa/tag_allocation.cc b/re2c/src/ir/dfa/tag_allocation.cc index 92e0fd56..632a92ab 100644 --- a/re2c/src/ir/dfa/tag_allocation.cc +++ b/re2c/src/ir/dfa/tag_allocation.cc @@ -99,7 +99,7 @@ tagver_t tag_allocation(const dfa_t &dfa, const bool *interf, if (repr[x] != END) continue; // try all existing classes - for (rx = nver; --rx >= 0;) { + for (rx = 0; rx < nver; ++rx) { if (rx != repr[rx]) continue; // check interference with class members @@ -117,13 +117,13 @@ tagver_t tag_allocation(const dfa_t &dfa, const bool *interf, } // make new equivalence class - if (rx < 0) { + if (rx == nver) { repr[x] = x; } } tagver_t maxver = 0; - for (rx = nver; --rx >= 0;) { + for (rx = 0; rx < nver; ++rx) { if (repr[rx] != rx) continue; ++maxver; diff --git a/re2c/test/tags/copy_coalescing1.i--tags.c b/re2c/test/tags/copy_coalescing1.i--tags.c index 2f5b66b9..6ec1a8e7 100644 --- a/re2c/test/tags/copy_coalescing1.i--tags.c +++ b/re2c/test/tags/copy_coalescing1.i--tags.c @@ -22,8 +22,8 @@ yyt2 default: goto yy3; } yy2: - q = yyt2; - p = yyt1; + q = yyt1; + p = yyt2; { p q } yy3: ++YYCURSOR; @@ -33,10 +33,10 @@ yy5: yych = *++YYCURSOR; switch (yych) { case 'c': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy6; case 'd': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy7; default: goto yy4; } @@ -48,7 +48,7 @@ yy6: switch (yych) { case 'a': goto yy9; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy2; } yy7: @@ -59,12 +59,12 @@ yy7: switch (yych) { case 'a': goto yy11; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; } yy8: - s = yyt2; - r = yyt1; + s = yyt1; + r = yyt2; { r s } yy9: ++YYCURSOR; @@ -72,17 +72,17 @@ yy9: yych = *YYCURSOR; switch (yych) { case 'c': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy6; default: goto yy10; } yy10: YYCURSOR = YYMARKER; if (yyaccept == 0) { - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy2; } else { - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; } yy11: @@ -91,7 +91,7 @@ yy11: yych = *YYCURSOR; switch (yych) { case 'd': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy7; default: goto yy10; } diff --git a/re2c/test/tags/dedup4.i--tags.c b/re2c/test/tags/dedup4.i--tags.c index 782c5b62..d02028c2 100644 --- a/re2c/test/tags/dedup4.i--tags.c +++ b/re2c/test/tags/dedup4.i--tags.c @@ -13,16 +13,23 @@ yy2: {} yy4: ++YYCURSOR; - yyt1 = yyt2 = YYCURSOR; switch ((yych = *YYCURSOR)) { - case 'b': goto yy6; - case 'c': goto yy8; - case 'd': goto yy11; - default: goto yy5; + case 'b': + yyt2 = YYCURSOR; + goto yy6; + case 'c': + yyt1 = yyt2 = YYCURSOR; + goto yy8; + case 'd': + yyt1 = yyt2 = YYCURSOR; + goto yy11; + default: + yyt1 = yyt2 = YYCURSOR; + goto yy5; } yy5: - YYCURSOR = yyt2; - p = yyt1; + YYCURSOR = yyt1; + p = yyt2; { 1 p } yy6: ++YYCURSOR; @@ -34,10 +41,10 @@ yy6: yyt1 = YYCURSOR; goto yy8; case 'd': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy11; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; } yy8: @@ -85,11 +92,11 @@ yy17: yyt1 = yyt2 = YYCURSOR; goto yy21; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy18; } yy18: - p = yyt2; + p = yyt1; { 1 p } yy19: ++YYCURSOR; @@ -98,7 +105,7 @@ yy19: switch (yych) { case 'b': goto yy19; case 'c': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy21; default: goto yy18; } @@ -111,8 +118,8 @@ yy21: default: goto yy23; } yy23: - YYCURSOR = yyt2; - p = yyt1; + YYCURSOR = yyt1; + p = yyt2; { 2 p } } @@ -135,17 +142,17 @@ yy28: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case 'b': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy30; case 'c': yyt1 = yyt2 = YYCURSOR; goto yy32; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy29; } yy29: - p = yyt2; + p = yyt1; { 1 p } yy30: yyaccept = 1; @@ -155,7 +162,7 @@ yy30: switch (yych) { case 'b': goto yy30; case 'c': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy32; default: goto yy29; } @@ -171,7 +178,7 @@ yy33: YYCURSOR = YYMARKER; switch (yyaccept) { case 0: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy29; case 1: goto yy29; default: goto yy35; @@ -186,8 +193,8 @@ yy34: default: goto yy35; } yy35: - YYCURSOR = yyt1; - p = yyt2; + YYCURSOR = yyt2; + p = yyt1; { 2 p } } @@ -210,7 +217,7 @@ yy40: yych = *++YYCURSOR; switch (yych) { case 'b': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy41; default: goto yy39; } @@ -222,12 +229,12 @@ yy41: switch (yych) { case 'b': goto yy41; case 'c': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy44; default: goto yy43; } yy43: - p = yyt2; + p = yyt1; { 1 p } yy44: ++YYCURSOR; @@ -254,8 +261,8 @@ yy46: default: goto yy47; } yy47: - YYCURSOR = yyt1; - p = yyt2; + YYCURSOR = yyt2; + p = yyt1; { 2 p } } diff --git a/re2c/test/tags/fallback4.i--tags.c b/re2c/test/tags/fallback4.i--tags.c index e12828da..ad9b7209 100644 --- a/re2c/test/tags/fallback4.i--tags.c +++ b/re2c/test/tags/fallback4.i--tags.c @@ -13,12 +13,12 @@ yyt2 yych = *YYCURSOR; switch (yych) { case 'a': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy5; default: goto yy3; } yy2: - YYCURSOR = yyt1; + YYCURSOR = yyt2; {} yy3: ++YYCURSOR; @@ -28,7 +28,7 @@ yy5: yych = *++YYCURSOR; switch (yych) { case 'b': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy6; default: goto yy4; } @@ -44,12 +44,12 @@ yy7: yych = *YYCURSOR; switch (yych) { case 'a': - yyt1 = yyt2; + yyt2 = yyt1; goto yy9; default: goto yy8; } yy8: - p = yyt2; + p = yyt1; { p } yy9: ++YYCURSOR; @@ -57,13 +57,13 @@ yy9: yych = *YYCURSOR; switch (yych) { case 'b': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy11; default: goto yy10; } yy10: YYCURSOR = YYMARKER; - yyt2 = yyt1; + yyt1 = yyt2; goto yy8; yy11: ++YYCURSOR; diff --git a/re2c/test/tags/fix4.i--tags.c b/re2c/test/tags/fix4.i--tags.c index 116418bb..7ba19c81 100644 --- a/re2c/test/tags/fix4.i--tags.c +++ b/re2c/test/tags/fix4.i--tags.c @@ -22,10 +22,10 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '1': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy5; case '2': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy8; default: goto yy3; } @@ -44,10 +44,10 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '3': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy9; case '4': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy11; default: goto yy7; } @@ -62,10 +62,10 @@ yy9: yy11: ++YYCURSOR; p4 = YYCURSOR - 1; - p3 = yyt2; - p2 = yyt2 - 1; - p1 = yyt1; - p0 = yyt1 - 1; + p3 = yyt1; + p2 = yyt1 - 1; + p1 = yyt2; + p0 = yyt2 - 1; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%.*s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix4_trail.i--tags.c b/re2c/test/tags/fix4_trail.i--tags.c index f1e18825..4963a7ac 100644 --- a/re2c/test/tags/fix4_trail.i--tags.c +++ b/re2c/test/tags/fix4_trail.i--tags.c @@ -22,10 +22,10 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '1': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy5; case '2': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy8; default: goto yy3; } @@ -44,10 +44,10 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '3': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy9; case '4': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy11; default: goto yy7; } @@ -62,10 +62,10 @@ yy9: yy11: ++YYCURSOR; YYCURSOR -= 1; - p3 = yyt2; - p2 = yyt2 - 1; - p1 = yyt1; - p0 = yyt1 - 1; + p3 = yyt1; + p2 = yyt1 - 1; + p1 = yyt2; + p0 = yyt2 - 1; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix5.i--tags.c b/re2c/test/tags/fix5.i--tags.c index f656b625..42bb00a8 100644 --- a/re2c/test/tags/fix5.i--tags.c +++ b/re2c/test/tags/fix5.i--tags.c @@ -12,10 +12,10 @@ static void lex(const char *YYCURSOR) yych = *YYCURSOR; switch (yych) { case '0': - yyt1 = YYCURSOR; + yyt3 = YYCURSOR; goto yy4; case '1': - yyt1 = YYCURSOR; + yyt3 = YYCURSOR; goto yy5; default: goto yy2; } @@ -74,15 +74,15 @@ yy10: } yy12: ++YYCURSOR; - yyt3 = YYCURSOR; + yyt1 = YYCURSOR; yych = *YYCURSOR; goto yy15; yy13: - p4 = yyt3; - p3 = yyt3 - 1; + p4 = yyt1; + p3 = yyt1 - 1; p2 = yyt2; p1 = yyt2 - 1; - p0 = yyt1; + p0 = yyt3; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%.*s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix5_trail.i--tags.c b/re2c/test/tags/fix5_trail.i--tags.c index 55ebebe2..a21476e8 100644 --- a/re2c/test/tags/fix5_trail.i--tags.c +++ b/re2c/test/tags/fix5_trail.i--tags.c @@ -12,10 +12,10 @@ static void lex(const char *YYCURSOR) yych = *YYCURSOR; switch (yych) { case '0': - yyt1 = YYCURSOR; + yyt3 = YYCURSOR; goto yy4; case '1': - yyt1 = YYCURSOR; + yyt3 = YYCURSOR; goto yy5; default: goto yy2; } @@ -74,15 +74,15 @@ yy10: } yy12: ++YYCURSOR; - yyt3 = YYCURSOR; + yyt1 = YYCURSOR; yych = *YYCURSOR; goto yy15; yy13: - YYCURSOR = yyt3; - p3 = yyt3 - 1; + YYCURSOR = yyt1; + p3 = yyt1 - 1; p2 = yyt2; p1 = yyt2 - 1; - p0 = yyt1; + p0 = yyt3; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0,