diff options
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCAsmStreamer.cpp | 20 | ||||
-rw-r--r-- | lib/MC/MCSection.cpp | 27 |
2 files changed, 28 insertions, 19 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index a71174a77b..0aed948d30 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -100,13 +100,6 @@ static inline bool NeedsQuoting(const StringRef &Str) { return false; } -/// Allow printing sections directly to a raw_ostream with proper quoting. -static inline raw_ostream &operator<<(raw_ostream &os, const MCSection *S) { - if (NeedsQuoting(S->getName())) - return os << '"' << S->getName() << '"'; - return os << S->getName(); -} - /// Allow printing symbols directly to a raw_ostream with proper quoting. static inline raw_ostream &operator<<(raw_ostream &os, const MCSymbol *S) { if (NeedsQuoting(S->getName())) @@ -144,10 +137,8 @@ void MCAsmStreamer::SwitchSection(MCSection *Section) { if (Section != CurSection) { CurSection = Section; - // FIXME: Really we would like the segment, flags, etc. to be separate - // values instead of embedded in the name. Not all assemblers understand all - // this stuff though. - OS << ".section " << Section << "\n"; + // FIXME: Needs TargetAsmInfo! + Section->PrintSwitchToSection(*(const TargetAsmInfo*)0, OS); } } @@ -228,7 +219,12 @@ void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, // FIXME: Really we would like the segment and section names as well as the // section type to be separate values instead of embedded in the name. Not // all assemblers understand all this stuff though. - OS << ".zerofill " << Section; + OS << ".zerofill "; + + // This is a mach-o specific directive. + OS << '"' << ((MCSectionMachO*)Section)->getName() << '"'; + + if (Symbol != NULL) { OS << ',' << Symbol << ',' << Size; if (Pow2Alignment != 0) diff --git a/lib/MC/MCSection.cpp b/lib/MC/MCSection.cpp index a1f5664859..80a80e7d8d 100644 --- a/lib/MC/MCSection.cpp +++ b/lib/MC/MCSection.cpp @@ -20,13 +20,6 @@ using namespace llvm; MCSection::~MCSection() { } -MCSection::MCSection(const StringRef &N, bool isDirective, SectionKind K, - MCContext &Ctx) - : Name(N), IsDirective(isDirective), Kind(K) { - MCSection *&Entry = Ctx.Sections[Name]; - assert(Entry == 0 && "Multiple sections with the same name created"); - Entry = this; -} //===----------------------------------------------------------------------===// // MCSectionELF @@ -37,6 +30,13 @@ Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { return new (Ctx) MCSectionELF(Name, IsDirective, K, Ctx); } +MCSectionELF::MCSectionELF(const StringRef &name, bool isDirective, + SectionKind K, MCContext &Ctx) + : MCSection(K), Name(name), IsDirective(isDirective) { + Ctx.SetSection(Name, this); +} + + void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI, raw_ostream &OS) const { if (isDirective()) { @@ -118,6 +118,12 @@ Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { return new (Ctx) MCSectionMachO(Name, IsDirective, K, Ctx); } +MCSectionMachO::MCSectionMachO(const StringRef &name, bool isDirective, + SectionKind K, MCContext &Ctx) + : MCSection(K), Name(name), IsDirective(isDirective) { + Ctx.SetSection(Name, this); +} + void MCSectionMachO::PrintSwitchToSection(const TargetAsmInfo &TAI, raw_ostream &OS) const { if (!isDirective()) @@ -135,6 +141,13 @@ Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { return new (Ctx) MCSectionCOFF(Name, IsDirective, K, Ctx); } +MCSectionCOFF::MCSectionCOFF(const StringRef &name, bool isDirective, + SectionKind K, MCContext &Ctx) + : MCSection(K), Name(name), IsDirective(isDirective) { + Ctx.SetSection(Name, this); +} + + void MCSectionCOFF::PrintSwitchToSection(const TargetAsmInfo &TAI, raw_ostream &OS) const { |