rename Mergable -> Mergeable and Writable -> Writeable

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77138 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-07-26 06:48:26 +00:00
parent 94809c3b10
commit 2ceb60a677
9 changed files with 87 additions and 82 deletions

View File

@ -40,7 +40,8 @@ namespace llvm {
Mangler *Mang) const;
virtual const Section *getSectionForMergableConstant(SectionKind Kind)const;
virtual const Section *
getSectionForMergeableConstant(SectionKind Kind) const;
private:
const Section* MergeableStringSection(const GlobalVariable *GV) const;

View File

@ -25,11 +25,11 @@ namespace llvm {
struct ELFTargetAsmInfo: public TargetAsmInfo {
explicit ELFTargetAsmInfo(const TargetMachine &TM);
/// getSectionForMergableConstant - Given a mergable constant with the
/// getSectionForMergeableConstant - Given a mergeable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
virtual const Section *
getSectionForMergableConstant(SectionKind Kind) const;
getSectionForMergeableConstant(SectionKind Kind) const;
/// getFlagsForNamedSection - If this target wants to be able to infer
/// section flags based on the name of the section specified for a global
@ -48,9 +48,9 @@ namespace llvm {
const Section *DataRelROSection;
const Section *DataRelROLocalSection;
const Section *MergableConst4Section;
const Section *MergableConst8Section;
const Section *MergableConst16Section;
const Section *MergeableConst4Section;
const Section *MergeableConst8Section;
const Section *MergeableConst16Section;
private:
const Section *MergeableStringSection(const GlobalVariable *GV) const;

View File

@ -45,38 +45,38 @@ namespace llvm {
/// ReadOnly - Data that is never written to at program runtime by the
/// program or the dynamic linker. Things in the top-level readonly
/// SectionKind are not mergable.
/// SectionKind are not mergeable.
ReadOnly,
/// MergableCString - This is a special section for nul-terminated
/// MergeableCString - This is a special section for nul-terminated
/// strings. The linker can unique the C strings, knowing their
/// semantics. Because it uniques based on the nul terminators, the
/// compiler can't put strings in this section that have embeded nuls
/// in them.
MergableCString,
MergeableCString,
/// MergableConst - These are sections for merging fixed-length
/// MergeableConst - These are sections for merging fixed-length
/// constants together. For example, this can be used to unique
/// constant pool entries etc.
MergableConst,
MergeableConst,
/// MergableConst4 - This is a section used by 4-byte constants,
/// MergeableConst4 - This is a section used by 4-byte constants,
/// for example, floats.
MergableConst4,
MergeableConst4,
/// MergableConst8 - This is a section used by 8-byte constants,
/// MergeableConst8 - This is a section used by 8-byte constants,
/// for example, doubles.
MergableConst8,
MergeableConst8,
/// MergableConst16 - This is a section used by 16-byte constants,
/// MergeableConst16 - This is a section used by 16-byte constants,
/// for example, vectors.
MergableConst16,
MergeableConst16,
/// Writable - This is the base of all segments that need to be written
/// Writeable - This is the base of all segments that need to be written
/// to during program runtime.
/// ThreadLocal - This is the base of all TLS segments. All TLS
/// objects must be writable, otherwise there is no reason for them to
/// objects must be writeable, otherwise there is no reason for them to
/// be thread local!
/// ThreadBSS - Zero-initialized TLS data objects.
@ -85,10 +85,10 @@ namespace llvm {
/// ThreadData - Initialized TLS data objects.
ThreadData,
/// GlobalWritableData - Writable data that is global (not thread
/// GlobalWriteableData - Writeable data that is global (not thread
/// local).
/// BSS - Zero initialized writable data.
/// BSS - Zero initialized writeable data.
BSS,
/// DataRel - This is the most general form of data that is written
@ -96,54 +96,59 @@ namespace llvm {
/// globals.
DataRel,
/// DataRelLocal - This is writable data that has a non-zero
/// DataRelLocal - This is writeable data that has a non-zero
/// initializer and has relocations in it, but all of the
/// relocations are known to be within the final linked image
/// the global is linked into.
DataRelLocal,
/// DataNoRel - This is writable data that has a non-zero
/// DataNoRel - This is writeable data that has a non-zero
/// initializer, but whose initializer is known to have no
/// relocations.
DataNoRel,
/// ReadOnlyWithRel - These are global variables that are never
/// written to by the program, but that have relocations, so they
/// must be stuck in a writable section so that the dynamic linker
/// must be stuck in a writeable section so that the dynamic linker
/// can write to them. If it chooses to, the dynamic linker can
/// mark the pages these globals end up on as read-only after it is
/// done with its relocation phase.
ReadOnlyWithRel,
/// ReadOnlyWithRelLocal - This is data that is readonly by the
/// program, but must be writable so that the dynamic linker
/// program, but must be writeable so that the dynamic linker
/// can perform relocations in it. This is used when we know
/// that all the relocations are to globals in this final
/// linked image.
ReadOnlyWithRelLocal
} K : 8; // This is private.
};
//private:
Kind K : 8; // This is private.
//public:
bool isText() const {
return K == Text;
}
bool isReadOnly() const {
return K == ReadOnly || K == MergableCString || isMergableConst();
return K == ReadOnly || K == MergeableCString || isMergeableConst();
}
bool isMergableCString() const { return K == MergableCString; }
bool isMergableConst() const {
return K == MergableConst || K == MergableConst4 ||
K == MergableConst8 || K == MergableConst16;
bool isMergeableCString() const { return K == MergeableCString; }
bool isMergeableConst() const {
return K == MergeableConst || K == MergeableConst4 ||
K == MergeableConst8 || K == MergeableConst16;
}
bool isMergableConst4() const { return K == MergableConst4; }
bool isMergableConst8() const { return K == MergableConst8; }
bool isMergableConst16() const { return K == MergableConst16; }
bool isMergeableConst4() const { return K == MergeableConst4; }
bool isMergeableConst8() const { return K == MergeableConst8; }
bool isMergeableConst16() const { return K == MergeableConst16; }
bool isWritable() const {
return isThreadLocal() || isGlobalWritableData();
bool isWriteable() const {
return isThreadLocal() || isGlobalWriteableData();
}
bool isThreadLocal() const {
@ -153,7 +158,7 @@ namespace llvm {
bool isThreadBSS() const { return K == ThreadBSS; }
bool isThreadData() const { return K == ThreadData; }
bool isGlobalWritableData() const {
bool isGlobalWriteableData() const {
return isBSS() || isDataRel() || isReadOnlyWithRel();
}
@ -187,7 +192,7 @@ namespace llvm {
const unsigned Invalid = -1U;
const unsigned None = 0;
const unsigned Code = 1 << 0; ///< Section contains code
const unsigned Writable = 1 << 1; ///< Section is writable
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
@ -690,10 +695,10 @@ namespace llvm {
bool Global) const;
/// getSectionForMergableConstant - Given a mergable constant with the
/// getSectionForMergeableConstant - Given a Mergeable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
virtual const Section *getSectionForMergableConstant(SectionKind Kind)const;
virtual const Section *getSectionForMergeableConstant(SectionKind Kind)const;
/// getSectionPrefixForUniqueGlobal - Return a string that we should prepend

View File

@ -315,14 +315,14 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
case 1: Kind = SectionKind::get(SectionKind::ReadOnlyWithRelLocal); break;
case 0:
switch (TM.getTargetData()->getTypeAllocSize(CPE.getType())) {
case 4: Kind = SectionKind::get(SectionKind::MergableConst4); break;
case 8: Kind = SectionKind::get(SectionKind::MergableConst8); break;
case 16: Kind = SectionKind::get(SectionKind::MergableConst16); break;
default: Kind = SectionKind::get(SectionKind::MergableConst); break;
case 4: Kind = SectionKind::get(SectionKind::MergeableConst4); break;
case 8: Kind = SectionKind::get(SectionKind::MergeableConst8); break;
case 16: Kind = SectionKind::get(SectionKind::MergeableConst16); break;
default: Kind = SectionKind::get(SectionKind::MergeableConst); break;
}
}
const Section *S = TAI->getSectionForMergableConstant(Kind);
const Section *S = TAI->getSectionForMergeableConstant(Kind);
// The number of sections are small, just do a linear search from the
// last section to the first.

View File

@ -161,15 +161,14 @@ ELFSection &ELFWriter::getConstantPoolSection(MachineConstantPoolEntry &CPE) {
case 1: Kind = SectionKind::get(SectionKind::ReadOnlyWithRelLocal); break;
case 0:
switch (TM.getTargetData()->getTypeAllocSize(CPE.getType())) {
case 4: Kind = SectionKind::get(SectionKind::MergableConst4); break;
case 8: Kind = SectionKind::get(SectionKind::MergableConst8); break;
case 16: Kind = SectionKind::get(SectionKind::MergableConst16); break;
default: Kind = SectionKind::get(SectionKind::MergableConst); break;
case 4: Kind = SectionKind::get(SectionKind::MergeableConst4); break;
case 8: Kind = SectionKind::get(SectionKind::MergeableConst8); break;
case 16: Kind = SectionKind::get(SectionKind::MergeableConst16); break;
default: Kind = SectionKind::get(SectionKind::MergeableConst); break;
}
}
std::string CstPoolName = TAI->getSectionForMergableConstant(Kind)->getName();
return getSection(CstPoolName,
return getSection(TAI->getSectionForMergeableConstant(Kind)->getName(),
ELFSection::SHT_PROGBITS,
ELFSection::SHF_MERGE | ELFSection::SHF_ALLOC,
CPE.getAlignment());

View File

@ -144,21 +144,21 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
}
// FIXME: Alignment check should be handled by section classifier.
if (Kind.isMergableCString())
if (Kind.isMergeableCString())
return MergeableStringSection(cast<GlobalVariable>(GV));
if (Kind.isMergableConst()) {
if (Kind.isMergableConst4())
if (Kind.isMergeableConst()) {
if (Kind.isMergeableConst4())
return FourByteConstantSection;
if (Kind.isMergableConst8())
if (Kind.isMergeableConst8())
return EightByteConstantSection;
if (Kind.isMergableConst16() && SixteenByteConstantSection)
if (Kind.isMergeableConst16() && SixteenByteConstantSection)
return SixteenByteConstantSection;
return ReadOnlySection; // .const
}
// FIXME: ROData -> const in -static mode that is relocatable but they happen
// by the static linker. Why not mergable?
// by the static linker. Why not mergeable?
if (Kind.isReadOnly())
return getReadOnlySection();
@ -188,17 +188,17 @@ DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
}
const Section *
DarwinTargetAsmInfo::getSectionForMergableConstant(SectionKind Kind) const {
DarwinTargetAsmInfo::getSectionForMergeableConstant(SectionKind Kind) const {
// If this constant requires a relocation, we have to put it in the data
// segment, not in the text segment.
if (Kind.isDataRel())
return ConstDataSection;
if (Kind.isMergableConst4())
if (Kind.isMergeableConst4())
return FourByteConstantSection;
if (Kind.isMergableConst8())
if (Kind.isMergeableConst8())
return EightByteConstantSection;
if (Kind.isMergableConst16() && SixteenByteConstantSection)
if (Kind.isMergeableConst16() && SixteenByteConstantSection)
return SixteenByteConstantSection;
return ReadOnlySection; // .const
}

View File

@ -44,11 +44,11 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
SectionFlags::Writable);
MergableConst4Section = getNamedSection(".rodata.cst4",
MergeableConst4Section = getNamedSection(".rodata.cst4",
SectionFlags::setEntitySize(SectionFlags::Mergeable, 4));
MergableConst8Section = getNamedSection(".rodata.cst8",
MergeableConst8Section = getNamedSection(".rodata.cst8",
SectionFlags::setEntitySize(SectionFlags::Mergeable, 8));
MergableConst16Section = getNamedSection(".rodata.cst16",
MergeableConst16Section = getNamedSection(".rodata.cst16",
SectionFlags::setEntitySize(SectionFlags::Mergeable, 16));
}
@ -57,16 +57,16 @@ const Section*
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
SectionKind Kind) const {
if (Kind.isText()) return TextSection;
if (Kind.isMergableCString())
if (Kind.isMergeableCString())
return MergeableStringSection(cast<GlobalVariable>(GV));
if (Kind.isMergableConst()) {
if (Kind.isMergableConst4())
return MergableConst4Section;
if (Kind.isMergableConst8())
return MergableConst8Section;
if (Kind.isMergableConst16())
return MergableConst16Section;
if (Kind.isMergeableConst()) {
if (Kind.isMergeableConst4())
return MergeableConst4Section;
if (Kind.isMergeableConst8())
return MergeableConst8Section;
if (Kind.isMergeableConst16())
return MergeableConst16Section;
return ReadOnlySection; // .const
}
@ -88,11 +88,11 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
return DataRelROSection;
}
/// getSectionForMergableConstant - Given a mergable constant with the
/// getSectionForMergeableConstant - Given a Mergeable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
const Section *
ELFTargetAsmInfo::getSectionForMergableConstant(SectionKind Kind) const {
ELFTargetAsmInfo::getSectionForMergeableConstant(SectionKind Kind) const {
return SelectSectionForGlobal(0, Kind);
}

View File

@ -211,7 +211,7 @@ static unsigned SectionFlagsForGlobal(const GlobalValue *GV,
Flags |= SectionFlags::TLS;
if (Kind.isText())
Flags |= SectionFlags::Code;
if (Kind.isWritable())
if (Kind.isWriteable())
Flags |= SectionFlags::Writable;
return Flags;
@ -252,16 +252,16 @@ static SectionKind SectionKindForGlobal(const GlobalValue *GV,
// If initializer is a null-terminated string, put it in a "cstring"
// section if the target has it.
if (isConstantString(C))
return SectionKind::get(SectionKind::MergableCString);
return SectionKind::get(SectionKind::MergeableCString);
// Otherwise, just drop it into a mergable constant section. If we have
// a section for this size, use it, otherwise use the arbitrary sized
// mergable section.
switch (TM.getTargetData()->getTypeAllocSize(C->getType())) {
case 4: return SectionKind::get(SectionKind::MergableConst4);
case 8: return SectionKind::get(SectionKind::MergableConst8);
case 16: return SectionKind::get(SectionKind::MergableConst16);
default: return SectionKind::get(SectionKind::MergableConst);
case 4: return SectionKind::get(SectionKind::MergeableConst4);
case 8: return SectionKind::get(SectionKind::MergeableConst8);
case 16: return SectionKind::get(SectionKind::MergeableConst16);
default: return SectionKind::get(SectionKind::MergeableConst);
}
case Constant::LocalRelocation:
@ -377,7 +377,7 @@ TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
/// specified size and relocation information, return a section that it
/// should be placed in.
const Section *
TargetAsmInfo::getSectionForMergableConstant(SectionKind Kind) const {
TargetAsmInfo::getSectionForMergeableConstant(SectionKind Kind) const {
if (Kind.isReadOnly())
if (const Section *S = getReadOnlySection())
return S;

View File

@ -269,7 +269,7 @@ const char *X86COFFTargetAsmInfo::
getSectionPrefixForUniqueGlobal(SectionKind Kind) const {
if (Kind.isText())
return ".text$linkonce";
if (Kind.isWritable())
if (Kind.isWriteable())
return ".data$linkonce";
return ".rdata$linkonce";
}