LLVM  10.0.0svn
MCSectionXCOFF.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/MC/MCAsmInfo.h"
11 #include "llvm/MC/MCExpr.h"
13 
14 using namespace llvm;
15 
17 
19  switch (SMC) {
20  case XCOFF::XMC_DS:
21  return "DS";
22  case XCOFF::XMC_RW:
23  return "RW";
24  case XCOFF::XMC_PR:
25  return "PR";
26  default:
27  report_fatal_error("Unhandled storage-mapping class.");
28  }
29 }
30 
32  raw_ostream &OS,
33  const MCExpr *Subsection) const {
34  if (getKind().isText()) {
36  report_fatal_error("Unhandled storage-mapping class for .text csect");
37 
38  OS << "\t.csect " << getSectionName() << "["
40  << "]" << '\n';
41  return;
42  }
43 
44  if (getKind().isData()) {
45  switch (getMappingClass()) {
46  case XCOFF::XMC_RW:
47  case XCOFF::XMC_DS:
48  OS << "\t.csect " << getSectionName() << "["
49  << getMappingClassString(getMappingClass()) << "]" << '\n';
50  break;
51  case XCOFF::XMC_TC0:
52  OS << "\t.toc\n";
53  break;
54  default:
56  "Unhandled storage-mapping class for .data csect.");
57  }
58  return;
59  }
60 
61  if (getKind().isBSSLocal() || getKind().isCommon()) {
64  "Generated a storage-mapping class for a common/bss csect we don't "
65  "understand how to switch to.");
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
70  // csect.
71  return;
72  }
73 
74  report_fatal_error("Printing for this SectionKind is unimplemented.");
75 }
76 
77 bool MCSectionXCOFF::UseCodeAlign() const { return getKind().isText(); }
78 
SectionKind getKind() const
Definition: MCSection.h:106
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:139
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static StringRef getMappingClassString(XCOFF::StorageMappingClass SMC)
TOC Anchor for TOC Addressability.
Definition: XCOFF.h:43
Read Write Data.
Definition: XCOFF.h:42
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
bool isText() const
Definition: SectionKind.h:118
Common csect definition. For uninitialized storage.
Definition: XCOFF.h:148
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Program Code.
Definition: XCOFF.h:30
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
StorageMappingClass
Storage Mapping Class definitions.
Definition: XCOFF.h:28
bool isVirtualSection() const override
Check whether this section is "virtual", that is has no actual object file contents.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
XCOFF::SymbolType getCSectType() const
bool UseCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
BSS class (uninitialized static internal)
Definition: XCOFF.h:48
void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const override
XCOFF::StorageMappingClass getMappingClass() const
StringRef getSectionName() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Descriptor csect.
Definition: XCOFF.h:46