diff --git a/src/rose/rose_build_anchored.cpp b/src/rose/rose_build_anchored.cpp index 77eef142..8ba80f8e 100644 --- a/src/rose/rose_build_anchored.cpp +++ b/src/rose/rose_build_anchored.cpp @@ -848,7 +848,6 @@ vector buildAnchoredDfas(RoseBuildImpl &build) { aligned_unique_ptr buildAnchoredMatcher(RoseBuildImpl &build, vector &dfas, - const map &final_to_frag_map, size_t *asize) { const CompileContext &cc = build.cc; @@ -859,7 +858,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, vector &dfas, } for (auto &rdfa : dfas) { - remapIdsToPrograms(rdfa, final_to_frag_map); + remapIdsToPrograms(rdfa, build.final_to_frag_map); } vector> nfas; diff --git a/src/rose/rose_build_anchored.h b/src/rose/rose_build_anchored.h index 3d411bd7..618a46a3 100644 --- a/src/rose/rose_build_anchored.h +++ b/src/rose/rose_build_anchored.h @@ -59,7 +59,6 @@ std::vector buildAnchoredDfas(RoseBuildImpl &build); */ aligned_unique_ptr buildAnchoredMatcher(RoseBuildImpl &build, std::vector &dfas, - const std::map &final_to_frag_map, size_t *asize); u32 anchoredStateSize(const anchored_matcher_info &atable); diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index 51d8da97..42142936 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -4707,12 +4707,11 @@ map groupByFragment(const RoseBuildImpl &build) { * - total number of literal fragments */ static -tuple -buildLiteralPrograms(RoseBuildImpl &build, build_context &bc, - map &final_to_frag_map) { +tuple buildLiteralPrograms(RoseBuildImpl &build, + build_context &bc) { // Build a reverse mapping from fragment -> final_id. map> frag_to_final_map; - for (const auto &m : final_to_frag_map) { + for (const auto &m : build.final_to_frag_map) { frag_to_final_map[m.second.fragment_id].insert(m.first); } @@ -4736,7 +4735,7 @@ buildLiteralPrograms(RoseBuildImpl &build, build_context &bc, } // Update LitFragment entries. - for (auto &frag : final_to_frag_map | map_values) { + for (auto &frag : build.final_to_frag_map | map_values) { frag.lit_program_offset = litPrograms[frag.fragment_id]; frag.delay_program_offset = delayRebuildPrograms[frag.fragment_id]; } @@ -5480,7 +5479,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { u32 litDelayRebuildProgramOffset; u32 litProgramCount; tie(litProgramOffset, litDelayRebuildProgramOffset, litProgramCount) = - buildLiteralPrograms(*this, bc, final_to_frag_map); + buildLiteralPrograms(*this, bc); u32 delayProgramOffset = buildDelayPrograms(*this, bc); u32 anchoredProgramOffset = buildAnchoredPrograms(*this, bc); @@ -5519,8 +5518,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { // Build anchored matcher. size_t asize = 0; u32 amatcherOffset = 0; - auto atable = - buildAnchoredMatcher(*this, anchored_dfas, final_to_frag_map, &asize); + auto atable = buildAnchoredMatcher(*this, anchored_dfas, &asize); if (atable) { currOffset = ROUNDUP_CL(currOffset); amatcherOffset = currOffset; @@ -5531,8 +5529,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { rose_group fgroups = 0; size_t fsize = 0; auto ftable = buildFloatingMatcher(*this, bc.longLitLengthThreshold, - final_to_frag_map, &fgroups, &fsize, - &historyRequired); + &fgroups, &fsize, &historyRequired); u32 fmatcherOffset = 0; if (ftable) { currOffset = ROUNDUP_CL(currOffset); @@ -5543,8 +5540,8 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { // Build delay rebuild HWLM matcher. size_t drsize = 0; - auto drtable = buildDelayRebuildMatcher(*this, bc.longLitLengthThreshold, - final_to_frag_map, &drsize); + auto drtable = + buildDelayRebuildMatcher(*this, bc.longLitLengthThreshold, &drsize); u32 drmatcherOffset = 0; if (drtable) { currOffset = ROUNDUP_CL(currOffset); @@ -5554,7 +5551,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { // Build EOD-anchored HWLM matcher. size_t esize = 0; - auto etable = buildEodAnchoredMatcher(*this, final_to_frag_map, &esize); + auto etable = buildEodAnchoredMatcher(*this, &esize); u32 ematcherOffset = 0; if (etable) { currOffset = ROUNDUP_CL(currOffset); @@ -5564,7 +5561,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { // Build small-block HWLM matcher. size_t sbsize = 0; - auto sbtable = buildSmallBlockMatcher(*this, final_to_frag_map, &sbsize); + auto sbtable = buildSmallBlockMatcher(*this, &sbsize); u32 sbmatcherOffset = 0; if (sbtable) { currOffset = ROUNDUP_CL(currOffset); diff --git a/src/rose/rose_build_dump.cpp b/src/rose/rose_build_dump.cpp index 2b19e197..3df2d5f5 100644 --- a/src/rose/rose_build_dump.cpp +++ b/src/rose/rose_build_dump.cpp @@ -505,28 +505,24 @@ void dumpRoseTestLiterals(const RoseBuildImpl &build, const string &base) { size_t longLitLengthThreshold = calcLongLitThreshold(build, historyRequired); - auto mp = makeMatcherProto(build, build.final_to_frag_map, ROSE_ANCHORED, - false, longLitLengthThreshold); + auto mp = + makeMatcherProto(build, ROSE_ANCHORED, false, longLitLengthThreshold); dumpTestLiterals(base + "rose_anchored_test_literals.txt", mp.lits); - mp = makeMatcherProto(build, build.final_to_frag_map, ROSE_FLOATING, false, - longLitLengthThreshold); + mp = makeMatcherProto(build, ROSE_FLOATING, false, longLitLengthThreshold); dumpTestLiterals(base + "rose_float_test_literals.txt", mp.lits); - mp = makeMatcherProto(build, build.final_to_frag_map, ROSE_FLOATING, true, - longLitLengthThreshold); + mp = makeMatcherProto(build, ROSE_FLOATING, true, longLitLengthThreshold); dumpTestLiterals(base + "rose_delay_rebuild_test_literals.txt", mp.lits); - mp = makeMatcherProto(build, build.final_to_frag_map, ROSE_EOD_ANCHORED, - false, build.ematcher_region_size); + mp = makeMatcherProto(build, ROSE_EOD_ANCHORED, false, + build.ematcher_region_size); dumpTestLiterals(base + "rose_eod_test_literals.txt", mp.lits); if (!build.cc.streaming) { - mp = - makeMatcherProto(build, build.final_to_frag_map, ROSE_FLOATING, - false, ROSE_SMALL_BLOCK_LEN, ROSE_SMALL_BLOCK_LEN); - auto mp2 = makeMatcherProto(build, build.final_to_frag_map, - ROSE_ANCHORED_SMALL_BLOCK, false, + mp = makeMatcherProto(build, ROSE_FLOATING, false, ROSE_SMALL_BLOCK_LEN, + ROSE_SMALL_BLOCK_LEN); + auto mp2 = makeMatcherProto(build, ROSE_ANCHORED_SMALL_BLOCK, false, ROSE_SMALL_BLOCK_LEN, ROSE_SMALL_BLOCK_LEN); mp.lits.insert(end(mp.lits), begin(mp2.lits), end(mp2.lits)); dumpTestLiterals(base + "rose_smallblock_test_literals.txt", mp.lits); diff --git a/src/rose/rose_build_matchers.cpp b/src/rose/rose_build_matchers.cpp index c725b39d..998cd545 100644 --- a/src/rose/rose_build_matchers.cpp +++ b/src/rose/rose_build_matchers.cpp @@ -636,11 +636,10 @@ u64a literalMinReportOffset(const RoseBuildImpl &build, } static -map makeFragGroupMap(const RoseBuildImpl &build, - const map &final_to_frag_map) { +map makeFragGroupMap(const RoseBuildImpl &build) { map frag_to_group; - for (const auto &m : final_to_frag_map) { + for (const auto &m : build.final_to_frag_map) { u32 final_id = m.first; u32 frag_id = m.second.fragment_id; hwlm_group_t groups = 0; @@ -665,7 +664,6 @@ void trim_to_suffix(Container &c, size_t len) { } MatcherProto makeMatcherProto(const RoseBuildImpl &build, - const map &final_to_frag_map, rose_literal_table table, bool delay_rebuild, size_t max_len, u32 max_offset) { MatcherProto mp; @@ -753,12 +751,12 @@ MatcherProto makeMatcherProto(const RoseBuildImpl &build, cmp); } - auto frag_group_map = makeFragGroupMap(build, final_to_frag_map); + auto frag_group_map = makeFragGroupMap(build); for (auto &lit : mp.lits) { u32 final_id = lit.id; - assert(contains(final_to_frag_map, final_id)); - const auto &frag = final_to_frag_map.at(final_id); + assert(contains(build.final_to_frag_map, final_id)); + const auto &frag = build.final_to_frag_map.at(final_id); lit.id = delay_rebuild ? frag.delay_program_offset : frag.lit_program_offset; assert(contains(frag_group_map, frag.fragment_id)); @@ -805,14 +803,13 @@ void buildAccel(const RoseBuildImpl &build, const MatcherProto &mp, aligned_unique_ptr buildFloatingMatcher(const RoseBuildImpl &build, size_t longLitLengthThreshold, - const map &final_to_frag_map, rose_group *fgroups, size_t *fsize, size_t *historyRequired) { *fsize = 0; *fgroups = 0; - auto mp = makeMatcherProto(build, final_to_frag_map, ROSE_FLOATING, false, - longLitLengthThreshold); + auto mp = + makeMatcherProto(build, ROSE_FLOATING, false, longLitLengthThreshold); if (mp.lits.empty()) { DEBUG_PRINTF("empty floating matcher\n"); return nullptr; @@ -841,9 +838,9 @@ buildFloatingMatcher(const RoseBuildImpl &build, size_t longLitLengthThreshold, return hwlm; } -aligned_unique_ptr buildDelayRebuildMatcher( - const RoseBuildImpl &build, size_t longLitLengthThreshold, - const map &final_to_frag_map, size_t *drsize) { +aligned_unique_ptr buildDelayRebuildMatcher(const RoseBuildImpl &build, + size_t longLitLengthThreshold, + size_t *drsize) { *drsize = 0; if (!build.cc.streaming) { @@ -851,8 +848,8 @@ aligned_unique_ptr buildDelayRebuildMatcher( return nullptr; } - auto mp = makeMatcherProto(build, final_to_frag_map, ROSE_FLOATING, true, - longLitLengthThreshold); + auto mp = + makeMatcherProto(build, ROSE_FLOATING, true, longLitLengthThreshold); if (mp.lits.empty()) { DEBUG_PRINTF("empty delay rebuild matcher\n"); return nullptr; @@ -871,10 +868,8 @@ aligned_unique_ptr buildDelayRebuildMatcher( return hwlm; } -aligned_unique_ptr -buildSmallBlockMatcher(const RoseBuildImpl &build, - const map &final_to_frag_map, - size_t *sbsize) { +aligned_unique_ptr buildSmallBlockMatcher(const RoseBuildImpl &build, + size_t *sbsize) { *sbsize = 0; if (build.cc.streaming) { @@ -889,7 +884,7 @@ buildSmallBlockMatcher(const RoseBuildImpl &build, return nullptr; } - auto mp = makeMatcherProto(build, final_to_frag_map, ROSE_FLOATING, false, + auto mp = makeMatcherProto(build, ROSE_FLOATING, false, ROSE_SMALL_BLOCK_LEN, ROSE_SMALL_BLOCK_LEN); if (mp.lits.empty()) { DEBUG_PRINTF("no floating table\n"); @@ -900,8 +895,8 @@ buildSmallBlockMatcher(const RoseBuildImpl &build, } auto mp_anchored = - makeMatcherProto(build, final_to_frag_map, ROSE_ANCHORED_SMALL_BLOCK, - false, ROSE_SMALL_BLOCK_LEN, ROSE_SMALL_BLOCK_LEN); + makeMatcherProto(build, ROSE_ANCHORED_SMALL_BLOCK, false, + ROSE_SMALL_BLOCK_LEN, ROSE_SMALL_BLOCK_LEN); if (mp_anchored.lits.empty()) { DEBUG_PRINTF("no small-block anchored literals\n"); return nullptr; @@ -932,14 +927,12 @@ buildSmallBlockMatcher(const RoseBuildImpl &build, return hwlm; } -aligned_unique_ptr -buildEodAnchoredMatcher(const RoseBuildImpl &build, - const map &final_to_frag_map, - size_t *esize) { +aligned_unique_ptr buildEodAnchoredMatcher(const RoseBuildImpl &build, + size_t *esize) { *esize = 0; - auto mp = makeMatcherProto(build, final_to_frag_map, ROSE_EOD_ANCHORED, - false, build.ematcher_region_size); + auto mp = makeMatcherProto(build, ROSE_EOD_ANCHORED, false, + build.ematcher_region_size); if (mp.lits.empty()) { DEBUG_PRINTF("no eod anchored literals\n"); diff --git a/src/rose/rose_build_matchers.h b/src/rose/rose_build_matchers.h index d7da113c..184c2633 100644 --- a/src/rose/rose_build_matchers.h +++ b/src/rose/rose_build_matchers.h @@ -67,31 +67,25 @@ struct MatcherProto { * If max_offset is specified (and not ROSE_BOUND_INF), then literals that can * only lead to a pattern match after max_offset may be excluded. */ -MatcherProto -makeMatcherProto(const RoseBuildImpl &build, - const std::map &final_to_frag_map, - rose_literal_table table, bool delay_rebuild, size_t max_len, - u32 max_offset = ROSE_BOUND_INF); +MatcherProto makeMatcherProto(const RoseBuildImpl &build, + rose_literal_table table, bool delay_rebuild, + size_t max_len, u32 max_offset = ROSE_BOUND_INF); -aligned_unique_ptr -buildFloatingMatcher(const RoseBuildImpl &build, size_t longLitLengthThreshold, - const std::map &final_to_frag_map, - rose_group *fgroups, size_t *fsize, - size_t *historyRequired); +aligned_unique_ptr buildFloatingMatcher(const RoseBuildImpl &build, + size_t longLitLengthThreshold, + rose_group *fgroups, + size_t *fsize, + size_t *historyRequired); -aligned_unique_ptr buildDelayRebuildMatcher( - const RoseBuildImpl &build, size_t longLitLengthThreshold, - const std::map &final_to_frag_map, size_t *drsize); +aligned_unique_ptr buildDelayRebuildMatcher(const RoseBuildImpl &build, + size_t longLitLengthThreshold, + size_t *drsize); -aligned_unique_ptr -buildSmallBlockMatcher(const RoseBuildImpl &build, - const std::map &final_to_frag_map, - size_t *sbsize); +aligned_unique_ptr buildSmallBlockMatcher(const RoseBuildImpl &build, + size_t *sbsize); -aligned_unique_ptr -buildEodAnchoredMatcher(const RoseBuildImpl &build, - const std::map &final_to_frag_map, - size_t *esize); +aligned_unique_ptr buildEodAnchoredMatcher(const RoseBuildImpl &build, + size_t *esize); void findMoreLiteralMasks(RoseBuildImpl &build);