mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 03:34:25 +03:00
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:
committed by
Matthew Barr
parent
a425bb9b7c
commit
9cf66b6ac9
@@ -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>
|
||||
|
@@ -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));
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -176,7 +176,7 @@ public:
|
||||
: g(g_in), rm(&rm_in) {}
|
||||
|
||||
NFAWriter(const GraphT &g_in,
|
||||
const ue2::unordered_map<NFAVertex, u32> ®ion_map_in)
|
||||
const unordered_map<NFAVertex, u32> ®ion_map_in)
|
||||
: g(g_in), region_map(®ion_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> ®ion_map) {
|
||||
const unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_map,
|
||||
unsigned int stageNumber, const char *stageName,
|
||||
const Grey &grey) {
|
||||
if (grey.dumpFlags & Grey::DUMP_INT_GRAPH) {
|
||||
|
@@ -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> ®ion_map,
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
UNUSED const std::unordered_map<NFAVertex, u32> ®ion_map,
|
||||
UNUSED unsigned int stageNumber, UNUSED const char *name,
|
||||
UNUSED const Grey &grey) {
|
||||
#ifdef DUMP_SUPPORT
|
||||
|
@@ -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>
|
||||
|
@@ -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.
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -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()) {
|
||||
|
@@ -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 {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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>
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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);
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -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>
|
||||
|
@@ -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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_map,
|
||||
map<u32, RegionInfo> ®ions, 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> ®ion_map) {
|
||||
const unordered_map<NFAVertex, u32> ®ion_map) {
|
||||
map<u32, RegionInfo> regions;
|
||||
for (auto v : vertices_range(h)) {
|
||||
if (is_special(v, h)) {
|
||||
|
@@ -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;
|
||||
|
@@ -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)) {
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -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> ®ion_map) {
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map) {
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map) {
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map) {
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map) {
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map) {
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map) {
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_map) {
|
||||
assert(isRegionEntry(g, v, region_map));
|
||||
|
||||
DEBUG_PRINTF("check if r%u is optional (inspecting v%zu)\n",
|
||||
|
@@ -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> ®ion_map) {
|
||||
const unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_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> ®ion_map) {
|
||||
const unordered_map<NFAVertex, u32> ®ion_map) {
|
||||
map<u32, RegionInfo> info;
|
||||
|
||||
for (auto v : vertices_range(g)) {
|
||||
|
@@ -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(),
|
||||
rsi.vertices.end());
|
||||
ue2::unordered_set<NFAVertex> tail(involved); // to look for back-edges.
|
||||
ue2::unordered_set<NFAVertex> pred, succ;
|
||||
unordered_set<NFAVertex> involved(rsi.vertices.begin(),
|
||||
rsi.vertices.end());
|
||||
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,16 +833,16 @@ 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(),
|
||||
rsi.vertices.end());
|
||||
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,8 +998,8 @@ 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 Grey &grey, ReachSubgraph &rsi) {
|
||||
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,
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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 {
|
||||
|
@@ -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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
makePrefix(const NGHolder &g, const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
void expandGraph(NGHolder &g, unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
|
||||
static
|
||||
bool doTreePlanningIntl(NGHolder &g,
|
||||
const ue2::unordered_map<NFAVertex, u32> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ©_to_orig,
|
||||
const unordered_map<NFAVertex, NFAVertex> ©_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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
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> ®ions,
|
||||
const unordered_map<NFAVertex, u32> ®ions,
|
||||
const map<u32, region_info> &info,
|
||||
const map<u32, region_info>::const_iterator &picked,
|
||||
vector<DepthMinMax> *depths, bool prefix_by_rev,
|
||||
|
@@ -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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_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)) {
|
||||
|
@@ -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> ®ion_map,
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
const std::unordered_map<NFAVertex, u32> ®ion_map,
|
||||
const NGHolder &sent, u32 last_head_region,
|
||||
u32 *bad_region);
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_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> ®ion_map,
|
||||
const unordered_map<NFAVertex, u32> ®ion_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]);
|
||||
|
@@ -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;
|
||||
|
||||
/**
|
||||
|
@@ -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,8 +71,8 @@ template <typename Graph>
|
||||
NFAUndirectedGraph createUnGraph(const Graph &g,
|
||||
bool excludeStarts,
|
||||
bool excludeAccepts,
|
||||
unordered_map<typename Graph::vertex_descriptor,
|
||||
NFAUndirectedVertex> &old2new) {
|
||||
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));
|
||||
|
@@ -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)));
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user