[llvm] r185662 - [PowerPC] Implement writeNopData
Ulrich Weigand
ulrich.weigand at de.ibm.com
Thu Jul 4 11:28:46 PDT 2013
Author: uweigand
Date: Thu Jul 4 13:28:46 2013
New Revision: 185662
URL: http://llvm.org/viewvc/llvm-project?rev=185662&view=rev
Log:
[PowerPC] Implement writeNopData
This implements a proper PPCAsmBackend::writeNopData routine
that actually writes PowerPC nop instructions.
This fixes the last remaining difference in object file output
(text section) between the integrated assembler and GNU as
that I've seen anywhere.
Added:
llvm/trunk/test/MC/PowerPC/ppc-nop.s
Modified:
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp?rev=185662&r1=185661&r2=185662&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp Thu Jul 4 13:28:46 2013
@@ -148,10 +148,14 @@ public:
}
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const {
- // 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);
+ // Can't 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(0x60000000);
+
return true;
}
Added: llvm/trunk/test/MC/PowerPC/ppc-nop.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/ppc-nop.s?rev=185662&view=auto
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc-nop.s (added)
+++ llvm/trunk/test/MC/PowerPC/ppc-nop.s Thu Jul 4 13:28:46 2013
@@ -0,0 +1,9 @@
+# RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-linux-gnu %s | llvm-readobj -s -sd - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux-gnu %s | llvm-readobj -s -sd - | FileCheck %s
+
+blr
+.p2align 3
+blr
+
+# CHECK: 0000: 4E800020 60000000 4E800020
+
More information about the llvm-commits
mailing list