Skip to content

Commit

Permalink
Fix/xfail testgen failures, fix lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Dodd <[email protected]>
  • Loading branch information
ChrisDodd committed Jan 30, 2025
1 parent 618c817 commit 176cee2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 8 deletions.
3 changes: 0 additions & 3 deletions backends/p4tools/common/core/abstract_execution_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ std::vector<IR::StateVariable> AbstractExecutionState::getFlatFields(
for (size_t arrayIndex = 0; arrayIndex < typeStack->getSize(); arrayIndex++) {
const auto *newArr =
HSIndexToMember::produceStackIndex(stackElementsType, parent, arrayIndex);
BUG_CHECK(stackElementsType->is<IR::Type_StructLike>(),
"Trying to get the flat fields for a non Type_StructLike element : %1%",
stackElementsType);
auto subFields = getFlatFields(newArr, validVector);
flatFields.insert(flatFields.end(), subFields.begin(), subFields.end());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ p4tools_add_xfail_reason(
loop-3-clause-tricky2.p4
)

p4tools_add_xfail_reason(
"testgen-p4c-bmv2-metadata"
"Cast failed"
# testgen has issues with arrays
array1.p4
array2.p4
)

####################################################################################################
# 3. WONTFIX
####################################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ p4tools_add_xfail_reason(
loop-3-clause-tricky2.p4
)

p4tools_add_xfail_reason(
"testgen-p4c-bmv2-ptf"
"Cast failed"
# testgen has issues with arrays
array1.p4
array2.p4
)

####################################################################################################
# 3. WONTFIX
# These are failures that can not be solved by changing P4Testgen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ p4tools_add_xfail_reason(
loop-3-clause-tricky2.p4
)

p4tools_add_xfail_reason(
"testgen-p4c-bmv2-protobuf-ir"
"Cast failed"
# testgen has issues with arrays
array1.p4
array2.p4
)

####################################################################################################
# 3. WONTFIX
####################################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ p4tools_add_xfail_reason(
loop-3-clause-tricky2.p4
)

p4tools_add_xfail_reason(
"testgen-p4c-bmv2-stf"
"Cast failed"
# testgen has issues with arrays
array1.p4
array2.p4
)

####################################################################################################
# 3. WONTFIX
# These are failures that can not be solved by changing P4Testgen
Expand Down
4 changes: 2 additions & 2 deletions frontends/p4/typeChecking/typeCheckExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,8 +1707,8 @@ const IR::Node *TypeInferenceBase::postorder(const IR::Member *expression) {
if (auto *stack = type->to<IR::Type_Stack>()) {
auto parser = findContext<IR::P4Parser>();
auto eltype = stack->elementType;
if (!eltype->is<IR::Type_Header>() && !eltype->is<IR::Type_HeaderUnion>() /* &&
!eltype->is<IR::Type_SpecializedCanonical>() */) {
if (auto sc = eltype->to<IR::Type_SpecializedCanonical>()) eltype = sc->baseType;
if (!eltype->is<IR::Type_Header>() && !eltype->is<IR::Type_HeaderUnion>()) {
typeError("%1%: '%2%' can only be used on header stacks", expression, member);
return expression;
} else if (member == IR::Type_Stack::next || member == IR::Type_Stack::last) {
Expand Down
9 changes: 6 additions & 3 deletions frontends/p4/typeChecking/typeCheckTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,12 @@ const IR::Node *TypeInferenceBase::postorder(const IR::Type_Header *type) {
auto canon = setTypeType(type);
auto validator = [this](const IR::Type *t) {
while (1) {
if (t->is<IR::Type_Newtype>()) t = getTypeType(t->to<IR::Type_Newtype>()->type);
else if (auto *st = t->to<IR::Type_Stack>()) t = st->elementType;
else break;
if (t->is<IR::Type_Newtype>())
t = getTypeType(t->to<IR::Type_Newtype>()->type);
else if (auto *st = t->to<IR::Type_Stack>())
t = st->elementType;
else
break;
}
return t->is<IR::Type_Bits>() || t->is<IR::Type_Varbits>() ||
(t->is<IR::Type_Struct>() && onlyBitsOrBitStructs(t)) || t->is<IR::Type_SerEnum>() ||
Expand Down

0 comments on commit 176cee2

Please sign in to comment.