diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-08-07 09:50:34 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-08-07 09:50:34 +0000 |
| commit | ef643a485014eca5c29614949f47329a88f6dc79 (patch) | |
| tree | 092b3cc00be34480613a42ae4cca577c0e66fa94 | |
| parent | 25cdad59fec2e37aa9b5d4ae999a45bb6e12e8aa (diff) | |
| download | bcm5719-llvm-ef643a485014eca5c29614949f47329a88f6dc79.tar.gz bcm5719-llvm-ef643a485014eca5c29614949f47329a88f6dc79.zip | |
Select section for constant pool entries
llvm-svn: 54448
| -rw-r--r-- | llvm/include/llvm/Target/ELFTargetAsmInfo.h | 4 | ||||
| -rw-r--r-- | llvm/include/llvm/Target/TargetAsmInfo.h | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/ELFTargetAsmInfo.cpp | 19 | ||||
| -rw-r--r-- | llvm/lib/Target/TargetAsmInfo.cpp | 7 |
4 files changed, 30 insertions, 3 deletions
diff --git a/llvm/include/llvm/Target/ELFTargetAsmInfo.h b/llvm/include/llvm/Target/ELFTargetAsmInfo.h index 703d8006985..fe339f8e591 100644 --- a/llvm/include/llvm/Target/ELFTargetAsmInfo.h +++ b/llvm/include/llvm/Target/ELFTargetAsmInfo.h @@ -21,6 +21,7 @@ namespace llvm { class GlobalValue; class GlobalVariable; + class Type; struct ELFTargetAsmInfo: public virtual TargetAsmInfo { explicit ELFTargetAsmInfo(const TargetMachine &TM); @@ -28,7 +29,10 @@ namespace llvm { virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const; virtual std::string PrintSectionFlags(unsigned flags) const; const Section* MergeableConstSection(const GlobalVariable *GV) const; + inline const Section* MergeableConstSection(const Type *Ty) const; const Section* MergeableStringSection(const GlobalVariable *GV) const; + virtual const Section* + SelectSectionForMachineConst(const Type *Ty) const; protected: const TargetMachine* ETM; }; diff --git a/llvm/include/llvm/Target/TargetAsmInfo.h b/llvm/include/llvm/Target/TargetAsmInfo.h index 852e03a3791..e20a6c8995b 100644 --- a/llvm/include/llvm/Target/TargetAsmInfo.h +++ b/llvm/include/llvm/Target/TargetAsmInfo.h @@ -76,6 +76,7 @@ namespace llvm { class TargetMachine; class CallInst; class GlobalValue; + class Type; class Section { friend class TargetAsmInfo; @@ -542,6 +543,8 @@ namespace llvm { virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const; + virtual const Section* SelectSectionForMachineConst(const Type *Ty) const; + // Accessors. // const char *getTextSection() const { diff --git a/llvm/lib/Target/ELFTargetAsmInfo.cpp b/llvm/lib/Target/ELFTargetAsmInfo.cpp index 6ce01a836b4..3b89c3f1e2d 100644 --- a/llvm/lib/Target/ELFTargetAsmInfo.cpp +++ b/llvm/lib/Target/ELFTargetAsmInfo.cpp @@ -17,6 +17,7 @@ #include "llvm/Function.h" #include "llvm/GlobalVariable.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Target/ELFTargetAsmInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetData.h" @@ -90,15 +91,27 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { } const Section* +ELFTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const { + // FIXME: Support data.rel stuff someday + return MergeableConstSection(Ty); +} + +const Section* ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const { - const TargetData *TD = ETM->getTargetData(); Constant *C = cast<GlobalVariable>(GV)->getInitializer(); - const Type *Type = C->getType(); + const Type *Ty = C->getType(); + + return MergeableConstSection(Ty); +} + +inline const Section* +ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const { + const TargetData *TD = ETM->getTargetData(); // FIXME: string here is temporary, until stuff will fully land in. // We cannot use {Four,Eight,Sixteen}ByteConstantSection here, since it's // currently directly used by asmprinter. - unsigned Size = TD->getABITypeSize(Type); + unsigned Size = TD->getABITypeSize(Ty); if (Size == 4 || Size == 8 || Size == 16) { std::string Name = ".rodata.cst" + utostr(Size); diff --git a/llvm/lib/Target/TargetAsmInfo.cpp b/llvm/lib/Target/TargetAsmInfo.cpp index ad804131b01..eb74836aec3 100644 --- a/llvm/lib/Target/TargetAsmInfo.cpp +++ b/llvm/lib/Target/TargetAsmInfo.cpp @@ -321,6 +321,13 @@ TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { return getDataSection_(); } +// 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_(); +} + std::string TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV, SectionKind::Kind Kind) const { |

