1 //===- RuntimeVerifiableOpInterface.cpp - Op Verification -----------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "mlir/Interfaces/RuntimeVerifiableOpInterface.h"
15 /// Generate an error message string for the given op and the specified error.
17 RuntimeVerifiableOpInterface::generateErrorMessage(Operation
*op
,
18 const std::string
&msg
) {
20 llvm::raw_string_ostream
stream(buffer
);
21 OpPrintingFlags flags
;
22 // We may generate a lot of error messages and so we need to ensure the
24 flags
.elideLargeElementsAttrs();
25 flags
.printGenericOpForm();
27 flags
.useLocalScope();
28 stream
<< "ERROR: Runtime op verification failed\n";
29 op
->print(stream
, flags
);
30 stream
<< "\n^ " << msg
;
31 stream
<< "\nLocation: ";
32 op
->getLoc().print(stream
);
37 /// Include the definitions of the interface.
38 #include "mlir/Interfaces/RuntimeVerifiableOpInterface.cpp.inc"