[llvm-commits] [llvm] r77812 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/Target/TargetLoweringObjectFile.h lib/Target/PIC16/PIC16TargetObjectFile.cpp lib/Target/PIC16/PIC16TargetObjectFile.h lib/Target/TargetLoweringObjectFile.cpp
Chris Lattner
sabre at nondot.org
Sat Aug 1 14:46:23 PDT 2009
Author: lattner
Date: Sat Aug 1 16:46:23 2009
New Revision: 77812
URL: http://llvm.org/viewvc/llvm-project?rev=77812&view=rev
Log:
it turns out that isWeak() was basically dead anyway. Kill off SectionInfo :-/
Modified:
llvm/trunk/include/llvm/MC/MCSection.h
llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp
llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h
llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
Modified: llvm/trunk/include/llvm/MC/MCSection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSection.h?rev=77812&r1=77811&r2=77812&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSection.h (original)
+++ llvm/trunk/include/llvm/MC/MCSection.h Sat Aug 1 16:46:23 2009
@@ -43,12 +43,12 @@
public:
virtual ~MCSection();
- bool isDirective() const { return IsDirective; }
-
static MCSection *Create(const StringRef &Name, bool IsDirective,
SectionKind K, MCContext &Ctx);
const std::string &getName() const { return Name; }
+ bool isDirective() const { return IsDirective; }
+
SectionKind getKind() const { return Kind; }
};
Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=77812&r1=77811&r2=77812&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Sat Aug 1 16:46:23 2009
@@ -26,35 +26,7 @@
class Mangler;
class TargetMachine;
-
-/// SectionInfo - This class is a target-independent classification of a global
-/// which is used to simplify target-specific code by exposing common
-/// predicates.
-class SectionInfo : public SectionKind {
- /// Weak - This is true if the referenced symbol is weak (i.e. linkonce,
- /// weak, weak_odr, etc). This is orthogonal from the categorization.
- bool Weak : 1;
-
-public:
-
- /// Weak - This is true if the referenced symbol is weak (i.e. linkonce,
- /// weak, weak_odr, etc). This is orthogonal from the categorization.
- bool isWeak() const { return Weak; }
-
- static SectionInfo get(Kind K, bool isWeak = false) {
- SectionInfo Res;
- Res.K = K;
- Res.Weak = isWeak;
- return Res;
- }
- static SectionInfo get(SectionKind K, bool isWeak = false) {
- SectionInfo Res;
- *(SectionKind*)&Res = K;
- Res.Weak = isWeak;
- return Res;
- }
-};
-
+
class TargetLoweringObjectFile {
MCContext *Ctx;
protected:
@@ -146,7 +118,7 @@
/// getFlagsForNamedSection.
virtual const MCSection *
getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
- SectionInfo Kind) const {
+ SectionKind Kind) const {
return 0;
}
@@ -159,7 +131,7 @@
protected:
virtual const MCSection *
- SelectSectionForGlobal(const GlobalValue *GV, SectionInfo Kind,
+ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const;
};
@@ -192,7 +164,7 @@
SmallVectorImpl<char> &Str) const;
virtual const MCSection *
- SelectSectionForGlobal(const GlobalValue *GV, SectionInfo Kind,
+ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const;
protected:
const MCSection *DataRelSection;
@@ -221,7 +193,7 @@
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
virtual const MCSection *
- SelectSectionForGlobal(const GlobalValue *GV, SectionInfo Kind,
+ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const;
virtual const MCSection *
@@ -244,7 +216,7 @@
SmallVectorImpl<char> &Str) const;
virtual const MCSection *
- SelectSectionForGlobal(const GlobalValue *GV, SectionInfo Kind,
+ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const;
};
Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=77812&r1=77811&r2=77812&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Sat Aug 1 16:46:23 2009
@@ -166,14 +166,14 @@
// multiple data sections if required.
const MCSection *
PIC16TargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV1,
- SectionInfo Info,
+ SectionKind Kind,
Mangler *Mang,
const TargetMachine &TM) const {
// We select the section based on the initializer here, so it really
// has to be a GlobalVariable.
const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1);
if (!GV)
- return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Info, Mang,TM);
+ return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Kind, Mang,TM);
// Record External Var Decls.
if (GV->isDeclaration()) {
@@ -207,7 +207,7 @@
return getROSectionForGlobal(GV);
// Else let the default implementation take care of it.
- return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Info, Mang,TM);
+ return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM);
}
PIC16TargetObjectFile::~PIC16TargetObjectFile() {
@@ -229,7 +229,7 @@
const MCSection *
PIC16TargetObjectFile::getSpecialCasedSectionGlobals(const GlobalValue *GV,
Mangler *Mang,
- SectionInfo Info) const {
+ SectionKind Kind) const {
// If GV has a sectin name or section address create that section now.
if (GV->hasSection()) {
if (const GlobalVariable *GVar = cast<GlobalVariable>(GV)) {
Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=77812&r1=77811&r2=77812&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Sat Aug 1 16:46:23 2009
@@ -62,9 +62,9 @@
/// section assignment of a global.
virtual const MCSection *
getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
- SectionInfo Info) const;
+ SectionKind Kind) const;
virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
- SectionInfo Info,
+ SectionKind Kind,
Mangler *Mang,
const TargetMachine&) const;
private:
Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=77812&r1=77811&r2=77812&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Aug 1 16:46:23 2009
@@ -190,13 +190,12 @@
"Can only be used for global definitions");
SectionKind Kind = SectionKindForGlobal(GV, TM);
- SectionInfo Info = SectionInfo::get(Kind, GV->isWeakForLinker());
// Select section name.
if (GV->hasSection()) {
// If the target has special section hacks for specifically named globals,
// return them now.
- if (const MCSection *TS = getSpecialCasedSectionGlobals(GV, Mang, Info))
+ if (const MCSection *TS = getSpecialCasedSectionGlobals(GV, Mang, Kind))
return TS;
// If the target has magic semantics for certain section names, make sure to
@@ -209,24 +208,24 @@
// Use default section depending on the 'type' of global
- return SelectSectionForGlobal(GV, Info, Mang, TM);
+ return SelectSectionForGlobal(GV, Kind, Mang, TM);
}
// Lame default implementation. Calculate the section name for global.
const MCSection *
TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
- SectionInfo Info,
+ SectionKind Kind,
Mangler *Mang,
const TargetMachine &TM) const{
- assert(!Info.isThreadLocal() && "Doesn't support TLS");
+ assert(!Kind.isThreadLocal() && "Doesn't support TLS");
- if (Info.isText())
+ if (Kind.isText())
return getTextSection();
- if (Info.isBSS() && BSSSection_ != 0)
+ if (Kind.isBSS() && BSSSection_ != 0)
return BSSSection_;
- if (Info.isReadOnly() && ReadOnlySection != 0)
+ if (Kind.isReadOnly() && ReadOnlySection != 0)
return ReadOnlySection;
return getDataSection();
@@ -410,20 +409,20 @@
}
const MCSection *TargetLoweringObjectFileELF::
-SelectSectionForGlobal(const GlobalValue *GV, SectionInfo Info,
+SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const {
// 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.
if (GV->isWeakForLinker()) {
- const char *Prefix = getSectionPrefixForUniqueGlobal(Info);
+ const char *Prefix = getSectionPrefixForUniqueGlobal(Kind);
std::string Name = Mang->makeNameProper(GV->getNameStr());
- return getOrCreateSection((Prefix+Name).c_str(), false, Info);
+ return getOrCreateSection((Prefix+Name).c_str(), false, Kind);
}
- if (Info.isText()) return TextSection;
+ if (Kind.isText()) return TextSection;
- if (Info.isMergeableCString()) {
+ if (Kind.isMergeableCString()) {
assert(CStringSection_ && "Should have string section prefix");
// We also need alignment here.
@@ -437,29 +436,29 @@
SectionKind::get(SectionKind::MergeableCString));
}
- if (Info.isMergeableConst()) {
- if (Info.isMergeableConst4())
+ if (Kind.isMergeableConst()) {
+ if (Kind.isMergeableConst4())
return MergeableConst4Section;
- if (Info.isMergeableConst8())
+ if (Kind.isMergeableConst8())
return MergeableConst8Section;
- if (Info.isMergeableConst16())
+ if (Kind.isMergeableConst16())
return MergeableConst16Section;
return ReadOnlySection; // .const
}
- if (Info.isReadOnly()) return ReadOnlySection;
+ if (Kind.isReadOnly()) return ReadOnlySection;
- if (Info.isThreadData()) return TLSDataSection;
- if (Info.isThreadBSS()) return TLSBSSSection;
+ if (Kind.isThreadData()) return TLSDataSection;
+ if (Kind.isThreadBSS()) return TLSBSSSection;
- if (Info.isBSS()) return BSSSection_;
+ if (Kind.isBSS()) return BSSSection_;
- if (Info.isDataNoRel()) return DataSection;
- if (Info.isDataRelLocal()) return DataRelLocalSection;
- if (Info.isDataRel()) return DataRelSection;
- if (Info.isReadOnlyWithRelLocal()) return DataRelROLocalSection;
+ if (Kind.isDataNoRel()) return DataSection;
+ if (Kind.isDataRelLocal()) return DataRelLocalSection;
+ if (Kind.isDataRel()) return DataRelSection;
+ if (Kind.isReadOnlyWithRelLocal()) return DataRelROLocalSection;
- assert(Info.isReadOnlyWithRel() && "Unknown section kind");
+ assert(Kind.isReadOnlyWithRel() && "Unknown section kind");
return DataRelROSection;
}
@@ -531,23 +530,23 @@
}
const MCSection *TargetLoweringObjectFileMachO::
-SelectSectionForGlobal(const GlobalValue *GV, SectionInfo Info,
+SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const {
- assert(!Info.isThreadLocal() && "Darwin doesn't support TLS");
+ assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS");
- if (Info.isText())
+ if (Kind.isText())
return GV->isWeakForLinker() ? TextCoalSection : TextSection;
// If this is weak/linkonce, put this in a coalescable section, either in text
// or data depending on if it is writable.
if (GV->isWeakForLinker()) {
- if (Info.isReadOnly())
+ if (Kind.isReadOnly())
return ConstTextCoalSection;
return DataCoalSection;
}
// FIXME: Alignment check should be handled by section classifier.
- if (Info.isMergeableCString()) {
+ if (Kind.isMergeableCString()) {
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
const Type *Ty = cast<ArrayType>(C->getType())->getElementType();
const TargetData &TD = *TM.getTargetData();
@@ -561,24 +560,24 @@
return ReadOnlySection;
}
- if (Info.isMergeableConst()) {
- if (Info.isMergeableConst4())
+ if (Kind.isMergeableConst()) {
+ if (Kind.isMergeableConst4())
return FourByteConstantSection;
- if (Info.isMergeableConst8())
+ if (Kind.isMergeableConst8())
return EightByteConstantSection;
- if (Info.isMergeableConst16() && 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 mergeable?
- if (Info.isReadOnly())
+ if (Kind.isReadOnly())
return ReadOnlySection;
// If this is marked const, put it into a const section. But if the dynamic
// linker needs to write to it, put it in the data segment.
- if (Info.isReadOnlyWithRel())
+ if (Kind.isReadOnlyWithRel())
return ConstDataSection;
// Otherwise, just drop the variable in the normal data section.
@@ -661,25 +660,25 @@
const MCSection *TargetLoweringObjectFileCOFF::
-SelectSectionForGlobal(const GlobalValue *GV, SectionInfo Info,
+SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const {
- assert(!Info.isThreadLocal() && "Doesn't support TLS");
+ assert(!Kind.isThreadLocal() && "Doesn't support TLS");
// 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.
if (GV->isWeakForLinker()) {
- const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Info);
+ const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind);
std::string Name = Mang->makeNameProper(GV->getNameStr());
- return getOrCreateSection((Prefix+Name).c_str(), false, Info);
+ return getOrCreateSection((Prefix+Name).c_str(), false, Kind);
}
- if (Info.isText())
+ if (Kind.isText())
return getTextSection();
- if (Info.isBSS() && BSSSection_ != 0)
+ if (Kind.isBSS() && BSSSection_ != 0)
return BSSSection_;
- if (Info.isReadOnly() && ReadOnlySection != 0)
+ if (Kind.isReadOnly() && ReadOnlySection != 0)
return ReadOnlySection;
return getDataSection();
More information about the llvm-commits
mailing list