blob: 333a4710f962d9593d7426b0a0f81f694f86f202 [file] [log] [blame]
Chris Lattnered47a042009-07-31 17:02:00 +00001//===- lib/MC/MCSection.cpp - Machine Code Section Representation ---------===//
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/MCSection.h"
11#include "llvm/MC/MCContext.h"
Chris Lattneraf76e592009-08-22 20:48:53 +000012#include "llvm/MC/MCAsmInfo.h"
Chris Lattner892e1822009-08-08 22:41:53 +000013#include "llvm/Support/raw_ostream.h"
Chris Lattnered47a042009-07-31 17:02:00 +000014using namespace llvm;
15
Chris Lattner892e1822009-08-08 22:41:53 +000016//===----------------------------------------------------------------------===//
17// MCSection
18//===----------------------------------------------------------------------===//
19
Chris Lattnered47a042009-07-31 17:02:00 +000020MCSection::~MCSection() {
21}
22
Chris Lattner892e1822009-08-08 22:41:53 +000023//===----------------------------------------------------------------------===//
24// MCSectionCOFF
25//===----------------------------------------------------------------------===//
Chris Lattnera1c31b72009-08-08 20:50:49 +000026
Chris Lattner7c599d02009-08-08 20:52:13 +000027MCSectionCOFF *MCSectionCOFF::
Chris Lattnera1c31b72009-08-08 20:50:49 +000028Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
Chris Lattner38cff382009-08-13 00:37:15 +000029 return new (Ctx) MCSectionCOFF(Name, IsDirective, K);
Chris Lattnera1c31b72009-08-08 20:50:49 +000030}
31
Chris Lattner33adcfb2009-08-22 21:43:10 +000032void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
Chris Lattner892e1822009-08-08 22:41:53 +000033 raw_ostream &OS) const {
34
35 if (isDirective()) {
36 OS << getName() << '\n';
37 return;
38 }
39 OS << "\t.section\t" << getName() << ",\"";
40 if (getKind().isText())
41 OS << 'x';
42 if (getKind().isWriteable())
43 OS << 'w';
44 OS << "\"\n";
45}