78 RegisterCallsByAction action_register_calls;
79 RegisterExecuteCallByAction action_register_exec_calls;
80 RegisterActionsByControl control_register_actions;
81 ActionsByRegister generated_register_actions;
82 ActionsByRegister actions_using_register;
93 class CheckRegisterActions :
public Inspector {
95 std::unordered_map<
const IR::Declaration *,
96 std::vector<const IR::Declaration *>>
102 bool preorder(
const IR::Declaration_Instance *)
override;
103 void end_apply()
override;
113 class UpdateRegisterActionsAndExecuteCalls :
public Transform {
115 std::map<const IR::P4Control *, IR::Declaration_Instance *> register_actions;
116 IR::Node *preorder(IR::P4Action *)
override;
117 IR::Node *preorder(IR::Declaration_Instance *)
override;
118 IR::Node *postorder(IR::P4Control *ctrl)
override;
120 bool processDeclaration(
const IR::Declaration *action,
const IR::BlockStatement *&body)
121 __attribute__((__warn_unused_result__));
124 explicit UpdateRegisterActionsAndExecuteCalls(
RegisterReadWrite &self) : self(self) {}
139 class AnalyzeActionWithRegisterCalls :
public Inspector {
141 struct RegActionInfo {
144 IR::Declaration_Instance *reg_action =
nullptr;
145 IR::ParameterList *apply_params =
nullptr;
146 IR::BlockStatement *apply_body =
nullptr;
147 IR::MethodCallExpression *execute_call =
nullptr;
148 const IR::Expression *read_expr =
nullptr;
150 bool preorder(
const IR::Declaration *)
override;
152 void createRegisterExecute(RegActionInfo ®_info,
const IR::Statement *reg_stmt,
154 void createRegisterAction(RegActionInfo ®_info,
const IR::Statement *reg_stmt,
155 const IR::Declaration *act);
167 class CollectRegisterReadsWrites :
public Inspector {
169 bool preorder(
const IR::MethodCallExpression *)
override;
170 void end_apply()
override;
171 void collectRegReadWrite(
const IR::MethodCallExpression *,
const IR::Declaration *);
189 class MoveRegisterParameters :
public Modifier {
191 bool preorder(IR::P4Control *c)
override;
200 : refMap(refMap), typeMap(typeMap) {
202 addPasses({typeChecking, &table_mutex,
new MoveRegisterParameters(*
this),
203 new CollectRegisterReadsWrites(*
this),
new AnalyzeActionWithRegisterCalls(*
this),
204 new UpdateRegisterActionsAndExecuteCalls(*
this),
new P4::ClearTypeMap(typeMap),
206 typeChecking,
new CheckRegisterActions(*
this)});
209 static std::pair<
const IR::MethodCallExpression * ,
210 const IR::Expression * >