|
13 | 13 | #include "llvm/ADT/StringSwitch.h"
|
14 | 14 | #include "llvm/BinaryFormat/ELF.h"
|
15 | 15 | #include "llvm/MC/MCAsmBackend.h"
|
| 16 | +#include "llvm/MC/MCAsmInfo.h" |
16 | 17 | #include "llvm/MC/MCAssembler.h"
|
17 | 18 | #include "llvm/MC/MCContext.h"
|
18 | 19 | #include "llvm/MC/MCObjectWriter.h"
|
@@ -194,18 +195,21 @@ unsigned AMDGPUAsmBackend::getMinimumNopSize() const {
|
194 | 195 |
|
195 | 196 | bool AMDGPUAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
|
196 | 197 | const MCSubtargetInfo *STI) const {
|
197 |
| - // If the count is not 4-byte aligned, we must be writing data into the text |
198 |
| - // section (otherwise we have unaligned instructions, and thus have far |
199 |
| - // bigger problems), so just write zeros instead. |
200 |
| - OS.write_zeros(Count % 4); |
| 198 | + // If the count is not aligned to the minimum instruction alignment, we must |
| 199 | + // be writing data into the text section (otherwise we have unaligned |
| 200 | + // instructions, and thus have far bigger problems), so just write zeros |
| 201 | + // instead. |
| 202 | + unsigned MinInstAlignment = getContext().getAsmInfo()->getMinInstAlignment(); |
| 203 | + OS.write_zeros(Count % MinInstAlignment); |
201 | 204 |
|
202 | 205 | // We are properly aligned, so write NOPs as requested.
|
203 |
| - Count /= 4; |
| 206 | + Count /= MinInstAlignment; |
204 | 207 |
|
205 | 208 | // FIXME: R600 support.
|
206 | 209 | // s_nop 0
|
207 | 210 | const uint32_t Encoded_S_NOP_0 = 0xbf800000;
|
208 | 211 |
|
| 212 | + assert(MinInstAlignment == sizeof(Encoded_S_NOP_0)); |
209 | 213 | for (uint64_t I = 0; I != Count; ++I)
|
210 | 214 | support::endian::write<uint32_t>(OS, Encoded_S_NOP_0, Endian);
|
211 | 215 |
|
|
0 commit comments