blob: d00a435b6250ca601260cfd9e9a998f591c95dc0 [file] [log] [blame]
Sean Fertilef09d54e2019-07-09 19:21:01 +00001//===- lib/MC/MCSectionXCOFF.cpp - XCOFF Code Section Representation ------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/MC/MCSectionXCOFF.h"
10#include "llvm/MC/MCAsmInfo.h"
11#include "llvm/MC/MCExpr.h"
12#include "llvm/Support/raw_ostream.h"
13
14using namespace llvm;
15
16MCSectionXCOFF::~MCSectionXCOFF() = default;
17
18void MCSectionXCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
19 raw_ostream &OS,
20 const MCExpr *Subsection) const {
21 if (getKind().isText()) {
Sean Fertile942537d2019-07-22 19:15:29 +000022 if (getMappingClass() != XCOFF::XMC_PR)
23 llvm_unreachable("Unsupported storage-mapping class for .text csect");
24
Sean Fertilef09d54e2019-07-09 19:21:01 +000025 OS << "\t.csect " << getSectionName() << "["
26 << "PR"
27 << "]" << '\n';
28 return;
29 }
30
David Tenty8558aac2019-08-08 15:40:35 +000031 if (getKind().isBSSLocal() || getKind().isCommon()) {
David Tenty9bf01e52019-08-13 17:04:51 +000032 assert((getMappingClass() == XCOFF::XMC_RW ||
33 getMappingClass() == XCOFF::XMC_BS) &&
34 "Generated a storage-mapping class for a common/bss csect we don't "
35 "understand how to switch to.");
36 assert(getCSectType() == XCOFF::XTY_CM &&
37 "wrong csect type for .bss csect");
Sean Fertile942537d2019-07-22 19:15:29 +000038 // Don't have to print a directive for switching to section for commons.
39 // '.comm' and '.lcomm' directives for the variable will create the needed
40 // csect.
41 return;
42 }
43
Sean Fertilef09d54e2019-07-09 19:21:01 +000044 report_fatal_error("Printing for this SectionKind is unimplemented.");
45}
46
47bool MCSectionXCOFF::UseCodeAlign() const { return getKind().isText(); }
48
Sean Fertile942537d2019-07-22 19:15:29 +000049bool MCSectionXCOFF::isVirtualSection() const { return XCOFF::XTY_CM == Type; }