//===- llvm/MC/MCTargetAsmParser.h - Target Assembly Parser -----*- C++ -*-===// // // 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 LLVM_MC_MCPARSER_MCTARGETASMPARSER_H #define LLVM_MC_MCPARSER_MCTARGETASMPARSER_H #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCParser/MCAsmParserExtension.h" #include "llvm/MC/MCParser/MCParsedAsmOperand.h" #include "llvm/MC/MCTargetOptions.h" #include "llvm/Support/SMLoc.h" #include "llvm/TargetParser/SubtargetFeature.h" #include <cstdint> #include <memory> namespace llvm { class MCContext; class MCInst; class MCInstrInfo; class MCRegister; class MCStreamer; class MCSubtargetInfo; class MCSymbol; template <typename T> class SmallVectorImpl; OperandVector; enum AsmRewriteKind { … }; const char AsmRewritePrecedence [] = …; // Represent the various parts which make up an intel expression, // used for emitting compound intel expressions struct IntelExpr { … }; struct AsmRewrite { … }; struct ParseInstructionInfo { … }; enum OperandMatchResultTy { … }; /// Ternary parse status returned by various parse* methods. class ParseStatus { … }; enum class DiagnosticPredicateTy { … }; // When an operand is parsed, the assembler will try to iterate through a set of // possible operand classes that the operand might match and call the // corresponding PredicateMethod to determine that. // // If there are two AsmOperands that would give a specific diagnostic if there // is no match, there is currently no mechanism to distinguish which operand is // a closer match. The DiagnosticPredicate distinguishes between 'completely // no match' and 'near match', so the assembler can decide whether to give a // specific diagnostic, or use 'InvalidOperand' and continue to find a // 'better matching' diagnostic. // // For example: // opcode opnd0, onpd1, opnd2 // // where: // opnd2 could be an 'immediate of range [-8, 7]' // opnd2 could be a 'register + shift/extend'. // // If opnd2 is a valid register, but with a wrong shift/extend suffix, it makes // little sense to give a diagnostic that the operand should be an immediate // in range [-8, 7]. // // This is a light-weight alternative to the 'NearMissInfo' approach // below which collects *all* possible diagnostics. This alternative // is optional and fully backward compatible with existing // PredicateMethods that return a 'bool' (match or no match). struct DiagnosticPredicate { … }; // When matching of an assembly instruction fails, there may be multiple // encodings that are close to being a match. It's often ambiguous which one // the programmer intended to use, so we want to report an error which mentions // each of these "near-miss" encodings. This struct contains information about // one such encoding, and why it did not match the parsed instruction. class NearMissInfo { … }; /// MCTargetAsmParser - Generic interface to target specific assembly parsers. class MCTargetAsmParser : public MCAsmParserExtension { … }; } // end namespace llvm #endif // LLVM_MC_MCPARSER_MCTARGETASMPARSER_H