forked from OSchip/llvm-project
Eliminate SectionFlags, just embed a SectionKind into Section
instead and drive things based off of that. llvm-svn: 77184
This commit is contained in:
parent
4ead0b9e1c
commit
149465ea06
|
@ -31,18 +31,15 @@ namespace llvm {
|
||||||
virtual const Section *
|
virtual const Section *
|
||||||
getSectionForMergeableConstant(SectionKind Kind) const;
|
getSectionForMergeableConstant(SectionKind Kind) const;
|
||||||
|
|
||||||
/// getFlagsForNamedSection - If this target wants to be able to infer
|
virtual SectionKind::Kind getKindForNamedSection(const char *Section,
|
||||||
/// section flags based on the name of the section specified for a global
|
SectionKind::Kind K) const;
|
||||||
/// variable, it can implement this. This is used on ELF systems so that
|
void getSectionFlagsAsString(SectionKind Kind,
|
||||||
/// ".tbss" gets the TLS bit set etc.
|
SmallVectorImpl<char> &Str) const;
|
||||||
virtual unsigned getFlagsForNamedSection(const char *Section) const;
|
|
||||||
|
|
||||||
const char *getSectionPrefixForUniqueGlobal(SectionKind Kind) const;
|
const char *getSectionPrefixForUniqueGlobal(SectionKind Kind) const;
|
||||||
|
|
||||||
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
|
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
|
||||||
SectionKind Kind) const;
|
SectionKind Kind) const;
|
||||||
virtual void getSectionFlags(unsigned Flags,
|
|
||||||
SmallVectorImpl<char> &Str) const;
|
|
||||||
|
|
||||||
const Section *DataRelSection;
|
const Section *DataRelSection;
|
||||||
const Section *DataRelLocalSection;
|
const Section *DataRelLocalSection;
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
template <typename T> class SmallVectorImpl;
|
template <typename T> class SmallVectorImpl;
|
||||||
|
class TargetMachine;
|
||||||
|
class GlobalValue;
|
||||||
|
class Mangler;
|
||||||
|
|
||||||
// DWARF encoding query type
|
// DWARF encoding query type
|
||||||
namespace DwarfEncoding {
|
namespace DwarfEncoding {
|
||||||
|
@ -39,8 +42,12 @@ namespace llvm {
|
||||||
///
|
///
|
||||||
/// The comments below describe these as if they were an inheritance hierarchy
|
/// The comments below describe these as if they were an inheritance hierarchy
|
||||||
/// in order to explain the predicates below.
|
/// in order to explain the predicates below.
|
||||||
struct SectionKind {
|
class SectionKind {
|
||||||
|
public:
|
||||||
enum Kind {
|
enum Kind {
|
||||||
|
/// Metadata - Debug info sections or other metadata.
|
||||||
|
Metadata,
|
||||||
|
|
||||||
/// Text - Text section, used for functions and other executable code.
|
/// Text - Text section, used for functions and other executable code.
|
||||||
Text,
|
Text,
|
||||||
|
|
||||||
|
@ -140,6 +147,8 @@ namespace llvm {
|
||||||
bool isWeak() const { return Weak; }
|
bool isWeak() const { return Weak; }
|
||||||
bool hasExplicitSection() const { return ExplicitSection; }
|
bool hasExplicitSection() const { return ExplicitSection; }
|
||||||
|
|
||||||
|
|
||||||
|
bool isMetadata() const { return K == Metadata; }
|
||||||
bool isText() const { return K == Text; }
|
bool isText() const { return K == Text; }
|
||||||
|
|
||||||
bool isReadOnly() const {
|
bool isReadOnly() const {
|
||||||
|
@ -191,7 +200,7 @@ namespace llvm {
|
||||||
return K == ReadOnlyWithRelLocal;
|
return K == ReadOnlyWithRelLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SectionKind get(Kind K, bool isWeak,
|
static SectionKind get(Kind K, bool isWeak = false,
|
||||||
bool hasExplicitSection = false) {
|
bool hasExplicitSection = false) {
|
||||||
SectionKind Res;
|
SectionKind Res;
|
||||||
Res.K = K;
|
Res.K = K;
|
||||||
|
@ -201,65 +210,18 @@ namespace llvm {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace SectionFlags {
|
|
||||||
const unsigned Invalid = -1U;
|
|
||||||
const unsigned None = 0;
|
|
||||||
const unsigned Code = 1 << 0; ///< Section contains code
|
|
||||||
const unsigned Writable = 1 << 1; ///< Section is writeable
|
|
||||||
const unsigned BSS = 1 << 2; ///< Section contains only zeroes
|
|
||||||
const unsigned Mergeable = 1 << 3; ///< Section contains mergeable data
|
|
||||||
const unsigned Strings = 1 << 4; ///< Section contains C-type strings
|
|
||||||
const unsigned TLS = 1 << 5; ///< Section contains thread-local data
|
|
||||||
const unsigned Debug = 1 << 6; ///< Section contains debug data
|
|
||||||
const unsigned Linkonce = 1 << 7; ///< Section is linkonce
|
|
||||||
const unsigned TypeFlags = 0xFF;
|
|
||||||
// Some gap for future flags
|
|
||||||
|
|
||||||
/// Named - True if this section should be printed with ".section <name>",
|
|
||||||
/// false if the section name is something like ".const".
|
|
||||||
const unsigned Named = 1 << 23; ///< Section is named
|
|
||||||
const unsigned EntitySize = 0xFF << 24; ///< Entity size for mergeable stuff
|
|
||||||
|
|
||||||
static inline unsigned getEntitySize(unsigned Flags) {
|
|
||||||
return (Flags >> 24) & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Why does this return a value?
|
|
||||||
static inline unsigned setEntitySize(unsigned Flags, unsigned Size) {
|
|
||||||
return (Flags & ~EntitySize) | ((Size & 0xFF) << 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct KeyInfo {
|
|
||||||
static inline unsigned getEmptyKey() { return Invalid; }
|
|
||||||
static inline unsigned getTombstoneKey() { return Invalid - 1; }
|
|
||||||
static unsigned getHashValue(const unsigned &Key) { return Key; }
|
|
||||||
static bool isEqual(unsigned LHS, unsigned RHS) { return LHS == RHS; }
|
|
||||||
static bool isPod() { return true; }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class TargetMachine;
|
|
||||||
class CallInst;
|
|
||||||
class GlobalValue;
|
|
||||||
class Type;
|
|
||||||
class Mangler;
|
|
||||||
|
|
||||||
class Section {
|
class Section {
|
||||||
friend class TargetAsmInfo;
|
friend class TargetAsmInfo;
|
||||||
friend class StringMapEntry<Section>;
|
friend class StringMapEntry<Section>;
|
||||||
friend class StringMap<Section>;
|
friend class StringMap<Section>;
|
||||||
|
|
||||||
std::string Name;
|
std::string Name;
|
||||||
unsigned Flags;
|
SectionKind Kind;
|
||||||
explicit Section(unsigned F = SectionFlags::Invalid) : Flags(F) { }
|
explicit Section() { }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned getEntitySize() const { return (Flags >> 24) & 0xFF; }
|
|
||||||
|
|
||||||
const std::string &getName() const { return Name; }
|
const std::string &getName() const { return Name; }
|
||||||
unsigned getFlags() const { return Flags; }
|
SectionKind getKind() const { return Kind; }
|
||||||
|
|
||||||
bool hasFlag(unsigned F) const { return (Flags & F) != 0; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// TargetAsmInfo - This class is intended to be used as a base class for asm
|
/// TargetAsmInfo - This class is intended to be used as a base class for asm
|
||||||
|
@ -678,9 +640,9 @@ namespace llvm {
|
||||||
virtual ~TargetAsmInfo();
|
virtual ~TargetAsmInfo();
|
||||||
|
|
||||||
const Section* getNamedSection(const char *Name,
|
const Section* getNamedSection(const char *Name,
|
||||||
unsigned Flags = SectionFlags::None) const;
|
SectionKind::Kind K) const;
|
||||||
const Section* getUnnamedSection(const char *Directive,
|
const Section* getUnnamedSection(const char *Directive,
|
||||||
unsigned Flags = SectionFlags::None) const;
|
SectionKind::Kind K) const;
|
||||||
|
|
||||||
/// Measure the specified inline asm to determine an approximation of its
|
/// Measure the specified inline asm to determine an approximation of its
|
||||||
/// length.
|
/// length.
|
||||||
|
@ -717,12 +679,13 @@ namespace llvm {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getFlagsForNamedSection - If this target wants to be able to infer
|
/// getKindForNamedSection - If this target wants to be able to override
|
||||||
/// section flags based on the name of the section specified for a global
|
/// section flags based on the name of the section specified for a global
|
||||||
/// variable, it can implement this. This is used on ELF systems so that
|
/// variable, it can implement this. This is used on ELF systems so that
|
||||||
/// ".tbss" gets the TLS bit set etc.
|
/// ".tbss" gets the TLS bit set etc.
|
||||||
virtual unsigned getFlagsForNamedSection(const char *Section) const {
|
virtual SectionKind::Kind getKindForNamedSection(const char *Section,
|
||||||
return 0;
|
SectionKind::Kind K) const{
|
||||||
|
return K;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SectionForGlobal - This method computes the appropriate section to emit
|
/// SectionForGlobal - This method computes the appropriate section to emit
|
||||||
|
@ -741,10 +704,11 @@ namespace llvm {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Turn the specified flags into a string that can be printed to the
|
/// getSectionFlagsAsString - Turn the flags in the specified SectionKind
|
||||||
/// assembly file.
|
/// into a string that can be printed to the assembly file after the
|
||||||
virtual void getSectionFlags(unsigned Flags,
|
/// ".section foo" part of a section directive.
|
||||||
SmallVectorImpl<char> &Str) const {
|
virtual void getSectionFlagsAsString(SectionKind Kind,
|
||||||
|
SmallVectorImpl<char> &Str) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Eliminate this.
|
// FIXME: Eliminate this.
|
||||||
|
|
|
@ -117,8 +117,8 @@ void AsmPrinter::SwitchToDataSection(const char *NewSection,
|
||||||
|
|
||||||
/// SwitchToSection - Switch to the specified section of the executable if we
|
/// SwitchToSection - Switch to the specified section of the executable if we
|
||||||
/// are not already in it!
|
/// are not already in it!
|
||||||
void AsmPrinter::SwitchToSection(const Section* NS) {
|
void AsmPrinter::SwitchToSection(const Section *NS) {
|
||||||
const std::string& NewSection = NS->getName();
|
const std::string &NewSection = NS->getName();
|
||||||
|
|
||||||
// If we're already in this section, we're done.
|
// If we're already in this section, we're done.
|
||||||
if (CurrentSection == NewSection) return;
|
if (CurrentSection == NewSection) return;
|
||||||
|
@ -135,20 +135,20 @@ void AsmPrinter::SwitchToSection(const Section* NS) {
|
||||||
// If section is named we need to switch into it via special '.section'
|
// If section is named we need to switch into it via special '.section'
|
||||||
// directive and also append funky flags. Otherwise - section name is just
|
// directive and also append funky flags. Otherwise - section name is just
|
||||||
// some magic assembler directive.
|
// some magic assembler directive.
|
||||||
if (NS->hasFlag(SectionFlags::Named)) {
|
if (NS->getKind().hasExplicitSection()) {
|
||||||
O << TAI->getSwitchToSectionDirective()
|
|
||||||
<< CurrentSection;
|
|
||||||
|
|
||||||
SmallString<32> FlagsStr;
|
SmallString<32> FlagsStr;
|
||||||
TAI->getSectionFlags(NS->getFlags(), FlagsStr);
|
TAI->getSectionFlagsAsString(NS->getKind(), FlagsStr);
|
||||||
O << FlagsStr.c_str();
|
|
||||||
|
O << TAI->getSwitchToSectionDirective()
|
||||||
|
<< CurrentSection
|
||||||
|
<< FlagsStr.c_str();
|
||||||
} else {
|
} else {
|
||||||
O << CurrentSection;
|
O << CurrentSection;
|
||||||
}
|
}
|
||||||
O << TAI->getDataSectionStartSuffix() << '\n';
|
O << TAI->getDataSectionStartSuffix() << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
IsInTextSection = (NS->getFlags() & SectionFlags::Code);
|
IsInTextSection = NS->getKind().isText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
|
@ -404,7 +404,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
|
||||||
bool JTInDiffSection = false;
|
bool JTInDiffSection = false;
|
||||||
if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) ||
|
if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) ||
|
||||||
!JumpTableDataSection ||
|
!JumpTableDataSection ||
|
||||||
FuncSection->hasFlag(SectionFlags::Linkonce)) {
|
FuncSection->getKind().isWeak()) {
|
||||||
// In PIC mode, we need to emit the jump table to the same section as the
|
// In PIC mode, we need to emit the jump table to the same section as the
|
||||||
// function body itself, otherwise the label differences won't make sense.
|
// function body itself, otherwise the label differences won't make sense.
|
||||||
// We should also do if the section name is NULL or function is declared in
|
// We should also do if the section name is NULL or function is declared in
|
||||||
|
|
|
@ -228,18 +228,18 @@ unsigned ELFWriter::getGlobalELFType(const GlobalValue *GV) {
|
||||||
|
|
||||||
// getElfSectionFlags - Get the ELF Section Header flags based
|
// getElfSectionFlags - Get the ELF Section Header flags based
|
||||||
// on the flags defined in ELFTargetAsmInfo.
|
// on the flags defined in ELFTargetAsmInfo.
|
||||||
unsigned ELFWriter::getElfSectionFlags(unsigned Flags) {
|
unsigned ELFWriter::getElfSectionFlags(SectionKind Kind) {
|
||||||
unsigned ElfSectionFlags = ELFSection::SHF_ALLOC;
|
unsigned ElfSectionFlags = ELFSection::SHF_ALLOC;
|
||||||
|
|
||||||
if (Flags & SectionFlags::Code)
|
if (Kind.isText())
|
||||||
ElfSectionFlags |= ELFSection::SHF_EXECINSTR;
|
ElfSectionFlags |= ELFSection::SHF_EXECINSTR;
|
||||||
if (Flags & SectionFlags::Writable)
|
if (Kind.isWriteable())
|
||||||
ElfSectionFlags |= ELFSection::SHF_WRITE;
|
ElfSectionFlags |= ELFSection::SHF_WRITE;
|
||||||
if (Flags & SectionFlags::Mergeable)
|
if (Kind.isMergeableConst())
|
||||||
ElfSectionFlags |= ELFSection::SHF_MERGE;
|
ElfSectionFlags |= ELFSection::SHF_MERGE;
|
||||||
if (Flags & SectionFlags::TLS)
|
if (Kind.isThreadLocal())
|
||||||
ElfSectionFlags |= ELFSection::SHF_TLS;
|
ElfSectionFlags |= ELFSection::SHF_TLS;
|
||||||
if (Flags & SectionFlags::Strings)
|
if (Kind.isMergeableCString())
|
||||||
ElfSectionFlags |= ELFSection::SHF_STRINGS;
|
ElfSectionFlags |= ELFSection::SHF_STRINGS;
|
||||||
|
|
||||||
return ElfSectionFlags;
|
return ElfSectionFlags;
|
||||||
|
@ -293,7 +293,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
|
||||||
|
|
||||||
// Get ELF section from TAI
|
// Get ELF section from TAI
|
||||||
const Section *S = TAI->SectionForGlobal(GV);
|
const Section *S = TAI->SectionForGlobal(GV);
|
||||||
unsigned SectionFlags = getElfSectionFlags(S->getFlags());
|
unsigned SectionFlags = getElfSectionFlags(S->getKind());
|
||||||
|
|
||||||
// The symbol align should update the section alignment if needed
|
// The symbol align should update the section alignment if needed
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace llvm {
|
||||||
class TargetAsmInfo;
|
class TargetAsmInfo;
|
||||||
class TargetELFWriterInfo;
|
class TargetELFWriterInfo;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
class SectionKind;
|
||||||
|
|
||||||
typedef std::vector<ELFSym*>::iterator ELFSymIter;
|
typedef std::vector<ELFSym*>::iterator ELFSymIter;
|
||||||
typedef std::vector<ELFSection*>::iterator ELFSectionIter;
|
typedef std::vector<ELFSection*>::iterator ELFSectionIter;
|
||||||
|
@ -209,7 +210,7 @@ namespace llvm {
|
||||||
unsigned getGlobalELFBinding(const GlobalValue *GV);
|
unsigned getGlobalELFBinding(const GlobalValue *GV);
|
||||||
unsigned getGlobalELFType(const GlobalValue *GV);
|
unsigned getGlobalELFType(const GlobalValue *GV);
|
||||||
unsigned getGlobalELFVisibility(const GlobalValue *GV);
|
unsigned getGlobalELFVisibility(const GlobalValue *GV);
|
||||||
unsigned getElfSectionFlags(unsigned Flags);
|
unsigned getElfSectionFlags(SectionKind Kind);
|
||||||
|
|
||||||
// setGlobalSymLookup - Set global value 'GV' with 'Index' in the lookup map
|
// setGlobalSymLookup - Set global value 'GV' with 'Index' in the lookup map
|
||||||
void setGlobalSymLookup(const GlobalValue *GV, unsigned Index) {
|
void setGlobalSymLookup(const GlobalValue *GV, unsigned Index) {
|
||||||
|
|
|
@ -59,8 +59,7 @@ ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMBaseTargetMachine &TM):
|
||||||
ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) {
|
ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) {
|
||||||
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||||
|
|
||||||
BSSSection_ = getUnnamedSection("\t.bss",
|
BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
|
|
||||||
NeedsSet = false;
|
NeedsSet = false;
|
||||||
HasLEB128 = true;
|
HasLEB128 = true;
|
||||||
|
|
|
@ -1130,9 +1130,10 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||||
const Section *TheSection = TAI->SectionForGlobal(GVar);
|
const Section *TheSection = TAI->SectionForGlobal(GVar);
|
||||||
SwitchToSection(TheSection);
|
SwitchToSection(TheSection);
|
||||||
|
|
||||||
|
// FIXME: get this stuff from section kind flags.
|
||||||
if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() &&
|
if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() &&
|
||||||
// Don't put things that should go in the cstring section into "comm".
|
// Don't put things that should go in the cstring section into "comm".
|
||||||
!TheSection->hasFlag(SectionFlags::Strings)) {
|
!TheSection->getKind().isMergeableCString()) {
|
||||||
if (GVar->hasExternalLinkage()) {
|
if (GVar->hasExternalLinkage()) {
|
||||||
if (const char *Directive = TAI->getZeroFillDirective()) {
|
if (const char *Directive = TAI->getZeroFillDirective()) {
|
||||||
O << "\t.globl\t" << name << "\n";
|
O << "\t.globl\t" << name << "\n";
|
||||||
|
|
|
@ -35,8 +35,7 @@ SPULinuxTargetAsmInfo::SPULinuxTargetAsmInfo(const SPUTargetMachine &TM) :
|
||||||
|
|
||||||
// BSS section needs to be emitted as ".section"
|
// BSS section needs to be emitted as ".section"
|
||||||
BSSSection = "\t.section\t.bss";
|
BSSSection = "\t.section\t.bss";
|
||||||
BSSSection_ = getUnnamedSection("\t.section\t.bss",
|
BSSSection_ = getUnnamedSection("\t.section\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
|
|
||||||
SupportsDebugInformation = true;
|
SupportsDebugInformation = true;
|
||||||
NeedsSet = true;
|
NeedsSet = true;
|
||||||
|
|
|
@ -29,28 +29,29 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
|
||||||
: TargetAsmInfo(TM) {
|
: TargetAsmInfo(TM) {
|
||||||
|
|
||||||
CStringSection_ = getUnnamedSection("\t.cstring",
|
CStringSection_ = getUnnamedSection("\t.cstring",
|
||||||
SectionFlags::Mergeable |SectionFlags::Strings);
|
SectionKind::MergeableCString);
|
||||||
FourByteConstantSection = getUnnamedSection("\t.literal4\n",
|
FourByteConstantSection = getUnnamedSection("\t.literal4\n",
|
||||||
SectionFlags::Mergeable);
|
SectionKind::MergeableConst4);
|
||||||
EightByteConstantSection = getUnnamedSection("\t.literal8\n",
|
EightByteConstantSection = getUnnamedSection("\t.literal8\n",
|
||||||
SectionFlags::Mergeable);
|
SectionKind::MergeableConst8);
|
||||||
|
|
||||||
// Note: 16-byte constant section is subtarget specific and should be provided
|
// Note: 16-byte constant section is subtarget specific and should be provided
|
||||||
// there, if needed.
|
// there, if needed.
|
||||||
SixteenByteConstantSection = 0;
|
SixteenByteConstantSection = 0;
|
||||||
|
|
||||||
ReadOnlySection = getUnnamedSection("\t.const", SectionFlags::None);
|
ReadOnlySection = getUnnamedSection("\t.const", SectionKind::ReadOnly);
|
||||||
|
|
||||||
TextCoalSection =
|
TextCoalSection =
|
||||||
getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
|
getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
|
||||||
SectionFlags::Code);
|
SectionKind::Text);
|
||||||
ConstTextCoalSection = getNamedSection("\t__TEXT,__const_coal,coalesced",
|
ConstTextCoalSection = getNamedSection("\t__TEXT,__const_coal,coalesced",
|
||||||
SectionFlags::None);
|
SectionKind::Text);
|
||||||
ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced",
|
ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced",
|
||||||
SectionFlags::None);
|
SectionKind::Text);
|
||||||
ConstDataSection = getUnnamedSection("\t.const_data", SectionFlags::None);
|
ConstDataSection = getUnnamedSection("\t.const_data",
|
||||||
|
SectionKind::ReadOnlyWithRel);
|
||||||
DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced",
|
DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced",
|
||||||
SectionFlags::Writable);
|
SectionKind::DataRel);
|
||||||
|
|
||||||
|
|
||||||
// Common settings for all Darwin targets.
|
// Common settings for all Darwin targets.
|
||||||
|
|
|
@ -27,28 +27,24 @@ using namespace llvm;
|
||||||
ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
|
ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
|
||||||
: TargetAsmInfo(TM) {
|
: TargetAsmInfo(TM) {
|
||||||
|
|
||||||
BSSSection_ = getUnnamedSection("\t.bss",
|
ReadOnlySection = getNamedSection("\t.rodata", SectionKind::ReadOnly);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
TLSDataSection = getNamedSection("\t.tdata", SectionKind::ThreadData);
|
||||||
ReadOnlySection = getNamedSection("\t.rodata", SectionFlags::None);
|
TLSBSSSection = getNamedSection("\t.tbss", SectionKind::ThreadBSS);
|
||||||
TLSDataSection = getNamedSection("\t.tdata",
|
|
||||||
SectionFlags::Writable | SectionFlags::TLS);
|
|
||||||
TLSBSSSection = getNamedSection("\t.tbss",
|
|
||||||
SectionFlags::Writable | SectionFlags::TLS | SectionFlags::BSS);
|
|
||||||
|
|
||||||
DataRelSection = getNamedSection("\t.data.rel", SectionFlags::Writable);
|
DataRelSection = getNamedSection("\t.data.rel", SectionKind::DataRel);
|
||||||
DataRelLocalSection = getNamedSection("\t.data.rel.local",
|
DataRelLocalSection = getNamedSection("\t.data.rel.local",
|
||||||
SectionFlags::Writable);
|
SectionKind::DataRelLocal);
|
||||||
DataRelROSection = getNamedSection("\t.data.rel.ro",
|
DataRelROSection = getNamedSection("\t.data.rel.ro",
|
||||||
SectionFlags::Writable);
|
SectionKind::ReadOnlyWithRel);
|
||||||
DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
|
DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
|
||||||
SectionFlags::Writable);
|
SectionKind::ReadOnlyWithRelLocal);
|
||||||
|
|
||||||
MergeableConst4Section = getNamedSection(".rodata.cst4",
|
MergeableConst4Section = getNamedSection(".rodata.cst4",
|
||||||
SectionFlags::setEntitySize(SectionFlags::Mergeable, 4));
|
SectionKind::MergeableConst4);
|
||||||
MergeableConst8Section = getNamedSection(".rodata.cst8",
|
MergeableConst8Section = getNamedSection(".rodata.cst8",
|
||||||
SectionFlags::setEntitySize(SectionFlags::Mergeable, 8));
|
SectionKind::MergeableConst8);
|
||||||
MergeableConst16Section = getNamedSection(".rodata.cst16",
|
MergeableConst16Section = getNamedSection(".rodata.cst16",
|
||||||
SectionFlags::setEntitySize(SectionFlags::Mergeable, 16));
|
SectionKind::MergeableConst16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,28 +94,30 @@ ELFTargetAsmInfo::getSectionForMergeableConstant(SectionKind Kind) const {
|
||||||
/// getFlagsForNamedSection - If this target wants to be able to infer
|
/// getFlagsForNamedSection - If this target wants to be able to infer
|
||||||
/// section flags based on the name of the section specified for a global
|
/// section flags based on the name of the section specified for a global
|
||||||
/// variable, it can implement this.
|
/// variable, it can implement this.
|
||||||
unsigned ELFTargetAsmInfo::getFlagsForNamedSection(const char *Name) const {
|
SectionKind::Kind ELFTargetAsmInfo::getKindForNamedSection(const char *Name,
|
||||||
unsigned Flags = 0;
|
SectionKind::Kind K) const {
|
||||||
if (Name[0] != '.') return 0;
|
if (Name[0] != '.') return K;
|
||||||
|
|
||||||
// Some lame default implementation based on some magic section names.
|
// Some lame default implementation based on some magic section names.
|
||||||
if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
|
if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
|
||||||
strncmp(Name, ".llvm.linkonce.b.", 17) == 0 ||
|
strncmp(Name, ".llvm.linkonce.b.", 17) == 0 ||
|
||||||
strncmp(Name, ".gnu.linkonce.sb.", 17) == 0 ||
|
strncmp(Name, ".gnu.linkonce.sb.", 17) == 0 ||
|
||||||
strncmp(Name, ".llvm.linkonce.sb.", 18) == 0)
|
strncmp(Name, ".llvm.linkonce.sb.", 18) == 0)
|
||||||
Flags |= SectionFlags::BSS;
|
return SectionKind::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;
|
|
||||||
|
|
||||||
return Flags;
|
if (strcmp(Name, ".tdata") == 0 ||
|
||||||
|
strncmp(Name, ".tdata.", 7) == 0 ||
|
||||||
|
strncmp(Name, ".gnu.linkonce.td.", 17) == 0 ||
|
||||||
|
strncmp(Name, ".llvm.linkonce.td.", 18) == 0)
|
||||||
|
return SectionKind::ThreadData;
|
||||||
|
|
||||||
|
if (strcmp(Name, ".tbss") == 0 ||
|
||||||
|
strncmp(Name, ".tbss.", 6) == 0 ||
|
||||||
|
strncmp(Name, ".gnu.linkonce.tb.", 17) == 0 ||
|
||||||
|
strncmp(Name, ".llvm.linkonce.tb.", 18) == 0)
|
||||||
|
return SectionKind::ThreadBSS;
|
||||||
|
|
||||||
|
return K;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -152,37 +150,36 @@ ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
|
||||||
if (Size <= 16) {
|
if (Size <= 16) {
|
||||||
assert(getCStringSection() && "Should have string section prefix");
|
assert(getCStringSection() && "Should have string section prefix");
|
||||||
|
|
||||||
// We also need alignment here
|
// We also need alignment here.
|
||||||
|
// FIXME: this is getting the alignment of the character, not the alignment
|
||||||
|
// of the string!!
|
||||||
unsigned Align = TD->getPrefTypeAlignment(Ty);
|
unsigned Align = TD->getPrefTypeAlignment(Ty);
|
||||||
if (Align < Size)
|
if (Align < Size)
|
||||||
Align = Size;
|
Align = Size;
|
||||||
|
|
||||||
std::string Name = getCStringSection() + utostr(Size) + '.' + utostr(Align);
|
std::string Name = getCStringSection() + utostr(Size) + '.' + utostr(Align);
|
||||||
unsigned Flags = SectionFlags::setEntitySize(SectionFlags::Mergeable |
|
return getNamedSection(Name.c_str(), SectionKind::MergeableCString);
|
||||||
SectionFlags::Strings,
|
|
||||||
Size);
|
|
||||||
return getNamedSection(Name.c_str(), Flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return getReadOnlySection();
|
return getReadOnlySection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFTargetAsmInfo::getSectionFlags(unsigned Flags,
|
void ELFTargetAsmInfo::getSectionFlagsAsString(SectionKind Kind,
|
||||||
SmallVectorImpl<char> &Str) const {
|
SmallVectorImpl<char> &Str) const {
|
||||||
Str.push_back(',');
|
Str.push_back(',');
|
||||||
Str.push_back('"');
|
Str.push_back('"');
|
||||||
|
|
||||||
if (!(Flags & SectionFlags::Debug))
|
if (!Kind.isMetadata())
|
||||||
Str.push_back('a');
|
Str.push_back('a');
|
||||||
if (Flags & SectionFlags::Code)
|
if (Kind.isText())
|
||||||
Str.push_back('x');
|
Str.push_back('x');
|
||||||
if (Flags & SectionFlags::Writable)
|
if (Kind.isWriteable())
|
||||||
Str.push_back('w');
|
Str.push_back('w');
|
||||||
if (Flags & SectionFlags::Mergeable)
|
if (Kind.isMergeableConst() || Kind.isMergeableCString())
|
||||||
Str.push_back('M');
|
Str.push_back('M');
|
||||||
if (Flags & SectionFlags::Strings)
|
if (Kind.isMergeableCString())
|
||||||
Str.push_back('S');
|
Str.push_back('S');
|
||||||
if (Flags & SectionFlags::TLS)
|
if (Kind.isThreadLocal())
|
||||||
Str.push_back('T');
|
Str.push_back('T');
|
||||||
|
|
||||||
Str.push_back('"');
|
Str.push_back('"');
|
||||||
|
@ -195,16 +192,27 @@ void ELFTargetAsmInfo::getSectionFlags(unsigned Flags,
|
||||||
Str.push_back('@');
|
Str.push_back('@');
|
||||||
|
|
||||||
const char *KindStr;
|
const char *KindStr;
|
||||||
if (Flags & SectionFlags::BSS)
|
if (Kind.isBSS())
|
||||||
KindStr = "nobits";
|
KindStr = "nobits";
|
||||||
else
|
else
|
||||||
KindStr = "progbits";
|
KindStr = "progbits";
|
||||||
|
|
||||||
Str.append(KindStr, KindStr+strlen(KindStr));
|
Str.append(KindStr, KindStr+strlen(KindStr));
|
||||||
|
|
||||||
if (unsigned entitySize = SectionFlags::getEntitySize(Flags)) {
|
if (Kind.isMergeableCString()) {
|
||||||
|
// TODO: Eventually handle multiple byte character strings. For now, all
|
||||||
|
// mergable C strings are single byte.
|
||||||
Str.push_back(',');
|
Str.push_back(',');
|
||||||
std::string Size = utostr(entitySize);
|
Str.push_back('1');
|
||||||
Str.append(Size.begin(), Size.end());
|
} else if (Kind.isMergeableConst4()) {
|
||||||
|
Str.push_back(',');
|
||||||
|
Str.push_back('4');
|
||||||
|
} else if (Kind.isMergeableConst8()) {
|
||||||
|
Str.push_back(',');
|
||||||
|
Str.push_back('8');
|
||||||
|
} else if (Kind.isMergeableConst16()) {
|
||||||
|
Str.push_back(',');
|
||||||
|
Str.push_back('1');
|
||||||
|
Str.push_back('6');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,5 @@ MSP430TargetAsmInfo::MSP430TargetAsmInfo(const TargetMachine &TM)
|
||||||
: ELFTargetAsmInfo(TM) {
|
: ELFTargetAsmInfo(TM) {
|
||||||
AlignmentIsInBytes = false;
|
AlignmentIsInBytes = false;
|
||||||
|
|
||||||
BSSSection_ = getUnnamedSection("\t.bss",
|
BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,7 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM)
|
||||||
BSSSection = "\t.section\t.bss";
|
BSSSection = "\t.section\t.bss";
|
||||||
CStringSection = ".rodata.str";
|
CStringSection = ".rodata.str";
|
||||||
|
|
||||||
BSSSection_ = getUnnamedSection("\t.bss",
|
BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
|
|
||||||
if (!TM.getSubtarget<MipsSubtarget>().hasABICall())
|
if (!TM.getSubtarget<MipsSubtarget>().hasABICall())
|
||||||
JumpTableDirective = "\t.word\t";
|
JumpTableDirective = "\t.word\t";
|
||||||
|
|
|
@ -61,8 +61,8 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
// Now emit the instructions of function in its code section.
|
// Now emit the instructions of function in its code section.
|
||||||
const char *codeSection = PAN::getCodeSectionName(CurrentFnName).c_str();
|
const char *codeSection = PAN::getCodeSectionName(CurrentFnName).c_str();
|
||||||
|
|
||||||
const Section *fCodeSection = TAI->getNamedSection(codeSection,
|
const Section *fCodeSection =
|
||||||
SectionFlags::Code);
|
TAI->getNamedSection(codeSection, SectionKind::Text);
|
||||||
// Start the Code Section.
|
// Start the Code Section.
|
||||||
O << "\n";
|
O << "\n";
|
||||||
SwitchToSection(fCodeSection);
|
SwitchToSection(fCodeSection);
|
||||||
|
@ -291,8 +291,8 @@ void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) {
|
||||||
O << "\n";
|
O << "\n";
|
||||||
const char *SectionName = PAN::getFrameSectionName(CurrentFnName).c_str();
|
const char *SectionName = PAN::getFrameSectionName(CurrentFnName).c_str();
|
||||||
|
|
||||||
const Section *fPDataSection = TAI->getNamedSection(SectionName,
|
const Section *fPDataSection =
|
||||||
SectionFlags::Writable);
|
TAI->getNamedSection(SectionName, SectionKind::DataRel);
|
||||||
SwitchToSection(fPDataSection);
|
SwitchToSection(fPDataSection);
|
||||||
|
|
||||||
// Emit function frame label
|
// Emit function frame label
|
||||||
|
|
|
@ -37,18 +37,21 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
|
||||||
ZeroDirective = NULL;
|
ZeroDirective = NULL;
|
||||||
AsciiDirective = " dt ";
|
AsciiDirective = " dt ";
|
||||||
AscizDirective = NULL;
|
AscizDirective = NULL;
|
||||||
BSSSection_ = getNamedSection("udata.# UDATA",
|
BSSSection_ = getNamedSection("udata.# UDATA", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
ReadOnlySection = getNamedSection("romdata.# ROMDATA", SectionKind::ReadOnly);
|
||||||
ReadOnlySection = getNamedSection("romdata.# ROMDATA", SectionFlags::None);
|
DataSection = getNamedSection("idata.# IDATA", SectionKind::DataRel);
|
||||||
DataSection = getNamedSection("idata.# IDATA", SectionFlags::Writable);
|
|
||||||
SwitchToSectionDirective = "";
|
SwitchToSectionDirective = "";
|
||||||
// Need because otherwise a .text symbol is emitted by DwarfWriter
|
// Need because otherwise a .text symbol is emitted by DwarfWriter
|
||||||
// in BeginModule, and gpasm cribbs for that .text symbol.
|
// in BeginModule, and gpasm cribbs for that .text symbol.
|
||||||
TextSection = getUnnamedSection("", SectionFlags::Code);
|
TextSection = getUnnamedSection("", SectionKind::Text);
|
||||||
PIC16Section *ROSection = new PIC16Section(getReadOnlySection());
|
PIC16Section *ROSection = new PIC16Section(getReadOnlySection());
|
||||||
ROSections.push_back(ROSection);
|
ROSections.push_back(ROSection);
|
||||||
ExternalVarDecls = new PIC16Section(getNamedSection("ExternalVarDecls"));
|
|
||||||
ExternalVarDefs = new PIC16Section(getNamedSection("ExternalVarDefs"));
|
// FIXME: I don't know what the classification of these sections really is.
|
||||||
|
ExternalVarDecls = new PIC16Section(getNamedSection("ExternalVarDecls",
|
||||||
|
SectionKind::Metadata));
|
||||||
|
ExternalVarDefs = new PIC16Section(getNamedSection("ExternalVarDefs",
|
||||||
|
SectionKind::Metadata));
|
||||||
// Set it to false because we weed to generate c file name and not bc file
|
// Set it to false because we weed to generate c file name and not bc file
|
||||||
// name.
|
// name.
|
||||||
HasSingleParameterDotFile = false;
|
HasSingleParameterDotFile = false;
|
||||||
|
@ -95,7 +98,9 @@ PIC16TargetAsmInfo::getBSSSectionForGlobal(const GlobalVariable *GV) const {
|
||||||
// No BSS section spacious enough was found. Crate a new one.
|
// No BSS section spacious enough was found. Crate a new one.
|
||||||
if (!FoundBSS) {
|
if (!FoundBSS) {
|
||||||
std::string name = PAN::getUdataSectionName(BSSSections.size());
|
std::string name = PAN::getUdataSectionName(BSSSections.size());
|
||||||
const Section *NewSection = getNamedSection(name.c_str());
|
const Section *NewSection = getNamedSection(name.c_str(),
|
||||||
|
// FIXME.
|
||||||
|
SectionKind::Metadata);
|
||||||
|
|
||||||
FoundBSS = new PIC16Section(NewSection);
|
FoundBSS = new PIC16Section(NewSection);
|
||||||
|
|
||||||
|
@ -135,7 +140,9 @@ PIC16TargetAsmInfo::getIDATASectionForGlobal(const GlobalVariable *GV) const {
|
||||||
// No IDATA section spacious enough was found. Crate a new one.
|
// No IDATA section spacious enough was found. Crate a new one.
|
||||||
if (!FoundIDATA) {
|
if (!FoundIDATA) {
|
||||||
std::string name = PAN::getIdataSectionName(IDATASections.size());
|
std::string name = PAN::getIdataSectionName(IDATASections.size());
|
||||||
const Section *NewSection = getNamedSection(name.c_str());
|
const Section *NewSection = getNamedSection(name.c_str(),
|
||||||
|
// FIXME.
|
||||||
|
SectionKind::Metadata);
|
||||||
|
|
||||||
FoundIDATA = new PIC16Section(NewSection);
|
FoundIDATA = new PIC16Section(NewSection);
|
||||||
|
|
||||||
|
@ -168,7 +175,9 @@ PIC16TargetAsmInfo::getSectionForAuto(const GlobalVariable *GV) const {
|
||||||
|
|
||||||
// No Auto section was found. Crate a new one.
|
// No Auto section was found. Crate a new one.
|
||||||
if (!FoundAutoSec) {
|
if (!FoundAutoSec) {
|
||||||
const Section *NewSection = getNamedSection(name.c_str());
|
const Section *NewSection = getNamedSection(name.c_str(),
|
||||||
|
// FIXME.
|
||||||
|
SectionKind::Metadata);
|
||||||
|
|
||||||
FoundAutoSec = new PIC16Section(NewSection);
|
FoundAutoSec = new PIC16Section(NewSection);
|
||||||
|
|
||||||
|
@ -316,7 +325,7 @@ PIC16TargetAsmInfo::CreateBSSSectionForGlobal(const GlobalVariable *GV,
|
||||||
|
|
||||||
PIC16Section *NewBSS = FoundBSS;
|
PIC16Section *NewBSS = FoundBSS;
|
||||||
if (NewBSS == NULL) {
|
if (NewBSS == NULL) {
|
||||||
const Section *NewSection = getNamedSection(Name.c_str());
|
const Section *NewSection = getNamedSection(Name.c_str(), SectionKind::BSS);
|
||||||
NewBSS = new PIC16Section(NewSection);
|
NewBSS = new PIC16Section(NewSection);
|
||||||
BSSSections.push_back(NewBSS);
|
BSSSections.push_back(NewBSS);
|
||||||
}
|
}
|
||||||
|
@ -367,7 +376,9 @@ PIC16TargetAsmInfo::CreateIDATASectionForGlobal(const GlobalVariable *GV,
|
||||||
|
|
||||||
PIC16Section *NewIDATASec = FoundIDATASec;
|
PIC16Section *NewIDATASec = FoundIDATASec;
|
||||||
if (NewIDATASec == NULL) {
|
if (NewIDATASec == NULL) {
|
||||||
const Section *NewSection = getNamedSection(Name.c_str());
|
const Section *NewSection = getNamedSection(Name.c_str(),
|
||||||
|
// FIXME:
|
||||||
|
SectionKind::Metadata);
|
||||||
NewIDATASec = new PIC16Section(NewSection);
|
NewIDATASec = new PIC16Section(NewSection);
|
||||||
IDATASections.push_back(NewIDATASec);
|
IDATASections.push_back(NewIDATASec);
|
||||||
}
|
}
|
||||||
|
@ -405,7 +416,8 @@ PIC16TargetAsmInfo::CreateROSectionForGlobal(const GlobalVariable *GV,
|
||||||
|
|
||||||
PIC16Section *NewRomSec = FoundROSec;
|
PIC16Section *NewRomSec = FoundROSec;
|
||||||
if (NewRomSec == NULL) {
|
if (NewRomSec == NULL) {
|
||||||
const Section *NewSection = getNamedSection(Name.c_str());
|
const Section *NewSection = getNamedSection(Name.c_str(),
|
||||||
|
SectionKind::ReadOnly);
|
||||||
NewRomSec = new PIC16Section(NewSection);
|
NewRomSec = new PIC16Section(NewSection);
|
||||||
ROSections.push_back(NewRomSec);
|
ROSections.push_back(NewRomSec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -899,7 +899,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||||
(GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
|
(GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
|
||||||
GVar->isWeakForLinker()) &&
|
GVar->isWeakForLinker()) &&
|
||||||
// Don't put things that should go in the cstring section into "comm".
|
// Don't put things that should go in the cstring section into "comm".
|
||||||
!TheSection->hasFlag(SectionFlags::Strings)) {
|
!TheSection->getKind().isMergeableCString()) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
if (GVar->hasExternalLinkage()) {
|
if (GVar->hasExternalLinkage()) {
|
||||||
|
|
|
@ -49,8 +49,7 @@ PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
||||||
return DW_EH_PE_absptr;
|
return DW_EH_PE_absptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const {
|
||||||
PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const {
|
|
||||||
const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
|
const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
|
||||||
if (Subtarget->getDarwinVers() > 9)
|
if (Subtarget->getDarwinVers() > 9)
|
||||||
return PrivateGlobalPrefix;
|
return PrivateGlobalPrefix;
|
||||||
|
@ -72,8 +71,7 @@ PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
|
||||||
BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
|
BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
|
||||||
|
|
||||||
// PPC/Linux normally uses named section for BSS.
|
// PPC/Linux normally uses named section for BSS.
|
||||||
BSSSection_ = getNamedSection("\t.bss",
|
BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
|
|
||||||
// Debug Information
|
// Debug Information
|
||||||
AbsoluteDebugSectionOffsets = true;
|
AbsoluteDebugSectionOffsets = true;
|
||||||
|
|
|
@ -27,25 +27,24 @@ SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM)
|
||||||
CStringSection=".rodata.str";
|
CStringSection=".rodata.str";
|
||||||
|
|
||||||
// Sparc normally uses named section for BSS.
|
// Sparc normally uses named section for BSS.
|
||||||
BSSSection_ = getNamedSection("\t.bss",
|
BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SparcELFTargetAsmInfo::getSectionFlags(unsigned Flags,
|
void SparcELFTargetAsmInfo::getSectionFlagsAsString(SectionKind Kind,
|
||||||
SmallVectorImpl<char> &Str) const {
|
SmallVectorImpl<char> &Str) const {
|
||||||
if (Flags & SectionFlags::Mergeable)
|
if (Kind.isMergeableConst() || Kind.isMergeableCString())
|
||||||
return ELFTargetAsmInfo::getSectionFlags(Flags, Str);
|
return ELFTargetAsmInfo::getSectionFlagsAsString(Kind, Str);
|
||||||
|
|
||||||
// FIXME: Inefficient.
|
// FIXME: Inefficient.
|
||||||
std::string Res;
|
std::string Res;
|
||||||
if (!(Flags & SectionFlags::Debug))
|
if (!Kind.isMetadata())
|
||||||
Res += ",#alloc";
|
Res += ",#alloc";
|
||||||
if (Flags & SectionFlags::Code)
|
if (Kind.isText())
|
||||||
Res += ",#execinstr";
|
Res += ",#execinstr";
|
||||||
if (Flags & SectionFlags::Writable)
|
if (Kind.isWriteable())
|
||||||
Res += ",#write";
|
Res += ",#write";
|
||||||
if (Flags & SectionFlags::TLS)
|
if (Kind.isThreadLocal())
|
||||||
Res += ",#tls";
|
Res += ",#tls";
|
||||||
|
|
||||||
Str.append(Res.begin(), Res.end());
|
Str.append(Res.begin(), Res.end());
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace llvm {
|
||||||
struct SparcELFTargetAsmInfo : public ELFTargetAsmInfo {
|
struct SparcELFTargetAsmInfo : public ELFTargetAsmInfo {
|
||||||
explicit SparcELFTargetAsmInfo(const TargetMachine &TM);
|
explicit SparcELFTargetAsmInfo(const TargetMachine &TM);
|
||||||
|
|
||||||
virtual void getSectionFlags(unsigned Flags,
|
virtual void getSectionFlagsAsString(SectionKind Kind,
|
||||||
SmallVectorImpl<char> &Str) const;
|
SmallVectorImpl<char> &Str) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,5 @@ SystemZTargetAsmInfo::SystemZTargetAsmInfo(const SystemZTargetMachine &TM)
|
||||||
|
|
||||||
NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
|
NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
|
||||||
|
|
||||||
BSSSection_ = getUnnamedSection("\t.bss",
|
BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,8 +122,8 @@ TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) : TM(tm) {
|
||||||
DwarfEHFrameSection = ".eh_frame";
|
DwarfEHFrameSection = ".eh_frame";
|
||||||
DwarfExceptionSection = ".gcc_except_table";
|
DwarfExceptionSection = ".gcc_except_table";
|
||||||
AsmTransCBE = 0;
|
AsmTransCBE = 0;
|
||||||
TextSection = getUnnamedSection("\t.text", SectionFlags::Code);
|
TextSection = getUnnamedSection("\t.text", SectionKind::Text);
|
||||||
DataSection = getUnnamedSection("\t.data", SectionFlags::Writable);
|
DataSection = getUnnamedSection("\t.data", SectionKind::DataRel);
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetAsmInfo::~TargetAsmInfo() {
|
TargetAsmInfo::~TargetAsmInfo() {
|
||||||
|
@ -199,23 +199,6 @@ static bool isConstantString(const Constant *C) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned SectionFlagsForGlobal(SectionKind Kind) {
|
|
||||||
// Decode flags from global and section kind.
|
|
||||||
unsigned Flags = SectionFlags::None;
|
|
||||||
if (Kind.isWeak())
|
|
||||||
Flags |= SectionFlags::Linkonce;
|
|
||||||
if (Kind.isBSS() || Kind.isThreadBSS())
|
|
||||||
Flags |= SectionFlags::BSS;
|
|
||||||
if (Kind.isThreadLocal())
|
|
||||||
Flags |= SectionFlags::TLS;
|
|
||||||
if (Kind.isText())
|
|
||||||
Flags |= SectionFlags::Code;
|
|
||||||
if (Kind.isWriteable())
|
|
||||||
Flags |= SectionFlags::Writable;
|
|
||||||
|
|
||||||
return Flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV,
|
static SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV,
|
||||||
const TargetMachine &TM) {
|
const TargetMachine &TM) {
|
||||||
Reloc::Model ReloModel = TM.getRelocationModel();
|
Reloc::Model ReloModel = TM.getRelocationModel();
|
||||||
|
@ -326,29 +309,21 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
|
||||||
if (const Section *TS = getSpecialCasedSectionGlobals(GV, Kind))
|
if (const Section *TS = getSpecialCasedSectionGlobals(GV, Kind))
|
||||||
return TS;
|
return TS;
|
||||||
|
|
||||||
// Honour section already set, if any.
|
|
||||||
unsigned Flags = SectionFlagsForGlobal(Kind);
|
|
||||||
|
|
||||||
// This is an explicitly named section.
|
|
||||||
Flags |= SectionFlags::Named;
|
|
||||||
|
|
||||||
// If the target has magic semantics for certain section names, make sure to
|
// If the target has magic semantics for certain section names, make sure to
|
||||||
// pick up the flags. This allows the user to write things with attribute
|
// pick up the flags. This allows the user to write things with attribute
|
||||||
// section and still get the appropriate section flags printed.
|
// section and still get the appropriate section flags printed.
|
||||||
Flags |= getFlagsForNamedSection(GV->getSection().c_str());
|
GVKind = getKindForNamedSection(GV->getSection().c_str(), GVKind);
|
||||||
|
|
||||||
return getNamedSection(GV->getSection().c_str(), Flags);
|
return getNamedSection(GV->getSection().c_str(), GVKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this global is linkonce/weak and the target handles this by emitting it
|
// If this global is linkonce/weak and the target handles this by emitting it
|
||||||
// into a 'uniqued' section name, create and return the section now.
|
// into a 'uniqued' section name, create and return the section now.
|
||||||
if (Kind.isWeak()) {
|
if (Kind.isWeak()) {
|
||||||
if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) {
|
if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) {
|
||||||
unsigned Flags = SectionFlagsForGlobal(Kind);
|
|
||||||
|
|
||||||
// FIXME: Use mangler interface (PR4584).
|
// FIXME: Use mangler interface (PR4584).
|
||||||
std::string Name = Prefix+GV->getNameStr();
|
std::string Name = Prefix+GV->getNameStr();
|
||||||
return getNamedSection(Name.c_str(), Flags);
|
return getNamedSection(Name.c_str(), GVKind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,12 +365,12 @@ TargetAsmInfo::getSectionForMergeableConstant(SectionKind Kind) const {
|
||||||
|
|
||||||
|
|
||||||
const Section *TargetAsmInfo::getNamedSection(const char *Name,
|
const Section *TargetAsmInfo::getNamedSection(const char *Name,
|
||||||
unsigned Flags) const {
|
SectionKind::Kind Kind) const {
|
||||||
Section &S = Sections[Name];
|
Section &S = Sections[Name];
|
||||||
|
|
||||||
// This is newly-created section, set it up properly.
|
// This is newly-created section, set it up properly.
|
||||||
if (S.Name.empty()) {
|
if (S.Name.empty()) {
|
||||||
S.Flags = Flags | SectionFlags::Named;
|
S.Kind = SectionKind::get(Kind, false /*weak*/, true /*Named*/);
|
||||||
S.Name = Name;
|
S.Name = Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,12 +378,13 @@ const Section *TargetAsmInfo::getNamedSection(const char *Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Section*
|
const Section*
|
||||||
TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags) const {
|
TargetAsmInfo::getUnnamedSection(const char *Directive,
|
||||||
|
SectionKind::Kind Kind) const {
|
||||||
Section& S = Sections[Directive];
|
Section& S = Sections[Directive];
|
||||||
|
|
||||||
// This is newly-created section, set it up properly.
|
// This is newly-created section, set it up properly.
|
||||||
if (S.Name.empty()) {
|
if (S.Name.empty()) {
|
||||||
S.Flags = Flags & ~SectionFlags::Named;
|
S.Kind = SectionKind::get(Kind, false /*weak*/, false /*Named*/);
|
||||||
S.Name = Directive;
|
S.Name = Directive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -799,7 +799,7 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||||
|
|
||||||
if (C->isNullValue() && !GVar->hasSection() &&
|
if (C->isNullValue() && !GVar->hasSection() &&
|
||||||
// Don't put things that should go in the cstring section into "comm".
|
// Don't put things that should go in the cstring section into "comm".
|
||||||
!TheSection->hasFlag(SectionFlags::Strings)) {
|
!TheSection->getKind().isMergeableCString()) {
|
||||||
if (GVar->hasExternalLinkage()) {
|
if (GVar->hasExternalLinkage()) {
|
||||||
if (const char *Directive = TAI->getZeroFillDirective()) {
|
if (const char *Directive = TAI->getZeroFillDirective()) {
|
||||||
O << "\t.globl " << name << '\n';
|
O << "\t.globl " << name << '\n';
|
||||||
|
|
|
@ -58,7 +58,7 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
|
||||||
// FIXME: Why don't we always use this section?
|
// FIXME: Why don't we always use this section?
|
||||||
if (is64Bit)
|
if (is64Bit)
|
||||||
SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
|
SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
|
||||||
SectionFlags::Mergeable);
|
SectionKind::MergeableConst16);
|
||||||
LCOMMDirective = "\t.lcomm\t";
|
LCOMMDirective = "\t.lcomm\t";
|
||||||
|
|
||||||
// Leopard and above support aligned common symbols.
|
// Leopard and above support aligned common symbols.
|
||||||
|
@ -128,8 +128,7 @@ X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
|
||||||
// Set up DWARF directives
|
// Set up DWARF directives
|
||||||
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
||||||
|
|
||||||
BSSSection_ = getUnnamedSection("\t.bss",
|
BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
|
||||||
SectionFlags::Writable | SectionFlags::BSS);
|
|
||||||
|
|
||||||
// Debug Information
|
// Debug Information
|
||||||
AbsoluteDebugSectionOffsets = true;
|
AbsoluteDebugSectionOffsets = true;
|
||||||
|
@ -278,13 +277,14 @@ getSectionPrefixForUniqueGlobal(SectionKind Kind) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void X86COFFTargetAsmInfo::getSectionFlags(unsigned Flags,
|
|
||||||
SmallVectorImpl<char> &Str) const {
|
void X86COFFTargetAsmInfo::getSectionFlagsAsString(SectionKind Kind,
|
||||||
|
SmallVectorImpl<char> &Str) const {
|
||||||
// FIXME: Inefficient.
|
// FIXME: Inefficient.
|
||||||
std::string Res = ",\"";
|
std::string Res = ",\"";
|
||||||
if (Flags & SectionFlags::Code)
|
if (Kind.isText())
|
||||||
Res += 'x';
|
Res += 'x';
|
||||||
if (Flags & SectionFlags::Writable)
|
if (Kind.isWriteable())
|
||||||
Res += 'w';
|
Res += 'w';
|
||||||
Res += "\"";
|
Res += "\"";
|
||||||
|
|
||||||
|
@ -314,8 +314,8 @@ X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
|
||||||
|
|
||||||
AlignmentIsInBytes = true;
|
AlignmentIsInBytes = true;
|
||||||
|
|
||||||
TextSection = getUnnamedSection("_text", SectionFlags::Code);
|
TextSection = getUnnamedSection("_text", SectionKind::Text);
|
||||||
DataSection = getUnnamedSection("_data", SectionFlags::Writable);
|
DataSection = getUnnamedSection("_data", SectionKind::DataRel);
|
||||||
|
|
||||||
JumpTableDataSection = NULL;
|
JumpTableDataSection = NULL;
|
||||||
SwitchToSectionDirective = "";
|
SwitchToSectionDirective = "";
|
||||||
|
|
|
@ -56,8 +56,8 @@ namespace llvm {
|
||||||
virtual const char *
|
virtual const char *
|
||||||
getSectionPrefixForUniqueGlobal(SectionKind kind) const;
|
getSectionPrefixForUniqueGlobal(SectionKind kind) const;
|
||||||
|
|
||||||
virtual void getSectionFlags(unsigned Flags,
|
virtual void getSectionFlagsAsString(SectionKind Kind,
|
||||||
SmallVectorImpl<char> &Str) const;
|
SmallVectorImpl<char> &Str) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct X86WinTargetAsmInfo : public X86GenericTargetAsmInfo {
|
struct X86WinTargetAsmInfo : public X86GenericTargetAsmInfo {
|
||||||
|
|
|
@ -24,10 +24,9 @@ using namespace llvm;
|
||||||
XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM)
|
XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM)
|
||||||
: ELFTargetAsmInfo(TM) {
|
: ELFTargetAsmInfo(TM) {
|
||||||
SupportsDebugInformation = true;
|
SupportsDebugInformation = true;
|
||||||
TextSection = getUnnamedSection("\t.text", SectionFlags::Code);
|
TextSection = getUnnamedSection("\t.text", SectionKind::Text);
|
||||||
DataSection = getNamedSection("\t.dp.data", SectionFlags::Writable);
|
DataSection = getNamedSection("\t.dp.data", SectionKind::DataRel);
|
||||||
BSSSection_ = getNamedSection("\t.dp.bss", SectionFlags::Writable |
|
BSSSection_ = getNamedSection("\t.dp.bss", SectionKind::BSS);
|
||||||
SectionFlags::BSS);
|
|
||||||
|
|
||||||
// TLS globals are lowered in the backend to arrays indexed by the current
|
// TLS globals are lowered in the backend to arrays indexed by the current
|
||||||
// thread id. After lowering they require no special handling by the linker
|
// thread id. After lowering they require no special handling by the linker
|
||||||
|
@ -36,9 +35,10 @@ XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM)
|
||||||
TLSBSSSection = BSSSection_;
|
TLSBSSSection = BSSSection_;
|
||||||
|
|
||||||
if (TM.getSubtargetImpl()->isXS1A())
|
if (TM.getSubtargetImpl()->isXS1A())
|
||||||
ReadOnlySection = getNamedSection("\t.dp.rodata", SectionFlags::Writable);
|
// FIXME: Why is this writable???
|
||||||
|
ReadOnlySection = getNamedSection("\t.dp.rodata", SectionKind::DataRel);
|
||||||
else
|
else
|
||||||
ReadOnlySection = getNamedSection("\t.cp.rodata", SectionFlags::None);
|
ReadOnlySection = getNamedSection("\t.cp.rodata", SectionKind::ReadOnly);
|
||||||
Data16bitsDirective = "\t.short\t";
|
Data16bitsDirective = "\t.short\t";
|
||||||
Data32bitsDirective = "\t.long\t";
|
Data32bitsDirective = "\t.long\t";
|
||||||
Data64bitsDirective = 0;
|
Data64bitsDirective = 0;
|
||||||
|
|
Loading…
Reference in New Issue