[llvm-commits] [llvm] r121195 - /llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp

Bill Wendling isanbard at gmail.com
Tue Dec 7 15:05:20 PST 2010


Author: void
Date: Tue Dec  7 17:05:20 2010
New Revision: 121195

URL: http://llvm.org/viewvc/llvm-project?rev=121195&view=rev
Log:
A bit of cleanup: early exit ApplyFixup and cache the Fixup offset. No
functionality change.

Modified:
    llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121195&r1=121194&r2=121195&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue Dec  7 17:05:20 2010
@@ -133,6 +133,7 @@
 }
 
 namespace {
+
 // FIXME: This should be in a separate file.
 // ELF is an ELF of course...
 class ELFARMAsmBackend : public ARMAsmBackend {
@@ -160,24 +161,24 @@
   }
 };
 
-// Fixme: Raise this to share code between Darwin and ELF.
+// FIXME: Raise this to share code between Darwin and ELF.
 void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
                                   unsigned DataSize, uint64_t Value) const {
-  // Fixme: 2 for Thumb
-  unsigned NumBytes = 4;
+  unsigned NumBytes = 4;        // FIXME: 2 for Thumb
+
   Value = adjustFixupValue(Fixup.getKind(), Value);
+  if (!Value) return;           // No need to encode nothing.
 
-  assert((Fixup.getOffset() % NumBytes == 0)
-         && "Offset mod NumBytes is nonzero!");
-  // For each byte of the fragment that the fixup touches, mask in the
-  // bits from the fixup value.
-  // The Value has been "split up" into the appropriate bitfields above.
-  for (unsigned i = 0; i != NumBytes; ++i) {
-    Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8));
-  }
+  unsigned Offset = Fixup.getOffset();
+  assert(Offset % NumBytes == 0 && "Offset mod NumBytes is nonzero!");
+
+  // For each byte of the fragment that the fixup touches, mask in the bits from
+  // the fixup value. The Value has been "split up" into the appropriate
+  // bitfields above.
+  for (unsigned i = 0; i != NumBytes; ++i)
+    Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
 }
 
-namespace {
 // FIXME: This should be in a separate file.
 class DarwinARMAsmBackend : public ARMAsmBackend {
   MCMachOObjectFormat Format;
@@ -205,7 +206,6 @@
     return false;
   }
 };
-} // end anonymous namespace
 
 static unsigned getFixupKindNumBytes(unsigned Kind) {
   switch (Kind) {
@@ -235,6 +235,7 @@
   for (unsigned i = 0; i != NumBytes; ++i)
     Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8));
 }
+
 } // end anonymous namespace
 
 TargetAsmBackend *llvm::createARMAsmBackend(const Target &T,





More information about the llvm-commits mailing list