Skip to content

Commit 39d9d44

Browse files
authored
Promote P4 to be THE project-wise top-level namespace (#4825)
* Introduce top-level namespace p4c to the lib/ dir Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace Util to p4c::Util Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace Test to p4c::Test Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace IR to p4c::IR Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace P4 to p4c::P4 Signed-off-by: Bili Dong <qobilidop@gmail.com> * Make sure all midend/ C++ code is under namespace p4c Signed-off-by: Bili Dong <qobilidop@gmail.com> * Make sure all frontend/ code is under namespace p4c Signed-off-by: Bili Dong <qobilidop@gmail.com> * Make sure all ir/ code is under namespace p4c Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace BMV2 to p4c::BMV2 Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace DPDK to p4c::DPDK Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace EBPF to p4c::EBPF Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace graphs to p4c::graphs Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace TC to p4c::TC Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change top-level namespace UBPF to p4c::UBPF Signed-off-by: Bili Dong <qobilidop@gmail.com> * Fully qualify `using namespace p4c` to be `using namespace ::p4c` Signed-off-by: Bili Dong <qobilidop@gmail.com> * Make sure all backends/ code is under namespace p4c Signed-off-by: Bili Dong <qobilidop@gmail.com> * Address some compiling issues Signed-off-by: Bili Dong <qobilidop@gmail.com> * Address remaining compiling issues Signed-off-by: Bili Dong <qobilidop@gmail.com> * Apply clang-format Signed-off-by: Bili Dong <qobilidop@gmail.com> * Address cpplint issues Signed-off-by: Bili Dong <qobilidop@gmail.com> * Update bazel/example/ code Signed-off-by: Bili Dong <qobilidop@gmail.com> * Address remaining namespace issues Signed-off-by: Bili Dong <qobilidop@gmail.com> * Try fixing the macOS compiling issue Signed-off-by: Bili Dong <qobilidop@gmail.com> * Address linter issues Signed-off-by: Bili Dong <qobilidop@gmail.com> * Revert the past few changes as they didn't work Signed-off-by: Bili Dong <qobilidop@gmail.com> * Change namespace naming from p4c to P4C Signed-off-by: Bili Dong <qobilidop@gmail.com> * Fix wrong replacements Signed-off-by: Bili Dong <qobilidop@gmail.com> * Add namespace P4C to newly added code Signed-off-by: Bili Dong <qobilidop@gmail.com> * Resolve some #include within namespace issues Signed-off-by: Bili Dong <qobilidop@gmail.com> * Switch to use `P4` as THE top-level namespace And avoid nested `P4::P4` namespace. Signed-off-by: Bili Dong <qobilidop@gmail.com> * Recover Ubuntu 18.04 support Signed-off-by: Bili Dong <qobilidop@gmail.com> * Avoid introducing new symbols into `namespace std` Signed-off-by: Bili Dong <qobilidop@gmail.com> * Resolve compiling issues for newly updated code Signed-off-by: Bili Dong <qobilidop@gmail.com> * Address review comments Signed-off-by: Bili Dong <qobilidop@gmail.com> * Further address compiling issues Signed-off-by: Bili Dong <qobilidop@gmail.com> * Apply namespace updates to newly added code Signed-off-by: Bili Dong <qobilidop@gmail.com> * Convert `using namespace ::P4` back to `using namespace P4` Signed-off-by: Bili Dong <qobilidop@gmail.com> * Use `::P4` consistently in macros under lib/ Signed-off-by: Bili Dong <qobilidop@gmail.com> * Fix more `P4` namespace usage in macros Signed-off-by: Bili Dong <qobilidop@gmail.com> --------- Signed-off-by: Bili Dong <qobilidop@gmail.com>
1 parent 1f5468c commit 39d9d44

File tree

811 files changed

+4642
-3899
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

811 files changed

+4642
-3899
lines changed

backends/bmv2/common/JsonObjects.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ limitations under the License.
1919
#include "helpers.h"
2020
#include "lib/json.h"
2121

22-
namespace BMV2 {
22+
namespace P4::BMV2 {
2323

2424
const int JSON_MAJOR_VERSION = 2;
2525
const int JSON_MINOR_VERSION = 23;
@@ -387,4 +387,4 @@ void JsonObjects::add_extern(const cstring &name, const cstring &type,
387387
externs->append(extn);
388388
}
389389

390-
} // namespace BMV2
390+
} // namespace P4::BMV2

backends/bmv2/common/JsonObjects.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License.
2222
#include "lib/json.h"
2323
#include "lib/ordered_map.h"
2424

25-
namespace BMV2 {
25+
namespace P4::BMV2 {
2626

2727
class JsonObjects {
2828
public:
@@ -227,6 +227,6 @@ class JsonObjects {
227227
Util::JsonArray *field_aliases;
228228
};
229229

230-
} // namespace BMV2
230+
} // namespace P4::BMV2
231231

232232
#endif /* BACKENDS_BMV2_COMMON_JSONOBJECTS_H_ */

backends/bmv2/common/action.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818

1919
#include "extern.h"
2020

21-
namespace BMV2 {
21+
namespace P4::BMV2 {
2222

2323
using namespace P4::literals;
2424

@@ -181,7 +181,7 @@ void ActionConverter::convertActionBody(const IR::Vector<IR::StatOrDecl> *body,
181181
continue;
182182
}
183183
}
184-
::error(ErrorType::ERR_UNSUPPORTED, "%1% not yet supported on this target", s);
184+
::P4::error(ErrorType::ERR_UNSUPPORTED, "%1% not yet supported on this target", s);
185185
}
186186
}
187187

@@ -197,8 +197,8 @@ void ActionConverter::convertActionParams(const IR::ParameterList *parameters,
197197
// TODO: added IR::Type_Enum here to support PSA_MeterColor_t
198198
// should re-consider how to support action parameters that is neither bit<> nor int<>
199199
if (!(type->is<IR::Type_Bits>() || type->is<IR::Type_Enum>()))
200-
::error(ErrorType::ERR_INVALID,
201-
"%1%: action parameters must be bit<> or int<> on this target", p);
200+
::P4::error(ErrorType::ERR_INVALID,
201+
"%1%: action parameters must be bit<> or int<> on this target", p);
202202
param->emplace("bitwidth", type->width_bits());
203203
params->append(param);
204204
}
@@ -215,4 +215,4 @@ void ActionConverter::postorder(const IR::P4Action *action) {
215215
ctxt->structure->ids.emplace(action, id);
216216
}
217217

218-
} // namespace BMV2
218+
} // namespace P4::BMV2

backends/bmv2/common/action.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020
#include "helpers.h"
2121
#include "ir/ir.h"
2222

23-
namespace BMV2 {
23+
namespace P4::BMV2 {
2424

2525
class ActionConverter : public Inspector {
2626
ConversionContext *ctxt;
@@ -38,6 +38,6 @@ class ActionConverter : public Inspector {
3838
}
3939
};
4040

41-
} // namespace BMV2
41+
} // namespace P4::BMV2
4242

4343
#endif /* BACKENDS_BMV2_COMMON_ACTION_H_ */

backends/bmv2/common/annotations.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020
#include "frontends/p4/parseAnnotations.h"
2121
#include "ir/ir.h"
2222

23-
namespace BMV2 {
23+
namespace P4::BMV2 {
2424

2525
using namespace P4::literals;
2626

@@ -39,6 +39,6 @@ class ParseAnnotations : public P4::ParseAnnotations {
3939
}) {}
4040
};
4141

42-
} // namespace BMV2
42+
} // namespace P4::BMV2
4343

4444
#endif /* BACKENDS_BMV2_COMMON_ANNOTATIONS_H_ */

backends/bmv2/common/backend.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ limitations under the License.
3838
#include "options.h"
3939
#include "sharedActionSelectorCheck.h"
4040

41-
namespace BMV2 {
41+
namespace P4::BMV2 {
4242

4343
enum gress_t { INGRESS, EGRESS };
4444
enum block_t {
@@ -194,6 +194,6 @@ class RenameUserMetadata : public Transform {
194194
}
195195
};
196196

197-
} // namespace BMV2
197+
} // namespace P4::BMV2
198198

199199
#endif /* BACKENDS_BMV2_COMMON_BACKEND_H_ */

backends/bmv2/common/check_unsupported.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License.
2222
#include "lower.h"
2323
#include "midend/convertEnums.h"
2424

25-
namespace BMV2 {
25+
namespace P4::BMV2 {
2626

2727
class CheckUnsupported : public Inspector {
2828
bool preorder(const IR::ForStatement *fs) override {
@@ -35,6 +35,6 @@ class CheckUnsupported : public Inspector {
3535
}
3636
};
3737

38-
} // namespace BMV2
38+
} // namespace P4::BMV2
3939

4040
#endif /* BACKENDS_BMV2_COMMON_CHECK_UNSUPPORTED_H_ */

0 commit comments

Comments
 (0)