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

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

Initial version of PipelineKernel? + revised StreamSet? model.

File size: 1.4 KB
RevLine 
[5934]1#include "collect_ccs.h"
2#include <cc/alphabet.h>
[5565]3#include <re/re_name.h>
[5631]4#include <re/re_any.h>
[5565]5#include <re/re_alt.h>
6#include <re/re_cc.h>
7#include <re/re_seq.h>
8#include <re/re_rep.h>
[5772]9#include <re/re_range.h>
[5565]10#include <re/re_diff.h>
11#include <re/re_intersect.h>
12#include <re/re_assertion.h>
[5796]13#include <cc/alphabet.h>
[6173]14#include <re/re_toolchain.h>
[5935]15
[5565]16#include <boost/container/flat_set.hpp>
[5796]17#include <llvm/Support/raw_ostream.h>
[5565]18
19using namespace llvm;
20
21namespace re {
[5631]22   
[6173]23struct SetCollector final : public RE_Inspector {
[5565]24
[6173]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);
[5565]36        }
[6173]37    }
38
39    void inspectCC(CC * cc) final {
40        if (LLVM_LIKELY(cc->getAlphabet() == alphabet)) {
41            ccs.push_back(cc);
[5935]42        }
[5565]43    }
[5748]44
[6173]45private:
46    const cc::Alphabet * const alphabet;
47    const std::set<Name *> & ignoredExternals;
48    std::vector<CC *> & ccs;
49};
50
51
[6184]52std::vector<CC *> collectCCs(RE * const re, const cc::Alphabet & a, std::set<Name *> external) {
[6173]53    std::vector<CC *> ccs;
[6184]54    SetCollector collector(&a, external, ccs);
[6173]55    collector.inspectRE(re);
56    return ccs;
[5631]57}
[5565]58
[5748]59
60
[5565]61}
Note: See TracBrowser for help on using the repository browser.