Skip to content

Commit

Permalink
Clean up the P4-14 dependent code.
Browse files Browse the repository at this point in the history
Signed-off-by: fruffy <fruffy@nyu.edu>
  • Loading branch information
fruffy committed Sep 27, 2024
1 parent a9f0e67 commit 3afcf84
Show file tree
Hide file tree
Showing 37 changed files with 571 additions and 578 deletions.
2 changes: 1 addition & 1 deletion backends/bmv2/common/controlFlowGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
#include "controlFlowGraph.h"

#include "frontends/common/resolveReferences/referenceMap.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/methodInstance.h"
#include "frontends/p4/tableApply.h"
#include "frontends/p4/typeMap.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/common/extern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

#include "extern.h"

#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "lib/json.h"

namespace P4::BMV2 {
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/common/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
#include "controlFlowGraph.h"
#include "expression.h"
#include "frontends/common/model.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "ir/ir.h"
#include "lib/cstring.h"
#include "lib/json.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/common/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.

#include "lower.h"

#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/coreLibrary.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/methodInstance.h"
#include "lib/big_int_util.h"

Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/common/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ limitations under the License.
#include "JsonObjects.h"
#include "backend.h"
#include "extern.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/coreLibrary.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "lib/algorithm.h"

namespace P4::BMV2 {
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/pna_nic/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ limitations under the License.
#include "backends/bmv2/pna_nic/options.h"
#include "frontends/common/constantFolding.h"
#include "frontends/common/resolveReferences/resolveReferences.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/evaluator/evaluator.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/moveDeclarations.h"
#include "frontends/p4/simplify.h"
#include "frontends/p4/simplifyParsers.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/portable_common/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ limitations under the License.
#include "backends/bmv2/portable_common/options.h"
#include "frontends/common/constantFolding.h"
#include "frontends/common/resolveReferences/resolveReferences.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/evaluator/evaluator.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/moveDeclarations.h"
#include "frontends/p4/simplify.h"
#include "frontends/p4/simplifyParsers.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/psa_switch/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ limitations under the License.
#include "backends/bmv2/psa_switch/options.h"
#include "frontends/common/constantFolding.h"
#include "frontends/common/resolveReferences/resolveReferences.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/evaluator/evaluator.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/moveDeclarations.h"
#include "frontends/p4/simplify.h"
#include "frontends/p4/simplifyParsers.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/simple_switch/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ limitations under the License.
#include "backends/bmv2/simple_switch/options.h"
#include "frontends/common/constantFolding.h"
#include "frontends/common/resolveReferences/resolveReferences.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/evaluator/evaluator.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/moveDeclarations.h"
#include "frontends/p4/simplify.h"
#include "frontends/p4/simplifyParsers.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/simple_switch/simpleSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ limitations under the License.

#include "backends/bmv2/common/annotations.h"
#include "backends/bmv2/simple_switch/options.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/cloner.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "lib/json.h"
#include "midend/flattenLogMsg.h"

Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/simple_switch/simpleSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ limitations under the License.
#include "backends/bmv2/common/sharedActionSelectorCheck.h"
#include "backends/common/programStructure.h"
#include "frontends/common/constantFolding.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/evaluator/evaluator.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/simplify.h"
#include "frontends/p4/unusedDeclarations.h"
#include "midend/convertEnums.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/dpdk/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ limitations under the License.
#include "dpdkArch.h"
#include "frontends/common/constantFolding.h"
#include "frontends/common/resolveReferences/resolveReferences.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/evaluator/evaluator.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/moveDeclarations.h"
#include "frontends/p4/simplify.h"
#include "frontends/p4/simplifyParsers.h"
Expand Down
7 changes: 3 additions & 4 deletions backends/p4fmt/p4formatter.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include "p4formatter.h"

#include <deque>
#include <sstream>
#include <string>

#include "frontends/common/options.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/getV1ModelVersion.h"
#include "frontends/parsers/p4/p4parser.hpp"
#include "ir/dump.h"

Expand Down Expand Up @@ -69,7 +68,7 @@ bool P4Formatter::preorder(const IR::P4Program *program) {
if (sourceFile.parent_path() == p4includePath) {
std::filesystem::path p = sourceFile.filename();
if (P4V1::V1Model::instance.file.name == p) {
P4V1::getV1ModelVersion g;
P4V1::GetV1ModelVersion g;
program->apply(g);
builder.append("#define V1MODEL_VERSION ");
builder.append(g.version);
Expand Down
2 changes: 1 addition & 1 deletion backends/p4test/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ limitations under the License.

#include "frontends/common/constantFolding.h"
#include "frontends/common/resolveReferences/resolveReferences.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/evaluator/evaluator.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/moveDeclarations.h"
#include "frontends/p4/simplify.h"
#include "frontends/p4/simplifyParsers.h"
Expand Down
2 changes: 1 addition & 1 deletion control-plane/p4RuntimeArchHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ limitations under the License.
#include "frontends/common/resolveReferences/referenceMap.h"
// TODO(antonin): this include should go away when we cleanup getTableSize
// implementation.
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/externInstance.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/toP4/toP4.h"
#include "frontends/p4/typeMap.h"
#include "ir/ir.h"
Expand Down
1 change: 0 additions & 1 deletion control-plane/p4RuntimeArchStandard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ limitations under the License.
#include <unordered_map>

#include "frontends/common/resolveReferences/referenceMap.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4/typeMap.h"
#include "ir/ir.h"
#include "lib/log.h"
Expand Down
2 changes: 1 addition & 1 deletion control-plane/p4RuntimeArchStandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
#define CONTROL_PLANE_P4RUNTIMEARCHSTANDARD_H_

#include "frontends/common/resolveReferences/referenceMap.h"
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/typeMap.h"
#include "ir/ir.h"
#include "p4RuntimeArchHandler.h"
Expand Down
2 changes: 1 addition & 1 deletion control-plane/p4RuntimeSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ limitations under the License.
#include "frontends/p4/externInstance.h"
// TODO(antonin): this include should go away when we cleanup getMatchFields
// and tableNeedsPriority implementations.
#include "frontends/p4/fromv1.0/v1model.h"
#include "frontends/p4-14/fromv1.0/v1model.h"
#include "frontends/p4/methodInstance.h"
#include "frontends/p4/typeChecking/typeChecker.h"
#include "frontends/p4/typeMap.h"
Expand Down
15 changes: 9 additions & 6 deletions frontends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ set (P4_FRONTEND_SRCS
p4/evaluator/evaluator.cpp
p4/evaluator/substituteParameters.cpp
p4/externInstance.cpp
p4/fromv1.0/converters.cpp
p4/fromv1.0/programStructure.cpp
p4/frontend.cpp
p4/functionsInlining.cpp
p4/hierarchicalNames.cpp
p4/inlining.cpp
p4/localizeActions.cpp
p4/methodInstance.cpp
p4/modelInstances.cpp
p4/moveConstructors.cpp
p4/moveDeclarations.cpp
p4/parameterSubstitution.cpp
Expand Down Expand Up @@ -110,9 +107,6 @@ set (P4_FRONTEND_HDRS
p4/evaluator/evaluator.h
p4/evaluator/substituteParameters.h
p4/externInstance.h
p4/fromv1.0/converters.h
p4/fromv1.0/programStructure.h
p4/fromv1.0/v1model.h
p4/frontend.h
p4/functionsInlining.h
p4/hierarchicalNames.h
Expand Down Expand Up @@ -196,6 +190,11 @@ set (COMMON_FRONTEND_HDRS
set (V1_FRONTEND_SRCS
p4-14/typecheck.cpp
p4-14/header_type.cpp
p4-14/v1.cpp

p4-14/fromv1.0/converters.cpp
p4-14/fromv1.0/programStructure.cpp
p4-14/fromv1.0/v1model.cpp
)

set (IR_DEF_FILES ${IR_DEF_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/p4-14/ir-v1.def PARENT_SCOPE)
Expand All @@ -204,6 +203,10 @@ set (V1_FRONTEND_HDRS
p4-14/header_type.h
p4-14/inline_control_flow.h
p4-14/typecheck.h

p4-14/fromv1.0/converters.h
p4-14/fromv1.0/programStructure.h
p4-14/fromv1.0/v1model.h
)

set (PARSERS_SRCS
Expand Down
2 changes: 1 addition & 1 deletion frontends/common/parseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.
#include <cstdio>
#include <sstream>

#include "frontends/p4/fromv1.0/converters.h"
#include "frontends/p4-14/fromv1.0/converters.h"
#include "frontends/parsers/parserDriver.h"
#include "lib/error.h"

Expand Down
2 changes: 1 addition & 1 deletion frontends/common/parseInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.

#include "frontends/common/options.h"
#include "frontends/common/parser_options.h"
#include "frontends/p4/fromv1.0/converters.h"
#include "frontends/p4-14/fromv1.0/converters.h"
#include "frontends/parsers/parserDriver.h"
#include "lib/error.h"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef FRONTENDS_P4_FROMV1_0_CONVERTERS_H_
#define FRONTENDS_P4_FROMV1_0_CONVERTERS_H_
#ifndef FRONTENDS_P4_14_FROMV1_0_CONVERTERS_H_
#define FRONTENDS_P4_14_FROMV1_0_CONVERTERS_H_

#include <typeindex>
#include <typeinfo>
Expand Down Expand Up @@ -1059,4 +1059,4 @@ class Converter : public PassManager {

} // namespace P4::P4V1

#endif /* FRONTENDS_P4_FROMV1_0_CONVERTERS_H_ */
#endif /* FRONTENDS_P4_14_FROMV1_0_CONVERTERS_H_ */
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef FRONTENDS_P4_FROMV1_0_PROGRAMSTRUCTURE_H_
#define FRONTENDS_P4_FROMV1_0_PROGRAMSTRUCTURE_H_
#ifndef FRONTENDS_P4_14_FROMV1_0_PROGRAMSTRUCTURE_H_
#define FRONTENDS_P4_14_FROMV1_0_PROGRAMSTRUCTURE_H_

#include <set>
#include <vector>
Expand Down Expand Up @@ -330,4 +330,4 @@ class ProgramStructure {

} // namespace P4::P4V1

#endif /* FRONTENDS_P4_FROMV1_0_PROGRAMSTRUCTURE_H_ */
#endif /* FRONTENDS_P4_14_FROMV1_0_PROGRAMSTRUCTURE_H_ */
11 changes: 11 additions & 0 deletions frontends/p4-14/fromv1.0/v1model.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "frontends/p4-14/fromv1.0/v1model.h"

/* These must be in the same compilation unit to ensure that P4CoreLibrary::instance
* is initialized before V1Model::instance */
namespace P4::P4V1 {

V1Model V1Model::instance;
const char *V1Model::versionInitial = "20180101";
const char *V1Model::versionCurrent = "20200408";

} // namespace P4::P4V1
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef FRONTENDS_P4_FROMV1_0_V1MODEL_H_
#define FRONTENDS_P4_FROMV1_0_V1MODEL_H_
#ifndef FRONTENDS_P4_14_FROMV1_0_V1MODEL_H_
#define FRONTENDS_P4_14_FROMV1_0_V1MODEL_H_

#include "frontends/common/model.h"
#include "frontends/p4/coreLibrary.h"
#include "frontends/p4/methodInstance.h"
#include "ir/ir.h"
#include "lib/cstring.h"
#include "lib/json.h"

namespace P4::P4V1 {

Expand Down Expand Up @@ -353,22 +351,6 @@ class V1Model : public Model::Model {
static const char *versionCurrent; // 20200408
};

/// Stores the version of the global constant __v1model_version used
/// in the 'version' public instance variable.
class getV1ModelVersion : public Inspector {
bool preorder(const IR::Declaration_Constant *dc) override {
if (dc->name == "__v1model_version") {
auto val = dc->initializer->to<IR::Constant>();
version = static_cast<unsigned>(val->value);
}
return false;
}
bool preorder(const IR::Declaration *) override { return false; }

public:
unsigned version = 0;
};

} // namespace P4::P4V1

#endif /* FRONTENDS_P4_FROMV1_0_V1MODEL_H_ */
#endif /* FRONTENDS_P4_14_FROMV1_0_V1MODEL_H_ */
Loading

0 comments on commit 3afcf84

Please sign in to comment.