[PATCH] Allowing MC backends to decide relaxation based on fixup resolution

Colin LeMahieu colinl at codeaurora.org
Thu Apr 30 10:24:04 PDT 2015


I like the new virtual function suggestion, it makes this patch far easier.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8217

Files:
  include/llvm/MC/MCAsmBackend.h
  lib/MC/MCAsmBackend.cpp
  lib/MC/MCAssembler.cpp

Index: include/llvm/MC/MCAsmBackend.h
===================================================================
--- include/llvm/MC/MCAsmBackend.h
+++ include/llvm/MC/MCAsmBackend.h
@@ -97,6 +97,12 @@
 
   /// Target specific predicate for whether a given fixup requires the
   /// associated instruction to be relaxed.
+  virtual bool fixupNeedsRelaxationAdvanced(const MCFixup &Fixup, bool Resolved,
+                                    uint64_t Value,
+                                    const MCRelaxableFragment *DF,
+                                    const MCAsmLayout &Layout) const;
+
+  /// Simple predicate for targets where !Resolved implies requiring relaxation
   virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
                                     const MCRelaxableFragment *DF,
                                     const MCAsmLayout &Layout) const = 0;
Index: lib/MC/MCAsmBackend.cpp
===================================================================
--- lib/MC/MCAsmBackend.cpp
+++ lib/MC/MCAsmBackend.cpp
@@ -40,3 +40,11 @@
   assert((size_t)Kind <= array_lengthof(Builtins) && "Unknown fixup kind");
   return Builtins[Kind];
 }
+
+bool MCAsmBackend::fixupNeedsRelaxationAdvanced(
+    const MCFixup &Fixup, bool Resolved, uint64_t Value,
+    const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const {
+  if (!Resolved)
+    return true;
+  return fixupNeedsRelaxation(Fixup, Value, DF, Layout);
+}
Index: lib/MC/MCAssembler.cpp
===================================================================
--- lib/MC/MCAssembler.cpp
+++ lib/MC/MCAssembler.cpp
@@ -976,10 +976,10 @@
   // If we cannot resolve the fixup value, it requires relaxation.
   MCValue Target;
   uint64_t Value;
-  if (!evaluateFixup(Layout, Fixup, DF, Target, Value))
-    return true;
+  bool Resolved = evaluateFixup(Layout, Fixup, DF, Target, Value);
 
-  return getBackend().fixupNeedsRelaxation(Fixup, Value, DF, Layout);
+  return getBackend().fixupNeedsRelaxationAdvanced(Fixup, Resolved, Value, DF,
+                                                   Layout);
 }
 
 bool MCAssembler::fragmentNeedsRelaxation(const MCRelaxableFragment *F,

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8217.24744.patch
Type: text/x-patch
Size: 2162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150430/49b7c4c3/attachment.bin>


More information about the llvm-commits mailing list