aligned_unique_ptr<anchored_matcher_info>
buildAnchoredMatcher(RoseBuildImpl &build, vector<raw_dfa> &dfas,
- const map<u32, LitFragment> &final_to_frag_map,
size_t *asize) {
const CompileContext &cc = build.cc;
}
for (auto &rdfa : dfas) {
- remapIdsToPrograms(rdfa, final_to_frag_map);
+ remapIdsToPrograms(rdfa, build.final_to_frag_map);
}
vector<aligned_unique_ptr<NFA>> nfas;
*/
aligned_unique_ptr<anchored_matcher_info>
buildAnchoredMatcher(RoseBuildImpl &build, std::vector<raw_dfa> &dfas,
- const std::map<u32, LitFragment> &final_to_frag_map,
size_t *asize);
u32 anchoredStateSize(const anchored_matcher_info &atable);
* - total number of literal fragments
*/
static
-tuple<u32, u32, u32>
-buildLiteralPrograms(RoseBuildImpl &build, build_context &bc,
- map<u32, LitFragment> &final_to_frag_map) {
+tuple<u32, u32, u32> buildLiteralPrograms(RoseBuildImpl &build,
+ build_context &bc) {
// Build a reverse mapping from fragment -> final_id.
map<u32, flat_set<u32>> 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);
}
}
// 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];
}
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);
// 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;
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);
// 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);
// 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);
// 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);
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);
}
static
-map<u32, hwlm_group_t> makeFragGroupMap(const RoseBuildImpl &build,
- const map<u32, LitFragment> &final_to_frag_map) {
+map<u32, hwlm_group_t> makeFragGroupMap(const RoseBuildImpl &build) {
map<u32, hwlm_group_t> 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;
}
MatcherProto makeMatcherProto(const RoseBuildImpl &build,
- const map<u32, LitFragment> &final_to_frag_map,
rose_literal_table table, bool delay_rebuild,
size_t max_len, u32 max_offset) {
MatcherProto mp;
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));
aligned_unique_ptr<HWLM>
buildFloatingMatcher(const RoseBuildImpl &build, size_t longLitLengthThreshold,
- const map<u32, LitFragment> &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;
return hwlm;
}
-aligned_unique_ptr<HWLM> buildDelayRebuildMatcher(
- const RoseBuildImpl &build, size_t longLitLengthThreshold,
- const map<u32, LitFragment> &final_to_frag_map, size_t *drsize) {
+aligned_unique_ptr<HWLM> buildDelayRebuildMatcher(const RoseBuildImpl &build,
+ size_t longLitLengthThreshold,
+ size_t *drsize) {
*drsize = 0;
if (!build.cc.streaming) {
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;
return hwlm;
}
-aligned_unique_ptr<HWLM>
-buildSmallBlockMatcher(const RoseBuildImpl &build,
- const map<u32, LitFragment> &final_to_frag_map,
- size_t *sbsize) {
+aligned_unique_ptr<HWLM> buildSmallBlockMatcher(const RoseBuildImpl &build,
+ size_t *sbsize) {
*sbsize = 0;
if (build.cc.streaming) {
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");
}
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;
return hwlm;
}
-aligned_unique_ptr<HWLM>
-buildEodAnchoredMatcher(const RoseBuildImpl &build,
- const map<u32, LitFragment> &final_to_frag_map,
- size_t *esize) {
+aligned_unique_ptr<HWLM> 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");
* 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<u32, LitFragment> &final_to_frag_map,
- rose_literal_table table, bool delay_rebuild, size_t max_len,
- u32 max_offset = ROSE_BOUND_INF);
-
-aligned_unique_ptr<HWLM>
-buildFloatingMatcher(const RoseBuildImpl &build, size_t longLitLengthThreshold,
- const std::map<u32, LitFragment> &final_to_frag_map,
- rose_group *fgroups, size_t *fsize,
- size_t *historyRequired);
-
-aligned_unique_ptr<HWLM> buildDelayRebuildMatcher(
- const RoseBuildImpl &build, size_t longLitLengthThreshold,
- const std::map<u32, LitFragment> &final_to_frag_map, size_t *drsize);
-
-aligned_unique_ptr<HWLM>
-buildSmallBlockMatcher(const RoseBuildImpl &build,
- const std::map<u32, LitFragment> &final_to_frag_map,
- size_t *sbsize);
-
-aligned_unique_ptr<HWLM>
-buildEodAnchoredMatcher(const RoseBuildImpl &build,
- const std::map<u32, LitFragment> &final_to_frag_map,
- size_t *esize);
+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<HWLM> buildFloatingMatcher(const RoseBuildImpl &build,
+ size_t longLitLengthThreshold,
+ rose_group *fgroups,
+ size_t *fsize,
+ size_t *historyRequired);
+
+aligned_unique_ptr<HWLM> buildDelayRebuildMatcher(const RoseBuildImpl &build,
+ size_t longLitLengthThreshold,
+ size_t *drsize);
+
+aligned_unique_ptr<HWLM> buildSmallBlockMatcher(const RoseBuildImpl &build,
+ size_t *sbsize);
+
+aligned_unique_ptr<HWLM> buildEodAnchoredMatcher(const RoseBuildImpl &build,
+ size_t *esize);
void findMoreLiteralMasks(RoseBuildImpl &build);