@@ -4436,26 +4436,67 @@ class P4HirToP4Exporter {
44364436 // / ```p4
44374437 // / in bit<32> data
44384438 // / ```
4439+ // mlir::LogicalResult exportArgument(mlir::FunctionOpInterface functionInterface,
4440+ // ExtendedFormattedOStream &ss, int index) {
4441+ // if (auto argAttrs = functionInterface.getArgAttrsAttr()) {
4442+ // if (index < static_cast<int>(argAttrs.size())) {
4443+ // if (auto dict =
4444+ // mlir::dyn_cast_if_present<mlir::DictionaryAttr>(argAttrs[index])) {
4445+ // auto annots =
4446+ // mlir::dyn_cast_if_present<mlir::DictionaryAttr>(dict.get("annotations"));
4447+ // if (!annots) {
4448+ // annots = mlir::dyn_cast_if_present<mlir::DictionaryAttr>(
4449+ // dict.get("p4hir.annotations"));
4450+ // }
4451+ // if (annots) {
4452+ // if (failed(exportAnnotations(annots, ss))) {
4453+ // return mlir::failure();
4454+ // }
4455+ // }
4456+ // }
4457+ // }
4458+ // }
4459+
4460+
4461+
4462+
44394463 mlir::LogicalResult exportArgument (mlir::FunctionOpInterface functionInterface,
4440- ExtendedFormattedOStream &ss, int index) {
4441- if ( auto argAttrs = functionInterface. getArgAttrsAttr ()) {
4442- if (index < static_cast < int >( argAttrs. size () )) {
4443- if (auto dict =
4444- mlir::dyn_cast_if_present<mlir::DictionaryAttr>(argAttrs[index])) {
4445- auto annots =
4446- mlir::dyn_cast_if_present<mlir::DictionaryAttr>(dict. get ( " annotations " ));
4447- if (!annots) {
4448- annots = mlir::dyn_cast_if_present<mlir::DictionaryAttr>(
4449- dict. get ( " p4hir.annotations " ));
4450- }
4451- if (annots) {
4452- if (failed ( exportAnnotations ( annots, ss)) ) {
4453- return mlir::failure ();
4454- }
4464+ ExtendedFormattedOStream &ss, int index) {
4465+ // 🔹 Handle annotations
4466+ if (auto argAttrs = functionInterface. getArgAttrsAttr ( )) {
4467+ if (index < static_cast < int >(argAttrs. size ())) {
4468+ if ( auto dict =
4469+ mlir::dyn_cast_if_present<mlir::DictionaryAttr>(argAttrs[index])) {
4470+ auto annots =
4471+ mlir::dyn_cast_if_present<mlir::DictionaryAttr>(dict. get ( " annotations " ));
4472+ if (! annots) {
4473+ annots = mlir::dyn_cast_if_present<mlir::DictionaryAttr>(
4474+ dict. get ( " p4hir.annotations " ));
4475+ }
4476+ if (annots) {
4477+ if ( failed ( exportAnnotations (annots, ss))) {
4478+ return mlir::failure ();
44554479 }
44564480 }
44574481 }
44584482 }
4483+ }
4484+
4485+ ss << " in " ;
4486+
4487+ auto type = functionInterface.getArgumentTypes ()[index];
4488+ if (failed (exportP4Type (type, ss))) {
4489+ return mlir::failure ();
4490+ }
4491+
4492+ ss << " arg" << index;
4493+
4494+ return mlir::success ();
4495+ }
4496+
4497+
4498+
4499+
44594500 // Export direction (in, out, inout).
44604501 auto directionAttr =
44614502 functionInterface.getArgAttr(index, P4HIR::FuncOp::getDirectionAttrName());
0 commit comments