1//===- OpAsmInterface.td - Asm Interfaces for opse ---------*- 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// This file contains Interfaces for interacting with the AsmParser and 10// AsmPrinter. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef MLIR_OPASMINTERFACE 15#define MLIR_OPASMINTERFACE 16 17include "mlir/IR/OpBase.td" 18 19/// Interface for hooking into the OpAsmPrinter and OpAsmParser. 20def OpAsmOpInterface : OpInterface<"OpAsmOpInterface"> { 21 let description = [{ 22 This interface provides hooks to interact with the AsmPrinter and AsmParser 23 classes. 24 }]; 25 let cppNamespace = "::mlir"; 26 27 let methods = [ 28 InterfaceMethod<[{ 29 Get a special name to use when printing the results of this operation. 30 The given callback is invoked with a specific result value that starts a 31 result "pack", and the name to give this result pack. To signal that a 32 result pack should use the default naming scheme, a None can be passed 33 in instead of the name. 34 35 For example, if you have an operation that has four results and you want 36 to split these into three distinct groups you could do the following: 37 38 ```c++ 39 setNameFn(getResult(0), "first_result"); 40 setNameFn(getResult(1), "middle_results"); 41 setNameFn(getResult(3), ""); // use the default numbering. 42 ``` 43 44 This would print the operation as follows: 45 46 ```mlir 47 %first_result, %middle_results:2, %0 = "my.op" ... 48 ``` 49 }], 50 "void", "getAsmResultNames", (ins "OpAsmSetValueNameFn":$setNameFn) 51 >, 52 ]; 53} 54 55#endif // MLIR_OPASMINTERFACE 56