#include "Parser.h"
#include "AsmParserImpl.h"
#include "mlir/AsmParser/AsmParser.h"
#include "mlir/AsmParser/AsmParserState.h"
#include "mlir/AsmParser/CodeComplete.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/AsmState.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/OwningOpRef.h"
#include "mlir/IR/Region.h"
#include "mlir/IR/Value.h"
#include "mlir/IR/Verifier.h"
#include "mlir/IR/Visitors.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/TypeID.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
usingnamespacemlir;
usingnamespacemlir::detail;
AsmParserCodeCompleteContext::~AsmParserCodeCompleteContext() = default;
ParseResult
Parser::parseCommaSeparatedList(Delimiter delimiter,
function_ref<ParseResult()> parseElementFn,
StringRef contextMessage) { … }
ParseResult
Parser::parseCommaSeparatedListUntil(Token::Kind rightToken,
function_ref<ParseResult()> parseElement,
bool allowEmptyList) { … }
InFlightDiagnostic Parser::emitError(const Twine &message) { … }
InFlightDiagnostic Parser::emitError(SMLoc loc, const Twine &message) { … }
InFlightDiagnostic Parser::emitWrongTokenError(const Twine &message) { … }
ParseResult Parser::parseToken(Token::Kind expectedToken,
const Twine &message) { … }
OptionalParseResult Parser::parseOptionalInteger(APInt &result) { … }
OptionalParseResult Parser::parseOptionalDecimalInteger(APInt &result) { … }
ParseResult Parser::parseFloatFromIntegerLiteral(
std::optional<APFloat> &result, const Token &tok, bool isNegative,
const llvm::fltSemantics &semantics, size_t typeSizeInBits) { … }
ParseResult Parser::parseOptionalKeyword(StringRef *keyword) { … }
FailureOr<AsmDialectResourceHandle>
Parser::parseResourceHandle(const OpAsmDialectInterface *dialect,
StringRef &name) { … }
FailureOr<AsmDialectResourceHandle>
Parser::parseResourceHandle(Dialect *dialect) { … }
ParseResult Parser::codeCompleteDialectName() { … }
ParseResult Parser::codeCompleteOperationName(StringRef dialectName) { … }
ParseResult Parser::codeCompleteDialectOrElidedOpName(SMLoc loc) { … }
ParseResult Parser::codeCompleteStringDialectOrOperationName(StringRef name) { … }
ParseResult Parser::codeCompleteExpectedTokens(ArrayRef<StringRef> tokens) { … }
ParseResult Parser::codeCompleteOptionalTokens(ArrayRef<StringRef> tokens) { … }
Attribute Parser::codeCompleteAttribute() { … }
Type Parser::codeCompleteType() { … }
Attribute
Parser::codeCompleteDialectSymbol(const llvm::StringMap<Attribute> &aliases) { … }
Type Parser::codeCompleteDialectSymbol(const llvm::StringMap<Type> &aliases) { … }
namespace {
class OperationParser : public Parser { … };
}
MLIR_DECLARE_EXPLICIT_TYPE_ID(OperationParser::DeferredLocInfo *)
MLIR_DEFINE_EXPLICIT_TYPE_ID(OperationParser::DeferredLocInfo *)
OperationParser::OperationParser(ParserState &state, ModuleOp topLevelOp)
: … { … }
OperationParser::~OperationParser() { … }
ParseResult OperationParser::finalize() { … }
void OperationParser::pushSSANameScope(bool isIsolated) { … }
ParseResult OperationParser::popSSANameScope() { … }
ParseResult OperationParser::addDefinition(UnresolvedOperand useInfo,
Value value) { … }
ParseResult OperationParser::parseOptionalSSAUseList(
SmallVectorImpl<UnresolvedOperand> &results) { … }
ParseResult OperationParser::parseSSAUse(UnresolvedOperand &result,
bool allowResultNumber) { … }
Value OperationParser::resolveSSAUse(UnresolvedOperand useInfo, Type type) { … }
ParseResult OperationParser::parseSSADefOrUseAndType(
function_ref<ParseResult(UnresolvedOperand, Type)> action) { … }
ParseResult OperationParser::parseOptionalSSAUseAndTypeList(
SmallVectorImpl<Value> &results) { … }
void OperationParser::recordDefinition(StringRef def) { … }
auto OperationParser::getSSAValueEntry(StringRef name)
-> SmallVectorImpl<ValueDefinition> & { … }
Value OperationParser::createForwardRefPlaceholder(SMLoc loc, Type type) { … }
ParseResult OperationParser::parseOperation() { … }
ParseResult OperationParser::parseSuccessor(Block *&dest) { … }
ParseResult
OperationParser::parseSuccessors(SmallVectorImpl<Block *> &destinations) { … }
namespace {
struct CleanupOpStateRegions { … };
}
ParseResult OperationParser::parseGenericOperationAfterOpName(
OperationState &result,
std::optional<ArrayRef<UnresolvedOperand>> parsedOperandUseInfo,
std::optional<ArrayRef<Block *>> parsedSuccessors,
std::optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions,
std::optional<ArrayRef<NamedAttribute>> parsedAttributes,
std::optional<Attribute> propertiesAttribute,
std::optional<FunctionType> parsedFnType) { … }
Operation *OperationParser::parseGenericOperation() { … }
Operation *OperationParser::parseGenericOperation(Block *insertBlock,
Block::iterator insertPt) { … }
namespace {
class CustomOpAsmParser : public AsmParserImpl<OpAsmParser> { … };
}
FailureOr<OperationName> OperationParser::parseCustomOperationName() { … }
Operation *
OperationParser::parseCustomOperation(ArrayRef<ResultRecord> resultIDs) { … }
ParseResult OperationParser::parseLocationAlias(LocationAttr &loc) { … }
ParseResult
OperationParser::parseTrailingLocationSpecifier(OpOrArgument opOrArgument) { … }
ParseResult OperationParser::parseRegion(Region ®ion,
ArrayRef<Argument> entryArguments,
bool isIsolatedNameScope) { … }
ParseResult OperationParser::parseRegionBody(Region ®ion, SMLoc startLoc,
ArrayRef<Argument> entryArguments,
bool isIsolatedNameScope) { … }
ParseResult OperationParser::parseBlock(Block *&block) { … }
ParseResult OperationParser::parseBlockBody(Block *block) { … }
Block *OperationParser::getBlockNamed(StringRef name, SMLoc loc) { … }
ParseResult OperationParser::parseOptionalBlockArgList(Block *owner) { … }
ParseResult OperationParser::codeCompleteSSAUse() { … }
ParseResult OperationParser::codeCompleteBlock() { … }
namespace {
class TopLevelOperationParser : public Parser { … };
class ParsedResourceEntry : public AsmParsedResourceEntry { … };
}
ParseResult TopLevelOperationParser::parseAttributeAliasDef() { … }
ParseResult TopLevelOperationParser::parseTypeAliasDef() { … }
ParseResult TopLevelOperationParser::parseFileMetadataDictionary() { … }
ParseResult TopLevelOperationParser::parseResourceFileMetadata(
function_ref<ParseResult(StringRef, SMLoc)> parseBody) { … }
ParseResult TopLevelOperationParser::parseDialectResourceFileMetadata() { … }
ParseResult TopLevelOperationParser::parseExternalResourceFileMetadata() { … }
ParseResult TopLevelOperationParser::parse(Block *topLevelBlock,
Location parserLoc) { … }
LogicalResult
mlir::parseAsmSourceFile(const llvm::SourceMgr &sourceMgr, Block *block,
const ParserConfig &config, AsmParserState *asmState,
AsmParserCodeCompleteContext *codeCompleteContext) { … }