gn build: Extract git() and git_out() functions in sync script
[llvm-complete.git] / lib / MC / MCSectionXCOFF.cpp
bloba3f79c35e841483a98fd2fd03a3a08630585e985
1 //===- 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 //===----------------------------------------------------------------------===//
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"
14 using namespace llvm;
16 MCSectionXCOFF::~MCSectionXCOFF() = default;
18 void MCSectionXCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
19 raw_ostream &OS,
20 const MCExpr *Subsection) const {
21 if (getKind().isText()) {
22 if (getMappingClass() != XCOFF::XMC_PR)
23 llvm_unreachable("Unsupported storage-mapping class for .text csect");
25 OS << "\t.csect " << getSectionName() << "["
26 << "PR"
27 << "]" << '\n';
28 return;
31 if (getKind().isBSSLocal() || getKind().isCommon()) {
32 if (getMappingClass() != XCOFF::XMC_RW &&
33 getMappingClass() != XCOFF::XMC_BS)
34 llvm_unreachable("Generated a storage-mapping class for a common/bss "
35 "csect we don't understand how to switch to.");
36 if (getCSectType() != XCOFF::XTY_CM)
37 llvm_unreachable("wrong csect type for .bss csect");
38 // 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;
44 report_fatal_error("Printing for this SectionKind is unimplemented.");
47 bool MCSectionXCOFF::UseCodeAlign() const { return getKind().isText(); }
49 bool MCSectionXCOFF::isVirtualSection() const { return XCOFF::XTY_CM == Type; }