blob: d3f7f7783ffa7b60a901f6d315b745be0da783b7 [file] [log] [blame]
Daniel Dunbar8dc68ab2010-06-16 20:04:22 +00001//===- 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"
13using namespace llvm;
14
15MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB,
16 raw_ostream &_OS, MCCodeEmitter *_Emitter)
Daniel Dunbar83b46712010-06-16 20:04:25 +000017 : MCStreamer(Context), Assembler(new MCAssembler(Context, TAB,
18 *_Emitter, _OS)),
19 CurSectionData(0)
Daniel Dunbar8dc68ab2010-06-16 20:04:22 +000020{
21}
22
23MCObjectStreamer::~MCObjectStreamer() {
24 delete Assembler;
25}
Daniel Dunbar83b46712010-06-16 20:04:25 +000026
27void 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
37void MCObjectStreamer::Finish() {
38 getAssembler().Finish();
39}