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(
SMLoc DirectiveLoc);
605 bool parseDirectiveCFISections();
606 bool parseDirectiveCFIStartProc();
607 bool parseDirectiveCFIEndProc();
608 bool parseDirectiveCFIDefCfaOffset(
SMLoc DirectiveLoc);
609 bool parseDirectiveCFIDefCfa(
SMLoc DirectiveLoc);
610 bool parseDirectiveCFIAdjustCfaOffset(
SMLoc DirectiveLoc);
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(
SMLoc DirectiveLoc);
617 bool parseDirectiveCFIRestoreState(
SMLoc DirectiveLoc);
618 bool parseDirectiveCFISameValue(
SMLoc DirectiveLoc);
619 bool parseDirectiveCFIRestore(
SMLoc DirectiveLoc);
620 bool parseDirectiveCFIEscape(
SMLoc DirectiveLoc);
621 bool parseDirectiveCFIReturnColumn(
SMLoc DirectiveLoc);
622 bool parseDirectiveCFISignalFrame(
SMLoc DirectiveLoc);
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");
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 ParseStatus TPDirectiveReturn = getTargetParser().parseDirective(
ID);
2004 "Should only return Failure iff there was an error");
2012 std::pair<MCAsmParserExtension *, DirectiveHandler> Handler =
2013 ExtensionDirectiveMap.
lookup(IDVal);
2015 return (*Handler.second)(Handler.first, IDVal, IDLoc);
2024 return parseDirectiveSet(IDVal, AssignmentKind::Set);
2026 return parseDirectiveSet(IDVal, AssignmentKind::Equiv);
2027 case DK_LTO_SET_CONDITIONAL:
2028 return parseDirectiveSet(IDVal, AssignmentKind::LTOSetConditional);
2030 return parseDirectiveAscii(IDVal,
false);
2033 return parseDirectiveAscii(IDVal,
true);
2036 return parseDirectiveValue(IDVal, 1);
2042 return parseDirectiveValue(IDVal, 2);
2047 return parseDirectiveValue(IDVal, 4);
2050 return parseDirectiveValue(IDVal, 8);
2052 return parseDirectiveValue(
2053 IDVal, getContext().getAsmInfo()->getCodePointerSize());
2055 return parseDirectiveOctaValue(IDVal);
2059 return parseDirectiveRealValue(IDVal, APFloat::IEEEsingle());
2062 return parseDirectiveRealValue(IDVal, APFloat::IEEEdouble());
2064 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes();
2065 return parseDirectiveAlign(IsPow2, 1);
2068 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes();
2069 return parseDirectiveAlign(IsPow2, 4);
2072 return parseDirectiveAlign(
false, 1);
2074 return parseDirectiveAlign(
false, 2);
2076 return parseDirectiveAlign(
false, 4);
2078 return parseDirectiveAlign(
true, 1);
2080 return parseDirectiveAlign(
true, 2);
2082 return parseDirectiveAlign(
true, 4);
2084 return parseDirectiveOrg();
2086 return parseDirectiveFill();
2088 return parseDirectiveZero();
2090 eatToEndOfStatement();
2094 return parseDirectiveSymbolAttribute(
MCSA_Global);
2095 case DK_LAZY_REFERENCE:
2097 case DK_NO_DEAD_STRIP:
2099 case DK_SYMBOL_RESOLVER:
2101 case DK_PRIVATE_EXTERN:
2105 case DK_WEAK_DEFINITION:
2107 case DK_WEAK_REFERENCE:
2109 case DK_WEAK_DEF_CAN_BE_HIDDEN:
2112 return parseDirectiveSymbolAttribute(
MCSA_Cold);
2115 return parseDirectiveComm(
false);
2117 return parseDirectiveComm(
true);
2119 return parseDirectiveAbort();
2121 return parseDirectiveInclude();
2123 return parseDirectiveIncbin();
2126 return TokError(
Twine(IDVal) +
2127 " not currently supported for this target");
2129 return parseDirectiveRept(IDLoc, IDVal);
2131 return parseDirectiveIrp(IDLoc);
2133 return parseDirectiveIrpc(IDLoc);
2135 return parseDirectiveEndr(IDLoc);
2136 case DK_BUNDLE_ALIGN_MODE:
2137 return parseDirectiveBundleAlignMode();
2138 case DK_BUNDLE_LOCK:
2139 return parseDirectiveBundleLock();
2140 case DK_BUNDLE_UNLOCK:
2141 return parseDirectiveBundleUnlock();
2143 return parseDirectiveLEB128(
true);
2145 return parseDirectiveLEB128(
false);
2148 return parseDirectiveSpace(IDVal);
2150 return parseDirectiveFile(IDLoc);
2152 return parseDirectiveLine();
2154 return parseDirectiveLoc();
2156 return parseDirectiveStabs();
2158 return parseDirectiveCVFile();
2160 return parseDirectiveCVFuncId();
2161 case DK_CV_INLINE_SITE_ID:
2162 return parseDirectiveCVInlineSiteId();
2164 return parseDirectiveCVLoc();
2165 case DK_CV_LINETABLE:
2166 return parseDirectiveCVLinetable();
2167 case DK_CV_INLINE_LINETABLE:
2168 return parseDirectiveCVInlineLinetable();
2169 case DK_CV_DEF_RANGE:
2170 return parseDirectiveCVDefRange();
2172 return parseDirectiveCVString();
2173 case DK_CV_STRINGTABLE:
2174 return parseDirectiveCVStringTable();
2175 case DK_CV_FILECHECKSUMS:
2176 return parseDirectiveCVFileChecksums();
2177 case DK_CV_FILECHECKSUM_OFFSET:
2178 return parseDirectiveCVFileChecksumOffset();
2179 case DK_CV_FPO_DATA:
2180 return parseDirectiveCVFPOData();
2181 case DK_CFI_SECTIONS:
2182 return parseDirectiveCFISections();
2183 case DK_CFI_STARTPROC:
2184 return parseDirectiveCFIStartProc();
2185 case DK_CFI_ENDPROC:
2186 return parseDirectiveCFIEndProc();
2187 case DK_CFI_DEF_CFA:
2188 return parseDirectiveCFIDefCfa(IDLoc);
2189 case DK_CFI_DEF_CFA_OFFSET:
2190 return parseDirectiveCFIDefCfaOffset(IDLoc);
2191 case DK_CFI_ADJUST_CFA_OFFSET:
2192 return parseDirectiveCFIAdjustCfaOffset(IDLoc);
2193 case DK_CFI_DEF_CFA_REGISTER:
2194 return parseDirectiveCFIDefCfaRegister(IDLoc);
2195 case DK_CFI_LLVM_DEF_ASPACE_CFA:
2196 return parseDirectiveCFILLVMDefAspaceCfa(IDLoc);
2198 return parseDirectiveCFIOffset(IDLoc);
2199 case DK_CFI_REL_OFFSET:
2200 return parseDirectiveCFIRelOffset(IDLoc);
2201 case DK_CFI_PERSONALITY:
2202 return parseDirectiveCFIPersonalityOrLsda(
true);
2204 return parseDirectiveCFIPersonalityOrLsda(
false);
2205 case DK_CFI_REMEMBER_STATE:
2206 return parseDirectiveCFIRememberState(IDLoc);
2207 case DK_CFI_RESTORE_STATE:
2208 return parseDirectiveCFIRestoreState(IDLoc);
2209 case DK_CFI_SAME_VALUE:
2210 return parseDirectiveCFISameValue(IDLoc);
2211 case DK_CFI_RESTORE:
2212 return parseDirectiveCFIRestore(IDLoc);
2214 return parseDirectiveCFIEscape(IDLoc);
2215 case DK_CFI_RETURN_COLUMN:
2216 return parseDirectiveCFIReturnColumn(IDLoc);
2217 case DK_CFI_SIGNAL_FRAME:
2218 return parseDirectiveCFISignalFrame(IDLoc);
2219 case DK_CFI_UNDEFINED:
2220 return parseDirectiveCFIUndefined(IDLoc);
2221 case DK_CFI_REGISTER:
2222 return parseDirectiveCFIRegister(IDLoc);
2223 case DK_CFI_WINDOW_SAVE:
2224 return parseDirectiveCFIWindowSave(IDLoc);
2227 return parseDirectiveMacrosOnOff(IDVal);
2229 return parseDirectiveMacro(IDLoc);
2232 return parseDirectiveAltmacro(IDVal);
2234 return parseDirectiveExitMacro(IDVal);
2237 return parseDirectiveEndMacro(IDVal);
2239 return parseDirectivePurgeMacro(IDLoc);
2241 return parseDirectiveEnd(IDLoc);
2243 return parseDirectiveError(IDLoc,
false);
2245 return parseDirectiveError(IDLoc,
true);
2247 return parseDirectiveWarning(IDLoc);
2249 return parseDirectiveReloc(IDLoc);
2252 return parseDirectiveDCB(IDVal, 2);
2254 return parseDirectiveDCB(IDVal, 1);
2256 return parseDirectiveRealDCB(IDVal, APFloat::IEEEdouble());
2258 return parseDirectiveDCB(IDVal, 4);
2260 return parseDirectiveRealDCB(IDVal, APFloat::IEEEsingle());
2263 return TokError(
Twine(IDVal) +
2264 " not currently supported for this target");
2267 return parseDirectiveDS(IDVal, 2);
2269 return parseDirectiveDS(IDVal, 1);
2271 return parseDirectiveDS(IDVal, 8);
2274 return parseDirectiveDS(IDVal, 4);
2277 return parseDirectiveDS(IDVal, 12);
2279 return parseDirectivePrint(IDLoc);
2281 return parseDirectiveAddrsig();
2282 case DK_ADDRSIG_SYM:
2283 return parseDirectiveAddrsigSym();
2284 case DK_PSEUDO_PROBE:
2285 return parseDirectivePseudoProbe();
2286 case DK_LTO_DISCARD:
2287 return parseDirectiveLTODiscard();
2289 return parseDirectiveSymbolAttribute(
MCSA_Memtag);
2292 return Error(IDLoc,
"unknown directive");
2296 if (ParsingMSInlineAsm && (IDVal ==
"_emit" || IDVal ==
"__emit" ||
2297 IDVal ==
"_EMIT" || IDVal ==
"__EMIT"))
2298 return parseDirectiveMSEmit(IDLoc, Info, IDVal.
size());
2301 if (ParsingMSInlineAsm && (IDVal ==
"align" || IDVal ==
"ALIGN"))
2302 return parseDirectiveMSAlign(IDLoc, Info);
2304 if (ParsingMSInlineAsm && (IDVal ==
"even" || IDVal ==
"EVEN"))
2306 if (checkForValidSection())
2309 return parseAndMatchAndEmitTargetInstruction(Info, IDVal,
ID, IDLoc);
2312bool AsmParser::parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &Info,
2317 std::string OpcodeStr = IDVal.
lower();
2319 bool ParseHadError = getTargetParser().ParseInstruction(IInfo, OpcodeStr,
ID,
2320 Info.ParsedOperands);
2321 Info.ParseError = ParseHadError;
2324 if (getShowParsedOperands()) {
2327 OS <<
"parsed instruction: [";
2328 for (
unsigned i = 0; i !=
Info.ParsedOperands.size(); ++i) {
2331 Info.ParsedOperands[i]->print(
OS);
2339 if (hasPendingError() || ParseHadError)
2344 if (!ParseHadError && enabledGenDwarfForAssembly() &&
2345 getContext().getGenDwarfSectionSyms().
count(
2346 getStreamer().getCurrentSectionOnly())) {
2348 if (ActiveMacros.empty())
2352 ActiveMacros.front()->ExitBuffer);
2357 if (!CppHashInfo.Filename.empty()) {
2358 unsigned FileNumber = getStreamer().emitDwarfFileDirective(
2360 getContext().setGenDwarfFileNumber(FileNumber);
2362 unsigned CppHashLocLineNo =
2364 Line = CppHashInfo.LineNumber - 1 + (
Line - CppHashLocLineNo);
2367 getStreamer().emitDwarfLocDirective(
2368 getContext().getGenDwarfFileNumber(), Line, 0,
2374 if (!ParseHadError) {
2376 if (getTargetParser().MatchAndEmitInstruction(
2378 getTargetParser().isParsingMSInlineAsm()))
2404bool AsmParser::parseCppHashLineFilenameComment(
SMLoc L,
bool SaveLocInfo) {
2409 "Lexing Cpp line comment: Expected Integer");
2410 int64_t LineNumber = getTok().getIntVal();
2413 "Lexing Cpp line comment: Expected String");
2425 CppHashInfo.Loc =
L;
2427 CppHashInfo.LineNumber = LineNumber;
2428 CppHashInfo.Buf = CurBuffer;
2429 if (FirstCppHashFilename.
empty())
2436void AsmParser::DiagHandler(
const SMDiagnostic &Diag,
void *Context) {
2437 auto *Parser =
static_cast<AsmParser *
>(
Context);
2443 unsigned CppHashBuf =
2444 Parser->SrcMgr.FindBufferContainingLoc(Parser->CppHashInfo.Loc);
2449 if (!Parser->SavedDiagHandler && DiagCurBuffer &&
2458 if (!Parser->CppHashInfo.LineNumber || DiagBuf != CppHashBuf) {
2459 if (Parser->SavedDiagHandler)
2460 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2462 Parser->getContext().diagnose(Diag);
2469 const std::string &
Filename = std::string(Parser->CppHashInfo.Filename);
2472 int CppHashLocLineNo =
2473 Parser->SrcMgr.FindLineNumber(Parser->CppHashInfo.Loc, CppHashBuf);
2475 Parser->CppHashInfo.LineNumber - 1 + (DiagLocLineNo - CppHashLocLineNo);
2481 if (Parser->SavedDiagHandler)
2482 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2484 Parser->getContext().diagnose(NewDiag);
2492 return isalnum(
static_cast<unsigned char>(c)) || c ==
'_' || c ==
'$' ||
2499 bool EnableAtPseudoVariable,
SMLoc L) {
2500 unsigned NParameters = Parameters.
size();
2501 bool HasVararg = NParameters ? Parameters.
back().Vararg :
false;
2502 if ((!IsDarwin || NParameters != 0) && NParameters !=
A.size())
2503 return Error(L,
"Wrong number of arguments");
2507 while (!Body.
empty()) {
2509 std::size_t
End = Body.
size(), Pos = 0;
2510 for (; Pos !=
End; ++Pos) {
2512 if (IsDarwin && !NParameters) {
2514 if (Body[Pos] !=
'$' || Pos + 1 ==
End)
2517 char Next = Body[Pos + 1];
2518 if (Next ==
'$' || Next ==
'n' ||
2519 isdigit(
static_cast<unsigned char>(Next)))
2523 if (Body[Pos] ==
'\\' && Pos + 1 !=
End)
2535 if (IsDarwin && !NParameters) {
2536 switch (Body[Pos + 1]) {
2550 unsigned Index = Body[Pos + 1] -
'0';
2556 OS << Token.getString();
2562 unsigned I = Pos + 1;
2565 if (EnableAtPseudoVariable && Body[
I] ==
'@' &&
I + 1 !=
End)
2571 const char *Begin = Body.
data() + Pos + 1;
2576 OS << NumOfMacroInstantiations;
2583 if (
Index == NParameters) {
2584 if (Body[Pos + 1] ==
'(' && Body[Pos + 2] ==
')')
2591 bool VarargParameter = HasVararg &&
Index == (NParameters - 1);
2600 if (AltMacroMode && Token.getString().front() ==
'%' &&
2603 OS << Token.getIntVal();
2606 else if (AltMacroMode && Token.getString().front() ==
'<' &&
2613 OS << Token.getString();
2615 OS << Token.getStringContents();
2660class AsmLexerSkipSpaceRAII {
2662 AsmLexerSkipSpaceRAII(
AsmLexer &Lexer,
bool SkipSpace) : Lexer(Lexer) {
2666 ~AsmLexerSkipSpaceRAII() {
2676bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA,
bool Vararg) {
2680 StringRef Str = parseStringToEndOfStatement();
2686 unsigned ParenLevel = 0;
2689 AsmLexerSkipSpaceRAII ScopedSkipSpace(Lexer, IsDarwin);
2696 return TokError(
"unexpected token in macro instantiation");
2698 if (ParenLevel == 0) {
2713 MA.push_back(getTok());
2739 MA.push_back(getTok());
2743 if (ParenLevel != 0)
2744 return TokError(
"unbalanced parentheses in macro argument");
2749bool AsmParser::parseMacroArguments(
const MCAsmMacro *M,
2750 MCAsmMacroArguments &
A) {
2751 const unsigned NParameters =
M ?
M->Parameters.size() : 0;
2752 bool NamedParametersFound =
false;
2755 A.resize(NParameters);
2756 FALocs.
resize(NParameters);
2761 bool HasVararg = NParameters ?
M->Parameters.back().Vararg :
false;
2762 for (
unsigned Parameter = 0; !NParameters || Parameter < NParameters;
2768 if (parseIdentifier(FA.
Name))
2769 return Error(IDLoc,
"invalid argument identifier for formal argument");
2772 return TokError(
"expected '=' after formal parameter identifier");
2776 NamedParametersFound =
true;
2778 bool Vararg = HasVararg && Parameter == (NParameters - 1);
2780 if (NamedParametersFound && FA.
Name.
empty())
2781 return Error(IDLoc,
"cannot mix positional and keyword arguments");
2786 const MCExpr *AbsoluteExp;
2790 if (parseExpression(AbsoluteExp, EndLoc))
2792 if (!AbsoluteExp->evaluateAsAbsolute(
Value,
2793 getStreamer().getAssemblerPtr()))
2794 return Error(StrLoc,
"expected absolute expression");
2799 FA.
Value.push_back(newToken);
2804 jumpToLoc(EndLoc, CurBuffer);
2809 FA.
Value.push_back(newToken);
2810 }
else if(parseMacroArgument(FA.
Value, Vararg))
2813 unsigned PI = Parameter;
2816 for (FAI = 0; FAI < NParameters; ++FAI)
2817 if (
M->Parameters[FAI].Name == FA.
Name)
2820 if (FAI >= NParameters) {
2821 assert(M &&
"expected macro to be defined");
2822 return Error(IDLoc,
"parameter named '" + FA.
Name +
2823 "' does not exist for macro '" +
M->Name +
"'");
2828 if (!FA.
Value.empty()) {
2833 if (FALocs.
size() <= PI)
2836 FALocs[PI] = Lexer.
getLoc();
2844 for (
unsigned FAI = 0; FAI < NParameters; ++FAI) {
2845 if (
A[FAI].empty()) {
2846 if (
M->Parameters[FAI].Required) {
2848 "missing value for required parameter "
2849 "'" +
M->Parameters[FAI].Name +
"' in macro '" +
M->Name +
"'");
2853 if (!
M->Parameters[FAI].Value.empty())
2854 A[FAI] =
M->Parameters[FAI].Value;
2864 return TokError(
"too many positional arguments");
2871 if (ActiveMacros.size() == MaxNestingDepth) {
2872 std::ostringstream MaxNestingDepthError;
2873 MaxNestingDepthError <<
"macros cannot be nested more than "
2874 << MaxNestingDepth <<
" levels deep."
2875 <<
" Use -asm-macro-max-nesting-depth to increase "
2877 return TokError(MaxNestingDepthError.str());
2880 MCAsmMacroArguments
A;
2881 if (parseMacroArguments(M,
A))
2890 if (expandMacro(
OS, Body,
M->Parameters,
A,
true, getTok().getLoc()))
2895 OS <<
".endmacro\n";
2897 std::unique_ptr<MemoryBuffer> Instantiation =
2902 MacroInstantiation *
MI =
new MacroInstantiation{
2903 NameLoc, CurBuffer, getTok().getLoc(), TheCondStack.size()};
2904 ActiveMacros.push_back(
MI);
2906 ++NumOfMacroInstantiations;
2916void AsmParser::handleMacroExit() {
2918 jumpToLoc(ActiveMacros.back()->ExitLoc, ActiveMacros.back()->ExitBuffer);
2922 delete ActiveMacros.back();
2923 ActiveMacros.pop_back();
2926bool AsmParser::parseAssignment(
StringRef Name, AssignmentKind Kind) {
2929 SMLoc ExprLoc = getTok().getLoc();
2931 Kind == AssignmentKind::Set ||
Kind == AssignmentKind::Equal;
2943 if (discardLTOSymbol(
Name))
2948 case AssignmentKind::Equal:
2951 case AssignmentKind::Set:
2952 case AssignmentKind::Equiv:
2956 case AssignmentKind::LTOSetConditional:
2958 return Error(ExprLoc,
"expected identifier");
2970bool AsmParser::parseIdentifier(
StringRef &Res) {
2977 SMLoc PrefixLoc = getLexer().getLoc();
2989 if (PrefixLoc.
getPointer() + 1 != Buf[0].getLoc().getPointer())
3003 Res = getTok().getIdentifier();
3015bool AsmParser::parseDirectiveSet(
StringRef IDVal, AssignmentKind Kind) {
3017 if (
check(parseIdentifier(
Name),
"expected identifier") || parseComma() ||
3018 parseAssignment(
Name, Kind))
3023bool AsmParser::parseEscapedString(std::string &
Data) {
3028 StringRef Str = getTok().getStringContents();
3029 for (
unsigned i = 0, e = Str.size(); i != e; ++i) {
3030 if (Str[i] !=
'\\') {
3039 return TokError(
"unexpected backslash at end of string");
3042 if (Str[i] ==
'x' || Str[i] ==
'X') {
3043 size_t length = Str.size();
3044 if (i + 1 >= length || !
isHexDigit(Str[i + 1]))
3045 return TokError(
"invalid hexadecimal escape sequence");
3050 while (i + 1 < length &&
isHexDigit(Str[i + 1]))
3051 Value =
Value * 16 + hexDigitValue(Str[++i]);
3058 if ((
unsigned)(Str[i] -
'0') <= 7) {
3060 unsigned Value = Str[i] -
'0';
3062 if (i + 1 != e && ((
unsigned)(Str[i + 1] -
'0')) <= 7) {
3066 if (i + 1 != e && ((
unsigned)(Str[i + 1] -
'0')) <= 7) {
3073 return TokError(
"invalid octal escape sequence (out of range)");
3083 return TokError(
"invalid escape sequence (unrecognized character)");
3085 case 'b':
Data +=
'\b';
break;
3086 case 'f':
Data +=
'\f';
break;
3087 case 'n':
Data +=
'\n';
break;
3088 case 'r':
Data +=
'\r';
break;
3089 case 't':
Data +=
'\t';
break;
3090 case '"':
Data +=
'"';
break;
3091 case '\\':
Data +=
'\\';
break;
3099bool AsmParser::parseAngleBracketString(std::string &
Data) {
3100 SMLoc EndLoc, StartLoc = getTok().getLoc();
3102 const char *StartChar = StartLoc.
getPointer() + 1;
3103 const char *EndChar = EndLoc.
getPointer() - 1;
3104 jumpToLoc(EndLoc, CurBuffer);
3117bool AsmParser::parseDirectiveAscii(
StringRef IDVal,
bool ZeroTerminated) {
3118 auto parseOp = [&]() ->
bool {
3120 if (checkForValidSection())
3125 if (parseEscapedString(
Data))
3127 getStreamer().emitBytes(
Data);
3130 getStreamer().emitBytes(
StringRef(
"\0", 1));
3134 return parseMany(parseOp);
3139bool AsmParser::parseDirectiveReloc(
SMLoc DirectiveLoc) {
3141 const MCExpr *Expr =
nullptr;
3144 if (parseExpression(
Offset))
3157 if (parseExpression(Expr))
3162 return Error(ExprLoc,
"expression must be relocatable");
3170 if (std::optional<std::pair<bool, std::string>> Err =
3171 getStreamer().emitRelocDirective(*
Offset,
Name, Expr, DirectiveLoc,
3173 return Error(Err->first ? NameLoc : OffsetLoc, Err->second);
3180bool AsmParser::parseDirectiveValue(
StringRef IDVal,
unsigned Size) {
3181 auto parseOp = [&]() ->
bool {
3183 SMLoc ExprLoc = getLexer().getLoc();
3184 if (checkForValidSection() || parseExpression(
Value))
3189 uint64_t IntValue = MCE->getValue();
3191 return Error(ExprLoc,
"out of range literal value");
3192 getStreamer().emitIntValue(IntValue,
Size);
3194 getStreamer().emitValue(
Value,
Size, ExprLoc);
3198 return parseMany(parseOp);
3204 return Asm.TokError(
"unknown token in expression");
3205 SMLoc ExprLoc = Asm.getTok().getLoc();
3206 APInt IntValue = Asm.getTok().getAPIntVal();
3208 if (!IntValue.
isIntN(128))
3209 return Asm.Error(ExprLoc,
"out of range literal value");
3210 if (!IntValue.
isIntN(64)) {
3223bool AsmParser::parseDirectiveOctaValue(
StringRef IDVal) {
3224 auto parseOp = [&]() ->
bool {
3225 if (checkForValidSection())
3231 getStreamer().emitInt64(lo);
3232 getStreamer().emitInt64(hi);
3234 getStreamer().emitInt64(hi);
3235 getStreamer().emitInt64(lo);
3240 return parseMany(parseOp);
3254 return TokError(Lexer.
getErr());
3257 return TokError(
"unexpected token in directive");
3269 return TokError(
"invalid floating point literal");
3271 Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven)
3273 return TokError(
"invalid floating point literal");
3280 Res =
Value.bitcastToAPInt();
3287bool AsmParser::parseDirectiveRealValue(
StringRef IDVal,
3289 auto parseOp = [&]() ->
bool {
3291 if (checkForValidSection() || parseRealValue(Semantics, AsInt))
3298 return parseMany(parseOp);
3303bool AsmParser::parseDirectiveZero() {
3306 if (checkForValidSection() || parseExpression(NumBytes))
3312 if (parseAbsoluteExpression(Val))
3318 getStreamer().emitFill(*NumBytes, Val, NumBytesLoc);
3325bool AsmParser::parseDirectiveFill() {
3328 if (checkForValidSection() || parseExpression(NumValues))
3331 int64_t FillSize = 1;
3332 int64_t FillExpr = 0;
3334 SMLoc SizeLoc, ExprLoc;
3337 SizeLoc = getTok().getLoc();
3338 if (parseAbsoluteExpression(FillSize))
3341 ExprLoc = getTok().getLoc();
3342 if (parseAbsoluteExpression(FillExpr))
3350 Warning(SizeLoc,
"'.fill' directive with negative size has no effect");
3354 Warning(SizeLoc,
"'.fill' directive with size greater than 8 has been truncated to 8");
3358 if (!isUInt<32>(FillExpr) && FillSize > 4)
3359 Warning(ExprLoc,
"'.fill' directive pattern has been truncated to 32-bits");
3361 getStreamer().emitFill(*NumValues, FillSize, FillExpr, NumValuesLoc);
3368bool AsmParser::parseDirectiveOrg() {
3371 if (checkForValidSection() || parseExpression(
Offset))
3375 int64_t FillExpr = 0;
3377 if (parseAbsoluteExpression(FillExpr))
3382 getStreamer().emitValueToOffset(
Offset, FillExpr, OffsetLoc);
3388bool AsmParser::parseDirectiveAlign(
bool IsPow2,
unsigned ValueSize) {
3389 SMLoc AlignmentLoc = getLexer().getLoc();
3392 bool HasFillExpr =
false;
3393 int64_t FillExpr = 0;
3394 int64_t MaxBytesToFill = 0;
3397 auto parseAlign = [&]() ->
bool {
3398 if (parseAbsoluteExpression(Alignment))
3406 if (parseTokenLoc(FillExprLoc) || parseAbsoluteExpression(FillExpr))
3410 if (parseTokenLoc(MaxBytesLoc) ||
3411 parseAbsoluteExpression(MaxBytesToFill))
3417 if (checkForValidSection())
3421 Warning(AlignmentLoc,
"p2align directive with no operand(s) is ignored");
3428 bool ReturnVal =
false;
3433 if (Alignment >= 32) {
3434 ReturnVal |=
Error(AlignmentLoc,
"invalid alignment value");
3438 Alignment = 1ULL << Alignment;
3446 ReturnVal |=
Error(AlignmentLoc,
"alignment must be a power of 2");
3447 Alignment = llvm::bit_floor<uint64_t>(Alignment);
3449 if (!isUInt<32>(Alignment)) {
3450 ReturnVal |=
Error(AlignmentLoc,
"alignment must be smaller than 2**32");
3451 Alignment = 1u << 31;
3456 MCSection *Sec = getStreamer().getCurrentSectionOnly();
3459 Warning(FillExprLoc,
"ignoring non-zero fill value in " +
3468 if (MaxBytesToFill < 1) {
3469 ReturnVal |=
Error(MaxBytesLoc,
3470 "alignment directive can never be satisfied in this "
3471 "many bytes, ignoring maximum bytes expression");
3475 if (MaxBytesToFill >= Alignment) {
3476 Warning(MaxBytesLoc,
"maximum bytes expression exceeds alignment and "
3485 assert(Section &&
"must have section to emit alignment");
3486 bool useCodeAlign =
Section->useCodeAlign();
3487 if ((!HasFillExpr || Lexer.getMAI().getTextAlignFillValue() == FillExpr) &&
3488 ValueSize == 1 && useCodeAlign) {
3489 getStreamer().emitCodeAlignment(
3490 Align(Alignment), &getTargetParser().getSTI(), MaxBytesToFill);
3493 getStreamer().emitValueToAlignment(
Align(Alignment), FillExpr, ValueSize,
3503bool AsmParser::parseDirectiveFile(
SMLoc DirectiveLoc) {
3505 int64_t FileNumber = -1;
3507 FileNumber = getTok().getIntVal();
3511 return TokError(
"negative file number");
3518 if (parseEscapedString(Path))
3523 std::string FilenameData;
3525 if (
check(FileNumber == -1,
3526 "explicit path specified, but no file number") ||
3527 parseEscapedString(FilenameData))
3536 bool HasMD5 =
false;
3538 std::optional<StringRef>
Source;
3539 bool HasSource =
false;
3540 std::string SourceString;
3545 "unexpected token in '.file' directive") ||
3546 parseIdentifier(Keyword))
3548 if (Keyword ==
"md5") {
3550 if (
check(FileNumber == -1,
3551 "MD5 checksum specified, but no file number") ||
3554 }
else if (Keyword ==
"source") {
3556 if (
check(FileNumber == -1,
3557 "source specified, but no file number") ||
3559 "unexpected token in '.file' directive") ||
3560 parseEscapedString(SourceString))
3563 return TokError(
"unexpected token in '.file' directive");
3567 if (FileNumber == -1) {
3571 if (getContext().getAsmInfo()->hasSingleParameterDotFile())
3572 getStreamer().emitFileDirective(Filename);
3582 std::optional<MD5::MD5Result> CKMem;
3585 for (
unsigned i = 0; i != 8; ++i) {
3586 Sum[i] = uint8_t(MD5Hi >> ((7 - i) * 8));
3587 Sum[i + 8] = uint8_t(MD5Lo >> ((7 - i) * 8));
3592 char *SourceBuf =
static_cast<char *
>(Ctx.
allocate(SourceString.size()));
3593 memcpy(SourceBuf, SourceString.data(), SourceString.size());
3596 if (FileNumber == 0) {
3600 getStreamer().emitDwarfFile0Directive(Directory, Filename, CKMem, Source);
3603 FileNumber, Directory, Filename, CKMem, Source);
3610 ReportedInconsistentMD5 =
true;
3611 return Warning(DirectiveLoc,
"inconsistent use of MD5 checksums");
3620bool AsmParser::parseDirectiveLine() {
3623 if (parseIntToken(LineNumber,
"unexpected token in '.line' directive"))
3638bool AsmParser::parseDirectiveLoc() {
3639 int64_t FileNumber = 0, LineNumber = 0;
3640 SMLoc Loc = getTok().getLoc();
3641 if (parseIntToken(FileNumber,
"unexpected token in '.loc' directive") ||
3643 "file number less than one in '.loc' directive") ||
3644 check(!getContext().isValidDwarfFileNumber(FileNumber), Loc,
3645 "unassigned file number in '.loc' directive"))
3650 LineNumber = getTok().getIntVal();
3652 return TokError(
"line number less than zero in '.loc' directive");
3656 int64_t ColumnPos = 0;
3658 ColumnPos = getTok().getIntVal();
3660 return TokError(
"column position less than zero in '.loc' directive");
3664 auto PrevFlags = getContext().getCurrentDwarfLoc().getFlags();
3669 auto parseLocOp = [&]() ->
bool {
3671 SMLoc Loc = getTok().getLoc();
3672 if (parseIdentifier(
Name))
3673 return TokError(
"unexpected token in '.loc' directive");
3675 if (
Name ==
"basic_block")
3677 else if (
Name ==
"prologue_end")
3679 else if (
Name ==
"epilogue_begin")
3681 else if (
Name ==
"is_stmt") {
3682 Loc = getTok().getLoc();
3684 if (parseExpression(
Value))
3688 int Value = MCE->getValue();
3690 Flags &= ~DWARF2_FLAG_IS_STMT;
3691 else if (
Value == 1)
3694 return Error(Loc,
"is_stmt value not 0 or 1");
3696 return Error(Loc,
"is_stmt value not the constant value of 0 or 1");
3698 }
else if (
Name ==
"isa") {
3699 Loc = getTok().getLoc();
3701 if (parseExpression(
Value))
3705 int Value = MCE->getValue();
3707 return Error(Loc,
"isa number less than zero");
3710 return Error(Loc,
"isa number not a constant value");
3712 }
else if (
Name ==
"discriminator") {
3713 if (parseAbsoluteExpression(Discriminator))
3716 return Error(Loc,
"unknown sub-directive in '.loc' directive");
3721 if (parseMany(parseLocOp,
false ))
3724 getStreamer().emitDwarfLocDirective(FileNumber, LineNumber, ColumnPos, Flags,
3732bool AsmParser::parseDirectiveStabs() {
3733 return TokError(
"unsupported directive '.stabs'");
3738bool AsmParser::parseDirectiveCVFile() {
3739 SMLoc FileNumberLoc = getTok().getLoc();
3742 std::string Checksum;
3745 if (parseIntToken(FileNumber,
3746 "expected file number in '.cv_file' directive") ||
3747 check(FileNumber < 1, FileNumberLoc,
"file number less than one") ||
3749 "unexpected token in '.cv_file' directive") ||
3750 parseEscapedString(Filename))
3754 "unexpected token in '.cv_file' directive") ||
3755 parseEscapedString(Checksum) ||
3756 parseIntToken(ChecksumKind,
3757 "expected checksum kind in '.cv_file' directive") ||
3762 Checksum = fromHex(Checksum);
3763 void *CKMem = Ctx.
allocate(Checksum.size(), 1);
3764 memcpy(CKMem, Checksum.data(), Checksum.size());
3768 if (!getStreamer().emitCVFileDirective(FileNumber, Filename, ChecksumAsBytes,
3769 static_cast<uint8_t
>(ChecksumKind)))
3770 return Error(FileNumberLoc,
"file number already allocated");
3775bool AsmParser::parseCVFunctionId(int64_t &FunctionId,
3778 return parseTokenLoc(Loc) ||
3779 parseIntToken(FunctionId,
"expected function id in '" + DirectiveName +
3781 check(FunctionId < 0 || FunctionId >= UINT_MAX, Loc,
3782 "expected function id within range [0, UINT_MAX)");
3785bool AsmParser::parseCVFileId(int64_t &FileNumber,
StringRef DirectiveName) {
3787 return parseTokenLoc(Loc) ||
3788 parseIntToken(FileNumber,
"expected integer in '" + DirectiveName +
3790 check(FileNumber < 1, Loc,
"file number less than one in '" +
3791 DirectiveName +
"' directive") ||
3792 check(!getCVContext().isValidFileNumber(FileNumber), Loc,
3793 "unassigned file number in '" + DirectiveName +
"' directive");
3800bool AsmParser::parseDirectiveCVFuncId() {
3801 SMLoc FunctionIdLoc = getTok().getLoc();
3804 if (parseCVFunctionId(FunctionId,
".cv_func_id") || parseEOL())
3807 if (!getStreamer().emitCVFuncIdDirective(FunctionId))
3808 return Error(FunctionIdLoc,
"function id already allocated");
3821bool AsmParser::parseDirectiveCVInlineSiteId() {
3822 SMLoc FunctionIdLoc = getTok().getLoc();
3830 if (parseCVFunctionId(FunctionId,
".cv_inline_site_id"))
3835 getTok().getIdentifier() !=
"within"),
3836 "expected 'within' identifier in '.cv_inline_site_id' directive"))
3841 if (parseCVFunctionId(IAFunc,
".cv_inline_site_id"))
3846 getTok().getIdentifier() !=
"inlined_at"),
3847 "expected 'inlined_at' identifier in '.cv_inline_site_id' "
3853 if (parseCVFileId(IAFile,
".cv_inline_site_id") ||
3854 parseIntToken(IALine,
"expected line number after 'inlined_at'"))
3859 IACol = getTok().getIntVal();
3866 if (!getStreamer().emitCVInlineSiteIdDirective(FunctionId, IAFunc, IAFile,
3867 IALine, IACol, FunctionIdLoc))
3868 return Error(FunctionIdLoc,
"function id already allocated");
3880bool AsmParser::parseDirectiveCVLoc() {
3881 SMLoc DirectiveLoc = getTok().getLoc();
3882 int64_t FunctionId, FileNumber;
3883 if (parseCVFunctionId(FunctionId,
".cv_loc") ||
3884 parseCVFileId(FileNumber,
".cv_loc"))
3887 int64_t LineNumber = 0;
3889 LineNumber = getTok().getIntVal();
3891 return TokError(
"line number less than zero in '.cv_loc' directive");
3895 int64_t ColumnPos = 0;
3897 ColumnPos = getTok().getIntVal();
3899 return TokError(
"column position less than zero in '.cv_loc' directive");
3903 bool PrologueEnd =
false;
3906 auto parseOp = [&]() ->
bool {
3908 SMLoc Loc = getTok().getLoc();
3909 if (parseIdentifier(
Name))
3910 return TokError(
"unexpected token in '.cv_loc' directive");
3911 if (
Name ==
"prologue_end")
3913 else if (
Name ==
"is_stmt") {
3914 Loc = getTok().getLoc();
3916 if (parseExpression(
Value))
3920 if (
const auto *MCE = dyn_cast<MCConstantExpr>(
Value))
3921 IsStmt = MCE->getValue();
3924 return Error(Loc,
"is_stmt value not 0 or 1");
3926 return Error(Loc,
"unknown sub-directive in '.cv_loc' directive");
3931 if (parseMany(parseOp,
false ))
3934 getStreamer().emitCVLocDirective(FunctionId, FileNumber, LineNumber,
3935 ColumnPos, PrologueEnd, IsStmt,
StringRef(),
3942bool AsmParser::parseDirectiveCVLinetable() {
3945 SMLoc Loc = getTok().getLoc();
3946 if (parseCVFunctionId(FunctionId,
".cv_linetable") || parseComma() ||
3947 parseTokenLoc(Loc) ||
3948 check(parseIdentifier(FnStartName), Loc,
3949 "expected identifier in directive") ||
3950 parseComma() || parseTokenLoc(Loc) ||
3951 check(parseIdentifier(FnEndName), Loc,
3952 "expected identifier in directive"))
3955 MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
3956 MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
3958 getStreamer().emitCVLinetableDirective(FunctionId, FnStartSym, FnEndSym);
3964bool AsmParser::parseDirectiveCVInlineLinetable() {
3965 int64_t PrimaryFunctionId, SourceFileId, SourceLineNum;
3967 SMLoc Loc = getTok().getLoc();
3968 if (parseCVFunctionId(PrimaryFunctionId,
".cv_inline_linetable") ||
3969 parseTokenLoc(Loc) ||
3972 "expected SourceField in '.cv_inline_linetable' directive") ||
3973 check(SourceFileId <= 0, Loc,
3974 "File id less than zero in '.cv_inline_linetable' directive") ||
3975 parseTokenLoc(Loc) ||
3978 "expected SourceLineNum in '.cv_inline_linetable' directive") ||
3979 check(SourceLineNum < 0, Loc,
3980 "Line number less than zero in '.cv_inline_linetable' directive") ||
3981 parseTokenLoc(Loc) ||
check(parseIdentifier(FnStartName), Loc,
3982 "expected identifier in directive") ||
3983 parseTokenLoc(Loc) ||
check(parseIdentifier(FnEndName), Loc,
3984 "expected identifier in directive"))
3990 MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
3991 MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
3992 getStreamer().emitCVInlineLinetableDirective(PrimaryFunctionId, SourceFileId,
3993 SourceLineNum, FnStartSym,
3998void AsmParser::initializeCVDefRangeTypeMap() {
3999 CVDefRangeTypeMap[
"reg"] = CVDR_DEFRANGE_REGISTER;
4000 CVDefRangeTypeMap[
"frame_ptr_rel"] = CVDR_DEFRANGE_FRAMEPOINTER_REL;
4001 CVDefRangeTypeMap[
"subfield_reg"] = CVDR_DEFRANGE_SUBFIELD_REGISTER;
4002 CVDefRangeTypeMap[
"reg_rel"] = CVDR_DEFRANGE_REGISTER_REL;
4007bool AsmParser::parseDirectiveCVDefRange() {
4009 std::vector<std::pair<const MCSymbol *, const MCSymbol *>>
Ranges;
4011 Loc = getLexer().getLoc();
4013 if (parseIdentifier(GapStartName))
4014 return Error(Loc,
"expected identifier in directive");
4015 MCSymbol *GapStartSym = getContext().getOrCreateSymbol(GapStartName);
4017 Loc = getLexer().getLoc();
4019 if (parseIdentifier(GapEndName))
4020 return Error(Loc,
"expected identifier in directive");
4021 MCSymbol *GapEndSym = getContext().getOrCreateSymbol(GapEndName);
4023 Ranges.push_back({GapStartSym, GapEndSym});
4029 "expected comma before def_range type in .cv_def_range directive") ||
4030 parseIdentifier(CVDefRangeTypeStr))
4031 return Error(Loc,
"expected def_range type in directive");
4034 CVDefRangeTypeMap.find(CVDefRangeTypeStr);
4035 CVDefRangeType CVDRType = (CVTypeIt == CVDefRangeTypeMap.end())
4037 : CVTypeIt->getValue();
4039 case CVDR_DEFRANGE_REGISTER: {
4041 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4042 ".cv_def_range directive") ||
4043 parseAbsoluteExpression(DRRegister))
4044 return Error(Loc,
"expected register number");
4049 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4052 case CVDR_DEFRANGE_FRAMEPOINTER_REL: {
4055 "expected comma before offset in .cv_def_range directive") ||
4056 parseAbsoluteExpression(DROffset))
4057 return Error(Loc,
"expected offset value");
4061 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4064 case CVDR_DEFRANGE_SUBFIELD_REGISTER: {
4066 int64_t DROffsetInParent;
4067 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4068 ".cv_def_range directive") ||
4069 parseAbsoluteExpression(DRRegister))
4070 return Error(Loc,
"expected register number");
4072 "expected comma before offset in .cv_def_range directive") ||
4073 parseAbsoluteExpression(DROffsetInParent))
4074 return Error(Loc,
"expected offset value");
4080 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4083 case CVDR_DEFRANGE_REGISTER_REL: {
4086 int64_t DRBasePointerOffset;
4087 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4088 ".cv_def_range directive") ||
4089 parseAbsoluteExpression(DRRegister))
4090 return Error(Loc,
"expected register value");
4093 "expected comma before flag value in .cv_def_range directive") ||
4094 parseAbsoluteExpression(DRFlags))
4095 return Error(Loc,
"expected flag value");
4096 if (parseToken(
AsmToken::Comma,
"expected comma before base pointer offset "
4097 "in .cv_def_range directive") ||
4098 parseAbsoluteExpression(DRBasePointerOffset))
4099 return Error(Loc,
"expected base pointer offset value");
4103 DRHdr.
Flags = DRFlags;
4105 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4109 return Error(Loc,
"unexpected def_range type in .cv_def_range directive");
4116bool AsmParser::parseDirectiveCVString() {
4118 if (checkForValidSection() || parseEscapedString(
Data))
4122 std::pair<StringRef, unsigned> Insertion =
4123 getCVContext().addToStringTable(
Data);
4124 getStreamer().emitInt32(Insertion.second);
4130bool AsmParser::parseDirectiveCVStringTable() {
4131 getStreamer().emitCVStringTableDirective();
4137bool AsmParser::parseDirectiveCVFileChecksums() {
4138 getStreamer().emitCVFileChecksumsDirective();
4144bool AsmParser::parseDirectiveCVFileChecksumOffset() {
4146 if (parseIntToken(FileNo,
"expected identifier in directive"))
4150 getStreamer().emitCVFileChecksumOffsetDirective(FileNo);
4156bool AsmParser::parseDirectiveCVFPOData() {
4157 SMLoc DirLoc = getLexer().getLoc();
4159 if (parseIdentifier(ProcName))
4160 return TokError(
"expected symbol name");
4163 MCSymbol *ProcSym = getContext().getOrCreateSymbol(ProcName);
4164 getStreamer().emitCVFPOData(ProcSym, DirLoc);
4170bool AsmParser::parseDirectiveCFISections() {
4177 if (parseIdentifier(
Name))
4178 return TokError(
"expected .eh_frame or .debug_frame");
4179 if (
Name ==
".eh_frame")
4181 else if (
Name ==
".debug_frame")
4189 getStreamer().emitCFISections(EH,
Debug);
4195bool AsmParser::parseDirectiveCFIStartProc() {
4199 "unexpected token") ||
4209 getStreamer().emitCFIStartProc(!
Simple.empty(), Lexer.
getLoc());
4215bool AsmParser::parseDirectiveCFIEndProc() {
4218 getStreamer().emitCFIEndProc();
4223bool AsmParser::parseRegisterOrRegisterNumber(int64_t &
Register,
4224 SMLoc DirectiveLoc) {
4228 if (getTargetParser().parseRegister(RegNo, DirectiveLoc, DirectiveLoc))
4230 Register = getContext().getRegisterInfo()->getDwarfRegNum(RegNo,
true);
4232 return parseAbsoluteExpression(
Register);
4239bool AsmParser::parseDirectiveCFIDefCfa(
SMLoc DirectiveLoc) {
4241 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4242 parseAbsoluteExpression(
Offset) || parseEOL())
4251bool AsmParser::parseDirectiveCFIDefCfaOffset(
SMLoc DirectiveLoc) {
4253 if (parseAbsoluteExpression(
Offset) || parseEOL())
4256 getStreamer().emitCFIDefCfaOffset(
Offset, DirectiveLoc);
4262bool AsmParser::parseDirectiveCFIRegister(
SMLoc DirectiveLoc) {
4263 int64_t Register1 = 0, Register2 = 0;
4264 if (parseRegisterOrRegisterNumber(Register1, DirectiveLoc) || parseComma() ||
4265 parseRegisterOrRegisterNumber(Register2, DirectiveLoc) || parseEOL())
4268 getStreamer().emitCFIRegister(Register1, Register2, DirectiveLoc);
4274bool AsmParser::parseDirectiveCFIWindowSave(
SMLoc DirectiveLoc) {
4277 getStreamer().emitCFIWindowSave(DirectiveLoc);
4283bool AsmParser::parseDirectiveCFIAdjustCfaOffset(
SMLoc DirectiveLoc) {
4284 int64_t Adjustment = 0;
4285 if (parseAbsoluteExpression(Adjustment) || parseEOL())
4288 getStreamer().emitCFIAdjustCfaOffset(Adjustment, DirectiveLoc);
4294bool AsmParser::parseDirectiveCFIDefCfaRegister(
SMLoc DirectiveLoc) {
4296 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4299 getStreamer().emitCFIDefCfaRegister(
Register, DirectiveLoc);
4305bool AsmParser::parseDirectiveCFILLVMDefAspaceCfa(
SMLoc DirectiveLoc) {
4307 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4308 parseAbsoluteExpression(
Offset) || parseComma() ||
4319bool AsmParser::parseDirectiveCFIOffset(
SMLoc DirectiveLoc) {
4323 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4324 parseAbsoluteExpression(
Offset) || parseEOL())
4333bool AsmParser::parseDirectiveCFIRelOffset(
SMLoc DirectiveLoc) {
4336 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4337 parseAbsoluteExpression(
Offset) || parseEOL())
4345 if (Encoding & ~0xff)
4351 const unsigned Format = Encoding & 0xf;
4358 const unsigned Application = Encoding & 0x70;
4370bool AsmParser::parseDirectiveCFIPersonalityOrLsda(
bool IsPersonality) {
4371 int64_t Encoding = 0;
4372 if (parseAbsoluteExpression(Encoding))
4380 check(parseIdentifier(
Name),
"expected identifier in directive") ||
4387 getStreamer().emitCFIPersonality(
Sym, Encoding);
4389 getStreamer().emitCFILsda(
Sym, Encoding);
4395bool AsmParser::parseDirectiveCFIRememberState(
SMLoc DirectiveLoc) {
4398 getStreamer().emitCFIRememberState(DirectiveLoc);
4404bool AsmParser::parseDirectiveCFIRestoreState(
SMLoc DirectiveLoc) {
4407 getStreamer().emitCFIRestoreState(DirectiveLoc);
4413bool AsmParser::parseDirectiveCFISameValue(
SMLoc DirectiveLoc) {
4416 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4419 getStreamer().emitCFISameValue(
Register, DirectiveLoc);
4425bool AsmParser::parseDirectiveCFIRestore(
SMLoc DirectiveLoc) {
4427 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4430 getStreamer().emitCFIRestore(
Register, DirectiveLoc);
4436bool AsmParser::parseDirectiveCFIEscape(
SMLoc DirectiveLoc) {
4439 if (parseAbsoluteExpression(CurrValue))
4442 Values.push_back((uint8_t)CurrValue);
4447 if (parseAbsoluteExpression(CurrValue))
4450 Values.push_back((uint8_t)CurrValue);
4453 getStreamer().emitCFIEscape(Values, DirectiveLoc);
4459bool AsmParser::parseDirectiveCFIReturnColumn(
SMLoc DirectiveLoc) {
4461 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4463 getStreamer().emitCFIReturnColumn(
Register);
4469bool AsmParser::parseDirectiveCFISignalFrame(
SMLoc DirectiveLoc) {
4473 getStreamer().emitCFISignalFrame();
4479bool AsmParser::parseDirectiveCFIUndefined(
SMLoc DirectiveLoc) {
4482 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4485 getStreamer().emitCFIUndefined(
Register, DirectiveLoc);
4495 AltMacroMode = (
Directive ==
".altmacro");
4505 setMacrosEnabled(
Directive ==
".macros_on");
4511bool AsmParser::parseDirectiveMacro(
SMLoc DirectiveLoc) {
4513 if (parseIdentifier(
Name))
4514 return TokError(
"expected identifier in '.macro' directive");
4522 if (!Parameters.empty() && Parameters.back().Vararg)
4523 return Error(Lexer.
getLoc(),
"vararg parameter '" +
4524 Parameters.back().Name +
4525 "' should be the last parameter");
4528 if (parseIdentifier(Parameter.
Name))
4529 return TokError(
"expected identifier in '.macro' directive");
4533 if (CurrParam.Name.equals(Parameter.
Name))
4534 return TokError(
"macro '" +
Name +
"' has multiple parameters"
4535 " named '" + Parameter.
Name +
"'");
4543 QualLoc = Lexer.
getLoc();
4544 if (parseIdentifier(Qualifier))
4545 return Error(QualLoc,
"missing parameter qualifier for "
4546 "'" + Parameter.
Name +
"' in macro '" +
Name +
"'");
4548 if (Qualifier ==
"req")
4550 else if (Qualifier ==
"vararg")
4553 return Error(QualLoc, Qualifier +
" is not a valid parameter qualifier "
4554 "for '" + Parameter.
Name +
"' in macro '" +
Name +
"'");
4562 ParamLoc = Lexer.
getLoc();
4563 if (parseMacroArgument(Parameter.
Value,
false ))
4567 Warning(ParamLoc,
"pointless default value for required parameter "
4568 "'" + Parameter.
Name +
"' in macro '" +
Name +
"'");
4571 Parameters.push_back(std::move(Parameter));
4581 AsmToken EndToken, StartToken = getTok();
4582 unsigned MacroDepth = 0;
4592 return Error(DirectiveLoc,
"no matching '.endmacro' in definition");
4597 if (getTok().getIdentifier() ==
".endm" ||
4598 getTok().getIdentifier() ==
".endmacro") {
4599 if (MacroDepth == 0) {
4600 EndToken = getTok();
4603 return TokError(
"unexpected token in '" + EndToken.
getIdentifier() +
4610 }
else if (getTok().getIdentifier() ==
".macro") {
4616 (void)parseCppHashLineFilenameComment(getLexer().getLoc());
4620 eatToEndOfStatement();
4623 if (getContext().lookupMacro(
Name)) {
4624 return Error(DirectiveLoc,
"macro '" +
Name +
"' is already defined");
4630 checkForBadMacro(DirectiveLoc,
Name, Body, Parameters);
4634 getContext().defineMacro(
Name, std::move(
Macro));
4657 unsigned NParameters = Parameters.
size();
4658 if (NParameters == 0)
4661 bool NamedParametersFound =
false;
4662 bool PositionalParametersFound =
false;
4667 while (!Body.
empty()) {
4669 std::size_t
End = Body.
size(), Pos = 0;
4670 for (; Pos !=
End; ++Pos) {
4673 if (Body[Pos] ==
'\\' && Pos + 1 !=
End)
4677 if (Body[Pos] !=
'$' || Pos + 1 ==
End)
4679 char Next = Body[Pos + 1];
4680 if (Next ==
'$' || Next ==
'n' ||
4681 isdigit(
static_cast<unsigned char>(Next)))
4689 if (Body[Pos] ==
'$') {
4690 switch (Body[Pos + 1]) {
4697 PositionalParametersFound =
true;
4702 PositionalParametersFound =
true;
4708 unsigned I = Pos + 1;
4712 const char *Begin = Body.
data() + Pos + 1;
4719 if (
Index == NParameters) {
4720 if (Body[Pos + 1] ==
'(' && Body[Pos + 2] ==
')')
4726 NamedParametersFound =
true;
4734 if (!NamedParametersFound && PositionalParametersFound)
4735 Warning(DirectiveLoc,
"macro defined with named parameters which are not "
4736 "used in macro body, possible positional parameter "
4737 "found in body which will have no effect");
4746 if (!isInsideMacroInstantiation())
4747 return TokError(
"unexpected '" +
Directive +
"' in file, "
4748 "no current macro definition");
4751 while (TheCondStack.size() != ActiveMacros.back()->CondStackDepth) {
4752 TheCondState = TheCondStack.back();
4753 TheCondStack.pop_back();
4765 return TokError(
"unexpected token in '" +
Directive +
"' directive");
4769 if (isInsideMacroInstantiation()) {
4776 return TokError(
"unexpected '" +
Directive +
"' in file, "
4777 "no current macro definition");
4782bool AsmParser::parseDirectivePurgeMacro(
SMLoc DirectiveLoc) {
4785 if (parseTokenLoc(Loc) ||
4787 "expected identifier in '.purgem' directive") ||
4791 if (!getContext().lookupMacro(
Name))
4792 return Error(DirectiveLoc,
"macro '" +
Name +
"' is not defined");
4794 getContext().undefineMacro(
Name);
4796 <<
"Un-defining macro: " <<
Name <<
"\n");
4802bool AsmParser::parseDirectiveBundleAlignMode() {
4805 SMLoc ExprLoc = getLexer().getLoc();
4806 int64_t AlignSizePow2;
4807 if (checkForValidSection() || parseAbsoluteExpression(AlignSizePow2) ||
4809 check(AlignSizePow2 < 0 || AlignSizePow2 > 30, ExprLoc,
4810 "invalid bundle alignment size (expected between 0 and 30)"))
4813 getStreamer().emitBundleAlignMode(
Align(1ULL << AlignSizePow2));
4819bool AsmParser::parseDirectiveBundleLock() {
4820 if (checkForValidSection())
4822 bool AlignToEnd =
false;
4825 SMLoc Loc = getTok().getLoc();
4826 const char *kInvalidOptionError =
4827 "invalid option for '.bundle_lock' directive";
4830 if (
check(parseIdentifier(Option), Loc, kInvalidOptionError) ||
4831 check(Option !=
"align_to_end", Loc, kInvalidOptionError) || parseEOL())
4836 getStreamer().emitBundleLock(AlignToEnd);
4842bool AsmParser::parseDirectiveBundleUnlock() {
4843 if (checkForValidSection() || parseEOL())
4846 getStreamer().emitBundleUnlock();
4852bool AsmParser::parseDirectiveSpace(
StringRef IDVal) {
4855 if (checkForValidSection() || parseExpression(NumBytes))
4858 int64_t FillExpr = 0;
4860 if (parseAbsoluteExpression(FillExpr))
4866 getStreamer().emitFill(*NumBytes, FillExpr, NumBytesLoc);
4873bool AsmParser::parseDirectiveDCB(
StringRef IDVal,
unsigned Size) {
4876 if (checkForValidSection() || parseAbsoluteExpression(NumValues))
4879 if (NumValues < 0) {
4880 Warning(NumValuesLoc,
"'" +
Twine(IDVal) +
"' directive with negative repeat count has no effect");
4888 SMLoc ExprLoc = getLexer().getLoc();
4889 if (parseExpression(
Value))
4895 uint64_t IntValue = MCE->getValue();
4897 return Error(ExprLoc,
"literal value out of range for directive");
4898 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4899 getStreamer().emitIntValue(IntValue,
Size);
4901 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4902 getStreamer().emitValue(
Value,
Size, ExprLoc);
4913 if (checkForValidSection() || parseAbsoluteExpression(NumValues))
4916 if (NumValues < 0) {
4917 Warning(NumValuesLoc,
"'" +
Twine(IDVal) +
"' directive with negative repeat count has no effect");
4925 if (parseRealValue(Semantics, AsInt) || parseEOL())
4928 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4937bool AsmParser::parseDirectiveDS(
StringRef IDVal,
unsigned Size) {
4940 if (checkForValidSection() || parseAbsoluteExpression(NumValues) ||
4944 if (NumValues < 0) {
4945 Warning(NumValuesLoc,
"'" +
Twine(IDVal) +
"' directive with negative repeat count has no effect");
4949 for (
uint64_t i = 0, e = NumValues; i !=
e; ++i)
4950 getStreamer().emitFill(
Size, 0);
4957bool AsmParser::parseDirectiveLEB128(
bool Signed) {
4958 if (checkForValidSection())
4961 auto parseOp = [&]() ->
bool {
4963 if (parseExpression(
Value))
4966 getStreamer().emitSLEB128Value(
Value);
4968 getStreamer().emitULEB128Value(
Value);
4972 return parseMany(parseOp);
4977bool AsmParser::parseDirectiveSymbolAttribute(
MCSymbolAttr Attr) {
4978 auto parseOp = [&]() ->
bool {
4980 SMLoc Loc = getTok().getLoc();
4981 if (parseIdentifier(
Name))
4982 return Error(Loc,
"expected identifier");
4984 if (discardLTOSymbol(
Name))
4992 return Error(Loc,
"non-local symbol required");
4994 if (!getStreamer().emitSymbolAttribute(
Sym, Attr))
4995 return Error(Loc,
"unable to emit symbol attribute");
4999 return parseMany(parseOp);
5004bool AsmParser::parseDirectiveComm(
bool IsLocal) {
5005 if (checkForValidSection())
5008 SMLoc IDLoc = getLexer().getLoc();
5010 if (parseIdentifier(
Name))
5011 return TokError(
"expected identifier in directive");
5020 SMLoc SizeLoc = getLexer().getLoc();
5021 if (parseAbsoluteExpression(
Size))
5024 int64_t Pow2Alignment = 0;
5025 SMLoc Pow2AlignmentLoc;
5028 Pow2AlignmentLoc = getLexer().getLoc();
5029 if (parseAbsoluteExpression(Pow2Alignment))
5034 return Error(Pow2AlignmentLoc,
"alignment not supported on this target");
5037 if ((!IsLocal && Lexer.getMAI().getCOMMDirectiveAlignmentIsInBytes()) ||
5040 return Error(Pow2AlignmentLoc,
"alignment must be a power of 2");
5041 Pow2Alignment =
Log2_64(Pow2Alignment);
5051 return Error(SizeLoc,
"size must be non-negative");
5053 Sym->redefineIfPossible();
5054 if (!
Sym->isUndefined())
5055 return Error(IDLoc,
"invalid symbol redefinition");
5059 getStreamer().emitLocalCommonSymbol(
Sym,
Size,
5060 Align(1ULL << Pow2Alignment));
5064 getStreamer().emitCommonSymbol(
Sym,
Size,
Align(1ULL << Pow2Alignment));
5070bool AsmParser::parseDirectiveAbort() {
5072 SMLoc Loc = getLexer().getLoc();
5074 StringRef Str = parseStringToEndOfStatement();
5079 return Error(Loc,
".abort detected. Assembly stopping.");
5081 return Error(Loc,
".abort '" + Str +
"' detected. Assembly stopping.");
5089bool AsmParser::parseDirectiveInclude() {
5092 SMLoc IncludeLoc = getTok().getLoc();
5095 "expected string in '.include' directive") ||
5096 parseEscapedString(Filename) ||
5098 "unexpected token in '.include' directive") ||
5101 check(enterIncludeFile(Filename), IncludeLoc,
5102 "Could not find include file '" + Filename +
"'"))
5110bool AsmParser::parseDirectiveIncbin() {
5113 SMLoc IncbinLoc = getTok().getLoc();
5115 "expected string in '.incbin' directive") ||
5116 parseEscapedString(Filename))
5120 const MCExpr *Count =
nullptr;
5121 SMLoc SkipLoc, CountLoc;
5126 if (parseTokenLoc(SkipLoc) || parseAbsoluteExpression(Skip))
5130 CountLoc = getTok().getLoc();
5131 if (parseExpression(Count))
5139 if (
check(Skip < 0, SkipLoc,
"skip is negative"))
5143 if (processIncbinFile(Filename, Skip, Count, CountLoc))
5144 return Error(IncbinLoc,
"Could not find incbin file '" + Filename +
"'");
5150bool AsmParser::parseDirectiveIf(
SMLoc DirectiveLoc, DirectiveKind DirKind) {
5151 TheCondStack.push_back(TheCondState);
5153 if (TheCondState.
Ignore) {
5154 eatToEndOfStatement();
5157 if (parseAbsoluteExpression(ExprValue) || parseEOL())
5167 ExprValue = ExprValue == 0;
5170 ExprValue = ExprValue >= 0;
5173 ExprValue = ExprValue > 0;
5176 ExprValue = ExprValue <= 0;
5179 ExprValue = ExprValue < 0;
5183 TheCondState.
CondMet = ExprValue;
5192bool AsmParser::parseDirectiveIfb(
SMLoc DirectiveLoc,
bool ExpectBlank) {
5193 TheCondStack.push_back(TheCondState);
5196 if (TheCondState.
Ignore) {
5197 eatToEndOfStatement();
5199 StringRef Str = parseStringToEndOfStatement();
5204 TheCondState.
CondMet = ExpectBlank == Str.empty();
5214bool AsmParser::parseDirectiveIfc(
SMLoc DirectiveLoc,
bool ExpectEqual) {
5215 TheCondStack.push_back(TheCondState);
5218 if (TheCondState.
Ignore) {
5219 eatToEndOfStatement();
5226 StringRef Str2 = parseStringToEndOfStatement();
5240bool AsmParser::parseDirectiveIfeqs(
SMLoc DirectiveLoc,
bool ExpectEqual) {
5243 return TokError(
"expected string parameter for '.ifeqs' directive");
5244 return TokError(
"expected string parameter for '.ifnes' directive");
5247 StringRef String1 = getTok().getStringContents();
5253 "expected comma after first string for '.ifeqs' directive");
5254 return TokError(
"expected comma after first string for '.ifnes' directive");
5261 return TokError(
"expected string parameter for '.ifeqs' directive");
5262 return TokError(
"expected string parameter for '.ifnes' directive");
5265 StringRef String2 = getTok().getStringContents();
5268 TheCondStack.push_back(TheCondState);
5270 TheCondState.
CondMet = ExpectEqual == (String1 == String2);
5278bool AsmParser::parseDirectiveIfdef(
SMLoc DirectiveLoc,
bool expect_defined) {
5280 TheCondStack.push_back(TheCondState);
5283 if (TheCondState.
Ignore) {
5284 eatToEndOfStatement();
5286 if (
check(parseIdentifier(
Name),
"expected identifier after '.ifdef'") ||
5304bool AsmParser::parseDirectiveElseIf(
SMLoc DirectiveLoc) {
5307 return Error(DirectiveLoc,
"Encountered a .elseif that doesn't follow an"
5308 " .if or an .elseif");
5311 bool LastIgnoreState =
false;
5312 if (!TheCondStack.empty())
5313 LastIgnoreState = TheCondStack.back().Ignore;
5314 if (LastIgnoreState || TheCondState.
CondMet) {
5315 TheCondState.
Ignore =
true;
5316 eatToEndOfStatement();
5319 if (parseAbsoluteExpression(ExprValue))
5325 TheCondState.
CondMet = ExprValue;
5334bool AsmParser::parseDirectiveElse(
SMLoc DirectiveLoc) {
5340 return Error(DirectiveLoc,
"Encountered a .else that doesn't follow "
5341 " an .if or an .elseif");
5343 bool LastIgnoreState =
false;
5344 if (!TheCondStack.empty())
5345 LastIgnoreState = TheCondStack.back().Ignore;
5346 if (LastIgnoreState || TheCondState.
CondMet)
5347 TheCondState.
Ignore =
true;
5349 TheCondState.
Ignore =
false;
5356bool AsmParser::parseDirectiveEnd(
SMLoc DirectiveLoc) {
5369bool AsmParser::parseDirectiveError(
SMLoc L,
bool WithMessage) {
5370 if (!TheCondStack.empty()) {
5371 if (TheCondStack.back().Ignore) {
5372 eatToEndOfStatement();
5378 return Error(L,
".err encountered");
5380 StringRef Message =
".error directive invoked in source file";
5383 return TokError(
".error argument must be a string");
5385 Message = getTok().getStringContents();
5389 return Error(L, Message);
5394bool AsmParser::parseDirectiveWarning(
SMLoc L) {
5395 if (!TheCondStack.empty()) {
5396 if (TheCondStack.back().Ignore) {
5397 eatToEndOfStatement();
5402 StringRef Message =
".warning directive invoked in source file";
5406 return TokError(
".warning argument must be a string");
5408 Message = getTok().getStringContents();
5419bool AsmParser::parseDirectiveEndIf(
SMLoc DirectiveLoc) {
5424 return Error(DirectiveLoc,
"Encountered a .endif that doesn't follow "
5426 if (!TheCondStack.empty()) {
5427 TheCondState = TheCondStack.back();
5428 TheCondStack.pop_back();
5434void AsmParser::initializeDirectiveKindMap() {
5441 DirectiveKindMap[
".set"] = DK_SET;
5442 DirectiveKindMap[
".equ"] = DK_EQU;
5443 DirectiveKindMap[
".equiv"] = DK_EQUIV;
5444 DirectiveKindMap[
".ascii"] = DK_ASCII;
5445 DirectiveKindMap[
".asciz"] = DK_ASCIZ;
5446 DirectiveKindMap[
".string"] = DK_STRING;
5447 DirectiveKindMap[
".byte"] = DK_BYTE;
5448 DirectiveKindMap[
".short"] = DK_SHORT;
5449 DirectiveKindMap[
".value"] = DK_VALUE;
5450 DirectiveKindMap[
".2byte"] = DK_2BYTE;
5451 DirectiveKindMap[
".long"] = DK_LONG;
5452 DirectiveKindMap[
".int"] = DK_INT;
5453 DirectiveKindMap[
".4byte"] = DK_4BYTE;
5454 DirectiveKindMap[
".quad"] = DK_QUAD;
5455 DirectiveKindMap[
".8byte"] = DK_8BYTE;
5456 DirectiveKindMap[
".octa"] = DK_OCTA;
5457 DirectiveKindMap[
".single"] = DK_SINGLE;
5458 DirectiveKindMap[
".float"] = DK_FLOAT;
5459 DirectiveKindMap[
".double"] = DK_DOUBLE;
5460 DirectiveKindMap[
".align"] = DK_ALIGN;
5461 DirectiveKindMap[
".align32"] = DK_ALIGN32;
5462 DirectiveKindMap[
".balign"] = DK_BALIGN;
5463 DirectiveKindMap[
".balignw"] = DK_BALIGNW;
5464 DirectiveKindMap[
".balignl"] = DK_BALIGNL;
5465 DirectiveKindMap[
".p2align"] = DK_P2ALIGN;
5466 DirectiveKindMap[
".p2alignw"] = DK_P2ALIGNW;
5467 DirectiveKindMap[
".p2alignl"] = DK_P2ALIGNL;
5468 DirectiveKindMap[
".org"] = DK_ORG;
5469 DirectiveKindMap[
".fill"] = DK_FILL;
5470 DirectiveKindMap[
".zero"] = DK_ZERO;
5471 DirectiveKindMap[
".extern"] = DK_EXTERN;
5472 DirectiveKindMap[
".globl"] = DK_GLOBL;
5473 DirectiveKindMap[
".global"] = DK_GLOBAL;
5474 DirectiveKindMap[
".lazy_reference"] = DK_LAZY_REFERENCE;
5475 DirectiveKindMap[
".no_dead_strip"] = DK_NO_DEAD_STRIP;
5476 DirectiveKindMap[
".symbol_resolver"] = DK_SYMBOL_RESOLVER;
5477 DirectiveKindMap[
".private_extern"] = DK_PRIVATE_EXTERN;
5478 DirectiveKindMap[
".reference"] = DK_REFERENCE;
5479 DirectiveKindMap[
".weak_definition"] = DK_WEAK_DEFINITION;
5480 DirectiveKindMap[
".weak_reference"] = DK_WEAK_REFERENCE;
5481 DirectiveKindMap[
".weak_def_can_be_hidden"] = DK_WEAK_DEF_CAN_BE_HIDDEN;
5482 DirectiveKindMap[
".cold"] = DK_COLD;
5483 DirectiveKindMap[
".comm"] = DK_COMM;
5484 DirectiveKindMap[
".common"] = DK_COMMON;
5485 DirectiveKindMap[
".lcomm"] = DK_LCOMM;
5486 DirectiveKindMap[
".abort"] = DK_ABORT;
5487 DirectiveKindMap[
".include"] = DK_INCLUDE;
5488 DirectiveKindMap[
".incbin"] = DK_INCBIN;
5489 DirectiveKindMap[
".code16"] = DK_CODE16;
5490 DirectiveKindMap[
".code16gcc"] = DK_CODE16GCC;
5491 DirectiveKindMap[
".rept"] = DK_REPT;
5492 DirectiveKindMap[
".rep"] = DK_REPT;
5493 DirectiveKindMap[
".irp"] = DK_IRP;
5494 DirectiveKindMap[
".irpc"] = DK_IRPC;
5495 DirectiveKindMap[
".endr"] = DK_ENDR;
5496 DirectiveKindMap[
".bundle_align_mode"] = DK_BUNDLE_ALIGN_MODE;
5497 DirectiveKindMap[
".bundle_lock"] = DK_BUNDLE_LOCK;
5498 DirectiveKindMap[
".bundle_unlock"] = DK_BUNDLE_UNLOCK;
5499 DirectiveKindMap[
".if"] = DK_IF;
5500 DirectiveKindMap[
".ifeq"] = DK_IFEQ;
5501 DirectiveKindMap[
".ifge"] = DK_IFGE;
5502 DirectiveKindMap[
".ifgt"] = DK_IFGT;
5503 DirectiveKindMap[
".ifle"] = DK_IFLE;
5504 DirectiveKindMap[
".iflt"] = DK_IFLT;
5505 DirectiveKindMap[
".ifne"] = DK_IFNE;
5506 DirectiveKindMap[
".ifb"] = DK_IFB;
5507 DirectiveKindMap[
".ifnb"] = DK_IFNB;
5508 DirectiveKindMap[
".ifc"] = DK_IFC;
5509 DirectiveKindMap[
".ifeqs"] = DK_IFEQS;
5510 DirectiveKindMap[
".ifnc"] = DK_IFNC;
5511 DirectiveKindMap[
".ifnes"] = DK_IFNES;
5512 DirectiveKindMap[
".ifdef"] = DK_IFDEF;
5513 DirectiveKindMap[
".ifndef"] = DK_IFNDEF;
5514 DirectiveKindMap[
".ifnotdef"] = DK_IFNOTDEF;
5515 DirectiveKindMap[
".elseif"] = DK_ELSEIF;
5516 DirectiveKindMap[
".else"] = DK_ELSE;
5517 DirectiveKindMap[
".end"] = DK_END;
5518 DirectiveKindMap[
".endif"] = DK_ENDIF;
5519 DirectiveKindMap[
".skip"] = DK_SKIP;
5520 DirectiveKindMap[
".space"] = DK_SPACE;
5521 DirectiveKindMap[
".file"] = DK_FILE;
5522 DirectiveKindMap[
".line"] = DK_LINE;
5523 DirectiveKindMap[
".loc"] = DK_LOC;
5524 DirectiveKindMap[
".stabs"] = DK_STABS;
5525 DirectiveKindMap[
".cv_file"] = DK_CV_FILE;
5526 DirectiveKindMap[
".cv_func_id"] = DK_CV_FUNC_ID;
5527 DirectiveKindMap[
".cv_loc"] = DK_CV_LOC;
5528 DirectiveKindMap[
".cv_linetable"] = DK_CV_LINETABLE;
5529 DirectiveKindMap[
".cv_inline_linetable"] = DK_CV_INLINE_LINETABLE;
5530 DirectiveKindMap[
".cv_inline_site_id"] = DK_CV_INLINE_SITE_ID;
5531 DirectiveKindMap[
".cv_def_range"] = DK_CV_DEF_RANGE;
5532 DirectiveKindMap[
".cv_string"] = DK_CV_STRING;
5533 DirectiveKindMap[
".cv_stringtable"] = DK_CV_STRINGTABLE;
5534 DirectiveKindMap[
".cv_filechecksums"] = DK_CV_FILECHECKSUMS;
5535 DirectiveKindMap[
".cv_filechecksumoffset"] = DK_CV_FILECHECKSUM_OFFSET;
5536 DirectiveKindMap[
".cv_fpo_data"] = DK_CV_FPO_DATA;
5537 DirectiveKindMap[
".sleb128"] = DK_SLEB128;
5538 DirectiveKindMap[
".uleb128"] = DK_ULEB128;
5539 DirectiveKindMap[
".cfi_sections"] = DK_CFI_SECTIONS;
5540 DirectiveKindMap[
".cfi_startproc"] = DK_CFI_STARTPROC;
5541 DirectiveKindMap[
".cfi_endproc"] = DK_CFI_ENDPROC;
5542 DirectiveKindMap[
".cfi_def_cfa"] = DK_CFI_DEF_CFA;
5543 DirectiveKindMap[
".cfi_def_cfa_offset"] = DK_CFI_DEF_CFA_OFFSET;
5544 DirectiveKindMap[
".cfi_adjust_cfa_offset"] = DK_CFI_ADJUST_CFA_OFFSET;
5545 DirectiveKindMap[
".cfi_def_cfa_register"] = DK_CFI_DEF_CFA_REGISTER;
5546 DirectiveKindMap[
".cfi_llvm_def_aspace_cfa"] = DK_CFI_LLVM_DEF_ASPACE_CFA;
5547 DirectiveKindMap[
".cfi_offset"] = DK_CFI_OFFSET;
5548 DirectiveKindMap[
".cfi_rel_offset"] = DK_CFI_REL_OFFSET;
5549 DirectiveKindMap[
".cfi_personality"] = DK_CFI_PERSONALITY;
5550 DirectiveKindMap[
".cfi_lsda"] = DK_CFI_LSDA;
5551 DirectiveKindMap[
".cfi_remember_state"] = DK_CFI_REMEMBER_STATE;
5552 DirectiveKindMap[
".cfi_restore_state"] = DK_CFI_RESTORE_STATE;
5553 DirectiveKindMap[
".cfi_same_value"] = DK_CFI_SAME_VALUE;
5554 DirectiveKindMap[
".cfi_restore"] = DK_CFI_RESTORE;
5555 DirectiveKindMap[
".cfi_escape"] = DK_CFI_ESCAPE;
5556 DirectiveKindMap[
".cfi_return_column"] = DK_CFI_RETURN_COLUMN;
5557 DirectiveKindMap[
".cfi_signal_frame"] = DK_CFI_SIGNAL_FRAME;
5558 DirectiveKindMap[
".cfi_undefined"] = DK_CFI_UNDEFINED;
5559 DirectiveKindMap[
".cfi_register"] = DK_CFI_REGISTER;
5560 DirectiveKindMap[
".cfi_window_save"] = DK_CFI_WIN