Skip to content

Commit

Permalink
Fix cpplint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bleibig committed Jun 3, 2022
1 parent 17416af commit 00f1389
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions frontends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ set (P4_FRONTEND_HDRS
p4/parserCallGraph.h
p4/parserControlFlow.h
p4/reassociation.h
p4/redundantParsers.h
p4/removeParameters.h
p4/removeReturns.h
p4/reservedWords.h
Expand Down
2 changes: 1 addition & 1 deletion frontends/p4/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ const IR::P4Program *FrontEnd::run(const CompilerOptions &options, const IR::P4P
new RemoveDontcareArgs(&refMap, &typeMap),
new MoveConstructors(&refMap),
new RemoveAllUnusedDeclarations(&refMap),
new ClearTypeMap(&typeMap),
new RemoveRedundantParsers(&typeMap),
new ClearTypeMap(&typeMap),
evaluator,
new Inline(&refMap, &typeMap, evaluator, options.optimizeParserInlining),
new InlineActions(&refMap, &typeMap),
Expand Down
1 change: 1 addition & 0 deletions frontends/p4/redundantParsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

#include "redundantParsers.h"
#include "typeMap.h"

namespace P4 {
bool FindRedundantParsers::preorder(const IR::P4Parser *parser) {
Expand Down
19 changes: 10 additions & 9 deletions frontends/p4/redundantParsers.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013-present Barefoot Networks, Inc.
Copyright 2022-present Barefoot Networks, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,22 +14,23 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _P4_REDUNDANT_PARSERS_H
#define _P4_REDUNDANT_PARSERS_H
#ifndef FRONTENDS_P4_REDUNDANTPARSERS_H_
#define FRONTENDS_P4_REDUNDANTPARSERS_H_

#include "ir/ir.h"
#include "typeMap.h"

namespace P4 {

class TypeMap;

/** Find parsers that have an unconditional "accept" in their start
* state, and put them in redundantParsers.
*/
class FindRedundantParsers : public Inspector {
std::set<cstring> &redundantParsers;
bool preorder(const IR::P4Parser *parser) override;
public:
FindRedundantParsers(std::set<cstring> &redundantParsers)
explicit FindRedundantParsers(std::set<cstring> &redundantParsers)
: redundantParsers(redundantParsers) { }
};

Expand All @@ -40,16 +41,16 @@ class EliminateSubparserCalls : public Transform {
const std::set<cstring> &redundantParsers;
TypeMap *typeMap;
const IR::Node *postorder(IR::MethodCallStatement *methodCallStmt) override;
public:
public:
EliminateSubparserCalls(const std::set<cstring> &redundantParsers, TypeMap *typeMap)
: redundantParsers(redundantParsers), typeMap(typeMap)
{ }
};

class RemoveRedundantParsers : public PassManager {
std::set<cstring> redundantParsers;
public:
RemoveRedundantParsers(TypeMap *typeMap)
public:
explicit RemoveRedundantParsers(TypeMap *typeMap)
: PassManager {
new FindRedundantParsers(redundantParsers),
new EliminateSubparserCalls(redundantParsers, typeMap)
Expand All @@ -60,4 +61,4 @@ class RemoveRedundantParsers : public PassManager {

}

#endif
#endif /* FRONTENDS_P4_REDUNDANTPARSERS_H_ */

0 comments on commit 00f1389

Please sign in to comment.