81typedef std::vector<AsmToken> MCAsmMacroArgument;
82typedef std::vector<MCAsmMacroArgument> MCAsmMacroArguments;
86struct MacroInstantiation {
88 SMLoc InstantiationLoc;
97 size_t CondStackDepth;
100struct ParseStatementInfo {
105 unsigned Opcode = ~0
U;
108 bool ParseError =
false;
110 SmallVectorImpl<AsmRewrite> *AsmRewrites =
nullptr;
112 ParseStatementInfo() =
delete;
113 ParseStatementInfo(SmallVectorImpl<AsmRewrite> *rewrites)
114 : AsmRewrites(rewrites) {}
121 void *SavedDiagContext;
122 std::unique_ptr<MCAsmParserExtension> PlatformParser;
124 std::optional<SMLoc> CFIStartProcLoc;
130 AsmCond TheCondState;
131 std::vector<AsmCond> TheCondStack;
136 StringMap<ExtensionDirectiveHandler> ExtensionDirectiveMap;
139 std::vector<MacroInstantiation*> ActiveMacros;
142 std::deque<MCAsmMacro> MacroLikeBodies;
145 unsigned MacrosEnabledFlag : 1;
148 unsigned NumOfMacroInstantiations = 0;
151 struct CppHashInfoTy {
156 CppHashInfoTy() : LineNumber(0), Buf(0) {}
158 CppHashInfoTy CppHashInfo;
161 bool HadCppHashFilename =
false;
166 SmallSet<StringRef, 2> LTODiscardSymbols;
169 unsigned AssemblerDialect = ~0
U;
172 bool IsDarwin =
false;
175 bool ParsingMSInlineAsm =
false;
178 bool ReportedInconsistentMD5 =
false;
181 bool AltMacroMode =
false;
184 virtual bool parseStatement(ParseStatementInfo &
Info,
185 MCAsmParserSemaCallback *SI);
190 bool parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &
Info,
191 StringRef IDVal, AsmToken
ID,
197 bool enabledGenDwarfForAssembly();
200 AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
201 const MCAsmInfo &MAI,
unsigned CB);
202 AsmParser(
const AsmParser &) =
delete;
203 AsmParser &operator=(
const AsmParser &) =
delete;
204 ~AsmParser()
override;
206 bool Run(
bool NoInitialTextSection,
bool NoFinalize =
false)
override;
208 void addDirectiveHandler(StringRef Directive,
209 ExtensionDirectiveHandler Handler)
override {
210 ExtensionDirectiveMap[Directive] = Handler;
213 void addAliasForDirective(StringRef Directive, StringRef Alias)
override {
214 DirectiveKindMap[Directive.
lower()] = DirectiveKindMap[Alias.
lower()];
220 CodeViewContext &getCVContext() {
return Ctx.getCVContext(); }
222 unsigned getAssemblerDialect()
override {
223 if (AssemblerDialect == ~0U)
224 return MAI.getAssemblerDialect();
226 return AssemblerDialect;
228 void setAssemblerDialect(
unsigned i)
override {
229 AssemblerDialect = i;
232 void Note(SMLoc L,
const Twine &Msg, SMRange
Range = {})
override;
233 bool Warning(SMLoc L,
const Twine &Msg, SMRange
Range = {})
override;
234 bool printError(SMLoc L,
const Twine &Msg, SMRange
Range = {})
override;
236 const AsmToken &Lex()
override;
238 void setParsingMSInlineAsm(
bool V)
override {
239 ParsingMSInlineAsm =
V;
242 Lexer.setLexMasmIntegers(V);
244 bool isParsingMSInlineAsm()
override {
return ParsingMSInlineAsm; }
246 bool discardLTOSymbol(StringRef Name)
const override {
247 return LTODiscardSymbols.contains(Name);
250 bool parseMSInlineAsm(std::string &AsmString,
unsigned &NumOutputs,
252 SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
253 SmallVectorImpl<std::string> &Constraints,
254 SmallVectorImpl<std::string> &Clobbers,
255 const MCInstrInfo *MII, MCInstPrinter *IP,
256 MCAsmParserSemaCallback &SI)
override;
258 bool parseExpression(
const MCExpr *&Res);
259 bool parseExpression(
const MCExpr *&Res, SMLoc &EndLoc)
override;
260 bool parsePrimaryExpr(
const MCExpr *&Res, SMLoc &EndLoc,
261 AsmTypeInfo *TypeInfo)
override;
262 bool parseParenExpression(
const MCExpr *&Res, SMLoc &EndLoc)
override;
263 bool parseAbsoluteExpression(int64_t &Res)
override;
267 bool parseRealValue(
const fltSemantics &Semantics, APInt &Res);
271 bool parseIdentifier(StringRef &Res)
override;
272 void eatToEndOfStatement()
override;
274 bool checkForValidSection()
override;
279 bool parseCurlyBlockScope(SmallVectorImpl<AsmRewrite>& AsmStrRewrites);
280 bool parseCppHashLineFilenameComment(SMLoc L,
bool SaveLocInfo =
true);
282 void checkForBadMacro(SMLoc DirectiveLoc, StringRef Name, StringRef Body,
284 bool expandMacro(raw_svector_ostream &OS, MCAsmMacro &
Macro,
289 bool areMacrosEnabled() {
return MacrosEnabledFlag;}
292 void setMacrosEnabled(
bool Flag) {MacrosEnabledFlag =
Flag;}
295 bool isInsideMacroInstantiation() {
return !ActiveMacros.empty();}
301 bool handleMacroEntry(MCAsmMacro *M, SMLoc NameLoc);
304 void handleMacroExit();
307 bool parseMacroArgument(MCAsmMacroArgument &MA,
bool Vararg);
310 bool parseMacroArguments(
const MCAsmMacro *M, MCAsmMacroArguments &
A);
312 void printMacroInstantiations();
314 SMRange
Range = {})
const {
321 bool enterIncludeFile(
const std::string &Filename);
325 bool processIncbinFile(
const std::string &Filename, int64_t Skip = 0,
326 const MCExpr *
Count =
nullptr, SMLoc Loc = SMLoc());
334 void jumpToLoc(SMLoc Loc,
unsigned InBuffer = 0);
339 StringRef parseStringToEndOfStatement()
override;
343 StringRef parseStringToComma();
345 enum class AssignmentKind {
352 bool parseAssignment(StringRef Name, AssignmentKind Kind);
357 bool parseBinOpRHS(
unsigned Precedence,
const MCExpr *&Res, SMLoc &EndLoc);
358 bool parseParenExpr(
const MCExpr *&Res, SMLoc &EndLoc);
359 bool parseBracketExpr(
const MCExpr *&Res, SMLoc &EndLoc);
361 bool parseRegisterOrRegisterNumber(int64_t &
Register, SMLoc DirectiveLoc);
363 bool parseCVFunctionId(int64_t &FunctionId, StringRef DirectiveName);
364 bool parseCVFileId(int64_t &FileId, StringRef DirectiveName);
434 DK_WEAK_DEF_CAN_BE_HIDDEN,
475 DK_CV_INLINE_SITE_ID,
478 DK_CV_INLINE_LINETABLE,
483 DK_CV_FILECHECKSUM_OFFSET,
489 DK_CFI_DEF_CFA_OFFSET,
490 DK_CFI_ADJUST_CFA_OFFSET,
491 DK_CFI_DEF_CFA_REGISTER,
492 DK_CFI_LLVM_DEF_ASPACE_CFA,
497 DK_CFI_REMEMBER_STATE,
498 DK_CFI_RESTORE_STATE,
502 DK_CFI_RETURN_COLUMN,
529 DK_LTO_SET_CONDITIONAL,
530 DK_CFI_MTE_TAGGED_FRAME,
538 StringMap<DirectiveKind> DirectiveKindMap;
541 enum CVDefRangeType {
543 CVDR_DEFRANGE_REGISTER,
544 CVDR_DEFRANGE_FRAMEPOINTER_REL,
545 CVDR_DEFRANGE_SUBFIELD_REGISTER,
546 CVDR_DEFRANGE_REGISTER_REL
551 StringMap<CVDefRangeType> CVDefRangeTypeMap;
554 bool parseDirectiveAscii(StringRef IDVal,
bool ZeroTerminated);
555 bool parseDirectiveBase64();
556 bool parseDirectiveReloc(SMLoc DirectiveLoc);
557 bool parseDirectiveValue(StringRef IDVal,
559 bool parseDirectiveOctaValue(StringRef IDVal);
560 bool parseDirectiveRealValue(StringRef IDVal,
561 const fltSemantics &);
562 bool parseDirectiveFill();
563 bool parseDirectiveZero();
565 bool parseDirectiveSet(StringRef IDVal, AssignmentKind Kind);
566 bool parseDirectiveOrg();
568 bool parseDirectiveAlign(
bool IsPow2, uint8_t ValueSize);
571 bool parseDirectiveFile(SMLoc DirectiveLoc);
572 bool parseDirectiveLine();
573 bool parseDirectiveLoc();
574 bool parseDirectiveLocLabel(SMLoc DirectiveLoc);
575 bool parseDirectiveStabs();
579 bool parseDirectiveCVFile();
580 bool parseDirectiveCVFuncId();
581 bool parseDirectiveCVInlineSiteId();
582 bool parseDirectiveCVLoc();
583 bool parseDirectiveCVLinetable();
584 bool parseDirectiveCVInlineLinetable();
585 bool parseDirectiveCVDefRange();
586 bool parseDirectiveCVString();
587 bool parseDirectiveCVStringTable();
588 bool parseDirectiveCVFileChecksums();
589 bool parseDirectiveCVFileChecksumOffset();
590 bool parseDirectiveCVFPOData();
593 bool parseDirectiveCFIRegister(SMLoc DirectiveLoc);
594 bool parseDirectiveCFIWindowSave(SMLoc DirectiveLoc);
595 bool parseDirectiveCFISections();
596 bool parseDirectiveCFIStartProc();
597 bool parseDirectiveCFIEndProc();
598 bool parseDirectiveCFIDefCfaOffset(SMLoc DirectiveLoc);
599 bool parseDirectiveCFIDefCfa(SMLoc DirectiveLoc);
600 bool parseDirectiveCFIAdjustCfaOffset(SMLoc DirectiveLoc);
601 bool parseDirectiveCFIDefCfaRegister(SMLoc DirectiveLoc);
602 bool parseDirectiveCFILLVMDefAspaceCfa(SMLoc DirectiveLoc);
603 bool parseDirectiveCFIOffset(SMLoc DirectiveLoc);
604 bool parseDirectiveCFIRelOffset(SMLoc DirectiveLoc);
605 bool parseDirectiveCFIPersonalityOrLsda(
bool IsPersonality);
606 bool parseDirectiveCFIRememberState(SMLoc DirectiveLoc);
607 bool parseDirectiveCFIRestoreState(SMLoc DirectiveLoc);
608 bool parseDirectiveCFISameValue(SMLoc DirectiveLoc);
609 bool parseDirectiveCFIRestore(SMLoc DirectiveLoc);
610 bool parseDirectiveCFIEscape(SMLoc DirectiveLoc);
611 bool parseDirectiveCFIReturnColumn(SMLoc DirectiveLoc);
612 bool parseDirectiveCFISignalFrame(SMLoc DirectiveLoc);
613 bool parseDirectiveCFIUndefined(SMLoc DirectiveLoc);
614 bool parseDirectiveCFILabel(SMLoc DirectiveLoc);
615 bool parseDirectiveCFIValOffset(SMLoc DirectiveLoc);
618 bool parseDirectivePurgeMacro(SMLoc DirectiveLoc);
619 bool parseDirectiveExitMacro(StringRef Directive);
620 bool parseDirectiveEndMacro(StringRef Directive);
621 bool parseDirectiveMacro(SMLoc DirectiveLoc);
622 bool parseDirectiveMacrosOnOff(StringRef Directive);
624 bool parseDirectiveAltmacro(StringRef Directive);
627 bool parseDirectiveSpace(StringRef IDVal);
630 bool parseDirectiveDCB(StringRef IDVal,
unsigned Size);
631 bool parseDirectiveRealDCB(StringRef IDVal,
const fltSemantics &);
633 bool parseDirectiveDS(StringRef IDVal,
unsigned Size);
636 bool parseDirectiveLEB128(
bool Signed);
642 bool parseDirectiveComm(
bool IsLocal);
644 bool parseDirectiveAbort(SMLoc DirectiveLoc);
645 bool parseDirectiveInclude();
646 bool parseDirectiveIncbin();
649 bool parseDirectiveIf(SMLoc DirectiveLoc, DirectiveKind DirKind);
651 bool parseDirectiveIfb(SMLoc DirectiveLoc,
bool ExpectBlank);
653 bool parseDirectiveIfc(SMLoc DirectiveLoc,
bool ExpectEqual);
655 bool parseDirectiveIfeqs(SMLoc DirectiveLoc,
bool ExpectEqual);
657 bool parseDirectiveIfdef(SMLoc DirectiveLoc,
bool expect_defined);
658 bool parseDirectiveElseIf(SMLoc DirectiveLoc);
659 bool parseDirectiveElse(SMLoc DirectiveLoc);
660 bool parseDirectiveEndIf(SMLoc DirectiveLoc);
661 bool parseEscapedString(std::string &
Data)
override;
662 bool parseAngleBracketString(std::string &
Data)
override;
665 MCAsmMacro *parseMacroLikeBody(SMLoc DirectiveLoc);
666 void instantiateMacroLikeBody(MCAsmMacro *M, SMLoc DirectiveLoc,
667 raw_svector_ostream &OS);
668 bool parseDirectiveRept(SMLoc DirectiveLoc, StringRef Directive);
669 bool parseDirectiveIrp(SMLoc DirectiveLoc);
670 bool parseDirectiveIrpc(SMLoc DirectiveLoc);
671 bool parseDirectiveEndr(SMLoc DirectiveLoc);
674 bool parseDirectiveMSEmit(SMLoc DirectiveLoc, ParseStatementInfo &
Info,
678 bool parseDirectiveMSAlign(SMLoc DirectiveLoc, ParseStatementInfo &
Info);
681 bool parseDirectiveEnd(SMLoc DirectiveLoc);
684 bool parseDirectiveError(SMLoc DirectiveLoc,
bool WithMessage);
687 bool parseDirectiveWarning(SMLoc DirectiveLoc);
690 bool parseDirectivePrint(SMLoc DirectiveLoc);
693 bool parseDirectivePseudoProbe();
696 bool parseDirectiveLTODiscard();
699 bool parseDirectiveAddrsig();
700 bool parseDirectiveAddrsigSym();
702 void initializeDirectiveKindMap();
703 void initializeCVDefRangeTypeMap();
706class HLASMAsmParser final :
public AsmParser {
711 void lexLeadingSpaces() {
716 bool parseAsHLASMLabel(ParseStatementInfo &
Info, MCAsmParserSemaCallback *SI);
717 bool parseAsMachineInstruction(ParseStatementInfo &
Info,
718 MCAsmParserSemaCallback *SI);
721 HLASMAsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
722 const MCAsmInfo &MAI,
unsigned CB = 0)
723 : AsmParser(SM, Ctx, Out, MAI, CB), Lexer(getLexer()), Out(Out) {
724 Lexer.setSkipSpace(
false);
725 Lexer.setAllowHashInIdentifier(
true);
726 Lexer.setLexHLASMIntegers(
true);
727 Lexer.setLexHLASMStrings(
true);
730 ~HLASMAsmParser()
override { Lexer.setSkipSpace(
true); }
732 bool parseStatement(ParseStatementInfo &
Info,
733 MCAsmParserSemaCallback *SI)
override;
746 :
MCAsmParser(Ctx, Out, SM, MAI), CurBuffer(CB ? CB : SM.getMainFileID()),
747 MacrosEnabledFlag(
true) {
750 SavedDiagHandler =
SrcMgr.getDiagHandler();
751 SavedDiagContext =
SrcMgr.getDiagContext();
759 switch (Ctx.getObjectFileType()) {
760 case MCContext::IsCOFF:
761 PlatformParser.reset(createCOFFAsmParser());
763 case MCContext::IsMachO:
764 PlatformParser.reset(createDarwinAsmParser());
767 case MCContext::IsELF:
768 PlatformParser.reset(createELFAsmParser());
770 case MCContext::IsGOFF:
771 PlatformParser.reset(createGOFFAsmParser());
773 case MCContext::IsSPIRV:
775 "Need to implement createSPIRVAsmParser for SPIRV format.");
777 case MCContext::IsWasm:
778 PlatformParser.reset(createWasmAsmParser());
780 case MCContext::IsXCOFF:
781 PlatformParser.reset(createXCOFFAsmParser());
783 case MCContext::IsDXContainer:
784 report_fatal_error(
"DXContainer is not supported yet");
788 PlatformParser->Initialize(*
this);
789 initializeDirectiveKindMap();
790 initializeCVDefRangeTypeMap();
793AsmParser::~AsmParser() {
794 assert((HadError || ActiveMacros.empty()) &&
795 "Unexpected active macro instantiation!");
804void AsmParser::printMacroInstantiations() {
806 for (MacroInstantiation *M :
reverse(ActiveMacros))
808 "while in macro instantiation");
811void AsmParser::Note(SMLoc L,
const Twine &Msg, SMRange
Range) {
812 printPendingErrors();
814 printMacroInstantiations();
817bool AsmParser::Warning(SMLoc L,
const Twine &Msg, SMRange
Range) {
818 if(getTargetParser().getTargetOptions().MCNoWarn)
820 if (getTargetParser().getTargetOptions().MCFatalWarnings)
823 printMacroInstantiations();
827bool AsmParser::printError(SMLoc L,
const Twine &Msg, SMRange
Range) {
830 printMacroInstantiations();
834bool AsmParser::enterIncludeFile(
const std::string &Filename) {
835 std::string IncludedFile;
849bool AsmParser::processIncbinFile(
const std::string &Filename, int64_t Skip,
850 const MCExpr *
Count, SMLoc Loc) {
851 std::string IncludedFile;
862 if (!
Count->evaluateAsAbsolute(Res, getStreamer().getAssemblerPtr()))
863 return Error(Loc,
"expected absolute expression");
865 return Warning(Loc,
"negative count has no effect");
868 getStreamer().emitBytes(Bytes);
872void AsmParser::jumpToLoc(SMLoc Loc,
unsigned InBuffer) {
878const AsmToken &AsmParser::Lex() {
885 if (!getTok().getString().
empty() && getTok().getString().
front() !=
'\n' &&
890 const AsmToken *tok = &Lexer.
Lex();
903 if (ParentIncludeLoc != SMLoc()) {
904 jumpToLoc(ParentIncludeLoc);
912bool AsmParser::enabledGenDwarfForAssembly() {
919 if (
getContext().getGenDwarfFileNumber() == 0) {
920 const MCDwarfFile &RootFile =
921 getContext().getMCDwarfLineTable(0).getRootFile();
922 getContext().setGenDwarfFileNumber(getStreamer().emitDwarfFileDirective(
929bool AsmParser::Run(
bool NoInitialTextSection,
bool NoFinalize) {
930 LTODiscardSymbols.
clear();
933 if (!NoInitialTextSection)
940 AsmCond StartingCondState = TheCondState;
948 MCSection *Sec = getStreamer().getCurrentSectionOnly();
951 getStreamer().emitLabel(SectionStartSym);
954 bool InsertResult =
getContext().addGenDwarfSection(Sec);
955 assert(InsertResult &&
".text section should not have debug info yet");
959 getTargetParser().onBeginOfFile();
963 ParseStatementInfo
Info(&AsmStrRewrites);
964 bool HasError = parseStatement(
Info,
nullptr);
973 printPendingErrors();
976 if (HasError && !getLexer().justConsumedEOL())
977 eatToEndOfStatement();
980 getTargetParser().onEndOfFile();
981 printPendingErrors();
984 assert(!hasPendingError() &&
"unexpected error from parseStatement");
988 printError(getTok().getLoc(),
"unmatched .ifs or .elses");
990 const auto &LineTables =
getContext().getMCDwarfLineTables();
991 if (!LineTables.empty()) {
993 for (
const auto &File : LineTables.begin()->second.getMCDwarfFiles()) {
994 if (
File.Name.empty() && Index != 0)
995 printError(getTok().getLoc(),
"unassigned file number: " +
997 " for .file directives");
1009 MCSymbol *Sym = TableEntry.getValue().Symbol;
1018 printError(getTok().getLoc(),
"assembler local symbol '" +
1019 Sym->
getName() +
"' not defined");
1025 for (std::tuple<SMLoc, CppHashInfoTy, MCSymbol *> &LocSym : DirLabels) {
1026 if (std::get<2>(LocSym)->isUndefined()) {
1029 CppHashInfo = std::get<1>(LocSym);
1030 printError(std::get<0>(LocSym),
"directional label undefined");
1036 if (!HadError && !NoFinalize) {
1038 TS->emitConstantPools();
1046bool AsmParser::checkForValidSection() {
1047 if (!ParsingMSInlineAsm && !getStreamer().getCurrentFragment()) {
1049 return Error(getTok().getLoc(),
1050 "expected section directive before assembly directive");
1056void AsmParser::eatToEndOfStatement() {
1065StringRef AsmParser::parseStringToEndOfStatement() {
1066 const char *
Start = getTok().getLoc().getPointer();
1072 return StringRef(Start, End - Start);
1075StringRef AsmParser::parseStringToComma() {
1076 const char *
Start = getTok().getLoc().getPointer();
1082 const char *End = getTok().getLoc().getPointer();
1083 return StringRef(Start, End - Start);
1091bool AsmParser::parseParenExpr(
const MCExpr *&Res, SMLoc &EndLoc) {
1092 if (parseExpression(Res))
1095 return parseRParen();
1103bool AsmParser::parseBracketExpr(
const MCExpr *&Res, SMLoc &EndLoc) {
1104 if (parseExpression(Res))
1106 EndLoc = getTok().getEndLoc();
1107 if (parseToken(
AsmToken::RBrac,
"expected ']' in brackets expression"))
1118bool AsmParser::parsePrimaryExpr(
const MCExpr *&Res, SMLoc &EndLoc,
1119 AsmTypeInfo *TypeInfo) {
1120 SMLoc FirstTokenLoc = getLexer().getLoc();
1122 switch (FirstTokenKind) {
1124 return TokError(
"unknown token in expression");
1130 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1140 if (parseIdentifier(Identifier)) {
1144 bool ShouldGenerateTempSymbol =
false;
1147 ShouldGenerateTempSymbol =
true;
1149 if (!ShouldGenerateTempSymbol)
1150 return Error(FirstTokenLoc,
"invalid token in expression");
1159 EndLoc = FirstTokenLoc;
1164 std::pair<StringRef, StringRef>
Split;
1169 SMLoc AtLoc = getLexer().getLoc();
1171 if (parseIdentifier(VName))
1172 return Error(AtLoc,
"expected symbol variant after '@'");
1174 Split = std::make_pair(Identifier, VName);
1182 parseIdentifier(VName);
1185 Split = std::make_pair(Identifier, VName);
1193 return Error(getLexer().getLoc(),
"expected a symbol reference");
1197 if (!
Split.second.empty()) {
1199 if (MaybeSpecifier) {
1201 Spec = *MaybeSpecifier;
1204 "invalid variant '" +
Split.second +
"'");
1219 DoInline = TV->inlineAssignedExpr();
1222 return Error(EndLoc,
"unexpected modifier on variable reference");
1233 return TokError(
"literal value out of range for directive");
1235 SMLoc Loc = getTok().getLoc();
1236 int64_t
IntVal = getTok().getIntVal();
1242 StringRef IDVal = getTok().getString();
1244 std::pair<StringRef, StringRef>
Split = IDVal.
split(
'@');
1246 if (
Split.first.size() != IDVal.
size()) {
1249 return TokError(
"invalid variant '" +
Split.second +
"'");
1250 IDVal =
Split.first;
1253 if (IDVal ==
"f" || IDVal ==
"b") {
1258 return Error(Loc,
"directional label undefined");
1259 DirLabels.push_back(std::make_tuple(Loc, CppHashInfo, Sym));
1267 APFloat RealVal(APFloat::IEEEdouble(), getTok().getString());
1268 uint64_t
IntVal = RealVal.bitcastToAPInt().getZExtValue();
1276 return TokError(
"cannot use . as current PC");
1289 return parseParenExpr(Res, EndLoc);
1291 if (!PlatformParser->HasBracketExpressions())
1292 return TokError(
"brackets expression not supported on this target");
1294 return parseBracketExpr(Res, EndLoc);
1297 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1303 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1309 if (parsePrimaryExpr(Res, EndLoc, TypeInfo))
1316bool AsmParser::parseExpression(
const MCExpr *&Res) {
1318 return parseExpression(Res, EndLoc);
1328 switch (E->getKind()) {
1339 TokError(
"invalid variant on expression '" +
getTok().getIdentifier() +
1340 "' (already modified)");
1391 "Argument to the function cannot be a NULL value");
1393 while ((*CharPtr !=
'>') && (*CharPtr !=
'\n') && (*CharPtr !=
'\r') &&
1394 (*CharPtr !=
'\0')) {
1395 if (*CharPtr ==
'!')
1399 if (*CharPtr ==
'>') {
1409 for (
size_t Pos = 0; Pos < AltMacroStr.
size(); Pos++) {
1410 if (AltMacroStr[Pos] ==
'!')
1412 Res += AltMacroStr[Pos];
1420 return TokError(
"expected specifier following '@'");
1422 auto Spec =
MAI.getSpecifierForName(
getTok().getIdentifier());
1424 return TokError(
"invalid specifier '@" +
getTok().getIdentifier() +
"'");
1444bool AsmParser::parseExpression(
const MCExpr *&Res,
SMLoc &EndLoc) {
1447 auto &TS = getTargetParser();
1448 if (TS.parsePrimaryExpr(Res, EndLoc) || parseBinOpRHS(1, Res, EndLoc))
1456 return TokError(
"unexpected symbol modifier following '@'");
1460 return TokError(
"invalid variant '" + getTok().getIdentifier() +
"'");
1462 const MCExpr *ModifiedRes = applySpecifier(Res, *
Spec);
1464 return TokError(
"invalid modifier '" + getTok().getIdentifier() +
1465 "' (no symbols present)");
1475 if (Res->evaluateAsAbsolute(
Value))
1481bool AsmParser::parseParenExpression(
const MCExpr *&Res, SMLoc &EndLoc) {
1483 return parseParenExpr(Res, EndLoc) || parseBinOpRHS(1, Res, EndLoc);
1486bool AsmParser::parseAbsoluteExpression(int64_t &Res) {
1489 SMLoc StartLoc = Lexer.
getLoc();
1490 if (parseExpression(Expr))
1493 if (!Expr->evaluateAsAbsolute(Res, getStreamer().getAssemblerPtr()))
1494 return Error(StartLoc,
"expected absolute expression");
1501 bool ShouldUseLogicalShr) {
1578 bool ShouldUseLogicalShr) {
1667bool AsmParser::parseBinOpRHS(
unsigned Precedence,
const MCExpr *&Res,
1669 SMLoc StartLoc = Lexer.
getLoc();
1672 unsigned TokPrec = getBinOpPrecedence(Lexer.
getKind(), Kind);
1676 if (TokPrec < Precedence)
1683 if (getTargetParser().parsePrimaryExpr(
RHS, EndLoc))
1689 unsigned NextTokPrec = getBinOpPrecedence(Lexer.
getKind(), Dummy);
1690 if (TokPrec < NextTokPrec && parseBinOpRHS(TokPrec + 1,
RHS, EndLoc))
1702bool AsmParser::parseStatement(ParseStatementInfo &
Info,
1703 MCAsmParserSemaCallback *SI) {
1704 assert(!hasPendingError() &&
"parseStatement started with pending error");
1710 if (getTok().getString().
empty() || getTok().getString().
front() ==
'\r' ||
1711 getTok().getString().
front() ==
'\n')
1717 AsmToken
ID = getTok();
1718 SMLoc IDLoc =
ID.getLoc();
1720 int64_t LocalLabelVal = -1;
1721 StartTokLoc =
ID.getLoc();
1723 return parseCppHashLineFilenameComment(IDLoc,
1724 !isInsideMacroInstantiation());
1728 LocalLabelVal = getTok().getIntVal();
1729 if (LocalLabelVal < 0) {
1730 if (!TheCondState.
Ignore) {
1732 return Error(IDLoc,
"unexpected token at start of statement");
1736 IDVal = getTok().getString();
1739 if (!TheCondState.
Ignore) {
1741 return Error(IDLoc,
"unexpected token at start of statement");
1749 }
else if (getTargetParser().tokenIsStartOfStatement(
ID.getKind())) {
1751 IDVal =
ID.getString();
1752 }
else if (parseIdentifier(IDVal)) {
1753 if (!TheCondState.
Ignore) {
1755 return Error(IDLoc,
"unexpected token at start of statement");
1764 DirectiveKindMap.find(IDVal.
lower());
1765 DirectiveKind DirKind = (DirKindIt == DirectiveKindMap.end())
1767 : DirKindIt->getValue();
1778 return parseDirectiveIf(IDLoc, DirKind);
1780 return parseDirectiveIfb(IDLoc,
true);
1782 return parseDirectiveIfb(IDLoc,
false);
1784 return parseDirectiveIfc(IDLoc,
true);
1786 return parseDirectiveIfeqs(IDLoc,
true);
1788 return parseDirectiveIfc(IDLoc,
false);
1790 return parseDirectiveIfeqs(IDLoc,
false);
1792 return parseDirectiveIfdef(IDLoc,
true);
1795 return parseDirectiveIfdef(IDLoc,
false);
1797 return parseDirectiveElseIf(IDLoc);
1799 return parseDirectiveElse(IDLoc);
1801 return parseDirectiveEndIf(IDLoc);
1806 if (TheCondState.
Ignore) {
1807 eatToEndOfStatement();
1817 if (checkForValidSection())
1824 return Error(IDLoc,
"invalid use of pseudo-symbol '.' as a label");
1832 if (LocalLabelVal == -1) {
1833 if (ParsingMSInlineAsm && SI) {
1834 StringRef RewrittenLabel =
1835 SI->LookupInlineAsmLabel(IDVal, getSourceManager(), IDLoc,
true);
1837 "We should have an internal name here.");
1840 IDVal = RewrittenLabel;
1850 StringRef CommentStr = parseStringToEndOfStatement();
1861 if (MAI.
isMachO() && CFIStartProcLoc) {
1862 auto *SymM =
static_cast<MCSymbolMachO *
>(Sym);
1863 if (SymM->isExternal() && !SymM->isAltEntry())
1864 return Error(StartTokLoc,
"non-private labels cannot appear between "
1865 ".cfi_startproc / .cfi_endproc pairs") &&
1866 Error(*CFIStartProcLoc,
"previous .cfi_startproc was here");
1869 if (discardLTOSymbol(IDVal))
1872 getTargetParser().doBeforeLabelEmit(Sym, IDLoc);
1875 if (!getTargetParser().isParsingMSInlineAsm())
1880 if (enabledGenDwarfForAssembly())
1884 getTargetParser().onLabelParsed(Sym);
1893 return parseAssignment(IDVal, AssignmentKind::Equal);
1897 if (areMacrosEnabled())
1898 if (MCAsmMacro *M =
getContext().lookupMacro(IDVal))
1899 return handleMacroEntry(M, IDLoc);
1916 getTargetParser().flushPendingInstructions(getStreamer());
1918 ParseStatus TPDirectiveReturn = getTargetParser().parseDirective(
ID);
1920 "Should only return Failure iff there was an error");
1928 std::pair<MCAsmParserExtension *, DirectiveHandler> Handler =
1929 ExtensionDirectiveMap.
lookup(IDVal);
1931 return (*Handler.second)(Handler.first, IDVal, IDLoc);
1940 return parseDirectiveSet(IDVal, AssignmentKind::Set);
1942 return parseDirectiveSet(IDVal, AssignmentKind::Equiv);
1943 case DK_LTO_SET_CONDITIONAL:
1944 return parseDirectiveSet(IDVal, AssignmentKind::LTOSetConditional);
1946 return parseDirectiveAscii(IDVal,
false);
1949 return parseDirectiveAscii(IDVal,
true);
1951 return parseDirectiveBase64();
1954 return parseDirectiveValue(IDVal, 1);
1960 return parseDirectiveValue(IDVal, 2);
1965 return parseDirectiveValue(IDVal, 4);
1968 return parseDirectiveValue(IDVal, 8);
1970 return parseDirectiveValue(
1971 IDVal,
getContext().getAsmInfo()->getCodePointerSize());
1973 return parseDirectiveOctaValue(IDVal);
1977 return parseDirectiveRealValue(IDVal, APFloat::IEEEsingle());
1980 return parseDirectiveRealValue(IDVal, APFloat::IEEEdouble());
1982 bool IsPow2 = !
getContext().getAsmInfo()->getAlignmentIsInBytes();
1983 return parseDirectiveAlign(IsPow2, 1);
1986 bool IsPow2 = !
getContext().getAsmInfo()->getAlignmentIsInBytes();
1987 return parseDirectiveAlign(IsPow2, 4);
1990 return parseDirectiveAlign(
false, 1);
1992 return parseDirectiveAlign(
false, 2);
1994 return parseDirectiveAlign(
false, 4);
1996 return parseDirectiveAlign(
true, 1);
1998 return parseDirectiveAlign(
true, 2);
2000 return parseDirectiveAlign(
true, 4);
2002 return parseDirectiveOrg();
2004 return parseDirectiveFill();
2006 return parseDirectiveZero();
2008 eatToEndOfStatement();
2012 return parseDirectiveSymbolAttribute(
MCSA_Global);
2013 case DK_LAZY_REFERENCE:
2015 case DK_NO_DEAD_STRIP:
2017 case DK_SYMBOL_RESOLVER:
2019 case DK_PRIVATE_EXTERN:
2023 case DK_WEAK_DEFINITION:
2025 case DK_WEAK_REFERENCE:
2027 case DK_WEAK_DEF_CAN_BE_HIDDEN:
2030 return parseDirectiveSymbolAttribute(
MCSA_Cold);
2033 return parseDirectiveComm(
false);
2035 return parseDirectiveComm(
true);
2037 return parseDirectiveAbort(IDLoc);
2039 return parseDirectiveInclude();
2041 return parseDirectiveIncbin();
2044 return TokError(Twine(IDVal) +
2045 " not currently supported for this target");
2047 return parseDirectiveRept(IDLoc, IDVal);
2049 return parseDirectiveIrp(IDLoc);
2051 return parseDirectiveIrpc(IDLoc);
2053 return parseDirectiveEndr(IDLoc);
2055 return parseDirectiveLEB128(
true);
2057 return parseDirectiveLEB128(
false);
2060 return parseDirectiveSpace(IDVal);
2062 return parseDirectiveFile(IDLoc);
2064 return parseDirectiveLine();
2066 return parseDirectiveLoc();
2068 return parseDirectiveLocLabel(IDLoc);
2070 return parseDirectiveStabs();
2072 return parseDirectiveCVFile();
2074 return parseDirectiveCVFuncId();
2075 case DK_CV_INLINE_SITE_ID:
2076 return parseDirectiveCVInlineSiteId();
2078 return parseDirectiveCVLoc();
2079 case DK_CV_LINETABLE:
2080 return parseDirectiveCVLinetable();
2081 case DK_CV_INLINE_LINETABLE:
2082 return parseDirectiveCVInlineLinetable();
2083 case DK_CV_DEF_RANGE:
2084 return parseDirectiveCVDefRange();
2086 return parseDirectiveCVString();
2087 case DK_CV_STRINGTABLE:
2088 return parseDirectiveCVStringTable();
2089 case DK_CV_FILECHECKSUMS:
2090 return parseDirectiveCVFileChecksums();
2091 case DK_CV_FILECHECKSUM_OFFSET:
2092 return parseDirectiveCVFileChecksumOffset();
2093 case DK_CV_FPO_DATA:
2094 return parseDirectiveCVFPOData();
2095 case DK_CFI_SECTIONS:
2096 return parseDirectiveCFISections();
2097 case DK_CFI_STARTPROC:
2098 return parseDirectiveCFIStartProc();
2099 case DK_CFI_ENDPROC:
2100 return parseDirectiveCFIEndProc();
2101 case DK_CFI_DEF_CFA:
2102 return parseDirectiveCFIDefCfa(IDLoc);
2103 case DK_CFI_DEF_CFA_OFFSET:
2104 return parseDirectiveCFIDefCfaOffset(IDLoc);
2105 case DK_CFI_ADJUST_CFA_OFFSET:
2106 return parseDirectiveCFIAdjustCfaOffset(IDLoc);
2107 case DK_CFI_DEF_CFA_REGISTER:
2108 return parseDirectiveCFIDefCfaRegister(IDLoc);
2109 case DK_CFI_LLVM_DEF_ASPACE_CFA:
2110 return parseDirectiveCFILLVMDefAspaceCfa(IDLoc);
2112 return parseDirectiveCFIOffset(IDLoc);
2113 case DK_CFI_REL_OFFSET:
2114 return parseDirectiveCFIRelOffset(IDLoc);
2115 case DK_CFI_PERSONALITY:
2116 return parseDirectiveCFIPersonalityOrLsda(
true);
2118 return parseDirectiveCFIPersonalityOrLsda(
false);
2119 case DK_CFI_REMEMBER_STATE:
2120 return parseDirectiveCFIRememberState(IDLoc);
2121 case DK_CFI_RESTORE_STATE:
2122 return parseDirectiveCFIRestoreState(IDLoc);
2123 case DK_CFI_SAME_VALUE:
2124 return parseDirectiveCFISameValue(IDLoc);
2125 case DK_CFI_RESTORE:
2126 return parseDirectiveCFIRestore(IDLoc);
2128 return parseDirectiveCFIEscape(IDLoc);
2129 case DK_CFI_RETURN_COLUMN:
2130 return parseDirectiveCFIReturnColumn(IDLoc);
2131 case DK_CFI_SIGNAL_FRAME:
2132 return parseDirectiveCFISignalFrame(IDLoc);
2133 case DK_CFI_UNDEFINED:
2134 return parseDirectiveCFIUndefined(IDLoc);
2135 case DK_CFI_REGISTER:
2136 return parseDirectiveCFIRegister(IDLoc);
2137 case DK_CFI_WINDOW_SAVE:
2138 return parseDirectiveCFIWindowSave(IDLoc);
2140 return parseDirectiveCFILabel(IDLoc);
2141 case DK_CFI_VAL_OFFSET:
2142 return parseDirectiveCFIValOffset(IDLoc);
2145 return parseDirectiveMacrosOnOff(IDVal);
2147 return parseDirectiveMacro(IDLoc);
2150 return parseDirectiveAltmacro(IDVal);
2152 return parseDirectiveExitMacro(IDVal);
2155 return parseDirectiveEndMacro(IDVal);
2157 return parseDirectivePurgeMacro(IDLoc);
2159 return parseDirectiveEnd(IDLoc);
2161 return parseDirectiveError(IDLoc,
false);
2163 return parseDirectiveError(IDLoc,
true);
2165 return parseDirectiveWarning(IDLoc);
2167 return parseDirectiveReloc(IDLoc);
2170 return parseDirectiveDCB(IDVal, 2);
2172 return parseDirectiveDCB(IDVal, 1);
2174 return parseDirectiveRealDCB(IDVal, APFloat::IEEEdouble());
2176 return parseDirectiveDCB(IDVal, 4);
2178 return parseDirectiveRealDCB(IDVal, APFloat::IEEEsingle());
2181 return TokError(Twine(IDVal) +
2182 " not currently supported for this target");
2185 return parseDirectiveDS(IDVal, 2);
2187 return parseDirectiveDS(IDVal, 1);
2189 return parseDirectiveDS(IDVal, 8);
2192 return parseDirectiveDS(IDVal, 4);
2195 return parseDirectiveDS(IDVal, 12);
2197 return parseDirectivePrint(IDLoc);
2199 return parseDirectiveAddrsig();
2200 case DK_ADDRSIG_SYM:
2201 return parseDirectiveAddrsigSym();
2202 case DK_PSEUDO_PROBE:
2203 return parseDirectivePseudoProbe();
2204 case DK_LTO_DISCARD:
2205 return parseDirectiveLTODiscard();
2207 return parseDirectiveSymbolAttribute(
MCSA_Memtag);
2210 return Error(IDLoc,
"unknown directive");
2214 if (ParsingMSInlineAsm && (IDVal ==
"_emit" || IDVal ==
"__emit" ||
2215 IDVal ==
"_EMIT" || IDVal ==
"__EMIT"))
2216 return parseDirectiveMSEmit(IDLoc,
Info, IDVal.
size());
2219 if (ParsingMSInlineAsm && (IDVal ==
"align" || IDVal ==
"ALIGN"))
2220 return parseDirectiveMSAlign(IDLoc,
Info);
2222 if (ParsingMSInlineAsm && (IDVal ==
"even" || IDVal ==
"EVEN"))
2224 if (checkForValidSection())
2227 return parseAndMatchAndEmitTargetInstruction(
Info, IDVal,
ID, IDLoc);
2230bool AsmParser::parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &
Info,
2235 std::string OpcodeStr = IDVal.
lower();
2236 ParseInstructionInfo IInfo(
Info.AsmRewrites);
2237 bool ParseHadError = getTargetParser().parseInstruction(IInfo, OpcodeStr,
ID,
2238 Info.ParsedOperands);
2239 Info.ParseError = ParseHadError;
2242 if (getShowParsedOperands()) {
2243 SmallString<256> Str;
2244 raw_svector_ostream OS(Str);
2245 OS <<
"parsed instruction: [";
2246 for (
unsigned i = 0; i !=
Info.ParsedOperands.size(); ++i) {
2249 Info.ParsedOperands[i]->print(OS, MAI);
2257 if (hasPendingError() || ParseHadError)
2262 if (!ParseHadError && enabledGenDwarfForAssembly() &&
2264 getStreamer().getCurrentSectionOnly())) {
2266 if (ActiveMacros.empty())
2270 ActiveMacros.front()->ExitBuffer);
2275 if (!CppHashInfo.Filename.empty()) {
2276 unsigned FileNumber = getStreamer().emitDwarfFileDirective(
2277 0, StringRef(), CppHashInfo.Filename);
2278 getContext().setGenDwarfFileNumber(FileNumber);
2280 unsigned CppHashLocLineNo =
2282 Line = CppHashInfo.LineNumber - 1 + (
Line - CppHashLocLineNo);
2285 getStreamer().emitDwarfLocDirective(
2286 getContext().getGenDwarfFileNumber(), Line, 0,
2292 if (!ParseHadError) {
2294 if (getTargetParser().matchAndEmitInstruction(
2295 IDLoc,
Info.Opcode,
Info.ParsedOperands, Out, ErrorInfo,
2296 getTargetParser().isParsingMSInlineAsm()))
2304AsmParser::parseCurlyBlockScope(SmallVectorImpl<AsmRewrite> &AsmStrRewrites) {
2309 SMLoc StartLoc = Lexer.
getLoc();
2322bool AsmParser::parseCppHashLineFilenameComment(SMLoc L,
bool SaveLocInfo) {
2327 "Lexing Cpp line comment: Expected Integer");
2328 int64_t LineNumber = getTok().getIntVal();
2331 "Lexing Cpp line comment: Expected String");
2332 StringRef
Filename = getTok().getString();
2343 CppHashInfo.Loc =
L;
2345 CppHashInfo.LineNumber = LineNumber;
2346 CppHashInfo.Buf = CurBuffer;
2347 if (!HadCppHashFilename) {
2348 HadCppHashFilename =
true;
2357 0,
getContext().getCompilationDir(), Filename,
2358 std::nullopt, std::nullopt);
2366void AsmParser::DiagHandler(
const SMDiagnostic &Diag,
void *
Context) {
2367 auto *Parser =
static_cast<AsmParser *
>(
Context);
2368 raw_ostream &OS =
errs();
2371 SMLoc DiagLoc = Diag.
getLoc();
2373 unsigned CppHashBuf =
2374 Parser->SrcMgr.FindBufferContainingLoc(Parser->CppHashInfo.Loc);
2379 if (!Parser->SavedDiagHandler && DiagCurBuffer &&
2388 if (!Parser->CppHashInfo.LineNumber || DiagBuf != CppHashBuf) {
2389 if (Parser->SavedDiagHandler)
2390 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2392 Parser->getContext().diagnose(Diag);
2399 const std::string &
Filename = std::string(Parser->CppHashInfo.Filename);
2402 int CppHashLocLineNo =
2403 Parser->SrcMgr.FindLineNumber(Parser->CppHashInfo.Loc, CppHashBuf);
2405 Parser->CppHashInfo.LineNumber - 1 + (DiagLocLineNo - CppHashLocLineNo);
2411 if (Parser->SavedDiagHandler)
2412 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2414 Parser->getContext().diagnose(NewDiag);
2422 return isalnum(
static_cast<unsigned char>(c)) || c ==
'_' || c ==
'$' ||
2426bool AsmParser::expandMacro(raw_svector_ostream &OS, MCAsmMacro &
Macro,
2429 bool EnableAtPseudoVariable) {
2431 auto expandArg = [&](
unsigned Index) {
2432 bool HasVararg = NParameters ?
Parameters.back().Vararg :
false;
2433 bool VarargParameter = HasVararg &&
Index == (NParameters - 1);
2434 for (
const AsmToken &Token :
A[Index])
2442 if (AltMacroMode && Token.getString().front() ==
'%' &&
2445 OS << Token.getIntVal();
2448 else if (AltMacroMode && Token.getString().front() ==
'<' &&
2455 OS << Token.getString();
2457 OS << Token.getStringContents();
2462 StringRef Body =
Macro.Body;
2463 size_t I = 0, End = Body.
size();
2465 if (Body[
I] ==
'\\' &&
I + 1 != End) {
2467 if (EnableAtPseudoVariable && Body[
I + 1] ==
'@') {
2468 OS << NumOfMacroInstantiations;
2472 if (Body[
I + 1] ==
'+') {
2477 if (Body[
I + 1] ==
'(' && Body[
I + 2] ==
')') {
2486 if (AltMacroMode &&
I != End && Body[
I] ==
'&')
2490 if (Parameters[Index].Name == Argument)
2492 if (Index == NParameters)
2501 if (Body[
I] ==
'$' &&
I + 1 != End && IsDarwin && !NParameters) {
2503 switch (Body[
I + 1]) {
2519 unsigned Index = Body[
I + 1] -
'0';
2520 if (Index <
A.size())
2521 for (
const AsmToken &Token :
A[Index])
2522 OS << Token.getString();
2537 StringRef Token(Body.
data() + Start,
I - Start);
2541 if (Parameters[Index].Name == Token)
2543 if (Index != NParameters) {
2545 if (
I != End && Body[
I] ==
'&')
2589class AsmLexerSkipSpaceRAII {
2591 AsmLexerSkipSpaceRAII(AsmLexer &Lexer,
bool SkipSpace) : Lexer(Lexer) {
2595 ~AsmLexerSkipSpaceRAII() {
2605bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA,
bool Vararg) {
2609 StringRef Str = parseStringToEndOfStatement();
2615 unsigned ParenLevel = 0;
2618 AsmLexerSkipSpaceRAII ScopedSkipSpace(Lexer, IsDarwin);
2625 return TokError(
"unexpected token in macro instantiation");
2627 if (ParenLevel == 0) {
2640 MA.push_back(getTok());
2664 MA.push_back(getTok());
2668 if (ParenLevel != 0)
2669 return TokError(
"unbalanced parentheses in macro argument");
2674bool AsmParser::parseMacroArguments(
const MCAsmMacro *M,
2675 MCAsmMacroArguments &
A) {
2676 const unsigned NParameters =
M ?
M->Parameters.size() : 0;
2677 bool NamedParametersFound =
false;
2678 SmallVector<SMLoc, 4> FALocs;
2680 A.resize(NParameters);
2681 FALocs.
resize(NParameters);
2686 bool HasVararg = NParameters ?
M->Parameters.back().Vararg :
false;
2687 for (
unsigned Parameter = 0; !NParameters ||
Parameter < NParameters;
2689 SMLoc IDLoc = Lexer.
getLoc();
2690 MCAsmMacroParameter FA;
2693 if (parseIdentifier(FA.
Name))
2694 return Error(IDLoc,
"invalid argument identifier for formal argument");
2697 return TokError(
"expected '=' after formal parameter identifier");
2701 NamedParametersFound =
true;
2703 bool Vararg = HasVararg &&
Parameter == (NParameters - 1);
2705 if (NamedParametersFound && FA.
Name.
empty())
2706 return Error(IDLoc,
"cannot mix positional and keyword arguments");
2708 SMLoc StrLoc = Lexer.
getLoc();
2711 const MCExpr *AbsoluteExp;
2715 if (parseExpression(AbsoluteExp, EndLoc))
2717 if (!AbsoluteExp->evaluateAsAbsolute(
Value,
2718 getStreamer().getAssemblerPtr()))
2719 return Error(StrLoc,
"expected absolute expression");
2723 StringRef(StrChar, EndChar - StrChar),
Value);
2724 FA.
Value.push_back(newToken);
2729 jumpToLoc(EndLoc, CurBuffer);
2733 StringRef(StrChar, EndChar - StrChar));
2734 FA.
Value.push_back(newToken);
2735 }
else if(parseMacroArgument(FA.
Value, Vararg))
2741 for (FAI = 0; FAI < NParameters; ++FAI)
2742 if (
M->Parameters[FAI].Name == FA.
Name)
2745 if (FAI >= NParameters) {
2746 assert(M &&
"expected macro to be defined");
2747 return Error(IDLoc,
"parameter named '" + FA.
Name +
2748 "' does not exist for macro '" +
M->Name +
"'");
2753 if (!FA.
Value.empty()) {
2758 if (FALocs.
size() <= PI)
2761 FALocs[PI] = Lexer.
getLoc();
2769 for (
unsigned FAI = 0; FAI < NParameters; ++FAI) {
2771 if (
M->Parameters[FAI].Required) {
2773 "missing value for required parameter "
2774 "'" +
M->Parameters[FAI].Name +
"' in macro '" +
M->Name +
"'");
2778 if (!
M->Parameters[FAI].Value.empty())
2779 A[FAI] =
M->Parameters[FAI].Value;
2788 return TokError(
"too many positional arguments");
2791bool AsmParser::handleMacroEntry(MCAsmMacro *M, SMLoc NameLoc) {
2795 if (ActiveMacros.size() == MaxNestingDepth) {
2796 std::ostringstream MaxNestingDepthError;
2797 MaxNestingDepthError <<
"macros cannot be nested more than "
2798 << MaxNestingDepth <<
" levels deep."
2799 <<
" Use -asm-macro-max-nesting-depth to increase "
2801 return TokError(MaxNestingDepthError.str());
2804 MCAsmMacroArguments
A;
2805 if (parseMacroArguments(M,
A))
2810 SmallString<256> Buf;
2811 raw_svector_ostream OS(Buf);
2813 if ((!IsDarwin ||
M->Parameters.size()) &&
M->Parameters.size() !=
A.size())
2814 return Error(getTok().getLoc(),
"Wrong number of arguments");
2815 if (expandMacro(OS, *M,
M->Parameters,
A,
true))
2820 OS <<
".endmacro\n";
2822 std::unique_ptr<MemoryBuffer> Instantiation =
2827 MacroInstantiation *
MI =
new MacroInstantiation{
2828 NameLoc, CurBuffer, getTok().getLoc(), TheCondStack.size()};
2829 ActiveMacros.push_back(
MI);
2831 ++NumOfMacroInstantiations;
2841void AsmParser::handleMacroExit() {
2843 jumpToLoc(ActiveMacros.back()->ExitLoc, ActiveMacros.back()->ExitBuffer);
2851 delete ActiveMacros.back();
2852 ActiveMacros.pop_back();
2855bool AsmParser::parseAssignment(StringRef Name, AssignmentKind Kind) {
2857 const MCExpr *
Value;
2858 SMLoc ExprLoc = getTok().getLoc();
2860 Kind == AssignmentKind::Set ||
Kind == AssignmentKind::Equal;
2872 if (discardLTOSymbol(Name))
2877 case AssignmentKind::Equal:
2880 case AssignmentKind::Set:
2881 case AssignmentKind::Equiv:
2885 case AssignmentKind::LTOSetConditional:
2887 return Error(ExprLoc,
"expected identifier");
2899bool AsmParser::parseIdentifier(StringRef &Res) {
2906 SMLoc PrefixLoc = getLexer().getLoc();
2918 if (PrefixLoc.
getPointer() + 1 != Buf[0].getLoc().getPointer())
2924 Res = StringRef(PrefixLoc.
getPointer(), getTok().getString().
size() + 1);
2932 Res = getTok().getIdentifier();
2944bool AsmParser::parseDirectiveSet(StringRef IDVal, AssignmentKind Kind) {
2946 if (check(parseIdentifier(Name),
"expected identifier") || parseComma() ||
2947 parseAssignment(Name, Kind))
2952bool AsmParser::parseEscapedString(std::string &
Data) {
2957 StringRef Str = getTok().getStringContents();
2958 for (
unsigned i = 0, e = Str.size(); i != e; ++i) {
2959 if (Str[i] !=
'\\') {
2960 if ((Str[i] ==
'\n') || (Str[i] ==
'\r')) {
2962 if ((Str[i] ==
'\n') && (i > 0) && (Str[i - 1] ==
'\r'))
2966 if (
Warning(NewlineLoc,
"unterminated string; newline inserted"))
2977 return TokError(
"unexpected backslash at end of string");
2980 if (Str[i] ==
'x' || Str[i] ==
'X') {
2981 size_t length = Str.size();
2982 if (i + 1 >= length || !
isHexDigit(Str[i + 1]))
2983 return TokError(
"invalid hexadecimal escape sequence");
2988 while (i + 1 < length &&
isHexDigit(Str[i + 1]))
2996 if ((
unsigned)(Str[i] -
'0') <= 7) {
2998 unsigned Value = Str[i] -
'0';
3000 if (i + 1 != e && ((
unsigned)(Str[i + 1] -
'0')) <= 7) {
3004 if (i + 1 != e && ((
unsigned)(Str[i + 1] -
'0')) <= 7) {
3011 return TokError(
"invalid octal escape sequence (out of range)");
3021 return TokError(
"invalid escape sequence (unrecognized character)");
3023 case 'b':
Data +=
'\b';
break;
3024 case 'f':
Data +=
'\f';
break;
3025 case 'n':
Data +=
'\n';
break;
3026 case 'r':
Data +=
'\r';
break;
3027 case 't':
Data +=
'\t';
break;
3028 case '"':
Data +=
'"';
break;
3029 case '\\':
Data +=
'\\';
break;
3037bool AsmParser::parseAngleBracketString(std::string &
Data) {
3038 SMLoc EndLoc, StartLoc = getTok().getLoc();
3040 const char *StartChar = StartLoc.
getPointer() + 1;
3041 const char *EndChar = EndLoc.
getPointer() - 1;
3042 jumpToLoc(EndLoc, CurBuffer);
3055bool AsmParser::parseDirectiveAscii(StringRef IDVal,
bool ZeroTerminated) {
3056 auto parseOp = [&]() ->
bool {
3058 if (checkForValidSection())
3063 if (parseEscapedString(
Data))
3065 getStreamer().emitBytes(
Data);
3068 getStreamer().emitBytes(StringRef(
"\0", 1));
3072 return parseMany(parseOp);
3077bool AsmParser::parseDirectiveBase64() {
3078 auto parseOp = [&]() ->
bool {
3079 if (checkForValidSection())
3086 std::vector<char> Decoded;
3087 std::string
const str = getTok().getStringContents().str();
3088 if (check(str.empty(),
"expected nonempty string")) {
3095 return Error(Lexer.
getLoc(),
"failed to base64 decode string data");
3098 getStreamer().emitBytes(std::string(Decoded.begin(), Decoded.end()));
3103 return check(parseMany(parseOp),
"expected string");
3108bool AsmParser::parseDirectiveReloc(SMLoc DirectiveLoc) {
3110 const MCExpr *Expr =
nullptr;
3112 if (parseExpression(
Offset))
3124 SMLoc ExprLoc = Lexer.
getLoc();
3125 if (parseExpression(Expr))
3130 return Error(ExprLoc,
"expression must be relocatable");
3136 getStreamer().emitRelocDirective(*
Offset, Name, Expr, NameLoc);
3142bool AsmParser::parseDirectiveValue(StringRef IDVal,
unsigned Size) {
3143 auto parseOp = [&]() ->
bool {
3144 const MCExpr *
Value;
3145 SMLoc ExprLoc = getLexer().getLoc();
3146 if (checkForValidSection() || getTargetParser().parseDataExpr(
Value))
3151 uint64_t IntValue = MCE->getValue();
3153 return Error(ExprLoc,
"out of range literal value");
3154 getStreamer().emitIntValue(IntValue,
Size);
3156 getStreamer().emitValue(
Value,
Size, ExprLoc);
3160 return parseMany(parseOp);
3166 return Asm.TokError(
"unknown token in expression");
3167 SMLoc ExprLoc = Asm.getTok().getLoc();
3168 APInt IntValue = Asm.getTok().getAPIntVal();
3170 if (!IntValue.
isIntN(128))
3171 return Asm.Error(ExprLoc,
"out of range literal value");
3172 if (!IntValue.
isIntN(64)) {
3185bool AsmParser::parseDirectiveOctaValue(StringRef IDVal) {
3186 auto parseOp = [&]() ->
bool {
3187 if (checkForValidSection())
3193 getStreamer().emitInt64(lo);
3194 getStreamer().emitInt64(hi);
3196 getStreamer().emitInt64(hi);
3197 getStreamer().emitInt64(lo);
3202 return parseMany(parseOp);
3205bool AsmParser::parseRealValue(
const fltSemantics &Semantics, APInt &Res) {
3216 return TokError(Lexer.
getErr());
3219 return TokError(
"unexpected token in directive");
3223 StringRef IDVal = getTok().getString();
3231 return TokError(
"invalid floating point literal");
3233 Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven)
3235 return TokError(
"invalid floating point literal");
3242 Res =
Value.bitcastToAPInt();
3249bool AsmParser::parseDirectiveRealValue(StringRef IDVal,
3250 const fltSemantics &Semantics) {
3251 auto parseOp = [&]() ->
bool {
3253 if (checkForValidSection() || parseRealValue(Semantics, AsInt))
3260 return parseMany(parseOp);
3265bool AsmParser::parseDirectiveZero() {
3266 SMLoc NumBytesLoc = Lexer.
getLoc();
3267 const MCExpr *NumBytes;
3268 if (checkForValidSection() || parseExpression(NumBytes))
3274 if (parseAbsoluteExpression(Val))
3280 getStreamer().emitFill(*NumBytes, Val, NumBytesLoc);
3287bool AsmParser::parseDirectiveFill() {
3288 SMLoc NumValuesLoc = Lexer.
getLoc();
3289 const MCExpr *NumValues;
3290 if (checkForValidSection() || parseExpression(NumValues))
3293 int64_t FillSize = 1;
3294 int64_t FillExpr = 0;
3296 SMLoc SizeLoc, ExprLoc;
3299 SizeLoc = getTok().getLoc();
3300 if (parseAbsoluteExpression(FillSize))
3303 ExprLoc = getTok().getLoc();
3304 if (parseAbsoluteExpression(FillExpr))
3312 Warning(SizeLoc,
"'.fill' directive with negative size has no effect");
3316 Warning(SizeLoc,
"'.fill' directive with size greater than 8 has been truncated to 8");
3321 Warning(ExprLoc,
"'.fill' directive pattern has been truncated to 32-bits");
3323 getStreamer().emitFill(*NumValues, FillSize, FillExpr, NumValuesLoc);
3330bool AsmParser::parseDirectiveOrg() {
3332 SMLoc OffsetLoc = Lexer.
getLoc();
3333 if (checkForValidSection() || parseExpression(
Offset))
3337 int64_t FillExpr = 0;
3339 if (parseAbsoluteExpression(FillExpr))
3344 getStreamer().emitValueToOffset(
Offset, FillExpr, OffsetLoc);
3350bool AsmParser::parseDirectiveAlign(
bool IsPow2, uint8_t ValueSize) {
3351 SMLoc AlignmentLoc = getLexer().getLoc();
3354 bool HasFillExpr =
false;
3355 int64_t FillExpr = 0;
3356 int64_t MaxBytesToFill = 0;
3359 auto parseAlign = [&]() ->
bool {
3360 if (parseAbsoluteExpression(Alignment))
3368 if (parseTokenLoc(FillExprLoc) || parseAbsoluteExpression(FillExpr))
3372 if (parseTokenLoc(MaxBytesLoc) ||
3373 parseAbsoluteExpression(MaxBytesToFill))
3379 if (checkForValidSection())
3383 Warning(AlignmentLoc,
"p2align directive with no operand(s) is ignored");
3390 bool ReturnVal =
false;
3395 if (Alignment >= 32) {
3396 ReturnVal |=
Error(AlignmentLoc,
"invalid alignment value");
3400 Alignment = 1ULL << Alignment;
3408 ReturnVal |=
Error(AlignmentLoc,
"alignment must be a power of 2");
3412 ReturnVal |=
Error(AlignmentLoc,
"alignment must be smaller than 2**32");
3413 Alignment = 1u << 31;
3419 if (MaxBytesToFill < 1) {
3420 ReturnVal |=
Error(MaxBytesLoc,
3421 "alignment directive can never be satisfied in this "
3422 "many bytes, ignoring maximum bytes expression");
3426 if (MaxBytesToFill >= Alignment) {
3427 Warning(MaxBytesLoc,
"maximum bytes expression exceeds alignment and "
3433 const MCSection *
Section = getStreamer().getCurrentSectionOnly();
3434 assert(Section &&
"must have section to emit alignment");
3436 if (HasFillExpr && FillExpr != 0 &&
Section->isBssSection()) {
3438 Warning(FillExprLoc,
"ignoring non-zero fill value in BSS section '" +
3446 getStreamer().emitCodeAlignment(
3447 Align(Alignment), &getTargetParser().getSTI(), MaxBytesToFill);
3450 getStreamer().emitValueToAlignment(
Align(Alignment), FillExpr, ValueSize,
3460bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) {
3462 int64_t FileNumber = -1;
3464 FileNumber = getTok().getIntVal();
3468 return TokError(
"negative file number");
3475 if (parseEscapedString(Path))
3478 StringRef Directory;
3480 std::string FilenameData;
3482 if (check(FileNumber == -1,
3483 "explicit path specified, but no file number") ||
3484 parseEscapedString(FilenameData))
3492 uint64_t MD5Hi, MD5Lo;
3493 bool HasMD5 =
false;
3495 std::optional<StringRef>
Source;
3496 bool HasSource =
false;
3497 std::string SourceString;
3502 "unexpected token in '.file' directive") ||
3503 parseIdentifier(Keyword))
3505 if (Keyword ==
"md5") {
3507 if (check(FileNumber == -1,
3508 "MD5 checksum specified, but no file number") ||
3511 }
else if (Keyword ==
"source") {
3513 if (check(FileNumber == -1,
3514 "source specified, but no file number") ||
3516 "unexpected token in '.file' directive") ||
3517 parseEscapedString(SourceString))
3520 return TokError(
"unexpected token in '.file' directive");
3524 if (FileNumber == -1) {
3528 if (
getContext().getAsmInfo()->hasSingleParameterDotFile())
3529 getStreamer().emitFileDirective(Filename);
3539 std::optional<MD5::MD5Result> CKMem;
3542 for (
unsigned i = 0; i != 8; ++i) {
3543 Sum[i] = uint8_t(MD5Hi >> ((7 - i) * 8));
3544 Sum[i + 8] = uint8_t(MD5Lo >> ((7 - i) * 8));
3549 char *SourceBuf =
static_cast<char *
>(Ctx.
allocate(SourceString.size()));
3550 memcpy(SourceBuf, SourceString.data(), SourceString.size());
3551 Source = StringRef(SourceBuf, SourceString.size());
3553 if (FileNumber == 0) {
3557 getStreamer().emitDwarfFile0Directive(Directory, Filename, CKMem, Source);
3559 Expected<unsigned> FileNumOrErr = getStreamer().tryEmitDwarfFileDirective(
3560 FileNumber, Directory, Filename, CKMem, Source);
3567 ReportedInconsistentMD5 =
true;
3568 return Warning(DirectiveLoc,
"inconsistent use of MD5 checksums");
3577bool AsmParser::parseDirectiveLine() {
3589bool AsmParser::parseDirectiveLoc() {
3590 int64_t FileNumber = 0, LineNumber = 0;
3591 SMLoc Loc = getTok().getLoc();
3592 if (parseIntToken(FileNumber) ||
3594 "file number less than one in '.loc' directive") ||
3595 check(!
getContext().isValidDwarfFileNumber(FileNumber), Loc,
3596 "unassigned file number in '.loc' directive"))
3601 LineNumber = getTok().getIntVal();
3603 return TokError(
"line number less than zero in '.loc' directive");
3607 int64_t ColumnPos = 0;
3609 ColumnPos = getTok().getIntVal();
3611 return TokError(
"column position less than zero in '.loc' directive");
3615 auto PrevFlags =
getContext().getCurrentDwarfLoc().getFlags();
3620 auto parseLocOp = [&]() ->
bool {
3622 SMLoc Loc = getTok().getLoc();
3623 if (parseIdentifier(Name))
3624 return TokError(
"unexpected token in '.loc' directive");
3626 if (Name ==
"basic_block")
3628 else if (Name ==
"prologue_end")
3630 else if (Name ==
"epilogue_begin")
3632 else if (Name ==
"is_stmt") {
3633 Loc = getTok().getLoc();
3634 const MCExpr *
Value;
3635 if (parseExpression(
Value))
3639 int Value = MCE->getValue();
3641 Flags &= ~DWARF2_FLAG_IS_STMT;
3642 else if (
Value == 1)
3645 return Error(Loc,
"is_stmt value not 0 or 1");
3647 return Error(Loc,
"is_stmt value not the constant value of 0 or 1");
3649 }
else if (Name ==
"isa") {
3650 Loc = getTok().getLoc();
3651 const MCExpr *
Value;
3652 if (parseExpression(
Value))
3656 int Value = MCE->getValue();
3658 return Error(Loc,
"isa number less than zero");
3661 return Error(Loc,
"isa number not a constant value");
3663 }
else if (Name ==
"discriminator") {
3664 if (parseAbsoluteExpression(Discriminator))
3667 return Error(Loc,
"unknown sub-directive in '.loc' directive");
3672 if (parseMany(parseLocOp,
false ))
3675 getStreamer().emitDwarfLocDirective(FileNumber, LineNumber, ColumnPos, Flags,
3676 Isa, Discriminator, StringRef());
3683bool AsmParser::parseDirectiveLocLabel(SMLoc DirectiveLoc) {
3685 DirectiveLoc = Lexer.
getLoc();
3686 if (parseIdentifier(Name))
3687 return TokError(
"expected identifier");
3690 getStreamer().emitDwarfLocLabelDirective(DirectiveLoc, Name);
3696bool AsmParser::parseDirectiveStabs() {
3697 return TokError(
"unsupported directive '.stabs'");
3702bool AsmParser::parseDirectiveCVFile() {
3703 SMLoc FileNumberLoc = getTok().getLoc();
3706 std::string Checksum;
3709 if (parseIntToken(FileNumber,
"expected file number") ||
3710 check(FileNumber < 1, FileNumberLoc,
"file number less than one") ||
3712 "unexpected token in '.cv_file' directive") ||
3713 parseEscapedString(Filename))
3717 "unexpected token in '.cv_file' directive") ||
3718 parseEscapedString(Checksum) ||
3719 parseIntToken(ChecksumKind,
3720 "expected checksum kind in '.cv_file' directive") ||
3726 void *CKMem = Ctx.
allocate(Checksum.size(), 1);
3727 memcpy(CKMem, Checksum.data(), Checksum.size());
3728 ArrayRef<uint8_t> ChecksumAsBytes(
reinterpret_cast<const uint8_t *
>(CKMem),
3731 if (!getStreamer().emitCVFileDirective(FileNumber, Filename, ChecksumAsBytes,
3732 static_cast<uint8_t
>(ChecksumKind)))
3733 return Error(FileNumberLoc,
"file number already allocated");
3738bool AsmParser::parseCVFunctionId(int64_t &FunctionId,
3739 StringRef DirectiveName) {
3741 return parseTokenLoc(Loc) ||
3742 parseIntToken(FunctionId,
"expected function id") ||
3743 check(FunctionId < 0 || FunctionId >= UINT_MAX, Loc,
3744 "expected function id within range [0, UINT_MAX)");
3747bool AsmParser::parseCVFileId(int64_t &FileNumber, StringRef DirectiveName) {
3749 return parseTokenLoc(Loc) ||
3750 parseIntToken(FileNumber,
"expected file number") ||
3751 check(FileNumber < 1, Loc,
3752 "file number less than one in '" + DirectiveName +
3754 check(!getCVContext().isValidFileNumber(FileNumber), Loc,
3755 "unassigned file number in '" + DirectiveName +
"' directive");
3762bool AsmParser::parseDirectiveCVFuncId() {
3763 SMLoc FunctionIdLoc = getTok().getLoc();
3766 if (parseCVFunctionId(FunctionId,
".cv_func_id") || parseEOL())
3769 if (!getStreamer().emitCVFuncIdDirective(FunctionId))
3770 return Error(FunctionIdLoc,
"function id already allocated");
3783bool AsmParser::parseDirectiveCVInlineSiteId() {
3784 SMLoc FunctionIdLoc = getTok().getLoc();
3792 if (parseCVFunctionId(FunctionId,
".cv_inline_site_id"))
3797 getTok().getIdentifier() !=
"within"),
3798 "expected 'within' identifier in '.cv_inline_site_id' directive"))
3803 if (parseCVFunctionId(IAFunc,
".cv_inline_site_id"))
3808 getTok().getIdentifier() !=
"inlined_at"),
3809 "expected 'inlined_at' identifier in '.cv_inline_site_id' "
3815 if (parseCVFileId(IAFile,
".cv_inline_site_id") ||
3816 parseIntToken(IALine,
"expected line number after 'inlined_at'"))
3821 IACol = getTok().getIntVal();
3828 if (!getStreamer().emitCVInlineSiteIdDirective(FunctionId, IAFunc, IAFile,
3829 IALine, IACol, FunctionIdLoc))
3830 return Error(FunctionIdLoc,
"function id already allocated");
3842bool AsmParser::parseDirectiveCVLoc() {
3843 SMLoc DirectiveLoc = getTok().getLoc();
3844 int64_t FunctionId, FileNumber;
3845 if (parseCVFunctionId(FunctionId,
".cv_loc") ||
3846 parseCVFileId(FileNumber,
".cv_loc"))
3849 int64_t LineNumber = 0;
3851 LineNumber = getTok().getIntVal();
3853 return TokError(
"line number less than zero in '.cv_loc' directive");
3857 int64_t ColumnPos = 0;
3859 ColumnPos = getTok().getIntVal();
3861 return TokError(
"column position less than zero in '.cv_loc' directive");
3865 bool PrologueEnd =
false;
3866 uint64_t IsStmt = 0;
3868 auto parseOp = [&]() ->
bool {
3870 SMLoc Loc = getTok().getLoc();
3871 if (parseIdentifier(Name))
3872 return TokError(
"unexpected token in '.cv_loc' directive");
3873 if (Name ==
"prologue_end")
3875 else if (Name ==
"is_stmt") {
3876 Loc = getTok().getLoc();
3877 const MCExpr *
Value;
3878 if (parseExpression(
Value))
3883 IsStmt = MCE->getValue();
3886 return Error(Loc,
"is_stmt value not 0 or 1");
3888 return Error(Loc,
"unknown sub-directive in '.cv_loc' directive");
3893 if (parseMany(parseOp,
false ))
3896 getStreamer().emitCVLocDirective(FunctionId, FileNumber, LineNumber,
3897 ColumnPos, PrologueEnd, IsStmt, StringRef(),
3904bool AsmParser::parseDirectiveCVLinetable() {
3907 SMLoc Loc = getTok().getLoc();
3908 if (parseCVFunctionId(FunctionId,
".cv_linetable") || parseComma() ||
3909 parseTokenLoc(Loc) ||
3910 check(
parseSymbol(FnStartSym), Loc,
"expected identifier in directive") ||
3911 parseComma() || parseTokenLoc(Loc) ||
3912 check(
parseSymbol(FnEndSym), Loc,
"expected identifier in directive"))
3915 getStreamer().emitCVLinetableDirective(FunctionId, FnStartSym, FnEndSym);
3921bool AsmParser::parseDirectiveCVInlineLinetable() {
3922 int64_t PrimaryFunctionId, SourceFileId, SourceLineNum;
3924 SMLoc Loc = getTok().getLoc();
3925 if (parseCVFunctionId(PrimaryFunctionId,
".cv_inline_linetable") ||
3926 parseTokenLoc(Loc) ||
3927 parseIntToken(SourceFileId,
"expected SourceField") ||
3928 check(SourceFileId <= 0, Loc,
"File id less than zero") ||
3929 parseTokenLoc(Loc) ||
3930 parseIntToken(SourceLineNum,
"expected SourceLineNum") ||
3931 check(SourceLineNum < 0, Loc,
"Line number less than zero") ||
3932 parseTokenLoc(Loc) ||
3933 check(
parseSymbol(FnStartSym), Loc,
"expected identifier") ||
3934 parseTokenLoc(Loc) ||
3935 check(
parseSymbol(FnEndSym), Loc,
"expected identifier"))
3941 getStreamer().emitCVInlineLinetableDirective(PrimaryFunctionId, SourceFileId,
3942 SourceLineNum, FnStartSym,
3947void AsmParser::initializeCVDefRangeTypeMap() {
3948 CVDefRangeTypeMap[
"reg"] = CVDR_DEFRANGE_REGISTER;
3949 CVDefRangeTypeMap[
"frame_ptr_rel"] = CVDR_DEFRANGE_FRAMEPOINTER_REL;
3950 CVDefRangeTypeMap[
"subfield_reg"] = CVDR_DEFRANGE_SUBFIELD_REGISTER;
3951 CVDefRangeTypeMap[
"reg_rel"] = CVDR_DEFRANGE_REGISTER_REL;
3956bool AsmParser::parseDirectiveCVDefRange() {
3958 std::vector<std::pair<const MCSymbol *, const MCSymbol *>>
Ranges;
3960 Loc = getLexer().getLoc();
3963 return Error(Loc,
"expected identifier in directive");
3965 Loc = getLexer().getLoc();
3968 return Error(Loc,
"expected identifier in directive");
3970 Ranges.push_back({GapStartSym, GapEndSym});
3973 StringRef CVDefRangeTypeStr;
3976 "expected comma before def_range type in .cv_def_range directive") ||
3977 parseIdentifier(CVDefRangeTypeStr))
3978 return Error(Loc,
"expected def_range type in directive");
3981 CVDefRangeTypeMap.find(CVDefRangeTypeStr);
3982 CVDefRangeType CVDRType = (CVTypeIt == CVDefRangeTypeMap.end())
3984 : CVTypeIt->getValue();
3986 case CVDR_DEFRANGE_REGISTER: {
3988 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
3989 ".cv_def_range directive") ||
3990 parseAbsoluteExpression(DRRegister))
3991 return Error(Loc,
"expected register number");
3993 codeview::DefRangeRegisterHeader DRHdr;
3996 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
3999 case CVDR_DEFRANGE_FRAMEPOINTER_REL: {
4002 "expected comma before offset in .cv_def_range directive") ||
4003 parseAbsoluteExpression(DROffset))
4004 return Error(Loc,
"expected offset value");
4006 codeview::DefRangeFramePointerRelHeader DRHdr;
4008 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4011 case CVDR_DEFRANGE_SUBFIELD_REGISTER: {
4013 int64_t DROffsetInParent;
4014 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4015 ".cv_def_range directive") ||
4016 parseAbsoluteExpression(DRRegister))
4017 return Error(Loc,
"expected register number");
4019 "expected comma before offset in .cv_def_range directive") ||
4020 parseAbsoluteExpression(DROffsetInParent))
4021 return Error(Loc,
"expected offset value");
4023 codeview::DefRangeSubfieldRegisterHeader DRHdr;
4027 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4030 case CVDR_DEFRANGE_REGISTER_REL: {
4033 int64_t DRBasePointerOffset;
4034 if (parseToken(
AsmToken::Comma,
"expected comma before register number in "
4035 ".cv_def_range directive") ||
4036 parseAbsoluteExpression(DRRegister))
4037 return Error(Loc,
"expected register value");
4040 "expected comma before flag value in .cv_def_range directive") ||
4041 parseAbsoluteExpression(DRFlags))
4042 return Error(Loc,
"expected flag value");
4043 if (parseToken(
AsmToken::Comma,
"expected comma before base pointer offset "
4044 "in .cv_def_range directive") ||
4045 parseAbsoluteExpression(DRBasePointerOffset))
4046 return Error(Loc,
"expected base pointer offset value");
4048 codeview::DefRangeRegisterRelHeader DRHdr;
4050 DRHdr.
Flags = DRFlags;
4052 getStreamer().emitCVDefRangeDirective(Ranges, DRHdr);
4056 return Error(Loc,
"unexpected def_range type in .cv_def_range directive");
4063bool AsmParser::parseDirectiveCVString() {
4065 if (checkForValidSection() || parseEscapedString(
Data))
4069 std::pair<StringRef, unsigned> Insertion =
4070 getCVContext().addToStringTable(
Data);
4071 getStreamer().emitInt32(Insertion.second);
4077bool AsmParser::parseDirectiveCVStringTable() {
4078 getStreamer().emitCVStringTableDirective();
4084bool AsmParser::parseDirectiveCVFileChecksums() {
4085 getStreamer().emitCVFileChecksumsDirective();
4091bool AsmParser::parseDirectiveCVFileChecksumOffset() {
4093 if (parseIntToken(FileNo))
4097 getStreamer().emitCVFileChecksumOffsetDirective(FileNo);
4103bool AsmParser::parseDirectiveCVFPOData() {
4104 SMLoc DirLoc = getLexer().getLoc();
4107 return TokError(
"expected symbol name");
4110 getStreamer().emitCVFPOData(ProcSym, DirLoc);
4116bool AsmParser::parseDirectiveCFISections() {
4120 bool SFrame =
false;
4124 if (parseIdentifier(Name))
4125 return TokError(
"expected .eh_frame, .debug_frame, or .sframe");
4126 if (Name ==
".eh_frame")
4128 else if (Name ==
".debug_frame")
4130 else if (Name ==
".sframe")
4138 getStreamer().emitCFISections(EH,
Debug, SFrame);
4144bool AsmParser::parseDirectiveCFIStartProc() {
4145 CFIStartProcLoc = StartTokLoc;
4149 if (check(parseIdentifier(
Simple) ||
Simple !=
"simple",
4150 "unexpected token") ||
4160 getStreamer().emitCFIStartProc(!
Simple.empty(), Lexer.
getLoc());
4166bool AsmParser::parseDirectiveCFIEndProc() {
4167 CFIStartProcLoc = std::nullopt;
4172 getStreamer().emitCFIEndProc();
4177bool AsmParser::parseRegisterOrRegisterNumber(int64_t &
Register,
4178 SMLoc DirectiveLoc) {
4182 if (getTargetParser().parseRegister(RegNo, DirectiveLoc, DirectiveLoc))
4186 return parseAbsoluteExpression(
Register);
4193bool AsmParser::parseDirectiveCFIDefCfa(SMLoc DirectiveLoc) {
4195 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4196 parseAbsoluteExpression(
Offset) || parseEOL())
4205bool AsmParser::parseDirectiveCFIDefCfaOffset(SMLoc DirectiveLoc) {
4207 if (parseAbsoluteExpression(
Offset) || parseEOL())
4210 getStreamer().emitCFIDefCfaOffset(
Offset, DirectiveLoc);
4216bool AsmParser::parseDirectiveCFIRegister(SMLoc DirectiveLoc) {
4217 int64_t Register1 = 0, Register2 = 0;
4218 if (parseRegisterOrRegisterNumber(Register1, DirectiveLoc) || parseComma() ||
4219 parseRegisterOrRegisterNumber(Register2, DirectiveLoc) || parseEOL())
4222 getStreamer().emitCFIRegister(Register1, Register2, DirectiveLoc);
4228bool AsmParser::parseDirectiveCFIWindowSave(SMLoc DirectiveLoc) {
4231 getStreamer().emitCFIWindowSave(DirectiveLoc);
4237bool AsmParser::parseDirectiveCFIAdjustCfaOffset(SMLoc DirectiveLoc) {
4238 int64_t Adjustment = 0;
4239 if (parseAbsoluteExpression(Adjustment) || parseEOL())
4242 getStreamer().emitCFIAdjustCfaOffset(Adjustment, DirectiveLoc);
4248bool AsmParser::parseDirectiveCFIDefCfaRegister(SMLoc DirectiveLoc) {
4250 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4253 getStreamer().emitCFIDefCfaRegister(
Register, DirectiveLoc);
4259bool AsmParser::parseDirectiveCFILLVMDefAspaceCfa(SMLoc DirectiveLoc) {
4261 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4262 parseAbsoluteExpression(
Offset) || parseComma() ||
4273bool AsmParser::parseDirectiveCFIOffset(SMLoc DirectiveLoc) {
4277 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4278 parseAbsoluteExpression(
Offset) || parseEOL())
4287bool AsmParser::parseDirectiveCFIRelOffset(SMLoc DirectiveLoc) {
4290 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4291 parseAbsoluteExpression(
Offset) || parseEOL())
4299 if (Encoding & ~0xff)
4305 const unsigned Format = Encoding & 0xf;
4312 const unsigned Application = Encoding & 0x70;
4324bool AsmParser::parseDirectiveCFIPersonalityOrLsda(
bool IsPersonality) {
4325 int64_t Encoding = 0;
4326 if (parseAbsoluteExpression(Encoding))
4334 check(
parseSymbol(Sym),
"expected identifier in directive") || parseEOL())
4338 getStreamer().emitCFIPersonality(Sym, Encoding);
4340 getStreamer().emitCFILsda(Sym, Encoding);
4346bool AsmParser::parseDirectiveCFIRememberState(SMLoc DirectiveLoc) {
4349 getStreamer().emitCFIRememberState(DirectiveLoc);
4355bool AsmParser::parseDirectiveCFIRestoreState(SMLoc DirectiveLoc) {
4358 getStreamer().emitCFIRestoreState(DirectiveLoc);
4364bool AsmParser::parseDirectiveCFISameValue(SMLoc DirectiveLoc) {
4367 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4370 getStreamer().emitCFISameValue(
Register, DirectiveLoc);
4376bool AsmParser::parseDirectiveCFIRestore(SMLoc DirectiveLoc) {
4378 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4381 getStreamer().emitCFIRestore(
Register, DirectiveLoc);
4387bool AsmParser::parseDirectiveCFIEscape(SMLoc DirectiveLoc) {
4390 if (parseAbsoluteExpression(CurrValue))
4393 Values.push_back((uint8_t)CurrValue);
4398 if (parseAbsoluteExpression(CurrValue))
4401 Values.push_back((uint8_t)CurrValue);
4404 getStreamer().emitCFIEscape(Values, DirectiveLoc);
4410bool AsmParser::parseDirectiveCFIReturnColumn(SMLoc DirectiveLoc) {
4412 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4414 getStreamer().emitCFIReturnColumn(
Register);
4420bool AsmParser::parseDirectiveCFISignalFrame(SMLoc DirectiveLoc) {
4424 getStreamer().emitCFISignalFrame();
4430bool AsmParser::parseDirectiveCFIUndefined(SMLoc DirectiveLoc) {
4433 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseEOL())
4436 getStreamer().emitCFIUndefined(
Register, DirectiveLoc);
4442bool AsmParser::parseDirectiveCFILabel(SMLoc Loc) {
4445 if (parseIdentifier(Name))
4446 return TokError(
"expected identifier");
4449 getStreamer().emitCFILabelDirective(Loc, Name);
4455bool AsmParser::parseDirectiveCFIValOffset(SMLoc DirectiveLoc) {
4459 if (parseRegisterOrRegisterNumber(
Register, DirectiveLoc) || parseComma() ||
4460 parseAbsoluteExpression(
Offset) || parseEOL())
4470bool AsmParser::parseDirectiveAltmacro(StringRef Directive) {
4473 AltMacroMode = (Directive ==
".altmacro");
4480bool AsmParser::parseDirectiveMacrosOnOff(StringRef Directive) {
4483 setMacrosEnabled(Directive ==
".macros_on");
4489bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) {
4491 if (parseIdentifier(Name))
4492 return TokError(
"expected identifier in '.macro' directive");
4501 return Error(Lexer.
getLoc(),
"vararg parameter '" +
4503 "' should be the last parameter");
4507 return TokError(
"expected identifier in '.macro' directive");
4510 for (
const MCAsmMacroParameter& CurrParam : Parameters)
4512 return TokError(
"macro '" + Name +
"' has multiple parameters"
4521 QualLoc = Lexer.
getLoc();
4522 if (parseIdentifier(Qualifier))
4523 return Error(QualLoc,
"missing parameter qualifier for "
4524 "'" +
Parameter.Name +
"' in macro '" + Name +
"'");
4526 if (Qualifier ==
"req")
4528 else if (Qualifier ==
"vararg")
4531 return Error(QualLoc, Qualifier +
" is not a valid parameter qualifier "
4532 "for '" +
Parameter.Name +
"' in macro '" + Name +
"'");
4540 ParamLoc = Lexer.
getLoc();
4541 if (parseMacroArgument(
Parameter.Value,
false ))
4545 Warning(ParamLoc,
"pointless default value for required parameter "
4546 "'" +
Parameter.Name +
"' in macro '" + Name +
"'");
4559 AsmToken EndToken, StartToken = getTok();
4560 unsigned MacroDepth = 0;
4570 return Error(DirectiveLoc,
"no matching '.endmacro' in definition");
4575 if (getTok().getIdentifier() ==
".endm" ||
4576 getTok().getIdentifier() ==
".endmacro") {
4577 if (MacroDepth == 0) {
4578 EndToken = getTok();
4581 return TokError(
"unexpected token in '" + EndToken.
getIdentifier() +
4588 }
else if (getTok().getIdentifier() ==
".macro") {
4594 (void)parseCppHashLineFilenameComment(getLexer().getLoc());
4598 eatToEndOfStatement();
4602 return Error(DirectiveLoc,
"macro '" + Name +
"' is already defined");
4607 StringRef Body = StringRef(BodyStart, BodyEnd - BodyStart);
4608 checkForBadMacro(DirectiveLoc, Name, Body, Parameters);
4609 MCAsmMacro
Macro(Name, Body, std::move(Parameters));
4630void AsmParser::checkForBadMacro(SMLoc DirectiveLoc, StringRef Name,
4636 if (NParameters == 0)
4639 bool NamedParametersFound =
false;
4640 bool PositionalParametersFound =
false;
4645 while (!Body.
empty()) {
4647 std::size_t End = Body.
size(), Pos = 0;
4648 for (; Pos != End; ++Pos) {
4651 if (Body[Pos] ==
'\\' && Pos + 1 != End)
4655 if (Body[Pos] !=
'$' || Pos + 1 == End)
4657 char Next = Body[Pos + 1];
4659 isdigit(
static_cast<unsigned char>(
Next)))
4667 if (Body[Pos] ==
'$') {
4668 switch (Body[Pos + 1]) {
4675 PositionalParametersFound =
true;
4680 PositionalParametersFound =
true;
4686 unsigned I = Pos + 1;
4690 const char *Begin = Body.
data() + Pos + 1;
4691 StringRef
Argument(Begin,
I - (Pos + 1));
4694 if (Parameters[Index].Name == Argument)
4697 if (Index == NParameters) {
4698 if (Body[Pos + 1] ==
'(' && Body[Pos + 2] ==
')')
4704 NamedParametersFound =
true;
4712 if (!NamedParametersFound && PositionalParametersFound)
4713 Warning(DirectiveLoc,
"macro defined with named parameters which are not "
4714 "used in macro body, possible positional parameter "
4715 "found in body which will have no effect");
4720bool AsmParser::parseDirectiveExitMacro(StringRef Directive) {
4724 if (!isInsideMacroInstantiation())
4725 return TokError(
"unexpected '" + Directive +
"' in file, "
4726 "no current macro definition");
4729 while (TheCondStack.size() != ActiveMacros.back()->CondStackDepth) {
4730 TheCondState = TheCondStack.back();
4731 TheCondStack.pop_back();
4741bool AsmParser::parseDirectiveEndMacro(StringRef Directive) {
4743 return TokError(
"unexpected token in '" + Directive +
"' directive");
4747 if (isInsideMacroInstantiation()) {
4754 return TokError(
"unexpected '" + Directive +
"' in file, "
4755 "no current macro definition");
4760bool AsmParser::parseDirectivePurgeMacro(SMLoc DirectiveLoc) {
4763 if (parseTokenLoc(Loc) ||
4764 check(parseIdentifier(Name), Loc,
4765 "expected identifier in '.purgem' directive") ||
4770 return Error(DirectiveLoc,
"macro '" + Name +
"' is not defined");
4774 <<
"Un-defining macro: " << Name <<
"\n");
4780bool AsmParser::parseDirectiveSpace(StringRef IDVal) {
4781 SMLoc NumBytesLoc = Lexer.
getLoc();
4782 const MCExpr *NumBytes;
4783 if (checkForValidSection() || parseExpression(NumBytes))
4786 int64_t FillExpr = 0;
4788 if (parseAbsoluteExpression(FillExpr))
4794 getStreamer().emitFill(*NumBytes, FillExpr, NumBytesLoc);
4801bool AsmParser::parseDirectiveDCB(StringRef IDVal,
unsigned Size) {
4802 SMLoc NumValuesLoc = Lexer.
getLoc();
4804 if (checkForValidSection() || parseAbsoluteExpression(NumValues))
4807 if (NumValues < 0) {
4808 Warning(NumValuesLoc,
"'" + Twine(IDVal) +
"' directive with negative repeat count has no effect");
4815 const MCExpr *
Value;
4816 SMLoc ExprLoc = getLexer().getLoc();
4817 if (parseExpression(
Value))
4823 uint64_t IntValue = MCE->getValue();
4825 return Error(ExprLoc,
"literal value out of range for directive");
4826 for (uint64_t i = 0, e = NumValues; i !=
e; ++i)
4827 getStreamer().emitIntValue(IntValue,
Size);
4829 for (uint64_t i = 0, e = NumValues; i !=
e; ++i)
4830 getStreamer().emitValue(
Value,
Size, ExprLoc);
4838bool AsmParser::parseDirectiveRealDCB(StringRef IDVal,
const fltSemantics &Semantics) {
4839 SMLoc NumValuesLoc = Lexer.
getLoc();
4841 if (checkForValidSection() || parseAbsoluteExpression(NumValues))
4844 if (NumValues < 0) {
4845 Warning(NumValuesLoc,
"'" + Twine(IDVal) +
"' directive with negative repeat count has no effect");
4853 if (parseRealValue(Semantics, AsInt) || parseEOL())
4856 for (uint64_t i = 0, e = NumValues; i !=
e; ++i)
4865bool AsmParser::parseDirectiveDS(StringRef IDVal,
unsigned Size) {
4866 SMLoc NumValuesLoc = Lexer.
getLoc();
4868 if (checkForValidSection() || parseAbsoluteExpression(NumValues) ||
4872 if (NumValues < 0) {
4873 Warning(NumValuesLoc,
"'" + Twine(IDVal) +
"' directive with negative repeat count has no effect");
4877 for (uint64_t i = 0, e = NumValues; i !=
e; ++i)
4878 getStreamer().emitFill(
Size, 0);
4885bool AsmParser::parseDirectiveLEB128(
bool Signed) {
4886 if (checkForValidSection())
4889 auto parseOp = [&]() ->
bool {
4890 const MCExpr *
Value;
4891 if (parseExpression(
Value))
4894 getStreamer().emitSLEB128Value(
Value);
4896 getStreamer().emitULEB128Value(
Value);
4900 return parseMany(parseOp);
4905bool AsmParser::parseDirectiveSymbolAttribute(
MCSymbolAttr Attr) {
4906 auto parseOp = [&]() ->
bool {
4908 SMLoc Loc = getTok().getLoc();
4909 if (parseIdentifier(Name))
4910 return Error(Loc,
"expected identifier");
4912 if (discardLTOSymbol(Name))
4920 return Error(Loc,
"non-local symbol required");
4922 if (!getStreamer().emitSymbolAttribute(Sym, Attr))
4923 return Error(Loc,
"unable to emit symbol attribute");
4927 return parseMany(parseOp);
4932bool AsmParser::parseDirectiveComm(
bool IsLocal) {
4933 if (checkForValidSection())
4936 SMLoc IDLoc = getLexer().getLoc();
4939 return TokError(
"expected identifier in directive");
4945 SMLoc SizeLoc = getLexer().getLoc();
4946 if (parseAbsoluteExpression(
Size))
4949 int64_t Pow2Alignment = 0;
4950 SMLoc Pow2AlignmentLoc;
4953 Pow2AlignmentLoc = getLexer().getLoc();
4954 if (parseAbsoluteExpression(Pow2Alignment))
4959 return Error(Pow2AlignmentLoc,
"alignment not supported on this target");
4965 return Error(Pow2AlignmentLoc,
"alignment must be a power of 2");
4966 Pow2Alignment =
Log2_64(Pow2Alignment);
4976 return Error(SizeLoc,
"size must be non-negative");
4980 return Error(IDLoc,
"invalid symbol redefinition");
4984 getStreamer().emitLocalCommonSymbol(Sym,
Size,
4985 Align(1ULL << Pow2Alignment));
4989 getStreamer().emitCommonSymbol(Sym,
Size,
Align(1ULL << Pow2Alignment));
4995bool AsmParser::parseDirectiveAbort(SMLoc DirectiveLoc) {
4996 StringRef Str = parseStringToEndOfStatement();
5001 return Error(DirectiveLoc,
".abort detected. Assembly stopping");
5004 return Error(DirectiveLoc,
5005 ".abort '" + Str +
"' detected. Assembly stopping");
5010bool AsmParser::parseDirectiveInclude() {
5013 SMLoc IncludeLoc = getTok().getLoc();
5016 "expected string in '.include' directive") ||
5017 parseEscapedString(Filename) ||
5019 "unexpected token in '.include' directive") ||
5022 check(enterIncludeFile(Filename), IncludeLoc,
5023 "Could not find include file '" + Filename +
"'"))
5031bool AsmParser::parseDirectiveIncbin() {
5034 SMLoc IncbinLoc = getTok().getLoc();
5036 "expected string in '.incbin' directive") ||
5037 parseEscapedString(Filename))
5041 const MCExpr *
Count =
nullptr;
5042 SMLoc SkipLoc, CountLoc;
5047 if (parseTokenLoc(SkipLoc) || parseAbsoluteExpression(Skip))
5051 CountLoc = getTok().getLoc();
5052 if (parseExpression(
Count))
5060 if (check(Skip < 0, SkipLoc,
"skip is negative"))
5064 if (processIncbinFile(Filename, Skip,
Count, CountLoc))
5065 return Error(IncbinLoc,
"Could not find incbin file '" + Filename +
"'");
5071bool AsmParser::parseDirectiveIf(SMLoc DirectiveLoc, DirectiveKind DirKind) {
5072 TheCondStack.push_back(TheCondState);
5074 if (TheCondState.
Ignore) {
5075 eatToEndOfStatement();
5078 if (parseAbsoluteExpression(ExprValue) || parseEOL())
5088 ExprValue = ExprValue == 0;
5091 ExprValue = ExprValue >= 0;
5094 ExprValue = ExprValue > 0;
5097 ExprValue = ExprValue <= 0;
5100 ExprValue = ExprValue < 0;
5104 TheCondState.
CondMet = ExprValue;
5113bool AsmParser::parseDirectiveIfb(SMLoc DirectiveLoc,
bool ExpectBlank) {
5114 TheCondStack.push_back(TheCondState);
5117 if (TheCondState.
Ignore) {
5118 eatToEndOfStatement();
5120 StringRef Str = parseStringToEndOfStatement();
5125 TheCondState.
CondMet = ExpectBlank == Str.empty();
5135bool AsmParser::parseDirectiveIfc(SMLoc DirectiveLoc,
bool ExpectEqual) {
5136 TheCondStack.push_back(TheCondState);
5139 if (TheCondState.
Ignore) {
5140 eatToEndOfStatement();
5142 StringRef Str1 = parseStringToComma();
5147 StringRef Str2 = parseStringToEndOfStatement();
5161bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc,
bool ExpectEqual) {
5162 TheCondStack.push_back(TheCondState);
5165 if (TheCondState.
Ignore) {
5166 eatToEndOfStatement();
5170 return TokError(
"expected string parameter for '.ifeqs' directive");
5171 return TokError(
"expected string parameter for '.ifnes' directive");
5174 StringRef String1 = getTok().getStringContents();
5180 "expected comma after first string for '.ifeqs' directive");
5182 "expected comma after first string for '.ifnes' directive");
5189 return TokError(
"expected string parameter for '.ifeqs' directive");
5190 return TokError(
"expected string parameter for '.ifnes' directive");
5193 StringRef String2 = getTok().getStringContents();
5196 TheCondState.
CondMet = ExpectEqual == (String1 == String2);
5205bool AsmParser::parseDirectiveIfdef(SMLoc DirectiveLoc,
bool expect_defined) {
5207 TheCondStack.push_back(TheCondState);
5210 if (TheCondState.
Ignore) {
5211 eatToEndOfStatement();
5213 if (check(parseIdentifier(Name),
"expected identifier after '.ifdef'") ||
5231bool AsmParser::parseDirectiveElseIf(SMLoc DirectiveLoc) {
5234 return Error(DirectiveLoc,
"Encountered a .elseif that doesn't follow an"
5235 " .if or an .elseif");
5238 bool LastIgnoreState =
false;
5239 if (!TheCondStack.empty())
5240 LastIgnoreState = TheCondStack.back().Ignore;
5241 if (LastIgnoreState || TheCondState.
CondMet) {
5242 TheCondState.
Ignore =
true;
5243 eatToEndOfStatement();
5246 if (parseAbsoluteExpression(ExprValue))
5252 TheCondState.
CondMet = ExprValue;
5261bool AsmParser::parseDirectiveElse(SMLoc DirectiveLoc) {
5267 return Error(DirectiveLoc,
"Encountered a .else that doesn't follow "
5268 " an .if or an .elseif");
5270 bool LastIgnoreState =
false;
5271 if (!TheCondStack.empty())
5272 LastIgnoreState = TheCondStack.back().Ignore;
5273 if (LastIgnoreState || TheCondState.
CondMet)
5274 TheCondState.
Ignore =
true;
5276 TheCondState.
Ignore =
false;
5283bool AsmParser::parseDirectiveEnd(SMLoc DirectiveLoc) {
5296bool AsmParser::parseDirectiveError(SMLoc L,
bool WithMessage) {
5297 if (!TheCondStack.empty()) {
5298 if (TheCondStack.back().Ignore) {
5299 eatToEndOfStatement();
5305 return Error(L,
".err encountered");
5307 StringRef Message =
".error directive invoked in source file";
5310 return TokError(
".error argument must be a string");
5312 Message = getTok().getStringContents();
5316 return Error(L, Message);
5321bool AsmParser::parseDirectiveWarning(SMLoc L) {
5322 if (!TheCondStack.empty()) {
5323 if (TheCondStack.back().Ignore) {
5324 eatToEndOfStatement();
5329 StringRef Message =
".warning directive invoked in source file";
5333 return TokError(
".warning argument must be a string");
5335 Message = getTok().getStringContents();
5346bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
5351 return Error(DirectiveLoc,
"Encountered a .endif that doesn't follow "
5353 if (!TheCondStack.empty()) {
5354 TheCondState = TheCondStack.back();
5355 TheCondStack.pop_back();
5361void AsmParser::initializeDirectiveKindMap() {
5368 DirectiveKindMap[
".set"] = DK_SET;
5369 DirectiveKindMap[
".equ"] = DK_EQU;
5370 DirectiveKindMap[
".equiv"] = DK_EQUIV;
5371 DirectiveKindMap[
".ascii"] = DK_ASCII;
5372 DirectiveKindMap[
".asciz"] = DK_ASCIZ;
5373 DirectiveKindMap[
".string"] = DK_STRING;
5374 DirectiveKindMap[
".byte"] = DK_BYTE;
5375 DirectiveKindMap[
".base64"] = DK_BASE64;
5376 DirectiveKindMap[
".short"] = DK_SHORT;
5377 DirectiveKindMap[
".value"] = DK_VALUE;
5378 DirectiveKindMap[
".2byte"] = DK_2BYTE;
5379 DirectiveKindMap[
".long"] = DK_LONG;
5380 DirectiveKindMap[
".int"] = DK_INT;
5381 DirectiveKindMap[
".4byte"] = DK_4BYTE;
5382 DirectiveKindMap[
".quad"] = DK_QUAD;
5383 DirectiveKindMap[
".8byte"] = DK_8BYTE;
5384 DirectiveKindMap[
".octa"] = DK_OCTA;
5385 DirectiveKindMap[
".single"] = DK_SINGLE;
5386 DirectiveKindMap[
".float"] = DK_FLOAT;
5387 DirectiveKindMap[
".double"] = DK_DOUBLE;
5388 DirectiveKindMap[
".align"] = DK_ALIGN;
5389 DirectiveKindMap[
".align32"] = DK_ALIGN32;
5390 DirectiveKindMap[
".balign"] = DK_BALIGN;
5391 DirectiveKindMap[
".balignw"] = DK_BALIGNW;
5392 DirectiveKindMap[
".balignl"] = DK_BALIGNL;
5393 DirectiveKindMap[
".p2align"] = DK_P2ALIGN;
5394 DirectiveKindMap[
".p2alignw"] = DK_P2ALIGNW;
5395 DirectiveKindMap[
".p2alignl"] = DK_P2ALIGNL;
5396 DirectiveKindMap[
".org"] = DK_ORG;
5397 DirectiveKindMap[
".fill"] = DK_FILL;
5398 DirectiveKindMap[
".zero"] = DK_ZERO;
5399 DirectiveKindMap[
".extern"] = DK_EXTERN;
5400 DirectiveKindMap[
".globl"] = DK_GLOBL;
5401 DirectiveKindMap[
".global"] = DK_GLOBAL;
5402 DirectiveKindMap[
".lazy_reference"] = DK_LAZY_REFERENCE;
5403 DirectiveKindMap[
".no_dead_strip"] = DK_NO_DEAD_STRIP;
5404 DirectiveKindMap[
".symbol_resolver"] = DK_SYMBOL_RESOLVER;
5405 DirectiveKindMap[
".private_extern"] = DK_PRIVATE_EXTERN;
5406 DirectiveKindMap[
".reference"] = DK_REFERENCE;
5407 DirectiveKindMap[
".weak_definition"] = DK_WEAK_DEFINITION;
5408 DirectiveKindMap[
".weak_reference"] = DK_WEAK_REFERENCE;
5409 DirectiveKindMap[
".weak_def_can_be_hidden"] = DK_WEAK_DEF_CAN_BE_HIDDEN;
5410 DirectiveKindMap[
".cold"] = DK_COLD;
5411 DirectiveKindMap[
".comm"] = DK_COMM;
5412 DirectiveKindMap[
".common"] = DK_COMMON;
5413 DirectiveKindMap[
".lcomm"] = DK_LCOMM;
5414 DirectiveKindMap[
".abort"] = DK_ABORT;
5415 DirectiveKindMap[
".include"] = DK_INCLUDE;
5416 DirectiveKindMap[
".incbin"] = DK_INCBIN;
5417 DirectiveKindMap[
".code16"] = DK_CODE16;
5418 DirectiveKindMap[
".code16gcc"] = DK_CODE16GCC;
5419 DirectiveKindMap[
".rept"] = DK_REPT;
5420 DirectiveKindMap[
".rep"] = DK_REPT;
5421 DirectiveKindMap[
".irp"] = DK_IRP;
5422 DirectiveKindMap[
".irpc"] = DK_IRPC;
5423 DirectiveKindMap[
".endr"] = DK_ENDR;
5424 DirectiveKindMap[
".if"] = DK_IF;
5425 DirectiveKindMap[
".ifeq"] = DK_IFEQ;
5426 DirectiveKindMap[
".ifge"] = DK_IFGE;
5427 DirectiveKindMap[
".ifgt"] = DK_IFGT;
5428 DirectiveKindMap[
".ifle"] = DK_IFLE;
5429 DirectiveKindMap[
".iflt"] = DK_IFLT;
5430 DirectiveKindMap[
".ifne"] = DK_IFNE;
5431 DirectiveKindMap[
".ifb"] = DK_IFB;
5432 DirectiveKindMap[
".ifnb"] = DK_IFNB;
5433 DirectiveKindMap[
".ifc"] = DK_IFC;
5434 DirectiveKindMap[
".ifeqs"] = DK_IFEQS;
5435 DirectiveKindMap[
".ifnc"] = DK_IFNC;
5436 DirectiveKindMap[
".ifnes"] = DK_IFNES;
5437 DirectiveKindMap[
".ifdef"] = DK_IFDEF;
5438 DirectiveKindMap[
".ifndef"] = DK_IFNDEF;
5439 DirectiveKindMap[
".ifnotdef"] = DK_IFNOTDEF;
5440 DirectiveKindMap[
".elseif"] = DK_ELSEIF;
5441 DirectiveKindMap[
".else"] = DK_ELSE;
5442 DirectiveKindMap[
".end"] = DK_END;
5443 DirectiveKindMap[
".endif"] = DK_ENDIF;
5444 DirectiveKindMap[
".skip"] = DK_SKIP;
5445 DirectiveKindMap[
".space"] = DK_SPACE;
5446 DirectiveKindMap[
".file"] = DK_FILE;
5447 DirectiveKindMap[
".line"] = DK_LINE;
5448 DirectiveKindMap[
".loc"] = DK_LOC;
5449 DirectiveKindMap[
".loc_label"] = DK_LOC_LABEL;
5450 DirectiveKindMap[
".stabs"] = DK_STABS;
5451 DirectiveKindMap[
".cv_file"] = DK_CV_FILE;
5452 DirectiveKindMap[
".cv_func_id"] = DK_CV_FUNC_ID;
5453 DirectiveKindMap[
".cv_loc"] = DK_CV_LOC;
5454 DirectiveKindMap[
".cv_linetable"] = DK_CV_LINETABLE;
5455 DirectiveKindMap[
".cv_inline_linetable"] = DK_CV_INLINE_LINETABLE;
5456 DirectiveKindMap[
".cv_inline_site_id"] = DK_CV_INLINE_SITE_ID;
5457 DirectiveKindMap[
".cv_def_range"] = DK_CV_DEF_RANGE;
5458 DirectiveKindMap[
".cv_string"] = DK_CV_STRING;
5459 DirectiveKindMap[
".cv_stringtable"] = DK_CV_STRINGTABLE;
5460 DirectiveKindMap[
".cv_filechecksums"] = DK_CV_FILECHECKSUMS;
5461 DirectiveKindMap[
".cv_filechecksumoffset"] = DK_CV_FILECHECKSUM_OFFSET;
5462 DirectiveKindMap[
".cv_fpo_data"] = DK_CV_FPO_DATA;
5463 DirectiveKindMap[
".sleb128"] = DK_SLEB128;
5464 DirectiveKindMap[
".uleb128"] = DK_ULEB128;
5465 DirectiveKindMap[
".cfi_sections"] = DK_CFI_SECTIONS;
5466 DirectiveKindMap[
".cfi_startproc"] = DK_CFI_STARTPROC;
5467 DirectiveKindMap[
".cfi_endproc"] = DK_CFI_ENDPROC;
5468 DirectiveKindMap[
".cfi_def_cfa"] = DK_CFI_DEF_CFA;
5469 DirectiveKindMap[
".cfi_def_cfa_offset"] = DK_CFI_DEF_CFA_OFFSET;
5470 DirectiveKindMap[
".cfi_adjust_cfa_offset"] = DK_CFI_ADJUST_CFA_OFFSET;
5471 DirectiveKindMap[
".cfi_def_cfa_register"] = DK_CFI_DEF_CFA_REGISTER;
5472 DirectiveKindMap[
".cfi_llvm_def_aspace_cfa"] = DK_CFI_LLVM_DEF_ASPACE_CFA;
5473 DirectiveKindMap[
".cfi_offset"] = DK_CFI_OFFSET;
5474 DirectiveKindMap[
".cfi_rel_offset"] = DK_CFI_REL_OFFSET;
5475 DirectiveKindMap[
".cfi_personality"] = DK_CFI_PERSONALITY;
5476 DirectiveKindMap[
".cfi_lsda"] = DK_CFI_LSDA;
5477 DirectiveKindMap[
".cfi_remember_state"] = DK_CFI_REMEMBER_STATE;
5478 DirectiveKindMap[
".cfi_restore_state"] = DK_CFI_RESTORE_STATE;
5479 DirectiveKindMap[
".cfi_same_value"] = DK_CFI_SAME_VALUE;
5480 DirectiveKindMap[
".cfi_restore"] = DK_CFI_RESTORE;
5481 DirectiveKindMap[
".cfi_escape"] = DK_CFI_ESCAPE;
5482 DirectiveKindMap[
".cfi_return_column"] = DK_CFI_RETURN_COLUMN;
5483 DirectiveKindMap[
".cfi_signal_frame"] = DK_CFI_SIGNAL_FRAME;
5484 DirectiveKindMap[
".cfi_undefined"] = DK_CFI_UNDEFINED;
5485 DirectiveKindMap[
".cfi_register"] = DK_CFI_REGISTER;
5486 DirectiveKindMap[
".cfi_window_save"] = DK_CFI_WINDOW_SAVE;
5487 DirectiveKindMap[
".cfi_label"] = DK_CFI_LABEL;
5488 DirectiveKindMap[
".cfi_b_key_frame"] = DK_CFI_B_KEY_FRAME;
5489 DirectiveKindMap[
".cfi_mte_tagged_frame"] = DK_CFI_MTE_TAGGED_FRAME;
5490 DirectiveKindMap[
".cfi_val_offset"] = DK_CFI_VAL_OFFSET;
5491 DirectiveKindMap[
".macros_on"] = DK_MACROS_ON;
5492 DirectiveKindMap[
".macros_off"] = DK_MACROS_OFF;
5493 DirectiveKindMap[
".macro"] = DK_MACRO;
5494 DirectiveKindMap[
".exitm"] = DK_EXITM;
5495 DirectiveKindMap[
".endm"] = DK_ENDM;
5496 DirectiveKindMap[
".endmacro"] = DK_ENDMACRO;
5497 DirectiveKindMap[
".purgem"] = DK_PURGEM;
5498 DirectiveKindMap[
".err"] = DK_ERR;
5499 DirectiveKindMap[
".error"] = DK_ERROR;
5500 DirectiveKindMap[
".warning"] = DK_WARNING;
5501 DirectiveKindMap[
".altmacro"] = DK_ALTMACRO;
5502 DirectiveKindMap[
".noaltmacro"] = DK_NOALTMACRO;
5503 DirectiveKindMap[
".reloc"] = DK_RELOC;
5504 DirectiveKindMap[
".dc"] = DK_DC;
5505 DirectiveKindMap[
".dc.a"] = DK_DC_A;
5506 DirectiveKindMap[
".dc.b"] = DK_DC_B;
5507 DirectiveKindMap[
".dc.d"] = DK_DC_D;
5508 DirectiveKindMap[
".dc.l"] = DK_DC_L;
5509 DirectiveKindMap[
".dc.s"] = DK_DC_S;
5510 DirectiveKindMap[
".dc.w"] = DK_DC_W;
5511 DirectiveKindMap[
".dc.x"] = DK_DC_X;
5512 DirectiveKindMap[
".dcb"] = DK_DCB;
5513 DirectiveKindMap[
".dcb.b"] = DK_DCB_B;
5514 DirectiveKindMap[
".dcb.d"] = DK_DCB_D;
5515 DirectiveKindMap[
".dcb.l"] = DK_DCB_L;
5516 DirectiveKindMap[
".dcb.s"] = DK_DCB_S;
5517 DirectiveKindMap[
".dcb.w"] = DK_DCB_W;
5518 DirectiveKindMap[
".dcb.x"] = DK_DCB_X;
5519 DirectiveKindMap[
".ds"] = DK_DS;
5520 DirectiveKindMap[
".ds.b"] = DK_DS_B;
5521 DirectiveKindMap[
".ds.d"] = DK_DS_D;
5522 DirectiveKindMap[
".ds.l"] = DK_DS_L;
5523 DirectiveKindMap[
".ds.p"] = DK_DS_P;
5524 DirectiveKindMap[
".ds.s"] = DK_DS_S;
5525 DirectiveKindMap[
".ds.w"] = DK_DS_W;
5526 DirectiveKindMap[
".ds.x"] = DK_DS_X;
5527 DirectiveKindMap[
".print"] = DK_PRINT;
5528 DirectiveKindMap[
".addrsig"] = DK_ADDRSIG;
5529 DirectiveKindMap[
".addrsig_sym"] = DK_ADDRSIG_SYM;
5530 DirectiveKindMap[
".pseudoprobe"] = DK_PSEUDO_PROBE;
5531 DirectiveKindMap[
".lto_discard"] = DK_LTO_DISCARD;
5532 DirectiveKindMap[
".lto_set_conditional"] = DK_LTO_SET_CONDITIONAL;
5533 DirectiveKindMap[
".memtag"] = DK_MEMTAG;
5536MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
5537 AsmToken EndToken, StartToken = getTok();
5539 unsigned NestLevel = 0;
5543 printError(DirectiveLoc,
"no matching '.endr' in definition");
5548 StringRef Ident = getTok().getIdentifier();
5549 if (Ident ==
".rep" || Ident ==
".rept" || Ident ==
".irp" ||
5552 }
else if (Ident ==
".endr") {
5553 if (NestLevel == 0) {
5554 EndToken = getTok();
5558 printError(getTok().getLoc(),
"expected newline");
5566 eatToEndOfStatement();
5571 StringRef Body = StringRef(BodyStart, BodyEnd - BodyStart);
5575 return &MacroLikeBodies.back();
5578void AsmParser::instantiateMacroLikeBody(MCAsmMacro *M, SMLoc DirectiveLoc,
5579 raw_svector_ostream &OS) {
5582 std::unique_ptr<MemoryBuffer> Instantiation =
5587 MacroInstantiation *
MI =
new MacroInstantiation{
5588 DirectiveLoc, CurBuffer, getTok().getLoc(), TheCondStack.size()};
5589 ActiveMacros.push_back(
MI);
5599bool AsmParser::parseDirectiveRept(SMLoc DirectiveLoc, StringRef Dir) {
5600 const MCExpr *CountExpr;
5601 SMLoc CountLoc = getTok().getLoc();
5602 if (parseExpression(CountExpr))
5606 if (!CountExpr->evaluateAsAbsolute(
Count, getStreamer().getAssemblerPtr())) {
5607 return Error(CountLoc,
"unexpected token in '" + Dir +
"' directive");
5610 if (check(
Count < 0, CountLoc,
"Count is negative") || parseEOL())
5614 MCAsmMacro *
M = parseMacroLikeBody(DirectiveLoc);
5620 SmallString<256> Buf;
5621 raw_svector_ostream OS(Buf);
5624 if (expandMacro(OS, *M, {}, {},
false))
5627 instantiateMacroLikeBody(M, DirectiveLoc, OS);
5634bool AsmParser::parseDirectiveIrp(SMLoc DirectiveLoc) {
5636 MCAsmMacroArguments
A;
5637 if (check(parseIdentifier(
Parameter.Name),
5638 "expected identifier in '.irp' directive") ||
5639 parseComma() || parseMacroArguments(
nullptr,
A) || parseEOL())
5643 MCAsmMacro *
M = parseMacroLikeBody(DirectiveLoc);
5649 SmallString<256> Buf;
5650 raw_svector_ostream OS(Buf);
5652 for (
const MCAsmMacroArgument &Arg :
A) {
5655 if (expandMacro(OS, *M, Parameter, Arg,
true))
5659 instantiateMacroLikeBody(M, DirectiveLoc, OS);
5666bool AsmParser::parseDirectiveIrpc(SMLoc DirectiveLoc) {
5668 MCAsmMacroArguments
A;
5670 if (check(parseIdentifier(
Parameter.Name),
5671 "expected identifier in '.irpc' directive") ||
5672 parseComma() || parseMacroArguments(
nullptr,
A))
5675 if (
A.size() != 1 ||
A.front().size() != 1)
5676 return TokError(
"unexpected token in '.irpc' directive");
5681 MCAsmMacro *
M = parseMacroLikeBody(DirectiveLoc);
5687 SmallString<256> Buf;
5688 raw_svector_ostream OS(Buf);
5691 :
A[0][0].getString();
5692 for (std::size_t
I = 0, End = Values.
size();
I != End; ++
I) {
5693 MCAsmMacroArgument Arg;
5698 if (expandMacro(OS, *M, Parameter, Arg,
true))
5702 instantiateMacroLikeBody(M, DirectiveLoc, OS);
5707bool AsmParser::parseDirectiveEndr(SMLoc DirectiveLoc) {
5708 if (ActiveMacros.empty())
5709 return TokError(
"unmatched '.endr' directive");
5719bool AsmParser::parseDirectiveMSEmit(SMLoc IDLoc, ParseStatementInfo &
Info,
5721 const MCExpr *
Value;
5722 SMLoc ExprLoc = getLexer().getLoc();
5723 if (parseExpression(
Value))
5727 return Error(ExprLoc,
"unexpected expression in _emit");
5728 uint64_t IntValue = MCE->
getValue();
5730 return Error(ExprLoc,
"literal value out of range for directive");
5736bool AsmParser::parseDirectiveMSAlign(SMLoc IDLoc, ParseStatementInfo &
Info) {
5737 const MCExpr *
Value;
5738 SMLoc ExprLoc = getLexer().getLoc();
5739 if (parseExpression(
Value))
5743 return Error(ExprLoc,
"unexpected expression in align");
5744 uint64_t IntValue = MCE->
getValue();
5746 return Error(ExprLoc,
"literal value not a power of two greater then zero");
5752bool AsmParser::parseDirectivePrint(SMLoc DirectiveLoc) {
5753 const AsmToken StrTok = getTok();
5756 return Error(DirectiveLoc,
"expected double quoted string after .print");
5763bool AsmParser::parseDirectiveAddrsig() {
5766 getStreamer().emitAddrsig();
5770bool AsmParser::parseDirectiveAddrsigSym() {
5772 if (check(
parseSymbol(Sym),
"expected identifier") || parseEOL())
5774 getStreamer().emitAddrsigSym(Sym);
5778bool AsmParser::parseDirectivePseudoProbe() {
5784 if (parseIntToken(
Guid))
5786 if (parseIntToken(Index))
5788 if (parseIntToken(
Type))
5790 if (parseIntToken(Attr))
5802 int64_t CallerGuid = 0;
5804 CallerGuid = getTok().getIntVal();
5812 int64_t CallerProbeId = 0;
5814 CallerProbeId = getTok().getIntVal();
5824 if (parseIdentifier(FnName))
5825 return Error(getLexer().getLoc(),
"expected identifier");
5831 getStreamer().emitPseudoProbe(
Guid, Index,
Type, Attr, Discriminator,
5832 InlineStack, FnSym);
5841bool AsmParser::parseDirectiveLTODiscard() {
5842 auto ParseOp = [&]() ->
bool {
5844 SMLoc Loc = getTok().getLoc();
5845 if (parseIdentifier(Name))
5846 return Error(Loc,
"expected identifier");
5847 LTODiscardSymbols.
insert(Name);
5851 LTODiscardSymbols.
clear();
5852 return parseMany(ParseOp);
5878bool AsmParser::parseMSInlineAsm(
5879 std::string &AsmString,
unsigned &NumOutputs,
unsigned &NumInputs,
5880 SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
5881 SmallVectorImpl<std::string> &Constraints,
5882 SmallVectorImpl<std::string> &Clobbers,
const MCInstrInfo *MII,
5883 MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
5884 SmallVector<void *, 4> InputDecls;
5885 SmallVector<void *, 4> OutputDecls;
5888 SmallVector<std::string, 4> InputConstraints;
5889 SmallVector<std::string, 4> OutputConstraints;
5898 unsigned InputIdx = 0;
5899 unsigned OutputIdx = 0;
5902 if (parseCurlyBlockScope(AsmStrRewrites))
5905 ParseStatementInfo
Info(&AsmStrRewrites);
5906 bool StatementErr = parseStatement(
Info, &SI);
5908 if (StatementErr ||
Info.ParseError) {
5910 printPendingErrors();
5915 assert(!hasPendingError() &&
"unexpected error from parseStatement");
5917 if (
Info.Opcode == ~0U)
5923 for (
unsigned i = 1, e =
Info.ParsedOperands.size(); i != e; ++i) {
5924 MCParsedAsmOperand &Operand = *
Info.ParsedOperands[i];
5928 !getTargetParser().omitRegisterFromClobberLists(Operand.
getReg())) {
5929 unsigned NumDefs =
Desc.getNumDefs();
5938 if (SymName.
empty())
5946 if (Operand.
isImm()) {
5954 bool isOutput = (i == 1) &&
Desc.mayStore();
5961 OutputConstraints.
push_back((
"=" + Constraint).str());
5968 if (
Desc.operands()[i - 1].isBranchTarget())
5982 NumOutputs = OutputDecls.
size();
5983 NumInputs = InputDecls.
size();
5988 Clobbers.
assign(ClobberRegs.
size(), std::string());
5989 for (
unsigned I = 0,
E = ClobberRegs.
size();
I !=
E; ++
I) {
5990 raw_string_ostream OS(Clobbers[
I]);
5995 if (NumOutputs || NumInputs) {
5996 unsigned NumExprs = NumOutputs + NumInputs;
5997 OpDecls.resize(NumExprs);
5998 Constraints.
resize(NumExprs);
5999 for (
unsigned i = 0; i < NumOutputs; ++i) {
6000 OpDecls[i] = std::make_pair(OutputDecls[i], OutputDeclsAddressOf[i]);
6001 Constraints[i] = OutputConstraints[i];
6003 for (
unsigned i = 0, j = NumOutputs; i < NumInputs; ++i, ++
j) {
6004 OpDecls[
j] = std::make_pair(InputDecls[i], InputDeclsAddressOf[i]);
6005 Constraints[
j] = InputConstraints[i];
6010 std::string AsmStringIR;
6011 raw_string_ostream OS(AsmStringIR);
6012 StringRef ASMString =
6014 const char *AsmStart = ASMString.
begin();
6015 const char *AsmEnd = ASMString.
end();
6017 for (
auto I = AsmStrRewrites.
begin(),
E = AsmStrRewrites.
end();
I !=
E; ++
I) {
6018 const AsmRewrite &AR = *
I;
6025 assert(Loc >= AsmStart &&
"Expected Loc to be at or after Start!");
6028 if (
unsigned Len = Loc - AsmStart)
6029 OS << StringRef(AsmStart, Len);
6033 AsmStart = Loc + AR.
Len;
6037 unsigned AdditionalSkip = 0;
6059 size_t OffsetLen = OffsetName.
size();
6060 auto rewrite_it = std::find_if(
6061 I, AsmStrRewrites.
end(), [&](
const AsmRewrite &FusingAR) {
6062 return FusingAR.Loc == OffsetLoc && FusingAR.Len == OffsetLen &&
6063 (FusingAR.Kind == AOK_Input ||
6064 FusingAR.Kind == AOK_CallInput);
6066 if (rewrite_it == AsmStrRewrites.
end()) {
6067 OS <<
"offset " << OffsetName;
6069 OS <<
"${" << InputIdx++ <<
":P}";
6070 rewrite_it->Done =
true;
6072 OS <<
'$' << InputIdx++;
6073 rewrite_it->Done =
true;
6086 OS <<
"${" << InputIdx++ <<
":P}";
6088 OS <<
'$' << InputIdx++;
6091 OS <<
"${" << InputIdx++ <<
":P}";
6095 OS <<
"${" << OutputIdx++ <<
":P}";
6097 OS <<
'$' << OutputIdx++;
6102 case 8: OS <<
"byte ptr ";
break;
6103 case 16: OS <<
"word ptr ";
break;
6104 case 32: OS <<
"dword ptr ";
break;
6105 case 64: OS <<
"qword ptr ";
break;
6106 case 80: OS <<
"xword ptr ";
break;
6107 case 128: OS <<
"xmmword ptr ";
break;
6108 case 256: OS <<
"ymmword ptr ";
break;
6118 if (
getContext().getAsmInfo()->getAlignmentIsInBytes())
6123 unsigned Val = AR.
Val;
6125 assert(Val < 10 &&
"Expected alignment less then 2^10.");
6126 AdditionalSkip = (Val < 4) ? 2 : Val < 7 ? 3 : 4;
6138 AsmStart = Loc + AR.
Len + AdditionalSkip;
6142 if (AsmStart != AsmEnd)
6143 OS << StringRef(AsmStart, AsmEnd - AsmStart);
6145 AsmString = std::move(AsmStringIR);
6149bool HLASMAsmParser::parseAsHLASMLabel(ParseStatementInfo &
Info,
6150 MCAsmParserSemaCallback *SI) {
6151 AsmToken LabelTok = getTok();
6152 SMLoc LabelLoc = LabelTok.
getLoc();
6155 if (parseIdentifier(LabelVal))
6156 return Error(LabelLoc,
"The HLASM Label has to be an Identifier");
6161 if (!getTargetParser().isLabel(LabelTok) || checkForValidSection())
6170 return Error(LabelLoc,
6171 "Cannot have just a label for an HLASM inline asm statement");
6181 if (enabledGenDwarfForAssembly())
6188bool HLASMAsmParser::parseAsMachineInstruction(ParseStatementInfo &
Info,
6189 MCAsmParserSemaCallback *SI) {
6190 AsmToken OperationEntryTok = Lexer.
getTok();
6191 SMLoc OperationEntryLoc = OperationEntryTok.
getLoc();
6192 StringRef OperationEntryVal;
6195 if (parseIdentifier(OperationEntryVal))
6196 return Error(OperationEntryLoc,
"unexpected token at start of statement");
6202 return parseAndMatchAndEmitTargetInstruction(
6203 Info, OperationEntryVal, OperationEntryTok, OperationEntryLoc);
6206bool HLASMAsmParser::parseStatement(ParseStatementInfo &
Info,
6207 MCAsmParserSemaCallback *SI) {
6208 assert(!hasPendingError() &&
"parseStatement started with pending error");
6211 bool ShouldParseAsHLASMLabel =
false;
6220 ShouldParseAsHLASMLabel =
true;
6226 if (getTok().getString().
empty() || getTok().getString().
front() ==
'\r' ||
6227 getTok().getString().
front() ==
'\n')
6242 if (getTok().getString().
front() ==
'\n' ||
6243 getTok().getString().
front() ==
'\r') {
6252 if (ShouldParseAsHLASMLabel) {
6255 if (parseAsHLASMLabel(
Info, SI)) {
6258 eatToEndOfStatement();
6263 return parseAsMachineInstruction(
Info, SI);
6275 return Parser.
TokError(
"missing expression");
6281 return Parser.
Error(
6282 EqualLoc,
"relocation specifier not permitted in symbol equating");
6290 return Parser.
Error(EqualLoc,
"redefinition of '" + Name +
"'");
6296 }
else if (Name ==
".") {
6311 if (
C.getTargetTriple().isSystemZ() &&
C.getTargetTriple().isOSzOS())
6312 return new HLASMAsmParser(SM,
C, Out, MAI, CB);
6314 return new AsmParser(SM,
C, Out, MAI, CB);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static Expected< std::vector< unsigned > > getSymbols(SymbolicFile *Obj, uint16_t Index, raw_ostream &SymNames, SymMap *SymMap)
static bool isValidEncoding(int64_t Encoding)
static bool isAngleBracketString(SMLoc &StrLoc, SMLoc &EndLoc)
This function checks if the next token is <string> type or arithmetic.
static unsigned getDarwinBinOpPrecedence(AsmToken::TokenKind K, MCBinaryExpr::Opcode &Kind, bool ShouldUseLogicalShr)
static unsigned getGNUBinOpPrecedence(const MCAsmInfo &MAI, AsmToken::TokenKind K, MCBinaryExpr::Opcode &Kind, bool ShouldUseLogicalShr)
static std::string angleBracketString(StringRef AltMacroStr)
creating a string without the escape characters '!'.
static int rewritesSort(const AsmRewrite *AsmRewriteA, const AsmRewrite *AsmRewriteB)
static bool parseHexOcta(AsmParser &Asm, uint64_t &hi, uint64_t &lo)
static bool isOperator(AsmToken::TokenKind kind)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
This file contains constants used for implementing Dwarf debug support.
#define DWARF2_FLAG_IS_STMT
#define DWARF2_FLAG_BASIC_BLOCK
#define DWARF2_LINE_DEFAULT_IS_STMT
#define DWARF2_FLAG_PROLOGUE_END
#define DWARF2_FLAG_EPILOGUE_BEGIN
static bool isIdentifierChar(char C)
Return true if the given character satisfies the following regular expression: [-a-zA-Z$....
Promote Memory to Register
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
This file defines the SmallSet class.
This file defines the SmallString class.
This file defines the SmallVector class.
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
Class for arbitrary precision integers.
LLVM_ABI APInt getLoBits(unsigned numBits) const
Compute an APInt containing numBits lowbits from this APInt.
uint64_t getZExtValue() const
Get zero extended value.
LLVM_ABI APInt getHiBits(unsigned numBits) const
Compute an APInt containing numBits highbits from this APInt.
unsigned getBitWidth() const
Return the number of bits in the APInt.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
ConditionalAssemblyType TheCond
SMLoc getLoc() const
Get the current source location.
const AsmToken peekTok(bool ShouldSkipSpace=true)
Look ahead at the next token to be lexed.
bool getAllowAtInIdentifier()
void UnLex(AsmToken const &Token)
AsmToken::TokenKind getKind() const
Get the kind of current token.
const MCAsmInfo & getMAI() const
const AsmToken & getTok() const
Get the current (last) lexed token.
bool is(AsmToken::TokenKind K) const
Check if the current token has kind K.
SMLoc getErrLoc()
Get the current error location.
const std::string & getErr()
Get the current error string.
const AsmToken & Lex()
Consume the next token from the input stream and return it.
void setSkipSpace(bool val)
Set whether spaces should be ignored by the lexer.
LLVM_ABI void setBuffer(StringRef Buf, const char *ptr=nullptr, bool EndStatementAtEOF=true)
Set buffer to be lexed.
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
LLVM_ABI size_t peekTokens(MutableArrayRef< AsmToken > Buf, bool ShouldSkipSpace=true)
Look ahead an arbitrary number of tokens.
LLVM_ABI SMLoc getLoc() const
bool isNot(TokenKind K) const
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
StringRef getStringContents() const
Get the contents of a string token (without quotes).
bool is(TokenKind K) const
LLVM_ABI SMLoc getEndLoc() const
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
Error takeError()
Take ownership of the stored error.
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool preserveAsmComments() const
Return true if assembly (inline or otherwise) should be parsed.
bool isLittleEndian() const
True if the target is little endian.
bool useAtForSpecifier() const
bool doesAllowAtInName() const
StringRef getPrivateLabelPrefix() const
std::optional< uint32_t > getSpecifierForName(StringRef Name) const
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
bool shouldUseLogicalShr() const
StringRef getCommentString() const
bool hasSubsectionsViaSymbols() const
bool getCOMMDirectiveAlignmentIsInBytes() const
virtual bool useCodeAlign(const MCSection &Sec) const
bool useParensForSpecifier() const
bool getDollarIsPC() const
virtual ~MCAsmParserSemaCallback()
Generic assembler parser interface, for use by target specific assembly parsers.
bool Error(SMLoc L, const Twine &Msg, SMRange Range={})
Return an error at the location L, with the message Msg.
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
bool parseAtSpecifier(const MCExpr *&Res, SMLoc &EndLoc)
const AsmToken & getTok() const
Get the current AsmToken from the stream.
const MCExpr * applySpecifier(const MCExpr *E, uint32_t Variant)
bool parseOptionalToken(AsmToken::TokenKind T)
Attempt to parse and consume token, returning true on success.
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
bool TokError(const Twine &Msg, SMRange Range={})
Report an error at the current lexer location.
MCStreamer & getStreamer()
MCTargetAsmParser & getTargetParser() const
Binary assembler expressions.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Opcode getOpcode() const
Get the kind of this binary expression.
static LLVM_ABI const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
@ AShr
Arithmetic shift right.
@ LShr
Logical shift right.
@ GTE
Signed greater than or equal comparison (result is either 0 or some target-specific non-zero value).
@ GT
Signed greater than comparison (result is either 0 or some target-specific non-zero value)
@ Xor
Bitwise exclusive or.
@ LT
Signed less than comparison (result is either 0 or some target-specific non-zero value).
@ LTE
Signed less than or equal comparison (result is either 0 or some target-specific non-zero value).
@ NE
Inequality comparison.
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
void * allocate(unsigned Size, unsigned Align=8)
bool isDwarfMD5UsageConsistent(unsigned CUID) const
Reports whether MD5 checksum usage is consistent (all-or-none).
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
bool getGenDwarfForAssembly()
void setGenDwarfForAssembly(bool Value)
void setDwarfVersion(uint16_t v)
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
LLVM_ABI MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
LLVM_ABI MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions).
uint16_t getDwarfVersion() const
const MCAsmInfo * getAsmInfo() const
LLVM_ABI MCSymbol * cloneSymbol(MCSymbol &Sym)
Clone a symbol for the .set directive, replacing it in the symbol table.
LLVM_ABI MCSymbol * parseSymbol(const Twine &Name)
Variant of getOrCreateSymbol that handles backslash-escaped symbols.
LLVM_ABI MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references).
Base class for the full range of assembler expressions which are needed for parsing.
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
@ Unary
Unary expressions.
@ Constant
Constant expressions.
@ SymbolRef
References to labels and assigned expressions.
@ Target
Target specific expression.
@ Specifier
Expression with a relocation specifier.
@ Binary
Binary expressions.
static LLVM_ABI void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)
virtual void printRegName(raw_ostream &OS, MCRegister Reg)
Print the assembler register name.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
virtual bool isMemUseUpRegs() const
isMemUseUpRegs - Is memory operand use up regs, for example, intel MS inline asm may use ARR[baseReg ...
virtual bool isReg() const =0
isReg - Is this a register operand?
virtual bool needAddressOf() const
needAddressOf - Do we need to emit code to get the address of the variable/label?
virtual MCRegister getReg() const =0
virtual bool isOffsetOfLocal() const
isOffsetOfLocal - Do we need to emit code to get the offset of the local variable,...
virtual StringRef getSymName()
virtual bool isImm() const =0
isImm - Is this an immediate operand?
unsigned getMCOperandNum()
StringRef getConstraint()
virtual void * getOpDecl()
void setBeginSymbol(MCSymbol *Sym)
MCSymbol * getBeginSymbol()
Streaming machine code generation interface.
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void addBlankLine()
Emit a blank line to a .s file to pretty it up.
virtual void initSections(bool NoExecStack, const MCSubtargetInfo &STI)
Create the default sections and set the initial one.
void setStartTokLocPtr(const SMLoc *Loc)
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
MCTargetStreamer * getTargetStreamer()
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
virtual void emitConditionalAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol, but only if Value is also emitted.
void finish(SMLoc EndLoc=SMLoc())
Finish emission of machine code.
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
uint16_t getSpecifier() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
StringRef getName() const
getName - Get the symbol name.
bool isVariable() const
isVariable - Check if this is a variable symbol.
bool isRedefinable() const
Check if this symbol is redefinable.
void setRedefinable(bool Value)
Mark this symbol as redefinable.
void redefineIfPossible()
Prepare this symbol to be redefined.
const MCExpr * getVariableValue() const
Get the expression of the variable symbol.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Unary assembler expressions.
Opcode getOpcode() const
Get the kind of this unary expression.
static LLVM_ABI const MCUnaryExpr * create(Opcode Op, const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCUnaryExpr * createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
const MCExpr * getSubExpr() const
Get the child of this unary expression.
static const MCUnaryExpr * createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCUnaryExpr * createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
StringRef getBuffer() const
constexpr bool isFailure() const
constexpr bool isSuccess() const
SourceMgr::DiagKind getKind() const
StringRef getLineContents() const
StringRef getMessage() const
ArrayRef< std::pair< unsigned, unsigned > > getRanges() const
const SourceMgr * getSourceMgr() const
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
constexpr bool isValid() const
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
void assign(size_type NumElts, ValueParamT Elt)
reference emplace_back(ArgTypes &&... Args)
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
unsigned getMainFileID() const
const MemoryBuffer * getMemoryBuffer(unsigned i) const
LLVM_ABI void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
SMLoc getParentIncludeLoc(unsigned i) const
LLVM_ABI void PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const
Prints the names of included files and the line of the file they were included from.
LLVM_ABI unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
void(*)(const SMDiagnostic &, void *Context) DiagHandlerTy
Clients that want to handle their own diagnostics in a custom way can register a function pointer+con...
void setDiagHandler(DiagHandlerTy DH, void *Ctx=nullptr)
Specify a diagnostic handler to be invoked every time PrintMessage is called.
LLVM_ABI unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc, std::string &IncludedFile)
Search for a file with the specified name in the current directory or in one of the IncludeDirs.
unsigned FindLineNumber(SMLoc Loc, unsigned BufferID=0) const
Find the line number for the specified location in the specified file.
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
StringMapIterBase< ValueTy, true > const_iterator
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
std::string str() const
str - Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
LLVM_ABI std::string upper() const
Convert the given ASCII string to uppercase.
constexpr size_t size() const
size - Get the string size.
char front() const
front - Get the first character in the string.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
LLVM_ABI std::string lower() const
LLVM_ABI int compare_insensitive(StringRef RHS) const
Compare two strings, ignoring case.
LLVM Value Representation.
StringRef str() const
Return a StringRef for the vector contents.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
bool parseAssignmentExpression(StringRef Name, bool allow_redef, MCAsmParser &Parser, MCSymbol *&Symbol, const MCExpr *&Value)
Parse a value expression and return whether it can be assigned to a symbol with the given name.
LLVM_ABI SimpleSymbol parseSymbol(StringRef SymName)
Get symbol classification by parsing the name of a symbol.
std::variant< std::monostate, DecisionParameters, BranchParameters > Parameters
The type of MC/DC-specific parameters.
@ Parameter
An inlay hint that is for a parameter.
Context & getContext() const
LLVM_ABI Instruction & front() const
This is an optimization pass for GlobalISel generic memory operations.
bool errorToBool(Error Err)
Helper for converting an Error to a bool.
FunctionAddr VTableAddr Value
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
std::string fromHex(StringRef Input)
Convert hexadecimal string Input to its binary representation. The return string is half the size of ...
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
std::tuple< uint64_t, uint32_t > InlineSite
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
std::vector< MCAsmMacroParameter > MCAsmMacroParameters
auto unique(Range &&R, Predicate P)
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
auto reverse(ContainerTy &&C)
cl::opt< unsigned > AsmMacroMaxNestingDepth
SmallVector< InlineSite, 8 > MCPseudoProbeInlineStack
const char AsmRewritePrecedence[]
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static bool hasDiscriminator(uint32_t Flags)
bool isDigit(char C)
Checks if character C is one of the 10 decimal digits.
FunctionAddr VTableAddr Count
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
LLVM_ABI llvm::Error decodeBase64(llvm::StringRef Input, std::vector< char > &Output)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI MCAsmParser * createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &, const MCAsmInfo &, unsigned CB=0)
Create an MCAsmParser instance for parsing assembly similar to gas syntax.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
@ Sub
Subtraction of integers.
FunctionAddr VTableAddr Next
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
ArrayRef(const T &OneElt) -> ArrayRef< T >
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
bool isHexDigit(char C)
Checks if character C is a hexadecimal numeric character.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
void consumeError(Error Err)
Consume a Error without doing anything.
@ MCSA_WeakDefAutoPrivate
.weak_def_can_be_hidden (MachO)
@ MCSA_Memtag
.memtag (ELF)
@ MCSA_PrivateExtern
.private_extern (MachO)
@ MCSA_WeakReference
.weak_reference (MachO)
@ MCSA_LazyReference
.lazy_reference (MachO)
@ MCSA_Reference
.reference (MachO)
@ MCSA_SymbolResolver
.symbol_resolver (MachO)
@ MCSA_WeakDefinition
.weak_definition (MachO)
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
ArrayRef< int > hi(ArrayRef< int > Vuu)
ArrayRef< int > lo(ArrayRef< int > Vuu)
std::vector< AsmToken > Value
std::optional< MD5::MD5Result > Checksum
The MD5 checksum, if there is one.
std::optional< StringRef > Source
The source code of the file.