Next patch after D139548 and D139439. Same expectations, the change seems safe with as far as llvm goes, we cannot check downstream implementations.
Differential Revision: https://reviews.llvm.org/D139614
std::move(Emitter)) {}
bool emitSymbolAttribute(MCSymbol *, MCSymbolAttr) override { return false; }
- void emitCommonSymbol(MCSymbol *, uint64_t, unsigned) override {}
+ void emitCommonSymbol(MCSymbol *, uint64_t, Align) override {}
void emitZerofill(MCSection *, MCSymbol *Symbol = nullptr, uint64_t Size = 0,
Align ByteAlignment = Align(1),
SMLoc Loc = SMLoc()) override {}
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name,
return false;
}
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override {}
+ Align ByteAlignment) override {}
void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
uint64_t Size = 0, Align ByteAlignment = Align(1),
SMLoc Loc = SMLoc()) override {}
///
/// \param Symbol - The common symbol to emit.
/// \param Size - The size of the common symbol.
- /// \param ByteAlignment - The alignment of the symbol if
- /// non-zero. This must be a power of 2.
+ /// \param ByteAlignment - The alignment of the symbol.
virtual void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) = 0;
+ Align ByteAlignment) = 0;
/// Emit a local common (.lcomm) symbol.
///
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment) override;
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
uint64_t Size = 0, Align ByteAlignment = Align(1),
SMLoc Loc = SMLoc()) override;
if (GVKind.isCommon()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
// .comm _foo, 42, 4
- OutStreamer->emitCommonSymbol(GVSym, Size, Alignment.value());
+ OutStreamer->emitCommonSymbol(GVSym, Size, Alignment);
return;
}
// .local _foo
OutStreamer->emitSymbolAttribute(GVSym, MCSA_Local);
// .comm _foo, 42, 4
- OutStreamer->emitCommonSymbol(GVSym, Size, Alignment.value());
+ OutStreamer->emitCommonSymbol(GVSym, Size, Alignment);
return;
}
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
/// Emit a local common (.lcomm) symbol.
///
}
void MCAsmStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) {
+ Align ByteAlignment) {
OS << "\t.comm\t";
Symbol->print(OS, MAI);
OS << ',' << Size;
if (MAI->getCOMMDirectiveAlignmentIsInBytes())
- OS << ',' << ByteAlignment;
+ OS << ',' << ByteAlignment.value();
else
- OS << ',' << Log2_32(ByteAlignment);
+ OS << ',' << Log2(ByteAlignment);
EmitEOL();
// Print symbol's rename (original name contains invalid character(s)) if
MCSymbolXCOFF *XSym = dyn_cast<MCSymbolXCOFF>(Symbol);
if (XSym && XSym->hasRename())
emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
-
}
void MCAsmStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
}
void MCELFStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size,
- unsigned ByteAlignment) {
+ Align ByteAlignment) {
auto *Symbol = cast<MCSymbolELF>(S);
getAssembler().registerSymbol(*Symbol);
MCSectionSubPair P = getCurrentSection();
switchSection(&Section);
- emitValueToAlignment(Align(ByteAlignment), 0, 1, 0);
+ emitValueToAlignment(ByteAlignment, 0, 1, 0);
emitLabel(Symbol);
emitZeros(Size);
switchSection(P.first, P.second);
} else {
- if(Symbol->declareCommon(Size, ByteAlignment))
+ if (Symbol->declareCommon(Size, ByteAlignment.value()))
report_fatal_error(Twine("Symbol: ") + Symbol->getName() +
" redeclared as different type");
}
// FIXME: Should this be caught and done earlier?
getAssembler().registerSymbol(*Symbol);
Symbol->setBinding(ELF::STB_LOCAL);
- emitCommonSymbol(Symbol, Size, ByteAlignment.value());
+ emitCommonSymbol(Symbol, Size, ByteAlignment);
}
void MCELFStreamer::emitValueImpl(const MCExpr *Value, unsigned Size,
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment) override;
}
void MCMachOStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) {
+ Align ByteAlignment) {
// FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true);
- Symbol->setCommon(Size, ByteAlignment);
+ Symbol->setCommon(Size, ByteAlignment.value());
}
void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
}
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override {}
+ Align ByteAlignment) override {}
void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
uint64_t Size = 0, Align ByteAlignment = Align(1),
SMLoc Loc = SMLoc()) override {}
return false;
}
- getStreamer().emitCommonSymbol(Sym, Size, 1 << Pow2Alignment);
+ getStreamer().emitCommonSymbol(Sym, Size, Align(1ULL << Pow2Alignment));
return false;
}
return false;
}
- getStreamer().emitCommonSymbol(Sym, Size, 1 << Pow2Alignment);
+ getStreamer().emitCommonSymbol(Sym, Size, Align(1ULL << Pow2Alignment));
return false;
}
}
void MCWasmStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size,
- unsigned ByteAlignment) {
+ Align ByteAlignment) {
llvm_unreachable("Common symbols are not yet implemented for Wasm");
}
}
void MCWinCOFFStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size,
- unsigned ByteAlignment) {
+ Align ByteAlignment) {
auto *Symbol = cast<MCSymbolCOFF>(S);
const Triple &T = getContext().getTargetTriple();
report_fatal_error("alignment is limited to 32-bytes");
// Round size up to alignment so that we will honor the alignment request.
- Size = std::max(Size, static_cast<uint64_t>(ByteAlignment));
+ Size = std::max(Size, ByteAlignment.value());
}
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true);
- Symbol->setCommon(Size, ByteAlignment);
+ Symbol->setCommon(Size, ByteAlignment.value());
if (!T.isWindowsMSVCEnvironment() && ByteAlignment > 1) {
SmallString<128> Directive;
const MCObjectFileInfo *MFI = getContext().getObjectFileInfo();
OS << " -aligncomm:\"" << Symbol->getName() << "\","
- << Log2_32_Ceil(ByteAlignment);
+ << Log2_32_Ceil(ByteAlignment.value());
pushSection();
switchSection(MFI->getDrectveSection());
}
void MCXCOFFStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) {
+ Align ByteAlignment) {
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(cast<MCSymbolXCOFF>(Symbol)->getStorageClass() !=
XCOFF::C_HIDEXT);
- Symbol->setCommon(Size, ByteAlignment);
+ Symbol->setCommon(Size, ByteAlignment.value());
// Default csect align is 4, but common symbols have explicit alignment values
// and we should honor it.
cast<MCSymbolXCOFF>(Symbol)->getRepresentedCsect()->setAlignment(
- Align(ByteAlignment));
+ ByteAlignment);
// Emit the alignment and storage for the variable to the section.
- emitValueToAlignment(Align(ByteAlignment));
+ emitValueToAlignment(ByteAlignment);
emitZeros(Size);
}
uint64_t Size,
MCSymbol *CsectSym,
Align Alignment) {
- emitCommonSymbol(CsectSym, Size, Alignment.value());
+ emitCommonSymbol(CsectSym, Size, Alignment);
}
}
void RecordStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) {
+ Align ByteAlignment) {
markDefined(*Symbol);
}
void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment, SMLoc Loc = SMLoc()) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
// Ignore COFF-specific directives; we do not need any information from them,
// but the default implementation of these methods crashes, so we override
OutContext.getOrCreateSymbol(GVSym->getSymbolTableName()), Size,
GVSym, Alignment);
else
- OutStreamer->emitCommonSymbol(GVSym, Size, Alignment.value());
+ OutStreamer->emitCommonSymbol(GVSym, Size, Alignment);
return;
}
private:
// We only care about instructions, we don't implement this part of the API.
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override {}
+ Align ByteAlignment) override {}
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override {
return false;
}
}
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override {}
+ Align ByteAlignment) override {}
void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
uint64_t Size = 0, Align ByteAlignment = Align(1),
SMLoc Loc = SMLoc()) override {}
MOCK_METHOD2(emitSymbolAttribute,
bool(MCSymbol *Symbol, MCSymbolAttr Attribute));
MOCK_METHOD3(emitCommonSymbol,
- void(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment));
+ void(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment));
MOCK_METHOD5(emitZerofill,
void(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment, SMLoc Loc));