Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCObjectStreamer.cpp - Object File MCStreamer Interface -----===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/MC/MCObjectStreamer.h" |
| 11 | |
| 12 | #include "llvm/MC/MCAssembler.h" |
| 13 | using namespace llvm; |
| 14 | |
| 15 | MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, |
| 16 | raw_ostream &_OS, MCCodeEmitter *_Emitter) |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 17 | : MCStreamer(Context), Assembler(new MCAssembler(Context, TAB, |
| 18 | *_Emitter, _OS)), |
| 19 | CurSectionData(0) |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 20 | { |
| 21 | } |
| 22 | |
| 23 | MCObjectStreamer::~MCObjectStreamer() { |
| 24 | delete Assembler; |
| 25 | } |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 26 | |
| 27 | void MCObjectStreamer::SwitchSection(const MCSection *Section) { |
| 28 | assert(Section && "Cannot switch to a null section!"); |
| 29 | |
| 30 | // If already in this section, then this is a noop. |
| 31 | if (Section == CurSection) return; |
| 32 | |
| 33 | CurSection = Section; |
| 34 | CurSectionData = &getAssembler().getOrCreateSectionData(*Section); |
| 35 | } |
| 36 | |
| 37 | void MCObjectStreamer::Finish() { |
| 38 | getAssembler().Finish(); |
| 39 | } |