34 std::map<const IR::P4Action *, const IR::MethodCallExpression *> invocations;
35 std::set<const IR::P4Action *> all;
36 std::set<const IR::MethodCallExpression *> calls;
38 std::map<const IR::MethodCallExpression *, unsigned> defaultActions;
41 void bind(
const IR::P4Action *action,
const IR::MethodCallExpression *invocation,
44 BUG_CHECK(invocations.find(action) == invocations.end(),
"%1%: action called twice",
46 invocations.emplace(action, invocation);
47 if (allParams) all.emplace(action);
48 calls.emplace(invocation);
50 void bindDefaultAction(
const IR::P4Action *action,
51 const IR::MethodCallExpression *defaultInvocation) {
53 auto actionCallInvocation = ::P4::get(invocations, action);
54 CHECK_NULL(actionCallInvocation);
56 unsigned boundArgs = actionCallInvocation->arguments->size();
57 defaultActions.emplace(defaultInvocation, boundArgs);
59 const IR::MethodCallExpression *get(
const IR::P4Action *action)
const {
60 return ::P4::get(invocations, action);
62 bool removeAllParameters(
const IR::P4Action *action)
const {
63 return all.find(action) != all.end();
65 bool isCall(
const IR::MethodCallExpression *expression)
const {
66 return calls.find(expression) != calls.end();
68 unsigned argsToRemove(
const IR::MethodCallExpression *defaultCall)
const {
69 if (defaultActions.find(defaultCall) == defaultActions.end())
return 0;
70 return ::P4::get(defaultActions, defaultCall);
120 explicit DoRemoveActionParameters(
ActionInvocation *invocations) : invocations(invocations) {
121 CHECK_NULL(invocations);
122 setName(
"DoRemoveActionParameters");
125 const IR::Node *postorder(IR::P4Action *table)
override;
126 const IR::Node *postorder(IR::ActionListElement *element)
override;
127 const IR::Node *postorder(IR::MethodCallExpression *expression)
override;
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24