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

Adjust the p4-14 model for selectors. #182

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 19 additions & 0 deletions frontends/p4-14/typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ class TypeCheck::Pass1 : public Transform {
else
error("%s: No header type %s defined", hm->srcInfo, hm->type_name);
return hm; }
const IR::Node *preorder(IR::ActionSelector *sel) override {
if (!global) return sel;
if (sel->key_fields != nullptr) return sel;
const IR::FieldListCalculation *kf = nullptr;
if (sel->key.name && (kf = global->get<IR::FieldListCalculation>(sel->key)))
sel->key_fields = kf;
else
error("%s: Key must coordinate to a field_list_calculation");
return sel; }
const IR::Node *preorder(IR::FieldListCalculation *flc) {
if (!global) return flc;
if (flc->input_fields != nullptr) return flc;
const IR::FieldList *in_f = nullptr;
// FIXME: This is incorrect
if (flc->input && (in_f = global->get<IR::FieldList>(flc->input->names[0])))
flc->input_fields = in_f;
else
error("%s: input must be a field_list");
return flc; }
const IR::Node *postorder(IR::NamedRef *ref) override {
if (!global) return ref;
const Visitor::Context *prop_ctxt = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions ir/v1.def
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class FieldList {
class FieldListCalculation {
optional ID name;
NullOK NameList input = nullptr;
NullOK FieldList input_fields = nullptr;
ID algorithm = {};
int output_width = 0;
Annotations annotations;
Expand Down Expand Up @@ -396,6 +397,7 @@ class ActionProfile : Attached {

class ActionSelector : Attached {
ID key = {};
NullOK FieldListCalculation key_fields = nullptr;
ID mode = {};
ID type = {};
const char *kind() const override { return "action_selector"; }
Expand Down