[Sparc] Implement writeNopData. Emit actual NOP instruction instead of just filling...
authorVenkatraman Govindaraju <venkatra@cs.wisc.edu>
Sat, 1 Mar 2014 05:45:09 +0000 (05:45 +0000)
committerVenkatraman Govindaraju <venkatra@cs.wisc.edu>
Sat, 1 Mar 2014 05:45:09 +0000 (05:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202572 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp
test/MC/Sparc/sparc-nop-data.s [new file with mode: 0644]

index 812f4b73bd1d5d9acef24f9d20438b361474aeb5..f6c581654971367ae951042d2af2996682240f43 100644 (file)
@@ -200,9 +200,14 @@ namespace {
     }
 
     bool writeNopData(uint64_t Count, MCObjectWriter *OW) const {
-      // FIXME: Zero fill for now.
-      for (uint64_t i = 0; i != Count; ++i)
-        OW->Write8(0);
+      // Cannot emit NOP with size not multiple of 32 bits.
+      if (Count % 4 != 0)
+        return false;
+
+      uint64_t NumNops = Count / 4;
+      for (uint64_t i = 0; i != NumNops; ++i)
+        OW->Write32(0x01000000);
+
       return true;
     }
 
diff --git a/test/MC/Sparc/sparc-nop-data.s b/test/MC/Sparc/sparc-nop-data.s
new file mode 100644 (file)
index 0000000..1538505
--- /dev/null
@@ -0,0 +1,11 @@
+! RUN: llvm-mc %s -arch=sparc  -filetype=obj | llvm-readobj -s -sd | FileCheck %s
+! RUN: llvm-mc %s -arch=sparcv9  -filetype=obj | llvm-readobj -s -sd | FileCheck %s
+
+! CHECK: 0000: BA1F401D 01000000 01000000 01000000
+! CHECK: 0010: BA1F401D
+
+foo:
+        xor %i5, %i5, %i5
+        .align 16
+        xor %i5, %i5, %i5
+