22#ifndef BACKENDS_TOFINO_BF_P4C_MIDEND_COLLECT_PIPELINES_H_
23#define BACKENDS_TOFINO_BF_P4C_MIDEND_COLLECT_PIPELINES_H_
26#include <unordered_map>
29#include "frontends/common/resolveReferences/referenceMap.h"
44 bool preorder(
const IR::Declaration_Instance *)
override;
49 const IR::BFN::TnaParser *parser =
nullptr;
50 const IR::BFN::TnaControl *control =
nullptr;
51 const IR::BFN::TnaDeparser *deparser =
nullptr;
64 const IR::BFN::TnaControl *ghost =
nullptr;
65 const IR::Declaration_Instance *dec =
nullptr;
75 using PipeSet = std::set<Pipe>;
82 std::vector<Pipe> pipes;
83 std::map<const IR::Type_Declaration *, std::unordered_set<int>,
87 PipeSet _get(
const IR::Type_Declaration *dec)
const {
88 auto it = declarationToPipe.find(dec);
89 BUG_CHECK(it != declarationToPipe.end(),
"Declaration %1% not found in pipes", dec);
91 for (
int idx : it->second) out.insert(pipes[idx]);
96 std::vector<Pipe>::const_iterator begin()
const {
return pipes.begin(); }
97 std::vector<Pipe>::const_iterator end()
const {
return pipes.end(); }
100 PipeSet
get(
const IR::BFN::TnaParser *p)
const {
return _get(p); }
102 PipeSet
get(
const IR::BFN::TnaDeparser *d)
const {
return _get(d); }
104 PipeSet
get(
const IR::BFN::TnaControl *c)
const {
return _get(c); }
109 Pipelines *pipelines;
110 std::unordered_map<const IR::IDeclaration *, Pipe> pipesByDec;
116 : refMap(refMap), pipelines(pipelines) {}
Definition collect_pipelines.h:58
bool operator==(const Pipe &) const
Definition collect_pipelines.cpp:73
bool operator<(const Pipe &) const
A total order given by declaration names (i.e. consistent with ==).
Definition collect_pipelines.cpp:77
Definition collect_pipelines.h:80
PipeSet get(const IR::BFN::TnaControl *c) const
Set of all pipes using this control.
Definition collect_pipelines.h:104
PipeSet get(const IR::BFN::TnaParser *p) const
Set of all pipes using this parser.
Definition collect_pipelines.h:100
PipeSet get(const IR::BFN::TnaDeparser *d) const
Set of all pipes using this deparser.
Definition collect_pipelines.h:102
The Declaration interface, representing objects with names.
Definition declaration.h:26
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
CollectPipelines(P4::ReferenceMap *refMap, Pipelines *pipelines)
Definition collect_pipelines.h:115
Inspector pass that collects information about all pipelines declared in the Switch....
Definition collect_pipelines.h:42
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
Description ingress or egress.
Definition collect_pipelines.h:48