Skip to content

Commit

Permalink
support for directCounterMap (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Calin Cascaval authored and Han Wang committed May 4, 2017
1 parent 258a5c3 commit add976f
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 100 deletions.
4 changes: 2 additions & 2 deletions backends/bmv2/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ void Backend::convert(const IR::ToplevelBlock* tb) {
new VisitFunctor([this](){ addLocals(); }),
new VisitFunctor([this](){ padScalars(); }),
new VisitFunctor([this](){ addErrors(errors); }),
new ConvertExterns(&refMap, &typeMap, conv, externs),
new ConvertExterns(this),
new ConvertParser(&refMap, &typeMap, conv, parsers),
new ConvertControl(&refMap, &typeMap, conv, &structure, pipelines, counters),
new ConvertControl(this),
new ConvertDeparser(&refMap, &typeMap, conv, deparsers),
new VisitFunctor([this](){ createActions(actions); }),
};
Expand Down
16 changes: 12 additions & 4 deletions backends/bmv2/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ limitations under the License.

namespace BMV2 {


class Backend : public PassManager {
using DirectCounterMap = std::map<cstring, const IR::P4Table*>;

ExpressionConverter* conv;
P4::ConvertEnums::EnumMapping* enumMap;
P4::P4CoreLibrary& corelib;
Expand All @@ -45,6 +48,7 @@ class Backend : public PassManager {
Util::JsonObject toplevel;
P4::V2Model& model;
P4V1::V1Model& v1model;
DirectCounterMap directCounterMap;
DirectMeterMap meterMap;
ErrorCodesMap errorCodesMap;

Expand Down Expand Up @@ -104,10 +108,14 @@ class Backend : public PassManager {
void convert(const IR::ToplevelBlock* block);
void serialize(std::ostream& out) const
{ toplevel.serialize(out); }
ExpressionConverter* getExpressionConverter() { return conv; };
DirectMeterMap& getMeterMap() { return meterMap; }
P4::ReferenceMap& getRefMap() { return refMap; }
P4::TypeMap& getTypeMap() { return typeMap; }
P4::P4CoreLibrary & getCoreLibrary() const { return corelib; }
ExpressionConverter * getExpressionConverter() { return conv; };
DirectCounterMap & getDirectCounterMap() { return directCounterMap; }
DirectMeterMap & getMeterMap() { return meterMap; }
P4::V2Model & getModel() { return model; }
P4::ReferenceMap & getRefMap() { return refMap; }
ProgramParts & getStructure() { return structure; }
P4::TypeMap & getTypeMap() { return typeMap; }
};

} // namespace BMV2
Expand Down
Loading

0 comments on commit add976f

Please sign in to comment.