//===- DimLvlMapParser.cpp - `DimLvlMap` parser 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 "DimLvlMapParser.h" usingnamespacemlir; usingnamespacemlir::sparse_tensor; usingnamespacemlir::sparse_tensor::ir_detail; #define FAILURE_IF_FAILED(RES) … /// Helper function for `FAILURE_IF_NULLOPT_OR_FAILED` to avoid duplicating /// its `RES` parameter. static inline bool didntSucceed(OptionalParseResult res) { … } #define FAILURE_IF_NULLOPT_OR_FAILED(RES) … // NOTE: this macro assumes `AsmParser parser` and `SMLoc loc` are in scope. #define ERROR_IF(COND, MSG) … //===----------------------------------------------------------------------===// // `DimLvlMapParser` implementation for variable parsing. //===----------------------------------------------------------------------===// // Our variation on `AffineParser::{parseBareIdExpr,parseIdentifierDefinition}` OptionalParseResult DimLvlMapParser::parseVar(VarKind vk, bool isOptional, Policy creationPolicy, VarInfo::ID &varID, bool &didCreate) { … } FailureOr<VarInfo::ID> DimLvlMapParser::parseVarUsage(VarKind vk, bool requireKnown) { … } FailureOr<VarInfo::ID> DimLvlMapParser::parseVarBinding(VarKind vk, bool requireKnown) { … } FailureOr<std::pair<Var, bool>> DimLvlMapParser::parseOptionalVarBinding(VarKind vk, bool requireKnown) { … } Var DimLvlMapParser::bindVar(llvm::SMLoc loc, VarInfo::ID id) { … } //===----------------------------------------------------------------------===// // `DimLvlMapParser` implementation for `DimLvlMap` per se. //===----------------------------------------------------------------------===// FailureOr<DimLvlMap> DimLvlMapParser::parseDimLvlMap() { … } ParseResult DimLvlMapParser::parseSymbolBindingList() { … } ParseResult DimLvlMapParser::parseLvlVarBindingList() { … } //===----------------------------------------------------------------------===// // `DimLvlMapParser` implementation for `DimSpec`. //===----------------------------------------------------------------------===// ParseResult DimLvlMapParser::parseDimSpecList() { … } ParseResult DimLvlMapParser::parseDimSpec() { … } //===----------------------------------------------------------------------===// // `DimLvlMapParser` implementation for `LvlSpec`. //===----------------------------------------------------------------------===// ParseResult DimLvlMapParser::parseLvlSpecList() { … } static inline Twine nth(Var::Num n) { … } FailureOr<LvlVar> DimLvlMapParser::parseLvlVarBinding(bool requireLvlVarBinding) { … } ParseResult DimLvlMapParser::parseLvlSpec(bool requireLvlVarBinding) { … } //===----------------------------------------------------------------------===//