summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-05-25 18:34:26 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-05-25 18:34:26 +0000
commitcd62518369a8a711b26f6bcb85d727b5e386b2f1 (patch)
tree6f1442ec08d66b816e5a62ff13c74b9b76087cde
parent0be4fa761f21505099bf904652b3e061b3ce732f (diff)
downloadbcm5719-llvm-cd62518369a8a711b26f6bcb85d727b5e386b2f1.tar.gz
bcm5719-llvm-cd62518369a8a711b26f6bcb85d727b5e386b2f1.zip
Move HasInstructions to MCSection.
llvm-svn: 238150
-rw-r--r--llvm/include/llvm/MC/MCAssembler.h7
-rw-r--r--llvm/include/llvm/MC/MCObjectStreamer.h4
-rw-r--r--llvm/include/llvm/MC/MCSection.h8
-rw-r--r--llvm/lib/MC/MCAssembler.cpp2
-rw-r--r--llvm/lib/MC/MCELFStreamer.cpp13
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp6
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp2
7 files changed, 23 insertions, 19 deletions
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h
index da3fb9f2faf..ee7583e0e82 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -557,10 +557,6 @@ private:
//
// FIXME: This could all be kept private to the assembler implementation.
- /// HasInstructions - Whether this section has had instructions emitted into
- /// it.
- unsigned HasInstructions : 1;
-
/// Mapping from subsection number to insertion point for subsection numbers
/// below that number.
SmallVector<std::pair<unsigned, MCFragment *>, 1> SubsectionFragmentMap;
@@ -574,9 +570,6 @@ public:
MCSection &getSection() const { return *Section; }
- bool hasInstructions() const { return HasInstructions; }
- void setHasInstructions(bool Value) { HasInstructions = Value; }
-
/// \name Fragment Access
/// @{
diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h
index 284dd55443d..646603975f5 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -146,9 +146,7 @@ public:
bool emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
unsigned Size) override;
- bool mayHaveInstructions(MCSection &Sec) const override {
- return Assembler->getOrCreateSectionData(Sec).hasInstructions();
- }
+ bool mayHaveInstructions(MCSection &Sec) const override;
};
} // end namespace llvm
diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h
index 99d11c40c4e..4dbf4ba6f02 100644
--- a/llvm/include/llvm/MC/MCSection.h
+++ b/llvm/include/llvm/MC/MCSection.h
@@ -61,9 +61,12 @@ private:
/// yet.
bool BundleGroupBeforeFirstInst = false;
+ /// Whether this section has had instructions emitted into it.
+ unsigned HasInstructions : 1;
+
protected:
MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
- : Begin(Begin), Variant(V), Kind(K) {}
+ : Begin(Begin), HasInstructions(false), Variant(V), Kind(K) {}
SectionVariant Variant;
SectionKind Kind;
@@ -105,6 +108,9 @@ public:
BundleGroupBeforeFirstInst = IsFirst;
}
+ bool hasInstructions() const { return HasInstructions; }
+ void setHasInstructions(bool Value) { HasInstructions = Value; }
+
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
const MCExpr *Subsection) const = 0;
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index a3c7c70321c..d7712f7fc98 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -293,7 +293,7 @@ MCEncodedFragmentWithFixups::~MCEncodedFragmentWithFixups() {
MCSectionData::MCSectionData() : Section(nullptr) {}
MCSectionData::MCSectionData(MCSection &Section, MCAssembler *A)
- : Section(&Section), HasInstructions(false) {
+ : Section(&Section) {
if (A)
A->getSectionList().push_back(this);
}
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 0e4d637c8ce..23546cc085d 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -137,11 +137,14 @@ void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
// If bundle aligment is used and there are any instructions in the section, it
// needs to be aligned to at least the bundle size.
-static void setSectionAlignmentForBundling(
- const MCAssembler &Assembler, MCSectionData *Section) {
- if (Assembler.isBundlingEnabled() && Section && Section->hasInstructions() &&
- Section->getSection().getAlignment() < Assembler.getBundleAlignSize())
- Section->getSection().setAlignment(Assembler.getBundleAlignSize());
+static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
+ MCSectionData *SD) {
+ if (!SD)
+ return;
+ MCSection &Section = SD->getSection();
+ if (Assembler.isBundlingEnabled() && Section.hasInstructions() &&
+ Section.getAlignment() < Assembler.getBundleAlignSize())
+ Section.setAlignment(Assembler.getBundleAlignSize());
}
void MCELFStreamer::ChangeSection(MCSection *Section,
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index b244c3a679c..8584a79a8d1 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -230,12 +230,16 @@ void MCObjectStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
MCStreamer::EmitAssignment(Symbol, Value);
}
+bool MCObjectStreamer::mayHaveInstructions(MCSection &Sec) const {
+ return Sec.hasInstructions();
+}
+
void MCObjectStreamer::EmitInstruction(const MCInst &Inst,
const MCSubtargetInfo &STI) {
MCStreamer::EmitInstruction(Inst, STI);
MCSectionData *SD = getCurrentSectionData();
- SD->setHasInstructions(true);
+ SD->getSection().setHasInstructions(true);
// Now that a machine instruction has been assembled into this section, make
// a line entry for any .loc directive that has been seen.
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 45096d428b7..79de0f9a936 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -225,7 +225,7 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
Write32(FileOffset);
unsigned Flags = Section.getTypeAndAttributes();
- if (SD.hasInstructions())
+ if (Section.hasInstructions())
Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
assert(isPowerOf2_32(Section.getAlignment()) && "Invalid alignment!");
OpenPOWER on IntegriCloud