Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ternary const entries #3347

Merged
merged 8 commits into from
May 25, 2022
Merged

Conversation

kmateuszssak
Copy link
Contributor

This PR adds possibility to use const entries with ternary tables.

}

void EBPFTablePSA::emitKeysAndValues(CodeBuilder *builder,
std::vector<const IR::Entry *> &samePrefixEntries,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistent indentation

BUG("Cannot assess field bit width");
}
builder->append("0x");
for (int j = 0; j < width / 8; j++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work with non-aligned widths too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should factor this into a utility function getHexMask, or something of the kind.

}
}

std::vector<std::vector<const IR::Entry*>> EBPFTablePSA::getConstEntriesGroupedByPrefix() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small comment would help make this function easier to interpret.

std::vector<std::vector<const IR::Entry*>> EBPFTablePSA::getConstEntriesGroupedByPrefix() {
std::vector<std::vector<const IR::Entry*>> entriesGroupedByPrefix;
const IR::EntriesList* entries = table->container->getEntries();
if (entries != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

especially for long ifs I find it simpler to if (!entries) return ...;
One less level of indentation afterwards.

@kmateuszssak
Copy link
Contributor Author

@mbudiu-vmw I've addressed comments.

@mihaibudiu mihaibudiu merged commit ea2f917 into p4lang:main May 25, 2022
github-sajan pushed a commit to github-sajan/p4c that referenced this pull request May 26, 2022
* Add support for ternary const entries in ebpf-PSA backend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants