MLIR  19.0.0git
Syntax.h
Go to the documentation of this file.
1 //===- Syntax.h - Custom syntax for Linalg transform ops --------*- C++ -*-===//
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_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H
10 #define MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H
11 
12 #include "mlir/Support/LLVM.h"
13 
14 namespace mlir {
15 class ParseResult;
16 class OpAsmParser;
17 class OpAsmPrinter;
18 class Type;
19 class TypeRange;
20 class Operation;
21 
22 /// Parses a single non-function type or a function type with at least one
23 /// argument. This allows for the following syntax:
24 ///
25 /// - type: just the argument type;
26 /// - `(` type `)` `->` type: one argument and one result type;
27 /// - `(` type `)` `->` `(` comma-separated-type-list `)`: one argument and
28 /// multiple result types.
29 ///
30 /// Unlike FunctionType, this allows and requires one to omit the parens around
31 /// the argument type in absence of result types, and does not accept the
32 /// trailing `-> ()` construct, which makes the syntax nicer for operations.
33 ParseResult parseSemiFunctionType(OpAsmParser &parser, Type &argumentType,
34  Type &resultType);
35 ParseResult parseSemiFunctionType(OpAsmParser &parser, Type &argumentType,
36  SmallVectorImpl<Type> &resultTypes);
37 
38 /// Prints argument and result types in a syntax similar to that of FunctionType
39 /// but allowing and requiring one to omit the parens around the argument type
40 /// in absence of result types, and without the trailing `-> ()`.
41 void printSemiFunctionType(OpAsmPrinter &printer, Operation *op,
42  Type argumentType, TypeRange resultType);
43 void printSemiFunctionType(OpAsmPrinter &printer, Operation *op,
44  Type argumentType, Type resultType);
45 } // namespace mlir
46 
47 #endif // MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H
@ Type
An inlay hint that for a type annotation.
Include the generated interface declarations.
ParseResult parseSemiFunctionType(OpAsmParser &parser, Type &argumentType, Type &resultType)
Parses a single non-function type or a function type with at least one argument.
Definition: Syntax.cpp:14
void printSemiFunctionType(OpAsmPrinter &printer, Operation *op, Type argumentType, TypeRange resultType)
Prints argument and result types in a syntax similar to that of FunctionType but allowing and requiri...
Definition: Syntax.cpp:55