aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCParser
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2025-02-03 18:51:27 +0000
committerDimitry Andric <dim@FreeBSD.org>2025-02-03 18:51:27 +0000
commit32a711e1c447004eb1fd015925f305ed1d8426de (patch)
tree6647b84917053748367f573f9bdc66e809cb17f5 /llvm/lib/MC/MCParser
parentac9a064cb179f3425b310fa2847f8764ac970a4d (diff)
Vendor import of llvm-project main llvmorg-20-init-19504-g8c2574832ed2,vendor/llvm-project/llvmorg-20-init-19504-g8c2574832ed2vendor/llvm-project/main
the last commit before the upstream release/20.x branch was created.
Diffstat (limited to 'llvm/lib/MC/MCParser')
-rw-r--r--llvm/lib/MC/MCParser/AsmLexer.cpp4
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp163
-rw-r--r--llvm/lib/MC/MCParser/COFFAsmParser.cpp254
-rw-r--r--llvm/lib/MC/MCParser/COFFMasmParser.cpp95
-rw-r--r--llvm/lib/MC/MCParser/DarwinAsmParser.cpp2
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp174
-rw-r--r--llvm/lib/MC/MCParser/MCAsmParserExtension.cpp4
-rw-r--r--llvm/lib/MC/MCParser/MasmParser.cpp30
8 files changed, 389 insertions, 337 deletions
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index 778ca340e124..32b6e869cc63 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -707,7 +707,7 @@ size_t AsmLexer::peekTokens(MutableArrayRef<AsmToken> Buf,
}
bool AsmLexer::isAtStartOfComment(const char *Ptr) {
- if (MAI.getRestrictCommentStringToStartOfStatement() && !IsAtStartOfStatement)
+ if (MAI.isHLASM() && !IsAtStartOfStatement)
return false;
StringRef CommentString = MAI.getCommentString();
@@ -836,7 +836,7 @@ AsmToken AsmLexer::LexToken() {
return LexIdentifier();
return AsmToken(AsmToken::At, StringRef(TokStart, 1));
case '#':
- if (MAI.doesAllowHashAtStartOfIdentifier())
+ if (MAI.isHLASM())
return LexIdentifier();
return AsmToken(AsmToken::Hash, StringRef(TokStart, 1));
case '?':
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 992b69f1c5f3..bf952df1b241 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -162,8 +162,8 @@ private:
};
CppHashInfoTy CppHashInfo;
- /// The filename from the first cpp hash file line comment, if any.
- StringRef FirstCppHashFilename;
+ /// Have we seen any file line comment.
+ bool HadCppHashFilename = false;
/// List of forward directional labels for diagnosis at the end.
SmallVector<std::tuple<SMLoc, CppHashInfoTy, MCSymbol *>, 4> DirLabels;
@@ -264,7 +264,7 @@ public:
SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
SmallVectorImpl<std::string> &Constraints,
SmallVectorImpl<std::string> &Clobbers,
- const MCInstrInfo *MII, const MCInstPrinter *IP,
+ const MCInstrInfo *MII, MCInstPrinter *IP,
MCAsmParserSemaCallback &SI) override;
bool parseExpression(const MCExpr *&Res);
@@ -485,6 +485,7 @@ private:
DK_FILE,
DK_LINE,
DK_LOC,
+ DK_LOC_LABEL,
DK_STABS,
DK_CV_FILE,
DK_CV_FUNC_ID,
@@ -522,6 +523,7 @@ private:
DK_CFI_WINDOW_SAVE,
DK_CFI_LABEL,
DK_CFI_B_KEY_FRAME,
+ DK_CFI_VAL_OFFSET,
DK_MACROS_ON,
DK_MACROS_OFF,
DK_ALTMACRO,
@@ -580,10 +582,11 @@ private:
// ".align{,32}", ".p2align{,w,l}"
bool parseDirectiveAlign(bool IsPow2, unsigned ValueSize);
- // ".file", ".line", ".loc", ".stabs"
+ // ".file", ".line", ".loc", ".loc_label", ".stabs"
bool parseDirectiveFile(SMLoc DirectiveLoc);
bool parseDirectiveLine();
bool parseDirectiveLoc();
+ bool parseDirectiveLocLabel(SMLoc DirectiveLoc);
bool parseDirectiveStabs();
// ".cv_file", ".cv_func_id", ".cv_inline_site_id", ".cv_loc", ".cv_linetable",
@@ -624,6 +627,7 @@ private:
bool parseDirectiveCFISignalFrame(SMLoc DirectiveLoc);
bool parseDirectiveCFIUndefined(SMLoc DirectiveLoc);
bool parseDirectiveCFILabel(SMLoc DirectiveLoc);
+ bool parseDirectiveCFIValOffset(SMLoc DirectiveLoc);
// macro directives
bool parseDirectivePurgeMacro(SMLoc DirectiveLoc);
@@ -948,12 +952,6 @@ bool AsmParser::enabledGenDwarfForAssembly() {
// the assembler source was produced with debug info already) then emit one
// describing the assembler source file itself.
if (getContext().getGenDwarfFileNumber() == 0) {
- // Use the first #line directive for this, if any. It's preprocessed, so
- // there is no checksum, and of course no source directive.
- if (!FirstCppHashFilename.empty())
- getContext().setMCLineTableRootFile(
- /*CUID=*/0, getContext().getCompilationDir(), FirstCppHashFilename,
- /*Cksum=*/std::nullopt, /*Source=*/std::nullopt);
const MCDwarfFile &RootFile =
getContext().getMCDwarfLineTable(/*CUID=*/0).getRootFile();
getContext().setGenDwarfFileNumber(getStreamer().emitDwarfFileDirective(
@@ -1042,7 +1040,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
// Check to see that all assembler local symbols were actually defined.
// Targets that don't do subsections via symbols may not want this, though,
// so conservatively exclude them. Only do this if we're finalizing, though,
- // as otherwise we won't necessarilly have seen everything yet.
+ // as otherwise we won't necessarily have seen everything yet.
if (!NoFinalize) {
if (MAI.hasSubsectionsViaSymbols()) {
for (const auto &TableEntry : getContext().getSymbols()) {
@@ -1183,7 +1181,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
if (getTok().is(AsmToken::Dollar) || getTok().is(AsmToken::Star)) {
bool ShouldGenerateTempSymbol = false;
if ((getTok().is(AsmToken::Dollar) && MAI.getDollarIsPC()) ||
- (getTok().is(AsmToken::Star) && MAI.getStarIsPC()))
+ (getTok().is(AsmToken::Star) && MAI.isHLASM()))
ShouldGenerateTempSymbol = true;
if (!ShouldGenerateTempSymbol)
@@ -1250,8 +1248,8 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
MCSymbol *Sym = getContext().getInlineAsmLabel(SymbolName);
if (!Sym)
- Sym = getContext().getOrCreateSymbol(
- MAI.shouldEmitLabelsInUpperCase() ? SymbolName.upper() : SymbolName);
+ Sym = getContext().getOrCreateSymbol(MAI.isHLASM() ? SymbolName.upper()
+ : SymbolName);
// If this is an absolute variable reference, substitute it now to preserve
// semantics in the face of reassignment.
@@ -1314,7 +1312,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
return false;
}
case AsmToken::Dot: {
- if (!MAI.getDotIsPC())
+ if (MAI.isHLASM())
return TokError("cannot use . as current PC");
// This is a '.' reference, which references the current PC. Emit a
@@ -2156,6 +2154,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
return parseDirectiveLine();
case DK_LOC:
return parseDirectiveLoc();
+ case DK_LOC_LABEL:
+ return parseDirectiveLocLabel(IDLoc);
case DK_STABS:
return parseDirectiveStabs();
case DK_CV_FILE:
@@ -2228,6 +2228,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
return parseDirectiveCFIWindowSave(IDLoc);
case DK_CFI_LABEL:
return parseDirectiveCFILabel(IDLoc);
+ case DK_CFI_VAL_OFFSET:
+ return parseDirectiveCFIValOffset(IDLoc);
case DK_MACROS_ON:
case DK_MACROS_OFF:
return parseDirectiveMacrosOnOff(IDVal);
@@ -2322,7 +2324,7 @@ bool AsmParser::parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &Info,
// Canonicalize the opcode to lower case.
std::string OpcodeStr = IDVal.lower();
ParseInstructionInfo IInfo(Info.AsmRewrites);
- bool ParseHadError = getTargetParser().ParseInstruction(IInfo, OpcodeStr, ID,
+ bool ParseHadError = getTargetParser().parseInstruction(IInfo, OpcodeStr, ID,
Info.ParsedOperands);
Info.ParseError = ParseHadError;
@@ -2379,7 +2381,7 @@ bool AsmParser::parseAndMatchAndEmitTargetInstruction(ParseStatementInfo &Info,
// If parsing succeeded, match the instruction.
if (!ParseHadError) {
uint64_t ErrorInfo;
- if (getTargetParser().MatchAndEmitInstruction(
+ if (getTargetParser().matchAndEmitInstruction(
IDLoc, Info.Opcode, Info.ParsedOperands, Out, ErrorInfo,
getTargetParser().isParsingMSInlineAsm()))
return true;
@@ -2432,8 +2434,20 @@ bool AsmParser::parseCppHashLineFilenameComment(SMLoc L, bool SaveLocInfo) {
CppHashInfo.Filename = Filename;
CppHashInfo.LineNumber = LineNumber;
CppHashInfo.Buf = CurBuffer;
- if (FirstCppHashFilename.empty())
- FirstCppHashFilename = Filename;
+ if (!HadCppHashFilename) {
+ HadCppHashFilename = true;
+ // If we haven't encountered any .file directives, then the first #line
+ // directive describes the "root" file and directory of the compilation
+ // unit.
+ if (getContext().getGenDwarfForAssembly() &&
+ getContext().getGenDwarfFileNumber() == 0) {
+ // It's preprocessed, so there is no checksum, and of course no source
+ // directive.
+ getContext().setMCLineTableRootFile(
+ /*CUID=*/0, getContext().getCompilationDir(), Filename,
+ /*Cksum=*/std::nullopt, /*Source=*/std::nullopt);
+ }
+ }
return false;
}
@@ -3033,7 +3047,11 @@ bool AsmParser::parseEscapedString(std::string &Data) {
StringRef Str = getTok().getStringContents();
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
if (Str[i] != '\\') {
- if (Str[i] == '\n') {
+ if ((Str[i] == '\n') || (Str[i] == '\r')) {
+ // Don't double-warn for Windows newlines.
+ if ((Str[i] == '\n') && (i > 0) && (Str[i - 1] == '\r'))
+ continue;
+
SMLoc NewlineLoc = SMLoc::getFromPointer(Str.data() + i);
if (Warning(NewlineLoc, "unterminated string; newline inserted"))
return true;
@@ -3462,17 +3480,6 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
}
}
- if (HasFillExpr && FillExpr != 0) {
- MCSection *Sec = getStreamer().getCurrentSectionOnly();
- if (Sec && Sec->isVirtualSection()) {
- ReturnVal |=
- Warning(FillExprLoc, "ignoring non-zero fill value in " +
- Sec->getVirtualSectionKind() + " section '" +
- Sec->getName() + "'");
- FillExpr = 0;
- }
- }
-
// Diagnose non-sensical max bytes to align.
if (MaxBytesLoc.isValid()) {
if (MaxBytesToFill < 1) {
@@ -3489,13 +3496,20 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
}
}
- // Check whether we should use optimal code alignment for this .align
- // directive.
const MCSection *Section = getStreamer().getCurrentSectionOnly();
assert(Section && "must have section to emit alignment");
- bool useCodeAlign = Section->useCodeAlign();
- if ((!HasFillExpr || Lexer.getMAI().getTextAlignFillValue() == FillExpr) &&
- ValueSize == 1 && useCodeAlign) {
+
+ if (HasFillExpr && FillExpr != 0 && Section->isVirtualSection()) {
+ ReturnVal |=
+ Warning(FillExprLoc, "ignoring non-zero fill value in " +
+ Section->getVirtualSectionKind() +
+ " section '" + Section->getName() + "'");
+ FillExpr = 0;
+ }
+
+ // Check whether we should use optimal code alignment for this .align
+ // directive.
+ if (Section->useCodeAlign() && !HasFillExpr) {
getStreamer().emitCodeAlignment(
Align(Alignment), &getTargetParser().getSTI(), MaxBytesToFill);
} else {
@@ -3737,6 +3751,19 @@ bool AsmParser::parseDirectiveLoc() {
return false;
}
+/// parseDirectiveLoc
+/// ::= .loc_label label
+bool AsmParser::parseDirectiveLocLabel(SMLoc DirectiveLoc) {
+ StringRef Name;
+ DirectiveLoc = Lexer.getLoc();
+ if (parseIdentifier(Name))
+ return TokError("expected identifier");
+ if (parseEOL())
+ return true;
+ getStreamer().emitDwarfLocLabelDirective(DirectiveLoc, Name);
+ return false;
+}
+
/// parseDirectiveStabs
/// ::= .stabs string, number, number, number
bool AsmParser::parseDirectiveStabs() {
@@ -4514,6 +4541,20 @@ bool AsmParser::parseDirectiveCFILabel(SMLoc Loc) {
return false;
}
+/// parseDirectiveCFIValOffset
+/// ::= .cfi_val_offset register, offset
+bool AsmParser::parseDirectiveCFIValOffset(SMLoc DirectiveLoc) {
+ int64_t Register = 0;
+ int64_t Offset = 0;
+
+ if (parseRegisterOrRegisterNumber(Register, DirectiveLoc) || parseComma() ||
+ parseAbsoluteExpression(Offset) || parseEOL())
+ return true;
+
+ getStreamer().emitCFIValOffset(Register, Offset, DirectiveLoc);
+ return false;
+}
+
/// parseDirectiveAltmacro
/// ::= .altmacro
/// ::= .noaltmacro
@@ -5545,6 +5586,7 @@ void AsmParser::initializeDirectiveKindMap() {
DirectiveKindMap[".file"] = DK_FILE;
DirectiveKindMap[".line"] = DK_LINE;
DirectiveKindMap[".loc"] = DK_LOC;
+ DirectiveKindMap[".loc_label"] = DK_LOC_LABEL;
DirectiveKindMap[".stabs"] = DK_STABS;
DirectiveKindMap[".cv_file"] = DK_CV_FILE;
DirectiveKindMap[".cv_func_id"] = DK_CV_FUNC_ID;
@@ -5585,6 +5627,7 @@ void AsmParser::initializeDirectiveKindMap() {
DirectiveKindMap[".cfi_label"] = DK_CFI_LABEL;
DirectiveKindMap[".cfi_b_key_frame"] = DK_CFI_B_KEY_FRAME;
DirectiveKindMap[".cfi_mte_tagged_frame"] = DK_CFI_MTE_TAGGED_FRAME;
+ DirectiveKindMap[".cfi_val_offset"] = DK_CFI_VAL_OFFSET;
DirectiveKindMap[".macros_on"] = DK_MACROS_ON;
DirectiveKindMap[".macros_off"] = DK_MACROS_OFF;
DirectiveKindMap[".macro"] = DK_MACRO;
@@ -5718,7 +5761,7 @@ bool AsmParser::parseDirectiveRept(SMLoc DirectiveLoc, StringRef Dir) {
raw_svector_ostream OS(Buf);
while (Count--) {
// Note that the AtPseudoVariable is disabled for instantiations of .rep(t).
- if (expandMacro(OS, *M, std::nullopt, std::nullopt, false))
+ if (expandMacro(OS, *M, {}, {}, false))
return true;
}
instantiateMacroLikeBody(M, DirectiveLoc, OS);
@@ -5784,10 +5827,11 @@ bool AsmParser::parseDirectiveIrpc(SMLoc DirectiveLoc) {
SmallString<256> Buf;
raw_svector_ostream OS(Buf);
- StringRef Values = A.front().front().getString();
+ StringRef Values = A[0][0].is(AsmToken::String) ? A[0][0].getStringContents()
+ : A[0][0].getString();
for (std::size_t I = 0, End = Values.size(); I != End; ++I) {
MCAsmMacroArgument Arg;
- Arg.emplace_back(AsmToken::Identifier, Values.slice(I, I + 1));
+ Arg.emplace_back(AsmToken::Identifier, Values.substr(I, 1));
// Note that the AtPseudoVariable is enabled for instantiations of .irpc.
// This is undocumented, but GAS seems to support it.
@@ -5987,14 +6031,14 @@ bool AsmParser::parseMSInlineAsm(
SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
SmallVectorImpl<std::string> &Constraints,
SmallVectorImpl<std::string> &Clobbers, const MCInstrInfo *MII,
- const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
+ MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
SmallVector<void *, 4> InputDecls;
SmallVector<void *, 4> OutputDecls;
SmallVector<bool, 4> InputDeclsAddressOf;
SmallVector<bool, 4> OutputDeclsAddressOf;
SmallVector<std::string, 4> InputConstraints;
SmallVector<std::string, 4> OutputConstraints;
- SmallVector<unsigned, 4> ClobberRegs;
+ SmallVector<MCRegister, 4> ClobberRegs;
SmallVector<AsmRewrite, 4> AsmStrRewrites;
@@ -6032,7 +6076,7 @@ bool AsmParser::parseMSInlineAsm(
// Register operand.
if (Operand.isReg() && !Operand.needAddressOf() &&
- !getTargetParser().OmitRegisterFromClobberLists(Operand.getReg())) {
+ !getTargetParser().omitRegisterFromClobberLists(Operand.getReg())) {
unsigned NumDefs = Desc.getNumDefs();
// Clobber.
if (NumDefs && Operand.getMCOperandNum() < NumDefs)
@@ -6249,7 +6293,7 @@ bool AsmParser::parseMSInlineAsm(
if (AsmStart != AsmEnd)
OS << StringRef(AsmStart, AsmEnd - AsmStart);
- AsmString = AsmStringIR;
+ AsmString = std::move(AsmStringIR);
return false;
}
@@ -6278,9 +6322,7 @@ bool HLASMAsmParser::parseAsHLASMLabel(ParseStatementInfo &Info,
"Cannot have just a label for an HLASM inline asm statement");
MCSymbol *Sym = getContext().getOrCreateSymbol(
- getContext().getAsmInfo()->shouldEmitLabelsInUpperCase()
- ? LabelVal.upper()
- : LabelVal);
+ getContext().getAsmInfo()->isHLASM() ? LabelVal.upper() : LabelVal);
getTargetParser().doBeforeLabelEmit(Sym, LabelLoc);
@@ -6379,33 +6421,6 @@ bool HLASMAsmParser::parseStatement(ParseStatementInfo &Info,
namespace llvm {
namespace MCParserUtils {
-/// Returns whether the given symbol is used anywhere in the given expression,
-/// or subexpressions.
-static bool isSymbolUsedInExpression(const MCSymbol *Sym, const MCExpr *Value) {
- switch (Value->getKind()) {
- case MCExpr::Binary: {
- const MCBinaryExpr *BE = static_cast<const MCBinaryExpr *>(Value);
- return isSymbolUsedInExpression(Sym, BE->getLHS()) ||
- isSymbolUsedInExpression(Sym, BE->getRHS());
- }
- case MCExpr::Target:
- case MCExpr::Constant:
- return false;
- case MCExpr::SymbolRef: {
- const MCSymbol &S =
- static_cast<const MCSymbolRefExpr *>(Value)->getSymbol();
- if (S.isVariable() && !S.isWeakExternal())
- return isSymbolUsedInExpression(Sym, S.getVariableValue());
- return &S == Sym;
- }
- case MCExpr::Unary:
- return isSymbolUsedInExpression(
- Sym, static_cast<const MCUnaryExpr *>(Value)->getSubExpr());
- }
-
- llvm_unreachable("Unknown expr kind!");
-}
-
bool parseAssignmentExpression(StringRef Name, bool allow_redef,
MCAsmParser &Parser, MCSymbol *&Sym,
const MCExpr *&Value) {
@@ -6430,7 +6445,7 @@ bool parseAssignmentExpression(StringRef Name, bool allow_redef,
//
// FIXME: Diagnostics. Note the location of the definition as a label.
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
- if (isSymbolUsedInExpression(Sym, Value))
+ if (Value->isSymbolUsedInExpression(Sym))
return Parser.Error(EqualLoc, "Recursive use of '" + Name + "'");
else if (Sym->isUndefined(/*SetUsed*/ false) && !Sym->isUsed() &&
!Sym->isVariable())
diff --git a/llvm/lib/MC/MCParser/COFFAsmParser.cpp b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
index a69276c36c56..dd5ce9964a19 100644
--- a/llvm/lib/MC/MCParser/COFFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
@@ -16,7 +16,6 @@
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
#include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCStreamer.h"
-#include "llvm/MC/SectionKind.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/TargetParser/Triple.h"
#include <cassert>
@@ -36,110 +35,115 @@ class COFFAsmParser : public MCAsmParserExtension {
getParser().addDirectiveHandler(Directive, Handler);
}
- bool ParseSectionSwitch(StringRef Section, unsigned Characteristics);
+ bool parseSectionSwitch(StringRef Section, unsigned Characteristics);
- bool ParseSectionSwitch(StringRef Section, unsigned Characteristics,
+ bool parseSectionSwitch(StringRef Section, unsigned Characteristics,
StringRef COMDATSymName, COFF::COMDATType Type);
- bool ParseSectionName(StringRef &SectionName);
- bool ParseSectionFlags(StringRef SectionName, StringRef FlagsString,
+ bool parseSectionName(StringRef &SectionName);
+ bool parseSectionFlags(StringRef SectionName, StringRef FlagsString,
unsigned *Flags);
void Initialize(MCAsmParser &Parser) override {
// Call the base implementation.
MCAsmParserExtension::Initialize(Parser);
- addDirectiveHandler<&COFFAsmParser::ParseSectionDirectiveText>(".text");
- addDirectiveHandler<&COFFAsmParser::ParseSectionDirectiveData>(".data");
- addDirectiveHandler<&COFFAsmParser::ParseSectionDirectiveBSS>(".bss");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveSection>(".section");
- addDirectiveHandler<&COFFAsmParser::ParseDirectivePushSection>(
+ addDirectiveHandler<&COFFAsmParser::parseSectionDirectiveText>(".text");
+ addDirectiveHandler<&COFFAsmParser::parseSectionDirectiveData>(".data");
+ addDirectiveHandler<&COFFAsmParser::parseSectionDirectiveBSS>(".bss");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSection>(".section");
+ addDirectiveHandler<&COFFAsmParser::parseDirectivePushSection>(
".pushsection");
- addDirectiveHandler<&COFFAsmParser::ParseDirectivePopSection>(
+ addDirectiveHandler<&COFFAsmParser::parseDirectivePopSection>(
".popsection");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveDef>(".def");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveScl>(".scl");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveType>(".type");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveEndef>(".endef");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveSecRel32>(".secrel32");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveSymIdx>(".symidx");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveSafeSEH>(".safeseh");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveSecIdx>(".secidx");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveLinkOnce>(".linkonce");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveRVA>(".rva");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveSymbolAttribute>(".weak_anti_dep");
- addDirectiveHandler<&COFFAsmParser::ParseDirectiveCGProfile>(".cg_profile");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveDef>(".def");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveScl>(".scl");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveType>(".type");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveEndef>(".endef");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSecRel32>(".secrel32");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSymIdx>(".symidx");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSafeSEH>(".safeseh");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSecIdx>(".secidx");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveLinkOnce>(".linkonce");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveRVA>(".rva");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSymbolAttribute>(".weak");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSymbolAttribute>(
+ ".weak_anti_dep");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveCGProfile>(".cg_profile");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSecNum>(".secnum");
+ addDirectiveHandler<&COFFAsmParser::parseDirectiveSecOffset>(".secoffset");
// Win64 EH directives.
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveStartProc>(
- ".seh_proc");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveEndProc>(
- ".seh_endproc");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveEndFuncletOrFunc>(
- ".seh_endfunclet");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveStartChained>(
- ".seh_startchained");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveEndChained>(
- ".seh_endchained");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveHandler>(
- ".seh_handler");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveHandlerData>(
- ".seh_handlerdata");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveAllocStack>(
- ".seh_stackalloc");
- addDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveEndProlog>(
- ".seh_endprologue");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveStartProc>(
+ ".seh_proc");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveEndProc>(
+ ".seh_endproc");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveEndFuncletOrFunc>(
+ ".seh_endfunclet");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveStartChained>(
+ ".seh_startchained");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveEndChained>(
+ ".seh_endchained");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveHandler>(
+ ".seh_handler");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveHandlerData>(
+ ".seh_handlerdata");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveAllocStack>(
+ ".seh_stackalloc");
+ addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveEndProlog>(
+ ".seh_endprologue");
}
- bool ParseSectionDirectiveText(StringRef, SMLoc) {
- return ParseSectionSwitch(".text", COFF::IMAGE_SCN_CNT_CODE |
+ bool parseSectionDirectiveText(StringRef, SMLoc) {
+ return parseSectionSwitch(".text", COFF::IMAGE_SCN_CNT_CODE |
COFF::IMAGE_SCN_MEM_EXECUTE |
COFF::IMAGE_SCN_MEM_READ);
}
- bool ParseSectionDirectiveData(StringRef, SMLoc) {
- return ParseSectionSwitch(".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ bool parseSectionDirectiveData(StringRef, SMLoc) {
+ return parseSectionSwitch(".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE);
}
- bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
- return ParseSectionSwitch(".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
+ bool parseSectionDirectiveBSS(StringRef, SMLoc) {
+ return parseSectionSwitch(".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE);
}
- bool ParseDirectiveSection(StringRef, SMLoc);
+ bool parseDirectiveSection(StringRef, SMLoc);
bool parseSectionArguments(StringRef, SMLoc);
- bool ParseDirectivePushSection(StringRef, SMLoc);
- bool ParseDirectivePopSection(StringRef, SMLoc);
- bool ParseDirectiveDef(StringRef, SMLoc);
- bool ParseDirectiveScl(StringRef, SMLoc);
- bool ParseDirectiveType(StringRef, SMLoc);
- bool ParseDirectiveEndef(StringRef, SMLoc);
- bool ParseDirectiveSecRel32(StringRef, SMLoc);
- bool ParseDirectiveSecIdx(StringRef, SMLoc);
- bool ParseDirectiveSafeSEH(StringRef, SMLoc);
- bool ParseDirectiveSymIdx(StringRef, SMLoc);
+ bool parseDirectivePushSection(StringRef, SMLoc);
+ bool parseDirectivePopSection(StringRef, SMLoc);
+ bool parseDirectiveDef(StringRef, SMLoc);
+ bool parseDirectiveScl(StringRef, SMLoc);
+ bool parseDirectiveType(StringRef, SMLoc);
+ bool parseDirectiveEndef(StringRef, SMLoc);
+ bool parseDirectiveSecRel32(StringRef, SMLoc);
+ bool parseDirectiveSecIdx(StringRef, SMLoc);
+ bool parseDirectiveSafeSEH(StringRef, SMLoc);
+ bool parseDirectiveSymIdx(StringRef, SMLoc);
bool parseCOMDATType(COFF::COMDATType &Type);
- bool ParseDirectiveLinkOnce(StringRef, SMLoc);
- bool ParseDirectiveRVA(StringRef, SMLoc);
- bool ParseDirectiveCGProfile(StringRef, SMLoc);
+ bool parseDirectiveLinkOnce(StringRef, SMLoc);
+ bool parseDirectiveRVA(StringRef, SMLoc);
+ bool parseDirectiveCGProfile(StringRef, SMLoc);
+ bool parseDirectiveSecNum(StringRef, SMLoc);
+ bool parseDirectiveSecOffset(StringRef, SMLoc);
// Win64 EH directives.
- bool ParseSEHDirectiveStartProc(StringRef, SMLoc);
- bool ParseSEHDirectiveEndProc(StringRef, SMLoc);
- bool ParseSEHDirectiveEndFuncletOrFunc(StringRef, SMLoc);
- bool ParseSEHDirectiveStartChained(StringRef, SMLoc);
- bool ParseSEHDirectiveEndChained(StringRef, SMLoc);
- bool ParseSEHDirectiveHandler(StringRef, SMLoc);
- bool ParseSEHDirectiveHandlerData(StringRef, SMLoc);
- bool ParseSEHDirectiveAllocStack(StringRef, SMLoc);
- bool ParseSEHDirectiveEndProlog(StringRef, SMLoc);
-
- bool ParseAtUnwindOrAtExcept(bool &unwind, bool &except);
- bool ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc);
+ bool parseSEHDirectiveStartProc(StringRef, SMLoc);
+ bool parseSEHDirectiveEndProc(StringRef, SMLoc);
+ bool parseSEHDirectiveEndFuncletOrFunc(StringRef, SMLoc);
+ bool parseSEHDirectiveStartChained(StringRef, SMLoc);
+ bool parseSEHDirectiveEndChained(StringRef, SMLoc);
+ bool parseSEHDirectiveHandler(StringRef, SMLoc);
+ bool parseSEHDirectiveHandlerData(StringRef, SMLoc);
+ bool parseSEHDirectiveAllocStack(StringRef, SMLoc);
+ bool parseSEHDirectiveEndProlog(StringRef, SMLoc);
+
+ bool parseAtUnwindOrAtExcept(bool &unwind, bool &except);
+ bool parseDirectiveSymbolAttribute(StringRef Directive, SMLoc);
public:
COFFAsmParser() = default;
@@ -147,7 +151,7 @@ public:
} // end anonymous namespace.
-bool COFFAsmParser::ParseSectionFlags(StringRef SectionName,
+bool COFFAsmParser::parseSectionFlags(StringRef SectionName,
StringRef FlagsString, unsigned *Flags) {
enum {
None = 0,
@@ -269,7 +273,7 @@ bool COFFAsmParser::ParseSectionFlags(StringRef SectionName,
/// ParseDirectiveSymbolAttribute
/// ::= { ".weak", ... } [ identifier ( , identifier )* ]
-bool COFFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
+bool COFFAsmParser::parseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Directive)
.Case(".weak", MCSA_Weak)
.Case(".weak_anti_dep", MCSA_WeakAntiDep)
@@ -299,16 +303,16 @@ bool COFFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveCGProfile(StringRef S, SMLoc Loc) {
- return MCAsmParserExtension::ParseDirectiveCGProfile(S, Loc);
+bool COFFAsmParser::parseDirectiveCGProfile(StringRef S, SMLoc Loc) {
+ return MCAsmParserExtension::parseDirectiveCGProfile(S, Loc);
}
-bool COFFAsmParser::ParseSectionSwitch(StringRef Section,
+bool COFFAsmParser::parseSectionSwitch(StringRef Section,
unsigned Characteristics) {
- return ParseSectionSwitch(Section, Characteristics, "", (COFF::COMDATType)0);
+ return parseSectionSwitch(Section, Characteristics, "", (COFF::COMDATType)0);
}
-bool COFFAsmParser::ParseSectionSwitch(StringRef Section,
+bool COFFAsmParser::parseSectionSwitch(StringRef Section,
unsigned Characteristics,
StringRef COMDATSymName,
COFF::COMDATType Type) {
@@ -322,7 +326,7 @@ bool COFFAsmParser::ParseSectionSwitch(StringRef Section,
return false;
}
-bool COFFAsmParser::ParseSectionName(StringRef &SectionName) {
+bool COFFAsmParser::parseSectionName(StringRef &SectionName) {
if (!getLexer().is(AsmToken::Identifier) && !getLexer().is(AsmToken::String))
return true;
@@ -331,7 +335,7 @@ bool COFFAsmParser::ParseSectionName(StringRef &SectionName) {
return false;
}
-bool COFFAsmParser::ParseDirectiveSection(StringRef directive, SMLoc loc) {
+bool COFFAsmParser::parseDirectiveSection(StringRef directive, SMLoc loc) {
return parseSectionArguments(directive, loc);
}
@@ -354,7 +358,7 @@ bool COFFAsmParser::ParseDirectiveSection(StringRef directive, SMLoc loc) {
bool COFFAsmParser::parseSectionArguments(StringRef, SMLoc) {
StringRef SectionName;
- if (ParseSectionName(SectionName))
+ if (parseSectionName(SectionName))
return TokError("expected identifier in directive");
unsigned Flags = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
@@ -370,7 +374,7 @@ bool COFFAsmParser::parseSectionArguments(StringRef, SMLoc) {
StringRef FlagsStr = getTok().getStringContents();
Lex();
- if (ParseSectionFlags(SectionName, FlagsStr, &Flags))
+ if (parseSectionFlags(SectionName, FlagsStr, &Flags))
return true;
}
@@ -405,11 +409,11 @@ bool COFFAsmParser::parseSectionArguments(StringRef, SMLoc) {
if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
Flags |= COFF::IMAGE_SCN_MEM_16BIT;
}
- ParseSectionSwitch(SectionName, Flags, COMDATSymName, Type);
+ parseSectionSwitch(SectionName, Flags, COMDATSymName, Type);
return false;
}
-bool COFFAsmParser::ParseDirectivePushSection(StringRef directive, SMLoc loc) {
+bool COFFAsmParser::parseDirectivePushSection(StringRef directive, SMLoc loc) {
getStreamer().pushSection();
if (parseSectionArguments(directive, loc)) {
@@ -420,13 +424,13 @@ bool COFFAsmParser::ParseDirectivePushSection(StringRef directive, SMLoc loc) {
return false;
}
-bool COFFAsmParser::ParseDirectivePopSection(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectivePopSection(StringRef, SMLoc) {
if (!getStreamer().popSection())
return TokError(".popsection without corresponding .pushsection");
return false;
}
-bool COFFAsmParser::ParseDirectiveDef(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveDef(StringRef, SMLoc) {
StringRef SymbolName;
if (getParser().parseIdentifier(SymbolName))
@@ -440,7 +444,7 @@ bool COFFAsmParser::ParseDirectiveDef(StringRef, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveScl(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveScl(StringRef, SMLoc) {
int64_t SymbolStorageClass;
if (getParser().parseAbsoluteExpression(SymbolStorageClass))
return true;
@@ -453,7 +457,7 @@ bool COFFAsmParser::ParseDirectiveScl(StringRef, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveType(StringRef, SMLoc) {
int64_t Type;
if (getParser().parseAbsoluteExpression(Type))
return true;
@@ -466,13 +470,13 @@ bool COFFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveEndef(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveEndef(StringRef, SMLoc) {
Lex();
getStreamer().endCOFFSymbolDef();
return false;
}
-bool COFFAsmParser::ParseDirectiveSecRel32(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveSecRel32(StringRef, SMLoc) {
StringRef SymbolID;
if (getParser().parseIdentifier(SymbolID))
return TokError("expected identifier in directive");
@@ -501,7 +505,7 @@ bool COFFAsmParser::ParseDirectiveSecRel32(StringRef, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveRVA(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveRVA(StringRef, SMLoc) {
auto parseOp = [&]() -> bool {
StringRef SymbolID;
if (getParser().parseIdentifier(SymbolID))
@@ -532,7 +536,7 @@ bool COFFAsmParser::ParseDirectiveRVA(StringRef, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveSafeSEH(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveSafeSEH(StringRef, SMLoc) {
StringRef SymbolID;
if (getParser().parseIdentifier(SymbolID))
return TokError("expected identifier in directive");
@@ -547,7 +551,7 @@ bool COFFAsmParser::ParseDirectiveSafeSEH(StringRef, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveSecIdx(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveSecIdx(StringRef, SMLoc) {
StringRef SymbolID;
if (getParser().parseIdentifier(SymbolID))
return TokError("expected identifier in directive");
@@ -562,7 +566,7 @@ bool COFFAsmParser::ParseDirectiveSecIdx(StringRef, SMLoc) {
return false;
}
-bool COFFAsmParser::ParseDirectiveSymIdx(StringRef, SMLoc) {
+bool COFFAsmParser::parseDirectiveSymIdx(StringRef, SMLoc) {
StringRef SymbolID;
if (getParser().parseIdentifier(SymbolID))
return TokError("expected identifier in directive");
@@ -577,6 +581,36 @@ bool COFFAsmParser::ParseDirectiveSymIdx(StringRef, SMLoc) {
return false;
}
+bool COFFAsmParser::parseDirectiveSecNum(StringRef, SMLoc) {
+ StringRef SymbolID;
+ if (getParser().parseIdentifier(SymbolID))
+ return TokError("expected identifier in directive");
+
+ if (getLexer().isNot(AsmToken::EndOfStatement))
+ return TokError("unexpected token in directive");
+
+ MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
+
+ Lex();
+ getStreamer().emitCOFFSecNumber(Symbol);
+ return false;
+}
+
+bool COFFAsmParser::parseDirectiveSecOffset(StringRef, SMLoc) {
+ StringRef SymbolID;
+ if (getParser().parseIdentifier(SymbolID))
+ return TokError("expected identifier in directive");
+
+ if (getLexer().isNot(AsmToken::EndOfStatement))
+ return TokError("unexpected token in directive");
+
+ MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
+
+ Lex();
+ getStreamer().emitCOFFSecOffset(Symbol);
+ return false;
+}
+
/// ::= [ identifier ]
bool COFFAsmParser::parseCOMDATType(COFF::COMDATType &Type) {
StringRef TypeId = getTok().getIdentifier();
@@ -601,7 +635,7 @@ bool COFFAsmParser::parseCOMDATType(COFF::COMDATType &Type) {
/// ParseDirectiveLinkOnce
/// ::= .linkonce [ identifier ]
-bool COFFAsmParser::ParseDirectiveLinkOnce(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseDirectiveLinkOnce(StringRef, SMLoc Loc) {
COFF::COMDATType Type = COFF::IMAGE_COMDAT_SELECT_ANY;
if (getLexer().is(AsmToken::Identifier))
if (parseCOMDATType(Type))
@@ -625,7 +659,7 @@ bool COFFAsmParser::ParseDirectiveLinkOnce(StringRef, SMLoc Loc) {
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveStartProc(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveStartProc(StringRef, SMLoc Loc) {
StringRef SymbolID;
if (getParser().parseIdentifier(SymbolID))
return true;
@@ -640,31 +674,31 @@ bool COFFAsmParser::ParseSEHDirectiveStartProc(StringRef, SMLoc Loc) {
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveEndProc(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveEndProc(StringRef, SMLoc Loc) {
Lex();
getStreamer().emitWinCFIEndProc(Loc);
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveEndFuncletOrFunc(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveEndFuncletOrFunc(StringRef, SMLoc Loc) {
Lex();
getStreamer().emitWinCFIFuncletOrFuncEnd(Loc);
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveStartChained(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveStartChained(StringRef, SMLoc Loc) {
Lex();
getStreamer().emitWinCFIStartChained(Loc);
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveEndChained(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveEndChained(StringRef, SMLoc Loc) {
Lex();
getStreamer().emitWinCFIEndChained(Loc);
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveHandler(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveHandler(StringRef, SMLoc Loc) {
StringRef SymbolID;
if (getParser().parseIdentifier(SymbolID))
return true;
@@ -673,11 +707,11 @@ bool COFFAsmParser::ParseSEHDirectiveHandler(StringRef, SMLoc Loc) {
return TokError("you must specify one or both of @unwind or @except");
Lex();
bool unwind = false, except = false;
- if (ParseAtUnwindOrAtExcept(unwind, except))
+ if (parseAtUnwindOrAtExcept(unwind, except))
return true;
if (getLexer().is(AsmToken::Comma)) {
Lex();
- if (ParseAtUnwindOrAtExcept(unwind, except))
+ if (parseAtUnwindOrAtExcept(unwind, except))
return true;
}
if (getLexer().isNot(AsmToken::EndOfStatement))
@@ -690,13 +724,13 @@ bool COFFAsmParser::ParseSEHDirectiveHandler(StringRef, SMLoc Loc) {
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveHandlerData(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveHandlerData(StringRef, SMLoc Loc) {
Lex();
getStreamer().emitWinEHHandlerData();
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveAllocStack(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveAllocStack(StringRef, SMLoc Loc) {
int64_t Size;
if (getParser().parseAbsoluteExpression(Size))
return true;
@@ -709,13 +743,13 @@ bool COFFAsmParser::ParseSEHDirectiveAllocStack(StringRef, SMLoc Loc) {
return false;
}
-bool COFFAsmParser::ParseSEHDirectiveEndProlog(StringRef, SMLoc Loc) {
+bool COFFAsmParser::parseSEHDirectiveEndProlog(StringRef, SMLoc Loc) {
Lex();
getStreamer().emitWinCFIEndProlog(Loc);
return false;
}
-bool COFFAsmParser::ParseAtUnwindOrAtExcept(bool &unwind, bool &except) {
+bool COFFAsmParser::parseAtUnwindOrAtExcept(bool &unwind, bool &except) {
StringRef identifier;
if (getLexer().isNot(AsmToken::At) && getLexer().isNot(AsmToken::Percent))
return TokError("a handler attribute must begin with '@' or '%'");
diff --git a/llvm/lib/MC/MCParser/COFFMasmParser.cpp b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
index 912e2b996792..8464a2392680 100644
--- a/llvm/lib/MC/MCParser/COFFMasmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
@@ -35,23 +35,23 @@ class COFFMasmParser : public MCAsmParserExtension {
getParser().addDirectiveHandler(Directive, Handler);
}
- bool ParseSectionSwitch(StringRef SectionName, unsigned Characteristics);
+ bool parseSectionSwitch(StringRef SectionName, unsigned Characteristics);
- bool ParseSectionSwitch(StringRef SectionName, unsigned Characteristics,
+ bool parseSectionSwitch(StringRef SectionName, unsigned Characteristics,
StringRef COMDATSymName, COFF::COMDATType Type,
Align Alignment);
- bool ParseDirectiveProc(StringRef, SMLoc);
- bool ParseDirectiveEndProc(StringRef, SMLoc);
- bool ParseDirectiveSegment(StringRef, SMLoc);
- bool ParseDirectiveSegmentEnd(StringRef, SMLoc);
- bool ParseDirectiveIncludelib(StringRef, SMLoc);
- bool ParseDirectiveOption(StringRef, SMLoc);
+ bool parseDirectiveProc(StringRef, SMLoc);
+ bool parseDirectiveEndProc(StringRef, SMLoc);
+ bool parseDirectiveSegment(StringRef, SMLoc);
+ bool parseDirectiveSegmentEnd(StringRef, SMLoc);
+ bool parseDirectiveIncludelib(StringRef, SMLoc);
+ bool parseDirectiveOption(StringRef, SMLoc);
- bool ParseDirectiveAlias(StringRef, SMLoc);
+ bool parseDirectiveAlias(StringRef, SMLoc);
- bool ParseSEHDirectiveAllocStack(StringRef, SMLoc);
- bool ParseSEHDirectiveEndProlog(StringRef, SMLoc);
+ bool parseSEHDirectiveAllocStack(StringRef, SMLoc);
+ bool parseSEHDirectiveEndProlog(StringRef, SMLoc);
bool IgnoreDirective(StringRef, SMLoc) {
while (!getLexer().is(AsmToken::EndOfStatement)) {
@@ -65,9 +65,9 @@ class COFFMasmParser : public MCAsmParserExtension {
MCAsmParserExtension::Initialize(Parser);
// x64 directives
- addDirectiveHandler<&COFFMasmParser::ParseSEHDirectiveAllocStack>(
+ addDirectiveHandler<&COFFMasmParser::parseSEHDirectiveAllocStack>(
".allocstack");
- addDirectiveHandler<&COFFMasmParser::ParseSEHDirectiveEndProlog>(
+ addDirectiveHandler<&COFFMasmParser::parseSEHDirectiveEndProlog>(
".endprolog");
// Code label directives
@@ -115,20 +115,20 @@ class COFFMasmParser : public MCAsmParserExtension {
// goto
// Miscellaneous directives
- addDirectiveHandler<&COFFMasmParser::ParseDirectiveAlias>("alias");
+ addDirectiveHandler<&COFFMasmParser::parseDirectiveAlias>("alias");
// assume
// .fpo
- addDirectiveHandler<&COFFMasmParser::ParseDirectiveIncludelib>(
+ addDirectiveHandler<&COFFMasmParser::parseDirectiveIncludelib>(
"includelib");
- addDirectiveHandler<&COFFMasmParser::ParseDirectiveOption>("option");
+ addDirectiveHandler<&COFFMasmParser::parseDirectiveOption>("option");
// popcontext
// pushcontext
// .safeseh
// Procedure directives
- addDirectiveHandler<&COFFMasmParser::ParseDirectiveEndProc>("endp");
+ addDirectiveHandler<&COFFMasmParser::parseDirectiveEndProc>("endp");
// invoke (32-bit only)
- addDirectiveHandler<&COFFMasmParser::ParseDirectiveProc>("proc");
+ addDirectiveHandler<&COFFMasmParser::parseDirectiveProc>("proc");
// proto
// Processor directives; all ignored
@@ -153,17 +153,17 @@ class COFFMasmParser : public MCAsmParserExtension {
// .alpha (32-bit only, order segments alphabetically)
// .dosseg (32-bit only, order segments in DOS convention)
// .seq (32-bit only, order segments sequentially)
- addDirectiveHandler<&COFFMasmParser::ParseDirectiveSegmentEnd>("ends");
+ addDirectiveHandler<&COFFMasmParser::parseDirectiveSegmentEnd>("ends");
// group (32-bit only)
- addDirectiveHandler<&COFFMasmParser::ParseDirectiveSegment>("segment");
+ addDirectiveHandler<&COFFMasmParser::parseDirectiveSegment>("segment");
// Simplified segment directives
- addDirectiveHandler<&COFFMasmParser::ParseSectionDirectiveCode>(".code");
+ addDirectiveHandler<&COFFMasmParser::parseSectionDirectiveCode>(".code");
// .const
+ addDirectiveHandler<&COFFMasmParser::parseSectionDirectiveInitializedData>(
+ ".data");
addDirectiveHandler<
- &COFFMasmParser::ParseSectionDirectiveInitializedData>(".data");
- addDirectiveHandler<
- &COFFMasmParser::ParseSectionDirectiveUninitializedData>(".data?");
+ &COFFMasmParser::parseSectionDirectiveUninitializedData>(".data?");
// .exit
// .fardata
// .fardata?
@@ -182,20 +182,20 @@ class COFFMasmParser : public MCAsmParserExtension {
// typedef
}
- bool ParseSectionDirectiveCode(StringRef, SMLoc) {
- return ParseSectionSwitch(".text", COFF::IMAGE_SCN_CNT_CODE |
+ bool parseSectionDirectiveCode(StringRef, SMLoc) {
+ return parseSectionSwitch(".text", COFF::IMAGE_SCN_CNT_CODE |
COFF::IMAGE_SCN_MEM_EXECUTE |
COFF::IMAGE_SCN_MEM_READ);
}
- bool ParseSectionDirectiveInitializedData(StringRef, SMLoc) {
- return ParseSectionSwitch(".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ bool parseSectionDirectiveInitializedData(StringRef, SMLoc) {
+ return parseSectionSwitch(".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE);
}
- bool ParseSectionDirectiveUninitializedData(StringRef, SMLoc) {
- return ParseSectionSwitch(".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
+ bool parseSectionDirectiveUninitializedData(StringRef, SMLoc) {
+ return parseSectionSwitch(".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE);
}
@@ -210,13 +210,13 @@ public:
} // end anonymous namespace.
-bool COFFMasmParser::ParseSectionSwitch(StringRef SectionName,
+bool COFFMasmParser::parseSectionSwitch(StringRef SectionName,
unsigned Characteristics) {
- return ParseSectionSwitch(SectionName, Characteristics, "",
+ return parseSectionSwitch(SectionName, Characteristics, "",
(COFF::COMDATType)0, Align(16));
}
-bool COFFMasmParser::ParseSectionSwitch(StringRef SectionName,
+bool COFFMasmParser::parseSectionSwitch(StringRef SectionName,
unsigned Characteristics,
StringRef COMDATSymName,
COFF::COMDATType Type,
@@ -233,7 +233,7 @@ bool COFFMasmParser::ParseSectionSwitch(StringRef SectionName,
return false;
}
-bool COFFMasmParser::ParseDirectiveSegment(StringRef Directive, SMLoc Loc) {
+bool COFFMasmParser::parseDirectiveSegment(StringRef Directive, SMLoc Loc) {
StringRef SegmentName;
if (!getLexer().is(AsmToken::Identifier))
return TokError("expected identifier in directive");
@@ -367,9 +367,9 @@ bool COFFMasmParser::ParseDirectiveSegment(StringRef Directive, SMLoc Loc) {
return false;
}
-/// ParseDirectiveSegmentEnd
+/// parseDirectiveSegmentEnd
/// ::= identifier "ends"
-bool COFFMasmParser::ParseDirectiveSegmentEnd(StringRef Directive, SMLoc Loc) {
+bool COFFMasmParser::parseDirectiveSegmentEnd(StringRef Directive, SMLoc Loc) {
StringRef SegmentName;
if (!getLexer().is(AsmToken::Identifier))
return TokError("expected identifier in directive");
@@ -380,9 +380,9 @@ bool COFFMasmParser::ParseDirectiveSegmentEnd(StringRef Directive, SMLoc Loc) {
return false;
}
-/// ParseDirectiveIncludelib
+/// parseDirectiveIncludelib
/// ::= "includelib" identifier
-bool COFFMasmParser::ParseDirectiveIncludelib(StringRef Directive, SMLoc Loc) {
+bool COFFMasmParser::parseDirectiveIncludelib(StringRef Directive, SMLoc Loc) {
StringRef Lib;
if (getParser().parseIdentifier(Lib))
return TokError("expected identifier in includelib directive");
@@ -398,9 +398,9 @@ bool COFFMasmParser::ParseDirectiveIncludelib(StringRef Directive, SMLoc Loc) {
return false;
}
-/// ParseDirectiveOption
+/// parseDirectiveOption
/// ::= "option" option-list
-bool COFFMasmParser::ParseDirectiveOption(StringRef Directive, SMLoc Loc) {
+bool COFFMasmParser::parseDirectiveOption(StringRef Directive, SMLoc Loc) {
auto parseOption = [&]() -> bool {
StringRef Option;
if (getParser().parseIdentifier(Option))
@@ -435,12 +435,15 @@ bool COFFMasmParser::ParseDirectiveOption(StringRef Directive, SMLoc Loc) {
return false;
}
-/// ParseDirectiveProc
+/// parseDirectiveProc
/// TODO(epastor): Implement parameters and other attributes.
/// ::= label "proc" [[distance]]
/// statements
/// label "endproc"
-bool COFFMasmParser::ParseDirectiveProc(StringRef Directive, SMLoc Loc) {
+bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
+ if (!getStreamer().getCurrentFragment())
+ return Error(getTok().getLoc(), "expected section directive");
+
StringRef Label;
if (getParser().parseIdentifier(Label))
return Error(Loc, "expected identifier for procedure");
@@ -476,7 +479,7 @@ bool COFFMasmParser::ParseDirectiveProc(StringRef Directive, SMLoc Loc) {
CurrentProceduresFramed.push_back(Framed);
return false;
}
-bool COFFMasmParser::ParseDirectiveEndProc(StringRef Directive, SMLoc Loc) {
+bool COFFMasmParser::parseDirectiveEndProc(StringRef Directive, SMLoc Loc) {
StringRef Label;
SMLoc LabelLoc = getTok().getLoc();
if (getParser().parseIdentifier(Label))
@@ -496,7 +499,7 @@ bool COFFMasmParser::ParseDirectiveEndProc(StringRef Directive, SMLoc Loc) {
return false;
}
-bool COFFMasmParser::ParseDirectiveAlias(StringRef Directive, SMLoc Loc) {
+bool COFFMasmParser::parseDirectiveAlias(StringRef Directive, SMLoc Loc) {
std::string AliasName, ActualName;
if (getTok().isNot(AsmToken::Less) ||
getParser().parseAngleBracketString(AliasName))
@@ -515,7 +518,7 @@ bool COFFMasmParser::ParseDirectiveAlias(StringRef Directive, SMLoc Loc) {
return false;
}
-bool COFFMasmParser::ParseSEHDirectiveAllocStack(StringRef Directive,
+bool COFFMasmParser::parseSEHDirectiveAllocStack(StringRef Directive,
SMLoc Loc) {
int64_t Size;
SMLoc SizeLoc = getTok().getLoc();
@@ -527,7 +530,7 @@ bool COFFMasmParser::ParseSEHDirectiveAllocStack(StringRef Directive,
return false;
}
-bool COFFMasmParser::ParseSEHDirectiveEndProlog(StringRef Directive,
+bool COFFMasmParser::parseSEHDirectiveEndProlog(StringRef Directive,
SMLoc Loc) {
getStreamer().emitWinCFIEndProlog(Loc);
return false;
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index a97b72997ae3..5dc9cb64c46a 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -1205,7 +1205,7 @@ bool DarwinAsmParser::parseBuildVersion(StringRef Directive, SMLoc Loc) {
/// parseDirectiveCGProfile
/// ::= .cg_profile from, to, count
bool DarwinAsmParser::parseDirectiveCGProfile(StringRef S, SMLoc Loc) {
- return MCAsmParserExtension::ParseDirectiveCGProfile(S, Loc);
+ return MCAsmParserExtension::parseDirectiveCGProfile(S, Loc);
}
namespace llvm {
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index e8a22d3defd6..b58210b3c268 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -41,7 +41,7 @@ class ELFAsmParser : public MCAsmParserExtension {
getParser().addDirectiveHandler(Directive, Handler);
}
- bool ParseSectionSwitch(StringRef Section, unsigned Type, unsigned Flags,
+ bool parseSectionSwitch(StringRef Section, unsigned Type, unsigned Flags,
SectionKind Kind);
public:
@@ -51,108 +51,108 @@ public:
// Call the base implementation.
this->MCAsmParserExtension::Initialize(Parser);
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveData>(".data");
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveText>(".text");
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveBSS>(".bss");
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveRoData>(".rodata");
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTData>(".tdata");
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTBSS>(".tbss");
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveData>(".data");
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveText>(".text");
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveBSS>(".bss");
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveRoData>(".rodata");
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveTData>(".tdata");
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveTBSS>(".tbss");
addDirectiveHandler<
- &ELFAsmParser::ParseSectionDirectiveDataRel>(".data.rel");
+ &ELFAsmParser::parseSectionDirectiveDataRel>(".data.rel");
addDirectiveHandler<
- &ELFAsmParser::ParseSectionDirectiveDataRelRo>(".data.rel.ro");
+ &ELFAsmParser::parseSectionDirectiveDataRelRo>(".data.rel.ro");
addDirectiveHandler<
- &ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSection>(".section");
+ &ELFAsmParser::parseSectionDirectiveEhFrame>(".eh_frame");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSection>(".section");
addDirectiveHandler<
- &ELFAsmParser::ParseDirectivePushSection>(".pushsection");
- addDirectiveHandler<&ELFAsmParser::ParseDirectivePopSection>(".popsection");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size");
- addDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveVersion>(".version");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local");
+ &ELFAsmParser::parseDirectivePushSection>(".pushsection");
+ addDirectiveHandler<&ELFAsmParser::parseDirectivePopSection>(".popsection");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSize>(".size");
+ addDirectiveHandler<&ELFAsmParser::parseDirectivePrevious>(".previous");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveType>(".type");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveIdent>(".ident");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSymver>(".symver");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveVersion>(".version");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveWeakref>(".weakref");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSymbolAttribute>(".weak");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSymbolAttribute>(".local");
addDirectiveHandler<
- &ELFAsmParser::ParseDirectiveSymbolAttribute>(".protected");
+ &ELFAsmParser::parseDirectiveSymbolAttribute>(".protected");
addDirectiveHandler<
- &ELFAsmParser::ParseDirectiveSymbolAttribute>(".internal");
+ &ELFAsmParser::parseDirectiveSymbolAttribute>(".internal");
addDirectiveHandler<
- &ELFAsmParser::ParseDirectiveSymbolAttribute>(".hidden");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSubsection>(".subsection");
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveCGProfile>(".cg_profile");
+ &ELFAsmParser::parseDirectiveSymbolAttribute>(".hidden");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSubsection>(".subsection");
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveCGProfile>(".cg_profile");
}
// FIXME: Part of this logic is duplicated in the MCELFStreamer. What is
// the best way for us to get access to it?
- bool ParseSectionDirectiveData(StringRef, SMLoc) {
- return ParseSectionSwitch(".data", ELF::SHT_PROGBITS,
+ bool parseSectionDirectiveData(StringRef, SMLoc) {
+ return parseSectionSwitch(".data", ELF::SHT_PROGBITS,
ELF::SHF_WRITE | ELF::SHF_ALLOC,
SectionKind::getData());
}
- bool ParseSectionDirectiveText(StringRef, SMLoc) {
- return ParseSectionSwitch(".text", ELF::SHT_PROGBITS,
+ bool parseSectionDirectiveText(StringRef, SMLoc) {
+ return parseSectionSwitch(".text", ELF::SHT_PROGBITS,
ELF::SHF_EXECINSTR |
ELF::SHF_ALLOC, SectionKind::getText());
}
- bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
- return ParseSectionSwitch(".bss", ELF::SHT_NOBITS,
+ bool parseSectionDirectiveBSS(StringRef, SMLoc) {
+ return parseSectionSwitch(".bss", ELF::SHT_NOBITS,
ELF::SHF_WRITE |
ELF::SHF_ALLOC, SectionKind::getBSS());
}
- bool ParseSectionDirectiveRoData(StringRef, SMLoc) {
- return ParseSectionSwitch(".rodata", ELF::SHT_PROGBITS,
+ bool parseSectionDirectiveRoData(StringRef, SMLoc) {
+ return parseSectionSwitch(".rodata", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC,
SectionKind::getReadOnly());
}
- bool ParseSectionDirectiveTData(StringRef, SMLoc) {
- return ParseSectionSwitch(".tdata", ELF::SHT_PROGBITS,
+ bool parseSectionDirectiveTData(StringRef, SMLoc) {
+ return parseSectionSwitch(".tdata", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC |
ELF::SHF_TLS | ELF::SHF_WRITE,
SectionKind::getThreadData());
}
- bool ParseSectionDirectiveTBSS(StringRef, SMLoc) {
- return ParseSectionSwitch(".tbss", ELF::SHT_NOBITS,
+ bool parseSectionDirectiveTBSS(StringRef, SMLoc) {
+ return parseSectionSwitch(".tbss", ELF::SHT_NOBITS,
ELF::SHF_ALLOC |
ELF::SHF_TLS | ELF::SHF_WRITE,
SectionKind::getThreadBSS());
}
- bool ParseSectionDirectiveDataRel(StringRef, SMLoc) {
- return ParseSectionSwitch(".data.rel", ELF::SHT_PROGBITS,
+ bool parseSectionDirectiveDataRel(StringRef, SMLoc) {
+ return parseSectionSwitch(".data.rel", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC | ELF::SHF_WRITE,
SectionKind::getData());
}
- bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) {
- return ParseSectionSwitch(".data.rel.ro", ELF::SHT_PROGBITS,
+ bool parseSectionDirectiveDataRelRo(StringRef, SMLoc) {
+ return parseSectionSwitch(".data.rel.ro", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC |
ELF::SHF_WRITE,
SectionKind::getReadOnlyWithRel());
}
- bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) {
- return ParseSectionSwitch(".eh_frame", ELF::SHT_PROGBITS,
+ bool parseSectionDirectiveEhFrame(StringRef, SMLoc) {
+ return parseSectionSwitch(".eh_frame", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC | ELF::SHF_WRITE,
SectionKind::getData());
}
- bool ParseDirectivePushSection(StringRef, SMLoc);
- bool ParseDirectivePopSection(StringRef, SMLoc);
- bool ParseDirectiveSection(StringRef, SMLoc);
- bool ParseDirectiveSize(StringRef, SMLoc);
- bool ParseDirectivePrevious(StringRef, SMLoc);
- bool ParseDirectiveType(StringRef, SMLoc);
- bool ParseDirectiveIdent(StringRef, SMLoc);
- bool ParseDirectiveSymver(StringRef, SMLoc);
- bool ParseDirectiveVersion(StringRef, SMLoc);
- bool ParseDirectiveWeakref(StringRef, SMLoc);
- bool ParseDirectiveSymbolAttribute(StringRef, SMLoc);
- bool ParseDirectiveSubsection(StringRef, SMLoc);
- bool ParseDirectiveCGProfile(StringRef, SMLoc);
+ bool parseDirectivePushSection(StringRef, SMLoc);
+ bool parseDirectivePopSection(StringRef, SMLoc);
+ bool parseDirectiveSection(StringRef, SMLoc);
+ bool parseDirectiveSize(StringRef, SMLoc);
+ bool parseDirectivePrevious(StringRef, SMLoc);
+ bool parseDirectiveType(StringRef, SMLoc);
+ bool parseDirectiveIdent(StringRef, SMLoc);
+ bool parseDirectiveSymver(StringRef, SMLoc);
+ bool parseDirectiveVersion(StringRef, SMLoc);
+ bool parseDirectiveWeakref(StringRef, SMLoc);
+ bool parseDirectiveSymbolAttribute(StringRef, SMLoc);
+ bool parseDirectiveSubsection(StringRef, SMLoc);
+ bool parseDirectiveCGProfile(StringRef, SMLoc);
private:
- bool ParseSectionName(StringRef &SectionName);
- bool ParseSectionArguments(bool IsPush, SMLoc loc);
+ bool parseSectionName(StringRef &SectionName);
+ bool parseSectionArguments(bool IsPush, SMLoc loc);
unsigned parseSunStyleSectionFlags();
bool maybeParseSectionType(StringRef &TypeName);
bool parseMergeSize(int64_t &Size);
@@ -163,9 +163,9 @@ private:
} // end anonymous namespace
-/// ParseDirectiveSymbolAttribute
+/// parseDirectiveSymbolAttribute
/// ::= { ".local", ".weak", ... } [ identifier ( , identifier )* ]
-bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
+bool ELFAsmParser::parseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Directive)
.Case(".weak", MCSA_Weak)
.Case(".local", MCSA_Local)
@@ -204,7 +204,7 @@ bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
return false;
}
-bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
+bool ELFAsmParser::parseSectionSwitch(StringRef Section, unsigned Type,
unsigned Flags, SectionKind Kind) {
const MCExpr *Subsection = nullptr;
if (getLexer().isNot(AsmToken::EndOfStatement)) {
@@ -219,7 +219,7 @@ bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
return false;
}
-bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectiveSize(StringRef, SMLoc) {
StringRef Name;
if (getParser().parseIdentifier(Name))
return TokError("expected identifier");
@@ -241,7 +241,7 @@ bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
return false;
}
-bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
+bool ELFAsmParser::parseSectionName(StringRef &SectionName) {
// A section name can contain -, so we cannot just use
// parseIdentifier.
SMLoc FirstLoc = getLexer().getLoc();
@@ -392,10 +392,10 @@ unsigned ELFAsmParser::parseSunStyleSectionFlags() {
}
-bool ELFAsmParser::ParseDirectivePushSection(StringRef s, SMLoc loc) {
+bool ELFAsmParser::parseDirectivePushSection(StringRef s, SMLoc loc) {
getStreamer().pushSection();
- if (ParseSectionArguments(/*IsPush=*/true, loc)) {
+ if (parseSectionArguments(/*IsPush=*/true, loc)) {
getStreamer().popSection();
return true;
}
@@ -403,14 +403,14 @@ bool ELFAsmParser::ParseDirectivePushSection(StringRef s, SMLoc loc) {
return false;
}
-bool ELFAsmParser::ParseDirectivePopSection(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectivePopSection(StringRef, SMLoc) {
if (!getStreamer().popSection())
return TokError(".popsection without corresponding .pushsection");
return false;
}
-bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc loc) {
- return ParseSectionArguments(/*IsPush=*/false, loc);
+bool ELFAsmParser::parseDirectiveSection(StringRef, SMLoc loc) {
+ return parseSectionArguments(/*IsPush=*/false, loc);
}
bool ELFAsmParser::maybeParseSectionType(StringRef &TypeName) {
@@ -536,10 +536,10 @@ static bool allowSectionTypeMismatch(const Triple &TT, StringRef SectionName,
return false;
}
-bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
+bool ELFAsmParser::parseSectionArguments(bool IsPush, SMLoc loc) {
StringRef SectionName;
- if (ParseSectionName(SectionName))
+ if (parseSectionName(SectionName))
return TokError("expected identifier");
StringRef TypeName;
@@ -677,6 +677,8 @@ EndStmt:
Type = ELF::SHT_LLVM_OFFLOADING;
else if (TypeName == "llvm_lto")
Type = ELF::SHT_LLVM_LTO;
+ else if (TypeName == "llvm_jt_sizes")
+ Type = ELF::SHT_LLVM_JT_SIZES;
else if (TypeName.getAsInteger(0, Type))
return TokError("unknown section type");
}
@@ -722,7 +724,7 @@ EndStmt:
return false;
}
-bool ELFAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) {
+bool ELFAsmParser::parseDirectivePrevious(StringRef DirName, SMLoc) {
MCSectionSubPair PreviousSection = getStreamer().getPreviousSection();
if (PreviousSection.first == nullptr)
return TokError(".previous without corresponding .section");
@@ -744,13 +746,13 @@ static MCSymbolAttr MCAttrForString(StringRef Type) {
.Default(MCSA_Invalid);
}
-/// ParseDirectiveELFType
+/// parseDirectiveELFType
/// ::= .type identifier , STT_<TYPE_IN_UPPER_CASE>
/// ::= .type identifier , #attribute
/// ::= .type identifier , @attribute
/// ::= .type identifier , %attribute
/// ::= .type identifier , "attribute"
-bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectiveType(StringRef, SMLoc) {
StringRef Name;
if (getParser().parseIdentifier(Name))
return TokError("expected identifier");
@@ -801,9 +803,9 @@ bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
return false;
}
-/// ParseDirectiveIdent
+/// parseDirectiveIdent
/// ::= .ident string
-bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectiveIdent(StringRef, SMLoc) {
if (getLexer().isNot(AsmToken::String))
return TokError("expected string");
@@ -819,9 +821,9 @@ bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
return false;
}
-/// ParseDirectiveSymver
+/// parseDirectiveSymver
/// ::= .symver foo, bar2@zed
-bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectiveSymver(StringRef, SMLoc) {
StringRef OriginalName, Name, Action;
if (getParser().parseIdentifier(OriginalName))
return TokError("expected identifier");
@@ -856,9 +858,9 @@ bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
return false;
}
-/// ParseDirectiveVersion
+/// parseDirectiveVersion
/// ::= .version string
-bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectiveVersion(StringRef, SMLoc) {
if (getLexer().isNot(AsmToken::String))
return TokError("expected string");
@@ -880,9 +882,9 @@ bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) {
return false;
}
-/// ParseDirectiveWeakref
+/// parseDirectiveWeakref
/// ::= .weakref foo, bar
-bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectiveWeakref(StringRef, SMLoc) {
// FIXME: Share code with the other alias building directives.
StringRef AliasName;
@@ -906,7 +908,7 @@ bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
return false;
}
-bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) {
+bool ELFAsmParser::parseDirectiveSubsection(StringRef, SMLoc) {
const MCExpr *Subsection = MCConstantExpr::create(0, getContext());
if (getLexer().isNot(AsmToken::EndOfStatement)) {
if (getParser().parseExpression(Subsection))
@@ -922,8 +924,8 @@ bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) {
Subsection);
}
-bool ELFAsmParser::ParseDirectiveCGProfile(StringRef S, SMLoc Loc) {
- return MCAsmParserExtension::ParseDirectiveCGProfile(S, Loc);
+bool ELFAsmParser::parseDirectiveCGProfile(StringRef S, SMLoc Loc) {
+ return MCAsmParserExtension::parseDirectiveCGProfile(S, Loc);
}
namespace llvm {
diff --git a/llvm/lib/MC/MCParser/MCAsmParserExtension.cpp b/llvm/lib/MC/MCParser/MCAsmParserExtension.cpp
index f5a10ce9805b..444ce395a4de 100644
--- a/llvm/lib/MC/MCParser/MCAsmParserExtension.cpp
+++ b/llvm/lib/MC/MCParser/MCAsmParserExtension.cpp
@@ -22,9 +22,9 @@ void MCAsmParserExtension::Initialize(MCAsmParser &Parser) {
this->Parser = &Parser;
}
-/// ParseDirectiveCGProfile
+/// parseDirectiveCGProfile
/// ::= .cg_profile identifier, identifier, <number>
-bool MCAsmParserExtension::ParseDirectiveCGProfile(StringRef, SMLoc) {
+bool MCAsmParserExtension::parseDirectiveCGProfile(StringRef, SMLoc) {
StringRef From;
SMLoc FromLoc = getLexer().getLoc();
if (getParser().parseIdentifier(From))
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index f64b7f62d61d..b2c956e0a459 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -479,9 +479,7 @@ public:
void addDirectiveHandler(StringRef Directive,
ExtensionDirectiveHandler Handler) override {
ExtensionDirectiveMap[Directive] = Handler;
- if (!DirectiveKindMap.contains(Directive)) {
- DirectiveKindMap[Directive] = DK_HANDLER_DIRECTIVE;
- }
+ DirectiveKindMap.try_emplace(Directive, DK_HANDLER_DIRECTIVE);
}
void addAliasForDirective(StringRef Directive, StringRef Alias) override {
@@ -541,7 +539,7 @@ public:
SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
SmallVectorImpl<std::string> &Constraints,
SmallVectorImpl<std::string> &Clobbers,
- const MCInstrInfo *MII, const MCInstPrinter *IP,
+ const MCInstrInfo *MII, MCInstPrinter *IP,
MCAsmParserSemaCallback &SI) override;
bool parseExpression(const MCExpr *&Res);
@@ -1417,7 +1415,7 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
// Check to see that all assembler local symbols were actually defined.
// Targets that don't do subsections via symbols may not want this, though,
// so conservatively exclude them. Only do this if we're finalizing, though,
- // as otherwise we won't necessarilly have seen everything yet.
+ // as otherwise we won't necessarily have seen everything yet.
if (!NoFinalize) {
if (MAI.hasSubsectionsViaSymbols()) {
for (const auto &TableEntry : getContext().getSymbols()) {
@@ -1456,7 +1454,8 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
}
bool MasmParser::checkForValidSection() {
- if (!ParsingMSInlineAsm && !getStreamer().getCurrentSectionOnly()) {
+ if (!ParsingMSInlineAsm && !(getStreamer().getCurrentFragment() &&
+ getStreamer().getCurrentSectionOnly())) {
Out.initSections(false, getTargetParser().getSTI());
return Error(getTok().getLoc(),
"expected section directive before assembly directive");
@@ -2657,7 +2656,7 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
// Canonicalize the opcode to lower case.
std::string OpcodeStr = IDVal.lower();
ParseInstructionInfo IInfo(Info.AsmRewrites);
- bool ParseHadError = getTargetParser().ParseInstruction(IInfo, OpcodeStr, ID,
+ bool ParseHadError = getTargetParser().parseInstruction(IInfo, OpcodeStr, ID,
Info.ParsedOperands);
Info.ParseError = ParseHadError;
@@ -2714,7 +2713,7 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
// If parsing succeeded, match the instruction.
if (!ParseHadError) {
uint64_t ErrorInfo;
- if (getTargetParser().MatchAndEmitInstruction(
+ if (getTargetParser().matchAndEmitInstruction(
IDLoc, Info.Opcode, Info.ParsedOperands, Out, ErrorInfo,
getTargetParser().isParsingMSInlineAsm()))
return true;
@@ -6752,6 +6751,7 @@ void MasmParser::initializeDirectiveKindMap() {
// DirectiveKindMap[".cfi_register"] = DK_CFI_REGISTER;
// DirectiveKindMap[".cfi_window_save"] = DK_CFI_WINDOW_SAVE;
// DirectiveKindMap[".cfi_b_key_frame"] = DK_CFI_B_KEY_FRAME;
+ // DirectiveKindMap[".cfi_val_offset"] = DK_CFI_VAL_OFFSET;
DirectiveKindMap["macro"] = DK_MACRO;
DirectiveKindMap["exitm"] = DK_EXITM;
DirectiveKindMap["endm"] = DK_ENDM;
@@ -6955,8 +6955,7 @@ bool MasmParser::parseDirectiveRepeat(SMLoc DirectiveLoc, StringRef Dir) {
SmallString<256> Buf;
raw_svector_ostream OS(Buf);
while (Count--) {
- if (expandMacro(OS, M->Body, std::nullopt, std::nullopt, M->Locals,
- getTok().getLoc()))
+ if (expandMacro(OS, M->Body, {}, {}, M->Locals, getTok().getLoc()))
return true;
}
instantiateMacroLikeBody(M, DirectiveLoc, OS);
@@ -6989,8 +6988,7 @@ bool MasmParser::parseDirectiveWhile(SMLoc DirectiveLoc) {
if (Condition) {
// Instantiate the macro, then resume at this directive to recheck the
// condition.
- if (expandMacro(OS, M->Body, std::nullopt, std::nullopt, M->Locals,
- getTok().getLoc()))
+ if (expandMacro(OS, M->Body, {}, {}, M->Locals, getTok().getLoc()))
return true;
instantiateMacroLikeBody(M, DirectiveLoc, /*ExitLoc=*/DirectiveLoc, OS);
}
@@ -7125,7 +7123,7 @@ bool MasmParser::parseDirectiveForc(SMLoc DirectiveLoc, StringRef Directive) {
StringRef Values(Argument);
for (std::size_t I = 0, End = Values.size(); I != End; ++I) {
MCAsmMacroArgument Arg;
- Arg.emplace_back(AsmToken::Identifier, Values.slice(I, I + 1));
+ Arg.emplace_back(AsmToken::Identifier, Values.substr(I, 1));
if (expandMacro(OS, M->Body, Parameter, Arg, M->Locals, getTok().getLoc()))
return true;
@@ -7344,14 +7342,14 @@ bool MasmParser::parseMSInlineAsm(
SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
SmallVectorImpl<std::string> &Constraints,
SmallVectorImpl<std::string> &Clobbers, const MCInstrInfo *MII,
- const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
+ MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
SmallVector<void *, 4> InputDecls;
SmallVector<void *, 4> OutputDecls;
SmallVector<bool, 4> InputDeclsAddressOf;
SmallVector<bool, 4> OutputDeclsAddressOf;
SmallVector<std::string, 4> InputConstraints;
SmallVector<std::string, 4> OutputConstraints;
- SmallVector<unsigned, 4> ClobberRegs;
+ SmallVector<MCRegister, 4> ClobberRegs;
SmallVector<AsmRewrite, 4> AsmStrRewrites;
@@ -7389,7 +7387,7 @@ bool MasmParser::parseMSInlineAsm(
// Register operand.
if (Operand.isReg() && !Operand.needAddressOf() &&
- !getTargetParser().OmitRegisterFromClobberLists(Operand.getReg())) {
+ !getTargetParser().omitRegisterFromClobberLists(Operand.getReg())) {
unsigned NumDefs = Desc.getNumDefs();
// Clobber.
if (NumDefs && Operand.getMCOperandNum() < NumDefs)