Skip to content

Commit

Permalink
set refMap to v1 and initialize the control names for ingress and egr…
Browse files Browse the repository at this point in the history
…ess (#12)
  • Loading branch information
Calin Cascaval authored and hanw committed May 5, 2017
1 parent 6466503 commit 54f794a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions backends/bmv2/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ class Backend : public PassManager {
void padScalars();

public:
explicit Backend(P4::ReferenceMap &refMap, P4::TypeMap &typeMap,
P4::ConvertEnums::EnumMapping* enumMap) :
refMap(refMap), typeMap(typeMap), enumMap(enumMap), corelib(P4::P4CoreLibrary::instance),
explicit Backend(bool isV1,
P4::ConvertEnums::EnumMapping* enumMap) :
enumMap(enumMap), corelib(P4::P4CoreLibrary::instance),
model(P4::V2Model::instance), v1model(P4V1::V1Model::instance)
{}
{ refMap.setIsV1(isV1); }
void process(const IR::ToplevelBlock* block);
void convert(const IR::ToplevelBlock* block, CompilerOptions& options);
void serialize(std::ostream& out) const
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/bmv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char *const argv[]) {
if (::errorCount() > 0 || toplevel == nullptr)
return 1;

BMV2::Backend backend(midEnd.refMap, midEnd.typeMap, &midEnd.enumMap);
BMV2::Backend backend(options.isv1(), &midEnd.enumMap);
try {
backend.addDebugHook(hook);
backend.process(toplevel);
Expand Down
8 changes: 4 additions & 4 deletions backends/bmv2/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ MidEnd::MidEnd(CompilerOptions& options) {
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::CompileTimeOperations(),
new P4::TableHit(&refMap, &typeMap),
// TODO(hanw): skip synthesizing actions in verify, update and deparser.
new P4::SynthesizeActions(&refMap, &typeMap, new SkipControls(skipv1controls)),
new P4::MoveActionsToTables(&refMap, &typeMap),
new P4::TypeChecking(&refMap, &typeMap),
Expand All @@ -187,9 +186,10 @@ MidEnd::MidEnd(CompilerOptions& options) {
new LowerExpressions(&typeMap),
new P4::ConstantFolding(&refMap, &typeMap, false),
new P4::TypeChecking(&refMap, &typeMap),
// TODO(hanw): re-enable these two passes
// new RemoveComplexExpressions(&refMap, &typeMap,
// &ingressControlBlockName, &egressControlBlockName),
new RemoveComplexExpressions(&refMap, &typeMap,
&P4V1::V1Model::instance.ingress.name,
&P4V1::V1Model::instance.egress.name),
// TODO(hanw): re-enable this pass
// new FixupChecksum(&updateControlBlockName),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::RemoveAllUnusedDeclarations(&refMap),
Expand Down
2 changes: 0 additions & 2 deletions backends/bmv2/midend.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class MidEnd : public PassManager {
P4::InlineWorkList controlsToInline;
P4::ActionsInlineList actionsToInline;
cstring updateControlBlockName;
cstring ingressControlBlockName;
cstring egressControlBlockName;

public:
// These will be accurate when the mid-end completes evaluation
Expand Down

0 comments on commit 54f794a

Please sign in to comment.