blob: 237b96de1ad4b77661f119018cfafd960e69eed4 [file] [log] [blame]
Jim Laskey7c95ad42006-09-06 19:21:41 +00001//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
Jim Laskeyec0d9fe2006-09-06 18:35:33 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskeyec0d9fe2006-09-06 18:35:33 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines target asm properties related what form asm statements
11// should take.
12//
13//===----------------------------------------------------------------------===//
14
Anton Korobeynikov28a2b542008-06-28 13:45:57 +000015#include "llvm/Constants.h"
16#include "llvm/GlobalVariable.h"
17#include "llvm/Function.h"
18#include "llvm/Module.h"
19#include "llvm/Type.h"
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000020#include "llvm/Target/TargetAsmInfo.h"
Anton Korobeynikov28a2b542008-06-28 13:45:57 +000021#include "llvm/Target/TargetOptions.h"
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000022#include "llvm/Support/Dwarf.h"
Dale Johannesen3bb62832007-04-23 20:00:17 +000023#include <cctype>
24#include <cstring>
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000025
26using namespace llvm;
27
28TargetAsmInfo::TargetAsmInfo() :
Dan Gohman95701652007-05-03 18:46:30 +000029 TextSection("\t.text"),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000030 TextSection_(0),
Dan Gohman95701652007-05-03 18:46:30 +000031 DataSection("\t.data"),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000032 DataSection_(0),
Dan Gohman95701652007-05-03 18:46:30 +000033 BSSSection("\t.bss"),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000034 BSSSection_(0),
35 ReadOnlySection(0),
36 ReadOnlySection_(0),
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000037 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000038 TLSDataSection_(0),
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000039 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000040 TLSBSSSection_(0),
Chris Lattner6f198df2007-01-17 17:42:42 +000041 ZeroFillDirective(0),
Dan Gohmana779a982008-05-05 00:28:39 +000042 NonexecutableStackDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000043 NeedsSet(false),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000044 MaxInstLength(4),
Jim Laskeyb82313f2007-02-01 16:31:34 +000045 PCSymbol("$"),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000046 SeparatorChar(';'),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000047 CommentString("#"),
48 GlobalPrefix(""),
49 PrivateGlobalPrefix("."),
Chris Lattner393a8ee2007-01-18 01:12:56 +000050 JumpTableSpecialLabelPrefix(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000051 GlobalVarAddrPrefix(""),
52 GlobalVarAddrSuffix(""),
53 FunctionAddrPrefix(""),
54 FunctionAddrSuffix(""),
Bill Wendlingd60da492007-09-11 08:27:17 +000055 PersonalityPrefix(""),
56 PersonalitySuffix(""),
Bill Wendlingef4a6612007-09-11 17:20:55 +000057 NeedsIndirectEncoding(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000058 InlineAsmStart("#APP"),
59 InlineAsmEnd("#NO_APP"),
Bill Wendlingeb9a42c2007-01-16 03:42:04 +000060 AssemblerDialect(0),
Dale Johannesen428ac542008-06-03 18:09:06 +000061 StringConstantPrefix(".str"),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000062 ZeroDirective("\t.zero\t"),
63 ZeroDirectiveSuffix(0),
64 AsciiDirective("\t.ascii\t"),
65 AscizDirective("\t.asciz\t"),
66 Data8bitsDirective("\t.byte\t"),
67 Data16bitsDirective("\t.short\t"),
68 Data32bitsDirective("\t.long\t"),
69 Data64bitsDirective("\t.quad\t"),
70 AlignDirective("\t.align\t"),
71 AlignmentIsInBytes(true),
Lauro Ramos Venanciof3c630e2008-02-28 22:14:09 +000072 TextAlignFillValue(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000073 SwitchToSectionDirective("\t.section\t"),
74 TextSectionStartSuffix(""),
75 DataSectionStartSuffix(""),
76 SectionEndDirectiveSuffix(0),
Dan Gohmanaf67ea72007-06-14 15:00:27 +000077 ConstantPoolSection("\t.section .rodata"),
78 JumpTableDataSection("\t.section .rodata"),
Andrew Lenharthbeec30e2006-09-24 19:45:58 +000079 JumpTableDirective(0),
Reid Spencerc50209b2006-10-27 16:14:06 +000080 CStringSection(0),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000081 CStringSection_(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000082 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
83 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
84 FourByteConstantSection(0),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000085 FourByteConstantSection_(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000086 EightByteConstantSection(0),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000087 EightByteConstantSection_(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000088 SixteenByteConstantSection(0),
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000089 SixteenByteConstantSection_(0),
Gordon Henriksen81361d62007-12-23 20:58:16 +000090 GlobalDirective("\t.globl\t"),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000091 SetDirective(0),
92 LCOMMDirective(0),
93 COMMDirective("\t.comm\t"),
94 COMMDirectiveTakesAlignment(true),
95 HasDotTypeDotSizeDirective(true),
Chris Lattnercb05af82006-09-26 03:38:18 +000096 UsedDirective(0),
Evan Cheng8752ce62006-12-01 20:47:11 +000097 WeakRefDirective(0),
Dale Johannesen1d4ce2a2007-11-20 23:24:42 +000098 WeakDefDirective(0),
Chris Lattner9784bc72007-01-14 06:27:21 +000099 HiddenDirective("\t.hidden\t"),
Anton Korobeynikov6f9896f2007-04-29 18:35:00 +0000100 ProtectedDirective("\t.protected\t"),
Anton Korobeynikov79dda2b2007-05-01 22:23:12 +0000101 AbsoluteDebugSectionOffsets(false),
102 AbsoluteEHSectionOffsets(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +0000103 HasLEB128(false),
Dan Gohman72252732007-09-24 21:09:53 +0000104 HasDotLocAndDotFile(false),
Anton Korobeynikov2a07e2f2007-05-05 09:04:50 +0000105 SupportsDebugInformation(false),
Jim Laskey072200c2007-01-29 18:51:14 +0000106 SupportsExceptionHandling(false),
Reid Spencer02b85112006-10-30 22:32:30 +0000107 DwarfRequiresFrameSection(true),
Dale Johannesen9305dcb2007-11-21 00:45:00 +0000108 GlobalEHDirective(0),
Dale Johannesen038129d2008-01-10 02:03:30 +0000109 SupportsWeakOmittedEHFrame(true),
Anton Korobeynikova6199c82007-03-07 02:47:57 +0000110 DwarfSectionOffsetDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +0000111 DwarfAbbrevSection(".debug_abbrev"),
112 DwarfInfoSection(".debug_info"),
113 DwarfLineSection(".debug_line"),
114 DwarfFrameSection(".debug_frame"),
115 DwarfPubNamesSection(".debug_pubnames"),
116 DwarfPubTypesSection(".debug_pubtypes"),
117 DwarfStrSection(".debug_str"),
118 DwarfLocSection(".debug_loc"),
119 DwarfARangesSection(".debug_aranges"),
120 DwarfRangesSection(".debug_ranges"),
Andrew Lenharth3655de62006-11-28 19:52:20 +0000121 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyb82313f2007-02-01 16:31:34 +0000122 DwarfEHFrameSection(".eh_frame"),
Jim Laskeya15be8c2007-02-21 22:43:40 +0000123 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharth3655de62006-11-28 19:52:20 +0000124 AsmTransCBE(0) {
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000125 TextSection_ = getUnnamedSection(TextSection);
126 DataSection_ = getUnnamedSection(DataSection);
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000127}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +0000128
129TargetAsmInfo::~TargetAsmInfo() {
130}
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000131
132/// Measure the specified inline asm to determine an approximation of its
133/// length.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000134/// Comments (which run till the next SeparatorChar or newline) do not
135/// count as an instruction.
136/// Any other non-whitespace text is considered an instruction, with
137/// multiple instructions separated by SeparatorChar or newlines.
138/// Variable-length instructions are not handled here; this function
139/// may be overloaded in the target code to do that.
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000140unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
141 // Count the number of instructions in the asm.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000142 bool atInsnStart = true;
143 unsigned Length = 0;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000144 for (; *Str; ++Str) {
145 if (*Str == '\n' || *Str == SeparatorChar)
Dale Johannesen3bb62832007-04-23 20:00:17 +0000146 atInsnStart = true;
147 if (atInsnStart && !isspace(*Str)) {
148 Length += MaxInstLength;
149 atInsnStart = false;
150 }
151 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
152 atInsnStart = false;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000153 }
154
Dale Johannesen3bb62832007-04-23 20:00:17 +0000155 return Length;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000156}
Anton Korobeynikova6199c82007-03-07 02:47:57 +0000157
Anton Korobeynikov8213f9c2008-02-29 22:09:08 +0000158unsigned TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000159 bool Global) const {
160 return dwarf::DW_EH_PE_absptr;
161}
162
Anton Korobeynikov28a2b542008-06-28 13:45:57 +0000163static bool isSuitableForBSS(const GlobalVariable *GV) {
164 if (!GV->hasInitializer())
165 return true;
166
167 // Leave constant zeros in readonly constant sections, so they can be shared
168 Constant *C = GV->getInitializer();
169 return (C->isNullValue() && !GV->isConstant() && !NoZerosInBSS);
170}
171
172SectionKind::Kind
173TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
174 // Early exit - functions should be always in text sections.
175 if (isa<Function>(GV))
176 return SectionKind::Text;
177
178 const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
179 bool isThreadLocal = GVar->isThreadLocal();
180 assert(GVar && "Invalid global value for section selection");
181
Anton Korobeynikov28a2b542008-06-28 13:45:57 +0000182 if (isSuitableForBSS(GVar)) {
183 // Variable can be easily put to BSS section.
184 return (isThreadLocal ? SectionKind::ThreadBSS : SectionKind::BSS);
185 } else if (GVar->isConstant() && !isThreadLocal) {
186 // Now we know, that varible has initializer and it is constant. We need to
187 // check its initializer to decide, which section to output it into. Also
188 // note, there is no thread-local r/o section.
189 Constant *C = GVar->getInitializer();
190 if (C->ContainsRelocations())
Anton Korobeynikov0e48a0c2008-07-09 13:24:38 +0000191 return SectionKind::ROData;
Anton Korobeynikov28a2b542008-06-28 13:45:57 +0000192 else {
193 const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
194 // Check, if initializer is a null-terminated string
195 if (CVA && CVA->isCString())
Anton Korobeynikov0e48a0c2008-07-09 13:24:38 +0000196 return SectionKind::RODataMergeStr;
Anton Korobeynikov28a2b542008-06-28 13:45:57 +0000197 else
Anton Korobeynikov0e48a0c2008-07-09 13:24:38 +0000198 return SectionKind::RODataMergeConst;
Anton Korobeynikov28a2b542008-06-28 13:45:57 +0000199 }
200 }
201
202 // Variable is not constant or thread-local - emit to generic data section.
203 return (isThreadLocal ? SectionKind::ThreadData : SectionKind::Data);
204}
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000205
206unsigned
207TargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000208 const char* Name) const {
209 unsigned Flags = SectionFlags::None;
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000210
211 // Decode flags from global itself.
212 if (GV) {
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000213 SectionKind::Kind Kind = SectionKindForGlobal(GV);
214 switch (Kind) {
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000215 case SectionKind::Text:
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000216 Flags |= SectionFlags::Code;
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000217 break;
218 case SectionKind::ThreadData:
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000219 case SectionKind::ThreadBSS:
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000220 Flags |= SectionFlags::TLS;
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000221 // FALLS THROUGH
Anton Korobeynikov7d51edf2008-07-09 13:29:44 +0000222 case SectionKind::Data:
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000223 case SectionKind::BSS:
Anton Korobeynikov7d51edf2008-07-09 13:29:44 +0000224 Flags |= SectionFlags::Writeable;
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000225 break;
226 case SectionKind::ROData:
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000227 case SectionKind::RODataMergeStr:
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000228 case SectionKind::RODataMergeConst:
Anton Korobeynikov7d51edf2008-07-09 13:29:44 +0000229 // No additional flags here
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000230 break;
231 default:
232 assert(0 && "Unexpected section kind!");
233 }
234
Anton Korobeynikovc33a7442008-07-09 13:27:59 +0000235 if (GV->isWeakForLinker())
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000236 Flags |= SectionFlags::Linkonce;
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000237 }
238
239 // Add flags from sections, if any.
Anton Korobeynikov2a889172008-07-09 13:25:46 +0000240 if (Name && *Name) {
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000241 Flags |= SectionFlags::Named;
242
243 // Some lame default implementation based on some magic section names.
244 if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
245 strncmp(Name, ".llvm.linkonce.b.", 17) == 0)
246 Flags |= SectionFlags::BSS;
247 else if (strcmp(Name, ".tdata") == 0 ||
248 strncmp(Name, ".tdata.", 7) == 0 ||
249 strncmp(Name, ".gnu.linkonce.td.", 17) == 0 ||
250 strncmp(Name, ".llvm.linkonce.td.", 18) == 0)
251 Flags |= SectionFlags::TLS;
252 else if (strcmp(Name, ".tbss") == 0 ||
253 strncmp(Name, ".tbss.", 6) == 0 ||
254 strncmp(Name, ".gnu.linkonce.tb.", 17) == 0 ||
255 strncmp(Name, ".llvm.linkonce.tb.", 18) == 0)
256 Flags |= SectionFlags::BSS | SectionFlags::TLS;
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000257 }
258
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000259 return Flags;
Anton Korobeynikovbeb9d402008-07-09 13:16:59 +0000260}
Anton Korobeynikov0c602462008-07-09 13:18:02 +0000261
Anton Korobeynikovc0f41db2008-07-09 13:19:08 +0000262std::string
Anton Korobeynikov0c602462008-07-09 13:18:02 +0000263TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000264 const Section* S;
Anton Korobeynikov265c5252008-07-09 13:22:46 +0000265 // Select section name
266 if (GV->hasSection()) {
267 // Honour section already set, if any
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000268 unsigned Flags = SectionFlagsForGlobal(GV,
269 GV->getSection().c_str());
270 S = getNamedSection(GV->getSection().c_str(), Flags);
Anton Korobeynikov265c5252008-07-09 13:22:46 +0000271 } else {
272 // Use default section depending on the 'type' of global
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000273 S = SelectSectionForGlobal(GV);
Anton Korobeynikov265c5252008-07-09 13:22:46 +0000274 }
275
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000276 std::string Name = S->Name;
277
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000278 // If section is named we need to switch into it via special '.section'
279 // directive and also append funky flags. Otherwise - section name is just
280 // some magic assembler directive.
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000281 if (S->isNamed())
282 Name = getSwitchToSectionDirective() + Name + PrintSectionFlags(S->Flags);
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000283
Anton Korobeynikov265c5252008-07-09 13:22:46 +0000284 return Name;
285}
286
287// Lame default implementation. Calculate the section name for global.
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000288const Section*
Anton Korobeynikov265c5252008-07-09 13:22:46 +0000289TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000290 SectionKind::Kind Kind = SectionKindForGlobal(GV);
Anton Korobeynikov0c602462008-07-09 13:18:02 +0000291
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000292 if (GV->isWeakForLinker()) {
293 std::string Name = UniqueSectionForGlobal(GV, Kind);
294 unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
295 return getNamedSection(Name.c_str(), Flags);
296 } else {
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000297 if (Kind == SectionKind::Text)
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000298 return getTextSection_();
299 else if (Kind == SectionKind::BSS && getBSSSection_())
300 return getBSSSection_();
301 else if (getReadOnlySection_() &&
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000302 (Kind == SectionKind::ROData ||
303 Kind == SectionKind::RODataMergeConst ||
304 Kind == SectionKind::RODataMergeStr))
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000305 return getReadOnlySection_();
Anton Korobeynikov265c5252008-07-09 13:22:46 +0000306 }
Anton Korobeynikov0c602462008-07-09 13:18:02 +0000307
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000308 return getDataSection_();
Anton Korobeynikov0c602462008-07-09 13:18:02 +0000309}
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000310
311std::string
312TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000313 SectionKind::Kind Kind) const {
314 switch (Kind) {
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000315 case SectionKind::Text:
Anton Korobeynikov52486702008-07-09 13:24:55 +0000316 return ".gnu.linkonce.t." + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000317 case SectionKind::Data:
Anton Korobeynikov52486702008-07-09 13:24:55 +0000318 return ".gnu.linkonce.d." + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000319 case SectionKind::BSS:
Anton Korobeynikov52486702008-07-09 13:24:55 +0000320 return ".gnu.linkonce.b." + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000321 case SectionKind::ROData:
322 case SectionKind::RODataMergeConst:
323 case SectionKind::RODataMergeStr:
Anton Korobeynikov52486702008-07-09 13:24:55 +0000324 return ".gnu.linkonce.r." + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000325 case SectionKind::ThreadData:
Anton Korobeynikov52486702008-07-09 13:24:55 +0000326 return ".gnu.linkonce.td." + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000327 case SectionKind::ThreadBSS:
Anton Korobeynikov52486702008-07-09 13:24:55 +0000328 return ".gnu.linkonce.tb." + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000329 default:
330 assert(0 && "Unknown section kind");
331 }
332}
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000333
334const Section*
335TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags) const {
336 Section& S = Sections[Name];
337
338 // This is newly-created section, set it up properly.
339 if (S.Flags == SectionFlags::Invalid) {
340 S.Flags = Flags | SectionFlags::Named;
341 S.Name = Name;
342 }
343
344 return &S;
345}
346
347const Section*
348TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags) const {
349 Section& S = Sections[Directive];
350
351 // This is newly-created section, set it up properly.
352 if (S.Flags == SectionFlags::Invalid) {
353 S.Flags = Flags & ~SectionFlags::Named;
354 S.Name = Directive;
355 }
356
357 return &S;
358}