Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions backends/tc/tcenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import time
from pathlib import Path
from typing import Any, List, Optional
from urllib.parse import unquote

# Append tools to the import path.
FILE_DIR = Path(__file__).resolve().parent
Expand Down Expand Up @@ -133,19 +134,29 @@ def __del__(self):
testutils.kill_proc_group(self.vm_proc)

def _get_version(self, url):
pattern = r"(\d+\.\d+\.0p\d+tc-v\d+-rc\d+)"

match = re.search(pattern, url)
candidates = [
# Legacy linux-p4tc kernel release naming.
(r"(\d+\.\d+\.0p\d+tc-v\d+-rc\d+\+?)", True),
# Newer release labels can be plain semantic versions.
(r"[Vv]ersion\s+(\d+\.\d+\.\d+(?:\.\d+)?\+?)", False),
# Fallback for asset names: linux-image-<version>_<arch>.deb
(r"linux-image-([^/_]+?)(?:_[^/]+)?(?:\.deb)?$", False),
]
source = unquote(url.strip())

if match:
for pattern, force_plus in candidates:
match = re.search(pattern, source)
if not match:
continue
version = match.group(1)
if force_plus and not version.endswith("+"):
version += "+"
if self.verbose:
print(f"Extracted version: {version}")
else:
testutils.log.error("Version string not found")
return None
return version

return version + "+"
testutils.log.error("Version string not found in '%s'", source)
return None

def extract_version(self):
cmd = f'curl -s {self.release_url} | jq .assets[2].browser_download_url | tr -d \\"'
Expand Down
2 changes: 2 additions & 0 deletions backends/tofino/bf-p4c/mau/mau_power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <ostream>
#include <string>

#include <boost/format.hpp>

#include "backends/tofino/bf-p4c/mau/memories.h"
#include "backends/tofino/bf-p4c/specs/device.h"
#include "lib/hex.h"
Expand Down
2 changes: 2 additions & 0 deletions backends/tofino/bf-p4c/mau/walk_power_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <set>
#include <vector>

#include <boost/format.hpp>

#include "backends/tofino/bf-p4c/common/asm_output.h"
#include "backends/tofino/bf-p4c/common/run_id.h"
#include "backends/tofino/bf-p4c/ir/unique_id.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class RewriteEgressIntrinsicMetadataHeader : public P4::PassManager {
BUG_CHECK(
prev &&
(canonicalType->width_bits() + prev_type->width_bits()) % 8 == 0,
"%1% not padded to be byte-aligned in %2%", field->name,
"egress_intrinsic_metadata_t");
"%1% not padded to be byte-aligned in egress_intrinsic_metadata_t",
field->name);
new_fields.push_back(prev);
}
new_fields.push_back(field);
Expand Down
1 change: 1 addition & 0 deletions backends/tofino/bf-p4c/phv/action_phv_constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <sstream>
#include <tuple>

#include <boost/format.hpp>
#include <boost/optional/optional_io.hpp>

#include "backends/tofino/bf-p4c/common/asm_output.h"
Expand Down
1 change: 1 addition & 0 deletions backends/tofino/bf-p4c/phv/analysis/dominator_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "backends/tofino/bf-p4c/phv/analysis/dominator_tree.h"

#include <boost/format.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dominator_tree.hpp>

Expand Down
3 changes: 2 additions & 1 deletion backends/tofino/bf-p4c/phv/analysis/jbay_phv_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

#include "jbay_phv_analysis.h"

#include <boost/format.hpp>

#include "backends/tofino/bf-p4c/phv/phv_fields.h"
#include "backends/tofino/bf-p4c/phv/phv_parde_mau_use.h"
#include "backends/tofino/bf-p4c/specs/device.h"

Visitor::profile_t JbayPhvAnalysis::init_apply(const IR::Node *root) {
profile_t rv = Inspector::init_apply(root);
Expand Down
2 changes: 2 additions & 0 deletions backends/tofino/bf-p4c/phv/analysis/meta_live_range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "backends/tofino/bf-p4c/phv/analysis/meta_live_range.h"

#include <boost/format.hpp>

cstring MetadataLiveRange::printAccess(int access) {
switch (access) {
case 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <algorithm>
#include <optional>

#include <boost/format.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/join.hpp>

Expand Down
2 changes: 2 additions & 0 deletions backends/tofino/bf-p4c/phv/mau_backtracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "backends/tofino/bf-p4c/phv/mau_backtracker.h"

#include <boost/format.hpp>

#include "backends/tofino/bf-p4c/phv/allocate_phv.h"
#include "lib/log.h"

Expand Down
2 changes: 2 additions & 0 deletions backends/tofino/bf-p4c/phv/phv.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef BACKENDS_TOFINO_BF_P4C_PHV_PHV_H_
#define BACKENDS_TOFINO_BF_P4C_PHV_PHV_H_

#include <boost/functional/hash.hpp>

#include "backends/tofino/bf-p4c/specs/phv.h"
#include "ir/json_generator.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <sstream>
#include <unordered_set>

#include <boost/format.hpp>
#include <boost/format/format_fwd.hpp>

#include "backends/tofino/bf-p4c/ir/bitrange.h"
Expand Down
2 changes: 2 additions & 0 deletions backends/tofino/bf-p4c/phv/utils/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <numeric>

#include <boost/format.hpp>

#include "backends/tofino/bf-p4c/common/table_printer.h"

using ContainerAllocStatus = PHV::Allocation::ContainerAllocStatus;
Expand Down
2 changes: 2 additions & 0 deletions backends/tofino/bf-p4c/phv/utils/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef BACKENDS_TOFINO_BF_P4C_PHV_UTILS_REPORT_H_
#define BACKENDS_TOFINO_BF_P4C_PHV_UTILS_REPORT_H_

#include <boost/format.hpp>

#include "backends/tofino/bf-p4c/phv/utils/utils.h"

namespace PHV {
Expand Down
1 change: 1 addition & 0 deletions backends/tofino/bf-p4c/phv/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <numeric>
#include <optional>

#include <boost/format.hpp>
#include <boost/optional/optional_io.hpp>

#include "backends/tofino/bf-p4c/common/table_printer.h"
Expand Down
1 change: 1 addition & 0 deletions backends/tofino/bf-p4c/phv/v2/action_packing_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <algorithm>
#include <optional>

#include <boost/format.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/join.hpp>

Expand Down
5 changes: 2 additions & 3 deletions backends/tofino/bf-p4c/test/gtest/error_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ class ErrorReporterTest : public ::testing::Test {
};

TEST_F(ErrorReporterTest, ErrorHelperPlainFormatsCorrectly) {
boost::format fmt("Str: %1%, Dec: %2%");

EXPECT_EQ(::error_helper(fmt, "hello", 10).toString(), "Str: hello, Dec: 10\n");
EXPECT_EQ(::error_helper("Str: %1%, Dec: %2%", "hello", 10).toString(),
"Str: hello, Dec: 10\n");
}

TEST_F(ErrorReporterTest, WarningsConformToExpectedFormat) {
Expand Down
2 changes: 1 addition & 1 deletion frontends/common/constantParsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int parseConstantChecked(const Util::SourceInfo &srcInfo, const UnparsedConstant
auto cst = parseConstant(srcInfo, constant, 0);
if (!cst->fitsInt()) {
::P4::error(ErrorType::ERR_OVERLIMIT,
"%1$x: this implementation does not support bitstrings this large", cst);
"%s: this implementation does not support bitstrings this large", cst);
return 8; // this is a fine value for a width; compilation will stop anyway
}
return cst->asInt();
Expand Down
16 changes: 8 additions & 8 deletions frontends/p4/typeChecking/typeConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,30 @@ std::string TypeConstraint::localError(Explain *explainer) const {
if (errFormat.isNullOrEmpty()) return "";

std::string message, explanation;
boost::format fmt = boost::format(errFormat.c_str());
switch (errArguments.size()) {
case 0:
message = boost::str(fmt);
message = ::P4::createFormattedMessage(errFormat.c_str());
break;
case 1:
absl::StrAppend(&explanation, explain(0, explainer));
message = ::P4::error_helper(fmt, errArguments.at(0)).toString();
message = ::P4::error_helper(errFormat.c_str(), errArguments.at(0)).toString();
break;
case 2:
absl::StrAppend(&explanation, explain(0, explainer), explain(1, explainer));
message = ::P4::error_helper(fmt, errArguments.at(0), errArguments.at(1)).toString();
message = ::P4::error_helper(errFormat.c_str(), errArguments.at(0), errArguments.at(1))
.toString();
break;
case 3:
absl::StrAppend(&explanation, explain(0, explainer), explain(1, explainer),
explain(2, explainer));
message =
::P4::error_helper(fmt, errArguments.at(0), errArguments.at(1), errArguments.at(2))
.toString();
message = ::P4::error_helper(errFormat.c_str(), errArguments.at(0), errArguments.at(1),
errArguments.at(2))
.toString();
break;
case 4:
absl::StrAppend(&explanation, explain(0, explainer), explain(1, explainer),
explain(2, explainer), explain(3, explainer));
message = ::P4::error_helper(fmt, errArguments.at(0), errArguments.at(1),
message = ::P4::error_helper(errFormat.c_str(), errArguments.at(0), errArguments.at(1),
errArguments.at(2), errArguments.at(3))
.toString();
break;
Expand Down
7 changes: 3 additions & 4 deletions frontends/p4/typeChecking/typeConstraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ class TypeConstraint : public IHasDbPrint, public ICastable {
/// composed in reverse order, from bottom to top. The top of the stack
/// has no 'derivedFrom' field, and it contains the actual source
/// position where the analysis started.
boost::format fmt(format);
return reportErrorImpl(subst,
" ---- Actual error:\n" +
::P4::error_helper(fmt, std::forward<Args>(args)...).toString());
return reportErrorImpl(
subst, " ---- Actual error:\n" +
::P4::error_helper(format, std::forward<Args>(args)...).toString());
}
// Default error message; returns 'false'
virtual bool reportError(const TypeVariableSubstitution *subst) const = 0;
Expand Down
10 changes: 5 additions & 5 deletions ir/expression.def
Original file line number Diff line number Diff line change
Expand Up @@ -318,25 +318,25 @@ class Constant : Literal {
inline bool fitsInt64() const { return value >= INT64_MIN && value <= INT64_MAX; }
inline long asLong() const {
if (!fitsLong())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for long", this);
::P4::error(ErrorType::ERR_OVERLIMIT, "%s: Value too large for long", this);
return static_cast<long>(value); }
inline int asInt() const {
if (!fitsInt())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for int", this);
::P4::error(ErrorType::ERR_OVERLIMIT, "%s: Value too large for int", this);
return static_cast<int>(value); }
inline unsigned asUnsigned() const {
if (!fitsUint())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for unsigned int", this);
::P4::error(ErrorType::ERR_OVERLIMIT, "%s: Value too large for unsigned int", this);
return static_cast<unsigned>(value);
}
inline uint64_t asUint64() const {
if (!fitsUint64())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for uint64", this);
::P4::error(ErrorType::ERR_OVERLIMIT, "%s: Value too large for uint64", this);
return static_cast<uint64_t>(value);
}
inline int64_t asInt64() const {
if (!fitsInt64())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for int64", this);
::P4::error(ErrorType::ERR_OVERLIMIT, "%s: Value too large for int64", this);
return static_cast<int64_t>(value);
}
// The following operators are only used in special circumstances.
Expand Down
1 change: 1 addition & 0 deletions lib/bitrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ limitations under the License.

#include "absl/numeric/bits.h"
#include "bitvec.h"
#include "cstring.h"
#include "exceptions.h"
#include "hash.h"

Expand Down
Loading
Loading