mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-15 17:02:14 +03:00
addressing 47 [constParameterReference],48 [constVariableReference],58
[constVariable]
This commit is contained in:
@@ -159,7 +159,7 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
|
||||
map<u32, vector<LiteralIndex> > res2lits;
|
||||
hwlm_group_t gm = 0;
|
||||
for (LiteralIndex i = 0; i < lits.size(); i++) {
|
||||
LitInfo & li = tmpLitInfo[i];
|
||||
const LitInfo & li = tmpLitInfo[i];
|
||||
u32 hash = CONF_HASH_CALL(li.v, andmsk, mult, nBits);
|
||||
DEBUG_PRINTF("%016llx --> %u\n", li.v, hash);
|
||||
res2lits[hash].emplace_back(i);
|
||||
|
||||
@@ -622,7 +622,7 @@ bytecode_ptr<FDR> TeddyCompiler::build() {
|
||||
static
|
||||
bool assignStringsToBuckets(
|
||||
const vector<hwlmLiteral> &lits,
|
||||
TeddyEngineDescription &eng,
|
||||
const TeddyEngineDescription &eng,
|
||||
map<BucketIndex, vector<LiteralIndex>> &bucketToLits) {
|
||||
assert(eng.numMasks <= MAX_NUM_MASKS);
|
||||
if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) {
|
||||
|
||||
@@ -1017,7 +1017,7 @@ void update_accel_prog_offset(const gough_build_strat &gbs,
|
||||
verts[gbs.gg[v].state_id] = v;
|
||||
}
|
||||
|
||||
for (auto &m : gbs.built_accel) {
|
||||
for (const auto &m : gbs.built_accel) {
|
||||
gough_accel *ga = m.first;
|
||||
assert(!ga->prog_offset);
|
||||
GoughVertex v = verts[m.second];
|
||||
|
||||
@@ -438,7 +438,7 @@ void create_slot_mapping(const GoughGraph &cfg, UNUSED u32 old_slot_count,
|
||||
}
|
||||
|
||||
static
|
||||
void update_local_slots(GoughGraph &g, set<GoughSSAVar *> &locals,
|
||||
void update_local_slots(GoughGraph &g, const set<GoughSSAVar *> &locals,
|
||||
u32 local_base) {
|
||||
DEBUG_PRINTF("%zu local variables\n", locals.size());
|
||||
/* local variables only occur on edges (joins are never local) */
|
||||
|
||||
@@ -361,7 +361,7 @@ struct raw_report_list {
|
||||
raw_report_list(const flat_set<ReportID> &reports_in,
|
||||
const ReportManager &rm, bool do_remap) {
|
||||
if (do_remap) {
|
||||
for (auto &id : reports_in) {
|
||||
for (const auto &id : reports_in) {
|
||||
reports.insert(rm.getProgramOffset(id));
|
||||
}
|
||||
} else {
|
||||
@@ -540,7 +540,7 @@ size_t calcWideRegionSize(const dfa_info &info) {
|
||||
static
|
||||
void fillInAux(mstate_aux *aux, dstate_id_t i, const dfa_info &info,
|
||||
const vector<u32> &reports, const vector<u32> &reports_eod,
|
||||
vector<u32> &reportOffsets) {
|
||||
const vector<u32> &reportOffsets) {
|
||||
const dstate &raw_state = info.states[i];
|
||||
aux->accept = raw_state.reports.empty() ? 0 : reportOffsets[reports[i]];
|
||||
aux->accept_eod = raw_state.reports_eod.empty() ? 0
|
||||
@@ -794,8 +794,8 @@ bytecode_ptr<NFA> mcclellanCompile16(dfa_info &info, const CompileContext &cc,
|
||||
}
|
||||
|
||||
for (size_t i : order) {
|
||||
vector<dstate_id_t> &state_chain = info.wide_state_chain[i];
|
||||
vector<symbol_t> &symbol_chain = info.wide_symbol_chain[i];
|
||||
const vector<dstate_id_t> &state_chain = info.wide_state_chain[i];
|
||||
const vector<symbol_t> &symbol_chain = info.wide_symbol_chain[i];
|
||||
|
||||
u16 width = verify_u16(symbol_chain.size());
|
||||
*(u16 *)(curr_wide_entry + WIDE_WIDTH_OFFSET) = width;
|
||||
@@ -1367,11 +1367,11 @@ bool store_chain_longest(vector<vector<dstate_id_t>> &candidate_chain,
|
||||
/* \brief Generate wide_symbol_chain from wide_state_chain. */
|
||||
static
|
||||
void generate_symbol_chain(dfa_info &info, vector<symbol_t> &chain_tail) {
|
||||
raw_dfa &rdfa = info.raw;
|
||||
const raw_dfa &rdfa = info.raw;
|
||||
assert(chain_tail.size() == info.wide_state_chain.size());
|
||||
|
||||
for (size_t i = 0; i < info.wide_state_chain.size(); i++) {
|
||||
vector<dstate_id_t> &state_chain = info.wide_state_chain[i];
|
||||
const vector<dstate_id_t> &state_chain = info.wide_state_chain[i];
|
||||
vector<symbol_t> symbol_chain;
|
||||
|
||||
info.extra[state_chain[0]].wideHead = true;
|
||||
|
||||
@@ -955,7 +955,7 @@ bool is_cyclic_near(const raw_dfa &raw, dstate_id_t root) {
|
||||
}
|
||||
|
||||
static
|
||||
void fill_in_sherman(NFA *nfa, dfa_info &info, UNUSED u16 sherman_limit) {
|
||||
void fill_in_sherman(NFA *nfa, const dfa_info &info, UNUSED u16 sherman_limit) {
|
||||
char *nfa_base = (char *)nfa;
|
||||
mcsheng *m = (mcsheng *)getMutableImplNfa(nfa);
|
||||
char *sherman_table = nfa_base + m->sherman_offset;
|
||||
@@ -1109,7 +1109,7 @@ void fill_in_succ_table_8(NFA *nfa, const dfa_info &info,
|
||||
}
|
||||
|
||||
static
|
||||
void fill_in_sherman64(NFA *nfa, dfa_info &info, UNUSED u16 sherman_limit) {
|
||||
void fill_in_sherman64(NFA *nfa, const dfa_info &info, UNUSED u16 sherman_limit) {
|
||||
char *nfa_base = (char *)nfa;
|
||||
mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(nfa);
|
||||
char *sherman_table = nfa_base + m->sherman_offset;
|
||||
|
||||
@@ -99,7 +99,7 @@ struct dfa_info {
|
||||
return next(idx, TOP);
|
||||
}
|
||||
dstate &next(dstate_id_t idx, u16 chr) {
|
||||
auto &src = (*this)[idx];
|
||||
const auto &src = (*this)[idx];
|
||||
auto next_id = src.next[raw.alpha_remap[chr]];
|
||||
return states[next_id];
|
||||
}
|
||||
@@ -109,7 +109,7 @@ struct dfa_info {
|
||||
// if DFA can't die, shift all indices left by 1
|
||||
return can_die ? idx : idx + 1;
|
||||
}
|
||||
bool isDead(dstate &state) {
|
||||
bool isDead(const dstate &state) {
|
||||
return raw_id(state.impl_id) == DEAD_STATE;
|
||||
}
|
||||
bool isDead(dstate_id_t idx) {
|
||||
@@ -117,7 +117,7 @@ struct dfa_info {
|
||||
}
|
||||
|
||||
private:
|
||||
static bool dfaCanDie(raw_dfa &rdfa) {
|
||||
static bool dfaCanDie(const raw_dfa &rdfa) {
|
||||
for (unsigned chr = 0; chr < 256; chr++) {
|
||||
for (dstate_id_t state = 0; state < rdfa.states.size(); state++) {
|
||||
auto succ = rdfa.states[state].next[rdfa.alpha_remap[chr]];
|
||||
@@ -138,7 +138,7 @@ struct raw_report_list {
|
||||
raw_report_list(const flat_set<ReportID> &reports_in,
|
||||
const ReportManager &rm, bool do_remap) {
|
||||
if (do_remap) {
|
||||
for (auto &id : reports_in) {
|
||||
for (const auto &id : reports_in) {
|
||||
reports.insert(rm.getProgramOffset(id));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -227,7 +227,7 @@ const u8 *fwdBlock(SuperVector<S> shuf_mask_lo_highclear, SuperVector<S> shuf_ma
|
||||
}
|
||||
|
||||
template <uint16_t S>
|
||||
const u8 *truffleExecReal(m128 &shuf_mask_lo_highclear, m128 shuf_mask_lo_highset, const u8 *buf, const u8 *buf_end) {
|
||||
const u8 *truffleExecReal(const m128 &shuf_mask_lo_highclear, m128 shuf_mask_lo_highset, const u8 *buf, const u8 *buf_end) {
|
||||
assert(buf && buf_end);
|
||||
assert(buf < buf_end);
|
||||
DEBUG_PRINTF("truffle %p len %zu\n", buf, buf_end - buf);
|
||||
@@ -349,4 +349,4 @@ const u8 *rtruffleExecReal(m128 shuf_mask_lo_highclear, m128 shuf_mask_lo_highse
|
||||
|
||||
return buf - 1;
|
||||
}
|
||||
#endif //HAVE_SVE
|
||||
#endif //HAVE_SVE
|
||||
|
||||
@@ -292,7 +292,7 @@ bool addComponent(NG &ng, NGHolder &g, const ExpressionInfo &expr,
|
||||
|
||||
// Returns true if all components have been added.
|
||||
static
|
||||
bool processComponents(NG &ng, ExpressionInfo &expr,
|
||||
bool processComponents(NG &ng, const ExpressionInfo &expr,
|
||||
deque<unique_ptr<NGHolder>> &g_comp,
|
||||
const som_type som) {
|
||||
const u32 num_components = g_comp.size();
|
||||
|
||||
@@ -257,7 +257,7 @@ void reformAnchoredRepeatsComponent(NGHolder &g,
|
||||
|
||||
static
|
||||
void reformUnanchoredRepeatsComponent(NGHolder &g,
|
||||
set<NFAVertex> &compAnchoredStarts,
|
||||
const set<NFAVertex> &compAnchoredStarts,
|
||||
set<NFAVertex> &compUnanchoredStarts,
|
||||
set<NFAVertex> &dead,
|
||||
depth *startBegin, depth *startEnd) {
|
||||
@@ -555,7 +555,7 @@ void collapseVariableRepeats(NGHolder &g, depth *startBegin, depth *startEnd) {
|
||||
}
|
||||
|
||||
static
|
||||
void addDotsBetween(NGHolder &g, NFAVertex lhs, vector<NFAVertex> &rhs,
|
||||
void addDotsBetween(NGHolder &g, NFAVertex lhs, const vector<NFAVertex> &rhs,
|
||||
depth min_repeat, depth max_repeat) {
|
||||
const bool unbounded = max_repeat.is_infinite();
|
||||
if (unbounded) {
|
||||
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
return id;
|
||||
}
|
||||
|
||||
void append(WorkQueue &other) {
|
||||
void append(const WorkQueue &other) {
|
||||
for (const auto &e : other) {
|
||||
push(e);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ private:
|
||||
}
|
||||
|
||||
static
|
||||
bool outIsIrreducible(NFAVertex &v, const NGHolder &g) {
|
||||
bool outIsIrreducible(const NFAVertex &v, const NGHolder &g) {
|
||||
unsigned nonSpecialVertices = 0;
|
||||
for (auto w : adjacent_vertices_range(v, g)) {
|
||||
if (!is_special(w, g) && w != v) {
|
||||
@@ -204,7 +204,7 @@ bool outIsIrreducible(NFAVertex &v, const NGHolder &g) {
|
||||
}
|
||||
|
||||
static
|
||||
bool inIsIrreducible(NFAVertex &v, const NGHolder &g) {
|
||||
bool inIsIrreducible(const NFAVertex &v, const NGHolder &g) {
|
||||
unsigned nonSpecialVertices = 0;
|
||||
for (auto u : inv_adjacent_vertices_range(v, g)) {
|
||||
if (!is_special(u, g) && u != v) {
|
||||
|
||||
@@ -430,7 +430,7 @@ NFAVertex findSingleCyclic(const NGHolder &g) {
|
||||
}
|
||||
|
||||
static
|
||||
bool hasOffsetAdjust(const ReportManager &rm, NGHolder &g,
|
||||
bool hasOffsetAdjust(const ReportManager &rm, const NGHolder &g,
|
||||
int *adjust) {
|
||||
const auto &reports = all_reports(g);
|
||||
if (reports.empty()) {
|
||||
|
||||
@@ -582,7 +582,7 @@ private:
|
||||
|
||||
// set up all reports
|
||||
bool clone = false;
|
||||
for (auto &pair : reports_to_vertices) {
|
||||
for (const auto &pair : reports_to_vertices) {
|
||||
const auto &reports = pair.first;
|
||||
const auto &vertices = pair.second;
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ void addToString(string &s, const NGHolder &g, NFAVertex v) {
|
||||
}
|
||||
|
||||
static
|
||||
bool splitOffLiteral(NG &ng, NGHolder &g, NFAVertex v, const bool anchored,
|
||||
bool splitOffLiteral(NG &ng, const NGHolder &g, NFAVertex v, const bool anchored,
|
||||
set<NFAVertex> &dead) {
|
||||
DEBUG_PRINTF("examine vertex %zu\n", g[v].index);
|
||||
bool nocase = false, casefixed = false;
|
||||
|
||||
@@ -241,7 +241,7 @@ u32 allowedSquashDistance(const CharReach &cr, u32 min_width, const NGHolder &g,
|
||||
/** Gives a stronger puff trigger when the trigger is connected to a wide
|
||||
* cyclic state (aside from sds) */
|
||||
static
|
||||
void improveHead(NGHolder &g, NFAVertex *a, vector<NFAVertex> *nodes) {
|
||||
void improveHead(const NGHolder &g, NFAVertex *a, vector<NFAVertex> *nodes) {
|
||||
DEBUG_PRINTF("attempting to improve puff trigger\n");
|
||||
assert(!nodes->empty());
|
||||
const CharReach &puff_cr = g[nodes->back()].char_reach;
|
||||
@@ -260,7 +260,7 @@ void improveHead(NGHolder &g, NFAVertex *a, vector<NFAVertex> *nodes) {
|
||||
}
|
||||
|
||||
static
|
||||
void constructPuff(NGHolder &g, const NFAVertex a, const NFAVertex puffv,
|
||||
void constructPuff(const NGHolder &g, const NFAVertex a, const NFAVertex puffv,
|
||||
const CharReach &cr, const ReportID report, u32 width,
|
||||
bool fixed_depth, bool unbounded, bool auto_restart,
|
||||
RoseBuild &rose, ReportManager &rm,
|
||||
|
||||
@@ -323,7 +323,7 @@ bool doUselessMergePass(NGHolder &g, som_type som, VertexInfoMap &infoMap,
|
||||
|
||||
bool changed = false;
|
||||
for (auto v : vertices_range(g)) {
|
||||
VertexInfo &info = infoMap[v];
|
||||
const VertexInfo &info = infoMap[v];
|
||||
|
||||
if (info.isRemoved) {
|
||||
continue;
|
||||
@@ -439,7 +439,7 @@ bool doUselessMergePass(NGHolder &g, som_type som, VertexInfoMap &infoMap,
|
||||
continue; // Conservatively skip anything with nonzero tops.
|
||||
}
|
||||
|
||||
CharReach &otherReach = g[t].char_reach;
|
||||
const CharReach &otherReach = g[t].char_reach;
|
||||
if (currReach.isSubsetOf(otherReach)) {
|
||||
DEBUG_PRINTF("removing redundant vertex %zu (keeping %zu)\n",
|
||||
g[v].index, g[t].index);
|
||||
@@ -745,7 +745,7 @@ u32 findCyclic(const NGHolder &g, vector<bool> &cyclic) {
|
||||
}
|
||||
|
||||
static
|
||||
void findCyclicDom(NGHolder &g, vector<bool> &cyclic,
|
||||
void findCyclicDom(const NGHolder &g, vector<bool> &cyclic,
|
||||
set<NFAEdge> &dead, som_type som) {
|
||||
auto dominators = findDominators(g);
|
||||
|
||||
@@ -789,7 +789,7 @@ void findCyclicDom(NGHolder &g, vector<bool> &cyclic,
|
||||
}
|
||||
|
||||
static
|
||||
void findCyclicPostDom(NGHolder &g, vector<bool> &cyclic,
|
||||
void findCyclicPostDom(const NGHolder &g, vector<bool> &cyclic,
|
||||
set<NFAEdge> &dead) {
|
||||
auto postdominators = findPostDominators(g);
|
||||
|
||||
|
||||
@@ -1874,7 +1874,7 @@ void buildFeeder(NGHolder &g, const BoundedRepeatData &rd,
|
||||
* offset.
|
||||
*/
|
||||
static
|
||||
bool improveLeadingRepeat(NGHolder &g, BoundedRepeatData &rd,
|
||||
bool improveLeadingRepeat(NGHolder &g, const BoundedRepeatData &rd,
|
||||
unordered_set<NFAVertex> &created,
|
||||
const vector<BoundedRepeatData> &all_repeats) {
|
||||
assert(edge(g.startDs, g.startDs, g).second);
|
||||
@@ -1944,7 +1944,7 @@ bool improveLeadingRepeat(NGHolder &g, BoundedRepeatData &rd,
|
||||
}
|
||||
|
||||
static
|
||||
vector<NFAVertex> makeOwnStraw(NGHolder &g, BoundedRepeatData &rd,
|
||||
vector<NFAVertex> makeOwnStraw(NGHolder &g, const BoundedRepeatData &rd,
|
||||
const vector<NFAVertex> &straw) {
|
||||
// Straw runs from startDs to our pos trigger.
|
||||
assert(!straw.empty());
|
||||
|
||||
@@ -1177,7 +1177,7 @@ void expandGraph(NGHolder &g, unordered_map<NFAVertex, u32> ®ions,
|
||||
}
|
||||
|
||||
static
|
||||
bool doTreePlanningIntl(NGHolder &g,
|
||||
bool doTreePlanningIntl(const NGHolder &g,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
const map<u32, region_info> &info,
|
||||
map<u32, region_info>::const_iterator picked, u32 bad_region,
|
||||
@@ -1855,7 +1855,7 @@ bool doSomRevNfa(NG &ng, NGHolder &g, const CompileContext &cc) {
|
||||
}
|
||||
|
||||
static
|
||||
u32 doSomRevNfaPrefix(NG &ng, const ExpressionInfo &expr, NGHolder &g,
|
||||
u32 doSomRevNfaPrefix(NG &ng, const ExpressionInfo &expr, const NGHolder &g,
|
||||
const CompileContext &cc) {
|
||||
depth maxWidth = findMaxWidth(g);
|
||||
|
||||
@@ -2011,7 +2011,7 @@ void setReportOnHaigPrefix(RoseBuild &rose, NGHolder &h) {
|
||||
}
|
||||
|
||||
static
|
||||
bool tryHaig(RoseBuild &rose, NGHolder &g,
|
||||
bool tryHaig(RoseBuild &rose, const NGHolder &g,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
som_type som, u32 somPrecision,
|
||||
map<u32, region_info>::const_iterator picked,
|
||||
@@ -2442,7 +2442,7 @@ void makeReportsSomPass(ReportManager &rm, NGHolder &g) {
|
||||
}
|
||||
|
||||
static
|
||||
bool doLitHaigSom(NG &ng, NGHolder &g, som_type som) {
|
||||
bool doLitHaigSom(NG &ng, const NGHolder &g, som_type som) {
|
||||
ue2_literal lit;
|
||||
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
|
||||
if (!rhs) {
|
||||
@@ -2659,7 +2659,7 @@ bool doHaigLitHaigSom(NG &ng, NGHolder &g,
|
||||
}
|
||||
|
||||
static
|
||||
bool doMultiLitHaigSom(NG &ng, NGHolder &g, som_type som) {
|
||||
bool doMultiLitHaigSom(NG &ng, const NGHolder &g, som_type som) {
|
||||
set<ue2_literal> lits;
|
||||
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
|
||||
if (!ng.cc.grey.allowLitHaig) {
|
||||
|
||||
@@ -112,7 +112,7 @@ bool forkVertex(NFAVertex v, NGHolder &g, vector<DepthMinMax> &depths,
|
||||
}
|
||||
*numNewVertices += predGroups.size();
|
||||
|
||||
for (auto &group : predGroups) {
|
||||
for (const auto &group : predGroups) {
|
||||
const depth &predDepth = group.first;
|
||||
const vector<NFAEdge> &preds = group.second;
|
||||
|
||||
|
||||
@@ -454,8 +454,8 @@ void buildNfaMergeQueue(const vector<NGHolder *> &cluster,
|
||||
}
|
||||
}
|
||||
|
||||
NGHolder &g_i = *(cluster[ci]);
|
||||
NGHolder &g_j = *(cluster[cj]);
|
||||
const NGHolder &g_i = *(cluster[ci]);
|
||||
const NGHolder &g_j = *(cluster[cj]);
|
||||
|
||||
if (!compatibleStarts(g_i, g_j)) {
|
||||
continue;
|
||||
|
||||
@@ -688,7 +688,7 @@ unique_ptr<VertLitInfo> findBestSplit(const NGHolder &g,
|
||||
}
|
||||
|
||||
if (seeking_transient) {
|
||||
for (auto &a : lits) {
|
||||
for (const auto &a : lits) {
|
||||
a->creates_transient
|
||||
= createsTransientLHS(g, a->vv, *depths, cc.grey);
|
||||
}
|
||||
@@ -697,7 +697,7 @@ unique_ptr<VertLitInfo> findBestSplit(const NGHolder &g,
|
||||
if (last_chance) {
|
||||
const size_t num_verts = num_vertices(g);
|
||||
auto color_map = make_small_color_map(g);
|
||||
for (auto &a : lits) {
|
||||
for (const auto &a : lits) {
|
||||
size_t num_reachable = count_reachable(g, a->vv, color_map);
|
||||
double ratio = (double)num_reachable / (double)num_verts;
|
||||
a->split_ratio = ratio > 0.5 ? 1 - ratio : ratio;
|
||||
@@ -1172,7 +1172,7 @@ bool splitRoseEdge(const NGHolder &base_graph, RoseInGraph &vg,
|
||||
#define MAX_LEN_2_LITERALS_PER_CUT 3
|
||||
|
||||
static
|
||||
bool checkValidNetflowLits(NGHolder &h, const vector<u64a> &scores,
|
||||
bool checkValidNetflowLits(const NGHolder &h, const vector<u64a> &scores,
|
||||
const map<NFAEdge, set<ue2_literal>> &cut_lits,
|
||||
u32 min_allowed_length) {
|
||||
DEBUG_PRINTF("cut width %zu; min allowed %u\n", cut_lits.size(),
|
||||
@@ -1209,7 +1209,7 @@ bool checkValidNetflowLits(NGHolder &h, const vector<u64a> &scores,
|
||||
}
|
||||
|
||||
static
|
||||
void splitEdgesByCut(NGHolder &h, RoseInGraph &vg,
|
||||
void splitEdgesByCut(const NGHolder &h, RoseInGraph &vg,
|
||||
const vector<RoseInEdge> &to_cut,
|
||||
const vector<NFAEdge> &cut,
|
||||
const map<NFAEdge, set<ue2_literal>> &cut_lits) {
|
||||
@@ -1805,7 +1805,7 @@ void removeRedundantLiterals(RoseInGraph &g, const CompileContext &cc) {
|
||||
}
|
||||
|
||||
static
|
||||
RoseInVertex getStart(RoseInGraph &vg) {
|
||||
RoseInVertex getStart(const RoseInGraph &vg) {
|
||||
for (RoseInVertex v : vertices_range(vg)) {
|
||||
if (vg[v].type == RIV_START || vg[v].type == RIV_ANCHORED_START) {
|
||||
return v;
|
||||
@@ -1870,7 +1870,7 @@ unique_ptr<NGHolder> make_chain(u32 count) {
|
||||
#define SHORT_TRIGGER_LEN 16
|
||||
|
||||
static
|
||||
bool makeTransientFromLongLiteral(NGHolder &h, RoseInGraph &vg,
|
||||
bool makeTransientFromLongLiteral(const NGHolder &h, RoseInGraph &vg,
|
||||
const vector<RoseInEdge> &ee,
|
||||
const CompileContext &cc) {
|
||||
/* check max width and literal lengths to see if possible */
|
||||
@@ -2150,7 +2150,7 @@ void findBetterPrefixes(RoseInGraph &vg, const CompileContext &cc) {
|
||||
#define MAX_EXTRACT_STRONG_LITERAL_GRAPHS 10
|
||||
|
||||
static
|
||||
bool extractStrongLiteral(NGHolder &h, RoseInGraph &vg,
|
||||
bool extractStrongLiteral(const NGHolder &h, RoseInGraph &vg,
|
||||
const vector<RoseInEdge> &ee,
|
||||
const CompileContext &cc) {
|
||||
DEBUG_PRINTF("looking for string literal\n");
|
||||
@@ -2805,7 +2805,7 @@ bool tryForEarlyDfa(const NGHolder &h, const CompileContext &cc) {
|
||||
}
|
||||
|
||||
static
|
||||
vector<vector<CharReach>> getDfaTriggers(RoseInGraph &vg,
|
||||
vector<vector<CharReach>> getDfaTriggers(const RoseInGraph &vg,
|
||||
const vector<RoseInEdge> &edges,
|
||||
bool *single_trigger) {
|
||||
vector<vector<CharReach>> triggers;
|
||||
@@ -2927,7 +2927,7 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
|
||||
vector<RoseInEdge>> edges_by_graph;
|
||||
for (const RoseInEdge &ve : edges_range(vg)) {
|
||||
if (vg[ve].graph && !vg[ve].dfa) {
|
||||
auto &h = vg[ve].graph;
|
||||
const auto &h = vg[ve].graph;
|
||||
edges_by_graph[h].emplace_back(ve);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ void addBase(Position base, vector<PositionInfo> &firsts,
|
||||
}
|
||||
|
||||
static
|
||||
void checkPositions(vector<PositionInfo> &v, const GlushkovBuildState &bs) {
|
||||
void checkPositions(const vector<PositionInfo> &v, const GlushkovBuildState &bs) {
|
||||
const NFABuilder& builder = bs.getBuilder();
|
||||
for (const auto &e : v) {
|
||||
if (builder.isSpecialState(e.pos)) {
|
||||
|
||||
@@ -242,7 +242,7 @@ Position makeNewlineAssertPos(GlushkovBuildState &bs) {
|
||||
static
|
||||
void generateAccepts(GlushkovBuildStateImpl &bs, const PositionInfo &from,
|
||||
vector<PositionInfo> *tolist) {
|
||||
NFABuilder &builder = bs.getBuilder();
|
||||
const NFABuilder &builder = bs.getBuilder();
|
||||
u32 flags = from.flags;
|
||||
|
||||
bool require_eod = flags & POS_FLAG_WIRE_EOD;
|
||||
|
||||
@@ -353,7 +353,7 @@ void createVertices(RoseBuildImpl *tbi,
|
||||
edge_props.minBound, edge_props.maxBound);
|
||||
}
|
||||
|
||||
for (auto &m : created) {
|
||||
for (const auto &m : created) {
|
||||
tbi->ghost[m.second] = g_v;
|
||||
}
|
||||
}
|
||||
@@ -938,7 +938,7 @@ void shift_accepts_to_end(const RoseInGraph &ig,
|
||||
}
|
||||
|
||||
static
|
||||
void populateRoseGraph(RoseBuildImpl *tbi, RoseBuildData &bd) {
|
||||
void populateRoseGraph(RoseBuildImpl *tbi, const RoseBuildData &bd) {
|
||||
const RoseInGraph &ig = bd.ig;
|
||||
|
||||
/* add the pattern in to the main rose graph */
|
||||
|
||||
@@ -674,7 +674,7 @@ buildSuffix(const ReportManager &rm, const SomSlotManager &ssm,
|
||||
}
|
||||
|
||||
assert(suff.graph());
|
||||
NGHolder &holder = *suff.graph();
|
||||
const NGHolder &holder = *suff.graph();
|
||||
assert(holder.kind == NFA_SUFFIX);
|
||||
const bool oneTop = onlyOneTop(holder);
|
||||
bool compress_state = cc.streaming;
|
||||
@@ -1378,7 +1378,7 @@ void updateExclusiveSuffixProperties(const RoseBuildImpl &build,
|
||||
const vector<ExclusiveInfo> &exclusive_info,
|
||||
set<u32> *no_retrigger_queues) {
|
||||
const RoseGraph &g = build.g;
|
||||
for (auto &info : exclusive_info) {
|
||||
for (const auto &info : exclusive_info) {
|
||||
const auto &qi = info.queue;
|
||||
const auto &subengines = info.subengines;
|
||||
bool no_retrigger = true;
|
||||
@@ -1627,11 +1627,11 @@ public:
|
||||
build.rm);
|
||||
}
|
||||
|
||||
bytecode_ptr<NFA> operator()(unique_ptr<NGHolder> &holder) const {
|
||||
bytecode_ptr<NFA> operator()(const unique_ptr<NGHolder> &holder) const {
|
||||
const CompileContext &cc = build.cc;
|
||||
const ReportManager &rm = build.rm;
|
||||
|
||||
NGHolder &h = *holder;
|
||||
const NGHolder &h = *holder;
|
||||
assert(h.kind == NFA_OUTFIX);
|
||||
|
||||
// Build NFA.
|
||||
@@ -1657,7 +1657,7 @@ public:
|
||||
return n;
|
||||
}
|
||||
|
||||
bytecode_ptr<NFA> operator()(UNUSED MpvProto &mpv) const {
|
||||
bytecode_ptr<NFA> operator()(UNUSED const MpvProto &mpv) const {
|
||||
// MPV construction handled separately.
|
||||
assert(mpv.puffettes.empty());
|
||||
return nullptr;
|
||||
@@ -2728,7 +2728,7 @@ void buildLeftInfoTable(const RoseBuildImpl &tbi, build_context &bc,
|
||||
}
|
||||
|
||||
static
|
||||
RoseProgram makeLiteralProgram(const RoseBuildImpl &build, build_context &bc,
|
||||
RoseProgram makeLiteralProgram(const RoseBuildImpl &build, const build_context &bc,
|
||||
ProgramBuild &prog_build, u32 lit_id,
|
||||
const vector<vector<RoseEdge>> &lit_edge_map,
|
||||
bool is_anchored_replay_program) {
|
||||
@@ -2973,7 +2973,7 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
|
||||
pfrag.lit_ids, lit_edge_map);
|
||||
if (pfrag.included_frag_id != INVALID_FRAG_ID &&
|
||||
!lit_prog.empty()) {
|
||||
auto &cfrag = fragments[pfrag.included_frag_id];
|
||||
const auto &cfrag = fragments[pfrag.included_frag_id];
|
||||
assert(pfrag.s.length() >= cfrag.s.length() &&
|
||||
!pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
|
||||
u32 child_offset = cfrag.lit_program_offset;
|
||||
@@ -2992,7 +2992,7 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
|
||||
pfrag.lit_ids);
|
||||
if (pfrag.included_delay_frag_id != INVALID_FRAG_ID &&
|
||||
!rebuild_prog.empty()) {
|
||||
auto &cfrag = fragments[pfrag.included_delay_frag_id];
|
||||
const auto &cfrag = fragments[pfrag.included_delay_frag_id];
|
||||
assert(pfrag.s.length() >= cfrag.s.length() &&
|
||||
!pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
|
||||
u32 child_offset = cfrag.delay_program_offset;
|
||||
@@ -3011,7 +3011,7 @@ void updateLitProtoProgramOffset(vector<LitFragment> &fragments,
|
||||
auto &proto = *litProto.hwlmProto;
|
||||
for (auto &lit : proto.lits) {
|
||||
auto fragId = lit.id;
|
||||
auto &frag = fragments[fragId];
|
||||
const auto &frag = fragments[fragId];
|
||||
if (delay) {
|
||||
DEBUG_PRINTF("delay_program_offset:%u\n",
|
||||
frag.delay_program_offset);
|
||||
|
||||
@@ -118,7 +118,7 @@ bool addPrefixLiterals(NGHolder &h, unordered_set<u32> &tailId,
|
||||
|
||||
for (auto v : adjacent_vertices_range(start, h)) {
|
||||
if (v != h.startDs) {
|
||||
for (auto &t : tails) {
|
||||
for (const auto &t : tails) {
|
||||
add_edge(t, v, h);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ bool addPrefixLiterals(NGHolder &h, unordered_set<u32> &tailId,
|
||||
|
||||
clear_out_edges(start, h);
|
||||
add_edge(h.start, h.start, h);
|
||||
for (auto &t : heads) {
|
||||
for (const auto &t : heads) {
|
||||
add_edge(start, t, h);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ void assignGroupsToLiterals(RoseBuildImpl &build) {
|
||||
// Second pass: the other literals.
|
||||
for (u32 id = 0; id < literals.size(); id++) {
|
||||
const rose_literal_id &lit = literals.at(id);
|
||||
rose_literal_info &info = literal_info[id];
|
||||
const rose_literal_info &info = literal_info[id];
|
||||
|
||||
if (!requires_group_assignment(lit, info)) {
|
||||
continue;
|
||||
|
||||
@@ -1338,7 +1338,7 @@ void chunk(vector<T> in, vector<vector<T>> *out, size_t chunk_size) {
|
||||
}
|
||||
|
||||
static
|
||||
insertion_ordered_map<left_id, vector<RoseVertex>> get_eng_verts(RoseGraph &g) {
|
||||
insertion_ordered_map<left_id, vector<RoseVertex>> get_eng_verts(const RoseGraph &g) {
|
||||
insertion_ordered_map<left_id, vector<RoseVertex>> eng_verts;
|
||||
for (auto v : vertices_range(g)) {
|
||||
const auto &left = g[v].left;
|
||||
@@ -1924,7 +1924,7 @@ void mergeSmallLeftfixes(RoseBuildImpl &tbi) {
|
||||
}
|
||||
|
||||
assert(left.graph());
|
||||
NGHolder &h = *left.graph();
|
||||
const NGHolder &h = *left.graph();
|
||||
|
||||
/* Ensure that kind on the graph is correct */
|
||||
assert(h.kind == (tbi.isRootSuccessor(v) ? NFA_PREFIX : NFA_INFIX));
|
||||
@@ -2024,7 +2024,7 @@ void mergeCastleLeftfixes(RoseBuildImpl &build) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoseGraph &g = build.g;
|
||||
const RoseGraph &g = build.g;
|
||||
|
||||
insertion_ordered_map<left_id, vector<RoseVertex>> eng_verts;
|
||||
|
||||
@@ -2306,7 +2306,7 @@ void mergeOutfixInfo(OutfixInfo &winner, const OutfixInfo &victim) {
|
||||
}
|
||||
|
||||
static
|
||||
map<NGHolder *, NGHolder *> chunkedNfaMerge(RoseBuildImpl &build,
|
||||
map<NGHolder *, NGHolder *> chunkedNfaMerge(const RoseBuildImpl &build,
|
||||
const vector<NGHolder *> &nfas) {
|
||||
map<NGHolder *, NGHolder *> merged;
|
||||
|
||||
|
||||
@@ -1352,8 +1352,8 @@ bool attemptRoseMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a,
|
||||
assert(a != b);
|
||||
|
||||
RoseGraph &g = build.g;
|
||||
LeftEngInfo &a_left = g[a].left;
|
||||
LeftEngInfo &b_left = g[b].left;
|
||||
const LeftEngInfo &a_left = g[a].left;
|
||||
const LeftEngInfo &b_left = g[b].left;
|
||||
|
||||
// Trivial case.
|
||||
if (a_left == b_left) {
|
||||
@@ -1601,7 +1601,7 @@ void diamondMergePass(CandidateSet &candidates, RoseBuildImpl &build,
|
||||
vector<RoseVertex> *dead, bool mergeRoses,
|
||||
RoseAliasingInfo &rai) {
|
||||
DEBUG_PRINTF("begin\n");
|
||||
RoseGraph &g = build.g;
|
||||
const RoseGraph &g = build.g;
|
||||
|
||||
if (candidates.empty()) {
|
||||
return;
|
||||
@@ -1972,7 +1972,7 @@ bool hasNoDiamondSiblings(const RoseGraph &g, RoseVertex v) {
|
||||
* merge.
|
||||
*/
|
||||
static
|
||||
void filterDiamondCandidates(RoseGraph &g, CandidateSet &candidates) {
|
||||
void filterDiamondCandidates(const RoseGraph &g, CandidateSet &candidates) {
|
||||
DEBUG_PRINTF("%zu candidates enter\n", candidates.size());
|
||||
|
||||
vector<RoseVertex> dead;
|
||||
|
||||
@@ -187,7 +187,7 @@ u32 SomSlotManager::getInitialResetSomSlot(const NGHolder &prefix,
|
||||
find_if(reset.entries.begin(), reset.entries.end(),
|
||||
has_prefix_func) != reset.entries.end();
|
||||
|
||||
for (auto &e : reset.entries) {
|
||||
for (const auto &e : reset.entries) {
|
||||
u32 temp = 0;
|
||||
/* we don't need to test against sentinels which are identical to
|
||||
* our current one as races don't matter and we know it clears
|
||||
|
||||
@@ -79,7 +79,7 @@ vector<u32> findCliqueGroup(CliqueGraph &cg) {
|
||||
|
||||
// Choose a vertex from the graph
|
||||
u32 id = g[0];
|
||||
CliqueVertex &n = vertexMap.at(id);
|
||||
const CliqueVertex &n = vertexMap.at(id);
|
||||
clique.emplace_back(id);
|
||||
// Corresponding vertex in the original graph
|
||||
set<u32> subgraphId(g.begin(), g.end());
|
||||
|
||||
Reference in New Issue
Block a user