summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-09-02 18:53:37 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-09-02 18:53:37 +0000
commite39017cb9735faa156e11799eaaffeeaaff18244 (patch)
tree34f06355f2105e0213c5d6eca55fd26092b3b20a /llvm/lib
parent1ba95136f2a006f90ac819cf44b4941998030f1b (diff)
downloadbcm5719-llvm-e39017cb9735faa156e11799eaaffeeaaff18244.tar.gz
bcm5719-llvm-e39017cb9735faa156e11799eaaffeeaaff18244.zip
Add AsmParser support for the ELF .previous directive. Patch by Roman Divacky.
llvm-svn: 112849
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCAsmStreamer.cpp1
-rw-r--r--llvm/lib/MC/MCNullStreamer.cpp1
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp1
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp10
-rw-r--r--llvm/lib/MC/MCStreamer.cpp3
5 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 4ededb24fdc..1cc8fb0b548 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -217,6 +217,7 @@ static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
void MCAsmStreamer::SwitchSection(const MCSection *Section) {
assert(Section && "Cannot switch to a null section!");
if (Section != CurSection) {
+ PrevSection = CurSection;
CurSection = Section;
Section->PrintSwitchToSection(MAI, OS);
}
diff --git a/llvm/lib/MC/MCNullStreamer.cpp b/llvm/lib/MC/MCNullStreamer.cpp
index 5332ade2115..f7a2f20ca4b 100644
--- a/llvm/lib/MC/MCNullStreamer.cpp
+++ b/llvm/lib/MC/MCNullStreamer.cpp
@@ -26,6 +26,7 @@ namespace {
/// @{
virtual void SwitchSection(const MCSection *Section) {
+ PrevSection = CurSection;
CurSection = Section;
}
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index eed4e7bd4f6..2b2385ef915 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -77,6 +77,7 @@ void MCObjectStreamer::SwitchSection(const MCSection *Section) {
// If already in this section, then this is a noop.
if (Section == CurSection) return;
+ PrevSection = CurSection;
CurSection = Section;
CurSectionData = &getAssembler().getOrCreateSectionData(*Section);
}
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index b0bc5c6114e..f982fdaecb1 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -50,6 +50,7 @@ public:
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size");
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveLEB128>(".sleb128");
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveLEB128>(".uleb128");
+ AddDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous");
}
bool ParseSectionDirectiveData(StringRef, SMLoc) {
@@ -111,6 +112,7 @@ public:
bool ParseDirectiveLEB128(StringRef, SMLoc);
bool ParseDirectiveSection(StringRef, SMLoc);
bool ParseDirectiveSize(StringRef, SMLoc);
+ bool ParseDirectivePrevious(StringRef, SMLoc);
};
}
@@ -272,6 +274,14 @@ bool ELFAsmParser::ParseDirectiveLEB128(StringRef DirName, SMLoc) {
return TokError("LEB128 not supported yet");
}
+bool ELFAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) {
+ const MCSection *PreviousSection = getStreamer().getPreviousSection();
+ if (PreviousSection != NULL)
+ getStreamer().SwitchSection(PreviousSection);
+
+ return false;
+}
+
namespace llvm {
MCAsmParserExtension *createELFAsmParser() {
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index f682721b4a1..3e9d02ea5ae 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -15,7 +15,8 @@
#include <cstdlib>
using namespace llvm;
-MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx), CurSection(0) {
+MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx), CurSection(0),
+ PrevSection(0) {
}
MCStreamer::~MCStreamer() {
OpenPOWER on IntegriCloud