#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCParser/AsmCond.h"
#include "llvm/MC/MCParser/AsmLexer.h"
#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
#include "llvm/MC/MCParser/MCAsmParserUtils.h"
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
#include "llvm/MC/MCParser/MCTargetAsmParser.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolMachO.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <deque>
#include <memory>
#include <optional>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
usingnamespacellvm;
MCAsmParserSemaCallback::~MCAsmParserSemaCallback() = default;
namespace {
MCAsmMacroArgument;
MCAsmMacroArguments;
struct MacroInstantiation { … };
struct ParseStatementInfo { … };
class AsmParser : public MCAsmParser { … };
class HLASMAsmParser final : public AsmParser { … };
}
namespace llvm {
extern cl::opt<unsigned> AsmMacroMaxNestingDepth;
extern MCAsmParserExtension *createDarwinAsmParser();
extern MCAsmParserExtension *createELFAsmParser();
extern MCAsmParserExtension *createCOFFAsmParser();
extern MCAsmParserExtension *createGOFFAsmParser();
extern MCAsmParserExtension *createXCOFFAsmParser();
extern MCAsmParserExtension *createWasmAsmParser();
}
enum { … };
AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
const MCAsmInfo &MAI, unsigned CB = 0)
: … { … }
AsmParser::~AsmParser() { … }
void AsmParser::printMacroInstantiations() { … }
void AsmParser::Note(SMLoc L, const Twine &Msg, SMRange Range) { … }
bool AsmParser::Warning(SMLoc L, const Twine &Msg, SMRange Range) { … }
bool AsmParser::printError(SMLoc L, const Twine &Msg, SMRange Range) { … }
bool AsmParser::enterIncludeFile(const std::string &Filename) { … }
bool AsmParser::processIncbinFile(const std::string &Filename, int64_t Skip,
const MCExpr *Count, SMLoc Loc) { … }
void AsmParser::jumpToLoc(SMLoc Loc, unsigned InBuffer) { … }
const AsmToken &AsmParser::Lex() { … }
bool AsmParser::enabledGenDwarfForAssembly() { … }
bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { … }
bool AsmParser::checkForValidSection() { … }
void AsmParser::eatToEndOfStatement() { … }
StringRef AsmParser::parseStringToEndOfStatement() { … }
StringRef AsmParser::parseStringToComma() { … }
bool AsmParser::parseParenExpr(const MCExpr *&Res, SMLoc &EndLoc) { … }
bool AsmParser::parseBracketExpr(const MCExpr *&Res, SMLoc &EndLoc) { … }
bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
AsmTypeInfo *TypeInfo) { … }
bool AsmParser::parseExpression(const MCExpr *&Res) { … }
const MCExpr *
AsmParser::applyModifierToExpr(const MCExpr *E,
MCSymbolRefExpr::VariantKind Variant) { … }
static bool isAngleBracketString(SMLoc &StrLoc, SMLoc &EndLoc) { … }
static std::string angleBracketString(StringRef AltMacroStr) { … }
bool AsmParser::parseExpression(const MCExpr *&Res, SMLoc &EndLoc) { … }
bool AsmParser::parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) { … }
bool AsmParser::parseParenExprOfDepth(unsigned ParenDepth, const MCExpr *&Res,
SMLoc &EndLoc) { … }
bool AsmParser::parseAbsoluteExpression(int64_t &Res) { … }
static unsigned getDarwinBinOpPrecedence(AsmToken::TokenKind K,
MCBinaryExpr::Opcode &Kind,
bool ShouldUseLogicalShr) { … }
static unsigned getGNUBinOpPrecedence(const MCAsmInfo &MAI,
AsmToken::TokenKind K,
MCBinaryExpr::Opcode &Kind,
bool ShouldUseLogicalShr) { … }
unsigned AsmParser::getBinOpPrecedence(AsmToken::TokenKind K,
MCBinaryExpr::Opcode &Kind) { … }
bool AsmParser::parseBinOpRHS(unsigned Precedence, const MCExpr *&Res,
SMLoc &EndLoc) { … }
bool AsmParser::parseStatement(ParseStatementInfo &Info,
MCAsmParserSemaCallback *SI) { … }
bool AsmParser::parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &Info,
StringRef IDVal,
AsmToken ID,
SMLoc IDLoc) { … }
bool
AsmParser::parseCurlyBlockScope(SmallVectorImpl<AsmRewrite> &AsmStrRewrites) { … }
bool AsmParser::parseCppHashLineFilenameComment(SMLoc L, bool SaveLocInfo) { … }
void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) { … }
static bool isIdentifierChar(char c) { … }
bool AsmParser::expandMacro(raw_svector_ostream &OS, MCAsmMacro &Macro,
ArrayRef<MCAsmMacroParameter> Parameters,
ArrayRef<MCAsmMacroArgument> A,
bool EnableAtPseudoVariable) { … }
static bool isOperator(AsmToken::TokenKind kind) { … }
namespace {
class AsmLexerSkipSpaceRAII { … };
}
bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA, bool Vararg) { … }
bool AsmParser::parseMacroArguments(const MCAsmMacro *M,
MCAsmMacroArguments &A) { … }
bool AsmParser::handleMacroEntry(MCAsmMacro *M, SMLoc NameLoc) { … }
void AsmParser::handleMacroExit() { … }
bool AsmParser::parseAssignment(StringRef Name, AssignmentKind Kind) { … }
bool AsmParser::parseIdentifier(StringRef &Res) { … }
bool AsmParser::parseDirectiveSet(StringRef IDVal, AssignmentKind Kind) { … }
bool AsmParser::parseEscapedString(std::string &Data) { … }
bool AsmParser::parseAngleBracketString(std::string &Data) { … }
bool AsmParser::parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) { … }
bool AsmParser::parseDirectiveReloc(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveValue(StringRef IDVal, unsigned Size) { … }
static bool parseHexOcta(AsmParser &Asm, uint64_t &hi, uint64_t &lo) { … }
bool AsmParser::parseDirectiveOctaValue(StringRef IDVal) { … }
bool AsmParser::parseRealValue(const fltSemantics &Semantics, APInt &Res) { … }
bool AsmParser::parseDirectiveRealValue(StringRef IDVal,
const fltSemantics &Semantics) { … }
bool AsmParser::parseDirectiveZero() { … }
bool AsmParser::parseDirectiveFill() { … }
bool AsmParser::parseDirectiveOrg() { … }
bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) { … }
bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveLine() { … }
bool AsmParser::parseDirectiveLoc() { … }
bool AsmParser::parseDirectiveLocLabel(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveStabs() { … }
bool AsmParser::parseDirectiveCVFile() { … }
bool AsmParser::parseCVFunctionId(int64_t &FunctionId,
StringRef DirectiveName) { … }
bool AsmParser::parseCVFileId(int64_t &FileNumber, StringRef DirectiveName) { … }
bool AsmParser::parseDirectiveCVFuncId() { … }
bool AsmParser::parseDirectiveCVInlineSiteId() { … }
bool AsmParser::parseDirectiveCVLoc() { … }
bool AsmParser::parseDirectiveCVLinetable() { … }
bool AsmParser::parseDirectiveCVInlineLinetable() { … }
void AsmParser::initializeCVDefRangeTypeMap() { … }
bool AsmParser::parseDirectiveCVDefRange() { … }
bool AsmParser::parseDirectiveCVString() { … }
bool AsmParser::parseDirectiveCVStringTable() { … }
bool AsmParser::parseDirectiveCVFileChecksums() { … }
bool AsmParser::parseDirectiveCVFileChecksumOffset() { … }
bool AsmParser::parseDirectiveCVFPOData() { … }
bool AsmParser::parseDirectiveCFISections() { … }
bool AsmParser::parseDirectiveCFIStartProc() { … }
bool AsmParser::parseDirectiveCFIEndProc() { … }
bool AsmParser::parseRegisterOrRegisterNumber(int64_t &Register,
SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIDefCfa(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIDefCfaOffset(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIRegister(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIWindowSave(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIAdjustCfaOffset(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIDefCfaRegister(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFILLVMDefAspaceCfa(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIOffset(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIRelOffset(SMLoc DirectiveLoc) { … }
static bool isValidEncoding(int64_t Encoding) { … }
bool AsmParser::parseDirectiveCFIPersonalityOrLsda(bool IsPersonality) { … }
bool AsmParser::parseDirectiveCFIRememberState(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIRestoreState(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFISameValue(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIRestore(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIEscape(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIReturnColumn(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFISignalFrame(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFIUndefined(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveCFILabel(SMLoc Loc) { … }
bool AsmParser::parseDirectiveAltmacro(StringRef Directive) { … }
bool AsmParser::parseDirectiveMacrosOnOff(StringRef Directive) { … }
bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) { … }
void AsmParser::checkForBadMacro(SMLoc DirectiveLoc, StringRef Name,
StringRef Body,
ArrayRef<MCAsmMacroParameter> Parameters) { … }
bool AsmParser::parseDirectiveExitMacro(StringRef Directive) { … }
bool AsmParser::parseDirectiveEndMacro(StringRef Directive) { … }
bool AsmParser::parseDirectivePurgeMacro(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveBundleAlignMode() { … }
bool AsmParser::parseDirectiveBundleLock() { … }
bool AsmParser::parseDirectiveBundleUnlock() { … }
bool AsmParser::parseDirectiveSpace(StringRef IDVal) { … }
bool AsmParser::parseDirectiveDCB(StringRef IDVal, unsigned Size) { … }
bool AsmParser::parseDirectiveRealDCB(StringRef IDVal, const fltSemantics &Semantics) { … }
bool AsmParser::parseDirectiveDS(StringRef IDVal, unsigned Size) { … }
bool AsmParser::parseDirectiveLEB128(bool Signed) { … }
bool AsmParser::parseDirectiveSymbolAttribute(MCSymbolAttr Attr) { … }
bool AsmParser::parseDirectiveComm(bool IsLocal) { … }
bool AsmParser::parseDirectiveAbort(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveInclude() { … }
bool AsmParser::parseDirectiveIncbin() { … }
bool AsmParser::parseDirectiveIf(SMLoc DirectiveLoc, DirectiveKind DirKind) { … }
bool AsmParser::parseDirectiveIfb(SMLoc DirectiveLoc, bool ExpectBlank) { … }
bool AsmParser::parseDirectiveIfc(SMLoc DirectiveLoc, bool ExpectEqual) { … }
bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc, bool ExpectEqual) { … }
bool AsmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) { … }
bool AsmParser::parseDirectiveElseIf(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveElse(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveEnd(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveError(SMLoc L, bool WithMessage) { … }
bool AsmParser::parseDirectiveWarning(SMLoc L) { … }
bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) { … }
void AsmParser::initializeDirectiveKindMap() { … }
MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) { … }
void AsmParser::instantiateMacroLikeBody(MCAsmMacro *M, SMLoc DirectiveLoc,
raw_svector_ostream &OS) { … }
bool AsmParser::parseDirectiveRept(SMLoc DirectiveLoc, StringRef Dir) { … }
bool AsmParser::parseDirectiveIrp(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveIrpc(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveEndr(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveMSEmit(SMLoc IDLoc, ParseStatementInfo &Info,
size_t Len) { … }
bool AsmParser::parseDirectiveMSAlign(SMLoc IDLoc, ParseStatementInfo &Info) { … }
bool AsmParser::parseDirectivePrint(SMLoc DirectiveLoc) { … }
bool AsmParser::parseDirectiveAddrsig() { … }
bool AsmParser::parseDirectiveAddrsigSym() { … }
bool AsmParser::parseDirectivePseudoProbe() { … }
bool AsmParser::parseDirectiveLTODiscard() { … }
static int rewritesSort(const AsmRewrite *AsmRewriteA,
const AsmRewrite *AsmRewriteB) { … }
bool AsmParser::parseMSInlineAsm(
std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
SmallVectorImpl<std::string> &Constraints,
SmallVectorImpl<std::string> &Clobbers, const MCInstrInfo *MII,
const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) { … }
bool HLASMAsmParser::parseAsHLASMLabel(ParseStatementInfo &Info,
MCAsmParserSemaCallback *SI) { … }
bool HLASMAsmParser::parseAsMachineInstruction(ParseStatementInfo &Info,
MCAsmParserSemaCallback *SI) { … }
bool HLASMAsmParser::parseStatement(ParseStatementInfo &Info,
MCAsmParserSemaCallback *SI) { … }
namespace llvm {
namespace MCParserUtils {
static bool isSymbolUsedInExpression(const MCSymbol *Sym, const MCExpr *Value) { … }
bool parseAssignmentExpression(StringRef Name, bool allow_redef,
MCAsmParser &Parser, MCSymbol *&Sym,
const MCExpr *&Value) { … }
}
}
MCAsmParser *llvm::createMCAsmParser(SourceMgr &SM, MCContext &C,
MCStreamer &Out, const MCAsmInfo &MAI,
unsigned CB) { … }