aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLU-JOHN <John.Lu@amd.com>2025-07-09 13:24:33 -0500
committerGitHub <noreply@github.com>2025-07-09 14:24:33 -0400
commit85cc4afdefee251b38d711f3922eac6fba84d5f8 (patch)
treeb1c53985e4ddb1c3d0e3cf3aa4ccb3d5678d76b2
parentbdc0119e1b6001be813a540134bd1772b4d9c4dc (diff)
downloadllvm-85cc4afdefee251b38d711f3922eac6fba84d5f8.zip
llvm-85cc4afdefee251b38d711f3922eac6fba84d5f8.tar.gz
llvm-85cc4afdefee251b38d711f3922eac6fba84d5f8.tar.bz2
[NFC][AMDGPU] Do not hardcode minimum instruction alignment (#147785)
Use symbolic value for minimum instruction alignment. Signed-off-by: John Lu <John.Lu@amd.com>
-rw-r--r--llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
index 8f89168..e7d0e18 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/MC/MCAsmBackend.h"
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectWriter.h"
@@ -194,18 +195,21 @@ unsigned AMDGPUAsmBackend::getMinimumNopSize() const {
bool AMDGPUAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
const MCSubtargetInfo *STI) const {
- // If the count is not 4-byte aligned, we must be writing data into the text
- // section (otherwise we have unaligned instructions, and thus have far
- // bigger problems), so just write zeros instead.
- OS.write_zeros(Count % 4);
+ // If the count is not aligned to the minimum instruction alignment, we must
+ // be writing data into the text section (otherwise we have unaligned
+ // instructions, and thus have far bigger problems), so just write zeros
+ // instead.
+ unsigned MinInstAlignment = getContext().getAsmInfo()->getMinInstAlignment();
+ OS.write_zeros(Count % MinInstAlignment);
// We are properly aligned, so write NOPs as requested.
- Count /= 4;
+ Count /= MinInstAlignment;
// FIXME: R600 support.
// s_nop 0
const uint32_t Encoded_S_NOP_0 = 0xbf800000;
+ assert(MinInstAlignment == sizeof(Encoded_S_NOP_0));
for (uint64_t I = 0; I != Count; ++I)
support::endian::write<uint32_t>(OS, Encoded_S_NOP_0, Endian);