[llvm-commits] [llvm] r98789 - in /llvm/trunk: include/llvm/Target/TargetAsmBackend.h lib/MC/TargetAsmBackend.cpp lib/Target/X86/X86AsmBackend.cpp

Daniel Dunbar daniel at zuster.org
Wed Mar 17 17:58:53 PDT 2010


Author: ddunbar
Date: Wed Mar 17 19:58:53 2010
New Revision: 98789

URL: http://llvm.org/viewvc/llvm-project?rev=98789&view=rev
Log:
MC/Darwin: Add a new target hook for whether the target uses "reliable" symbol differences, basically whether the assembler should attempt to understand atoms when using scattered symbols.

Also, avoid some virtual call overhead.

Modified:
    llvm/trunk/include/llvm/Target/TargetAsmBackend.h
    llvm/trunk/lib/MC/TargetAsmBackend.cpp
    llvm/trunk/lib/Target/X86/X86AsmBackend.cpp

Modified: llvm/trunk/include/llvm/Target/TargetAsmBackend.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmBackend.h?rev=98789&r1=98788&r2=98789&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmBackend.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmBackend.h Wed Mar 17 19:58:53 2010
@@ -24,6 +24,10 @@
   /// TheTarget - The Target that this machine was created for.
   const Target &TheTarget;
 
+  unsigned HasAbsolutizedSet : 1;
+  unsigned HasReliableSymbolDifference : 1;
+  unsigned HasScatteredSymbols : 1;
+
 public:
   virtual ~TargetAsmBackend();
 
@@ -40,7 +44,21 @@
   /// value of L0 - L1. This distinction is only relevant for platforms that
   /// support scattered symbols, since in the absence of scattered symbols (a -
   /// b) cannot change after assembly.
-  virtual bool hasAbsolutizedSet() const { return false; }
+  bool hasAbsolutizedSet() const { return HasAbsolutizedSet; }
+
+  /// hasReliableSymbolDifference - Check whether this target implements
+  /// accurate relocations for differences between symbols. If not, differences
+  /// between symbols will always be relocatable expressions and any references
+  /// to temporary symbols will be assumed to be in the same atom, unless they
+  /// reside in a different section.
+  ///
+  /// This should always be true (since it results in fewer relocations with no
+  /// loss of functionality), but is currently supported as a way to maintain
+  /// exact object compatibility with Darwin 'as' (on non-x86_64). It should
+  /// eventually should be eliminated. See also \see hasAbsolutizedSet.
+  bool hasReliableSymbolDifference() const {
+    return HasReliableSymbolDifference;
+  }
 
   /// hasScatteredSymbols - Check whether this target supports scattered
   /// symbols. If so, the assembler should assume that atoms can be scattered by
@@ -50,7 +68,7 @@
   ///
   /// Note that the assembler currently does not reason about atoms, instead it
   /// assumes all temporary symbols reside in the "current atom".
-  virtual bool hasScatteredSymbols() const { return false; }
+  bool hasScatteredSymbols() const { return HasScatteredSymbols; }
 
   /// doesSectionRequireSymbols - Check whether the given section requires that
   /// all symbols (even temporaries) have symbol table entries.

Modified: llvm/trunk/lib/MC/TargetAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/TargetAsmBackend.cpp?rev=98789&r1=98788&r2=98789&view=diff
==============================================================================
--- llvm/trunk/lib/MC/TargetAsmBackend.cpp (original)
+++ llvm/trunk/lib/MC/TargetAsmBackend.cpp Wed Mar 17 19:58:53 2010
@@ -11,7 +11,10 @@
 using namespace llvm;
 
 TargetAsmBackend::TargetAsmBackend(const Target &T)
-  : TheTarget(T)
+  : TheTarget(T),
+    HasAbsolutizedSet(false),
+    HasReliableSymbolDifference(false),
+    HasScatteredSymbols(false)
 {
 }
 

Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=98789&r1=98788&r2=98789&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Wed Mar 17 19:58:53 2010
@@ -25,11 +25,10 @@
 class DarwinX86AsmBackend : public X86AsmBackend {
 public:
   DarwinX86AsmBackend(const Target &T)
-    : X86AsmBackend(T) {}
-
-  virtual bool hasAbsolutizedSet() const { return true; }
-
-  virtual bool hasScatteredSymbols() const { return true; }
+    : X86AsmBackend(T) {
+    HasAbsolutizedSet = true;
+    HasScatteredSymbols = true;
+  }
 };
 
 class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {
@@ -41,7 +40,9 @@
 class DarwinX86_64AsmBackend : public DarwinX86AsmBackend {
 public:
   DarwinX86_64AsmBackend(const Target &T)
-    : DarwinX86AsmBackend(T) {}
+    : DarwinX86AsmBackend(T) {
+    HasReliableSymbolDifference = true;
+  }
 
   virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
     // Temporary labels in the string literals sections require symbols. The





More information about the llvm-commits mailing list