Delete MCSubtargetInfo data members from target MCCodeEmitter classes
[oota-llvm.git] / lib / Target / PowerPC / MCTargetDesc / PPCMachObjectWriter.cpp
index aea3c5b2099601cfdf90d3090669a41bd01e6cf0..bbafe2e789559af115baf57c9730259f14b1d5a0 100644 (file)
@@ -162,16 +162,15 @@ static void makeRelocationInfo(MachO::any_relocation_info &MRE,
 }
 
 static void
-makeScatteredRelocationInfo(MachO::scattered_relocation_info &MRE,
+makeScatteredRelocationInfo(MachO::any_relocation_info &MRE,
                             const uint32_t Addr, const unsigned Type,
                             const unsigned Log2Size, const unsigned IsPCRel,
                             const uint32_t Value2) {
-  MRE.r_scattered = true;
-  MRE.r_pcrel = IsPCRel;
-  MRE.r_length = Log2Size;
-  MRE.r_type = Type;
-  MRE.r_address = Addr;
-  MRE.r_value = Value2;
+  // For notes on bitfield positions and endianness, see:
+  // https://developer.apple.com/library/mac/documentation/developertools/conceptual/MachORuntime/Reference/reference.html#//apple_ref/doc/uid/20001298-scattered_relocation_entry
+  MRE.r_word0 = ((Addr << 0) | (Type << 24) | (Log2Size << 28) |
+                 (IsPCRel << 30) | MachO::R_SCATTERED);
+  MRE.r_word1 = Value2;
 }
 
 /// Compute fixup offset (address).
@@ -280,7 +279,7 @@ bool PPCMachObjectWriter::RecordScatteredRelocation(
       break;
     }
 
-    MachO::scattered_relocation_info MRE;
+    MachO::any_relocation_info MRE;
     makeScatteredRelocationInfo(MRE, other_half, MachO::GENERIC_RELOC_PAIR,
                                 Log2Size, IsPCRel, Value2);
     Writer->addRelocation(Fragment->getParent(), MRE);
@@ -295,7 +294,7 @@ bool PPCMachObjectWriter::RecordScatteredRelocation(
     if (FixupOffset > 0xffffff)
       return false;
   }
-  MachO::scattered_relocation_info MRE;
+  MachO::any_relocation_info MRE;
   makeScatteredRelocationInfo(MRE, FixupOffset, Type, Log2Size, IsPCRel, Value);
   Writer->addRelocation(Fragment->getParent(), MRE);
   return true;
@@ -374,6 +373,7 @@ void PPCMachObjectWriter::RecordPPCRelocation(
       FixedValue -= Writer->getSectionAddress(Fragment->getParent());
   }
 
+  // struct relocation_info (8 bytes)
   MachO::any_relocation_info MRE;
   makeRelocationInfo(MRE, FixupOffset, Index, IsPCRel, Log2Size, IsExtern,
                      Type);