blob: d15146654ebf8c4a2afcc688aa5c29dda3c736c9 [file] [log] [blame]
Chris Lattnereb40a0f2010-05-07 17:17:41 +00001//===- lib/MC/MCSectionCOFF.cpp - COFF 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/MCSectionCOFF.h"
11#include "llvm/MC/MCAsmInfo.h"
12#include "llvm/MC/MCContext.h"
13#include "llvm/MC/MCSymbol.h"
14#include "llvm/Support/raw_ostream.h"
15using namespace llvm;
16
17MCSectionCOFF::~MCSectionCOFF() {} // anchor.
18
19// ShouldOmitSectionDirective - Decides whether a '.section' directive
20// should be printed before the section name
21bool MCSectionCOFF::ShouldOmitSectionDirective(StringRef Name,
22 const MCAsmInfo &MAI) const {
23
24 // FIXME: Does .section .bss/.data/.text work everywhere??
25 if (Name == ".text" || Name == ".data" || Name == ".bss")
26 return true;
27
28 return false;
29}
30
31void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
32 raw_ostream &OS) const {
33
34 if (ShouldOmitSectionDirective(SectionName, MAI)) {
35 OS << '\t' << getSectionName() << '\n';
36 return;
37 }
38
39 OS << "\t.section\t" << getSectionName() << ",\"";
40 if (getKind().isText())
41 OS << 'x';
42 if (getKind().isWriteable())
43 OS << 'w';
44 else
45 OS << 'r';
Chris Lattner6e5ce282010-05-07 21:49:09 +000046 if (getCharacteristics() & MCSectionCOFF::IMAGE_SCN_MEM_DISCARDABLE)
Chris Lattnereb40a0f2010-05-07 17:17:41 +000047 OS << 'n';
48 OS << "\"\n";
49}