diff options
Diffstat (limited to 'lib/MC/MCWasmStreamer.cpp')
-rw-r--r-- | lib/MC/MCWasmStreamer.cpp | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/lib/MC/MCWasmStreamer.cpp b/lib/MC/MCWasmStreamer.cpp index d9cefbd3994f..0e5932214047 100644 --- a/lib/MC/MCWasmStreamer.cpp +++ b/lib/MC/MCWasmStreamer.cpp @@ -45,7 +45,8 @@ void MCWasmStreamer::mergeFragment(MCDataFragment *DF, MCDataFragment *EF) { DF->getContents().size()); DF->getFixups().push_back(EF->getFixups()[i]); } - DF->setHasInstructions(true); + if (DF->getSubtargetInfo() == nullptr && EF->getSubtargetInfo()) + DF->setHasInstructions(*EF->getSubtargetInfo()); DF->getContents().append(EF->getContents().begin(), EF->getContents().end()); } @@ -66,6 +67,7 @@ void MCWasmStreamer::ChangeSection(MCSection *Section, Asm.registerSymbol(*Grp); this->MCObjectStreamer::ChangeSection(Section, Subsection); + Asm.registerSymbol(*Section->getBeginSymbol()); } void MCWasmStreamer::EmitWeakReference(MCSymbol *Alias, @@ -81,9 +83,9 @@ bool MCWasmStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) { auto *Symbol = cast<MCSymbolWasm>(S); - // Adding a symbol attribute always introduces the symbol, note that an - // important side effect of calling registerSymbol here is to register - // the symbol with the assembler. + // Adding a symbol attribute always introduces the symbol; note that an + // important side effect of calling registerSymbol here is to register the + // symbol with the assembler. getAssembler().registerSymbol(*Symbol); switch (Attribute) { @@ -113,11 +115,11 @@ bool MCWasmStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) { break; case MCSA_ELF_TypeFunction: - Symbol->setIsFunction(true); + Symbol->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); break; case MCSA_ELF_TypeObject: - Symbol->setIsFunction(false); + Symbol->setType(wasm::WASM_SYMBOL_TYPE_DATA); break; default: @@ -156,17 +158,8 @@ void MCWasmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value, } void MCWasmStreamer::EmitIdent(StringRef IdentString) { - MCSection *Comment = getAssembler().getContext().getWasmSection( - ".comment", SectionKind::getMetadata()); - PushSection(); - SwitchSection(Comment); - if (!SeenIdent) { - EmitIntValue(0, 1); - SeenIdent = true; - } - EmitBytes(IdentString); - EmitIntValue(0, 1); - PopSection(); + // TODO(sbc): Add the ident section once we support mergable strings + // sections in the object format } void MCWasmStreamer::EmitInstToFragment(const MCInst &Inst, @@ -191,7 +184,7 @@ void MCWasmStreamer::EmitInstToData(const MCInst &Inst, Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); DF->getFixups().push_back(Fixups[i]); } - DF->setHasInstructions(true); + DF->setHasInstructions(STI); DF->getContents().append(Code.begin(), Code.end()); } @@ -203,11 +196,11 @@ void MCWasmStreamer::FinishImpl() { MCStreamer *llvm::createWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> &&MAB, - raw_pwrite_stream &OS, + std::unique_ptr<MCObjectWriter> &&OW, std::unique_ptr<MCCodeEmitter> &&CE, bool RelaxAll) { MCWasmStreamer *S = - new MCWasmStreamer(Context, std::move(MAB), OS, std::move(CE)); + new MCWasmStreamer(Context, std::move(MAB), std::move(OW), std::move(CE)); if (RelaxAll) S->getAssembler().setRelaxAll(true); return S; @@ -222,7 +215,8 @@ void MCWasmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { } void MCWasmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment) { + uint64_t Size, unsigned ByteAlignment, + SMLoc Loc) { llvm_unreachable("Wasm doesn't support this directive"); } |