Skip to content
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

[P4Testgen] Run typechecking after front and mid end. #4834

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backends/p4tools/common/compiler/compiler_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ const IR::P4Program *CompilerTarget::runFrontend(const CompilerOptions &options,
auto frontEnd = mkFrontEnd();
frontEnd.addDebugHook(options.getDebugHook());
program = frontEnd.run(options, program);
P4::ReferenceMap refMap;
P4::TypeMap typeMap;
// Perform a last round of type checking.
program = program->apply(P4::TypeChecking(&refMap, &typeMap, true));
if ((program == nullptr) || ::P4::errorCount() > 0) {
return nullptr;
}
Expand Down
3 changes: 3 additions & 0 deletions backends/p4tools/common/compiler/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ void MidEnd::addDefaultPasses() {
new P4::EliminateTuples(&refMap, &typeMap),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::SimplifyControlFlow(&typeMap),
// Perform a last round of type-checking before passes which do not type-check begin.
// TODO: We should split mid end passes into safe and unsafe passes.
new P4::TypeChecking(&refMap, &typeMap, true),
// Simplify header stack assignments with runtime indices into conditional statements.
new P4::HSIndexSimplifier(&refMap, &typeMap),
// Convert Type_Varbits into a type that contains information about the assigned width.
Expand Down
Loading