LLVM 19.0.0git
MCSectionCOFF.cpp
Go to the documentation of this file.
1//===- lib/MC/MCSectionCOFF.cpp - COFF 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
11#include "llvm/MC/MCSymbol.h"
13#include <cassert>
14
15using namespace llvm;
16
17// shouldOmitSectionDirective - Decides whether a '.section' directive
18// should be printed before the section name
20 const MCAsmInfo &MAI) const {
21 if (COMDATSymbol)
22 return false;
23
24 // FIXME: Does .section .bss/.data/.text work everywhere??
25 if (Name == ".text" || Name == ".data" || Name == ".bss")
26 return true;
27
28 return false;
29}
30
32 assert(Selection != 0 && "invalid COMDAT selection type");
33 this->Selection = Selection;
34 Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
35}
36
39 uint32_t Subsection) const {
40 // standard sections don't require the '.section'
42 OS << '\t' << getName() << '\n';
43 return;
44 }
45
46 OS << "\t.section\t" << getName() << ",\"";
48 OS << 'd';
50 OS << 'b';
52 OS << 'x';
54 OS << 'w';
56 OS << 'r';
57 else
58 OS << 'y';
60 OS << 'n';
62 OS << 's';
65 OS << 'D';
67 OS << 'i';
68 OS << '"';
69
71 if (COMDATSymbol)
72 OS << ",";
73 else
74 OS << "\n\t.linkonce\t";
75 switch (Selection) {
77 OS << "one_only";
78 break;
80 OS << "discard";
81 break;
83 OS << "same_size";
84 break;
86 OS << "same_contents";
87 break;
89 OS << "associative";
90 break;
92 OS << "largest";
93 break;
95 OS << "newest";
96 break;
97 default:
98 assert(false && "unsupported COFF selection type");
99 break;
100 }
101 if (COMDATSymbol) {
102 OS << ",";
103 COMDATSymbol->print(OS, &MAI);
104 }
105 }
106 OS << '\n';
107}
108
109bool MCSectionCOFF::useCodeAlign() const { return isText(); }
110
112 return "IMAGE_SCN_CNT_UNINITIALIZED_DATA";
113}
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
std::string Name
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
static bool isImplicitlyDiscardable(StringRef Name)
Definition: MCSectionCOFF.h:87
bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const
Decides whether a '.section' directive should be printed before the section name.
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, uint32_t Subsection) const override
unsigned getCharacteristics() const
Definition: MCSectionCOFF.h:69
StringRef getVirtualSectionKind() const override
bool useCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
void setSelection(int Selection) const
bool isText() const
Definition: MCSection.h:143
StringRef Name
Definition: MCSection.h:131
StringRef getName() const
Definition: MCSection.h:142
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition: MCSymbol.cpp:58
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
@ IMAGE_SCN_MEM_SHARED
Definition: COFF.h:333
@ IMAGE_SCN_LNK_REMOVE
Definition: COFF.h:307
@ IMAGE_SCN_MEM_READ
Definition: COFF.h:335
@ IMAGE_SCN_MEM_EXECUTE
Definition: COFF.h:334
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
Definition: COFF.h:304
@ IMAGE_SCN_MEM_DISCARDABLE
Definition: COFF.h:330
@ IMAGE_SCN_LNK_INFO
Definition: COFF.h:306
@ IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: COFF.h:303
@ IMAGE_SCN_LNK_COMDAT
Definition: COFF.h:308
@ IMAGE_SCN_MEM_WRITE
Definition: COFF.h:336
@ IMAGE_COMDAT_SELECT_NODUPLICATES
Definition: COFF.h:421
@ IMAGE_COMDAT_SELECT_LARGEST
Definition: COFF.h:426
@ IMAGE_COMDAT_SELECT_NEWEST
Definition: COFF.h:427
@ IMAGE_COMDAT_SELECT_SAME_SIZE
Definition: COFF.h:423
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
Definition: COFF.h:425
@ IMAGE_COMDAT_SELECT_EXACT_MATCH
Definition: COFF.h:424
@ IMAGE_COMDAT_SELECT_ANY
Definition: COFF.h:422
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18