[llvm] r202572 - [Sparc] Implement writeNopData. Emit actual NOP instruction instead of just filling with zeroes.
Venkatraman Govindaraju
venkatra at cs.wisc.edu
Fri Feb 28 21:45:09 PST 2014
Author: venkatra
Date: Fri Feb 28 23:45:09 2014
New Revision: 202572
URL: http://llvm.org/viewvc/llvm-project?rev=202572&view=rev
Log:
[Sparc] Implement writeNopData. Emit actual NOP instruction instead of just filling with zeroes.
Added:
llvm/trunk/test/MC/Sparc/sparc-nop-data.s
Modified:
llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp
Modified: llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp?rev=202572&r1=202571&r2=202572&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp Fri Feb 28 23:45:09 2014
@@ -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;
}
Added: llvm/trunk/test/MC/Sparc/sparc-nop-data.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Sparc/sparc-nop-data.s?rev=202572&view=auto
==============================================================================
--- llvm/trunk/test/MC/Sparc/sparc-nop-data.s (added)
+++ llvm/trunk/test/MC/Sparc/sparc-nop-data.s Fri Feb 28 23:45:09 2014
@@ -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
+
More information about the llvm-commits
mailing list