80typedef std::vector<AsmToken> MCAsmMacroArgument;
81typedef std::vector<MCAsmMacroArgument> MCAsmMacroArguments;
85struct MacroInstantiation {
87 SMLoc InstantiationLoc;
96 size_t CondStackDepth;
99struct ParseStatementInfo {
104 unsigned Opcode = ~0
U;
107 bool ParseError =
false;
111 ParseStatementInfo() =
delete;
113 : AsmRewrites(rewrites) {}
125 void *SavedDiagContext;
126 std::unique_ptr<MCAsmParserExtension> PlatformParser;
134 std::vector<AsmCond> TheCondStack;
142 std::vector<MacroInstantiation*> ActiveMacros;
145 std::deque<MCAsmMacro> MacroLikeBodies;
148 unsigned MacrosEnabledFlag : 1;
151 unsigned NumOfMacroInstantiations;
154 struct CppHashInfoTy {
159 CppHashInfoTy() : LineNumber(0), Buf(0) {}
161 CppHashInfoTy CppHashInfo;
172 unsigned AssemblerDialect = ~0
U;
175 bool IsDarwin =
false;
178 bool ParsingMSInlineAsm =
false;
181 bool ReportedInconsistentMD5 =
false;
184 bool AltMacroMode =
false;
187 virtual bool parseStatement(ParseStatementInfo &Info,
193 bool parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &Info,
200 bool enabledGenDwarfForAssembly();
205 AsmParser(
const AsmParser &) =
delete;
206 AsmParser &
operator=(
const AsmParser &) =
delete;
207 ~AsmParser()
override;
209 bool Run(
bool NoInitialTextSection,
bool NoFinalize =
false)
override;
212 ExtensionDirectiveHandler Handler)
override {
213 ExtensionDirectiveMap[
Directive] = Handler;
217 DirectiveKindMap[
Directive.lower()] = DirectiveKindMap[Alias.
lower()];
231 if (AssemblerDialect == ~0U)
234 return AssemblerDialect;
237 AssemblerDialect = i;
242 SMRange Range = std::nullopt)
override;
244 SMRange Range = std::nullopt)
override;
249 ParsingMSInlineAsm =
V;
274 SMLoc &EndLoc)
override;
292 bool parseCppHashLineFilenameComment(
SMLoc L,
bool SaveLocInfo =
true);
302 bool areMacrosEnabled() {
return MacrosEnabledFlag;}
305 void setMacrosEnabled(
bool Flag) {MacrosEnabledFlag =
Flag;}
308 bool isInsideMacroInstantiation() {
return !ActiveMacros.empty();}
317 void handleMacroExit();
320 bool parseMacroArgument(MCAsmMacroArgument &MA,
bool Vararg);
323 bool parseMacroArguments(
const MCAsmMacro *M, MCAsmMacroArguments &
A);
325 void printMacroInstantiations();
327 SMRange Range = std::nullopt)
const {
334 bool enterIncludeFile(
const std::string &Filename);
338 bool processIncbinFile(
const std::string &Filename, int64_t Skip = 0,
347 void jumpToLoc(
SMLoc Loc,
unsigned InBuffer = 0);
358 enum class AssignmentKind {
370 bool parseBinOpRHS(
unsigned Precedence,
const MCExpr *&Res,
SMLoc &EndLoc);
371 bool parseParenExpr(
const MCExpr *&Res,
SMLoc &EndLoc);
372 bool parseBracketExpr(
const MCExpr *&Res,
SMLoc &EndLoc);
374 bool parseRegisterOrRegisterNumber(int64_t &
Register,
SMLoc DirectiveLoc);
376 bool parseCVFunctionId(int64_t &FunctionId,
StringRef DirectiveName);
377 bool parseCVFileId(int64_t &FileId,
StringRef DirectiveName);
436 DK_BUNDLE_ALIGN_MODE,
450 DK_WEAK_DEF_CAN_BE_HIDDEN,
490 DK_CV_INLINE_SITE_ID,
493 DK_CV_INLINE_LINETABLE,
498 DK_CV_FILECHECKSUM_OFFSET,
504 DK_CFI_DEF_CFA_OFFSET,
505 DK_CFI_ADJUST_CFA_OFFSET,
506 DK_CFI_DEF_CFA_REGISTER,
507 DK_CFI_LLVM_DEF_ASPACE_CFA,
512 DK_CFI_REMEMBER_STATE,
513 DK_CFI_RESTORE_STATE,
517 DK_CFI_RETURN_COLUMN,
542 DK_LTO_SET_CONDITIONAL,
543 DK_CFI_MTE_TAGGED_FRAME,
553 enum CVDefRangeType {
555 CVDR_DEFRANGE_REGISTER,
556 CVDR_DEFRANGE_FRAMEPOINTER_REL,
557 CVDR_DEFRANGE_SUBFIELD_REGISTER,
558 CVDR_DEFRANGE_REGISTER_REL
566 bool parseDirectiveAscii(
StringRef IDVal,
bool ZeroTerminated);
567 bool parseDirectiveReloc(
SMLoc DirectiveLoc);
568 bool parseDirectiveValue(
StringRef IDVal,
570 bool parseDirectiveOctaValue(
StringRef IDVal);
571 bool parseDirectiveRealValue(
StringRef IDVal,
573 bool parseDirectiveFill();
574 bool parseDirectiveZero();
576 bool parseDirectiveSet(
StringRef IDVal, AssignmentKind Kind);
577 bool parseDirectiveOrg();
579 bool parseDirectiveAlign(
bool IsPow2,
unsigned ValueSize);
582 bool parseDirectiveFile(
SMLoc DirectiveLoc);
583 bool parseDirectiveLine();
584 bool parseDirectiveLoc();
585 bool parseDirectiveStabs();
589 bool parseDirectiveCVFile();
590 bool parseDirectiveCVFuncId();
591 bool parseDirectiveCVInlineSiteId();
592 bool parseDirectiveCVLoc();
593 bool parseDirectiveCVLinetable();
594 bool parseDirectiveCVInlineLinetable();
595 bool parseDirectiveCVDefRange();
596 bool parseDirectiveCVString();
597 bool parseDirectiveCVStringTable();
598 bool parseDirectiveCVFileChecksums();
599 bool parseDirectiveCVFileChecksumOffset();
600 bool parseDirectiveCVFPOData();
603 bool parseDirectiveCFIRegister(
SMLoc DirectiveLoc);
604 bool parseDirectiveCFIWindowSave();
605 bool parseDirectiveCFISections();
606 bool parseDirectiveCFIStartProc();
607 bool parseDirectiveCFIEndProc();
608 bool parseDirectiveCFIDefCfaOffset();
609 bool parseDirectiveCFIDefCfa(
SMLoc DirectiveLoc);
610 bool parseDirectiveCFIAdjustCfaOffset();
611 bool parseDirectiveCFIDefCfaRegister(
SMLoc DirectiveLoc);
612 bool parseDirectiveCFILLVMDefAspaceCfa(
SMLoc DirectiveLoc);
613 bool parseDirectiveCFIOffset(
SMLoc DirectiveLoc);
614 bool parseDirectiveCFIRelOffset(
SMLoc DirectiveLoc);
615 bool parseDirectiveCFIPersonalityOrLsda(
bool IsPersonality);
616 bool parseDirectiveCFIRememberState();
617 bool parseDirectiveCFIRestoreState();
618 bool parseDirectiveCFISameValue(
SMLoc DirectiveLoc);
619 bool parseDirectiveCFIRestore(
SMLoc DirectiveLoc);
620 bool parseDirectiveCFIEscape();
621 bool parseDirectiveCFIReturnColumn(
SMLoc DirectiveLoc);
622 bool parseDirectiveCFISignalFrame();
623 bool parseDirectiveCFIUndefined(
SMLoc DirectiveLoc);
626 bool parseDirectivePurgeMacro(
SMLoc DirectiveLoc);
629 bool parseDirectiveMacro(
SMLoc DirectiveLoc);
634 bool parseDirectiveBundleAlignMode();
636 bool parseDirectiveBundleLock();
638 bool parseDirectiveBundleUnlock();
641 bool parseDirectiveSpace(
StringRef IDVal);
650 bool parseDirectiveLEB128(
bool Signed);
656 bool parseDirectiveComm(
bool IsLocal);
658 bool parseDirectiveAbort();
659 bool parseDirectiveInclude();
660 bool parseDirectiveIncbin();
663 bool parseDirectiveIf(
SMLoc DirectiveLoc, DirectiveKind DirKind);
665 bool parseDirectiveIfb(
SMLoc DirectiveLoc,
bool ExpectBlank);
667 bool parseDirectiveIfc(
SMLoc DirectiveLoc,
bool ExpectEqual);
669 bool parseDirectiveIfeqs(
SMLoc DirectiveLoc,
bool ExpectEqual);
671 bool parseDirectiveIfdef(
SMLoc DirectiveLoc,
bool expect_defined);
672 bool parseDirectiveElseIf(
SMLoc DirectiveLoc);
673 bool parseDirectiveElse(
SMLoc DirectiveLoc);
674 bool parseDirectiveEndIf(
SMLoc DirectiveLoc);
686 bool parseDirectiveIrp(
SMLoc DirectiveLoc);
687 bool parseDirectiveIrpc(
SMLoc DirectiveLoc);
688 bool parseDirectiveEndr(
SMLoc DirectiveLoc);
691 bool parseDirectiveMSEmit(
SMLoc DirectiveLoc, ParseStatementInfo &Info,
695 bool parseDirectiveMSAlign(
SMLoc DirectiveLoc, ParseStatementInfo &Info);
698 bool parseDirectiveEnd(
SMLoc DirectiveLoc);
701 bool parseDirectiveError(
SMLoc DirectiveLoc,
bool WithMessage);
704 bool parseDirectiveWarning(
SMLoc DirectiveLoc);
707 bool parseDirectivePrint(
SMLoc DirectiveLoc);
710 bool parseDirectivePseudoProbe();
713 bool parseDirectiveLTODiscard();
716 bool parseDirectiveAddrsig();
717 bool parseDirectiveAddrsigSym();
719 void initializeDirectiveKindMap();
720 void initializeCVDefRangeTypeMap();
723class HLASMAsmParser final :
public AsmParser {
728 void lexLeadingSpaces() {
734 bool parseAsMachineInstruction(ParseStatementInfo &Info,
740 : AsmParser(SM, Ctx, Out, MAI, CB), Lexer(getLexer()), Out(Out) {
749 bool parseStatement(ParseStatementInfo &Info,
772 : Lexer(MAI), Ctx(Ctx), Out(Out), MAI(MAI),
SrcMgr(SM),
773 CurBuffer(CB ? CB : SM.getMainFileID()), MacrosEnabledFlag(
true) {
801 "Need to implement createSPIRVAsmParser for SPIRV format.");
814 PlatformParser->Initialize(*
this);
815 initializeDirectiveKindMap();
816 initializeCVDefRangeTypeMap();
818 NumOfMacroInstantiations = 0;
821AsmParser::~AsmParser() {
822 assert((HadError || ActiveMacros.empty()) &&
823 "Unexpected active macro instantiation!");
832void AsmParser::printMacroInstantiations() {
834 for (std::vector<MacroInstantiation *>::const_reverse_iterator
835 it = ActiveMacros.rbegin(),
836 ie = ActiveMacros.rend();
839 "while in macro instantiation");
843 printPendingErrors();
845 printMacroInstantiations();
849 if(getTargetParser().getTargetOptions().MCNoWarn)
851 if (getTargetParser().getTargetOptions().MCFatalWarnings)
852 return Error(L, Msg, Range);
854 printMacroInstantiations();
861 printMacroInstantiations();
865bool AsmParser::enterIncludeFile(
const std::string &Filename) {
866 std::string IncludedFile;
880bool AsmParser::processIncbinFile(
const std::string &Filename, int64_t Skip,
882 std::string IncludedFile;
893 if (!Count->evaluateAsAbsolute(Res, getStreamer().getAssemblerPtr()))
894 return Error(Loc,
"expected absolute expression");
896 return Warning(Loc,
"negative count has no effect");
899 getStreamer().emitBytes(Bytes);
903void AsmParser::jumpToLoc(
SMLoc Loc,
unsigned InBuffer) {
916 if (!getTok().getString().empty() && getTok().getString().front() !=
'\n' &&
934 if (ParentIncludeLoc !=
SMLoc()) {
935 jumpToLoc(ParentIncludeLoc);
943bool AsmParser::enabledGenDwarfForAssembly() {
945 if (!getContext().getGenDwarfForAssembly())
950 if (getContext().getGenDwarfFileNumber() == 0) {
953 if (!FirstCppHashFilename.
empty())
954 getContext().setMCLineTableRootFile(
955 0, getContext().getCompilationDir(), FirstCppHashFilename,
956 std::nullopt, std::nullopt);
958 getContext().getMCDwarfLineTable(0).getRootFile();
959 getContext().setGenDwarfFileNumber(getStreamer().emitDwarfFileDirective(
960 0, getContext().getCompilationDir(), RootFile.
Name,
966bool AsmParser::Run(
bool NoInitialTextSection,
bool NoFinalize) {
967 LTODiscardSymbols.
clear();
970 if (!NoInitialTextSection)
977 AsmCond StartingCondState = TheCondState;
984 if (getContext().getGenDwarfForAssembly()) {
985 MCSection *Sec = getStreamer().getCurrentSectionOnly();
987 MCSymbol *SectionStartSym = getContext().createTempSymbol();
988 getStreamer().emitLabel(SectionStartSym);
991 bool InsertResult = getContext().addGenDwarfSection(Sec);
992 assert(InsertResult &&
".text section should not have debug info yet");
996 getTargetParser().onBeginOfFile();
1000 ParseStatementInfo
Info(&AsmStrRewrites);
1001 bool Parsed = parseStatement(Info,
nullptr);
1011 printPendingErrors();
1014 if (Parsed && !getLexer().isAtStartOfStatement())
1015 eatToEndOfStatement();
1018 getTargetParser().onEndOfFile();
1019 printPendingErrors();
1022 assert(!hasPendingError() &&
"unexpected error from parseStatement");
1024 getTargetParser().flushPendingInstructions(getStreamer());
1028 printError(getTok().getLoc(),
"unmatched .ifs or .elses");
1030 const auto &LineTables = getContext().getMCDwarfLineTables();
1031 if (!LineTables.empty()) {
1033 for (
const auto &File : LineTables.begin()->second.getMCDwarfFiles()) {
1035 printError(getTok().getLoc(),
"unassigned file number: " +
1037 " for .file directives");
1048 for (
const auto &TableEntry : getContext().
getSymbols()) {
1053 if (
Sym->isTemporary() && !
Sym->isVariable() && !
Sym->isDefined())
1057 printError(getTok().getLoc(),
"assembler local symbol '" +
1058 Sym->getName() +
"' not defined");
1064 for (std::tuple<SMLoc, CppHashInfoTy, MCSymbol *> &LocSym : DirLabels) {
1065 if (std::get<2>(LocSym)->isUndefined()) {
1068 CppHashInfo = std::get<1>(LocSym);
1069 printError(std::get<0>(LocSym),
"directional label undefined");
1075 if (!HadError && !NoFinalize) {
1077 TS->emitConstantPools();
1082 return HadError || getContext().hadError();
1085bool AsmParser::checkForValidSection() {
1086 if (!ParsingMSInlineAsm && !getStreamer().getCurrentSectionOnly()) {
1088 return Error(getTok().getLoc(),
1089 "expected section directive before assembly directive");
1095void AsmParser::eatToEndOfStatement() {
1104StringRef AsmParser::parseStringToEndOfStatement() {
1105 const char *Start = getTok().getLoc().getPointer();
1110 const char *
End = getTok().getLoc().getPointer();
1114StringRef AsmParser::parseStringToComma() {
1115 const char *Start = getTok().getLoc().getPointer();
1121 const char *
End = getTok().getLoc().getPointer();
1130bool AsmParser::parseParenExpr(
const MCExpr *&Res,
SMLoc &EndLoc) {
1131 if (parseExpression(Res))
1134 return parseRParen();
1142bool AsmParser::parseBracketExpr(
const MCExpr *&Res,
SMLoc &EndLoc) {
1143 if (parseExpression(Res))
1145 EndLoc = getTok().getEndLoc();
1146 if (parseToken(
AsmToken::RBrac,
"expected ']' in brackets expression"))
1157bool AsmParser::parsePrimaryExpr(
const MCExpr *&Res,
SMLoc &EndLoc,
1159 SMLoc FirstTokenLoc = getLexer().getLoc();
1161 switch (FirstTokenKind) {
1163 return TokError(
"unknown token in expression");
1169 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1179 if (parseIdentifier(Identifier)) {
1183 bool ShouldGenerateTempSymbol =
false;
1186 ShouldGenerateTempSymbol =
true;
1188 if (!ShouldGenerateTempSymbol)
1189 return Error(FirstTokenLoc,
"invalid token in expression");
1199 EndLoc = FirstTokenLoc;
1204 std::pair<StringRef, StringRef>
Split;
1209 SMLoc AtLoc = getLexer().getLoc();
1211 if (parseIdentifier(VName))
1212 return Error(AtLoc,
"expected symbol variant after '@'");
1214 Split = std::make_pair(Identifier, VName);
1222 parseIdentifier(VName);
1225 Split = std::make_pair(Identifier, VName);
1233 return Error(getLexer().getLoc(),
"expected a symbol reference");
1238 if (!
Split.second.empty()) {
1246 "invalid variant '" +
Split.second +
"'");
1250 MCSymbol *
Sym = getContext().getInlineAsmLabel(SymbolName);
1252 Sym = getContext().getOrCreateSymbol(
1257 if (
Sym->isVariable()) {
1258 auto V =
Sym->getVariableValue(
false);
1259 bool DoInline = isa<MCConstantExpr>(V) && !
Variant;
1260 if (
auto TV = dyn_cast<MCTargetExpr>(V))
1261 DoInline = TV->inlineAssignedExpr();
1264 return Error(EndLoc,
"unexpected modifier on variable reference");
1265 Res =
Sym->getVariableValue(
false);
1275 return TokError(
"literal value out of range for directive");
1277 SMLoc Loc = getTok().getLoc();
1278 int64_t
IntVal = getTok().getIntVal();
1286 std::pair<StringRef, StringRef>
Split = IDVal.
split(
'@');
1288 if (
Split.first.size() != IDVal.
size()) {
1291 return TokError(
"invalid variant '" +
Split.second +
"'");
1292 IDVal =
Split.first;
1294 if (IDVal ==
"f" || IDVal ==
"b") {
1298 if (IDVal ==
"b" &&
Sym->isUndefined())
1299 return Error(Loc,
"directional label undefined");
1300 DirLabels.push_back(std::make_tuple(Loc, CppHashInfo,
Sym));
1308 APFloat RealVal(APFloat::IEEEdouble(), getTok().getString());
1317 return TokError(
"cannot use . as current PC");
1330 return parseParenExpr(Res, EndLoc);
1332 if (!PlatformParser->HasBracketExpressions())
1333 return TokError(
"brackets expression not supported on this target");
1335 return parseBracketExpr(Res, EndLoc);
1338 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1344 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1350 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1382 return TokError(
"expected '(' after operator");
1384 if (parseExpression(Res, EndLoc))
1388 Res = getTargetParser().createTargetUnaryExpr(Res, FirstTokenKind, Ctx);
1393bool AsmParser::parseExpression(
const MCExpr *&Res) {
1395 return parseExpression(Res, EndLoc);
1399AsmParser::applyModifierToExpr(
const MCExpr *
E,
1402 const MCExpr *NewE = getTargetParser().applyModifierToExpr(
E, Variant, Ctx);
1407 switch (
E->getKind()) {
1416 TokError(
"invalid variant on expression '" + getTok().getIdentifier() +
1417 "' (already modified)");
1465 "Argument to the function cannot be a NULL value");
1467 while ((*CharPtr !=
'>') && (*CharPtr !=
'\n') && (*CharPtr !=
'\r') &&
1468 (*CharPtr !=
'\0')) {
1469 if (*CharPtr ==
'!')
1473 if (*CharPtr ==
'>') {
1483 for (
size_t Pos = 0; Pos < AltMacroStr.
size(); Pos++) {
1484 if (AltMacroStr[Pos] ==
'!')
1486 Res += AltMacroStr[Pos];
1501bool AsmParser::parseExpression(
const MCExpr *&Res,
SMLoc &EndLoc) {
1504 if (getTargetParser().parsePrimaryExpr(Res, EndLoc) ||
1505 parseBinOpRHS(1, Res, EndLoc))
1515 return TokError(
"unexpected symbol modifier following '@'");
1520 return TokError(
"invalid variant '" + getTok().getIdentifier() +
"'");
1522 const MCExpr *ModifiedRes = applyModifierToExpr(Res, Variant);
1524 return TokError(
"invalid modifier '" + getTok().getIdentifier() +
1525 "' (no symbols present)");
1535 if (Res->evaluateAsAbsolute(
Value))
1541bool AsmParser::parseParenExpression(
const MCExpr *&Res,
SMLoc &EndLoc) {
1543 return parseParenExpr(Res, EndLoc) || parseBinOpRHS(1, Res, EndLoc);
1546bool AsmParser::parseParenExprOfDepth(
unsigned ParenDepth,
const MCExpr *&Res,
1548 if (parseParenExpr(Res, EndLoc))
1551 for (; ParenDepth > 0; --ParenDepth) {
1552 if (parseBinOpRHS(1, Res, EndLoc))
1557 if (ParenDepth - 1 > 0) {
1558 EndLoc = getTok().getEndLoc();
1566bool AsmParser::parseAbsoluteExpression(int64_t &Res) {
1570 if (parseExpression(Expr))
1573 if (!Expr->evaluateAsAbsolute(Res, getStreamer().getAssemblerPtr()))
1574 return Error(StartLoc,
"expected absolute expression");
1581 bool ShouldUseLogicalShr) {
1658 bool ShouldUseLogicalShr) {
1747bool AsmParser::parseBinOpRHS(
unsigned Precedence,
const MCExpr *&Res,
1752 unsigned TokPrec = getBinOpPrecedence(Lexer.
getKind(), Kind);
1756 if (TokPrec < Precedence)
1763 if (getTargetParser().parsePrimaryExpr(RHS, EndLoc))
1769 unsigned NextTokPrec = getBinOpPrecedence(Lexer.
getKind(), Dummy);
1770 if (TokPrec < NextTokPrec && parseBinOpRHS(TokPrec + 1, RHS, EndLoc))
1782bool AsmParser::parseStatement(ParseStatementInfo &Info,
1784 assert(!hasPendingError() &&
"parseStatement started with pending error");
1790 if (getTok().getString().empty() || getTok().getString().front() ==
'\r' ||
1791 getTok().getString().front() ==
'\n')
1800 int64_t LocalLabelVal = -1;
1801 StartTokLoc =
ID.getLoc();
1803 return parseCppHashLineFilenameComment(IDLoc,
1804 !isInsideMacroInstantiation());
1808 LocalLabelVal = getTok().getIntVal();
1809 if (LocalLabelVal < 0) {
1810 if (!TheCondState.
Ignore) {
1812 return Error(IDLoc,
"unexpected token at start of statement");
1816 IDVal = getTok().getString();
1819 if (!TheCondState.
Ignore) {
1821 return Error(IDLoc,
"unexpected token at start of statement");
1839 getTargetParser().starIsStartOfStatement()) {
1843 }
else if (parseIdentifier(IDVal)) {
1844 if (!TheCondState.
Ignore) {
1846 return Error(IDLoc,
"unexpected token at start of statement");
1855 DirectiveKindMap.find(IDVal.
lower());
1856 DirectiveKind DirKind = (DirKindIt == DirectiveKindMap.end())
1858 : DirKindIt->getValue();
1869 return parseDirectiveIf(IDLoc, DirKind);
1871 return parseDirectiveIfb(IDLoc,
true);
1873 return parseDirectiveIfb(IDLoc,
false);
1875 return parseDirectiveIfc(IDLoc,
true);
1877 return parseDirectiveIfeqs(IDLoc,
true);
1879 return parseDirectiveIfc(IDLoc,
false);
1881 return parseDirectiveIfeqs(IDLoc,
false);
1883 return parseDirectiveIfdef(IDLoc,
true);
1886 return parseDirectiveIfdef(IDLoc,
false);
1888 return parseDirectiveElseIf(IDLoc);
1890 return parseDirectiveElse(IDLoc);
1892 return parseDirectiveEndIf(IDLoc);
1897 if (TheCondState.
Ignore) {
1898 eatToEndOfStatement();
1908 if (checkForValidSection())
1915 return Error(IDLoc,
"invalid use of pseudo-symbol '.' as a label");
1923 if (LocalLabelVal == -1) {
1924 if (ParsingMSInlineAsm && SI) {
1926 SI->LookupInlineAsmLabel(IDVal, getSourceManager(), IDLoc,
true);
1928 "We should have an internal name here.");
1931 IDVal = RewrittenLabel;
1933 Sym = getContext().getOrCreateSymbol(IDVal);
1941 StringRef CommentStr = parseStringToEndOfStatement();
1952 if (discardLTOSymbol(IDVal))
1955 getTargetParser().doBeforeLabelEmit(
Sym, IDLoc);
1958 if (!getTargetParser().isParsingMSInlineAsm())
1963 if (enabledGenDwarfForAssembly())
1967 getTargetParser().onLabelParsed(
Sym);
1976 return parseAssignment(IDVal, AssignmentKind::Equal);
1980 if (areMacrosEnabled())
1981 if (
const MCAsmMacro *M = getContext().lookupMacro(IDVal)) {
1982 return handleMacroEntry(M, IDLoc);
2000 getTargetParser().flushPendingInstructions(getStreamer());
2002 SMLoc StartTokLoc = getTok().getLoc();
2003 bool TPDirectiveReturn = getTargetParser().ParseDirective(
ID);
2005 if (hasPendingError())
2012 if (TPDirectiveReturn && StartTokLoc != getTok().getLoc())
2015 if (!TPDirectiveReturn || StartTokLoc != getTok().getLoc())
2020 std::pair<MCAsmParserExtension *, DirectiveHandler> Handler =
2021 ExtensionDirectiveMap.
lookup(IDVal);
2023 return (*Handler.second)(Handler.first, IDVal, IDLoc);
2032 return parseDirectiveSet(IDVal, AssignmentKind::Set);
2034 return parseDirectiveSet(IDVal, AssignmentKind::Equiv);
2035 case DK_LTO_SET_CONDITIONAL:
2036 return parseDirectiveSet(IDVal, AssignmentKind::LTOSetConditional);
2038 return parseDirectiveAscii(IDVal,
false);
2041 return parseDirectiveAscii(IDVal,
true);
2044 return parseDirectiveValue(IDVal, 1);
2050 return parseDirectiveValue(IDVal, 2);
2055 return parseDirectiveValue(IDVal, 4);
2058 return parseDirectiveValue(IDVal, 8);
2060 return parseDirectiveValue(
2061 IDVal, getContext().getAsmInfo()->getCodePointerSize());
2063 return parseDirectiveOctaValue(IDVal);
2067 return parseDirectiveRealValue(IDVal, APFloat::IEEEsingle());
2070 return parseDirectiveRealValue(IDVal, APFloat::IEEEdouble());
2072 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes();
2073 return parseDirectiveAlign(IsPow2, 1);
2076 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes();
2077 return parseDirectiveAlign(IsPow2, 4);
2080 return parseDirectiveAlign(
false, 1);
2082 return parseDirectiveAlign(
false, 2);
2084 return parseDirectiveAlign(
false, 4);
2086 return parseDirectiveAlign(
true, 1);
2088 return parseDirectiveAlign(
true, 2);
2090 return parseDirectiveAlign(
true, 4);
2092 return parseDirectiveOrg();
2094 return parseDirectiveFill();
2096 return parseDirectiveZero();
2098 eatToEndOfStatement();
2102 return parseDirectiveSymbolAttribute(
MCSA_Global);
2103 case DK_LAZY_REFERENCE:
2105 case DK_NO_DEAD_STRIP:
2107 case DK_SYMBOL_RESOLVER:
2109 case DK_PRIVATE_EXTERN:
2113 case DK_WEAK_DEFINITION:
2115 case DK_WEAK_REFERENCE:
2117 case DK_WEAK_DEF_CAN_BE_HIDDEN:
2120 return parseDirectiveSymbolAttribute(
MCSA_Cold);
2123 return parseDirectiveComm(
false);
2125 return parseDirectiveComm(
true);
2127 return parseDirectiveAbort();
2129 return parseDirectiveInclude();
2131 return parseDirectiveIncbin();
2134 return TokError(
Twine(IDVal) +
2135 " not currently supported for this target");
2137 return parseDirectiveRept(IDLoc, IDVal);
2139 return parseDirectiveIrp(IDLoc);
2141 return parseDirectiveIrpc(IDLoc);
2143 return parseDirectiveEndr(IDLoc);
2144 case DK_BUNDLE_ALIGN_MODE:
2145 return parseDirectiveBundleAlignMode();
2146 case DK_BUNDLE_LOCK:
2147 return parseDirectiveBundleLock();
2148 case DK_BUNDLE_UNLOCK:
2149 return parseDirectiveBundleUnlock();
2151 return parseDirectiveLEB128(
true);
2153 return parseDirectiveLEB128(
false);
2156 return parseDirectiveSpace(IDVal);
2158 return parseDirectiveFile(IDLoc);
2160 return parseDirectiveLine();
2162 return parseDirectiveLoc();
2164 return parseDirectiveStabs();
2166 return parseDirectiveCVFile();
2168 return parseDirectiveCVFuncId();
2169 case DK_CV_INLINE_SITE_ID:
2170 return parseDirectiveCVInlineSiteId();
2172 return parseDirectiveCVLoc();
2173 case DK_CV_LINETABLE:
2174 return parseDirectiveCVLinetable();
2175 case DK_CV_INLINE_LINETABLE:
2176 return parseDirectiveCVInlineLinetable();
2177 case DK_CV_DEF_RANGE:
2178 return parseDirectiveCVDefRange();
2180 return parseDirectiveCVString();
2181 case DK_CV_STRINGTABLE:
2182 return parseDirectiveCVStringTable();
2183 case DK_CV_FILECHECKSUMS:
2184 return parseDirectiveCVFileChecksums();
2185 case DK_CV_FILECHECKSUM_OFFSET:
2186 return parseDirectiveCVFileChecksumOffset();
2187 case DK_CV_FPO_DATA:
2188 return parseDirectiveCVFPOData();
2189 case DK_CFI_SECTIONS:
2190 return parseDirectiveCFISections();
2191 case DK_CFI_STARTPROC:
2192 return parseDirectiveCFIStartProc();
2193 case DK_CFI_ENDPROC:
2194 return parseDirectiveCFIEndProc();
2195 case DK_CFI_DEF_CFA:
2196 return parseDirectiveCFIDefCfa(IDLoc);
2197 case DK_CFI_DEF_CFA_OFFSET:
2198 return parseDirectiveCFIDefCfaOffset();
2199 case DK_CFI_ADJUST_CFA_OFFSET:
2200 return parseDirectiveCFIAdjustCfaOffset();
2201 case DK_CFI_DEF_CFA_REGISTER:
2202 return parseDirectiveCFIDefCfaRegister(IDLoc);
2203 case DK_CFI_LLVM_DEF_ASPACE_CFA:
2204 return parseDirectiveCFILLVMDefAspaceCfa(IDLoc);
2206 return parseDirectiveCFIOffset(IDLoc);
2207 case DK_CFI_REL_OFFSET:
2208 return parseDirectiveCFIRelOffset(IDLoc);
2209 case DK_CFI_PERSONALITY:
2210 return parseDirectiveCFIPersonalityOrLsda(
true);
2212 return parseDirectiveCFIPersonalityOrLsda(
false);
2213 case DK_CFI_REMEMBER_STATE:
2214 return parseDirectiveCFIRememberState();
2215 case DK_CFI_RESTORE_STATE:
2216 return parseDirectiveCFIRestoreState();
2217 case DK_CFI_SAME_VALUE:
2218 return parseDirectiveCFISameValue(IDLoc);
2219 case DK_CFI_RESTORE:
2220 return parseDirectiveCFIRestore(IDLoc);
2222 return parseDirectiveCFIEscape();
2223 case DK_CFI_RETURN_COLUMN:
2224 return parseDirectiveCFIReturnColumn(IDLoc);
2225 case DK_CFI_SIGNAL_FRAME:
2226 return parseDirectiveCFISignalFrame();
2227 case DK_CFI_UNDEFINED:
2228 return parseDirectiveCFIUndefined(IDLoc);
2229 case DK_CFI_REGISTER:
2230 return parseDirectiveCFIRegister(IDLoc);
2231 case DK_CFI_WINDOW_SAVE:
2232 return parseDirectiveCFIWindowSave();
2235 return parseDirectiveMacrosOnOff(IDVal);
2237 return parseDirectiveMacro(IDLoc);
2240 return parseDirectiveAltmacro(IDVal);
2242 return parseDirectiveExitMacro(IDVal);
2245 return parseDirectiveEndMacro(IDVal);
2247 return parseDirectivePurgeMacro(IDLoc);
2249 return parseDirectiveEnd(IDLoc);
2251 return parseDirectiveError(IDLoc,
false);
2253 return parseDirectiveError(IDLoc,
true);
2255 return parseDirectiveWarning(IDLoc);
2257 return parseDirectiveReloc(IDLoc);
2260 return parseDirectiveDCB(IDVal, 2);
2262 return parseDirectiveDCB(IDVal, 1);
2264 return parseDirectiveRealDCB(IDVal, APFloat::IEEEdouble());
2266 return parseDirectiveDCB(IDVal, 4);
2268 return parseDirectiveRealDCB(IDVal, APFloat::IEEEsingle());
2271 return TokError(
Twine(IDVal) +
2272 " not currently supported for this target");
2275 return parseDirectiveDS(IDVal, 2);
2277 return parseDirectiveDS(IDVal, 1);
2279 return parseDirectiveDS(IDVal, 8);
2282 return parseDirectiveDS(IDVal, 4);
2285 return parseDirectiveDS(IDVal, 12);
2287 return parseDirectivePrint(IDLoc);
2289 return parseDirectiveAddrsig();
2290 case DK_ADDRSIG_SYM:
2291 return parseDirectiveAddrsigSym();
2292 case DK_PSEUDO_PROBE:
2293 return parseDirectivePseudoProbe();
2294 case DK_LTO_DISCARD:
2295 return parseDirectiveLTODiscard();
2297 return parseDirectiveSymbolAttribute(
MCSA_Memtag);
2300 return Error(IDLoc,
"unknown directive");
2304 if (ParsingMSInlineAsm && (IDVal ==
"_emit" || IDVal ==
"__emit" ||
2305 IDVal ==
"_EMIT" || IDVal ==
"__EMIT"))
2306 return parseDirectiveMSEmit(IDLoc, Info, IDVal.
size());
2309 if (ParsingMSInlineAsm && (IDVal ==
"align" || IDVal ==
"ALIGN"))
2310 return parseDirectiveMSAlign(IDLoc, Info);
2312 if (ParsingMSInlineAsm && (IDVal ==
"even" || IDVal ==
"EVEN"))
2314 if (checkForValidSection())
2317 return parseAndMatchAndEmitTargetInstruction(Info, IDVal,
ID, IDLoc);
2320bool AsmParser::parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &Info,
2325 std::string OpcodeStr = IDVal.
lower();
2327 bool ParseHadError = getTargetParser().ParseInstruction(IInfo, OpcodeStr,
ID,
2328 Info.ParsedOperands);
2329 Info.ParseError = ParseHadError;
2332 if (getShowParsedOperands()) {
2335 OS <<
"parsed instruction: [";
2336 for (
unsigned i = 0; i !=
Info.ParsedOperands.size(); ++i) {
2339 Info.ParsedOperands[i]->print(
OS);
2347 if (hasPendingError() || ParseHadError)
2352 if (!ParseHadError && enabledGenDwarfForAssembly() &&
2353 getContext().getGenDwarfSectionSyms().
count(
2354 getStreamer().getCurrentSectionOnly())) {
2356 if (ActiveMacros.empty())
2360 ActiveMacros.front()->ExitBuffer);
2365 if (!CppHashInfo.Filename.empty()) {
2366 unsigned FileNumber = getStreamer().emitDwarfFileDirective(
2368 getContext().setGenDwarfFileNumber(FileNumber);
2370 unsigned CppHashLocLineNo =
2372 Line = CppHashInfo.LineNumber - 1 + (
Line - CppHashLocLineNo);
2375 getStreamer().emitDwarfLocDirective(
2376 getContext().getGenDwarfFileNumber(), Line, 0,
2382 if (!ParseHadError) {
2384 if (getTargetParser().MatchAndEmitInstruction(
2386 getTargetParser().isParsingMSInlineAsm()))
2412bool AsmParser::parseCppHashLineFilenameComment(
SMLoc L,
bool SaveLocInfo) {
2417 "Lexing Cpp line comment: Expected Integer");
2418 int64_t LineNumber = getTok().getIntVal();
2421 "Lexing Cpp line comment: Expected String");
2433 CppHashInfo.Loc =
L;
2435 CppHashInfo.LineNumber = LineNumber;
2436 CppHashInfo.Buf = CurBuffer;
2437 if (FirstCppHashFilename.
empty())
2444void AsmParser::DiagHandler(
const SMDiagnostic &Diag,
void *Context) {
2445 auto *Parser =
static_cast<AsmParser *
>(
Context);
2451 unsigned CppHashBuf =
2452 Parser->SrcMgr.FindBufferContainingLoc(Parser->CppHashInfo.Loc);
2457 if (!Parser->SavedDiagHandler && DiagCurBuffer &&
2466 if (!Parser->CppHashInfo.LineNumber || DiagBuf != CppHashBuf) {
2467 if (Parser->SavedDiagHandler)
2468 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2470 Parser->getContext().diagnose(Diag);
2477 const std::string &
Filename = std::string(Parser->CppHashInfo.Filename);
2480 int CppHashLocLineNo =
2481 Parser->SrcMgr.FindLineNumber(Parser->CppHashInfo.Loc, CppHashBuf);
2483 Parser->CppHashInfo.LineNumber - 1 + (DiagLocLineNo - CppHashLocLineNo);
2489 if (Parser->SavedDiagHandler)
2490 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2492 Parser->getContext().diagnose(NewDiag);
2500 return isalnum(
static_cast<unsigned char>(c)) || c ==
'_' || c ==
'$' ||
2507 bool EnableAtPseudoVariable,
SMLoc L) {
2508 unsigned NParameters = Parameters.
size();
2509 bool HasVararg = NParameters ? Parameters.
back().Vararg :
false;
2510 if ((!IsDarwin || NParameters != 0) && NParameters !=
A.size())
2511 return Error(L,
"Wrong number of arguments");
2515 while (!Body.
empty()) {
2517 std::size_t
End = Body.
size(), Pos = 0;
2518 for (; Pos !=
End; ++Pos) {
2520 if (IsDarwin && !NParameters) {
2522 if (Body[Pos] !=
'$' || Pos + 1 ==
End)
2525 char Next = Body[Pos + 1];
2526 if (Next ==
'$' || Next ==
'n' ||
2527 isdigit(
static_cast<unsigned char>(Next)))
2531 if (Body[Pos] ==
'\\' && Pos + 1 !=
End)
2543 if (IsDarwin && !NParameters) {
2544 switch (Body[Pos + 1]) {
2558 unsigned Index = Body[Pos + 1] -
'0';
2564 OS << Token.getString();
2570 unsigned I = Pos + 1;
2573 if (EnableAtPseudoVariable && Body[
I] ==
'@' &&
I + 1 !=
End)
2579 const char *Begin = Body.
data() + Pos + 1;
2584 OS << NumOfMacroInstantiations;
2591 if (
Index == NParameters) {
2592 if (Body[Pos + 1] ==
'(' && Body[Pos + 2] ==
')')
2599 bool VarargParameter = HasVararg &&
Index == (NParameters - 1);
2608 if (AltMacroMode && Token.getString().front() ==
'%' &&
2611 OS << Token.getIntVal();
2614 else if (AltMacroMode && Token.getString().front() ==
'<' &&
2621 OS << Token.getString();
2623 OS << Token.getStringContents();
2668class AsmLexerSkipSpaceRAII {
2670 AsmLexerSkipSpaceRAII(
AsmLexer &Lexer,
bool SkipSpace) : Lexer(Lexer) {
2674 ~AsmLexerSkipSpaceRAII() {
2684bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA,
bool Vararg) {
2688 StringRef Str = parseStringToEndOfStatement();
2694 unsigned ParenLevel = 0;
2697 AsmLexerSkipSpaceRAII ScopedSkipSpace(Lexer, IsDarwin);
2704 return TokError(
"unexpected token in macro instantiation");
2706 if (ParenLevel == 0) {
2721 MA.push_back(getTok());
2747 MA.push_back(getTok());
2751 if (ParenLevel != 0)
2752 return TokError(
"unbalanced parentheses in macro argument");
2757bool AsmParser::parseMacroArguments(
const MCAsmMacro *M,
2758 MCAsmMacroArguments &
A) {
2759 const unsigned NParameters =
M ?
M->Parameters.size() : 0;
2760 bool NamedParametersFound =
false;
2763 A.resize(NParameters);
2764 FALocs.
resize(NParameters);
2769 bool HasVararg = NParameters ?
M->Parameters.back().Vararg :
false;
2770 for (
unsigned Parameter = 0; !NParameters || Parameter < NParameters;
2776 if (parseIdentifier(FA.
Name))
2777 return Error(IDLoc,
"invalid argument identifier for formal argument");
2780 return TokError(
"expected '=' after formal parameter identifier");
2784 NamedParametersFound =
true;
2786 bool Vararg = HasVararg && Parameter == (NParameters - 1);
2788 if (NamedParametersFound && FA.
Name.
empty())
2789 return Error(IDLoc,
"cannot mix positional and keyword arguments");
2794 const MCExpr *AbsoluteExp;
2798 if (parseExpression(AbsoluteExp, EndLoc))
2800 if (!AbsoluteExp->evaluateAsAbsolute(
Value,
2801 getStreamer().getAssemblerPtr()))
2802 return Error(StrLoc,
"expected absolute expression");
2807 FA.
Value.push_back(newToken);
2812 jumpToLoc(EndLoc, CurBuffer);
2817 FA.
Value.push_back(newToken);
2818 }
else if(parseMacroArgument(FA.
Value, Vararg))
2821 unsigned PI = Parameter;
2824 for (FAI = 0; FAI < NParameters; ++FAI)
2825 if (
M->Parameters[FAI].Name == FA.
Name)
2828 if (FAI >= NParameters) {
2829 assert(M &&
"expected macro to be defined");
2830 return Error(IDLoc,
"parameter named '" + FA.
Name +
2831 "' does not exist for macro '" +
M->Name +
"'");
2836 if (!FA.
Value.empty()) {
2841 if (FALocs.
size() <= PI)
2844 FALocs[PI] = Lexer.
getLoc();
2852 for (
unsigned FAI = 0; FAI < NParameters; ++FAI) {
2853 if (
A[FAI].empty()) {
2854 if (
M->Parameters[FAI].Required) {
2856 "missing value for required parameter "
2857 "'" +
M->Parameters[FAI].Name +
"' in macro '" +
M->Name +
"'");
2861 if (!
M->Parameters[FAI].Value.empty())
2862 A[FAI] =
M->Parameters[FAI].Value;
2872 return TokError(
"too many positional arguments");
2879 if (ActiveMacros.size() == MaxNestingDepth) {
2880 std::ostringstream MaxNestingDepthError;
2881 MaxNestingDepthError <<
"macros cannot be nested more than "
2882 << MaxNestingDepth <<
" levels deep."
2883 <<
" Use -asm-macro-max-nesting-depth to increase "
2885 return TokError(MaxNestingDepthError.str());
2888 MCAsmMacroArguments
A;
2889 if (parseMacroArguments(M,
A))
2898 if (expandMacro(
OS, Body,
M->Parameters,
A,
true, getTok().getLoc()))
2903 OS <<
".endmacro\n";
2905 std::unique_ptr<MemoryBuffer> Instantiation =
2910 MacroInstantiation *
MI =
new MacroInstantiation{
2911 NameLoc, CurBuffer, getTok().getLoc(), TheCondStack.size()};
2912 ActiveMacros.push_back(
MI);
2914 ++NumOfMacroInstantiations;
2924void AsmParser::handleMacroExit() {
2926 jumpToLoc(ActiveMacros.back()->ExitLoc, ActiveMacros.back()->ExitBuffer);
2930 delete ActiveMacros.back();
2931 ActiveMacros.pop_back();
2934bool AsmParser::parseAssignment(
StringRef Name, AssignmentKind Kind) {
2937 SMLoc ExprLoc = getTok().getLoc();
2939 Kind == AssignmentKind::Set ||
Kind == AssignmentKind::Equal;
2951 if (discardLTOSymbol(
Name))
2956 case AssignmentKind::Equal:
2959 case AssignmentKind::Set:
2960 case AssignmentKind::Equiv:
2964 case AssignmentKind::LTOSetConditional:
2966 return Error(ExprLoc,
"expected identifier");
2978bool AsmParser::parseIdentifier(
StringRef &Res) {
2985 SMLoc PrefixLoc = getLexer().getLoc();
2997 if (PrefixLoc.
getPointer() + 1 != Buf[0].getLoc().getPointer())
3011 Res = getTok().getIdentifier();
3023bool AsmParser::parseDirectiveSet(
StringRef IDVal, AssignmentKind Kind) {
3025 if (
check(parseIdentifier(
Name),
"expected identifier") || parseComma() ||
3026 parseAssignment(
Name, Kind))
3031bool AsmParser::parseEscapedString(std::string &
Data) {
3036 StringRef Str = getTok().getStringContents();
3037 for (
unsigned i = 0, e = Str.size(); i != e; ++i) {
3038 if (Str[i] !=
'\\') {
3047 return TokError(
"unexpected backslash at end of string");
3050 if (Str[i] ==
'x' || Str[i] ==
'X') {
3051 size_t length = Str.size();
3052 if (i + 1 >= length || !
isHexDigit(Str[i + 1]))
3053 return TokError(
"invalid hexadecimal escape sequence");
3058 while (i + 1 < length &&
isHexDigit(Str[i + 1]))
3059 Value =
Value * 16 + hexDigitValue(Str[++i]);
3066 if ((
unsigned)(Str[i] -
'0') <= 7) {
3068 unsigned Value = Str[i] -
'0';
3070 if (i + 1 != e && ((
unsigned)(Str[i + 1] -
'0')) <= 7) {
3074 if (i + 1 != e && ((
unsigned)(Str[i + 1] -
'0')) <= 7) {
3081 return TokError(
"invalid octal escape sequence (out of range)");
3091 return TokError(
"invalid escape sequence (unrecognized character)");
3093 case 'b':
Data +=
'\b';
break;
3094 case 'f':
Data +=
'\f';
break;
3095 case 'n':
Data +=
'\n';
break;
3096 case 'r':
Data +=
'\r';
break;
3097 case 't':
Data +=
'\t';
break;
3098 case '"':
Data +=
'"';
break;
3099 case '\\':
Data +=
'\\';
break;
3107bool AsmParser::parseAngleBracketString(std::string &
Data) {
3108 SMLoc EndLoc, StartLoc = getTok().getLoc();
3110 const char *StartChar = StartLoc.
getPointer() + 1;
3111 const char *EndChar = EndLoc.
getPointer() - 1;
3112 jumpToLoc(EndLoc, CurBuffer);
3125bool AsmParser::parseDirectiveAscii(
StringRef IDVal,
bool ZeroTerminated) {
3126 auto parseOp = [&]() ->
bool {
3128 if (checkForValidSection())
3133 if (parseEscapedString(
Data))
3135 getStreamer().emitBytes(
Data);
3138 getStreamer().emitBytes(
StringRef(
"\0", 1));
3142 return parseMany(parseOp);
3147bool AsmParser::parseDirectiveReloc(
SMLoc DirectiveLoc) {
3149 const MCExpr *Expr =
nullptr;
3152 if (parseExpression(
Offset))
3165 if (parseExpression(Expr))
3170 return Error(ExprLoc,
"expression must be relocatable");
3178 if (std::optional<std::pair<bool, std::string>> Err =
3179 getStreamer().emitRelocDirective(*
Offset,
Name, Expr, DirectiveLoc,
3181 return Error(Err->first ? NameLoc : OffsetLoc, Err->second);
3188bool AsmParser::parseDirectiveValue(
StringRef IDVal,
unsigned Size) {
3189 auto parseOp = [&]() ->
bool {
3191 SMLoc ExprLoc = getLexer().getLoc();
3192 if (checkForValidSection() || parseExpression(
Value))
3197 uint64_t IntValue = MCE->getValue();
3199 return Error(ExprLoc,
"out of range literal value");
3200 getStreamer().emitIntValue(IntValue,
Size);
3202 getStreamer().emitValue(
Value,
Size, ExprLoc);
3206 return parseMany(parseOp);
3212 return Asm.TokError(
"unknown token in expression");
3213 SMLoc ExprLoc = Asm.getTok().getLoc();
3214 APInt IntValue = Asm.getTok().getAPIntVal();
3216 if (!IntValue.
isIntN(128))
3217 return Asm.Error(ExprLoc,
"out of range literal value");
3218 if (!IntValue.
isIntN(64)) {
3231bool AsmParser::parseDirectiveOctaValue(
StringRef IDVal) {
3232 auto parseOp = [&]() ->
bool {
3233 if (checkForValidSection())
3239 getStreamer().emitInt64(lo);
3240 getStreamer().emitInt64(hi);
3242 getStreamer().emitInt64(hi);
3243 getStreamer().emitInt64(lo);
3248 return parseMany(parseOp);
3262 return TokError(Lexer.
getErr());
3265 return TokError(
"unexpected token in directive");
3277 return TokError(
"invalid floating point literal");
3279 Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven)
3281 return TokError(
"invalid floating point literal");
3288 Res =
Value.bitcastToAPInt();
3295bool AsmParser::parseDirectiveRealValue(
StringRef IDVal,
3297 auto parseOp = [&]() ->
bool {
3299 if (checkForValidSection() || parseRealValue(Semantics, AsInt))
3306 return parseMany(parseOp);
3311bool AsmParser::parseDirectiveZero() {
3314 if (checkForValidSection() || parseExpression(NumBytes))
3320 if (parseAbsoluteExpression(Val))
3326 getStreamer().emitFill(*NumBytes, Val, NumBytesLoc);
3333bool AsmParser::parseDirectiveFill() {
3336 if (checkForValidSection() || parseExpression(NumValues))
3339 int64_t FillSize = 1;
3340 int64_t FillExpr = 0;
3342 SMLoc SizeLoc, ExprLoc;
3345 SizeLoc = getTok().getLoc();
3346 if (parseAbsoluteExpression(FillSize))
3349 ExprLoc = getTok().getLoc();
3350 if (parseAbsoluteExpression(FillExpr))
3358 Warning(SizeLoc,
"'.fill' directive with negative size has no effect");
3362 Warning(SizeLoc,
"'.fill' directive with size greater than 8 has been truncated to 8");
3366 if (!isUInt<32>(FillExpr) && FillSize > 4)
3367 Warning(ExprLoc,
"'.fill' directive pattern has been truncated to 32-bits");
3369 getStreamer().emitFill(*NumValues, FillSize, FillExpr, NumValuesLoc);
3376bool AsmParser::parseDirectiveOrg() {
3379 if (checkForValidSection() || parseExpression(
Offset))
3383 int64_t FillExpr = 0;
3385 if (parseAbsoluteExpression(FillExpr))
3390 getStreamer().emitValueToOffset(
Offset, FillExpr, OffsetLoc);
3396bool AsmParser::parseDirectiveAlign(
bool IsPow2,
unsigned ValueSize) {
3397 SMLoc AlignmentLoc = getLexer().getLoc();
3400 bool HasFillExpr =
false;
3401 int64_t FillExpr = 0;
3402 int64_t MaxBytesToFill = 0;
3404 auto parseAlign = [&]() ->
bool {
3405 if (parseAbsoluteExpression(Alignment))
3413 if (parseAbsoluteExpression(FillExpr))
3417 if (parseTokenLoc(MaxBytesLoc) ||
3418 parseAbsoluteExpression(MaxBytesToFill))
3424 if (checkForValidSection())
3428 Warning(AlignmentLoc,
"p2align directive with no operand(s) is ignored");
3435 bool ReturnVal =
false;
3440 if (Alignment >= 32) {
3441 ReturnVal |=
Error(AlignmentLoc,
"invalid alignment value");
3445 Alignment = 1ULL << Alignment;
3453 ReturnVal |=
Error(AlignmentLoc,
"alignment must be a power of 2");
3454 Alignment = llvm::bit_floor<uint64_t>(Alignment);
3456 if (!isUInt<32>(Alignment)) {
3457 ReturnVal |=
Error(AlignmentLoc,
"alignment must be smaller than 2**32");
3458 Alignment = 1u << 31;
3464 if (MaxBytesToFill < 1) {
3465 ReturnVal |=
Error(MaxBytesLoc,
3466 "alignment directive can never be satisfied in this "
3467 "many bytes, ignoring maximum bytes expression");
3471 if (MaxBytesToFill >= Alignment) {
3472 Warning(MaxBytesLoc,
"maximum bytes expression exceeds alignment and "
3481 assert(Section &&
"must have section to emit alignment");
3482 bool useCodeAlign =
Section->useCodeAlign();
3483 if ((!HasFillExpr || Lexer.getMAI().getTextAlignFillValue() == FillExpr) &&
3484 ValueSize == 1 && useCodeAlign) {
3485 getStreamer().emitCodeAlignment(
3486 Align(Alignment), &getTargetParser().getSTI(), MaxBytesToFill);
3489 getStreamer().emitValueToAlignment(
Align(Alignment), FillExpr, ValueSize,
3499bool AsmParser::parseDirectiveFile(
SMLoc DirectiveLoc) {
3501 int64_t FileNumber = -1;
3503 FileNumber = getTok().getIntVal();
3507 return TokError(
"negative file number");
3514 if (parseEscapedString(Path))
3519 std::string FilenameData;
3521 if (
check(FileNumber == -1,
3522 "explicit path specified, but no file number") ||
3523 parseEscapedString(FilenameData))
3532 bool HasMD5 =
false;
3534 std::optional<StringRef>
Source;
3535 bool HasSource =
false;
3536 std::string SourceString;
3541 "unexpected token in '.file' directive") ||
3542 parseIdentifier(Keyword))
3544 if (Keyword ==
"md5") {
3546 if (
check(FileNumber == -1,
3547 "MD5 checksum specified, but no file number") ||
3550 }
else if (Keyword ==
"source") {
3552 if (
check(FileNumber == -1,
3553 "source specified, but no file number") ||
3555 "unexpected token in '.file' directive") ||
3556 parseEscapedString(SourceString))
3559 return TokError(
"unexpected token in '.file' directive");
3563 if (FileNumber == -1) {
3567 if (getContext().getAsmInfo()->hasSingleParameterDotFile())
3568 getStreamer().emitFileDirective(Filename);
3578 std::optional<MD5::MD5Result> CKMem;
3581 for (
unsigned i = 0; i != 8; ++i) {
3582 Sum[i] = uint8_t(MD5Hi >> ((7 - i) * 8));
3583 Sum[i + 8] = uint8_t(MD5Lo >> ((7 - i) * 8));
3588 char *SourceBuf =
static_cast<char *
>(Ctx.
allocate(SourceString.size()));
3589 memcpy(SourceBuf, SourceString.data(), SourceString.size());
3592 if (FileNumber == 0) {
3596 getStreamer().emitDwarfFile0Directive(Directory, Filename, CKMem, Source);
3599 FileNumber, Directory, Filename, CKMem, Source);
3606 ReportedInconsistentMD5 =
true;
3607 return Warning(DirectiveLoc,
"inconsistent use of MD5 checksums");
3616bool AsmParser::parseDirectiveLine() {
3619 if (parseIntToken(LineNumber,
"unexpected token in '.line' directive"))
3634bool AsmParser::parseDirectiveLoc() {
3635 int64_t FileNumber = 0, LineNumber = 0;
3636 SMLoc Loc = getTok().getLoc();
3637 if (parseIntToken(FileNumber,
"unexpected token in '.loc' directive") ||
3639 "file number less than one in '.loc' directive") ||
3640 check(!getContext().isValidDwarfFileNumber(FileNumber), Loc,
3641 "unassigned file number in '.loc' directive"))
3646 LineNumber = getTok().getIntVal();
3648 return TokError(
"line number less than zero in '.loc' directive");
3652 int64_t ColumnPos = 0;
3654 ColumnPos = getTok().getIntVal();
3656 return TokError(
"column position less than zero in '.loc' directive");
3660 auto PrevFlags = getContext().getCurrentDwarfLoc().getFlags();
3665 auto parseLocOp = [&]() ->
bool {
3667 SMLoc Loc = getTok().getLoc();
3668 if (parseIdentifier(
Name))
3669 return TokError(
"unexpected token in '.loc' directive");
3671 if (
Name ==
"basic_block")
3673 else if (
Name ==
"prologue_end")
3675 else if (
Name ==
"epilogue_begin")
3677 else if (
Name ==
"is_stmt") {
3678 Loc = getTok().getLoc();
3680 if (parseExpression(
Value))
3684 int Value = MCE->getValue();
3686 Flags &= ~DWARF2_FLAG_IS_STMT;
3687 else if (
Value == 1)
3690 return Error(Loc,
"is_stmt value not 0 or 1");
3692 return Error(Loc,
"is_stmt value not the constant value of 0 or 1");
3694 }
else if (
Name ==
"isa") {
3695 Loc = getTok().getLoc();
3697 if (parseExpression(
Value))
3701 int Value = MCE->getValue();
3703 return Error(Loc,
"isa number less than zero");
3706 return Error(Loc,
"isa number not a constant value");
3708 }
else if (
Name ==
"discriminator") {
3709 if (parseAbsoluteExpression(Discriminator))
3712 return Error(Loc,
"unknown sub-directive in '.loc' directive");
3717 if (parseMany(parseLocOp,
false ))
3720 getStreamer().emitDwarfLocDirective(FileNumber, LineNumber, ColumnPos, Flags,
3728bool AsmParser::parseDirectiveStabs() {
3729 return TokError(
"unsupported directive '.stabs'");
3734bool AsmParser::parseDirectiveCVFile() {
3735 SMLoc FileNumberLoc = getTok().getLoc();
3738 std::string Checksum;
3741 if (parseIntToken(FileNumber,
3742 "expected file number in '.cv_file' directive") ||
3743 check(FileNumber < 1, FileNumberLoc,
"file number less than one") ||
3745 "unexpected token in '.cv_file' directive") ||
3746 parseEscapedString(Filename))
3750 "unexpected token in '.cv_file' directive") ||
3751 parseEscapedString(Checksum) ||
3752 parseIntToken(ChecksumKind,
3753 "expected checksum kind in '.cv_file' directive") ||
3758 Checksum = fromHex(Checksum);
3759 void *CKMem = Ctx.
allocate(Checksum.size(), 1);
3760 memcpy(CKMem, Checksum.data(), Checksum.size());
3764 if (!getStreamer().emitCVFileDirective(FileNumber, Filename, ChecksumAsBytes,
3765 static_cast<uint8_t
>(ChecksumKind)))
3766 return Error(FileNumberLoc,
"file number already allocated");
3771bool AsmParser::parseCVFunctionId(int64_t &FunctionId,
3774 return parseTokenLoc(Loc) ||
3775 parseIntToken(FunctionId,
"expected function id in '" + DirectiveName +
3777 check(FunctionId < 0 || FunctionId >= UINT_MAX, Loc,
3778 "expected function id within range [0, UINT_MAX)");
3781bool AsmParser::parseCVFileId(int64_t &FileNumber,
StringRef DirectiveName) {
3783 return parseTokenLoc(Loc) ||
3784 parseIntToken(FileNumber,
"expected integer in '" + DirectiveName +
3786 check(FileNumber < 1, Loc,
"file number less than one in '" +
3787 DirectiveName +
"' directive") ||
3788 check(!getCVContext().isValidFileNumber(FileNumber), Loc,
3789 "unassigned file number in '" + DirectiveName +
"' directive");
3796bool AsmParser::parseDirectiveCVFuncId() {
3797 SMLoc FunctionIdLoc = getTok().getLoc();
3800 if (parseCVFunctionId(FunctionId,
".cv_func_id") || parseEOL())
3803 if (!getStreamer().emitCVFuncIdDirective(FunctionId))
3804 return Error(FunctionIdLoc,
"function id already allocated");
3817bool AsmParser::parseDirectiveCVInlineSiteId() {
3818 SMLoc FunctionIdLoc = getTok().getLoc();
3826 if (parseCVFunctionId(FunctionId,
".cv_inline_site_id"))
3831 getTok().getIdentifier() !=
"within"),
3832 "expected 'within' identifier in '.cv_inline_site_id' directive"))
3837 if (parseCVFunctionId(IAFunc,
".cv_inline_site_id"))
3842 getTok().getIdentifier() !=
"inlined_at"),
3843 "expected 'inlined_at' identifier in '.cv_inline_site_id' "
3849 if (parseCVFileId(IAFile,
".cv_inline_site_id") ||
3850 parseIntToken(IALine,
"expected line number after 'inlined_at'"))
3855 IACol = getTok().getIntVal();
3862 if (!getStreamer().emitCVInlineSiteIdDirective(FunctionId, IAFunc, IAFile,
3863 IALine, IACol, FunctionIdLoc))
3864 return Error(FunctionIdLoc,
"function id already allocated");
3876bool AsmParser::parseDirectiveCVLoc() {
3877 SMLoc DirectiveLoc = getTok().getLoc();
3878 int64_t FunctionId, FileNumber;
3879 if (parseCVFunctionId(FunctionId,
".cv_loc") ||
3880 parseCVFileId(FileNumber,
".cv_loc"))
3883 int64_t LineNumber = 0;
3885 LineNumber = getTok().getIntVal();
3887 return TokError(
"line number less than zero in '.cv_loc' directive");
3891 int64_t ColumnPos = 0;
3893 ColumnPos = getTok().getIntVal();
3895 return TokError(
"column position less than zero in '.cv_loc' directive");
3899 bool PrologueEnd =
false;
3902 auto parseOp = [&]() ->
bool {
3904 SMLoc Loc = getTok().getLoc();
3905 if (parseIdentifier(
Name))
3906 return TokError(
"unexpected token in '.cv_loc' directive");
3907 if (
Name ==
"prologue_end")
3909 else if (
Name ==
"is_stmt") {
3910 Loc = getTok().getLoc();
3912 if (parseExpression(
Value))
3916 if (
const auto *MCE = dyn_cast<MCConstantExpr>(
Value))
3917 IsStmt = MCE->getValue();
3920 return Error(Loc,
"is_stmt value not 0 or 1");
3922 return Error(Loc,
"unknown sub-directive in '.cv_loc' directive");
3927 if (parseMany(parseOp,
false ))
3930 getStreamer().emitCVLocDirective(FunctionId, FileNumber, LineNumber,
3931 ColumnPos, PrologueEnd, IsStmt,
StringRef(),
3938bool AsmParser::parseDirectiveCVLinetable() {
3941 SMLoc Loc = getTok().getLoc();
3942 if (parseCVFunctionId(FunctionId,
".cv_linetable") || parseComma() ||
3943 parseTokenLoc(Loc) ||
3944 check(parseIdentifier(FnStartName), Loc,
3945 "expected identifier in directive") ||
3946 parseComma() || parseTokenLoc(Loc) ||
3947 check(parseIdentifier(FnEndName), Loc,
3948 "expected identifier in directive"))
3951 MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
3952 MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
3954 getStreamer().emitCVLinetableDirective(FunctionId, FnStartSym, FnEndSym);
3960bool AsmParser::parseDirectiveCVInlineLinetable() {
3961 int64_t PrimaryFunctionId, SourceFileId, SourceLineNum;
3963 SMLoc Loc = getTok().getLoc();
3964 if (parseCVFunctionId(PrimaryFunctionId,
".cv_inline_linetable") ||
3965 parseTokenLoc(Loc) ||
3968 "expected SourceField in '.cv_inline_linetable' directive") ||
3969 check(SourceFileId <= 0, Loc,
3970 "File id less than zero in '.cv_inline_linetable' directive") ||
3971 parseTokenLoc(Loc) ||
3974 "expected SourceLineNum in '.cv_inline_linetable' directive") ||
3975 check(SourceLineNum < 0, Loc,
3976 "Line number less than zero in '.cv_inline_linetable' directive") ||
3977 parseTokenLoc(Loc) ||
check(parseIdentifier(FnStartName), Loc,
3978 "expected identifier in directive") ||
3979 parseTokenLoc(Loc) ||
check(parseIdentifier(FnEndName), Loc,
3980 "expected identifier in directive"))
3986 MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
3987 MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
3988 getStreamer().emitCVInlineLinetableDirective(PrimaryFunctionId, SourceFileId,
3989 SourceLineNum, FnStartSym,
3994void AsmParser::initializeCVDefRangeTypeMap() {
3995 CVDefRangeTypeMap[
"reg"] = CVDR_DEFRANGE_REGISTER;
3996 CVDefRangeTypeMap[
"frame_ptr_rel"] = CVDR_DEFRANGE_FRAMEPOINTER_REL;
3997 CVDefRangeTypeMap[
"subfield_reg"] = CVDR_DEFRANGE_SUBFIELD_REGISTER;
3998 CVDefRangeTypeMap[
"reg_rel"] = CVDR_DEFRANGE_REGISTER_REL;
4003bool AsmParser::parseDirectiveCVDefRange() {
4005 std::vector<std::pair<const MCSymbol *, const MCSymbol *>>
Ranges;
4007 Loc = getLexer().getLoc();
4009 if (parseIdentifier(GapStartName))
4010 return Error(Loc,
"expected identifier in directive");
4011 MCSymbol *GapStartSym = getContext().getOrCreateSymbol(GapStartName);
4013 Loc = getLexer().getLoc();
4015 if (parseIdentifier(GapEndName))
4016 return Error(Loc,
"expected identifier in directive");
4017 MCSymbol *GapEndSym = getContext().getOrCreateSymbol(GapEndName);
4019 Ranges.push_back({GapStartSym, GapEndSym});
4025 "expected comma before def_range type in .cv_def_range directive") ||
4026 parseIdentifier(CVDefRangeTypeStr))
4027 return Error(Loc,
"expected def_range type in directive");
4030 CVDefRangeTypeMap.find(CVDefRangeTypeStr);
4031 CVDefRangeType CVDRType = (CVTypeIt == CVDefRangeTypeMap.end())
4033 : CVTypeIt->getValue();
4035 case CVDR_DEFRANGE_REGISTER: {
4037 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4038 ".cv_def_range directive") ||
4039 parseAbsoluteExpression(DRRegister))
4040 return Error(Loc,
"expected register number");
4045 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4048 case CVDR_DEFRANGE_FRAMEPOINTER_REL: {
4051 "expected comma before offset in .cv_def_range directive") ||
4052 parseAbsoluteExpression(DROffset))
4053 return Error(Loc,
"expected offset value");
4057 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4060 case CVDR_DEFRANGE_SUBFIELD_REGISTER: {
4062 int64_t DROffsetInParent;
4063 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4064 ".cv_def_range directive") ||
4065 parseAbsoluteExpression(DRRegister))
4066 return Error(Loc,
"expected register number");
4068 "expected comma before offset in .cv_def_range directive") ||
4069 parseAbsoluteExpression(DROffsetInParent))
4070 return Error(Loc,
"expected offset value");
4076 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4079 case CVDR_DEFRANGE_REGISTER_REL: {
4082 int64_t DRBasePointerOffset;
4083 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4084 ".cv_def_range directive") ||
4085 parseAbsoluteExpression(DRRegister))
4086 return Error(Loc,
"expected register value");
4089 "expected comma before flag value in .cv_def_range directive") ||
4090 parseAbsoluteExpression(DRFlags))
4091 return Error(Loc,
"expected flag value");
4092 if (parseToken(
AsmToken::Comma,
"expected comma before base pointer offset "
4093 "in .cv_def_range directive") ||
4094 parseAbsoluteExpression(DRBasePointerOffset))
4095 return Error(Loc,
"expected base pointer offset value");
4099 DRHdr.
Flags = DRFlags;
4101 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4105 return Error(Loc,
"unexpected def_range type in .cv_def_range directive");
4112bool AsmParser::parseDirectiveCVString() {
4114 if (checkForValidSection() || parseEscapedString(
Data))
4118 std::pair<StringRef, unsigned> Insertion =
4119 getCVContext().addToStringTable(
Data);
4120 getStreamer().emitInt32(Insertion.second);
4126bool AsmParser::parseDirectiveCVStringTable() {
4127 getStreamer().emitCVStringTableDirective();
4133bool AsmParser::parseDirectiveCVFileChecksums() {
4134 getStreamer().emitCVFileChecksumsDirective();
4140bool AsmParser::parseDirectiveCVFileChecksumOffset() {
4142 if (parseIntToken(FileNo,
"expected identifier in directive"))
4146 getStreamer().emitCVFileChecksumOffsetDirective(FileNo);
4152bool AsmParser::parseDirectiveCVFPOData() {
4153 SMLoc DirLoc = getLexer().getLoc();
4155 if (parseIdentifier(ProcName))
4156 return TokError(
"expected symbol name");
4159 MCSymbol *ProcSym = getContext().getOrCreateSymbol(ProcName);
4160 getStreamer().emitCVFPOData(ProcSym, DirLoc);
4166bool AsmParser::parseDirectiveCFISections() {
4173 if (parseIdentifier(
Name))
4174 return TokError(
"expected .eh_frame or .debug_frame");
4175 if (
Name ==
".eh_frame")
4177 else if (
Name ==
".debug_frame")
4185 getStreamer().emitCFISections(EH,
Debug);
4191bool AsmParser::parseDirectiveCFIStartProc() {
4195 "unexpected token") ||
4205 getStreamer().emitCFIStartProc(!
Simple.empty(), Lexer.
getLoc());
4211bool AsmParser::parseDirectiveCFIEndProc() {
4214 getStreamer().emitCFIEndProc();
4219bool AsmParser::parseRegisterOrRegisterNumber(int64_t &
Register,
4220 SMLoc DirectiveLoc) {
4224 if (getTargetParser().parseRegister(RegNo, DirectiveLoc, DirectiveLoc))
4226 Register = getContext().getRegisterInfo()->getDwarfRegNum(RegNo,
true);
4228 return parseAbsoluteExpression(
Register);
4235bool AsmParser::parseDirectiveCFIDefCfa(
SMLoc DirectiveLoc) {
4237 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4238 parseAbsoluteExpression(
Offset) || parseEOL())
4247bool AsmParser::parseDirectiveCFIDefCfaOffset() {
4249 if (parseAbsoluteExpression(
Offset) || parseEOL())
4252 getStreamer().emitCFIDefCfaOffset(
Offset);
4258bool AsmParser::parseDirectiveCFIRegister(
SMLoc DirectiveLoc) {
4259 int64_t Register1 = 0, Register2 = 0;
4260 if (parseRegisterOrRegisterNumber(Register1, DirectiveLoc) || parseComma() ||
4261 parseRegisterOrRegisterNumber(Register2, DirectiveLoc) || parseEOL())
4264 getStreamer().emitCFIRegister(Register1, Register2);
4270bool AsmParser::parseDirectiveCFIWindowSave() {
4273 getStreamer().emitCFIWindowSave();
4279bool AsmParser::parseDirectiveCFIAdjustCfaOffset() {
4280 int64_t Adjustment = 0;
4281 if (parseAbsoluteExpression(Adjustment) || parseEOL())
4284 getStreamer().emitCFIAdjustCfaOffset(Adjustment);
4290bool AsmParser::parseDirectiveCFIDefCfaRegister(
SMLoc DirectiveLoc) {
4292 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4295 getStreamer().emitCFIDefCfaRegister(
Register);
4301bool AsmParser::parseDirectiveCFILLVMDefAspaceCfa(
SMLoc DirectiveLoc) {
4303 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4304 parseAbsoluteExpression(
Offset) || parseComma() ||
4314bool AsmParser::parseDirectiveCFIOffset(
SMLoc DirectiveLoc) {
4318 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4319 parseAbsoluteExpression(
Offset) || parseEOL())
4328bool AsmParser::parseDirectiveCFIRelOffset(
SMLoc DirectiveLoc) {
4331 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4332 parseAbsoluteExpression(
Offset) || parseEOL())
4340 if (Encoding & ~0xff)
4346 const unsigned Format = Encoding & 0xf;
4353 const unsigned Application = Encoding & 0x70;
4365bool AsmParser::parseDirectiveCFIPersonalityOrLsda(
bool IsPersonality) {
4366 int64_t Encoding = 0;
4367 if (parseAbsoluteExpression(Encoding))
4375 check(parseIdentifier(
Name),
"expected identifier in directive") ||
4382 getStreamer().emitCFIPersonality(
Sym, Encoding);
4384 getStreamer().emitCFILsda(
Sym, Encoding);
4390bool AsmParser::parseDirectiveCFIRememberState() {
4393 getStreamer().emitCFIRememberState();
4399bool AsmParser::parseDirectiveCFIRestoreState() {
4402 getStreamer().emitCFIRestoreState();
4408bool AsmParser::parseDirectiveCFISameValue(
SMLoc DirectiveLoc) {
4411 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4414 getStreamer().emitCFISameValue(
Register);
4420bool AsmParser::parseDirectiveCFIRestore(
SMLoc DirectiveLoc) {
4422 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4425 getStreamer().emitCFIRestore(
Register);
4431bool AsmParser::parseDirectiveCFIEscape() {
4434 if (parseAbsoluteExpression(CurrValue))
4437 Values.push_back((uint8_t)CurrValue);
4442 if (parseAbsoluteExpression(CurrValue))
4445 Values.push_back((uint8_t)CurrValue);
4448 getStreamer().emitCFIEscape(Values);
4454bool AsmParser::parseDirectiveCFIReturnColumn(
SMLoc DirectiveLoc) {
4456 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4458 getStreamer().emitCFIReturnColumn(
Register);
4464bool AsmParser::parseDirectiveCFISignalFrame() {
4468 getStreamer().emitCFISignalFrame();
4474bool AsmParser::parseDirectiveCFIUndefined(
SMLoc DirectiveLoc) {
4477 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4480 getStreamer().emitCFIUndefined(
Register);
4490 AltMacroMode = (
Directive ==
".altmacro");
4500 setMacrosEnabled(
Directive ==
".macros_on");
4506bool AsmParser::parseDirectiveMacro(
SMLoc DirectiveLoc) {
4508 if (parseIdentifier(
Name))
4509 return TokError(
"expected identifier in '.macro' directive");
4517 if (!Parameters.empty() && Parameters.back().Vararg)
4518 return Error(Lexer.
getLoc(),
"vararg parameter '" +
4519 Parameters.back().Name +
4520 "' should be the last parameter");
4523 if (parseIdentifier(Parameter.
Name))
4524 return TokError(
"expected identifier in '.macro' directive");
4528 if (CurrParam.Name.equals(Parameter.
Name))
4529 return TokError(
"macro '" +
Name +
"' has multiple parameters"
4530 " named '" + Parameter.
Name +
"'");
4538 QualLoc = Lexer.
getLoc();
4539 if (parseIdentifier(Qualifier))
4540 return Error(QualLoc,
"missing parameter qualifier for "
4541 "'" + Parameter.
Name +
"' in macro '" +
Name +
"'");
4543 if (Qualifier ==
"req")
4545 else if (Qualifier ==
"vararg")
4548 return Error(QualLoc, Qualifier +
" is not a valid parameter qualifier "
4549 "for '" + Parameter.
Name +
"' in macro '" +
Name +
"'");
4557 ParamLoc = Lexer.
getLoc();
4558 if (parseMacroArgument(Parameter.
Value,
false ))
4562 Warning(ParamLoc,
"pointless default value for required parameter "
4563 "'" + Parameter.
Name +
"' in macro '" +
Name +
"'");
4566 Parameters.push_back(std::move(Parameter));
4576 AsmToken EndToken, StartToken = getTok();
4577 unsigned MacroDepth = 0;
4587 return Error(DirectiveLoc,
"no matching '.endmacro' in definition");
4592 if (getTok().getIdentifier() ==
".endm" ||
4593 getTok().getIdentifier() ==
".endmacro") {
4594 if (MacroDepth == 0) {
4595 EndToken = getTok();
4598 return TokError(
"unexpected token in '" + EndToken.
getIdentifier() +
4605 }
else if (getTok().getIdentifier() ==
".macro") {
4611 (void)parseCppHashLineFilenameComment(getLexer().getLoc());
4615 eatToEndOfStatement();
4618 if (getContext().lookupMacro(
Name)) {
4619 return Error(DirectiveLoc,
"macro '" +
Name +
"' is already defined");
4625 checkForBadMacro(DirectiveLoc,
Name, Body, Parameters);
4629 getContext().defineMacro(
Name, std::move(
Macro));
4652 unsigned NParameters = Parameters.
size();
4653 if (NParameters == 0)
4656 bool NamedParametersFound =
false;
4657 bool PositionalParametersFound =
false;
4662 while (!Body.
empty()) {
4664 std::size_t
End = Body.
size(), Pos = 0;
4665 for (; Pos !=
End; ++Pos) {
4668 if (Body[Pos] ==
'\\' && Pos + 1 !=
End)
4672 if (Body[Pos] !=
'$' || Pos + 1 ==
End)
4674 char Next = Body[Pos + 1];
4675 if (Next ==
'$' || Next ==
'n' ||
4676 isdigit(
static_cast<unsigned char>(Next)))
4684 if (Body[Pos] ==
'$') {
4685 switch (Body[Pos + 1]) {
4692 PositionalParametersFound =
true;
4697 PositionalParametersFound =
true;
4703 unsigned I = Pos + 1;
4707 const char *Begin = Body.
data() + Pos + 1;
4714 if (
Index == NParameters) {
4715 if (Body[Pos + 1] ==
'(' && Body[Pos + 2] ==
')')
4721 NamedParametersFound =
true;
4729 if (!NamedParametersFound && PositionalParametersFound)
4730 Warning(DirectiveLoc,
"macro defined with named parameters which are not "
4731 "used in macro body, possible positional parameter "
4732 "found in body which will have no effect");
4741 if (!isInsideMacroInstantiation())
4742 return TokError(
"unexpected '" +
Directive +
"' in file, "
4743 "no current macro definition");
4746 while (TheCondStack.size() != ActiveMacros.back()->CondStackDepth) {
4747 TheCondState = TheCondStack.back();
4748 TheCondStack.pop_back();
4760 return TokError(
"unexpected token in '" +
Directive +
"' directive");
4764 if (isInsideMacroInstantiation()) {
4771 return TokError(
"unexpected '" +
Directive +
"' in file, "
4772 "no current macro definition");
4777bool AsmParser::parseDirectivePurgeMacro(
SMLoc DirectiveLoc) {
4780 if (parseTokenLoc(Loc) ||
4782 "expected identifier in '.purgem' directive") ||
4786 if (!getContext().lookupMacro(
Name))
4787 return Error(DirectiveLoc,
"macro '" +
Name +
"' is not defined");
4789 getContext().undefineMacro(
Name);
4791 <<
"Un-defining macro: " <<
Name <<
"\n");
4797bool AsmParser::parseDirectiveBundleAlignMode() {
4800 SMLoc ExprLoc = getLexer().getLoc();
4801 int64_t AlignSizePow2;
4802 if (checkForValidSection() || parseAbsoluteExpression(AlignSizePow2) ||
4804 check(AlignSizePow2 < 0 || AlignSizePow2 > 30, ExprLoc,
4805 "invalid bundle alignment size (expected between 0 and 30)"))
4808 getStreamer().emitBundleAlignMode(
Align(1ULL << AlignSizePow2));
4814bool AsmParser::parseDirectiveBundleLock() {
4815 if (checkForValidSection())
4817 bool AlignToEnd =
false;
4820 SMLoc Loc = getTok().getLoc();
4821 const char *kInvalidOptionError =
4822 "invalid option for '.bundle_lock' directive";
4825 if (
check(parseIdentifier(Option), Loc, kInvalidOptionError) ||
4826 check(Option !=
"align_to_end", Loc, kInvalidOptionError) || parseEOL())
4831 getStreamer().emitBundleLock(AlignToEnd);
4837bool AsmParser::parseDirectiveBundleUnlock() {
4838 if (checkForValidSection() || parseEOL())
4841 getStreamer().emitBundleUnlock();
4847bool AsmParser::parseDirectiveSpace(
StringRef IDVal) {
4850 if (checkForValidSection() || parseExpression(NumBytes))
4853 int64_t FillExpr = 0;
4855 if (parseAbsoluteExpression(FillExpr))
4861 getStreamer().emitFill(*NumBytes, FillExpr, NumBytesLoc);
4868bool AsmParser::parseDirectiveDCB(
StringRef IDVal,
unsigned Size) {
4871 if (checkForValidSection() || parseAbsoluteExpression(NumValues))
4874 if (NumValues < 0) {
4875 Warning(NumValuesLoc,
"'" +
Twine(IDVal) +
"' directive with negative repeat count has no effect");
4883 SMLoc ExprLoc = getLexer().getLoc();
4884 if (parseExpression(
Value))
4890 uint64_t IntValue = MCE->getValue();
4892 return Error(ExprLoc,
"literal value out of range for directive");
4893 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4894 getStreamer().emitIntValue(IntValue,
Size);
4896 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4897 getStreamer().emitValue(
Value,
Size, ExprLoc);
4908 if (checkForValidSection() || parseAbsoluteExpression(NumValues))
4911 if (NumValues < 0) {
4912 Warning(NumValuesLoc,
"'" +
Twine(IDVal) +
"' directive with negative repeat count has no effect");
4920 if (parseRealValue(Semantics, AsInt) || parseEOL())
4923 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4932bool AsmParser::parseDirectiveDS(
StringRef IDVal,
unsigned Size) {
4935 if (checkForValidSection() || parseAbsoluteExpression(NumValues) ||
4939 if (NumValues < 0) {
4940 Warning(NumValuesLoc,
"'" +
Twine(IDVal) +
"' directive with negative repeat count has no effect");
4944 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4945 getStreamer().emitFill(
Size, 0);
4952bool AsmParser::parseDirectiveLEB128(
bool Signed) {
4953 if (checkForValidSection())
4956 auto parseOp = [&]() ->
bool {
4958 if (parseExpression(
Value))
4961 getStreamer().emitSLEB128Value(
Value);
4963 getStreamer().emitULEB128Value(
Value);
4967 return parseMany(parseOp);
4972bool AsmParser::parseDirectiveSymbolAttribute(
MCSymbolAttr Attr) {
4973 auto parseOp = [&]() ->
bool {
4975 SMLoc Loc = getTok().getLoc();
4976 if (parseIdentifier(
Name))
4977 return Error(Loc,
"expected identifier");
4979 if (discardLTOSymbol(
Name))
4987 return Error(Loc,
"non-local symbol required");
4989 if (!getStreamer().emitSymbolAttribute(
Sym, Attr))
4990 return Error(Loc,
"unable to emit symbol attribute");
4994 return parseMany(parseOp);
4999bool AsmParser::parseDirectiveComm(
bool IsLocal) {
5000 if (checkForValidSection())
5003 SMLoc IDLoc = getLexer().getLoc();
5005 if (parseIdentifier(
Name))
5006 return TokError(
"expected identifier in directive");
5015 SMLoc SizeLoc = getLexer().getLoc();
5016 if (parseAbsoluteExpression(
Size))
5019 int64_t Pow2Alignment = 0;
5020 SMLoc Pow2AlignmentLoc;
5023 Pow2AlignmentLoc = getLexer().getLoc();
5024 if (parseAbsoluteExpression(Pow2Alignment))
5029 return Error(Pow2AlignmentLoc,
"alignment not supported on this target");
5032 if ((!IsLocal && Lexer.getMAI().getCOMMDirectiveAlignmentIsInBytes()) ||
5035 return Error(Pow2AlignmentLoc,
"alignment must be a power of 2");
5036 Pow2Alignment =
Log2_64(Pow2Alignment);
5046 return Error(SizeLoc,
"size must be non-negative");
5048 Sym->redefineIfPossible();
5049 if (!
Sym->isUndefined())
5050 return Error(IDLoc,
"invalid symbol redefinition");
5054 getStreamer().emitLocalCommonSymbol(
Sym,
Size,
5055 Align(1ULL << Pow2Alignment));
5059 getStreamer().emitCommonSymbol(
Sym,
Size,
Align(1ULL << Pow2Alignment));
5065bool AsmParser::parseDirectiveAbort() {
5067 SMLoc Loc = getLexer().getLoc();
5069 StringRef Str = parseStringToEndOfStatement();
5074 return Error(Loc,
".abort detected. Assembly stopping.");
5076 return Error(Loc,
".abort '" + Str +
"' detected. Assembly stopping.");
5084bool AsmParser::parseDirectiveInclude() {
5087 SMLoc IncludeLoc = getTok().getLoc();
5090 "expected string in '.include' directive") ||
5091 parseEscapedString(Filename) ||
5093 "unexpected token in '.include' directive") ||
5096 check(enterIncludeFile(Filename), IncludeLoc,
5097 "Could not find include file '" + Filename +
"'"))
5105bool AsmParser::parseDirectiveIncbin() {
5108 SMLoc IncbinLoc = getTok().getLoc();
5110 "expected string in '.incbin' directive") ||
5111 parseEscapedString(Filename))
5115 const MCExpr *Count =
nullptr;
5116 SMLoc SkipLoc, CountLoc;
5121 if (parseTokenLoc(SkipLoc) || parseAbsoluteExpression(Skip))
5125 CountLoc = getTok().getLoc();
5126 if (parseExpression(Count))
5134 if (
check(Skip < 0, SkipLoc,
"skip is negative"))
5138 if (processIncbinFile(Filename, Skip, Count, CountLoc))
5139 return Error(IncbinLoc,
"Could not find incbin file '" + Filename +
"'");
5145bool AsmParser::parseDirectiveIf(
SMLoc DirectiveLoc, DirectiveKind DirKind) {
5146 TheCondStack.push_back(TheCondState);
5148 if (TheCondState.
Ignore) {
5149 eatToEndOfStatement();
5152 if (parseAbsoluteExpression(ExprValue) || parseEOL())
5162 ExprValue = ExprValue == 0;
5165 ExprValue = ExprValue >= 0;
5168 ExprValue = ExprValue > 0;
5171 ExprValue = ExprValue <= 0;
5174 ExprValue = ExprValue < 0;
5178 TheCondState.
CondMet = ExprValue;
5187bool AsmParser::parseDirectiveIfb(
SMLoc DirectiveLoc,
bool ExpectBlank) {
5188 TheCondStack.push_back(TheCondState);
5191 if (TheCondState.
Ignore) {
5192 eatToEndOfStatement();
5194 StringRef Str = parseStringToEndOfStatement();
5199 TheCondState.
CondMet = ExpectBlank == Str.empty();
5209bool AsmParser::parseDirectiveIfc(
SMLoc DirectiveLoc,
bool ExpectEqual) {
5210 TheCondStack.push_back(TheCondState);
5213 if (TheCondState.
Ignore) {
5214 eatToEndOfStatement();
5221 StringRef Str2 = parseStringToEndOfStatement();
5235bool AsmParser::parseDirectiveIfeqs(
SMLoc DirectiveLoc,
bool ExpectEqual) {
5238 return TokError(
"expected string parameter for '.ifeqs' directive");
5239 return TokError(
"expected string parameter for '.ifnes' directive");
5242 StringRef String1 = getTok().getStringContents();
5248 "expected comma after first string for '.ifeqs' directive");
5249 return TokError(
"expected comma after first string for '.ifnes' directive");
5256 return TokError(
"expected string parameter for '.ifeqs' directive");
5257 return TokError(
"expected string parameter for '.ifnes' directive");
5260 StringRef String2 = getTok().getStringContents();
5263 TheCondStack.push_back(TheCondState);
5265 TheCondState.
CondMet = ExpectEqual == (String1 == String2);
5273bool AsmParser::parseDirectiveIfdef(
SMLoc DirectiveLoc,
bool expect_defined) {
5275 TheCondStack.push_back(TheCondState);
5278 if (TheCondState.
Ignore) {
5279 eatToEndOfStatement();
5281 if (
check(parseIdentifier(
Name),
"expected identifier after '.ifdef'") ||
5299bool AsmParser::parseDirectiveElseIf(
SMLoc DirectiveLoc) {
5302 return Error(DirectiveLoc,
"Encountered a .elseif that doesn't follow an"
5303 " .if or an .elseif");
5306 bool LastIgnoreState =
false;
5307 if (!TheCondStack.empty())
5308 LastIgnoreState = TheCondStack.back().Ignore;
5309 if (LastIgnoreState || TheCondState.
CondMet) {
5310 TheCondState.
Ignore =
true;
5311 eatToEndOfStatement();
5314 if (parseAbsoluteExpression(ExprValue))
5320 TheCondState.
CondMet = ExprValue;
5329bool AsmParser::parseDirectiveElse(
SMLoc DirectiveLoc) {
5335 return Error(DirectiveLoc,
"Encountered a .else that doesn't follow "
5336 " an .if or an .elseif");
5338 bool LastIgnoreState =
false;
5339 if (!TheCondStack.empty())
5340 LastIgnoreState = TheCondStack.back().Ignore;
5341 if (LastIgnoreState || TheCondState.
CondMet)
5342 TheCondState.
Ignore =
true;
5344 TheCondState.
Ignore =
false;
5351bool AsmParser::parseDirectiveEnd(
SMLoc DirectiveLoc) {
5364bool AsmParser::parseDirectiveError(
SMLoc L,
bool WithMessage) {
5365 if (!TheCondStack.empty()) {
5366 if (TheCondStack.back().Ignore) {
5367 eatToEndOfStatement();
5373 return Error(L,
".err encountered");
5375 StringRef Message =
".error directive invoked in source file";
5378 return TokError(
".error argument must be a string");
5380 Message = getTok().getStringContents();
5384 return Error(L, Message);
5389bool AsmParser::parseDirectiveWarning(
SMLoc L) {
5390 if (!TheCondStack.empty()) {
5391 if (TheCondStack.back().Ignore) {
5392 eatToEndOfStatement();
5397 StringRef Message =
".warning directive invoked in source file";
5401 return TokError(
".warning argument must be a string");
5403 Message = getTok().getStringContents();
5414bool AsmParser::parseDirectiveEndIf(
SMLoc DirectiveLoc) {
5419 return Error(DirectiveLoc,
"Encountered a .endif that doesn't follow "
5421 if (!TheCondStack.empty()) {
5422 TheCondState = TheCondStack.back();
5423 TheCondStack.pop_back();
5429void AsmParser::initializeDirectiveKindMap() {
5436 DirectiveKindMap[
".set"] = DK_SET;
5437 DirectiveKindMap[
".equ"] = DK_EQU;
5438 DirectiveKindMap[
".equiv"] = DK_EQUIV;
5439 DirectiveKindMap[
".ascii"] = DK_ASCII;
5440 DirectiveKindMap[
".asciz"] = DK_ASCIZ;
5441 DirectiveKindMap[
".string"] = DK_STRING;
5442 DirectiveKindMap[
".byte"] = DK_BYTE;
5443 DirectiveKindMap[
".short"] = DK_SHORT;
5444 DirectiveKindMap[
".value"] = DK_VALUE;
5445 DirectiveKindMap[
".2byte"] = DK_2BYTE;
5446 DirectiveKindMap[
".long"] = DK_LONG;
5447 DirectiveKindMap[
".int"] = DK_INT;
5448 DirectiveKindMap[
".4byte"] = DK_4BYTE;
5449 DirectiveKindMap[
".quad"] = DK_QUAD;
5450 DirectiveKindMap[
".8byte"] = DK_8BYTE;
5451 DirectiveKindMap[
".octa"] = DK_OCTA;
5452 DirectiveKindMap[
".single"] = DK_SINGLE;
5453 DirectiveKindMap[
".float"] = DK_FLOAT;
5454 DirectiveKindMap[
".double"] = DK_DOUBLE;
5455 DirectiveKindMap[
".align"] = DK_ALIGN;
5456 DirectiveKindMap[
".align32"] = DK_ALIGN32;
5457 DirectiveKindMap[
".balign"] = DK_BALIGN;
5458 DirectiveKindMap[
".balignw"] = DK_BALIGNW;
5459 DirectiveKindMap[
".balignl"] = DK_BALIGNL;
5460 DirectiveKindMap[
".p2align"] = DK_P2ALIGN;
5461 DirectiveKindMap[
".p2alignw"] = DK_P2ALIGNW;
5462 DirectiveKindMap[
".p2alignl"] = DK_P2ALIGNL;
5463 DirectiveKindMap[
".org"] = DK_ORG;
5464 DirectiveKindMap[
".fill"] = DK_FILL;
5465 DirectiveKindMap[
".zero"] = DK_ZERO;
5466 DirectiveKindMap[
".extern"] = DK_EXTERN;
5467 DirectiveKindMap[
".globl"] = DK_GLOBL;
5468 DirectiveKindMap[
".global"] = DK_GLOBAL;
5469 DirectiveKindMap[
".lazy_reference"] = DK_LAZY_REFERENCE;
5470 DirectiveKindMap[
".no_dead_strip"] = DK_NO_DEAD_STRIP;
5471 DirectiveKindMap[
".symbol_resolver"] = DK_SYMBOL_RESOLVER;
5472 DirectiveKindMap[
".private_extern"] = DK_PRIVATE_EXTERN;
5473 DirectiveKindMap[
".reference"] = DK_REFERENCE;
5474 DirectiveKindMap[
".weak_definition"] = DK_WEAK_DEFINITION;
5475 DirectiveKindMap[
".weak_reference"] = DK_WEAK_REFERENCE;
5476 DirectiveKindMap[
".weak_def_can_be_hidden"] = DK_WEAK_DEF_CAN_BE_HIDDEN;
5477 DirectiveKindMap[
".cold"] = DK_COLD;
5478 DirectiveKindMap[
".comm"] = DK_COMM;
5479 DirectiveKindMap[
".common"] = DK_COMMON;
5480 DirectiveKindMap[
".lcomm"] = DK_LCOMM;
5481 DirectiveKindMap[
".abort"] = DK_ABORT;
5482 DirectiveKindMap[
".include"] = DK_INCLUDE;
5483 DirectiveKindMap[
".incbin"] = DK_INCBIN;
5484 DirectiveKindMap[
".code16"] = DK_CODE16;
5485 DirectiveKindMap[
".code16gcc"] = DK_CODE16GCC;
5486 DirectiveKindMap[
".rept"] = DK_REPT;
5487 DirectiveKindMap[
".rep"] = DK_REPT;
5488 DirectiveKindMap[
".irp"] = DK_IRP;
5489 DirectiveKindMap[
".irpc"] = DK_IRPC;
5490 DirectiveKindMap[
".endr"] = DK_ENDR;
5491 DirectiveKindMap[
".bundle_align_mode"] = DK_BUNDLE_ALIGN_MODE;
5492 DirectiveKindMap[
".bundle_lock"] = DK_BUNDLE_LOCK;
5493 DirectiveKindMap[
".bundle_unlock"] = DK_BUNDLE_UNLOCK;
5494 DirectiveKindMap[
".if"] = DK_IF;
5495 DirectiveKindMap[
".ifeq"] = DK_IFEQ;
5496 DirectiveKindMap[
".ifge"] = DK_IFGE;
5497 DirectiveKindMap[
".ifgt"] = DK_IFGT;
5498 DirectiveKindMap[
".ifle"] = DK_IFLE;
5499 DirectiveKindMap[
".iflt"] = DK_IFLT;
5500 DirectiveKindMap[
".ifne"] = DK_IFNE;
5501 DirectiveKindMap[
".ifb"] = DK_IFB;
5502 DirectiveKindMap[
".ifnb"] = DK_IFNB;
5503 DirectiveKindMap[
".ifc"] = DK_IFC;
5504 DirectiveKindMap[
".ifeqs"] = DK_IFEQS;
5505 DirectiveKindMap[
".ifnc"] = DK_IFNC;
5506 DirectiveKindMap[
".ifnes"] = DK_IFNES;
5507 DirectiveKindMap[
".ifdef"] = DK_IFDEF;
5508 DirectiveKindMap[
".ifndef"] = DK_IFNDEF;
5509 DirectiveKindMap[
".ifnotdef"] = DK_IFNOTDEF;
5510 DirectiveKindMap[
".elseif"] = DK_ELSEIF;
5511 DirectiveKindMap[
".else"] = DK_ELSE;
5512 DirectiveKindMap[
".end"] = DK_END;
5513 DirectiveKindMap[
".endif"] = DK_ENDIF;
5514 DirectiveKindMap[
".skip"] = DK_SKIP;
5515 DirectiveKindMap[
".space"] = DK_SPACE;
5516 DirectiveKindMap[
".file"] = DK_FILE;
5517 DirectiveKindMap[
".line"] = DK_LINE;
5518 DirectiveKindMap[
".loc"] = DK_LOC;
5519 DirectiveKindMap[
".stabs"] = DK_STABS;
5520 DirectiveKindMap[
".cv_file"] = DK_CV_FILE;
5521 DirectiveKindMap[
".cv_func_id"] = DK_CV_FUNC_ID;
5522 DirectiveKindMap[
".cv_loc"] = DK_CV_LOC;
5523 DirectiveKindMap[
".cv_linetable"] = DK_CV_LINETABLE;
5524 DirectiveKindMap[
".cv_inline_linetable"] = DK_CV_INLINE_LINETABLE;
5525 DirectiveKindMap[
".cv_inline_site_id"] = DK_CV_INLINE_SITE_ID;
5526 DirectiveKindMap[
".cv_def_range"] = DK_CV_DEF_RANGE;
5527 DirectiveKindMap[
".cv_string"] = DK_CV_STRING;
5528 DirectiveKindMap[
".cv_stringtable"] = DK_CV_STRINGTABLE;
5529 DirectiveKindMap[
".cv_filechecksums"] = DK_CV_FILECHECKSUMS;
5530 DirectiveKindMap[
".cv_filechecksumoffset"] = DK_CV_FILECHECKSUM_OFFSET;
5531 DirectiveKindMap[
".cv_fpo_data"] = DK_CV_FPO_DATA;
5532 DirectiveKindMap[
".sleb128"] = DK_SLEB128;
5533 DirectiveKindMap[
".uleb128"] = DK_ULEB128;
5534 DirectiveKindMap[
".cfi_sections"] = DK_CFI_SECTIONS;
5535 DirectiveKindMap[
".cfi_startproc"] = DK_CFI_STARTPROC;
5536 DirectiveKindMap[
".cfi_endproc"] = DK_CFI_ENDPROC;
5537 DirectiveKindMap[
".cfi_def_cfa"] = DK_CFI_DEF_CFA;
5538 DirectiveKindMap[
".cfi_def_cfa_offset"] = DK_CFI_DEF_CFA_OFFSET;
5539 DirectiveKindMap[
".cfi_adjust_cfa_offset"] = DK_CFI_ADJUST_CFA_OFFSET;
5540 DirectiveKindMap[
".cfi_def_cfa_register"] = DK_CFI_DEF_CFA_REGISTER;
5541 DirectiveKindMap[
".cfi_llvm_def_aspace_cfa"] = DK_CFI_LLVM_DEF_ASPACE_CFA;
5542 DirectiveKindMap[
".cfi_offset"] = DK_CFI_OFFSET;
5543 DirectiveKindMap[
".cfi_rel_offset"] = DK_CFI_REL_OFFSET;
5544 DirectiveKindMap[
".cfi_personality"] = DK_CFI_PERSONALITY;
5545 DirectiveKindMap[
".cfi_lsda"] = DK_CFI_LSDA;
5546 DirectiveKindMap[
".cfi_remember_state"] = DK_CFI_REMEMBER_STATE;
5547 DirectiveKindMap[
".cfi_restore_state"] = DK_CFI_RESTORE_STATE;
5548 DirectiveKindMap[
".cfi_same_value"] = DK_CFI_SAME_VALUE;
5549 DirectiveKindMap[
".cfi_restore"] = DK_CFI_RESTORE;
5550 DirectiveKindMap[
".cfi_escape"] = DK_CFI_ESCAPE;
5551 DirectiveKindMap[
".cfi_return_column"] = DK_CFI_RETURN_COLUMN;
5552 DirectiveKindMap[
".cfi_signal_frame"] = DK_CFI_SIGNAL_FRAME;
5553 DirectiveKindMap[
".cfi_undefined"] = DK_CFI_UNDEFINED;
5554 DirectiveKindMap[
".cfi_register"] = DK_CFI_REGISTER;
5555 DirectiveKindMap[
".cfi_window_save"] = DK_CFI_WINDOW_SAVE;
5556 DirectiveKindMap[
".cfi_b_key_frame"] = DK_CFI_B_KEY_FRAME;
5557 DirectiveKindMap[
".cfi_mte_tagged_frame"] = DK_CFI_MTE_TAGGED_FRAME;
5558 DirectiveKindMap[
".macros_on"] = DK_MACROS_ON;
5559 DirectiveKindMap[
".macros_off"] = DK_MACROS_OFF;
5560 DirectiveKindMap[
".macro"] = DK_MACRO;
5561 DirectiveKindMap[
".exitm"] = DK_EXITM;
5562 DirectiveKindMap[
".endm"] = DK_ENDM;
5563 DirectiveKindMap[
".endmacro"] = DK_ENDMACRO;
5564 DirectiveKindMap[
".purgem"] = DK_PURGEM;
5565 DirectiveKindMap[
".err"] = DK_ERR;
5566 DirectiveKindMap[
".error"] = DK_ERROR;
5567 DirectiveKindMap[
".warning"] = DK_WARNING;
5568 DirectiveKindMap[
".altmacro"] = DK_ALTMACRO;
5569 DirectiveKindMap[
".noaltmacro"] = DK_NOALTMACRO;
5570 DirectiveKindMap[
".reloc"