[PATCH] D72822: [mlir] Replace AbstractOperation::classof with a ClassID instance.
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 10:23:08 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8fb29d4a5073: [mlir] Replace AbstractOperation::classof with a ClassID instance. (authored by rriddle).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72822/new/
https://reviews.llvm.org/D72822
Files:
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/OperationSupport.h
Index: mlir/include/mlir/IR/OperationSupport.h
===================================================================
--- mlir/include/mlir/IR/OperationSupport.h
+++ mlir/include/mlir/IR/OperationSupport.h
@@ -90,8 +90,8 @@
/// This is the dialect that this operation belongs to.
Dialect &dialect;
- /// Return true if this "op class" can match against the specified operation.
- bool (&classof)(Operation *op);
+ /// The unique identifier of the derived Op class.
+ ClassID *classID;
/// Use the specified object to parse this ops custom assembly format.
ParseResult (&parseAssembly)(OpAsmParser &parser, OperationState &result);
@@ -158,15 +158,16 @@
/// operations they contain.
template <typename T> static AbstractOperation get(Dialect &dialect) {
return AbstractOperation(
- T::getOperationName(), dialect, T::getOperationProperties(), T::classof,
- T::parseAssembly, T::printAssembly, T::verifyInvariants, T::foldHook,
- T::getCanonicalizationPatterns, T::getRawInterface, T::hasTrait);
+ T::getOperationName(), dialect, T::getOperationProperties(),
+ ClassID::getID<T>(), T::parseAssembly, T::printAssembly,
+ T::verifyInvariants, T::foldHook, T::getCanonicalizationPatterns,
+ T::getRawInterface, T::hasTrait);
}
private:
AbstractOperation(
StringRef name, Dialect &dialect, OperationProperties opProperties,
- bool (&classof)(Operation *op),
+ ClassID *classID,
ParseResult (&parseAssembly)(OpAsmParser &parser, OperationState &result),
void (&printAssembly)(Operation *op, OpAsmPrinter &p),
LogicalResult (&verifyInvariants)(Operation *op),
@@ -176,7 +177,7 @@
MLIRContext *context),
void *(&getRawInterface)(ClassID *interfaceID),
bool (&hasTrait)(ClassID *traitID))
- : name(name), dialect(dialect), classof(classof),
+ : name(name), dialect(dialect), classID(classID),
parseAssembly(parseAssembly), printAssembly(printAssembly),
verifyInvariants(verifyInvariants), foldHook(foldHook),
getCanonicalizationPatterns(getCanonicalizationPatterns),
Index: mlir/include/mlir/IR/OpDefinition.h
===================================================================
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -984,7 +984,7 @@
/// Return true if this "op class" can match against the specified operation.
static bool classof(Operation *op) {
if (auto *abstractOp = op->getAbstractOperation())
- return &classof == abstractOp->classof;
+ return ClassID::getID<ConcreteType>() == abstractOp->classID;
return op->getName().getStringRef() == ConcreteType::getOperationName();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72822.238821.patch
Type: text/x-patch
Size: 2764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200117/7ffe916c/attachment.bin>
More information about the llvm-commits
mailing list