aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/MCParser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MC/MCParser')
-rw-r--r--lib/MC/MCParser/AsmParser.cpp49
-rw-r--r--lib/MC/MCParser/CMakeLists.txt3
-rw-r--r--lib/MC/MCParser/COFFAsmParser.cpp8
-rw-r--r--lib/MC/MCParser/ELFAsmParser.cpp54
4 files changed, 52 insertions, 62 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index de7d961..ef6a540 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -111,8 +111,8 @@ struct ParseStatementInfo {
/// \brief The concrete assembly parser instance.
class AsmParser : public MCAsmParser {
- AsmParser(const AsmParser &) LLVM_DELETED_FUNCTION;
- void operator=(const AsmParser &) LLVM_DELETED_FUNCTION;
+ AsmParser(const AsmParser &) = delete;
+ void operator=(const AsmParser &) = delete;
private:
AsmLexer Lexer;
MCContext &Ctx;
@@ -1298,6 +1298,9 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
Sym = getContext().GetOrCreateSymbol(IDVal);
} else
Sym = Ctx.CreateDirectionalLocalSymbol(LocalLabelVal);
+
+ Sym->redefineIfPossible();
+
if (!Sym->isUndefined() || Sym->isVariable())
return Error(IDLoc, "invalid symbol redefinition");
@@ -1595,14 +1598,18 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
// directive for the instruction.
if (!HadError && getContext().getGenDwarfForAssembly() &&
getContext().getGenDwarfSectionSyms().count(
- getStreamer().getCurrentSection().first)) {
-
- unsigned Line = SrcMgr.FindLineNumber(IDLoc, CurBuffer);
+ getStreamer().getCurrentSection().first)) {
+ unsigned Line;
+ if (ActiveMacros.empty())
+ Line = SrcMgr.FindLineNumber(IDLoc, CurBuffer);
+ else
+ Line = SrcMgr.FindLineNumber(ActiveMacros.back()->InstantiationLoc,
+ ActiveMacros.back()->ExitBuffer);
// If we previously parsed a cpp hash file line comment then make sure the
// current Dwarf File is for the CppHashFilename if not then emit the
// Dwarf File table for it and adjust the line number for the .loc.
- if (CppHashFilename.size() != 0) {
+ if (CppHashFilename.size()) {
unsigned FileNumber = getStreamer().EmitDwarfFileDirective(
0, StringRef(), CppHashFilename);
getContext().setGenDwarfFileNumber(FileNumber);
@@ -2213,6 +2220,8 @@ bool AsmParser::parseAssignment(StringRef Name, bool allow_redef,
} else
Sym = getContext().GetOrCreateSymbol(Name);
+ Sym->setRedefinable(allow_redef);
+
// Do the assignment.
Out.EmitAssignment(Sym, Value);
if (NoDeadStrip)
@@ -3266,7 +3275,7 @@ bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) {
MCAsmMacroParameters Parameters;
while (getLexer().isNot(AsmToken::EndOfStatement)) {
- if (Parameters.size() && Parameters.back().Vararg)
+ if (!Parameters.empty() && Parameters.back().Vararg)
return Error(Lexer.getLoc(),
"Vararg parameter '" + Parameters.back().Name +
"' should be last one in the list of parameters.");
@@ -3627,21 +3636,27 @@ bool AsmParser::parseDirectiveSpace(StringRef IDVal) {
}
/// parseDirectiveLEB128
-/// ::= (.sleb128 | .uleb128) expression
+/// ::= (.sleb128 | .uleb128) [ expression (, expression)* ]
bool AsmParser::parseDirectiveLEB128(bool Signed) {
checkForValidSection();
const MCExpr *Value;
- if (parseExpression(Value))
- return true;
+ for (;;) {
+ if (parseExpression(Value))
+ return true;
- if (getLexer().isNot(AsmToken::EndOfStatement))
- return TokError("unexpected token in directive");
+ if (Signed)
+ getStreamer().EmitSLEB128Value(Value);
+ else
+ getStreamer().EmitULEB128Value(Value);
- if (Signed)
- getStreamer().EmitSLEB128Value(Value);
- else
- getStreamer().EmitULEB128Value(Value);
+ if (getLexer().is(AsmToken::EndOfStatement))
+ break;
+
+ if (getLexer().isNot(AsmToken::Comma))
+ return TokError("unexpected token in directive");
+ Lex();
+ }
return false;
}
@@ -4662,7 +4677,7 @@ bool AsmParser::parseMSInlineAsm(
OS << "$$";
break;
case AOK_Label:
- OS << Ctx.getAsmInfo()->getPrivateGlobalPrefix() << AR.Label;
+ OS << Ctx.getAsmInfo()->getPrivateLabelPrefix() << AR.Label;
break;
case AOK_Input:
OS << '$' << InputIdx++;
diff --git a/lib/MC/MCParser/CMakeLists.txt b/lib/MC/MCParser/CMakeLists.txt
index 222f237..957c94e 100644
--- a/lib/MC/MCParser/CMakeLists.txt
+++ b/lib/MC/MCParser/CMakeLists.txt
@@ -8,4 +8,7 @@ add_llvm_library(LLVMMCParser
MCAsmParser.cpp
MCAsmParserExtension.cpp
MCTargetAsmParser.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${LLVM_MAIN_INCLUDE_DIR}/llvm/MCParser
)
diff --git a/lib/MC/MCParser/COFFAsmParser.cpp b/lib/MC/MCParser/COFFAsmParser.cpp
index 6f82e6e..18bdb03 100644
--- a/lib/MC/MCParser/COFFAsmParser.cpp
+++ b/lib/MC/MCParser/COFFAsmParser.cpp
@@ -582,7 +582,7 @@ bool COFFAsmParser::ParseSEHDirectiveHandlerData(StringRef, SMLoc) {
}
bool COFFAsmParser::ParseSEHDirectivePushReg(StringRef, SMLoc L) {
- unsigned Reg;
+ unsigned Reg = 0;
if (ParseSEHRegisterNumber(Reg))
return true;
@@ -595,7 +595,7 @@ bool COFFAsmParser::ParseSEHDirectivePushReg(StringRef, SMLoc L) {
}
bool COFFAsmParser::ParseSEHDirectiveSetFrame(StringRef, SMLoc L) {
- unsigned Reg;
+ unsigned Reg = 0;
int64_t Off;
if (ParseSEHRegisterNumber(Reg))
return true;
@@ -636,7 +636,7 @@ bool COFFAsmParser::ParseSEHDirectiveAllocStack(StringRef, SMLoc) {
}
bool COFFAsmParser::ParseSEHDirectiveSaveReg(StringRef, SMLoc L) {
- unsigned Reg;
+ unsigned Reg = 0;
int64_t Off;
if (ParseSEHRegisterNumber(Reg))
return true;
@@ -663,7 +663,7 @@ bool COFFAsmParser::ParseSEHDirectiveSaveReg(StringRef, SMLoc L) {
// FIXME: This method is inherently x86-specific. It should really be in the
// x86 backend.
bool COFFAsmParser::ParseSEHDirectiveSaveXMM(StringRef, SMLoc L) {
- unsigned Reg;
+ unsigned Reg = 0;
int64_t Off;
if (ParseSEHRegisterNumber(Reg))
return true;
diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp
index e302004..7a120a1 100644
--- a/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/lib/MC/MCParser/ELFAsmParser.cpp
@@ -199,8 +199,7 @@ bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
return true;
}
- getStreamer().SwitchSection(getContext().getELFSection(
- Section, Type, Flags, Kind),
+ getStreamer().SwitchSection(getContext().getELFSection(Section, Type, Flags),
Subsection);
return false;
@@ -269,40 +268,6 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
return false;
}
-static SectionKind computeSectionKind(unsigned Flags, unsigned ElemSize) {
- if (Flags & ELF::SHF_EXECINSTR)
- return SectionKind::getText();
- if (Flags & ELF::SHF_TLS)
- return SectionKind::getThreadData();
- if (Flags & ELF::SHF_MERGE) {
- if (Flags & ELF::SHF_STRINGS) {
- switch (ElemSize) {
- default:
- break;
- case 1:
- return SectionKind::getMergeable1ByteCString();
- case 2:
- return SectionKind::getMergeable2ByteCString();
- case 4:
- return SectionKind::getMergeable4ByteCString();
- }
- } else {
- switch (ElemSize) {
- default:
- break;
- case 4:
- return SectionKind::getMergeableConst4();
- case 8:
- return SectionKind::getMergeableConst8();
- case 16:
- return SectionKind::getMergeableConst16();
- }
- }
- }
-
- return SectionKind::getDataRel();
-}
-
static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) {
unsigned flags = 0;
@@ -413,6 +378,8 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
unsigned Flags = 0;
const MCExpr *Subsection = nullptr;
bool UseLastGroup = false;
+ StringRef UniqueStr;
+ bool Unique = false;
// Set the defaults first.
if (SectionName == ".fini" || SectionName == ".init" ||
@@ -497,6 +464,14 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
return TokError("Linkage must be 'comdat'");
}
}
+ if (getLexer().is(AsmToken::Comma)) {
+ Lex();
+ if (getParser().parseIdentifier(UniqueStr))
+ return TokError("expected identifier in directive");
+ if (UniqueStr != "unique")
+ return TokError("expected 'unique'");
+ Unique = true;
+ }
}
}
@@ -544,9 +519,8 @@ EndStmt:
}
}
- SectionKind Kind = computeSectionKind(Flags, Size);
const MCSection *ELFSection = getContext().getELFSection(
- SectionName, Type, Flags, Kind, Size, GroupName);
+ SectionName, Type, Flags, Size, GroupName, Unique);
getStreamer().SwitchSection(ELFSection, Subsection);
if (getContext().getGenDwarfForAssembly()) {
@@ -697,9 +671,7 @@ bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) {
Lex();
- const MCSection *Note =
- getContext().getELFSection(".note", ELF::SHT_NOTE, 0,
- SectionKind::getReadOnly());
+ const MCSection *Note = getContext().getELFSection(".note", ELF::SHT_NOTE, 0);
getStreamer().PushSection();
getStreamer().SwitchSection(Note);