24 std::map<const IR::P4Action *, const IR::MethodCallExpression *> invocations;
25 std::set<const IR::P4Action *> all;
26 std::set<const IR::MethodCallExpression *> calls;
28 std::map<const IR::MethodCallExpression *, unsigned> defaultActions;
31 void bind(
const IR::P4Action *action,
const IR::MethodCallExpression *invocation,
34 BUG_CHECK(invocations.find(action) == invocations.end(),
"%1%: action called twice",
36 invocations.emplace(action, invocation);
37 if (allParams) all.emplace(action);
38 calls.emplace(invocation);
40 void bindDefaultAction(
const IR::P4Action *action,
41 const IR::MethodCallExpression *defaultInvocation) {
43 auto actionCallInvocation = ::P4::get(invocations, action);
44 CHECK_NULL(actionCallInvocation);
46 unsigned boundArgs = actionCallInvocation->arguments->size();
47 defaultActions.emplace(defaultInvocation, boundArgs);
49 const IR::MethodCallExpression *get(
const IR::P4Action *action)
const {
50 return ::P4::get(invocations, action);
52 bool removeAllParameters(
const IR::P4Action *action)
const {
53 return all.find(action) != all.end();
55 bool isCall(
const IR::MethodCallExpression *expression)
const {
56 return calls.find(expression) != calls.end();
58 unsigned argsToRemove(
const IR::MethodCallExpression *defaultCall)
const {
59 if (defaultActions.find(defaultCall) == defaultActions.end())
return 0;
60 return ::P4::get(defaultActions, defaultCall);
114 : invocations(invocations), typeMap(typeMap), nameGen(nameGen) {
115 CHECK_NULL(invocations);
118 setName(
"DoRemoveActionParameters");
121 const IR::Node *postorder(IR::P4Action *table)
override;
122 const IR::Node *postorder(IR::ActionListElement *element)
override;
123 const IR::Node *postorder(IR::MethodCallExpression *expression)
override;
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13