@@ -139,6 +139,12 @@ class OperationName {
139139 setPropertiesFromAttr (OperationName, OpaqueProperties, Attribute,
140140 function_ref<InFlightDiagnostic()> emitError) = 0 ;
141141 virtual Attribute getPropertiesAsAttr (Operation *) = 0;
142+ virtual LogicalResult
143+ setPropertyFromAttr (OperationName, OpaqueProperties, StringRef name,
144+ Attribute,
145+ function_ref<InFlightDiagnostic()> emitError) = 0 ;
146+ virtual FailureOr<Attribute> getPropertyAsAttr (Operation *,
147+ StringRef name) = 0;
142148 virtual void copyProperties (OpaqueProperties, OpaqueProperties) = 0;
143149 virtual bool compareProperties (OpaqueProperties, OpaqueProperties) = 0;
144150 virtual llvm::hash_code hashProperties (OpaqueProperties) = 0;
@@ -220,6 +226,11 @@ class OperationName {
220226 setPropertiesFromAttr (OperationName, OpaqueProperties, Attribute,
221227 function_ref<InFlightDiagnostic()> emitError) final ;
222228 Attribute getPropertiesAsAttr (Operation *) final ;
229+ LogicalResult
230+ setPropertyFromAttr (OperationName, OpaqueProperties, StringRef name,
231+ Attribute,
232+ function_ref<InFlightDiagnostic()> emitError) final ;
233+ FailureOr<Attribute> getPropertyAsAttr (Operation *, StringRef name) final ;
223234 void copyProperties (OpaqueProperties, OpaqueProperties) final ;
224235 bool compareProperties (OpaqueProperties, OpaqueProperties) final ;
225236 llvm::hash_code hashProperties (OpaqueProperties) final ;
@@ -441,6 +452,20 @@ class OperationName {
441452 emitError);
442453 }
443454
455+ // / Return an op property converted to an Attribute.
456+ FailureOr<Attribute> getOpPropertyAsAttribute (Operation *op,
457+ StringRef name) const {
458+ return getImpl ()->getPropertyAsAttr (op, name);
459+ }
460+
461+ // / Define an op property from the provided Attribute.
462+ LogicalResult setOpPropertyFromAttribute (
463+ OperationName opName, OpaqueProperties properties, StringRef name,
464+ Attribute attr, function_ref<InFlightDiagnostic()> emitError) const {
465+ return getImpl ()->setPropertyFromAttr (opName, properties, name, attr,
466+ emitError);
467+ }
468+
444469 void copyOpProperties (OpaqueProperties lhs, OpaqueProperties rhs) const {
445470 return getImpl ()->copyProperties (lhs, rhs);
446471 }
@@ -650,6 +675,26 @@ class RegisteredOperationName : public OperationName {
650675 }
651676 return {};
652677 }
678+ LogicalResult
679+ setPropertyFromAttr (OperationName opName, OpaqueProperties properties,
680+ StringRef name, Attribute attr,
681+ function_ref<InFlightDiagnostic()> emitError) final {
682+ if constexpr (hasProperties) {
683+ auto p = properties.as <Properties *>();
684+ return ConcreteOp::setPropertyFromAttr (*p, name, attr, emitError);
685+ }
686+ emitError () << " this operation does not support properties" ;
687+ return failure ();
688+ }
689+ FailureOr<Attribute> getPropertyAsAttr (Operation *op,
690+ StringRef name) final {
691+ if constexpr (hasProperties) {
692+ auto concreteOp = cast<ConcreteOp>(op);
693+ return ConcreteOp::getPropertyAsAttr (concreteOp->getContext (),
694+ concreteOp.getProperties (), name);
695+ }
696+ return failure ();
697+ }
653698 bool compareProperties (OpaqueProperties lhs, OpaqueProperties rhs) final {
654699 if constexpr (hasProperties) {
655700 return *lhs.as <Properties *>() == *rhs.as <Properties *>();
0 commit comments