summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/MC/MCMachOStreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/llvm/lib/MC/MCMachOStreamer.cpp')
-rw-r--r--gnu/llvm/lib/MC/MCMachOStreamer.cpp81
1 files changed, 33 insertions, 48 deletions
diff --git a/gnu/llvm/lib/MC/MCMachOStreamer.cpp b/gnu/llvm/lib/MC/MCMachOStreamer.cpp
index 674c7b9bf61..3969143bb2c 100644
--- a/gnu/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/gnu/llvm/lib/MC/MCMachOStreamer.cpp
@@ -62,10 +62,12 @@ private:
void EmitDataRegionEnd();
public:
- MCMachOStreamer(MCContext &Context, MCAsmBackend &MAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter, bool DWARFMustBeAtTheEnd, bool label)
- : MCObjectStreamer(Context, MAB, OS, Emitter), LabelSections(label),
- DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd), CreatedADWARFSection(false) {}
+ MCMachOStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, std::unique_ptr<MCCodeEmitter> Emitter,
+ bool DWARFMustBeAtTheEnd, bool label)
+ : MCObjectStreamer(Context, std::move(MAB), OS, std::move(Emitter)),
+ LabelSections(label), DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd),
+ CreatedADWARFSection(false) {}
/// state management
void reset() override {
@@ -86,6 +88,8 @@ public:
void EmitDataRegion(MCDataRegionType Kind) override;
void EmitVersionMin(MCVersionMinType Kind, unsigned Major,
unsigned Minor, unsigned Update) override;
+ void EmitBuildVersion(unsigned Platform, unsigned Major,
+ unsigned Minor, unsigned Update) override;
void EmitThumbFunc(MCSymbol *Func) override;
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
@@ -263,7 +267,13 @@ void MCMachOStreamer::EmitDataRegion(MCDataRegionType Kind) {
void MCMachOStreamer::EmitVersionMin(MCVersionMinType Kind, unsigned Major,
unsigned Minor, unsigned Update) {
- getAssembler().setVersionMinInfo(Kind, Major, Minor, Update);
+ getAssembler().setVersionMin(Kind, Major, Minor, Update);
+}
+
+void MCMachOStreamer::EmitBuildVersion(unsigned Platform, unsigned Major,
+ unsigned Minor, unsigned Update) {
+ getAssembler().setBuildVersion((MachO::PlatformType)Platform, Major, Minor,
+ Update);
}
void MCMachOStreamer::EmitThumbFunc(MCSymbol *Symbol) {
@@ -401,29 +411,19 @@ void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
uint64_t Size, unsigned ByteAlignment) {
- getAssembler().registerSection(*Section);
-
- // The symbol may not be present, which only creates the section.
- if (!Symbol)
- return;
-
// On darwin all virtual sections have zerofill type.
assert(Section->isVirtualSection() && "Section does not have zerofill type!");
- assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
+ PushSection();
+ SwitchSection(Section);
- getAssembler().registerSymbol(*Symbol);
-
- // Emit an align fragment if necessary.
- if (ByteAlignment != 1)
- new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
-
- MCFragment *F = new MCFillFragment(0, Size, Section);
- Symbol->setFragment(F);
-
- // Update the maximum alignment on the zero fill section if necessary.
- if (ByteAlignment > Section->getAlignment())
- Section->setAlignment(ByteAlignment);
+ // The symbol may not be present, which only creates the section.
+ if (Symbol) {
+ EmitValueToAlignment(ByteAlignment, 0, 1, 0);
+ EmitLabel(Symbol);
+ EmitZeros(Size);
+ }
+ PopSection();
}
// This should always be called with the thread local bss section. Like the
@@ -483,32 +483,17 @@ void MCMachOStreamer::FinishImpl() {
this->MCObjectStreamer::FinishImpl();
}
-MCStreamer *llvm::createMachOStreamer(MCContext &Context, MCAsmBackend &MAB,
- raw_pwrite_stream &OS, MCCodeEmitter *CE,
+MCStreamer *llvm::createMachOStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ raw_pwrite_stream &OS,
+ std::unique_ptr<MCCodeEmitter> &&CE,
bool RelaxAll, bool DWARFMustBeAtTheEnd,
bool LabelSections) {
- MCMachOStreamer *S = new MCMachOStreamer(Context, MAB, OS, CE,
- DWARFMustBeAtTheEnd, LabelSections);
- const Triple &TT = Context.getObjectFileInfo()->getTargetTriple();
- if (TT.isOSDarwin()) {
- unsigned Major, Minor, Update;
- TT.getOSVersion(Major, Minor, Update);
- // If there is a version specified, Major will be non-zero.
- if (Major) {
- MCVersionMinType VersionType;
- if (TT.isWatchOS())
- VersionType = MCVM_WatchOSVersionMin;
- else if (TT.isTvOS())
- VersionType = MCVM_TvOSVersionMin;
- else if (TT.isMacOSX())
- VersionType = MCVM_OSXVersionMin;
- else {
- assert(TT.isiOS() && "Must only be iOS platform left");
- VersionType = MCVM_IOSVersionMin;
- }
- S->EmitVersionMin(VersionType, Major, Minor, Update);
- }
- }
+ MCMachOStreamer *S =
+ new MCMachOStreamer(Context, std::move(MAB), OS, std::move(CE),
+ DWARFMustBeAtTheEnd, LabelSections);
+ const Triple &Target = Context.getObjectFileInfo()->getTargetTriple();
+ S->EmitVersionForTarget(Target);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
return S;