mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-28 08:16:05 +00:00
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
This commit is contained in:
parent
635dcaf513
commit
42ebf056b8
@ -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
|
/// 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
|
/// output. If the target cannot generate such a sequence, it should return an
|
||||||
/// error.
|
/// error.
|
||||||
|
@ -325,6 +325,12 @@ uint64_t MCAssembler::computeFragmentSize(const MCAsmLayout &Layout,
|
|||||||
const MCAlignFragment &AF = cast<MCAlignFragment>(F);
|
const MCAlignFragment &AF = cast<MCAlignFragment>(F);
|
||||||
unsigned Offset = Layout.getFragmentOffset(&AF);
|
unsigned Offset = Layout.getFragmentOffset(&AF);
|
||||||
unsigned Size = OffsetToAlignment(Offset, AF.getAlignment());
|
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())
|
if (Size > AF.getMaxBytesToEmit())
|
||||||
return 0;
|
return 0;
|
||||||
return Size;
|
return Size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user