1 //===- lib/MC/MCSectionXCOFF.cpp - XCOFF Code Section Representation ------===//
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
7 //===----------------------------------------------------------------------===//
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"
16 MCSectionXCOFF::~MCSectionXCOFF() = default;
19 void MCSectionXCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
21 const MCExpr *Subsection) const {
22 if (getKind().isText()) {
23 if (getMappingClass() != XCOFF::XMC_PR)
24 report_fatal_error("Unhandled storage-mapping class for .text csect");
26 OS << "\t.csect " << QualName->getName() << '\n';
30 if (getKind().isReadOnly()) {
31 if (getMappingClass() != XCOFF::XMC_RO)
32 report_fatal_error("Unhandled storage-mapping class for .rodata csect.");
33 OS << "\t.csect " << QualName->getName() << '\n';
37 if (getKind().isData()) {
38 switch (getMappingClass()) {
41 OS << "\t.csect " << QualName->getName() << '\n';
50 "Unhandled storage-mapping class for .data csect.");
55 if (getKind().isBSSLocal() || getKind().isCommon()) {
56 assert((getMappingClass() == XCOFF::XMC_RW ||
57 getMappingClass() == XCOFF::XMC_BS) &&
58 "Generated a storage-mapping class for a common/bss csect we don't "
59 "understand how to switch to.");
60 assert(getCSectType() == XCOFF::XTY_CM &&
61 "wrong csect type for .bss csect");
62 // Don't have to print a directive for switching to section for commons.
63 // '.comm' and '.lcomm' directives for the variable will create the needed
68 report_fatal_error("Printing for this SectionKind is unimplemented.");
71 bool MCSectionXCOFF::UseCodeAlign() const { return getKind().isText(); }
73 bool MCSectionXCOFF::isVirtualSection() const { return XCOFF::XTY_CM == Type; }