1 //===- MCSectionXCOFF.h - XCOFF Machine Code Sections -----------*- C++ -*-===//
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 // This file declares the MCSectionXCOFF class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_MC_MCSECTIONXCOFF_H
14 #define LLVM_MC_MCSECTIONXCOFF_H
16 #include "llvm/ADT/Twine.h"
17 #include "llvm/BinaryFormat/XCOFF.h"
18 #include "llvm/MC/MCSection.h"
24 // This class represents an XCOFF `Control Section`, more commonly referred to
25 // as a csect. A csect represents the smallest possible unit of data/code which
26 // will be relocated as a single block. A csect can either be:
27 // 1) Initialized: The Type will be XTY_SD, and the symbols inside the csect
28 // will have a label definition representing their offset within the csect.
29 // 2) Uninitialized: The Type will be XTY_CM, it will contain a single symbol,
30 // and may not contain label definitions.
31 // 3) An external reference providing a symbol table entry for a symbol
32 // contained in another XCOFF object file. External reference csects are not
34 class MCSectionXCOFF final
: public MCSection
{
35 friend class MCContext
;
38 XCOFF::StorageMappingClass MappingClass
;
39 XCOFF::SymbolType Type
;
40 XCOFF::StorageClass StorageClass
;
42 MCSectionXCOFF(StringRef Section
, XCOFF::StorageMappingClass SMC
,
43 XCOFF::SymbolType ST
, XCOFF::StorageClass SC
, SectionKind K
,
45 : MCSection(SV_XCOFF
, K
, Begin
), Name(Section
), MappingClass(SMC
),
46 Type(ST
), StorageClass(SC
) {
47 assert((ST
== XCOFF::XTY_SD
|| ST
== XCOFF::XTY_CM
) &&
48 "Invalid or unhandled type for csect.");
54 static bool classof(const MCSection
*S
) {
55 return S
->getVariant() == SV_XCOFF
;
58 StringRef
getSectionName() const { return Name
; }
59 XCOFF::StorageMappingClass
getMappingClass() const { return MappingClass
; }
60 XCOFF::StorageClass
getStorageClass() const { return StorageClass
; }
61 XCOFF::SymbolType
getCSectType() const { return Type
; }
63 void PrintSwitchToSection(const MCAsmInfo
&MAI
, const Triple
&T
,
65 const MCExpr
*Subsection
) const override
;
66 bool UseCodeAlign() const override
;
67 bool isVirtualSection() const override
;
70 } // end namespace llvm