2006-09-06 19:21:41 +00:00
|
|
|
//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
|
2006-09-06 18:35:33 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-09-06 18:35:33 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines target asm properties related what form asm statements
|
|
|
|
// should take.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-06-28 13:45:57 +00:00
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/GlobalVariable.h"
|
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/Type.h"
|
2006-09-06 18:35:33 +00:00
|
|
|
#include "llvm/Target/TargetAsmInfo.h"
|
2008-06-28 13:45:57 +00:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2008-02-27 23:33:50 +00:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
2007-04-23 20:00:17 +00:00
|
|
|
#include <cctype>
|
|
|
|
#include <cstring>
|
2006-09-06 18:35:33 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
TargetAsmInfo::TargetAsmInfo() :
|
2007-05-03 18:46:30 +00:00
|
|
|
TextSection("\t.text"),
|
2008-07-09 13:28:49 +00:00
|
|
|
TextSection_(0),
|
2007-05-03 18:46:30 +00:00
|
|
|
DataSection("\t.data"),
|
2008-07-09 13:28:49 +00:00
|
|
|
DataSection_(0),
|
2007-05-03 18:46:30 +00:00
|
|
|
BSSSection("\t.bss"),
|
2008-07-09 13:28:49 +00:00
|
|
|
BSSSection_(0),
|
|
|
|
ReadOnlySection(0),
|
|
|
|
ReadOnlySection_(0),
|
2008-07-22 15:26:53 +00:00
|
|
|
SmallDataSection(0),
|
|
|
|
SmallBSSSection(0),
|
|
|
|
SmallRODataSection(0),
|
2007-04-20 21:38:10 +00:00
|
|
|
TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
|
2008-07-09 13:28:49 +00:00
|
|
|
TLSDataSection_(0),
|
2007-04-20 21:38:10 +00:00
|
|
|
TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
|
2008-07-09 13:28:49 +00:00
|
|
|
TLSBSSSection_(0),
|
2007-01-17 17:42:42 +00:00
|
|
|
ZeroFillDirective(0),
|
2008-05-05 00:28:39 +00:00
|
|
|
NonexecutableStackDirective(0),
|
2006-09-06 18:35:33 +00:00
|
|
|
NeedsSet(false),
|
2006-10-13 17:50:07 +00:00
|
|
|
MaxInstLength(4),
|
2007-02-01 16:31:34 +00:00
|
|
|
PCSymbol("$"),
|
2006-10-13 17:50:07 +00:00
|
|
|
SeparatorChar(';'),
|
2006-09-06 18:35:33 +00:00
|
|
|
CommentString("#"),
|
|
|
|
GlobalPrefix(""),
|
|
|
|
PrivateGlobalPrefix("."),
|
2007-01-18 01:12:56 +00:00
|
|
|
JumpTableSpecialLabelPrefix(0),
|
2006-09-06 18:35:33 +00:00
|
|
|
GlobalVarAddrPrefix(""),
|
|
|
|
GlobalVarAddrSuffix(""),
|
|
|
|
FunctionAddrPrefix(""),
|
|
|
|
FunctionAddrSuffix(""),
|
2007-09-11 08:27:17 +00:00
|
|
|
PersonalityPrefix(""),
|
|
|
|
PersonalitySuffix(""),
|
2007-09-11 17:20:55 +00:00
|
|
|
NeedsIndirectEncoding(false),
|
2006-09-06 18:35:33 +00:00
|
|
|
InlineAsmStart("#APP"),
|
|
|
|
InlineAsmEnd("#NO_APP"),
|
2007-01-16 03:42:04 +00:00
|
|
|
AssemblerDialect(0),
|
2008-06-03 18:09:06 +00:00
|
|
|
StringConstantPrefix(".str"),
|
2006-09-06 18:35:33 +00:00
|
|
|
ZeroDirective("\t.zero\t"),
|
|
|
|
ZeroDirectiveSuffix(0),
|
|
|
|
AsciiDirective("\t.ascii\t"),
|
|
|
|
AscizDirective("\t.asciz\t"),
|
|
|
|
Data8bitsDirective("\t.byte\t"),
|
|
|
|
Data16bitsDirective("\t.short\t"),
|
|
|
|
Data32bitsDirective("\t.long\t"),
|
|
|
|
Data64bitsDirective("\t.quad\t"),
|
|
|
|
AlignDirective("\t.align\t"),
|
|
|
|
AlignmentIsInBytes(true),
|
2008-02-28 22:14:09 +00:00
|
|
|
TextAlignFillValue(0),
|
2006-09-06 18:35:33 +00:00
|
|
|
SwitchToSectionDirective("\t.section\t"),
|
|
|
|
TextSectionStartSuffix(""),
|
|
|
|
DataSectionStartSuffix(""),
|
|
|
|
SectionEndDirectiveSuffix(0),
|
2007-06-14 15:00:27 +00:00
|
|
|
ConstantPoolSection("\t.section .rodata"),
|
|
|
|
JumpTableDataSection("\t.section .rodata"),
|
2006-09-24 19:45:58 +00:00
|
|
|
JumpTableDirective(0),
|
2006-10-27 16:14:06 +00:00
|
|
|
CStringSection(0),
|
2008-07-09 13:28:49 +00:00
|
|
|
CStringSection_(0),
|
2006-09-06 18:35:33 +00:00
|
|
|
StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
|
|
|
|
StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
|
|
|
|
FourByteConstantSection(0),
|
2008-07-09 13:28:49 +00:00
|
|
|
FourByteConstantSection_(0),
|
2006-09-06 18:35:33 +00:00
|
|
|
EightByteConstantSection(0),
|
2008-07-09 13:28:49 +00:00
|
|
|
EightByteConstantSection_(0),
|
2006-09-06 18:35:33 +00:00
|
|
|
SixteenByteConstantSection(0),
|
2008-07-09 13:28:49 +00:00
|
|
|
SixteenByteConstantSection_(0),
|
2007-12-23 20:58:16 +00:00
|
|
|
GlobalDirective("\t.globl\t"),
|
2006-09-06 18:35:33 +00:00
|
|
|
SetDirective(0),
|
|
|
|
LCOMMDirective(0),
|
|
|
|
COMMDirective("\t.comm\t"),
|
|
|
|
COMMDirectiveTakesAlignment(true),
|
|
|
|
HasDotTypeDotSizeDirective(true),
|
2006-09-26 03:38:18 +00:00
|
|
|
UsedDirective(0),
|
2006-12-01 20:47:11 +00:00
|
|
|
WeakRefDirective(0),
|
2007-11-20 23:24:42 +00:00
|
|
|
WeakDefDirective(0),
|
2007-01-14 06:27:21 +00:00
|
|
|
HiddenDirective("\t.hidden\t"),
|
2007-04-29 18:35:00 +00:00
|
|
|
ProtectedDirective("\t.protected\t"),
|
2007-05-01 22:23:12 +00:00
|
|
|
AbsoluteDebugSectionOffsets(false),
|
|
|
|
AbsoluteEHSectionOffsets(false),
|
2006-09-06 18:35:33 +00:00
|
|
|
HasLEB128(false),
|
2007-09-24 21:09:53 +00:00
|
|
|
HasDotLocAndDotFile(false),
|
2007-05-05 09:04:50 +00:00
|
|
|
SupportsDebugInformation(false),
|
2007-01-29 18:51:14 +00:00
|
|
|
SupportsExceptionHandling(false),
|
2006-10-30 22:32:30 +00:00
|
|
|
DwarfRequiresFrameSection(true),
|
2007-11-21 00:45:00 +00:00
|
|
|
GlobalEHDirective(0),
|
2008-01-10 02:03:30 +00:00
|
|
|
SupportsWeakOmittedEHFrame(true),
|
2007-03-07 02:47:57 +00:00
|
|
|
DwarfSectionOffsetDirective(0),
|
2006-09-06 18:35:33 +00:00
|
|
|
DwarfAbbrevSection(".debug_abbrev"),
|
|
|
|
DwarfInfoSection(".debug_info"),
|
|
|
|
DwarfLineSection(".debug_line"),
|
|
|
|
DwarfFrameSection(".debug_frame"),
|
|
|
|
DwarfPubNamesSection(".debug_pubnames"),
|
|
|
|
DwarfPubTypesSection(".debug_pubtypes"),
|
|
|
|
DwarfStrSection(".debug_str"),
|
|
|
|
DwarfLocSection(".debug_loc"),
|
|
|
|
DwarfARangesSection(".debug_aranges"),
|
|
|
|
DwarfRangesSection(".debug_ranges"),
|
2006-11-28 19:52:20 +00:00
|
|
|
DwarfMacInfoSection(".debug_macinfo"),
|
2007-02-01 16:31:34 +00:00
|
|
|
DwarfEHFrameSection(".eh_frame"),
|
2007-02-21 22:43:40 +00:00
|
|
|
DwarfExceptionSection(".gcc_except_table"),
|
2006-11-28 19:52:20 +00:00
|
|
|
AsmTransCBE(0) {
|
2008-07-09 13:28:49 +00:00
|
|
|
TextSection_ = getUnnamedSection(TextSection);
|
|
|
|
DataSection_ = getUnnamedSection(DataSection);
|
2006-10-13 17:50:07 +00:00
|
|
|
}
|
2006-10-05 00:35:16 +00:00
|
|
|
|
|
|
|
TargetAsmInfo::~TargetAsmInfo() {
|
|
|
|
}
|
2006-10-13 17:50:07 +00:00
|
|
|
|
|
|
|
/// Measure the specified inline asm to determine an approximation of its
|
|
|
|
/// length.
|
2007-04-23 20:00:17 +00:00
|
|
|
/// Comments (which run till the next SeparatorChar or newline) do not
|
|
|
|
/// count as an instruction.
|
|
|
|
/// Any other non-whitespace text is considered an instruction, with
|
|
|
|
/// multiple instructions separated by SeparatorChar or newlines.
|
|
|
|
/// Variable-length instructions are not handled here; this function
|
|
|
|
/// may be overloaded in the target code to do that.
|
2006-10-13 17:50:07 +00:00
|
|
|
unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
|
|
|
|
// Count the number of instructions in the asm.
|
2007-04-23 20:00:17 +00:00
|
|
|
bool atInsnStart = true;
|
|
|
|
unsigned Length = 0;
|
2006-10-13 17:50:07 +00:00
|
|
|
for (; *Str; ++Str) {
|
|
|
|
if (*Str == '\n' || *Str == SeparatorChar)
|
2007-04-23 20:00:17 +00:00
|
|
|
atInsnStart = true;
|
|
|
|
if (atInsnStart && !isspace(*Str)) {
|
|
|
|
Length += MaxInstLength;
|
|
|
|
atInsnStart = false;
|
|
|
|
}
|
|
|
|
if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
|
|
|
|
atInsnStart = false;
|
2006-10-13 17:50:07 +00:00
|
|
|
}
|
|
|
|
|
2007-04-23 20:00:17 +00:00
|
|
|
return Length;
|
2006-10-13 17:50:07 +00:00
|
|
|
}
|
2007-03-07 02:47:57 +00:00
|
|
|
|
2008-02-29 22:09:08 +00:00
|
|
|
unsigned TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
2008-02-27 23:33:50 +00:00
|
|
|
bool Global) const {
|
|
|
|
return dwarf::DW_EH_PE_absptr;
|
|
|
|
}
|
|
|
|
|
2008-06-28 13:45:57 +00:00
|
|
|
static bool isSuitableForBSS(const GlobalVariable *GV) {
|
|
|
|
if (!GV->hasInitializer())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Leave constant zeros in readonly constant sections, so they can be shared
|
|
|
|
Constant *C = GV->getInitializer();
|
|
|
|
return (C->isNullValue() && !GV->isConstant() && !NoZerosInBSS);
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionKind::Kind
|
|
|
|
TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
|
|
|
|
// Early exit - functions should be always in text sections.
|
|
|
|
if (isa<Function>(GV))
|
|
|
|
return SectionKind::Text;
|
|
|
|
|
|
|
|
const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
|
|
|
|
bool isThreadLocal = GVar->isThreadLocal();
|
|
|
|
assert(GVar && "Invalid global value for section selection");
|
|
|
|
|
|
|
|
if (isSuitableForBSS(GVar)) {
|
|
|
|
// Variable can be easily put to BSS section.
|
|
|
|
return (isThreadLocal ? SectionKind::ThreadBSS : SectionKind::BSS);
|
|
|
|
} else if (GVar->isConstant() && !isThreadLocal) {
|
|
|
|
// Now we know, that varible has initializer and it is constant. We need to
|
|
|
|
// check its initializer to decide, which section to output it into. Also
|
|
|
|
// note, there is no thread-local r/o section.
|
|
|
|
Constant *C = GVar->getInitializer();
|
|
|
|
if (C->ContainsRelocations())
|
2008-07-09 13:24:38 +00:00
|
|
|
return SectionKind::ROData;
|
2008-06-28 13:45:57 +00:00
|
|
|
else {
|
|
|
|
const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
|
|
|
|
// Check, if initializer is a null-terminated string
|
|
|
|
if (CVA && CVA->isCString())
|
2008-07-09 13:24:38 +00:00
|
|
|
return SectionKind::RODataMergeStr;
|
2008-06-28 13:45:57 +00:00
|
|
|
else
|
2008-07-09 13:24:38 +00:00
|
|
|
return SectionKind::RODataMergeConst;
|
2008-06-28 13:45:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Variable is not constant or thread-local - emit to generic data section.
|
|
|
|
return (isThreadLocal ? SectionKind::ThreadData : SectionKind::Data);
|
|
|
|
}
|
2008-07-09 13:16:59 +00:00
|
|
|
|
|
|
|
unsigned
|
|
|
|
TargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
|
2008-07-09 13:25:26 +00:00
|
|
|
const char* Name) const {
|
|
|
|
unsigned Flags = SectionFlags::None;
|
2008-07-09 13:16:59 +00:00
|
|
|
|
|
|
|
// Decode flags from global itself.
|
|
|
|
if (GV) {
|
2008-07-09 13:25:26 +00:00
|
|
|
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
|
|
|
switch (Kind) {
|
2008-07-09 13:16:59 +00:00
|
|
|
case SectionKind::Text:
|
2008-07-09 13:25:26 +00:00
|
|
|
Flags |= SectionFlags::Code;
|
2008-07-09 13:16:59 +00:00
|
|
|
break;
|
|
|
|
case SectionKind::ThreadData:
|
|
|
|
case SectionKind::ThreadBSS:
|
2008-07-09 13:25:26 +00:00
|
|
|
Flags |= SectionFlags::TLS;
|
2008-07-09 13:16:59 +00:00
|
|
|
// FALLS THROUGH
|
2008-07-09 13:29:44 +00:00
|
|
|
case SectionKind::Data:
|
2008-07-09 13:16:59 +00:00
|
|
|
case SectionKind::BSS:
|
2008-07-09 13:29:44 +00:00
|
|
|
Flags |= SectionFlags::Writeable;
|
2008-07-09 13:16:59 +00:00
|
|
|
break;
|
|
|
|
case SectionKind::ROData:
|
|
|
|
case SectionKind::RODataMergeStr:
|
|
|
|
case SectionKind::RODataMergeConst:
|
2008-07-09 13:29:44 +00:00
|
|
|
// No additional flags here
|
2008-07-09 13:16:59 +00:00
|
|
|
break;
|
2008-07-22 17:09:59 +00:00
|
|
|
case SectionKind::SmallData:
|
|
|
|
case SectionKind::SmallBSS:
|
|
|
|
Flags |= SectionFlags::Writeable;
|
|
|
|
// FALLS THROUGH
|
|
|
|
case SectionKind::SmallROData:
|
|
|
|
Flags |= SectionFlags::Small;
|
|
|
|
break;
|
2008-07-09 13:16:59 +00:00
|
|
|
default:
|
|
|
|
assert(0 && "Unexpected section kind!");
|
|
|
|
}
|
|
|
|
|
2008-07-09 13:27:59 +00:00
|
|
|
if (GV->isWeakForLinker())
|
2008-07-09 13:25:26 +00:00
|
|
|
Flags |= SectionFlags::Linkonce;
|
2008-07-09 13:16:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add flags from sections, if any.
|
2008-07-09 13:25:46 +00:00
|
|
|
if (Name && *Name) {
|
2008-07-09 13:25:26 +00:00
|
|
|
Flags |= SectionFlags::Named;
|
|
|
|
|
|
|
|
// Some lame default implementation based on some magic section names.
|
|
|
|
if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
|
2008-07-22 17:09:59 +00:00
|
|
|
strncmp(Name, ".llvm.linkonce.b.", 17) == 0 ||
|
|
|
|
strncmp(Name, ".gnu.linkonce.sb.", 17) == 0 ||
|
|
|
|
strncmp(Name, ".llvm.linkonce.sb.", 18) == 0)
|
2008-07-09 13:25:26 +00:00
|
|
|
Flags |= SectionFlags::BSS;
|
|
|
|
else if (strcmp(Name, ".tdata") == 0 ||
|
|
|
|
strncmp(Name, ".tdata.", 7) == 0 ||
|
|
|
|
strncmp(Name, ".gnu.linkonce.td.", 17) == 0 ||
|
|
|
|
strncmp(Name, ".llvm.linkonce.td.", 18) == 0)
|
|
|
|
Flags |= SectionFlags::TLS;
|
|
|
|
else if (strcmp(Name, ".tbss") == 0 ||
|
|
|
|
strncmp(Name, ".tbss.", 6) == 0 ||
|
|
|
|
strncmp(Name, ".gnu.linkonce.tb.", 17) == 0 ||
|
|
|
|
strncmp(Name, ".llvm.linkonce.tb.", 18) == 0)
|
|
|
|
Flags |= SectionFlags::BSS | SectionFlags::TLS;
|
2008-07-09 13:16:59 +00:00
|
|
|
}
|
|
|
|
|
2008-07-09 13:25:26 +00:00
|
|
|
return Flags;
|
2008-07-09 13:16:59 +00:00
|
|
|
}
|
2008-07-09 13:18:02 +00:00
|
|
|
|
2008-07-09 13:19:08 +00:00
|
|
|
std::string
|
2008-08-08 17:56:50 +00:00
|
|
|
TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
|
2008-07-09 13:28:49 +00:00
|
|
|
const Section* S;
|
2008-07-09 13:22:46 +00:00
|
|
|
// Select section name
|
|
|
|
if (GV->hasSection()) {
|
|
|
|
// Honour section already set, if any
|
2008-07-09 13:28:49 +00:00
|
|
|
unsigned Flags = SectionFlagsForGlobal(GV,
|
|
|
|
GV->getSection().c_str());
|
|
|
|
S = getNamedSection(GV->getSection().c_str(), Flags);
|
2008-07-09 13:22:46 +00:00
|
|
|
} else {
|
|
|
|
// Use default section depending on the 'type' of global
|
2008-08-08 17:56:50 +00:00
|
|
|
S = SelectSectionForGlobal(GV);
|
2008-07-09 13:22:46 +00:00
|
|
|
}
|
|
|
|
|
2008-07-15 18:37:51 +00:00
|
|
|
if (!S->isNamed())
|
|
|
|
return S->Name;
|
2008-07-09 13:28:49 +00:00
|
|
|
|
2008-07-09 13:25:26 +00:00
|
|
|
// If section is named we need to switch into it via special '.section'
|
|
|
|
// directive and also append funky flags. Otherwise - section name is just
|
|
|
|
// some magic assembler directive.
|
2008-08-16 12:57:07 +00:00
|
|
|
return getSwitchToSectionDirective() + S->Name + getSectionFlags(S->Flags);
|
2008-07-09 13:22:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lame default implementation. Calculate the section name for global.
|
2008-08-08 17:56:50 +00:00
|
|
|
const Section*
|
|
|
|
TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
2008-07-09 13:25:26 +00:00
|
|
|
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
2008-07-09 13:18:02 +00:00
|
|
|
|
2008-07-09 13:28:49 +00:00
|
|
|
if (GV->isWeakForLinker()) {
|
|
|
|
std::string Name = UniqueSectionForGlobal(GV, Kind);
|
|
|
|
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
|
|
|
|
return getNamedSection(Name.c_str(), Flags);
|
|
|
|
} else {
|
2008-07-09 13:25:26 +00:00
|
|
|
if (Kind == SectionKind::Text)
|
2008-07-09 13:28:49 +00:00
|
|
|
return getTextSection_();
|
2008-08-07 09:51:54 +00:00
|
|
|
else if (isBSS(Kind) && getBSSSection_())
|
2008-07-09 13:28:49 +00:00
|
|
|
return getBSSSection_();
|
2008-08-07 09:51:54 +00:00
|
|
|
else if (getReadOnlySection_() && SectionKind::isReadOnly(Kind))
|
2008-07-09 13:28:49 +00:00
|
|
|
return getReadOnlySection_();
|
2008-07-09 13:22:46 +00:00
|
|
|
}
|
2008-07-09 13:18:02 +00:00
|
|
|
|
2008-07-09 13:28:49 +00:00
|
|
|
return getDataSection_();
|
2008-07-09 13:18:02 +00:00
|
|
|
}
|
2008-07-09 13:19:38 +00:00
|
|
|
|
2008-08-07 09:50:34 +00:00
|
|
|
// Lame default implementation. Calculate the section name for machine const.
|
|
|
|
const Section*
|
|
|
|
TargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
|
|
|
|
// FIXME: Support data.rel stuff someday
|
|
|
|
return getDataSection_();
|
|
|
|
}
|
|
|
|
|
2008-07-09 13:19:38 +00:00
|
|
|
std::string
|
|
|
|
TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
|
2008-07-09 13:25:26 +00:00
|
|
|
SectionKind::Kind Kind) const {
|
|
|
|
switch (Kind) {
|
2008-07-09 13:19:38 +00:00
|
|
|
case SectionKind::Text:
|
2008-07-09 13:24:55 +00:00
|
|
|
return ".gnu.linkonce.t." + GV->getName();
|
2008-07-09 13:19:38 +00:00
|
|
|
case SectionKind::Data:
|
2008-07-09 13:24:55 +00:00
|
|
|
return ".gnu.linkonce.d." + GV->getName();
|
2008-07-22 17:09:59 +00:00
|
|
|
case SectionKind::SmallData:
|
|
|
|
return ".gnu.linkonce.s." + GV->getName();
|
2008-07-09 13:19:38 +00:00
|
|
|
case SectionKind::BSS:
|
2008-07-09 13:24:55 +00:00
|
|
|
return ".gnu.linkonce.b." + GV->getName();
|
2008-07-22 17:09:59 +00:00
|
|
|
case SectionKind::SmallBSS:
|
|
|
|
return ".gnu.linkonce.sb." + GV->getName();
|
2008-07-09 13:19:38 +00:00
|
|
|
case SectionKind::ROData:
|
|
|
|
case SectionKind::RODataMergeConst:
|
|
|
|
case SectionKind::RODataMergeStr:
|
2008-07-09 13:24:55 +00:00
|
|
|
return ".gnu.linkonce.r." + GV->getName();
|
2008-07-22 17:09:59 +00:00
|
|
|
case SectionKind::SmallROData:
|
|
|
|
return ".gnu.linkonce.s2." + GV->getName();
|
2008-07-09 13:19:38 +00:00
|
|
|
case SectionKind::ThreadData:
|
2008-07-09 13:24:55 +00:00
|
|
|
return ".gnu.linkonce.td." + GV->getName();
|
2008-07-09 13:19:38 +00:00
|
|
|
case SectionKind::ThreadBSS:
|
2008-07-09 13:24:55 +00:00
|
|
|
return ".gnu.linkonce.tb." + GV->getName();
|
2008-07-09 13:19:38 +00:00
|
|
|
default:
|
|
|
|
assert(0 && "Unknown section kind");
|
|
|
|
}
|
|
|
|
}
|
2008-07-09 13:28:49 +00:00
|
|
|
|
|
|
|
const Section*
|
|
|
|
TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags) const {
|
|
|
|
Section& S = Sections[Name];
|
|
|
|
|
|
|
|
// This is newly-created section, set it up properly.
|
|
|
|
if (S.Flags == SectionFlags::Invalid) {
|
|
|
|
S.Flags = Flags | SectionFlags::Named;
|
|
|
|
S.Name = Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &S;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Section*
|
|
|
|
TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags) const {
|
|
|
|
Section& S = Sections[Directive];
|
|
|
|
|
|
|
|
// This is newly-created section, set it up properly.
|
|
|
|
if (S.Flags == SectionFlags::Invalid) {
|
|
|
|
S.Flags = Flags & ~SectionFlags::Named;
|
|
|
|
S.Name = Directive;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &S;
|
|
|
|
}
|
2008-08-16 12:57:07 +00:00
|
|
|
|
|
|
|
const std::string&
|
|
|
|
TargetAsmInfo::getSectionFlags(unsigned Flags) const {
|
|
|
|
SectionFlags::FlagsStringsMapType::iterator I = FlagsStrings.find(Flags);
|
|
|
|
|
|
|
|
// We didn't print these flags yet, print and save them to map. This reduces
|
|
|
|
// amount of heap trashing due to std::string construction / concatenation.
|
|
|
|
if (I == FlagsStrings.end())
|
|
|
|
I = FlagsStrings.insert(std::make_pair(Flags,
|
|
|
|
printSectionFlags(Flags))).first;
|
|
|
|
|
|
|
|
return I->second;
|
|
|
|
}
|