Enhance the customizable "Op" implementations in a bunch of ways:
- Op classes can now provide customized matchers, allowing specializations
beyond just a name match.
- We now provide default implementations of verify/print hooks, so Op classes
only need to implement them if they're doing custom stuff, and only have to
implement the ones they're interested in.
- "Base" now takes a variadic list of template template arguments, allowing
concrete Op types to avoid passing the Concrete type multiple times.
- Add new ZeroOperands trait.
- Add verification hooks to Zero/One/Two operands and OneResult to check that
ops using them are correctly formed.
- Implement getOperand hooks to zero/one/two operand traits, and
getResult/getType hook to OneResult trait.
- Add a new "constant" op to show some of this off, with a specialization for
the constant case.
This patch also splits op validity checks out to a new test/IR/invalid-ops.mlir
file.
This stubs out support for default asmprinter support. My next planned patch
building on top of this will make asmprinter hooks real and will revise this.
PiperOrigin-RevId: 205833214
diff --git a/lib/Parser/Parser.cpp b/lib/Parser/Parser.cpp
index 90e3dd3..daf20db 100644
--- a/lib/Parser/Parser.cpp
+++ b/lib/Parser/Parser.cpp
@@ -1576,7 +1576,7 @@
// source location.
if (auto *opInfo = op->getAbstractOperation(builder.getContext())) {
if (auto error = opInfo->verifyInvariants(op))
- return emitError(loc, error);
+ return emitError(loc, Twine("'") + op->getName().str() + "' op " + error);
}
// If the instruction had a name, register it.