[llvm-commits] [llvm] r96091 - /llvm/trunk/lib/MC/MCMachOStreamer.cpp

Daniel Dunbar daniel at zuster.org
Sat Feb 13 01:28:22 PST 2010


Author: ddunbar
Date: Sat Feb 13 03:28:22 2010
New Revision: 96091

URL: http://llvm.org/viewvc/llvm-project?rev=96091&view=rev
Log:
MC/Mach-O: Implement EmitValue using data fragments + fixups instead of fill fragment.

Modified:
    llvm/trunk/lib/MC/MCMachOStreamer.cpp

Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=96091&r1=96090&r2=96091&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sat Feb 13 03:28:22 2010
@@ -333,7 +333,23 @@
 
 void MCMachOStreamer::EmitValue(const MCExpr *Value, unsigned Size,
                                 unsigned AddrSpace) {
-  new MCFillFragment(*AddValueSymbols(Value), Size, 1, CurSectionData);
+  // Assume the front-end will have evaluate things absolute expressions, so
+  // just create data + fixup.
+  MCDataFragment *DF = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
+  if (!DF)
+    DF = new MCDataFragment(CurSectionData);
+
+  // Avoid fixups when possible.
+  int64_t AbsValue;
+  if (Value->EvaluateAsAbsolute(AbsValue)) {
+    // FIXME: Endianness assumption.
+    for (unsigned i = 0; i != Size; ++i)
+      DF->getContents().push_back(uint8_t(AbsValue >> (i * 8)));
+  } else {
+    DF->getFixups().push_back(MCAsmFixup(DF->getContents().size(),
+                                         *AddValueSymbols(Value), Size));
+    DF->getContents().resize(DF->getContents().size() + Size, 0);
+  }
 }
 
 void MCMachOStreamer::EmitValueToAlignment(unsigned ByteAlignment,





More information about the llvm-commits mailing list