brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.4 KiB · e914f9a Raw
231 lines · c
1//===- TestFormatUtils.h - MLIR Test Dialect Assembly Format Utilities ----===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef MLIR_TESTFORMATUTILS_H10#define MLIR_TESTFORMATUTILS_H11 12#include "mlir/IR/OpImplementation.h"13 14namespace test {15 16//===----------------------------------------------------------------------===//17// CustomDirectiveOperands18//===----------------------------------------------------------------------===//19 20mlir::ParseResult parseCustomDirectiveOperands(21    mlir::OpAsmParser &parser, mlir::OpAsmParser::UnresolvedOperand &operand,22    std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand,23    llvm::SmallVectorImpl<mlir::OpAsmParser::UnresolvedOperand> &varOperands);24 25void printCustomDirectiveOperands(mlir::OpAsmPrinter &printer,26                                  mlir::Operation *, mlir::Value operand,27                                  mlir::Value optOperand,28                                  mlir::OperandRange varOperands);29 30//===----------------------------------------------------------------------===//31// CustomDirectiveResults32//===----------------------------------------------------------------------===//33 34mlir::ParseResult35parseCustomDirectiveResults(mlir::OpAsmParser &parser, mlir::Type &operandType,36                            mlir::Type &optOperandType,37                            llvm::SmallVectorImpl<mlir::Type> &varOperandTypes);38 39void printCustomDirectiveResults(mlir::OpAsmPrinter &printer, mlir::Operation *,40                                 mlir::Type operandType,41                                 mlir::Type optOperandType,42                                 mlir::TypeRange varOperandTypes);43 44//===----------------------------------------------------------------------===//45// CustomDirectiveWithTypeRefs46//===----------------------------------------------------------------------===//47 48mlir::ParseResult parseCustomDirectiveWithTypeRefs(49    mlir::OpAsmParser &parser, mlir::Type operandType,50    mlir::Type optOperandType,51    const llvm::SmallVectorImpl<mlir::Type> &varOperandTypes);52 53void printCustomDirectiveWithTypeRefs(mlir::OpAsmPrinter &printer,54                                      mlir::Operation *op,55                                      mlir::Type operandType,56                                      mlir::Type optOperandType,57                                      mlir::TypeRange varOperandTypes);58 59//===----------------------------------------------------------------------===//60// CustomDirectiveOperandsAndTypes61//===----------------------------------------------------------------------===//62 63mlir::ParseResult parseCustomDirectiveOperandsAndTypes(64    mlir::OpAsmParser &parser, mlir::OpAsmParser::UnresolvedOperand &operand,65    std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand,66    llvm::SmallVectorImpl<mlir::OpAsmParser::UnresolvedOperand> &varOperands,67    mlir::Type &operandType, mlir::Type &optOperandType,68    llvm::SmallVectorImpl<mlir::Type> &varOperandTypes);69 70void printCustomDirectiveOperandsAndTypes(71    mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Value operand,72    mlir::Value optOperand, mlir::OperandRange varOperands,73    mlir::Type operandType, mlir::Type optOperandType,74    mlir::TypeRange varOperandTypes);75 76//===----------------------------------------------------------------------===//77// CustomDirectiveRegions78//===----------------------------------------------------------------------===//79 80mlir::ParseResult parseCustomDirectiveRegions(81    mlir::OpAsmParser &parser, mlir::Region &region,82    llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &varRegions);83 84void printCustomDirectiveRegions(85    mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Region &region,86    llvm::MutableArrayRef<mlir::Region> varRegions);87 88//===----------------------------------------------------------------------===//89// CustomDirectiveSuccessors90//===----------------------------------------------------------------------===//91 92mlir::ParseResult parseCustomDirectiveSuccessors(93    mlir::OpAsmParser &parser, mlir::Block *&successor,94    llvm::SmallVectorImpl<mlir::Block *> &varSuccessors);95 96void printCustomDirectiveSuccessors(mlir::OpAsmPrinter &printer,97                                    mlir::Operation *, mlir::Block *successor,98                                    mlir::SuccessorRange varSuccessors);99 100//===----------------------------------------------------------------------===//101// CustomDirectiveAttributes102//===----------------------------------------------------------------------===//103 104mlir::ParseResult parseCustomDirectiveAttributes(mlir::OpAsmParser &parser,105                                                 mlir::IntegerAttr &attr,106                                                 mlir::IntegerAttr &optAttr);107 108void printCustomDirectiveAttributes(mlir::OpAsmPrinter &printer,109                                    mlir::Operation *,110                                    mlir::Attribute attribute,111                                    mlir::Attribute optAttribute);112 113//===----------------------------------------------------------------------===//114// CustomDirectiveAttrDict115//===----------------------------------------------------------------------===//116 117mlir::ParseResult parseCustomDirectiveAttrDict(mlir::OpAsmParser &parser,118                                               mlir::NamedAttrList &attrs);119 120void printCustomDirectiveAttrDict(mlir::OpAsmPrinter &printer,121                                  mlir::Operation *op,122                                  mlir::DictionaryAttr attrs);123 124//===----------------------------------------------------------------------===//125// CustomDirectiveOptionalOperandRef126//===----------------------------------------------------------------------===//127 128mlir::ParseResult parseCustomDirectiveOptionalOperandRef(129    mlir::OpAsmParser &parser,130    std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand);131 132void printCustomDirectiveOptionalOperandRef(mlir::OpAsmPrinter &printer,133                                            mlir::Operation *op,134                                            mlir::Value optOperand);135 136//===----------------------------------------------------------------------===//137// CustomDirectiveOptionalOperand138//===----------------------------------------------------------------------===//139 140mlir::ParseResult parseCustomOptionalOperand(141    mlir::OpAsmParser &parser,142    std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand);143 144void printCustomOptionalOperand(mlir::OpAsmPrinter &printer, mlir::Operation *,145                                mlir::Value optOperand);146 147//===----------------------------------------------------------------------===//148// CustomDirectiveSwitchCases149//===----------------------------------------------------------------------===//150 151mlir::ParseResult parseSwitchCases(152    mlir::OpAsmParser &p, mlir::DenseI64ArrayAttr &cases,153    llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &caseRegions);154 155void printSwitchCases(mlir::OpAsmPrinter &p, mlir::Operation *op,156                      mlir::DenseI64ArrayAttr cases,157                      mlir::RegionRange caseRegions);158 159//===----------------------------------------------------------------------===//160// CustomUsingPropertyInCustom161//===----------------------------------------------------------------------===//162 163bool parseUsingPropertyInCustom(mlir::OpAsmParser &parser,164                                llvm::SmallVector<int64_t> &value);165 166void printUsingPropertyInCustom(mlir::OpAsmPrinter &printer,167                                mlir::Operation *op,168                                llvm::ArrayRef<int64_t> value);169 170//===----------------------------------------------------------------------===//171// CustomDirectiveIntProperty172//===----------------------------------------------------------------------===//173 174bool parseIntProperty(mlir::OpAsmParser &parser, int64_t &value);175 176void printIntProperty(mlir::OpAsmPrinter &printer, mlir::Operation *op,177                      int64_t value);178 179//===----------------------------------------------------------------------===//180// CustomDirectiveSumProperty181//===----------------------------------------------------------------------===//182 183bool parseSumProperty(mlir::OpAsmParser &parser, int64_t &second,184                      int64_t first);185 186void printSumProperty(mlir::OpAsmPrinter &printer, mlir::Operation *op,187                      int64_t second, int64_t first);188 189//===----------------------------------------------------------------------===//190// CustomDirectiveOptionalCustomParser191//===----------------------------------------------------------------------===//192 193mlir::OptionalParseResult parseOptionalCustomParser(mlir::AsmParser &p,194                                                    mlir::IntegerAttr &result);195 196void printOptionalCustomParser(mlir::AsmPrinter &p, mlir::Operation *,197                               mlir::IntegerAttr result);198 199//===----------------------------------------------------------------------===//200// CustomDirectiveAttrElideType201//===----------------------------------------------------------------------===//202 203mlir::ParseResult parseAttrElideType(mlir::AsmParser &parser,204                                     mlir::TypeAttr type,205                                     mlir::Attribute &attr);206 207void printAttrElideType(mlir::AsmPrinter &printer, mlir::Operation *op,208                        mlir::TypeAttr type, mlir::Attribute attr);209 210//===----------------------------------------------------------------------===//211// CustomDirectiveDummyRegionRef212//===----------------------------------------------------------------------===//213 214mlir::ParseResult parseDummyRegionRef(mlir::OpAsmParser &parser,215                                      mlir::Region &region);216void printDummyRegionRef(mlir::OpAsmPrinter &printer, mlir::Operation *op,217                         mlir::Region &region);218 219//===----------------------------------------------------------------------===//220// CustomDirectiveDummySuccessorRef221//===----------------------------------------------------------------------===//222 223mlir::ParseResult parseDummySuccessorRef(mlir::OpAsmParser &parser,224                                         mlir::Block *successor);225void printDummySuccessorRef(mlir::OpAsmPrinter &printer, mlir::Operation *op,226                            mlir::Block *successor);227 228} // end namespace test229 230#endif // MLIR_TESTFORMATUTILS_H231