//===- MLProgramOps.cpp - MLProgram dialect ops implementation ------------===// // // 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 // //===----------------------------------------------------------------------===// #include "mlir/Dialect/MLProgram/IR/MLProgram.h" #include "mlir/IR/Builders.h" #include "mlir/Interfaces/FunctionImplementation.h" usingnamespacemlir; usingnamespacemlir::ml_program; //===----------------------------------------------------------------------===// // Custom asm helpers //===----------------------------------------------------------------------===// /// Parse and print an ordering clause for a variadic of consuming tokens /// and an producing token. /// /// Syntax: /// ordering(%0, %1 -> !ml_program.token) /// ordering(() -> !ml_program.token) /// /// If both the consuming and producing token are not present on the op, then /// the clause prints nothing. static ParseResult parseTokenOrdering( OpAsmParser &parser, SmallVectorImpl<OpAsmParser::UnresolvedOperand> &consumeTokens, Type &produceTokenType) { … } static void printTokenOrdering(OpAsmPrinter &p, Operation *op, OperandRange consumeTokens, Type produceTokenType) { … } /// some.op custom<TypeOrAttr>($type, $attr) /// /// Uninitialized: /// some.op : tensor<3xi32> /// Initialized to narrower type than op: /// some.op (dense<0> : tensor<3xi32>) : tensor<?xi32> static ParseResult parseTypedInitialValue(OpAsmParser &parser, TypeAttr &typeAttr, Attribute &attr) { … } static void printTypedInitialValue(OpAsmPrinter &p, Operation *op, TypeAttr type, Attribute attr) { … } /// some.op custom<SymbolVisibility>($sym_visibility) $sym_name /// -> /// some.op public @foo /// some.op private @foo static ParseResult parseSymbolVisibility(OpAsmParser &parser, StringAttr &symVisibilityAttr) { … } static void printSymbolVisibility(OpAsmPrinter &p, Operation *op, StringAttr symVisibilityAttr) { … } //===----------------------------------------------------------------------===// // TableGen'd op method definitions //===----------------------------------------------------------------------===// #define GET_OP_CLASSES #include "mlir/Dialect/MLProgram/IR/MLProgramOps.cpp.inc" //===----------------------------------------------------------------------===// // FuncOp //===----------------------------------------------------------------------===// ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) { … } void FuncOp::print(OpAsmPrinter &p) { … } //===----------------------------------------------------------------------===// // GlobalOp //===----------------------------------------------------------------------===// LogicalResult GlobalOp::verify() { … } //===----------------------------------------------------------------------===// // GlobalLoadOp //===----------------------------------------------------------------------===// GlobalOp GlobalLoadOp::getGlobalOp(SymbolTableCollection &symbolTable) { … } LogicalResult GlobalLoadOp::verifySymbolUses(SymbolTableCollection &symbolTable) { … } //===----------------------------------------------------------------------===// // GlobalLoadConstOp //===----------------------------------------------------------------------===// GlobalOp GlobalLoadConstOp::getGlobalOp(SymbolTableCollection &symbolTable) { … } LogicalResult GlobalLoadConstOp::verifySymbolUses(SymbolTableCollection &symbolTable) { … } //===----------------------------------------------------------------------===// // GlobalLoadGraphOp //===----------------------------------------------------------------------===// GlobalOp GlobalLoadGraphOp::getGlobalOp(SymbolTableCollection &symbolTable) { … } LogicalResult GlobalLoadGraphOp::verifySymbolUses(SymbolTableCollection &symbolTable) { … } //===----------------------------------------------------------------------===// // GlobalStoreOp //===----------------------------------------------------------------------===// GlobalOp GlobalStoreOp::getGlobalOp(SymbolTableCollection &symbolTable) { … } LogicalResult GlobalStoreOp::verifySymbolUses(SymbolTableCollection &symbolTable) { … } //===----------------------------------------------------------------------===// // GlobalStoreGraphOp //===----------------------------------------------------------------------===// GlobalOp GlobalStoreGraphOp::getGlobalOp(SymbolTableCollection &symbolTable) { … } LogicalResult GlobalStoreGraphOp::verifySymbolUses(SymbolTableCollection &symbolTable) { … } //===----------------------------------------------------------------------===// // SubgraphOp //===----------------------------------------------------------------------===// ParseResult SubgraphOp::parse(OpAsmParser &parser, OperationState &result) { … } void SubgraphOp::print(OpAsmPrinter &p) { … } //===----------------------------------------------------------------------===// // OutputOp //===----------------------------------------------------------------------===// LogicalResult OutputOp::verify() { … } //===----------------------------------------------------------------------===// // ReturnOp //===----------------------------------------------------------------------===// LogicalResult ReturnOp::verify() { … }