//===- TestFormatUtils.h - MLIR Test Dialect Assembly Format Utilities ----===// // // 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_TESTFORMATUTILS_H #define MLIR_TESTFORMATUTILS_H #include "mlir/IR/OpImplementation.h" namespace test { //===----------------------------------------------------------------------===// // CustomDirectiveOperands //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveOperands( mlir::OpAsmParser &parser, mlir::OpAsmParser::UnresolvedOperand &operand, std::optional &optOperand, llvm::SmallVectorImpl &varOperands); void printCustomDirectiveOperands(mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Value operand, mlir::Value optOperand, mlir::OperandRange varOperands); //===----------------------------------------------------------------------===// // CustomDirectiveResults //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveResults(mlir::OpAsmParser &parser, mlir::Type &operandType, mlir::Type &optOperandType, llvm::SmallVectorImpl &varOperandTypes); void printCustomDirectiveResults(mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Type operandType, mlir::Type optOperandType, mlir::TypeRange varOperandTypes); //===----------------------------------------------------------------------===// // CustomDirectiveWithTypeRefs //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveWithTypeRefs( mlir::OpAsmParser &parser, mlir::Type operandType, mlir::Type optOperandType, const llvm::SmallVectorImpl &varOperandTypes); void printCustomDirectiveWithTypeRefs(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Type operandType, mlir::Type optOperandType, mlir::TypeRange varOperandTypes); //===----------------------------------------------------------------------===// // CustomDirectiveOperandsAndTypes //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveOperandsAndTypes( mlir::OpAsmParser &parser, mlir::OpAsmParser::UnresolvedOperand &operand, std::optional &optOperand, llvm::SmallVectorImpl &varOperands, mlir::Type &operandType, mlir::Type &optOperandType, llvm::SmallVectorImpl &varOperandTypes); void printCustomDirectiveOperandsAndTypes( mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Value operand, mlir::Value optOperand, mlir::OperandRange varOperands, mlir::Type operandType, mlir::Type optOperandType, mlir::TypeRange varOperandTypes); //===----------------------------------------------------------------------===// // CustomDirectiveRegions //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveRegions( mlir::OpAsmParser &parser, mlir::Region ®ion, llvm::SmallVectorImpl> &varRegions); void printCustomDirectiveRegions( mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Region ®ion, llvm::MutableArrayRef varRegions); //===----------------------------------------------------------------------===// // CustomDirectiveSuccessors //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveSuccessors( mlir::OpAsmParser &parser, mlir::Block *&successor, llvm::SmallVectorImpl &varSuccessors); void printCustomDirectiveSuccessors(mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Block *successor, mlir::SuccessorRange varSuccessors); //===----------------------------------------------------------------------===// // CustomDirectiveAttributes //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveAttributes(mlir::OpAsmParser &parser, mlir::IntegerAttr &attr, mlir::IntegerAttr &optAttr); void printCustomDirectiveAttributes(mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Attribute attribute, mlir::Attribute optAttribute); //===----------------------------------------------------------------------===// // CustomDirectiveAttrDict //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveAttrDict(mlir::OpAsmParser &parser, mlir::NamedAttrList &attrs); void printCustomDirectiveAttrDict(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::DictionaryAttr attrs); //===----------------------------------------------------------------------===// // CustomDirectiveOptionalOperandRef //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomDirectiveOptionalOperandRef( mlir::OpAsmParser &parser, std::optional &optOperand); void printCustomDirectiveOptionalOperandRef(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Value optOperand); //===----------------------------------------------------------------------===// // CustomDirectiveOptionalOperand //===----------------------------------------------------------------------===// mlir::ParseResult parseCustomOptionalOperand( mlir::OpAsmParser &parser, std::optional &optOperand); void printCustomOptionalOperand(mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Value optOperand); //===----------------------------------------------------------------------===// // CustomDirectiveSwitchCases //===----------------------------------------------------------------------===// mlir::ParseResult parseSwitchCases( mlir::OpAsmParser &p, mlir::DenseI64ArrayAttr &cases, llvm::SmallVectorImpl> &caseRegions); void printSwitchCases(mlir::OpAsmPrinter &p, mlir::Operation *op, mlir::DenseI64ArrayAttr cases, mlir::RegionRange caseRegions); //===----------------------------------------------------------------------===// // CustomUsingPropertyInCustom //===----------------------------------------------------------------------===// bool parseUsingPropertyInCustom(mlir::OpAsmParser &parser, llvm::SmallVector &value); void printUsingPropertyInCustom(mlir::OpAsmPrinter &printer, mlir::Operation *op, llvm::ArrayRef value); //===----------------------------------------------------------------------===// // CustomDirectiveIntProperty //===----------------------------------------------------------------------===// bool parseIntProperty(mlir::OpAsmParser &parser, int64_t &value); void printIntProperty(mlir::OpAsmPrinter &printer, mlir::Operation *op, int64_t value); //===----------------------------------------------------------------------===// // CustomDirectiveSumProperty //===----------------------------------------------------------------------===// bool parseSumProperty(mlir::OpAsmParser &parser, int64_t &second, int64_t first); void printSumProperty(mlir::OpAsmPrinter &printer, mlir::Operation *op, int64_t second, int64_t first); //===----------------------------------------------------------------------===// // CustomDirectiveOptionalCustomParser //===----------------------------------------------------------------------===// mlir::OptionalParseResult parseOptionalCustomParser(mlir::AsmParser &p, mlir::IntegerAttr &result); void printOptionalCustomParser(mlir::AsmPrinter &p, mlir::Operation *, mlir::IntegerAttr result); //===----------------------------------------------------------------------===// // CustomDirectiveAttrElideType //===----------------------------------------------------------------------===// mlir::ParseResult parseAttrElideType(mlir::AsmParser &parser, mlir::TypeAttr type, mlir::Attribute &attr); void printAttrElideType(mlir::AsmPrinter &printer, mlir::Operation *op, mlir::TypeAttr type, mlir::Attribute attr); //===----------------------------------------------------------------------===// // CustomDirectiveDummyRegionRef //===----------------------------------------------------------------------===// mlir::ParseResult parseDummyRegionRef(mlir::OpAsmParser &parser, mlir::Region ®ion); void printDummyRegionRef(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Region ®ion); //===----------------------------------------------------------------------===// // CustomDirectiveDummySuccessorRef //===----------------------------------------------------------------------===// mlir::ParseResult parseDummySuccessorRef(mlir::OpAsmParser &parser, mlir::Block *successor); void printDummySuccessorRef(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Block *successor); } // end namespace test #endif // MLIR_TESTFORMATUTILS_H