1//===- RuntimeVerifiableOpInterface.td - Op Verification ---*- tablegen -*-===// 2// 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 6// 7//===----------------------------------------------------------------------===// 8 9#ifndef MLIR_INTERFACES_RUNTIMEVERIFIABLEOPINTERFACE 10#define MLIR_INTERFACES_RUNTIMEVERIFIABLEOPINTERFACE 11 12include "mlir/IR/OpBase.td" 13 14def RuntimeVerifiableOpInterface : OpInterface<"RuntimeVerifiableOpInterface"> { 15 let description = [{ 16 Implementations of this interface generate IR for runtime op verification. 17 18 Incorrect op usage can often be caught by op verifiers based on static 19 program information. However, in the absence of static program information, 20 it can remain undetected at compile time (e.g., in case of dynamic memref 21 strides instead of static memref strides). Such cases can be checked at 22 runtime. The op-specific checks are generated by this interface. 23 }]; 24 let cppNamespace = "::mlir"; 25 26 let methods = [ 27 InterfaceMethod< 28 /*desc=*/[{ 29 Generate IR to verify this op at runtime, aborting runtime execution if 30 verification fails. 31 }], 32 /*retTy=*/"void", 33 /*methodName=*/"generateRuntimeVerification", 34 /*args=*/(ins "::mlir::OpBuilder &":$builder, 35 "::mlir::Location":$loc) 36 >, 37 ]; 38 39 let extraClassDeclaration = [{ 40 /// Generate the error message that will be printed to the user when 41 /// verification fails. 42 static std::string generateErrorMessage(Operation *op, const std::string &msg); 43 }]; 44} 45 46#endif // MLIR_INTERFACES_RUNTIMEVERIFIABLEOPINTERFACE 47