Start of support for binary emit of 16-it Thumb instructions.
authorJim Grosbach <grosbach@apple.com>
Thu, 11 Nov 2010 23:41:09 +0000 (23:41 +0000)
committerJim Grosbach <grosbach@apple.com>
Thu, 11 Nov 2010 23:41:09 +0000 (23:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118859 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMAsmBackend.cpp
lib/Target/ARM/ARMMCCodeEmitter.cpp

index 54cd1aefd4f18e368a31420e3028de0199c2d220..d5a27592da07224b5ac6a9d5879986fd853d1921 100644 (file)
@@ -56,10 +56,14 @@ void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
 }
 
 bool ARMAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
-  if ((Count % 4) != 0) {
-    // Fixme: % 2 for Thumb?
-    return false;
-  }
+//  if ((Count % 4) != 0) {
+//    // Fixme: % 2 for Thumb?
+//    return false;
+//  }
+  // FIXME: Zero fill for now. That's not right, but at least will get the
+  // section size right.
+  for (uint64_t i = 0; i != Count; ++i)
+    OW->Write8(0);
   return true;
 }
 } // end anonymous namespace
index ebd0d9b559976dbf7d931d8ceef63a6ce81ea2b2..96da945f604719c12e1a527f7083b3a187330128 100644 (file)
@@ -608,10 +608,17 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
                   SmallVectorImpl<MCFixup> &Fixups) const {
   // Pseudo instructions don't get encoded.
   const TargetInstrDesc &Desc = TII.get(MI.getOpcode());
-  if ((Desc.TSFlags & ARMII::FormMask) == ARMII::Pseudo)
+  uint64_t TSFlags = Desc.TSFlags;
+  if ((TSFlags & ARMII::FormMask) == ARMII::Pseudo)
     return;
-
-  EmitConstant(getBinaryCodeForInstr(MI, Fixups), 4, OS);
+  int Size;
+  // Basic size info comes from the TSFlags field.
+  switch ((TSFlags & ARMII::SizeMask) >> ARMII::SizeShift) {
+  default: llvm_unreachable("Unexpected instruction size!");
+  case ARMII::Size2Bytes: Size = 2; break;
+  case ARMII::Size4Bytes: Size = 4; break;
+  }
+  EmitConstant(getBinaryCodeForInstr(MI, Fixups), Size, OS);
   ++MCNumEmitted;  // Keep track of the # of mi's emitted.
 }