Skip to content

Commit

Permalink
Remove more instances of .string_view() calls
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Korobeynikov <[email protected]>
  • Loading branch information
asl committed Nov 1, 2024
1 parent d40822b commit 6ff7a30
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 86 deletions.
2 changes: 1 addition & 1 deletion backends/bmv2/common/midend.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EnumOn32Bits : public P4::ChooseEnumRepresentation {
bool convert(const IR::Type_Enum *type) const override {
if (type->srcInfo.isValid()) {
auto sourceFile = type->srcInfo.getSourceFile();
if (sourceFile.endsWith(filename.string_view()))
if (sourceFile.endsWith(filename))
// Don't convert any of the standard enums
return false;
}
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 @@ -78,7 +78,7 @@ class PnaEnumOn32Bits : public P4::ChooseEnumRepresentation {
if (type->name == "PNA_MeterColor_t") return true;
if (type->srcInfo.isValid()) {
auto sourceFile = type->srcInfo.getSourceFile();
if (sourceFile.endsWith(filename.string_view()))
if (sourceFile.endsWith(filename))
// Don't convert any of the standard enums
return false;
}
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 @@ -78,7 +78,7 @@ class PsaEnumOn32Bits : public P4::ChooseEnumRepresentation {
if (type->name == "PSA_MeterColor_t") return true;
if (type->srcInfo.isValid()) {
auto sourceFile = type->srcInfo.getSourceFile();
if (sourceFile.endsWith(filename.string_view()))
if (sourceFile.endsWith(filename))
// Don't convert any of the standard enums
return false;
}
Expand Down
18 changes: 9 additions & 9 deletions backends/dpdk/control-plane/bfruntime_arch_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon<arch> {
}
auto *externType = p4info->add_externs();
externType->set_extern_type_id(static_cast<p4rt_id_t>(typeId));
externType->set_extern_type_name(typeName.string_view());
externType->set_extern_type_name(typeName);
return externType;
}

Expand All @@ -161,8 +161,8 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon<arch> {
auto *externInstance = externType->add_instances();
auto *pre = externInstance->mutable_preamble();
pre->set_id(symbols.getId(typeId, name));
pre->set_name(prefix(pipeName, name).string_view());
pre->set_alias(symbols.getAlias(name).string_view());
pre->set_name(prefix(pipeName, name));
pre->set_alias(symbols.getAlias(name));
Helpers::addAnnotations(pre, annotations);
Helpers::addDocumentation(pre, annotations);
externInstance->mutable_info()->PackFrom(message);
Expand Down Expand Up @@ -237,7 +237,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon<arch> {
auto pipeName = getBlockNamePrefix(tableBlock);
auto *pre = table->mutable_preamble();
if (pre->name() == tableDeclaration->controlPlaneName())
pre->set_name(prefix(pipeName, pre->name()).string_view());
pre->set_name(prefix(pipeName, pre->name()));
}

void addExternInstance(const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info,
Expand All @@ -261,39 +261,39 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon<arch> {
for (auto &extType : *p4info->mutable_action_profiles()) {
auto *pre = extType.mutable_preamble();
if (pre->name() == decl->controlPlaneName()) {
pre->set_name(prefix(pipeName, pre->name()).string_view());
pre->set_name(prefix(pipeName, pre->name()));
break;
}
}
} else if (externBlock->type->name == "ActionProfile") {
for (auto &extType : *p4info->mutable_action_profiles()) {
auto *pre = extType.mutable_preamble();
if (pre->name() == decl->controlPlaneName()) {
pre->set_name(prefix(pipeName, pre->name()).string_view());
pre->set_name(prefix(pipeName, pre->name()));
break;
}
}
} else if (externBlock->type->name == "Meter") {
for (auto &extType : *p4info->mutable_meters()) {
auto *pre = extType.mutable_preamble();
if (pre->name() == decl->controlPlaneName()) {
pre->set_name(prefix(pipeName, pre->name()).string_view());
pre->set_name(prefix(pipeName, pre->name()));
break;
}
}
} else if (externBlock->type->name == "Counter") {
for (auto &extType : *p4info->mutable_counters()) {
auto *pre = extType.mutable_preamble();
if (pre->name() == decl->controlPlaneName()) {
pre->set_name(prefix(pipeName, pre->name()).string_view());
pre->set_name(prefix(pipeName, pre->name()));
break;
}
}
} else if (externBlock->type->name == "Register") {
for (auto &extType : *p4info->mutable_registers()) {
auto *pre = extType.mutable_preamble();
if (pre->name() == decl->controlPlaneName()) {
pre->set_name(prefix(pipeName, pre->name()).string_view());
pre->set_name(prefix(pipeName, pre->name()));
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions backends/dpdk/dpdkAsmOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ void EmitDpdkTableConfig::addAction(const IR::Expression *actionRef, P4::Referen
actionName = newNameMap[actionDecl->name.name];
else
actionName = actionDecl->name.name;
print(actionName.string_view(), " ");
print(actionName, " ");
if (actionDecl->parameters->parameters.size() == 1) {
std::vector<cstring> paramNames;
std::vector<big_int> argVals;
Expand Down Expand Up @@ -458,7 +458,7 @@ void EmitDpdkTableConfig::addAction(const IR::Expression *actionRef, P4::Referen
}

for (size_t i = 0; i < argVals.size(); i++) {
print(paramNames[i].string_view(), " ");
print(paramNames[i], " ");
print(argVals[i], " ");
}
}
Expand Down
10 changes: 5 additions & 5 deletions backends/dpdk/dpdkHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,9 +1530,9 @@ void ConvertStatementToDpdk::add128bitwiseInstr(const IR::Expression *src1Op,
const IR::Type_Header *Type_Header = nullptr;
const IR::Type_Header *Type_Tmp = nullptr;
for (auto header : structure->header_types) {
if (strcmp(header.first, "_p4c_sandbox_header_t") == 0) {
if (header.first == "_p4c_sandbox_header_t") {
Type_Header = header.second;
} else if (strcmp(header.first, "_p4c_tmp128_t") == 0) {
} else if (header.first == "_p4c_tmp128_t") {
Type_Tmp = header.second;
}
}
Expand Down Expand Up @@ -1637,7 +1637,7 @@ void ConvertStatementToDpdk::add128ComparisonInstr(cstring true_label, const IR:
}
const IR::Type_Header *Type_Header = nullptr;
for (auto header : structure->header_types) {
if (strcmp(header.first, "_p4c_sandbox_header_t") == 0) {
if (header.first == "_p4c_sandbox_header_t") {
Type_Header = header.second;
}
}
Expand Down Expand Up @@ -1700,9 +1700,9 @@ void ConvertStatementToDpdk::add128bitComplInstr(const IR::Expression *dst,
const IR::Type_Header *Type_Header = nullptr;
const IR::Type_Header *Type_Tmp = nullptr;
for (auto header : structure->header_types) {
if (strcmp(header.first, "_p4c_sandbox_header_t") == 0) {
if (header.first == "_p4c_sandbox_header_t") {
Type_Header = header.second;
} else if (strcmp(header.first, "_p4c_tmp128_t") == 0) {
} else if (header.first == "_p4c_tmp128_t") {
Type_Tmp = header.second;
}
}
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/psa/ebpfPsaDeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void XDPIngressDeparserPSA::emitPreDeparser(CodeBuilder *builder) {
cstring conditionSendToTC =
"if (%s->clone || %s->multicast_group != 0 ||"
" (!%s->drop && %s->egress_port == 0 && !%s->resubmit && %s->multicast_group == 0)) "_cs;
conditionSendToTC = conditionSendToTC.replace("%s", istd->name.name.string_view());
conditionSendToTC = conditionSendToTC.replace("%s", istd->name.name);
builder->append(conditionSendToTC);
builder->blockStart();
builder->emitIndent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const IR::Expression *makeConstant(Token input, const IdenitifierTypeMap &typeMa
for (const auto &[identifier, keyType] : typeMap) {
auto annoSize = identifier.size();
auto tokenLength = inputStr.length();
if (inputStr.compare(tokenLength - annoSize, annoSize, identifier.string_view()) != 0) {
if (inputStr.compare(tokenLength - annoSize, annoSize, identifier) != 0) {
continue;
}
if (const auto *bit = keyType->to<IR::Type_Bits>()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const IR::SymbolicVariable *RefersToParser::getReferencedKey(const IR::P4Control
const IR::IDeclaration *tableDeclaration = nullptr;
for (const auto *decl : *ctrlContext.getDeclarations()) {
auto declName = decl->controlPlaneName();
if (declName.endsWith(tableReference.string_view())) {
if (declName.endsWith(tableReference)) {
tableDeclaration = decl;
break;
}
Expand Down
8 changes: 4 additions & 4 deletions backends/tc/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ cstring ConvertToBackendIR::HandleTableAccessPermission(const IR::P4Table *t) {
}
}
// FIXME: refactor not to require cstring
auto access_cp = GetAccessNumericValue(control_path.string_view());
auto access_dp = GetAccessNumericValue(data_path.string_view());
auto access_cp = GetAccessNumericValue(control_path);
auto access_dp = GetAccessNumericValue(data_path);
auto access_permisson = (access_cp << 7) | access_dp;
std::stringstream value;
value << "0x" << std::hex << access_permisson;
Expand Down Expand Up @@ -847,8 +847,8 @@ cstring ConvertToBackendIR::processExternPermission(const IR::Type_Extern *ext)
if (data_path.isNullOrEmpty()) {
data_path = cstring(DEFAULT_EXTERN_DATA_PATH_ACCESS);
}
auto access_cp = GetAccessNumericValue(control_path.string_view());
auto access_dp = GetAccessNumericValue(data_path.string_view());
auto access_cp = GetAccessNumericValue(control_path);
auto access_dp = GetAccessNumericValue(data_path);
auto access_permisson = (access_cp << 7) | access_dp;
std::stringstream value;
value << "0x" << std::hex << access_permisson;
Expand Down
Loading

0 comments on commit 6ff7a30

Please sign in to comment.