]> granicus.if.org Git - re2c/commitdiff
Split source file in two.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 17 Jul 2017 22:11:18 +0000 (23:11 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Tue, 18 Jul 2017 07:56:22 +0000 (08:56 +0100)
re2c/Makefile.am
re2c/src/dfa/cfg/freeze.cc [new file with mode: 0644]
re2c/src/dfa/cfg/optimize.cc

index 5fb65d94fcfede64a1ca52a05fb116d6ab6d4ac1..6656a7c26411d0e1e0e56953a04705aef916e48c 100644 (file)
@@ -96,6 +96,7 @@ SRC = \
        src/dfa/cfg/compact.cc \
        src/dfa/cfg/dce.cc \
        src/dfa/cfg/dump.cc \
+       src/dfa/cfg/freeze.cc \
        src/dfa/cfg/interfere.cc \
        src/dfa/cfg/liveanal.cc \
        src/dfa/cfg/normalize.cc \
diff --git a/re2c/src/dfa/cfg/freeze.cc b/re2c/src/dfa/cfg/freeze.cc
new file mode 100644 (file)
index 0000000..6b8e9fb
--- /dev/null
@@ -0,0 +1,52 @@
+#include "src/dfa/dfa.h"
+
+namespace re2c
+{
+
+/* note [tag freezing]
+ *
+ * Comparison of tag commands should be very fast (constant time):
+ * many optimizations rely on this (like tunnelling, hoisting and
+ * especially Moore's minimization, which compares whole classes
+ * of tagged transition at once). So we bring each command to some
+ * 'normal form' and insert it into common index.
+ *
+ * After that commands can be addressed and compared by index.
+ * They also become immutable, because different commands may
+ * share representation in memory.
+ */
+void freeze_tags(dfa_t &dfa)
+{
+       tcpool_t &pool = dfa.tcpool;
+       const size_t
+               nstate = dfa.states.size(),
+               nsym = dfa.nchars;
+
+       dfa.tcid0 = pool.insert(dfa.tcmd0);
+       dfa.tcmd0 = NULL;
+
+       for (size_t i = 0; i < nstate; ++i) {
+               dfa_state_t *s = dfa.states[i];
+               tcmd_t **cmd = s->tcmd,
+                       **const fin = cmd + nsym,
+                       **const fall = fin + 1;
+               tcid_t *id = s->tcid = new tcid_t[nsym + 2];
+
+               // transition commands
+               for(; cmd < fin; ++cmd) {
+                       *id++ = pool.insert(*cmd);
+               }
+
+               // final epsilon-transition command
+               *id++ = pool.insert(*fin);
+
+               // fallback epsilon-transition command
+               *id++ = pool.insert(*fall);
+
+               delete[] s->tcmd;
+               s->tcmd = NULL;
+       }
+}
+
+} // namespace re2c
+
index 02f76a00cad7b90d82bb985442131746557713cf..f27820c04c0a9b9e58f0ef0e6442984b10e5da23 100644 (file)
@@ -39,50 +39,5 @@ void optimize_tags(dfa_t &dfa)
        }
 }
 
-/* note [tag freezing]
- *
- * Comparison of tag commands should be very fast (constant time):
- * many optimizations rely on this (like tunnelling, hoisting and
- * especially Moore's minimization, which compares whole classes
- * of tagged transition at once). So we bring each command to some
- * 'normal form' and insert it into common index.
- *
- * After that commands can be addressed and compared by index.
- * They also become immutable, because different commands may
- * share representation in memory.
- */
-void freeze_tags(dfa_t &dfa)
-{
-       tcpool_t &pool = dfa.tcpool;
-       const size_t
-               nstate = dfa.states.size(),
-               nsym = dfa.nchars;
-
-       dfa.tcid0 = pool.insert(dfa.tcmd0);
-       dfa.tcmd0 = NULL;
-
-       for (size_t i = 0; i < nstate; ++i) {
-               dfa_state_t *s = dfa.states[i];
-               tcmd_t **cmd = s->tcmd,
-                       **const fin = cmd + nsym,
-                       **const fall = fin + 1;
-               tcid_t *id = s->tcid = new tcid_t[nsym + 2];
-
-               // transition commands
-               for(; cmd < fin; ++cmd) {
-                       *id++ = pool.insert(*cmd);
-               }
-
-               // final epsilon-transition command
-               *id++ = pool.insert(*fin);
-
-               // fallback epsilon-transition command
-               *id++ = pool.insert(*fall);
-
-               delete[] s->tcmd;
-               s->tcmd = NULL;
-       }
-}
-
 } // namespace re2c