diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-04 13:12:43 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-04 13:12:43 +0000 |
commit | e660fc15fe1f1b8a19488f39d0ec09acc79bed0d (patch) | |
tree | 5d13654e9f153001009062b7832b2bb52c05e6be /lib/MC/MCObjectStreamer.cpp | |
parent | ee700cfc943f17f3521c4f04b2e3b9917b2ed1b6 (diff) |
Hoist some grossly duplicated code from the COFF/ELF/MachO streamers into MCObjectStreamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165225 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | lib/MC/MCObjectStreamer.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index 4b9acf750d..774632306d 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -232,6 +232,31 @@ void MCObjectStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, new MCDwarfCallFrameFragment(*AddrDelta, getCurrentSectionData()); } +void MCObjectStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { + assert(AddrSpace == 0 && "Address space must be 0!"); + getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end()); +} + +void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment, + int64_t Value, + unsigned ValueSize, + unsigned MaxBytesToEmit) { + if (MaxBytesToEmit == 0) + MaxBytesToEmit = ByteAlignment; + new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit, + getCurrentSectionData()); + + // Update the maximum alignment on the current section if necessary. + if (ByteAlignment > getCurrentSectionData()->getAlignment()) + getCurrentSectionData()->setAlignment(ByteAlignment); +} + +void MCObjectStreamer::EmitCodeAlignment(unsigned ByteAlignment, + unsigned MaxBytesToEmit) { + EmitValueToAlignment(ByteAlignment, 0, 1, MaxBytesToEmit); + cast<MCAlignFragment>(getCurrentFragment())->setEmitNops(true); +} + bool MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset, unsigned char Value) { int64_t Res; |