Skip to content

Commit

Permalink
Merge branch 'master' into combo-of-duplication-action-name-check-and…
Browse files Browse the repository at this point in the history
…-localizeallactions-fix
  • Loading branch information
jafingerhut committed Jan 8, 2025
2 parents 2f861cf + 80ef07c commit e4e4ae6
Show file tree
Hide file tree
Showing 237 changed files with 8,128 additions and 4,037 deletions.
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Remove once #5066 is resolved.
common --enable_workspace
# Enable once #5066 is resolved.
common --noenable_bzlmod

build --action_env=BAZEL_CXXOPTS="-std=c++17"
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
7.4.1
39 changes: 16 additions & 23 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
#
# clang-format configuration file. Intended for clang-format >= 4.
#
# For more information, see:
#
# Documentation/process/clang-format.rst
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
---
Language: Cpp
BasedOnStyle: Google
IndentWidth: 4
FixNamespaceComments: true
Expand All @@ -22,16 +13,18 @@ DerivePointerAlignment: false
PointerAlignment: Right
Standard: c++17
IncludeCategories:
# Matches common headers first and sorts them before project includes
- Regex: '^<.+/.*\.h>'
Priority: 2000
- Regex: '^<.+/.*>'
Priority: 4000
- Regex: '^<.*\.h>'
Priority: 1000
- Regex: '^<.*>'
Priority: 3000
- Regex: 'testgen/.*'
Priority: 6000
- Regex: '.*'
Priority: 5000
# Matches common headers first and sorts them before project includes
- Regex: '^<.+/.*\.h>'
Priority: 2000
- Regex: "^<.+/.*>"
Priority: 4000
- Regex: '^<.*\.h>'
Priority: 1000
- Regex: "^<.*>"
Priority: 3000
- Regex: "testgen/.*"
Priority: 6000
- Regex: ".*"
Priority: 5000
IncludeIsMainRegex: '(_test)?$'
...
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
CompilationDatabase: build/
4 changes: 4 additions & 0 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:
env:
IMAGE_TYPE: test
CMAKE_ONLY: ON
CTEST_PARALLEL_LEVEL: 4
ENABLE_GTESTS: ON
ENABLE_TOFINO: ON
ENABLE_TEST_TOOLS: ON
steps:
- uses: actions/checkout@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
DOXYGEN_VERSION: 1.12.0
DOXYGEN_AWESOME_VERSION: 2.3.3
DOXYGEN_VERSION: 1.13.0
DOXYGEN_AWESOME_VERSION: 2.3.4
PR_PATH: pr-preview/${{ github.event.number }}
DOMAIN: p4lang.github.io
DEPLOYMENT: '<img src="https://github.com/user-attachments/assets/f94fada5-45ca-4271-9106-180728235ad2" alt="Rocket" width="25"/>'
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ list (APPEND P4C_LIB_DEPS ${P4C_ABSL_LIBRARIES})
p4c_add_library (rt clock_gettime HAVE_CLOCK_GETTIME)

# Check includes.
check_include_file(execinfo.h HAVE_EXECINFO_H)
check_include_file(ucontext.h HAVE_UCONTEXT_H)
check_include_file(backtrace-supported.h HAVE_LIBBACKTRACE)
check_include_file_cxx(mm_malloc.h HAVE_MM_MALLOC_H)
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ use them, but YMMV.
- Python 3 for scripting and running tests
- Optional: Documentation generation requires Doxygen (1.12.0) and Graphviz (2.38.0 or higher).
- Optional: Documentation generation requires Doxygen (1.13.0) and Graphviz (2.38.0 or higher).
Backends may have additional dependencies. The dependencies for the backends
included with `P4C` are documented here:
Expand All @@ -311,14 +311,14 @@ pip3 install --user -r requirements.txt
**For documentation building:**

**Tools**
- Download the Doxygen 1.12.0 binary
- Download the Doxygen 1.13.0 binary
```bash
wget https://github.com/doxygen/doxygen/releases/download/Release_1_12_0/doxygen-1.12.0.linux.bin.tar.gz
wget https://github.com/doxygen/doxygen/releases/download/Release_1_13_0/doxygen-1.13.0.linux.bin.tar.gz
```
- Extract and install Doxygen
```bash
tar xzvf doxygen-1.12.0.linux.bin.tar.gz
cd doxygen-1.12.0
tar xzvf doxygen-1.13.0.linux.bin.tar.gz
cd doxygen-1.13.0
sudo make install
cd ..
```
Expand All @@ -328,7 +328,7 @@ sudo apt-get install -y graphviz
```
**Theme**
```bash
git clone --depth 1 -b v2.3.3 https://github.com/jothepro/doxygen-awesome-css ./docs/doxygen/awesome_css
git clone --depth 1 -b v2.3.4 https://github.com/jothepro/doxygen-awesome-css ./docs/doxygen/awesome_css
```

`P4C` also depends on Google Protocol Buffers (Protobuf). `P4C` requires version
Expand Down Expand Up @@ -362,14 +362,14 @@ sudo pip3 install -r requirements.txt
**For documentation building:**

**Tools**
- Download the Doxygen 1.12.0 binary
- Download the Doxygen 1.13.0 binary
```bash
wget https://github.com/doxygen/doxygen/releases/download/Release_1_12_0/doxygen-1.12.0.linux.bin.tar.gz
wget https://github.com/doxygen/doxygen/releases/download/Release_1_13_0/doxygen-1.13.0.linux.bin.tar.gz
```
- Extract and install Doxygen
```bash
tar xzvf doxygen-1.12.0.linux.bin.tar.gz
cd doxygen-1.12.0
tar xzvf doxygen-1.13.0.linux.bin.tar.gz
cd doxygen-1.13.0
sudo make install
cd ..
```
Expand All @@ -379,7 +379,7 @@ sudo dnf install -y graphviz
```
**Theme**
```bash
git clone --depth 1 -b v2.3.3 https://github.com/jothepro/doxygen-awesome-css ./docs/doxygen/awesome_css
git clone --depth 1 -b v2.3.4 https://github.com/jothepro/doxygen-awesome-css ./docs/doxygen/awesome_css
```

You can also look at the [dependencies installation script](https://github.com/p4lang/p4c/blob/main/tools/install_fedora_deps.sh)
Expand Down Expand Up @@ -421,14 +421,14 @@ Installing on macOS:
```

**Optional documentation building tools:**
- Download and install the Doxygen 1.12.0 DMG file from [here](https://github.com/doxygen/doxygen/releases/download/Release_1_12_0/Doxygen-1.12.0.dmg).
- Download and install the Doxygen 1.13.0 DMG file from [here](https://github.com/doxygen/doxygen/releases/download/Release_1_13_0/Doxygen-1.13.0.dmg).
- Install Graphviz
```
brew install graphviz
```
**Optional Documentation theme:**
```
git clone --depth 1 -b v2.3.3 https://github.com/jothepro/doxygen-awesome-css ./docs/doxygen/awesome_css
git clone --depth 1 -b v2.3.4 https://github.com/jothepro/doxygen-awesome-css ./docs/doxygen/awesome_css
```

Homebrew offers a `protobuf` formula. It installs version 3.2, which should
Expand Down
2 changes: 1 addition & 1 deletion Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.5.1
1.2.5.2
2 changes: 2 additions & 0 deletions backends/bmv2/simple_switch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ limitations under the License.
#include "ir/json_generator.h"
#include "ir/json_loader.h"
#include "lib/algorithm.h"
#include "lib/crash.h"
#include "lib/error.h"
#include "lib/exceptions.h"
#include "lib/gc.h"
Expand All @@ -42,6 +43,7 @@ using namespace P4;

int main(int argc, char *const argv[]) {
setup_gc_logging();
setup_signals();

AutoCompileContext autoBMV2Context(new BMV2::SimpleSwitchContext);
auto &options = BMV2::SimpleSwitchContext::get().options();
Expand Down
1 change: 0 additions & 1 deletion backends/dpdk/DpdkXfail.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ p4c_add_xfail_reason("dpdk"
testdata/p4_16_samples/pna-dpdk-invalid-hdr-warnings5.p4
testdata/p4_16_samples/pna-dpdk-invalid-hdr-warnings6.p4
testdata/p4_16_samples/pna-dpdk-header-union-stack2.p4
testdata/p4_16_samples/dash/dash-pipeline-pna-dpdk.p4
)

p4c_add_xfail_reason("dpdk"
Expand Down
17 changes: 13 additions & 4 deletions backends/dpdk/dpdkArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2957,17 +2957,26 @@ MoveNonHeaderFieldsToPseudoHeader::addAssignmentStmt(const IR::Expression *e) {
const IR::Node *MoveNonHeaderFieldsToPseudoHeader::postorder(IR::AssignmentStatement *assn) {
if (is_all_args_header) return assn;
auto result = new IR::IndexedVector<IR::StatOrDecl>();
if (isLargeFieldOperand(assn->left) && assn->right->is<IR::Constant>()) {
auto leftType = assn->left->type->to<IR::Type_Bits>()->width_bits();
auto rightType = assn->right->type->to<IR::Type_Bits>()->width_bits();
if (leftType == SupportedBitWidth && rightType == leftType) {
auto cst = assn->right->to<IR::Constant>();
if (!cst->fitsUint64()) return assn;
}
}
if ((isLargeFieldOperand(assn->left) && !isLargeFieldOperand(assn->right) &&
!isInsideHeader(assn->right)) ||
(isLargeFieldOperand(assn->left) && assn->right->is<IR::Constant>())) {
auto expr = assn->right;
if (auto base = assn->right->to<IR::Cast>()) expr = base->expr;
if (auto cst = assn->right->to<IR::Constant>()) {
if (!cst->fitsUint64()) {
::P4::error(
ErrorType::ERR_OVERLIMIT,
"DPDK target supports up-to 64-bit immediate values, %1% exceeds the limit",
cst);
::P4::error(ErrorType::ERR_OVERLIMIT,
"DPDK target supports constant values "
"that are up to 64-bits, and also exactly 128-bits, but no other "
"sizes. %1% is not a supported size",
cst);
return assn;
}
}
Expand Down
73 changes: 60 additions & 13 deletions backends/dpdk/dpdkHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ bool ConvertStatementToDpdk::preorder(const IR::AssignmentStatement *a) {
"Negate operation is only supported on BIT types");
return false;
}
if (n->expr->type->to<IR::Type_Bits>()->width_bits() == 128) {
if (n->expr->type->to<IR::Type_Bits>()->width_bits() == SupportedBitWidth) {
add128bitComplInstr(left, n->expr);
} else {
BUG_CHECK(metadataStruct, "Metadata structure missing unexpectedly!");
Expand Down Expand Up @@ -632,7 +632,12 @@ bool ConvertStatementToDpdk::preorder(const IR::AssignmentStatement *a) {
}
} else if (right->is<IR::PathExpression>() || right->is<IR::Member>() ||
right->is<IR::BoolLiteral>() || right->is<IR::Constant>()) {
i = new IR::DpdkMovStatement(a->left, a->right);
if (right->is<IR::Constant>() &&
right->type->to<IR::Type_Bits>()->width_bits() == SupportedBitWidth) {
add128bitMovInstr(left, right);
} else {
i = new IR::DpdkMovStatement(left, right);
}
} else {
std::cerr << right->node_type_name() << std::endl;
BUG("Not implemented.");
Expand Down Expand Up @@ -1506,9 +1511,9 @@ bool ConvertStatementToDpdk::preorder(const IR::SwitchStatement *s) {
bool ConvertStatementToDpdk::checkIf128bitOp(const IR::Expression *src1Op,
const IR::Expression *src2Op) {
if (auto src1Type = src1Op->type->to<IR::Type_Bits>()) {
if (src1Type->width_bits() == 128) {
if (src1Type->width_bits() == SupportedBitWidth) {
if (auto src2Type = src2Op->type->to<IR::Type_Bits>()) {
if (src2Type->width_bits() == 128) return true;
if (src2Type->width_bits() == SupportedBitWidth) return true;
}
}
}
Expand Down Expand Up @@ -1559,22 +1564,25 @@ void ConvertStatementToDpdk::add128bitwiseInstr(const IR::Expression *src1Op,
add_instr(new IR::DpdkMovhStatement(src1OpUpper, src1Op));
add_instr(new IR::DpdkMovStatement(src1OpLower, src1Op));
if (src2Op->is<IR::Constant>()) {
auto ConstVal = src2Op->to<IR::Constant>()->value;
auto upperConst = new IR::Constant(ConstVal >> 64);
auto lowerConst = new IR::Constant(ConstVal & 0xFFFFFFFFFFFFFFFF);
add_instr(new IR::DpdkMovStatement(tmp, src1OpLower));
if (strcmp(op, "xor") == 0) {
add_instr(new IR::DpdkXorStatement(tmp, tmp, src2Op));
add_instr(new IR::DpdkXorStatement(tmp, tmp, lowerConst));
} else if (strcmp(op, "or") == 0) {
add_instr(new IR::DpdkOrStatement(tmp, tmp, src2Op));
add_instr(new IR::DpdkOrStatement(tmp, tmp, lowerConst));
} else if (strcmp(op, "and") == 0) {
add_instr(new IR::DpdkAndStatement(tmp, tmp, src2Op));
add_instr(new IR::DpdkAndStatement(tmp, tmp, lowerConst));
}
add_instr(new IR::DpdkMovStatement(src1Op, tmp));
add_instr(new IR::DpdkMovStatement(tmp, src1OpUpper));
if (strcmp(op, "xor") == 0) {
add_instr(new IR::DpdkXorStatement(tmp, tmp, src2Op));
add_instr(new IR::DpdkXorStatement(tmp, tmp, upperConst));
} else if (strcmp(op, "or") == 0) {
add_instr(new IR::DpdkOrStatement(tmp, tmp, src2Op));
add_instr(new IR::DpdkOrStatement(tmp, tmp, upperConst));
} else if (strcmp(op, "and") == 0) {
add_instr(new IR::DpdkAndStatement(tmp, tmp, src2Op));
add_instr(new IR::DpdkAndStatement(tmp, tmp, upperConst));
}
add_instr(new IR::DpdkMovhStatement(src1Op, tmp));
} else {
Expand Down Expand Up @@ -1624,7 +1632,7 @@ void ConvertStatementToDpdk::createSandboxHeader() {

void ConvertStatementToDpdk::createTmpVarForSandbox() {
auto fields = new IR::IndexedVector<IR::StructField>;
fields->push_back(new IR::StructField("tmp", IR::Type_Bits::get(64)));
fields->push_back(new IR::StructField("inter", IR::Type_Bits::get(64)));
const IR::Type_Header *headerStruct = new IR::Type_Header(IR::ID("_p4c_tmp128_t"), *fields);
structure->header_types.emplace(cstring("_p4c_tmp128_t"), headerStruct);
}
Expand Down Expand Up @@ -1659,8 +1667,11 @@ void ConvertStatementToDpdk::add128ComparisonInstr(cstring true_label, const IR:
add_instr(new IR::DpdkMovhStatement(src1OpUpper, src1Op));
add_instr(new IR::DpdkMovStatement(src1OpLower, src1Op));
if (src2Op->is<IR::Constant>()) {
add_instr(new IR::DpdkXorStatement(src1OpUpper, src1OpUpper, src2Op));
add_instr(new IR::DpdkXorStatement(src1OpLower, src1OpLower, src2Op));
auto ConstVal = src2Op->to<IR::Constant>()->value;
auto upperConst = new IR::Constant(ConstVal >> 64);
auto lowerConst = new IR::Constant(ConstVal & 0xFFFFFFFFFFFFFFFF);
add_instr(new IR::DpdkXorStatement(src1OpUpper, src1OpUpper, upperConst));
add_instr(new IR::DpdkXorStatement(src1OpLower, src1OpLower, lowerConst));
} else {
auto src2OpHeaderName = src2Op->toString();
if (src2Op->is<IR::Member>()) {
Expand Down Expand Up @@ -1734,4 +1745,40 @@ void ConvertStatementToDpdk::add128bitComplInstr(const IR::Expression *dst,
add_instr(new IR::DpdkMovStatement(dst, src1OpLower));
add_instr(new IR::DpdkMovhStatement(dst, src1OpUpper));
}

void ConvertStatementToDpdk::add128bitMovInstr(const IR::Expression *left,
const IR::Expression *right) {
if (!createSandboxHeaderType) {
createSandboxHeaderType = true;
createSandboxHeader();
}
const IR::Type_Header *Type_Header = nullptr;
for (auto header : structure->header_types) {
if (header.first == "_p4c_sandbox_header_t") {
Type_Header = header.second;
}
}
if (Type_Header == nullptr) {
BUG("Header type not found");
}
auto leftHeaderName = left->toString();
if (left->is<IR::Member>()) {
leftHeaderName = left->to<IR::Member>()->member.name;
}
leftHeaderName = leftHeaderName + "_128";
auto leftHeader = new IR::Declaration_Variable(leftHeaderName, Type_Header);
auto leftHeaderInstance = new IR::DpdkHeaderInstance(leftHeader, Type_Header);
structure->addHeaderInstances(leftHeaderInstance);
auto leftUpper =
new IR::Member(new IR::PathExpression("h." + leftHeader->name), IR::ID("upper_half"));
auto leftLower =
new IR::Member(new IR::PathExpression("h." + leftHeader->name), IR::ID("lower_half"));
auto ConstVal = right->to<IR::Constant>()->value;
auto upperConst = new IR::Constant(ConstVal >> 64);
auto lowerConst = new IR::Constant(ConstVal & 0xFFFFFFFFFFFFFFFF);
add_instr(new IR::DpdkMovStatement(leftUpper, upperConst));
add_instr(new IR::DpdkMovStatement(leftLower, lowerConst));
add_instr(new IR::DpdkMovStatement(left, leftLower));
add_instr(new IR::DpdkMovhStatement(left, leftUpper));
}
} // namespace P4::DPDK
3 changes: 3 additions & 0 deletions backends/dpdk/dpdkHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ limitations under the License.

namespace P4::DPDK {

static const int SupportedBitWidth = 128;

class ConvertStatementToDpdk;

/// @brief Name of the metadata used as output port.
Expand Down Expand Up @@ -199,6 +201,7 @@ class ConvertStatementToDpdk : public Inspector {
void add128ComparisonInstr(cstring true_label, const IR::Expression *src1Op,
const IR::Expression *src2Op, const char *op);
void add128bitComplInstr(const IR::Expression *, const IR::Expression *);
void add128bitMovInstr(const IR::Expression *left, const IR::Expression *right);
};
/// Only simplify complex expression in ingress/egress.
class ProcessControls : public P4::RemoveComplexExpressionsPolicy {
Expand Down
Loading

0 comments on commit e4e4ae6

Please sign in to comment.