Skip to content

Commit

Permalink
unique headers and disable field aliases (#10)
Browse files Browse the repository at this point in the history
* generate only one header instance

* disable field aliases until we figure out how to handle multiple aliases to the same standard metadata field
  • Loading branch information
Calin Cascaval authored and hanw committed May 4, 2017
1 parent 1ad9331 commit b7db69a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backends/bmv2/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ void Backend::convert(const IR::ToplevelBlock* tb, CompilerOptions& options) {
new VisitFunctor([this](){ createActions(actions); }),
new ConvertControl(this),
new ConvertDeparser(this),
new VisitFunctor([this, metadata_remap_file](){
createFieldAliases(metadata_remap_file); }),
// new VisitFunctor([this, metadata_remap_file](){
// createFieldAliases(metadata_remap_file); }),
};
tb->getMain()->apply(codegen_passes);
}
Expand Down
5 changes: 5 additions & 0 deletions backends/bmv2/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,15 @@ bool ConvertHeaders::preorder(const IR::Parameter* param) {
}
#else
auto block = getContext()->parent->node;
// keep track of which headers we've already generated the json for
if (block->is<IR::Type_Control>() || block->is<IR::Type_Parser>()) {
auto ft = backend->getTypeMap().getType(param->getNode(), true);
if (ft->is<IR::Type_Struct>()) {
auto st = ft->to<IR::Type_Struct>();
if (visitedHeaders.find(st->getName()) != visitedHeaders.end())
return false; // already seen
else
visitedHeaders.emplace(st->getName());
LOG1("name " << st->getName());
LOG1("anno " << st->getAnnotations());
if (st->getAnnotation("metadata")) {
Expand Down
1 change: 1 addition & 0 deletions backends/bmv2/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace BMV2 {

class ConvertHeaders : public Inspector {
BMV2::Backend* backend;
std::set<cstring> visitedHeaders;

protected:
Util::JsonArray* pushNewArray(Util::JsonArray* parent);
Expand Down

0 comments on commit b7db69a

Please sign in to comment.