]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose: make assignGroupsToLiterals a free function
authorJustin Viiret <justin.viiret@intel.com>
Thu, 2 Jun 2016 03:57:03 +0000 (13:57 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 8 Jul 2016 00:47:08 +0000 (10:47 +1000)
src/rose/rose_build_compile.cpp
src/rose/rose_build_groups.cpp
src/rose/rose_build_groups.h
src/rose/rose_build_impl.h

index b86058de4a54b7392740fb14ce7baa1be93e68c0..a6868ff88117d8b02437fb3a54333639a0e1dc0e 100644 (file)
@@ -1660,7 +1660,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildRose(u32 minWidth) {
 
     findMoreLiteralMasks(*this);
 
-    assignGroupsToLiterals();
+    assignGroupsToLiterals(*this);
     assignGroupsToRoles(*this);
     findGroupSquashers(*this);
 
index fd96fbd668fa6f34fa0f27a39e72b45c58bf7c48..e1a130ef2444efaf712ed8b099ccf8ef72bef5a7 100644 (file)
@@ -170,9 +170,10 @@ u32 next_available_group(u32 counter, u32 min_start_group) {
     return counter;
 }
 
-// Assigns groups to literals in the general case, when we have more literals
-// than available groups.
-void RoseBuildImpl::assignGroupsToLiterals() {
+void assignGroupsToLiterals(RoseBuildImpl &build) {
+    auto &literals = build.literals;
+    auto &literal_info = build.literal_info;
+
     bool small_literal_count = literal_info.size() <= MAX_LIGHT_LITERAL_CASE;
 
     map<u8, u32> groupCount; /* group index to number of members */
@@ -193,7 +194,7 @@ void RoseBuildImpl::assignGroupsToLiterals() {
         // If this literal has a root role, we always have to search for it
         // anyway, so it goes in the always-on group.
         /* We could end up squashing it if it is followed by a .* */
-        if (eligibleForAlwaysOnGroup(*this, id)) {
+        if (eligibleForAlwaysOnGroup(build, id)) {
             info.group_mask = 1ULL << group_always_on;
             groupCount[group_always_on]++;
             continue;
@@ -223,7 +224,7 @@ void RoseBuildImpl::assignGroupsToLiterals() {
             continue;
         }
 
-        assert(!eligibleForAlwaysOnGroup(*this, id));
+        assert(!eligibleForAlwaysOnGroup(build, id));
         pq.push(make_pair(make_pair(-(s32)literal_info[id].vertices.size(),
                                     -(s32)lit.s.length()), id));
     }
@@ -237,8 +238,8 @@ void RoseBuildImpl::assignGroupsToLiterals() {
 
         u8 group_id = 0;
         rose_group group = ~0ULL;
-        for (auto v : getAssociatedVertices(*this, id)) {
-            rose_group local_group = calcLocalGroup(v, g, literal_info,
+        for (auto v : getAssociatedVertices(build, id)) {
+            rose_group local_group = calcLocalGroup(v, build.g, literal_info,
                                                     small_literal_count);
             group &= local_group;
             if (!group) {
@@ -323,14 +324,14 @@ void RoseBuildImpl::assignGroupsToLiterals() {
         rose_group groups = literal_info[id].group_mask;
         while (groups) {
             u32 group_id = findAndClearLSB_64(&groups);
-            group_to_literal[group_id].insert(id);
+            build.group_to_literal[group_id].insert(id);
         }
     }
 
     /* find how many groups we allocated */
     for (u32 i = 0; i < ROSE_GROUPS_MAX; i++) {
         if (groupCount[i]) {
-            group_end = MAX(group_end, i + 1);
+            build.group_end = max(build.group_end, i + 1);
         }
     }
 }
index 6719fbeadd8ac2ec0c5283258bfadf79e8c02256..3ab5eb786552ffff5be82cfbd74e188ec2798c59 100644 (file)
@@ -44,6 +44,8 @@ getVertexGroupMap(const RoseBuildImpl &build);
 
 rose_group getSquashableGroups(const RoseBuildImpl &build);
 
+void assignGroupsToLiterals(RoseBuildImpl &build);
+
 void assignGroupsToRoles(RoseBuildImpl &build);
 
 void findGroupSquashers(RoseBuildImpl &build);
index b1d7ac36615c1746132ba31f3bd012ac1b8557ea..5f1871e44f8f304f470959915c0c4e14b1927925 100644 (file)
@@ -470,8 +470,6 @@ public:
     bool hasLiteralInTable(RoseVertex v, enum rose_literal_table t) const;
     bool hasAnchoredTablePred(RoseVertex v) const;
 
-    void assignGroupsToLiterals(void);
-
     // Is the given vertex a successor of either root or anchored_root?
     bool isRootSuccessor(const RoseVertex &v) const;
     /* Is the given vertex a successor of something other than root or