util: switch from Boost to std::unordered set/map

This commit replaces the ue2::unordered_{set,map} types with their STL
versions, with some new hashing utilities in util/hash.h. The new types
ue2_unordered_set<T> and ue2_unordered_map<Key, T> default to using the
ue2_hasher.

The header util/ue2_containers.h has been removed, and the flat_set/map
containers moved to util/flat_containers.h.
This commit is contained in:
Justin Viiret 2017-07-14 14:59:52 +10:00 committed by Matthew Barr
parent a425bb9b7c
commit 9cf66b6ac9
123 changed files with 1048 additions and 772 deletions

View File

@ -997,6 +997,7 @@ SET (hs_SRCS
src/util/dump_mask.h
src/util/fatbit_build.cpp
src/util/fatbit_build.h
src/util/flat_containers.h
src/util/graph.h
src/util/graph_range.h
src/util/graph_small_color_map.h
@ -1019,7 +1020,6 @@ SET (hs_SRCS
src/util/small_vector.h
src/util/target_info.cpp
src/util/target_info.h
src/util/ue2_containers.h
src/util/ue2_graph.h
src/util/ue2string.cpp
src/util/ue2string.h
@ -1027,6 +1027,7 @@ SET (hs_SRCS
src/util/unicode_def.h
src/util/unicode_set.h
src/util/uniform_ops.h
src/util/unordered.h
src/util/verify_types.h
)

View File

@ -48,7 +48,6 @@
#include "util/math.h"
#include "util/noncopyable.h"
#include "util/target_info.h"
#include "util/ue2_containers.h"
#include "util/ue2string.h"
#include "util/verify_types.h"
@ -64,6 +63,8 @@
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <boost/multi_array.hpp>
@ -459,7 +460,7 @@ bool getMultiEntriesAtPosition(const FDREngineDescription &eng,
const vector<LiteralIndex> &vl,
const vector<hwlmLiteral> &lits,
SuffixPositionInString pos,
std::map<u32, ue2::unordered_set<u32> > &m2) {
map<u32, unordered_set<u32>> &m2) {
assert(eng.bits < 32);
u32 distance = 0;
@ -530,7 +531,7 @@ void FDRCompiler::setupTab() {
SuffixPositionInString pLimit = eng.getBucketWidth(b);
for (SuffixPositionInString pos = 0; pos < pLimit; pos++) {
u32 bit = eng.getSchemeBit(b, pos);
map<u32, ue2::unordered_set<u32>> m2;
map<u32, unordered_set<u32>> m2;
bool done = getMultiEntriesAtPosition(eng, vl, lits, pos, m2);
if (done) {
clearbit(&defaultMask[0], bit);
@ -538,7 +539,7 @@ void FDRCompiler::setupTab() {
}
for (const auto &elem : m2) {
u32 dc = elem.first;
const ue2::unordered_set<u32> &mskSet = elem.second;
const unordered_set<u32> &mskSet = elem.second;
u32 v = ~dc;
do {
u32 b2 = v & dc;

View File

@ -30,7 +30,6 @@
#define FDR_ENGINE_DESCRIPTION_H
#include "engine_description.h"
#include "util/ue2_containers.h"
#include <map>
#include <memory>

View File

@ -49,6 +49,7 @@
#include "util/make_unique.h"
#include "util/noncopyable.h"
#include "util/popcount.h"
#include "util/small_vector.h"
#include "util/target_info.h"
#include "util/verify_types.h"

View File

@ -41,6 +41,7 @@
#include "util/verify_types.h"
#include <sstream>
#include <unordered_set>
#include <vector>
#define PATHS_LIMIT 500
@ -254,7 +255,7 @@ dstate_id_t get_sds_or_proxy(const raw_dfa &raw) {
u16 top_remap = raw.alpha_remap[TOP];
ue2::unordered_set<dstate_id_t> seen;
std::unordered_set<dstate_id_t> seen;
while (true) {
seen.insert(s);
DEBUG_PRINTF("basis %hu\n", s);

View File

@ -44,6 +44,8 @@
#include "util/simd_types.h"
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#ifndef DUMP_SUPPORT

View File

@ -31,7 +31,7 @@
#include "ue2common.h"
#include "util/charreach.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
union AccelAux;

View File

@ -48,11 +48,11 @@
#include "util/compile_context.h"
#include "util/container.h"
#include "util/dump_charclass.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/make_unique.h"
#include "util/multibit_build.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include "util/verify_types.h"
#include "grey.h"
@ -153,7 +153,7 @@ static
void getNeighborInfo(const CliqueGraph &g, vector<u32> &neighbor,
const CliqueVertex &cv, const set<u32> &group) {
u32 id = g[cv].stateId;
ue2::unordered_set<u32> neighborId;
unordered_set<u32> neighborId;
// find neighbors for cv
for (const auto &v : adjacent_vertices_range(cv, g)) {

View File

@ -39,11 +39,12 @@
#include "nfagraph/ng_repeat.h"
#include "util/bytecode_ptr.h"
#include "util/depth.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <map>
#include <memory>
#include <set>
#include <unordered_map>
#include <vector>
struct NFA;
@ -89,7 +90,7 @@ struct CastleProto {
std::map<u32, PureRepeat> repeats;
/** \brief Mapping from report to associated tops. */
ue2::unordered_map<ReportID, flat_set<u32>> report_map;
std::unordered_map<ReportID, flat_set<u32>> report_map;
/**
* \brief Next top id to use. Repeats may be removed without top remapping,
@ -155,7 +156,7 @@ bool is_equal(const CastleProto &c1, const CastleProto &c2);
* of the reports in the given set.
*/
bool requiresDedupe(const CastleProto &proto,
const ue2::flat_set<ReportID> &reports);
const flat_set<ReportID> &reports);
/**
* \brief Build an NGHolder from a CastleProto.

View File

@ -63,9 +63,9 @@
#include "rdfa.h"
#include "ue2common.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/noncopyable.h"
#include "util/partitioned_set.h"
#include "util/ue2_containers.h"
#include <algorithm>
#include <functional>

View File

@ -37,11 +37,11 @@
#include "nfa_internal.h"
#include "util/compile_context.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/make_unique.h"
#include "util/order_check.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include "util/verify_types.h"
#include "ue2common.h"

View File

@ -33,7 +33,7 @@
#include "nfa_kind.h"
#include "ue2common.h"
#include "util/bytecode_ptr.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/order_check.h"
#include <map>

View File

@ -33,9 +33,9 @@
#include "mcclellancompile.h"
#include "ue2common.h"
#include "util/charreach.h"
#include "util/flat_containers.h"
#include "util/noncopyable.h"
#include "util/order_check.h"
#include "util/ue2_containers.h"
#include <map>
#include <memory>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -32,10 +32,10 @@
#include "gough_internal.h"
#include "grey.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/order_check.h"
#include "util/ue2_containers.h"
#include "ue2common.h"
@ -235,7 +235,7 @@ void handle_pending_vertices(GoughSSAVar *def, const GoughGraph &g,
if (contains(aux.containing_v, def)) {
def_v = aux.containing_v.at(def);
}
ue2::unordered_set<GoughVertex> done;
unordered_set<GoughVertex> done;
while (!pending_vertex.empty()) {
GoughVertex current = *pending_vertex.begin();
pending_vertex.erase(current);

View File

@ -53,12 +53,13 @@
#include "util/charreach.h"
#include "util/compile_context.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/graph_small_color_map.h"
#include "util/order_check.h"
#include "util/unordered.h"
#include "util/verify_types.h"
#include "util/ue2_containers.h"
#include <algorithm>
#include <cassert>
@ -97,16 +98,16 @@ struct precalcAccel {
};
struct limex_accel_info {
ue2::unordered_set<NFAVertex> accelerable;
unordered_set<NFAVertex> accelerable;
map<NFAStateSet, precalcAccel> precalc;
ue2::unordered_map<NFAVertex, flat_set<NFAVertex>> friends;
ue2::unordered_map<NFAVertex, AccelScheme> accel_map;
unordered_map<NFAVertex, flat_set<NFAVertex>> friends;
unordered_map<NFAVertex, AccelScheme> accel_map;
};
static
map<NFAVertex, NFAStateSet>
reindexByStateId(const map<NFAVertex, NFAStateSet> &in, const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &state_ids,
const unordered_map<NFAVertex, u32> &state_ids,
const u32 num_states) {
map<NFAVertex, NFAStateSet> out;
@ -138,7 +139,7 @@ reindexByStateId(const map<NFAVertex, NFAStateSet> &in, const NGHolder &g,
struct build_info {
build_info(NGHolder &hi,
const ue2::unordered_map<NFAVertex, u32> &states_in,
const unordered_map<NFAVertex, u32> &states_in,
const vector<BoundedRepeatData> &ri,
const map<NFAVertex, NFAStateSet> &rsmi,
const map<NFAVertex, NFAStateSet> &smi,
@ -161,7 +162,7 @@ struct build_info {
}
NGHolder &h;
const ue2::unordered_map<NFAVertex, u32> &state_ids;
const unordered_map<NFAVertex, u32> &state_ids;
const vector<BoundedRepeatData> &repeats;
// Squash maps; state sets are indexed by state_id.
@ -169,7 +170,7 @@ struct build_info {
map<NFAVertex, NFAStateSet> squashMap;
const map<u32, set<NFAVertex>> &tops;
ue2::unordered_set<NFAVertex> tugs;
unordered_set<NFAVertex> tugs;
map<NFAVertex, BoundedRepeatSummary> br_cyclic;
const set<NFAVertex> &zombies;
bool do_accel;
@ -479,7 +480,7 @@ bool allow_wide_accel(const vector<NFAVertex> &vv, const NGHolder &g,
static
void nfaFindAccelSchemes(const NGHolder &g,
const map<NFAVertex, BoundedRepeatSummary> &br_cyclic,
ue2::unordered_map<NFAVertex, AccelScheme> *out) {
unordered_map<NFAVertex, AccelScheme> *out) {
vector<CharReach> refined_cr = reduced_cr(g, br_cyclic);
NFAVertex sds_or_proxy = get_sds_or_proxy(g);
@ -504,8 +505,8 @@ void nfaFindAccelSchemes(const NGHolder &g,
}
struct fas_visitor : public boost::default_bfs_visitor {
fas_visitor(const ue2::unordered_map<NFAVertex, AccelScheme> &am_in,
ue2::unordered_map<NFAVertex, AccelScheme> *out_in)
fas_visitor(const unordered_map<NFAVertex, AccelScheme> &am_in,
unordered_map<NFAVertex, AccelScheme> *out_in)
: accel_map(am_in), out(out_in) {}
void discover_vertex(NFAVertex v, const NGHolder &) {
@ -516,13 +517,13 @@ struct fas_visitor : public boost::default_bfs_visitor {
throw this; /* done */
}
}
const ue2::unordered_map<NFAVertex, AccelScheme> &accel_map;
ue2::unordered_map<NFAVertex, AccelScheme> *out;
const unordered_map<NFAVertex, AccelScheme> &accel_map;
unordered_map<NFAVertex, AccelScheme> *out;
};
static
void filterAccelStates(NGHolder &g, const map<u32, set<NFAVertex>> &tops,
ue2::unordered_map<NFAVertex, AccelScheme> *accel_map) {
unordered_map<NFAVertex, AccelScheme> *accel_map) {
/* We want the NFA_MAX_ACCEL_STATES best acceleration states, everything
* else should be ditched. We use a simple BFS to choose accel states near
* the start. */
@ -542,7 +543,7 @@ void filterAccelStates(NGHolder &g, const map<u32, set<NFAVertex>> &tops,
tempEdges.push_back(e); // Remove edge later.
}
ue2::unordered_map<NFAVertex, AccelScheme> out;
unordered_map<NFAVertex, AccelScheme> out;
try {
boost::breadth_first_search(g, g.start,
@ -982,16 +983,18 @@ u32 addSquashMask(const build_info &args, const NFAVertex &v,
return idx;
}
using ReportListCache = ue2_unordered_map<vector<ReportID>, u32>;
static
u32 addReports(const flat_set<ReportID> &r, vector<ReportID> &reports,
unordered_map<vector<ReportID>, u32> &reportListCache) {
ReportListCache &reports_cache) {
assert(!r.empty());
vector<ReportID> my_reports(begin(r), end(r));
my_reports.push_back(MO_INVALID_IDX); // sentinel
auto cache_it = reportListCache.find(my_reports);
if (cache_it != end(reportListCache)) {
auto cache_it = reports_cache.find(my_reports);
if (cache_it != end(reports_cache)) {
u32 offset = cache_it->second;
DEBUG_PRINTF("reusing cached report list at %u\n", offset);
return offset;
@ -1007,13 +1010,12 @@ u32 addReports(const flat_set<ReportID> &r, vector<ReportID> &reports,
u32 offset = verify_u32(reports.size());
insert(&reports, reports.end(), my_reports);
reportListCache.emplace(move(my_reports), offset);
reports_cache.emplace(move(my_reports), offset);
return offset;
}
static
void buildAcceptsList(const build_info &args,
unordered_map<vector<ReportID>, u32> &reports_cache,
void buildAcceptsList(const build_info &args, ReportListCache &reports_cache,
vector<NFAVertex> &verts, vector<NFAAccept> &accepts,
vector<ReportID> &reports, vector<NFAStateSet> &squash) {
if (verts.empty()) {
@ -1051,8 +1053,7 @@ void buildAcceptsList(const build_info &args,
}
static
void buildAccepts(const build_info &args,
unordered_map<vector<ReportID>, u32> &reports_cache,
void buildAccepts(const build_info &args, ReportListCache &reports_cache,
NFAStateSet &acceptMask, NFAStateSet &acceptEodMask,
vector<NFAAccept> &accepts, vector<NFAAccept> &acceptsEod,
vector<ReportID> &reports, vector<NFAStateSet> &squash) {
@ -1119,7 +1120,7 @@ u32 uncompressedStateSize(u32 num_states) {
static
u32 compressedStateSize(const NGHolder &h, const NFAStateSet &maskedStates,
const ue2::unordered_map<NFAVertex, u32> &state_ids) {
const unordered_map<NFAVertex, u32> &state_ids) {
// Shrink state requirement to enough to fit the compressed largest reach.
vector<u32> allreach(N_CHARS, 0);
@ -1190,7 +1191,7 @@ bool hasSquashableInitDs(const build_info &args) {
static
bool hasInitDsStates(const NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &state_ids) {
const unordered_map<NFAVertex, u32> &state_ids) {
if (state_ids.at(h.startDs) != NO_STATE) {
return true;
}
@ -1358,17 +1359,16 @@ struct ExceptionProto {
};
static
u32 buildExceptionMap(const build_info &args,
unordered_map<vector<ReportID>, u32> &reports_cache,
const ue2::unordered_set<NFAEdge> &exceptional,
u32 buildExceptionMap(const build_info &args, ReportListCache &reports_cache,
const unordered_set<NFAEdge> &exceptional,
map<ExceptionProto, vector<u32>> &exceptionMap,
vector<ReportID> &reportList) {
const NGHolder &h = args.h;
const u32 num_states = args.num_states;
u32 exceptionCount = 0;
ue2::unordered_map<NFAVertex, u32> pos_trigger;
ue2::unordered_map<NFAVertex, u32> tug_trigger;
unordered_map<NFAVertex, u32> pos_trigger;
unordered_map<NFAVertex, u32> tug_trigger;
for (u32 i = 0; i < args.repeats.size(); i++) {
const BoundedRepeatData &br = args.repeats[i];
@ -1893,7 +1893,7 @@ struct Factory {
static
void findExceptionalTransitions(const build_info &args,
ue2::unordered_set<NFAEdge> &exceptional,
unordered_set<NFAEdge> &exceptional,
u32 maxShift) {
const NGHolder &h = args.h;
@ -2168,9 +2168,9 @@ struct Factory {
// We track report lists that have already been written into the global
// list in case we can reuse them.
unordered_map<vector<ReportID>, u32> reports_cache;
ReportListCache reports_cache;
ue2::unordered_set<NFAEdge> exceptional;
unordered_set<NFAEdge> exceptional;
u32 shiftCount = findBestNumOfVarShifts(args);
assert(shiftCount);
u32 maxShift = findMaxVarShift(args, shiftCount);
@ -2374,10 +2374,10 @@ MAKE_LIMEX_TRAITS(512)
// Some sanity tests, called by an assertion in generate().
static UNUSED
bool isSane(const NGHolder &h, const map<u32, set<NFAVertex>> &tops,
const ue2::unordered_map<NFAVertex, u32> &state_ids,
const unordered_map<NFAVertex, u32> &state_ids,
u32 num_states) {
ue2::unordered_set<u32> seen;
ue2::unordered_set<NFAVertex> top_starts;
unordered_set<u32> seen;
unordered_set<NFAVertex> top_starts;
for (const auto &vv : tops | map_values) {
insert(&top_starts, vv);
}
@ -2424,7 +2424,7 @@ bool isSane(const NGHolder &h, const map<u32, set<NFAVertex>> &tops,
#endif // NDEBUG
static
u32 max_state(const ue2::unordered_map<NFAVertex, u32> &state_ids) {
u32 max_state(const unordered_map<NFAVertex, u32> &state_ids) {
u32 rv = 0;
for (const auto &m : state_ids) {
DEBUG_PRINTF("state %u\n", m.second);
@ -2437,7 +2437,7 @@ u32 max_state(const ue2::unordered_map<NFAVertex, u32> &state_ids) {
}
bytecode_ptr<NFA> generate(NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &states,
const unordered_map<NFAVertex, u32> &states,
const vector<BoundedRepeatData> &repeats,
const map<NFAVertex, NFAStateSet> &reportSquashMap,
const map<NFAVertex, NFAStateSet> &squashMap,
@ -2507,7 +2507,7 @@ bytecode_ptr<NFA> generate(NGHolder &h,
}
u32 countAccelStates(NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &states,
const unordered_map<NFAVertex, u32> &states,
const vector<BoundedRepeatData> &repeats,
const map<NFAVertex, NFAStateSet> &reportSquashMap,
const map<NFAVertex, NFAStateSet> &squashMap,

View File

@ -34,15 +34,16 @@
#ifndef LIMEX_COMPILE_H
#define LIMEX_COMPILE_H
#include <map>
#include <memory>
#include <vector>
#include "nfagraph/ng_holder.h"
#include "nfagraph/ng_squash.h" // for NFAStateSet
#include "ue2common.h"
#include "util/bytecode_ptr.h"
#include "util/ue2_containers.h"
#include <set>
#include <map>
#include <memory>
#include <unordered_map>
#include <vector>
struct NFA;
@ -69,7 +70,7 @@ struct CompileContext;
* graph.
*/
bytecode_ptr<NFA> generate(NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &states,
const std::unordered_map<NFAVertex, u32> &states,
const std::vector<BoundedRepeatData> &repeats,
const std::map<NFAVertex, NFAStateSet> &reportSquashMap,
const std::map<NFAVertex, NFAStateSet> &squashMap,
@ -87,7 +88,7 @@ bytecode_ptr<NFA> generate(NGHolder &g,
* implementable.
*/
u32 countAccelStates(NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &states,
const std::unordered_map<NFAVertex, u32> &states,
const std::vector<BoundedRepeatData> &repeats,
const std::map<NFAVertex, NFAStateSet> &reportSquashMap,
const std::map<NFAVertex, NFAStateSet> &squashMap,

View File

@ -46,7 +46,7 @@
#include "util/make_unique.h"
#include "util/order_check.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/unaligned.h"
#include "util/verify_types.h"

View File

@ -33,7 +33,6 @@
#include "rdfa.h"
#include "ue2common.h"
#include "util/bytecode_ptr.h"
#include "util/ue2_containers.h"
#include <memory>
#include <vector>

View File

@ -30,12 +30,11 @@
#include "rdfa.h"
#include "util/container.h"
#include "util/ue2_containers.h"
#include "util/hash.h"
#include "ue2common.h"
#include <deque>
#include <boost/functional/hash/hash.hpp>
#include <map>
using namespace std;
@ -232,22 +231,18 @@ bool has_non_eod_accepts(const raw_dfa &rdfa) {
}
size_t hash_dfa_no_reports(const raw_dfa &rdfa) {
using boost::hash_combine;
using boost::hash_range;
size_t v = 0;
hash_combine(v, rdfa.alpha_size);
hash_combine(v, hash_range(begin(rdfa.alpha_remap), end(rdfa.alpha_remap)));
hash_combine(v, rdfa.alpha_remap);
for (const auto &ds : rdfa.states) {
hash_combine(v, hash_range(begin(ds.next), end(ds.next)));
hash_combine(v, ds.next);
}
return v;
}
size_t hash_dfa(const raw_dfa &rdfa) {
using boost::hash_combine;
size_t v = 0;
hash_combine(v, hash_dfa_no_reports(rdfa));
hash_combine(v, all_reports(rdfa));

View File

@ -45,13 +45,14 @@
#include "util/compare.h"
#include "util/compile_context.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/make_unique.h"
#include "util/order_check.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include "util/unaligned.h"
#include "util/unordered.h"
#include "util/verify_types.h"
#include <algorithm>
@ -383,6 +384,8 @@ CharReach get_edge_reach(dstate_id_t u, dstate_id_t v, const dfa_info &info) {
#define MAX_SHENG_STATES 16
#define MAX_SHENG_LEAKINESS 0.05
using LeakinessCache = ue2_unordered_map<pair<RdfaVertex, u32>, double>;
/**
* Returns the proportion of strings of length 'depth' which will leave the
* sheng region when starting at state 'u'.
@ -390,8 +393,7 @@ CharReach get_edge_reach(dstate_id_t u, dstate_id_t v, const dfa_info &info) {
static
double leakiness(const RdfaGraph &g, dfa_info &info,
const flat_set<RdfaVertex> &sheng_states, RdfaVertex u,
u32 depth,
unordered_map<pair<RdfaVertex, u32>, double> &cache) {
u32 depth, LeakinessCache &cache) {
double rv = 0;
if (contains(cache, make_pair(u, depth))) {
return cache[make_pair(u, depth)];
@ -426,7 +428,7 @@ double leakiness(const RdfaGraph &g, dfa_info &info,
static
double leakiness(const RdfaGraph &g, dfa_info &info,
const flat_set<RdfaVertex> &sheng_states, RdfaVertex u) {
unordered_map<pair<RdfaVertex, u32>, double> cache;
LeakinessCache cache;
double rv = leakiness(g, info, sheng_states, u, 8, cache);
return rv;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -32,7 +32,7 @@
#include "nfa_kind.h"
#include "ue2common.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <array>
#include <vector>

View File

@ -36,9 +36,10 @@
#include "nfagraph/ng_mcclellan_internal.h"
#include "util/container.h"
#include "util/determinise.h"
#include "util/flat_containers.h"
#include "util/make_unique.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include "util/unordered.h"
#include <algorithm>
#include <queue>
@ -54,7 +55,7 @@ namespace {
class Automaton_Merge {
public:
using StateSet = vector<u16>;
using StateMap = unordered_map<StateSet, dstate_id_t>;
using StateMap = ue2_unordered_map<StateSet, dstate_id_t>;
Automaton_Merge(const raw_dfa *rdfa1, const raw_dfa *rdfa2,
const ReportManager *rm_in, const Grey &grey_in)

View File

@ -33,7 +33,10 @@
#include "rdfa.h"
#include "util/bytecode_ptr.h"
#include "util/charreach.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <memory>
#include <set>
struct NFA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -33,7 +33,7 @@
#include "ue2common.h"
#include "util/charreach.h"
#include "util/container.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <array>
#include <cassert>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -35,7 +35,7 @@
#include "ue2common.h"
#include "util/charreach.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <utility>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -32,12 +32,15 @@
* truffle is always able to represent an entire character class, providing a
* backstop to other acceleration engines.
*/
#include "trufflecompile.h"
#include "ue2common.h"
#include "util/charreach.h"
#include "util/dump_mask.h"
#include "util/simd_types.h"
#include "util/dump_mask.h"
#include <cstring>
using namespace std;

View File

@ -44,7 +44,6 @@
#include "util/graph.h"
#include "util/noncopyable.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include <deque>
#include <map>

View File

@ -310,11 +310,11 @@ void splitIntoComponents(unique_ptr<NGHolder> g,
return;
}
ue2::unordered_map<NFAVertex, NFAUndirectedVertex> old2new;
unordered_map<NFAVertex, NFAUndirectedVertex> old2new;
auto ug = createUnGraph(*g, true, true, old2new);
// Construct reverse mapping.
ue2::unordered_map<NFAUndirectedVertex, NFAVertex> new2old;
unordered_map<NFAUndirectedVertex, NFAVertex> new2old;
for (const auto &m : old2new) {
new2old.emplace(m.second, m.first);
}
@ -356,7 +356,7 @@ void splitIntoComponents(unique_ptr<NGHolder> g,
DEBUG_PRINTF("vertex %zu is in comp %u\n", (*g)[v].index, c);
}
ue2::unordered_map<NFAVertex, NFAVertex> v_map; // temp map for fillHolder
unordered_map<NFAVertex, NFAVertex> v_map; // temp map for fillHolder
for (auto &vv : verts) {
// Shells are in every component.
vv.insert(vv.end(), begin(head_shell), end(head_shell));

View File

@ -62,9 +62,9 @@
#include "ng_prune.h"
#include "ng_util.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/graph_small_color_map.h"
#include "util/ue2_containers.h"
#include <algorithm>
#include <boost/graph/depth_first_search.hpp>

View File

@ -36,7 +36,6 @@
#include "ue2common.h"
#include "ng_holder.h"
#include "ng_util.h"
#include "util/ue2_containers.h"
#include <boost-patched/graph/dominator_tree.hpp> // locally patched version
#include <boost-patched/graph/reverse_graph.hpp>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -36,15 +36,14 @@
#define NG_DOMINATORS_H
#include "ng_holder.h"
#include "util/ue2_containers.h"
#include <unordered_map>
namespace ue2 {
class NGHolder;
std::unordered_map<NFAVertex, NFAVertex> findDominators(const NGHolder &g);
ue2::unordered_map<NFAVertex, NFAVertex> findDominators(const NGHolder &g);
ue2::unordered_map<NFAVertex, NFAVertex> findPostDominators(const NGHolder &g);
std::unordered_map<NFAVertex, NFAVertex> findPostDominators(const NGHolder &g);
} // namespace ue2

View File

@ -176,7 +176,7 @@ public:
: g(g_in), rm(&rm_in) {}
NFAWriter(const GraphT &g_in,
const ue2::unordered_map<NFAVertex, u32> &region_map_in)
const unordered_map<NFAVertex, u32> &region_map_in)
: g(g_in), region_map(&region_map_in) {}
void operator()(ostream& os, const VertexT& v) const {
@ -254,7 +254,7 @@ public:
private:
const GraphT &g;
const ReportManager *rm = nullptr;
const ue2::unordered_map<NFAVertex, u32> *region_map = nullptr;
const unordered_map<NFAVertex, u32> *region_map = nullptr;
};
}
@ -278,7 +278,7 @@ void dumpGraphImpl(const char *name, const GraphT &g, const ReportManager &rm) {
template <typename GraphT>
void dumpGraphImpl(const char *name, const GraphT &g,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const unordered_map<NFAVertex, u32> &region_map) {
typedef typename boost::graph_traits<GraphT>::vertex_descriptor VertexT;
typedef typename boost::graph_traits<GraphT>::edge_descriptor EdgeT;
ofstream os(name);
@ -332,7 +332,7 @@ void dumpHolderImpl(const NGHolder &h, unsigned int stageNumber,
}
void dumpHolderImpl(const NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
unsigned int stageNumber, const char *stageName,
const Grey &grey) {
if (grey.dumpFlags & Grey::DUMP_INT_GRAPH) {

View File

@ -36,7 +36,8 @@
#include "grey.h"
#include "ng_holder.h" // for graph types
#include "ue2common.h"
#include "util/ue2_containers.h"
#include <unordered_map>
#ifdef DUMP_SUPPORT
#include <fstream>
@ -75,7 +76,7 @@ void dumpHolderImpl(const NGHolder &h, unsigned int stageNumber,
// Variant that takes a region map as well.
void dumpHolderImpl(const NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const std::unordered_map<NFAVertex, u32> &region_map,
unsigned int stageNumber, const char *stageName,
const Grey &grey);
@ -123,7 +124,7 @@ void dumpHolder(UNUSED const NGHolder &h, UNUSED unsigned int stageNumber,
UNUSED static inline
void dumpHolder(UNUSED const NGHolder &h,
UNUSED const ue2::unordered_map<NFAVertex, u32> &region_map,
UNUSED const std::unordered_map<NFAVertex, u32> &region_map,
UNUSED unsigned int stageNumber, UNUSED const char *name,
UNUSED const Grey &grey) {
#ifdef DUMP_SUPPORT

View File

@ -38,8 +38,8 @@
#include "parser/position.h"
#include "util/compile_context.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include <set>
#include <vector>

View File

@ -37,9 +37,10 @@
#include "ng_holder.h"
#include "ng_util.h"
#include "util/compile_context.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/make_unique.h"
#include "util/ue2_containers.h"
#include "util/unordered.h"
#include <algorithm>
#include <memory>
@ -121,16 +122,9 @@ public:
vertex_flags == b.vertex_flags && rs == b.rs;
}
friend size_t hash_value(const ClassInfo &c) {
size_t val = 0;
boost::hash_combine(val, c.rs);
boost::hash_combine(val, c.vertex_flags);
boost::hash_combine(val, c.cr);
boost::hash_combine(val, c.adjacent_cr);
boost::hash_combine(val, c.node_type);
boost::hash_combine(val, c.depth.d1);
boost::hash_combine(val, c.depth.d2);
return val;
size_t hash() const {
return hash_all(rs, vertex_flags, cr, adjacent_cr, node_type, depth.d1,
depth.d2);
}
private:
@ -319,7 +313,7 @@ vector<VertexInfoSet> partitionGraph(vector<unique_ptr<VertexInfo>> &infos,
const size_t num_verts = infos.size();
vector<VertexInfoSet> classes;
unordered_map<ClassInfo, unsigned> classinfomap;
ue2_unordered_map<ClassInfo, unsigned> classinfomap;
// assume we will have lots of classes, so we don't waste time resizing
// these structures.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -35,7 +35,7 @@
#define NG_EXECUTE_H
#include "ng_holder.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <vector>

View File

@ -40,11 +40,12 @@
#include "util/bitfield.h"
#include "util/container.h"
#include "util/determinise.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/hash_dynamic_bitset.h"
#include "util/make_unique.h"
#include "util/ue2_containers.h"
#include "util/unordered.h"
#include <algorithm>
#include <functional>
@ -258,7 +259,7 @@ public:
struct Graph_Traits {
using StateSet = bitfield<NFA_STATE_LIMIT>;
using StateMap = ue2::unordered_map<StateSet, dstate_id_t>;
using StateMap = unordered_map<StateSet, dstate_id_t>;
static StateSet init_states(UNUSED u32 num) {
assert(num <= NFA_STATE_LIMIT);
@ -286,7 +287,7 @@ public:
class Automaton_Haig_Merge {
public:
using StateSet = vector<u16>;
using StateMap = unordered_map<StateSet, dstate_id_t>;
using StateMap = ue2_unordered_map<StateSet, dstate_id_t>;
explicit Automaton_Haig_Merge(const vector<const raw_som_dfa *> &in)
: nfas(in.begin(), in.end()), dead(in.size()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -40,7 +40,7 @@
#include "ue2common.h"
#include "nfa/nfa_kind.h"
#include "util/charreach.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/ue2_graph.h"
namespace ue2 {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -39,13 +39,9 @@
#include "ng_util.h"
#include "ue2common.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/make_unique.h"
#include "util/ue2_containers.h"
#include <set>
#include <boost/functional/hash/hash.hpp>
using namespace std;
@ -200,11 +196,11 @@ u64a hash_holder(const NGHolder &g) {
size_t rv = 0;
for (auto v : vertices_range(g)) {
boost::hash_combine(rv, g[v].index);
boost::hash_combine(rv, g[v].char_reach);
hash_combine(rv, g[v].index);
hash_combine(rv, g[v].char_reach);
for (auto w : adjacent_vertices_range(v, g)) {
boost::hash_combine(rv, g[w].index);
hash_combine(rv, g[w].index);
}
}

View File

@ -53,11 +53,13 @@
#include "util/container.h"
#include "util/graph_range.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/verify_types.h"
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <boost/range/adaptor/map.hpp>
@ -73,8 +75,8 @@ namespace ue2 {
// Only used in assertions.
static
bool sanityCheckGraph(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &state_ids) {
ue2::unordered_set<u32> seen_states;
const unordered_map<NFAVertex, u32> &state_ids) {
unordered_set<u32> seen_states;
for (auto v : vertices_range(g)) {
// Non-specials should have non-empty reachability.
@ -468,7 +470,7 @@ void makeTopStates(NGHolder &g, map<u32, set<NFAVertex>> &tops_out,
static
set<NFAVertex> findZombies(const NGHolder &h,
const map<NFAVertex, BoundedRepeatSummary> &br_cyclic,
const ue2::unordered_map<NFAVertex, u32> &state_ids,
const unordered_map<NFAVertex, u32> &state_ids,
const CompileContext &cc) {
set<NFAVertex> zombies;
if (!cc.grey.allowZombies) {
@ -516,7 +518,7 @@ set<NFAVertex> findZombies(const NGHolder &h,
}
static
void reverseStateOrdering(ue2::unordered_map<NFAVertex, u32> &state_ids) {
void reverseStateOrdering(unordered_map<NFAVertex, u32> &state_ids) {
vector<NFAVertex> ordering;
for (auto &e : state_ids) {
if (e.second == NO_STATE) {
@ -569,7 +571,7 @@ prepareGraph(const NGHolder &h_in, const ReportManager *rm,
const map<u32, u32> &fixed_depth_tops,
const map<u32, vector<vector<CharReach>>> &triggers,
bool impl_test_only, const CompileContext &cc,
ue2::unordered_map<NFAVertex, u32> &state_ids,
unordered_map<NFAVertex, u32> &state_ids,
vector<BoundedRepeatData> &repeats,
map<u32, set<NFAVertex>> &tops) {
assert(is_triggered(h_in) || fixed_depth_tops.empty());
@ -637,7 +639,7 @@ constructNFA(const NGHolder &h_in, const ReportManager *rm,
assert(rm);
}
ue2::unordered_map<NFAVertex, u32> state_ids;
unordered_map<NFAVertex, u32> state_ids;
vector<BoundedRepeatData> repeats;
map<u32, set<NFAVertex>> tops;
unique_ptr<NGHolder> h
@ -785,7 +787,7 @@ u32 isImplementableNFA(const NGHolder &g, const ReportManager *rm,
* resultant NGHolder has <= NFA_MAX_STATES. If it does, we know we can
* implement it as an NFA. */
ue2::unordered_map<NFAVertex, u32> state_ids;
unordered_map<NFAVertex, u32> state_ids;
vector<BoundedRepeatData> repeats;
map<u32, set<NFAVertex>> tops;
unique_ptr<NGHolder> h
@ -832,7 +834,7 @@ u32 countAccelStates(const NGHolder &g, const ReportManager *rm,
const map<u32, u32> fixed_depth_tops; // empty
const map<u32, vector<vector<CharReach>>> triggers; // empty
ue2::unordered_map<NFAVertex, u32> state_ids;
unordered_map<NFAVertex, u32> state_ids;
vector<BoundedRepeatData> repeats;
map<u32, set<NFAVertex>> tops;
unique_ptr<NGHolder> h

View File

@ -39,8 +39,8 @@
#include "nfa/accelcompile.h"
#include "util/accel_scheme.h"
#include "util/charreach.h"
#include "util/flat_containers.h"
#include "util/order_check.h"
#include "util/ue2_containers.h"
#include <map>
#include <vector>

View File

@ -811,7 +811,7 @@ bool splitOffLeadingLiteral(const NGHolder &g, ue2_literal *lit_out,
}
assert(u != g.startDs);
ue2::unordered_map<NFAVertex, NFAVertex> rhs_map;
unordered_map<NFAVertex, NFAVertex> rhs_map;
vector<NFAVertex> pivots = make_vector_from(adjacent_vertices(u, g));
splitRHS(g, pivots, rhs, &rhs_map);

View File

@ -45,6 +45,8 @@
#include "util/graph_range.h"
#include "util/ue2string.h"
#include <unordered_set>
using namespace std;
namespace ue2 {
@ -196,7 +198,7 @@ bool splitOffLiterals(NG &ng, NGHolder &g) {
bool changed = false;
set<NFAVertex> dead;
ue2::unordered_set<NFAVertex> unanchored; // for faster lookup.
unordered_set<NFAVertex> unanchored; // for faster lookup.
insert(&unanchored, adjacent_vertices(g.startDs, g));
// Anchored literals.

View File

@ -41,17 +41,18 @@
#include "ue2common.h"
#include "util/bitfield.h"
#include "util/determinise.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/hash.h"
#include "util/hash_dynamic_bitset.h"
#include "util/make_unique.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <vector>
#include <boost/dynamic_bitset.hpp>
@ -483,7 +484,7 @@ public:
struct Graph_Traits {
using StateSet = bitfield<NFA_STATE_LIMIT>;
using StateMap = ue2::unordered_map<StateSet, dstate_id_t>;
using StateMap = unordered_map<StateSet, dstate_id_t>;
static StateSet init_states(UNUSED u32 num) {
assert(num <= NFA_STATE_LIMIT);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -38,7 +38,7 @@
#include "nfagraph/ng_holder.h"
#include "util/charreach.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <boost/dynamic_bitset.hpp>

View File

@ -70,7 +70,7 @@
#include "util/container.h"
#include "util/graph_range.h"
#include "util/graph_small_color_map.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "ue2common.h"
#include <boost/dynamic_bitset.hpp>

View File

@ -55,10 +55,11 @@
#include "util/compile_context.h"
#include "util/container.h"
#include "util/dump_charclass.h"
#include "util/ue2_containers.h"
#include "util/graph_range.h"
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/adaptor/map.hpp>
@ -127,10 +128,10 @@ struct RegionInfoQueueComp {
static
void findWidths(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
RegionInfo &ri) {
NGHolder rg;
ue2::unordered_map<NFAVertex, NFAVertex> mapping;
unordered_map<NFAVertex, NFAVertex> mapping;
fillHolder(&rg, g, ri.vertices, &mapping);
// Wire our entries to start and our exits to accept.
@ -155,7 +156,7 @@ void findWidths(const NGHolder &g,
// acc can be either h.accept or h.acceptEod.
static
void markBoundaryRegions(const NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
map<u32, RegionInfo> &regions, NFAVertex acc) {
for (auto v : inv_adjacent_vertices_range(acc, h)) {
if (is_special(v, h)) {
@ -174,7 +175,7 @@ void markBoundaryRegions(const NGHolder &h,
static
map<u32, RegionInfo> findRegionInfo(const NGHolder &h,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const unordered_map<NFAVertex, u32> &region_map) {
map<u32, RegionInfo> regions;
for (auto v : vertices_range(h)) {
if (is_special(v, h)) {

View File

@ -223,7 +223,7 @@ void pruneHighlanderAccepts(NGHolder &g, const ReportManager &rm) {
static
bool isDominatedByReporter(const NGHolder &g,
const ue2::unordered_map<NFAVertex, NFAVertex> &dom,
const unordered_map<NFAVertex, NFAVertex> &dom,
NFAVertex v, ReportID report_id) {
for (auto it = dom.find(v); it != end(dom); it = dom.find(v)) {
NFAVertex u = it->second;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -78,8 +78,8 @@
#include "ng_util.h"
#include "ue2common.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include <algorithm>
#include <cassert>
@ -747,7 +747,7 @@ u32 findCyclic(const NGHolder &g, vector<bool> &cyclic) {
static
void findCyclicDom(NGHolder &g, vector<bool> &cyclic,
set<NFAEdge> &dead, som_type som) {
ue2::unordered_map<NFAVertex, NFAVertex> dominators = findDominators(g);
auto dominators = findDominators(g);
for (auto v : vertices_range(g)) {
if (is_special(v, g)) {
@ -791,8 +791,7 @@ void findCyclicDom(NGHolder &g, vector<bool> &cyclic,
static
void findCyclicPostDom(NGHolder &g, vector<bool> &cyclic,
set<NFAEdge> &dead) {
ue2::unordered_map<NFAVertex, NFAVertex> postdominators =
findPostDominators(g);
auto postdominators = findPostDominators(g);
for (auto v : vertices_range(g)) {
if (is_special(v, g)) {

View File

@ -56,7 +56,7 @@
#include "ng_util.h"
#include "ue2common.h"
#include "util/container.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/graph_small_color_map.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -36,19 +36,19 @@
#include "ng_holder.h"
#include "util/container.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include <unordered_map>
#include <vector>
namespace ue2 {
/** \brief Assign a region ID to every vertex in the graph. */
ue2::unordered_map<NFAVertex, u32> assignRegions(const NGHolder &g);
std::unordered_map<NFAVertex, u32> assignRegions(const NGHolder &g);
/** \brief True if vertices \p a and \p b are in the same region. */
template <class Graph>
bool inSameRegion(const Graph &g, NFAVertex a, NFAVertex b,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const std::unordered_map<NFAVertex, u32> &region_map) {
assert(contains(region_map, a) && contains(region_map, b));
return region_map.at(a) == region_map.at(b) &&
@ -58,7 +58,7 @@ bool inSameRegion(const Graph &g, NFAVertex a, NFAVertex b,
/** \brief True if vertex \p b is in a later region than vertex \p a. */
template <class Graph>
bool inLaterRegion(const Graph &g, NFAVertex a, NFAVertex b,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const std::unordered_map<NFAVertex, u32> &region_map) {
assert(contains(region_map, a) && contains(region_map, b));
u32 aa = g[a].index;
@ -85,7 +85,7 @@ bool inLaterRegion(const Graph &g, NFAVertex a, NFAVertex b,
/** \brief True if vertex \p b is in an earlier region than vertex \p a. */
template <class Graph>
bool inEarlierRegion(const Graph &g, NFAVertex a, NFAVertex b,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const std::unordered_map<NFAVertex, u32> &region_map) {
assert(contains(region_map, a) && contains(region_map, b));
u32 aa = g[a].index;
@ -112,7 +112,7 @@ bool inEarlierRegion(const Graph &g, NFAVertex a, NFAVertex b,
/** \brief True if vertex \p v is an entry vertex for its region. */
template <class Graph>
bool isRegionEntry(const Graph &g, NFAVertex v,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const std::unordered_map<NFAVertex, u32> &region_map) {
// Note that some graph types do not have inv_adjacent_vertices, so we must
// use in_edges here.
for (const auto &e : in_edges_range(v, g)) {
@ -127,7 +127,7 @@ bool isRegionEntry(const Graph &g, NFAVertex v,
/** \brief True if vertex \p v is an exit vertex for its region. */
template <class Graph>
bool isRegionExit(const Graph &g, NFAVertex v,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const std::unordered_map<NFAVertex, u32> &region_map) {
for (auto w : adjacent_vertices_range(v, g)) {
if (!inSameRegion(g, v, w, region_map)) {
return true;
@ -140,7 +140,7 @@ bool isRegionExit(const Graph &g, NFAVertex v,
/** \brief True if vertex \p v is in a region all on its own. */
template <class Graph>
bool isSingletonRegion(const Graph &g, NFAVertex v,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const std::unordered_map<NFAVertex, u32> &region_map) {
for (const auto &e : in_edges_range(v, g)) {
auto u = source(e, g);
if (u != v && inSameRegion(g, v, u, region_map)) {
@ -178,7 +178,7 @@ bool isSingletonRegion(const Graph &g, NFAVertex v,
*/
template <class Graph>
bool isOptionalRegion(const Graph &g, NFAVertex v,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const std::unordered_map<NFAVertex, u32> &region_map) {
assert(isRegionEntry(g, v, region_map));
DEBUG_PRINTF("check if r%u is optional (inspecting v%zu)\n",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -60,7 +60,7 @@ struct RegionInfo {
static
bool regionHasUnexpectedAccept(const NGHolder &g, const u32 region,
const flat_set<ReportID> &expected_reports,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const unordered_map<NFAVertex, u32> &region_map) {
/* TODO: only check vertices connected to accept/acceptEOD */
for (auto v : vertices_range(g)) {
if (region != region_map.at(v)) {
@ -84,7 +84,7 @@ bool regionHasUnexpectedAccept(const NGHolder &g, const u32 region,
static
void processCyclicStateForward(NGHolder &h, NFAVertex cyc,
const map<u32, RegionInfo> &info,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
set<u32> &deadRegions) {
u32 region = region_map.at(cyc);
CharReach cr = h[cyc].char_reach;
@ -130,7 +130,7 @@ void processCyclicStateForward(NGHolder &h, NFAVertex cyc,
static
void processCyclicStateReverse(NGHolder &h, NFAVertex cyc,
const map<u32, RegionInfo> &info,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
set<u32> &deadRegions) {
u32 region = region_map.at(cyc);
CharReach cr = h[cyc].char_reach;
@ -179,7 +179,7 @@ void processCyclicStateReverse(NGHolder &h, NFAVertex cyc,
static
map<u32, RegionInfo> buildRegionInfoMap(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map) {
const unordered_map<NFAVertex, u32> &region_map) {
map<u32, RegionInfo> info;
for (auto v : vertices_range(g)) {

View File

@ -49,10 +49,13 @@
#include "util/graph_range.h"
#include "util/graph_small_color_map.h"
#include "util/report_manager.h"
#include "util/unordered.h"
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <boost/graph/connected_components.hpp>
#include <boost/graph/depth_first_search.hpp>
@ -64,6 +67,7 @@
using namespace std;
using boost::depth_first_search;
using boost::depth_first_visit;
using boost::make_assoc_property_map;
namespace ue2 {
@ -118,7 +122,7 @@ struct ReachSubgraph {
static
void findInitDepths(const NGHolder &g,
ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths) {
unordered_map<NFAVertex, NFAVertexDepth> &depths) {
auto d = calcDepths(g);
for (auto v : vertices_range(g)) {
@ -133,12 +137,12 @@ vector<NFAVertex> buildTopoOrder(const RepeatGraph &g) {
/* Note: RepeatGraph is a filtered version of NGHolder and still has
* NFAVertex as its vertex descriptor */
typedef ue2::unordered_set<NFAEdge> EdgeSet;
typedef unordered_set<NFAEdge> EdgeSet;
EdgeSet deadEdges;
// We don't have indices spanning [0,N] on our filtered graph, so we
// provide a colour map.
ue2::unordered_map<NFAVertex, boost::default_color_type> colours;
unordered_map<NFAVertex, boost::default_color_type> colours;
depth_first_search(g, visitor(BackEdges<EdgeSet>(deadEdges)).
color_map(make_assoc_property_map(colours)));
@ -155,22 +159,22 @@ vector<NFAVertex> buildTopoOrder(const RepeatGraph &g) {
static
void proper_pred(const NGHolder &g, NFAVertex v,
ue2::unordered_set<NFAVertex> &p) {
unordered_set<NFAVertex> &p) {
pred(g, v, &p);
p.erase(v); // self-loops
}
static
void proper_succ(const NGHolder &g, NFAVertex v,
ue2::unordered_set<NFAVertex> &s) {
unordered_set<NFAVertex> &s) {
succ(g, v, &s);
s.erase(v); // self-loops
}
static
bool roguePredecessor(const NGHolder &g, NFAVertex v,
const ue2::unordered_set<NFAVertex> &involved,
const ue2::unordered_set<NFAVertex> &pred) {
const unordered_set<NFAVertex> &involved,
const unordered_set<NFAVertex> &pred) {
u32 seen = 0;
for (auto u : inv_adjacent_vertices_range(v, g)) {
@ -195,8 +199,8 @@ bool roguePredecessor(const NGHolder &g, NFAVertex v,
static
bool rogueSuccessor(const NGHolder &g, NFAVertex v,
const ue2::unordered_set<NFAVertex> &involved,
const ue2::unordered_set<NFAVertex> &succ) {
const unordered_set<NFAVertex> &involved,
const unordered_set<NFAVertex> &succ) {
u32 seen = 0;
for (auto w : adjacent_vertices_range(v, g)) {
if (contains(involved, w)) {
@ -245,10 +249,10 @@ bool hasDifferentTops(const NGHolder &g, const vector<NFAVertex> &verts) {
static
bool vertexIsBad(const NGHolder &g, NFAVertex v,
const ue2::unordered_set<NFAVertex> &involved,
const ue2::unordered_set<NFAVertex> &tail,
const ue2::unordered_set<NFAVertex> &pred,
const ue2::unordered_set<NFAVertex> &succ,
const unordered_set<NFAVertex> &involved,
const unordered_set<NFAVertex> &tail,
const unordered_set<NFAVertex> &pred,
const unordered_set<NFAVertex> &succ,
const flat_set<ReportID> &reports) {
DEBUG_PRINTF("check vertex %zu\n", g[v].index);
@ -293,13 +297,13 @@ void splitSubgraph(const NGHolder &g, const deque<NFAVertex> &verts,
// We construct a copy of the graph using just the vertices we want, rather
// than using a filtered_graph -- this way is faster.
NGHolder verts_g;
ue2::unordered_map<NFAVertex, NFAVertex> verts_map; // in g -> in verts_g
unordered_map<NFAVertex, NFAVertex> verts_map; // in g -> in verts_g
fillHolder(&verts_g, g, verts, &verts_map);
ue2::unordered_map<NFAVertex, NFAUndirectedVertex> old2new;
unordered_map<NFAVertex, NFAUndirectedVertex> old2new;
auto ug = createUnGraph(verts_g, true, true, old2new);
ue2::unordered_map<NFAUndirectedVertex, u32> repeatMap;
unordered_map<NFAUndirectedVertex, u32> repeatMap;
size_t num = connected_components(ug, make_assoc_property_map(repeatMap));
DEBUG_PRINTF("found %zu connected repeat components\n", num);
@ -377,10 +381,10 @@ void checkReachSubgraphs(const NGHolder &g, vector<ReachSubgraph> &rs,
continue;
}
ue2::unordered_set<NFAVertex> involved(rsi.vertices.begin(),
unordered_set<NFAVertex> involved(rsi.vertices.begin(),
rsi.vertices.end());
ue2::unordered_set<NFAVertex> tail(involved); // to look for back-edges.
ue2::unordered_set<NFAVertex> pred, succ;
unordered_set<NFAVertex> tail(involved); // to look for back-edges.
unordered_set<NFAVertex> pred, succ;
proper_pred(g, rsi.vertices.front(), pred);
proper_succ(g, rsi.vertices.back(), succ);
@ -514,7 +518,7 @@ bool processSubgraph(const NGHolder &g, ReachSubgraph &rsi,
NFAVertex first = rsi.vertices.front();
NFAVertex last = rsi.vertices.back();
typedef ue2::unordered_map<NFAVertex, DistanceSet> DistanceMap;
typedef unordered_map<NFAVertex, DistanceSet> DistanceMap;
DistanceMap dist;
// Initial distance sets.
@ -608,7 +612,7 @@ bool processSubgraph(const NGHolder &g, ReachSubgraph &rsi,
static
bool allPredsInSubgraph(NFAVertex v, const NGHolder &g,
const ue2::unordered_set<NFAVertex> &involved) {
const unordered_set<NFAVertex> &involved) {
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!contains(involved, u)) {
return false;
@ -619,8 +623,8 @@ bool allPredsInSubgraph(NFAVertex v, const NGHolder &g,
static
void buildTugTrigger(NGHolder &g, NFAVertex cyclic, NFAVertex v,
const ue2::unordered_set<NFAVertex> &involved,
ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
const unordered_set<NFAVertex> &involved,
unordered_map<NFAVertex, NFAVertexDepth> &depths,
vector<NFAVertex> &tugs) {
if (allPredsInSubgraph(v, g, involved)) {
// We can transform this vertex into a tug trigger in-place.
@ -699,7 +703,7 @@ u32 unpeelAmount(const NGHolder &g, const ReachSubgraph &rsi) {
static
void unpeelNearEnd(NGHolder &g, ReachSubgraph &rsi,
ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
unordered_map<NFAVertex, NFAVertexDepth> &depths,
vector<NFAVertex> *succs) {
u32 unpeel = unpeelAmount(g, rsi);
DEBUG_PRINTF("unpeeling %u vertices\n", unpeel);
@ -759,8 +763,8 @@ void getSuccessors(const NGHolder &g, const ReachSubgraph &rsi,
static
void replaceSubgraphWithSpecial(NGHolder &g, ReachSubgraph &rsi,
vector<BoundedRepeatData> *repeats,
ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
ue2::unordered_set<NFAVertex> &created) {
unordered_map<NFAVertex, NFAVertexDepth> &depths,
unordered_set<NFAVertex> &created) {
assert(!rsi.bad);
assert(rsi.repeatMin > depth(0));
assert(rsi.repeatMax >= rsi.repeatMin);
@ -768,7 +772,7 @@ void replaceSubgraphWithSpecial(NGHolder &g, ReachSubgraph &rsi,
DEBUG_PRINTF("entry\n");
const ue2::unordered_set<NFAVertex> involved(rsi.vertices.begin(),
const unordered_set<NFAVertex> involved(rsi.vertices.begin(),
rsi.vertices.end());
vector<NFAVertex> succs;
getSuccessors(g, rsi, &succs);
@ -829,15 +833,15 @@ void replaceSubgraphWithSpecial(NGHolder &g, ReachSubgraph &rsi,
static
void replaceSubgraphWithLazySpecial(NGHolder &g, ReachSubgraph &rsi,
vector<BoundedRepeatData> *repeats,
ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
ue2::unordered_set<NFAVertex> &created) {
unordered_map<NFAVertex, NFAVertexDepth> &depths,
unordered_set<NFAVertex> &created) {
assert(!rsi.bad);
assert(rsi.repeatMin);
assert(rsi.repeatMax >= rsi.repeatMin);
DEBUG_PRINTF("entry\n");
const ue2::unordered_set<NFAVertex> involved(rsi.vertices.begin(),
const unordered_set<NFAVertex> involved(rsi.vertices.begin(),
rsi.vertices.end());
vector<NFAVertex> succs;
getSuccessors(g, rsi, &succs);
@ -932,7 +936,7 @@ void reprocessSubgraph(const NGHolder &h, const Grey &grey,
* involved in other repeats as a result of earlier repeat transformations. */
static
bool peelSubgraph(const NGHolder &g, const Grey &grey, ReachSubgraph &rsi,
const ue2::unordered_set<NFAVertex> &created) {
const unordered_set<NFAVertex> &created) {
assert(!rsi.bad);
if (created.empty()) {
@ -994,7 +998,7 @@ bool peelSubgraph(const NGHolder &g, const Grey &grey, ReachSubgraph &rsi,
* idea to extend to cyclic states, too. */
static
void peelStartDotStar(const NGHolder &g,
const ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
const unordered_map<NFAVertex, NFAVertexDepth> &depths,
const Grey &grey, ReachSubgraph &rsi) {
if (rsi.vertices.size() < 1) {
return;
@ -1073,8 +1077,8 @@ bool hasSkipEdges(const NGHolder &g, const ReachSubgraph &rsi) {
/* depth info is valid as calculated at entry */
static
bool entered_at_fixed_offset(NFAVertex v, const NGHolder &g,
const ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
const ue2::unordered_set<NFAVertex> &reached_by_fixed_tops) {
const unordered_map<NFAVertex, NFAVertexDepth> &depths,
const unordered_set<NFAVertex> &reached_by_fixed_tops) {
DEBUG_PRINTF("|reached_by_fixed_tops| %zu\n",
reached_by_fixed_tops.size());
if (is_triggered(g) && !contains(reached_by_fixed_tops, v)) {
@ -1200,12 +1204,12 @@ CharReach predReach(const NGHolder &g, NFAVertex v) {
*/
static
void filterMap(const NGHolder &subg,
ue2::unordered_map<NFAVertex, NFAVertex> &vmap) {
unordered_map<NFAVertex, NFAVertex> &vmap) {
NGHolder::vertex_iterator vi, ve;
tie(vi, ve) = vertices(subg);
const ue2::unordered_set<NFAVertex> remaining_verts(vi, ve);
const unordered_set<NFAVertex> remaining_verts(vi, ve);
ue2::unordered_map<NFAVertex, NFAVertex> fmap; // filtered map
unordered_map<NFAVertex, NFAVertex> fmap; // filtered map
for (const auto &m : vmap) {
if (contains(remaining_verts, m.second)) {
@ -1220,7 +1224,7 @@ void filterMap(const NGHolder &subg,
* the bounded repeat. */
static
void buildRepeatGraph(NGHolder &rg,
ue2::unordered_map<NFAVertex, NFAVertex> &rg_map,
unordered_map<NFAVertex, NFAVertex> &rg_map,
const NGHolder &g, const ReachSubgraph &rsi,
const map<u32, vector<vector<CharReach>>> &triggers) {
cloneHolder(rg, g, &rg_map);
@ -1231,7 +1235,7 @@ void buildRepeatGraph(NGHolder &rg,
add_edge(rg.accept, rg.acceptEod, rg);
// Find the set of vertices in rg involved in the repeat.
ue2::unordered_set<NFAVertex> rg_involved;
unordered_set<NFAVertex> rg_involved;
for (const auto &v : rsi.vertices) {
assert(contains(rg_map, v));
rg_involved.insert(rg_map.at(v));
@ -1273,7 +1277,7 @@ void buildRepeatGraph(NGHolder &rg,
*/
static
void buildInputGraph(NGHolder &lhs,
ue2::unordered_map<NFAVertex, NFAVertex> &lhs_map,
unordered_map<NFAVertex, NFAVertex> &lhs_map,
const NGHolder &g, const NFAVertex first,
const map<u32, vector<vector<CharReach>>> &triggers) {
DEBUG_PRINTF("building lhs with first=%zu\n", g[first].index);
@ -1327,8 +1331,8 @@ static const size_t MAX_SOLE_ENTRY_VERTICES = 10000;
* single offset at runtime. See UE-1361. */
static
bool hasSoleEntry(const NGHolder &g, const ReachSubgraph &rsi,
const ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
const ue2::unordered_set<NFAVertex> &reached_by_fixed_tops,
const unordered_map<NFAVertex, NFAVertexDepth> &depths,
const unordered_set<NFAVertex> &reached_by_fixed_tops,
const map<u32, vector<vector<CharReach>>> &triggers) {
DEBUG_PRINTF("checking repeat {%s,%s}\n", rsi.repeatMin.str().c_str(),
rsi.repeatMax.str().c_str());
@ -1358,12 +1362,12 @@ bool hasSoleEntry(const NGHolder &g, const ReachSubgraph &rsi,
}
NGHolder rg;
ue2::unordered_map<NFAVertex, NFAVertex> rg_map;
unordered_map<NFAVertex, NFAVertex> rg_map;
buildRepeatGraph(rg, rg_map, g, rsi, triggers);
assert(rg.kind == g.kind);
NGHolder lhs;
ue2::unordered_map<NFAVertex, NFAVertex> lhs_map;
unordered_map<NFAVertex, NFAVertex> lhs_map;
buildInputGraph(lhs, lhs_map, g, first, triggers);
assert(lhs.kind == g.kind);
@ -1377,7 +1381,7 @@ bool hasSoleEntry(const NGHolder &g, const ReachSubgraph &rsi,
// are in one region, vertices in the bounded repeat are in another.
const u32 lhs_region = 1;
const u32 repeat_region = 2;
ue2::unordered_map<NFAVertex, u32> region_map;
unordered_map<NFAVertex, u32> region_map;
for (const auto &v : rsi.vertices) {
assert(!is_special(v, g)); // no specials in repeats
@ -1473,7 +1477,7 @@ struct StrawWalker {
NFAVertex walk(NFAVertex v, vector<NFAVertex> &straw) const {
DEBUG_PRINTF("walk from %zu\n", g[v].index);
ue2::unordered_set<NFAVertex> visited;
unordered_set<NFAVertex> visited;
straw.clear();
while (!is_special(v, g)) {
@ -1695,7 +1699,7 @@ vector<vector<CharReach>> getRepeatTriggers(const NGHolder &g,
assert(!done.empty());
// Convert our path list into a set of unique triggers.
ue2::unordered_set<vector<CharReach>> unique_triggers;
ue2_unordered_set<vector<CharReach>> unique_triggers;
for (const auto &path : done) {
vector<CharReach> reach_path;
for (auto jt = path.rbegin(), jte = path.rend(); jt != jte; ++jt) {
@ -1743,8 +1747,8 @@ static
void
selectHistoryScheme(const NGHolder &g, const ReportManager *rm,
ReachSubgraph &rsi,
const ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths,
const ue2::unordered_set<NFAVertex> &reached_by_fixed_tops,
const unordered_map<NFAVertex, NFAVertexDepth> &depths,
const unordered_set<NFAVertex> &reached_by_fixed_tops,
const map<u32, vector<vector<CharReach>>> &triggers,
const vector<BoundedRepeatData> &all_repeats,
const bool simple_model_selection) {
@ -1812,7 +1816,7 @@ selectHistoryScheme(const NGHolder &g, const ReportManager *rm,
static
void buildFeeder(NGHolder &g, const BoundedRepeatData &rd,
ue2::unordered_set<NFAVertex> &created,
unordered_set<NFAVertex> &created,
const vector<NFAVertex> &straw) {
if (!g[rd.cyclic].char_reach.all()) {
// Create another cyclic feeder state with flipped reach. It has an
@ -1859,7 +1863,7 @@ void buildFeeder(NGHolder &g, const BoundedRepeatData &rd,
*/
static
bool improveLeadingRepeat(NGHolder &g, BoundedRepeatData &rd,
ue2::unordered_set<NFAVertex> &created,
unordered_set<NFAVertex> &created,
const vector<BoundedRepeatData> &all_repeats) {
assert(edge(g.startDs, g.startDs, g).second);
@ -1963,7 +1967,7 @@ vector<NFAVertex> makeOwnStraw(NGHolder &g, BoundedRepeatData &rd,
*/
static
bool improveLeadingRepeatOutfix(NGHolder &g, BoundedRepeatData &rd,
ue2::unordered_set<NFAVertex> &created,
unordered_set<NFAVertex> &created,
const vector<BoundedRepeatData> &all_repeats) {
assert(g.kind == NFA_OUTFIX);
@ -2061,7 +2065,7 @@ bool endsInAcceptEod(const NGHolder &g, const ReachSubgraph &rsi) {
namespace {
class pfti_visitor : public boost::default_dfs_visitor {
public:
pfti_visitor(ue2::unordered_map<NFAVertex, depth> &top_depths_in,
pfti_visitor(unordered_map<NFAVertex, depth> &top_depths_in,
const depth &our_depth_in)
: top_depths(top_depths_in), our_depth(our_depth_in) {}
@ -2077,7 +2081,7 @@ public:
top_depths[v] = our_depth;
}
}
ue2::unordered_map<NFAVertex, depth> &top_depths;
unordered_map<NFAVertex, depth> &top_depths;
const depth &our_depth;
};
} // namespace
@ -2091,7 +2095,7 @@ void populateFixedTopInfo(const map<u32, u32> &fixed_depth_tops,
}
assert(!proper_out_degree(g.startDs, g));
ue2::unordered_map<NFAVertex, depth> top_depths;
unordered_map<NFAVertex, depth> top_depths;
auto colours = make_small_color_map(g);
for (const auto &e : out_edges_range(g.start, g)) {
@ -2142,7 +2146,7 @@ void populateFixedTopInfo(const map<u32, u32> &fixed_depth_tops,
static
bool hasOverlappingRepeats(UNUSED const NGHolder &g,
const vector<BoundedRepeatData> &repeats) {
ue2::unordered_set<NFAVertex> involved;
unordered_set<NFAVertex> involved;
for (const auto &br : repeats) {
if (contains(involved, br.cyclic)) {
@ -2177,7 +2181,7 @@ bool hasOverlappingRepeats(UNUSED const NGHolder &g,
*/
static
bool repeatIsNasty(const NGHolder &g, const ReachSubgraph &rsi,
const ue2::unordered_map<NFAVertex, NFAVertexDepth> &depths) {
const unordered_map<NFAVertex, NFAVertexDepth> &depths) {
if (num_vertices(g) > NFA_MAX_STATES) {
// We may have no choice but to implement this repeat to get the graph
// down to a tractable number of vertices.
@ -2236,7 +2240,7 @@ void analyseRepeats(NGHolder &g, const ReportManager *rm,
// Later on, we're (a little bit) dependent on depth information for
// unpeeling and so forth. Note that these depths MUST be maintained when
// new vertices are added.
ue2::unordered_map<NFAVertex, NFAVertexDepth> depths;
unordered_map<NFAVertex, NFAVertexDepth> depths;
findInitDepths(g, depths);
// Construct our list of subgraphs with the same reach using BGL magic.
@ -2293,13 +2297,13 @@ void analyseRepeats(NGHolder &g, const ReportManager *rm,
// could make this unnecessary?
const unique_ptr<const NGHolder> orig_g(cloneHolder(g));
ue2::unordered_set<NFAVertex> reached_by_fixed_tops;
unordered_set<NFAVertex> reached_by_fixed_tops;
if (is_triggered(g)) {
populateFixedTopInfo(fixed_depth_tops, g, &reached_by_fixed_tops);
}
// Go to town on the remaining acceptable subgraphs.
ue2::unordered_set<NFAVertex> created;
unordered_set<NFAVertex> created;
for (auto &rsi : rs) {
DEBUG_PRINTF("subgraph (beginning vertex %zu) is a {%s,%s} repeat\n",
g[rsi.vertices.front()].index,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -37,7 +37,7 @@
#include "ue2common.h"
#include "nfa/repeat_internal.h"
#include "util/depth.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <map>
#include <vector>
@ -122,7 +122,7 @@ void findRepeats(const NGHolder &h, u32 minRepeatVertices,
struct PureRepeat {
CharReach reach;
DepthMinMax bounds;
ue2::flat_set<ReportID> reports;
flat_set<ReportID> reports;
bool operator==(const PureRepeat &a) const {
return reach == a.reach && bounds == a.bounds && reports == a.reports;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -131,9 +131,9 @@ void getStateOrdering(NGHolder &g, const flat_set<NFAVertex> &tops,
// Returns the number of states.
static
ue2::unordered_map<NFAVertex, u32>
unordered_map<NFAVertex, u32>
getStateIndices(const NGHolder &h, const vector<NFAVertex> &ordering) {
ue2::unordered_map<NFAVertex, u32> states;
unordered_map<NFAVertex, u32> states;
for (const auto &v : vertices_range(h)) {
states[v] = NO_STATE;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -28,14 +28,16 @@
/** \file
* \brief State numbering and late graph restructuring code.
*/
#ifndef NG_RESTRUCTURING_H
#define NG_RESTRUCTURING_H
#include "ng_holder.h"
#include "ue2common.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <unordered_map>
namespace ue2 {
@ -48,14 +50,14 @@ static constexpr u32 NO_STATE = ~0;
/**
* \brief Gives each participating vertex in the graph a unique state index.
*/
unordered_map<NFAVertex, u32>
std::unordered_map<NFAVertex, u32>
numberStates(NGHolder &h, const flat_set<NFAVertex> &tops);
/**
* \brief Counts the number of states (vertices with state indices) in the
* graph.
*/
u32 countStates(const unordered_map<NFAVertex, u32> &state_ids);
u32 countStates(const std::unordered_map<NFAVertex, u32> &state_ids);
} // namespace ue2

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -40,6 +40,8 @@
#include "util/charreach.h"
#include "util/graph_range.h"
#include <set>
using namespace std;
namespace ue2 {

View File

@ -69,6 +69,8 @@
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
@ -103,7 +105,7 @@ struct som_plan {
static
bool regionCanEstablishSom(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const u32 region, const vector<NFAVertex> &r_exits,
const vector<DepthMinMax> &depths) {
if (region == regions.at(g.accept) ||
@ -149,7 +151,7 @@ struct region_info {
static
void buildRegionMapping(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
map<u32, region_info> &info,
bool include_region_0 = false) {
for (auto v : vertices_range(g)) {
@ -228,7 +230,7 @@ void buildRegionMapping(const NGHolder &g,
static
bool validateXSL(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const u32 region, const CharReach &escapes, u32 *bad_region) {
/* need to check that the escapes escape all of the graph past region */
u32 first_bad_region = ~0U;
@ -251,7 +253,7 @@ bool validateXSL(const NGHolder &g,
static
bool validateEXSL(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const u32 region, const CharReach &escapes,
const NGHolder &prefix, u32 *bad_region) {
/* EXSL: To be a valid EXSL with escapes e, we require that all states
@ -353,7 +355,7 @@ bool isPossibleLock(const NGHolder &g,
static
unique_ptr<NGHolder>
makePrefix(const NGHolder &g, const ue2::unordered_map<NFAVertex, u32> &regions,
makePrefix(const NGHolder &g, const unordered_map<NFAVertex, u32> &regions,
const region_info &curr, const region_info &next,
bool renumber = true) {
const vector<NFAVertex> &curr_exits = curr.exits;
@ -368,12 +370,12 @@ makePrefix(const NGHolder &g, const ue2::unordered_map<NFAVertex, u32> &regions,
deque<NFAVertex> lhs_verts;
insert(&lhs_verts, lhs_verts.end(), vertices(g));
ue2::unordered_map<NFAVertex, NFAVertex> lhs_map; // g -> prefix
unordered_map<NFAVertex, NFAVertex> lhs_map; // g -> prefix
fillHolder(&prefix, g, lhs_verts, &lhs_map);
prefix.kind = NFA_OUTFIX;
// We need a reverse mapping to track regions.
ue2::unordered_map<NFAVertex, NFAVertex> rev_map; // prefix -> g
unordered_map<NFAVertex, NFAVertex> rev_map; // prefix -> g
for (const auto &e : lhs_map) {
rev_map.emplace(e.second, e.first);
}
@ -541,7 +543,7 @@ void setMidfixReports(ReportManager &rm, const som_plan &item,
static
bool finalRegion(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
NFAVertex v) {
u32 region = regions.at(v);
for (auto w : adjacent_vertices_range(v, g)) {
@ -771,7 +773,7 @@ void fillHolderForLockCheck(NGHolder *out, const NGHolder &g,
static
void fillRoughMidfix(NGHolder *out, const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
map<u32, region_info>::const_iterator picked) {
/* as we are not the first prefix, we are probably not acyclic. We need to
@ -941,7 +943,7 @@ bool isMandRegionBetween(map<u32, region_info>::const_iterator a,
// (woot!); updates picked, plan and bad_region.
static
bool advancePlan(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const NGHolder &prefix, bool stuck,
map<u32, region_info>::const_iterator &picked,
const map<u32, region_info>::const_iterator furthest,
@ -1051,13 +1053,12 @@ void addReporterVertices(const region_info &r, const NGHolder &g,
// Fetches the mappings of all preds of {accept, acceptEod} in this region.
static
void addMappedReporterVertices(const region_info &r, const NGHolder &g,
const ue2::unordered_map<NFAVertex, NFAVertex> &mapping,
const unordered_map<NFAVertex, NFAVertex> &mapping,
vector<NFAVertex> &reporters) {
for (auto v : r.exits) {
if (edge(v, g.accept, g).second || edge(v, g.acceptEod, g).second) {
DEBUG_PRINTF("adding v=%zu\n", g[v].index);
ue2::unordered_map<NFAVertex, NFAVertex>::const_iterator it =
mapping.find(v);
auto it = mapping.find(v);
assert(it != mapping.end());
reporters.push_back(it->second);
}
@ -1068,9 +1069,9 @@ void addMappedReporterVertices(const region_info &r, const NGHolder &g,
// from earlier regions.
static
void cloneGraphWithOneEntry(NGHolder &out, const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
NFAVertex entry, const vector<NFAVertex> &enters,
ue2::unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
orig_to_copy.clear();
cloneHolder(out, g, &orig_to_copy);
@ -1095,7 +1096,7 @@ void cloneGraphWithOneEntry(NGHolder &out, const NGHolder &g,
}
static
void expandGraph(NGHolder &g, ue2::unordered_map<NFAVertex, u32> &regions,
void expandGraph(NGHolder &g, unordered_map<NFAVertex, u32> &regions,
vector<NFAVertex> &enters) {
assert(!enters.empty());
const u32 split_region = regions.at(enters.front());
@ -1178,11 +1179,11 @@ void expandGraph(NGHolder &g, ue2::unordered_map<NFAVertex, u32> &regions,
static
bool doTreePlanningIntl(NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
map<u32, region_info>::const_iterator picked, u32 bad_region,
u32 parent_plan,
const ue2::unordered_map<NFAVertex, NFAVertex> &copy_to_orig,
const unordered_map<NFAVertex, NFAVertex> &copy_to_orig,
vector<som_plan> &plan, const Grey &grey) {
assert(picked != info.end());
@ -1341,7 +1342,7 @@ bool doTreePlanning(NGHolder &g,
// regions.
NGHolder g_path;
ue2::unordered_map<NFAVertex, NFAVertex> orig_to_copy;
unordered_map<NFAVertex, NFAVertex> orig_to_copy;
cloneGraphWithOneEntry(g_path, g, g_regions, v, enters, orig_to_copy);
auto regions = assignRegions(g_path);
dumpHolder(g_path, regions, 14, "som_treepath", grey);
@ -1375,7 +1376,7 @@ bool doTreePlanning(NGHolder &g,
}
// Construct reverse mapping from vertices in g_path to g.
ue2::unordered_map<NFAVertex, NFAVertex> copy_to_orig;
unordered_map<NFAVertex, NFAVertex> copy_to_orig;
for (const auto &m : orig_to_copy) {
copy_to_orig.insert(make_pair(m.second, m.first));
}
@ -1398,7 +1399,7 @@ enum dsp_behaviour {
static
bool doSomPlanning(NGHolder &g, bool stuck_in,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
map<u32, region_info>::const_iterator picked,
vector<som_plan> &plan,
@ -1940,7 +1941,7 @@ map<u32, region_info>::const_iterator findLaterLiteral(const NGHolder &g,
static
bool attemptToBuildChainAfterSombe(SomSlotManager &ssm, NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
map<u32, region_info>::const_iterator picked,
const Grey &grey,
@ -2014,7 +2015,7 @@ void setReportOnHaigPrefix(RoseBuild &rose, NGHolder &h) {
static
bool tryHaig(RoseBuild &rose, NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
som_type som, u32 somPrecision,
map<u32, region_info>::const_iterator picked,
shared_ptr<raw_som_dfa> *haig, shared_ptr<NGHolder> *haig_prefix,
@ -2062,7 +2063,7 @@ void roseAddHaigLiteral(RoseBuild &tb, const shared_ptr<NGHolder> &prefix,
static
sombe_rv doHaigLitSom(NG &ng, NGHolder &g, const ExpressionInfo &expr,
u32 comp_id, som_type som,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
map<u32, region_info>::const_iterator lower_bound) {
DEBUG_PRINTF("entry\n");
@ -2343,7 +2344,7 @@ bool splitOffLeadingLiterals(const NGHolder &g, set<ue2_literal> *lit_out,
}
}
ue2::unordered_map<NFAVertex, NFAVertex> rhs_map;
unordered_map<NFAVertex, NFAVertex> rhs_map;
vector<NFAVertex> pivots;
insert(&pivots, pivots.end(), adj_term1);
splitRHS(g, pivots, rhs, &rhs_map);
@ -2354,7 +2355,7 @@ bool splitOffLeadingLiterals(const NGHolder &g, set<ue2_literal> *lit_out,
static
void findBestLiteral(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
ue2_literal *lit_out, NFAVertex *v,
const CompileContext &cc) {
map<u32, region_info> info;
@ -2394,7 +2395,7 @@ void findBestLiteral(const NGHolder &g,
static
bool splitOffBestLiteral(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
ue2_literal *lit_out, NGHolder *lhs, NGHolder *rhs,
const CompileContext &cc) {
NFAVertex v = NGHolder::null_vertex();
@ -2406,8 +2407,8 @@ bool splitOffBestLiteral(const NGHolder &g,
DEBUG_PRINTF("literal is '%s'\n", dumpString(*lit_out).c_str());
ue2::unordered_map<NFAVertex, NFAVertex> lhs_map;
ue2::unordered_map<NFAVertex, NFAVertex> rhs_map;
unordered_map<NFAVertex, NFAVertex> lhs_map;
unordered_map<NFAVertex, NFAVertex> rhs_map;
splitGraph(g, v, lhs, &lhs_map, rhs, &rhs_map);
@ -2498,7 +2499,7 @@ bool doLitHaigSom(NG &ng, NGHolder &g, som_type som) {
static
bool doHaigLitHaigSom(NG &ng, NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
som_type som) {
if (!ng.cc.grey.allowLitHaig) {
return false;
@ -2732,7 +2733,7 @@ bool trySombe(NG &ng, NGHolder &g, som_type som) {
static
map<u32, region_info>::const_iterator pickInitialSomCut(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
const vector<DepthMinMax> &depths) {
map<u32, region_info>::const_iterator picked = info.end();
@ -2757,7 +2758,7 @@ map<u32, region_info>::const_iterator pickInitialSomCut(const NGHolder &g,
static
map<u32, region_info>::const_iterator tryForLaterRevNfaCut(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
const vector<DepthMinMax> &depths,
const map<u32, region_info>::const_iterator &orig,
@ -2849,7 +2850,7 @@ map<u32, region_info>::const_iterator tryForLaterRevNfaCut(const NGHolder &g,
static
unique_ptr<NGHolder> makePrefixForChain(NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &regions,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
const map<u32, region_info>::const_iterator &picked,
vector<DepthMinMax> *depths, bool prefix_by_rev,

View File

@ -54,7 +54,7 @@ vector<DepthMinMax> getDistancesFromSOM(const NGHolder &g_orig) {
// We operate on a temporary copy of the original graph here, so we don't
// have to mutate the original.
NGHolder g;
ue2::unordered_map<NFAVertex, NFAVertex> vmap; // vertex in g_orig to vertex in g
unordered_map<NFAVertex, NFAVertex> vmap; // vertex in g_orig to vertex in g
cloneHolder(g, g_orig, &vmap);
vector<NFAVertex> vstarts;
@ -136,7 +136,7 @@ bool firstMatchIsFirst(const NGHolder &p) {
return false;
}
ue2::flat_set<NFAVertex> states;
flat_set<NFAVertex> states;
/* turn on all states (except starts - avoid suffix matches) */
/* If we were doing (1) we would also except states leading to accepts -
avoid prefix matches */
@ -166,7 +166,7 @@ bool firstMatchIsFirst(const NGHolder &p) {
}
bool somMayGoBackwards(NFAVertex u, const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
smgb_cache &cache) {
/* Need to ensure all matches of the graph g up to u contain no infixes
* which are also matches of the graph to u.
@ -215,7 +215,7 @@ bool somMayGoBackwards(NFAVertex u, const NGHolder &g,
}
}
ue2::unordered_map<NFAVertex, NFAVertex> orig_to_copy;
unordered_map<NFAVertex, NFAVertex> orig_to_copy;
NGHolder c_g;
cloneHolder(c_g, g, &orig_to_copy);
@ -287,7 +287,7 @@ bool somMayGoBackwards(NFAVertex u, const NGHolder &g,
}
bool sentClearsTail(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
const NGHolder &sent, u32 last_head_region,
u32 *bad_region) {
/* if a subsequent match from the prefix clears the rest of the pattern
@ -312,7 +312,7 @@ bool sentClearsTail(const NGHolder &g,
*/
u32 first_bad_region = ~0U;
ue2::flat_set<NFAVertex> states;
flat_set<NFAVertex> states;
/* turn on all states */
DEBUG_PRINTF("region %u is cutover\n", last_head_region);
for (auto v : vertices_range(g)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -35,9 +35,9 @@
#include "ng_util.h"
#include "util/depth.h"
#include "util/ue2_containers.h"
#include <map>
#include <unordered_map>
#include <vector>
namespace ue2 {
@ -61,7 +61,7 @@ struct smgb_cache : public mbsb_cache {
};
bool somMayGoBackwards(NFAVertex u, const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const std::unordered_map<NFAVertex, u32> &region_map,
smgb_cache &cache);
/**
@ -75,7 +75,7 @@ bool somMayGoBackwards(NFAVertex u, const NGHolder &g,
* region ID associated with a tail state that is still on.
*/
bool sentClearsTail(const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const std::unordered_map<NFAVertex, u32> &region_map,
const NGHolder &sent, u32 last_head_region,
u32 *bad_region);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -37,7 +37,6 @@
#include "util/container.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include <map>
#include <set>
@ -63,12 +62,13 @@ void clearAccepts(NGHolder &g) {
}
static
void filterSplitMap(const NGHolder &g, ue2::unordered_map<NFAVertex, NFAVertex> *out_map) {
ue2::unordered_set<NFAVertex> verts;
void filterSplitMap(const NGHolder &g,
unordered_map<NFAVertex, NFAVertex> *out_map) {
unordered_set<NFAVertex> verts;
insert(&verts, vertices(g));
ue2::unordered_map<NFAVertex, NFAVertex>::iterator it = out_map->begin();
auto it = out_map->begin();
while (it != out_map->end()) {
ue2::unordered_map<NFAVertex, NFAVertex>::iterator jt = it;
auto jt = it;
++it;
if (!contains(verts, jt->second)) {
out_map->erase(jt);
@ -78,8 +78,8 @@ void filterSplitMap(const NGHolder &g, ue2::unordered_map<NFAVertex, NFAVertex>
static
void splitLHS(const NGHolder &base, const vector<NFAVertex> &pivots,
const vector<NFAVertex> &rhs_pivots,
NGHolder *lhs, ue2::unordered_map<NFAVertex, NFAVertex> *lhs_map) {
const vector<NFAVertex> &rhs_pivots, NGHolder *lhs,
unordered_map<NFAVertex, NFAVertex> *lhs_map) {
assert(lhs && lhs_map);
cloneHolder(*lhs, base, lhs_map);
@ -131,7 +131,7 @@ void splitLHS(const NGHolder &base, const vector<NFAVertex> &pivots,
}
void splitLHS(const NGHolder &base, NFAVertex pivot,
NGHolder *lhs, ue2::unordered_map<NFAVertex, NFAVertex> *lhs_map) {
NGHolder *lhs, unordered_map<NFAVertex, NFAVertex> *lhs_map) {
vector<NFAVertex> pivots(1, pivot);
vector<NFAVertex> rhs_pivots;
insert(&rhs_pivots, rhs_pivots.end(), adjacent_vertices(pivot, base));
@ -139,7 +139,7 @@ void splitLHS(const NGHolder &base, NFAVertex pivot,
}
void splitRHS(const NGHolder &base, const vector<NFAVertex> &pivots,
NGHolder *rhs, ue2::unordered_map<NFAVertex, NFAVertex> *rhs_map) {
NGHolder *rhs, unordered_map<NFAVertex, NFAVertex> *rhs_map) {
assert(rhs && rhs_map);
cloneHolder(*rhs, base, rhs_map);
@ -211,8 +211,8 @@ void findCommonSuccessors(const NGHolder &g, const vector<NFAVertex> &pivots,
}
void splitGraph(const NGHolder &base, const vector<NFAVertex> &pivots,
NGHolder *lhs, ue2::unordered_map<NFAVertex, NFAVertex> *lhs_map,
NGHolder *rhs, ue2::unordered_map<NFAVertex, NFAVertex> *rhs_map) {
NGHolder *lhs, unordered_map<NFAVertex, NFAVertex> *lhs_map,
NGHolder *rhs, unordered_map<NFAVertex, NFAVertex> *rhs_map) {
DEBUG_PRINTF("splitting graph at %zu vertices\n", pivots.size());
assert(!has_parallel_edge(base));
@ -235,8 +235,8 @@ void splitGraph(const NGHolder &base, const vector<NFAVertex> &pivots,
}
void splitGraph(const NGHolder &base, NFAVertex pivot,
NGHolder *lhs, ue2::unordered_map<NFAVertex, NFAVertex> *lhs_map,
NGHolder *rhs, ue2::unordered_map<NFAVertex, NFAVertex> *rhs_map) {
NGHolder *lhs, unordered_map<NFAVertex, NFAVertex> *lhs_map,
NGHolder *rhs, unordered_map<NFAVertex, NFAVertex> *rhs_map) {
vector<NFAVertex> pivots(1, pivot);
splitGraph(base, pivots, lhs, lhs_map, rhs, rhs_map);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -33,10 +33,10 @@
#ifndef NG_SPLIT_H
#define NG_SPLIT_H
#include <vector>
#include "ng_holder.h"
#include "util/ue2_containers.h"
#include <unordered_map>
#include <vector>
namespace ue2 {
@ -55,21 +55,21 @@ class NGHolder;
* vertices which have an edge to every pivot
*/
void splitGraph(const NGHolder &base, NFAVertex pivot, NGHolder *lhs,
ue2::unordered_map<NFAVertex, NFAVertex> *lhs_map,
std::unordered_map<NFAVertex, NFAVertex> *lhs_map,
NGHolder *rhs,
ue2::unordered_map<NFAVertex, NFAVertex> *rhs_map);
std::unordered_map<NFAVertex, NFAVertex> *rhs_map);
void splitGraph(const NGHolder &base, const std::vector<NFAVertex> &pivots,
NGHolder *lhs,
ue2::unordered_map<NFAVertex, NFAVertex> *lhs_map,
std::unordered_map<NFAVertex, NFAVertex> *lhs_map,
NGHolder *rhs,
ue2::unordered_map<NFAVertex, NFAVertex> *rhs_map);
std::unordered_map<NFAVertex, NFAVertex> *rhs_map);
void splitLHS(const NGHolder &base, NFAVertex pivot, NGHolder *lhs,
ue2::unordered_map<NFAVertex, NFAVertex> *lhs_map);
std::unordered_map<NFAVertex, NFAVertex> *lhs_map);
void splitRHS(const NGHolder &base, const std::vector<NFAVertex> &pivots,
NGHolder *rhs, ue2::unordered_map<NFAVertex, NFAVertex> *rhs_map);
NGHolder *rhs, std::unordered_map<NFAVertex, NFAVertex> *rhs_map);
} // namespace ue2

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -104,7 +104,6 @@
#include "ng_region.h"
#include "ng_som_util.h"
#include "ng_util.h"
#include "ng_util.h"
#include "util/container.h"
#include "util/graph_range.h"
#include "util/report_manager.h"
@ -112,6 +111,8 @@
#include <deque>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/reverse_graph.hpp>
@ -120,13 +121,11 @@ using namespace std;
namespace ue2 {
typedef ue2::unordered_map<NFAVertex,
ue2::unordered_set<NFAVertex> > PostDomTree;
typedef unordered_map<NFAVertex, unordered_set<NFAVertex>> PostDomTree;
static
void buildPDomTree(const NGHolder &g, PostDomTree &tree) {
ue2::unordered_map<NFAVertex, NFAVertex> postdominators =
findPostDominators(g);
auto postdominators = findPostDominators(g);
for (auto v : vertices_range(g)) {
if (is_special(v, g)) {
@ -150,7 +149,7 @@ void buildSquashMask(NFAStateSet &mask, const NGHolder &g, NFAVertex v,
const CharReach &cr, const NFAStateSet &init,
const vector<NFAVertex> &vByIndex, const PostDomTree &tree,
som_type som, const vector<DepthMinMax> &som_depths,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
smgb_cache &cache) {
DEBUG_PRINTF("build base squash mask for vertex %zu)\n", g[v].index);
@ -274,7 +273,7 @@ void findDerivedSquashers(const NGHolder &g, const vector<NFAVertex> &vByIndex,
const PostDomTree &pdom_tree, const NFAStateSet &init,
map<NFAVertex, NFAStateSet> *squash, som_type som,
const vector<DepthMinMax> &som_depths,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
smgb_cache &cache) {
deque<NFAVertex> remaining;
for (const auto &m : *squash) {
@ -619,7 +618,7 @@ static
vector<NFAVertex> findUnreachable(const NGHolder &g) {
const boost::reverse_graph<NGHolder, const NGHolder &> revg(g);
ue2::unordered_map<NFAVertex, boost::default_color_type> colours;
unordered_map<NFAVertex, boost::default_color_type> colours;
colours.reserve(num_vertices(g));
depth_first_visit(revg, g.acceptEod,
@ -661,7 +660,7 @@ findHighlanderSquashers(const NGHolder &g, const ReportManager &rm) {
// cutting the appropriate out-edges to accept and seeing which
// vertices become unreachable.
ue2::unordered_map<NFAVertex, NFAVertex> orig_to_copy;
unordered_map<NFAVertex, NFAVertex> orig_to_copy;
NGHolder h;
cloneHolder(h, g, &orig_to_copy);
removeEdgesToAccept(h, orig_to_copy[v]);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -35,7 +35,6 @@
#include "ng_holder.h"
#include "som/som.h"
#include "ue2common.h"
#include "util/ue2_containers.h"
#include <map>
#include <boost/dynamic_bitset.hpp>
@ -45,7 +44,9 @@ namespace ue2 {
class NGHolder;
class ReportManager;
/** Dynamically-sized bitset, as an NFA can have an arbitrary number of states. */
/**
* Dynamically-sized bitset, as an NFA can have an arbitrary number of states.
*/
typedef boost::dynamic_bitset<> NFAStateSet;
/**

View File

@ -37,7 +37,7 @@
#include "ng_util.h"
#include "ue2common.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include "util/unordered.h"
#include <vector>
@ -71,7 +71,7 @@ template <typename Graph>
NFAUndirectedGraph createUnGraph(const Graph &g,
bool excludeStarts,
bool excludeAccepts,
unordered_map<typename Graph::vertex_descriptor,
std::unordered_map<typename Graph::vertex_descriptor,
NFAUndirectedVertex> &old2new) {
NFAUndirectedGraph ug;
size_t idx = 0;
@ -97,7 +97,7 @@ NFAUndirectedGraph createUnGraph(const Graph &g,
// Track seen edges so that we don't insert parallel edges.
using Vertex = typename Graph::vertex_descriptor;
unordered_set<std::pair<Vertex, Vertex>> seen;
ue2_unordered_set<std::pair<Vertex, Vertex>> seen;
seen.reserve(num_edges(g));
auto make_ordered_edge = [](Vertex a, Vertex b) {
return std::make_pair(std::min(a, b), std::max(a, b));

View File

@ -48,6 +48,9 @@
#include <limits>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/graph/filtered_graph.hpp>
#include <boost/graph/topological_sort.hpp>
#include <boost/range/adaptor/map.hpp>
@ -353,7 +356,7 @@ vector<NFAVertex> getTopoOrdering(const NGHolder &g) {
// having to reallocate it, etc.
auto colors = make_small_color_map(g);
using EdgeSet = ue2::unordered_set<NFAEdge>;
using EdgeSet = unordered_set<NFAEdge>;
EdgeSet backEdges;
BackEdges<EdgeSet> be(backEdges);
@ -467,7 +470,7 @@ void setTops(NGHolder &h, u32 top) {
void clearReports(NGHolder &g) {
DEBUG_PRINTF("clearing reports without an accept edge\n");
ue2::unordered_set<NFAVertex> allow;
unordered_set<NFAVertex> allow;
insert(&allow, inv_adjacent_vertices(g.accept, g));
insert(&allow, inv_adjacent_vertices(g.acceptEod, g));
allow.erase(g.accept); // due to stylised edge.
@ -491,7 +494,7 @@ void duplicateReport(NGHolder &g, ReportID r_old, ReportID r_new) {
static
void fillHolderOutEdges(NGHolder &out, const NGHolder &in,
const ue2::unordered_map<NFAVertex, NFAVertex> &v_map,
const unordered_map<NFAVertex, NFAVertex> &v_map,
NFAVertex u) {
NFAVertex u_new = v_map.at(u);
@ -513,9 +516,9 @@ void fillHolderOutEdges(NGHolder &out, const NGHolder &in,
}
void fillHolder(NGHolder *outp, const NGHolder &in, const deque<NFAVertex> &vv,
ue2::unordered_map<NFAVertex, NFAVertex> *v_map_out) {
unordered_map<NFAVertex, NFAVertex> *v_map_out) {
NGHolder &out = *outp;
ue2::unordered_map<NFAVertex, NFAVertex> &v_map = *v_map_out;
unordered_map<NFAVertex, NFAVertex> &v_map = *v_map_out;
out.kind = in.kind;
@ -597,7 +600,7 @@ void cloneHolder(NGHolder &out, const NGHolder &in) {
}
void cloneHolder(NGHolder &out, const NGHolder &in,
ue2::unordered_map<NFAVertex, NFAVertex> *mapping) {
unordered_map<NFAVertex, NFAVertex> *mapping) {
cloneHolder(out, in);
vector<NFAVertex> out_verts(num_vertices(in));
for (auto v : vertices_range(out)) {
@ -620,7 +623,7 @@ unique_ptr<NGHolder> cloneHolder(const NGHolder &in) {
void reverseHolder(const NGHolder &g_in, NGHolder &g) {
// Make the BGL do the grunt work.
ue2::unordered_map<NFAVertex, NFAVertex> vertexMap;
unordered_map<NFAVertex, NFAVertex> vertexMap;
boost::transpose_graph(g_in, g,
orig_to_copy(boost::make_assoc_property_map(vertexMap)));

View File

@ -32,16 +32,17 @@
#ifndef NG_UTIL_H
#define NG_UTIL_H
#include <map>
#include <vector>
#include "ng_holder.h"
#include "ue2common.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include <boost/graph/depth_first_search.hpp> // for default_dfs_visitor
#include "ng_holder.h"
#include "ue2common.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include <map>
#include <unordered_map>
#include <vector>
namespace ue2 {
@ -272,12 +273,12 @@ void appendLiteral(NGHolder &h, const ue2_literal &s);
* \a in). A vertex mapping is returned in \a v_map_out. */
void fillHolder(NGHolder *outp, const NGHolder &in,
const std::deque<NFAVertex> &vv,
unordered_map<NFAVertex, NFAVertex> *v_map_out);
std::unordered_map<NFAVertex, NFAVertex> *v_map_out);
/** \brief Clone the graph in \a in into graph \a out, returning a vertex
* mapping in \a v_map_out. */
void cloneHolder(NGHolder &out, const NGHolder &in,
unordered_map<NFAVertex, NFAVertex> *v_map_out);
std::unordered_map<NFAVertex, NFAVertex> *v_map_out);
/** \brief Clone the graph in \a in into graph \a out. */
void cloneHolder(NGHolder &out, const NGHolder &in);

View File

@ -57,13 +57,13 @@
#include "util/compare.h"
#include "util/compile_context.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/make_unique.h"
#include "util/order_check.h"
#include "util/target_info.h"
#include "util/ue2string.h"
#include "util/ue2_containers.h"
#include <set>
#include <utility>
@ -559,7 +559,7 @@ void filterCandPivots(const NGHolder &g, const set<NFAVertex> &cand_raw,
static
void getCandidatePivots(const NGHolder &g, set<NFAVertex> *cand,
set<NFAVertex> *cand_raw) {
ue2::unordered_map<NFAVertex, NFAVertex> dominators = findDominators(g);
auto dominators = findDominators(g);
set<NFAVertex> accepts;
@ -1023,8 +1023,8 @@ bool splitRoseEdge(const NGHolder &base_graph, RoseInGraph &vg,
shared_ptr<NGHolder> lhs = make_shared<NGHolder>();
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
ue2::unordered_map<NFAVertex, NFAVertex> lhs_map;
ue2::unordered_map<NFAVertex, NFAVertex> rhs_map;
unordered_map<NFAVertex, NFAVertex> lhs_map;
unordered_map<NFAVertex, NFAVertex> rhs_map;
splitGraph(base_graph, splitters, lhs.get(), &lhs_map, rhs.get(), &rhs_map);
DEBUG_PRINTF("split %s:%zu into %s:%zu + %s:%zu\n",
@ -1217,7 +1217,7 @@ void splitEdgesByCut(NGHolder &h, RoseInGraph &vg,
NFAVertex pivot = target(e, h);
DEBUG_PRINTF("splitting on pivot %zu\n", h[pivot].index);
ue2::unordered_map<NFAVertex, NFAVertex> temp_map;
unordered_map<NFAVertex, NFAVertex> temp_map;
shared_ptr<NGHolder> new_lhs = make_shared<NGHolder>();
splitLHS(h, pivot, new_lhs.get(), &temp_map);
@ -1298,7 +1298,7 @@ void splitEdgesByCut(NGHolder &h, RoseInGraph &vg,
effort */
if (!contains(done_rhs, adj)) {
ue2::unordered_map<NFAVertex, NFAVertex> temp_map;
unordered_map<NFAVertex, NFAVertex> temp_map;
shared_ptr<NGHolder> new_rhs = make_shared<NGHolder>();
splitRHS(h, adj, new_rhs.get(), &temp_map);
remove_edge(new_rhs->start, new_rhs->accept, *new_rhs);

View File

@ -53,8 +53,8 @@
#include "parser/Parser.h"
#include "ue2common.h"
#include "util/compare.h"
#include "util/flat_containers.h"
#include "util/make_unique.h"
#include "util/ue2_containers.h"
#include "util/unicode_def.h"
#include "util/verify_types.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -39,8 +39,10 @@
#include "nfagraph/ng_builder.h"
#include "util/charreach.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/hash.h"
#include "util/make_unique.h"
#include "util/ue2_containers.h"
#include "util/unordered.h"
#include <algorithm>
#include <iterator>
@ -449,7 +451,7 @@ unique_ptr<GlushkovBuildState> makeGlushkovBuildState(NFABuilder &b,
* Scans through a list of positions and retains only the highest priority
* version of a given (position, flags) entry. */
void cleanupPositions(vector<PositionInfo> &a) {
ue2::unordered_set<pair<Position, int>> seen; // track dupes
ue2_unordered_set<pair<Position, int>> seen;
vector<PositionInfo> out;
out.reserve(a.size()); // output should be close to input in size.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -36,7 +36,7 @@
#include "ConstComponentVisitor.h"
#include "parse_error.h"
#include "util/container.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <sstream>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -26,14 +26,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \file
/**
* \file
* \brief Component tree analysis that checks that references (such as
* back-refs, conditionals) have valid referents.
*/
#ifndef PARSER_CHECK_REFS_H_
#define PARSER_CHECK_REFS_H_
#include "util/ue2_containers.h"
#ifndef PARSER_CHECK_REFS_H
#define PARSER_CHECK_REFS_H
#include "util/flat_containers.h"
#include <string>
@ -43,8 +45,8 @@ class Component;
class ComponentSequence;
void checkReferences(const Component &root, unsigned int groupIndices,
const ue2::flat_set<std::string> &groupNames);
const flat_set<std::string> &groupNames);
} // namespace ue2
#endif // PARSER_CHECK_REFS_H_
#endif // PARSER_CHECK_REFS_H

View File

@ -42,8 +42,8 @@
#include "rose_in_graph.h"
#include "util/bytecode_ptr.h"
#include "util/charreach.h"
#include "util/flat_containers.h"
#include "util/noncopyable.h"
#include "util/ue2_containers.h"
#include "util/ue2string.h"
#include <memory>
@ -73,7 +73,7 @@ public:
/** \brief True if we can not establish that at most a single callback will
* be generated at a given offset from this set of reports. */
virtual bool requiresDedupeSupport(const ue2::flat_set<ReportID> &reports)
virtual bool requiresDedupeSupport(const flat_set<ReportID> &reports)
const = 0;
};
@ -85,7 +85,7 @@ public:
/** \brief Adds a single literal. */
virtual void add(bool anchored, bool eod, const ue2_literal &lit,
const ue2::flat_set<ReportID> &ids) = 0;
const flat_set<ReportID> &ids) = 0;
virtual bool addRose(const RoseInGraph &ig, bool prefilter) = 0;
virtual bool addSombeRose(const RoseInGraph &ig) = 0;
@ -99,17 +99,17 @@ public:
/** \brief Returns true if we were able to add it as a mask. */
virtual bool add(bool anchored, const std::vector<CharReach> &mask,
const ue2::flat_set<ReportID> &reports) = 0;
const flat_set<ReportID> &reports) = 0;
/** \brief Attempts to add the graph to the anchored acyclic table. Returns
* true on success. */
virtual bool addAnchoredAcyclic(const NGHolder &graph) = 0;
virtual bool validateMask(const std::vector<CharReach> &mask,
const ue2::flat_set<ReportID> &reports,
const flat_set<ReportID> &reports,
bool anchored, bool eod) const = 0;
virtual void addMask(const std::vector<CharReach> &mask,
const ue2::flat_set<ReportID> &reports, bool anchored,
const flat_set<ReportID> &reports, bool anchored,
bool eod) = 0;
/** \brief Construct a runtime implementation. */

View File

@ -85,7 +85,7 @@ struct RoseBuildData : noncopyable {
/** Edges we've transformed (in \ref transformAnchoredLiteralOverlap) which
* require ANCH history to prevent overlap. */
ue2::unordered_set<RoseInEdge> anch_history_edges;
unordered_set<RoseInEdge> anch_history_edges;
/** True if we're tracking Start of Match. */
bool som;

View File

@ -49,11 +49,12 @@
#include "util/compile_error.h"
#include "util/container.h"
#include "util/determinise.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/make_unique.h"
#include "util/order_check.h"
#include "util/ue2_containers.h"
#include "util/ue2string.h"
#include "util/unordered.h"
#include "util/verify_types.h"
#include <map>
@ -285,19 +286,16 @@ struct Holder_StateSet {
bool operator==(const Holder_StateSet &b) const {
return wdelay == b.wdelay && wrap_state == b.wrap_state;
}
};
size_t hash_value(const Holder_StateSet &s) {
size_t val = 0;
boost::hash_combine(val, s.wrap_state);
boost::hash_combine(val, s.wdelay);
return val;
}
size_t hash() const {
return hash_all(wrap_state, wdelay);
}
};
class Automaton_Holder {
public:
using StateSet = Holder_StateSet;
using StateMap = unordered_map<StateSet, dstate_id_t>;
using StateMap = ue2_unordered_map<StateSet, dstate_id_t>;
explicit Automaton_Holder(const NGHolder &g_in) : g(g_in) {
for (auto v : vertices_range(g)) {
@ -416,7 +414,7 @@ public:
private:
const NGHolder &g;
ue2::unordered_map<NFAVertex, u32> vertexToIndex;
unordered_map<NFAVertex, u32> vertexToIndex;
vector<NFAVertex> indexToVertex;
vector<CharReach> cr_by_index;
StateSet init;
@ -712,7 +710,7 @@ int addAutomaton(RoseBuildImpl &build, const NGHolder &h, ReportID *remap) {
static
void setReports(NGHolder &h, const map<NFAVertex, set<u32>> &reportMap,
const ue2::unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
const unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
for (const auto &m : reportMap) {
NFAVertex t = orig_to_copy.at(m.first);
assert(!m.second.empty());
@ -724,7 +722,7 @@ void setReports(NGHolder &h, const map<NFAVertex, set<u32>> &reportMap,
int addAnchoredNFA(RoseBuildImpl &build, const NGHolder &wrapper,
const map<NFAVertex, set<u32>> &reportMap) {
NGHolder h;
ue2::unordered_map<NFAVertex, NFAVertex> orig_to_copy;
unordered_map<NFAVertex, NFAVertex> orig_to_copy;
cloneHolder(h, wrapper, &orig_to_copy);
clear_in_edges(h.accept, h);
clear_in_edges(h.acceptEod, h);

View File

@ -145,7 +145,7 @@ struct build_context : noncopyable {
/** \brief Simple cache of programs written to engine blob, used for
* deduplication. */
ue2::unordered_map<RoseProgram, u32, RoseProgramHash,
unordered_map<RoseProgram, u32, RoseProgramHash,
RoseProgramEquivalence> program_cache;
/** \brief State indices, for those roles that have them.
@ -155,7 +155,7 @@ struct build_context : noncopyable {
/** \brief Mapping from queue index to bytecode offset for built engines
* that have already been pushed into the engine_blob. */
ue2::unordered_map<u32, u32> engineOffsets;
unordered_map<u32, u32> engineOffsets;
/** \brief List of long literals (ones with CHECK_LONG_LIT instructions)
* that need hash table support. */
@ -1470,7 +1470,7 @@ bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
map<left_id, set<PredTopPair> > infixTriggers;
vector<left_id> order;
unordered_map<left_id, vector<RoseVertex> > succs;
unordered_map<left_id, vector<RoseVertex>> succs;
findInfixTriggers(tbi, &infixTriggers);
if (cc.grey.allowTamarama && cc.streaming && !do_prefix) {
@ -2269,9 +2269,9 @@ bool hasMpvTrigger(const set<u32> &reports, const ReportManager &rm) {
}
static
bool anyEndfixMpvTriggers(const RoseBuildImpl &tbi) {
const RoseGraph &g = tbi.g;
ue2::unordered_set<suffix_id> done;
bool anyEndfixMpvTriggers(const RoseBuildImpl &build) {
const RoseGraph &g = build.g;
unordered_set<suffix_id> done;
/* suffixes */
for (auto v : vertices_range(g)) {
@ -2283,14 +2283,14 @@ bool anyEndfixMpvTriggers(const RoseBuildImpl &tbi) {
}
done.insert(g[v].suffix);
if (hasMpvTrigger(all_reports(g[v].suffix), tbi.rm)) {
if (hasMpvTrigger(all_reports(g[v].suffix), build.rm)) {
return true;
}
}
/* outfixes */
for (const auto &out : tbi.outfixes) {
if (hasMpvTrigger(all_reports(out), tbi.rm)) {
for (const auto &out : build.outfixes) {
if (hasMpvTrigger(all_reports(out), build.rm)) {
return true;
}
}
@ -2588,7 +2588,7 @@ void buildLeftInfoTable(const RoseBuildImpl &tbi, build_context &bc,
const RoseGraph &g = tbi.g;
const CompileContext &cc = tbi.cc;
ue2::unordered_set<u32> done_core;
unordered_set<u32> done_core;
leftTable.resize(leftfixCount);

View File

@ -38,7 +38,6 @@
#include "util/container.h"
#include "util/dump_charclass.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include "util/ue2string.h"
#include <map>
@ -85,7 +84,7 @@ void makeCastle(LeftEngInfo &left,
static
void makeCastleSuffix(RoseBuildImpl &tbi, RoseVertex v,
ue2::unordered_map<const NGHolder *, shared_ptr<CastleProto> > &cache) {
unordered_map<const NGHolder *, shared_ptr<CastleProto>> &cache) {
RoseSuffixInfo &suffix = tbi.g[v].suffix;
if (!suffix.graph) {
return;
@ -298,8 +297,8 @@ bool unmakeCastles(RoseBuildImpl &tbi) {
}
void remapCastleTops(RoseBuildImpl &tbi) {
ue2::unordered_map<CastleProto *, vector<RoseVertex> > rose_castles;
ue2::unordered_map<CastleProto *, vector<RoseVertex> > suffix_castles;
unordered_map<CastleProto *, vector<RoseVertex>> rose_castles;
unordered_map<CastleProto *, vector<RoseVertex>> suffix_castles;
RoseGraph &g = tbi.g;
for (auto v : vertices_range(g)) {

View File

@ -61,10 +61,10 @@
#include "util/compile_context.h"
#include "util/container.h"
#include "util/dump_charclass.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/order_check.h"
#include "util/report_manager.h"
#include "util/ue2_containers.h"
#include "util/ue2string.h"
#include "util/verify_types.h"
@ -1639,7 +1639,7 @@ static
bool danglingVertexRef(RoseBuildImpl &tbi) {
RoseGraph::vertex_iterator vi, ve;
tie(vi, ve) = vertices(tbi.g);
const ue2::unordered_set<RoseVertex> valid_vertices(vi, ve);
const unordered_set<RoseVertex> valid_vertices(vi, ve);
if (!contains(valid_vertices, tbi.anchored_root)) {
DEBUG_PRINTF("anchored root vertex %zu not in graph\n",

View File

@ -58,8 +58,9 @@
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/range/adaptor/map.hpp>
@ -561,7 +562,7 @@ bool handleMixedPrefixCliche(const NGHolder &h, RoseGraph &g, RoseVertex v,
DEBUG_PRINTF("woot?\n");
shared_ptr<NGHolder> h_new = make_shared<NGHolder>();
ue2::unordered_map<NFAVertex, NFAVertex> rhs_map;
unordered_map<NFAVertex, NFAVertex> rhs_map;
vector<NFAVertex> exits_vec;
insert(&exits_vec, exits_vec.end(), exits);
splitRHS(h, exits_vec, h_new.get(), &rhs_map);

View File

@ -36,13 +36,14 @@
#include "util/bytecode_ptr.h"
#include "util/charreach.h"
#include "util/container.h"
#include "util/hash.h"
#include "util/multibit_build.h"
#include "util/noncopyable.h"
#include "util/ue2_containers.h"
#include "util/verify_types.h"
#include "util/unordered.h"
#include <vector>
#include <type_traits>
#include <vector>
namespace ue2 {
@ -56,9 +57,10 @@ struct lookaround_info : noncopyable {
u32 get_offset_of(const std::vector<s8> &look, RoseEngineBlob &blob);
private:
unordered_map<std::vector<std::vector<CharReach>>, u32> multi_cache;
unordered_map<std::vector<s8>, u32> lcache;
unordered_map<std::vector<CharReach>, u32> rcache;
using Path = std::vector<CharReach>;
ue2_unordered_map<std::vector<Path>, u32> multi_cache;
ue2_unordered_map<std::vector<s8>, u32> lcache;
ue2_unordered_map<Path, u32> rcache;
};
class RoseEngineBlob : noncopyable {
@ -160,7 +162,7 @@ private:
}
/** \brief Cache of previously-written sparse iterators. */
unordered_map<std::vector<mmbit_sparse_iter>, u32> cached_iters;
ue2_unordered_map<std::vector<mmbit_sparse_iter>, u32> cached_iters;
/**
* \brief Contents of the Rose bytecode immediately following the

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Intel Corporation
* Copyright (c) 2016-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -87,7 +87,7 @@ vector<RoleChunk<role_id>> divideIntoChunks(const RoseBuildImpl &build,
/* add prefix literals to engine graph */
static
bool addPrefixLiterals(NGHolder &h, ue2::unordered_set<u32> &tailId,
bool addPrefixLiterals(NGHolder &h, unordered_set<u32> &tailId,
const vector<vector<CharReach>> &triggers) {
DEBUG_PRINTF("add literals to graph\n");
@ -196,8 +196,8 @@ vector<CharReach> findStartPos(const CharReach &cr1,
template<typename role_id>
static
bool isExclusive(const NGHolder &h,
const u32 num, ue2::unordered_set<u32> &tailId,
map<u32, ue2::unordered_set<u32>> &skipList,
const u32 num, unordered_set<u32> &tailId,
map<u32, unordered_set<u32>> &skipList,
const RoleInfo<role_id> &role1,
const RoleInfo<role_id> &role2) {
const u32 id1 = role1.id;
@ -253,12 +253,12 @@ bool isExclusive(const NGHolder &h,
template<typename role_id>
static
ue2::unordered_set<u32> checkExclusivity(const NGHolder &h,
const u32 num, ue2::unordered_set<u32> &tailId,
map<u32, ue2::unordered_set<u32>> &skipList,
unordered_set<u32> checkExclusivity(const NGHolder &h,
const u32 num, unordered_set<u32> &tailId,
map<u32, unordered_set<u32>> &skipList,
const RoleInfo<role_id> &role1,
const RoleChunk<role_id> &roleChunk) {
ue2::unordered_set<u32> info;
unordered_set<u32> info;
const u32 id1 = role1.id;
for (const auto &role2 : roleChunk.roles) {
const u32 id2 = role2.id;
@ -316,7 +316,7 @@ void findCliques(const map<u32, set<u32>> &exclusiveGroups,
static
map<u32, set<u32>> findExclusiveGroups(const RoseBuildImpl &build,
const map<u32, ue2::unordered_set<u32>> &exclusiveInfo,
const map<u32, unordered_set<u32>> &exclusiveInfo,
const map<u32, vector<RoseVertex>> &vertex_map,
const bool is_infix) {
map<u32, set<u32>> exclusiveGroups;
@ -396,10 +396,10 @@ void exclusiveAnalysis(const RoseBuildImpl &build,
vector<vector<u32>> &exclusive_roles, const bool is_infix) {
const auto &chunks = divideIntoChunks(build, roleInfoSet);
DEBUG_PRINTF("Exclusivity analysis entry\n");
map<u32, ue2::unordered_set<u32>> exclusiveInfo;
map<u32, unordered_set<u32>> exclusiveInfo;
for (const auto &roleChunk : chunks) {
map<u32, ue2::unordered_set<u32>> skipList;
map<u32, unordered_set<u32>> skipList;
for (const auto &role1 : roleChunk.roles) {
const u32 id1 = role1.id;
const role_id &s1 = role1.role;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Intel Corporation
* Copyright (c) 2016-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -35,11 +35,12 @@
#define ROSE_BUILD_GROUPS_H
#include "rose_build_impl.h"
#include "util/ue2_containers.h"
#include <unordered_map>
namespace ue2 {
unordered_map<RoseVertex, rose_group>
std::unordered_map<RoseVertex, rose_group>
getVertexGroupMap(const RoseBuildImpl &build);
rose_group getSquashableGroups(const RoseBuildImpl &build);

View File

@ -39,11 +39,12 @@
#include "nfagraph/ng_holder.h"
#include "nfagraph/ng_revacc.h"
#include "util/bytecode_ptr.h"
#include "util/flat_containers.h"
#include "util/hash.h"
#include "util/order_check.h"
#include "util/queue_index_factory.h"
#include "util/ue2_containers.h"
#include "util/ue2string.h"
#include "util/unordered.h"
#include "util/verify_types.h"
#include <deque>
@ -177,7 +178,6 @@ depth findMinWidth(const suffix_id &s);
depth findMaxWidth(const suffix_id &s);
depth findMinWidth(const suffix_id &s, u32 top);
depth findMaxWidth(const suffix_id &s, u32 top);
size_t hash_value(const suffix_id &s);
/** \brief represents an engine to the left of a rose role */
struct left_id {
@ -258,11 +258,10 @@ bool isAnchored(const left_id &r);
depth findMinWidth(const left_id &r);
depth findMaxWidth(const left_id &r);
u32 num_tops(const left_id &r);
size_t hash_value(const left_id &r);
struct rose_literal_info {
ue2::flat_set<u32> delayed_ids;
ue2::flat_set<RoseVertex> vertices;
flat_set<u32> delayed_ids;
flat_set<RoseVertex> vertices;
rose_group group_mask = 0;
u32 undelayed_id = MO_INVALID_IDX;
bool squash_group = false;
@ -306,6 +305,10 @@ struct rose_literal_id {
return s == b.s && msk == b.msk && cmp == b.cmp && table == b.table &&
delay == b.delay && distinctiveness == b.distinctiveness;
}
size_t hash() const {
return hash_all(s, msk, cmp, table, delay, distinctiveness);
}
};
static inline
@ -319,12 +322,6 @@ bool operator<(const rose_literal_id &a, const rose_literal_id &b) {
return 0;
}
inline
size_t hash_value(const rose_literal_id &lit) {
return hash_all(lit.s, lit.msk, lit.cmp, lit.table, lit.delay,
lit.distinctiveness);
}
class RoseLiteralMap {
/**
* \brief Main storage for literals.
@ -336,7 +333,7 @@ class RoseLiteralMap {
std::deque<rose_literal_id> lits;
/** \brief Quick-lookup index from literal -> index in lits. */
unordered_map<rose_literal_id, u32> lits_index;
ue2_unordered_map<rose_literal_id, u32> lits_index;
public:
std::pair<u32, bool> insert(const rose_literal_id &lit) {
@ -504,7 +501,7 @@ public:
// Adds a single literal.
void add(bool anchored, bool eod, const ue2_literal &lit,
const ue2::flat_set<ReportID> &ids) override;
const flat_set<ReportID> &ids) override;
bool addRose(const RoseInGraph &ig, bool prefilter) override;
bool addSombeRose(const RoseInGraph &ig) override;
@ -517,15 +514,15 @@ public:
// Returns true if we were able to add it as a mask
bool add(bool anchored, const std::vector<CharReach> &mask,
const ue2::flat_set<ReportID> &reports) override;
const flat_set<ReportID> &reports) override;
bool addAnchoredAcyclic(const NGHolder &graph) override;
bool validateMask(const std::vector<CharReach> &mask,
const ue2::flat_set<ReportID> &reports, bool anchored,
const flat_set<ReportID> &reports, bool anchored,
bool eod) const override;
void addMask(const std::vector<CharReach> &mask,
const ue2::flat_set<ReportID> &reports, bool anchored,
const flat_set<ReportID> &reports, bool anchored,
bool eod) override;
// Construct a runtime implementation.
@ -627,8 +624,8 @@ public:
* overlap calculation in history assignment. */
std::map<u32, rose_literal_id> anchoredLitSuffix;
unordered_set<left_id> transient;
unordered_map<left_id, rose_group> rose_squash_masks;
ue2_unordered_set<left_id> transient;
ue2_unordered_map<left_id, rose_group> rose_squash_masks;
std::vector<OutfixInfo> outfixes;
@ -689,4 +686,22 @@ bool canImplementGraphs(const RoseBuildImpl &tbi);
} // namespace ue2
namespace std {
template<>
struct hash<ue2::left_id> {
size_t operator()(const ue2::left_id &l) const {
return l.hash();
}
};
template<>
struct hash<ue2::suffix_id> {
size_t operator()(const ue2::suffix_id &s) const {
return s.hash();
}
};
} // namespace std
#endif /* ROSE_BUILD_IMPL_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -36,10 +36,12 @@
#include "rose/rose_build_impl.h"
#include "util/container.h"
#include "util/dump_charclass.h"
#include "util/flat_containers.h"
#include "util/graph_range.h"
#include "util/graph.h"
#include "util/ue2_containers.h"
#include "util/hash.h"
#include "util/ue2string.h"
#include "util/unordered.h"
#include <algorithm>
#include <set>
@ -51,7 +53,7 @@ namespace ue2 {
static
bool couldEndLiteral(const ue2_literal &s, NFAVertex initial,
const NGHolder &h) {
ue2::flat_set<NFAVertex> curr, next;
flat_set<NFAVertex> curr, next;
curr.insert(initial);
for (auto it = s.rbegin(), ite = s.rend(); it != ite; ++it) {
@ -82,9 +84,10 @@ bool couldEndLiteral(const ue2_literal &s, NFAVertex initial,
return true;
}
using EdgeCache = ue2_unordered_set<pair<NFAVertex, NFAVertex>>;
static
void contractVertex(NGHolder &g, NFAVertex v,
ue2::unordered_set<pair<NFAVertex, NFAVertex>> &all_edges) {
void contractVertex(NGHolder &g, NFAVertex v, EdgeCache &all_edges) {
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u == v) {
continue; // self-edge
@ -144,8 +147,9 @@ u32 findMaxLiteralMatches(const NGHolder &h, const set<ue2_literal> &lits) {
cloneHolder(g, h);
vector<NFAVertex> dead;
// The set of all edges in the graph is used for existence checks in contractVertex.
ue2::unordered_set<pair<NFAVertex, NFAVertex>> all_edges;
// The set of all edges in the graph is used for existence checks in
// contractVertex.
EdgeCache all_edges;
for (const auto &e : edges_range(g)) {
all_edges.emplace(source(e, g), target(e, g));
}

View File

@ -39,6 +39,7 @@
#include "rose_build_lookaround.h"
#include "rose_build_program.h"
#include "util/hash.h"
#include "util/verify_types.h"
namespace ue2 {
@ -65,7 +66,7 @@ public:
/** \brief Length of the bytecode instruction in bytes. */
virtual size_t byte_length() const = 0;
using OffsetMap = unordered_map<const RoseInstruction *, u32>;
using OffsetMap = std::unordered_map<const RoseInstruction *, u32>;
/**
* \brief Writes a concrete implementation of this instruction.
@ -149,6 +150,10 @@ private:
}
};
template<RoseInstructionCode Opcode, class ImplType, class RoseInstrType>
constexpr RoseInstructionCode
RoseInstrBase<Opcode, ImplType, RoseInstrType>::opcode;
/**
* \brief Refinement of RoseInstrBase to use for instructions that have
* just a single target member, called "target".
@ -190,7 +195,7 @@ public:
virtual bool operator==(const RoseInstrType &) const { return true; }
size_t hash() const override {
return boost::hash_value(static_cast<int>(Opcode));
return hash_all(Opcode);
}
bool equiv_to(const RoseInstrType &, const RoseInstruction::OffsetMap &,
@ -222,7 +227,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), groups, anch_id);
return hash_all(opcode, groups, anch_id);
}
void write(void *dest, RoseEngineBlob &blob,
@ -251,7 +256,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), min_offset);
return hash_all(opcode, min_offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -278,7 +283,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), groups);
return hash_all(opcode, groups);
}
void write(void *dest, RoseEngineBlob &blob,
@ -305,7 +310,7 @@ public:
}
size_t hash() const override {
return boost::hash_value(static_cast<int>(opcode));
return hash_all(opcode);
}
void write(void *dest, RoseEngineBlob &blob,
@ -335,7 +340,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), min_bound, max_bound);
return hash_all(opcode, min_bound, max_bound);
}
void write(void *dest, RoseEngineBlob &blob,
@ -364,7 +369,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), key);
return hash_all(opcode, key);
}
void write(void *dest, RoseEngineBlob &blob,
@ -395,7 +400,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), offset, reach);
return hash_all(opcode, offset, reach);
}
void write(void *dest, RoseEngineBlob &blob,
@ -426,7 +431,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), look);
return hash_all(opcode, look);
}
void write(void *dest, RoseEngineBlob &blob,
@ -462,8 +467,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), and_mask, cmp_mask, neg_mask,
offset);
return hash_all(opcode, and_mask, cmp_mask, neg_mask, offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -501,8 +505,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), and_mask, cmp_mask, neg_mask,
offset);
return hash_all(opcode, and_mask, cmp_mask, neg_mask, offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -539,8 +542,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), and_mask, cmp_mask, negation,
offset);
return hash_all(opcode, and_mask, cmp_mask, negation, offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -581,8 +583,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), nib_mask,
bucket_select_mask, neg_mask, offset);
return hash_all(opcode, nib_mask, bucket_select_mask, neg_mask, offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -626,8 +627,8 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
bucket_select_mask, neg_mask, offset);
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask, neg_mask,
offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -671,8 +672,8 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
bucket_select_mask, neg_mask, offset);
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask, neg_mask,
offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -720,9 +721,8 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
bucket_select_mask_hi, bucket_select_mask_lo,
neg_mask, offset);
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask_hi,
bucket_select_mask_lo, neg_mask, offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -758,7 +758,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), queue, lag, report);
return hash_all(opcode, queue, lag, report);
}
void write(void *dest, RoseEngineBlob &blob,
@ -791,7 +791,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), queue, lag, report);
return hash_all(opcode, queue, lag, report);
}
void write(void *dest, RoseEngineBlob &blob,
@ -820,7 +820,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), delay, index);
return hash_all(opcode, delay, index);
}
void write(void *dest, RoseEngineBlob &blob,
@ -861,7 +861,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), distance);
return hash_all(opcode, distance);
}
void write(void *dest, RoseEngineBlob &blob,
@ -889,7 +889,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), queue, lag);
return hash_all(opcode, queue, lag);
}
void write(void *dest, RoseEngineBlob &blob,
@ -917,7 +917,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), som.type, som.onmatch);
return hash_all(opcode, som.type, som.onmatch);
}
void write(void *dest, RoseEngineBlob &blob,
@ -953,7 +953,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), cancel, queue, event);
return hash_all(opcode, cancel, queue, event);
}
void write(void *dest, RoseEngineBlob &blob,
@ -981,7 +981,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), queue, event);
return hash_all(opcode, queue, event);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1013,8 +1013,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), quash_som, dkey,
offset_adjust);
return hash_all(opcode, quash_som, dkey, offset_adjust);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1049,8 +1048,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), quash_som, dkey,
offset_adjust);
return hash_all(opcode, quash_som, dkey, offset_adjust);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1081,7 +1079,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), event, top_squash_distance);
return hash_all(opcode, event, top_squash_distance);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1110,7 +1108,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), som.type, som.onmatch);
return hash_all(opcode, som.type, som.onmatch);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1138,7 +1136,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), som.type, som.onmatch);
return hash_all(opcode, som.type, som.onmatch);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1165,7 +1163,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust);
return hash_all(opcode, onmatch, offset_adjust);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1196,7 +1194,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust, ekey);
return hash_all(opcode, onmatch, offset_adjust, ekey);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1225,7 +1223,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust);
return hash_all(opcode, onmatch, offset_adjust);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1256,7 +1254,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust, ekey);
return hash_all(opcode, onmatch, offset_adjust, ekey);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1293,8 +1291,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), quash_som, dkey, onmatch,
offset_adjust);
return hash_all(opcode, quash_som, dkey, onmatch, offset_adjust);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1324,7 +1321,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust);
return hash_all(opcode, onmatch, offset_adjust);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1352,7 +1349,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), ekey);
return hash_all(opcode, ekey);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1384,7 +1381,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), end_adj, min_length);
return hash_all(opcode, end_adj, min_length);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1410,7 +1407,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), index);
return hash_all(opcode, index);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1436,7 +1433,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), groups);
return hash_all(opcode, groups);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1462,7 +1459,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), groups);
return hash_all(opcode, groups);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1490,7 +1487,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), index);
return hash_all(opcode, index);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1522,9 +1519,9 @@ public:
}
size_t hash() const override {
size_t v = hash_all(static_cast<int>(opcode), num_keys);
size_t v = hash_all(opcode, num_keys);
for (const u32 &key : jump_table | boost::adaptors::map_keys) {
boost::hash_combine(v, key);
hash_combine(v, key);
}
return v;
}
@ -1594,7 +1591,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), state);
return hash_all(opcode, state);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1638,7 +1635,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), num_keys, keys);
return hash_all(opcode, num_keys, keys);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1665,7 +1662,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), iter_offset);
return hash_all(opcode, iter_offset);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1709,7 +1706,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), literal);
return hash_all(opcode, literal);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1741,7 +1738,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), literal);
return hash_all(opcode, literal);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1772,7 +1769,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), literal);
return hash_all(opcode, literal);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1804,7 +1801,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), literal);
return hash_all(opcode, literal);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1849,8 +1846,7 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), multi_look, last_start,
start_mask);
return hash_all(opcode, multi_look, last_start, start_mask);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1905,9 +1901,9 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), nib_mask,
bucket_select_mask, data_select_mask, hi_bits_mask,
lo_bits_mask, neg_mask, base_offset, last_start);
return hash_all(opcode, nib_mask, bucket_select_mask, data_select_mask,
hi_bits_mask, lo_bits_mask, neg_mask, base_offset,
last_start);
}
void write(void *dest, RoseEngineBlob &blob,
@ -1968,9 +1964,9 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
bucket_select_mask, data_select_mask, hi_bits_mask,
lo_bits_mask, neg_mask, base_offset, last_start);
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask,
data_select_mask, hi_bits_mask, lo_bits_mask, neg_mask,
base_offset, last_start);
}
void write(void *dest, RoseEngineBlob &blob,
@ -2035,10 +2031,9 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
bucket_select_mask_hi, bucket_select_mask_lo,
data_select_mask, hi_bits_mask, lo_bits_mask, neg_mask,
base_offset, last_start);
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask_hi,
bucket_select_mask_lo, data_select_mask, hi_bits_mask,
lo_bits_mask, neg_mask, base_offset, last_start);
}
void write(void *dest, RoseEngineBlob &blob,
@ -2100,9 +2095,9 @@ public:
}
size_t hash() const override {
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
bucket_select_mask, data_select_mask, hi_bits_mask,
lo_bits_mask, neg_mask, base_offset, last_start);
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask,
data_select_mask, hi_bits_mask, lo_bits_mask, neg_mask,
base_offset, last_start);
}
void write(void *dest, RoseEngineBlob &blob,

View File

@ -40,7 +40,7 @@
#include "util/container.h"
#include "util/dump_charclass.h"
#include "util/graph_range.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/verify_types.h"
#include <cstdlib>
@ -79,7 +79,7 @@ string dump(const map<s32, CharReach> &look) {
static
void getForwardReach(const NGHolder &g, u32 top, map<s32, CharReach> &look) {
ue2::flat_set<NFAVertex> curr, next;
flat_set<NFAVertex> curr, next;
// Consider only successors of start with the required top.
for (const auto &e : out_edges_range(g.start, g)) {
@ -116,7 +116,7 @@ void getForwardReach(const NGHolder &g, u32 top, map<s32, CharReach> &look) {
static
void getBackwardReach(const NGHolder &g, ReportID report, u32 lag,
map<s32, CharReach> &look) {
ue2::flat_set<NFAVertex> curr, next;
flat_set<NFAVertex> curr, next;
for (auto v : inv_adjacent_vertices_range(g.accept, g)) {
if (contains(g[v].reports, report)) {
@ -187,7 +187,7 @@ void getForwardReach(const raw_dfa &rdfa, map<s32, CharReach> &look) {
return;
}
ue2::flat_set<dstate_id_t> curr, next;
flat_set<dstate_id_t> curr, next;
curr.insert(rdfa.start_anchored);
for (u32 i = 0; i < MAX_FWD_LEN && !curr.empty(); i++) {
@ -849,7 +849,7 @@ void mergeLookaround(vector<LookEntry> &lookaround,
}
// Don't merge lookarounds at offsets we already have entries for.
ue2::flat_set<s8> offsets;
flat_set<s8> offsets;
for (const auto &e : lookaround) {
offsets.insert(e.offset);
}

View File

@ -33,6 +33,7 @@
#define ROSE_ROSE_BUILD_LOOKAROUND_H
#include "rose_graph.h"
#include "util/hash.h"
#include <vector>
@ -58,14 +59,6 @@ struct LookEntry {
}
};
static inline
size_t hash_value(const LookEntry &l) {
size_t val = 0;
boost::hash_combine(val, l.offset);
boost::hash_combine(val, l.reach);
return val;
}
void findLookaroundMasks(const RoseBuildImpl &tbi, const RoseVertex v,
std::vector<LookEntry> &look_more);
@ -83,4 +76,15 @@ void mergeLookaround(std::vector<LookEntry> &lookaround,
} // namespace ue2
namespace std {
template<>
struct hash<ue2::LookEntry> {
size_t operator()(const ue2::LookEntry &l) const {
return ue2::hash_all(l.offset, l.reach);
}
};
} // namespace std
#endif // ROSE_ROSE_BUILD_LOOKAROUND_H

View File

@ -63,9 +63,11 @@
#include "util/container.h"
#include "util/dump_charclass.h"
#include "util/graph_range.h"
#include "util/hash.h"
#include "util/order_check.h"
#include "util/report_manager.h"
#include "util/ue2string.h"
#include "util/unordered.h"
#include <algorithm>
#include <functional>
@ -77,12 +79,10 @@
#include <vector>
#include <utility>
#include <boost/functional/hash/hash_fwd.hpp>
#include <boost/range/adaptor/map.hpp>
using namespace std;
using boost::adaptors::map_values;
using boost::hash_combine;
namespace ue2 {
@ -336,7 +336,7 @@ void findUncalcLeavesCandidates(RoseBuildImpl &tbi,
const RoseGraph &g = tbi.g;
vector<RoseVertex> suffix_vertices; // vertices with suffix graphs
ue2::unordered_map<const NGHolder *, u32> fcount; // ref count per graph
unordered_map<const NGHolder *, u32> fcount; // ref count per graph
for (auto v : vertices_range(g)) {
if (g[v].suffix) {
@ -566,7 +566,7 @@ bool dedupeLeftfixes(RoseBuildImpl &tbi) {
for (deque<RoseVertex> &verts : roses | map_values) {
DEBUG_PRINTF("group has %zu vertices\n", verts.size());
ue2::unordered_set<left_id> seen;
unordered_set<left_id> seen;
for (auto jt = verts.begin(), jte = verts.end(); jt != jte; ++jt) {
RoseVertex v = *jt;
@ -636,7 +636,7 @@ bool is_equal(const suffix_id &s1, const suffix_id &s2) {
void dedupeSuffixes(RoseBuildImpl &tbi) {
DEBUG_PRINTF("deduping suffixes\n");
ue2::unordered_map<suffix_id, set<RoseVertex>> suffix_map;
unordered_map<suffix_id, set<RoseVertex>> suffix_map;
map<pair<size_t, set<ReportID>>, vector<suffix_id>> part;
// Collect suffixes into groups.
@ -703,7 +703,7 @@ template<class EngineRef>
class Bouquet {
private:
list<EngineRef> ordering; // Unique list in insert order.
typedef ue2::unordered_map<EngineRef, deque<RoseVertex> > BouquetMap;
using BouquetMap = ue2_unordered_map<EngineRef, deque<RoseVertex>>;
BouquetMap bouquet;
public:
void insert(const EngineRef &h, RoseVertex v) {
@ -1331,7 +1331,7 @@ bool mergeRosePair(RoseBuildImpl &tbi, left_id &r1, left_id &r2,
static
void processMergeQueue(RoseBuildImpl &tbi, RoseBouquet &roses,
priority_queue<RoseMergeCandidate> &pq) {
ue2::unordered_set<left_id> dead;
unordered_set<left_id> dead;
DEBUG_PRINTF("merge queue has %zu entries\n", pq.size());
@ -1862,7 +1862,7 @@ void mergeNfaLeftfixes(RoseBuildImpl &tbi, RoseBouquet &roses) {
// We track the number of accelerable states for each graph in a map and
// only recompute them when the graph is modified.
ue2::unordered_map<left_id, u32> accel_count;
unordered_map<left_id, u32> accel_count;
for (const auto &rose : roses) {
assert(rose.graph()->kind == NFA_INFIX);
accel_count[rose] = estimatedAccelStates(tbi, *rose.graph());
@ -2157,7 +2157,7 @@ void mergeSuffixes(RoseBuildImpl &tbi, SuffixBouquet &suffixes,
// If this isn't an acyclic case, we track the number of accelerable states
// for each graph in a map and only recompute them when the graph is
// modified.
ue2::unordered_map<suffix_id, u32> accel_count;
unordered_map<suffix_id, u32> accel_count;
if (!acyclic) {
for (const auto &suffix : suffixes) {
assert(suffix.graph() && suffix.graph()->kind == NFA_SUFFIX);
@ -2499,7 +2499,7 @@ private:
template<class RawDfa, class MergeFunctor>
static
void pairwiseDfaMerge(vector<RawDfa *> &dfas,
ue2::unordered_map<RawDfa *, size_t> &dfa_mapping,
unordered_map<RawDfa *, size_t> &dfa_mapping,
vector<OutfixInfo> &outfixes,
MergeFunctor merge_func) {
DEBUG_PRINTF("merging group of size %zu\n", dfas.size());
@ -2541,7 +2541,7 @@ void pairwiseDfaMerge(vector<RawDfa *> &dfas,
template<class RawDfa, class MergeFunctor>
static
void chunkedDfaMerge(vector<RawDfa *> &dfas,
ue2::unordered_map<RawDfa *, size_t> &dfa_mapping,
unordered_map<RawDfa *, size_t> &dfa_mapping,
vector<OutfixInfo> &outfixes,
MergeFunctor merge_func) {
DEBUG_PRINTF("begin merge of %zu dfas\n", dfas.size());
@ -2575,7 +2575,7 @@ void mergeOutfixDfas(RoseBuildImpl &tbi, vector<raw_dfa *> &dfas) {
/* key is index into outfix array as iterators, etc may be invalidated by
* element addition. */
ue2::unordered_map<raw_dfa *, size_t> dfa_mapping;
unordered_map<raw_dfa *, size_t> dfa_mapping;
for (size_t i = 0; i < outfixes.size(); i++) {
auto *rdfa = outfixes[i].rdfa();
if (rdfa) {
@ -2619,7 +2619,7 @@ void mergeOutfixCombo(RoseBuildImpl &tbi, const ReportManager &rm,
/* key is index into outfix array as iterators, etc may be invalidated by
* element addition. */
size_t new_dfas = 0;
ue2::unordered_map<raw_dfa *, size_t> dfa_mapping;
unordered_map<raw_dfa *, size_t> dfa_mapping;
vector<raw_dfa *> dfas;
for (auto it = tbi.outfixes.begin(); it != tbi.outfixes.end(); ++it) {
@ -2670,7 +2670,7 @@ void mergeOutfixHaigs(RoseBuildImpl &tbi, vector<raw_som_dfa *> &dfas,
vector<OutfixInfo> &outfixes = tbi.outfixes;
ue2::unordered_map<raw_som_dfa *, size_t> dfa_mapping;
unordered_map<raw_som_dfa *, size_t> dfa_mapping;
for (size_t i = 0; i < outfixes.size(); i++) {
auto *haig = outfixes[i].haig();
if (haig) {

View File

@ -56,11 +56,9 @@
#include "ue2common.h"
#include "grey.h"
#include <boost/functional/hash/hash_fwd.hpp>
#include <boost/graph/breadth_first_search.hpp>
using namespace std;
using boost::hash_combine;
namespace ue2 {
@ -691,16 +689,7 @@ set<u32> all_tops(const suffix_id &s) {
}
size_t suffix_id::hash() const {
size_t val = 0;
hash_combine(val, g);
hash_combine(val, c);
hash_combine(val, d);
hash_combine(val, h);
return val;
}
size_t hash_value(const suffix_id &s) {
return s.hash();
return hash_all(g, c, d, h);
}
bool isAnchored(const left_id &r) {
@ -761,16 +750,7 @@ u32 num_tops(const left_id &r) {
}
size_t left_id::hash() const {
size_t val = 0;
hash_combine(val, g);
hash_combine(val, c);
hash_combine(val, d);
hash_combine(val, h);
return val;
}
size_t hash_value(const left_id &r) {
return r.hash();
return hash_all(g, c, d, h);
}
u64a findMaxOffset(const set<ReportID> &reports, const ReportManager &rm) {
@ -997,8 +977,8 @@ bool canImplementGraphs(const RoseBuildImpl &tbi) {
bool hasOrphanedTops(const RoseBuildImpl &build) {
const RoseGraph &g = build.g;
ue2::unordered_map<left_id, set<u32> > roses;
ue2::unordered_map<suffix_id, set<u32> > suffixes;
unordered_map<left_id, set<u32>> roses;
unordered_map<suffix_id, set<u32>> suffixes;
for (auto v : vertices_range(g)) {
if (g[v].left) {

View File

@ -41,6 +41,7 @@
#include "util/compile_context.h"
#include "util/compile_error.h"
#include "util/report_manager.h"
#include "util/unordered.h"
#include "util/verify_types.h"
#include <boost/range/adaptor/map.hpp>
@ -226,7 +227,7 @@ size_t RoseProgramHash::operator()(const RoseProgram &program) const {
size_t v = 0;
for (const auto &ri : program) {
assert(ri);
boost::hash_combine(v, ri->hash());
hash_combine(v, ri->hash());
}
return v;
}
@ -1934,14 +1935,14 @@ void makeGroupSquashInstruction(const RoseBuildImpl &build, u32 lit_id,
namespace {
struct ProgKey {
ProgKey(const RoseProgram &p) : prog(&p) { }
ProgKey(const RoseProgram &p) : prog(&p) {}
bool operator==(const ProgKey &b) const {
return RoseProgramEquivalence()(*prog, *b.prog);
}
friend size_t hash_value(const ProgKey &a) {
return RoseProgramHash()(*a.prog);
size_t hash() const {
return RoseProgramHash()(*prog);
}
private:
const RoseProgram *prog;
@ -1954,7 +1955,7 @@ RoseProgram assembleProgramBlocks(vector<RoseProgram> &&blocks_in) {
vector<RoseProgram> blocks;
blocks.reserve(blocks_in.size()); /* to ensure stable reference for seen */
unordered_set<ProgKey> seen;
ue2_unordered_set<ProgKey> seen;
for (auto &block : blocks_in) {
if (contains(seen, block)) {
continue;

View File

@ -34,8 +34,8 @@
#include "util/bytecode_ptr.h"
#include "util/hash.h"
#include "util/make_unique.h"
#include "util/ue2_containers.h"
#include <unordered_map>
#include <vector>
#include <boost/range/adaptor/map.hpp>
@ -168,7 +168,7 @@ struct ProgramBuild : noncopyable {
/** \brief Mapping from vertex to key, for vertices with a
* CHECK_NOT_HANDLED instruction. */
ue2::unordered_map<RoseVertex, u32> handledKeys;
std::unordered_map<RoseVertex, u32> handledKeys;
/** \brief Mapping from Rose literal ID to anchored program index. */
std::map<u32, u32> anchored_programs;
@ -178,7 +178,7 @@ struct ProgramBuild : noncopyable {
/** \brief Mapping from every vertex to the groups that must be on for that
* vertex to be reached. */
ue2::unordered_map<RoseVertex, rose_group> vertex_group_map;
std::unordered_map<RoseVertex, rose_group> vertex_group_map;
/** \brief Global bitmap of groups that can be squashed. */
rose_group squashable_groups = 0;
@ -242,7 +242,7 @@ RoseProgram makeLiteralProgram(const RoseBuildImpl &build,
const std::map<RoseVertex, left_build_info> &leftfix_info,
const std::map<suffix_id, u32> &suffixes,
const std::map<u32, engine_info> &engine_info_by_queue,
const unordered_map<RoseVertex, u32> &roleStateIndices,
const std::unordered_map<RoseVertex, u32> &roleStateIndices,
ProgramBuild &prog_build, u32 lit_id,
const std::vector<RoseEdge> &lit_edges,
bool is_anchored_replay_program);

View File

@ -45,16 +45,15 @@
#include "util/bitutils.h"
#include "util/compile_context.h"
#include "util/container.h"
#include "util/flat_containers.h"
#include "util/graph.h"
#include "util/graph_range.h"
#include "util/hash.h"
#include "util/order_check.h"
#include "util/ue2_containers.h"
#include <algorithm>
#include <numeric>
#include <vector>
#include <boost/functional/hash/hash.hpp>
#include <boost/graph/adjacency_iterator.hpp>
#include <boost/range/adaptor/map.hpp>
@ -154,7 +153,7 @@ public:
private:
/* if a vertex is worth storing, it is worth storing twice */
set<RoseVertex> main_cont; /* deterministic iterator */
ue2::unordered_set<RoseVertex> hash_cont; /* member checks */
unordered_set<RoseVertex> hash_cont; /* member checks */
};
struct RoseAliasingInfo {
@ -175,10 +174,10 @@ struct RoseAliasingInfo {
}
/** \brief Mapping from leftfix to vertices. */
ue2::unordered_map<left_id, set<RoseVertex>> rev_leftfix;
unordered_map<left_id, set<RoseVertex>> rev_leftfix;
/** \brief Mapping from undelayed ghost to delayed vertices. */
ue2::unordered_map<RoseVertex, set<RoseVertex>> rev_ghost;
unordered_map<RoseVertex, set<RoseVertex>> rev_ghost;
};
} // namespace
@ -787,7 +786,7 @@ void updateEdgeTops(RoseGraph &g, RoseVertex v, const map<u32, u32> &top_map) {
static
void pruneUnusedTops(CastleProto &castle, const RoseGraph &g,
const set<RoseVertex> &verts) {
ue2::unordered_set<u32> used_tops;
unordered_set<u32> used_tops;
for (auto v : verts) {
assert(g[v].left.castle.get() == &castle);
@ -818,7 +817,7 @@ void pruneUnusedTops(NGHolder &h, const RoseGraph &g,
}
assert(isCorrectlyTopped(h));
DEBUG_PRINTF("pruning unused tops\n");
ue2::flat_set<u32> used_tops;
flat_set<u32> used_tops;
for (auto v : verts) {
assert(g[v].left.graph.get() == &h);
@ -1415,7 +1414,7 @@ void removeSingletonBuckets(vector<vector<RoseVertex>> &buckets) {
static
void buildInvBucketMap(const vector<vector<RoseVertex>> &buckets,
ue2::unordered_map<RoseVertex, size_t> &inv) {
unordered_map<RoseVertex, size_t> &inv) {
inv.clear();
for (size_t i = 0; i < buckets.size(); i++) {
for (auto v : buckets[i]) {
@ -1469,7 +1468,7 @@ void splitByReportSuffixBehaviour(const RoseGraph &g,
vector<vector<RoseVertex>> &buckets) {
// Split by report set and suffix info.
auto make_split_key = [&g](RoseVertex v) {
return hash_all(g[v].reports, g[v].suffix);
return hash_all(g[v].reports, suffix_id(g[v].suffix));
};
splitAndFilterBuckets(buckets, make_split_key);
}
@ -1483,14 +1482,15 @@ void splitByLiteralTable(const RoseBuildImpl &build,
auto make_split_key = [&](RoseVertex v) {
const auto &lits = g[v].literals;
assert(!lits.empty());
return build.literals.at(*lits.begin()).table;
auto table = build.literals.at(*lits.begin()).table;
return std::underlying_type<decltype(table)>::type(table);
};
splitAndFilterBuckets(buckets, make_split_key);
}
static
void splitByNeighbour(const RoseGraph &g, vector<vector<RoseVertex>> &buckets,
ue2::unordered_map<RoseVertex, size_t> &inv, bool succ) {
unordered_map<RoseVertex, size_t> &inv, bool succ) {
vector<vector<RoseVertex>> extras;
map<size_t, vector<RoseVertex>> neighbours_by_bucket;
set<RoseVertex> picked;
@ -1575,7 +1575,7 @@ splitDiamondMergeBuckets(CandidateSet &candidates, const RoseBuildImpl &build) {
}
// Neighbour splits require inverse map.
ue2::unordered_map<RoseVertex, size_t> inv;
unordered_map<RoseVertex, size_t> inv;
buildInvBucketMap(buckets, inv);
splitByNeighbour(g, buckets, inv, true);

View File

@ -43,7 +43,7 @@
#include "nfa/nfa_internal.h" // for MO_INVALID_IDX
#include "util/charreach.h"
#include "util/depth.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/ue2_graph.h"
#include <memory>

View File

@ -45,7 +45,7 @@
#include "ue2common.h"
#include "rose/rose_common.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include "util/ue2_graph.h"
#include "util/ue2string.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -36,7 +36,6 @@
#include "util/container.h"
#include "util/graph_range.h"
#include "util/make_unique.h"
#include "util/ue2_containers.h"
#include <vector>

View File

@ -40,6 +40,7 @@
#include "nfagraph/ng_som_util.h"
#include "nfagraph/ng_region.h"
#include "util/charreach.h"
#include "util/hash.h"
#include "util/make_unique.h"
#include "util/dump_charclass.h"
#include "util/verify_types.h"
@ -48,8 +49,6 @@
#include <deque>
#include <utility>
#include <boost/functional/hash/hash.hpp>
using namespace std;
namespace ue2 {
@ -67,13 +66,8 @@ SlotCacheEntry::SlotCacheEntry(const NGHolder &prefix_in,
size_t SlotEntryHasher::operator()(const SlotCacheEntry &e) const {
assert(e.prefix);
using boost::hash_combine;
size_t v = 0;
hash_combine(v, hash_holder(*e.prefix));
hash_combine(v, e.parent_slot);
hash_combine(v, e.is_reset);
hash_combine(v, e.escapes.hash());
size_t v = hash_all(hash_holder(*e.prefix), e.parent_slot,
e.is_reset, e.escapes);
DEBUG_PRINTF("%zu vertices, parent_slot=%u, escapes=%s, is_reset=%d "
"hashes to %zx\n", num_vertices(*e.prefix), e.parent_slot,
@ -143,7 +137,7 @@ u32 SomSlotManager::getSomSlot(const NGHolder &prefix,
u32 SomSlotManager::getInitialResetSomSlot(const NGHolder &prefix,
const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const unordered_map<NFAVertex, u32> &region_map,
u32 last_sent_region, bool *prefix_already_implemented) {
DEBUG_PRINTF("getting initial reset; last sent region %u\n",
last_sent_region);
@ -171,9 +165,9 @@ u32 SomSlotManager::getInitialResetSomSlot(const NGHolder &prefix,
// Clone a copy of g (and its region map) that we will be able to store
// later on.
shared_ptr<NGHolder> gg = make_shared<NGHolder>();
ue2::unordered_map<NFAVertex, NFAVertex> orig_to_copy;
unordered_map<NFAVertex, NFAVertex> orig_to_copy;
cloneHolder(*gg, g, &orig_to_copy);
ue2::unordered_map<NFAVertex, u32> gg_region_map;
unordered_map<NFAVertex, u32> gg_region_map;
for (const auto &m : region_map) {
assert(contains(region_map, m.first));
gg_region_map.emplace(orig_to_copy.at(m.first), m.second);

View File

@ -38,10 +38,10 @@
#include "nfagraph/ng_holder.h"
#include "util/bytecode_ptr.h"
#include "util/noncopyable.h"
#include "util/ue2_containers.h"
#include <deque>
#include <memory>
#include <unordered_map>
struct NFA;
@ -69,7 +69,7 @@ public:
/** prefix must be acting as a resetting sentinel and should be a dag (if
* not how are we establish som?) */
u32 getInitialResetSomSlot(const NGHolder &prefix, const NGHolder &g,
const ue2::unordered_map<NFAVertex, u32> &region_map,
const std::unordered_map<NFAVertex, u32> &region_map,
u32 last_sent_region,
bool *prefix_already_implemented);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -32,10 +32,11 @@
#include "nfagraph/ng.h"
#include "nfagraph/ng_is_equal.h"
#include "util/charreach.h"
#include "util/ue2_containers.h"
#include "ue2common.h"
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace ue2 {
@ -43,14 +44,14 @@ namespace ue2 {
struct InitialResetEntry {
InitialResetEntry(std::shared_ptr<const NGHolder> sent_in,
std::shared_ptr<const NGHolder> body_in,
const ue2::unordered_map<NFAVertex, u32> &body_regions_in,
const std::unordered_map<NFAVertex, u32> &body_regions_in,
u32 sent_region_in, u32 first_bad_region_in)
: sent(sent_in), body(body_in), body_regions(body_regions_in),
sent_region(sent_region_in), first_bad_region(first_bad_region_in) {}
std::shared_ptr<const NGHolder> sent;
std::shared_ptr<const NGHolder> body;
ue2::unordered_map<NFAVertex, u32> body_regions;
std::unordered_map<NFAVertex, u32> body_regions;
u32 sent_region;
u32 first_bad_region; /* ~0U if it must cover the whole g */
};
@ -85,7 +86,7 @@ struct SlotEntryEqual {
};
struct SlotCache {
typedef ue2::unordered_set<SlotCacheEntry, SlotEntryHasher,
typedef std::unordered_set<SlotCacheEntry, SlotEntryHasher,
SlotEntryEqual> CacheStore;
void insert(const NGHolder &prefix, const CharReach &escapes,
@ -96,7 +97,7 @@ struct SlotCache {
CacheStore store;
ue2::unordered_set<std::shared_ptr<const NGHolder>, NGHolderHasher,
std::unordered_set<std::shared_ptr<const NGHolder>, NGHolderHasher,
NGHolderEqual> initial_prefixes;
std::vector<InitialResetInfo> initial_resets;
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Intel Corporation
* Copyright (c) 2016-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -30,7 +30,7 @@
#define ACCEL_SCHEME_H
#include "util/charreach.h"
#include "util/ue2_containers.h"
#include "util/flat_containers.h"
#include <utility>
@ -39,7 +39,7 @@ namespace ue2 {
#define MAX_ACCEL_DEPTH 4
struct AccelScheme {
flat_set<std::pair<u8, u8> > double_byte;
flat_set<std::pair<u8, u8>> double_byte;
CharReach cr = CharReach::dot();
CharReach double_cr;
u32 offset = MAX_ACCEL_DEPTH + 1;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -36,12 +36,12 @@
#include "ue2common.h"
#include "popcount.h"
#include "util/bitutils.h"
#include "util/hash.h"
#include <array>
#include <cassert>
#include <boost/dynamic_bitset.hpp>
#include <boost/functional/hash/hash.hpp>
namespace ue2 {
@ -373,7 +373,7 @@ public:
/// Simple hash.
size_t hash() const {
return boost::hash_range(std::begin(bits), std::end(bits));
return ue2_hasher()(bits);
}
/// Sentinel value meaning "no more bits", used by find_first and
@ -420,12 +420,17 @@ private:
std::array<block_type, num_blocks> bits;
};
/** \brief Boost-style hash free function. */
template<size_t requested_size>
size_t hash_value(const bitfield<requested_size> &b) {
return b.hash();
}
} // namespace ue2
namespace std {
template<size_t requested_size>
struct hash<ue2::bitfield<requested_size>> {
size_t operator()(const ue2::bitfield<requested_size> &b) const {
return b.hash();
}
};
} // namespace std
#endif // BITFIELD_H

Some files were not shown because too many files have changed in this diff Show More