@@ -191,7 +191,7 @@ class OpState {
191191 Operation *state;
192192
193193 // / Allow access to internal hook implementation methods.
194- friend AbstractOperation ;
194+ friend RegisteredOperationName ;
195195};
196196
197197// Allow comparing operators.
@@ -1585,8 +1585,8 @@ class Op : public OpState, public Traits<ConcreteType>... {
15851585
15861586 // / Return true if this "op class" can match against the specified operation.
15871587 static bool classof (Operation *op) {
1588- if (auto *abstractOp = op->getAbstractOperation ())
1589- return TypeID::get<ConcreteType>() == abstractOp-> typeID ;
1588+ if (auto info = op->getRegisteredInfo ())
1589+ return TypeID::get<ConcreteType>() == info-> getTypeID () ;
15901590#ifndef NDEBUG
15911591 if (op->getName ().getStringRef () == ConcreteType::getOperationName ())
15921592 llvm::report_fatal_error (
@@ -1628,13 +1628,13 @@ class Op : public OpState, public Traits<ConcreteType>... {
16281628 // / for the concrete operation.
16291629 template <typename ... Models>
16301630 static void attachInterface (MLIRContext &context) {
1631- AbstractOperation *abstract = AbstractOperation::lookupMutable (
1631+ Optional<RegisteredOperationName> info = RegisteredOperationName::lookup (
16321632 ConcreteType::getOperationName (), &context);
1633- if (!abstract )
1633+ if (!info )
16341634 llvm::report_fatal_error (
16351635 " Attempting to attach an interface to an unregistered operation " +
16361636 ConcreteType::getOperationName () + " ." );
1637- abstract-> interfaceMap . insert <Models...>();
1637+ info-> attachInterface <Models...>();
16381638 }
16391639
16401640private:
@@ -1673,10 +1673,10 @@ class Op : public OpState, public Traits<ConcreteType>... {
16731673 return detail::InterfaceMap::template get<Traits<ConcreteType>...>();
16741674 }
16751675
1676- // / Return the internal implementations of each of the AbstractOperation
1676+ // / Return the internal implementations of each of the OperationName
16771677 // / hooks.
1678- // / Implementation of `FoldHookFn` AbstractOperation hook.
1679- static AbstractOperation ::FoldHookFn getFoldHookFn () {
1678+ // / Implementation of `FoldHookFn` OperationName hook.
1679+ static OperationName ::FoldHookFn getFoldHookFn () {
16801680 return getFoldHookFnImpl<ConcreteType>();
16811681 }
16821682 // / The internal implementation of `getFoldHookFn` above that is invoked if
@@ -1685,7 +1685,7 @@ class Op : public OpState, public Traits<ConcreteType>... {
16851685 static std::enable_if_t <llvm::is_one_of<OpTrait::OneResult<ConcreteOpT>,
16861686 Traits<ConcreteOpT>...>::value &&
16871687 detect_has_single_result_fold<ConcreteOpT>::value,
1688- AbstractOperation ::FoldHookFn>
1688+ OperationName ::FoldHookFn>
16891689 getFoldHookFnImpl () {
16901690 return [](Operation *op, ArrayRef<Attribute> operands,
16911691 SmallVectorImpl<OpFoldResult> &results) {
@@ -1698,7 +1698,7 @@ class Op : public OpState, public Traits<ConcreteType>... {
16981698 static std::enable_if_t <!llvm::is_one_of<OpTrait::OneResult<ConcreteOpT>,
16991699 Traits<ConcreteOpT>...>::value &&
17001700 detect_has_fold<ConcreteOpT>::value,
1701- AbstractOperation ::FoldHookFn>
1701+ OperationName ::FoldHookFn>
17021702 getFoldHookFnImpl () {
17031703 return [](Operation *op, ArrayRef<Attribute> operands,
17041704 SmallVectorImpl<OpFoldResult> &results) {
@@ -1710,7 +1710,7 @@ class Op : public OpState, public Traits<ConcreteType>... {
17101710 template <typename ConcreteOpT>
17111711 static std::enable_if_t <!detect_has_single_result_fold<ConcreteOpT>::value &&
17121712 !detect_has_fold<ConcreteOpT>::value,
1713- AbstractOperation ::FoldHookFn>
1713+ OperationName ::FoldHookFn>
17141714 getFoldHookFnImpl () {
17151715 return [](Operation *op, ArrayRef<Attribute> operands,
17161716 SmallVectorImpl<OpFoldResult> &results) {
@@ -1754,29 +1754,29 @@ class Op : public OpState, public Traits<ConcreteType>... {
17541754 return result;
17551755 }
17561756
1757- // / Implementation of `GetCanonicalizationPatternsFn` AbstractOperation hook.
1758- static AbstractOperation ::GetCanonicalizationPatternsFn
1757+ // / Implementation of `GetCanonicalizationPatternsFn` OperationName hook.
1758+ static OperationName ::GetCanonicalizationPatternsFn
17591759 getGetCanonicalizationPatternsFn () {
17601760 return &ConcreteType::getCanonicalizationPatterns;
17611761 }
17621762 // / Implementation of `GetHasTraitFn`
1763- static AbstractOperation ::HasTraitFn getHasTraitFn () {
1763+ static OperationName ::HasTraitFn getHasTraitFn () {
17641764 return
17651765 [](TypeID id) { return op_definition_impl::hasTrait<Traits...>(id); };
17661766 }
1767- // / Implementation of `ParseAssemblyFn` AbstractOperation hook.
1768- static AbstractOperation ::ParseAssemblyFn getParseAssemblyFn () {
1767+ // / Implementation of `ParseAssemblyFn` OperationName hook.
1768+ static OperationName ::ParseAssemblyFn getParseAssemblyFn () {
17691769 return &ConcreteType::parse;
17701770 }
1771- // / Implementation of `PrintAssemblyFn` AbstractOperation hook.
1772- static AbstractOperation ::PrintAssemblyFn getPrintAssemblyFn () {
1771+ // / Implementation of `PrintAssemblyFn` OperationName hook.
1772+ static OperationName ::PrintAssemblyFn getPrintAssemblyFn () {
17731773 return getPrintAssemblyFnImpl<ConcreteType>();
17741774 }
17751775 // / The internal implementation of `getPrintAssemblyFn` that is invoked when
17761776 // / the concrete operation does not define a `print` method.
17771777 template <typename ConcreteOpT>
17781778 static std::enable_if_t <!detect_has_print<ConcreteOpT>::value,
1779- AbstractOperation ::PrintAssemblyFn>
1779+ OperationName ::PrintAssemblyFn>
17801780 getPrintAssemblyFnImpl () {
17811781 return [](Operation *op, OpAsmPrinter &printer, StringRef defaultDialect) {
17821782 return OpState::print (op, printer);
@@ -1786,7 +1786,7 @@ class Op : public OpState, public Traits<ConcreteType>... {
17861786 // / the concrete operation defines a `print` method.
17871787 template <typename ConcreteOpT>
17881788 static std::enable_if_t <detect_has_print<ConcreteOpT>::value,
1789- AbstractOperation ::PrintAssemblyFn>
1789+ OperationName ::PrintAssemblyFn>
17901790 getPrintAssemblyFnImpl () {
17911791 return &printAssembly;
17921792 }
@@ -1795,8 +1795,8 @@ class Op : public OpState, public Traits<ConcreteType>... {
17951795 OpState::printOpName (op, p, defaultDialect);
17961796 return cast<ConcreteType>(op).print (p);
17971797 }
1798- // / Implementation of `VerifyInvariantsFn` AbstractOperation hook.
1799- static AbstractOperation ::VerifyInvariantsFn getVerifyInvariantsFn () {
1798+ // / Implementation of `VerifyInvariantsFn` OperationName hook.
1799+ static OperationName ::VerifyInvariantsFn getVerifyInvariantsFn () {
18001800 return &verifyInvariants;
18011801 }
18021802
@@ -1816,7 +1816,7 @@ class Op : public OpState, public Traits<ConcreteType>... {
18161816 }
18171817
18181818 // / Allow access to internal implementation methods.
1819- friend AbstractOperation ;
1819+ friend RegisteredOperationName ;
18201820};
18211821
18221822// / This class represents the base of an operation interface. See the definition
@@ -1836,22 +1836,22 @@ class OpInterface
18361836protected:
18371837 // / Returns the impl interface instance for the given operation.
18381838 static typename InterfaceBase::Concept *getInterfaceFor (Operation *op) {
1839- // Access the raw interface from the abstract operation.
1840- auto *abstractOp = op->getAbstractOperation ();
1841- if (abstractOp) {
1842- if (auto *opIface = abstractOp->getInterface <ConcreteType>())
1839+ OperationName name = op->getName ();
1840+
1841+ // Access the raw interface from the operation info.
1842+ if (Optional<RegisteredOperationName> rInfo = name.getRegisteredInfo ()) {
1843+ if (auto *opIface = rInfo->getInterface <ConcreteType>())
18431844 return opIface;
18441845 // Fallback to the dialect to provide it with a chance to implement this
18451846 // interface for this operation.
1846- return abstractOp-> dialect .getRegisteredInterfaceForOp <ConcreteType>(
1847+ return rInfo-> getDialect () .getRegisteredInterfaceForOp <ConcreteType>(
18471848 op->getName ());
18481849 }
18491850 // Fallback to the dialect to provide it with a chance to implement this
18501851 // interface for this operation.
1851- Dialect *dialect = op->getName ().getDialect ();
1852- return dialect ? dialect->getRegisteredInterfaceForOp <ConcreteType>(
1853- op->getName ())
1854- : nullptr ;
1852+ if (Dialect *dialect = name.getDialect ())
1853+ return dialect->getRegisteredInterfaceForOp <ConcreteType>(name);
1854+ return nullptr ;
18551855 }
18561856
18571857 // / Allow access to `getInterfaceFor`.
0 commit comments