OSDN Git Service

move emitUsedDirectiveFor to TargetLoweringObjectFile and rename it to
authorChris Lattner <sabre@nondot.org>
Fri, 31 Jul 2009 20:52:39 +0000 (20:52 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 31 Jul 2009 20:52:39 +0000 (20:52 +0000)
indicate that it is a predicate, not an emitter.  This eliminates TAI
dependencies on Mangler and GlobalValue.

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

include/llvm/Target/DarwinTargetAsmInfo.h
include/llvm/Target/TargetAsmInfo.h
include/llvm/Target/TargetLoweringObjectFile.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/DarwinTargetAsmInfo.cpp
lib/Target/TargetLoweringObjectFile.cpp

index c934c05..99e4130 100644 (file)
@@ -25,8 +25,6 @@ namespace llvm {
 
   struct DarwinTargetAsmInfo : public TargetAsmInfo {
     explicit DarwinTargetAsmInfo(const TargetMachine &TM);
-    virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
-                                      Mangler *Mang) const;
   };
 }
 
index 373e556..ad4f431 100644 (file)
@@ -23,8 +23,6 @@
 namespace llvm {
   template <typename T> class SmallVectorImpl;
   class TargetMachine;
-  class GlobalValue;
-  class Mangler;
   
   // DWARF encoding query type
   namespace DwarfEncoding {
@@ -430,14 +428,6 @@ namespace llvm {
     /// length.
     virtual unsigned getInlineAsmLength(const char *Str) const;
 
-    /// emitUsedDirectiveFor - This hook allows targets to selectively decide
-    /// not to emit the UsedDirective for some symbols in llvm.used.
-// FIXME: REMOVE this (rdar://7071300)
-    virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
-                                      Mangler *) const {
-      return (GV!=0);
-    }
-
     /// PreferredEHDataFormat - This hook allows the target to select data
     /// format used for encoding pointers in exception handling data. Reason is
     /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
index feecaac..868b274 100644 (file)
@@ -259,6 +259,13 @@ public:
   const MCSection *getTextSection() const { return TextSection; }
   const MCSection *getDataSection() const { return DataSection; }
   
+  /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
+  /// decide not to emit the UsedDirective for some symbols in llvm.used.
+  /// FIXME: REMOVE this (rdar://7071300)
+  virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
+                                          Mangler *) const {
+    return (GV!=0);
+  }
   
   /// getSectionForMergeableConstant - Given a mergeable constant with the
   /// specified size and relocation information, return a section that it
@@ -368,6 +375,12 @@ public:
   
   virtual const MCSection *
   getSectionForMergeableConstant(SectionKind Kind) const;
+  
+  /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
+  /// decide not to emit the UsedDirective for some symbols in llvm.used.
+  /// FIXME: REMOVE this (rdar://7071300)
+  virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
+                                          Mangler *) const;
 };
 
 
index 178bbaa..077d72e 100644 (file)
@@ -564,7 +564,7 @@ void AsmPrinter::EmitLLVMUsedList(Constant *List) {
   for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
     const GlobalValue *GV =
       dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts());
-    if (GV && TAI->emitUsedDirectiveFor(GV, Mang)) {
+    if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, Mang)) {
       O << Directive;
       EmitConstantValueOnly(InitList->getOperand(i));
       O << '\n';
index aa93c0d..306300e 100644 (file)
@@ -79,23 +79,3 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
   DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
 }
 
-/// emitUsedDirectiveFor - On Darwin, internally linked data beginning with
-/// the PrivateGlobalPrefix or the LinkerPrivateGlobalPrefix does not have the
-/// directive emitted (this occurs in ObjC metadata).
-bool DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
-                                               Mangler *Mang) const {
-  if (!GV) return false;
-  
-  // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix.
-  if (GV->hasLocalLinkage() && !isa<Function>(GV)) {
-    // FIXME: ObjC metadata is currently emitted as internal symbols that have
-    // \1L and \0l prefixes on them.  Fix them to be Private/LinkerPrivate and
-    // this horrible hack can go away.
-    const std::string &Name = Mang->getMangledName(GV);
-    if (Name[0] == 'L' || Name[0] == 'l')
-      return false;
-  }
-
-  return true;
-}
-
index 36fda0b..9ba12bb 100644 (file)
@@ -585,6 +585,29 @@ getSectionForMergeableConstant(SectionKind Kind) const {
   return ReadOnlySection;  // .const
 }
 
+/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively decide
+/// not to emit the UsedDirective for some symbols in llvm.used.
+// FIXME: REMOVE this (rdar://7071300)
+bool TargetLoweringObjectFileMachO::
+shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
+  /// On Darwin, internally linked data beginning with "L" or "l" does not have
+  /// the directive emitted (this occurs in ObjC metadata).
+  if (!GV) return false;
+    
+  // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix.
+  if (GV->hasLocalLinkage() && !isa<Function>(GV)) {
+    // FIXME: ObjC metadata is currently emitted as internal symbols that have
+    // \1L and \0l prefixes on them.  Fix them to be Private/LinkerPrivate and
+    // this horrible hack can go away.
+    const std::string &Name = Mang->getMangledName(GV);
+    if (Name[0] == 'L' || Name[0] == 'l')
+      return false;
+  }
+  
+  return true;
+}
+
+
 //===----------------------------------------------------------------------===//
 //                                  COFF
 //===----------------------------------------------------------------------===//