Skip to content

Commit

Permalink
Run typechecking after front and mid end.
Browse files Browse the repository at this point in the history
Signed-off-by: fruffy <fruffy@nyu.edu>
  • Loading branch information
fruffy committed Aug 9, 2024
1 parent 63c4071 commit f496c1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
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) || ::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

0 comments on commit f496c1d

Please sign in to comment.