rose: make assignGroupsToRoles a free function

This commit is contained in:
Justin Viiret 2016-06-02 13:52:29 +10:00 committed by Matthew Barr
parent de201997b7
commit 89dbbe6c53
4 changed files with 11 additions and 10 deletions

View File

@ -1661,7 +1661,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildRose(u32 minWidth) {
findMoreLiteralMasks(*this); findMoreLiteralMasks(*this);
assignGroupsToLiterals(); assignGroupsToLiterals();
assignGroupsToRoles(); assignGroupsToRoles(*this);
findGroupSquashers(*this); findGroupSquashers(*this);
/* final prep work */ /* final prep work */

View File

@ -363,20 +363,23 @@ rose_group RoseBuildImpl::getSuccGroups(RoseVertex start) const {
* The groups that a role sets are determined by the union of its successor * The groups that a role sets are determined by the union of its successor
* literals. Requires the literals already have had groups assigned. * literals. Requires the literals already have had groups assigned.
*/ */
void RoseBuildImpl::assignGroupsToRoles() { void assignGroupsToRoles(RoseBuildImpl &build) {
auto &g = build.g;
/* Note: if there is a succ literal in the sidematcher, its successors /* Note: if there is a succ literal in the sidematcher, its successors
* literals must be added instead */ * literals must be added instead */
for (auto v : vertices_range(g)) { for (auto v : vertices_range(g)) {
if (isAnyStart(v)) { if (build.isAnyStart(v)) {
continue; continue;
} }
const rose_group succ_groups = getSuccGroups(v); const rose_group succ_groups = build.getSuccGroups(v);
g[v].groups |= succ_groups; g[v].groups |= succ_groups;
if (ghost.find(v) != ghost.end()) { auto ghost_it = build.ghost.find(v);
if (ghost_it != end(build.ghost)) {
/* delayed roles need to supply their groups to the ghost role */ /* delayed roles need to supply their groups to the ghost role */
g[ghost[v]].groups |= succ_groups; g[ghost_it->second].groups |= succ_groups;
} }
DEBUG_PRINTF("vertex %zu: groups=%llx\n", g[v].idx, g[v].groups); DEBUG_PRINTF("vertex %zu: groups=%llx\n", g[v].idx, g[v].groups);

View File

@ -44,6 +44,8 @@ getVertexGroupMap(const RoseBuildImpl &build);
rose_group getSquashableGroups(const RoseBuildImpl &build); rose_group getSquashableGroups(const RoseBuildImpl &build);
void assignGroupsToRoles(RoseBuildImpl &build);
void findGroupSquashers(RoseBuildImpl &build); void findGroupSquashers(RoseBuildImpl &build);
} // namespace ue2 } // namespace ue2

View File

@ -439,10 +439,6 @@ public:
// Find the maximum bound on the edges to this vertex's successors. // Find the maximum bound on the edges to this vertex's successors.
u32 calcSuccMaxBound(RoseVertex u) const; u32 calcSuccMaxBound(RoseVertex u) const;
// Assign roles to groups, writing the groups bitset into each role in the
// graph.
void assignGroupsToRoles();
/* Returns the ID of the given literal in the literal map, adding it if /* Returns the ID of the given literal in the literal map, adding it if
* necessary. */ * necessary. */
u32 getLiteralId(const ue2_literal &s, u32 delay, rose_literal_table table); u32 getLiteralId(const ue2_literal &s, u32 delay, rose_literal_table table);