virtual void
getTypeAliases(SmallVectorImpl<std::pair<StringRef, Type>> &aliases) {}
- /// Verify an attribute from this dialect on the given function. Returns true
- /// if the verification failed, false otherwise.
- virtual bool verifyFunctionAttribute(Function *, NamedAttribute) {
- return false;
+ /// Verify an attribute from this dialect on the given function. Returns
+ /// failure if the verification failed, success otherwise.
+ virtual LogicalResult verifyFunctionAttribute(Function *, NamedAttribute) {
+ return success();
}
/// Verify an attribute from this dialect on the argument at 'argIndex' for
- /// the given function. Returns true if the verification failed, false
+ /// the given function. Returns failure if the verification failed, success
/// otherwise.
- virtual bool verifyFunctionArgAttribute(Function *, unsigned argIndex,
- NamedAttribute) {
- return false;
+ virtual LogicalResult
+ verifyFunctionArgAttribute(Function *, unsigned argIndex, NamedAttribute) {
+ return success();
}
/// Verify an attribute from this dialect on the given operation. Returns
- /// true if the verification failed, false otherwise.
- virtual bool verifyOperationAttribute(Operation *, NamedAttribute) {
- return false;
+ /// failure if the verification failed, success otherwise.
+ virtual LogicalResult verifyOperationAttribute(Operation *, NamedAttribute) {
+ return success();
}
virtual ~Dialect();
/// Emit an error about fatal conditions with this operation, reporting up to
/// any diagnostic handlers that may be listening. This function always
- /// returns true. NOTE: This may terminate the containing application, only
- /// use when the IR is in an inconsistent state.
- bool emitError(const Twine &message);
+ /// returns failure. NOTE: This may terminate the containing application,
+ /// only use when the IR is in an inconsistent state.
+ LogicalResult emitError(const Twine &message);
/// Emit a warning about this operation, reporting up to any diagnostic
/// handlers that may be listening.
void printType(Type type, raw_ostream &os) const override;
/// Verify a function argument attribute registered to this dialect.
- /// Returns true if the verification failed, false otherwise.
- bool verifyFunctionArgAttribute(Function *func, unsigned argIdx,
- NamedAttribute argAttr) override;
+ /// Returns failure if the verification failed, success otherwise.
+ LogicalResult verifyFunctionArgAttribute(Function *func, unsigned argIdx,
+ NamedAttribute argAttr) override;
private:
llvm::LLVMContext llvmContext;
LogicalResult failure() { return mlir::failure(); }
LogicalResult failure(const Twine &message, Operation &value) {
- return value.emitError(message), failure();
+ return value.emitError(message);
}
LogicalResult failure(const Twine &message, Function &fn) {
- return fn.emitError(message), failure();
+ return fn.emitError(message);
}
LogicalResult failure(const Twine &message, Block &bb) {
// Verify this attribute with the defining dialect.
if (auto *dialect = getDialectForAttribute(attr))
- if (dialect->verifyFunctionAttribute(&fn, attr))
+ if (failed(dialect->verifyFunctionAttribute(&fn, attr)))
return failure();
}
// Verify this attribute with the defining dialect.
if (auto *dialect = getDialectForAttribute(attr))
- if (dialect->verifyFunctionArgAttribute(&fn, i, attr))
+ if (failed(dialect->verifyFunctionArgAttribute(&fn, i, attr)))
return failure();
}
}
if (!attr.first.strref().contains('.'))
continue;
if (auto *dialect = getDialectForAttribute(attr))
- if (dialect->verifyOperationAttribute(&op, attr))
+ if (failed(dialect->verifyOperationAttribute(&op, attr)))
return failure();
}
/// Emit an error about fatal conditions with this operation, reporting up to
/// any diagnostic handlers that may be listening. This function always
-/// returns true. NOTE: This may terminate the containing application, only use
-/// when the IR is in an inconsistent state.
-bool Function::emitError(const Twine &message) {
- return getContext()->emitError(getLoc(), message);
+/// returns failure. NOTE: This may terminate the containing application, only
+/// use when the IR is in an inconsistent state.
+LogicalResult Function::emitError(const Twine &message) {
+ return getContext()->emitError(getLoc(), message), failure();
}
/// Clone the internal blocks from this function into dest and all attributes
}
/// Verify LLVMIR function argument attributes.
-bool LLVMDialect::verifyFunctionArgAttribute(Function *func, unsigned argIdx,
- NamedAttribute argAttr) {
+LogicalResult LLVMDialect::verifyFunctionArgAttribute(Function *func,
+ unsigned argIdx,
+ NamedAttribute argAttr) {
// Check that llvm.noalias is a boolean attribute.
if (argAttr.first == "llvm.noalias" && !argAttr.second.isa<BoolAttr>())
return func->emitError(
"llvm.noalias argument attribute of non boolean type");
- return false;
+ return success();
}
static DialectRegistration<LLVMDialect> llvmDialect;