Skip to content

Commit

Permalink
Promote P4 to be THE project-wise top-level namespace (#4825)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
qobilidop committed Aug 15, 2024
1 parent 1f5468c commit 39d9d44
Show file tree
Hide file tree
Showing 811 changed files with 4,642 additions and 3,899 deletions.
4 changes: 2 additions & 2 deletions backends/bmv2/common/JsonObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.
#include "helpers.h"
#include "lib/json.h"

namespace BMV2 {
namespace P4::BMV2 {

const int JSON_MAJOR_VERSION = 2;
const int JSON_MINOR_VERSION = 23;
Expand Down Expand Up @@ -387,4 +387,4 @@ void JsonObjects::add_extern(const cstring &name, const cstring &type,
externs->append(extn);
}

} // namespace BMV2
} // namespace P4::BMV2
4 changes: 2 additions & 2 deletions backends/bmv2/common/JsonObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
#include "lib/json.h"
#include "lib/ordered_map.h"

namespace BMV2 {
namespace P4::BMV2 {

class JsonObjects {
public:
Expand Down Expand Up @@ -227,6 +227,6 @@ class JsonObjects {
Util::JsonArray *field_aliases;
};

} // namespace BMV2
} // namespace P4::BMV2

#endif /* BACKENDS_BMV2_COMMON_JSONOBJECTS_H_ */
10 changes: 5 additions & 5 deletions backends/bmv2/common/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.

#include "extern.h"

namespace BMV2 {
namespace P4::BMV2 {

using namespace P4::literals;

Expand Down Expand Up @@ -181,7 +181,7 @@ void ActionConverter::convertActionBody(const IR::Vector<IR::StatOrDecl> *body,
continue;
}
}
::error(ErrorType::ERR_UNSUPPORTED, "%1% not yet supported on this target", s);
::P4::error(ErrorType::ERR_UNSUPPORTED, "%1% not yet supported on this target", s);
}
}

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

} // namespace BMV2
} // namespace P4::BMV2
4 changes: 2 additions & 2 deletions backends/bmv2/common/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
#include "helpers.h"
#include "ir/ir.h"

namespace BMV2 {
namespace P4::BMV2 {

class ActionConverter : public Inspector {
ConversionContext *ctxt;
Expand All @@ -38,6 +38,6 @@ class ActionConverter : public Inspector {
}
};

} // namespace BMV2
} // namespace P4::BMV2

#endif /* BACKENDS_BMV2_COMMON_ACTION_H_ */
4 changes: 2 additions & 2 deletions backends/bmv2/common/annotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
#include "frontends/p4/parseAnnotations.h"
#include "ir/ir.h"

namespace BMV2 {
namespace P4::BMV2 {

using namespace P4::literals;

Expand All @@ -39,6 +39,6 @@ class ParseAnnotations : public P4::ParseAnnotations {
}) {}
};

} // namespace BMV2
} // namespace P4::BMV2

#endif /* BACKENDS_BMV2_COMMON_ANNOTATIONS_H_ */
4 changes: 2 additions & 2 deletions backends/bmv2/common/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ limitations under the License.
#include "options.h"
#include "sharedActionSelectorCheck.h"

namespace BMV2 {
namespace P4::BMV2 {

enum gress_t { INGRESS, EGRESS };
enum block_t {
Expand Down Expand Up @@ -194,6 +194,6 @@ class RenameUserMetadata : public Transform {
}
};

} // namespace BMV2
} // namespace P4::BMV2

#endif /* BACKENDS_BMV2_COMMON_BACKEND_H_ */
4 changes: 2 additions & 2 deletions backends/bmv2/common/check_unsupported.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
#include "lower.h"
#include "midend/convertEnums.h"

namespace BMV2 {
namespace P4::BMV2 {

class CheckUnsupported : public Inspector {
bool preorder(const IR::ForStatement *fs) override {
Expand All @@ -35,6 +35,6 @@ class CheckUnsupported : public Inspector {
}
};

} // namespace BMV2
} // namespace P4::BMV2

#endif /* BACKENDS_BMV2_COMMON_CHECK_UNSUPPORTED_H_ */
Loading

0 comments on commit 39d9d44

Please sign in to comment.