expose SectionKindForGlobal to curious clients, named as
authorChris Lattner <sabre@nondot.org>
Wed, 5 Aug 2009 04:25:40 +0000 (04:25 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 5 Aug 2009 04:25:40 +0000 (04:25 +0000)
getKindForGlobal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78156 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLoweringObjectFile.h
lib/Target/TargetLoweringObjectFile.cpp

index 10ce48158ae7892f292a8555225df2b68f565594..630f9d0604b55068f27c7a5bda5766ad5e709c7f 100644 (file)
@@ -141,13 +141,27 @@ public:
     return K;
   }
   
+  /// getKindForGlobal - Classify the specified global variable into a set of
+  /// target independent categories embodied in SectionKind.
+  static SectionKind getKindForGlobal(const GlobalValue *GV,
+                                      const TargetMachine &TM);
+  
   /// SectionForGlobal - This method computes the appropriate section to emit
   /// the specified global variable or function definition.  This should not
   /// be passed external (or available externally) globals.
   const MCSection *SectionForGlobal(const GlobalValue *GV,
-                                    Mangler *Mang,
+                                    SectionKind Kind, Mangler *Mang,
                                     const TargetMachine &TM) const;
   
+  /// SectionForGlobal - This method computes the appropriate section to emit
+  /// the specified global variable or function definition.  This should not
+  /// be passed external (or available externally) globals.
+  const MCSection *SectionForGlobal(const GlobalValue *GV,
+                                    Mangler *Mang,
+                                    const TargetMachine &TM) const {
+    return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
+  }
+  
   /// getSpecialCasedSectionGlobals - Allow the target to completely override
   /// section assignment of a global.
   /// FIXME: ELIMINATE this by making PIC16 implement ADDRESS with
index 7489883998d84c32db595c3a2d7444fd95a6512e..23e549a42b08442140be4b0a328dd8c1fe2e11ec 100644 (file)
@@ -110,13 +110,16 @@ static bool IsNullTerminatedString(const Constant *C) {
   return false;
 }
 
-/// SectionKindForGlobal - This is a top-level target-independent classifier for
+/// getKindForGlobal - This is a top-level target-independent classifier for
 /// a global variable.  Given an global variable and information from TM, it
 /// classifies the global in a variety of ways that make various target
 /// implementations simpler.  The target implementation is free to ignore this
 /// extra info of course.
-static SectionKind SectionKindForGlobal(const GlobalValue *GV,
-                                        const TargetMachine &TM) {
+SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
+                                                       const TargetMachine &TM){
+  assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
+         "Can only be used for global definitions");
+  
   Reloc::Model ReloModel = TM.getRelocationModel();
   
   // Early exit - functions should be always in text sections.
@@ -227,13 +230,8 @@ static SectionKind SectionKindForGlobal(const GlobalValue *GV,
 /// the specified global variable or function definition.  This should not
 /// be passed external (or available externally) globals.
 const MCSection *TargetLoweringObjectFile::
-SectionForGlobal(const GlobalValue *GV, Mangler *Mang,
+SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
                  const TargetMachine &TM) const {
-  assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
-         "Can only be used for global definitions");
-  
-  SectionKind Kind = SectionKindForGlobal(GV, TM);
-  
   // Select section name.
   if (GV->hasSection()) {
     // If the target has special section hacks for specifically named globals,
@@ -254,6 +252,7 @@ SectionForGlobal(const GlobalValue *GV, Mangler *Mang,
   return SelectSectionForGlobal(GV, Kind, Mang, TM);
 }
 
+
 // Lame default implementation. Calculate the section name for global.
 const MCSection *
 TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,