@@ -115,30 +115,38 @@ std::optional<ControlPlaneConstraints> FlayTarget::computeControlPlaneConstraint
115
115
// By default we only support P4Runtime parsing.
116
116
if (options.controlPlaneApi () == " P4RUNTIME" ) {
117
117
auto deserializedConfig =
118
- Protobuf::deserializeObjectFromFile<p4runtime::flaytests::Config >(confPath);
118
+ Protobuf::deserializeObjectFromFile<p4::v1::WriteRequest >(confPath);
119
119
if (!deserializedConfig.has_value ()) {
120
120
return std::nullopt;
121
121
}
122
122
SymbolSet symbolSet;
123
- if (P4Runtime::updateControlPlaneConstraints (deserializedConfig.value (),
124
- *compilerResult.getP4RuntimeApi ().p4Info ,
125
- constraints, symbolSet) != EXIT_SUCCESS) {
126
- return std::nullopt;
123
+ for (const auto &msg : deserializedConfig.value ().updates ()) {
124
+ if (P4Runtime::updateControlPlaneConstraintsWithEntityMessage (
125
+ msg.entity (), *compilerResult.getP4RuntimeApi ().p4Info , constraints,
126
+ msg.type (), symbolSet) != EXIT_SUCCESS) {
127
+ return std::nullopt;
128
+ }
127
129
}
130
+ warning (" Parsed %1% control plane updates for the initial configuration." ,
131
+ deserializedConfig.value ().updates ().size ());
128
132
return constraints;
129
133
}
130
134
if (options.controlPlaneApi () == " BFRUNTIME" ) {
131
135
auto deserializedConfig =
132
- Protobuf::deserializeObjectFromFile<bfruntime::flaytests::Config >(confPath);
136
+ Protobuf::deserializeObjectFromFile<bfrt_proto::WriteRequest >(confPath);
133
137
if (!deserializedConfig.has_value ()) {
134
138
return std::nullopt;
135
139
}
136
140
SymbolSet symbolSet;
137
- if (BfRuntime::updateControlPlaneConstraints (deserializedConfig.value (),
138
- *compilerResult.getP4RuntimeApi ().p4Info ,
139
- constraints, symbolSet) != EXIT_SUCCESS) {
140
- return std::nullopt;
141
+ for (const auto &msg : deserializedConfig.value ().updates ()) {
142
+ if (BfRuntime::updateControlPlaneConstraintsWithEntityMessage (
143
+ msg.entity (), *compilerResult.getP4RuntimeApi ().p4Info , constraints,
144
+ msg.type (), symbolSet) != EXIT_SUCCESS) {
145
+ return std::nullopt;
146
+ }
141
147
}
148
+ printInfo (" Parsed %1% control plane updates for the initial configuration." ,
149
+ deserializedConfig.value ().updates ().size ());
142
150
return constraints;
143
151
}
144
152
}
@@ -151,28 +159,27 @@ std::optional<ControlPlaneConstraints> FlayTarget::computeControlPlaneConstraint
151
159
MidEnd FlayTarget::mkMidEnd (const CompilerOptions &options) const {
152
160
MidEnd midEnd (options);
153
161
midEnd.setStopOnError (true );
154
- auto *refMap = midEnd.getRefMap ();
155
162
auto *typeMap = midEnd.getTypeMap ();
156
163
midEnd.addPasses ({
157
164
// Sort call arguments according to the order of the function's parameters.
158
- new P4::OrderArguments (refMap, typeMap),
165
+ new P4::OrderArguments (typeMap),
159
166
// Replace any slices in the left side of assignments and convert them to casts.
160
- new P4::RemoveLeftSlices (refMap, typeMap),
167
+ new P4::RemoveLeftSlices (typeMap),
161
168
new PassRepeated ({
162
169
// Local copy propagation and dead-code elimination.
163
170
// Skip this if skipSideEffectOrdering is set.
164
171
// TODO: Pass FlayOptions as argument here.
165
172
FlayOptions::get ().skipSideEffectOrdering ()
166
173
? nullptr
167
174
: new P4::LocalCopyPropagation (
168
- refMap, typeMap, nullptr ,
175
+ typeMap, nullptr ,
169
176
[](const Visitor::Context * /* context*/ , const IR::Expression * /* expr*/ ) {
170
177
return true ;
171
178
}),
172
179
// Simplify control flow that has constants as conditions.
173
180
new P4::SimplifyControlFlow (typeMap),
174
181
// Compress member access to struct expressions.
175
- new P4::ConstantFolding (refMap, typeMap),
182
+ new P4::ConstantFolding (typeMap),
176
183
}),
177
184
});
178
185
return midEnd;
@@ -186,11 +193,11 @@ PassManager FlayTarget::mkPrivateMidEnd(const CompilerOptions &options, P4::Refe
186
193
midEnd.addDebugHook (options.getDebugHook (), true );
187
194
midEnd.addPasses ({
188
195
// Replace serializable enum constants with their values.
189
- new P4::EliminateSerEnums (refMap, typeMap),
196
+ new P4::EliminateSerEnums (typeMap),
190
197
// Replace types introduced by 'type' with 'typedef'.
191
- new P4::EliminateNewtype (refMap, typeMap),
198
+ new P4::EliminateNewtype (typeMap),
192
199
// Make sure that we have no TypeDef left in the program.
193
- new P4::EliminateTypedef (refMap, typeMap),
200
+ new P4::EliminateTypedef (typeMap),
194
201
// Remove exit statements from the program.
195
202
// TODO: We should not depend on this pass. It has bugs.
196
203
new P4::RemoveExits (typeMap),
@@ -199,11 +206,11 @@ PassManager FlayTarget::mkPrivateMidEnd(const CompilerOptions &options, P4::Refe
199
206
new P4::ParsersUnroll (true , refMap, typeMap),
200
207
new P4::TypeChecking (refMap, typeMap, true ),
201
208
// Convert enums and errors to bit<32>.
202
- new P4::ConvertEnums (refMap, typeMap, new EnumOn32Bits ()),
203
- new P4::ConvertErrors (refMap, typeMap, new ErrorOn32Bits ()),
209
+ new P4::ConvertEnums (typeMap, new EnumOn32Bits ()),
210
+ new P4::ConvertErrors (typeMap, new ErrorOn32Bits ()),
204
211
// Simplify header stack assignments with runtime indices into conditional statements.
205
212
// TODO: Get rid of this pass.
206
- new P4::HSIndexSimplifier (refMap, typeMap),
213
+ new P4::HSIndexSimplifier (typeMap),
207
214
// Parse BMv2-specific annotations.
208
215
new BMV2::ParseAnnotations (),
209
216
// Convert Type_Varbits into a type that contains information about the assigned width.
0 commit comments