source: icGREP/icgrep-devel/icgrep/re/collect_ccs.cpp @ 6237

Last change on this file since 6237 was 6184, checked in by nmedfort, 10 months ago

Initial version of PipelineKernel? + revised StreamSet? model.

File size: 1.4 KB
Line 
1#include "collect_ccs.h"
2#include <cc/alphabet.h>
3#include <re/re_name.h>
4#include <re/re_any.h>
5#include <re/re_alt.h>
6#include <re/re_cc.h>
7#include <re/re_seq.h>
8#include <re/re_rep.h>
9#include <re/re_range.h>
10#include <re/re_diff.h>
11#include <re/re_intersect.h>
12#include <re/re_assertion.h>
13#include <cc/alphabet.h>
14#include <re/re_toolchain.h>
15
16#include <boost/container/flat_set.hpp>
17#include <llvm/Support/raw_ostream.h>
18
19using namespace llvm;
20
21namespace re {
22   
23struct SetCollector final : public RE_Inspector {
24
25    SetCollector(const cc::Alphabet * alphabet, const std::set<Name *> & ignoredExternals, std::vector<CC *> & ccs)
26    : RE_Inspector(InspectionMode::IgnoreNonUnique)
27    , alphabet(alphabet)
28    , ignoredExternals(ignoredExternals)
29    , ccs(ccs) {
30
31    }
32
33    void inspectName(Name * n) final {
34        if (ignoredExternals.count(n) == 0) {
35            RE_Inspector::inspectName(n);
36        }
37    }
38
39    void inspectCC(CC * cc) final {
40        if (LLVM_LIKELY(cc->getAlphabet() == alphabet)) {
41            ccs.push_back(cc);
42        }
43    }
44
45private:
46    const cc::Alphabet * const alphabet;
47    const std::set<Name *> & ignoredExternals;
48    std::vector<CC *> & ccs;
49};
50
51
52std::vector<CC *> collectCCs(RE * const re, const cc::Alphabet & a, std::set<Name *> external) {
53    std::vector<CC *> ccs;
54    SetCollector collector(&a, external, ccs);
55    collector.inspectRE(re);
56    return ccs;
57}
58
59
60
61}
Note: See TracBrowser for help on using the repository browser.