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;
18 static StringRef
getMappingClassString(XCOFF::StorageMappingClass SMC
) {
27 report_fatal_error("Unhandled storage-mapping class.");
31 void MCSectionXCOFF::PrintSwitchToSection(const MCAsmInfo
&MAI
, const Triple
&T
,
33 const MCExpr
*Subsection
) const {
34 if (getKind().isText()) {
35 if (getMappingClass() != XCOFF::XMC_PR
)
36 report_fatal_error("Unhandled storage-mapping class for .text csect");
38 OS
<< "\t.csect " << getSectionName() << "["
39 << getMappingClassString(getMappingClass())
44 if (getKind().isData()) {
45 switch (getMappingClass()) {
48 OS
<< "\t.csect " << getSectionName() << "["
49 << getMappingClassString(getMappingClass()) << "]" << '\n';
56 "Unhandled storage-mapping class for .data csect.");
61 if (getKind().isBSSLocal() || getKind().isCommon()) {
62 assert((getMappingClass() == XCOFF::XMC_RW
||
63 getMappingClass() == XCOFF::XMC_BS
) &&
64 "Generated a storage-mapping class for a common/bss csect we don't "
65 "understand how to switch to.");
66 assert(getCSectType() == XCOFF::XTY_CM
&&
67 "wrong csect type for .bss csect");
68 // Don't have to print a directive for switching to section for commons.
69 // '.comm' and '.lcomm' directives for the variable will create the needed
74 report_fatal_error("Printing for this SectionKind is unimplemented.");
77 bool MCSectionXCOFF::UseCodeAlign() const { return getKind().isText(); }
79 bool MCSectionXCOFF::isVirtualSection() const { return XCOFF::XTY_CM
== Type
; }