From 9242ded302211858672c84b1cf3a2a1572d76ebc Mon Sep 17 00:00:00 2001 From: Venkatraman Govindaraju Date: Sat, 1 Mar 2014 05:45:09 +0000 Subject: [PATCH] [Sparc] Implement writeNopData. Emit actual NOP instruction instead of just filling with zeroes. llvm-svn: 202572 --- lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp | 11 ++++++++--- test/MC/Sparc/sparc-nop-data.s | 11 +++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 test/MC/Sparc/sparc-nop-data.s diff --git a/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp b/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp index 812f4b73bd1..f6c58165497 100644 --- a/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp +++ b/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp @@ -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 index 00000000000..1538505af73 --- /dev/null +++ b/test/MC/Sparc/sparc-nop-data.s @@ -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 +