-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the Tofino spec files independent of the generated IR. #5063
base: main
Are you sure you want to change the base?
Conversation
e1813de
to
8aae242
Compare
ir/inode.h
Outdated
return result; | ||
} | ||
|
||
DECLARE_TYPEINFO(INode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asl I have a question on the RTTI macros. I am trying to factor out some classes to avoid pulling in the entire IR code. Unfortunately, for IDeclaration and INode macros like DECLARE_TYPEINFO_WITH_TYPEID(INode, NodeKind::INode);
require pulling in ir/ir-tree-macros.h
which is generated.
Is there a way to avoid this while still being correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the typeid's should be unique. It is part of gen-tree-macro.h
. The location is a bit weird, but it was emitted there exactly in order not to pull the whole IR header. It could be even split into separate .h file if gen-tree-macro.h
is undesired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, gen-tree-macro depends on the generator which is a little unpleasant. Although the code there is less complex than what is being put into ir-generated.h.
You effectively run into #5013.
Maybe there is a way to depend on gen-tree or just the rtti enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, one way to do this is to split enum into "static" and "generated" parts. Static would be for all classes not autogenerated (INode
, IDeclaration
, Vector
), etc. and everything else will be outside the scope.
tools/ir-generator/irclass.cpp
Outdated
<< "#include \"ir/vector.h\" // IWYU pragma: keep\n" | ||
<< "#include \"lib/ordered_map.h\" // IWYU pragma: keep\n" | ||
<< std::endl | ||
<< "namespace P4 {\n" | ||
<< std::endl | ||
<< "class JSONLoader;\n" | ||
<< "using NodeFactoryFn = IR::Node*(*)(JSONLoader&);\n" | ||
<< "using NodeFactoryFn = IR::INode*(*)(JSONLoader&);\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks a bit weird. After all, interface is a property of the object, there is no way to "materialize" pure interface w/o underlying object. But factory produces definite objects, not abstract interfaces, so should be Node
here...
cb4309d
to
71eb3a4
Compare
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
71eb3a4
to
4449f61
Compare
This makes it possible to depend on these files without pulling in the entire compiler. The advantages of this separation is a mid end that does not depend on the Tofino back end and the ability of other tools (primarily P4Testgen) to link into certain Tofino files.