mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-07-12 21:44:44 +03:00
rose: dump leftfix/suffix queue indices
This commit is contained in:
parent
6d87533ef0
commit
9b7eca5400
@ -1102,7 +1102,7 @@ void setLeftNfaProperties(NFA &n, const left_id &left) {
|
||||
}
|
||||
|
||||
static
|
||||
bool buildLeftfixes(const RoseBuildImpl &tbi, build_context &bc,
|
||||
bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||
QueueIndexFactory &qif, set<u32> *no_retrigger_queues,
|
||||
bool do_prefix) {
|
||||
const RoseGraph &g = tbi.g;
|
||||
@ -1174,6 +1174,7 @@ bool buildLeftfixes(const RoseBuildImpl &tbi, build_context &bc,
|
||||
setLeftNfaProperties(*nfa, leftfix);
|
||||
|
||||
qi = qif.get_queue();
|
||||
tbi.leftfix_queue_map.emplace(leftfix, qi);
|
||||
nfa->queueIndex = qi;
|
||||
|
||||
if (!is_prefix && !leftfix.haig() && leftfix.graph() &&
|
||||
@ -1458,6 +1459,7 @@ void assignSuffixQueues(RoseBuildImpl &build, build_context &bc) {
|
||||
u32 queue = build.qif.get_queue();
|
||||
DEBUG_PRINTF("assigning %p to queue %u\n", s.graph(), queue);
|
||||
bc.suffixes.emplace(s, queue);
|
||||
build.suffix_queue_map.emplace(s, queue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,12 +30,13 @@
|
||||
|
||||
#include "rose_build_dump.h"
|
||||
|
||||
#include "hwlm/hwlm_build.h"
|
||||
#include "rose_build_impl.h"
|
||||
#include "rose_build_matchers.h"
|
||||
#include "rose/rose_dump.h"
|
||||
#include "rose_internal.h"
|
||||
#include "ue2common.h"
|
||||
#include "hwlm/hwlm_build.h"
|
||||
#include "nfa/castlecompile.h"
|
||||
#include "nfa/nfa_internal.h"
|
||||
#include "nfagraph/ng_dump.h"
|
||||
#include "som/slot_manager_dump.h"
|
||||
@ -64,22 +65,40 @@ static
|
||||
string to_string(nfa_kind k) {
|
||||
switch (k) {
|
||||
case NFA_PREFIX:
|
||||
return "p";
|
||||
return "PREFIX";
|
||||
case NFA_INFIX:
|
||||
return "i";
|
||||
return "INFIX";
|
||||
case NFA_SUFFIX:
|
||||
return "s";
|
||||
return "SUFFIX";
|
||||
case NFA_OUTFIX:
|
||||
return "o";
|
||||
return "OUTFIX";
|
||||
case NFA_REV_PREFIX:
|
||||
return "r";
|
||||
return "REV_PREFIX";
|
||||
case NFA_OUTFIX_RAW:
|
||||
return "O";
|
||||
return "OUTFIX_RAW";
|
||||
}
|
||||
assert(0);
|
||||
return "?";
|
||||
}
|
||||
|
||||
/** \brief Return the kind of a left_id or a suffix_id. */
|
||||
template<class Graph>
|
||||
string render_kind(const Graph &g) {
|
||||
if (g.graph()) {
|
||||
return to_string(g.graph()->kind);
|
||||
}
|
||||
if (g.dfa()) {
|
||||
return to_string(g.dfa()->kind);
|
||||
}
|
||||
if (g.haig()) {
|
||||
return to_string(g.haig()->kind);
|
||||
}
|
||||
if (g.castle()) {
|
||||
return to_string(g.castle()->kind);
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class RoseGraphWriter {
|
||||
@ -130,22 +149,12 @@ public:
|
||||
}
|
||||
|
||||
if (g[v].suffix) {
|
||||
os << "\\nSUFFIX (TOP " << g[v].suffix.top;
|
||||
// Can't dump the queue number, but we can identify the suffix.
|
||||
if (g[v].suffix.graph) {
|
||||
os << ", graph=" << g[v].suffix.graph.get() << " "
|
||||
<< to_string(g[v].suffix.graph->kind);
|
||||
suffix_id suff(g[v].suffix);
|
||||
os << "\\n" << render_kind(suff) << " (top " << g[v].suffix.top;
|
||||
auto it = build.suffix_queue_map.find(suff);
|
||||
if (it != end(build.suffix_queue_map)) {
|
||||
os << ", queue " << it->second;
|
||||
}
|
||||
if (g[v].suffix.castle) {
|
||||
os << ", castle=" << g[v].suffix.castle.get();
|
||||
}
|
||||
if (g[v].suffix.rdfa) {
|
||||
os << ", dfa=" << g[v].suffix.rdfa.get();
|
||||
}
|
||||
if (g[v].suffix.haig) {
|
||||
os << ", haig=" << g[v].suffix.haig.get();
|
||||
}
|
||||
|
||||
os << ")";
|
||||
}
|
||||
|
||||
@ -154,15 +163,15 @@ public:
|
||||
}
|
||||
|
||||
if (g[v].left) {
|
||||
const char *roseKind =
|
||||
build.isRootSuccessor(v) ? "PREFIX" : "INFIX";
|
||||
os << "\\nROSE " << roseKind;
|
||||
os << " (";
|
||||
os << "report " << g[v].left.leftfix_report << ")";
|
||||
|
||||
if (g[v].left.graph) {
|
||||
os << " " << to_string(g[v].left.graph->kind);
|
||||
left_id left(g[v].left);
|
||||
os << "\\n" << render_kind(left) << " (queue ";
|
||||
auto it = build.leftfix_queue_map.find(left);
|
||||
if (it != end(build.leftfix_queue_map)) {
|
||||
os << it->second;
|
||||
} else {
|
||||
os << "??";
|
||||
}
|
||||
os << ", report " << g[v].left.leftfix_report << ")";
|
||||
}
|
||||
|
||||
os << "\"";
|
||||
|
@ -541,6 +541,12 @@ public:
|
||||
|
||||
u32 ematcher_region_size; /**< number of bytes the eod table runs over */
|
||||
|
||||
/** \brief Mapping from leftfix to queue ID (used in dump code). */
|
||||
unordered_map<left_id, u32> leftfix_queue_map;
|
||||
|
||||
/** \brief Mapping from suffix to queue ID (used in dump code). */
|
||||
unordered_map<suffix_id, u32> suffix_queue_map;
|
||||
|
||||
/** \brief Mapping from anchored literal ID to the original literal suffix
|
||||
* present when the literal was added to the literal matcher. Used for
|
||||
* overlap calculation in history assignment. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user