summaryrefslogtreecommitdiff
path: root/mlir/include/mlir/Dialect/Linalg/TransformOps/Syntax.h
blob: 13b0dc0e0b95e36724f1eff3a3e106d4776a10a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//===- Syntax.h - Custom syntax for Linalg transform ops --------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H
#define MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H

#include "mlir/Support/LLVM.h"

namespace mlir {
class ParseResult;
class OpAsmParser;
class OpAsmPrinter;
class Type;
class TypeRange;
class Operation;

/// Parses a single non-function type or a function type with at least one
/// argument. This allows for the following syntax:
///
///   - type: just the argument type;
///   - `(` type `)` `->` type: one argument and one result type;
///   - `(` type `)` `->` `(` comma-separated-type-list `)`: one argument and
///     multiple result types.
///
/// Unlike FunctionType, this allows and requires one to omit the parens around
/// the argument type in absence of result types, and does not accept the
/// trailing `-> ()` construct, which makes the syntax nicer for operations.
ParseResult parseSemiFunctionType(OpAsmParser &parser, Type &argumentType,
                                  Type &resultType);
ParseResult parseSemiFunctionType(OpAsmParser &parser, Type &argumentType,
                                  SmallVectorImpl<Type> &resultTypes);

/// Prints argument and result types in a syntax similar to that of FunctionType
/// but allowing and requiring one to omit the parens around the argument type
/// in absence of result types, and without the trailing `-> ()`.
void printSemiFunctionType(OpAsmPrinter &printer, Operation *op,
                           Type argumentType, TypeRange resultType);
void printSemiFunctionType(OpAsmPrinter &printer, Operation *op,
                           Type argumentType, Type resultType);
} // namespace mlir

#endif // MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H