@@ -22,31 +22,41 @@ limitations under the License.
22
22
23
23
namespace P4 {
24
24
25
- // Policy which selects the control blocks where action
26
- // synthesis is applied.
25
+ /* *
26
+ Policy which selects the control blocks where action
27
+ synthesis is applied.
28
+ */
27
29
class ActionSynthesisPolicy {
28
30
public:
29
31
virtual ~ActionSynthesisPolicy () {}
30
- // If the policy returns true the control block is processed,
31
- // otherwise it is left unchanged.
32
+ /* *
33
+ If the policy returns true the control block is processed,
34
+ otherwise it is left unchanged.
35
+ */
32
36
virtual bool convert (const IR::P4Control* control) const = 0;
33
37
};
34
38
35
- // Convert direct action calls to table invocations.
36
- // control c() {
37
- // action x(in bit b) { ... }
38
- // apply { x(e); }
39
- // }
40
- // turns into
41
- // control c() {
42
- // action x(in bit b) { ... }
43
- // table _tmp() {
44
- // actions = { x(e); }
45
- // const default_action = x();
46
- // }
47
- // apply { _tmp.apply(); }
48
- // }
49
- // For this to work all variable declarations must have been moved to the beginning.
39
+ /* *
40
+ Convert direct action calls to table invocations.
41
+
42
+ control c() {
43
+ action x(in bit b) { ... }
44
+ apply { x(e); }
45
+ }
46
+
47
+ turns into
48
+
49
+ control c() {
50
+ action x(in bit b) { ... }
51
+ table _tmp() {
52
+ actions = { x(e); }
53
+ const default_action = x();
54
+ }
55
+ apply { _tmp.apply(); }
56
+ }
57
+
58
+ For this to work all variable declarations must have been moved to the beginning.
59
+ */
50
60
class DoMoveActionsToTables : public Transform {
51
61
ReferenceMap* refMap;
52
62
TypeMap* typeMap;
@@ -66,17 +76,23 @@ class DoMoveActionsToTables : public Transform {
66
76
const IR::Node* postorder (IR::MethodCallStatement* statement) override ;
67
77
};
68
78
69
- // Convert some statements into action invocations by synthesizing new actions.
70
- // E.g.
71
- // control c(inout bit x) {
72
- // apply { x = 1; }
73
- // }
74
- // is converted to:
75
- // control c(inout bit x) {
76
- // action act() { x = 1; }
77
- // apply { act(); }
78
- // }
79
- // For this to work all variable declarations must have been moved to the beginning.
79
+ /* *
80
+ Convert some statements into action invocations by synthesizing new actions.
81
+ E.g.
82
+
83
+ control c(inout bit x) {
84
+ apply { x = 1; }
85
+ }
86
+
87
+ is converted to:
88
+
89
+ control c(inout bit x) {
90
+ action act() { x = 1; }
91
+ apply { act(); }
92
+ }
93
+
94
+ For this to work all variable declarations must have been moved to the beginning.
95
+ */
80
96
class DoSynthesizeActions : public Transform {
81
97
ReferenceMap* refMap;
82
98
TypeMap* typeMap;
0 commit comments