diff options
| author | Owen Anderson <resistor@mac.com> | 2012-08-29 22:18:56 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2012-08-29 22:18:56 +0000 |
| commit | 9d0f923e7c2956ade5794a0621d8c7f0d7b172de (patch) | |
| tree | 489b92c98897513b2985ac9d80aa1581df664b16 /llvm | |
| parent | b2bef482fd5b4eb5483131688812714a1a894ad7 (diff) | |
| download | bcm5719-llvm-9d0f923e7c2956ade5794a0621d8c7f0d7b172de.tar.gz bcm5719-llvm-9d0f923e7c2956ade5794a0621d8c7f0d7b172de.zip | |
Allow targets to specify a minimum supported NOP size when performing NOP padding. If the desired padding is smaller than the supported NOP size,
we will enlarge the padding to make it work.
llvm-svn: 162870
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/MC/MCAsmBackend.h | 7 | ||||
| -rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h index 43aceba3e14..1c450909b1a 100644 --- a/llvm/include/llvm/MC/MCAsmBackend.h +++ b/llvm/include/llvm/MC/MCAsmBackend.h @@ -133,6 +133,13 @@ public: /// @} + /// getMinimumNopSize - Returns the minimum size of a nop in bytes on this + /// target. The assembler will use this to emit excess padding in situations + /// where the padding required for simple alignment would be less than the + /// minimum nop size. + /// + virtual unsigned getMinimumNopSize() const { return 1; } + /// writeNopData - Write an (optimal) nop sequence of Count bytes to the given /// output. If the target cannot generate such a sequence, it should return an /// error. diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 05519b56ffe..c872bd62c9a 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -325,6 +325,12 @@ uint64_t MCAssembler::computeFragmentSize(const MCAsmLayout &Layout, const MCAlignFragment &AF = cast<MCAlignFragment>(F); unsigned Offset = Layout.getFragmentOffset(&AF); unsigned Size = OffsetToAlignment(Offset, AF.getAlignment()); + // If we are padding with nops, force the padding to be larger than the + // minimum nop size. + if (Size > 0 && AF.hasEmitNops()) { + while (Size % getBackend().getMinimumNopSize()) + Size += AF.getAlignment(); + } if (Size > AF.getMaxBytesToEmit()) return 0; return Size; |

