[llvm] r207342 - MC: style tweaks to WinCOFFStreamer
Saleem Abdulrasool
compnerd at compnerd.org
Sat Apr 26 20:48:01 PDT 2014
Author: compnerd
Date: Sat Apr 26 22:48:01 2014
New Revision: 207342
URL: http://llvm.org/viewvc/llvm-project?rev=207342&view=rev
Log:
MC: style tweaks to WinCOFFStreamer
Stylistic changes to prepare for splitting up the COFFStreamer into target
specific streamers. Tweak some assertion messages. No functional change.
Modified:
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=207342&r1=207341&r2=207342&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Sat Apr 26 22:48:01 2014
@@ -40,9 +40,7 @@ class WinCOFFStreamer : public MCObjectS
public:
MCSymbol const *CurSymbol;
- WinCOFFStreamer(MCContext &Context,
- MCAsmBackend &MAB,
- MCCodeEmitter &CE,
+ WinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB, MCCodeEmitter &CE,
raw_ostream &OS);
// MCStreamer interface
@@ -65,10 +63,10 @@ public:
unsigned ByteAlignment) override;
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) override;
- void EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
- uint64_t Size,unsigned ByteAlignment) override;
- void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment) override;
+ void EmitZerofill(const MCSection *Section, MCSymbol *Symbol, uint64_t Size,
+ unsigned ByteAlignment) override;
+ void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, uint64_t Size,
+ unsigned ByteAlignment) override;
void EmitFileDirective(StringRef Filename) override;
void EmitIdent(StringRef IdentString) override;
void EmitWin64EHHandlerData() override;
@@ -124,6 +122,7 @@ void WinCOFFStreamer::EmitLabel(MCSymbol
void WinCOFFStreamer::EmitDebugLabel(MCSymbol *Symbol) {
EmitLabel(Symbol);
}
+
void WinCOFFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
llvm_unreachable("not implemented");
}
@@ -135,24 +134,22 @@ void WinCOFFStreamer::EmitThumbFunc(MCSy
bool WinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
MCSymbolAttr Attribute) {
assert(Symbol && "Symbol must be non-null!");
- assert((Symbol->isInSection()
- ? Symbol->getSection().getVariant() == MCSection::SV_COFF
- : true) && "Got non-COFF section in the COFF backend!");
+ assert((!Symbol->isInSection() ||
+ Symbol->getSection().getVariant() == MCSection::SV_COFF) &&
+ "Got non-COFF section in the COFF backend!");
+
+ MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
+
switch (Attribute) {
+ default: return false;
case MCSA_WeakReference:
- case MCSA_Weak: {
- MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
- SD.modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal);
- SD.setExternal(true);
- }
+ case MCSA_Weak:
+ SD.modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal);
+ SD.setExternal(true);
break;
-
case MCSA_Global:
- getAssembler().getOrCreateSymbolData(*Symbol).setExternal(true);
+ SD.setExternal(true);
break;
-
- default:
- return false;
}
return true;
@@ -163,68 +160,64 @@ void WinCOFFStreamer::EmitSymbolDesc(MCS
}
void WinCOFFStreamer::BeginCOFFSymbolDef(MCSymbol const *Symbol) {
- assert((Symbol->isInSection()
- ? Symbol->getSection().getVariant() == MCSection::SV_COFF
- : true) && "Got non-COFF section in the COFF backend!");
- assert(!CurSymbol && "EndCOFFSymbolDef must be called between calls "
- "to BeginCOFFSymbolDef!");
+ assert((!Symbol->isInSection() ||
+ Symbol->getSection().getVariant() == MCSection::SV_COFF) &&
+ "Got non-COFF section in the COFF backend!");
+ assert(!CurSymbol && "starting new symbol definition in a symbol definition");
CurSymbol = Symbol;
}
void WinCOFFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {
- assert(CurSymbol && "BeginCOFFSymbolDef must be called first!");
- assert((StorageClass & ~0xFF) == 0 && "StorageClass must only have data in "
- "the first byte!");
-
- getAssembler().getOrCreateSymbolData(*CurSymbol).modifyFlags(
- StorageClass << COFF::SF_ClassShift,
- COFF::SF_ClassMask);
+ assert(CurSymbol && "StorageClass specified outside of symbol definition");
+ assert((StorageClass & ~0xFF) == 0 &&
+ "StorageClass must only have data in the first byte!");
+
+ MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*CurSymbol);
+ SD.modifyFlags(StorageClass << COFF::SF_ClassShift, COFF::SF_ClassMask);
}
void WinCOFFStreamer::EmitCOFFSymbolType(int Type) {
- assert(CurSymbol && "BeginCOFFSymbolDef must be called first!");
- assert((Type & ~0xFFFF) == 0 && "Type must only have data in the first 2 "
- "bytes");
-
- getAssembler().getOrCreateSymbolData(*CurSymbol).modifyFlags(
- Type << COFF::SF_TypeShift,
- COFF::SF_TypeMask);
+ assert(CurSymbol && "SymbolType specified outside of a symbol definition");
+ assert((Type & ~0xFFFF) == 0 &&
+ "Type must only have data in the first 2 bytes");
+
+ MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*CurSymbol);
+ SD.modifyFlags(Type << COFF::SF_TypeShift, COFF::SF_TypeMask);
}
void WinCOFFStreamer::EndCOFFSymbolDef() {
- assert(CurSymbol && "BeginCOFFSymbolDef must be called first!");
+ assert(CurSymbol && "ending symbol definition without beginning one");
CurSymbol = nullptr;
}
void WinCOFFStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
MCDataFragment *DF = getOrCreateDataFragment();
- DF->getFixups().push_back(MCFixup::Create(
- DF->getContents().size(), MCSymbolRefExpr::Create(Symbol, getContext()),
- FK_SecRel_2));
+ const MCSymbolRefExpr *SRE = MCSymbolRefExpr::Create(Symbol, getContext());
+ MCFixup Fixup = MCFixup::Create(DF->getContents().size(), SRE, FK_SecRel_2);
+ DF->getFixups().push_back(Fixup);
DF->getContents().resize(DF->getContents().size() + 4, 0);
}
void WinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {
MCDataFragment *DF = getOrCreateDataFragment();
- DF->getFixups().push_back(MCFixup::Create(
- DF->getContents().size(), MCSymbolRefExpr::Create(Symbol, getContext()),
- FK_SecRel_4));
+ const MCSymbolRefExpr *SRE = MCSymbolRefExpr::Create(Symbol, getContext());
+ MCFixup Fixup = MCFixup::Create(DF->getContents().size(), SRE, FK_SecRel_4);
+ DF->getFixups().push_back(Fixup);
DF->getContents().resize(DF->getContents().size() + 4, 0);
}
void WinCOFFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
- llvm_unreachable("not implemented");
+ llvm_unreachable("not supported");
}
void WinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) {
- assert((Symbol->isInSection()
- ? Symbol->getSection().getVariant() == MCSection::SV_COFF
- : true) && "Got non-COFF section in the COFF backend!");
+ assert((!Symbol->isInSection() ||
+ Symbol->getSection().getVariant() == MCSection::SV_COFF) &&
+ "Got non-COFF section in the COFF backend!");
if (ByteAlignment > 32)
- report_fatal_error(
- "The linker won't align common symbols beyond 32 bytes.");
+ report_fatal_error("alignment is limited to 32-bytes");
AssignSection(Symbol, nullptr);
@@ -251,12 +244,13 @@ void WinCOFFStreamer::EmitLocalCommonSym
new MCAlignFragment(ByteAlignment, /*_Value=*/0, /*_ValueSize=*/0,
ByteAlignment, &SectionData);
- SD.setFragment(
- new MCFillFragment(/*_Value=*/0, /*_ValueSize=*/0, Size, &SectionData));
+ MCFillFragment *Fragment =
+ new MCFillFragment(/*_Value=*/0, /*_ValueSize=*/0, Size, &SectionData);
+ SD.setFragment(Fragment);
}
void WinCOFFStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
- uint64_t Size,unsigned ByteAlignment) {
+ uint64_t Size, unsigned ByteAlignment) {
llvm_unreachable("not implemented");
}
@@ -271,7 +265,7 @@ void WinCOFFStreamer::EmitFileDirective(
// TODO: Implement this if you want to emit .comment section in COFF obj files.
void WinCOFFStreamer::EmitIdent(StringRef IdentString) {
- llvm_unreachable("unsupported directive");
+ llvm_unreachable("not implemented");
}
void WinCOFFStreamer::EmitWin64EHHandlerData() {
@@ -288,15 +282,13 @@ void WinCOFFStreamer::FinishImpl() {
MCObjectStreamer::FinishImpl();
}
-namespace llvm
-{
- MCStreamer *createWinCOFFStreamer(MCContext &Context,
- MCAsmBackend &MAB,
- MCCodeEmitter &CE,
- raw_ostream &OS,
- bool RelaxAll) {
- WinCOFFStreamer *S = new WinCOFFStreamer(Context, MAB, CE, OS);
- S->getAssembler().setRelaxAll(RelaxAll);
- return S;
- }
+namespace llvm {
+MCStreamer *createWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
+ MCCodeEmitter &CE, raw_ostream &OS,
+ bool RelaxAll) {
+ WinCOFFStreamer *S = new WinCOFFStreamer(Context, MAB, CE, OS);
+ S->getAssembler().setRelaxAll(RelaxAll);
+ return S;
+}
}
+
More information about the llvm-commits
mailing list