[llvm-commits] [llvm] r54449 - in /llvm/trunk: include/llvm/Target/DarwinTargetAsmInfo.h lib/Target/DarwinTargetAsmInfo.cpp lib/Target/ELFTargetAsmInfo.cpp

Anton Korobeynikov asl at math.spbu.ru
Thu Aug 7 02:51:03 PDT 2008


Author: asl
Date: Thu Aug  7 04:51:02 2008
New Revision: 54449

URL: http://llvm.org/viewvc/llvm-project?rev=54449&view=rev
Log:
Add hook for constant pool section selection for darwin.

Modified:
    llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h
    llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
    llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp

Modified: llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h?rev=54449&r1=54448&r2=54449&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h Thu Aug  7 04:51:02 2008
@@ -21,6 +21,7 @@
 namespace llvm {
   class GlobalValue;
   class GlobalVariable;
+  class Type;
 
   struct DarwinTargetAsmInfo: public virtual TargetAsmInfo {
     const Section* TextCoalSection;
@@ -33,7 +34,9 @@
     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const;
     const Section* MergeableConstSection(const GlobalVariable *GV) const;
+    const Section* MergeableConstSection(const Type *Ty) const;
     const Section* MergeableStringSection(const GlobalVariable *GV) const;
+    const Section* SelectSectionForMachineConst(const Type *Ty) const;
   protected:
     const TargetMachine* DTM;
   };

Modified: llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp?rev=54449&r1=54448&r2=54449&view=diff

==============================================================================
--- llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp Thu Aug  7 04:51:02 2008
@@ -107,10 +107,16 @@
 
 const Section*
 DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
-  const TargetData *TD = DTM->getTargetData();
   Constant *C = cast<GlobalVariable>(GV)->getInitializer();
 
-  unsigned Size = TD->getABITypeSize(C->getType());
+  return MergeableConstSection(C->getType());
+}
+
+inline const Section*
+DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
+  const TargetData *TD = DTM->getTargetData();
+
+  unsigned Size = TD->getABITypeSize(Ty);
   if (Size == 4)
     return FourByteConstantSection_;
   else if (Size == 8)
@@ -121,6 +127,18 @@
   return getReadOnlySection_();
 }
 
+const Section*
+DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
+  const Section* S = MergeableConstSection(Ty);
+
+  // Handle weird special case, when compiling PIC stuff.
+  if (S == getReadOnlySection_() &&
+      DTM->getRelocationModel() != Reloc::Static)
+    return ConstDataSection;
+
+  return S;
+}
+
 std::string
 DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const {

Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=54449&r1=54448&r2=54449&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Thu Aug  7 04:51:02 2008
@@ -99,9 +99,7 @@
 const Section*
 ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
   Constant *C = cast<GlobalVariable>(GV)->getInitializer();
-  const Type *Ty = C->getType();
-
-  return MergeableConstSection(Ty);
+  return MergeableConstSection(C->getType());
 }
 
 inline const Section*





More information about the llvm-commits mailing list